2008-10-26

Secret Santa Protocols

Some friends and I are kicking off the holiday season early this year! Along with Jason Kealey and Etienne Tremblay of LavaBlast Software, as well as their better halves, I've arranged to rent a rather nice cottage in mid-December. We decided to hold a Secret Santa gift exchange over there, which brings us to this post.

Dinner

How do you arrange a randomly-assigned Secret Santa event when the participants are geographically distributed?

Assignment of giver/recipient pairs is usually handled by drawing strips of paper from a hat, an approach that obviously won't work here, when planning over email. So I started to think about how one could do this without relying on a trusted third-party. Is it possible for a group of peers, communicating only through email, to each choose a random recipient and guarantee uniqueness of picks, while ensuring picks are not revealed to others, and no one ends up picking themselves? [My father, over dinner the other day, helpfully pointed out that this is known as a derangement problem.]

The real-world pragmatic approach

We ended up going with the very pragmatic approach of relying on a trusted third-party (in this case a simple computer program). I wrote a Java program that took the list (L) of 5 email addresses, shuffled it (using Collections.shuffle()), then sent an email to address L[i] containing address L[(i+1) % 5], all without printing to the screen what it was doing, or logging anything. Once the program exited, there was no way for anyone to recover who got what address, and it guarantees that the final assignment is a derangement: no person in the initial list gets themselves.

Now, this is all well and good, but it's a boring solution because of its reliance on software. Is this doable with only five people talking over email? (Yes, it's a mostly academic exercise.) I've had some ideas that go in the right direction, but haven't solved the problem of ensuring the final mapping is a derangement, other than running the process for multiple rounds, until no one declares they received themselves as an assignment.

Primitive: mapping IDs to gift recipients

The first primitive our protocol needs is a method of mapping an abstract identifier (say, a number) to an actual name. This is because since participants need to pick one of the 5 identifiers unsupervised, they must not know in advance which person this identifier will represent.

This is the easy part: have everyone pick a unique value i from the pool of identifiers [0-4] (randomly or not) and remember it without disclosing it. Your assigned name is then L[(i+d) % 5], where d is the integer part of the TSX composite index at market close the following day. The offset value d is the same for everyone, is not known in advance, and when we all exchange gifts we can audit that no one cheated and changed their chosen ID after knowing d.

Independently choosing IDs

The above relies on everyone having independently picked a unique value for i, and this is where things get interesting.

  • There are 3125 [5^5] sets of picks when done independently with no knowledge of the others.
  • Of those, only 120 [5!] contain unique, unduplicated, choices, or 3.84%.
  • Of those, only 44 are derangements, where no one ends up with themselves (1.408% of the total)

First approach: anonymous broadcast

If a means of anonymously broadcasting a message to the whole list is available, we can rapidly constrain picks to the 120 cases where there are no duplicates. We'll then have a 36.7% chance [44/120] of having a derangement in each round, so we should be able to settle on a solution in very few rounds.

  • We declare the round started, and the pool of legal choices to be {0, 1, 2, 3, 4}.
  • Everyone picks a random delay d in [0; 3599] (with 5 participants, collisions are unlikely).
  • After d seconds, pick a value in the pool of legal choices, and anonymously broadcast "n has been picked", everyone removes n from the pool. (You can also just always choose the first available number, that works equally well.)

Second approach: no anonymous broadcast

OK, so you don't have an anonymous remailer. No problem!

I've devised a method to ensure the picks are independent, but it can take many rounds to work, as the expected success rate is only 120/3125. (And after that you still have the problem of restarting if you don't have a derangement.)

