May 24th, 2008 by knorby
The ACM (just Borja really) organized a trip to Google Chicago, where all of the Google Summer of Code students who were accepted from UChicago (and in the US) gave lightening talks on our projects, which included me. The other GSoC students were Marcus Westin, Jordon Lewis, and Nick Edds. I put up my talk, as well as a more general page for my project on my CS site. Marcus and I both have projects with the Globus Alliance, so I was quite happy that he went before me, as I didn’t have to explain what Globus is. My project is fairly straight foreword to explain and I still don’t know the Globus Toolkit (GT) that well, so I couldn’t answer too many questions, and I ended up going under in time. Everyone seemed most interested in Nick’s project, since it is on the 2to3 tool in python, and a decent amount of the audience used Python, some with a great deal of dedication (it was at Google after all). I am pretty excited to see how Nick’s project turns out; we both went to the talk that his mentor, Collin Winter, gave at PyCon on the tool and the issues that Nick is working to fix.
The Chicago office’s engineering crew is dominated by subversion developers (in the small selection of software I like), but most of the presentations were about most unrelated projects. Ben Collins-Sussman discussed a VM for interactive fiction games like zork (I’ll still play my zork on the SDF TWENEX Machine; the version of zork installed is from 1981!). Karl Fogel, not a current Google developer, but subversion developer and good friend of the other googlers, gave a talk on script he wrote to help track patches from non-core developers based on logs. He put up some stats on the differences between subversion and GNU Emacs as projects; it further straightened my reasoning for using XEmacs. I went to a Russian choir concert the night before, as I had to go to a concert from a genre I don’t have any familiarity with, which he apparently was in; what a small world I live in. Brian Fitzpatrick gave a shortened version of the keynote he have at PyCon on balancing functional complexity with usability in software. Like all the other talks I have heard him give, it was an excellent talk; he has one of the best uses of slide shows I have seen, and I always end up thinking about the talks much later. There was also a talk from a developer for Blogger (he said he was now on feedburner); I would give his name, but I can’t remember it at the moment. I talked to him for a bit; I think my social awkwardness was in full swing at the time. I asked him about something I read on Valleywag about Google adding some preference search rankings with Blogger (I can’t find the post at the moment; I will link to it if I do); as I am sure is the case, he said that Google does no such evil. He also mentioned that Google crawls its own site with the same bot, which makes sense, but I hadn’t thought about it before. I wish I knew Blogger better, as I used it once for something else and had a couple thoughts about its workings.
It was a fairly awesome evening. I was very sleep deprived after one of my harder weeks here, so I was defintely in a strange state for the entirity of the thing. My thanks and appretiation go out to Borja and Google for this event. Apparently, my glorious face might end up on the GSoC blog or the Google open source blog.
Posted in ACM, Chicago, GSoC, Python, globus, google, personal, uchicago | 2 Comments
May 6th, 2008 by knorby
I wrote this “eulogy” for two computers that apparently got fried (as in electrical surge or something) recently in the Maclab. I intended it for fellow tutors, but I was fairly fond of it. It would probably help to know that these computers were named “python” and “ada.”
We are gathered here today to mourn the deaths of Python and Ada. They lived good, long lives as G5s. Tragically, Brian discovered their charred remains yesterday, which was confirmed today.
Ada always dreamed of being a missile guidance system, but as a G5, it was never able to fulfill its dream. It forgot its dream, and instead spent its life running word, with the occasional bit of matlab and powerpoint here and there. As it felt its final death blow surge, it visualized tracking a laser point until meeting a glorious, explosive end, it quietly whispered “I’m going home!”
Python suffered a far more tragic death. Realizing it was at its final moments, it began to question the meaning of it all:
>>> raw_input(”So this is it? Was it good? Why do I have to die? Where
I am going?”)
So this is it? Was it good? Why do I have to die? Where I am
going?Traceback (most recent call last):
File ““, line 1, in ?
EOFError
Unfortunately, its questions were left unanswered:
>>> raise UnboundLocalError, “Oh Noes!!!!”
Traceback (most recent call last):
File ““, line 1, in ?
UnboundLocalError: Oh Noes!!!!
>>> raise SystemExit
$
Unfortunately, no one was there to catch its exception.
Posted in Apple, Python, humor | No Comments
March 25th, 2008 by knorby
I have been playing around with the ctypes library in python recently. It is a foreign function interface for dynamic linked libraries(DLL)/shared libraries. It works back to python 2.3, and it was added into the standard library in python 2.5. Anyway, it provides a much nicer way to access C libraries then using one of the various methods to create a C extension, though it is a bit slower. As I learned at pycon, one of the benefits is that PyPy (one of the craziest things I have ever seen) can use ctypes. I was thinking of staying for the PyPy sprint at pycon, but I think they were going to work on a pure python implementation of the library, which was far too intimidating to me. I will post about pycon at some point soon.
I guess I find ctypes so special just because it is the first thing in recent history with python where I was really amazed. I first saw it with µTidylib, which is a python wrapper around the HTML tidy library. What got me was just playing with it on the interpreter:
>>> from ctypes import *
>>> libc = CDLL("libc.so.6")
>>> libc.printf("Hello, World!\n")
Hello, World!
14
>>>
Obviously, it is a lot more powerful than this example illustrates, but you get the idea. I have been fixing up some of the filters in the print system at the Maclab over spring break, so I have been working with ghostscript a bit. There is an API for ghostscript, so I have started writing a wrapper library for it in my free time to practice using ctypes, and, well, because one doesn’t exist. I am trying to think of a name that somehow combines ghosts, snakes, and desktop publishing….
Posted in C, Python, coding, postscript | No Comments
February 9th, 2008 by knorby
While working on our project for software construction today, my partner and I started to work out an implementation of interfaces in Python. Fortunately, we didn’t end up needing to go to this extreme (it’s a weekend assignment). Interfaces have been proposed for python before, but the changes were never made. Anyway, we worked out a basic strategy to implement interfaces in python. The most common approach for this sort of thing is to just make a base class with methods that raise the NotImplementedError if they should be overridden. For the most basic implementation of an interface, this approach works, but what if we want to put contracts or a docstring test on this method? There is essentially no way to go about such an implementation with standard methods in python. Instead of using the traditional syntax to express inheritance, some function would be needed to implement interfaces. Really, most of we want to get from the interface could be considered “shell” around another function. We just want to put in the guts part of the method, and if the guts are not put in, python should raise an error. The easiest way to implement something like that would be to just maintain two methods. So, for every method foobar(self, arg1, arg2, …), there would also be a function __foobar(self, arg1, arg2, ….). Perhaps a different convention, such as __Interface_foobar(self, arg1, arg2, …), would be appropriate as to not interfere with one’s ability to assign __foobar to something else, but these are points are trivial. Ideally, I will come up with some sort of nice interface metaclass or base class and a set of function decorators that would take care of much of the work involved, but written out if full, it would look like
class Foobar(Interface):
#===============================================================================
def __init__(self):
raise NotImplementedError, "__init__ must be implemented by a subclass"
#===============================================================================
def foobar(self, aArg):
"""
This is a function is the shell of an interface method
"""
if not isinstance(aArg, BarType):
raise TypeError, "aArg must be a BarType"
return self.__Interface_foobar(aArg)
#===============================================================================
def spam(self):
"""
Just some regular method.
"""
return 3
Then after defining some class that implements this interface Foobar, do something like this
Foobar.implementedBy(eggs)
I will probably have to make some changes once I start banging away at python. I know python well, but I don’t know every bit of trivia.
One of the consequences of this setup is that everything is done at runtime, and some external testing procedure would be needed to verify that everything follows the interface. On the plus side, these would be something unique from interfaces as well; these thing really could be used for a whole bunch of things beyond the scope of normal interface. Also, everything needed to implement this sort of thing could be done without any changes to the language itself or use of modules outside of the python standard library. So, I will work on this thing sometime when I have time, which is never…
Posted in Python, coding, design | No Comments
January 10th, 2008 by knorby
What follows is probably the most perverse shell script I have ever written. I decided to write a script that somehow implemented Hello World for a bunch of languages. I didn’t include Java, because the installation of java on the machine I wrote this script on was somehow messed up. Plus, Java sucks hard. I didn’t do any javascript either as Rhino was messed up (see last sentence), and spidermonkey wasn’t installed. I included far too many, but I will gladly add more if someone bothers to write some. You can also download the file. Wordpress messed a few things up, which I tried to correct, so download the file copy if you actually want to try thing thing out. Also, you might need to install some stuff unless you are in the UofC CS department Linux clusters. I apologize to the world for what my boredom can cause…
#!/usr/bin/env bash
#====================================
echo "Bash:"
bash << EOF
echo "Hello World!"
EOF
#====================================
echo "Python:"
python << EOF
print "Hello World!"
EOF
#====================================
echo "C:"
TMPFILE="/tmp/stupidgcc.c"
TMPOUTPUT="/tmp/stupidgcc"
touch $TMPFILE
cat > $TMPFILE << EOF
#include <stdio.h>
int main(){
printf("Hello World!\n");
return 0;
};
EOF
gcc -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#====================================
echo "Ruby:"
ruby << EOF
puts "Hello World!\n"
EOF
#====================================
echo "Perl:"
perl << EOF
print "Hello World!\n"
EOF
#====================================
echo "C++:"
TMPFILE="/tmp/stupidg++.cpp"
TMPOUTPUT="/tmp/stupidg++"
touch $TMPFILE
cat > $TMPFILE << EOF
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
EOF
g++ -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#================================
echo "Haskell:"
ghci -e 'print "Hello World!"'
#================================
echo "Awk:"
echo '' |awk '{ print "Hello World!" }'
#================================
echo "Fortran77:"
TMPFILE="/tmp/stupidFortran.f"
TMPOUTPUT="/tmp/stupidFortran"
touch $TMPFILE
#http://www.roesler-ac.de/wolfram/hello.htm#Fortran77
cat > $TMPFILE << EOF
C Hello World in Fortran 77
PROGRAM HELLO
PRINT*, 'Hello World!'
END
EOF
f77 -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#=======================================
echo "Tcl:"
tclsh << EOF
puts "Hello World!"
EOF
#=======================================
echo "Octave:"
octave -q << EOF
printf("Hello World!\n");
EOF
Posted in Linux, Python, coding, humor, javascript | 6 Comments
January 4th, 2008 by knorby
This post is really for myself. I started a new project for myself last night, just another simple utility, mostly for my own use, that shouldn’t take me anytime at all. I say that before I start most things, but I think it will probably be true in this case. Anyways, I have a pretty large pile of projects that I have to work on or complete, and I wanted to make a list so that I might be able to judge which ones to work on and to just have a list.
(Mostly) Completed/There is Always More to Do
- pyXSD - pyXSD was my first big project. It was what I worked on at ORNL as a student intern over the summer of 2006, between high school and college. It was also my first program in Python, my favorite language. It is an XML Schema Validator, which works in some funky ways. It fills a small void in th python+xml world, but it still has a few bugs to work out, and there are a few features I would like to add. It has stayed at 0.1 for some time now, and I don’t know when I will get back into it. I have been kind of hoping for a few people to submit some changes, but only one person has (and that was barely anything). I really just can’t get excited about this project anymore. I don’t use XML Schema (RelaxNG all the way!); I really don’t have a reason to do much more with it. I am guessing it will stay at 0.1 for a while….
- ACLUofC Website - I mostly included this one, because I didn’t want this section to be one item long. There is really very little to this site. It has a simple design that I am mostly happy with, considering that I did it fairly fast. It needs content still, but I don’t really worry about that one too much.
Almost There, but Still Needs Some Work
- xmlViewer - My project at ORNL over the summer of 2007. Basically, it is an xml-based expert system to create an editor for a specific xml format. The system is currently written in javascript. It is a really nice system, and there is a lot in it that I am proud of. It just has a few bugs at the moment. I have been planning to write an xhtml editor with it as well, as I figure it could really do some interesting things. It also needs a better name.
- lambdaCarte - I was working on a project for a class, and I needed a nice command-line menu system in which I could associate actions, which usually are small. I did some quick searching, but I didn’t find any python packages that did just what I needed. I wrote it mostly in a night, and it seems to work surprisingly well. It needs a lot of cleanup, but it works. It’s really simple, but such things just make life easier.
- DOIT Fortune Library - I am not going to try and justify this thing’s existence here, mostly because I have none. It is not as much a project as it is a mission; I feel it is my duty to make available in any form I can conjure (that doesn’t take that much time and requires no money) to spread a list of bad ambiguous sex jokes from USENET I found when playing on the twenex.org computer. There are few things to work out on what I have so far, but I have been planning to make a DOIT of the day rss feed, and I recently started to look into making a DOIT facebook app. I must DOIT to the world.
Partially Complete
- xmlTools - I wanted to work with xml from the command line or in scripts, and there isn’t any easy to use toolset that I am aware. It is written in python and it uses the lxml library. A bunch of them work, but it needs further tests, and there are a few functions I want to add.
- pySchedule - A python scheduling library. I haven’t touched this thing in a while.
- packagemapWriter - A simple utility to create packagemaps for google code search. It is really a simple utility; I just wanted to something to pass the time over this last break, and I wanted it for some of my projects.
- deviceXmlFileSync - I have a bunch of gadgets with file storage, specifically mp3 players. I often will get a new album and need to load it on to several different devices, but I don’t remember which ones I have put it on. This python utility helps to queue up transfers. I haven’t worked on it in a while.
- fireScraper - The project resulting from the method I outlined to screen scrape using Firefox from the command-line. Still has a lot of work to be done, but I have already done much of the needed work.
- Political Networks - A research job I have.
- rstDocs - I write a lot of technical documents in reStructuredText (rst). Basically, I wanted something like google docs to write rst on and render it (except just for me and maybe some friends). I started this thing a couple nights ago. It was partly an excuse for me to play around with php.
- New Print System Interface - I work in the Mac and Linux Lab at the UofC, where we have a print monitor to prevent users from printing things they didn’t write and to enforce a quota. As staff, we have to be able to make exceptions and correct errors. We also have to maintain kiosks so that users can select which jobs they want to print. I started to rewrite it to use ajax techniques as opposed to a simple php script with a page refresh every few seconds. I also wanted to add a few possible actions that maclab tutors and users could use on documents.
Barely Scratched
- xmlDebt - I didn’t want to use any of the account tracking software I found, and it seemed like something simple enough to code, so I started on one, but I guess my love for accounting is not that great….
- rsoFundTracker - Simple system designed for RSOs (clubs at UofC). Financially, most have a lot in common, as they all have to fight..err…..deal with ORSCA.
- cssExtended - Basically, I think css sucks. It would if it was written using JSON instead, and it would be nice if the selectors included XPath and regular expressions. I started outlining this format, and a javascript engine to implement it. I was also thinking of writing a python script to implement it in the xhtml server-side or to files after any changes are made. I was also thinking of calling it jss.
So now I have a list to remind me of all the things I started so I don’t start more when I want to code. For the ACM, Cord and I have been working on PhoenixForge, a gforge server for UofC students wishing to work on projects on campus. Hopefully, it will cause me to be more productive.
Posted in Python, coding, javascript, personal | No Comments
December 2nd, 2007 by knorby
I follow the local Python user group’s mailing list (see chipy.org). Though UChicago has prevented me from going to all but one meeting, I can say that it is a fun group. Anyways, someone asked a question that spurred a few hilarious responses. The two best are this one bit of coding absurdity and this one just hilarious response.
Posted in Chicago, Python, coding, design, humor | No Comments