Recently in programming Category

Sunday, February 21, 2010, at 3:32 PM

Shipping the Autorantic Virtual Moonbat to Britain

Way back in 2004, I invented a humorous Flash application named the Autorantic Virtual Moonbat. It was a chatty hate-filled robot who generated random nonsensical leftist rants, such as “Chimpy McBushitler STOLE the ELECTION by outsourcing transgendered polar bears!!!” Perhaps you saw it. It wasn’t just on my blog, it was on hundreds of others as well, because I let anyone who wanted it embed it. It was very clever and funny, because it aped the style of excitable liberal writers so well.

And then, well, time passed. It still works, but I stopped updating its knowledgebase years ago. The poor dumb thing still thinks George Bush is running the world, and that global warming is a credible theory. Well, okay, so do other liberals, but my larger point is, I was pretty much done with it. And yet I still believe it can have a successful career in politics. That’s why I’m sending it to the United Kingdom.

An English political blogger contacted me, asking if the AVM could be reprogrammed as a crazy British leftist, rather than the American sort, in time for the upcoming U.K. general election in 2010. I answered in the affirmative, and so soon the device will have a new home — and a new name! — and a whole new list of enemies to hate. I will certainly keep you abreast of details as they are made final.

Comments on this entry:

There are 3 comments on this entry.
#1
25 Feb 2010
4:42 AM

Sweet! I love the shipping box.

#2
25 Feb 2010
4:47 AM

I love it!

#3
25 Feb 2010
9:55 AM

Don’t get too close, mates.

Tuesday, February 16, 2010, at 5:34 PM

Yesterday, I wrote about our new private URL shortener at u.gleeson.us. In the subsequent comments to that post, I explained more about how it works. But there are fascinating theoretical implications revolving around the whole topic. For instance, just how many URLs can this application hold before it runs out of room?

Before answering such a question, one must first define precisely what “running out of room” might mean, but as you’ll see, by any definition, the number of URLs we can shorten is… rather a lot.

Comments on this entry:

Showing only the most recent 12 comments.
See all 16 comments on this entry.
#5
16 Feb 2010
10:47 PM

I got a 500 error while posting #3, and another posting this comment the first time I tried. It’s probably just gremlins, but you might want to check Apache’s logfile and see what it had to say.

#6
16 Feb 2010
10:48 PM

Oops, I guess it worked after all. I didn’t get any error when I posted #5.

#7
16 Feb 2010
11:03 PM

You know, I was getting 500 errors myself earlier this evening when publishing template changes, then trying again and everything worked. When I checked the logs, it said something about CGI scripts missing their headers, so I suspect it was a Perl parsing thing. I think my server is having some issues tonight that have nothing to do with us. (I share it with other fine DreamHost customers, you know.)

#8
16 Feb 2010
11:06 PM

Ah, it must be Dreamhost killing off MT’s perl scripts when they run for too long, in order to preserve capability for everyone else on the server.

#9
16 Feb 2010
11:11 PM

Ironic, given that the main reason I went with MT rather than WP was to put less strain on the server.

I reckon I’ll leave the blog alone until morning, and see if it’s feeling better.

#10
16 Feb 2010
11:16 PM

Well, at least MT only gets hammered when someone doing something that causes a database write. WordPress gets hammered and falls down when people are doing nothing more than reading the page!

#11
17 Feb 2010
12:32 PM

Wow. For this comment, I didn’t sign in with my MT account, I signed in with my Facebook account! So now, anyone can sign in with a Facebook id, and bypass the CAPTCHA and everything.

I rock.

#12
17 Feb 2010
3:41 PM

Ev says he’s been trying to comment, but the reCAPTCHA isn’t working. So I’m testing it again. If you see this comment, it worked for me.

#13
17 Feb 2010
7:47 PM

Testing it out…

#14
17 Feb 2010
7:48 PM

Yay!

#15
17 Feb 2010
8:15 PM

Sean, Trying to make contact with you, can’t find a working e-mail address! Could you respond please?

#16
17 Feb 2010
9:01 PM

Sorry, Anna. I still haven’t finished building all the pages on this site. There will definitely be a full complement of contact information soon. You may email me at sean@gleeson.us

Monday, February 15, 2010, at 5:45 PM

