13:57:08 PDT - Sunday, August 19, 2012 in
Technology
While application compatibility has been better in OSX 10.8 than in previous versions (I haven’t had a major use-every-day application fail), one of my most-used widgets, TV Forecast (displays a list of TV shows and their next episode to air by querying TV Rage’s API) has stopped working. Their twitter has generally just been “It’ll be fixed”, emails have gone unanswered.
Nearly missing the start of season two of Boss (Starz network, it’s pretty good if a little silly), has prompted me to write my own replacement. Struggling to do the job with Bash scripting, I’ve instead moved to php (which is far, far, far easier to use).
The code’s a little too long to show and explain here (154 lines), but essentially it reads from a file (required argument, -f file, should be a list of the shows you want to query) and subsequently prints the name of the show, the next episode (in s00e00 format) with day of the week and date, and amount of time (in days/hours) till air – the format of this is customisable at the end of the script.
The file to pass in consists of lower-case names of shows, without spaces and with preceding “the”s removed. Check to see if the show is covered by the TV Rage API (or debug shows that don’t work) by checking http://services.tvrage.com/tools/quickinfo.php?show=[showname]. The TVForecast preferences file (if it hasn’t been wiped by the widget) is at ~/Library/Preferences/widget-com.mattcomi.widget.tvforecast.plist, if you want copy all your shows over.
Two optional arguments, -n [number of shows to display] and -s [index to start printing from], were generally designed in case there’s a need for multiple columns from different runnings of the script.
My use case at the moment is as a script run from Geektool, displaying on the desktop. It should run from the command line (“php tv.php -f tv.txt”) without messing in OS X (presumably other systems with a php install too).
Caveats:
The script manually indexes into the returned TVRage API info, instead of searching for the required line.
The structure is quite messy, as I wasn’t quite sure what I was doing, so didn’t plan out the functions in advance.
It doesn’t display shows with a general start date (eg “Jan 2013”).
It’s reasonably likely it will break in the future, but I’ll notice and fix it if it does.
First time I’ve ever written something in php, so there’s probably some massive faux pas.
(rename to .php to run)
Download
August 19th, 2012 in
Technology
00:08:30 PDT - Monday, May 9, 2011 in
Technology
5/5
So, after getting a Kindle feckin’ ages ago, and Sully having posted his long-term impressions of it recently, I decided it was time for me to do the same. On the whole, it’s the job.
The Good
—————–
3G
Lifesaver this. Free international 3G, so you’re always in touch, even when in the middle of nowhere. The browser’s rough but passable, easy to pick up mail and RSS.
Choice
No longer do I have to decide what to bring home for a weekend, or even decide what I want to read off the bookshelf. Grab the Kindle, read some Instapaper for ten minutes. Bored of that? I think I’ll read about Iraq. Bored of that? I think I’ll read about Zombies.
Dictionary
Don’t use it too often (probably two-three times per book), but it’s very useful to have. It’s one of those things you miss in Real Life (OS X’s system-level spellcheck is another, as is Quicksilver).
Heat resistant
Something that always annoyed me is how books warp in heat. A book that’s in perfect condition will be fucked after an hour or two’s reading in a hot car. Not so with the Kindle, always pristine!
Highlights
Again, something you wouldn’t think you’d need, but really comes in handy. Clipping things from articles or books to tell people later is very useful indeed.
Instapaper
I’ve been a fan of Instapaper for ages, had the iOS app since it was released ’round July 2008. But reading stuff on the iPod Touch just isn’t very nice. Sure, it’s handy to catch up on the odd article, but having to remember to open the app and resync articles before leaving the house, combined with the app’s general sluggishness (more to do with my 1G Touch, rather than the app itself) meant I didn’t use it too often.
Enter the Kindle. Auto-syncing (via email) of the latest 20 unread articles once a week means the most recent articles are always ready to read. It’d be even better if it could tell which articles you’d already read on the Kindle, but y’ can’t have everything!
Samples
Oh, that book looks interesting, I’ll just download the sample. What’s that? I can download the sample from the book’s page on Amazon direct to the Kindle? That’s unreeeeeal! Oh, that sample was good, I’ll just buy the full book directly from the sample.
Screen
People are always shocked when I say the screen improves in sunlight. It does.
Size
Even with a case, it’s only the size of a slim notebook (the only book comparison would be a novella) – small enough to go into a jacket pocket in winter, be held in the hand in summer. Beats carrying round a paperback.
The Meh
—————–
Browser
The browser’s described as “experimental” – some pages don’t load at all, the interface is clumsy, there’re no multiple tabs or windows. Results in a workable but rough browsing experience.
File formats
Mobi is nice and all, but I’d prefer it to have support for any format I could throw at it (epub, lit).
PDF viewing
Again, pretty rough. Navigation isn’t the best, rendering is slow, but it’ll do the job if you’re stuck.
Screen
An unfortunate sideffect of the eink screen is the refresh time between pages. You get used to it very quickly, but it can be jarring at first.
The Bad
—————–
Apps (lack of)
I’d love an email/rss app. Just something barebones, hooking into Gmail/Greader, that’d be unreal – no need for push updates, if I had the apps I’d be quite happy to pull down the stuff myself.
Batteries
Not the Kindle’s fault, but my own. Waiting at the gate for MIA-LHR flight (8h), time to read something, battery dead. Dammit!
Kindle Store (parts of)
Seemingly arbitrary books being available on the US store, but not on the UK store. Differences in releases between regions, despite the download being the same.
MP3 Playback
Fairly useless – at least provide some sort of UI to it!
Organisation
There’s no easy way to organise books – creating folders is easy, but there’re no sub-folders, and adding books to said folder is a torturous process. It’s so bad I’ve found it easier to delete the majority of books and organise them by Fiction, Non-fiction and Samples, rather than anything more fine grained (genre/series).
This could easily be solved by a software update so the creation of folders, and movement of content in those folders, through Windows/OS X was reflected in the Kindle itself.
Overall
—————–
Far and away one of the best bits of tech I’ve bought in the last few years, don’t let the few negative points detract from that – the organisation is the only one that affects day-to-day usage. It’s no iPad, but it’s not designed to be. I look at it as the best black and white tv you can buy – it can only do black and white, but it does it really, really, fucking well.
Definite buy, with the 3G and some sort of cover – the Amazon ones are pricey, if durable.
Don’t buy the cover with the light. When you read a book now, does the book have a light in its cover? No it fucking doesn’t.
May 9th, 2011 in
Technology
20:12:39 PDT - Monday, April 25, 2011 in
Technology
Decided to redo my desktop on a whim yesterday, ended up taking nearly a full day to get everything sorted. Finally, after a lot of hacking and messing and scripting, it looks to be in decent shape:

