And Yet Another Remodel

I have finally decided to do another remodel of this site. I had a few goals before starting:

  • Use one image
  • Use the YUI-CSS framework
  • Use Django
  • Make it easily extendable

So far, I think I’ve accomplished these goals. The site is easier to read, easy to modify, and has a few new features. More entries to come!

Database Woopsie

I returned to my computer today to notice I had the following error:

(145, "Table './databasename/comments_freecomment' is marked as crashed and should be repaired")

Darn. The solution is quite easy, however:

mysqlcheck -uUsername -pPassword databasename comments_freecomment

Now you know what you already know, you can fix it:

mysqlcheck -r -uUsername -pPassword databasename comments_freecomment

If that doesn’t work, you can try a slightly different method. First, go to the location where your databases are stored on the disk (most likely something like /var/lib/mysql/databasename). Next, stop the database – and try to free up as much memory as possible. Then run:

myisamchk -r comments_freecomment

If that doesn’t work, try to force it:

myisamchk -r comments_freecomment -f

Hope that helps!

GPS on the SkypePhone

Yesterday I was sort of curious if I could use my 3 Skypephone in a pinch if I got lost, which here in Sydney, happens quite often. Luckily 3’s Skypephone has both Bluetooth, and supports j2me apps. Mobile GPS unit, here I come.

The recipe to get maps on your Skypephone is pretty darn easy. You’ll need one dash bluetooth GPS receiver (I have the Qstarz BT-Q1000), TrekBuddy, a TrekBuddy acceptable map (easily downloadable), and one dab computer – but since you’re reading this, I figure you’ve got that part taken care of.

My process is as follows (on Linux): plug in your Skypephone and select “usb storage” on your phone. Drag the TrekBuddy.jar file onto your new mounted drive (mine comes up as KINGSTON). Drag a relevent map downloaded from bandnet.org onto your phone as well. Unplug your phone from the USB, and it will scan for new media. Hit Menu -> My Stuff -> Others and scroll down to treckbuddy.jar – hit Run. Go to your Connectivity settings and turn on bluetooth. Next go to Games and Apps and downloaded apps, start TrekBuddy. Press the key above MENU and select Load Map, and choose the map you uploaded to your phone. Now hit Start. Select the GPS device, and you’re in business!

There are more instructions here and also here.

Size of Uncompressed OSM File

I’ve been playing around with OSM a little lately, and have been meaning to construct my own slippy map. At first I wanted to do it on my VPS – but with rather limited storage, and even more limited memory, there just isn’t a way. Three problems exists: the first occurs when trying to use osm2pgsql to import the OSM file into the database. Current records state that this typically uses 650+ MB, something my 512MB VPS just doesn’t have (although I’m writing some code that might make this possible in the future).

The second problem exists with CPU usage. Processes on my VPS don’t really utilize the CPU much, which means renicing the process doesn’t do a thing. The CPU pegs at 100%, as it is supposed to do, except that the VPS auto-kills processes that stay at 100% for any length of time. Luckily somebody wrote a program called “cpulimit” (apt-get install cpulimit) that will cap the CPU usage for a process.

The last problem that I thought about is what if I could uncompress the file. Would that use less memory to stick it in the database? I searched and searched but couldn’t find an answer to how big the actual .osm file is. I ultimately broke down and decided to spend the 50c it would take to get this all done with EC2, and write some scripts to automate it in the future.

However, since I’ve finally uncompressed the .osm, I can tell you that as of about January 1st, 2008, the uncompressed OSM size is 67GB.

Using Distcc

I’m in the process of working on one of my projects, and the requirement came up to download a fairly large file (4GB). Since I only receive ~20GB/month at my house, I decided to just use my server in the U.S. The next requirement came about needing to compile Mapnik, which I had intended to do on the server at some point anyways, yet I ran into memory constraints.

Good old distcc comes to the rescue. I don’t need to use distcc that often, yet when I do, it is very handy. However, I always forget to set g++ to use distcc as well. So, for when I forget next time…

DISTCC_HOSTS='home'
./configure
make CC=distcc CXX=distcc

Maybe one of these days I’ll write a more in depth tutorial for installing distcc, yet until then, you can peruse the notes I left on my VPS provider’s wiki.

Sydney's Driving Habits

Status: ❌

I’ve heard that Sydney is one of the most liveable cities in the entire world – a statement I would generally agree with. However. whoever made this statement obviously didn’t drive to work every day. I’ve reached the conclusion that one of the biggest (and only) drawbacks to Sydney, is the traffic.

