Saturday, 18 February 2012

Mac DVDRipper Pro

I have a Mac mini under my TV, with an NFS mount to 2TB of RAID-1 space on the other end of a gigabit ethernet home network. So it makes perfect sense to get rid of physical DVDs, putting them in a box in the loft after ripping them into digital form. So I've been looking for software that does this well, and stumbled across Mac DVD Ripper Pro a few days ago. It even managed to rip/transcode some troublesome DVDs that seem to resist other means of doing the same.

MDRP offers an on-the-fly transcode feature which looks to be built on HandBrakeCLI.


All things considered, it's a pretty good converter: simple, slick and reliable. That said, I'm not sure how its proprietary license works with the GPL'd HandBrake underneath it.

Sunday, 12 February 2012

Shell Scripting: Counting Occurences of a Character

I recently found myself needing to know the occurrences of a letter in a line from a shell script. I was working with a delimited file, and needed to know how many columns were in a given line (it would be consistent within the same file, but could differ between files, depending upon the version of the code that produced it).

Surprisingly, it took a bit more digging than I thought would be needed for such a simple task. Counting lines is easy, but characters within a line? It's not a difficult thing to do in Perl or awk, but launching their respective interpreters seemed a bit heavyweight.

tr to the rescue. This under-used command line utility translates from one character set to another (a set can just be a single character). It can also delete characters from its input and, using the -c (complement) switch, can work on a set that's the inverse of the one specified. Tying those loose threads together, you end up with this to pick out occurrences of the letter 'e':


danny@khisanth ~ [2] % echo one two three four five | tr -cd 'e'
eeee%


That % is my shell indicating that the line didn't terminate with a newline, so it was just the 'e's. Once you have those, wc -c can do the rest:


danny@khisanth ~ [3] % echo one two three four five | tr -cd e | wc -c
4


Annoyingly, wc on some Unixes indents its output, so if you just want the number itself, you might need to play with your shell's string manipulation functions to get something neater. e.g., in zsh:


danny@khisanth ~ [4] % echo ${$(echo one two three four five | tr -cd e | wc -c)// /}
4

Wednesday, 29 June 2011

Gran Turismo 5 (eventually, I'm assuming)

I'm occasionally a bit behind the curve when it comes to gaming. Given the appalling state of some titles on release day, I've found that it's quite often sensible to wait a while until the first few patches have come out to address the glaring problems that the initial 'gold' build shipped with regardless.

So it's not until today that I got a copy of Gran Turismo 5 for the PS3 (pre-owned). I shove the disk in, and immediately have to download the better part of three quarters of a gigabyte of patches. As soon as this non-backgroundable download starts, I fire up the PS2, switch to component input, restore a save of Shadow of the Colossus, and then spend the next half hour beating the 9th colossus. I save that game, and switch back to the PS3 on HDMI in. The patches still haven't finished downloading, so I switch to DVI in and boot the Linux box, do some simple updates and routine administration, then check in on the PS3 again. Hey, all the patches are down! Maybe I'll get the play the game.

Or maybe not: right at the start, the game carries the advice that installing 8GB to hard disk can speed up loading times. Now, if the game developers felt the need to admit that, you know that there are going to be problems, so I click 'yes', and see an estimated time of a paltry 14 seconds. Good! Oh, wait: that's the preparation time before it can start installing: the actual estimate is more like 30 minutes.

So, I take the time to write this blog post, and it's still installing.

What the hell happened to console gaming?

Saturday, 25 June 2011

Console Gaming, Rebooted

I've become a bit disillusioned with console gaming over the past few years. Many hours of my late teens were spent on the original PlayStation on classics like Final Fantasy VII & VIII and the various incarnations of Resident Evil. The upgrade to the PlayStation 2 in my early twenties was a foregone conclusion, offering much the same experience, but with better graphics and DVD playback as an added bonus. But the PS3 has never quite captured me in the same way. Part of that is undoubtedly me simply getting older. I'm married, have a daughter, and run my own consultancy company: it's only natural that some of the less important things like computer games slip a bit.

Still, throughout each generation of console, I've always had at least a background flirtation with PC games. Some games (first person shooters springing immediately to mind) are just out-and-out better on a PC. Something a simple as mouse vs. control pad become critically important when you want to be able to turn quickly to find out what's shooting you. Other games (RPGs like Dragon age) are again just better on a PC largely because navigating the intricate menu systems of such games with a d-pad is infuriatingly slow. Thus, while games like Infamous and God of War 3 on the PS3 are undoubtedly best on their home platforms, the shiny black console spent most of its time languishing unused under the TV, while its forgotten dad, the PS2, was in a damp-proof box with its games in the attic.

Anyway, I bought a new monitor/TV earlier this week: finally time to retire the 4:3, 1280x1024 and catch up with the 1920x1080 high-def kids. One of the major selling points for this particular monitor was the sheer number of connectivity offerings on its back. My PC displays via DVI; I have a small, VIA-based server that has a VGA port for the occasional time (i.e. backups) when I need local terminal access; and there's an HDMI port for the aforementioned PS3. But there's also component input, which made me think of the old PS2. Indeed, why not hook both it and the PS3 up to the same display, just for kicks?

Well, since I've done that, I've played the PS2 more than its younger, more powerful offspring, and it's reminded me of why console gaming used to be fun: it was just so simple. Shove in the disk, and go.

With the PS3, turning it on assaults you with a menu of menus, each of which contains a dizzying number of options. If you're an infrequent player like me, it seems like you're being prompted for a firmware update just about every time you turn the damn thing on, and if you play a game that you've not touched in a while, there's every possibility that you'll be looking at anything been 100MB and 1GB of patches to fix the problems caused by rushing the original version out the door.

One of the great things about the PS1 and PS2 is that they didn't have internet connectivity, so game studios had to be very, very sure that the software they committed to CD or DVD was as bug free as possible. With the PS3 (and Xbox360—don't think I'm picking on the PS3 in particular), just about any old crap can be thrown together, to be patched later when the early adopters—devoted fans that a studio should treat especially well—are used as unpaid acceptance testers.

So I'm holding off on purchasing Infamous 2 for the PS3, and instead having fun with Shadow of the Colossus on the PS2. I think I should be able to get through that and Silent Hill 2 before I see if I can stomach the hassles of modern console gaming, or whether I just ditch the platform and stick to the PC.

Thursday, 10 March 2011

Continuously Learning Lisp

I like to think that I 'know' Perl. I also 'know' C, Java, Smalltalk, Ruby and a handful of other languages. But Lisp is the only one that continually makes me feel like a newbie. Just when you think you've got it pegged... BLAM— you read something that shows you a completely new dimension.

A good example of this for me is Nikodemus Siivola's post on "Optimizing Lookup Functions Using LOAD-TIME-VALUE", basically demonstrating a way of altering the language such that hash table lookups with keys that are known to be constant at compile time have no lookup overhead at runtime.

I feel like I have a whole lot to learn, and it's good :-)

Monday, 22 November 2010

Apple device fragmentation

Apple's Steve Jobs went on an anti-Android rant earlier this year, focussing in particular on market fragmentation. Apparently, there are so many configurations of Android device that it's writing software for the platform is next to impossible. This came as a surprise to people who actually develop for it.

Apple, on the other hand, dodge the issue of fragmentation completely. iOS is a completely unified platform, with only one catch: you must be up-to-date with the latest shiny toys. The new iOS 4.2 is now available, with the following small caveat:


Availability

The iOS 4.2 update is available today to download to iPad, iPhone and iPod touch by syncing the device with iTunes 10.1. iOS 4.2 is compatible with iPad, iPhone 3G, iPhone 3GS, iPhone 4, second and third generation iPod touch (late 2009 models with 32GB or 64GB) and new iPod touch. Some features may not be available on all products. For example, Multitasking requires iPhone 3GS, iPhone 4, third generation iPod touch (late 2009 models with 32GB or 64GB) or later.


So, as with recent OS updates, it won't work with my first generation iPod Touch (or second gens, for that matter). Owners of those devices are left with older versions of iOS, with no upgrade path that doesn't require a hardware purchase.

Meaning that, if you're an application developer looking to target the broadest user base, you're hit with platform fragmentation...

Sunday, 21 November 2010

Apple's 'Restart your computer' U-Turn

Once upon a time, Mac users could chuckle heartily at Windows users. After every Windows Update, you'd get that prompt to restart your computer, and it was annoying. If you're the kind of person who thinks that computers should serve rather than be served, you've probably got about a half dozen or more applications open, each containing reference material or partially completed work.

Damn, those restarts were annoying.

However, it's almost every other week that there's some update to Quicktime, Safari or iTunes, each adding more features that I don't care about (Ping? Yet another social network, but one that's only accessible via the locked-down iTunes ecosystem? Seriously..?) I don't need my iTunes to support the latest devices from Apple: I haven't bought anything from them since my first-generation iPod touch (which still works superbly, by the way: I have no intentions of replacing it).

Going back to that 'once upon a time', apps used to run on top of Mac OS. Now, Apple does what got Microsoft into so much hot water at the turn of the millennium: integrating home-grown apps into the operating system (otherwise known as 'gaining unfair advantage over competitors'). So, after updating to Mac OS 10.6.5 and restarting (ok, operating system updates require restarts), I find that iTunes and Safari are both needing updated, also nagging for a restart.

Well done, Apple. You are the new Microsoft. Enjoy the bubble.