Nov 032014

Recently I bought a three-pack of these cool Nike Dri-FIT Crew Socks and I guess they mold them specifically for your left and right foot?

In getting ready for work this morning, I grabbed a pair of these bad boys, and I noticed that more often than not, the laundry place where I get my laundry done seems to pair them correctly (meaning that each “L” sock is paired with a corresponding “R” sock). I was wondering if they’re just hyper-considerate laundry folders over there, or if maybe it was just a coincidence.

Not recalling my statistics, I wrote a brute-force script to figure out what percentage of the time they would be bundled “correctly” when bundled at random:

And I found the answer to be an astonishing 40%!

$ python 3 -n 100000
3 pairs of socks
100000 iterations
{False: 60011, True: 39989}
Good 39.99% of the time 

I don’t know about you, but I find that percentage to be super high! We’re saying that when choosing socks in random order, that almost half of the time they’ll end up being bundled “correctly” with three bundles of properly matched “R” and “L” socks!

Update: I finished getting ready and hopped on my bike, and as I was commuting into work I started thinking about my results, specifically wondering if I could come up with a statistical explanation, and I think I figured it out.

Steps and corresponding probabilities:

  1. Choose one sock at random (cool 100% of the time, hard to mess this one up)
  2. Choose a sock that matches (cool 60% of the time – of the 5 remaining socks, 3 should be the correct match, and 2 the wrong one)
  3. Choose another remaining sock at random (cool 100% of the time)
  4. Choose a sock that matches this sock (cool 66.666…% of the time – of the remaining 3 socks, 2 are the correct match and 1 is wrong)
  5. The last two socks will always match each other (100%)

Now using statistics, you multiply the probabilities of these events happening (right?):

1.00 * 0.60 * 1.00 * 66.666 * 1.00

or in fractions

3/5 * 2/3





Yay, math!

Oct 292014

This morning I set out on a quest to grab ESPN’s latest headlines using pup.

Long story short: I couldn’t figure out how to do it using pup alone.

Luckily, Eric Chiang (pup’s creator) came to my rescue with a solution using pup and jq in combination, and I’ve since written a command-line script for grabbing ESPN’s latest headlines, as well as modified my motd to include them!

Happy ESPN’ing! :)

Oct 282014

So first off, let me start by saying that I noticed that my last post is entitled NYC Subway Data, Part 4 – moar data!. I later noticed that there is no “Part 3” in this series. There never was. Too bad, it will remain a mystery.

Going forward, I’m happy to introduce MTA Fare Buster!!!

Based on Ben Wellington (iQuantNY)‘s post on the leftover money that you commonly end up with when buying a metrocard, I did some research and despite there being a few similar apps out there on the Android market, one was good but not updated with the latest bonus policy, one doesn’t give you options, and one wasn’t free, so I decided to write my own.

Full source code here:

Happy commuting!

May 012014

Introducing… MULTIPLAYER 2048!

That fun game that just won’t die is back again, this time in multiplayer form!

To play along, join the #2048 channel on Freenode and start issuing commands like “up”/”down”/”left”/”right” (or “u”/”d”/”l”/”r” for short).

From a technical perspective, I forked the original version and modified the controls so that they no longer come from the keyboard. This multiplayer version instead uses Pusher to update clients with realtime events and a Hubot with an IRC adapter and a custom script that calls a Python/Flask webserver, stores the data in a Redis list, and triggers the Pusher updates.

I was on the front page of Hacker News for about five minutes before being booted (still learning the ropes on how HN posting works), so I guess it wasn’t a big hit. I was even in touch with the kind folks over at Pusher who bumped me up to a higher number of allowed simultaneous connections to prepare for HN traffic, but alas I never needed it. Thanks anyway Pusherinos!

Happy 2048ing!

Enhanced by Zemanta

Jan 312014
Image representing Craigslist as depicted in C...

Image via CrunchBase

If you’re anything like me, you LOVE the prospect of finding a “new” used bike from Craigslist, but there are some pretty strong pain points there that keep you from doing it regularly:

  • so many links to click
  • so many bikes that are not my preferred <size|color|brand|etc.>

