Skip to main content

Posts

Best new blog I discovered at PyCon [so far]

I was talking to Adam Gomaa on Thursday when Ben Bangert stopped by us and told him he had an interesting blog. "If Ben says you have a good blog, I'll have to check it out," I told Adam. "That's not what I said," Ben corrected me. "I said interesting ." But it is good, and I'm glad I found it. And regarding Adam's post on declarative layers for SQLAlchemy , check out the new-in-SA 0.4.4 declarative plugin. It's almost exactly what Adam was looking for -- a little more verbose, in keeping with the "explicit is better than implicit" Python philosophy that SA shares, but creating your own superclass that creates a PK named "id" by default is just a few lines of code if that's what you prefer.

PyCon, Saturday and Sunday

Saturday I'll be at the SQLAlchemy and State of PyPy talks. Then the board game BOF in the evening. In between, probably mostly the "hallway track." Sunday I plan to attend "What Zope did wrong" and "Core Python Containers." (I'd also like to see the Wingware presentation in the 11:35 slot, but since I can only pick one, I guess I can just cross my fingers that this year's video recordings actually get published somewhere.) Feel free to stop me and introduce yourself. (If we met at a previous PyCon, I've changed my hair around a lot from year to year. The photo on this blog represents what I look like now. I should probably stick with this for a couple years so people can recognize me.)

Introverting

I'm taking a break during the evening tutorial in my hotel room on the second floor where I can enjoy the pycon wireless signal (which seems to be working quite well now). My name is Jonathan, and I am an introvert [too]. I suspect a lot of PyCon attendees can empathize. After the last tutorial session ends at 9:30, I'm planning to head down with my copy of Munchkin and see if anyone wants to start the board game social a day early.

Slides from Introduction to SQLAlchemy tutorial

My slides from this morning are up: http://utahpython.org/jellis/sa-intro.pdf . The about 1/3 of the class did not have SA installed yet, and the network was down. Fortunately, Mike and Jason brought 5 flash drives and by the time we got to the first exercise everyone was up and running. This was my third time doing a three-hour SQLAlchemy tutorial. Differences from (last time) include updated for the 0.4 series removed almost all the SQL-layer material added a section on the new relation filtering api Improved the parts of the Fundamentals sections that were poorly explained added a short section on the new-in-0.4 transaction management. There wasn't a wall clock in the tutorial room, so despite making an effort to be aware of time I went 10 minutes over. Sorry, guys. :) Jason Kirtland will be posting the slides from the Advanced SQLAlchemy tutorial soon.

Pylons: first impressions

A couple co-workers and I spent some time with Pylons yesterday, enough to get to where we started to feel productive, but not much more than that. I think there's value in a newbie's first impressions, so here are mine. I'm sure at least some of these are wrong. Poor documentation of core Pylons (Mako and SQLAlchemy are fine -- thanks, Mike ). I had to use the source several times. I'm still not really sure how Routes works, although I was mostly able to make it do what I wanted. The first tutorial overcomplicated things, showing how to configure things to handle semi-obscure requirements, without explaining those requirements or simpler alternatives. Helpful community. I got most of the answers I needed pretty quickly in the #pylons freenode IRC channel. Not much black magic: if you know Python you won't be struggling with weird Pylons-only concepts. It's all modules, classes, and dicts put together in an intuitive way (at least to my way of thinking). ...

SQLAlchemy at Pycon 08

SQLAlchemy will be well-represented this year with two tutorials and a talk. I'll be the primary instructor for the Introduction to SQLAlchemy tutorial. I just updated the pycon page with the outline of what we'll cover. The slides will be pretty similar to last time , only with more time spent on a high-level intro to ORM (object-relational mapping) for people who have little exposure to that. And of course last year 0.4 was not out. The SQLAlchemy documentation is thorough but a little intimidating. IMNSHO, the introduction tutorial is a great way to pick up the basics and get some practice, after which everything starts to make a lot more sense. Mike Bayer, the author of SA, will be the primary instructor for the Advanced SQLAlchemy tutorial. Jason Kirtland, one of the most prolific SA hackers besides Mike himself, will also be teaching. At the conference itself, Mike will be presenting Sqlalchemy 0.4 and beyond . To save you digging it out of the talks page, he...

Why IE rejects your cookies for no apparent reason

Seriously, WTF . I'll summarize for those of you who are allergic to MSN knowledge base articles, although this one is fairly to-the-point: If you implement a FRAMESET whose FRAMEs point to other Web sites on the networks of your partners or inside your network, but you use different top-level domain names... IE silently rejects cookies sent from third party sites. This bit me today while adding facebook support to my text-based game -- I'm going the IFRAME route for fb support rather than rewrite the whole app in FBML thankyouverymuch, and yes, apparently IFRAME counts too for IE retard-mode. What makes me cry a little inside is not the two hours spent deep in old and crufty login and cookie-setting legacy code wondering what the flaming hell was going on. No, what makes me cry is that I got screwed by a setting that will never block the bad guys, because labeling yourself a good guy is entirely voluntary . It's like someone at MS read the evil bit RFC and took...

