Some fairly large computer news

I’ve been working away from home more and more often lately, and the 13″ screen on my MacBook has been feeling more and more restrictive. So I decided to replace it with a something bigger. Obvoiusly my first thought was a MacBook Pro, but they’re just so expenssive that it’s hard to justify the cost. So instead, I bought a ThinkPad. I got a T61 with a 15″ WSXGA+ screen, 802.11n, dual-layer dvd burner, 2.5 GHz Core2Duo… basically the exact same features (and even hardware probably) as a MacBook pro. The biggest difference? I spent less than $1000 dollars on it.

This is actually my second ThinkPad; I had an x61 that I bought in college and actually used as my main computer when I first moved to Boston because my PowerMac was in-transit and I didn’t have anything else. I’ve also been impressed with the ThinkPad line, the higher end ones have very nice build quality, and they’re popular enough with the Linux crowd to have good Linux support. So, for the second time in my life, I’m running Linux as my main OS (specifically Gentoo Linux on kernel 2.6.25 with the tuxonice patches).

The biggest issue with using Linux was finding the appropriate replacements for my commonly used apps. Most of them were Easy: Firefox stays the same, I use Google Apps to host my email so no problems there either. For instant messaging I was planning on using Pidgin, but ended up going with Kopete because after trying it out, I just like it better (that’s right, I’m using KDE, 3.5 for now). The biggest challenge, was trying to find something to replace TextMate for coding in. I absolutely love TextMate, and take advantage of a lot of its advanced features all the time. Fortunately, back when I was a CS student, I got nice and familiar with Emacs, and was well aware that, even if the functionality I wanted wasn’t built in, someone’s probably created an add-on for it, and if not it would be pretty simple for me to do it myself. Turns out I was right.

I haven’t completed all my Emacs modification yet, but so far just two little scripts have given me most of what I was looking for. First was yasnippet, which provides a snippet feature that works in pretty much the exact same was as TextMate’s. Someone even wrote a script that will download TextMate bundles directly from the repository and covert the snippets they contain to work with yasnippet. You can’t do much better than that. I’m also using emacs-textmate which provides an Emacs minor mode that emulates some more of TextMate’s behaviors; specifically, it adds in the ability to automatically insert paired characters, so if you type ‘(’ it automatically inserts ‘)’, and handles deleting them gracefully as well.

There were a few other features that I use extensively in TextMate as well that weren’t provided by either of these add-ons. Fortunately, it was relatively simple for me to implement them myself (with a little help from a friendly Emacs guru on the Gentoo forums) and patch emacs-textmate to provide it. Specifically, I duplicated TextMate’s auto indent feature by adding an extra keybinding to emacs-textmate to bind the return key to the built-in Emacs function newline-and-indent. I also bound M- to a new function of my own creation defined thusly:

(defun open-next-line()
  (interactive)
  (move-end-of-line nil)
  (newline-and-indent))

This duplicates the behavior of command-return in TextMate, which is pretty much the same as ‘o’ in vi[m]. I’m still working on how to duplicate command-shift-return, which inserts the appropriate line ending character based on language (’;’ for C and C-like languages, ‘:’ for Python, &c.) and then opens and goes to the next line. But I don’t think that will be too hard once I learn a little more elisp. After that I just need to figure out how to duplicate Textmate’s tag closing function, which is a huge time-saver when coding HTML.

All in all, I’m quite happy with my new computer. Things may not be quite as pretty as in OS X, but they can be if I just put a little work in to making them so (I’ve already got e17 installed, which comes close and with some more tweaking may replace KDE as my default environment). As much as I love Mac OS X, there is definitely a strong argument to be made for Linux, at least for people who aren’t afraid to get their hands dirty with the command line and a good old text editor. Even with just a couple days spent adjusting the system, I think it’s already at a point where I could see using it full time, maybe even prefer it to OS X. Which is really saying something when you consider that I’ve been a Mac user for about 24 years.

I love Django

I’m currently working on a fairly large Django project that I think I’ve mentioned a couple times in the past. In that Django project there is a Person model and an Organization model. Both Persons and Organizations have email addresses. Organizations are related to Sites (through a ManyToMany field), but Persons are not (they’re related to Organizations through an intermediary table). I’m currently attempting to create a contact form, so that people can email either a Person or an Organization using newforms.

