Here’s some handy code for generating combinations of strings in Python. Provide a string with substitution variables and a list of iterables, and poof!
Doing things the un*x way means keeping a supply of “go-to” tools for the various tasks that spring up during development. For me, that’s a lot of bash, python and Perl on the dev machine and recently node.js on the server.
scraping acquiring multi-lingual (Unicode) data for a project, I had to make sure I kept the correct utf-8 encoding all along the processing pipeline. One screw-up and it’s garbage out. Here are some tips:
Here’s a tip for those of you using express as your node.js web framework. If you need a date library for pretty-printing in various date formats, do NOT use the Datejs library. It adds something toxic to the stock Date object that confunds express’s session cookie expiration date. You’ll never be able to keep anything in your session between requests.
Use underscore.date instead… it avoids the Date object altogether.
require.paths is removed in latest node
After tracking down the issue, I needed a way to install the latest cradle code from github. This is how you do it, installing into the
$ git clone firstname.lastname@example.org:<username>/cradle
$ npm remove cradle
$ npm install ./cradle
First you clone the cradle repository. This creates the
/cradle folder. Second, you remove existing cradle package using
npm. Lastly, you use
npm again to install from a folder. Easy as pie!
It’s good to be back!! Despite how much fun it was developing my own blogging/publishing framework with Node.js, I never actually got around to publishing much 🙂 Although I did learn a thing or two about the holy trinity… node.js – Amazon EC2 – git.
I’d like to say I’m back in business, but you know how it goes: full-time job, multiple side-projects, team call-ins, mouths to feed, etc… at least it’s now easier to publish something when the mood strikes!
In the previous post where we managed our node.js server with supervisor, we used a classic init script to have supervisor start on reboot. In this receipe, we’ll instead use upstart, a replacement for init bundled with Ubuntu distributions.
stop and remove the old supervisord script
Previously, we created this file in our home directory, so you might still have that first copy in case you want to go back doing it the old-fashioned way 🙂
$ sudo /etc/init.d/supervisord stop $ sudo rm /etc/init.d/supervisord
create an upstart script
Create a new file /etc/init/supervisor.conf. Its content should look like this:
description "supervisor" start on runlevel  stop on runlevel [!2345] respawn exec /usr/local/bin/supervisord --nodaemon --configuration /etc/supervisord.conf
Note that we’re using the same supervisord configuration file we used before. No changes there…
here’s the gotcha!
This upstart script is modified from one found at lincoln loop. The problem with using ‘supervisord.conf’ as the upstart script filename is that the command supervisorctl picks that up and attempt to use it as a supervisor configuration file, which it is NOT. By changing the upstart script and service description to simply supervisor sans ‘d’, we can use supervisorctl normally.
using supervisord with upstart
We can now start and stop supervisord with the following commands
$ sudo stop supervisor $ sudo start supervisor
To check the status of supervisor
$ initctl list $ initctl status supervisor