I think the following should work, but YMMV, I haven't proven it:

  • We publish the list of 5 participants. Their order is unimportant.

  • We publish 5 IDs. Let's use 5 prime numbers {3, 5, 7, 11, 13}. I don't think they need to be prime, but they must be picked to ensure that their product, known by all (in this case, P=15015) can only be achieved if you pick EXACTLY one of each number, and this is easy to ensure if you take primes [I think].

  • Everyone independently picks an ID i from the list, keeping it secret.

  • I'm first on the list. I choose a random large integer s. I compute P' = i * s * P.

  • I hand off this product (P') to the second person on the list. The number she receives from me is evenly divisible by 3, 5, 7, 11, 13 and P, so she has no way of knowing what my chosen i is, or what value of s I picked (there are 5 equiprobable possible values for s, which tells her nothing).

  • She multiplies P' by her own chosen i, and gives that to the third person on the list, and so on.

  • The list wraps around and I'm sent a value from the 5th person on the list. If everyone picked a unique value for i, I get s * i0 * i1 * i2 * i3 * i4 * P or, succinctly, s * P2. If I get anything else, then I know there's a duplicate.

  • I announce whether or not there was a duplicate. (I, or anyone else, can always lie, but then when gifts are exchanged we'd know someone lied - in the spirit of the holidays, the participants in this protocol are honest.)

Phew. Each round has a 1.408% chance of working, so it could take a while. I have yet to find a much better approach, so I think our little 30-line Java program was appropriate in this situation.

2008-10-21

This Week in Food

Will Ron Eade wake up with a head of lettuce in his bed?

First up is Ron Eade's column from Ottawa Citizen blogs, where he heaps some well-deserved praise on Kevin Mathieson (of Art-Is-In Bakery) for his bread. Eade says it's better than ACE bread (n.d.a.: no shit), and I for one am glad to note that the supply problems I was hurting from a year ago seem to be a thing of the past: whereas last year, getting your hands on Art-Is-In bread required much haste in returning home from the office, this year I find that retailers aren't consistently running out by late afternoon.

Eade calls New York Times' Mark Bittman's bread recipe a good replica of Art-Is-In's, which I have to humbly disagree with. Bittman's recipe is good, it's my go-to recipe for homemade bread, but I hardly think it's close to equal to Mathieson's.

I think it's awesome that he can get away with saying:


I'm not kidding when I say you need a six- to eight-quart heavy cast-iron Dutch oven with lid. Every kitchen should have one.


Yes, every kitchen should have one - but when I say anything like that, people roll their eyes at me. If you're a newspaper columnist though...


Amate

Amate in Wellington Village

Got around to trying Amate (link goes to ottawafoodies.com) for some quick Mexican take-out. I came in a few minutes before they decided to shut down for the night, and ordered a tostada with some puerco pibil. Unfortunately, I only got a tiny spoonful, maybe 40g, of pork but hey, what I tasted was good. I think they're still going through opening pains and are a bit disorganized, so it's not fair to say more at this time - let's give them a few more months.

I'll probably try my hand at making puerco pibil myself (in more generous quantities) when I get a free afternoon.

Malak Pastry

Tasty Baclava

I've lived in Westboro for over a year and had never tried Malak Pastry, despite it being right at Carling/Broadview - shame! It's a bakery offering up a range of baklawa (which I'll admit I know little about). I asked for the shopkeeper's recommendations and got a few samples to try before buying, and was incredibly impressed. Delicious! They weren't yet listed on OttawaFoodies, so I'm adding them presently.

foods++;

Finally, I've tried sauerkraut (at a corporate event at the office, no less), bringing my 100 Food countdown (previously blogged about) to 57% completion. Moving up 1% in two months is a rather pathetic pace, so I'm going to make a bigger effort.


2008-10-18

Sure, but what year?

Sure, but what year?

That's what I call optimistic.

I really, really, wish I could afford one of those condos, the artist's renderings I've seen look pretty sweet. Also, expensive.

2008-10-16

Coffee Shop Technology

I'm sitting in the Westboro Bridgehead, working on a presentation on my MacBook Pro.
Observations from the coffee shop:
  • A 50 year-old looking woman is texting. She's typing pretty fast, too.
  • No one is wearing iPod headphones. Everyone is here to enjoy the atmosphere, I like that.
  • Among the people typing away on laptops, the Mac market share is 100%. ONE HUNDRED. Way to go Apple.

2008-10-08

A bit of free money from ING Direct

ING Direct is trying to beat the fray of banks that will be offering TFSAs in January 2009. Even though, to the best of my knowledge, the federal government hasn't yet published the full TFSA rules and details, based on the details available now, banks are starting to jump in.

Here's the announcement they made on October 7th:

Earn special Bonus Interest between October 4th, 2008 and December 31st, 2008 and get saving tax-free earlier!

Because we just couldn’t wait until January 1, 2009 – we’ll cover your taxes!

Bonus Interest!

While we can’t help you avoid taxes in 2008, we can pay you more than enough bonus interest to cover those taxes! Effective January 1, 2009, funds deposited in the promotional Tax-Free Investment Savings Account opened between October 4 and December 31 will be transferred to a new Tax-Free Savings Account so you won’t miss a minute of Tax-Free interest.

Open an ING DIRECT promotional tax-free Investment Savings Account today and on December 31st we will double your interest payment. This should be enough to cover any tax you’ll need to pay on interest earned and will help you get a head start for tax-free saving in January.

Tax-Free

With the new Tax-Free Savings Account, any interest earned in an ING DIRECT Tax-Free Savings Account will not be taxed.


It seems this account is identical to their regular savings account, except it automatically gets registered as a TFSA on 1 January 2009, and on 31 December 2008, it gets a bonus interest payment equal to all the interest paid in the last 11 weeks of the year (from now until 31 December). They're marketing the bonus payment as a way to offset taxes paid on the regular portion of the interest in 2008, since TFSAs don't yet exist.

I'm not normally a fan of trivial quarter-point rate chasing between banks, but assuming you've got a savings account at ING Direct already (I keep my emergency cash at ING), I see absolutely no downside to getting in on this.

It took me about 2 minutes to login, create an anticipated TFSA, and transfer 5000$ from regular savings to the new account. At the current 3% rate, with monthly compounding, the expected interest on 5000$ between now and December 31st is around 35$, so they're giving away 35$ for two minutes of work.

2008-09-26

Dealing With a Cold

Holy crap, what a crummy week. Caught a cold, saw productivity go down a bit, but was able to pull through without missing any work thanks in part to reading Eric Rescorla's blog post about "Managing the Common Cold". The guy is an engineer / security guru but he happens to post frequently about statistics and health, and in this case he's really on to something as he goes much further than the classic advice: "Oh just take a Tylenol Cold and stop whining":

  • Nasal sprays and pseudoephedrine for congestion: He recommends Flonase, which requires a prescription, but I've had luck this week with an OTC decongestant spray once a day (mindful of widely-reported acclimatation effects) and Advil Cold & Sinus. I feel kind of stupid for buying Advil, as it's just ibuprofen and pseudoephedrine, but it was recommended by a colleague; next time I'll go generic.

  • diphenhydramine hydrochloride, an antihistamine with sedative effects to help fall asleep: costs practically nothing in generic form. Quite effective.

2008-09-24

The Absolutely Essential Software List for Mac Newbies

This is for my friend Jason Kealey, who finally got a MacBook Pro today. Welcome to the awesomeness of OSX :)

Newbies, here's the absolutely essential, grab-this-software-today stuff you want to go install:
I still haven't found a perfect image editor. I'm thinking of dropping the cash for Pixelmator, but even on a new MBP it feels a bit sluggish... I'm still wrestling with the decision while my trial period ticks down.

The fact that this list is actually pretty small for me means OSX is, really, quite a bit more functional out of the box than Windows. Bundling of software with an operating system can be a bit contentious, but I think OSX generally gets at least this correct.

2008-09-05

Ask TUAW - Finding which processes own which network connections - Here, I'll Save You 30 Bucks

A good question popped up on Ask TUAW today:

Richard asks
I have recently noticed that I have a fairly constant upload of 14-16 KB/s going on in the background (I'm using iSlayer's iStat menus), even though I haven't initiated any upload. I'm not now running any online backup apps. I've checked in Activity Monitor, and can't see anything very out of the ordinary there, although evidently I've missed something. Is there an easy way to see which applications/processes are using the network connection? Or should I get Little Snitch? It's quite annoying to see that the network connection is being used, and being unsure about what is using it. It's potentially disastrous when I'm using metered connections!

Here's the answer TUAW gave:

Little Snitch ($29.95) is probably the easiest way to go. There's also another recently released net monitoring application called ProteMac Meter ($29.95) which might be worth checking out. I don't recommend Glowworm FW as I've had serious problems with it under Leopard and have found others reporting similar difficulties. It may be that the demos of one of these application will be enough to find the source of your unknown network traffic.

Ummm, let me save you 30 bucks and a download, dude, OS X has everything you need built in:

lsof -i

Lists open sockets. Output looks like this, presto!

COMMAND     PID     USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
Quicksilv 784 jpdaigle 253u IPv4 0x4baba68 0t0 TCP 192.168.1.121:64139->host44.hrwebservices.net:http (CLOSE_WAIT)
SystemUIS 13716 jpdaigle 10u IPv4 0x431a880 0t0 UDP *:*
Mail 23859 jpdaigle 17u IPv4 0x51cb270 0t0 TCP 192.168.1.31:55041->webaccess.hostedmail.net:imaps (ESTABLISHED)
Mail 23859 jpdaigle 18u IPv4 0x6d7d270 0t0 TCP 192.168.1.31:55043->webaccess.hostedmail.net:imaps (ESTABLISHED)
Mail 23859 jpdaigle 23u IPv4 0x8587e64 0t0 TCP 192.168.1.31:55049->webaccess.hostedmail.net:imaps (ESTABLISHED)
Mail 23859 jpdaigle 26u IPv4 0x58f8e64 0t0 TCP 192.168.1.31:55044->webaccess.hostedmail.net:imaps (ESTABLISHED)
firefox-b 25763 jpdaigle 31u IPv4 0x703266c 0t0 TCP 192.168.1.31:55088->64.26.141.78:http (ESTABLISHED)
firefox-b 25763 jpdaigle 36u IPv4 0x9779270 0t0 TCP 192.168.1.31:55089->64.26.141.71:http (ESTABLISHED)

2008-08-30

Upgrading a Pay-as-You-Go Fido Account to an iPhone 3-Year Contract: Nontrivial

There's probably nothing too original at this point about someone blogging about problems buying a new phone from Fido, but, well, this particular problem, I haven't seen mentioned yet.

Walked up to a Fido booth tonight thinking I'd buy a new phone (not important which one for this story, but gee, I think you can take a guess). "In and out in 15 minutes", thought I. Ha. I've got to say though, the employees there, for all their trouble in getting things done, tried really hard and were so patient on the phone with the mothership (yes, the employees get put on hold for an hour too) that I really can't blame them at all.

I'm with Fido on a Pay-as-You-Go plan (prepaid airtime), and since I've been a customer for a while I have a bunch of rebate dollars (called FidoDollars) usable as credit towards new phones. Problem is, you can't walk into a Fido store and get your prepaid account converted to a 3-year contract while keeping the same phone number and already accumulated airtime credit. Can't be done, no matter how long the poor salespeople stay on hold with the customer service center trying to make it happen.

There are two main options available if you're already a Fido customer on Pay-as-You-Go, neither of them particularly appealing:

  • Buy the JesusPhone(TM) from the Fido store, have them activate it on a new phone number with a new account on a 3-year contract. You lose your existing phone number (well, it actually stays active on your old phone, but what use is that?) and get a new one. You can't use FidoDollars credit to help pay for the new phone, and you'll lose all your prepaid airtime when it expires. They have absolutely no way to use your FidoDollars or transfer your prepaid airtime credit.

  • Have the Fido store order a JesusPhone(TM) (by phone, which takes over 30 minutes for some reason) for you from the customer service center. You can keep your phone number and use your FidoDollars to help pay for the new phone, and also any unused prepaid airtime will be credited to your monthly bill. Perfect, except they'll start billing you your monthly contract BEFORE you receive the new phone, and as the sales girl explained, you'll then have to call customer service when you do get the new phone up and running and get them to credit a pro-rated portion of the month. Also, it takes ~10-12 days and you have to pay the 250$ charge cash on delivery when you receive the new phone. Finally, to pour MORE salt on that wound, it won't even work out of the box because you must then drive back to the Fido store and have them transfer the phone number from your old SIM to your new SIM. But the cherry on the sundae is reserved for the Fido employees: as I learned, they don't make any commission on this sale even after working for an hour and a half trying to sort it out and spending an hour on the phone, because it's ultimately completed as a phone order.

How nice. I went with the second option. I'm expecting a package, for which I have no tracking number, to show up in around 10 days, with cash-on-delivery. Sweet.

For the record, the Fido employees agreed this was completely ridiculous, they're just powerless to do anything about it.

I leave you with this piece of news, however: the voice plan I signed up for is a new plan just introduced this week (not yet advertised on their site), and it's fantastic: 17.50$ a month for 200 daytime minutes + unlimited evenings and weekends. I think this is the cheapest voice plan I've ever seen - add 30$ for 6GB of data and you're paying only 47.50$ + fees per month, which is actually really decent. Looking on their website, there's no plan anywhere even close to that cheap that offers unlimited evenings and weekends, so this is a really great deal, I suppose it's a time-limited promotional offer, but I've got it locked in for 3 years now.

2008-08-24

Wake-up Call for the Foodie

Or: I fail at omnivorism, apparently.

I know how much everyone hates blog memes that rely on propagating lists, but this one has merit as a device to instill humility in this foodie's psyche and renew my drive for exploration and experimentation. I'm talking, of course, about the Very Good Taste Omnivore's Hundred, a list of 100 foods that's making the rounds right now, billed as a collection of meals any self-respecting omnivore must have tried at least once.

Why am I calling this a wake-up call? Because I just went through the exercise and scored a rather pathetic 56%, forcing me to realize just how little I've really experienced. Try it yourself.

Here are the instructions from the original post:
* Copy this list into your blog or journal, including these instructions.
* Bold all the items you've eaten.
* Cross out any items that you would never consider eating.
* Optional extra: Post a comment here at www.verygoodtaste.co.uk linking to your results.

I'm crossing out Whole insects, Fugu, and Roadkill, so I'm really aiming for a score out of 97. Oh, and the insects thing is probably negotiable after a couple of drinks. I did my counting on Google Spreadsheets, so the following should get automatically updated whenever I check off something new.



Update: ah of course, the iframe won't show up in RSS readers. You have to click to go to the real page.

Kimchi

I just want to post a pointer to Ron Eade's recent blog entry about making kimchi at home. A quick perusal of the instructions reveal it's a fairly involved multi-step process, but overall it still seems simpler than I'd ever imagined.


I buy my kimchi at 168 Market on Somerset, but they seem to only have a single variety and it's not quite as good as what they serve at, say, Seoul House. I've asked around and people seem to only be aware of 168 Market as a source, so perhaps I should try making my own someday - I'd just have to massively scale down the quantities from Mr Eade's typical batch size!

2008-08-13

What exactly are Dell and Costco selling here?


Just got a weird little something in the mailbox: a Costco marketing email drew my attention with a rather unusual-looking picture of some Dell machines. I clicked on to the website:

What's Costco Selling?

Hmm, that desktop image sure seems familiar, doesn't it?

dell2

Perfect match! Who wants a Dell XPS with OSX? Maybe this is the Creative-Commons-licensed version of Apple's famous desktop image? ;-)

2008-08-07

Age is strictly a case of mind over matter. If you don't mind, it doesn't matter. --Jack Benny

I got ID'd at the LCBO this week. Youth is still mine. Made me happy :)

2008-08-03

Visa Desjardins' fraud detection

Visa Desjardins has, for the second time in as many months, deemed some of my account activity suspicious. Since they're on the hook, financially, for unauthorized transactions I can understand them having a certain bias towards prudence, but in both cases when I spoke to a CSR, the reason stated was quite vague ("this activity doesn't fit your account's pattern").

I would love to learn (out of personal interest, really, I'm not complaining!) about the decision rules or heuristics that apply here considering the two suspicious charges that were delayed this weekend.

The first is a 25$ renewal of my Flickr Pro account, charged by Yahoo. The CSR said that getting a charge from an online service provider was flagged. Never mind that I've got monthly credit-card charges from my ISP for Internet access, and from rsync.net for storage space, and that my account has, in the past, seen charges from a large gaggle of other online sellers.

The second is even more comical: it's a charge from a gas station in Kanata.


The green placemark is the Esso station where I always fill up, it's at the corner of Solandt and March in Kanata, right next to the office. It was closed this week, so I went to the Shell station instead (the red placemark) 1200 meters away. That got me flagged. Really.

2008-08-02

Good Sentences

From The Fishbowl:

In the news this morning, US Department of Homeland Security regulations allow them to confiscate laptops at the border, or duplicate any data, without any suspicion of wrongdoing on the part of the laptop’s owner.

It’s a very timely move by the DHS. You never know when someone might invent a global, unregulated data network that could allow evildoers to entirely bypass such checkpoints, making them nothing more than a sham way for border police to rake through people’s private data and copy their mp3 collections.
[...]


The scary thing is I don't really see a way to defend against this. Even if you take the nuclear option and wipe everything, putting it online, and cross the border with a squeaky-clean laptop, there's still a chance your hardware gets confiscated. I wonder if travel insurance would cover seizure of hardware by foreign customs?