Archive for June, 2007


Introducing my 1st Facebook app, Platypus

For those of you who were wondering about the Facebook application that I wrote about yesterday, you can now see it live on Facebook. If you don’t want to install it, you can click here to see a screenshot from my facebook profile.

As I mentioned in my last post, Platypus isn’t what I’m working on this summer. If it takes off, great! If not, it’s not going to hurt my feelings. Platypus was just something I threw together in a few hours to explore the capabilities of the new API.

I must say that I’m already intrigued by the viral nature of these new Facebook applications. I just released the application this morning, but every time I log on to Facebook I find 3 or 4 more strangers who have added Platypus to their profiles. I have no idea how so many people are finding it! It’s going to be interesting to see what happens once the application gets approved for the public directory.

Don’t worry. I’ll be posting lots of insider statistics along the way as more people keep adding my Platypus to their profiles.

 5 comments

The side project

Perhaps it’s inevitable anytime you get a bunch of smart people working together in one place. We live in a world where new opportunities abound and intelligent minds are overflowing with dreams of how to seize them. As an entrepreneur, you see the world, not as it is now, but how it could be. Everywhere you look, you see things that could be done better. There’s something in your nature that wants to jump at every opportunity you have.

So you have a new idea, but unfortunately it doesn’t fit into your company vision. It’s just a good idea that you know you can execute. Perhaps it’s enticing you with the promise of quick results and easy money, or maybe it’s just more fun than what you’re working on now. Either way, you get caught up in the excitement and before long a new entity is born: aka, the side project.

Over the weekend I had an idea for my own side project. It’s something that I have wanted to build for a long time and the release of the new Facebook API suddenly made it possible. I spent my day yesterday pursuing the idea, before coming to the conclusion that this isn’t the right time to be working on it. A big influence in this decision was the book Good to Great by Jim Collins. I went back and reread chapter 5 this morning. This time, the illustration about the fox and the hedgehog really hit home.

I can’t afford to let anything (not even a great idea) take focus away from what we are really doing this summer.

I know of several other teams at TechStars that working on side projects right now. That’s okay – your idea is probably more on target than mine was. My only challenge for you is to look at your goals and make sure your project is taking you closer to them instead of further away. You see, that’s the problem with side projects – they tend to distract us from what we first set out to do. They make us lose focus and we become scattered, diffused, and inconsistent in our vision.

As Jim Collins said, it is better to know only one big thing than to know many things. Go find that one thing that you can be great at, and focus all of you attention on that.

 1 comment

Auto detect a time zone with JavaScript

This blog post will attempt to explain how to automatically detect your user’s time zone using JavaScript. If you’re in a hurry, you can skip directly to the JavaScript timezone detection code on Github.

Previous attempts to solve this problem:

Server side:

Time is not included in an HTTP request. This means that there is no way to get your user’s time zone using a server side scripting language like PHP.

IP address geocoding:

Another method that people have used to address this problem is to geocode your visitors IP address. IP geocoding is what is used when you go to a website and are shown an ad to “meet other singles in Boulder”. Unfortunately, for simply detecting a timezone, IP geo-coding is an expensive way to go. Just check out the prices for Maxmind and ip2location. There’s no way I’m paying for that. I did find a free provider called hostip, but it is worthless as it couldn’t decide whether I live in CA or NC.

With JavaScript:

The common JavaScript that is used to detect a visitor’s timezone is:

var myDate = new Date();
document.write(myDate.getTimezoneOffset());

As I started reading up on the getTimezoneOffset code I realized it was too buggy to be used in any critical application. The function returned inconsistent results in different browsers and it never seemed to account for daylight saving time correctly. It quickly became clear that I was going to have to write my own script if I wanted this to work.

How I ended up doing it:

There are basically two things needed to figure out a visitor’s time zone. First, we need to determine the time offset from Greenwich Mean Time (GMT). This can easily be done by creating two dates (one local, and one in GMT) and comparing the time difference between them:

var rightNow = new Date();
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
var temp = jan1.toGMTString();
var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);

The second thing that you need to know is whether the location observes daylight savings time (DST) or not. Since DST is always observed during the summer, we can compare the time offset between two dates in January, to the time offset between two dates in June. If the offsets are different, then we know that the location observes DST. If the offsets are the same, then we know that the location DOES NOT observe DST.

var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
temp = june1.toGMTString();
var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
var dst;
if (std_time_offset == daylight_time_offset) {
    dst = "0"; // daylight savings time is NOT observed
} else {
    dst = "1"; // daylight savings time is observed
}

Once I had this code written, the next step was to compile a list of the various time zones around the world along with their opinions on DST. I actually ended up using the list of time zones from Microsoft Windows. It was rather time consuming to compile this list, so I hope you can make use of my work to save yourself some time.

Please let me know if you have any comments, questions or problems with this code. As with anything that I post on this blog, feel free to use this code however you want. Just don’t blame me if it breaks.

Update (06/27/07):

My code wasn’t correctly detecting timezones in the lower hemisphere. I have added hemisphere detection for all our Aussie friends out there. I also fixed a bug in the convert() function that was leaving off the + sign at certain offsets. Thanks Val for pointing this out and helping me with the fix.

Update (10/24/08):

Fixed the bug that Rama and Will pointed out in the comments.

Update (12/22/10):

Jon Nylander has taken my original code and written a a more robust solution. Use his version instead.
 133 comments

Beautiful new design from OrangeCoat

Evan Tishuk from OrangeCoat just sent me a link to the new site they designed for Wilderness Systems. Evan, I believe you outdid yourself this time. That design is beautiful!

Evan is one of those people that I hope to hire someday. I’m saving up, ’cause he’s worth a lot. Not only is he an amazing designer, but he’s also a great entrepreneur. Evan, I’m looking forward to building something cool together one of these days. Just let me know when you’re ready to start. 🙂

 1 comment