Enter this little script that goes through, “clicks” all the links for you, and searches for exactly the search terms you’re looking for! Happy Craigslisting!


Enhanced by Zemanta

Mar 282012
Android Robot. Français : le logo d'android 日本...

Android Robot. (Photo credit: Wikipedia)

Yeah, I know that I’ve been gone for a while, and no, this post won’t have anything to do with music, except to tell you that if you’re in Ljubljana tonight and missing Nils Frahm at Menza pri Koritu then I don’t know what to tell you.

No, today’s post is about finishing and what that means. I was going to start with a dictionary definition, but I think you all know what “finish” means. It means bringing a task or activity to an end; completing something that you started.

In truth, I don’t finish many of the things I start. When I was a kid I quit hockey. In middle school, The Boy Scouts. In high school I quit the swim team after one year. I started a company in college that we disbanded a few years later – in that time (Facebook‘s early days, when there was still space there) we built an entire social network that we never launched to more than a few hundred people. I remember when Facebook first opened their platform, and some of the proofs of concept Facebook apps that I came up with. I was also there with a handful of ideas and prototypes when Foursquare launched their API. Several years ago now, I wrote an entire autonomous Twitter bot platform that I’ve never officially done anything with. Before I moved to Slovenia I spent a few months screwing around with an Arduino, never to actually build anything long-standing or useful. In the last year and a half, I wrote the meat of a brilliant and complex social/gaming web application, working with an excellent UX person who is plugged into New York City’s thriving tech scene (she has friends at TechCrunch, in several influential tech startups, etc.), yet we still haven’t brought it across the finish line. When Android first came out I switched to TMobile and bought the G1. I was at all of the NYC Android meetups. In the last few years, I’ve written seven or eight interesting Android apps that are in a half-finished state sitting in my Eclipse workspace and/or on only my phone. I have all the excuses in the world (hockey got rough, boy scouts got boring, swimming wasn’t fun, no time, lost interest, etc.), but when all is said and done, what it boils down to is that I don’t finish things.

As a side note to any employers who think that they hired/are hiring/will hire a dud, I’m speaking strictly about things that I do/build in my free time; when it comes to a job and being professional, yes I do finish all of the tasks required of me. It is in my code of ethics to uphold my contractual obligations.

But why don’t I uphold that same code of ethics for things that I don’t get paid for? Why don’t I finish things?

I think that the answer lies in the fact that I love making a good proof of concept. I love mock ups. I love the kind of instant gratification that a prototype offers. I love spending enough time with a technology to learn about how it works, grasp it, and build something with it. Maybe my quest for knowledge is breadth-first? Back when I was a junior dev in my first startup, our chief architect (also a good friend) used to compare me and my colleague, saying that I’m like a sponge, soaking up all of the knowledge that I can about everything that I work on, while my colleague strived to finish each assignment as quickly as possible without needing to know why things worked, just that they did. I guess it’s good to have both types on your team. The yin and the yang.

Fast-forward to yesterday in the office: I was about to show off an Android app that I built this past weekend to a few coworkers, when my friend Drazen asked if it was the same app that I showed a few weeks before. I replied that it was something new that I cooked up from my bed this past Sunday morning. Drazen laughed and (rightfully) pointed out the fact that I don’t finish anything. At the time I was like “yeah, yeah” and shook it off, but his words stuck in my head for the remainder of the day. Last night at around midnight I fired up Eclipse, determined to finish what I started. At around 02:30 I had a fully working implementation of my gag app with basic functionality. I quickly read the release docs for the Android Market (now “Google Play”), registered for a developer account, paid the $25, signed my .apk file, posted a couple of shitty screen grabs and descriptions, and by 03:30 I officially had a finished product sitting on the Android Market, available to the masses!

I now present to you, Talking James! A proof of concept of finishing.

QR code for Talking James on the Android Market

QR code for "Talking James" on the Android Market


Enhanced by Zemanta