Josh Ourisman » On the other hand

Navigation: Blog, Portfolio

A zsh prompt for Mercurial users

November 16th, 2009

My friend Sebastian Celis recently posted on his blog about a zsh prompt for Git users. Basically, it's a set of scripts for ZSH that allow it to display the current status of the Git repo you're currently in. Very cool stuff, but unfortunately I don't use Git (very often), and instead use Mercurial for most of my projects. So I decided to modify it to work with Mercurial.

Very little has changed from his Git version (in fact, in most files it was a simple s/git/hg/), so I'm not going to go over how it all works. If you want to know that, you should read his original blog post. Instead, I'm just going to link to my bitbucket project for it: Mercurial for ZSH.

It is, at this point, a pretty half-assed port. There's still some work to do to fine-tune it for Mercurial, but it works. Another thing I'm interested in doing is seeing if I can get it to auto-detect what VCS is being used for the current directory and act accordingly so that it doesn't have to be limited to either Merurial or Git (which goes along nicely with another project that I'm working on and will hopefully be able to write about soon). But, half-assed or not, I think it may be useful to anyone out there using both ZSH and Mercurial (or any any VCS, if you want to fork the code again).

Car free once again

November 3rd, 2009

After a year and five months, Jessi and I are car free once again! Yup, yesterday we sold our '06 Mazda 3 that we bought in '07 and re-entered the ranks of the urban carless. This is the second time we've been without a car, the first was right after I moved to Boston from California and sold my Camaro. That lasted for about 6 months before Jessi got a new job that was not accessible by public transit.

This time, with my new job at Discovery Creative, and Jessi working from home, a car has become an unnecessary expense. A very large unnecessary expense, as a matter of fact: before taking into account gas an maintenance, owning the car was costing us around $500 per month! That's a lot of extra money that's now going to be sitting in our bank account! Of course some of it will go to Zipcar rentals for the few times when we actually do need a car, and some will probably go to getting our groceries delivered by either Peapod/Giant or Safeway, but even still those added expenses should be far less than what we're saving by having no car.

Building RESTful APIs with django-piston

September 26th, 2009

Discovery Creative has a lot of web sites and apps out there. And quite a few of them need to send email in one form or another. Previously that has meant that every single one of those sites/apps needed to implement it's own mechanism for sending email. This is obviously a bit of a pain, not to mention a potential security risk, and a blatant violation of the DRY principle. So I was tasked with building a better mousetrap, as it were.

One of the cool new things I had heard about at DjangoCon 2009 (which I really should have written about...) was Piston, a framework built in Django for building RESTful APIs by the bitbucket guys. I'd never actually built any sort of API before, but it seems to be the thing to do, so I decided to take django-piston for a whirl and how it works. As it turns out, it works extremely well. So well, in fact, that when coupled with some of the fun tools that Django provides (such as ModelForms) you can easily build a RESTful API in no time at all.

