The Input Box That Isn’t

Just an Android rant. I really don’t like the Google Search widget on my Android desktop. Looks like a button, but isn’t. Why?? Also, apps that show multiple — sometimes 3 at a time — progress spinners. Ugh…

UTF-8 Round Trip for Perl, MySQL and node.js

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.

While 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:

Continue reading

The Date is Off!

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 instead… it avoids the Date object altogether.



Installing node.js Packages From github

I had a situation the other day, where the cradle couchdb client from the npm repository was throwing an error like the one below:

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 node_modules folder:

$ git clone<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!

Back On WordPress

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!

Using Supervisor with Upstart

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 [2345]
stop on runlevel [!2345]


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