WiFi Christmas Tree

Based on an old IKEA JULEN I created a WiFi enabled Christmas tree!

wifi_christmas_tree

The JULEN tree is at least 10 years old, probably older and has been sitting around in storage without seeing much use. The 10W halogen + 2 W AC motor and ancient AC/AC transformer was a major reason. By using some WS2812B pixels and a Spark Core it can now be controlled from anywhere with an Internet connection and uses at most a fifth of the power!

First look at the TinyDuino

A few days ago I finally got my TinyDuino with various shields, it took a while since I had chosen at least one shield that only recently became available. It’s one of the first projects I backed on Kickstarter actually!

This thing really is tiny! Everything so far has worked out of the box, the motor driver shield will require some soldering of pins that were included but no hurry right now. I loaded the default Arduino blink example and it worked fine, so went ahead and downloaded the examples for the LED shield and the accelerometer shield. Something weird in the LED one though, I couldn’t get it to work properly before I added some debug code. Backing out the debug code showed that doing a Serial.begin() call in setup() made it work. No clue what’s going on there, haven’t used Arduinos at all before. With that working it didn’t take many minutes before I simply had to do a little copy & paste operation to create this little demonstration:

Note that I didn’t have any CR16xx coin batteries available, but that a CR2032 fits well enough. :-)

Wayfinder open sourced!

I got involved in a final project at Wayfinder Systems after we got permission to release a majority of our source code as open source. We’ve spent the last months cleaning up code and writing documentation and now it has finally been released! Have a look at the blog post over on the Wayfinder OSS site for more details. In the released code you will find our location based server platform and map & navigation clients for the major mobile platforms.
Vodafone has also published a press release!

I spent most of my time cleaning up and documenting the operations aspect of the server, and this includes releasing a lot of tools and scripts that we used for operating the Wayfinder server clusters but are generic tools. The two most interesting ones are WFConf; a minimal but still powerful Configuration Management tool (but I still recommend Puppet if you want to start using a CM tool) and a web based network kickstart file generator.  WFConf is documented here, and if you’re interested go ahead and look at it in the repository here. There you’ll find the less documented kickstart files as well and there is some sparse documentation you can have a look at.  The kickstart stuff is quite easy to use. You start out with a normal kickstart file and then you cut out the sections you need to vary across different servers and put the snippets  in separate files. You then create new nippets for different configurations, typically things like root passwords, disk partitioning, the post section etc. When you PXE boot your server the kickstart file is fetched from a Perl CGI which looks in a config file to determine which snippets to include for this particular server and pastes them into a complete file which is returned. In the config file you setup defaults and then specify the individual snippet configuration based on the ethernet address of the server. Here’s what it might look like:

%ks_ethers = (
   # defaults
   'default' => {
      'grubfix'      => 'nop',
      'rootpw'       => 'example',
      'partitioning' => 'one_disk_sda',
   },
   # mgmt1
   '00:aa:bb:cc:dd:ee'   => {
      'partitioning' => 'md_raid1_sda_sdb',
      'grubfix'      => 'md_raid1_sda_sdb',
   },
   # node1
   '00:aa:bb:cc:dd:ef'   => {
   },
   # node2
   '00:aa:bb:cc:dd:f0'   => {
   },
);

Combine this with a configuration management tool that setups all of your services and you can have a server with a specific configuration and role re-installed and ready to run in less than 10 minutes

Convenient interactive renaming in zsh

While risking turning this into the renaming files blog I just used another one of my favorite functions that I’ve named iren and realized it could be worth sharing as well. This one is really simple to put together when using zsh. It will allow you to type iren file1 file2 ... and for each file name specified you will get to interactively edit the file name using the normal line editing features in zsh. When you’re done you press enter and the file is renamed/moved. If you haven’t tried it before I can really recommend zsh, it used to be the best shell by far, although bash has caught up on many areas. iren uses the built-in zsh function vared that can be used to interactively edit any environment variable. Here’s the iren function, put it in your .zshrc file:

