Main page

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

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: ,

Sunday, May 17, 2009

Spag dogs

A week or two ago I came a cross this blog post about poking spaghetti through frankfurters (hot dogs) and cooking them (more pics here). I had to try it.

Uncooked spag dogs.

Cooked spag dogs.

Close up spag dogs.

I call them spag dogs. Amazingly it was actually pretty bad, but I think that was only because I didn't cook them long enough, so the spaghetti inside the frankfurters was barely cooked. I'll probably try it again, but I'll cook them longer and maybe put some tomato sauce on them.

Labels:

Saturday, January 31, 2009

New animation!

It's finally here: the animation I've been working on for the last seven weeks or so is at last complete. I present to you:

Launch Code

Labels:

Thursday, December 11, 2008

Control room

Here's a sneak preview of something I'm working on. It probably won't be ready for a while (weeks, maybe months) because there's a lot to do. But it's going to be awesome when it's finished.

Clicky for full size.
The control room

Labels:

Sunday, August 31, 2008

Drawage

there's a couple of new items on my sketch blog Mod Rocker. One is a comic, the other is just scary. This weekend I was gripped for no apparent reason by an urge to draw. I drew some other things which are in various stages of completion, including a comic I'm not sure I should post because it is just gross. I'm slowly starting to realise that if I stop trying so damn hard to get every line just perfect, things still end up looking pretty decent (or even better than they would otherwise) and I can draw like ten times faster, resulting in things that actually get finished instead of abandoned a quarter of the way through.

Labels:

Sunday, January 27, 2008

Duality

A few nights ago I decided to make a movie. Like most of my best work it was totally on a whim. So I got out my video camera and got to it, basically as an experiment in unplanned, scriptless, one-person film making.

It took about four hours to shoot, between 11 pm and 3 am (plus two small shots I had to re-do later). I edited it in a program called Kino, which took ages but I'm pretty happy with the result. All the gore effects were done with tomato sauce, of course. I credited myself with camera work but really most of the credit should go to various household tables, chairs and shelves.

Labels:

Tuesday, October 30, 2007

Der Keyboard

For some reason, in the last couple of weeks I've become very interested in keyboards. Not musical ones (though I want one of them too), but the QWERTY variety. For years I've been using the stock-standard rubber-dome keyboard that came with my computer, but an article has intrigued me about the prospect of using a buckling-spring keyboard like IBM's classic Model M. They're non-existent on eBay, except in America, and they're too heavy to ship from the US for less than about $60. I found some 122-key monsters on there, which look pretty leet, but they're not buckling spring, despite the listing's dishonest implications. I'd probably buy one anyway for the hacker cred, if not for the weird, gaming-unfriendly cursor key layout. The search continues.

Thinking about this reminded me of the fact that I still can't touch type - well, I sort of can, if you call 14 WPM "typing". So, inspired by Das Keyboard's supposed ability to force people to learn by preventing them from looking at the keys, I've painted my keyboard all black. It looks pretty cool, if a little emo. I also downloaded TuxTyping, a touch typing practice program. It's aimed at kids, but it should help a lot anyway.

Maybe in the holidays I'll do something like this. If only I had the necessary tools and stuff. Oh well, I'll think of something.

Labels:

Monday, August 13, 2007

Are you colourblind?

Take this easy test and find out!

Are you colourblind?

I'm going to make this into a T-shirt.

EDIT (20/10/07): So it turns out that this has been done before. I guess there really aren't any original ideas left in the world. Drag.

Labels:

Thursday, June 28, 2007

Speed studying

When I was studying for exams I decided to set up my camcorder to record a quarter of a second every 15 seconds, for a whole day. Then I got the footage, sped it up 2x and annotated it. Here it is:

Labels:

Thursday, May 24, 2007

ModRocker.net - my new sketch blog

OK guys so a couple of weeks ago I registered the domain www.modrocker.net, and didn't know what to do with it. Now it is the address for my my brand new, never-before-seen sketch blog, ModRocker.net. So, you know, check it out. I've been drawing a lot lately but I couldn't really be bothered digitally inking everything like I have been for Kenso Tech, so I guess I'll mostly just scan pencil drawings for ModRocker. I'll still do some stuff on the computer though.

I've stopped making the Kenso Tech comics, and they're now on the ModRocker site along with some other goodies.

Labels:

Sunday, April 15, 2007

Pac-Man returns

As one of the first additions to the Moved and Improved™ Middlerun's Stuff is a mirror of an old website of mine, Pac-Man Dots. It is accessible from here.

In other blogular news, I went kayaking today, over near Roseville. It was good fun. Speaking of things ending in "king", I saw an awesome guitarist on TV today called Kaki King. She uses heaps of fret-tapping and stuff to make a cool percussive guitar sound. Videos here. While I'm giving unsolicited music recommendations, you should check out Balthrop, Alabama. You can download their album for free, so you have no excuses.

Labels:

Saturday, April 14, 2007

Middlerun.net!

I've finally broken free of my crappy ad supported account at Sphosting and moved my site to a new and superior host, NearlyFreeSpeech.NET, and registered a fancy new domain name, www.middlerun.net! I wanted www.middlerun.com, but apparently it's taken? So I was pissed off about that, but I guess there's no shame in using the .net TLD (after all, my new host uses it!). Incidentally, middlerun.org is some kind of church preservation association.

I've also done some work to make better use of CSS, so I can easily change the site appearance if I want to. I haven't upgraded the THC pages yet because it will take ages, so it's not up on the new site yet but it's still available here if you really want to see it. THC is up now.

And all this while I should have been studying. Oh well.

Labels:

Monday, April 02, 2007

The original Victor Pond blockbuster

Here it is in all its glory, coming at you from 2002, Don't Forget To Die!



More info here.

Labels:

Tuesday, February 27, 2007

Kenso Tech: the name of my new comic?!?!

I've started a comic in which I will chronicle my adventures through tertiary education. It's called Kenso Tech and is located at http://kensotech.blogspot.com/

I'm planning on updating pretty frequently, but then, that's what I said about my other comic, The Hallucinogenic Cookbook, and I've updated that precisely twice in the last three months. Initially at least I want to put up at least one strip per week, hopefully more.

THC isn't officially dead, but don't hold your breath for new THC strips in the foreseeable future. Also, posts here may decline but I'll avoid posting non-uni-related stuff with the new comic, so I'll still blog stuff here.

TO RECAP: Read read read.

Labels:

Sunday, February 25, 2007

From Yugoslavia With Love trailer

I've finally edited the footage for From Yugoslavia With Love into something entertaining. Here it is!

Labels:


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