This morning, Phoebe and I were talking about stuff, as we are wont to do from time to time, and the topic of URL shortening came up. You know, those services like tinyurl.com and bit.ly that take a really long URL and convert it to a much shorter one. It’s handy for pasting URLs into emails, or tweets, or other spaces where an overly long URL doesn’t fit.

On the other hand, these services do have their drawbacks. For one thing, they are not guaranteed to be permanent; if they go out of business, your links might die along with them. For another, they are used so often by spammers for sneaky redirects that users might be wary of clicking on one of their generated links. Some websites even ban all tinyurl links from their sites, and with good reason.

But, we realized, these problems wouldn’t exist if we had our own URL shortener! And so today I built us one. We now have u.gleeson.us, a URL shortener that we own, and that only Phoebe and I can use. So now I can take really horribly long URLs like this…

http://www.amazon.com/gp/product/1596062266?ie=UTF8
&tag=gleesonus-20&linkCode=as2&camp=1789
&creative=390957&creativeASIN=1596062266

..and instantly convert them to short ones, like this…

u.gleeson.us/6

By the way, that link — both of them, really — goes to an excellent anthology by Jack Vance, one of my all-time favorite authors. Just in case you were curious, but not curious enough to click.

Comments on this entry:

There are 10 comments on this entry.
#1
15 Feb 2010
6:42 PM

Cool! Care to give us any clues as to how you did it? (Appending redirects to an .htaccess file, perhaps?)

#2
15 Feb 2010
6:54 PM

You guessed it! Here is my .htaccess file in its entirety:

RewriteEngine on
RewriteRule ^.+\..+$ - [L]
RewriteRule ^(.+)$ elongate.php?b=$1 [L]

The first RewriteRule just says to let any requests that include a period to pass through unchanged. That way I can still put normal files on that domain, because all filenames have periods. At least, they should.

All other requests go to the second RewriteRule, which invisibly loads a PHP script and passes the request in a query string.

The PHP script, of course, just converts the request (which is in a base-52 numbering system to make it extra short) to an integer, and looks up the URL with that index.

#3
16 Feb 2010
10:48 AM

Wow, how the heck does base 52 work? Are you using non-alphanumerics past 36?

#4
16 Feb 2010
12:19 PM

Upper and lowercase letters, dude. (The URL shortener tr.im uses a base-62 system with A-Z, a-z, and 0-9. So mine is 10 less.)

Here are the glyphs I use:

A-Z, except vowels -- 21 chars
a-z, except vowels -- 21 chars
2-9 -- 8 chars
hyphen and underscore -- 2 chars

That adds up to 52. I left out the vowels (and zero and one, because they can look like O and I) so that my encoded URLs will never inadvertently spell any offensive words in any language. It would be awkward, for instance, if I emailed my dad a link and it was u.gleeson.us/TitS wouldn’t it?

#5
16 Feb 2010
12:53 PM

Aha! Very clever, and it’s good design to avoid the ambiguity of 0 and O, l and 1.

I tried to figure out what you were doing by subtracting 36 from 52, but that’s 16, and I couldn’t figure out what the heck you were using sixteen of.

my encoded URLs will never inadvertently spell any offensive words in any language

You must not speak Klingon.

#6
16 Feb 2010
1:11 PM
You must not speak Klingon.

That’s a pretty good maxim for humans in general.

But come to think of it, Hebrew has no vowels, either, right? Maybe I should have left out the consonants instead.

#7
16 Feb 2010
1:17 PM

LOL.

I have a hard time reading your captcha, by the way. The black text on grainy grey background can be hard to parse. Have you considered recaptcha? It’s easier for humans to solve because words are easier to read than random unpronounceable strings (I’m solving a “zhsust” right now), there’s an MT plugin for it, and it’s even a good cause: people solving your captcha are actually helping to digitize books!

#8
16 Feb 2010
1:30 PM

Well, it’s hardly my fault if you don’t know what a zhsust is. But I do take your larger point. I will use recaptcha instead at my earliest opportunity.

#9
16 Feb 2010
10:24 PM

This is me, Sean Gleeson, but I am not signed in, so I can comment anonymously and test my new reCAPTCHA thingie. If you are seeing this comment on my site, then that means it worked.

#10
16 Feb 2010
10:37 PM

This is awesome, it’s working great!

(Thanks for reading all the way to the bottom.)

Sean Gleeson is an artist, developer, writer, teacher, statesman, and family man in Oklahoma City, Oklahoma.

See full profile.

Sean Gleeson Sean Gleeson