• You are currently browsing the Christian Heilmann blog archives for December, 2008.

  • Archive for December, 2008

    Small change in the flickr API output breaking my bad code

    Wednesday, December 31st, 2008

    During my absence I got an email that the first version of my unobtrusive Flickr badge has stopped working. The reason was that Flickr changed the output of the API. I the old version the JSON object contained an HTML description that was run through htmlspecialchars() first. I always considered this a bit of a nuisance and wondered about the reason. Now the Flickr feed does not have the encoding any longer as you can see for example in the JSON output of my latest photos:

    
    {
    "title": "Terminal 5 animated discs thingamabob *",
    "link": "http://www.flickr.com/photos/codepo8/3141566868/",
    "media": {<a href=""http://farm4.static.flickr.com/3104/3141566868_a9cd09a54d_m.jpg" title="">m</a>"},
    "date_taken": "2008-12-27T08:10:35-08:00",
    "description": "<p><a href="http://www.flickr.com/people/codepo8/">codepo8</a> posted a video:</p> <p><a href="http://www.flickr.com/photos/codepo8/3141566868/" title="Terminal 5 animated discs thingamabob *"><img src="http://farm4.static.flickr.com/3104/3141566868_a9cd09a54d_m.jpg" width="240" height="180" alt="Terminal 5 animated discs thingamabob *" /></a></p> <p>* technical term, really</p>",
    "published": "2008-12-27T16:10:35Z",
    "author": "nobody@flickr.com (codepo8)",
    "author_id": "11414938@N00",
    "tags": "london art heathrow awesome animation t5 ba britishairways terminal5"
    },
    

    Before the change this would have been:

    
    {
    "title": "Terminal 5 animated discs thingamabob *",
    "link": "http://www.flickr.com/photos/codepo8/3141566868/",
    "media": {<a href=""http://farm4.static.flickr.com/3104/3141566868_a9cd09a54d_m.jpg" title="">m</a>"},
    "date_taken": "2008-12-27T08:10:35-08:00",
    "description": "<p><a href="http://www.flickr.com/people/codepo8/">codepo8</a> posted a video:</p> <p><a href="http://www.flickr.com/photos/codepo8/3141566868/" title="Terminal 5 animated discs thingamabob *"><img src="http://farm4.static.flickr.com/3104/3141566868_a9cd09a54d_m.jpg" width="240" height="180" alt="Terminal 5 animated discs thingamabob *" /></a></p> <p>* technical term, really</p>",
    "published": "2008-12-27T16:10:35Z",
    "author": "nobody@flickr.com (codepo8)",
    "author_id": "11414938@N00",
    "tags": "london art heathrow awesome animation t5 ba britishairways terminal5"
    },
    

    This broke my code as I was relying on regular expressions to get the photos. Taught me a lesson, and as we have a media property now there is no need for this any longer. The fix for the badge code was:

    
    // buggy, bad
    temp=obj.items[i].description.match(/src="([^&]*)"/)[1];"
    // works :)
    temp=obj.items[i].media.m;
    

    Lesson learned: Don’t trust regular expressions and data scraping.

    Thanks to Jennifer Forman Orth for flagging this up!

    TTMMHTM: Back online, news draught, monkeys, squirrels

    Wednesday, December 31st, 2008

    Things that made me happy this morning:

    Squirrels with coffee - OMG!

    Time to go to the gym to work on those lazy bones.

    So what will I try to do in 2009?

    Monday, December 29th, 2008

    (Normally I tend not to write any personal posts here, but hey, why not?)
    It is the end of the year and time for new year’s resolutions. Luckily I had a great year and did most of the things I planned to do (the classics like losing weight, cleaning up the flat, changing my work and so on) worked out swimmingly. I gave a lot of talks, trained a lot of people, re-invented my job and organized my own event. All in all I am very happy about all that.

    So then, for the coming year I’ve just written an article for Digital Web that will be released in the new year that covers a lot of my thoughts on what I want to do. Generally I am seeing harsh times ahead – people are spooked out by the financial recession and the short time fixes (yes, layoffs). This means to me that I am planning to do a few things differently to give myself space to work with colleagues and contacts to get through this.

    My laundry list for the year:

    • be more moderate – I can get very cross about things that in the big picture are not of that much importance (this has improved constantly over the last few years though)
    • concentrate my work on markets and environments I hadn’t covered much this year – specifically universities as environments and South East Asia as markets (I am already scheduled for 3 university hack days in the US and India and plan to find more Hong Kong/China/Signapore/Australia/Taiwan/Korea assignments)
    • finish my work for the Opera Web Standard Curriculum (sorry Chris, I have delayed a lot)
    • write (or at least start) another book – this time for O’Reilly
    • look closer at my finances (I am terrible at that)
    • turn my flat into more of a home than a place to change suitcases
    • take Scripting Enabled more on the road. Somehow the “go forth and do it” doesn’t work that well…
    • clean out icant.co.uk ;)

    Let’s see how I will succeed.

    Merry Christmas all of you!

    Wednesday, December 24th, 2008

    I am currently in the German countryside to see my family and old school friends. My brother’s internet connection is actually trained weasels carrying the things I type on 5.1/4” floppy disk to the next internet hub and I need to write everything in their beautiful but hard language.

    Therefore I am not answering emails, will only twitter from Blackberry and generally try out this offline “life” thing for a few days.

    Merry Christmas ya’ll!

    cheers
    Chris

    TTMMHTM – Paris Web Videos, Project:Possibility, Mozilla Labs evening, Fish Sandwiches

    Saturday, December 20th, 2008

    Things that made me happy this morning (evening, afternoon? what do I know, jetlagged and confused):