Swap Escape and Caps Lock keys

When was the last time you used the Escape key on your keyboard? For a lot of you it quite probably was a fairly long time ago.

When was the last time you used the Caps Lock key? For all of you it should have been a long time ago!

I do my programming in Vim and to switch between Insert and Visual mode I have to press the Escape key. This wasn’t so much of a problem when I didn’t do so much coding, but now it’s my full-time job I find it to be quite a pain, literally. After a full week of programming in Vim my poor little finger is hurting from extending up to the Escape key.

Today I decided to solve this problem once and for all.

I mentioned the Caps Lock key earlier on. It’s on the “Home Row” of the keyboard. This means that it’s right beside where you should position your fingers when using a keyboard. Your left hand should sit on ASDF from little finger to index finger, and your right hand should sit on JKL; from index finger to little finger. You’ll notice that (on most keyboards) there is a little notch on the F and J keys. These are there to help you find the proper hand position without having to look at the keyboard. Of course, this all assumes you’re using the QWERTY keyboard layout and not Dvorak, or something entirely different.

Proper finger position

Proper finger position

In Linux there is a utility to change various keyboard and mouse settings called xmodmap. This gives you the ability to remap keys to different functionalities.

I’ve used xmodmap  to switch my Escape key fucntionality to the Caps Lock key and vice versa. This is going to take some getting used to, but the overall benefit to my fingers should be quite significant. It’ll also have the unintended side-effect of stopping me accidentally going into cPS MODE WHEN I MISS THE ‘A’ KEY. 😉 Of course, there will be some programs where pressing escape will cause the window to close, or the action to be cancelled. I guess I’ll just have to be more careful than I was before to avoid accidentally hitting the key to the left of ‘A’.

The way I set this up was using a file called .Xmodmap in my home directory. The contents of this file are loaded by xmodmap every time you log into the computer. The file contains the following:

! Swap Caps_Lock and Escape
remove Lock = Caps_Lock
remove Control = Escape
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
add Control = Escape

Now to get back to writing code and start saving my left little finger.

Romania Trip

This blog entry is best viewed on my site because Facebook and other places that might import it may not display it correctly.

This blog entry is the entire happenings of Romania as recorded in a little book I kept with me for the duration of the visit. I didn’t do a very good job of describing who was where. I just use the word “we” to refer to Lizz, Claire, Matt, Gordon, Sarah, Vlad, Jo, Howard, and me. 🙂

Sunday 24th of May 2009

It was a fairly short flight from Luton to Cluj with W!zz Air. We caught a taxi to the hotel after getting our bags together. It’s called Hotel Pedro (Pensiunea Pedro). Lizz and I were staying in room 12.

The view from our room

The view from our room

While we were still collecting our bags the handle on a case belonging to a lady snapped. I laughed a bit. Then when I went to pick up Lizz’s case the handle wouldn’t move up at all. Karma…

A little kid with aspergers was behind and then beside us on the plane. He was really loud and annoying. He spent half of the flight running around with no top on.

Our room at the hotel was pretty small, but has all we needed for the night. 🙂

After getting our things ready in our rooms we all met up to go for some food at a restaurant that Vlad knew from being a student in Cluj. We walked through the city to get there so we got to see a lot of cool things. There are quite a few big statues and cathedral-style buildings in the centre of Cluj.

The restaurant was at the top of a pretty steep hill and it was quite a walk up there, but well worth it. We went to the terrace at the back of the restaurant and it was lovely. This was the first place we encountered Ursus. The first of many!

After we’d had our pizzas in the restaurant we went back through part of the city to a bar that tune out to be closed. We went over the road to an Irish-style instead. There was quite a lot of Irish music being played in there from a computer with Winamp running on it. There were lots of photos of famous people on the walls. It was a pretty cool bar. Someone who worked in there must have spotted Vlad’s Gogol Bordello shirt and put a Gogol Bordello track on. The only drink I had in there was a really nice and creamy White Russian, after Vlad went to the man behind the bar and explained what it was for me.

