Skip to content

Regex Split bug in JScript?

I’ve been messing around with JavaScript quite a bit recently and I came across a ‘bug’ in the Microsoft implementation of the split() method.

Take the following example string (note the two tabs at the end):

var s = “Hello\tHow\tare\tyou\t\t”;

and then run the following to write it out to the screen:

document.writeln(s.split(”\t”));

Well that works as expected, and outputs “Hello,How,are,you,,”;

But if you replace the string in the split method with an inline Regex object it fails if run under a Microsoft implementation

document.writeln(s.split(/\t/));

This outputs the same as above in Firefox etc, but if run in JScript (i.e. Internet Explorer) you lose all empty elements and get the following: “Hello,How,are,you”. This is really weird, because if you use the string delimiter above it works just fine.

I have managed to find another blog post that tries to fix this problem, but doesn’t say why it happens.

http://blog.stevenlevithan.com/archives/cross-browser-split

To test this online, try going to W3Schools.com.

Tagged , ,

What makes StackOverflow different…

I was asked the question recently, what makes StackOverflow different from other developer forums. (Thanks http://twitter.com/redgum)

http://www.stackoverflow.com

I’ve only been using it for a few days now, and its still in private beta, although it is claimed to be (mostly) feature complete.

There are a few obvious things that mark it as different from your usual developer forum.

  1. No forums

It doesn’t have the concept of forums, instead uses tags to provide order to the chaos. This is good, in that everything gets at least some attention when it is posted, as well as the eventual problem of things being posted to the incorrect forum never appearing.

  1. No login

Eventually you will be able to ask questions and answer them without logging in. This does sound very strange, and as the web site is still in private beta it really isn’t being tested much yet, but it certainly could make life interesting.

  1. Voting

Questions, as well as answers can be voted up and down - you require a log in and the required reputation to do either of these things. Reputation is gained from answering questions, having questions and answers voted up, and by having answers marked as ‘correct’ by the question asker. The exact formula isn’t really known.

  1. Badges and Reputation

As you answer questions and generally interact you gain reputation, and various ‘badges’. This is in common with many game web sites (such as Kongregate) where completing certain objectives gives you a particular badge. Badges are given for things like ‘First Answer marked as Correct’.

So far this is producing a very fluid and engaging experience, but I don’t think it will truly get tested till it is open to a) Spam and b) Crap questions. Hopefully the reputation/voting system will encourage the better questions, while discouraging the worst.

Will StackOverflow end up any different from all the other developer forums? They have certainly set out on the right path. Whether this path enables them to end up better than the rest is something I think is still to be seen.

Tagged ,

Reasons Twitter is a better IM client…

I'm starting to like twitter. As with most (damn the phrase) web 2.0 major sites I have an account (I'm there on all the social networks, flickr, pownce, last.fm, friendfeed etc) but I found it quite hard work to get used to the format.

Then I started trying out http://www.posterous.com which takes anything I email them (like this), throws it on a blog and then updates twitter. That and a couple of people who've sent me actual tweets (ok, that still sounds silly) and the service just comes alive.

And the reasons I prefer it over normal IM - well mainly because of the whole "who's online" thing - I hate being pinged in IM by people at random times - if maybe I just logged on to check one thing in google, or I'm trying to write some code or play a game. So what do I do, well I shut down the IM client - or even worse make sure it doesn't start at startup. And from there on in it becomes pointless.

With Twitter there is no concept of being online - you just post anytime you want - and read others posts anytime you want. You can keep track of those sent to your ears, as well as what the world is saying (I think Search was the big thing missing, but now they've got that sorted too).

And if you close your twitter client (or heaven forbid twitter is down) then that's just a while for you to get more work done :)

Posted by email from Sam’s posterous

Big Bug in Flickr Screensaver

Hi

I’ve just been informed of a fairly large bug in the uninstaller for the latest Flickr Screensaver.

Basically if you uninstall it it will try and delete your Windows\System32 directory.

Obviously that is VERY BAD. I apologise. I’ve deleted the installer from the web site, but anyone who has the latest version of the screensaver should not uninstall it.

Sam

he thought of cars

he thought of cars

he thought of cars

I just got a bike - at the age of 33 it is technically my first mountain bike. I did have a raleigh BMX when I was a kid, but didn’t carry on with bikes into my teens. I am now trying to cycle to work 3 times a week - does depend on the weather thought :)

My new one is a Raleigh too, so I guess I got indoctrinated as a kid. So far I’ve done nearly 75 miles in a little under 2 weeks (which after much number crunching, based on roughly 30mpg and 115.9p per litre for petrol, giving 75/(300.22)1.159) is a saving of £13.17. Only another 20 weeks and I’ll have paid for the bike!

Unfortunately it doesn’t as yet have seemed to do anything for my weight :(

Tagged ,

Amen Corner - My Photo in Print

I’m pleased to announce that a photo I took a few years back was chosed to be the CD cover of american blue-grass band Railroad Earth (no, I hadn’t heard of them either). You can listen to most of the album on their web site if you want.

I’ve just received the pre-release CD and it’s great to see myself in print (and my name on the inside cover as well!)

Here’s a of shots of the finished work alongside the original:

Update: On the origins of my photo - I took the photo in Dec 2006. We actually have a street (or maybe its just the corner) called Amen Corner - it runs behind St Nicholas Cathedral in Newcastle (England).

The photo was taken during a winter festival called the Glow Festival that was run by the council - various light based art installations throughout Newcastle and Gateshead. This particular lamp had had its bulb changed to a red light - hence the colours in the photo.

I believe one of the band members found the photo on Flickr (see above link tot he original page) and suggested it to the rest of the band - and the rest as they say is history :)

Tagged , , ,

Virgin Media fixed my cable modem

I’d been having this strange problem with my Virgin Media (Telewest as was) broadband.

Basically, after about 5 minutes of trying to download files, the cable modem would ‘hang’ where the data light would stop flashing. The only way to get back to normal service was to unplug and reboot my cable modem.

I suffered this fault for a few weeks - the delay between reboot and crash seemed to vary between 5 minutes and a day (I suspect it was based on how much data had been downloaded, but I’m not sure). Then after two phone calls with Virgin Media tech support I eventually got it fixed, and I thought it might be useful to post the information here.

Disclaimer: If you follow any of the advice here and screw up your cable modem its not my fault! These instructions probably only apply to the WebStar cable modem I have as well.

First off, you can view your cable modem status page by going to http://192.168.100.1 in your browser. The following diagram shows the signal screen.

If you look carefully at the Downstream Frequency it reads 331000000Hz. Apparently either 331000000Hz or 339000000Hz are valid values, but mine was reading 3312500000Hz which isn’t a valid value, and hence was the cause (or symptom) of the problem.

So if your cable modem is having the same problem as this, and the status screen above doesn’t show a ‘correct’ value then this might be the cause of your problems.

Fixing the problem?

You can change this ’starting frequency’ on the following screen: http://192.168.100.1/gscan.htm

Double Disclaimer: Don’t blame me if this all goes pear shaped.

Tagged , ,

How to use ECHO to output a blank line

I learnt something new today. You can use the DOS ‘ECHO’ command to output a line (or in fact any text you want) by putting a period ‘.’ immediately after the ECHO. i.e. The following will echo a blank line.

C:\> ECHO.

Also, if you want to echo some special characters you can put a carat ‘^’ before them:

C:\> ECHO ^>^>^>

>>>

C:\> ECHO >>>

> was unexpected at this time.

Read the comments on the following post to get more juicy tips:

The Old New Thing : How do I force the ECHO command to echo?

Tagged , ,

Does More Than One Monitor Improve Productivity?

Coding Horror: Does More Than One Monitor Improve Productivity?

A difficult one this one - I’ve never actually been able to work with 2 same sized monitors, but I have tried to use a laptop and an external monitor at the same time, and personally I found the ’second’ monitor (the external one is bigger so that would be my primary monitor) to be a distraction - especially if I had a web browser or email application running on it.

Tagged , ,

garfield minus garfield

garfield minus garfield

Surreal, and poignant.

Tagged ,

Flickr .Net Screensaver - Release 4.2

Flickr .Net Screensaver - Release: Release 4.2

Finally released a new version of the screensaver. This is a beta release, but hopefully should fix the problems that people have been having with memory and threading issues.

Tagged , ,

20 things I’m longing to do in 2008 (Part One)

Tagged by Brenda, so…

I shall start at 1 and see how far I get - so in no particular order:

  1. Convert my Flickr Screensaver to WPF.

I thought I’d start off with this as this is a mostly code related blog. I’ve written some small prototypes and it looks like it could be quite good. I’ll also try and write a couple of blog posts about the process/what I learnt.

  1. Take more photos.