So why is the traffic this bad? I have a few theories. The first theory is that Sydney drivers aren’t particularly cordial. I mean, the road could be ending on the merging lane and drivers still won’t let you in. I’ve literally sat for two blocks in near deadlock traffic with my blinker on, and nobody would let me in. Combine this with the fact that whoever designed Sydney’s roads was drunk at the time (roads that suddenly veer off to one side, other roads that go from three lanes to one, roads that steer around a park causing 20 minute delays, or roads always having a bottleneck whilst crossing the rail tracks, etc.,). This plays a role in how everybody typically drives – they drive very close to each other. I don’t just mean tailgating, it is something else. I’ve been to quite a few cities in the world, and I’ve never seen people drive so close to each other.

This close driving has one serious repercussion: there are accidents every morning. When I list to the radio, I continually hear of several major accidents every day. Now, I can’t stop people from tailgating, nor can I stop the accidents – but what I can do is at least try to plot the bottlenecks around the city. I mean, after driving a route several times you’ll already know the bottlenecks – but I think it would be fun to visualize them.

I’ve already done a fair bit of the research how to technically graph it, although there is still quite a bit more to do. My plan is to use OpenLayersOpenStreetMapMapnik and of course Django to glue everything together. I’ll let you know when I have a prototype working.

Small Business Server 2003

Status: ✅

I’ve recently been hired for a company that does consulting for small businesses. Naturally, I haven’t had a huge exposure to SBS. My employer asked me to take the SBS MCP Certification, and this afternoon, I passed. The exam was pretty easy – I think Microsoft basically took the easy questions spread out across the MCSE and dumped them into the SBS exam (some of the questions were very similar). My tips to anybody taking the exam:

  • Really know the benefits and drawbacks of SBS; for instance, it has to be the root of the forest, Premium vs. Standard, it comes with Exchange/SQL/ISA, always use the wizards first…
  • The exam is a showcase for SBS, and then a showcase for 2003.
  • There is usually a logical answer.

Well, I know that isn’t helpful at all. But a start.

Exam 70-282: Designing, Deploying, and Managing a Network Solution for a Small- and Medium-Sized Business

Zenity GUI to a Shell Script

I have to admit, I’m pretty lazy. I don’t (ironically) like to type, and I really don’t like typing the same command over and over. I found myself switching between my external monitor and laptop quite frequently, and decided to somewhat automate the task. Although I know there are other programs out there that allow this, they either had too many features, or crashed. Xrandr works just fine, but like I said, I’m lazy…

Enter Zenity. Initially I created a PyGTK monitor switcher, yet wanted something even simpler. If you aren’t in the know, Zenity allows you to create super fast, super simple dialogs to regular commands. After you click “ok”, the command is executed, and the dialog disappears. Perfect for switching displays.

And here is the simplistic code behind it:

#!/bin/sh

ans=$(zenity  --list  --text "How do you want to switch your monitor?" \\
--radiolist  --column "Pick" --column "Output Type" TRUE LCD FALSE VGA \\
FALSE Both);

if [ "$ans" = "LCD" ]
then
    xrandr --output VGA --off
    xrandr --output LVDS --auto
elif [ "$ans" = "VGA" ]
then
    xrandr --output LVDS --off
    xrandr --output VGA --auto
elif [ "$ans" = "Both" ]
then
    xrandr --output VGA --auto
    xrandr --output LVDS --mode 1024x768
fi

I send a big cheers and thanks to the Zenity guys, I’ll surely use this quick language more frequently.

Mass Spam Delete Django

As you can read, I’ve been traveling around quite a bit lately. This means I haven’t been checking the comments on my blog, which means quite a bit of spam has been entered. I am blocking the spam via akismet, however, it is still recorded in the database. Being somebody who hates cluttered desktops, you can imagine how I feel about having a lot (447) of spam. Well, since akismet flips the is_public switch True for good comments and False for bad comments, that makes a really easy query in mysql.

mysql> delete from comments_freecomment where is_public = False

Of course, make sure you have backed up your database first.

Works With Windows Vista

I’m in Tibet right now, so will keep this somewhat brief.

For the next few hours I’ll be sitting in this dingy internet cafe in Lhasa updating my blog with my travels. I happened to look down and on the monitor it says “works with windows vista”. I find this quite humorous, of course it is going to work with vista, it is a normal generic monitor.

Anyhow, I guess there is a reason for marketing. Back to writing our travels.