The group in the Irish Bar.

The group in the Irish Bar.

We moved on to another bar where Vlad and Jo first met. It was called Musik Bar. We stayed there for the rest of the night and had LOTS of drinks. The bill came to 377 lei. We split it at about 40 lei each, which works out at about £10 each. The bill included 54 beers, some wine, some vodka, and some pancakes that Lizz had. That’s a pretty good bill!

Once we had got back to the hotel Matt, Vlad, Howard, and I went for a walk around the block looking for another bar that was open.

We didn’t find anything that was still open, but we did manage to stumble upon (nearly literally) a dying cat in the street. Vlad warned me about it when I was walking along because I nearly stood on it. We thought it was dead at first, but it turned out to be alive. It was really horrible just seeing it there. After walking around the block I decided the humane thing to do would be to put it out of its misery. I left the others behind and went to get it done, but I couldn’t just do it when I got there. Everyone caught up and we had a little discussion about it before Vlad and Matt convinced me it was probably a bad idea to kill it because I’d feel bad afterwards. We walked back to the hotel and I have no idea what happened to the cat after that.

Monday 26th of May 2009 11:00 – Pensuinea Pedro Room 12

I woke up with a headache. It was possibly the first proper hangover I’ve ever had, or it could just have been a headache caused by the incredibly hot room.

A few people went out for a walk, but I had a quick shower instead. Everyone was back pretty quickly, so we all went downstairs and paid the 93 lei for our rooms. It works out at around £25 per night, which is pretty good. 🙂

We went to a place called Steaua for breakfast. It was very similar to a German breakfast in that it consisted mostly of bread. It was really nice and made my head feel quite a lot better.

After breakfast we went for a walk around the centre of Cluj to see some of the sights in a bit more detail than the day before. The weather was absolutely perfect and it was very hot for the entire time we were out. It was lovely.

A statue of someone I don't remember

A statue of someone I don't remember

Romanian Flags with the fountain, statue, and cathedral in the background

Romanian Flags with the fountain, statue, and cathedral in the background

We all took a bunch of pictures of everything, and some of us spent a bit of time inside the cathedral before we met up with our yellow VW minibus. We went back to Hotel Pedro to collect our things and then set off for Vlad and Jo’s house in Târgu Jiu, around 200 miles south through the Carpathian mountains.

Just outside Cluj we stopped at a petrol station to buy lots of drinks and snacks. Claire and I were both very pleased to find Mountain dew on sale. I bought a 2.5 litre bottle of the stuff.

People in Romania are absolutely crazy in their cars. They overtake on blind corners, hills, or in tiny little gaps between oncoming traffic. At one point we were being overtaken by a lorry and there was no room for it to get by us, so it just forced us off the road onto the verge at the side. It was scary for a few seconds, but I guess the driver was used to that sort of thing.

On the journey we learned about Matt’s love of bridges. He is now known to us all as Matt Bridgill (instead of Matt Ridgill in case you don’t know him). 🙂

We stopped at a huge castle on the way only to find that it closed early on a Monday. We took some pictures anyway and then got on with the journey.

The castle we stopped at with Lizz posing before it

The castle we stopped at with Lizz posing before it

Us hanging out on the bridge to the castle

Us hanging out on the bridge to the castle

A large part of the journey consisted of going through a steep valley on a winding road. It was nice to look at, but was a bit scary when you consider the driving habits of the other people on the road.

The Carpathian Mountains

The Carpathian Mountains

Almost as soon as we got out of the valley there were no more mountains at all. The land flattened out to a huge expanse of fields.

After a little bit more driving we reached Târgu Jiu, and Vlad and Jo’s house was only a couple of minutes into town.

