How I Learned to Program

|

I’ve always liked to write and decided a good way to share my writing was on a personal blog. Three years ago I registered a free WordPress blog with the url “davidxia.worpdress.com.” I decided the “wordpress” in my URL was lame so I Googled how to buy a domain name. I registered “davidxia.com” through GoDaddy and rented some hosting space. (Unfortunately I rented hosting space with GoDaddy because I didn’t know any better. I’ve since switched to Linode.)



Robert Zubrin’s “the Significance of the Martian Frontier”

|

Robert Zubrin, an American aerospace engineer and author, wrote the essay The Significance of the Martian Frontier. He argues that the technological and cultural advancements of “Western humanist civilization” were the result of a frontier – a wild and unknown territory of vast resources. The Greeks had the Mediterranean. The United States had the American West (never mind that the Native Americans were here long before).


My Awesome Cofounder and Advisors

|

James

I had the opportunity of meeting James the day he left his law firm to start a company. He’s one of the most affable, able, and ambitious people I know. He told me that he wants to “Go big or go home” and for him its closer to the truth than you might think.

James and I worked very closely for half a year. I’ve never had a peer with whom I had such a close working relationship. How close? I spent more nights at his apartment than his girlfriend and kept an extra toothbrush in his bathroom.

It was six months of engineering and entrepreneurial bootcamp. James and I traveled to Boulder, Colorado to check out the Techstars incubator program. We flew to Vancouver, Canada to roll out our beta in an effort to acquire travel bloggers as our core users. I remember landing in Vancouver the day the city’s hockey team, the Canucks, won the fifth game of the 2011 Stanley Cup. James and I waded through 100,000 drunk, loud Canadians running through the streets with outstretched palms motioning for high fives. (Being from Boston, the city of the opposing Bruins team, I feared for my life the day the Canucks lost the championship and Vancouverites set police cars on fire.)

I met Ben and Nan, two Berkeley computer science graduates, through James. I’m glad to have met such smart advisors and friends who are insightful, patient, and frank. Launching a startup is do-or-die. I needed colleagues whom I could count on to call it like they see it and, when necessary, respectfully say, “You’re doing it wrong. Do it this way.”

Ben

Ben taught me how to build scalable websites, use Vim, and understand Git. He helped me on implementing input box autocompletes to job hunting. He’s a great mentor and genuinely likes teaching. He once said, “Teaching you Vim makes me happy.”

Nan

Nan helped me see why certain services or business models worked. He explained why companies like Tumblr and Gilt Groupe were able to become successful. Tumblr became popular because it created a new type of content by being like Twitter on steroids and having great UI. Gilt took advantage of distressed luxury inventory during the last recession (which I think never really ended).

Even after Shoutbound ended, James, Ben, and Nan have been tremendously helpful. All of them helped me transition to my new position.


WordPress Logged-in Cookie Problem and Solution

|

My WordPress blog is installed in a subdirectory in my document root. This keeps the document root tidier. The problem is that the cookie titled “wordpress_logged_in_somerandomhash” that tells WordPress you’re logged has its path set to http://www.yoursite.com/subdirectory. You can still log into the admin console. But when you visit your blog at http://www.yoursite.com, WordPress doesn’t think you’re logged in because your browser doesn’t send the wordpress_logged_in_somerandomhash cookie.

This is not a huge problem, but I wanted that nice banner on the top that allows me to have admin functions. I also wanted each post to have an “edit” link for easy editing.

Figuring this out took me all afternoon. The solution is to define “COOKIEPATH” in your config.php file. Just add define('COOKIEPATH', '/'); to the beginning of config.php.


My Favorite Acronyms

|

These are some of my favorite acronyms. I like them not only because they are funny but also because they sometimes contain a kernel of truth. I’ll be adding to this list over time.

  • ISAF = I suck at fighting, I saw Americans fighting
  • job = just over broke
  • army = ain’t ready for Marines yet

Post your favorite acronyms below.


How to Calculate Your Birthday According to Chinese Calendar

|

My birthday according to the Gregorian calendar is September 23, 1988. But the Gregorian calendar seems a bit passé. So this year I will celebrate my birthday according to the Chinese calendar.

To calculate your Chinese calendar birthday go to Baidu’s calendar converter; go to the year, month, and day of your birth; hover over that day and note the 农历 month (月) and day (曰). Mine is the 8th month and 13th day. Now go to this year and hover over dates in a similar range until you see the same month and day. This year, my lunar birthday is September 10, 2011 instead of September 23 and next year it’ll be September 28.


Secretary Problem

|

  1. There is a single position to fill.
  2. There are (n) candidates for the position, and the value of (n) is known.
  3. The candidates, if seen altogether, can be ranked from best to worst unambiguously.
  4. The candidates are interviewed sequentially in random order, with each order being equally likely.
  5. Immediately after an interview, the interviewed candidate is either accepted or rejected, and the decision is irrevocable.
  6. The decision to accept or reject a candidate can be based only on the relative ranks of the candidates interviewed so far.
  7. The objective is to select the best candidate with the highest possible probability.

The optimal strategy is to reject a certain number of candidates. Call the number of rejected candidates (k-1), where (k) is the first candidate that won’t be automatically rejected, ie that you’ll actually consider. We will refer to this let (k−1) go by strategy as strategy (k). Let (M) be the best candidate among these (k-1). Then choose the first subsequent candidate that’s better than (M).

So if we’re given (n), what (k) should we pick to give us the highest probability of picking the best candidate? What is this probability? What happens when (n) goes to infinity?

Let (p_{n}(k)) be the probability of choosing the best candidate with (n) candidates using strategy (k).

Case (bf{n = 3})

