RSS feed
  • Welcome

    Posted on December 2nd, 2010 No comments

    Hello, this is where I post content that I want to share. Most of it is simple information about programming problems I've run into. Hopefully there will be more posts about the house that I'm building on the land that we're buying with a new cooperative we're starting in Bloomington Indiana!

  • Carbon Footprint of Plastic

    Posted on January 5th, 2012 No comments

    We've been discussing the materials used in our new house and are pretty set on not using any plastic. However, there are a few key places where it might be extremely helpful so I decided to look into how bad it really is (from a carbon footprint perspective). I am still strongly opposed to having exposed plastic that would off-gas and degrade into the air, but if it is built into the structure maybe I wouldn't mind quite so much. Here are the numbers I can up with:

    • 600 square feet of 6 mil plastic → 100 kilowatt hours of electricity
    • 100' of 3/4" PEX tubing → 45 kilowatt hours of electricity

    This is only counting the manufacture of the materials I believe, not the transport of the finished product. for a reference point, our current house uses about ~120 kilowatt hours of electricity per month. The average home in the US uses about 800 kilowatt hours. This will be helpful in determining when we want to use plastic.

    Sources:

  • service error when starting mongodb

    Posted on August 26th, 2011 2 comments

    I was trying to start mongodb just now and couldn't understand why it wasn't working. Turns out I needed to be sudo - not the most clear error message ...

     
    $ service mongodb start
    start: Rejected send message, 1 matched rules; type="method_call", sender=":1.11
    212" (uid=1000 pid=1360 comm="start) interface="com.ubuntu.Upstart0_6.Job" membe
    r="Start" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart
    " (uid=0 pid=1 comm="/sbin/init"))
    $ sudo service mongodb start
    mongodb start/running, process 1326
    
  • Ubuntu 11.04 on Thinkpad T420s

    Posted on July 17th, 2011 14 comments

    Just bought this thinkpad 420s. The first thing I did when I got it was install Ubuntu 11.04 on it. Most everything worked on first install, including things which many people seemed to have problems with on the forums.

    Working:

    • Displays work fine with 3d effects and everything (dual monitor with and without docking station) (Intel HD Graphics 3000)
    • Built in speakers and headphone jack both work
    • Built-in mic and web-cam both work - I used skype and google hangouts and both worked flawlessly.
    • wireless worked with my open network connection (I haven't yet tried it on secure networks)
    • Bay battery seems to work.

    Not Working:

    • Audio output on docking station
    • Dual Displays sometimes reset to showing the same image on both rather than two seperate displays. This has always been fixed by reseting the settings in the Monitor configuration page.

    I am impressed with how flawless the install was. I was dreading it because last time I did this on my last laptop 4 years ago, I spent a few hours getting everything in working order. So far I have not yet had to do any custom installation. Everything that I needed working, worked out of the box!

    Let me know if you want me to test anything out and I'll try if I can.

  • python onexit

    Posted on July 15th, 2011 No comments

    Was looking for python's equivalent to onexit and found this:

    import atexit
    atexit.register(function_that_will_be_called_before_this_program_exits)
  • web.py: error: No socket could be created

    Posted on July 14th, 2011 1 comment

    This error message most often occurrs when trying to run web.py on an invalid address and port. An example of an invalid address would be example.net, instead of a proper ip address like 98.228.37.242.

    Other Causes:

    Was just trying to get a simple web.py test running:

    import web
     
    urls = (
      '/x', 'X',
    )
     
    class X :
      def GET(self) :
        return 'x'
     
    app = web.application(urls, globals())
    app.run()

    but I kept getting the error:

    error: No socket could be created

    The problem was that due to the way web.py loading works, you need to have the creation and running of the app only occur if this is the main entry point of the program. Otherwise, the class loader in web.py will reload this file again later, and wind up spawning a new server when its intent was simply to load a class:

    if __name__ == '__main__' :
      app = web.application(urls, globals())
      app.run()
  • python random timezone

    Posted on July 11th, 2011 No comments
     
    import random
    import pytz
     
    pytz.timezone(random.choice(pytz.all_timezones))
     
  • python-memcache is thread safe

    Posted on June 30th, 2011 No comments

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

     
    try:
        # Only exists in Python 2.4+
        from threading import local
    except ImportError:
        # TODO:  add the pure-python local implementation
        class local(object):
            pass
    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

    fyi
  • PiCloud Simulation: OSError: [errno 13] permission denied

    Posted on June 22nd, 2011 No comments

    I tried running a PiCloud simulation on Ubuntu 10.04 on linode and got the following error:

    OSError: [errno 13] permission denied

    I found the solution here:

    add the following line to your fstab and reboot:

    none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0

    If you don't want to reboot, a temporary fix might be:

    sudo chgrp $GROUP /dev/shm
    sudo chmod g+w /dev/shm

    That last part might not be the best way to do it, but it worked for me.

  • python: parsing the output of datetime.isoformat()

    Posted on June 21st, 2011 No comments

    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 = datetime.datetime.now()
      assert parse_iso_datetime(d.isoformat()) == d
      d = datetime.datetime.now().replace(microsecond = 0)
      assert parse_iso_datetime(d.isoformat()) == d
     
  • TP-Link TL-WN722N on Ubuntu 10.04

    Posted on May 13th, 2011 15 comments

    Note: according this guy this set of steps also works for Fedora 15.

    I had a lot of trouble getting this card to work. Here is how I finally got it.

    I am running 2.6.32-30-generic-pae #59-Ubuntu SMP
    running "lsusb" shows the following line for my device: 0cf3:9271 Atheros Communications, Inc.

    I tried a bunch of different compat-wireless versions and this one finally did it. At the time, it was the latest stable release. The daily snapshots were causing kernel panics ... Download it, decompress it and build it:


    $ tar xvf compat-wireless-2.6.38.2-2.tar.bz2
    $ cd compat-wireless-2.6.38.2-2
    $ ./scripts/driver-select ath9k_htc
    $ sudo make
    $ sudo make install

    I had to download version 1.2 of htc_9271.fw the firmware from here and copied the file to /lib/firmware.

    I was getting wlan%d instead of something reasonable like wlan0. Running sudo ifconfig wlan%d showed me the mac address which I could use to add an entry to /etc/udev/rules.d/70-persistent-net.rules. Heres the entry I added: (note that the browser adds newlines here, but you should add just two lines: one for the comment, and one for the rule)


    # USB device 0x0cf3:0x9271 (usb)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:e6:fc:94:91:35", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan2"

    reload the drivers by running:

    sudo modprobe ath9k_htc

    Now plug in the device. There were a lot of other steps that I followed while trying to get this to work, so I may have left something out.