Scala: first impressions

I'm reading the prerelease of the Scala book , since I'm working for a heavily Java-invested organization now and programming in Java feels like running a race with cement shoes. Politically, Jython doesn't seem like an option; Scala might be an easier sell. Here's some of my impressions going through the book. Scala is a decent scripting language [updated this section thanks to comments from anonymous, Jörn, and Eric.] Here's how you can loop through each line in a file: Python: import sys for line in open(sys.argv[0]): print line Scala: import scala.io.Source Source.fromFile(args(0)).getLines.foreach(println) The scala interpreter also has a REPL , which is nice for experimenting. This article has more examples of basic scripting in scala. Getters and setters One thing I despise in Java is the huge amount of wasted lines of code dedicated to getFoo and setFoo methods. Sure, your IDE can autogenerate thes...

Troubleshooting the ps3 wireless network connection, including error 80130128

My father got a ps3 for Christmas, but ran into some problems getting it on his wireless network. The first one was "connection error 80130128" after configuring it to use DHCP. I couldn't google anything useful about this; just a few other hapless victims asking if anyone had any ideas. Fortunately Dad had his laptop there too and noticed Windows complaining that two machines on the network were both using the same IP. So, over the phone, I walked him through setting up the ps3 with a static address: on his laptop, run -> cmd ipconfig Read the "gateway" ip. Put that into his browser to go to his router's admin page Find the DHCP settings for his router to see what range of IPs it hands out; pick one outside that range Set up the ps3 with that IP, the router IP as primary dns, and an opendns server as secondary This made the connection test happy. But when he tried to go to the playstation store, it gave a DNS error. If he repeated the connection te...

Reed-Solomon libraries

If you want to run a multi-petabyte storage system then you don't want to do it with Raid 5 or Raid 6 ; with modern disks' ~3% per year failure rate , that's 300 a year when you have 10000 disks and the odds start to get pretty good (relatively speaking) that you'll face permanent data loss at some point when you lose a third disk from an array while two are rebuilding. And of course monitoring and replacing disks in lots of small arrays is manpower-intensive, which to investors translates as "expensive." You probably don't want to go with triplication , either; disks are cheap, but not so cheap that you want to triple your hardware costs unnecessarily. While storing multiple copies of frequently used data is good, all your data probably isn't "frequently used." What is the solution? As it turns out, Raid is actually a special case of Reed-Solomon encoding , which lets you specify any degree of redundancy you want. You can be safer th...

Utah Data Recovery

About three years ago (so pre-Mozy and definitely pre-Mac Mozy) my brother had his powerbook hard disk die. As in, not just mostly dead -- it would not power up. It had a lot of stuff on it that he didn't want to lose, but he felt like the usual suspects who charge $1k to $2k for data recovery were a rip off. So he hung onto the disk in case a cheaper option came along. Then just recently when I saw some people on a local linux group mailing list recommend utah data rescue I suggested to my brother that he give it a try. UTDR starts at "only" $300. UTDR did indeed recover the data, although they charged $100 extra for this one. Mac fee? Tricky hw problem? I don't know. But it was still a lot cheaper than the other companies I googled for fixing a physically dead drive. (As opposed to a corrupt partition table or something where the hardware itself was okay.) At least, the ones that actually give you a price up front rather than hiding behind "reques...

Semi-automatic software installation on HP-UX, with dependencies

I had to install subversion on a couple HP-UX boxes. Fortunately, there's an HP-UX software archive out there with precompiled versions of lots of software. Unfortunately, dependency resolution is like the bad old days of 1997: entirely manual. And there's fifteen or so dependencies for subversion. So, I wrote a script to parse the dependencies and download the packages automatically. It requires Python -- which you can install from the archive with just the Python package and the Db package -- and BeautifulSoup, which you can google for. Usage is hpuxinstaller <archive package url> <package name> [e.g., hpuxinstaller http://hpux.cs.utah.edu/hppd/hpux/Development/Tools/subversion-1.4.4/ subversion] [wait for packages to download] gunzip *.gz [paste in conveniently given swinstall commands] Here is the script: #!/usr/local/bin/python import urlparse, urllib2, sys, os from subprocess import Popen, PIPE from BeautifulSoup import BeautifulSoup required = {...

Congratulations, Mozy

I left backup service provider Mozy about three months ago, and yesterday they were acquired by EMC as rumored by techcrunch earlier. The cool thing about startups is they pretty much have to hire people who are totally not qualified to do awesome things and let them try. There's no way Amazon would have hired me to write S3, but that's what I did for Mozy. Mozy was the third startup I've been a part of, and the first to amount to anything. I was employee number #3 and saw it grow from sharing a single rented office to 50 employees in two years. With people who didn't think it was strange to wear a tie to work. Trippy. Unfortunately I'm not there to witness the final stage of being assimilated by the Borg firsthand, but I hear that's not really any more fun than it sounds so perhaps it's just as well. Nice work, guys.

Wing IDE 3, Wing IDE 101 released

Wing IDE version 3 has been released . The list of new features is a little underwhelming. Multi-threaded debugging and the unit testing tool (only supporting unittest -- does anyone still use that old module anymore?) are nice but I don't see myself paying to upgrade from 2.1 yet. Now if they could get the GUI to keep up with my typing in Windows, I'd pay for that... I guess this is a sign that Python IDEs are nearing maturity; Komodo 4 didn't have any earth-shaking new features either, at least as far as Python was concerned. (Personally I think someone should start supporting django/genshi/mako templates already. Maybe in 3.1, guys?) Following ActiveState's lead , Wingware has also released a completely free version, Wing IDE 101. The main difference is that where the most essential feature Komodo Edit leaves out as an incentive to upgrade is debugging, Wing IDE 101 includes the debugger but omits code completion. Wingware also continues to offer the low-c...

That wasn't the pigeonhole I expected

I went to the BYU CS alumni dinner tonight. At one point they briefly put everyone's name and position on a projector, one at a time. (At five seconds apiece it wasn't as tedious as it sounds.) When it was my turn, it announced "Jonathan Ellis, System Administrator." What the hell? It turns out that when I RSVP'd I said I was a "python kung-fu master & sysadmin of last resort." (In the sense that, if you really can't find a better sysadmin, I know enough to be dangerous.) Don't bother trying to be clever around bureaucrats.

