Tuesday, January 27, 2009

When is a permanent redirection not permanent?

Let's say I have a flatmate called John. One day, his friend Simon rings:
Simon: "Hello, is John there please?"
Me: "No, he's at his girlfriend's this afternoon. Her number is ..."
Simon: "Ok, thanks."
No problems here. But eventually, John decides to move in with his girlfriend, but forgets to tell Simon the exact date.
Simon: "Hello, is John there please?"
Me: "No, he's moved in with his girlfriend. His new number is ..."
Simon: "Ok, thanks."
So, now I no longer have a flatmate called John. Then, one day:
Simon: "Hello, is John there please?"
Me: "No, he moved out, remember? His new number is ..."
Simon: "Ok, thanks."
Then another day:
Simon: "Hello, is John there please?"
Me: "No, I told you before, his new number is ..."
Simon: "Ok, thanks."
This is obviously wrong. When John was out for the afternoon, it was okay for Simon to ring and ask for John. But when I told Simon that John no longer lives here, Simon should just remember John's new number and start ringing that instead.

This, ladies and gentleman, is the difference between a temporary redirection and a permanent redirection. Those of us in the know call them a 302 and a 301. They behave exactly like I've described above -- if the server sends a 302, the client should keep checking back with the server for the resource in case its URL changes.

