MrPikes.com Logo Retro Star "That's why I find racism so curious. There are so many reasons to dislike people, and you're going to go with color?"
--Shalom Auslander
Home Who is... Books & Articles Gallery Formula 1 Work Contact Blog

Archive for April, 2008


GET vs. POST

Monday, April 21st, 2008

I promise, this gets funnier.

When one develops a web form, like the MrPikes Contact Form, one chooses the means by which the form data will get from the user’s browser to the program on the web server that *does* things with that data – like sends an email, or writes a record to a database. One’s choices are GET or POST.

The GET method encodes the form data into the URL. If the MrPikes Contact Form used the GET method, the resulting URL would look something like this:

http://www.mrpikes.com/contact.php?name=Max%20Mosley
&email=max.mosley%40fia.com&subject=Stop%20Heckling%20Me
&message=You’re%20hurting%20my%20feelings.
&human=20&submit=Send+Form

You tend to see long, ugly URLs like this on sites that dynamically nail their pages together based on database queries.

The POST method passes the form data to the web server in a way that is invisible to the user, i.e., the values are not encoded in the URL.

Each method has its advantages and disadvantages, but the rule that I always follow is that if a user input the data, always use POST.

This is to prevent URL hacking, which amounts to replacing values in the URL manually, with potentially devastating security implications.

It can also be hilarious.

CNN has a beta program which enables visitors to create t-shirts from headlines, available for purchase. The developers went with GET, meaning that users can hack the URL and make t-shirts that say whatever the hell they like. Since the program is still in beta, you cannot actually order the t-shirts, but that hasn’t stopped Gawker, Fark and numerous other sites from having a field day with the program.

My own contribution:

It's Raining Men. Hallelujah.

The Doomsday Algorithm

Thursday, April 17th, 2008

Okay, so this is my new favorite thing. John Horton Conway is a renowned mathematician who came to my attention for his Doomsday Algorithm.

The algorithm allows one, with the memorization of a few rules and some basic arithmetic, to determine the day of the week for any day, month and year specified. Conway himself can consistently provide the answer in under two seconds. Arthur Benjamin can also do it very quickly, as he demonstrates in this performance (starting at 7:54). I’ve been practicing for about an hour and can do the calculation in about half a minute…

The essential concept is that each year has a Doomsday (a day of the week), and that day is always the last day of February. For example, 2008’s Doomsday (February 29th) is Friday. Once you know a given year’s Doomsday, the day of the week for the date specified can be inferred from its offset to Doomsday, with the application of a few simple rules.

For example, let’s say that the date given is December 18th, 2008. 2008’s Doomsday is Friday. Based on the way that the Gregorian calendar works, December 12th (12/12, easy to remember) always falls on the same day of the week as the last day of February (the count of the days between the two is evenly divisible by 7). From there, all you do is calculate the offset from December 12th to the target date December 18th (6 days). So, December 18th is a Thursday.

The rules are different for different months. For example, take March 28th, 2008, the date that Max Mosley engaged in a five hour Nazi-themed orgy with five prostitutes (previously, previously). March 7th is always the same day of the week as Doomsday, so March 28th (offset by 21 days) is a Friday as well.

For me, the time-consuming part is determining a given year’s Doomsday, because of leap year rules (a leap year occurs every four years, except for years that are evenly divisible by 100, unless they are also evenly divisible by 400). The only method that I’ve located involves using a century offset. For example, if I want to know the Doomsday of the year 1967, I calculate it as an offset of 1900’s Doomsday.

1900’s Doomsday is Wednesday (which has to be memorized). To determine 1967’s Doomsday, you do three calculations and sum the results of each:

1) How many times does 12 go into 67 (as in 1967)? The answer is 5.
2) What is the remainder? The answer is 7.
3) How many times does 4 go into the remainder? The answer is 1.

5 + 7 + 1 = 13, which is the number of days that 1967’s Doomsday is offset from 1900’s Doomsday. So, 1967’s Doomsday is Tuesday.

I hope to get a lot faster, because it seems like a fun way to play with someone else’s mind. I’m not overly worried about this post spoiling the trick, because my legion readership is still dwarfed by Famous Jewish Sports Legends.


Discrete vs. Discreet

Monday, April 7th, 2008

Shopping for midget porn the other day, I came across an e-commerce site offering “Discrete Shipping”.

Discrete Shipping

A Google search on “Discrete Shipping” (over 63,000 results) suggests the problem is not isolated (but hilarious).

As a committed pedant, I thought I would take this opportunity to explain the difference between “discreet” and “discrete”, and even offer a mnemonic trick for remembering the difference.

Discreet – having or showing discernment or good judgment in conduct and especially in speech (Merriam-Webster Online), as in, “Max Mosley failed to keep his Nazi-themed orgy discreet.”

Discrete – distinct, constituting a separate entity or part (Princeton WordNet), as in, The five prostitutes that Max Mosley engaged for his Nazi-themed orgy were from five discrete agencies.”

So, taken literally, “discrete shipping” would mean that if I ordered three midget porn DVDs, they would arrive in three separate packages.

I’m glad that I didn’t order jelly beans.

The mnemonic trick is simple. Look at the “e”s in each spelling. Notice how the “e”s in “discrete” are separate, or discrete.

Isn’t learning fun?


Compare Stuff

Sunday, April 6th, 2008

My pal Gokmop recently published a post about Compare Stuff, a site that allows you to correlate a user-defined keyword axis against an axis of predefined collections (such as emotions, days of the week, etc,), using web search results as the data set:

God and Satan

Click to embiggen

What we learn here is that both God and Satan are extremely bored (which will probably clear up once the Wii shortage abates) and not very satisfied (perhaps they should go back to some good Old Testament jacking around with the likes of Job and Abraham), and that, annoyance aside, God seems generally more upbeat about the future.


Print *This*, Pal

Tuesday, April 1st, 2008

I decided to try out Yaakov’s sweet Perl hack on printers that use the HP Printer Job Language (HPPJL), in honor of April Fool’s Day.

The script connects via TCP to the printer’s (standard) port 9100 and changes the LCD “Ready” message to one of your choosing (with space limitations). Below are a few of the messages that our area’s network printer displayed today.

They ranged from the controversial:

HAIL SATAN

FREE TIBET

To the confusing, but plausible:

JIGGLE TRAY 1

REVERSE TRAY 1

To the bizarre:

REMOVE PANTS

WTF?

REPLACE GERBIL

Beer Me

Mmm, minty.

ICE TRAY LOW

To the confessional:

April Fools!


Home | Who is... | Books & Articles | Gallery | Formula 1 | Work | Contact | Blog

MrPikes Blog is proudly powered by WordPress
Entries (RSS) and Comments (RSS).