House of Rosania

Delicious musings about technology and entrepreneurship

Don’t Overload #nil?

There’s a popular post on Hacker News about writing confident code by, among other things, overloading Object#nil? and returning “null objects” instead of nil itself.

DO NOT DO THIS.

In Ruby, all objects (except nil itself) coerce to the boolean value true. Your object will be nil and true at the same time. Bad things will happen. Your coworkers will cry. Sad people from around the world will ask bewildering questions on your mailing list.

Here’s what happens:

1
2
3
4
5
6
7
8
9
10
11
class NullObject
  def nil?
    true
  end
end

o = NullObject.new

o.nil?             #=> true, great.
!!o                #=> true. not so great.
puts "exists" if o #=> "exists". ut oh.

Do you write all your guards using if o.nil? Neither do I.

If you overload #nil?, you will get burned. Please don’t.

Giles Bowkett, Swearing and the Greatest Ruby Talk Ever

At RubyFringe ‘08, Giles Bowkett went on a metaprogramming romp about Ruby, music, the evils of Venture Capital and the virtues of lightweight, ubiquitous protocols. He starts with an impressive demo, but it really gets going about 7 minutes in. Giles takes the crowd on a crazy, lightning-speed tour through 496 slides about Leonardo da Vinci, cougars, LSD and weasel-brained muppet fuckers.

He swears 10 times in 40 minutes, including 7 fucks. They’re like flourishes in an epic fireworks display.

Profanity is like rock music. The f-bomb is electric guitar. You might think it sounds sophmorish, but if you think it doesn’t add energy to a presentation, you’re lying to yourself.

Watch it.

http://www.infoq.com/presentations/archaeopteryx-bowkett

Buyer Beware: Firebug 1.6 + Firefox 4 Beta