If it sends back a 301 though, it's permanent. Never going to change. Never. So, the client may as well remember that, and indeed, this is what the spec says:
This response is cacheable unless indicated otherwise.
(Note that the spec never really says "Cache it, or else" -- it only gets worked up over things that aren't cacheable.)

So, any decent browser worth its salt will be caching this response, right? Wrong. Although there have been posts asking about this, it turns out that the neither Firefox nor Internet Explorer cache any kind of 3xx redirection. The only one I've come across that does is Google Chrome (as also noted by Mauricio Scheffer).

This is really annoying, and I spent a morning tearing out my hair trying to understand why this wasn't working. Hopefully this post means somebody else loses a bit less time.


So, in summary:

Google Chrome: good
Firefox: bad
Internet Explorer: bad

If you want to test your browser, I recommend the excellent suite of tests written by Mark Nottingham. He has also written an excellent introductory guide to caches, which I suggest you read to understand this area.

Sunday, January 25, 2009

Stuart Miller: Bug Disposer

One of the things I like doing most is getting rid of bugs. Today Leah called me into the bathroom sounding very worried: she could see a blurry oval shape (her eyes aren't so good without glasses). Anyway, this is what I found:


That's right, a big ugly huhu beetle cockroach! After wondering what to do, I eventually managed to capture him in a chinese food container (note: this was harder than it sounds. He was very quick, and would go running at the mere sight of the container. Luckily I think the camera flash stunned him so I took a few (bad) photos before I got the container on).

We took him down to the bushes outside our apartment and released him, so it all ended well after all.

For the rest of the pictures, head over to Flickr.

UPDATE: turns out it's not a huhu beetle, it was a cockroach. So, instead of saving a native bug, I saved a pest. Awesome. Thanks Tom.

Thursday, January 22, 2009

Windows 7 Mini Review

I've been using Windows 7 for about a week now, and I have to say -- it's pretty sweet. This is my completely subjective review.


Startup
Windows 7 makes my computer feel faster. I'm not running on the fastest hardware here -- I've got a 2.4Ghz P4 with 768MB RAM (the minimum specs call for 1Ghz and 1GB). With XP, it takes an age to get to the desktop, and even once you can see the desktop it takes a long time for it to actually be usable.

With 7, it starts up in roughly the same time, but the desktop is usable as soon as you can see it. While this feature was new in Vista, my computer doesn't spend ages on the "preparing your desktop" screen I have seen on Vista computers.


Using Windows 7
Applications load snappily in 7, and I have yet to see the freezes that sometimes occur in XP. I can't decide whether to put this down to 7 or the fact that it's just a new installation -- time will tell.

The best thing I can say about it is that there's nothing really bad about it. I like the little improvements, like how when I drag a file it explicitly says "move to..." and "copy to..." rather than rely on an icon. I like how when I minimise an application that's doing something, it displays the progress bar in the application's thumbnail in the start menu (I don't like how it takes focus when it's done). I like how I can set my desktop backgrounds to rotate through pictures, and I like that there's localisation features in the built-in themes (in the US at least, it'll show you a different background depending on where you live).

There's definitely a lot to like about 7. But, there's one thing I'm not sold on.


The Taskbar
In 7, Microsoft has decided to go a bit OS X-y and has turned the taskbar into more like a dock. Instead of having a separate window for every application you have open, you just have an icon for every application. Clicking that icon lets you visually choose between the different windows your application has open (and in Internet Explorer's case, the different tabs it has in all of its windows). This means I can't quickly see how many windows I have open (something I found myself trying to do when I was wondering which window a site I had opened was in).

I guess it's not really bad -- it's just different and new, and I haven't gotten used to it yet. It's interesting though that this is the only feature that I haven't loved at first use.


Overall
When you look at the entire product, there's not much wrong with it. It hasn't crashed once (remarkable, from a beta), it's fast, it found all my device drivers, and there are several new features that are great.

The Windows 7 beta is what Vista should have been. While it looks like Vista in many places, it doesn't get in your face like Vista sometimes does. I may or may not have User Account Control turned on -- the key thing here is that I don't know. That pretty much sums it up: this version of Windows gets out of the way and lets you do your work, and that's the best compliment you can pay an operating system.



Postscript
It would be remiss of me not to mention that the end-game effects in Solitaire and the other games have changed. In every previous version of Solitaire, the cards would bounce around and fill up the screen. Now they fall down from the top and shatter on the bottom. The other games, like Spider Solitaire, still feature the fireworks, but now they're 3D and pretty.

My games reviewer, Leah, would like it known that the Solitaire effect is not as good as the old one, but that the fireworks are much better.

Monday, January 19, 2009

Spammers in Gmail

I recently got an email from my brother. It reads as follows:

Dear sir/madam,
We are an international electronic company. sell high quality low price
products, like IPOD, laptop, LCD TV, camera, mobile and so on. Welcome to visit
them, please visit our Web site:{redacted}
Online MSN/Mail:redacted disturb your precious time understanding. Best
wishes


My brother may be in Germany at the moment, but his English is much better than that. It was pretty clear his account had been spoofed as the reply to address.

Or was it? I took a look at the headers, and I was surprised to see that Gmail reckoned it had been sent by gmail.com. This is the whole domain-keys thing which is meant to prevent spam; surely it couldn't have been spoofed?

As it turns out, it wasn't. My brother found out that somebody in China (or at least whose IP address, 115.49.89.238, resolved back to China) had logged into his account and had sent the email to his address book. Somehow they had gotten his password; we're not sure how yet.

I've gotten him to run an antivirus scan with AVG and Avast, and an anti-spyware scan. Nothing has turned up on his laptop, so I can only assume he was caught on somebody else's machine.

The moral of the story is be careful where you log into your email from. It's altogether too easy to be blasé about it and assume that nobody could possibly be interested in your email, but my brother's case shows that anybody can be targetted.

And, the most important thing: change your password regularly, and don't reuse it for different sites.

Wednesday, January 14, 2009

Windows 7 Installation

So I, like just about everybody else on the planet, recently installed Windows 7. Lured by the promise of "looks like Vista but is fast", I fired up Virtual PC and installed it.

I'd like to complement the installation procedure. I've installed various versions of Windows quite a few times, from the days of 3.11 where you had to insert about 10 different floppy disks, to Windows 98, to Windows XP. The Windows 7 installation was hands-down the easiest I've ever done.

It asks you for three bits of information at the start: your language, where it should install to, whether you agree to the license; and that's it. Then it goes and installs. After a few restarts it's done, and you get asked a few more questions (username, security settings and product key), but really, compared with the stop-start nature of Windows 98 and the "stop in the middle" nature of XP, this is just fantastic. Well done to the guys that designed and implemented this. It's really good.

Here's a screenshot of my installation. Note how the length of the "collecting information" is pleasingly smaller than the "installing" bar.

Saturday, January 10, 2009

SCJP 1.5

After it being on my todo list for the last two years, I finally got my Sun Certified Java Programmer certification. I was a nervous before the exam, but I came out with 90%, which I'm very happy with.

There are a couple of things I'd like to point out about the exam:
  1. The Sierra and Bates SCJP book is very good. The questions in it are similar in style to the ones you'll get in the exam, and they explain concepts very well.
  2. The Heller SCJP book is not so good. It has quite a few errors (most are listed in the book's errata), but also has a lot of stuff that isn't actually in the exam. Streams? Not in the exam, but covered in-depth in the book. Bitshifting? No, not in the exam and not even covered in the book, but there's at least one mock question on it which gave me a start.
Lastly, I'd like to reassure any of you that the questions in the Sierra and Bates book are harder than the real thing. I got around 60% in its mock exams, mainly due to the questions which turned out to be testing if I was javac (hint: no). The good thing about those questions was that it made me highly suspicious of all the exam questions and I (think) I caught the 'trick' questions because of it.

All in all, it was a pretty successful experience. I hope it'll be a useful addition to my CV.

Sunday, January 4, 2009

Planning San Francisco

As you may know, Leah and I are moving overseas in February. First though, we're having a holiday in San Francisco for a week.

We chose San Francisco because we weren't particularly smitten with the places we could go via Asia (although Japan would have been really nice). That pretty much leaves going through the US or Australia, and there's no way we were going to go on a flight direct from Sydney for 23 hours. So, it was either San Francisco or Los Angeles, and San Francisco looked lovely. It's not the warmest place, but it's very compact and looks to be tourist friendly.

After booking our flights, we took a look at activities and accommodation. I can recommend the Fodor's San Francisco book for lists of things to do -- we were lucky enough to find the 2009 version at our library, and have consulted it pretty heavily.

I can also recommend Expedia -- so far, at least. We took a while to decide where to stay; the guide book was particularly helpful in recommending areas to stay, but the hotels it recommended were a bit out of our price range. Luckily Expedia lets you search individual suburbs. We eventually chose the Hotel Stratford (mostly because Expedia was having a sale on it the day we were looking :) )

There are a few websites that will help you deciding which place to stay at; Booking.com is a good resource, as is Trip Advisor. Trip Advisor especially seems to be quite good at filtering out the cruft. I've noticed that a lot of the reviews on other sites are brought down by somebody who likes to whinge, but Trip Advisor seems to have detailed reviews from seasoned travellers.

The bad side of things? Trying to work out where everything is so you can plan which days you're going to do your activities! I found out that Google Maps has a way of 'bookmarking' a location only after I put everything into Google Earth first. Still, at least I have a nifty KMZ file now, which I bet I can put into Google Maps anyway.

Saturday, January 3, 2009

First!

I've pulled the trigger and bought my own domain. Now I just have to work out what to put on here.

Some things I've learnt in the process:
  • Google do the cheapest secure domain registration. It'll cost you US$10 to buy your domain, and it comes with the proxy registration so you won't get spammed.
  • You can then use Google Apps for Your Domain to get free email. The other features -- Docs and Sites -- aren't really worth worrying about. I made a basic homepage in Sites as a placeholder until I figure out what to put there.
  • For hosting your blog, your choices are basically wordpress.com or Blogger. Wordpress has beautiful themes, but charge $10 a year for pointing your domain at it. Blogger doesn't charge anything for using your own domain, and you can write your own template for it.
Now the challenge is to maintain this so I don't add to the alarmingly high percentage of inactive blogs...