Saturday, 25 February 2012

Visual Studio 11's New Look

Microsoft recently unveiled a proposal for a new look on Visual Studio 11. Now, I'm hardly a graphic designer, but one thing repeatedly strikes me as a bit bonkers in software written in the past ten years, and it's not restricted to Visual Studio: the 'save' and 'save all' icons.

Do you see that? They're floppy disks. I don't know if their continued representation is maybe indicative of an aging population of computer programmers, but floppy disks haven't been relevant since the turn of the millenium.

I wonder if new up-and-coming programmers even know what they're clicking?

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.

Update 19-Apr-2012: I ended up not really bothering with transcoding my DVDs: the storage on the NAS is such that I could avoid the re-coding overhead and just rip the VOBs directly with MPlayer:

mplayer dvd://1//dev/sr0 -dumpstream -dumpfile "Some DVD"

This way, I get all the audio and subtitle streams, and with the help of lsdvd can pick out just the movie track (which MDRP can do as well).
One potential gotcha is to remember, particularly with subtitled/multi-audio movies, is to grab the .INF files from the DVD, too. They contain the names of the tracks and the palette used in rendering the subs; the subs may render strangely without this information.

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'

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

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)// /}