Thanks to django-piston I was able to create a simple API that will allow us, moving forward, to use a single, centralized email solution for all our web apps. In fact anything that can send an HTTP POST request (including curl, which is what I've been using for testing) can send email using the API I created so long as it can also handle HTTP authentication (which django-piston easily handles against django.contrib.auth). I'm hoping, after a little more work and refinement, to open-source our API so that other can benefit from it (and, hopefully, contribute back to it!), but for now you'll have to make do with a sample project that I threw together for the most recent django-district meeting this past Thursday: Django-Piston Presentation. It's a bitbucket repository that includes all the code for a simple RESTful API that allows you to create, fetch, and delete objects from a simple Django object. This particular project was designed to be extremely flexible, and all one needs to do is add or remove fields from the model (or point it at a different model) to adapt it to just about anything. Hopefully it will serve as a pretty good instructional example to anyone who wants to create their own API with django-piston. The project also contains my notes on how to build and test it in an Emacs org-mode file.

Next up: Git, Mercurial, and moving on from Subversion.

Silverdocs.com: My first Discovery Creative project goes live!

June 2nd, 2009

I'm actually a bit late on this one, but I've been so busy with my next Discovery Creative project that I just haven't had time for much else. Anyway, from June 15 through 22 AFI, in partnership with the Discovery Channel will be putting on their Silverdocs Documentary Film Festival. Check out the website for more details on the festival and the films they'll be showing, not to mention an example of how awesome my (and the rest of Discovery Creative, I guess) work is.

Life in Maryland

May 10th, 2009

I've now been living in Maryland and working at Discovery Creative for a whole month, so I think it's about time I started writing again! My first couple weeks I was here alone while Jessi finished things up in Boston I had little motivation to do much outside of work, so I found myself going in to work early and home (I was staying with my aunt and uncle who graciously offered me a place to stay at their home in Bethesda during the limbo time between moving out of the condo in Somerville and into the apartment in Silver Spring) late. That left me pretty exhausted at the end of the day so relaxing, eating, and sleeping were much higher on my to do list than writing. Since Jessi got down here my time outside work has been dedicated to unpacking boxes and transmitting what little I know of the area to her and her sister Becky who flew out to help with the move. Now, however, we're unpacked—if not completely then at least enough to be comfortable—with most of our furniture in place and awaiting delivery on the few remaining items that we've purchased. So time to start looking towards the future again.

My experience here thus far suggests that there's a lot of interesting work ahead. I've got a few Django projects already going on, including working with some new stuff like OpenID, OpenCalais, Clickpass, Twitter, and many other things. I'll probably be starting work on a project using Google App Engine in the near future, and I've already begun learning about and starting to work on iPhone apps as well. So I should have lots of good fodder for technical posts in the coming months!

On top of that there's a whole new city to explore, and nearly the entirety of my family spend time with. Before we knew we were going to be moving, Jessi and I had been planning on getting kayaks this summer so we could spend some time on the Charles and Mystic rivers, maybe the Harbor Islands, and hopefully take them up to the Adirondacks to explore the lakes up there. That plan certainly hasn't changed as now we've got the Potomac and other bodies of water to play with. Plus we're now so close to Shenandoah that it would be a crime not to get in some camping and backpacking. (And after the missed opportunity last winter, I'm definitely planning on some winter backpacking in the Senandoah back country this year!)

So with any luck I should be doing a lot of writing on a lot of different topics in the future. At the very least I need to do some work on this site as I want to integrate my portfolio into the personal site and phase out the business one. And working on this site always seems to give my something to write about.

Good news, everyone!

March 26th, 2009

If you follow me on Twitter or Facebook you'll likely have seen my big news: I have a new job! That's right, I've been hired on as a web developer for Discovery Communications (the parent company of the Discovery Channel). More specifically, I'll be working at Discovery Creative, the subset of Discovery Networks that works on things like web sites (duh) and advertising. It's a pretty awesome job, and I can't wait to get started.

But, true to form, the transition to this next stage in my life is not as simple as that. The job is not here in Boston, rather it's down in Silver Spring, Maryland (just outside the northern tip of DC). So just three short years after moving to Boston, we're moving to Maryland! This is a little less crazy than it might sound. Nearly all of my family is down there, within about 10 miles of Silver Spring. The next largest concentration of my family members (which consists of just my grandmother and an aunt) is in South Jersey, about a 3 hours drive away. Other than that, there's no single place in the coutry where I could live near more than a single blood relation of mine (although there are a number of other places we could go to be overrun with members of Jessi's much larger family). On top of that, Jessi's sister and her daughter (our niece) are moving to Virginia this summer, about an hour away, and my sister is going to be in DC for at least the summer after her graduation in May. Strangely enough, DC actually seems to make a lot more sense for us logistically. The only real complication is what to do with our condo. Fortunately it's about four blocks away from Harvard Law School, basically on the campus of Lesley University, and within walking distance of Tufts University. So we're pretty confident that we'll be able to get it rented pretty quickly, and after some consulting on our mortgage (Best thing about the current economy? We can refinance and knock a good 2% off our interest rate!) it seems as though it should work out pretty well financially too.

So yet again this blog will turn into the chronical of a move. A much shorter move than last time (thankfully; as much as I enjoy driving cross-country, I really am not in the mood to do it again right now), but one that will, I think, prove quite interesting.

Oh, and the best thing about this new job? They have a dinosaur in the lobby!

How cool is that?

[Edit: Corrected a mistake. The parent company of the Discovery Channel is Discovery Communications, not Discovery Networks! Thanks Matt!]

Boston Restaurant Week, Winter 2009

February 18th, 2009

I can't believe I haven't written about this yet, but BostonChefs.com's the unofficial guide to Boston's Restaurant Week for Winter 2009 is live. I've been working on this particular site since 2007 when I first help make some PHP-based improvements to it. Last summer it became my first professional Django-based project when I completely redeveloped it in Django. This year I've made some further improvements to the Django codebase, including a completely re-implemented and much improved Google Maps mashup that lets you view the restaurants geographically.

Previously this had been using some old code that I had inherited from the original site. It was pretty good code, but more modern tools allowed me to vastly simplify it. Specifically, instead of always loading every restaurant and populating the map with markers, then simply zooming in on a specific neighborhood or restaurant, it now only loads the restaurants appropriate for the current target. If you select a specific neighborhood, it only loads the restaurants for that neighborhood, and puts markers on the map for them. Because of that I was able to use Google's API to automatically set the bounds and zoom level of the map to best show those restaurants. This removes the need to manually pick a set of coordinates and zoom level for each neighborhood (having, then, to fine tune it for each neighborhood individually) and instead takes care of all that automatically. The result is a map that's simpler to manage, presents the relevant information more intelligently, and is much quicker to load. All in all, I think it's a pretty big improvement.

Another project goes live: davidsmall.com

January 21st, 2009

I recently went live with another Django project. The Small Design Firm website uses Django and Prototype frameworks to showcase the company's previous projects and news articles. This was a pretty straightforward project and didn't really involve any real hacking, but was none the less a good reminder of how pleasant it is to work in Django and how quickly one can develop a website with it.

Modifying the Django Admin: redirects after adding, changing, and deleting

October 27th, 2008

One of the Django projects that I've been working on for about a year and and will (fingers crossed) be going live in the very very very near future has involved a lot of modification to Django's admin interface. I plan on writing more about the many, many specific changes that I've made to the interface (without modifying the actual Django codebase, so that the changes can be easily applied by anyone without breaking updates), but to talk about them all at once would make far too long of a post. So I'll be taking them on one at a time.

The change I want to talk about right now involves redirecting the user to the page I want them to be at after they've finished adding or editing an object rather than to that object's model's change_list. Normally, if you're editing an Entry object in the Blog app, when you hit save it will take you to /admin/blog/entry/, which is a list of all the Entry objects in the database. However there are some instances in which this isn't the behavior I want. Once such instance involves model inheritance. Say, for example, you have multiple types of Entries which you've accomodated through multi-table-inheritance. Because the different sub-classes are different models, they all have their own change_lists in the Django admin. But I want to be able to view, edit, and create Entries of all types from one page.

Fortunately, Django makes this fairly easy to accomplish. All that is necessary is to override the appropriate methods in the Entry ModelAdmin. That will end up looking something like this:

class EntryAdmin(admin.ModelAdmin):
def change_view(self, request, object_id, extra_context=None):
result = super(EntryAdminAdmin, self).change_view(request, object_id, extra_context)

if not request.POST.has_key('_addanother') and not request.POST.has_key('_continue'):
result['Location'] = iri_to_uri("/admin/blog/entry/")
return result

The exact same modification should be made to add_view as well, and a nearly identical modification to delete_view though it doesn't need to deal with the _addanother and _continue cases. You can then use the EntryAdmin class for all of your varioud Entry sub-classes, or, if you need some other changes to the admin for different Entries sub-classes you can sub-class EntryAdmin for them. Now, whenever you hit the save button after editing any sort of Entry, it will always take you back to /admin/blog/entry/ rather than /admin/blog/linkentry/ or whatever your other subclasses are. If you want it to only take you back to /admin/blog/entry/ if you're coming from a particular page and otherwise take you to /admin/blog/linkentry/ all you need is to add a GET variable to your url (something like '/admin/blog/linkentry/add/?return_to_main=True') and then check for it in your modified change_view, add_view, and delete_view methods with a request.GET.get('return_to_main', False). I've even used this between objects of different model types to create a 'dashboard' page that allows you to view, and alter the relationships between an object of one type with objects of another type. All that's necessary in a case like that is to pass the id of the object in your GET variable and take that into account when creating your uri. An added benefit of that it makes it easy to auto-fill the ForeignKey field when creating a related object. In such a case you'll also need to keep that GET variable in the URLs down the line in order to maintain compatilibility with the 'Save and add another' and 'Save and continue editing' features. But that's still a simple modification:

class EntryAdmin(admin.ModelAdmin):
def change_view(self, request, object_id, extra_context=None):
result = super(EntryAdminAdmin, self).change_view(request, object_id, extra_context)

other_id = request.GET.get("other_id", None)
if not request.POST.has_key('_addanother') and not request.POST.has_key('_continue'):
if other_id:
result['Location'] = iri_to_uri("/admin/dashboard/%s/") % other_id
return result
elif request.POST.has_key('_continue'):
if other_id:
result['Location'] = iri_to_uri("?other_id=%s" % other_id)
return result
elif request.POST.has_key('_addanother'):
if other_id:
result['Location'] = iri_to_uri("%s?other_id=%s" % (result['Location'], other_id))
return result
return result

But more on that sort of thing in other posts.

Duplicating WebFaction's Apache setup

October 13th, 2008

I've been using WebFaction for my hosting for a while now, and have been extremely pleased with them. In addition to the fantastic service I've received, I've been very impressed with the intelligent way they have their servers setup. They've clearly done a lot of work to make things as modular as possible which makes it insanely easy for me to run multiple sites with very different requirements seamlessly on the same server.

Basically what they've done is segment out all of your different websites into 'applications'. Each application in represented as a directory in your ~/webapps/ directory, and is essentially a self-contained environment with it's own apache instance, and, in the case of a Django app, it's own $PYTHONPATH. The end result is that even though all the websites are being stored and run from within my home directory, they're entirely modular, can have different, or different versions of the same, dependencies installed, and can be shut down and restarted independently of one another. On top of all this is a fantastically simple custom web-based control panel that I'm pretty sure is built with Django.

I've been so impressed with how well this setup works, that I've decided to duplicate it on my home server for development purposes. Currently I do pretty much all my development work on my Gentoo Linux powered ThinkPad. To that end I've installed Apache, MySQL, PostgreSQL, SQLite, Python, PHP, &c.; to allow me to mimic the live sites as closely as possible and to allow me to continue working when I don't have internet access (such as when I'm flying or visiting Jessi's family out beyond the reach of broadband). This works very well, but as I'm just using a basic Apache install, without any VirtualHosts, it's not nearly as flexible and means I can really only work on a single site at a time with some work necessary to switch back and forth between projects. Of course most of the time I just use Django's built-in development server when working with Django, but I do end up relying on Apache sometimes, and I'd like to set up my home server as a more complete development environment for both myself and some friends I can grant VPN access to. So to that end I've been looking into WebFaction's setup with the idea of re-implementing it myself.

Turns out it's pretty simple. Simple enough that I almost feel like I should have thought of it myself. Basically, WebFaction's setup scripts create a new 'app' in your ~/webapps/ directory, and populate it, most importantly with a copy, owned by your user, of the Apache executable, some scripts to start, stop, and restart that executable, and an httpd.conf file that sets the (in the case of a Python-based app) $PYTHONPATH variable to include a ~/webapps/yourappname/lib/python2.5/ directory allowing each site to maintain it's own dependencies independently (you can also put things in your ~/lib/python2.5/ for global dependencies if you want). Oh, each application also gets it's own copies of the necessary Apache modules to the same effect. Each application's Apache instance(s) is set up to listen to a different (non-80) port. The end result of this is an extremely simple, extremely modular setup that works fantastically.

Obviously I've left out a step here. If each Apache isntance is listening to a different, non-80, port, how does your traffic get to your actual site? This is the one part that I can't really just peek into the configuration files for, because it doesn't (as far as I can tell, which makes sense) live on the same server as my sites. I assume that what's happening is that WebFaction's name servers are simply pointing requests to (for example) joshourisman.com:80 at my.webfaction.server:portnumber. Again, a simple, yet elegant solution that allows for easy customization and expansion.

I haven't yet tried to implement this setup myself (I first want to move my server from FreeBSD to Linux (which now that I'm using full-time again I'm just much more familiar with), but there's nothing about it that's particularly tricky. Really, the routing is probably going to be the hardest part, but I'm planning on replacing our rather lackluster TrendNet wireless router with a Linux box which will give me much greater control and (hopefully) better reliability.

Replacing files in a Django ImageField or FieldField

September 24th, 2008

Django provides a lot of really useful tools to simplify the development process and let you focus only on the important bits. The FileField and ImageField (a subclass of FileField) are good examples of that letting you simply tell Django that your model will have a file or image and letting it take care of the issues of uploading, storing, and all that. In the past, that's really been enough. It will even automatically delete the file/image when you delete its parent model object. One thing it doesn't do, however (and this has been the topic of much debate), is delete a previously uploaded file/image when you upload a new one for the same model. What I mean by this is if you have a model with a FileField defined and use it to upload some file associated with an object. If you then later decide that you want a different file associated with that object and upload it, it doesn't delete the original file and instead leaves it in place and only changes the path stored in the database to point to the new file. Depending on the nature and traffic your website gets, this can lead to massive amounts of storage being wasted on orphaned files (assuming you don't want to keep those old files, of course). I toyed with a couple different approaches to this, including the possibility of subclassing the FileField to try and add that functionalty directly to the field. While this would probably work, I instead opted for a less generalized method: overriding the save() method of the model to take care of this:

