Archive for July, 2005

The sorry state of CD singles

Tuesday, July 26th, 2005

I happened to wander through the tumbleweed-wasteland of music CDs at a Dick Smith Powerhouse today, and something strange had happened to the singles section. The industry used to be able to command around $8 per single (before GST, even) – now every single is $2. What happened? Pressure from downloads, legal and illegal? And yet the whole time I was there, no-one was even browsing the singles section except me…

Bluetooth earpiece

Sunday, July 17th, 2005

I’ve borrowed a bluetooth headset-microphone from a friend to try out with my laptop (skype, ichat, etc). Here it is charging in its USB cradle.

Archiving webcam images

Sunday, July 17th, 2005

I’m using camE as my webcam software. Today I enabled its archiving feature: It can place a copy of every update into a directory so you have a set of archived pics, security camera style. Problem is, if you’re updating every 15 seconds that means your archive gets quite big (~100mb/day), so I wrote a couple of scripts to let cron keep only a subset of the images. Everything is kept for a week, after which only one photo per 5 minute block is kept. Then, after three months, only one photo per half hour is kept (these are kept forever).

These scripts assume you take four pics a minute, otherwise they will keep archives for a different length of time.

Archive after 7 days (run this once a day):

#!/bin/bash

cd /share/webcam-security-pics/current
count=0
for picture in `ls -t`
do
	let "count += 1"
	if [ "$count" -gt 40320 ]
	then
		if [ `expr $count % 20` -eq 1 ]
		then
			#echo "moving $picture"
			mv $picture ../archived/
		else
			#echo "deleting picture"
			rm $picture
		fi
	fi
done

Perma-archive after 3 months (run this once a week, say):

#!/bin/bash

# Keeping the most recent 40320 pics (12 weeks, assuming one pic every 5 minutes),
# archive 1 in every 6 pictures (representing 1 pic per 30 minutes) to the perma-archived
# directory.

cd /share/webcam-security-pics/archived
count=0
for picture in `ls -t`
do
	let "count += 1"
	if [ "$count" -gt 40320 ]
	then
		if [ `expr $count % 6` -eq 1 ]
		then
			#echo "moving $picture"
			mv $picture ../perma-archived/
		else
			#echo "deleting picture"
			rm $picture
		fi
	fi
done

Neuromancer

Monday, July 11th, 2005

But the dreams came on in the Japanese night like livewire voodoo, and he’d cry for it, cry in his sleep, and wake alone in the dark, curled in his capsule in some coffin hotel, his hands clawed into the bedslab, temperfoam bunched between his fingers, trying to reach the console that wasn’t there.

–William Gibson, Neuromancer

Taking chances

Sunday, July 10th, 2005

Have you ever lost sleep wondering about what sort of life-threatening risks are worth taking? Like, “If I was given the opportunity to have $10,000,000 if I submitted to a 1/1000 chance of instant death, would I take it?” Well, I have – so here’s a python script to let you play out this thought experiment:


#!/usr/bin/python

import random

print "Welcome to the death game.",
chance = int(raw_input("Please enter a number representing your chance of death (1/n chance): "))
repeats = int(raw_input("How many times will you do your Dangerous Thing? "))
luckynumber = int(raw_input("What's your lucky number? (1 to " + str(chance) + "): "))

print "1/%d chance of dying, lucky number %d" % (chance, luckynumber)

for iter in range(repeats):
    print "Attempt", iter+1, ":",
    actualnumber = random.randint(1, chance)
    if actualnumber == luckynumber:
        print actualnumber, "! You would have died"
        break
    else:
        print actualnumber, " - you would have been safe"

I knew it…

Thursday, July 7th, 2005

William Gibson digs Star Trek/Buffy crossover fanfic.