Super Happy Dev House

May 2nd, 2006

The new work

Attended my first Super Happy Dev House on Saturday night and had a great time. The house was packed with energetic people devoted to getting stuff done. Even though most of the people were strangers working on their own projects, it was really motivating to be surrounded by so much activity.

My project was getting boost.python working on my iBook. I wasn’t able to stay all night and didn’t reach my goal*, but I did learn about iPython from the people sitting next to me. Someone (not sure who) had designed a great poster for the event and they had printed up stickers & pins so there was even some schwag. I’m looking forward to the next one.

* My problem was I was trying to use the boost packages from fink. Turns out they delete a bunch of the files you need to use bjam. The answer? Download the source directly from boost.org (not sure why I didn’t think of that right away, actually). Mission accomplished.

Find new music: a song a day calendar

April 18th, 2006

So, here we are 108 days into the year and if you haven’t found some new music this year, it is time you check out CC365. It is a song a day calendar featuring exclusively Creative Commons music. Grant Robertson is doing a great job picking a wide selection of tunes: Jazz, electronica, j-pop, hip-hop, country, you name it. And since the artists encourage you to share their music, they don’t find themselves in the awkward position of suing their fans, grandmothers, and 12-year-old girls or installing hacker’s tools on your computer.

Free Music Daily - Indieish.com

Perplex City

April 17th, 2006

Last month, TR bought a Perplex City starter kit for my wife and I. What a cool game! There are so many levels you can play at. You can solve puzzle cards by yourself. You can join up with others online and solve cards together (including some really hard cards requiring group efforts). The city itself has a lot of depth, with record companies, pharmaceutical companies, schools, blogs, and newspapers. Some of these “companies” run ads in London newspapers, and puzzles from the game have shown up in newspapers and magazines. Finally, you can hunt for the stolen cube and try to get the $200K reward.