def save(self, force_insert=False, force_update=False):
try:
old_obj = ModelName.objects.get(pk=self.pk)
if old_obj.image.path != self.image.path:
path = old_obj.image.path
default_storage.delete(path)
except:
pass
super(ModelName, self).save(force_insert, force_update)

This work perfectly, though it has the disadvantage of being specific to a particular model, which violates the DRY principle (assuming you're going to use it on more than one model). Fortunately there's a simple way to solve this problem too: subclassing models.Model and then instead of having all your models subclass models.Model directly, have them subclass your own version of it instead. In that case you'll probably want to have it work generically on all ImageFields and/or FileFields rather than having to name them all specifically. This isn't too hard, and you can build up a list of all the ImageFields for a particular model like this (taken from the sorl-thumnail project):

for field in model._meta.fields:
if isinstance(field, models.ImageField):
if field.upload_to.find("%") == -1:
paths = paths.union((field.upload_to,))

[Edit: There was a bug in my code that I've corrected. Details are below in the comment by Comete.]
[Edit2: Fixed another problem in the code with variable names. Thanks, again Comete!]

My first Django patch

September 16th, 2008

I just submitted my first patch to Django! Among other things, this is my first real forray into the inner depths of the Django code. This patch fixes an issues that had been bothering me for quite some time. In Django's admin interface it's possible to specify that a particular field should be automatically filled in with the value(s) you enter in some other field(s). For example, as I typed 'My first Django patch' into the title field of the form I used to write this post, it was automatically filling in a slug field that's being used for the permalink to this post with 'my-first-django-patch'. This is a very useful features and uses just a little bit of javascript to accomplish it. The only problem is that it only works when you're trying to pull information from a text field. Sometimes, however, you might want to pull information from another sort of field, such as a drop-down menu. Previously Django simply wasn't capable of this. With my changes, however, it is able to handle this potentiality quite well.

It's not really a huge patch, just a fairly a little added code to a single javascript method, and there's no guarantee that my patch will every make it's way into the Django code base, but it's still fun to be able to contribute to one of my favorite open source projects ever. The patch, for those that are curious, can be found here, and I've also submitted it to djangosnippets.org here.

Fresh from the Family Farm: A new project goes live

September 12th, 2008

It's always fun doing this: a new project has gone live! In cooperation with BostonChefs.com, Fresh from the Family Farm is an event for local Boston-area restaurants to showcase the possibilities of local ingredients from area family farms. The event runs from Oct. 12 through Oct. 19, and a list of participating restaurants, along with links to make reservations through OpenTable (where available), and links to the restaurant's BostonChefs.com profile (also where available).

The website is powered by Django (which is now at 1.0, something I plan to write about soon), which even still I am growing to love more and more as I use it.

PHP again?

July 29th, 2008

I've just started working on a new project using ExpressionEngine, a PHP-based content management system. I didn't really know a whole lot about it going in (it was the client's choice to use EE), but from what I've seen so far it's a pretty decent piece of software.

Being a CMS, it sits somewhere between blogging software like WordPress, and a framework like Django. Basically this means that it's much more structured than Django, proving a lot more blogging and related functionality out of the box but still much more flexible than WordPress allowing for a lot more freedom in the creation of your website. So far it seems like they've struck a good balance, providing a relatively shallow learning curve while still giving you a lot of powerful features.

Of course, for me, I found the more structured nature of it to be a bit restrictive. Also, I just don't get some of the choices they made. For example, your URLs, while readable and search engine friendly, all look like 'domain.tld/index.php/blog/archive/&c;'. Not a bad URL, but why on Earth is that 'index.php' in there? If they're going to use URL re-writing to provide nice URLs, why do they leave that useless bit of information in there? It's not like it would have been any harder for them to have taken it out. Also, the only obvious way to edit templates is through their web-based control panel. I'm sure there's really nothing stopping me from going in with an FTP client or via SSH and editing the text files directly, but they don't even hint at where you would want to look to do that (and as I didn't install it on the server myself I have no experience with the directly structure). Neither of these problems is a big deal, or a big obstacle to someone who knows what they're doing and wants to change it, but they just seem like very strange design decisions to me.

Overall, however, I think it looks like a pretty good system, and very good way to rapidly build a flexible and highly useful CMS. I don't know that it'll ever be my first choice for a project, as anything I can do with EE I can also do with Django, and in a way that's more intuitive (though probably has a higher initial investment of time), and anything that I don't need that level of flexibility and power for, I'd probably just use WordPress. But still, it's a nice piece of software, and I can definitely see how it would be a very good choice for a lot of people.

Boston Restaurant Week

July 16th, 2008

As those in the Boston area are probably aware, this years Summer Restaurant Week is fast approaching. This year it will be two weeks, those of August 10 through August 15 and August 17 though August 22. If you've been reading my blog for a while you may know that one year ago, almost to the day (off by 5) I announced that I had helped work on BostonChefs.com's Unofficial Guide to Restaurant Week. Well, this year I'm announcing the same thing.

The site just went live with all the information you might want about what's going on with this Summer's Restaurant Week including the restaurants that are participating, what meals they'll be serving, what's on their menus (where available), and a Google Maps mashup to help you find them. The site has been completely redeveloped and is now powered by Django, making this my first Django-based project to go live! (Not counting my own website, of course.)

Go check it out, and bon appetit!

A big new project goes live

June 18th, 2008


It's been a while since I've been able to announce a big new project. Not because I haven't had any, but because everything I've been working on lately has been so large that nothing is quite ready to go live yet. But finally, I get to announce a big project that I recently finished: the Becoming MOBOS video blog. As I'm sure many of you from the Boston area are aware, there is a new Mandarin Oriental that's been under construction down by the Pru. They hired me to create an internal video blog for them. Unfortunately, since it's internal, I can't link to it, but the screenshot to the right links to a full-size, albeit redacted, image. It's a WordPress based blog using a verstion of WPelements.com's MassiveNews theme customized by your truly. I also used FlowPlayer to provide the Flash video playback capabilities. All in all, I think it turned out to be a pretty slick site.

That's not the only news, however. In preparation for announcing the Becoming MOBOS site I've been doing a little work sprucing up my own website. So I also get to announce a new version of the dy/dx tech website (I also changed hosts for it, so you may need to wait for the DNS to propagate if you're still seeing the old site). The overall look of the site is the same as before, but I've removed some rather pointless elements such as the Google Map that used to be on the front page. In it's place is now a slideshow of screenshots from my portfolio, which I think is a much better use of the space. The majority of the changes, however, are under the hood. As you may recall, I redeveloped the site using Django a while ago. Since then I've spent a lot more time with Django and know a lot more about it, so I completely redeveloped the site (using the newforms-admin branch and was able to make a lot of improvements to the code, and basically leave it better positioned to integrate more features in the future. Among other things, I plan on migrating this blog to a Django-based solution and integrating it into the dy/dx tech website to some extent. I've been working heavily with Django for the past several months, and I just keep liking it more and more. It makes every part of my job so much more enjoyable and, in a lot of cases, faster. Be on the lookout for another project going live in the next couple weeks: this one will be Django-based and will be very public, and, I predict, very popular.

I love Django

May 20th, 2008

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!

Finances

January 12th, 2008

2007 being over, and taxes looming on the horizon, I figured I should probably put together my finances for the year. I should have been keeping track of this on an ongoing basis, but...

Pretty much as soon as I started to delve into my records, I realized something: my hard copy records were fairly abysmal. Fortunately, I keep everything on my computer, and the hard copies are more of a convenience thing; as it is apparently the case that they're not actually all that convenient, I'm going to transition into fully electronic record keeping. Don't worry, I keep everything backed up both locally and remotely. I am in IT after all.

I realized something else almost immediately: things are actually going pretty well, especially when you also take my 2006 numbers into account. My business having started in the summer of 2006, I had pretty low revenues for that year. In fact, both my Q1 and Q4 revenues for 2007 were greater than my total revenues for 2006. The upshot of that is that in 2007 I saw approximately 300% growth in revenue over 2006. Quarter by quarter, I maintained an average growth of slightly over 55%.

One point of interest: on November 1 I changed my business model. In that month I brought on a new partner, and December ended up being my second highest grossing month yet, despite the holiday slowdown. Obviously I don't have the final numbers yet, but I can pretty much guarantee that January will beat it, and February will likely beat January. In fact, I'm currently set for Q1 of 2008 to not only be my highest grossing quarter so far, but to repeat the performance of Q1 2007 and gross higher than the entire previous year.

I think this means that my business model is working. :)

Apparently I might just know what I'm doing

December 11th, 2007

The other day I got a call from a recruiter. Apparently Apple wants to hire me to work at the Genius Bar at the new Boyleston Apple Store. Presumably they found me through my Apple certification, and I certainly have the resume for the job. Being a Genius isn't really that bad a gig. You get something like $20/hour, benefits, and, of course, you get to play with toys all day. Of course this isn't exactly the direction I'm looking to go in professionally. I have no particular desire to work retail. And I certainly have no particular desire to do nothing but fix people's computers for $20 and hour when I already do that for more money on the side of a more lucrative business. I might consider a job managing the Genius Bar, but retail tech support seems like a bit of a backwards step at this point.

On top of that I think I may be on the cusp of moving my business to the next stage. As I've mentioned before, I've transitioned my business into being primarily about web development and services. My business model has been to partner with web developers who need someone to do the programming for them. This strategy has been working very well, and for the past few months I've been much busier on average than I had been previously. Now, I think, things may be about to really take off.

I'm about to start a very big project, my biggest so far. Because of that, I'm basically going to be completely booked for the next two to three months while I work on this. But, with my business model being as successful as it has been lately, I can be pretty sure that during this time there will be a number of other opportunities that arise (in fact I already know of a few that will be coming up soon). This is exactly the position I've been working towards since I started this whole experiment just about 18 months ago: having more work coming in than I can handle myself. This means I'm finally at the point where I can seriously consider hiring more people. Of course at this point I'm really only looking for a contractor or two. Someone who can put in a few hours a month for me doing the work I don't have time for myself.

Having gotten to that point there's a clear path forward. While I work on this big new project, I'd only hire contractors as I need them for the work I don't have time for myself. Once it's done and I have a little more leeway to think about other things I can continue to take advantage of them to reduce my own work load and let me spend more time on finding new business. At some point after that I should be able to have enough business coming in that I can afford to hire a developer full-time and focus primarily on sales myself. And, of course, if that goes well I can hire someone to do sales full-time, and then I'll really be getting somewhere. The obvious 'end-point' of this strategy is for me to be managing a company that employs a full-time sales staff as well as a full-time development staff. Maybe even bringing in my own design team, although I think I'd prefer to maintain my partnerships with a large network of designers. At any rate, I think I'm finally approaching the point where I can truly consider this whole venture to be 'successful'.

In the meantime, I guess I should start looking for some contractors. Any LAMP developers out there who might be interested in a little freelance work? I'm mostly looking for PHP developers, but those working with Python, ASP, Ruby and others are welcome as well. Also, I'd favor the Boston area at this point, but am definitely interested in expanding geographically as well. Feel free to send me resumés at josh@dydxtech.com.

My Portfolio

November 28th, 2007

I've been meaning to do it for a while, but I've finally gotten around to creating a portfolio. Since my website is now Django based this was incredibly easy, and probably only took about 45 minutes to do. Previously I've just been keeping a list of links to former projects that I included in emails to prospective clients. I didn't really want to put up a portfolio when I only had a handful of projects to show off. But in the past few days three different projects went live: Lola Boston for which I created the locations database, Tundratour for which I created a database for the different trips as well as a 'shopping cart' to allow people to request more information on multiple trips at once, and Sel De La Terre which was live before but now has a tool for purchasing gift cards online that I created. I figured that 5 projects was a big enough number to go live with, especially as it should be growing pretty rapidly in the next few months.

I'm still trying to decide if I want to put more information in there. Should I put in a little description of each project, or at least expand on what my contribution to the project was? The Chainsaw Awards page was nominated for the MITX awards, I should probably mention that somewhere. Fortunately, now that it's there it will be easy enough to add more to it. The other question I've been asking myself is whether or not I should include websites that I worked on at my old job. I was just as much responsible for those projects as the ones I'm doing now, but somehow it just seems like I should leave them off. Fortunately again, it will be easy to add those later if I decide to. And in the meantime I have a portfolio to show off. A pretty nice one, if I do say so myself.

Also, I do still intend to write that post that I promised while I was in Jamaica, I've just been very busy ever since getting back. I'm going to be away again this weekend (Florida for another wedding), so hopefully I'll be able to get to it next week when I'm back.

A new business model

November 1st, 2007

When I first decided to start my own business, my idea was basically to offer IT services for Mac using individuals and companies. Previously I had been working in IT at an all Mac corporation, so I definitley have the skill set to do this. The problem with that idea turned out to basically be one of supply and demand: there's quite a lot of competition in the field, and as a newcomer without much of a background it was hard to distinguish myself and actually land jobs. During the past 18 months or so that I've been doing this I've gotten some work doing IT, but not really all that much. Instead I found myself filling the gaps by doing web development. For whatever reason, it appears that I'm much better at selling myself as a web developer than I am at selling myself as an IT consultant. So I've found myself doing mostly web development with IT work pretty much being something I do on the side.

So in the past month I've made the decision to change my business focus. Instead of dy/dx tech being a Mac IT business that also does some web development work, it is now a web development business. I've even let my membership in the Apple Consultants Network lapse, as the main benefit I derived from it was the great prices for software which I've now already got. There are a number of benefits for me making this switch. The first is that I'll now be able to focus all my energy on finding web development work rather than it being a secondary focus. Since even as a secondary focus, web development was much more successful than IT, I think this will really pay off. The other benefit is that it will be easier to distinguish myself from the competition. I have a number of web site projects that I'm working on right now, and that I've worked on in the past that I can put my name on. Having that lets me put together a nice pretty portfolio of work, something that IT work just isn't as good for. I'm currently working on putting together a portfolio application in Django to add to my website. This will increase the ability of my website to sell my services, and also serve as visual evidence of my businesses growth and therefore as a rought metric for the quality of my services. I'm waiting to finish up a few of the bigger projects that I'm currently working on before going live with online portfolio.

I will still, however, be doing some Mac IT work. But now I'll be doing it under the In Home Mac brand. In Home Mac is a company started by Matt Moglia, a good friend of mine from High School. He started doing the Mac IT thing for himself in the Bay Area at about the same time I started doing it in Boston. He's apparently much better than I am at marketing those services, and has now built up his company to the point where he's got multiple techs working for him in different areas. I'm now the In Home Mac tech for the Boston area. The main advantage of this for me is that I no longer have to worry about advertising those services. All the advertising and such wil be taken care of for me, so I just have to take care of the work when it comes in. This is just about a perfect arrangement for me as I can focus on selling the services that I'm actually good at selling and still have work to do with the services I'm good at but can't sell well.

I'm pretty confident that this change will, in the next several months, lead to me bringing in a lot more busines than I have been. Especially as I've already got a pretty good business model for the web development side of things. It's pretty rare to find people who are both good designers and good programers. This makes a lot of sense when you think about it, but what most people don't realize is that both skill sets are necessary for functional websites. In general, I've found that web designers tend to do the designing and then either muddle through with what little programming skills they have or get a friend or relative who knows more programming than them to do it on the side. This works for a while but tends not to be a very scalable model for a number of reasons. First, someone who's doing web development on the side can often make time to get one project done, but they just can't do it for project after project because they have other things to worry about. Second, it's usually not reasonable for that person to quit their day job and do web development full time because a single web designer or small web design firm isn't likely to generate enough work to justify a full time developer. So I have an advantage here. I have as much time as I need to dedicate to web development. On top of that, I have enough time to fine more web designers to partner with. The more designers I work with, the more steady the work coming in will be. Currently I'm working with two different small design firms which brings in decently steady work, and I'm always on the lookout for more designers and small design firms that might be interested in hiring me to do their development. This basically ends up being win-win for everyone as several different designers get to have a developer without needing to hire one full time, and I get to work full time as a developer without having to sell my soul to a big company.

My eventual plan now is to partner with enough designers and design firms that I can't actually handle all the work myself. At that point I can bring in more developers in the same way that Matt has brought in more Mac techs and my business can really start to grow not only in size and revenue, but in the variety and quality of the services that I can offer. There's only so much I can do myself, but when I start bringing in more people I'll be able to add their unique skills to the services I can offer and I'll be able to delegate work out in a logical way to improve the workflow, efficiency, and quality. I'm not quite to the point of needing to do that yet, but I think I'm on track to get there. And I've already got a few other people in mind to bring into the dy/dx tech web design fold including an SEO specialist and another general developer who's good with Ruby on Rails.

Working from the road

September 23rd, 2007

This will be my second post written from my iPhone. I'm currently in the middle of nowhere in Illinois at Jessi's mom's house. We'll be here until the 30th, which means I'll have some work to do on the trip. On my previous visits here there was always a wifi network available from one of the neighbors who was kindly sharing his sattelite Internet connection with the rest of the town (it's a very small town and they can't get cable or DSL out here). Sadly it turns out that someone had been using up his monthly bandwidth allotmen so that's no longer available to me. Hence me writing this entry from my iPhone.

Fortunately, I came prepared to work without Internet access. I had planned to do some work on the flight over here, so before I left I created a new Parallels virtual machine and installed a copy of Gentoo Linux in it, and set up a lighttpd server with PHP and Python running in FastCGI as well as SQLite and MySQL so I could do both PHP and Django development without having to only guess at whether or not it would actually work (technically this wasn't necessary for Django since it comes with a lightweight development server built-in, and OS X comes with SQLite installed standard, but I figures I might as well).

I also tried setting up Tinyproxy on my iPhone so I could share my iPhone's EDGE connection with my laptop for browsing, but for some reason it doesn't seem to be working even though I had no problem with it at home.

The end result is that, even though I have no real Internet access to speak of, I can still do my work. I can even keep in touch with everyone thanks to my iPhone and meebo, and, if the need were to arise, I could always set up an SSH tunnel through my iPhone and get SFTP access to my webserver (or any other, for that matter) that way. So even way out here where they don't even have DSL, I'm still fully connected. This is one of those times where, even though I spend pretty much all my time working with technology, I'm still completely amazed by it.

Now, I believe, it's time for dinner.

My first Django site

September 15th, 2007

My first Django project is now live. Sadly it's not a very interesting one, just a re-develop of the dy/dx tech website. It looks exactly the same as before, but it's now powered by Django. This doesn't really offer any advantages at the moment, but it will. For example, pretty much all the data on the site is currently stored in a database which means it will be extremely simple to add, remove, or change any of the services show in the services tab. Not that I really expect that to change any time soon (although you may notice that the services tab is the one part of the website that has changed; I've added a few, and consolidated some redundant ones), but the principle is sound.

More importantly having the site powered by Django will make it much easier for me to add some new features/online services that I've been thinking about for a while. The first one will definitely be a portfolio tab. I've worked on a pretty good number of websites in the year or so since I started this business, and I really should have a portfolio on my website to show off my work. I'd also like to put up a clients tab where I can list my clients and, if I'm lucky, get some testimonials to put up there as well. Then of course there's the WiFi database that I've been talking about for a while, that will have it's own subdomain, but I'll give it its own tab as well. Hopefully now that the whole site is done with Django and I'm a little more familiar with how the framework works development of those things and others will go a little faster.

Boston's Restaurant Week

July 11th, 2007

Most of you probably know about Boston's Restaurant Week. For those that don't, it's a week (or more) that happens twice a year during which participating Boston area restaurants offer meals from a prix fixe menu at very low prices. For example, Excelsior will be offering a three-course meal for $33.07 (I might just have to give that a try).

What you probably didn't know is that there's a fantastic website at restaurantweekboston.com (offered by bostonchefs.com) that will show you all the participating restaurants, the details of their participation, the prix fixe menus that they are offering, and a Google maps mashup to help you locate and get to those restaurants.

I helped create it, so you should go use it to help justify my services. ;)

Working from home

June 29th, 2007

For the past year or so I've been doing pretty much all of my work from home. Occasionally I go into a client's office and work from there, but the vast majority of my work I do here. Right now, for example, I'm sitting on my back porch.

This week, however, has been a little different. As anyone in the area knows, it's been extremely hot. Over 90° for the past three days in a row with about 50% humidity. Not pleasant. We have an air conditioner in the bedroom, but I prefer not to run it if I don't have to so I've been doing a lot of work from elsewhere. Specifically, I did a lot of work from the Breugger's Bagels in Porter Square. They have free WiFi and free air conditioning, so it's a pretty good deal. Yesterday and today I also spent a little time working at the Boloco in Davis Square. Their air conditioning isn't nearly as strong, and wasn't quite enough yesterday, though their free WiFi seems a little more reliable and faster.

Anyway, working from Bruegger's for basically an entire week was an interesting experience. I definitely wasn't the only one; every single day there were at least three or four other people there with their laptops working. Oddly though, there were very few people who did it multiple days. I definitely saw a buch of the same people every day, but they were mostly people who just came in for lunch. The people who came in to do work generally didn't seem to make a habit of it (except me, of course).

I also discovered something about myself. I found that it's much easier for me to focus on work and be productive when I'm not at home. Pretty intuitive really, but the extent to which it's true was surprising. I was definitely much more productive when I was working from Breugger's or Boloco than when I work from home; which isn't to say that I'm not productive from home, just that it's a little easier to get work done when I'm not. As a result, I plan on working from other places more often. This should help my productivity, probably my quality of work too, as well as just get me out of the house more, which will be nice. I only wish that there were more places around here with free WiFi. It's basically Breugger's in Porter, Boloco in Davis, The Druid in Inman, and Grand Prix in ...uh ...out past Porter on Mass Ave. Those places are all nice, but of them only Breugger's and Boloco are really that good for working. The Druid is a bar and doesn't have the most comfortable seating and Grand Prix just doesn't do it for me. I tried working there, but the big Plasma screen showing Sky Sports kept distracting me with rugby highlights. Maybe this is something I can help address as part of the Young Somerville Advisory Council.

In the meantime, I'd like to compile a more complete list of the places in Cambridge and Somerville with WiFi. There's any number of websites out there that claim to have a searchable list of this sort of thing, but in my experience they're usually pretty poorly done. I'm not sure why that is, it's an extremely simple concept. Maybe once I have a big enough list I'll try making one of my own. It's the perfect application for a Google Maps mash-up. Might even make a good added value service for the dy/dx tech website.

Anyone have any suggestions for good places with free WiFi in the area I might not know about?


copyright © Joshua Ourisman 2006-2010 all rights reserved