Israeli vs Palenstinian soldier in football

In an advertisement for a company called Cellcom there’s a football match between Israeli and Palestinian soldiers. It’s somewhat like the story of British and German soldiers meeting in no-man’s-land for a Christmas game of football during World War I.

Here’s the original advertisement:

Here’s what actually happens if you try that in real life:

Ellipses

I like to think I’m quite good at using the English language. I’ve written and read a lot, I’ve studied English and journalism, and I’m really pedantic. All of these should have made me nearly impervious to grammatical and punctuational mistakes. I still find myself struggling with certain aspects, however. The ellipsis is one of these.

In language an ellipsis refers to more than one thing. The first listed example in the dictionaries I have consulted is usually describing how it is used in English that isn’t necessarily written. For example:

I can see people jumping.

Ellipsis is used here to mean the lack of part of a sentence that would clarify the meaning. Between “people” and “jumping” you could place several words that would completely alter the meaning of the sentence. See e.g., “who are” or “by.”

I have done some research, but they haven’t.

Ellipsis is used here to mean the lack of repetition of a word or phrase or its equivalent. In this case it’s the lack of “done any research” as the equivalent of “done some research” at the end of the second clause.

These are both very handy in spoken English, and I think you’ll find you probably use them pretty well without even thinking about it. It’s the written form that I usually get incorrect.

The ellipsis is usually written as three dots (full-stops or periods) in a row, although sometimes it is seen as three asterisks.

It is used in quoted text, as with the examples above, to show that some part of the text has been removed, or to show that the speaker trailed off while talking. In non-quoted text it is used to show that the narrative has paused or is trailing off.

When ellipsis is used to show that words have been removed from the middle of a sentence you should absolutely always use three dots. Unfortunately there are disagreements between styles as to how you should space these dots. Some styles dictate that you should write the ellipsis as if it were a three letter word with no space between the dots, but a space on either side, while other styles say that there should be a space between each dot.

This is … an example of the first style. While this is . . . an example of the second style.

The styles that say the dots should be spaced also place importance on the fact that the dots should all appear on one line. Therefore, if you’re using the spaced style you need to make sure that there are non-breaking spaces between the dots so they all stay together.

If you’re omitting words from the end of a sentence then it is common to leave a space after the last word you’re quoting and then follow with the ellipsis, and then a regular full-stop, exclamation mark, or question mark after that depending on the sentence. Some styles have this as 4 dots in a row without spaces, while others space each one of the punctuation marks.

This is a valid way ….
If you are using a style that loves spacing . . . .
This is important …!
Is this helping…?

The above examples are all valid in different styles and under different guidelines.

If you’re omitting text after the end of one sentence then some styles will tell you to ignore any punctuation marks from the end of the sentence. Others will tell you to leave a space after the existing punctuation marks and then put in an ellipsis, and others will tell you to run them on straight after each other.

The man in black fled across the desert, and the gunslinger followed … An occasional tombstone sign pointed the way
The man in black fled across the desert, and the gunslinger followed. … An occasional tombstone sign pointed the way
The man in black fled across the desert, and the gunslinger followed…. An occasional tombstone sign pointed the way

According to various styles I’ve looked at these are all potentially valid uses of the ellipsis. This varied usage makes it incredibly difficult to give an accurate guide to the general usage. If you’re writing for one particular style then you should probably read the section of the style guide that relates to ellipses. If you’re writing on your own blog or on a forum then you can pick a style to suit yourself, but it’s a good habit to stick with one style. It’ll help to make it easier for other people to read and understand what you mean.

I prefer the more succinct, un-spaced ellipsis, but it’s all down to personal preference. Just make sure not to only use 3 or 4 dots in a row at any time. And only 4 if the ellipsis comes at or after the end of a sentence. Try to preserve the meaning and tone of the quote, for example, if the quote is a question then you might want to try to keep the question mark in there somewhere.

Dual monitors at work