Utah Open Source Conference 2007

The first Utah Open Source Conference finished today. I heard that they had close to 300 attendees -- not bad at all for a freshman effort. I reprised presentations that I've given before, on SQLAlchemy and distributed source control. My slides are on the presentations page (although if you've seen my slides from either before, there's not much new there -- I got lucky, SA 0.4 isn't stable yet so I stuck with 0.3.10). I had to work Friday so I missed a lot of presentations, but of the one I saw my favorite was on Ganglia , which I hadn't heard of before but which looks quite useful for anyone running a bunch of servers that takes uptime and qos seriously. (This was actually Brad Nicholes's third presentation of the conference -- he must have been busy!) Afterwards I went to the board games BoF and played Mag Blast. Fun little game.

What it means to "know Python"

Since Adam Barr replied to my post on his book , I'd like to elaborate a little on what I said. Adam wrote, [F]or me, "knowing" Python means you understand how slices work, the difference between a list and a tuple, the syntax for defining a dictionary, that indenting thing you do for blocks, and all that. It's not about knowing that there is a sort() function. In Python, reinventing sort and split is like a C programmer starting a project by writing his own malloc. It just isn't something you see very often. Similarly, I just don't think you can credibly argue that a C programmer who doesn't know how to use malloc really knows C. At some level, libraries do matter. On the other hand, I wouldn't claim that you must know all eleventy jillion methods that the Java library exposes in one way or another to say you know Java. What is the middle ground here? I think the answer is something along the lines of, "you have to get enough practi...

Merging two subversion repositories

Update: an anonymous commenter pointed out that yes, there is a (much!) better way to do this with svnadmin load --parent-dir, which is covered in the docs under "repository migration." All I can say in my defense is that it wasn't something google thought pertinent. So, for google's benefit: how to merge subversion repositories . Thanks for the pointer, anonymous! I needed to merge team A's svn repository into team B's. I wanted to preserve the history of team A's commits as much as reasonably possible. I would have thought that someone had written a tool to do this, but I couldn't find one, so I wrote this. (Of course, now that I'm posting this, I fully expect someone to point me to a better, pre-existing implementation that I missed.) The approach is to take a working copy of repository B, add a directory for A's code, and for each revision in A's repository, apply that to the working copy and commit it. This would be easy if...

A brief reaction to "Find the Bug"

I picked up a copy of Adam Barr's Find the Bug , which is a cool concept for a book. (5 languages, 50 programs, 50 bugs; see if you can spot them.) I found the bug in the first program, in C, then skipped to the Python chapter. The first two programs were not too bad, as pedagogical exercises go (although iterating through substrings instead of a.startswith(b) in the 2nd was painful). The third, though, was "Alphabetize words," 25 sloc to perform the equivalent of def alphabetize(buffer): L = buffer.split(' ') L.sort() return L ... doing everything about the hardest way possible. Now, it's pretty hard to introduce a non-obvious bug into my version of this function, so it wouldn't be appropriate for Mr. Barr's book when written this way. But the right thing to do is to make the task more difficult, not dumb Python down to the level of C! It's very very painful to read Python written like that. (Actually it's painful to read a...

Final version of OSCON SQLAlchemy slides

http://utahpython.org/jellis/sa-tutorial-oscon.pdf Also the code snippets: http://utahpython.org/jellis/test_tables.py http://utahpython.org/jellis/test_code.py This is what I'll be using in my tutorial tomorrow. Update: I forgot to "svn up" on my web server. So now the final version is up.