19 year-old dj and producer touring with tiesto and deadmau5 takes lyrical inspiration from Libertarian Manifesto

i saw a new gameplay video for battlefield 3 today which had strong anti-government lyrics, and i didn't immediately recognize it but it turns out the lyrics were from murray rothbard's Libertarian Manifesto:

The State: the government, the supreme, the eternal, the aggressor against the persons and property of the mass of the public. All States everywhere, whether democratic, dictatorial, or monarchical, whether red, white, blue, or brown.

For centuries the State has robbed people at bayonet point and called it "taxation."

For centuries the State has enslaved people into its armed battalions and called it "conscription."

By coercion and violence -- by the direct threat of confiscation or imprisonment if payment is not forthcoming. This is taxation.

The State by Porter Robinson

this will be the first time i've seen libertarian politics in a dubstep track, which also happens to be good enough to be on a soundtrack like c&c red alert.

why do people still buy books?

Screen_shot_2011-09-14_at_5
there's been a lot going on recently with books. i've been watching eric ries and i'm blown away by how successful he's been at promoting his book the lean startup. i saw that @dharmesh wrote about it at onstartups.com, and tweeting out small agreeable little tidbits from the book is genius--i don't know whether this was intentional or not, but that's an awesome idea.

Read the rest of this post »

The predictable criticism of my latest VentureBeat post

Venture_beat_logo
I've heard a few people criticize my advice when I wrote "How To Land Meetings with Anyone", although the response has overwhelmingly been very positive. It's one of the most-liked stories (by Facebook likes) on VentureBeat.

There are two major criticisms that I'd like to respond to. I wanted to first point out that trolls appear to running rampant on the post; I've only recently understood how to spot them and when to not respond. I'm talking about comments like this:

This has to be one of the lamest things I have ever read on hacker news. Hacking the system? Its called persistence. Yes, sometimes it can work, other times it can get you shitlisted. Is this the kind of crap they teach Urbana-Champaign? No wonder I rarely hire a recent college graduate.

There's a few things here. First, the person thought the advice is horrible. I can understand that. They also claim I'm misusing the term "hack", which has happened in the past before, so maybe I should actually explain that part.

Read the rest of this post »

scrape wikipedia

Wikipedia_logo
built a quick recursive wikipedia scraper with depth limit in ruby because wget was an epic fail. uses nokogiri, which is excellent for using CSS selectors.

this script will recursively get all categories based on a single category, so as an example i started off here: http://en.wikipedia.org/wiki/Category:Algorithms and then a text file is created which creates a full list of categories and subcategories. i set the initial depth limit to 3, otherwise it goes really deep and starts getting things that are no longer relevant to the original category.

i'll add more code later to scrape the pages of all the categories.

edit: the code was updated, you should uncomment the lines at the bottom to make this work.

edit: need to scrape stackoverflow? very simple scraper here with delay timer -- i got blocked from stackoverflow the first time i tried this.

scrape hn

Hacker_news_logo
working on a search engine and i am using hacker news as a test forum.  if anyone needs to do something similar, feel free to use my simple scraper:

grab top stories from hacker news

grab all comments for each story

it's pretty crappy code but wget would not suffice. uses nokogiri which works pretty nicely.

edit: sad face =[ hn only lets you go 1104 stories deep

edit 2: pg says comment count is omitted sometimes to optimize for speed; removed that metric

Picture_1

edit 3: i used lemur to do the actual work of searching and indexing. i added the Okapi BM25 ranking function to computeWeight() in DBInterface.cpp. this is one of the key ranking functions google uses.

where did the idea for foursquare's badges come from?

Foursquare_logo
i got to ask some questions i had always wondered about when i spoke to dennis crowley today, one of the cofounders of foursquare. i wanted to know what inspired him to come up with the badges, which was one of the most addictive parts of foursquare, which is now 7 million highly engaged users after only 2 years. just to make a comparison, facebook had 6 million users after 2 years. what i find interesting is that dennis worries every day about foursquare failing when i asked him about that--they don't feel happy with where they're at right now.

the idea for the badges came from a project dennis worked on after he worked on an application at areacode called shark runners. dennis left google on a friday and joined areacode on a monday. he mentioned that he had played games like zelda which had inspired those game mechanics, and the shark runners application is what caused them to come up with foursquare's badges and game mechanics.

as for the check-ins that foursquare invented? dennis and all of his friends were laid off in 2001. to continue keeping up with what everyone was doing, they created the check-in as a way to see where their friends were going and meet up with them.

the full interview will be released in the upcoming book about startup founders, which will be mentioned here later. the pre-order will start in the last week of march.

hacking your apartment's electronic entry system

i was talking to a founder of a startup since i'm publishing a book in april (shameless plug: it's about how many of today's startups came to be and the founders' stories). i ask every founder to answer the same question that shows up on the YC application: talk about the time you most successfully hacked some (non-computer) system to your advantage.

of the 30 interviews i've done so far, i've seen lots of creative answers.  one of the answers reminded me that our apartment uses RFID to get into the building from the outside.  the doors to get into my apartment lock automatically at night, so you need the RFID card to get in.  there's also keypad that allows you to enter in a room number.  so if i typed in my room number, the apartment calls my cell phone and i can talk to the person outside via a speaker near the keypad.

edit: shortly after this went up, i realized who inspired this hack. it was dan gross and robby walker (the guys who started greplin.com). special thanks to them, and some of the hacks they use at greplin.com are genius. the book will go into detail.

