08 November 2008

Setting Up A Django Development Virtual Environment on OS X

This is a simple script I currently use to set up a Python virtualenv for Django development. It just sets up a new virtualenv and checks out the latest revision of Django from their web site. Maybe someone else will find it useful. Improvements are definitely welcome!

#! /bin/bash
virtualenv env
svn co http://code.djangoproject.com/svn/django/trunk/django env/lib/python2.5/site-packages/django
cp env/lib/python2.5/site-packages/django/bin/django-admin.py django-admin.py

I save the script in /usr/local/bin as "djangovirtualenv.sh" and whenever I want to setup a new environment I do this:

justin$ cd ~/projects
justin$ mkdir NewProject
justin$ cd NewProject
justin$ djangovirtualenv.sh
justin$ source env/bin/activate
justin$ python djangoadmin.py startproject newproject

You can get virtualenv from PyPi

02 October 2008

Why Apple Might Close the iTunes Store

Vice president for iTunes, Eddy Cue:

Apple has repeatedly made clear that it is in this business to make money, and would most likely not continue to operate iTS if it were no longer possible to do so profitably

While the consensus on the web seems to be that this would never happen, I think a strong case could be made for Apple exiting the music sales business - if it did become unprofitable - and turning the iTunes store into a distribution platform for a current rival such as Amazon. Such an arrangement would allow Apple to keep the iTunes/iPod integration and lose the continued hassle of RIAA negotiations and DRM enforcement.

Via BBC News.

26 September 2008

"Mission Accomplished"

I read about this earlier but now it seems it's been confirmed. John McCain truly is a maverick if he can win a debate he wasn't planning on attending before it even occurs. Brilliant.

World, Stop for a Moment

Even Huckabee's calling McCain out on this bullshit political maneuver:

You can't just say, 'World, stop for a moment. I'm going to cancel everything,'

- Mike Huckabee on John McCains attempt to postpone the debate

22 September 2008

The Way Out Is Through

There is no more MTV, radio has lost it's reach and the major record labels are losing their relevance. Still, I never thought I would be getting direct marketing emails from Trent Reznor.

Message from Trent:

Hello everyone.

