glyph and I met for the first time a few weeks ago, and ever since, he's been asking me to do things. Write code, review patches, write blog posts, that kind of thing. Being the lazy person I am, I'm not really up-front or speedy about doing things outside of my habitual box. Thankfully, I got inspired by a troll.
Everybody's read Ted Dziuba's fantastic anti-Node troll, right? It's good food for thought, even if it is a little bit belligerent. I wanted to demonstrate that Twisted doesn't have the same problems as Node. I also wanted to write a small application for Heroku, because I participated in their Python beta and figured out how to run Twisted applications on their platform.
So, I wrote a tiny application that does a few things. First, it runs on Heroku. It includes the Procfile magic for running on Heroku correctly, and only depends on Twisted. Second, it calculates Fibonacci numbers. The idiom that I chose to implement involves not caching the numbers, and instead using threads to do background work. I was going to do something highly idiomatic and Twisted-like, such as setting a timer and coming back to do the work later, but I wanted to show off a feature of Twisted which is completely missing from Node: The ability to write threaded code without leaving your language.
The actual Heroku side of things is kind of boring. Heroku's Python support is fantastic. Use the cedar stack when you create your app with heroku apps:create --stack cedar and put a line into your Procfile which passes the $PORT shell variable into your app somehow. If you're deploying stock Twisted Web, something like bin/python ./twistd -n web --port=$PORT is a good starter. You can, of course, easily deploy WSGI apps on top of this using --wsgi. You must not daemonize on Heroku. That's really about it; it's a very straightforward platform which is easy to use and I'm very impressed by their work.
I have an application running on Heroku right now. The link is currently right here although it might be taken down in a few months when I need to experiment more. I'm a free customer, you see, and I'm not willing to pay a monthly fee just to prove a point about people on the Internets. Anyway, the application does nothing except check how many threads are running on the system, calculate a Fibonacci number, and tell you how long the request took. It can do this for many concurrent users; you might notice, if there are many active requests, that the page will stop loading halfway through as your request to calculate a Fibonacci number sits in line in a threadpool. Your actual browser connection won't be dropped, though.
The code is a demonstration of Heroku's cedar stack and a few fancier things in Twisted Web, like the new templating system added in Twisted 11.0. You can find it on Github; the repo is called "cancer" for obvious reasons.
if my_var is not None: ...
We don't check to see if my_var in locals() or anything stupid like that, because my_var should be easy to track and the line where it was defined should be obvious. If it's not, you're writing bad code.
Last modified on 2011-10-03 10:16:59
Some of you may remember the "Release Date: 2011" meme which we've been spreading for the past two years. We are proud to announce an actual piece of DCoN software, now available for your use.
Presenting DCoN, the Doubly-linked Comic ORM for Newrem. This is the new webcomic management system powering Newrem. It's young, but already it's powerful enough to fill the shoes it was designed to fill, and perhaps other people will find it useful as well.
We are releasing DCoN under the GPLv2, in accordance with obligations laid out by one of the component libraries. We hope it will be instructive for others looking to create or deploy webcomic management systems.
Please note that this software is, as people often say in the business, "brand-spankin'-new," so don't be surprised if there are still a few bugs left to hammer out.
Last modified on 2011-09-04 13:26:24
Hi! Just a quick status update on that crazy Chromebook of mine.
To get VBA-M to work, use the GTK+ frontend by emerging with USE="gtk". Set it however you like; I highly advise against setting it globally, but if you have sgt-puzzles installed, you will already have GTK+. Afterwards, you will have a shiny new gvbam executable, ready to use.
While ZSNES might be very unhappy, Snes9x can correctly accept input. Well, to a point, at least; sound output and screen scaling appear to be broken. More research is needed.
Last modified on 2011-08-13 15:22:29