Fun with OSM

I have to admit, to me, editing OpenStreetMap is actually a little therapeutic. Sort of like gardening.

My first major contribution was when I brought my little QStarz GPS unit across Indonesia, by train, sitting against the window.

The most recent contribution was our trip to Dubbo, where I helped fill in a few missing roads, and added an initial outlay of Dubbo Zoo.

If you have a GPS or have $60 to spend on one, and like anything CAD-drawing like, give editing OSM a try!

French Word Collage

For the last year YS and I have been studying French once a week (4.5hr on Saturday!) A few months ago I wrote some Python code to read the RSS feeds of the most popular French newspaper site, and then kept track of the count of each word. I repeated this every week for a few months.
In the end I had a database of the top ~3000 words used on the site. Today I decided I wanted to play with Processing, so created this little word collage. It is 1680x1050, my monitor’s resolution. Two thumbs up for Processing!

Testing SMS Gateways

For one of my projects I’m testing an SMS gateway, and decided it would be fun to build a useful alarm clock out of it. For those of you who know Python, you may find this funny. /dev/ttyUSB0 is my Arduino with a temperature sensor.

import serial
import urllib2
 
def check_temp():
    ser = serial.Serial('/dev/ttyUSB0', 9600)
    t = ser.readline().strip()
    return float(t)
 
    t = check_temp()
    if int(t) < 8:
        message = "It+is+now+%f+degrees;+chuck+a+sicky." % t
        f = urllib2.urlopen('http://api.clickatell.com/http/sendmsg?user=johnd&password=p@55w0rd&api_id=2132867&from=61433735555&to=61433735555&text=%s' % message)

```bash

And in crontab:

```bash
45 6 * * * python /opt/scripts/temp_alarm.py

Arduino 101

Tonight, I’m proud to say, I’ve returned to childhood. Let me explain.

OK, fun over, back to work.

For the last year I’ve been wanting to purchase an Arduino, for no other reason than to play with. Like a kid. My Arduino arrived two days ago. This is a story of problems, but not the pull-your-hair-out type, more the… like when you run out of gas in the middle of Sydney. Going to your Christmas dinner. In your friend’s car. Long story.

As a kid I never really learned about electronics. I took apart anything broken my parents set downstairs (and put back together the microwave I dismantled that my parent were going to give to my sister as a gift). But no electronics. I had a computer of some sort from when I was a wee kid, but not a single electronics kit, or not one I can remember.

I soon realised I forgot to order a few resistors needed for the various sensors I purchased. This morning before work I stopped by the local electronics store, and like a kid in a candy shop, ordered $1.60 worth of resistors and LEDs.

Just after coming home and eating insanely good Indian with YS, I set out to get an LED blinking. Without too many troubles, success! I graduated myself to the next grade and pulled out the temperature sensor. I looked at the ‘special’ wires I bought to connect to the sensor and the breadboard, and I soon realised I actually purchased the M->F wires instead of the assorted pack. I started looking around for cables I could cut.

Spare USB cable, no. Telephone cable, maybe. I realised I could just slice up one of the cables and see if it worked. The cables were braided instead of solid coper, which sort of made my hopes sink, but it was too late now.

I soon wired everything together as the various forum posts suggest, plugged it in to my laptop, started the Arduino software, and loaded the Dallas Temperature Library, and - “Invalid CRC”. I pulled the wires off, stripped a little more cabling off, plugged it back in, and tried again. It worked! I don’t really know if the temperature is correct or not - we don’t have any other way to measure it - but at this point, until I put in some more robust wires, I don’t really even care.

Overall, I’m happy. I’ve created two simple physical computing missions, and wrote two blog entries, in well under two hours. This has been quite a relaxing break from the other duties in life. I plan to make the little system ‘proper’ (more robust), and link it to my mini server. I’ll then create a simple chart (via Google’s API) to display on this website.
OK, fun over, back to work.

GPS Gem Find - TangoGPS

I’ve been looking for a simple, no-hassles GPS display program for Linux, and I believe I finally found one: TangoGPS. My requirements were quite simple; I needed something that would talk to gpsd, and display a dot on OpenStreetMaps. I’ve been able to do this in other programs (even in 3d in WorldWind), but I wanted something to download the maps for me, and GTK+ would be a plus.

TangoGPS was easy to install (apt-get install tangogps), and on my test ‘drive’ home tonight on the train, worked a treat. See related screenshots.

Downloading VMWare with Firefox

I’ve had this issue happen to me several times, and I’m finally writing myself a note to fix it in the future. There seems to be an issue with downloading VMWare Workstation (.bundle). I first tried it with Firefox, but it just died at loading it into /tmp. Next, I tried it with Lynx, but alas, it tried to download it as a text file.

Ahah! The quickest solution I could find is to right click the link, save as, and save it as a zip. Rename it to .bundle when you’re done.

Compiling kernel for Vortex86dx

Update: I’ve written up a short tutorial on the method I used to install Debian 5.0 on this device.

A few months ago I purchased the eBox-3300 from WDL Systems. The system was promptly shipped, and there were no “gotchas” from WDL. The little box fit my exact needs - it is small, and built very, very well. I flew back to Australia and, after some trial and error, installed Debian 5.0 on it. For quite some time I was just using the vmlinuz file provided by WDL, which was provided by ICOP (DMP). This worked well, but there were two issues:

  1. I couldn’t load any modules (e.g. NFS).
  2. I received an annoying email from OSSEC every few hours telling me it couldn’t find modules.dep.

At the end of last week I finally decided to do something about it, and considering this little box is “x86 compliant”, I figured it wouldn’t be too hard to create a new package. It has been several years since I last created a self-compiled Debian-packaged kernel, so I decided to document the process for the next time I do it. These steps are really just a summary - but if you have much Linux experience, they should be enough to guide you. If I’m unclear, just send me an email.

