Useful iPlayer addition

I currently have 2 laptops, an iMac, a PS3, an Xbox 360, Cheryl’s laptop, and Cheryl’s PS3 all capable of playing content from BBC iPlayer. If I want to view HD content I have to download it using the desktop app. This is available on the computers and laptops regardless of the operating system, which is very nice as I have Linux, Mac, and Windows installations at the moment.

My improvement comes from a situation I have found myself in a couple of times since Cheryl and I got the iMac the other day. I can download HD content on here, but if I do then I have no way of playing it on my TVs. The iMac has a nice 27 inch screen, but the dining chairs aren’t anywhere near as comfortable as the sofa.

When I’ve downloaded the HD copy of some media it would be great if I could connect to my BBC iPlayer installation on any of my other devices and stream that content over my local network. The DRM can all be handled in the same way it is by the app on the PS3 or whatever. It’s just a locally-hosted copy of the exact same file. They could even make it so that you can only stream the content from within the iPlayer app if they wanted.

I don’t want to pirate anything, I just want to be able to play media I’ve downloaded on one device on another. This would be possible if I did illegally download a copy of the media, I shouldn’t be punished for being honest.

First post from the iMac

Cheryl and I went to Stratford this morning to go and buy an iMac. Cheryl has been saying she wants one for quite a while now, and I think that some sort of desktop computer would be preferable for writing code on because I need screen real estate.

We decided to go and buy the 27-inch one with 8GB of RAM, a 1TB SATAII hard drive, and a bunch of other cool bits. Luckily Cheryl’s student card still passed the inspection by the staff in the Apple store, so we got 12% off.

We did ask the guy to give us the keyboard with the numpad section, and he said yes, but when we got home we found he hadn’t swapped it at all. Oh well, not a huge problem.

Getting the thing home was a massive effort. I had to carry it through the Westfield shopping centre as it was getting busier and busier. Then I had to carry it down escalators and through the tube gates and then find a place to stand with it on the tube. It was quite awkward at times, but luckily the trains leaving Stratford were considerably less busy than the ones arriving there.

At the moment it’s been set up on the dining table. It’ll probably be here for a while because there’s nowhere else suitable for it. When we get rid of the Christmas tree we’ll hopefully put some sort of big desk thing in its place and the iMac can live there. Then I’ll get a nice computer chair and everything will be nice.

Since we got it back here I’ve been configuring it to work more like a Linux installation. I’ve got my terminal set up, installed git, ports, Chrome, Spotify, Xcode, and all the other crap you need to make a computer feel personalised. It’s starting to feel pretty nice. It’s basically the most well-designed Linux distribution out there.

So yeah, I now have Linux, Windows, and Mac OSX running at the same time, as well as an Xbox 360, a PS3, and a Wii. I guess I just don’t believe in brand loyalty.

Funny comments in open source software

Whenever I’m looking through code at work I come across various little nuggets of wisdom from whoever wrote what I happen to be working on at the time. Usually it’s just something fairly innocuous and helpful, but sometimes it’s just downright funny.

Based on this I decided to take a look around various pieces of open source software to see what kind of things their developers leave behind for future coders. I’ve gone through and come up with a list of some of the better ones. Enjoy:

/* most drives spin up by 10sec */
/* > 99% working drives spin up before 20sec */
/* give > 30 secs of idleness for retarded devices */

Linux Kernel – drivers/ata/libata-eh.c

/*
* Now, we have to map the power management section to write
* a bit which enables access to the GPIO registers.
* What lunatic came up with this shit?
*/

Linux Kernel – arch/x86/kernel/visws_quirks.c

"""
This insane behavior probably doesn't matter, but we're compatible just for shits and giggles.
"""

Mozilla – source/build/pymake/pymake/data.py

/* There are, alas, devices in this world too dumb
* to read their own hardware colormaps. Sick, but
* true. */

X.org Server – dix/colormap.c

/* Well, I wonder, rfc1812 was written by Cisco employee,
what the hell these idiots break standrads established
by themself???
*/

Linux Kernel – net/ipv4/ip_gre.c

/* NB: this is conceptually wrong, the string returned by setlocale should
* be taken as opaque -- but then we would be in deep shit^Wtrouble. This
* seems to actually happen on Win32.
*/

XBMC – sources/enca-1.9/src/locale_detect.c

Dual monitors at work

I decided to get a second monitor working with my computer at work so I didn’t constantly have to flick between workspaces and different terminal windows to write code and read my logs.

After a lot of messing around Jim looked over and told me about the xrandar program. It took a considerable amount of messing around (and a third monitor) to get everything working correctly. It’s still not quite perfect because I’m missing the bottom of the right-hand screen because of a difference in screen resolutions.

