Home ::
::  Blog
::  Photos
::  About
::  Contact

[No comments] 2011 jan 26 (wed) 17:51  :: 

I'm using the combination of Celery and django-celery with RabbitMQ to do background video transcoding of videos uploaded to a Django web site. I use Supervisord to keep my gunicorn processes running, and I wanted to use to keep Celery running too. Unfortunately, it didn't work out of the box.

RabbitMQ just worked, no need for further comment there, except to say that it has a cool logo and is written in Erlang.

Celery comes with a supervisord/celeryd.conf file, but recommends that you use django-celery's celeryd.conf if you're using Django. This is my very slightly edited version of the file, with paths in directory and command to match the location of my project:

[program:celery]
command=/var/www/virtualenv/project/manage.py celeryd --loglevel=INFO
directory=/var/www/virtualenv/project
user=nobody
numprocs=1
...

When I reloaded the supervisord configs and tried to start celery it wouldn't work. I'd get one of the following error messages:

$ sudo supervisorctl status
celery          FATAL      Exited too quickly (process log may have details)
...

$ sudo supervisorctl status
celery          BACKOFF    Exited too quickly (process log may have details)
...

tail``ing ``/var/log/celeryd.log revealed the following:

...
Traceback (most recent call last):
  File "/var/www/virtualenv/project/manage.py", line 3, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management
...

I fixed if by customizing the Python path in manage.py so that it points to the Python bin in the virtualenv. This line:

#!/usr/bin/env python

becomes this line:

#!/var/www/stage/nikkeienv/bin/python

With that change and another sudo supervisorctl reload everything worked.

 

[No comments]  :: 

Been losing some time recently to a cool indie game that I picked up: Revenge of the Titans. I'm not actually much of a gamer (well... not since I kicked the WoW habit years ago) but this one really pulled me in. It's a sort of tower-defense-meets-realtime-strategy thing. It has retro-looking blocky graphics with scary-looking enemies that look sorta like the Pac Man ghosts. I've been reading through the development blog and some things stood out to me.

Puppy Games a really small studio: two developers, one of whom seems to do all the art as well. One of them lives in the UK while the other lives (lived?) in Spain. They do this part-time, working contract jobs to subsidize their development time.

Revenge of the Titans is their fourth game together, and it builds upon their three earlier games--they re-use characters/monsters, the game engine, and elements of game play (RotT is a sequel to Titan Attacks). They've been working on RotT for 4 years as of January 2011 and it looks like they've spent most of the last year tweaking it!

To be honest, their first couple games (Ultratron and Titan Attacks) don't really grab me, though Droid Assault is starting to get really interesting. RotT, though, is pretty awesome. It's really polished and has some very cool and subtle graphics and gameplay aspects. I can appreciate that they've taken time to carefully decide what features to keep and what doesn't fit. These guys have built up a cool Java-powered engine and set of tools over the years.

I've been feeling burnt out with my jobs recently, and the romace of game development is alluring. It'd be neat-o to write code that involved monsters and cool graphic effects of things blowing up. It'd be neat to work on a project with a friend over several years. It'd be cool to polish something until it shines like this.

 

[No comments]  :: 

Listened to FLOSS Weekly #140 in the car yesterday. The Perl6 people are not only building a new language, including kitchen sink, they're building a freaking distribution system for packaging the thing.

Which reminds me of Emacs Another recent FLOSS Weekly (#136) http://twit.tv/floss136 was about Emacs Org-Mode http://orgmode.org/ Carsten Dominik, the Org-Mode inventor guy put it all into perspective for me: Emacs is not so much a text editor as it is a LISP interpreter and environment that happens to have a text editor as its front-end.

 

[No comments] 2009 may 4 (mon) 12:30  :: 

I recently updated my personal laptop to Ubuntu 9.04. Everything went well during the upgrade, and it's all smooth sailing on the desktop afterwards. It's not an earth-shatteringly different upgrade but it's nice and solid.

The only problem is that it broke my local Django dev installs. I kept getting "Internal Server Error"s from Apache, and the following weird error when running Django's local dev server:

$ ./manage.py runserver
Traceback (most recent call last):
  File "./manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management

After some searching I found this bug report on LaunchPad which basically says that with Ubuntu 9.04 Python2.6 no longer has /usr/local/lib/python2.6/site-packages in the path. You have to put your local code in /usr/local/lib/python2.6/dist-packages. Once I moved my code everything worked fine.

 

[No comments] 2008 nov 26 (wed) 12:31  :: 

Alright, enough with Dojo. No, the project is not dead or anything, I've just switched my loyalties. It was nice while it lasted, but the more I got into it the less I liked it. jQuery is a better fit, at least for me and for what I want to use it for.

Here's how it happened. I wanted to add some date pickers and a tabbed-layer area to one form, and plug in Eric Florenzano's Django threadedcomments to my templates. Eflo used jQuery in his threadedcomments example, and at first I thought I'd be able to whip up a Dojo version of that. I'm sure I could given enough time, but the clock was ticking. I took another look at jQuery and Eflo's examples, and jQuery started to feel less like a black box and more like something I could work with. I switched everything over and feel like I made a good choice.

I wish there was better writing in the Javascript space about the differences between jQuery and Dojo and the other toolkits. As a Javascript outsider it was hard to figure out the strengths and weakness of the frameworks, and the differences in the problems they're trying to solve. I also realized that some programmers seem to be using several of the frameworks together, so they seem to address different levels of the application stack. I haven't found any good writing that articulates this, and I'm not quite sure I understand it well enough to do it myself.

 

1 comments 2008 nov 20 (thu) 11:55  :: 

dijit.Editor is one of those so-close-yet-so-far things. It gives users a way to enter fancy formatted text without having to learn HTML, and is part of the Dojo Toolkit, which is supposed to make Javascript easier to work with. But it was a real PITA to get Editor working with what I think its most common use case: replacing a common <textarea> in a form. I ended up spending almost an entire day googling and paging through O'Reilly's excellent book on Dojo before I got it to work. Here's what I finally figured out.

The Problem:

dijit.Editor can be inserted into a <textarea> like you insert other dijit widgets, using dojoType="dijit.Editor". The editor displays fine and works perfectly, except that it doesn't actually save to your form for some reason.

The Solution:

You have to make your actual textarea a hidden field, use <div> tags for Editor instead of <textarea>, and include some code in the dojo.addOnLoad() function that copies the text of the dijit.Editor field into the hidden field when the form is submitted. There's a good writeup of this over at Dojo Campus.org.

Thoughts

This problem is not mentioned anywhere that I could find in the official Dojo docs. I can see Dojo partisans making the case that dijit.Editor is a Dijit Application rather than one of the Dijit forms widgets, and that this justifies the special handling required. However, I think replacing the plain ol` <textarea> is probably the most common use case for dijit.Editor, so there really should be better documentation of this.

This experience makes me wonder if Dojo is really the right tool for the job I'm doing. I think I might have another look at jQuery...

P.S. JavaScript: The Good Parts is another really helpful book if you're getting into the language.

1 comments
 

[No comments] 2008 jan 8 (tue) 13:39  :: 

I just discovered a little chunk of code that made me laugh out loud. Seriously, a coworker came over to ask what was going on and I had to explain it. In case you're wondering too, the chunk of code is called AsciiDammit.py.

One of the banes of a web programmer's existence is dealing with user input, which can come in almost any form. You have to allow for malicious hackers who try to crash your site using strangely-formatted text, sure, but you also have to allow for users who write text in Microsoft apps like Word, which can also crash your site.

Microsoft, for their own insidious reasons, uses non-standard codes to represent things like "smart quotes", short and long dashes, etc. These codes cause errors in other programs unless they are converted, so every web programmer who hasn't sold out to The Man has to scrub user input before doing anything else with it.

Bless Leonard Richardson! He wrote a little Python class that handles this chore (and perfectly captures my feelings about this whole chore) called "AsciiDammit.py". I love it! The class also has a function called htmlDammit(), that works one HTML with "smart quotes" in it. Genius!

P.S. If you're interesting in alternatives to Word, there were a couple good articles about cool alternatives the other day.

UPDATE (2008-2-6): I just figured out that the Leonard Richardson behind ASCII, Dammit! is the same Leonard Richardson who wrote RESTful Web Services and the most excellent HTML parsing lib BeautifulSoup, His site is chock full 'o interesting stuff, like a script that turns a ReST-formatted text into presentation slides. I wanna be like Leonard when I grow up. :)