Programming


  • Monday, November 24, 2008 - 11:40

    Python has a really cool feature called decorators. Which allow you to wrap functions around other functions in a clean way. The classic example would be the @trace decorator which would let us do this:

    @trace
    def sayHello(name):
       print 'Hello %s!' % name

    If we define the trace decorator like this:

  • Thursday, November 6, 2008 - 16:57

    Okay, so things everyone should know about dictionaries, they are in the python manual but I still didn't know them until today. First off creating a dictionary in the code (ie hardcoded)

    <code>d = dict(one=2, two=3)<br /></code>

    This is a simpler way of doing things, and it sure beats having to rember all your quotes when doing:

    <code>d = {'one': 2, 'two': 3}</code>

    Granted the second way looks cooler! But we have to make compromises. Another cool thing, is taking a list of keys and list of values and turning them into a dictionary: 

  • Wednesday, October 8, 2008 - 23:31

    So I wanted to swap to objects, and I prefer to write short clean code, especially to carry out simple processes. The idea was that I have two objects, in this case treeA and treeB and I wanted treeA to be the deeper of the two trees. Now the long way would look something like this:

    if treeA.depth < treeB.depth:
        tree = treeA
        treeA = treeB
        treeB = tree

    Which is a little ugly, 4 lines to reorder something, so there neat trick is that if you want to swap two objects a and b simply use:

    a,b = b,a

    So the above code becomes:

  • Friday, July 18, 2008 - 22:49

    Photon mapping is a way to do illumination in 3D graphics. This is my computer graphics project from college.

  • Friday, July 18, 2008 - 22:48

    EveryBlog is meant to be a replacement for the default Drupal Blog module.

    May 25, 2009: EveryBlog is pretty much tabled as the core functionality is easily implemented using views and taxonomy, this site for instance is using taxonomy for both tagging posts and placing them within specific "blogs" and then views are used to display matching posts. Hence the overhead of an entirely seperate module is not needed as it is fairly easily to do using existing solutions which are likely to be far more stable due to their larger development community.

  • Sunday, February 3, 2008 - 00:55

    A ray tracing project from my computer graphics class. We built our own ray tracers from the ground up, its pretty cool!