function iren ()
{
        while [ "$1" != "" ]
        do
                source=$1
                dest=$1
                vared dest
                if [ "$source" != "$dest" ]
                then
                        mv "$source" "$dest"
                fi
                shift
        done
}

Rename files using your favorite text editor

When renaming lots of files you usually resort to your typical for f in … command line with a sed command or similar included, or perhaps you use rename(1) but sometimes it’s just easier if you can use your normal editor. In my case this is vim, where I can then use various nice things such as changes on blocks, or just ad hoc changes to the file names. To accomplish this in an easy way I use an old quick hack; which is the following script that I’ve named viren:

#!/bin/sh

# viren
# Rename files using an editor (vim in this case)

FNEW=`mktemp -t`
FORIG=`mktemp -t`
FCMDS=`mktemp -t`
for i in $*
do
        echo "\"$i\"" >> $FORIG
done
cat $FORIG > $FNEW

vim $FNEW

wcn=`wc -l $FNEW | cut -d\  -f1`
wco=`wc -l $FORIG | cut -d\  -f1`

# go ahead if the line count is the same
if [ $wcn -eq $wco ]
then
        paste $FORIG $FNEW | sed -e 's/^/mv /g' > $FCMDS
        source $FCMDS
        echo Renamed/moved files
else
        echo Aborted rename/move
fi

rm $FNEW $FORIG $FCMDS

Move files to directories based on modification time

Here’s a really simple shell script to move files to directories named based on the modification time of each file. It uses only the date and the script also accepts an optional first argument to set a suffix for each directory. I sometimes use this as a first step when I organize photos and videos, the suffix is set to the source of the files (user-device in my case, eg ckk-40d if it’s from my Canon 40D), I then manually add a short description to the end based on the directory contents. Most commonly applied when I empty the card from my point-and-shoot.

#!/bin/sh

# Put files on command line in one directory per date (based on mtime) with the
# suffix given by the first optional argument on the command line

if [ ! -n "$1" ]; then
   echo "Usage:"
   echo "$0 [suffix]  ... "
   exit
fi

if [ ! -f "$1" ]; then
  suffix=$1
  shift
fi

while [ -n "$1" -a -f "$1" ]; do
  mdate=`stat --printf "%y" $1 | cut -d\  -f1`
  mkdir -p $mdate$suffix
  mv -v $1 $mdate$suffix
  shift
done

Wii – First Impressions

Today my perseverance finally paid off, I managed to get hold of a Nintendo Wii! Unfortunately they were out of extra remotes but at least I got a copy of the new Zelda game as well. After getting everything connected, setting up the wireless network connection and letting the small box update itself I played around a bit with the Wii Shop and the Opera browser, which actually works remarkably well for browsing on a (non-HD) TV.

Then I inserted the Wii Sports disc.

It’s now 2 hours later and I realized that I’m hooked already. Baseball and Golf sucks. Boxing wasn’t as much fun as I thought, but it will probably help if I can figure out the controls properly instead of madly waving the remote and nunchuck in the air and getting smacked in the face by the cable… But Bowling is great and Tennis is brilliant! Normally playing any computer or console games isn’t something I do very often. I have an Xbox but it’s rarely used for anything else than Xbox Media Center (which really rocks BTW), but I definitely enjoyed playing on the Wii! The closest experience to the Wii that I’ve had before is probably Dance Dance Revolution. Someone could create completely insane stuff if they were to combine a dance mat with the Wii remote and nunchuck…

Tomorrow I’ll try to find a copy of Rayman Raving Rabbids and another remote, there seems to be a few of each in stock in some stores close by so I have high hopes. And of course I’ll have to spend some time with Zelda as well, but it might not be until Sunday since Saturday is almost fully booked with other activities.

The Wii concept is so far at least a 9 on a scale from 1 to 10! I have high hopes for Rayman, it seems like it could be quite a crazy multi-player game!