comment 0

Using Better Naming to Clarify Code

I’m a big fan of good naming in code, here’s a recent example:

Suppose you have a unique index in a database table and you’re trusting that index to enforce no more than one record with the key.

So you’re using an insert ignore into…on duplicate key update statement.

So you end up calling something like DataAccess.InsertRecord(data) or DataAccess.AddRecord(data). Looking at such code it’s very unclear that what really happens is an insert/update and you’re only left with one record.

You can go the way of making your code explicit my moving the logic into your app and doing something like

var record=DataAccess.GetRecord(key);
if(record == null)

But then you’ll be losing the power of using the database do that for you.

So what I’m suggesting is just making your naming better, for example: DataAccess.ReplaceRecord(data).

comment 0

Make the Ugly Scrollbars on your Facebook App Disappear

If you have annoying scrollbars around your Facebook app’s canvas, here’s what you need to do:

First, go to your app’s settings, click “Edit App” and then “Advanced” on the right.

Scroll all the way down to “Canvas Settings” and change “Canvas Height” to “Settable”.

Second, add a call to FB.Canvas.setSize() ( Make this call inside window.fbAsyncInit, after calling FB.init.

That’s it! Gorgeous app, no scrollbars!

comment 0

Adaptive Payments Error This transaction has already been approved

If you’re using the PayPal Adaptive Payments API in sandbox mode, redirecting the user to and getting the following error:

This transaction has already been approved

The problem may be that you’re using an incorrect sandbox user as the “sender” in the transaction.

You need to go to the sandbox ( and then to “test accounts” on the left.

You need to create a test account. Click “preconfigured” next to “new test account” and then make sure you select “buyer” under “account type”.

Now use the email of this account that you’ve just created as the “senderEmail” in the call to the “Pay” API operation.

comment 0

Jack Abramoff on How to Own The System

“When we would become friendly with an office,” he explained, “and they were important to us, and the chief of staff was a competent person, I would say or my staff would say to him or her at some point, ‘You know, when you’re done working on the Hill, we’d very much like you to consider coming to work for us.’ Now the moment I said that to them or any of our staff said that to ‘em, that was it. We owned them.”

Amazing stuff on the Jack Abramoff story.

comment 0

Hiking the Fjordruta in Norway

The Fjordruta is a great multi-day hike in the west of Norway. It has a little bit of everything: fjords, forests, mountains. The whole trail can take about two weeks but you can do as little as a couple of days.

The best time is summer. I did 3 days in late September: the conditions weren’t perfect but not too bad either. I had two overcast days with some rain and one sunny day. The ground is very wet so waterproof hiking boots will really be worthwhile.

The trail is well marked and there are unmanned, fully stocked cabins along the way. What the cabins have: food, gas, cooking gear, fireplace, beds with pillows and blankets, shower, toilet, water. This means that you don’t need to carry anything with you.

You need a special key to open the cabins. You can buy this key from the Norwegian Trekking Association (DNT) and from some tourist information offices. I don’t know how much it costs because I got mine from a friend. The price of the key is just a deposit so you can return it and get your money back.

You pay for the stay in the cabin and for the food you consumed by filling out a form and leaving it in a box in the cabin. They charge your credit card. A night costs 290NOK for non-members of DNT and 190NOK for members. It may be worthwhile signing up for DNT if you plan on spending more than a few nights, I didn’t check.

Getting there

From Oslo, you need to get to Kristiansund. You can either take a bus via Molde or a flight to Molde, then a bus to Kristiansund. Norwegian has some cheap flights and often a morning flight to Molde will be cheaper than the bus. The bus costs 690NOK from Oslo to Molde and when I went there I found a morning flight for 500NOK from Oslo to Molde. The flight is about 40 minutes, the bus is about 8 hours. The Oslo-Molde bus goes twice a day, in the morning and in the evening.

The bus from Molde to Kristiansund costs 140NOK and takes about an hour and a half. It also stops at the Molde airport and leaves every hour.
After getting to Kristiansund you need to get to Tommervag to start the trail. You do this by taking a bus from the Kristiansund bus station (Traffikterminal) to Tommervag. This bus uses a fairy to get to Tommerweg and also leaves about once an hour. It takes about 1 hour to get to Tommervag.

The trail

I used a trail map for the Fjordruta that you can get at the DNT offices. It’s from 2004 and it doesn’t have some newly built cabins which I will describe here. The whole trail is pretty strenuous in my view so take this into consideration.

The first cabin is Trollstua. It takes about 2 hours to reach from Tommervag. I didn’t stay there and continued directly to the next cabin, Gullsteinvollen. This took about 5 hours of very fast and hard hiking from Trollstua, so take this into consideration. Both Trollstua and Gullsteinvolen were built in 2006 and do not appear on the 2004 map.

On the second day I continued from Gullsteinvolen to Imarbu. This also took about 5 hours of fast and strenuous walking. Imarbu is right on the fjord and it’s really pretty. This was my favorite cabin.

On the third way I hiked from Imarbu to Nersetra. This also took about 5 hours. Nersetra is not as nice but it has hot water for shower because it’s next to some administrative building of the KNT (Kristiansund trekking association) that has electricity.

From Nersetra you can hike to Aure in about 2 hours and then take the bus back to Kristiansund. I didn’t do this because I was lucky to get a ride from Nersetra back to Kristiansund with a KNT employee that happened to also spend the night at Nersetra.

Don’t worry about getting back at any point between Tommervag and Aure because there are bus stops in many places where the hiking trail crosses a road. I don’t know about the rest of the trail, from Aure and on, but I assume it’s similar.

comment 0

Launching Cohaico Beta

A little less than three months ago I started working on my new project, Cohaico, and today I’m launching the public beta of the website. From the announcement post on the Cohaico blog:

Let us fix that for you.

Guess what – your friends are already sharing everything they know about stuff. They do it on social networks like Twitter.

But if you get on Twitter – you’ll just see what was said in the last few hours or so. It’s hard to see what all your friends said about a particular thing.

This is what Cohaico does.

Exciting times!

comment 0

San Francisco

People are zombies

Everybody’s on their iPhone, all the time. I find it kind of troubling. We’re soooo headed at The Matrix. And when it happens, 5-10 years from now, it won’t be all violent skynet-style-war-with-the-machines-kind-of-thing. When Steve Jobs comes up with the iThing that plugs via USB directly into your brain – people will just line up to get that $499 piece of crap.

People on their iPhones


This place is a bubble. And I don’t mean “startups are being funded too easily” bubble. Which is also true. I mean that people are just so into everything internet, that any kind of stupid idea flies. Which is pretty dangerous because the rest of the world just don’ work dat way ™.

I mean, homeless people ask you for help with Twitter API here…


I mean I knew about the (fake) Mark Twain quote and everything, and still I came dressed as if this is Israel. Please remember: San Francisco is cold. So get your warm (a.k.a. in Israel “winter”) clothes, even in the summer.

On the other (better) hand: South Bay is warm.

Getting around

The San Francisco bus/tram system is really useful. You should get yourself a “clipper” which is a rechargeable card to save the trouble of trying to find change and all. Clippers are sold at Walgreens. I don’t know why. I guess it’s because they’re everywhere. But then again so are Starbucks. I guess Starbucks said “fuck off”.
Get yourself a monthly one for $62 which is the best deal for anywhere from 2 weeks and up.

Getting down to the South Bay (Palo Alto, Mountain View and the such) is trickier. You can take the Caltrain but then you’re most likely need a cab too. I really recommend signing up for Zipcar. They have cars everywhere and is the best-value option for when you need a car for a few hours. If you have an Israeli driver’s license you’ll need to produce some papers from the Ministry of Transport. I am in the process of doing it, will update…

Use a coupon for some free hours too.

Getaround sadly don’t work with Israeli licenses at this point.

Update (July 22nd): Getting to meetings specifically in Palo Alto is doable with a Caltrain as the station is within 10 minutes walking of most locations on University Ave (this is where your meeting is going to be). Pro tip: schedule for half-past as Southbound trains get to Palo Alto at :03 past every hour between 10am and 4pm which gives you a good 30 minutes to walk there, then if you manage to end your meeting in 50 minutes you have 20 minutes to walk back to the train back that leaves at :41 past every hour (tip by @rutipo).

Hitting the meetups

Finding geeks/founders/investors/hackers in a social environment is super easy. Check out and Startup Digest for a ton of events. After a week you’ll start recognizing faces…

Working space

The city is full of coworking spaces. I am working out of Next Space which is great – nice people, great location and good facilities. Lots of activities (kind of like The Junction back home :)). I didn’t do any extensive research but some people I talked to did and they settled on Next Space so I guess it’s fine. Reasonably priced too, at $285/month.

comment 0

Some Early Lessons Learned Working on Cohaico

Over on the Cohaico blog, I wrote about some things I learned during the first months of working on a new startup:

Products that succeed? They are the ones that got the crazy distribution by getting people to use their service, other companies to partner with them etc.

On the outside, this often looks like “destiny” or “force majore”. You built such a kick-ass product that people are just magically drawn to it.

Bullshit. Nothing happened by itself. Every successful product came to be because somebody, deliberately, carefully and thoughtfully kicked ass doing sales and did it better than the competition.

Read more.

comment 0

How to Scare the Shit out of a QA Person in 3 Easy Steps

Google Chrome (and now also Firefox 4) have the useless little feature of allowing the user to resize any <TEXTAREA> on a page.
I’ve found the perfect use case for it:

1. Go to a page in your website that contains a <TEXTAREA>, like my Delver profile page:

2. Drag the corner of the <TEXTAREA> until reaching a particularly obnoxious appearance:

3. Now make a screenshot and send an email to your favorite QA person.
This is the part where you should really get creative. Here’s my suggested format:


OMG crazy UI bug in profile page – ON PROD!!


Hi [QA person name],
Check this out (found on my profile page in PROD).

I can’t *believe* we missed this and let it reach production this way. Please handle ASAP. Bug should be assigned as “critical”!

[Your name here]

You should also CC the QA team manager on this.

comment 0

Code Sample: Consuming the Twitter Streaming API

Here’s a c# example of consuming the Twitter Streaming API.
Suppose you want to take all Tweets mentioning a country and save it to a database.
I will be using the Twitterizer c# library. Let’s first look at the complete code and then walk through it:

private static bool streamEnded = false;
public static void HandleStream()
  DateTime end = DateTime.Now + TimeSpan.FromSeconds(60);

  OAuthTokens tokens = new OAuthTokens { ConsumerKey = “YOUR_KEY”, ConsumerSecret = “YOUR_SECRET”, AccessToken = “ACCESS_TOKEN”, AccessTokenSecret = “ACCESS_TOKEN_SECRET” };
  TwitterStream s = new TwitterStream(tokens);
  s.OnStatusReceived += new TwitterStatusReceivedHandler(s_OnStatusReceived);
  s.OnStreamEnded += new TwitterStreamEnded(s_OnStreamEnded);
  FilterStreamOptions ops = new FilterStreamOptions { Track = new List<string> { “italy”, “germany”, “spain”, “france”, “england” } };

  while (DateTime.Now < end && !streamEnded)

static void s_OnStreamEnded()
   streamEnded = true;
static void s_OnStatusReceived(Twitterizer.TwitterStatus status)

Now let’s look at the code in depth. First, as we’ll be processing tweets in a loop, let’s set an end to our loop. Let’s say we want to process tweets for 60 seconds:

DateTime end = DateTime.Now + TimeSpan.FromSeconds(60);

Next, we setup the Twitterizer class used to handle the Streaming API:

OAuthTokens tokens = new OAuthTokens { ConsumerKey = “YOUR_KEY”, ConsumerSecret = “YOUR_SECRET”, AccessToken = “ACCESS_TOKEN”, AccessTokenSecret = “ACCESS_TOKEN_SECRET” };
TwitterStream s = new TwitterStream(tokens);

The class TwitterStream is part of the “addons” to Twitterizer, so you will need to download the source of the 2.3.2 release of Twitterizer and make a small fix as I described here.
You will pass to TwitterStream the app keys of your Twitter application which you set up here and the OAuth tokens.
Next, we set up event handlers for the stream of tweets:

s.OnStatusReceived += new TwitterStatusReceivedHandler(s_OnStatusReceived);
s.OnStreamEnded += new TwitterStreamEnded(s_OnStreamEnded);

s_OnStatusReceived will be called by TwitterStream when a tweet is received from Streaming API and s_OnStreamEnded will be called when the connection to Twitter ends.
Next, we may add some options to the Streaming API. There are several methods to access the Streaming API: you can either get tweets for a list of keywords, a list of users or a random sample of all tweets. In our example, let’s ask Twitter for tweets mentioning a country and open the connection:

FilterStreamOptions ops = new FilterStreamOptions { Track = new List<string> { “italy”, “germany”, “spain”, “france”, “england” } };

The last thing to do is wait for the amount of time we decided on in the beginning and then close the stream:

while (DateTime.Now < end && !streamEnded)