Many of the puzzles make fun programming challenges. I’ve been doing them in python, since that is such a great language for rapid programming. Sweet Dreams (#85) makes an obvious candidate:

#!/usr/bin/env python

a = 1
b = 1
while a < 400000:
    c = a + b
    a = b
    b = c
    print c

My wife solved Rickety Old Bridge (#106) much faster than I was able to write the program (although the program found that there are two similar solutions, not just one). This was a good one to learn generators with:

#!/usr/bin/env python

class bridge:
    people = { "kurt":2, "scarlett":5, "violet":1, "sente":10 }
    states = [ {"near":people.keys(), "far":[], "moves":[]} ]

    def move(self, source, dest):
        """ yield all new states formed by moving
            a person from source -> dest """
        for state in self.states:
            for person in state[source]:
                yield {source:  [s for s in state[source] if s != person],
                       dest:    state[dest] + [person],
                       "moves": state["moves"] + [person] }

    def to_far(self):
        self.states = [s for s in self.move("near", "far")]

    def to_near(self):
        self.states = [s for s in self.move("far", "near")]

    def score(self, state):
        times = [self.people[name] for name in state["moves"]]
        total_time = max(times[0], times[1]) + times[2] + \\
                     max(times[3], times[4]) + times[5] + \\
                     max(times[6], times[7])
        return total_time, state["moves"]

    def print_scores(self):
        scores = [self.score(s) for s in self.states]
        scores.sort()
        scores.reverse()
        for s in scores:
            print s[0], s[1]

    def run(self):
        self.to_far()
        self.to_far()
        self.to_near()

        self.to_far()
        self.to_far()
        self.to_near()

        self.to_far()
        self.to_far()

        self.print_scores()

if __name__ == "__main__":
    b = bridge()
    b.run()

The program I came up with for solving Magic Square (98) takes a long time to run but eventually starts finding candidate solutions about 2.2 million squares into its search:

#!/usr/bin/env python

def comb(nums, n):
    if n == 0: yield [], nums
    else:
        for i in range(len(nums)):
            for tail, remaining in comb( nums[:i] + nums[i+1:], n-1):
                yield [nums[i]] + tail, remaining

def rows(nums):
    if not nums: yield []
    else:
        for row, remaining in comb(nums, 4):
            if sum(row) == 34:
                for other_rows in rows(remaining):
                    yield [row] + other_rows

def check(grid):
    magic = True
    for i in range(4):
        if sum([row[i] for row in grid]) != 34:
            magic = False
    if sum([grid[i][i] for i in range(4)]) != 34 or \\
       sum([grid[i][3-i] for i in range(4)]) != 34:
        magic = False
    return magic

count = 0
for grid in rows(range(1, 17)):
    count += 1
    if count % 100000 == 0:
        print count / 1000, "K"
    if check(grid):
        print grid

Throwing tops

April 1st, 2006

18th century toys? Help me, Internet

Several years ago I got an old-fashioned wooden throwing top for Christmas. Unfortunately no one in my family knew what do with it. We couldn’t figure out how to get it to spin, so it went into the back of the closet. TR’s post about yo-yo videos finally made the light go on: The Internet knows…

Sure enough, there are sites with video tutorials showing how to throw tops.

I never would have figured it out on my own…you wrap the string around a different part of the top than I was trying, and you throw it upside down (it flips over in the air). This is the kind of thing that makes the Internet more valuable than a library to me. Sure, I probably could have researched these tops at a library and gotten an instructional video through interlibrary loan. But not in 15 minutes.

Effort Threshold

April 1st, 2006

I’ve noticed something: If frequent tasks take too much effort they don’t get done. Unless it is dirt simple, people procrastinate. It’s as if there is an effort threshold. Easy tasks slip under the threshold and get done. Involved tasks…well…maybe we can start on them tomorrow.

I’ve seen this happen with all sorts of things:

  • Running unit tests: If it takes more than a single command or button-press to run tests, developers will only run them once a project. If you’re lucky.
  • Committing code: if your check-in process has too much red-tape, developers avoid checking in. Result? You might as well not be using version control.
  • Paying bills with checks instead of online: Putting checks in envelopes? Maybe tomorrow.
  • Editing digital photos before posting them to Flickr: I still don’t have a smooth enough workflow so photos sit on my computer unprocessed for way too long.
  • Writing blog posts: And now we get to the real point of this post…

Posting to Blosxom took just a little too much effort. TR posted some articles back in November and December I wanted to respond to, but I haven’t gotten around to. Admittedly, this was partly my fault because my CoolURI scheme added a few extra steps to posting. I like Blosxom and it was great software for starting out but it was time for something with more features. So, I switched to WordPress. The out-of-box experience is great:

  • simple installation
  • web-based interface for posting
  • web-based configuration interface
  • Larger user base so plugins and themes are plentiful
  • comments
  • pages load a lot faster than before (again, my fault because my CoolURI plugins slowed Blosxom down)
  • tags (well, categories but you can use them like tags if you like)

So, let’s see if this allows blogging to slip under the effort threshold again…

Flickr Account

June 26th, 2005

I finally signed up for a Flickr account (http://flickr.com/photos/zovirl), and I was impressed with their interface. It is very clean and simple, so it is really easy to get started. The people running Flickr seem genuinely cool. As a quick example, the 3rd link on their help page is to an offsite list of tips for beginners. Offsite links on an “official” page are a good sign of a company that really wants to work with their user community, in my opinion.

Changing Permissions in Subversion

June 22nd, 2005

It took me entirely too long to figure this today. Perhaps Google will pick this up and save someone else the effort.

I had a file in Subversion which should have been executable but wasn’t. I tried changing the file permissions and checking in the file, but Subversion refused to do anything since the file hadn’t changed. I poked around with Google but didn’t find anything helpful.

Finally the nice folks over in #svn on irc.freenode.net told me the command is svn propset svn:executable “*” filename. Sister commands include propdel and proplist.

Free Sectional Charts

June 5th, 2005

Flying in flight simulator just doesn’t seem right without sectional charts. I looked around for somewhere to get them, but didn’t find anything great. Paper charts are available but they are expensive if you want a wide area of coverage. There are some other digital charts, like the ones uploaded to the AVSIM file library by Matt Fox, but they aren’t available in one package. So I started with the excellent collection available at aviationtoolbox.org and made my own set.

This package includes sectional charts covering the entire US including Alaska and Hawaii. Also included are all the Terminal Area Charts, which show more detail around large airports. These are the same charts that pilots use for VFR flights. Hopefully they will make your flight simulator experience a little more realistic and enjoyable.

I suggest downloading a browser plugin like FSBrowser or FSX-ionals to view the charts in-flight. (An exciting project to keep an eye on is FSM MovingMap. Matt Fox’s maps work with this moving map software. Unfortunately, the maps in this package don’t because FSM MovingMap does not yet support the projection they use and I didn’t bother to convert the geocoding information.)

I’m putting these up under a Creative Commons license. Check out the readme for details. The download is about 500 Mb, so I’m using BitTorrent to distribute it. The hosting is being done through Prodigem, which offers free BitTorrent hosting for content under a Creative Commons license.

Download sectional charts (You need to have a BitTorrent client to download this.)

Dotcat 0.4

February 2nd, 2005

I just realized I’ve been sitting on version 0.4 of dotcat for, oh, 6 months. Well, no longer, here it is. The big change from the previous version is that it (hopefully) does a better job of picking which nodes to keep.

Download dotcat 0.4

Humble Beginnings: Your First OGRE Application (for linux)

September 22nd, 2004

Nicholas Green’s Humble Beginnings tutorial for the Ogre graphics engine says “Under construction” for the Linux section. This is an attempt to remedy that. I’m only going to cover setting up the project and getting to a basic program which compiles and runs, similar to the Mac OSX section. After that, you’re on your own…

To begin, make the Samples/Space directory for your project and copy these files into it:

  • Samples/SkyPlane/src/SkyPlane.cpp
  • Samples/SkyPlane/include/SkyPlane.h
  • Samples/Common/include/ExampleApplication.h
  • Samples/Common/include/ExampleFrameListener.h

Next we will set up a basic build system, for which we are going to use GNU automake and autoconf. If you want to learn more about these tools, I suggest reading the excellent tutorial at the autotools website. First we will write Samples/Space/configure.ac, which tells autoconf which programs and libraries we are going to use to compile our application:

AC_INIT([Ogre Space Tutorial],
        [0.0.1],
        [Mark Ivey zovirl@zovirl.com],
        [Space])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([dist-bzip2])

AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL

PKG_CHECK_MODULES(OGRE, OGRE >= 0.14.1,,AC_MSG_ERROR("OGRE not found!"))
AM_CXXFLAGS="$AM_CXXFLAGS $OGRE_CFLAGS"
AM_LDFLAGS="$AM_LDFLAGS $OGRE_LIBS"

AC_SUBST(AM_CXXFLAGS, "$AM_CXXFLAGS")
AC_SUBST(AM_LDFLAGS, "$AM_LDFLAGS")
AC_SUBST(PKGDATADIR, "${datadir}/${PACKAGE}")

AC_CONFIG_FILES([
   Makefile
])

AC_OUTPUT

Most of that is boiler-plate. The two important parts are “PKG_CHECK_MODULES(OGRE…)” which tells autoconf we will be using OGRE (and it should go find the correct compiler flags for us) library and “AC_CONFIG_FILES(…)” which tells autoconf which files we want it to generate.

Next we will write Samples/Space/Makefile.am, which tells automake how to compile our program:

bin_PROGRAMS = Space

noinst_HEADERs= ExampleApplication.h \
                ExampleFrameListener.h \
                SkyPlane.h

Space_SOURCES= SkyPlane.cpp

EXTRA_DIST = bootstrap configure

Ok, the last part of the build system is a short script to set everything up for us, Samples/Space/bootstrap:

#!/bin/sh

set -x
rm -f config.cache &&
libtoolize --force &&
aclocal &&
autoconf &&
autoheader &&
automake --foreign --add-missing

make that executable with “chmod +x bootstrap”

You are ready to compile (from the Samples/Space/ directory):

./bootstrap
./configure
make

Finally, you should be able to go into the data directory (Samples/Common/bin) and run ../../Space/Space.

Ok, the build system is done, now it is time to add the real source code. Remove SkyPlane.cpp and SkyPlane.h and edit Makefile.am to reflect the new files you are about to add:

bin_PROGRAMS = Space

noinst_HEADERs= ExampleApplication.h \
                ExampleFrameListener.h \
                SpaceApplication.h

Space_SOURCES= SpaceApplication.cpp

EXTRA_DIST = bootstrap configure

Finally, add the code for the application’s main loop in SpaceApplication.cpp:

#include "Ogre.h"
#include "SpaceApplication.h"

int main(int argc, char *argv[])
{
   // Create application object
   SpaceApplication  app;
   try {
      app.go();
   } catch( Ogre::Exception& e ) {

   std::cerr << "An exception has occured: " <<
   	e.getFullDescription().c_str() << std::endl;
   }

   return 0;
}

That won’t compile just yet because SpaceApplication.h hasn’t been added, but you are ready to continue on with the rest of the tutorial. Enjoy…