Subscribe

  • Subscribe via XML
  • Subscribe via Bloglines
  • Subscribe via NewsGator
  • Subscribe via MyYahoo
  • Subscribe via Google
  • Subscribe via MyMSN
  • Add this blog to my Technorati Favorites!

Archive for the 'Programming' Category

Google Seems to be Case Sensitive

Monday, February 25th, 2008

Google claims that "searches are NOT case sensitive". However, I have empirical evidence to believe otherwise.

I was recently seeing how well a fairly long, extremely specific blog title was indexed by Google. My general thinking has been that niche titles will appear high in search indices when Googled word-for-word. That is, even without surrounding the query in quotation marks, I would expect that a Google search for:

moving maven repository metadata files

…would pull up my blog posting, simply because it matches the title exactly. Here are the surprising results:

A lower-case Google search.

An upper-case Google search.

As you can see, the upper-case search returns a link to my blog as the second entry. The lower-case search returns a completely different page. To be fair, I recently upgraded my blog from MovableType to WordPress. In doing so, I changed the URL structure. The link that Google found with the capitalized words has a Permanent Redirect (HTTP 301 status code).

What is going on here? I can think of only two possible explanations:

  • Google is case sensitive, or at least has recently become so, and their documentation is incorrect.
  • Google is not case sensitive. The URL change, regardless of the HTTP 301 Permanent Redirect, has caused the index ranking of the page to change. Perhaps the capitalized version of the query was sent to a server that did not have the updated index.

In either case, the results are confusing. I would expect that a Google search behave as per their documentation. Maybe someone from Google could trackback and let me know :)

How To Write a PHP Quine

Wednesday, May 25th, 2005

A Quine is a piece of self-reproducing code. There are plenty of resources out there to explain the theoretical side of this, about Quine himself, examples in other languages, etc. I don’t want to reproduce that information, but I’d like to walk you through the step-by-step way to making your own quine in PHP.

If you want more background information on quines, here are some places to start:

http://en.wikipedia.org/wiki/Quine
http://www.nyx.net/~gthompso/quine.htm
http://www.philosophypages.com/ph/quin.htm

So, on with the PHP example.

You will need two PHP scripts to accomplish the task at hand. My examples will be run from the command line, though you could just as easily run these from a browser.

First, create the ‘quine’ script:

#!/usr/local/bin/php
<?php
$dna = '*';
echo str_replace(chr(42), $dna, base64_decode($dna));
?<

Second, create the ‘generator’ script:

#!/usr/local/bin/php
<?php
echo base64_encode(file_get_contents('./quine'))."n";
?>

Now, run the generator:

$ ./generator

Provided the files are exactly as mine, you will get a long string of characters, like “IyEvdXNyL2xvY2FsL2Jpbi9waHAKPD9 …”. Replace the asterisk in the ‘quine’ script with this long string of characters, like so:

#!/usr/local/bin/php
<?php
$dna = 'IyEvdXNyL2xvY2FsL2 ... ';
echo str_replace(chr(42), $dna, base64_decode($dna));
?>

Note that I have not included the full string of characters here; I’ve put an elipses where the rest of the string should be. Including it would have caused it to run way off to the right of the screen.

Now, run the ‘quine’ script:

$ ./quine

Pretty!

Notes: To follow this example exactly, you’ll need to have PHP-CLI enable (so that you can run PHP scripts from the command line). Also, your scripts will need to have the executable bits set:

$ chmod +x generator
$ chmod +x quine

The idea for this was stolen from Sam Barnum at 360works. His original program is here. There’s no step-by-step method of how he made his program, though, which I thought needed to be mentioned. Thanks Sam for the idea!

XmlHttpRequest Will be the Next Big Thing

Friday, February 11th, 2005

Check out Google’s “Suggest” if you haven’t already (http://www.google.com/webhp?complete=1&hl=en). It’s probably the coolest thing in web development I’ve seen in awhile. Actually, I suppose that GMail is littered with this new technology… this is just a higher-visibility usage of it, I think.

Anyway, enjoy.