'secret santa' tag

Unleashing SecretSantaBot

2

About two years ago the occasion arose for a Secret Santa with people who, for whatever reason, couldn’t find themselves in the same room to draw names from a hat. Determined, I soldiered on and wrote a script to email all parties with a randomly selected name. It worked, it drives a slow trickle of traffic to the site every December.

I decided to give it a bit of an OOP makeover this year and go ALL-OUT and get in on the git action, too. What I have ended up with is bizarrely tacked-on front-end to an otherwise super straightforward SecretSantaBot class.

I’m going to set up a site in the future to forgo the need to have a web server in order to use the script. That’s not as fun, eh? For now, it’s targeted at the developer.

Source @ Github | Demo

Oh, I should mention that before you ream me — this is the first PHP class I’ve written, and I’m sure it’s not the most optimally written thing out there. That’s what forking is for! Forking and reaming in the same sentence …

Secret Santa Script

2

Every year my friends and I typically have a little “Secret Santa” (we call it “Secret Satan”, but that’s neither here nor there) — you know, where you are randomly pick a person’s name out of a hat and it becomes your job to buy a present for said person.

In previous years it was always easier because we were able to meet up to do the hat-selection. The past two years have not been so easy, due to conflicting schedules and what-not. Last year’s solution was to get someone’s mom to send out the emails.

This year I opted for a PHP-based solution. If you’re thinking “THAT’S AMAZING”, you are correct, it is amazing. Because of the rush I was in to make it, it’s not as user-friendly as it should be. There’s two things you need to do to get this working out of the box:

  1. Edit the array containing names and emails. This is the most critical part.
  2. When you first run the script it will be in no-email mode, so you can preview the how the script might work (remember, it’s random …). Change the $noemail variable to false for it to send emails. You will NOT see who is paired up with who after debug mode is turned off.

It randomly pairs people up, making sure not to pair up the same person twice, or pairing the same person. Then it sounds out the emails! It’s just that easy (I hope).

Edit: this has been updated as of December 2009.

Demo | Source (on Github)