Lost Amazon Wishlist

Had a weird Amazon bug today, it decided I no longer had a wishlist. Despite having had one for years and updating it only a few weeks ago, it now asks me to create one every time I tried to add something to it.
Not convinced that it had actually gone, or that I had accidentally deleted it, I did a Google for it (“Bob Twells wishlist”) as my wishlist is public, and there it was, several Google links to items in my wishlist.
Oddly, just following one of the links to my wishlist fixed it, I could see my items again, and if I logged out from Amazon and went in again it was still there. Very odd, but a quick fix if anyone else has the problem.

Stupid Website Username Rules

I’m riled! Twice in the last couple of months I’ve signed up to websites who don’t allow your username to look like your real name or email address!

I’m probably signed up to literally hundreds of websites, and I always use the same username, ‘bobtwells’, because, well, it just makes sense. Even for this blog that is my username, the same for Facebook, Flickr, Twitter, email, EVERYTHING!

Then along come ebay, all big and brash and throwing their weight around, who decide I can’t change my registered email address to bobtwells@yahoo.com because it looks a bit like my username, bobtwells. Yes, yes it does, that’s because they’re both for me, I am the user and it’s MY email address, so it makes sense they look kinda similar. But no. Even the tech support guy on their live help chat couldn’t explain the reasons behind the rules, although he did eventually manage to manually override them for me and get it set up how I wanted it.

I expected more sense from such a big player in the web world.

Then today I signed up to My Hammer who wouldn’t allow me my usual username because it contains my surname. Duh. What possible probelem is that?! So now I have a stupid username like bob123 that I’ll never remember and probably end up having to click the forgotten password link every time I use the site and fail to log in first time!

Sort it out ebay and MyHammer. No need. Grrr. Rant over.

PHP Quine

I was reading the Wikipedia page on Quine programs, which are computer programs whose only output is their own source code. At first glance this sounds simple until you think it through, your mind ends up recursively parsing pseudo code! It took a while to get my head round how they work, but in the end it kinda made sense.

I decided to port one of the given C examples into PHP as an experiment, and here is what I came up with (I think it’s correct at least!).

<?$a='<?$a=%c%s%c;printf($a,39,$a,39)?>';printf($a,39,$a,39)?>

If you run this in PHP it should, well, output the above! Try it and then diff the output to the original source. Fingers crossed it should be the same.

It seems that the ‘challenge’ is to find the shortest possible quine in any given language. Since making the above I have found other PHP examples that use a very similar approach but cut down the code even further, such as this nice example from Komea Pimeässä:

<?printf($q='<?printf($q=%c%s%1$c,39,$q);',39,$q);

It uses some nice PHP shortcuts to remove unnecessary characters, like dropping the trailing ?> and putting the string assignment ($q=’…) as the first parameter of the printf call, instead of declaring it outside the function call and then referencing it again which wastes characters. It also uses one final difference from mine, and one which I wasn’t aware of, and that is using numbered specifiers in the printf function (%1$c in this case), so he can reuse the first specifier (%c) twice in his string without needing to declare it twice in the function call. Nice.

I don’t think I’m likely to find any way of shortening that further, but I’ll keep thinking it over.

UPDATE (15 minutes later):

I just had a thought on this, It may be considered cheating but surely this is a tiny valid PHP quine:

Q

Or, in fact, and text. Why do we need to actually break into PHP mode? It’s still a valid PHP file, and it will indeed output only it’s own contents, but it does just seems like a dirty trick. It doesn’t seem right that it doesn’t actually include any PHP statements.

After thinking of this, I had a more detailed read of the Wikipedia article for any rules. In fact it mentions that someone once submitted an empty file as the shortest possible quine in a C programming competition. They did however win the “worst abuse of the rules” prize. So maybe this single caracter PHP example just another, albeit not quite so short, example of the same abuse of rules? I’ll let someone else argue over that!