My desk at work

My desk at work

I was considering switching to something like Fedora or back to Ubuntu again because they’re usually pretty good at working out what to do with displays and stuff like that. Of course, it doesn’t help that the graphics card is an ATI something-or-other. nVidia cards are so much easier to set up because of their excellent little configuration tool.

Swap Escape and Caps Lock keys

When was the last time you used the Escape key on your keyboard? For a lot of you it quite probably was a fairly long time ago.

When was the last time you used the Caps Lock key? For all of you it should have been a long time ago!

I do my programming in Vim and to switch between Insert and Visual mode I have to press the Escape key. This wasn’t so much of a problem when I didn’t do so much coding, but now it’s my full-time job I find it to be quite a pain, literally. After a full week of programming in Vim my poor little finger is hurting from extending up to the Escape key.

Today I decided to solve this problem once and for all.

I mentioned the Caps Lock key earlier on. It’s on the “Home Row” of the keyboard. This means that it’s right beside where you should position your fingers when using a keyboard. Your left hand should sit on ASDF from little finger to index finger, and your right hand should sit on JKL; from index finger to little finger. You’ll notice that (on most keyboards) there is a little notch on the F and J keys. These are there to help you find the proper hand position without having to look at the keyboard. Of course, this all assumes you’re using the QWERTY keyboard layout and not Dvorak, or something entirely different.

Proper finger position

Proper finger position

In Linux there is a utility to change various keyboard and mouse settings called xmodmap. This gives you the ability to remap keys to different functionalities.

I’ve used xmodmap  to switch my Escape key fucntionality to the Caps Lock key and vice versa. This is going to take some getting used to, but the overall benefit to my fingers should be quite significant. It’ll also have the unintended side-effect of stopping me accidentally going into cPS MODE WHEN I MISS THE ‘A’ KEY. 😉 Of course, there will be some programs where pressing escape will cause the window to close, or the action to be cancelled. I guess I’ll just have to be more careful than I was before to avoid accidentally hitting the key to the left of ‘A’.

The way I set this up was using a file called .Xmodmap in my home directory. The contents of this file are loaded by xmodmap every time you log into the computer. The file contains the following:

! Swap Caps_Lock and Escape
remove Lock = Caps_Lock
remove Control = Escape
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
add Control = Escape

Now to get back to writing code and start saving my left little finger.

Most annoying hashtag of the month (#moonfruit)

I was getting bored of finding that several people I know (mostly you, 0lly :P) only bother tweeting if they stand a tiny little chance of winning a MacBook or whatever by sticking #moonfruit everywhere.

I decided to write a little command chain to show me how many of the most recent 200 tweets in my “friends timeline” contained the ubiquitous hashtag.

Turned out to be 9.5% of tweets. That’s damn near to 1 in 10 tweets being of absolutely no interest to me. Booooring! Here’s the command chain I wrote. I’m sure it can be refined plenty. I only use the XML API interface for Twitter because the JSON format doesn’t bother splitting results onto separate lines.

curl -s -u YOUR_TWITTER_USERNAME http://twitter.com/statuses/friends_timeline.xml?count=200 > /tmp/twitterlog.txt && echo -n 'scale=2; 100/200*' >/tmp/twittercount.txt && grep '#moonfruit' /tmp/twitterlog.txt | wc -l >>/tmp/twittercount.txt && cat /tmp/twittercount.txt && cat /tmp/twittercount.txt | bc

Obviously you’ll have to substitute YOUR_TWITTER_USERNAME for your actual username. You can also change the bit that says #moonfruit to anything else you want to search for. Oh yeah, this will prompt you for your Twitter password, but all communication is directly with Twitter, so you’ll be just about as safe as if you’d gone to the website. You’ll encounter a lot of problems if you try to run this in Windows, too. 🙂

iPlayer downloads in Linux

After reading an article on The Register this morning about iPlayer downloads being circumvented by Linux users I did a quick search and found this page. There was a comment on there by Andrew Williams with a Firefox bookmarklet to help make things easier. It still relies on having a User Agent Switcher extension installed to get the correct address.

I decided to go one step further than that.

I discovered that even when viewing the site with your regular User Agent you can gather enough information to build the URL needed for the iPhone version. I spent a fair while working on an improved iPlayer bookmarklet which you can drag and drop into your Bookmarks Toolbar Folder.

When you’re viewing a video in iPlayer you should click the iPlayer bookmarklet. It’ll change the title for the video to a command that you can copy and paste into your terminal. It’ll even name the file for you. 🙂