2013.05.19

Twitter API confusion


0 comments

In the process of achieving twitter favourite bankruptcy I came across an odd anomaly. The API insists I use American spelling of 'favorite':

Yet when doing a traversal on some returned JSON from I found nothing that matched the word 'favourite'. So by manually going through the JSON I came across the following key, spelled the British way:

'programming'

2012.11.12

Instagram prints


0 comments

I've been enjoying Instagram for a while (my screenname is lewiswalsh79). As with all digital photography though I'm a great advocate of printing pictures. I looked around at a few services and while the quality looked great the price seemed a little high for what are low-quality square pictures.

So I created a Photoshop action to load in my square images, resize them to 4in by 4in at 300 dpi (1200x1200px) then enlarge the canvas to 6"x4" (1800x1200px) using 50% grey as the background. A quick trip to a shop and I had 100 6x4 at 10p each.

Thirty minutes with a roto-trimmer...

And I have 100 instagram prints. Now I've just got to figure out what to do with them. Collage them and stick them on the wall, put them in an album, or something completely different.

'photography'

2012.07.29

Is John Gruber cool?


0 comments

Myopic Apple Fan-boy John Gruber recently wrote this about the new Apple Genius advertisements:

Reaction on Twitter seems overwhelmingly negative, but I’m not so sure. These spots don’t appeal to me, personally. They’re not cool. But they’re not supposed to be cool, and they’re not targeted at existing Mac users. This is about assuaging the doubts of would-be switchers. If you switch to Mac, we’ll help you. That’s the message.

Of course everyone knows existing Mac users are already cool. And those uncool Windows and Unix/Linux users really want to be cool.

'software'

2012.07.17

Twitter Favourite Bankruptcy or How I Lost 1365 tweets


0 comments

I use the favourites feature of Twitter as a bookmarking service. Every few days I go through some and unfavourite as I deal with each one. Unfortunately I favourite far more than I am able to deal with later so the count has recently grown to 1365 favourites, with some dating back up to three years! So I've decided it is time to declare bankruptcy.

I figured that partly what was slowing me down is that Twitter does not provide any way to sort or filter the favourites. Nor does it provide a way to bulk manage or export the favourites. So I turned to the API. Turns out Twitter has a nice, easy way to get favourites and return them as JSON:

https://api.twitter.com/1/favorites.json?screen_name=yourname

But this only returned the most recent favourites. Further digging showed that a count parameter can be added:

https://api.twitter.com/1/favorites.json?screen_name=yourname&count=1365

But Twitter only wants to send back approximately 200 at a time, though it does allow for pagination. So 1365 divided by 200 is six and a bit, so I need seven pages. I tried doing this with cURL and a loop but something wasn't working so did it manually and stored the output in seven files:

https://api.twitter.com/1/favorites.json?count=199&screen_name=lewiswalsh&page=2

Now all I needed to do was load the files as JSON, decode them to a data structure and drop them in to a CSV and a database. Each favourite returned has a LOT of information with it, but all I needed was the tweet itself, the date and the author.

Since most of my favourites are links to things I want to view or read later it was a simple matter to create a fourth field in my database called 'tag' and using LIKE '%http://%' in an UPDATE query I was able to tag over 1100 of my favourites with a tag 'link'. Since Twitter uses URL-shortening I reasoned searching for '%https://%' would be fruitless. The little one hundred remaining un-tagged I went through manually and tagged with various tags such as 'tip' and 'quote'.

Now all my old favourites and searchable, sortable and easily displayed in any way I see it. I thought it might also be useful to see who I favourite a lot of.

Now all I need to do is figure out a fast way to delete 1365 favourites from Twitter itself!

'arpanet'

2012.06.20

Conditional statement mid echo


0 comments

Astonishingly I've only just discovered this. In PHP there is a way to put a conditional statement in the middle of an echo statement using the ternary operators. I've been using ternary for a long time but it never occurred to me that I could I use it like this:

    $temp = 3;
    echo '<p>The weather today is '. ($temp > 18 ? 'hot' : 'cold') .'.</p>';

'programming'