I'd like to thank everyone for a very successful year so far in the world of Nine Inch Nails. I'm enjoying my couple of weeks off between legs of our Lights In The Sky tour and got to thinking... "wouldn't it be fun to send out a survey to everyone that's shown interest in NIN?" Well, that's not exactly how it went, but regardless - here it is. As we've moved from the familiar world of record labels and BS into the unknown world of doing everything yourself, we've realized it would benefit us and our ability to interact with you if we knew more about what you want, what you like, what you look like naked, etc. I know it's a pain in the ass but we'd truly appreciate it if you'd take a minute and help us out. As an incentive, everyone who completes the survey will be able to download a video of live performance from this most recent tour (and I know what's going through your little minds right now: "I'll just grab this off a torrent site and not have to fill out the survey!!!" and guess what? You will be able to do just that and BEAT THE SYSTEM!!!! NIN=pwn3d!!!)
BUT
What if we were to select some of those that DO complete the survey and provide them with something really cool? I'm not saying we'll ever get around to it, but if we did maybe something like signed stuff, flying someone to a show somewhere in the world, a magic amulet that makes you invisible, a date with Jeordie White (condoms supplied of course), you know - something cool. See, you'd miss that opportunity AND be a cheater. Do the right thing - help us out. You'll feel better.

Thank you and I've had too much caffeine this morning,
Trent

I can't imagine I'm the only one waiting to see what he does next.

Update: I took the survey and I am now eagerly awaiting my date with Jeordie White.

20 September 2008

Nanorganization

I currently sync two playlists to my iPod. A "smart" playlist and a manual playlist named iPod Smart and iPod Manual respectively. The "smart" playlist is configured to select 115 songs ordered by date from my library where a: the rating is greater than two and b: the play count is less than two. The other serves as a way sync up a few current favorites or even a pod cast.

As the idea of an iPod large enough to hold your entire library goes the way of the virtually ignored "classic", I think apple would do well to make some improvements in the tools it provides for managing and syncing it's iPod devices. What are your tricks?

Update: as I was syncing my iPod this morning I realized you could limit a "smart" playlist by total bytes (in GB and MB). This is a far more reliable method for someone like me trying to use every bit on a small drive. I'm not sure if this is a new feature in iTunes 8 or if I just never noticed before.

17 September 2008

Bandcamp

Great ideas are often based not on doing something new, but doing something the way most people didn't even realize it should be done. Bandcamp, the newly launched digital music publishing platform, looks like it may just fall into this category. As a musician, as well as a developer, I'm terribly excited about it's possibilities.

If you're at all interested in independent music or web application development, do yourself a favor and read the interview with Bandcamp founder Ethan Diamond at Waxy.org.

02 September 2008

Chrome Notes

Vassup!

  • Install and import process is painless and idiot proof
  • When you open a link in a new tab it opens next to the parent tab not at the end of the list
  • Built in site specific browser (SSB) functionality
  • Incremental but significant improvements to existing ideas such as the "omnibar" and the new tab page
  • WebKit
  • Minimal interface
  • History and bookmarks, all searchable and seamlessly integrated
  • It's really, really fast

Ich Don't Think So!

  • No Mac/Linux version, yet
  • The window "chrome" is very, very blue

Google Chrome

11 August 2008

CSS Variables

Alex Russell takes the W3C to task for this essay on CSS variables:

CSS authors who maintain the world’s most popular landing pages are contending with thousands of lines of CSS per page and hundreds of rules. This is orders of magnitude more complexity than the initially presented numbers, hopefully dispelling any notion that we could rely on those numbers as the basis for asserting anything but that those in the employ of the W3C and the volunteers which join them are not typical content authors and do not attempt the feats of CSS which are meerly [sic] work-a-day constructions for commercially successful websites.

There have been days in my career when I would probably have strangled the life from the author of this essay with my bare hands if it meant I could define variables in CSS.

31 July 2008

Origin Story

Every superhero needs an origin story.

Occasionally people ask me about the origins of my nickname BDFL (Benevolent Dictator For Life). At some point, Wikipedia claimed it was from a Monty Python skit, which is patently false, although it has sometimes been called a Pythonesque title. I recently trawled through an old mailbox of mine, and found a message from 1995 that pinpoints the origin exactly. I'm including the entire message here, to end any doubts that the term originated in the Python community.

I now find myself contemplating the existence of a Bizarro GvR.

30 July 2008

So What's "Cuil" Supposed to Mean Again?

Macworld:

Maybe Cuil’s founders tried to find an Irish dictionary using their site and couldn’t. Searching on Cuil.com for “Irish English dictionary” fails to turn up a link to such a dictionary in at least the first six pages of results.

Ouch.

26 July 2008

Dropbox is Better

I finally got an invite to the Dropbox beta program and having been trying it out for a few days now. It's minimal but it's lightweight and the web interface is clean and easy to use. It works quickly and quietly in the background and that's possibly the best compliment I can give any backup solution. It doesn't however, support all the features that MS Live Mesh provides.

Using Live Mesh, you can remote access any windows desktops in your cloud from any other device, including any Active X capable browser. Of course this leaves out Firefox, Safari and Opera. File access is supported for those browsers however, so they got that going for them. You can also add any folder on your Windows desktop to your "mesh" whereas you have to move files and folders to your Dropbox to have them sync.

Both of these services provide file backup and sync from multiple devices (desktops, laptops, Live Mesh promises mobile support). A file, once added to your "mesh" or your Dropbox, is immediately copied to the service's online system, and from there propagates down to each of your other devices. With Dropbox, and I'm imagining Mesh works similarly, if a file is modified only those modified bytes are transmitted. This reduces the amount of time and bandwidth the service needs to keep things in sync.

For right now, if you're on Mac or if you don't need the ability to remotely access your other devices I heartily recommend Dropbox. Live Mesh just feels bloated and clunkly in comparison.

25 July 2008

Force Gmail to Connect Using HTTPS

From the Official Gmail Blog:

We've added an option to Settings to always use https. If you don't regularly log in via unencrypted wireless connections at coffee shops or airports or college dorms, then you might not need this additional layer of security. But if you want to always use https, then this setting makes it super easy. Whenever you forget to type https://mail.google.com, we'll add the https for you. If you already have the https URL bookmarked, using this setting will ensure you access your account via https even when you don't use your bookmark. Any http link to Gmail (for example, the one at the top of Google.com) will be automatically redirected to https."

Home Economics

Jamie Lee Curtis:

"I am glad that I was given these skills as part of a basic, public school education. I want that for all children. So that whether they end up a political leader, scientist, teacher, artist or homemaker they all are given the best education possible so that they can develop their God given talents and abilities and flourish and thrive as adults."

I love to cook and I believe that sharing good food is an absolutely vital aspect of the human experience. It's a travesty that so many children in this country are being raised by parents who couldn't even put together a good casserole if their life depended on it.

Read the original article (The Huffington Post).

24 July 2008

iPhone Game Delisted Due To Security Concerns

"...because it's pretty much unfeasible to test each application to make sure they're not sending out your private data."

How exactly is it unfeasible for a company like apple to test the functionality of software written for their proprietary device in a proprietary development environment? They control the horizontal and they control the vertical. They chose to make themselves responsible when they decided to make the app store the only way to legitimately ship iPhone software and they screwed up letting this slip through.

Read the original article on Gizmodo.

Honest Music Consumers Get Screwed Again (and Again)

And the RIAA wonders why people steal music. From the YAHOO! email:

After September 30, 2008, you will not be able to transfer songs to unauthorized computers or re-license these songs after changing operating systems. Please note that your purchased tracks will generally continue to play on your existing authorized computers unless there is a change to the computer's operating system.

(Via Read Write Web)

18 July 2008

Older Than Dirt

So I turned thirty last week. Not exactly an event I wanted to announce from the rooftops (so instead I write about it on the internet?), but it beats the alternative. A few friends came out to celebrate and it was quite nice even though I caught a massive amount of flak for drinking Patrón on the rocks (with fresh lime of course — it's so good when it hits your lips). I do have a tendency to "dish it out" more than I "take it" so it was probably justified.

Oh, and the wedding went well. Not quite as planned, though I received nary a death threat and even a few compliments on the service so it must not have been too painful for those who attended. Even after years of performing both in small-time garage bands and in the theater, it was definitely the most nerve-racking experience of my life. Congratulations Mr. and Mrs. McKinney (I did my best)!

29 June 2008

I Now Pronounce You...

At one o'clock today I'm officiating my friends Ian and Heather's wedding. I've got my little speech written and I'm pretty sure all our paperwork is in order. Should be fun and it is definitely going to be interesting!

07 June 2008

Tell Me How You Really Feel About The New Google Favicon

Isaac Schlueter of Foo Hack has devised a strategy for reinstating the original Google favicon using a local apache proxy server. Personally I think visual identity has always been a weak spot for Google and the new icon really doesn't bother me much anyway (I tend to look at tab titles mostly and Safari doesn't even show favicons on tabs). Still, I have to admire him for doing something proactive and not just whining about it.

27 May 2008

Carnivores Like Me

Seed magazine has posted a very interesting, balanced and well written article about the impact of rising meat consumption around the world. As a meat-eater who's been trying to reduce his meat intake for health reasons (curse you, sedentary lifestyle!), I may now have some additional motivation.

Carnivores Like Us

Google Launches Its Own JavaScript Library CDN

Google just launched it's AJAX Libraries API. This is great news for the smaller, independent libraries but with Dojo already being hosted by AOL this move would seem to actually hurt their ability to optimize client caching by splintering deployment. I imagine the Dojo team is supporting this so maybe they know AOL is a horrible company with deplorable customer relations and an even worse environmental track record something I don't.

16 May 2008

Read This Later

One of the web services I've been using a lot lately is Instapaper. A site that lets you quickly save links to content you want to read, just not right now. It's like bookmarking, only transient. Sign-up is equally simple. All you need to do to get started is to supply either a user name or email address, a password is optional, and grab the bookmarklet.

15 May 2008

13 May 2008

A Few Favorite Mac Applications

I'm a switcher. I had no interest in anything Apple OS 9 and earlier. With the switch to X86 and OS X's geek-approved (and web development friendly) Unix foundation, I was forced to re-evaluate my position. Here are a few excellent applications that have struck a chord with me in my time with Apple.

TaskPaper

The GTD movement is officially out of control. That said, this little application from Hog Bay Software is a testament to the power of simplicity. If you'd rather spend more time working then you spend setting up your to-do lists, this app is for you.

Skitch

Everyone loves Skitch. Take a screen shot, annotate it, draw on it, upload it. If you're a software developer, once you file your first LOLBUG, you'll be hooked.

DrawIt

DrawIt has a clean single window interface, a simple plugin infrastructure, non-destructive editing and and good export options. While still not a replacement for Photoshop, this has become my favorite Core Image editor.

Media Snap

MediaSnap allows you to search Youtube and download the videos to your desktop as Quicktime movies. It's simple. It works. It's free.

TextMate

There are two kinds of software developers. Those who use huge, monolithic IDEs; and those that prefer a simple, lightweight, text editor. TextMate is the answer for anyone who falls into the latter category.

Edit: Added the URL for DrawIt's web site.

11 May 2008

Madeline

My niece was born today at 6:15 AM. She's healthy, weighs just under 7 pounds and measures 20 inches long. She is my bother's first child and my first niece (or nephew). Today is first day of her life. For her, anything is possible.

10 May 2008

An Ode To Spring

Waking up,
in the light.
Mountain bike.
Grill at night.
Rummage sales,
and local ales.
Garden's green.
House is clean.
I love Spring.

08 May 2008

On Amazon And The iTunes Music Store

Jeff Atwood has a great write up on his blog about why we should support DRM free music. For the most part I agree with his points (I love that Andy Baio quote). However, I think there's an aspect of the situation that's overlooked.

The real reason the iTunes music store was successful while so many others failed was in it's design and execution. Apple was the company that figured out how to make purchasing digital music fun, easy, and aesthetically pleasing. There's real value in the experience that Apple has created, that Amazon fails to provide.

I have not purchased DRM protected music in a long time. There's just too many other legitimate options these days. But if I have the choice of iTunes DRM free or Amazon I will choose Apple every time.

07 May 2008

Reflections On A Glossy Screen

When I first heard the new iMacs were shipping with ONLY glossy LCDs I was bummed.

"I'm a designer" I said with only a touch of self-congratulation, "and it's impermissible for us to use a glossy LCD!"

Never mind that LCDs themselves were technology non grata in the design world not long ago; a glossy screen was out of the question until I realized...

These days I do probably 90% of my work on the web where color reproduction is about as reliable as font availability or screen resolution and testing my designs on a variety of displays (including glossy ones) was much more important than the accuracy of my monitor.

Now I only have one problem. I can not stop cleaning this damn screen! I tilt the monitor so the light hits it "just so" and buff it over and over again with the little included cloth until my arm aches; and then I buff it some more. I buy expensive pre-moistened cloths. I get far too much satisfaction from see my reflection in it's perfect glossy black surface. My glossy screen has made me OCD.

Edit: Changed the title.

01 May 2008

I'm An Internet Superstar

This is just a note for the new people dropping by because this blog was featured. It has been nice to get a traffic spike but I've been forced to turn on comment moderation due to the spam and the "Nice blog! check out http://43usesformayonaise.blogspot.com!" comments I've been receiving.

Please feel free to leave a comment, it just make take me a while to get to it. Thanks for reading!

(Vote Obama!)

28 April 2008

Drawing Parallels

Picked up Parallels 3 with the MacUpdate bundle. So far I've been very impressed by the stability and surprisingly deep integration it provides. I'd dig on some DirectX 9 (or 10) love but at lease now I can easily test my web pages in IE6. Am I the only one that feels a little "godly" when running an OS in virtualization? It's like crazy, Frankenstein science that defies the rules of nature.

Because You're Smarter Than XML

While developing Atom Syndication support for the new site I started to get fed up (ha!) with the standard methods of XML generation in Python. Obtuse and verbose, the number of lines of code it took to generate a simple feed grew to an order of magnitude greater then the number of lines it took to serve that same feed. I wanted something a little less error prone and a little more convenient than string manipulation, but I didn't need any sort of validation or schema support or any of the other things that make the standard XML libraries "smart". The end result was StupidXML, a genuinely "stupid" XML generation library. I've put the code up on Google Code in case someone else will find it useful, let me know if you find any bugs!

15 April 2008

We Are What We Program

The image below, taken from the Google Code page for the App Engine SDK, provides an interesting look into the mentality of programmers drawn to specific languages.

Java

The Java programmer doesn't capitalize sentences or proper nouns as the language's strict syntax has left him with a weak sense of self and a "hive-mind" mentality.

Ruby

The Ruby programmer has a stronger sense of self but leaves the name of language uncapitalized due to his insecurity in the language and it's "celebrity" proponents.

PHP

The PHP programer's sense of entitlement is only outweighed by his inexperience.

Perl

In Perl, brevity is everything.

Edit: Fixed a spelling mistake as pointed out in the comments. Judge not, I suppose.

Edit: Fixed apostrophe as pointed out in the comments. This will teach me to post while inebriated.

13 April 2008

OS X Quick Tip

Cmd-Option click a dock icon to hide all other windows. I didn't know this and I use it CONSTANTLY now.

10 April 2008

Google App Engine And The Value Of What It Isn't

Since the announcement monday of Googles App Engine service I've heard little but complaints (apart from a few informed assesments) from the internet at large. Now this doesn't surprise me and I'm sure on some level the App Engine teams is grateful for the attention, negative or otherwise. However, I think this reaction sheds some light on how many web developers have become so entrenched in their own development "comfort zone" that they can't see the value in exploring beyond the boundaries of their own languages and frameworks.

Google Hasn't Taken Anything From You

From some of the reactions I've read this week you'd think that by choosing Python as the initial language for App Engine Google had somehow rendered all other development environments obsolete (and ran over everyone's dog in the process). There also seems to be a number of developers lamenting how hard it will be to "port" their existing applications to this new environment as if that had been mandated by some higher power. Why can't we just get along look at this from the perspective that whatever options you had for web application development on Sunday, you now have one more. Whether you choose to use it or not.

You Got Your Framework In My Framework

Another issue that's rubbing people the wrong way is the simple fact that either their framework of choice isn't supported (Pylons, Turbogears, CherryPy) or isn't fully supported (Django). I use, and respect, these frameworks but I personally think it was a mistake to "support" Django in App Engine. Whatever they gained by playing to one of the largest Python web developer communities, I think they lost more by giving people the impression that App Engine is just another mod_python to bootstrap your framework to. App Engine IS an application framework, maybe not a full stack, but enough that there are as many parts of Django that are either redundant or incompatible as there are parts that are functional.

You Can Choose Your Own Colors Even When You Have To Color Within The Lines

I've spent a decent part of this week evaluating the App Engine SDK and having a blast building my own framework to fill in the holes in Googles service. As so much functionality is available from the SDK, it's been easy to assemble the few pieces I need and wrap them up in a package that I think will be flexible enough to handle pretty much any project I can throw at it. Based loosely on the Pylons framework, A simple WSGI "front controller", Routes, WSGI based app controllers and a few convenience utilities was all it took to get a fairly robust system up and running. As an added bonus, the entire framework (apart from external libraries) is spread over only 3 files.

We're All Still Working Out The "Kinks"

My little framework's not perfect yet, and probably never will be, but neither is App Engine. I still need a good template engine, and a web form generation library for the datastore models would be nice. But even without these "niceties" it's a very productive environment considering it probably took me less then 6 hours to build. I've be denied certain choices I've become reliant on (PIL, Mako), but with quality of the initial APIs and Googles repeated insistence that the framework is nowhere near feature complete leave me at least hopeful for replacements in leu of fixes.

09 April 2008

App Engine Revisited

So I still haven't gotten my App Engine invite (sigh) but I've been working with the SDK and I've got a skeleton framework up and running with WebOb and Routes for controller dispatch. I've also put together a simple blogging application. I find the system limited, but limited in a way I think will inspire creativity among those who like to push the boundaries they've been given.

The included WSGI framework is admittedly simple, and I'm personally not that fond of the parts of Django they've managed to shoehorn into the environment so I think I'll be rolling my own framework for all future projects. A sort of Pylons lite, if you will. Routes, Mako (if possible *crosses fingers*, I have "issues" with Django templates) and Googles data store/ORM. I'm still debating the necessity of a session framework like Beaker if I'm going to be using the Users API but it would be nice to have.

Anyway, I hope to get an invite soon (hello? anybody?) but at least I'll be ready when I do. Hopefully this blog will soon be served up from AppEngine!

08 April 2008

Google Announces Google App Engine

The highlights for now:

  • Python! *Squeeee*
  • No C Extensions (boo! understandable, but still boo.)
  • WSGI!
  • Django!
  • Google Mail, Apps and Accounts integration!
  • BigTable™
  • FREE!
  • Did I mention Python and WSGI?!

I've got to go change my pants now, but I'll post my extended thoughts later. I'm furious I didn't hear about this sooner and get one of the initial invites. WTF internets?!

15 March 2008

How To Lose A User In Less Than 30 Seconds

Today Yazsoft, the developers of Speed Download decided the bad press they were getting from not giving Macheist customers a free upgrade to version 5.0 of their software was not worth the few licenses they'd have to give out to calm down the vocal minority that somehow decided they got just a little less free stuff than they deserved. I bought the Macheist bundle and personally, I didn't feel cheated in slightest. I was given Speed Download 4, basically for free; and the jump in logic I'd need to make to assume that I was entitled to get the upgrade totally gratis alludes me. Regardless, I never actually installed Speed Download 4, so when my free registration what sent I figured that since so many users fought so hard to right this "injustice", I should at least install the newer version to what all the fuss was about.

The Speed Download 5 distribution is a zip file containing the Speed Download app and nothing else. Without any installation instructions or a readme file I figured following standard Mac procedure was a good idea and copied the app bundle into my Applications folder and opened it. When run for the first time the app gave me two choices; a "manual" install that claimed to let me decide which components to set up and a "automatic" install that would integrate Speed Download into Safari, iTunes and possibly the small nerve cluster at the base of my brain that controls breathing (I'm just hypothesizing here). Having never used the application before, and not being familiar with the developers I chose the "manual" setup.

Things seem to go smoothly and once the application was set up and registered I figured quick test was in order. I opened Gmail and clicked the download link on a recently received file attachment and watched the default Safari download window quickly save the file to my Downloads folder.

"Must be the manual install." I deduced aloud. "I bet I just need to turn on something in the application preferences."

Within in the application preferences however, the Safari integration pane seemed to indicate that nothing was disabled and everything should be working.

"I'll just check the docs." I said.

I can only assume these docs were written for the obviously more intelligent users who had chosen the "automatic" setup as there didn't seem to be any information on "setting up" the Safari integration.

"Ok, fine, I'll uninstall the application and try the "automatic" setup." I conceded.

I selected the support item entitled "How to uninstall speed download properly" and was greeted with the following instructions:

  • You cannot simply trash the Speed Download folder to un-install it.
  • You must use the included un-installer.
  • Quit all browsers and any running copy of Speed Download.
  • Run the SD Uninstaller (located in your Speed Download folder).
  • Log out and log back in.
  • Empty the trash.

Now the observant reader may recall that the version 5 distribution came as a zip file containing only the application bundle. There was no "Speed Download" folder to speak of, let alone an "SD Uninstaller". Is the Speed Download folder created when you choose an automatic install? It didn't say.

This entire process may have taken slightly longer than 30 seconds, but if so, just slightly; and as a direct result of my brief experience with this program, I now have an unfortunate first impression of Yazsoft. Installing an application on my computer is a vote a confidence (or at least a wager against the likelihood said application will corrupt my system) and in my opinion your application should describe in detail what it wants to install and what functionality you will be surrendering by not letting it do so.

This was definately not the worst software experience I've had, and admitedly, I'm being rather harsh on a program that probably works quite well for people who are were willing to let it install itself into wherever it wants. Perhaps as a part-time Windows user, I've become paranoid about the true intentions of the applications I install. Regardless, for now Speed Download has been "App Zapped" from my Application folder.

I hope the Macheist users are happy with it.

Update: I sent an email regarding the "missing" uninstaller to Yazsoft's support email address and received a very quick reply with the uninstaller attached. This kind of support response time on a Saturday is impressive and as I was asked, I tried to quickly summarize my issue with the setup process in reply. I will definitely have to give the application another try.

14 March 2008

Post Traumatic Stress Disorder

I would really like to hear President Bush explain how he thinks this country will assimilate an entire army of Americans that have been damaged in so many ways by that cluster-fuck of a war he's started and is now leaving us to deal with. It makes me sick to think of another generation of forgotten solders living on our streets because the government has no need for them anymore, and society is ill-prepared to help them readjust.

Parents Of Marine Found Dead Seek PTSD Awareness

A Pure Python WSGI Server

I'm currently evaluating Python WSGI HTTP servers for a new project. Right now, it seems my best options are the Paste server and the Cherrypy server as the twisted implementation is still in development and a little rough around the edges from what I've heard.

If you've had any experience with these libraries, or would like to suggest a solution that's not listed here, please drop me a comment or an email.

11 March 2008

SQLite As A Production Database (No, Really)

There's a certain stigma surrounding Sqlite. It seems that many developers will happily use it to prototype a project, but wouldn't think of deploying on anything less than Postgres (or MySQL, if you swing that way). I say this partially because I used to feel this way myself. I've run more low traffic web apps off of a Postgres server than I'd care to admit now that I've discovered the inherent convenience and manageability of a file-based SQLite database.

With SQLite an entire python web application fits within a single directory on the disk. This makes backup, testing and maintenance easier than you can likely imagine. SQLite also requires next to no setup, and most likely, is already running on your server.

Recently a user came across a bug in one of my web applications. In order to reproduce the bug, I didn't have to set up a test database and populate it with dummy data. Instead I merely copied the actual production database file along with the application files and within minutes had an identical copy of the application, data and all, running on my development machine.

There are trade-offs with SQLite and the developers make this very clear. Concurrent writes are an issue (I'd wager that actually very few web sites depend upon a large number of concurrent database writes) and the types system can throw traditional database developers for a twist. All the same, as the development community comes to grips with the fact that scripting languages can solve real problems as well or better (when you factor in time-to-market) than compiled languages, I think projects such as SQLite and CouchDB will finally motivate developers to begin looking for data persistence solutions in places other than monolithic relational database servers.

"SQLite isn't trying to replace Oracle, it's trying to replace 'fopen'" - D. Richard Hipp, creator of SQLite

- FLOSS Weekly Podcast with D. Richard Hipp, the creator of SQLite.

07 March 2008

I Believe The Children Are Our Future

41 Hilarious Science Fair Experiments

I wonder if they ever published the results of "Crystal Meth - Friend Or Foe?".

Update: That "Drop It Like It's Hot" kid could be the only person in history to get some action from a science fair experiment.

05 March 2008

Django Photologue 1.0 Released

Photologue, after several revisions, refactorings and the addition of many new features, is finally being released as a complete product. The database schema is set, the documentation is finished, and I think it's damn nice piece of software.

From the project page:

Photologue is a Django application, more specifically, it's a complete image management solution for your Django site. Photologue replaces the ImageField in Django with a powerful system that supports resizing and image effects as well as providing a turn-key photo gallery solution. Photologue embraces the Django admin and smoothly integrates with photo thumbnails and effect previews.

Get the files and read the docs.

23 February 2008

Objects With Shared State In Python

Back when I was hacking on PHP and rolling my own webapp frameworks ("in the day" as it were) I'd often use the singleton pattern for creating a app "registry" where global data and variables could be stored and accessed by objects anywhere within the framework. Since moving most of my web development projects to Python a couple years ago I haven't really had any use for such global, shared state objects. That is, until I received this issue ticket for Photologue.

Some background...

Photologue provides a way to define "Photo Sizes" within your database that all your uploaded images can be resized to automatically. When a photo is requested in a certain size, the system loads the appropriate size description and resizes the image as specified (if the sized image has not already been cached). This gives the programmer/designer/site-admin a lot of freedom when developing apps and pages as any number of photo sizes can be defined at any time without changing any code or restarting the server. This was also causing the Django's ORM to make an unreasonably large amount of queries when a page full of images was loaded as each image was querying for the photo size object as it was loaded.

The fix was twofold. First, when a Photo object is initialized a function is called that adds a number of convenience functions for accessing the defined photo sizes. For instance if you define a "thumbnail" photo size a method named "get_thumbnail_url" would be added to the instance and would return the url of the photo sized to the "thumbnail" specification. These functions were originally added by "curry"ing existing functions on the model ("get_SIZE_url, get_SIZE_path, etc.) and the names of all found photo sizes. When called these function would use the name supplied to load the photo size from the database. The first fix was simply to pass the actual photo size object it self to these functions, eliminating the need to load them later:

for photosize in sizes:
    setattr(self, 'get_%s_size' % photosize.name, curry(self._get_SIZE_size, photosize=photosize))
    setattr(self, 'get_%s_url' % photosize.name, curry(self._get_SIZE_url, photosize=photosize))
    setattr(self, 'get_%s_path' % photosize.name, curry(self._get_SIZE_path, photosize=photosize))

Which brings us to the the title of this post...

I needed a way to load the photo size models once and then let any and all photos access these sizes without having to load them again. A global variable would work (as suggested by the original issue submitter) but seems kludgey and one thing I love about Python is being able to solve problem in a way that is as elegant as it is functional. So I did a little research and came across a pattern for creating classes with shared state. That is, all separate instances created from this class will maintain the same state wherever they exist within your program. When one instance is modified, all instances reflect the change. For example here's the class used to cache photo sizes within Photologue:

class PhotoSizeCache(object):
    __state = {"sizes": {}}
    def __init__(self):
        self.__dict__ = self.__state

Now, when a photo needs to access the list of photo sizes it simple instantiates an instance of PhotoSizeCache, which automatically is assigned the class's global state, and checks to see if the "sizes" dictionary has a length. If not it loads the full list of sizes and stores them within the cache for other any other objects to find. The final result was a drastic reduction in the number of hits made on the database (three down from over two thousand on a test page loading around seven hundred images). It's still global state (me bad?) but I think it has a certain beauty that's only made possible by Python's dynamic nature.

16 February 2008

Show/Hide Hidden Files In Finder

Show (in Terminal):

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Hide: (in Terminal):

defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder

Installing MacPorts 1.6.0 From the Package Installer

If (like yours truly), you try to install MacPorts 1.6.0 from the pkg installer and the postflight script hangs or fails to complete, the following commands should do the trick (why this information isn't on front page of the MacPorts project is beyond me):

sudo curl -O http://svn.macports.org/repository/macports/branches/release_1_6/base/portmgr/dmg/postflight
chmod -x postflight
./postflight

(What an exciting way to start a new blog!)