Blah Blah Woof Woof

Archived content 2005-2007

Please bring me my wine

Posted by Tim Riley Fri, 13 Apr 2007 08:00:00 GMT

If I were a bartender, whenever I’d get bored, I would answer drink requests with “We haven’t had that spirit here since 1969.”

Posted in Tumble | 3 comments

Evenly dividing array elements in bash

Posted by Tim Riley Tue, 27 Mar 2007 20:08:00 GMT

Writing in bash is fun because of the constraints it offers, but I’m never sure if I am choosing the most straightforward way to do things.

A few weeks ago I had to write a script to vacuum a bunch of databases once per week. Instead of doing them all at once, I wanted to evenly spread the load across the seven days.

I wrote something that works pretty well, I think, but it does seem a little hackish, and I’d love to hear if there is a better way to achieve this.

Here’s what I did, check it out:

 # 11 elements in this example
 # Should be processed 2 per day for the first 4 days, then 1 per day for the reamining 3 days
 items=("mario" "luigi" "toad" "peach" "yoshi" "wario" "koopa" "bowser" "lakitu" "birdo" "fryguy")


 # number of the current day, starting from 0
 let "today = `date +%u` - 1" 

 # number of whole that can be processed per day
 let "per_day = ${#items[*]} / ${days}" 

 # remainder of items that must also be processed
 let "remainder = ${#items[*]} % ${days}" 

 # index of array element to start iterating from for the current day
 if [ $today -gt $remainder ]; then
   let "start = (${per_day} * ${today}) + ${remainder}" 
   let "start = (${per_day} * ${today}) + ${today}" 

 # number of elements to iterate over for the current day
 if [ $today -ge $remainder ]; then
   let "count = ${per_day} + 1" 

 # Do it!
 echo "Processing ${count} items." 

 for ((i=$start; i < ($start+$count); i++)); do
   do_something_with_item ${items[$i]}

If you can offer any tips or suggestions, please comment on this entry!

Posted in Geek | 1 comment

Highrise is out

Posted by Tim Riley Tue, 20 Mar 2007 04:53:00 GMT

Check it out. I think this service could be a great leads tracker for our office.

Posted in Tumble, Geek | no comments

Turning 500

Posted by Tim Riley Sun, 18 Feb 2007 11:25:00 GMT

So I’ve been neglecting this blog a bit lately, but I have been posting photos regularly to my flickr page. Tonight I posted my 500th photo!

Hopefully I will resume writing in here more frequently as well.

Posted in Life, Meta | no comments

Volleyball in Melbourne

Posted by Tim Riley Sat, 02 Dec 2006 12:08:00 GMT

I’m in Melbourne this week coachying volleyball in my eighth Australian Volleyball Schools Cup. It’s shaping up to be another fun and exciting (and no doubt tiring!) week.

You can my team’s results on the web, and also look at the results for all of the Unley High teams.

Posted in Life, General, Travel | 4 comments | no trackbacks and copying mixed audio/data CDs

Posted by Tim Riley Tue, 21 Nov 2006 12:29:00 GMT

Here is my first Max OS X tip!

I have noticed some strange behaviour when using to copy a couple of my audio CDs. When it is storing the disc to be duplicated, the progress bar begins to grow steadily, but after a few percent is done, it skips straight to 100% and asks you to insert the blank disc.

This seems to happen when the disc in question is a mixed data/audio CD. Disco seems to only recognise the data session and ignores the audio one (which is the part I want).

To work around this, open up the OS X Disk Utility program (in /Applications/Utilities), and you will see two different mounted entries for your CD. Select the one that represents the data session and choose to unmount (not eject) it. Restrt Disco and then it will be able to properly copy your audio CD. You will lose the data session, but at least you can get your tunes!

Posted in Geek, Music | no comments | no trackbacks

Ikea Tip #1

Posted by Tim Riley Tue, 31 Oct 2006 01:06:00 GMT

<@Mikachu> the screws on my ikea office chair kept falling out, i had to glue them in

<@Mikachu> moral of story: if you buy cheap ikea chairs, also buy glue

Posted in General, Tumble | 5 comments | no trackbacks

Rails, AJAX requests and flash

Posted by Tim Riley Wed, 18 Oct 2006 04:37:00 GMT

My lesson from today: If you are loading Rails actions using AJAX, and your controller is using flash to pass messages to, for example, an RJS view, make sure you use to assign them. This way, they will only stay around for the one action instead of persisting for the next AJAX request or full page load.

Posted in Geek | no comments | no trackbacks

Don't trip up on the first log

Posted by Tim Riley Mon, 09 Oct 2006 13:59:00 GMT

Quick note for anyone moving from Rails to write a little Camping app: It pays to read the instructions! Particularly this part:

NOTE: Camping auto-prefixes table names. If your class is named Blog::Models::Post, your table will be called blog_posts. Since many Camping apps can be attached to a database at once, this helps prevent name clash.

What I would give to get that extra hour and a half back… sigh

Posted in Geek | 1 comment | no trackbacks


Posted by Tim Riley Fri, 25 Aug 2006 07:25:00 GMT

Hans Petter Jansson: ‘I think we should just blow up Pluto.’

Incidentally, who cares about the text books? Wikipedia is up to date!

Posted in Tumble | 1 comment | no trackbacks

Older posts: 1 2 3 4 5 ... 10