so i realized after pushing all the buttons on my cell phone that "9" unlocks the door.  in effect, if you get locked out because you had to throw the garbage out at 2am, you must have either your cell phone or RFID card. if you're missing those, you're locked out for good.

i thought it'd be cool to try and hack this, so here's what i did:

  1. i signed up for a twilio account.  this is free and they actually give you $30 of credit when you join.  they'll give you a free sandbox number, which you can use to test your scripts.
  2. in order to imitate the "9" being pressed which unlocks the door, i tried to find somewhere in twilio's API that supported single-digit dialing but they didn't offer it.  if i tried to call a single-digit number, it just threw an error and said "invalid number" on the call logs.  twilio however does support playback of mp3, so i did a search for the list of DTMF tones and found them here in mp3 format.
  3. i wrote the very simple script (here's a link to the sample twilio script) which upon receiving a call, plays back the dial tone "9." i uploaded this to my linode box along with the mp3 file and asked my apartment to update my cell number after switching my twilio account over from the sandbox number to a real number.
  4. i got a notice that the number was updated, and i started letting myself in without keys.

i realized that this would be an easy hack to do in other places where keyless entry systems worked the same way.  an e-mail could be sent to the apartment manager to the effect of "i've updated my cell phone number, i wanted to let you know. can you please update it for me? -resident name" and since most apartment managers probably don't verify the e-mail address, you could probably just find the resident names on a directory outside where the mailboxes are at. probably not too useful since that's just one layer of security though.

here's a video of the hack in action:

math behind dope wars drug trading for profit

Dopewars
disclaimer: this is not a complex analysis on the statistics of trading and risk in a game like dope wars.  it's mostly an uncovering of how simple the trading actually is, and is my attempt to offer some suggestions on how to make it a little more challenging to generate profit quickly in a game like this.

after looking at the python source code for dope wars, i realized there are no complex algorithms for trading drugs.  but as i'm building drug wars, i'm looking for a way to limit the profit potential to a new player to keep it interesting (too much profit makes a game too easy to win).

it turns out that's easy to do even using simple math.  an actual example using the drugs from that version of dope wars:

table of drugs + price range (minimum..maximum)

Acid    1000..4400
Cocaine    15000..29000
Hashish    480..1280
Heroin    5500..13000
Ludes    11..60
MDA    1500..4400
Opium    540..1250
PCP    1000..2500
Peyote    220..700
Shrooms    630..1300
Speed    90..250
Weed    315..890

from each of these drugs, we can see the minimum and maximum amount each will sell for.  as an example, on a very good day i can buy lots of cocaine for $15,000, then i can turn around and sell it on another very good day for $29,000.  that's a profit of $14,000 per unit of drug sold.  nice!

we can calculate the differences between the max and minimum drug price:

Acid    3400
Cocaine    14000
Hashish    800
Heroin    7500
Ludes    49
MDA    2900
Opium    710
PCP    1500
Peyote    480
Shrooms    670
Speed    160
Weed    575

i think there are a few ways of looking at the profit margins.  under a single trade it might be ((max-min)/(highest_max_of_all_drugs))*100.  in dope wars, it's sometimes possible to assume you can purchase the max of any drug--so would you always want to purchase cocaine?  the amount of return by the following (assuming no limit to buying a given drug):

((total money / min price) * max price) / total_money

to give a simple example, if you have $10,000 and you buy ludes, you can generate 5.4x return under the best scenario.  this allows you to generate (max-min) a number of (total_money/min) times.

Acid    4.4x
Cocaine    1.9x
Hashish    2.5x
Heroin    2.3x
Ludes    5.4x <- the cheapest drug, also the most profitable
MDA    2.9x
Opium    2.3x
PCP    2.5x
Peyote    3.1x
Shrooms    2.0x
Speed    2.8x
Weed    2.8x

if you want to make a game like this difficult to beat, i think you'll want to:

  1. keep the difference between the max and min price low.  this reduces the chance that a drug can be bought really low and sold really high.
  2. keep the minimum buying price high.  this reduces the number of times the things from #1 can happen.

my instinct was that cocaine would be the best drug to purchase since it had the largest difference (one trade would at best earn you $14,000).  but if there aren't any limits, you'd be better off doing a lot of smaller trades of ludes.

i haven't accounted for what you do in various situations when you have a limit on the drugs sold.  this is in many versions of the game, so i'd need to understand the likelihood of how many drugs are available in an area first.  i might write another post on that shortly, since that is really what we'd want to understand.  you'd also want to consider how much money you have at any given time.

i think a strong algorithm would do a few things:

  1. cause all locations to have an initially low demand
  2. associate an addiction multiplier to each drug, so as the drug is purchased, the demand increases and so does the price
  3. increase the presence of a police force as a drug with a high addiction multiplier increases in a location, making the risk higher to trade
  4. create a cap on how many drugs can be traded in a location (e.g. sold between players or limited by the system)

navigator.geolocation working only sometimes or not working at all

really annoying if you've ever worked with navigator.geolocation, you'll realize that sometimes it just doesn't work at all.  i thought there was some type of rate limiting where you can only make a request x times per hour.  as it turns out, there are error callbacks and by default navigator.geolocation has an infinite timeout.  to make matters worse, navigator.geolocation sometimes just doesn't work at all making it very unreliable.

as an example: this function will wait up to 15 seconds and then call the error callback if it cannot find the location: