Archive for the ‘Uncategorized’ Category

Sudoku Solver

Saturday, May 15th, 2010

The above is a Sudoku solver I wrote in Java a while back. Here it is running in the browser. The Java has been converted to in-browser Javascript by Google Web Toolkit.

Please feel free to type in the hardest Sudokus you can find anywhere, and let me know if it can solve them, I haven’t found any it can’t yet.

I assume the in-page Javascript will not work in RSS readers, email notifications, etc. If that’s the case, click here to get to the original Sudoku solver page on my blog.

The algorithm works by backtracking, i.e. simply going through all squares from top-left to bottom-right, and finding the set of “candidate numbers” for that square (i.e. which numbers are not already used on that row, column or 3×3 block). The first candidate number is “applied” by placed it into the square, and the algorithm moves to the next square. If there is a square where the set of candidate numbers is empty (i.e. no number would work, given the candidates applied in previous squares) then the system returns to the previous square and tries the next candidate for that square. Once the system has gone “beyond” the bottom-right square, then the set of applied candidates consitutes a solution. However, backtracking continues, if the system reaches beyond the bottom-right square again, then the previously found solution
was not unique, and the algorithm terminates. Once the system has backtracked back to the start, if a single solution was found then it is a “unique solution” (success case), otherwise if there are no solutions then the Sudoku is unsolvable.

By the way, Internet Explorer really isn’t that fast; I appreciate that is well-known to anyone who’s ever read Google Chrome marketing material! But the Sudoku here takes 708ms to solve on IE8, 334ms on Firefox 3.6, about 100ms on Safari 4 and Opera 10, and 49ms on Chrome 4, on this 2.3GHz/core Intel Windows Vista computer.

Update: Alas there were Sudokus which took too long for the original synchronous approach (i.e. user clicks, do calculation, update the screen with the results). So now, in the case the calculation takes too long, a “worker” is spawned, which does the calculation, and the spinner is displayed in that case.

Download the source here.

My mate came across the following HTML

Friday, April 30th, 2010
<select class="selectTitle" id="C5" name="C5">
  <option value="">--select--</option>
  <option value="1">Mr</option>
  <option value="2">Ms</option>
  <option value="3">Mrs</option>
  <option value="4">Miss</option>
  <option value="5">Doctor</option>
  <option value="6">Judge</option>
  <option value="7">Professor</option>
  <option value="8">Councillor</option>
  <option value="9">Madam</option>
  <option value="10">Mr &amp; Mrs</option>
 (more...)

/etc/cron.daily scripts may not have dots in their name

Sunday, April 18th, 2010

I just had the problem I’d placed a script into /etc/cron.daily on my Debian Lenny system but it wasn’t getting run (or at least it didn’t seem so).

Two things I learned:

(1) Execute the following to see which scripts would get run:

run-parts --test /etc/cron.daily

(2) In my case, the reason the script was never executed was that I called it “xyz.sh” as it was a shell script; the dot in the filename was the problem. I removed the dot and now it runs.

“me” vs “you” in user-interface dialogs

Monday, February 15th, 2010

Computers, if they are addressing the user, should address the user as “you”, not as “me”.

Computers need, from time to time, to address the user, for example “You have updated your setting successfully”.

Some programs use the word “you” to address the user, some use the word “me” on the grounds that the user is reading it, and to them, they are “me”.

However, using “me” to address someone is ridiculous! That’s as logical as a human using the word “I” or “me” to refer to the recipient of a piece of communication, “hey, do I fancy going to the pub?” on the grounds that, to the recipient, they are “I”.

“me” is the source of communication, “you” is the destination of communication; if a computer is communicating, the user is the recipient of the communication so should be called “you”.

Specifically Gmail is the main culprit for this in my life, it lists conversations between “me, Joe”; having “you, Joe” or “Adrian, Joe” would be much better! Gmail even, on the same screen that it lists conversations between “me” and other people, says “You are using 25% of your 7000MB”, so it’s not even consistent!

Learnt two new smileys today

Wednesday, February 10th, 2010

Thanks to Nessus!

\o/ – arms raised in the air – success gesture
<3  – heart

3 changes price from £10 to £1250 then charge me to cancel

Friday, September 18th, 2009

Where do I begin to describe how much I hate three (mobile operator UK) today.

(I had a mobile internet subscription / device from them.)

Firstly – and this is not new – the program they supply with the computer to show you how many MB you’ve used (and thus how much you’ve got left before they charge you) is “inaccurate” (= underestimates the amount you’ve used), some support person from three told me that. But this program has a massive window that comes up, with the 3 logo plastered all over it – I mean it’s not exactly obvious that this program is inaccurate. Why don’t they just put a huge warning up saying “this data is inaccurate”?

The product is something like 1000 MB surfing for £10 a month. The main point, for me, being that you can use it in certain foreign countries, including Austria, and the price is the same as if you used it in the UK. This is why I bought it – so I could use it from both the UK and Austria. This was called “roam like home”.

Well – that’s no longer the case. I noticed a bill (thankfully only £15), called them, tried to cancel, they told me I’d have to pay a cancellation fee as I’m still in the contract period. I mean this is so totally outrageous.

So I spent 45 minutes on the phone, failed to get them to drop the early cancellation fee (which admittedly is only 20 pounds). They say then sent me an SMS informing me of the changes, giving me 30 days in which to cancel. As I hadn’t cancelled within that time, I had to pay the fee.

However a UMTS modem for a computer – which I only use very rarely, simply isn’t switched on when it’s not in use. Normal SMS expire if they aren’t delivered after a certain period of time (10 days?) but they assured me this was a “special” SMS which didn’t expire. And I have often had problems with SMS when roaming, but they assured me this couldn’t have been the case.) Even if that had been the case, if the device is off for those 30 days, I wouldn’t receive the SMS in time. And anyway, I didn’t receive the SMS at all (but they claim I “must have done”)

