Secret Santa Name Picker Script

Monday, November 22nd, 2010

In the last ten years we’ve been gathering for our annual Pelago holiday party we’ve developed a fun Secret Santa tradition. The theme of the gift exchange is t-shirts. Each person picks a name from a hat to find out the lucky (or unlucky, depending on how you look at it) recipient of a hand-selected t-shirt. With one employee going remote and us being a technology company, it seemed somewhat Ludditean of us to continue picking strips of paper from a box.

This year we automated the process. We wrote a PHP script that would pick the names for us. It starts with an array of email addresses, matches them up in a random order and then emails each person their recipient. And it makes sure no one gets the same person. Take a look at the script below. It’s just a few simple lines of code. Feel free to use it for your next Secret Santa assignments. The basic code is below. Just plug the results in to your favorite email software to secretly distribute the results.


<?php

$emails = array(
     'name1@yourcompany.com',
     'name2@yourcompany.com',
     'name3@yourcompany.com',
     'name4@yourcompany.com',
     'name5@yourcompany.com',
);
$matches = array();

// randomize a key => value array
$givers = range(0,count($emails)-1);
$givees = range(0,count($emails)-1);

do {

     shuffle($givers);
     shuffle($givees);

     $matches = array_combine($givers, $givees);

     foreach ($matches as $er => $ee) {
          if ($er == $ee) continue 2;
     }

     break;

} while (true);

foreach ($matches as $er => $ee) {
     echo $emails[$er] . " gives to " . $emails[$ee] . "\n";
}

?>

Holiday Light Exchange

Monday, December 3rd, 2007

Residental customers of Southern California Edison can exchange one strand of old holiday lights for a box of new, energy efficient LED lights. LEDs use up to 98% less energy and last ten times longer, making them better for the environment and your electricity bills.

The exchange program starts today and runs through December 21st.

LOCATIONS:

  • Carpinteria City Hall: 5775 Carpinteria Ave. (805) 684-5405. Mon – Fri, 9am – 5pm
  • Goleta City Hall: 130 Cremona, Ste. B. (805) 961-7500. Mon – Thur, 7:30am – 5:30pm Fri, 8am – 1pm
  • Santa Barbara: Westside Community Center: 423 W. Victoria St. (805) 963-7567. Mon – Fri, 9am – 5pm
  • Franklin Neighborhood Center: 1136 E. Montecito St. (805) 963-7605. Mon – Fri, 9am – 5pm
  • Central Library: 40 E. Anapamu St. (805) 564-5601. Mon – Thurs, 10am – 9pm; Fri, Sat, 10am – 5:30pm; Sun, 1 – 5pm
  • Community Environmental Council: 26 W. Anapamu St, 2nd Floor. (805) 963-0583 x105. Mon – Fri, 9am – 6pm