Entries for October 2006

Ask.com Maps Has the Finished Village

Looks like Ask.com Maps has the most up to date aerial view of campus, better than Google Maps, Yahoo! Maps, and Virtual Earth. Google Maps comes in second place where it's at least under construction.

Now, I wonder if they have a geocoder I could add to geopy?

Automating Case Wiki Tasks

A while ago Chris added a login method to the CAS module in CaseClasses. It returns a mechanize Browser object so that you can programmatically surf the web as if you had logged into CAS in a real web browser.

CaseClasses also has a Codes module that has the abbreviated codes for majors, departments, and buildings. I combined these two features to tackle the Building codes project on the Case Wiki.

P.S.: There is a MediaWiki API that would normally be used to do this kind of stuff, but according to Greg, editing is not fully functional yet.

Think you could add a lot to the wiki with some automated task? Here's how it was done.

First, you'll need mechanize and CaseClasses:

$ sudo easy_install mechanize
$ sudo easy_install http://opensource.case.edu/svn/CaseClasses/python/trunk

Now log into CAS with mechanize:

import Case
from getpass import getpass

username = 'bmb12'
password = getpass() # Enter a password without echoing

cas = Case.CAS()
browser = cas.login(username, password)

You can open any page with browser and interact with it as a logged in Case user. So let's go to the Case Wiki and log in:

browser.set_handle_robots(False)
browser.open("http://wiki.case.edu")
browser.follow_link(text_regex='Log In')

Editing can be done like so:

browser.open("http://wiki.case.edu/User:Brian.Beck")
browser.follow_link(text='Edit this page') browser.select_form(name='editform') browser['wpTextbox1'] += " Also, this guy sucks!" browser.submit()

Automating the building code edits was done like so:

for code, name in Case.Codes.buildings.iteritems():
    url = "http://wiki.case.edu/%s" % name.replace(' ', '_')
    try:
        browser.open(url)
    except:
        print "Didn't find %r." % name
    else:
        browser.follow_link(text='Edit this page')
        browser.select_form(name='editform')
        source = browser['wpTextbox1']
        add_text = "The building code for %s is [[building code:=%s]].\r\n"
        add_text %= (name, code)
        if 'code:=' not in source:
            insert_at = source.find('{{Building')
            if insert_at != -1:
                new_source = source[:insert_at] + add_text + source[insert_at:]
            else:
                new_source = source + add_text
            browser['wpTextbox1'] = new_source
            browser.submit()
            print "Added building code for %r." % name

Happy automating!

Update: The same has now been done for the Street addresses project. Check out the discussion to see how.

FreeBSD on My Laptop

The other day I ditched openSUSE for FreeBSD on my laptop.

I got sick and tired of openSUSE's incredibly slow package management, and it has lots of customizations where I prefer the defaults. For instance, instead of Alt-Space activating the active window's context menu, it brought up Kerry Beagle search. And Meta/Super hotkeys didn't work (I use Run and Desktop hotkeys a lot). I decided that I shouldn't have to change a ton of things to their default value when they should be the default in the first place.

I like FreeBSD so far, it seems very easy to learn. The only thing that's confusing so far is that pkg_add, /usr/ports, and sysinstall Packages all seem to have a different list of packages... shouldn't they be the same?

Case Public Computing Thoughts

On a typical day at Case I use anywhere from 3 to 7 different computers, often on 2 or 3 different platforms (Windows, Linux, Mac). I only own two computers, so this means I spend a lot of time using the "public" computing facilities around campus.

There are three facilities that do nearly everything I want and offer an enjoyable experience. I'll save those for last. First I'd like to offer some criticism about everything else. I admit that I'm more demanding than most users, but why is that an excuse to make your facilities crappy?

iBooks in Kelvin Smith Library: Anyone can check out an iBook from the amazing Freedman Center in our library. Ah, wonderful! An operating system where I can easily SSH into my own computer and install things to my home directory without making a huge mess.

