Monthly Archives: September 2012

Playin’ with wikis…

I like wikis! I’ll confess that back in the dark ages about a zillion years ago, when I first heard about wikis back in the late 90’s (for the curious, here’s the history of the wiki), I said to myself, “why would anyone every want to create a website that lots of folks can edit?” My lack of imagination about things like this is why I’m not an entrepreneur, I guess 😉

I’ve used different wiki software, but mostly I’ve used PmWiki and MediaWiki. MediaWiki is more powerful and complex, but I like PmWiki for a “quick and easy” wiki that provides reasonable flexibility. They are both in PHP and will run most anywhere. I’m running a PmWiki instance on my Raspberry Pi now. I’ve used PmWiki to create exercises for the Systems Analysis class I teach at UNC-CH. We’ve got a family “notebook” running in PmWiki. I’ve got a family recipe archive in a MediaWiki instance, and some other things as well.

I’ve been sitting here on a rainy September Sunday doing some updates, and just reflecting on fun with wikis.

A Raspberry Pi…


I bought myself a Raspberry Pi, a small single board computer, about the size of a credit card. You can order one for $35, put it together with some parts you probably already have, and you’ve got a fully functional Linux computer. I haven’t really decided what to do with it yet, but it’s a good excuse to refresh my Linux skills. It supports a USB keyboard/mouse (I actually used one from an old 1st gen iMac that’s sitting in my closet (can’t bear to throw it out 😉 ) so it’ll use anything. Has HDMI output (with sound) to a TV, as well as composite video and 3.5mm audio. It’s got an Ethernet port, of course. Supposedly you can do WiFi by adding a USB WiFi adapter. Power comes from a micro-USB cellphone charger (1A or better). Storage is from an SD card (they recommend 4GB or larger; I used 4GB and it has ~2GB free after install). It boots from that, but you can supposedly add an external USB hard disk. You have to download the image (Debian-based) and write it to the SD card with something like “dd” depending on your environment (I did it from my current iMac). You could build multiple images, and just replace the SD card to boot to a different OS version.

I plugged it in (it has nice little activity lights that blink 😉 ) and it booted to its config program. I set the locale, timezone, enabled ssh connectivity it was ready to go. You’ve got your traditional command line, and can start an xserver for a GUI. I’ve not gotten remote windows working yet, still reading up on how the graphical display manager works. I did have one problem with sound drivers (no sound at first) but found a hit on the RPI forum and installed one program and sound worked to the HDMI-connected TV.

The standard distro is oriented to Python development. It also has Perl loaded on, but no PHP. It does have gcc. I’ve just started poking around.

I’ve got all the peripherals unplugged now, and the only thing connected is the Ethernet cable and the power. Have ssh to a bash shell (its default shell setting), and that terminal connection is just fine for the time being…it can sit there, and run, drawing just a tiny bit of power, while I figure out what I want to do with it. Pretty cool!

Writing a line of code, woohoo!

All I get to do at work these days is go to meetings and read email. Most any technical stuff these day is on my own personal time. Today was one of those times when I actually debugged and fixed something. I maintain the archives of a flyfishing listserve at which includes postings going back to 1990! I used to harvest and index the files monthly, but it’s gotten to be more like quarterly. Recently, I indexed the postings from April thru August. I noticed, though, that when I retrieved the articles, I was getting an extra blank line between all content, which made things much harder to read.

I looked systematically, wondering where the extra line was originating. I download the archive files via email from the server at the University of Kentucky, and then I strip out the email headers and run a PERL program against the file to put it into a format that the WAIS retrieval engine can index. The problem could have come from the server at UKY, from Gmail, from the browser I was using to save the archive files, from updates to PERL on my Mac or other things I’d not thought of…likely not the Linux VM since that’s been pretty static.

Using the “od” (octal dump) utility (found in Linux and MacOSX) I found that the problem seem to be that the archive files, as I saved them from the server, had lines separated with LF/CR (hex 0a 0d). The “good” archives from earlier times were using only the Unix line separator LF (hex 0a). I looked at the PERL program that I was using to reformat the archive for indexing, and decided that it was a good place to insert code to strip out the CR.

Time to try to remember how to write a regular expression! Pulled out the PERL book with a cheat sheet of examples 🙂 and came up with the fix, adding one line of code (plus a comment):

# added next line 9/2/12, apparently gmail saves now with LF/CR

$logLine =~ s/r//; # delete a carriage return

That’s it…but it was fun to figure out!