Tudor Barbu's blog

Ramblings about software development

While developing mooooody.com at Yahoo’s hackathon, I stumbled on a small problem: parsing Yahoo Weather’s results in PHP with simple_xml. The problem arose from Yahoo’s use of the yweather: namespace. By default, SimpleXML cannot parse tags like yweather:astronomy.

Being somewhat intellectually impaired by prolonged sleep depravation – I thought to just search the web for a solution and not come up with one myself. It was a hackathon, the point was to hack the app together fast, not write state of the art code. So, after a bit of googling around, I landed on this spanish blog. The guy’s idea was to just do a str_replace to remove all the yweather: bits and then parse it as regular XML. After a short talk with the team, we decided that we’re not *that* tired and we looked for a better solution.

Which came shortly after in the form of registering the proper namespace with the SimpleXML object. Check it out:

$response = file_get_contents('http://weather.yahooapis.com/forecastrss?w=868274&u=c');
$xml = new SimpleXMLElement($response);

$xml->registerXPathNamespace(
    'yweather',
    'http://xml.weather.yahoo.com/ns/rss/1.0'
);

$astronomy  = $xml->xpath('//yweather:astronomy');
$attributes = $astronomy[0]->attributes();
$sunrise    = (string) $attributes['sunrise'];
$sunset     = (string) $attributes['sunset'];

printf('In Bucharest, the sun rises at %s and sets at %s',
       $sunrise, $sunset);

Needless to say, it worked. Enjoy Mooooody.

16 May

Open Hack EU

Some asshole flying a plane in front of my house at 7 in the morning just woke me up, interrupting my well deserved rest after Yahoo’s 24 hours hackathon. But this post is not about Cessnas spraying chemicals, it’s about one of the best programer oriented events I ever attended. Thank you Yahoo! for making it possible.

I teamed up with my colleague from Vendo Adolfo Abegg and Alex Brausewetter, a former colleague that decided to start his own company called Helpdesk, aimed at delivering the best customer support and ticketing software on the market. Some friendly SEO can’t hurt, right ;) ?

The hacking event was great, a lot of cool hacks, both software and hardware. Yahoo’s Pipes service was hacked by members of the Romanian Security Team on the stage, while Yahoo’s CTO was watching – awkward. It seems that they got pulled into a “private chat” by Yahoo!’s officials shortly after. Read the whole story here.

Another hack that got my attention was evA-Ziune – a site where you can report small fraud, like not getting receipts, using Foursquare’s API. This will quickly overload their servers :) !

The hardware hacks were also impressive, especially the one called Yahoo! Farm, a table size farm which can tell you how many friends you have online on YMessenger using robotic sheep. Pretty nifty! It won the Hacker’s choice prize! Anyway, all the projects are available here and the winners here. Take a look! There are a lot of cool projects out there!

Our project was mooooody.com, a site which detects your location, queries Yahoo! Weather for that location and plays music accordingly. Although it has no market value – or any other value what so ever – we had fun building it and we got a lot of positive feedback from other attendees. We mashed up a lot of clever hacks and technologies but a project that doesn’t address a real problem and is built around illegally playing copyrighted music from Youtube – a service belonging to Yahoo!’s arch-rival Google – couldn’t possibly impress the jury so we didn’t win anything. Nevertheless, we’re proud of it!

Congratulations to the winners, congratulations to Yahoo! for organizing such an event and congratulations to all attendees for creating such a cool atmosphere.

14 Mar

Yahoo! hackathon

Posted by Tudor. Tags:

I’ll be attending Yahoo! hackathon in Bucharest! If you want to find out more about it read this article and register here.
Good luck :P

24 Jun

Pidgin, Ubuntu and Yahoo! Messenger

Posted by Tudor. Tags: , , ,

Pidgin Starting yesterday, my Pidgin stopped connecting to Yahoo!’s messenger service (MSN kept working). Being lazy, I’ve just changed the scs.msg.yahoo.com host to 66.163.181.166 in the user profile panel – the first solution I’ve came across on Google – and it started working again. For another day or so.

But today, it stopped working again and I couldn’t get it working again. So I’ve used Meebo to go online and ask others if their YM! clients worked, if they’ve also encountered this problem, and, most important, what did they do to fix it. And – thanks to Radu – I’ve found out the root of this problem: Yahoo! changed the specifications of its im protocol. Fortunately, the Pidgin guys don’t waste time and the problem can be solved by upgrading to Pidgin 2.5.7.

Details here and here.

27 Jan

Google Maps vs Yahoo Maps

Posted by Tudor. Tags: , , ,

Today I had to choose between Google’s and Yahoo’s Maps APIs. As I’m quite a Google fan, I first checked out its maps API. Very disappointing. It seems that the API was designed by some marketing guy or a janitor. I know, tough accusation. And I haven’t even code one page with Google’s API. What makes me say that? Well, it all ended when I started reading their Terms and Conditions. It seems that all Google Maps API key are domain dependent (only work for a specified domain). And this sucks.

There are 4 traditional stages in software development: development, integration, staging and production. Usually, all these stages take place of different machines that have different domains and/or subdomains. This means that you need a Google API key for each stage. It means that you’ll need at least 3 different API keys just to get to the part where you’re testing the application. But if the developers use different virtual hosts for the project, the number of required APIs increase exponentially. I know that API keys are free, but time isn’t and it’s quite annoying to have to register for a new API key everytime you set up a demo version of the project on a new subdomain.

With Yahoo on the other hand, you only need one API key. And it works. A word of advice: if you need a map API, go with Yahoo! I did…