Programming


Posts on various aspects of programming or hurdles I've jumped (or stumbled) over and anything else related to programming I might write.

  • Saturday, March 19, 2011 - 15:42

    The other day at work I was working on a project where I would be creating lots of small strings. And by a lot, I mean a lot, on the order of 100s of millions. So, I was wondering what is the most efficient way to deal with using StringBuilder. Building the strings would require dumping the contents of the builders. There are three methods, reallocating a new string builder each time, using sb.setLength(0), or sb.delete(0, sb.length()). Being the empirical scientist that I am, I figured the only way to determine which is the fastest is to profile it.

  • Thursday, October 7, 2010 - 12:08

    So I've been playing around the past few days with writing a simple 3D game. I can't tell you much about . . . sorry. I started off in Java using OpenGL. Things went fairly well considering 3D engines are not my strong suit and its a lot of learning. (And yes I looked at JME, but decided against it). Anyways, I decide that I'd try my hand at using XNA, which meant porting what I had from Java to C#. (I have this delusion of releasing it as an indie game one day on the 360). While porting I ran across my code where I used packed ints.

  • Thursday, September 16, 2010 - 10:37

    I've been flipping through the second edition of the "PHP Cookbook" by O'Reilly to see if there are any new tricks I can learn. I've worked with PHP quite a bit from small projects hacking Durpal to much larger ones such as a library management system, but there are always new things to learn.

  • Thursday, April 15, 2010 - 22:11

    This little program lets you create a bargraph of the number of results returned by a google search when replacing a small part each time. For example if you use
    Google Query: how to get better at <x>
    Search Terms: starcarft 2; kissing; cooking; robbing a bank; becoming cowboy neal

    It will plot the number of results returned by a google search when <x> is replaced by each search term. This means it would plot the number of results for each of "how to get better at starcraft 2", "how to get better at kissing", "how to get better at cooking" ....

    This was inspired by several XKCD comic strips like Numbers and Dangers. Of course, the numbers don't quite match up with the comics.

    Google query "<x>" will be replaced:

    Search terms to substituted into the above query (separated by semicolons):


  • Thursday, April 8, 2010 - 11:38

    Occasionally one has to jump through a lot of hoops and do some pretty bizzare and unorthadox things when coding. Especially when working with multiple versions of libraries. At work all of our iMacs were recently upgraded to Snow Leopard and Python 2.6 and libraries isntalled (all in 64-bit). Its nice to upgrade . . . when it doesn't break things. Unfortunately during the upgrade numpy 1.4 was installed. Now this was only unfortunate because the super computer we also need to run on has numpy 1.3 which won't unpickle objects pickled with numpy 1.4.

  • Saturday, March 13, 2010 - 15:36

     I use matplotlib fairly frequently in my research, it rocks. However, the fact that the MacOSX backed doesn't let me use 'Cmd-Q' to close things down is annoying. So my solution is a combination of pycario and preview with a little AppleScript through in for fun. I program in Eclipse with PyDev, however I run my python programs exclusively from iTerm. Hence, I'm used to cmd-tabbing back and forth between iterm and eclipse. However, when I run a program that opens up a gui, such doing "pylab.show()" things get annoying.

  • Monday, April 20, 2009 - 11:17

    For my Embedded Systems class I'm working on a project where we are doing some webcam capture and video processing/effects work. To make life simple we are using OpenCV, which rocks. Our language of quote-in-quote choice is C# and to work with OpenCV we are using EmguCV wrapper/binding/what-have-you. So, while working on code that has to capture a video frame, process the frame to do face detection and a video effect, then draw a frame to display to the user I decided to throw everything into its own frame.

  • Monday, April 6, 2009 - 13:16

    I have for some time now been using matplotlib to do all my graphing in python. Its a great package! Recently I've been wanting to do basic animation of graphs, while you'd think it would be simple has turned into a bit of a trek. There is a simple animation example found here: http://matplotlib.sourceforge.net/examples/animation/simple_anim_gtk.html it works okay, but if you try to move the window it freezes, and you can't use anything on the toolbar.

  • Sunday, February 15, 2009 - 15:18

    The more I work with python the cooler it becomes, especially the more I let my mind think of way out there things to do with the tools python provides. In my work I frequently find my self writing code in this order:

  • Friday, February 13, 2009 - 15:22

    So one of the coolest things I just found out about python is that it will let you chain comparisons, so 1 < a < 10 works. Even 1 < a < 10 < b < 25, and so on, you can even get really crazy and try a < 5 > b, wich is a funky way of saying a < 5 and b < 5, pretty cool huh!