We met Vlad’s parents Vali, Marietta, and Luci, as well as the dogs: Crow, Foxy and Dink (not sure of the spellings). Vlad’s parents live in a house built entirely in the back garden of Vlad and Jo’s house. There was still lots of garden available for growing vines, vegetables, and plenty of space for the dogs to run around on. The whole place is absolutely wonderful.

Vlad’s mum prepared food for our arrival, and Vlad’s dad made sure there was plenty to drink. We had some brandy that Vlad’s dad had made himself. I believe Gordon described it as being like rocket fuel, and he was right. It was still very nice though. One of the things we had to eat was stew. Everyone found it hilarious that I should be eating something with the same name as me. Vlad made sure that the joke was not lost on his parents, and for a little while I was known as Tocană (Romanian for stew). Lizz also became known as Dumplings (stew and dumplings). 🙂

Vlad and Jo started leading us to town to a bar. On the way we walked up an alley that basically consisted of coffin and headstone shops separated by gambling places and the occasional shop. It was a very strange alley that we affectionately dubbed Coffin Alley.

After a drink in the bar we went back to Vlad and Jo’s house for several more drinks. It was during these drinks that Matt let us know that he was conceived under a willow tree. Willow was added as a nickname for him, but Matt Bridgill still stuck around.

Lizz, Jo, Gordon, and Sarah were the first ones to bed, followed quickly by Matt and Claire. Vlad, Howard, and I stayed up a bit longer, and then we went to bed too. It had been a very long day.

Tuesday 27th of May 2009

I woke up early and went out onto the balcony. I noticed Sarah was awake after a couple of minutes, so I went downstairs to see her. Vlad and his mum were already up and Howard and Jo joined us a few minutes later. After a bit of breakfast Gordon joined us all.

Vlad and Howard went into the house and brought a stereo outside so we could listen to music. We listened to a station called Radio 21 “Your fun station” for a while before Vlad and Jo went to the supermarket, and Gordon and Sarah went for a walk. Shortly after Vlad and Jo got back everyone else got up and out of bed.

We all went for a walk into Târgu Jiu. We walked through the park that contains The Endless Column. We walked from there to the church where Vlad and Jo got married. From there we went to another park containing The Kissing Gate. All three places are in a straight line. Further into the park there’s a big stone table with some seats to sit on. It’s there to represent the average Romanian family before the first world war.

The Endless Column

The Endless Column

Lizz and I under The Kissing Gate

Lizz and I under The Kissing Gate

Everyone around the table

Everyone around the table

After a quick walk along the water we stoped at a cafe-bar for some drinks. We ended up having quite a few sitting under some umbrellas listening to Ace of Base on repeat. It was really relaxing and enjoyable.

From the park we went to a restaurant. Gordon and I decided to have pig brain between us. It was kind of like soft fish, and I definitely won’t be having it again!

We caught taxis back to Vlad’s house for a little while and then headed back to town for some more drinks. We struggled to get enough tables and chairs close enough for us all to hang out. By the time Vlad’s friends had arrived we’d worked it all out.

We went to the bar from the day before for one more drink and then we woke up some taxi drivers to take us back to Vlad’s house again.

We sat outside and listened to a Manu Chao album while we were outside. After that we all went to bed to get some much deserved sleep.

Wednesday 28th of May 2009

I woke up a bit after most other people and had a really quick shower. Vlad’s sister Luci came over and we went into the mountains in 2 cars.

After a fairly long journey we arrived at the cave of the women. At first I thought it’d just be us, but then we were joined by 20-30 school children on a school trip. It certainly made it a bit different. 🙂

Vlad spent a lot of the time translating what the cave tour guide was saying, making sure to spare us from the customary terrible tour guide jokes. It was really cold in the caves compared to outside them. That’s to be expected though. The caves were pretty impressive. Vlad told us how the caves got their name. The Turkish people were invading the surrounding area, so all the women, children, and old people were sent to the caves to hide while the men fought the battle. Unfortunately the men lost the battle and the Turkish military people found the cave and blocked all the people in there. When the caves were opened up they just found lots of skeletons. 🙁

