ruby rescue error message example

raise "this is an error message"
rescue Exception => e
# prints "this is an error message"
puts e.message
# or if you want the entire error message with stack trace and all:
puts "failed sending weekly power usage to house: #{$!}"

Retrospective on Concrete Foundation

One large pollutant in our house design is in the foundation. We ended up pouring around 13 yards of concrete due to the large elevation change from North to South. If the site was more flat, we could have used far less. 13 yards of concrete comes out to about 10 cubic meters and a similar carbon footprint to 2 months worth of electricity use of an average US household [1,2,3] or a bit more than a years worth of electricity for a very efficient house like we are hoping to achieve. That is a pretty significant source of pollutant.

We could have used less concrete if we had steped our foundation down with the slope of the building site and put 2 or 3 levels on our first floor, as our neighbor Danny is planning to do. We could have also chosen a more flat building site, or used a different construction method which used piers instead of a solid foundation around the perimeter. On the plus side, using a rubble trench foundation instead of a slab (as most homes are built these days) saved meant we used 3 times less concrete than that method would have required.

Admittedly CO2 emissions aren’t the only thing poluting the atmospehere so a comparison between electricity and concrete curing isn’t really fair. Coal emits lots of other nasty things and cement used in concrete can too, depending on the purity of the ore in use. It is difficult to find hard data about the pollutants from each and they differ from plant to plant.

This has made me want to do a carbon footprint analysis of our entire house to see how it all compares. I’ve already done it with some things … to be continued

See Also: The Carbon Footprint of Plastic


cubic foot of concrete → 9.56 kg co2 → 25.8 kwhr → 88000 BTU of electric heat
coal co2 emissions: 0.37 kg / kwhr



It was great to take a night off and relax with Shaina and Tulsi tonight. I feel like I’m winding up my rubber band of motivation more and more every minute I spend time with them. It’s hard not to keep thinking about it, but I think some subconscious slow thinking will probably do us all good.

I’m very excited to start posting more regular updates on our house design. Especially how certain design decisions were made, and all of the reasoning behind them. Good pictures of each step will be great to have. If anyone is going to be building houses with the CEB Press in the future, it would be nice if they didn’t have to figure out all of the same things that we did.

Perhaps a better format for all of this would be a wiki, rather than a blog or a blog that I edit like a wiki perhaps …

Adding pictures to the site should be easy. Its not quite there yet, though I guess it kinda is …

Raspberry Pi Timelapse Camera

Some steps I took to build my Raspberry Pi Timelapse camera:


The location of the timelapse camera puts it about 400 feet from the nearest building with electricity, so I figured it might make sense to put it on solar power and a battery, but it turns out to be prohibitively expensive. Even by piecing together a system myself from panels on ebay, car batteries, a home made controller, etc, it was still going to wind up costing at least $400. 400 feet of 12/2 cable is only around $120. Also, in a year or two, the electricity run will be shortened by a new power service installed near by. So for power, I am just going to run some cable from the house. There will be some voltage drop, but that shouldn’t be a problem, it won’t be much.


I spent a long time trying to figure out what kind of enclosure I should build or use to hold everything. I wanted something that I could open and close relatively easily (in case I needed to repair it). Turns out the easiest thing to use was a 8” x 8” x 4” junction box I found in the electrical section of a hardware store. It is much bigger than I needed, but it was the smallest I could find that would fit the raspberry pi with a cable sticking out both the USB port and the power port, which comes out to about 8”.


The camera I am using is a Nikon S3000. I made sure that it was in the list of cameras supported by gphoto2. Unfortunately, I wasn’t able to use the build of gphoto2 that is in the debian package manager because it is too old, so I downloaded and built the latest versions of libgphoto2 and gphoto2 from source.


I wrote a basic python script which will take pictures every 5 minutes. But then, for some reason on the raspberrypi, I’ve been having trouble controlling the camera. Every few commands I send to the camera, the usb connection fails. I have to issue a usbreset to get it back working, so I added some code to do that automatically before running every command. Also added some code to only take pictures during the day (in Bloomington, Indiana) which uses a nifty library which will give sunrise and sunset times for any day given a latitude and longitude.

All code is open source and available here.


I’ve mounted the camera to a small piece of scrap plywood and the plywood to a tree, with the camera facing both of the building sites that we are working on this year

What is the one feature you see as missing?

Rails Headers

You can access header values from rails from the request.env hash. request.env contains a lot of other non HTTP header values. The header name is a bit transformed too:

  • prepended with HTTP_
  • converted to uppercase
  • dashes converted to undersocres
  • … more?