And they also said they posted it on their website – nice one, as if I surf to three.co.uk every day to hang out – it’s the new Facebook, so much fun to be had there….

They also say they are not obliged to provide this service, it’s not in the terms and conditions. I knew they’d say this. But there were massive advertisements for this feature when I went into the shop and bought it – I mean many huge person-size signs advertising the service. The guy in the shop told me this was the product, he didn’t say “this is the product until further notice”. I even have an email from 3 confirming this is the case, again with no mention of this being something which could expire or change:

Austria is a 3 like home network. If you use data in this country then it’ll be first deducted from your allowance provided you are latched unto 3 network.

Normally out of allowance charges in Austria is £3.00 per MB however, as Austria is a 3 like home country if you exceed your allowance and are roaming to 3 network, you’ll be charged 10 pence per MB.

I mean I understand services can change over their lifetime, and prices can change, etc. But I mean this is no minor service change:

  • Before, when I bought it, I can use 1000 MB in Austria for £10
  • Now, 1 MB in Austria costs £1.25, so 1000 MB would be £1,250

So I spoke to them, to all their “managers” etc, on the phone, and they told me there’s nothing they can do. I didn’t cancel it in time; they understand my frustration but their hands are tied.

They’ve fundamentally changed the service – making it useless to me – and now charge me for cancelling it

Thankfully it didn’t cost me much - £15 in extra MB used, and £20 cancellation fee. But that’s mainly due to the wisdom I acquired by being charged €2500 by another mobile operator. This guy got charged £500 due to this change by 3, for example.

I hate mobile operators. Three is now added to my list of companies I’ll buy anything from again, the other being T-Mobile.

I mean this is capitalism – the operators are happy when they can charge people a few thousand Euros because they didn’t understand they were roaming, or didn’t understand the T&C had changed. As a consumer one is powerless. Capitalism shouldn’t have come to this.

ssh to easyname account

Thursday, September 3rd, 2009

We have just released a feature on www.easyname.eu where I work – it’s an automated domain-registration and web-hosting service – that you can “ssh” (log in) to your easyname filespace account. I think that’s cool – I don’t know of many web hosting companies where that feature is offered!

(I didn’t program the feature – neither the front-end nor the back-end – but I just released it, so I would have been responsible for any problems – although there weren’t any….)

Wasted 3 hours of my life

Thursday, August 20th, 2009

Working at Easyname, I heard from our support department that strange things were happening with PayPal payments – either they seemed not to be appearing on our site, or there were errors in the logfiles, and the users were complaining.

This is obviously a “drop everything” kind of bug – no matter the fact I was deep in the middle of doing some other software development (or even if I’d been working at another customer), if stuff to do with money doesn’t work, everything else must be stopped and that must be looked at with the highest priority.

What I did:

  • Look at the logfiles, there was an “unknown error” there (not very helpful!)
  • Set up a developer account for Paypal, get our software on my dev system to work with it
  • Test the PayPal IDN protocol using their tools and my newly set-up development environment
  • Change the software to produce more logging (rather than “unknown error” – although to my knowledge, that log had never been printed before, in the year or so the system was online)
  • Release the version with more debugging online
  • Communicate with various people I’m working with (management, support, ops, ..)
  • Test the new version by making a payment
  • See that it still didn’t work

What I should have done:

  • Do a search using twitter.
bluecrowbar I’m seeing problems with PayPal IPN (Instant Payment Notification). The notification is currently not instant. 13 minutes ago from Twitterrific
mystore Paypal IPN payments recived, they were just 4 hours late ;) 27 minutes ago from web
mystore @staleedstrom Check @chomasia ’s This page has details of the IPN issue with PayPal http://bit.ly/3yJ1w about 3 hours ago from web
tonydalian2009 Paypal IPN doesnt work by now. sigh~~~about 4 hours ago from web
travelfish What part of the word “Instant” in IPN doesn’t payPal understand? about 4 hours ago from TwitterFox

What can I say? Looking at logfiles is such a legacy approach to bug solving.

Optical device

Saturday, May 16th, 2009

I saw a cool device today. One of my customers manages data centers and they have a new data center and need to connect it to their old ones, so they’ve bought/rented some “dark fiber” between their data centers and have fiber multiplexers at each end so that lots of fiber-optical devices at each end can all talk to one another over this single dark fiber. (Or something like that – I don’t know too much about networking equipment!)

So basically this multiplexer looks like any other switch thing, a long horizontal device with a bunch of identical ports on the back, each with a number etc, and one “master” port which connects to the dark fiber. (only the optical sockets look slightly different from e.g. RJ45 sockets..)

But then i noticed, this device only had the identical data ports/master port on the back. I couldn’t find a power socket, I looked at all of its sides, and was confused for a while. Until i worked out the reason why I couldn’t see the power socket – the device was purely optical and didn’t need power!

Imagine that, data center, a bunch of hard-core networking and computing equipment, the last thing one expects is devices that don’t need power!

www.aaa-plus.com

Tuesday, April 28th, 2009

Thanks the the internet archive I found one of the first (or one of the only?) websites I designed i.e. I did the graphics, did the “implementation” using a tool which produced HTML, etc. (Although the company logo etc already existed, I didn’t write the texts..)

This was for AAA+ which was the first company I worked for in my life, which was also the company I worked for just after coming to Vienna, so has a lot of associations of newness in my life.

And I think it doesn’t look too bad :) www.aaa-plus.com (Internet Archive)