Main page

Console top Main page Blog Webcomic Other comics Music Animations Writing Other stuff Links Console bottom

Wednesday, April 28, 2010

This blog has moved


This blog is now located at http://blog.middlerun.net/.
You will be automatically redirected in 30 seconds, or you may click here.

For feed subscribers, please update your feed subscriptions to
http://blog.middlerun.net/feeds/posts/default.

Thursday, April 08, 2010

Gandalf and the Moth

Here's a thing I made:

Tuesday, January 05, 2010

Triple boot adventures

When I got my last hard drive, weighing in at 200 GB, I thought I'd never be able to fill it up. But then, that's what I thought about the 20 GB one I had before that. But of course dual booting and GTA IV and various BitTorrent downloads conspired to keep the drive full most of the time.

Now I've got a 1.5 TB drive (actually 1.36 TiB). Surely I'll never fill that up! Not for the next few weeks, anyway.

With the new drive I'm finally upgrading to Ubuntu 9.10, Karmic Koala (or as I like to think of it, Karmic Khameleon). The advantage of doing this on a new drive is that I can keep my old 9.04 installation in case anything goes wrong with Karmic. Luckily it's working flawlessly. Ubuntu really is amazing - every (free, half-yearly) release is easier and better than the last.

I'm also taking the opportunity to try some other new stuff. For a couple of months I've been curious to try running OS X on my computer. Now that it's gotten to the point where it's easy to install OSx86 with a release like iATKOS or Kalyway without any screwing around with the BIOS, I figured I might as well try it. As much as I don't like the way Apple uses DRM and vendor lock-in to keep its users on a short leash, it's probably useful to know how to use all the most popular operating systems. Plus I hear iMovie is pretty good, and I've been looking for a decent video editor.

Also I'm waving goodbye to Windows XP, which I've kept kicking around on my system primarily for games, and things like Flash. I managed to avoid Vista entirely, but I think it's time to bite the bullet and get rid of the eight year old XP in favour of Windows 7.

The first step of setting up the system was partitioning the new drive. I gave 100 GB to OS X, 200 GB to Windows 7 and the rest to Ubuntu.

I installed OS X first. Unlike Windows 7 I couldn't test OS X in a virtual machine first, so I didn't know how it would go. The OS X disc I used was iATKOS v7, and it seems pretty solid. Installation was mostly straightforward, although it took me a while to figure out that I needed to open a program separate from the installer to format the install partition to HFS+. Another problem was that I didn't know I had to tell it to install a kernel extension (kext) to make my PS/2 keyboard work, so I ended up having to reinstall it. It has a few graphical issues but apart from that it seems to be working fine now.

Next was Windows 7. Also pretty easy, though the DVD takes forever to load the installer. I thought the XP install disc was slow to start at a few minutes, but the Win7 installer takes about 20 minutes to start! The installation itself took a while too, but that's to be expected. I installed a few games I've been playing like GTA IV and Half-Life and transferred over my savegames. They all seem to be running fine.

Installing Ubuntu was a breeze, as usual. I installed it last so that it would install the GRUB bootloader without it being overwritten. The new version of GRUB is pretty cool, it managed to automatically add entries for not just the three new operating systems, but the two on the old drive as well.

Now all I have to do is make sure I've transferred everything important from the old drive to the new one, and then I can reformat the old drive and use it for backup. In the meantime, just look at this awesome GRUB screen:

Awesome quintuple boot GRUB screen

Just look at it.

Labels:

Thursday, December 17, 2009

So you want to hand me a book

I was in the city a few weeks ago, minding my own business when some Hare Krishna guy gave me a book. A fat hardback book, full of glossy colour illustrations which he eagerly pointed out to me, opening the book while it was still in my hands.

It's not the first time this has happened. A few years ago some other guy gave me a book hilariously named "Teachings of Queen Kunti". He assured me it would be the best book I would ever read, which I suspect would not have been true even if I had read it.

I'm not crazy about being handed stuff I don't want. For example, one of the worst things about UNSW is that there are perpetually people at the front gate handing out flyers and pamphlets and pestering me about stuff I don't care about when I'm trying to get to a class (though I suspect it is the same at every university). That's one of the advantages of having a motorbike - I can ride my bike straight onto campus and park there, bypassing these twerps. A guy called Samuel Kass had a good idea: a pamphlet to give to people giving out pamphlets called So You Want to Hand Me a Pamphlet.