Once we got out at the other side of the cave a few people went for a walk back to the cars while Lizz, Claire, Matt, and I hung out there. I walked along the river nearby looking for somewhere I could jump across safely. After finding that there was no such place I looked for the most likely place to avoid falling into the river. I plucked up my courage and jumped from rock to rock into the middle of the river, and then Lizz came along and was very unhappy with me. I jumped the last bit and we went back to wait for everyone else to turn up.

From the caves we went to visit a nearby monastery. When we got there Gordon and I had a race up the the hill to the entrance. I started out in the lead and managed to keep it right until the very end when Gordon caught up with me and we crossed the imagined finish line together. We settled for a draw. We didn’t stay at the monastery for very long, but we quite a few of us took a few pictures of thing you’re not supposed to photograph, and other people explored the building itself.

After the monastery we went to a roadside cafe for some lunch. Lizz and I shared a pizza and some chips, and I had another bottle of Mountain Dew. Yum.

A short drive from the cafe there were lots of people selling pottery at the side of the road. We stopped there and I bought my mum a vase, and Lizz bought some things for her mum, grandma, and Katy next-door-but-two.

On the rest of the way back everyone but Luci fell asleep, which is good because she was driving. It was really hot and the fact that we’d just eaten and been up late made it very difficult to keep our eyes open. On the very last bit of the journey Luci overtook Vlad and we had a little race through town to Vlad’s house. Vlad took a different route and ended up getting there ahead of us, much to his enjoyment.

I tried to call my mum when I was back, but there was no answer, so I called my sister instead. We had a short chat and then I thought I should go because it might be costing me a lot of money.

Gordon, Sarah, Howard, and I walked into town to buy some vodka and some cola. It was quite a struggle because the people there didn’t speak English and we hardly spoke Romanian. It turns out that instead of the small coinage they try to give you chewing gum instead. This would normally be fine by me, even though I don’t normally chew gum, but we didn’t get what she was doing, so we were all kind of perplexed. Eventually we got the correct change and headed back to Vlad’s house.

Back at Vlad’s everyone was getting ready for the Manchester United vs. Barcelona match. Vlad’s friends started to turn up and Vlad’s mum started to bring out the food. One of the dishes was called piftie. It was basically just leftover meat in congealed meat juice. It looked an awful lot like dog or cat food. The texture was more than I could get over when I was eating it, especially because it was cold. I think I was one of the very few people to actually try it though, so I’m pleased with that.

A few of us stayed up until it was getting light outside. I was pleased to be the last of the UK guests to be up. Jo also managed it, but I don’t count her as a guest there. At some point Vlad and I went into where Gordon was asleep and put toothpaste on his face. He muttered “that’s either Cove or a Romanian gypsy!”

It was an exhausting day, but lots of fun.

Thursday 29th of May 2009

I was quite late getting up and out of bed. I was pretty damn tired from the long night before.

After a bit of breakfast Lizz, Matt, Vlad, Jo, and I headed out in Vlad’s car and the others followed in Vlad’s friend’s car. We went to a place that had collected examples of old Romanian houses from around the county we were in. The sculptor of The Endless Column lived in one of the houses.

On the way around I spotted a horse rolling around on its back and then a huge bunch of red beetles hanging out on some rocks. They made a weird rustling sound when they were disturbed. It was probably just so many of them moving on dead leaves or something.

The house Vlad grew up in

The house Vlad grew up in

After the tour we went to another monastery in the hills. There was a bit of a storm in the mountains, but we only got a little bit of rain. The man who was responsible for the building of the monastery lived in a nearby cave during the construction process. We went up as close as we could to the cave, and then headed back out of there.