For security reasons, we don’t want the user to actually see the email address, just the name of the Organization or Person. Fortunately, newforms has the ModelChoiceField class that you pass a queryset of options. In keeping with DRY principles, I want to be able to use a single Form regardless of whether the person is trying to email a Person or an Organization (both models have a field named ‘email_address’). Unfortunately, this is where I ran into my first problem: ModelChoiceField doesn’t really allow you to define the queryset dynamically, you have to define it in the form definition. Luckily I found this blog entry which provides a method to re-define the queryset in the __init__() method which allows you to change it based on the HttpRequest object. My next problem was that I only want the user to be able to email Organizations and Persons on the current Site. Since Organizations are directly related to Sites I just used the CurrentSiteManager. However since People are not directly related to Sites, and are instead related only to Organizations (through an intermediary table), I couldn’t do this. Instead, I decided to try this crazy bit of code:

Person.objects.filter(persontoorganization_map__organization__in=Organization.on_site.all())

Amazingly, it just worked exactly as I would have wanted it to. No fuss, no problems, just a queryset of Persons related to the current site. Go Django!

Getting there with the TV

I posted a while ago about my plans for our TV setup. In the intervening months I’ve made a few changes to my plans and taken a big step towards getting it all set up.

The biggest change is that I’ve removed MythTV from the picture. Originally I was planning on either building my own MythTV powered HTPC or buying a TVease Zodiac MythTV system. It appears that TVease has gone out of business, so that’s now out of the question. But in the course of my research on building a MythTV box, I realized that it would be a similar price and far far easier for me to just buy my HDHomeRun through Elgato and get their EyeTV software with it. I can then just run it on a Mac Mini using Pyetv to control it all through Front Row.

With that in mind, I’ve now purchased my HDHomeRun from Elgato, and am currently watching the Detroit and Dallas in the Stanley Cup playoff live in a window next to my browser as I write this. We’ve also get it scheduled to automatically record Lost and Grey’s Anatomy.

So far I really like the EyeTV software. With the HDHomeRun we’ve got two tuners so we can do picture in picture and/or record one thing while watching another (or just record two shows simultaneously). I’ve had no problems or complains with either the software or hardware so far, though I have had a few problems actually introduced by my computers. For some reason, my iMac occassionally loses its AirPort connection which means it loses its connection to the HDHomeRun. As a result, our recording of the latest Grey’s Anatomy stopped after 7 minutes. Fortunately this won’t be a problem with the final setup because I’ll just connect the Mini to the network via ethernet. On the plus side, the 802.11n network I setup for my iMac gives me no problems watching two HD shows simultaneously. The other problem we’ve run into is that occasionally the reception isn’t that good. But that’s easily fixable by just getting a better antenna, which won’t be hard to do since we’re currently using some cheapo rabbit ears.

All in all, I’m pretty confident that this is going to work out well. And it will be easily upgradeable if we decide we want to get cable and/or sattelite (probably sattelite because if we’re paying all that money I’m going to want Setanta Sports).

Last night at the Apple Store