So, the desktop I used is here. I used Geektool for nearly everything on the desktop, with the exception of the music, which is a hacked Bowtie theme (here) and Desktoplyrics.
The Geektool stuff, mostly dirty hacks:
Two Tube-time scripts, one to show the status of all lines, when it’s not “Good Service” (with Monaco Regular 24pt):
curl --silent http://www.tfl.gov.uk/tfl/livetravelnews/realtime/tube/default.html | sed -n '/"lines"/,//ul/p' | grep -A 2 'ltn-name' | grep -B 2 'ltn-title' | grep -v div | sed 's/.*">//'| sed 's/<.*//' | sed 's/--//' | sed 's/amp;//' | awk 'NR%3==1 || NR%3==2' | sed 'N;s/n/ - /;' | column -t -s -
Another to get the full status of a particular line
curl --silent http://www.tfl.gov.uk/tfl/livetravelnews/realtime/tube/default.html | sed -n '/ltn-name">Bakerloo/,//li/p' | head -5 | grep -v '<div class="status pro' | grep -v '<div class="me' | sed 's/.*<.*">//' | sed 's///' | sed 's/.*<p>//' | sed 's/&/&/'
For the uptime (ripped from somewhere):
uptime | awk '{sub(/[0-9]|user,|users,|load/, "", $6); sub(/mins,|min,/, " minutes", $6); sub(",", " minutes", $5); sub(":", " hours
", $5); sub(/hrs,|hr,/, " hours
", $4); sub("h ", " hours
", $4); sub(/days,/, " days
", $4); sub(":", " hours
", $3); sub(",", " minutes", $3); print "" $3 $4 $5 $6}' | sed -e 's/ 1 days/ 1 day/g' -e 's/ 1 hours/ 1 hour/g' -e 's/1 minutes/1 minute/g' -e 's/usermin//g'
For timezones (you'll have to change it per city):
curl --silent http://www.timeanddate.com/worldclock/city.html?n=137 | grep 'id=ct' | sed 's/.*id=ct class=big>//' | sed 's/:[0-9][0-9].*//' | sed 's/.*,.*, /LA: /'
The text is just an ls, showing the most recently modified files (what I still have to watch)
ls -t /Downloads/ | head -n 9 | cut -c1-12
The temperature is from the same weather code, which I'll show in a minute.
The sun/cloud icon is from gtwthr.com, go there to get the location code.
The weather code on the right is a series of curls to yahoo weather:
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCODEHERE&u=c" | grep -E '(Current Conditions:|C<BR)' | tail -n 1 | sed 's/ C<BR />/C/g'
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCODEHERE&u=c" | grep -E '(Current Conditions:|<br)' | head -n 3 | tail -n 1 | tr -s '.' 'n' | sed 's/ Low/C Low/g' | sed 's/ High/High/g' | sed 's/<br />/C/g'
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCODEHERE&u=c" | grep -E '(Current Conditions:|<br)' | head -n 4 | tail -n 1 | tr -s '.' 'n' | sed 's/ Low/C Low/g' | sed 's/ H/H/g' | sed 's/<br />/C/g'
In the menu bar we've got the basics - Adium, Skype, Dropbox, Logmein, Time Machine, three iStat Pro items (CPU, network traffic, RAM) - I use iStat for the clock too.
In the dock, also fairly basic (put in 2D mode with Secrets) - iTunes, NetNewsWire, Mail, Adium (with Septi - the contact list style I use is a tweaked HUD).
That's about it - the Geektool fonts are all Ultralight Helvetica Neue, Courier/Courier New or Monaco, with full white or black and 50% transparency.
April 25th, 2011 in
Technology
15:45:43 PDT - Sunday, April 10, 2011 in
Technology
I wouldn’t have the most bulletproof code. Such is my coding ability, and the speed at which I’m required to hit milestones, if what I wrote what I would consider perfect code (ie fully tested production-level), I’d never get things done in time.
As a result, I tend to write things as fast as I can, and come back to the edge cases, error handling, the “proper” way to write things, later.
My manager noted this relatively quickly, it has since become a bane of his life, where he accepts he’ll probably have to rewrite everything I do. This provides me with an interesting way to get him worked up.
As an example, I was writing a piece of code to receive a PNG image from a server. The code just receives the information plainly from the server, it has no knowledge of the filetype – you receive the code in a binary format from the server, then pass it to a function saying its a PNG. An interesting problem arose where the code seemed to be picky about the amount of data it would render – if the image was under 2kb, no problem. Over 2kb, and it would either partially render it or return an error. This was compounded by it occasionally rendering the complete image correctly. So wanting to make sure it would actually render the image ok, if it received the correct amount of data, I added the following code:
do
{
sizeOfData = tryServer();
}while (sizeOfData < rightSize);
Which is roughly translated as "keep trying until you get the right answer", or "possibly the worst bit of code I've ever written".
But hey, it did what I wanted it to do (ensured the data would eventually get returned, and then draw the image), but not before my manager had told me to never show him anything I wrote like that ever again.
Mission accomplished.
April 10th, 2011 in
Technology
23:07:35 PDT - Monday, January 31, 2011 in
Technology
My 360 hasn’t been terribly stable since I switched rooms in November – first it was a refusal to get an IP from my MacBook, though I had it set up as DHCP; then, more recently, a refusal to sign in to Xbox Live on boot – it would display a generic “Cannot connect” message, then prompt to test the connection, which would work fine, then back to the main dashboard, and suddenly it signs in no problem.
I decided to totally sort it out this evening – get DHCP working properly again, which hopefully would solve my not-signing-in-on-boot problem, and perhaps improve my general play experience (played ~6 games of Hot Pursuit over the weekend, didn’t finish one – kept getting “This session is no longer available”; had enormous trouble playing in a party in Black Ops last night).
It was actually incredibly easy to fix, but I’ve summarised it here in case something goes wrong and I’ve to repeat the process – instructions for OS X 10.6, but I think they’re generic enough to be used on 10.4 and 10.5.
Network setup:
ISP router wireless to MacBook Pro. Ethernet from MacBook to Xbox 360 (old Premium model).
Anyway, open up Terminal, copy your /etc/bootpd.plist somewhere, edit it, changing the value
<key>reply_threshold_seconds</key>
<integer>4</integer>
to
<key>reply_threshold_seconds</key>
<integer>0</integer>
then copy it back over the original.
Then in to Internet Sharing (in System Preferences, under Sharing) enable it (you’re sharing from Airport to Ethernet).
In to Network settings, click the Advanced tab, then switch the “Configure IPv4” to “Off” (as we’ve already sorted out the DHCP options). Here’s one I made earlier:

Then, and this is the important bit (which I missed previously), stick your router IP in the DNS server space on the Ethernet tab. (if you dunno your router IP address, you can find it via Airport -> Advanced -> TCP/IP -> Router)

Now, with everything set to automatic on the 360, you should be good to go!
I’m not 100% sure in terms of connectability and lag and whatnot, though I played for about a year with this sort of setup before, I never had any problem with either.
January 31st, 2011 in
Technology