There is a bug in Firefox 4 beta 6 (#557791) that interferes with Firebug’s “XHR Spy” feature (Firebug issue #3223). The net effect is that XmlHttpRequest onReadyStateChange events don’t fire.

With JQuery, this manifests through $.ajax calls: success and error handlers don’t fire.

The workaround is to uncheck the “Show XmlHttpRequests” option in the Console panel.

For more details, see Firebug’s Known Issues page.

Hopefully this short post saves someone more time than I lost dealing with this bug today.

The Death of GOOG-411

Back in 2007 we launched 1-800-GOOG-411, a voice-powered directory assistance service that connects you quickly to businesses across the U.S. and Canada. On November 12, 2010, we will shut down the service.

“Goodbye to an old friend: 1-800-GOOG-411” on The Original Google Blog

That sucks. I confess that I usually use Google Maps, Yelp or other apps to do my phone number lookups these days. But sometimes I’m driving, or walking in a busy area and don’t want to be staring down at my phone. I know, no one calls each other anymore. But when a call is necessary, GOOG-411 was the best 411 resource out there. (Not to mention, free.)

R.I.P GOOG-411. At least one of us will miss you.

On Luck, and Entrepreneurship

… the second big thing is luck. And it’s not relying on luck, or relying on fortune. It’s being able to recognize when it’s happening around you, and being able to recognize a situation that encourages buildout and execution of an idea.

Jack Dorsey at NYT’s 99% Conference

Startups fail. If I got paid for every time I heard the 5-year small business success rate quoted, I’d have my fuck you money already. My dad, ever the scientist, likes to remind me that despite blood, sweat and tears, if my startup succeeds it will be because I was “one of the lucky ones.”

It’s true. And yet, the type of luck we seek as entrepreneurs is not blind luck, like finding a $100 bill on the sidewalk. The type of luck we are after is situational luck. Nailing a pitch. “Clicking” with a client prospect or investor. Hiring a kickass team, and watching them hit home runs for your company. Yes, the outcome of each singular event is lucky. But the sum of it all, the net outcome, is not luck.

We make our own luck, and it is a blend of situational awareness and tenacity.

Creating a “TheFunded” for Angel Investors

Adam Smith has a great post with many interesting observations about Y Combinator’s most recent demo day. I latched onto one:

Do we need a TheFunded for angel investors?

I think the answer is yes, for three reasons:

  • Angel investors come at a critical time for the company
  • Angels’ reputations are not always well known
  • The role of the angel is on the rise

Angel investors come at a critical time for the company

The right investor can bring critical momentum to a fledgling startup. For the “mega-angels” this can be clout, but it can also be key introductions to potential clients and business partners. Experienced angel investors also know how to manage their relationship with the company in a way that increases the company’s likelihood of success, without getting in the way.

On the other hand, the wrong angel investor can pose a serious risk. Inexperienced or overly aggressive investors can be a huge distraction during the fundraising process, and putting the deal at risk. The pain can continue once they’re in, as they chew up valuable time and energy.

Angels’ reputations are not always well known

VC firms’ reputations tend to be public. TheFunded is a valuable asset in this regard, but firms like Union Square Ventures and Sequoia are preceded by their reputations as well as the reputations of their partners. While the same is true for prolific angels like Ron Conway and Peter Thiel, it is not true for the many thousands of other angel investors clamoring for access to events like YC Demo Day.

The role of the angel is on the rise

More startups are trying to achieve profitability with less fundraising. Sometimes a seed round is all a company needs to get there. The financial climate is one factor, but movements like Lean Startup indicate a broader trend that will outlast the crisis, and pose a serious threat to the current VC model.

What this means for angels is they play a bigger overall role over the lifetime of the company. Instead of getting crammed down across Series A, B and C rounds, where VCs take control via equity and board seats, angels can expect to hold significant equity positions for a long period of a startup’s growth. As a result, startups need to be increasingly focused on identifying angels that can help move their company forward through introductions, rather than purely through investment.

Sidebar: … but is it legal?

Defamation laws in the United States might pose a challenge to a “TheFunded for Angels.” TheFunded is safe since it deals with organizations, but a review site for angels would by necessity contain reviews of individuals. While angel investors like Mark Cuban probably constitute “public figures”, many lesser known angel investors would not.

The authors of negative reviews of angel investors might be exposed to libel suits, regardless of the reviews’ accuracy. The types of angel investors that receive low ratings are likely the same types of people who wield lawyers to deal with their problems, and this could torpedo the concept.

But otherwise, I love the idea.

Apartment Hunting Is Not Core to Your Business

I just wrapped up an apartment search. In total, my girlfriend and I met with 5 brokers and viewed almost 15 apartments over 4 separate days. I’m guessing we invested at least 50 hours of time in the process, between phone calls, emails, research, traveling around town and just generally dealing with the annoyance that apartment hunting represents.

After all that, we settled on a unit in the building I already live in.

Why? Simplicity. When I began my apartment search, I was determined to cut my monthly rent by at least $200. By moving within my building, I am saving $150 a month (not quite $200). At the same time, I’m recovering a full month’s rent that would have been lost to our apartment broker. Amortized over the full year, that’s easily another $150 a month.

Had I made that choice from the beginning I could have saved myself and my girlfriend 100 combined hours of searching Craigslist, making phone calls and viewing apartments.

Moving would have involved:

  • A U-Haul ($50-100)
  • A full month’s rent as a broker’s fee in most cases ($1500+)
  • Several lost days of productivity packing, hauling and unpacking everything

What’s the point?

In my excitement to cut costs, I discarded the easiest option (stay in the building) without considering the opportunity cost. I wasted valuable hours (and nearly a lot of money) trying to optimize.

I can make a lot more by investing those hours into my startup. The potential cost savings I gain by shaving some monthly expenses off my budget are far outweighed by the value my business gains from having the hours invested in it.

I think there’s a lesson there for businesses: Focus on your core.

Quote: “We Are So Seduced By…

We are so seduced by the thought of a guaranteed paycheck every month that we completely ignore the fact that it’s actually never too late to pursue our dreams. The reason as I can understand is probably “fear of failure”. We fear we might fail and that fear leads us to cook up stories about why you can’t have what you want. Alibis like “I don’t have time, I have family, I’ll do it when I have more money etc”. Stories that convince us that it’s ok not to follow up on our dreams, that it’s ok not to do what you love, that it’s ok to just keep doing the everyday drill.

And guess what. That paycheck ain’t guaranteed, either.

From the fantastic post, For God’s sake, follow your dreams over at Rootein Blog.

Point-and-Click Install of MongoDB on OS X 10.5+

Update: v1.4.4 is now available! See download links below.

Our skunk-works project at CollegeJobConnect uses MongoDB extensively for persistence. (Through the excellent Mongoid ODM.) MongoDB is fantastic, but setup on my MacBook Pro is still a manual process with each new version, so I’ve packaged up a simple installer that should get you up and running in no time.

The Old Way

  1. Download the MongoDB binary distribution from the matrix at MongoDB.org
  2. Extract
  3. Move to /usr/local
  4. Symlink mongodb-osx-x86_64-1.4.4 -> mongodb
  5. Create a .plist file in /Library/LaunchDaemons
  6. Load the .plist file into launchd using launchctl
  7. Create data and log directories in /var
  8. Add Mongo to the path (/etc/paths.d/mongodb)

The New Way

  1. Download the MongoDB installer from Github (click here)
  2. Run the installer

You can check to see if it’s working properly by visiting http://localhost:28017/ after installation has completed.

Requirements

The installer uses launchd and the x86_64 release of MongoDB v.1.4.4. It requires:

  • Mac OS X 10.5 (Leopard) or 10.6 (Snow Leopard)
  • A 64-bit CPU (Core 2 Duo or newer)

Steps to get it working on 10.4 (Tiger) are probably minimal but are left as an exercise for the reader. I don’t use Tiger anymore… YMMV.

Feel free to leave feedback in the comments. Issues should be lodged at Github.

Disclaimer

The installer is provided as a community service to people like me who are looking for an easier way to install MongoDB and keep it up to date. It comes with no warranty. I am not responsible for any damage caused by the installer. The project is freely available on Github. Feel free to peruse the source if you like.

JRuby Deployment With Glassfish and Capistrano

At CollegeJobConnect, we need to process Word and PDF-format resumes that we receive from our members. In order to carefully curate our initial candidate pool, we have done a lot of this work by hand. However, as we grow we need to automate as much of the registration process as we can. This involves using automated text extraction to retrieve some basic attributes from these files. Fortunately, there are some great open source tools out there that wrangle Word and PDF documents into raw text. Unfortunately, they are written in Java. Enter JRuby.

JRuby makes our job drop-dead simple. We can tap into the Java libraries we need, while keeping our code in the language we love. Unfortunately, the state-of-the-art in JRuby deployment is in a bit of disarray. Charles Nutter does a good job of guiding the decision in his August 2009 blog post. We settled on his recommended approach for simple apps — GlassFish gem. However, things fell apart in the details. A post on Jacob Kessler’s blog at Sun provided some guidance, but we had trouble getting his deployment script working properly. We also wanted something that we could administer with initscripts, to DRY out process control. After a few hours of head-scratching frustration, we got things running. Here’s how:

Prerequisites

  • Java 6 JRE (sun-java6-jre on Ubuntu)
  • JRuby 1.5
  • Git

(Our server is running Ubuntu 10.04 LTS “Lucid Lynx”, but this should work in 9.10 and 8.04, and with minor adjustments in any similar Unix environment.)

Getting It Done

1. Install GlassFish gem: sudo jruby -S gem install glassfish

2. Capify your JRuby application. From your application’s root directory, run capify .

3. Customize config/deploy.rb for GlassFish. (Change the ”example_app” references to match your app.)

4. Install the glassfish-example_app initscript in /etc/init.d. (Change the “example_app” references and customize the GlassFish arguments to suit your fancy.)

5. Install the initscript in rc.d (this will only work on Ubuntu/Debian):

   sudo update-rc.d glassfish-example_app defaults

6. Deploy your app with cap deploy.

… and you’re done! Post in the comments if you have any comments or questions. If this saves you time, let me know!