AppleSo as I mentioned, I was at the opening of the new Boston Apple Store on Boyleston St. last night. Unfortunately I was a little late showing up and didn’t get my free t-shirt. :(

As I mentioned, it’s an extremely nice location with some extremely cool design. The entire top floor (of three) is dedicated to support with a gigantic Genius Bar that is apparently able to support several thousand people per day, and a ton of iMacs lining the walls where you can get one on one help/tutoring (they call it their One-to-One program). Another cool new features they’re rolling out (or possible already had and I just haven’t been paying attention) is their personal shopping service. You can make an appointment to show up and have, essentially, a personal shopper to help you out with any questions or help you might need while shopping. Seems like a pretty cool idea, and I imagine it will be very useful for the parents who want to get their kid a new computer or something but really have no idea what they’re looking for.

All in all, I think this store is going to be a huge success. Especially positioned, as it is, directly across the street from the Prudential Center and the soon-to-be-opened Mandarin Oriental hotel. It will definitely be a little more pleasant to visit than the Cambridgeside location, though parking won’t be nearly as easy so you’ll probably start seeing more people with big iMac boxes on the T…

And in closing, these people weren’t on the guest list and therefore aren’t as cool as me:
These people aren't as cool as me.

(Yes, both pictures in this post were taken with my iPhone.)

Apple Store Boyleston

I’m currently at the grand opening event of Apple’s new flagship retail store in Boston. I’ve only just gotten here, but so far I’ve hot to say that I’m impressed. It’s something like a cross between the 5th Ave. location in New York and the Miracle Mile location in Chicago. In short: three stories of beautiful, glassy architecture with a huge skylight topping it off and the iconic white Apple logo overlooking the Pru. Also, they’re giving me free beer and appetizers, so far so good. I’ll write more about itlater, for now I’ll just enjoy it, and play with the toys.

And another thing

Why is everything that disrupts parking labelled an ‘emergency’ around here? When it snows enough to disrupt parking it’s a ’snow emergency’. When they’re forbidding parking so that they can paint lines on the street it’s an ‘emergency’. Last night we walked into Porter Square for dinner and passed no fewer than two different ‘emergencies’: ‘Emergency! We’re painting lines on the street! Please file calmly, but quickly to the nearest exit!’, ‘Emergency! We’ve torn up the sidewalk! Please …walk around it!’.

Seriously, people, these are not emergencies… Ok, there’s a vague case for the ’snow emergency’, but there is absolutely no excuse for labeling an event that has been planned for weeks if not months as an emergency.

Some braindead planning by the city of Somerville

So, currently there are signs up and down both sides of Somerville Ave. saying that there’s no parking on those streets due to an ‘emergency’. Well, that’s all you can read of the signs as you drive around looking for parking due to the fact that everyone who usually parks on Somerville Ave. is now parked elsewhere, anyway. If, however, you take a closer look at those signs, they say that there’s no parking there on 4/30 and 5/1 from 7:30 pm until 6:00 am or so because they’re painting bike lanes.

Painting bike lanes? Bike lanes are great and all, and I wish there were more of them in general. But this is just an absolutely moronic way to go about it. The most obvious reason that it’s a completely moronic thing to do is that Somerville Ave. is currently being re-paved. For the past, I don’t know, 6 months or so, they’ve been very very very slowly working their way from Union Sq. towards Porter Sq. tearing up the roads and repaving them. Now this is definitely an essential thing for them to be doing as the state of Somerville Ave. is, in a word, abysmal. So, in general I heartily approve of both these measures.

The problem is that they’re doing it in the wrong order. Unless they’re planning on not fixing up all of Somerville Ave., which seems somewhat ridiculous since they’re already investing time and money in the project and disrupting just about everyone’s lives for it now, or they’re planning on somehow, miraculously finishing the rest of Somerville Ave. tonight and tomorrow, they’re just wasting a bunch of money here. They’re going to spend the next two days painting bike lanes on the street only to tear it up and re-pave it in another month or so (if we’re lucky).

This just strikes me as a tremendous waste of money. Also, it seems kind of odd for them to be painting bike lanes on a street that doesn’t really have car lanes painted on it. I guess we’re not really far enough away from Boston to escape the sphere of city planning moronicism.

Complex Django hosting

As you may recall, a while ago I got myself an account at MediaTemple with the idea that I’d move all my websites over to there. I had previously been using Dreamhost, but wanted something a little more high quality so that I could reasonably offer hosting services to some of my clients. MediaTemple seemed like a good way to go, and for the most part their service has been great.

Unfortunately, I have run into a few problems. Most importantly, despite spending a fairly significant number of man-hours working on it, I’ve been unable to get Django running on my (dv) server. Yes, they have a (beta) program that makes it easy to run Django on a (gs) account, but for my needs a (gs) simply won’t do and I really don’t want to have multiple accounts with them. The end result of this is that several of my web pages are still running on Dreamhost because they require Django (this blog actually is as well even though it’s currently a WordPress blog, because I want to switch to something Django-based and it seems like an unreasonable hassle to migrate my WordPress blog to a new server only to then have to migrate it again to new software, especially as I’m currently holding onto my Dreamhost account for my Django-based pages anyway).

The issue is now coming to a bit of a breaking point. Why? Because I’m currently working on a pretty large Django-based website that will be going live in the next month or two. For the purposes of development, it’s being hosted on WebFaction, which has been an amazing host. They make it incredibly simple to host a Django site, to the point that basically zero setup is required. But as we get closer to the point of going live, I’ve been considering what the hosting needs of the site will be going further, and how to best serve them.

The site is a redevelopment of an existing site, so we can get a pretty good idea of what the traffic numbers are going to look like. This will let us extrapolate the RAM and bandwidth requirements pretty well too. The issue, is that once the Django version of the site goes live, we’re going to start to expand it. Thanks to the capabilities of Django, it’s being developed with the potential for massive growth in mind. Specifically, it’s using Django’s Sites framework to allow for expansion to several sites. Currently there are only two, but the Django version will go live with 4 or 5, and there’s the potential to expand far beyond that.

This means that we’re going to require a pretty large number of (software) servers. There’s the MySQL server running the back-end, an HTTP server for static content, and then an HTTP server for each site, and they’re all going to be using up resources to different extents. Trying to find the best hosting solution for this sort of setup has led me to a couple of options:

  1. Stay with WebFaction. A number of people have said they believe that WebFaction’s shared hosting plans should be able to accomodate this. WebFaction provides a very good combination of ease of use and low-level access, their prices are good, and the way they have their hosting set up, it’s extremely simple to add another Django install complete with its own Apache/mod_python instance. They also offer dedicated server, but I think there are probably better routes to go than with WebFaction’s dedicated servers.
  2. Switch to Slicehost. I’ve only just learned about Slicehost, but so far they look like a pretty sweet deal. For a very reasonable price you get a virtualized server running a Linux distro of your choice (you can choose from 8 right now) run on Xen. They claim not to oversell their servers, so you’re guaranteed to actually get the full capacity that you pay for (unlike with budget hosts such as Dreamhost). And since you’re getting your own virtualized host you have full root access. They basically have nothing preinstalled, so you can easily set it up in whatever configuration you want without having to deal with the vagaries of the anointed hosting package (Plesk on MediaTemple, I’m looking at you). I really like like look of them, and they’ve been getting good reviews. They’re currently listed as the number 2 hosting company on Djangofriendly, behind only WebFaction. With my background in IT and Linux administration, the fact that I’d have to manage everything myself isn’t enough to scare me away either. The fact that they let you choose your Linux distro really appeals to me as well, as I’m by far more familiar and comfortable with Gentoo than any other Linux distro. I only wish they offered FreeBSD slices, but the only reason they don’t is technical, and once that issue is resolved it sounds like they plan on it. In a lot of ways, they’re basically a very affordable colocation provider. The biggest issue, it sounds like, is that apparently communication between different slices counts against your bandwidth allotment (for both slices, presumably). This means that as the site I’m working on grows, if it spreads out to multiple slices (which it undoubtedly would and which I’d want it to do since that will give the added reliability of spreading across multiple physical machines) we’ll basically be billed for database access from the sites that aren’t on the slice with the database server.
  3. Colocation. Colocation is basically the 800 lbs. gorilla in the room. It costs a lot more, but you get what you pay for. With colocation we’d have all the advantages of Slicehost (minus the low price, of course) plus the ability to expand more or less arbitrarily. We could have as many physical machines as we wanted running as much or as little of the site as we wanted. Provided we’re willing to pay, of course. On top of that all the server management would again fall to me, but this time without some of the nice shortcuts that Slicehost offers. Essentially, colocation is alway the fall-back option. But hopefully one of the other two hosts can offer us a solution that’s a little more balanced: we get less control, but more simplicity and ease of use for a greatly reduced price.

At the moment, I’m leaning towards sticking with WebFaction for now. I’m already very impressed with what they offer, and from the sound of things, they’ll continue to be a more than adequate host as we expand. But I’m also definitely looking for input. If anyone has any suggestions or recommendations I’d love to hear them. In particular, any first-hand experience with hosting large Django sites with any of these solutions are most welcome.

FreeBSD on an Apple MacBook

For the past week or so, I’ve been running FreeBSD on my MacBook. So far, I’ve got to say, I absolutely love it. I have a lot of experience running a range of Linux distributions on all sorts of hardware including both PPC and Intel Macs, but just a week or so of FreeBSD usage has convinced me of the OS’ value over Linux.

A standard FreeBSD install is incredibly simple. If you don’t want to dive into any messy details you don’t have to (though you do need to be comfortable with the fact that you’re going to be using a curses interface rather than a real GUI). You could probably have a full, working install of FreeBSD, complete with X.org, in 15-30 minutes if you didn’t want to do anything crazy.

I, of course, wanted to do some crazy things. Namely, I wanted to have it running on Sun’s ZFS, which took a little extra work. If you just want to run FreeBSD on your MacBook easily, I highly recommend this howto from Goddess-Gate.com. It’s very good and very easy to follow (just remember that you might not use a French-layout keyboard and you’ll be fine).

To start things off, after partitioning my drive with BootCamp, I used this ish.com howto to get a minimal FreeBSD install running with ZFS. At this point, my Airport card was working with the built-in drivers, which was absolutely stunning after all the work and effort I’ve put into trying to get WiFi to work with Linux in the past. After that I took a few tips from zenspider to get the basics setup like configuring my own user with sudo privs, and ZSH as the default shell (I’m a fan of things that start with Z, I guess…). After that, just a few tips from the Goddess-Gate.com howto as well as the MacBook page o the FreeBSD wiki (the wiki page will be important later) got me to a basically complete and usable stage.

In addition to the basics, I installed the e17 window manager, which so far I really like, gvim and xemacs, for my basic work needs (traditionally I’m an emacs guy, but lately I’ve been playing around with vim a lot), Opera for web browsing and some of the KDE packages, though I don’t want or plan to use KDE, I just wanted a few of the applications to play with (Konqueror and Kate), so I removed all the KDE packages other than kdebase and it’s dependencies.

At this point I only had a few issues with my install:

  1. the trackpad - FreeBSD currently has no support for advanced features with the MacBook trackpad. The synaptics drivers available in FreeBSD don’t recognize the USB trackpad that Apple uses, so you’re forced to use basic mouse drivers which means no two-finger scrolling or right-click. The best solution out there (and I’ll address this in a bit) is to configure xbindkeys so that F10 sets your mouse button to left-click, F11 sets it to middle-click, and F12 sets it to right-click.
  2. fn key - FreeBSD also currently has no support for the fn key on the MacBook keyboard which means that the home, end, pgup and pgdn keys are unusable. This isn’t a huge deal as you can use various other keybindings to the same effect, but it’s annoying.
  3. battery monitor - For some reason the battery monitor widget that comes with e17 only sort of works with my MacBook. If my battery is full, it says so. Otherwise, it just says ‘DRIVER’. Oddly enough, this doesn’t seem to indicate an actual driver problem, because I can get the full info on my batter at the command line including time remaining and all that fun stuff. Since the information is obviously all available I’m going to try and patch the e17 widget to work with a MacBook when I’ve got the time. Meanwhile, I’m sure that other battery monitor probably work, though I haven’t had a chance to try any yet.
  4. Firefox - I simply have not been able to get Firefox to work properly. I’ve tried various ports (firefox, firefox-devel,linux-firefox, and linux-firefox-devel), but sometimes they fail to compile, and even when they do, they won’t run. Since I’ve got both Opera and Konquerer installed I’m just going to ignore this issue until Firefox 3 is released and makes it into the ports tree.

Other than those four things, everything else has really been a dream in terms of ease of setup and use. And, I’m happy to announce, I’ve come up with a better solution to the right-click issue!

You have to install xvkbd and then add the following to your .bindkeysrc:

"xvkbd -text '\m3'"
	Control + b:1

"xvkbd -text '\m2'"
	Alt + b:1

This will allow you to use ctrl-click for right-click, as in the Mac OS, and alt-click for a middle-click.

The one caveat, which Rui Paolo, writer of the MacBook entry in the FreeBSD wiki helped me discover, is that you have to compile the latest version of xvkbd yourself, as the one in ports is outdated and doesn’t work for this. So I’m going to work on building a new port with the latest code. The lack of a simple way to right-click was the one thing that was really bothering me with my FreeBSD install, so this is a pretty huge deal as far as I’m concerned.

Well, that was a very long and geeky post. Now I have to get ready for my international flight tonight.

Leaving on a jet plane

Tomorrow night I’m flying to Dublin. Sadly, I’ll only be there a few days (Did I say days? I mean hours…) before I fly to Rome where I’m meeting up with my friend Evan. We’ll be spending 2 weeks in Rome, Venice, Vienna, and Munich. I’m taking my iPhone so that I can have internet access and all that without having to lug around my MacBook (or worry about it going missing), so I’ve been trying to find the best way that I can use it to post photos online. I thought that my Zooomr account would allow me to post photos by email, but I can’t find that option anymore. I also thought about using my tumblog, but I can’t seem to get the email posting feature to work for it. Fortunately, I also have a .Mac account which means that I can create Web Galleries for my photos. The iPhone integrates pretty seamlessly with that, and every picture I have on it gives me the option to post it directly there (once I set up .Mac email). This seems like a pretty good way of doing it, so I’ve set one up as a sort of photolog here: http://gallery.mac.com/josh.ourisman#100039

Any updates requiring more than just a photo will, of course, happen here.