August 15th, 2013

confident

Reducing URL length

I'm designing some of the short-URL mechanisms for AboutTh.is tonight, and I was actually able to borrow from my earlier seq.tw effort that was started (and then abandoned) in 2010. (Driving 20 hours a day seemed to sap my energy to be able to invest time in anything else back then.) I wasn't surprised to find tonight that my earlier thoughts on base 64 URL encoding actually match an Internet standard. Here's an excerpt from the AboutTh.is design, partially lifted from seq.tw:
The base 64 value could just be used as-is in URL's, except for a few specific business rules. First, the string must have a minimum of four "digits" (characters), as shorter strings have reserved purposes, and we also wish to avoid appearing "too small" when the site is first launched. Second, as all URL's are intended to be public, (with no password or financial data disclosed), we really don't need anything more complex, but since all the "cool kids", (e.g., bit.ly, goo.gl, et al.), are obfuscating their shortened URL's, for appearance's sake, we use a mild scrambling/mapping method that's still computationally cheap. This is done by rearranging the least-significant 24 bits (four "digits") and then flipping about half of them.
confident

Is that a BIGINT in your spec, or are you just looking for a huge membership?

I just realized that I had made a big mistake. I was using int(8) instead of BIGINT, int(4) instead of INT, int(2) instead of SMALLINT, etc. Oops. I'm fixing the full 19 page database schema, although it's actually not too bad, thanks to the centralization of the $DT_... definitions.

I am, however, going to have to delete this fun line in the spec:
$BYTES_BYTES = 4;  // number of bytes needed to represent number of bytes :-)
:
:
$DT_BYTES = "int($BYTES_BYTES) unsigned";