I had a slow end to the year photo-wise, but I got a new wide angle lens for Christmas which it would be rude not to use, plus strange people keep giving me rolls of film, so they need experimenting with.

  1. Lose weight and strengthen ‘core’.

I’ve been hovering at around the 13stone mark for quite a while now. I want to get down to 12.5-ish, all in an aid to…

  1. Improve my climbing.

Climbing is now definitely my main none-work related focus at the moment, and my main inspiration for getting the weight down. We have three trips abroad planned for this year, all climbing trips (Fontainebleau in France is the first one). Its a strange game, climbing - while there is a certain joy in ‘just climbing’ there is also a large part of you that always wants to be a little bit better.

Working on your ‘core stability’ (which is more than just your abs, but your back and other areas too) is very good for climbing. Good exercises include doing crunches on a swiss ball, planks (or benches as they are sometimes called) and super man exercises.

  1. Visit more places in the north-east.

This one should go nicely with the No 2. Places I want to go this year include Dunstanburgh Castle and Cragside, but there are plenty of other places out there (like the Farne Islans for example).

  1. Visit more places in the UK.

This one will go nicely with the climbing one as well. So far I’ve only really ever climbed a little in the Peak District, quite a bit in the Lake District, and lots in Northumberland. Possible places to go include definitely North Wales, other bits of Yorkshire, and ideally (though less likely) somewhere on the south coast, like Cornwall (there is an area called ‘Chair Ladder’ which has some amazing climbing on it).

  1. Spell better

Get it into my head that the middle vowel of ‘definitely’ is an ‘i’, not an ‘e’ or an ‘a’. Whenever my hands spell that damn word I always get it wrong. Oh, and win more games of Scrabulous in the process.

  1. Improve as a husband…

Hey, no-one said I’m perfect, so there’s always room for improvement. Luckily I have a wife who loves me (and who likes climbing too).

  1. Think of something else to put on this list to make 10.

Because 9 just seems to few :)

Tagged ,

Kenya II

A new update:

With Kofi Annan and his team working with the two leaders , there is optimism in the air. Yesterday Kofi Annan met with the opposition leader and team . Today Thursday he will meet with the government . The opposition have cancelled nation wide demonstrations for today, because Kofi Annan’s team had asked him to. So MAF and many other missions are working with full staff today, whereas many people would have stayed at home for fear of the violence that has accompanied rallies . Unfortunately some youths caused trouble outside a memorial service yesterday. Across Kenya Friday is a Day of prayer for peace and justice and for the many, many families that have been affected by the violence. MAF Kenya will be praying along with many thousands of Christians and people of other faiths will be praying as well.
Tagged ,

Kenya Update

I’ve got a friend, Paul Waugh, who works in IT for MAF in Kenya. He’s been sending out email updates, and I’ve decided to repost them here (partially prompted by this post).

Dear all, The opposition have announced that there will be no more street protests after Friday (yesterday). They say “These last three days have been very painful and we have seen a lot of needless deaths and suffering … but today is the last day of the protests and we are now going to move on” . We give praise to God that at last, the normal person in the street can get on with building his life up again. We look forward to the two leaders meeting face to face with Kofi Annan and his team. We have just heard by text message that things are very bad in one area of Kibera, and a pastor’s family there are requesting prayer. Pray for law and order -there are many stories of criminals using the political situation as an excuse to loot and burn. They burn one section, and when neighbours rush to help they loot the empty houses. Pray for Kenya for Peace and reconciliation Pray for the Families that have been devastated by the last few weeks , many of them so poor that they were already barely making ends meet. Pray that God move in the hearts of the two leaders as they meet , and that they will have good advisers. Thank God for the good stories of neighbours harbouring and helping their neighbours, sometimes of different tribes. Many have donated food to complete strangers, churches in Nairobi have taken collections to help the displaced people.
Tagged ,

Firefox users more likely to rock climb!

rock-climbing.pngExclusive: Mozilla Secretly Launches A Viral Campaign For Firefox

Techcrunch is reporting on an interesting video released by Mozilla about Firefox. Apparently Firefox users are 139% more likely to be rock climbers.

Well I’m a rock climber and I use Firefox. Mmm, must be true as its on the internet!

View the video direct on YouTube.

Also, in a similar vein, Firefox users are apparently 13% more likely to have purchased Classic Rock in the last 3 months.

Tagged ,