Sadly, not so. Even though OS X clearly has a satisfactory permissions model, these are totally locked down. You can't even run Terminal. Sorry, but if I can't do this on a computer, I consider it useless. Part of the problem is that there is a single universal login for everyone. Having real user profiles would be a hassle since they only connect via wireless and downloading a user's Home folder would slow things down quite a bit. Maybe there could be a link on the desktop to the user's Filer account, encouraging them to save there, and the Home folders could be wiped at the end of the session?

Desktops in Kelvin Smith Library: You have five options: Internet Explorer, Excel, PowerPoint, Publisher, and Word. No, not even Notepad or Calculator are available.

E-mail Machines in Thwing, Village at 115, Wade, Fribley: These Windows machines are only good at one thing: checking e-mail. Some of them won't even let you check the time, because the system tray clock is disabled for no apparent reason. They are totally locked down. There's no Firefox, so web surfing for more than a few minutes sucks. There's no PuTTY. Why do these have to suck so much? Here's how to fix them: install Firefox, install PuTTY, install TightVNC, let people run Remote Desktop if they can't already, and make the clock huge instead of nonexistant.

Virtual Worlds Lab: Not much to complain about here, these machines are pretty sweet despite the fact that they are running Windows. They have big storage drives separate from the Windows drive where you can install and run programs, but sadly these are machine-specific and not network drives. These machines would be absolutely sweet for graphic design, but every time I try this I remember that you can't install fonts due to the lame permissions, so you're stuck with the defaults. Also—correct me if I'm wrong—these are supposed to be gaming machines, yes? Are there even any games on there yet? It's been a year. And last I checked, using flash drives did not work in here.

Technology Enhanced Classrooms: These suffer from some of the same problems as the public computers in Thwing. No Firefox. No PuTTY, although thankfully you can run executables that don't install anything, so downloading PuTTY (and VNC, and VLC) is no problem. There is a universal login, so leftover crap from random people clutters the Desktop and My Documents folders. Also, could someone please explain to me how the ability to right-click is a security flaw? Seriously, it's like someone is playing a cruel joke by disabling random features—or is Windows really that busted?

Jennings Windows Lab: Why would anyone use these when there are machines that don't take five minutes to log on right across the room? Sometimes you get lucky and it doesn't take forever to migrate your profile for some reason. I think reading from flash drives works, but not writing.

Finally, here are the computing facilities I actually find enjoyable.

Jennings Unix Lab: Holy crap, these thin clients running Ubuntu are a dream come true. There are hundreds of awesome desktop apps on here. Your choice of KDE, GNOME, or something more exotic. You can install stuff to your home directory, and drop stuff in your ~/web directory to put it online. I think I have a better success rate printing from here than on the Windows machines. And Simon is looking to make these even better with one of those handy EECS bounties (which I took him up on).

Smith Computer Lab (aka Nord Lab): Wow, non-crippled Macs and power-user-friendly Windows machines. On the Macs, dragging applications to your Home folder installs them there, and you can run Terminal. Heck, I even installed SQLite, Ruby, Rails, and DarwinPorts on there and ran a server. I think there's a link to your Filer drive on the desktop.