When we were back down at the cars we saw 3 dogs trying to scare a couple of small horses. The horses weren’t very intimidated and just rubbed themselves against cars like cats sometimes do on tables or chair legs.

We drove back to Târgu Jiu and met up at a hotel restaurant for lunch. Most of us had Pizza Dracula and plenty of Ursus to go with it. The glasses for the Ursus were really nice. So nice in fact, that I borrowed one, permanently. Although I’ve since given it to Gordon.

Vlad, Howard, and I went back in the car. First Vlad, then Howard went for a bit of a sleep. After 5 or 10 minutes of lying down outside I decided I should have a nap too.

When everyone else got back we hung out at the house. Vlad and Matt went to get some beer from a shop. They brought back 2 cans of 5 different Romanian beer. We set up a taste test to see which one people preferred without them knowing what was what. Ursus came out on top, of course.

Lizz set up a game of higher or lower. We played that for a long time. Lizz introduced some new rules to the game. You were allowed to guess that the next card would be a pair, although you’d have to be pretty lucky to get that right. If you didn’t guess at a pair and a pair came up then you could shout “PAIR!” as quickly as possible. If you shouted it before the dealer then you could continue.

The Last Night

The Last Night

It was a good evening, but there was a sense of impending disappointment because we knew we were getting on the coach to Cluj at 11 or so.

Everyone was sad to reach the end of the holiday, but we all made plans to meet up and hang out again soon.

When we got on the minibus there was a girl on there already, in addition to the driver. She spent the whole journey up at the front though, so I guess she was just keeping the driver company.

We stopped at a petrol station and bought lots of drinks and snacks. I also bought a Romanian copy of Playboy. Unfortunately I discovered that it appeared to be a pregnant women special or something. I didn’t know this until Gordon, who looked at it first, pointed it out to me.

Most of the journey back to Cluj was spent trying to sleep, but mostly failing. It wasn’t very comfortable at all.

Friday 30th of May 2009

We queued up in the airport for a while and then went through to the departures lounge. This consisted of one shop. Lizz bought me my final bottle of Mountain Dew and then noticed that there was free Wi-Fi available. It certainly helped to pass the time.

At some point an English man asked me to watch his bag for him while he went to the shop. When he got back he decided to latch onto Lizz and I for the remainder of the time in departures. Everyone else walked off and left us with him. We managed to catch up with them when we lost him during boarding and we all sat together on two rows.

It was an uncomfortable flight spent trying to get some sleep, much like the drive of a few hours previous.

When we finally made it back to Luton a gypsy lady and her family of 600 people decided that the queue didn’t really apply to them at all. They walked all the way to the front of the queue with the fat gypsy woman saying “ups” (I assume she meant “oops”). It was extremely annoying, but as usual neither I nor anyone else actually said anything to her, and so she’s only learned that it works and will do it again next time.

We all got our bags and went outside into an absolutely boiling hot English morning. I don’t know how it was so warm so early in the morning, but it was quite amazing.

Gordon and Sarah left us at Nero Express and we caught the bus back to the long-stay car park. We were right underneath the L25 signpost which was very pleasing for Matt and I who had insisted that’s where we were parked. Lizz and Claire had both somehow decided we were at L26. Silly people.

Matt drove us home while we listened to Chris Moyles and his golden hour. There were so many songs from 1990, and then he decided to continue with that and played a bunch of other songs from the decade.

All in all it was a really great holiday. I really hope I get to go back to Romania again some day so I can see some of the other places. I’m extremely thankful to Vlad, Jo, and Vlad’s whole family for making it such an enjoyable experience for everyone.

