log sampling

A little Perl snippet for sampling a log file (or whatever): grep something myfile | perl -n -e ‘print if $. % 12 == 1;’

testing vs. documentation

I have made some progress on my automatic ipod transfer script The first step is to set Nautilus (that’s the file browser in the Gnome desktop) preferences, since it is the program which deals with automatically mounting media. So in Nautilus->Edit->Preferences->Media I set the ‘Media Handling’ for ‘Music Player’ to run a script of my […]

the step beyond ‘it works for me’

I wrote a new version of my command line twitter client1. It now has coloured output, which helps me read more easily. Also it grabs direct messages and tweets referring to me, as well as the regular friends updates. As with most of the personal software I write, it is some files with links into […]

how to loop by line in bash

ORIGIFS=$IFS; IFS=`echo -en "\n\b"`; for line in $(cat my_list_file); do echo $line; done; IFS=$ORIGIFS

automatic podcast transfer to ipod?

I have an iPod and a PC. When I connect the former to the latter, I would like it to automatically copy over the most recent podcast(s) from a certain directory on the PC, onto the iPod. This should not require any user interaction after plugging in the iPod. The PC is running Ubuntu 9.10, […]

video is best enjoyed on the TV

We recently acquired an Asus O!Play HDP-R1. This is a small box which connects to the TV and the home network so it can play video shared over the network. Since our main source of entertainment is downloaded video, we’d been looking out for something like this for a while, and this one had the […]

random compiz wallpaper

Since I have a growing number of pictures of my baby daughter, I wanted to randomly select some to use as desktop wallpaper. I put a bunch of pictures in my ‘wallpaper’ directory and wrote this script to deal with them. #!/usr/bin/env ruby   require ‘pathname’ require ‘dbus’   $wallpaper_dir = Pathname ‘/home/edward/wallpapers’ $screensize = […]

bash twitter

There are probably lots of variants out there. In fact mine is largely copied from here Inspired by BLT #!/bin/bash # a twitter client (uses .netrc for auth)   confdir=~/.bt seenfile=$confdir/seen feedstyle=$confdir/btfeed.xsl   if [ "$1" == "-h" ]; then echo " use: $(basename $0) -h | [ tweet ]" echo " -h help" echo […]

random dabbling roundup

I seem to be in a phase where I play with lots of new software things without creating a whole lot in any of them. Google App Engine is interesting due to the promise of getting massive distribution/scaling for ‘free’. I started trying to put together a Java application to try it out, but it […]

javascript in the shell

Different languages are good for different things. But unix shell style trumps all. An example: bin/urlencode #!/usr/bin/js   function urlEncode(str){ str=escape(str); str=str.replace(new RegExp(’\+’,‘g’),’%2B’); return str.replace(new RegExp(’%20’,‘g’),’‘); }     if(arguments && arguments.length > 0) { for(var i = 0; i < arguments.length; i+) { r = urlEncode(arguments[i]); print(r); } } else { importPackage(java.io); importPackage(java.lang); S […]