We list the 6 permutations of ({1, 2, 3}). 1 is the best, 3 the worst.

  • 1, 2, 3
  • 1, 3, 2
  • 2, 1, 3
  • 2, 3, 1
  • 3, 1, 2
  • 3, 2, 1

Possible values for (k) range from 1 to 3. If (k=1), we always pick the first candidate. If (k=3), we always pick the last. If (k=2), we always reject the first candidate and pick the first subsequent candidate that’s better than the first. So if the first candidate was 2, we end up picking 1. If the first is 3, we end up picking 1 or 2 depending on which one we see first. If the first candidate is 1, we never find a better candidate and end up picking the last one. Tragic.

Now we list (p_{n}(k)) for each value of (k):

k

(bf{p_{n}(k)})

1

1/3

2

½

3

1/3

(k=2) is optimal.

Case (bf{n = 4})

There are 24 permutations of ({1, 2, 3, 4}). 1 is the best, 4 the worst.

k

(bf{p_{n}(k)})

1

6/24

2

11/24

3

10/24

4

6/24

(k=2) is optimal.

Case (bf{n = 5})

There are 120 permutations of ({1, 2, 3, 4, 5}).

k

(bf{p_{n}(k)})

1

24/120

2

50/120

3

52/120

4

42/120

5

24/120

(k=3) is optimal.

The general case
For n candidates, let (X_{n}) denote the number or arrival order of the best candidate, and let (S_{n, k}) denote the event of success (that we pick (X_{n})) for strategy (k). All orderings/permutations of the candidates are equally likely so (X_{n}) is uniformly distributed on ({1, 2, …, n}).

There are two ways we can fail:

  1. the best candidate is among the first (k-1)
  2. the best candidate is not among the first (k-1) but is preceded by a candidate with a higher score than any in the first (k-1)

Since we can only pick one candidate from (k) to (n) and these events are exclusive, the probability of picking the best candidate is the sum of the probabilities that the one we picked is indeed the best.

So what’s probability that we succeed by picking a particular candidate? It’s the probability that this candidate is the best multiplied by the probability that we’ll pick him. This second part is very important. It can be rephrased as the probability that the best candidate before him was in the first (k-1). He has to be the best and no one before him can be better than the ones we automatically rejected. Since (X_{n}) is uniformly distributed on ({1, 2, …, n}), the probability that any particular candidate is the best is (1/n).

We calculate the probability of succeeding with candidate (k). The probability that he’s the best candidate is (1/n). The probability that the best candidate before him is in the first (k-1) is 1. So the probability of succeeding with candidate (k) is (1/n cdot 1 = 1/n).

We calculate the probability of succeeding with candidate (k 1). The probability that he’s the best candidate is (1/n). The probability that the best candidate before him is in the first k-1 is (frac{k-1}{k}). So the probability of succeeding with candidate k is (1/n cdot frac{k-1}{k} = frac{k-1}{nk}).

We calculate the probability of succeeding with candidate (k 2). The probability that he’s the best candidate is (1/n). The probability that the best candidate before him is in the first (k-1) is (frac{k-1}{k 1}). So the probability of succeeding with candidate (k) is (1/n cdot frac{k-1}{k 1} = frac{k-1}{n(k 1)}).

We calculate the probability of succeeding with the last candidate. The probability that he’s the best candidate is (1/n). The probability that the best candidate before him is in the first (k-1) is (frac{k-1}{n-1}). So the probability of succeeding with candidate (k) is (1/n cdot frac{k-1}{k 1} = frac{k-1}{n(n-1)}).

We sum up these probabilities.

begin{align}
p_{n}(k) &= mathbb{P}(S_{n,k}) = frac{1}{n} frac{k-1}{nk} frac{k-1}{n(k 1)} ldots frac{k-1}{n(n-1)}\
&= frac{k-1}{n} sum_{j=k}^n frac{1}{j-1}
end{align
}

So what’s the optimal strategy for (n=100)?

The maximum for (y) or (p_{100}(x)) is about (x=38) with (p_{100}(38) approx 0.37104). So given 100 candidates, we should reject the first 37.

Using Drake’s Equation to estimate eligible individuals
The Drake equation is used to estimate the number of detectable extraterrestrial civilizations that might exist in the Milky Way.

[
N = R* cdot f_{p} cdot n_{e} cdot f_{l} cdot f_{i} cdot f_{c} cdot L
]

(N) = the number of civilizations in our galaxy with which communication might be possible
(R*) = the average rate of star formation per year in our galaxy
(f{p}) = the fraction of those stars that have planets
(n
{e}) = the average number of planets that can potentially support life per star that has planets
(f{l}) = the fraction of the above that actually go on to develop life at some point
(f
{i}) = the fraction of the above that actually go on to develop intelligent life
(f_{c}) = the fraction of civilizations that develop a technology that releases detectable signs of their existence into space
(L) = the length of time for which such civilizations release detectable signals into space

New York City population 2010: 8,175,133
percentage women: 52.62%
20-26 years old: 10.8%
bachelor’s degree: 15.8% http://www.city-data.com/city/New-York-New-York.html

http://newyork.areaconnect.com/statistics.htm


How to Improve Your Facebook Experience

|

For quite a while now I’ve logged onto Facebook only to close the tab five minutes later feeling unsatisfied. But until recently I couldn’t put my finger on why I consistently had an unpleasant experience. I slowly began to realize that one of the primary reasons was the Law of Internet Entropy.

The Law of Internet Entropy states, as my friend friend once told me, “Websites eventually become Craigslist.” There are many examples of online communities and websites losing their niche and eventually catering to broad interests. It takes energy to maintain a focused service and well-defined community.