Strange Loops

No Matter Where You Go, There You Are

Moving to Clojure 1.1

| Comments

I'm not using the 1.1 features yet but I was planning on it. During the upgrade to clojure 1.1, I broke my emacs, slime and clojure setup. That's a good thing since the process has simplified since the last time I did it.

Here's what I did on my Mac (running Leopard). Git is a requirement. I installed mine through MacPorts.

First, I got myself an emacs starter kit. Since I'm using aquamacs, I went with an aquamacs variant of the starter kit. Aquamacs Emacs Starter Kit vs Emacs Starter Kit . Follow the instructions for installing the appropriate emacs starter kit. It should look something like this:


In this process I learnt a little about Aquamacs. The dot emacs file aka ~/.emacs  are read after the preferences that are under  ~/Library/Preferences/Aquamacs Emacs. Since I mostly used Aquamacs for hacking clojure, I didn't care and nuked all my emacs preferences. Your mileage may vary. Afterward your Preferences.el file should look like this:

Restart Aquamacs to ensure the new preferences get taken.

One of the important things the Emacs Starter Kit installs is the package manager for emacs (aka elpa). I used elpa to install the swank-clojure package. The starter kit also defaults Aquamacs to green text on a black background (changing that is left as an exercise to the reader).

You don't need to but I wanted to check out the packages available to be installed. The M key below is the meta key which on my Mac is bound to the Option and Esc key. Your key bindings might be set up differently but I would try the Option or Esc key to start with.


This is what the package list looks like.
To install a package, I used the package-install command.


You'll be prompted for the package to install.

You'll see some text scrolling by in a buffer. It looks like various emacs lisp files are being compiled. I got some errors. I ignored them. It seemed alright.

Once swank-clojure is installed, it's time to install clojure. To do this, I started up slime.


You'll get prompted about clojure not being installed. You want to say yes here.


You'll see some status messages about clojure getting installed. For reference purposes, this process installs clojure, contrib and swank clojure jars in ~/.swank-clojure Voila_Capture27  

Once that's completed, restart Aquamacs and type   'M-x slime' . You should now be ready to hack clojure code.

If you need a custom classpath, you'll need to set the  swank-clojure-classpath variable. I created a directory containing all my jar files (in ~/.emacs.d/clojure ) and have all the jar files there available in my slime session. To do this, my ~/.emacs file contains the following lines:

(setq swank-clojure-classpath 


       (directory-files "~/.swank-clojure" t ".jar$")

       (directory-files "~/.emacs.d/clojure" t ".jar$")))

This approach of globbing jar files together is simple and pretty effective. Alternatively,  leiningren appears to be the new hotness in terms of managing clojure dependancies. It's something I'll look at in the future.

Homemade CCTV System

| Comments

A couple of months ago, I started researching putting a homemade CCTV system on the cheap. I picked up a D-Link DCS920 Wireless-G Internet Camera to use as the initial prototype camera since it was the cheapest wireless camera I found. 

The first approach I took was to setup an Ubuntu 9.10 box and install ZoneMinder. Ubuntu 9.10 has the ZoneMinder packages in the repository so installing it was not hard. There were some additional steps that I found here to get it up and running. On a scale of 1-10, getting ZoneMinder to run was a 6.5.

The trouble I faced was configuring cameras once ZoneMinder was running. ZoneMinder is a full featured application and multitude of configuration options was intimidating. I got it to run in a motion detection mode (where it will capture moving objects in the video stream) but was not satisfied with how fast it was capturing video. This was probably no fault of the software. The Ubuntu box was older box and may not have been able to keep up. 

At this point, I was going to put this project on the backburner until I read a post on lifehacker. The Mac Mini that we use as our media server sits idle for parts of the day when we want a CCTV system in place. Thus there was no additional hardware costs. The resultant performance of the video capture with the Mac Mini was also leads me to believe that the Ubuntu box was too slow. The AMD CPU on the Ubuntu box is a couple of generations old where the Mac Mini has a more modern Core 2 Duo.

One nice feature of Vitamin D was the streamlined camera configuration process. It was able to auto detect the DCS920 wireless camera on our network and after clicking the "Continue" button a couple of times, we were ready to go.

By default, it records everything to the hard disk. It was straightforward to configure sending images of people to my email account.

The starter edition is free and so it fits perfectly into our budget. In the future, we might add additional cameras to our system (they have a compatibility list!) and upgrade to one of their more full featured editions

ActiveMQ Gotcha!

| Comments

We were doing a trial deploy of our brand new java service to the production host yesterday. The service had started up everywhere else so far

Of course it didn't start up on this production host. In the logs was a stack trace that included this error message:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'amq:broker'.

What caused this problem? This production host was firewalling off connections to This host was serving a XSD file which was required to validate the XML namespace we have used.

I'm thinking WTF! Seriously? Why wasn't the XSD file deployed with jars?

The simplest solution/workaround was to take and make it in our XML file. When validating the XML file, it'll use a version of the file available within the activemq jars.

Dropping the version causes Eclipse to complain but that's another problem (and another google search).

Compiling Jython Scripts to Java Class Files

| Comments

Had this little snippet of code lying around my directory.

Didn't know what to do with it. It was somewhat useful. We were trying to compile unit tests written in jython for our java code. The jythonc tool had gone away in jython 2.5 but an ant task (JythoncAntTask) in 2.5 still did that. I did a little bit of code spelunking and extracted the code snippet seen above. I don't know the reasons for removal of jythonc but I suspect this usage is not generally supported by the jython maintainers. Please don't complain if this doesn't work for you. We went with another approach for getting our jython unit test to run.