At least if it's a flyer or something I can just throw it away. But I feel weird about throwing a book away, even if I know I'll never read it. I've got better things to read, books that have been sitting on my shelf unread for years - interesting ones. I'm not going to go reading a (presumably religious) book some guy in orange robes gives me. But what really gets me is that these guys give you a book you don't want, and then have the gall to ask for a donation in return. "Most people give ten or fifteen dollars", the guy assured me.

For some reason I felt as though it would be uncalled for to tell him to shove it up his arse, and even just giving him back the book would have been awkward, so like a stupid sucker I dug a few dollars out of my wallet, insincerely apologising that it was all I had (which wasn't true, but I'm not going to reward someone with ten dollars for interrupting me as if I've got nothing better to do). Due to my paltry offering he politely swapped that large hardcover book for a smaller, paperback volume called "The Science of Self-Realization" (taking, I suspect, rather a creative liberty with the word "science").

This seems like a marketing loophole. Traditional marketing is about making people want something so they'll buy it. What this guy and his ilk have done is bypassed the "making people want it" stage, by giving people stuff and then exploiting their sense of social awkwardness and unwillingness to offend a friendly religious person to make them pay for what they never wanted in the first place.

And now this book is sitting on my shelf. I don't want it. I'll never read it. I don't want to throw it away because I sort of payed for it. Maybe I should write a book of my own, and hand it out to anyone in an orange robe. It will be called "I Don't Want Yer Damn Book: How To Avoid Creating Animosity Towards Your Cause".

Labels:

Tuesday, December 15, 2009

Hasta la vista, frozen app

I just came across an article, 6 Different Ways To End Unresponsive Programs In Linux. One of the methods caught my attention, the program xkill, which turns the mouse pointer into an app-killing cross of doom.

There's a cool effect in Compiz Fusion on Linux, where any window that is closed erupts in fire and burns up as it closes (it's part of the Animations Add-On plugin, more info here). When combined with xkill, it's pretty much like shooting the window. I decided to extend this by adding some shotgun sound effects. All it takes is a very simple shell script:

#!/bin/sh

play /usr/local/share/xkillshot/gun_cock.wav
xkill
play /usr/local/share/xkillshot/shotgun.wav


I call it xkillshot. When you run the script instead of running xkill directly, it first makes the shotgun pumping noise and arms the cursor. Then when you click the window the shotgun noise goes off and the program is killed.

The script goes somewhere in your $PATH such as /usr/local/bin and it requires the two files gun_cock.wav and shotgun.wav to be in the directory /usr/local/share/xkillshot and also seems to require the package sox, to enable the play command. Make sure the script and audio files have the right permissions. You can run it through a terminal or use Alt+F2, but for best results set a shortcut key. I used Ctrl+Alt+K. Any time Firefox or whatever freezes, I can just hit the shortcut to whip out the app-killing shotgun and blast it to pieces.