The Windows machines are done right, too, with PuTTY, TightVNC, and even an X11 server for Windows (the name escapes me, it's not Cygwin).

Astronomy Computer Lab: Located on the fifth floor of Sears next to the Astronomy Library are some Windows and Linux machines. The Linux machines are running RedHat and are totally sweet! They offer a very similar experience to the Jennings thin clients, except the audio output works and there's no annoying redraw that comes with using a thin client. The only problem is there is no automated account registration, you have to personally request an account (and probably have a purpose for it).

Speaking of public computing, the only computers around the (totally awesome) new EECS student lounge are the Windows machines in the circuits lab. There is so much desk space in this new lounge I was considering covertly setting up a Linux machine anyone could log onto with their Case ID; I wonder if anyone would notice?

geopy 0.93 Released: distance, util, GeoNames

Finally released geopy 0.93, which contains the distance and util modules I previously mentioned, a GeoNames geocoder, and improvements to the Google geocoder in other formats. Updating the documentation was all that was holding it back, really.

You can now pass domain and resource arguments to the Google geocoder. To query the actual Google Maps interface (instead of their official HTTP geocoder), initialize like so:

g = geocoders.Google(resource='maps')

The JavaScript results tend to be the best for this resource, so change that as well:

g = geocoders.Google(resource='maps', output_format='js')

Finally, for geocoding addresses outside of the US, change the domain being queried:

g = geocoders.Google(domain='maps.google.co.uk', resource='maps', output_format='js')

As James Robinson brought up on the geopy mailing list, work is under way for accuracy support. This will let you determine how precise the geocoded result is for the given location. For example, is it only guaranteed to be the correct city? Street? Is it the exact address? I decided to release this version of geopy without completing this, because not much work is done so far (and we also want to normalize values across geocoders), and the distance module was a pretty big addition.

To upgrade:

sudo easy_install geopy

Tango Schema for Konsole

Today Wouter Bolsterlee's post about Tango colors for gnome-terminal popped up in my RSS reader and I thought it looked pretty good. The Tango Desktop Project is primarily used by GNOME, but I'm still a big fan even though I prefer KDE.

Here is the equivalent schema for Konsole, KDE's terminal app: Tango_Colors.schema. It should pop up if you put it in ~/kde/share/apps/konsole/.

Screenshot:

Tango Schema for Konsole

A Web-Based Presentation System for Case

If you saw the new EECS department bounty system, you may have noticed the bounty for a web-based presentation system. This is now a work-in-progress by yours truly.

The goal is to let Case people generate slideshows through the web with Case-themed templates, mostly for use on the plasma displays in the EECS department (well, the displays that will be in Glennan). Another use could be by faculty in place of PowerPoint (so it should have familiar features such as transitions).

You may have seen those displays in the fishbowl last year showing pictures and such. Apparently these are a pain to administer because they are connected by a wireless connection and thus are not easy to connect to via Remote Desktop. So when they are rebooted or PowerPoint closes somehow, getting the slideshow back up and running can be a real hassle. Having them in kiosk mode in a web browser will allow them to easily refresh if anything goes wrong, and will also let them grab updated content. This is how the plasma displays around campus show their (I think Flash-based) slideshows.

There are two such tools on which to base such a system: S5 and Slidy. If you've ever viewed a text-based presentation online, it was probably with S5. This is the first time I have heard of Slidy, but it actually looks a lot better to me. Every time I've encountered S5 in the wild, the JavaScript has eventually completely messed up the text sizing and positioning, making everything unreadable.

There are existing services that combine web presentation systems with editing and sharing, such as S5 Presents and SoapBX. SoapBX is not open source while S5 Presents is GPL licensed and in Ruby. I would have no problem with using S5 Presents, but apparently it has gone unmaintained for almost two years, and Simon was disappointed when he looked into configuring it to run under a real web server.

Tonight I decided to see what actually using S5 is like, so I customized the default theme to resemble the Case PowerPoint template found on the Case branding page. So here is my Case-themed S5 presentation. It's pretty incomplete and doesn't match exactly, but it's close (and anyway, the goal is to make it look good, not match exactly—their PowerPoint template could use some work).

When I first considered this bounty, I thought "hmm, web-based, which web framework will I use?" One of the major goals is to be easily maintainable once I leave, so something popular or at least very easy would be the best choice. Which best fits this description? Django? TurboGears? web.py? I've never really considered the maintainability of any of these, since usually I can choose whichever I like at the moment.

After a bit of talking with Chris, we determined that any server-side code at all isn't even really needed. The only thing it would be used for is to display view and edit pages for the presentations and to store them. The first two can be done with static HTML and JavaScript, while the third can be used by POSTing with AJAX to some location. For example, we could POST presentations to the EECS department's new DokuWiki-powered site with the appropriate permissions. Since S5 and Slidy presentations are just HTML, the wiki page itself would be the presentation outline, and the slideshow viewer could just grab the markup from there. Or we could use AJAX to upload the presentation via WebDAV to the author's Filer account.

Since there would be heavy JavaScript usage regardless of the selected framework, the author would need to be fluent in it anyway. So why not a pure JavaScript solution, given the possibilities above? This is what I'll be looking into for the next few weeks. The code will soon live at opensource.case.edu/projects/present.

If anyone has experience with S5 or Slidy and would like to share their opinions, please do (even if it's just which system you like more).