I decided to get a second monitor working with my computer at work so I didn’t constantly have to flick between workspaces and different terminal windows to write code and read my logs.

After a lot of messing around Jim looked over and told me about the xrandar program. It took a considerable amount of messing around (and a third monitor) to get everything working correctly. It’s still not quite perfect because I’m missing the bottom of the right-hand screen because of a difference in screen resolutions.

My desk at work

My desk at work

I was considering switching to something like Fedora or back to Ubuntu again because they’re usually pretty good at working out what to do with displays and stuff like that. Of course, it doesn’t help that the graphics card is an ATI something-or-other. nVidia cards are so much easier to set up because of their excellent little configuration tool.

First day with Perl 6 – UK postcode grammar

Today I decided to install and play around with Perl 6. It’s the developing version of Perl that is meant to replace Perl 5 in the future. It’s still under very heavy development, and is not ready for general use, but I thought I’d give it a quick look. Perl 6 is not backwards compatible, which means that if you’re used to writing things in Perl 5 you’re in for a shock.

I decided a good first test of something to write would be a UK postcode parser/validator in order to try out something new to Perl 6, or at least to me: grammars.

Grammars are basically a way of relating several rules or regexes to each other in specific ways. By the way, you can’t call Perl 6 regexes “regular expressions” any more because they’re apparently not regular enough.

After a bit of playing around I actually managed to get the following code working:

grammar postcode {
  regex TOP {
    <outcode> ' ' <incode>
  }

  regex outcode {
    'GIR'|<[A..PR..UWYZ]>(\d**{1..2}|(<[A..HK..Y]>\d|<[A..HK..Y]>\d(\d|<[ABEHMNPRV..Y]>))|\d<[A..HJKS..UW]>)
  }

  regex incode {
    \d<[ABD..HJLNP..UW..Z]>**{2}
  }
}

my @postcodes = 'WC1N 2PL', 'NG18 3JL', 'L1 4DJ', 'GIR 0AA';

for @postcodes -> $postcode {
  print "$postcode: ";
  if postcode.parse($postcode) {
    say 'Yes!';
  } else {
    say 'No!';
  }
}

I think that the few examples I’ve put in there represent the vast majority of postcodes out there, including certain London-style postcodes and the GiroBank postcode (GIR 0AA). If you want to play around with this then you can just add extra postcodes to the array and they’ll be iterated over in the for loop.

There are a couple of interesting differences in the syntax of the Perl above compared to Perl 5. The if and for statements have no parentheses around the condition. This is because parentheses directly after a word represent a subroutine. Also, to use a different variable as the iterator in a for loop you now use the -> construct after the array name (or range, or whatever you’re looping over).

There are loads of other differences, but I haven’t really had much of a chance to play with them properly.

So far I’m liking Perl 6 a lot. 🙂

Steve Ballmer is a hypocrite

I was just reading a news article about Steve Ballmer’s reaction to the recently announced Google Chrome operating system when I stumbled on this little gem:

“I don’t know if they can’t make up their mind or what the problem is over there, but the last time I checked, you don’t need two client operating systems.”

A quick look at Microsoft’s website tells me that Windows 7 is going to be released in “Starter”, “Home premium”, “Professional”, and “Ultimate” versions. There are more versions available depending on where you live because of Microsoft’s legal obligation not to force Internet Explorer on everyone in certain countries.

These are admittedly just different versions of the same operating system, but then we have to consider Windows Mobile on smartphones. That’s a entirely different operating system because it’s designed for a different type of device. Perhaps Microsoft should be reminded of their Zune. That runs a version of Windows called Windows CE (or Windows Embedded Compact). This is similar to the uses of Google Android and Google Chrome OS. Nobody would run a full version of Windows Vista on a mobile phone. It just wouldn’t be practical. Why should it be any different for another company? Do Apple run a full Mac OSX installation on every iPod and iPhone out there? You bet your ass they don’t!

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.

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. 🙂