One should be able to compile it from the command line. You'll need the jython.jar to compile it. To run this against a jython script, I threw together a little shell script.

This post was also a little experiment in embedding code samples into my blog posts. The trick is the script tags provided by gist do not work with the preview/rich text mode provided by typepad. They only work after the blog entry has been published. Other than this little gotcha,  Gist is a nice tool for collecting code snippets.

Netbook Part Deux

| Comments

Over the holidays, I got myself a Lenovo IdeaPad S10-2. Initially the plan was to make it into a Hackintosh but since I got the machine working well I've decided to not go that route. Right now, I'm very pleased dual booting Windows XP with the Ubuntu 9.10 Netbook Remix. 

I was an early Netbook early adopter. I purchased an Asus EEE in Feb 2008. One of the first entries into the Netbook market. We were going to Maui for a week and the EEE seemed like a great travelling companion. The small form factor made it easy to pack and the low cost made the potential lost on the trip more acceptable.

However after the trip, I'm promptly sold it. The Asus EEE and Lenovo IdeaPad have roughly the same dimensions but the deal breaker for the Asus EEE was the tiny keyboard. There were fairly large speakers (in relation to the rest of the EEE) to the left and right of the keyboard. This made the keyboard even smaller than it had to be. The IdeaPad does not have the same issue. Though smallish, I'm fairly comfortable touch typing this entry on the IdeaPad's keyboard. 

By default, Windows XP is installed and required for any future servicing or restoring to factory condition. I'm more of a Mac and Linux person so I had to find tools/applications to make Windows acceptable and integrate with my other equipment. I'm pleased with what I've found and actually find the experience relatively painless.

1. Removed the antivirus program

I should not do this but after uninstalling the Norton antivirus program, the IdeaPad experienced a fairly nice performance boost. I don't use IE or Outlook so most infection vectors are closed off. I still have to be extra careful about what I install on this machine though.

2. Chrome and Firefox

I was impressed with my brief usage of Chrome in early 2009, it was fast and I liked its sandboxing architecture that made it resistant to attacks (see this). On the IdeaPad, it's my default browser. 

Firefox is also installed because they are too many useful Firefox add ons. I have to say the 3.6 version has been pretty good on my Mac. For day to day browsing, Safari used to be noticeably faster but I don't notice a difference anymore.

3. xmarks

xmarks is a bookmark synchronization tool. It synchronizes my bookmarks across my browsers on all my machines. When I had one machine, I never understood the use of xmarks. With multiple browsers and machines, I love having the ability to manage all my bookmarks from one central location.

4. Dropbox

I use dropbox for sharing and synchronizing files across my multiple machines. It also version files that you put into it (effectively serving as a backup). Any documents I'm working can be accessed from any of my machines.

5. Evernote

I use evernote for managing my notes across all my devices. 

6. Notepad++

notepad++ is a huge improvement over the regular notepad. Has a bunch of useful programming specific features (e.g. line numbering, syntax coloring) and does not have a problem with unix style line endings (where the regular notepad puts the entire file on a single line)

7. Ubuntu 9.10 Netbook Remix

Used Wubi to install Ubuntu. Sometimes I just need access to Linux. No repartitioning of the hard drive is necessary. Wubi installs Ubuntu on the windows partition of the hard drive (at the cost of slower disk performance which doesn't really matter in this situation).

8. Python

It's what I use these days for small projects. In the past, I liked Strawberry Perl and I would used it again if the need arises.

You'll also want easy_install to get new libraries.

9. Git, Putty

I need access to my git repositories since that's where my code is. Used TortoiseGIT (and it's dependency msysgit) for that. Works great for my simple usage. No major complaints. 

putty is the only game on windows for ssh'ing into my remote hosts.

3 + 4 + 5 + 9 form a common theme, they are tools I use for managing information/code I collect.

10. miro, songbird

For listening to podcasts and other digital media. This is one area I need to work on more. Figuring out how to access the digital media stored on my other computers.

11. External mouse

I've never liked trackpads so an external mouse eases that frustration. Nothing complicated. Just got myself a cheap (< $20), wireless optical mouse. This one fits the bill pretty well.

My New IPad

| Comments

My new IPad

The Lenovo I dea Pad S10-2 that I picked up on my trip to Singapore at the beginning of December. This one is a wifi only version. There is a 3G option available (based on what the user manual tells me). I've regularly taken this handy little device to the coffee shop whenever I want to catch up on my RSS feeds. The 10 inch display and regular keyboard make web browsing easier than on the iPhone. It evens come with a cute little pink carrying case.

This IPad is not be confused with  this . :)


| Comments

On my long run yesterday, I was able to reflect on the events from the last seven days. I was trying to understand what this experience would teach me. This has been a major wake up call. 

I thought through a lot but I kept coming back to 3 main ideas:

1. Life is too short to be anything but happy.

2. Someday might never come. 

3. What we leave behind is not as important as how we've lived.

It's not clear how I'll use these ideas since my mind is still in a fog of sadness, anger and fatigue. Hopefully the next couple of days will help to make things clearer.


| Comments

I’m numb tonight. I keep thinking about what has happened in the last day. I kept coming back to this quote spoken by one of my favorite fictional characters:

Someone once told me that time was a predator that stalked us all our lives, but I rather believe that time is a companion who goes with us on the journey and reminds us to cherish every moment because they’ll never come again. What we leave behind is not as important as how we’ve lived. - Jean Luc Picard, Generations