Most annoying hashtag of the month (#moonfruit)

I was getting bored of finding that several people I know (mostly you, 0lly :P) only bother tweeting if they stand a tiny little chance of winning a MacBook or whatever by sticking #moonfruit everywhere.

I decided to write a little command chain to show me how many of the most recent 200 tweets in my “friends timeline” contained the ubiquitous hashtag.

Turned out to be 9.5% of tweets. That’s damn near to 1 in 10 tweets being of absolutely no interest to me. Booooring! Here’s the command chain I wrote. I’m sure it can be refined plenty. I only use the XML API interface for Twitter because the JSON format doesn’t bother splitting results onto separate lines.

curl -s -u YOUR_TWITTER_USERNAME http://twitter.com/statuses/friends_timeline.xml?count=200 > /tmp/twitterlog.txt && echo -n 'scale=2; 100/200*' >/tmp/twittercount.txt && grep '#moonfruit' /tmp/twitterlog.txt | wc -l >>/tmp/twittercount.txt && cat /tmp/twittercount.txt && cat /tmp/twittercount.txt | bc

Obviously you’ll have to substitute YOUR_TWITTER_USERNAME for your actual username. You can also change the bit that says #moonfruit to anything else you want to search for. Oh yeah, this will prompt you for your Twitter password, but all communication is directly with Twitter, so you’ll be just about as safe as if you’d gone to the website. You’ll encounter a lot of problems if you try to run this in Windows, too. 🙂

MySQL default values should be better

I was creating a table a little while ago that stores a timestamp that is essentially an expiry date. I had wanted this to be a date 2 weeks in advance of the current date and time. With a timestamp field, however, the only non-constant default value available is CURRENT_TIMESTAMP. This, obviously, represents the moment in time that the row is created. I wanted to be able to do something more like the following:

expiry_date TIMESTAMP NOT NULL DEFAULT DATE_ADD(NOW(), INTERVAL 14 DAY)

Unfortunately that’s not allowed at all. Perhaps at some point in the future it will be though, and I look forward to that day.

If you’re doing this yourself and your expiry date is absolutely always going to be the same amount of time into the future then you can use something like the following:

start_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

You could then use something like the following query to fetch all rows where the expiry date has not been reached:

SELECT * FROM table_name WHERE DATE_ADD(start_date, INTERVAL 14 DAY) < NOW();

Oh well, just another little MySQL thing I found a bit interesting while I was poking around. 🙂

Birthdays, bad news, and buying furniture

On Friday I found out that JonP’s dad Peter had died the previous day. It’s really sad news and I can’t believe it happened. It was so completely unexpected as far as I knew. Dave, Len, and I went over to see JonP, Emma, and family over at Peter’s house and we stayed there until the early hours of the morning. I learned that you have to say your glass is half full no matter how much liquid is in it unless you want someone else to drink it for you.

Carly came to see everyone at one point. When it reached midnight it was her birthday, and also Peter’s brother-in-law George’s. We wished them all a happy birthday, which was quite strange considering the circumstances of the gathering. We left Peter’s house at 5am and went to McDonalds to get breakfast just as they opened. It was pretty nice at that time. Len caught a taxi back to Nottingham and Dave and I caught a taxi back to our houses.

I slept until about mid-day on Saturday and woke up feeling really hot even though it was overcast outside. Lizz was planning to go to Ikea, so I went along. We had all the usual arguments as we went around and eventually settled on a pair of wardrobes that are 236cm tall. That’s pretty much all the way to the ceiling in our bedroom. After we’d collected everything we began to wonder if it would all fit in the car or not. I called Dave to see if it would be possible to get his help if it wouldn’t fit in our car. He said there’s no way it would fit in his. It’s a good job we managed to get it all in our car. 🙂 The drive home was not a comfortable one for me as I had to sit on a folded-down seat crouched over like a hunchback. I couldn’t lean back because there were boxes beside me. I was glad to get home.

We constructed one of the wardrobes and then Dave and Emma came over to call for us. Lizz said she had to stay to work on the wardrobe because there were no doors or shelves or anything. I went along and we watched Yes Man at Hayley’s house before Hayley dropped us back off at home again.

Lizz went for a bike ride on Sunday, and so I got to work on the second wardrobe. I had just got it standing when Lizz’s dad and Philip arrived with the chicken coop. We moved that to the back garden. Lizz and her mum got back and we all hung out in the garden while Lizz’s dad put some rubber on top of the coop to keep the rain out.

When everyone had gone Lizz and I went upstairs and finished off the wardrobe and tidied up. Lizz got her clothes sorted out for the first time in a very long time and I think it made her very happy indeed. I didn’t have any coat hangers left over, so I’ll have to sort mine out later on.

I spent a while playing Burnout Paradise and managed to gain another couple of trophies, which is nice. Then Lizz and I relaxed on the sofa and watched an episode of Battlestar Galactica before I went upstairs to bed before Lizz because I was so tired.

A very mixed, eventful, busy weekend. Looking forward to a more relaxing one soon!

MySQL case insensitivity on varchar fields

I created a MySQL table like the following:

CREATE TABLE `links` (
`id` int(11) NOT NULL auto_increment,
`short_id` varchar(255) NOT NULL,
`url` text NOT NULL,
`user_id` int(11) default NULL,
`created_at` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT unique_key_1 UNIQUE (`short_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

This structure caused an error for me when it came to inserting an upper-case ‘A’ in addition to the lower-case ‘a’ into the short_id field. I removed the unique constraint for the short_id field and this allowed me to create a row with ‘A’ as the short_id.

Unfortunately

SELECT * FROM links WHERE short_id='A';

gave me both rows (‘a’ and ‘A’), with the ‘a’ row being first. To fix this I had to set the short_id field to be BINARY. When I’d done that I realised I could make the short_id field unique again.

To create the table properly I now use the following query:

CREATE TABLE IF NOT EXISTS `links` (
`id` int(11) NOT NULL auto_increment,
`short_id` varchar(255) character set utf8 collate utf8_bin NOT NULL,
`url` text NOT NULL,
`user_id` int(11) default NULL,
`created_at` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
CONSTRAINT unique_key_1 UNIQUE (`short_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

You can just add the BINARY keyword after the field data type if you like, e.g.:

`short_id` varchar(255) BINARY NOT NULL

Hope this helps someone else out there. 🙂

Stanford pwned by the FBI

I was just reading a news article about a guy named Sir Robert Allen Stanford. He’s basically guilty of doing the same sort of thing as Bernard Madoff, which is taking a shitload of money that doesn’t belong to him.

The part of the article that made me laugh was a quote from Stanford’s attorney, Dick DeGuerin:

“Federal agents in black SUVs surrounded his girlfriend’s house this afternoon, and just sat there. […] I told him to walk out and introduce himself. So he did, and he asked them, ‘If you’ve got a warrant, take me into custody. If you don’t, I’m going to Houston.’ And they did, so they arrested him.”

That’s a brilliant play by the FBI, in my opinion. It’s a proper comedy moment. I imagine the arresting officer shrugging his shoulder and saying “Ok then.” I wish I could have seen the look on his stupid face as he realised they did have a warrant.

The filming of a sit-com – The Scum Also Rises

Yesterday Dave took the day off work from his new job. I left early after working until 7pm the evening before and arriving half an hour early on the day. The reason for this is that we were going to see the filming of a sit-com starring Adam Buxton (as in Adam and Joe) and Iain Lee (as in The 11 O’clock Show).

I got free tickets from SRO Audiences, and so all we had to do was fuel a car and get down there for 6:35pm because the tickets were “priority” tickets. Dave arranged to pick me up from my work at 3:30pm. Unfortunately there was a really bad accident involving a car, a motorbike, and lots of blood on the road. I managed to meet Dave and we ended up leaving at around 3:20pm.

On the way out of Nottingham we got stuck in traffic. Then some of the traffic got stuck behind an ambulance that insisted on moving at around 20mph for some reason. It drove right by the hospital, too.

The M1 was pretty simple and we enjoyed the drive all the way down to London. As we reached London we heard that there had been an accident on the M25 so we decided to get sat nav on the job and go through some of the centre of London. This was a bad idea. Sat nav decided to lose reception while we were underneath a bunch of raised roads. We ended up getting onto the M4. I got directions on my phone because sat nav wasn’t playing any more. We followed the A312 for a bunch of time as the phone directions said. Unfortunately we stayed on it for far too long because we never saw the sign saying where we should turn off. We got sat nav back on and it started working again.

By this time we had already missed the 6:35 priority seats, but were aiming to be there in time for regular seats up until 7:15pm. This was when we ended up stuck in traffic on some annoying little high street somewhere near the A40. Apparently we had gone north on the A312 instead of south, somehow. We were sitting in traffic when 7:15pm came and went, so now we were heading for Teddington Studios as a matter of principle. We arrived around 15 minutes late, and then decided to just go visit JonP instead.

Teddingston Studios

Teddingston Studios

We ended up going to Morrison’s and bought some supplies for a barbecue and went back to JonP’s roof terrace. After eating some food Dave and I headed all the way back up to Mansfield and it was 2AM by the time I got home. On the way home we listened to a radio station that played Unchained Melody, Whiskey In The Jar, and The Ghostbusters theme. 🙂

So basically, I have no idea how good The Scum Also Rises may be. I didn’t get to see it. Perhaps another time…

War of the Worlds

Lizz met me after work yesterday so we could go to see Jeff Wayne’s War of the Worlds at Nottingham Arena.

I’ve liked War of the Worlds since I first heard the radio broadcast that sent people running to the hills.

The Jeff Wayne musical version is something my dad introduced me to shortly after. I know pretty much all of the songs and the music now and it was really great to go there and see it performed live. I do think that most of the effects and things like that were pretty cheesy when it came to the acting, but oh well. I was there for the music and it didn’t disappoint in that regard!

Update
I forgot to mention that at the end of the show we were asked to “show our appreciation” for the musicians, the singers, and then the on-screen cast! Why? When you’ve seen a film in the cinema do you stand up and applaud Jason Statham for another ridiculous action movie that’s somehow still compelling enough to make you go and watch the next one? No, you don’t. They’re on the screen and they can’t hear your applause.

Internet Explorer Quirks Mode Quirks

I have spent a large portion of this week working on getting Internet Explorer to display Flot graphs in the same way as Firefox. There’s a thing called ExplorerCanvas that basically acts as a <canvas> tag for IE.

Unfortunately IE requires that the page is rendered in quirks mode for the graphs to show up properly. This in itself is quite a simple thing to achieve. Adding an HTML comment before the doctype declaration (as below) will make IE render in quirks mode.

<!-- Quirks mode please -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

This has the side-effect of rendering the whole page as if you were using a browser from 1998. If you have well-formed CSS on the rest of your site then quirks mode will almost certainly screw that up for you.

I thought an easy way of getting around that would be to render the graph in an iframe in quirks mode, and render the rest of the page in standard mode. I rewrote a significant amount of code only to find that in Internet Explorer an iframe will be rendered in the same mode as the parent document regardless of the mode you set. It not only ignores a comment before the doctype, but also ignores the X-UA-Compatible header (or meta http-equiv data) sent with the iframed document. You can see this for yourself if you’re unlucky enough to have Internet Explorer to hand by going to my test pages.

Example Flot graph

Example Flot graph

Thankfully my code was all under version control in git so I could step back to how I had it before. I decided to add a configuration setting to this one particular script so that an additional CSS file was included for this script only. Of course this then caused the additional CSS file to be loaded in Firefox, which screwed up the display completely.

Finally I learned about conditional comments (below) that allowed me to only load the CSS file in Internet Explorer.

<!--[if IE]><link href="/IEQuirksMode.css" rel="stylesheet" type="text/css" /><![endif]-->