Saturday 18 September 2010

A new look for bawdo.com - soon


Around 5 years ago I wrote www.bawdo.com in PHP, this week I rewrote the site using Ruby on Rails. I have one more thing to do before I make it go live, and that is to migrate old posts over to the new site. Maybe tomorrow :-)



Here is a sneak preview. There are some missing elements such as a way to contact me from the site, my Mystery Tour page, and 150_002 Linux which is so old now it should probably be taken down.



The iPhone version of the site can currently display comments, but I have not hacked up the required form to add a new comment. Leave that for another day.

Saturday 17 April 2010

Japanese and English Keyboards - fun with evdev

I have been using Japanese keyboards now for many years and always make sure my laptops come with them. I like the layout and have become accustomed to it. However I was recently given a new Kinesis keyboard that has a US keyboard layout.

This new keyboard and nwo that evdev has become the flavour of the month when configuring keyboards under X make me write this post.

evdev and the default fdi keymap
However, the default fdi config does not play so nicely with Japanese keyboards. So here is my fdi keymap:


<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.keyboard">
<merge key="input.x11_driver" type="string">kbd</merge>
<merge key="input.x11_options.XkbRules" type="string">evdev</merge>
<merge key="input.x11_options.XkbLayout" type="string">jp</merge>
<merge key="input.x11_options.XkbModel" type="string">jp106</merge>
<merge key="input.x11_options.XkbOptions" type="string">ctrl:nocaps</merge>
<!-- If we're using Linux, we use evdev by default (falling back to keyboard otherwise). -->
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
string="Linux">
<merge key="input.x11_driver" type="string">evdev</merge>
</match>
</match>
</device>
</deviceinfo>


This works fine. Until you plug in another keyboard other than Japanese.

Keymap switching alias
To switch between Japanese and Keyboard layouts I have created the following aliases.

english='setxkbmap us'
japanese='setxkbmap jp'

This works fine except for the the "|\" key. Switching to English sees this key disappear all together. And if you have an international US keyboard the "|\" International Key becomes an "<>" key. So to fix this I have done the following.

# Create an ~/.Xmodmap file to remap keys 94 and 51 "|\"

keycode 94 = backslash bar
keycode 51 = backslash bar

# Change the above mentioned english alias.

english='setxkbmap us ; xmodmap ~/.Xmodmap'

Sunday 4 April 2010

Ruby syntax highlighting within websvn

I'm assuming you are using GNU Enscript for syntax highlighting with your websvn install.

It seems that enscript does not come with a ruby syntax highlighting rules file by default.So the first thing to do is find one. This one works for me:

http://support.rubyforge.org/svn/trunk/support/ruby.st?ref=darwinports.com

Now copy this into your enscript highlight rules directory. e.g.

cp ./ruby.st /usr/share/enscript/hl/

OPTIONAL: Test if highlighting is working or not:

enscript --color --language=html -Eruby --output=hello_ruby.html ./hello_world.rb

Now for the websvn side of things:

First off edit the websvn setup.php file and add rb and erb extensions to the $extEnscript array

e.g.
vim /usr/share/websvn/include/setup.php
# SNIP - find the extEnscript array
$extEnscript = array
# SNIP - and add these two
'.rb' => 'ruby',
'.erb' => 'ruby',
# SNIP

Next, edit websvn's config.inc file. e.g.

vim /etc/websvn/config.inc
# SNIP - search for extEnscript and add the following two lines.
$extEnscript[".rb"] = "ruby";
$extEnscript[".erb"] = "ruby";

This should be enough to get ruby syntax highlighting working. You can also edit your enscript.st to include naming and start rules for ruby if you'd like. e.g.

vim /usr/share/enscript/hl/enscript.st
# SNIP - Search for namerules and add the following:
/\.(rb|erb)$/ ruby;
# SNIP - Search for startrules and add the following:
/-\*- [Rr][Uu][Bb][Yy] -\*-/ ruby;

Friday 29 January 2010

To Ecky Thump Or Not?

Usually when traveling in China the taxi drivers are pretty good. About the worst one would expect in Beijing for example is a taxi driver that refuses to take you somewhere. However, once in a taxi I have found they either use the meter or they give you a reasonable price. Most will use the meter if you ask them to.