curl -H 'x-custom-value: foo'

can be accessed in rails with:


python: parsing the output of datetime.isoformat()

I couldn’t find this explicitly anywhere, so here it is. A function to parse a string which was generated by datetime.isoformat()

import datetime

def parse_iso_datetime(str) :
# parse a datetime generated by datetime.isoformat()
try :
return datetime.datetime.strptime(str, "%Y-%m-%dT%H:%M:%S")
except ValueError :
return datetime.datetime.strptime(str, "%Y-%m-%dT%H:%M:%S.%f")

# and a simple test case
def test() :
d =
assert parse_iso_datetime(d.isoformat()) == d
d = = 0)
assert parse_iso_datetime(d.isoformat()) == d

python onexit

Was looking for python’s equivalent to onexit and found atexit:

import atexit

python-memcache is thread safe

python-memcache is a thread safe library. In, which is the single source file, you’ll find:

# Only exists in Python 2.4+
from threading import local
except ImportError:
# TODO: add the pure-python local implementation
class local(object):
class Client(local):

Which means that all data accessed through self.variable_name have values which are thread specific (as long as you are running python version 2.4 or higher.) Very cool. Before I looked at the code, I wrote some multi-threaded tests to check and see if anything fishy would happen. I’d say looking at the code is a better solution.

more details threading.local



Axpress is an ongoing experiment in the design and implementation of a query language for not just the worlds information but your own information, all other information and information yet to be generated. I have a demo running on my laptop, but have not yet got a public demo running. there will be one soon.


fftknn learns to recognize any sound, vowel or pitch you teach it and associate it with a MIDI signal. Later, (in real time) when it hears similar sounds it will trigger the learned MIDI signals. (December 2008)


Allows users a view into the relationships between words found in blog posts around the web. What other words are commonly found in posts containing Obama for example. Or, how many negative adjectives like terrible, bad or gross appear in posts with the word linux compared to positive words like great, exciting or incredible? (Fall 2007 Class Midterm Project)


Understand basic commands and queries. An advanced form of regular expressions are used to match queries and understand what the user wants. For more information, see this paper, or visit the demo. My semi-organized notes that I took while working on this project can be found on my wiki here. (Fall 2007 Undergraduate Independent Research Project)


MMM is a graphical programming environment to create device graphs representing information flow through the system. Very similar in concept to Yahoo Pipes, Reaktor, MaxMSP, PD, or any modular synthesizer. Some devices create data such as a MIDI input device, keyboard or an RSS feed which can then be piped through any number of devices in any order, all realtime. Unlike many other implementations based on this idea, there is no strict data typing; The Lua tables are used to transmit data, with standards for all basic types like numbers, strings, lists, arrays, hashes, advanced data structures, etc. I hope to have a screen cast up showing the capabilities soon. (hobby project Summer 2007)

See also: LuaMIDI - A library I wrote for the Lua programming language providing MIDI I/O functionality. (Linux, Mac, Win)


1st Prize winner of Greener Gadgets design competition! (see video and interview)

The EnerJar is an easy-to-build device that accurately measures the power draw of electrical appliances. The user plugs the EnerJar into any three-prong wall outlet, and a device into the outlet on the EnerJar. It is our goal that users of the power meter will gain an understanding of power draw and use this knowledge to effectively reduce their electricity use. (hobby project Jan 2008)

Dream Clock

The Dream Clock has been modded to appear as if you are still dreaming. It is said that in dreams, it is often difficult to read small characters and text, or if you can, they change each time you read them. This clock used to be my alarm clock. The confusion created when you wake up, and try to read this time is indescribable. Inspired by Waking Life which first interested me in the dream state and lucid dreaming.

RTS Engine

This very simple RTS engine was a hobby project of mine back in high school as an expirment in real time 3d Rendering with DirectX. I’ve been recently getting excited about OpenGL and real time rendering again and look forward to revisiting this field.


ZDGP is a genetic programming library for Lua. This code is quite old, so I don’t have it on the web, but this was quite a strong interest of mine at the time. A friend of mine was making tons of money in the stock market and I wanted a piece of the action. The only programs I was able to evolve that might have been competitive required no transaction costs because it traded so often. I eventually decided that playing the stock market wasn’t something I really felt was worth my time. (2004)


And an article I wrote quite some time ago: SSE2 for Dummies (who know C/C++) (Summer 2003)