(I was going to make a video to demonstrate the awesomeness, but I can't seem to find a Linux video editor that doesn't suck balls. Pitivi had hardly any features, OpenShot has more features but as far as I can tell they mostly either don't work or cause the program to crash, Kino for some reason needs to convert the files into DV format which takes forever, Cinelerra is complicated and resource-heavy and Kdenlive is impossible to install. I have yet to try Open Movie Editor, but it hasn't been updated in nearly a year, not to mention it has a butt-fugly interface. I don't think I've tried LiVES either. But that's another blog post.)

EDIT: Here's an updated version of xkillshot which doesn't make the shotgun noise if you right click to cancel xkill.

#!/bin/sh

play /usr/local/share/xkillshot/gun_cock.wav
xkout=`xkill | wc -l`
if [ $xkout -ne 1 ]
then
play /usr/local/share/xkillshot/shotgun.wav
fi


Be careful with this. As it says in the manpage, xkill is a dangerous program. It doesn't just close the window, it instantly kills the process which can cause you to lose unsaved data, so it can screw things up if you accidentally kill a process you shouldn't. I learned the hard way not to close a Nautilus window this way - Nautilus closed completely and all my desktop icons disappeared until I restarted X. But if Firefox freezes or something and you need to kill it, this is quicker than using the System Monitor and more fun than just using xkill on its own.

Labels:

Thursday, October 08, 2009

Coin efficiency and the wisdom of quarters

I came across this post today on Freakonomics (via David Malki !), about the efficiency of various coin combinations. Go give it a read, or this post won't make much sense. Go on, I'll wait.

So in case you didn't read it, apparently if you want the least amount of coins in the average change from a purchase, the best combination (assuming four coins, starting at one cent) is one cent, three cents, 11 cents and 37 (or 38) cents. Of course, for the sake of simplicity this ignores the fact that some amounts of change are more likely than others (among other problems -- more on that later), but it's an interesting idea nonetheless.

Since I've been learning Perl at uni this semester I decided to try to write my own script to calculate this, as a coding exercise. That didn't take too long to code, but it sure took a long time to run -- not surprising really, as it has to find 152,096 coin combinations, calculate the efficiency for each one, and then sort the results. I did it on my laptop, and when I ran it it took about 4 and a half minutes to finish. On my desktop it was more like a minute.

The problem with the calculations in the article (and the program I wrote) is that they are limited in scope -- they're only for 4-coin systems which go down to the penny (i.e. America). Over here we have 4 (sub-dollar) coins too, but the smallest is 5 cents. I decided to modify the program to work for any number of coins, and any resolution (i.e. the smallest denomination). That led to a few hours of coding, during which the rest of the world faded out of existence like it always does during coding, only to snap back into place when I finish the program and I realise it's 8 o'clock and I want dinner.

This new version accepts command line arguments to set the number of coins and the smallest denomination. The downside is that is is much slower, taking nearly 4 minutes for a 4-coin, one-cent system (UPDATE: On my laptop it was more than 15 minutes). Having done that, I can say that the theoretical average number of coins of change for our system (5,10,20,50) is... 2.2. The most efficient system is (5,10,25,60) or (5,10,25,65), tying for first place at 2.05. Unlike the unweildy (1,3,11,37) combo, a (5,10,25,60) seems pretty good to me. I guess Americans aren't as silly as I thought they were for using quarters instead of 20-cent coins.

I alluded earlier to some problems with this whole idea. The algorithm I wrote to generate these results (and presumably also the one the other guy wrote, since we got the same results) sometimes overestimates the amount of coins. For example, if your system is (1,24,40) and you're getting 48 cents in change, the program will assume you're getting a 40-cent coin and eight one-cent coins for a total of nine coins. But really you could just get two 24-cent coins.

I'm going to try to fix the program to find the true minimum number of coins. Until then, here's the program.

Coin Efficiency Calculate-O-Mat v0.1

Labels: ,

Tuesday, August 25, 2009

Newsflash: DVRs rule

It's been a while since I blorged, so I'm going to blawg about DVRs. Basically, getting a DVR is the greatest thing a modern TV viewer can do.

The reason I'm pointing out this highly obvious fact is that a couple of years ago I got a DVR, and it ruled. Then about a year later, it somehow developed some fault, which rendered both the composite video and S-video outputs broken. It still had a functioning component output, but my TV doesn't have a component input, only composite and S-video.

So you see my problem.

Component video has three leads - one for luminance, which is basically a black and white signal, and two for colour information. The crappy solution I came up with was to plug a composite lead into the luminance channel of the component output, and watch things in black and white.

Watching stuff in black and white was all well and good in the 50's, and there are some great films which do not suffer for being monochrome, but it's no way to watch the Simpsons. So it was back to good old-fashioned VHS if I wanted to record anything and be able to watch it later in colour.

So convenient is the DVR that I still used it a fair bit, and put up with the black and white. I have it set up to automatically record most of the stuff I watch each week, in case I miss something I wanted to see. One of the things I've been watching from the DVR a lot in the last few months is the hilarious Canadian sitcom Corner Gas. I've seen so many episodes of Corner Gas in black and white from the DVR, I've started to think of it as a black and white show.

It occurred to me before long that it was probably possible to buy a device that converts component video into composite. I scoured eBay and Google trying to find one with no success. A couple of weeks ago, I finally realised that DealExtreme, that Mecca of all things cheap and nasty, might have such a device. And they did! Having bought other highly useful items from DealExtreme in the past, I confidently bought the video converter. It arrived today, it works, and at long last I can go back to using the DVR without having to pretend I'm some guy in the 50's, waiting two minutes for my huge TV with the tiny rounded screen to turn on so I can watch vaudevillian variety shows. While smoking a pipe.

Labels:


Middlerun's Stuff is best viewed at 1024 x 768 or greater resolution.
This page and all its contents (c) 2006-2010 Middlerun