Because the eBox-3300 is embedded, I logically decided to create the package on another system. However, I wanted to maximize the chances of it working, so I installed Debian 5.0 in VirtualBox, updated it, and proceeded.

As a prep, you may need to install ncurses-dev and kernel-package in your build environment.

apt-get install ncurses-dev kernel-package
  1. Download latest kernel from: http://www.kernel.org/pub/linux/kernel/v2.6/
  2. Download the DMP provided patch/config file for 2.6.27.3, copy it to /usr/src. Alternatively, you can borrow my 2.6.29.3 config Make a backup.
  3. Untar kernel, cd into the kernel directory. Issue:
make menuconfig
  1. Configure kernel. If you used my config file, a lot of these should already be ticked.
  • Load alternative config file, I selected mine as /usr/src/config-2.6.27.9-vortex86dx, or if you downloaded the one from me, use config-2.6.29.3-vortex86dx
  • Enable generic x86 support
  • Enable Kernel .config support
  • Device drivers -> Network -> 10 or 100Mbit -> RDC R6040, set at built in
  • Turn off generic IDE support
  • Exit, make sure to save the kernel
  • Verify .config exists. If it doesn’t, copy the config-2.6.x.x-vortex86dx file to .config
  1. Create the kernel debs. In the kernel directory, issue these commands. This will build the kernel image, the headers, and the modules.
make-kpkg --initrd kernel_image kernel_source kernel_headers modules_image
  1. Make coffee
  2. Copy the debs to your running ebox by sftp (or usb, or whatever is available)
  3. Install kernel in eBox-3300
dpkg -i linux-source-2.6.29.3-vortex86dx.deb
dpkg -i linux-headers-2.6.29.3-vortex86dx.deb
dpkg -i linux-image-2.6.29.3-vortex86dx.deb
  1. Reboot. If you want my compiled kernel/sources/header .DEBs, just shoot me an email and I’ll make them available.

Summary: My only gripe about this little box was the lack of an easily customizable kernel, but no more. I’m still very happy with this $150 purchase.

Fixing mysql warning message

After restoring databases from one server to another I sometimes get this error on Ubuntu or Debian:

error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'

This makes a lot of sense, and the solution is pretty simple. If you look in:

cat /etc/mysql/debian.cnf

You’ll see the defaults for your system. Copy the password listed there, and open a connection to MySQL as root (or some other user). Next, enter this (lets say your password specified in debian.cnf was ‘abracadabra’:

mysql> select PASSWORD('abracadabra');
+-------------------------------------------+
| PASSWORD('abracadabra')                   |
+-------------------------------------------+
| *38794E19D534EBA4F0F78903FA00F1DA2989DCA2 | 
+-------------------------------------------+
1 row in set (0.00 sec)

Next, since we already have the prompt open, do this command:

mysql> USE mysql;
mysql> UPDATE user SET password='*38794E19D534EBA4F0F78903FA00F1DA2989DCA2' where user='debian-sys-maint';
mysql> FLUSH privileges;

Restart MySQL, and the error should have gone away.

True Consolidation

Back in 2000 I managed to acquire several retired systems to bring to Uni: this included 4-5 cheap P120 machines. At the time, I thought this was great; I had an OpenBSD box as my gateway, a FreeBSD box, a few Linux boxes, and likely something else that doesn’t even exist now. The school has a superfast connection, unlimited bandwidth, and I was curious. Although I didn’t really have time, I still managed to install and have all these servers running from my room.

I realized I was doing at home what I was being paid to do at work.

Fast forward to 2007, and my mindset has changed. In 2007 I didn’t want to have 6 servers running at once, I wanted to have one server running 12 servers at once! Thanks to Xen and VMware this was easily obtained. Initially using Xen, and then ESXi, I had the freedom to setup Domains, tear them down, and start over. Eventually, however, I realized I was doing at home what I was being paid to do at work. That doesn’t sound like fun. I also realized that, despite picking a motherboard and processor that could shift into low power usage, I was still using more watts than I needed to. I was also spending way too much time mucking around with things - I want to focus on just one or two projects at a time, and I really want to start programming more.

Last month I finally finished the ultimate ‘consolidation’: I moved everything to a tiny embedded Linux box. While back in the U.S. I contacted WDL Systems and requested for shipping costs on a tiny embedded box. I bought the eBox-3300, with an embedded board from ICOP, and it was promptly shipped out. After returning home to Sydney I migrated all my apps from the various virtual servers to my little box running Debian 5.0: OSSEC, Samba, Lighttpd, Asterisk and flow-tools. The little box is just perfect for what I need - a tiny home server. I still get around 8MB/sec transferring files, which indicates the network is still the bottleneck, and VOIP calls with Asterisk are still clear.

Overall, I’ve been happy with this little box. My ‘playing time’ with IT has gone down significantly, my energy usage has gone down, and I now have a server I can take with me wherever I go.

Renaming Apache Log Locations

I realized a few of my log files were growing unusually large, and even worse, logrotate was skipping them. I took a look in logrotate.d and straight away realized why: I had created silly names for the log file. logrotate look for .log files, but I had specified mine as .log – e.g. kelvinism_access_log. I was as familiar with logrotate when I set up the domains, so set forth to get them in the rotation.

Firstly, I had to rename the actual log files. So, to rename kelvinism_access_log to kelvinism_access.log, a one-liner:

for x in *_log; do mv $x `basename $x _log`.log; done;

Next, I needed to rename the log location inside each of the Apache config files. While a one-liner might be possible, I used the following tiny script:

#!/bin/sh
 
for x in *
do
sed 's/_log/\.log/' $x > /tmp/tmpfile.tmp
mv /tmp/tmpfile.tmp $x
done