January 2012

You are currently browsing the monthly archive for January 2012.

In case you’ve ever wondered what the monthly traffic allowance in your web hosting plan means in bandwidth, here’s an easy-to-remember number:

3.19 (month kbit) / (sec GB) – I shall call this the Brian Adkins number

Under the assumption that traffic from a web server only flows in one direction it means that for every GB (gigabyte) of monthly traffic included in your plan you could consume 3.19 kbit/s constantly. Or for every TB (terabyte) of traffic allowed per month you can transmit data at a constant rate of 3.19 Mbit/s.

I have recently released my newest WordPress plugin to the public:

Smart Quotes should appeal to the international audience. E.g. if you’re a German writer and would like to use German book style quotation marks (»…«) even when you type so-called "dumb" quotes or use the <q> element: This plugin is for you!

Right now the plugin comes with shortcuts for Croatian/Hungarian/Polish/Romanian style quotation marks („…”), Czech or German style („…“), Danish (or German books) style (»…«), Finnish or Swedish style (”…”), French style (« … » – with spaces), Greek/Italian/Norwegian/Portuguese/Russian/Spanish/Swiss style («…» – without spaces), Japanese or Traditional Chinese style (「⋯」), but you’re free to manually enter/paste any arbitrary characters or character combinations.

Download “Smart Quotes” (.zip) now

After you’ve installed the plugin go to your Wrting Settings screen where you will find this:

Screenshot of Smart Quotes Settings

Right now the plugin comes in English and with a German translation, but for “Smart Quotes” I’d be particularly interested in adding more languages. Contact me if you think you can help! The .POT file for this one is really small, so I’m thinking it could be a quick fix. – If you have never translated software before: this thread on Lester Chan’s Forums is a good start and it’s specific to WordPress plugins.

I use revision control systems for almost all of my software development, deployment, and server configuration. When using Subversion there is, technically, no difference between a working copy on my personal or development machines vs. a working copy on a production server. (Yes, you need a working copy on the production server, because exports cannot be updated that easily.) However, modifications of the checked out code or config files on a production server can cause problems with the next round of updates. Sometimes you just don’t notice that there are conflicts that need to be resolved.

To make sure I notice when a colleague or I have fallen back into the bad habit of changing things on a production server directly, rather than checking in changes to the repository, I have created a Nagios Plugin: it’s called “check_svnstatus”

Click here to download the plugin and to see an example configuration

I’m using the post-commit hook to send out E-mail notifications when changes are committed to Subversion repositories.

If you search the web you’ll find a ton of scripts in various languages for this purpose. They all do more or less the same thing: create an E-mail message for the commit, including such details as the revision author, number, timestamp, a list of the paths that were changed, and a diff of the changes.

For one particular project I wanted the diff as an attachment, though, rather than inline in the message text. So I ended up writing my own script. It’s a Shell script that should work on most Unix/Linux based systems.

Click here to view the source code and installation instructions

Webduino, the web server library for Arduino, now supports HTTP Basic access authentication. You can download a .zip file of the latest version from GitHub. (Note: The download link does not point to a specific version, but always to the very latest version of Webduino including features and/or bugs that were added/fixed after I wrote this post. Here’s the front page of the GitHub repository.)

Authentication means that you can now protect the web-enabled functions of your Arduino with a username and password.

There is at least one other version of Webduino supporting authentication, written by Claudio Baldazzi. It’s in this post on the original Google Project site of Webduino, with an example here. When I started working on improvements of the Webduino, plus new features for my own use, I considered using Claudio’s version but decided against it for the following reason:

With the Claudio’s version all pages of the Arduino would be protected by the same username and password. However I wanted a way to distinguish different user levels. E.g. Person A should be allowed to see on the web whether the lights are on or off, but only Person B is allowed to flick the switch.

Here’s how I did it.

The WebServer class now has two new methods: httpUnauthorized() sends error 401 back to the client, which in the case of a regular web browser causes the user to see a prompt for username and password. checkCredentials() checks whether a username and password have been sent with the request and whether they are valid, i.e. they have certain values. In a Webduino command function you should first run checkCredentials() and depending on the return value either run your “protected” code, like turning on the lights, or fire httpUnauthorized(). See the methods’ subpages of the API documentation for example code.