The above has been my experience in Shanghai, Beijing, Guangzhou, Suzhou, and Chengdu. Not so in Shenzhen :(

I flew into Shenzhen for the first time ever and arrived at 2330. On walking out of the airport I was accosted by a horde of unlicensed taxi drivers. So far, this is par for the course in China. However what happened next was pretty crappy to say the least.

I walked past the unlicensed gang as I always do and went to the taxi rank. Jumped into the first taxi and gave the driver the address of my hotel. The driver turned and said, "how much"? My response was "use the meter please", whilst I indicated with gestures to help make myself understood. He understood, but refused to use the meter. I jumped out and then into the next taxi in line. The exact same conversation followed. I tried one more taxi with the same result.

I found myself surrounded by non-English speakers, no police or airport staff in sight and no way of knowing which bus I might catch if I could find one. I was forced to negotiate with some taxi drivers on a price. I called the hotel and asked them how much it should cost... "100 RMb and it should take 30 minutes", was the response.

Now I had to negotiate a price as no one would take me and use the meter. I found myself surrounded by around 10 "licensed" and "unlicensed" drivers. The "gang" decided the starting price would be 400 RMB. After several minutes and lots of back and forth no one would go below 180 RMB... Biting the bullet at midnight I jumped in and was whisked off to the far dark end of the airport and told to get out of the taxi under a dark underpass. I was now a good half kilometer away from where I started.

I jumped out, as did the driver. He was constantly saying "ok, ok, ok" and "look, look, look" while he would use the remote on his key chain to flash the hazard lights on a different taxi parked nearby. Somehow I think he expected this would make me feel more at ease about the whole affair.

Suffice to say I was on heightened alert. Standing in a position where I could better defend my self I was thinking the whole time I might have to do some ecky thump here.

After around 10 minutes I was ushered into the car with the flashing hazard lights. We sat, and then after a further 10 minutes and several phone calls (the "taxi driver" was making them every few minutes) another car appeared. It was a normal sedan and in good condition. An unlicensed taxi after all it would seem.

I was relocated to my third vehicle for the night. Money exchanged hands between the original and new "drivers" and I began to wonder if I was going to be spirited away somewhere only to appear on CNN as a kidnap victim some days later...

I positioned myself behind the driver and ensured I could open the door whilst the vehicle was moving... more thoughts of ecky thump.

We sped off down a main road and a few minutes later the first taxi driver pulls us over by flashing his lights and pounding on the horn. Some more money exchanges hands between them.

At this I jump out and move to the back of the vehicle and demand my bags be taken out of the boot. Both my new and former drivers are saying "no, no, no". At this point I became agitated, to put it mildly. For some reason both of them took a few steps back and remotely opened the boot.

I took my bags, put them in the first taxi and demanded I be taken back to the airport. Or at least I tried to demand this.

The original driver, by my actions, now "knew" I wanted to be taken to the hotel. More money changed hands between the two "drivers" and we were off again. Now the driver is visibly angry and driving dangerously. Dangerous even by normal Chinese driving standards.

He drove me part way to the hotel and pulled over next to yet another taxi and started a conversation with the newest of driver. My bags were taken out, and I was moved to yet another vehicle. More money changed hands between these first and third "drivers".

At this stage an older lady wanders down the road and jumps in without a word. We finally depart with driver three and old lady riding shotgun chatting away incessantly about something.

Around 20 minutes later I arrive at my hotel.

During this adventure I felt as though I was in real danger at several key moments. I was constantly weighing my options; should I run, strike, or ride it out and see what develops.

In the end all was well enough, but suffice it to say I will not be flying into Shenzhen at that time of night again. Actually I would highly recommend flying to Hong Kong and then catching the train into Shenzhen and getting off as close to your hotel as possible. Then taxi from there as the non-airport taxis seemed fine enough.

Saturday 24 January 2009

iPhone Apps Pricing Differences Between Regions

Recently I changed phones and decided to go with the iPhone. Besides battery life and the Apple iTunes lock in I'm happy with the device. Sidenote: why can't they make the device present as a USB hard drive?

However, the thing that gets me really annoyed is the way Apple locks you into iTunes by region. The really cruddy thing about this, beside the interface only being localised for the region you are in, and that some apps are missing altogether, is the price differences between region.

This is just one example, iSSH retails for 4.99 USD on the US iTunes site, and retails for 600 YEN on the Japanese. At current exchange rates that makes the local price approximalely 150 yen (1.70 USD) more.

C'mon what is the justification for this kind of difference in price?