I just ran into a problem with setTimeout and setInterval. Turns out the delay (in milliseconds) for these functions is a 32 bit signed quantity, which limits it to 231-1 ms (2147483647 ms) or 24.855 days.

I was writing an application that needed a 30+ day delay and my setTimeout callbacks were firing instantly. Here's code that demonstrates it:

setTimeout(function () {
  alert("doesn't work - instant alert");
}, 30 * 24 * 3600 * 1000) // 30 days (more than 2^31-1 milliseconds)

This doesn't work. Delay value overflows and setTimeout fires immediately.

I wrote my own setTimeout_ that wraps around native setTimeout and allows large delays:

function setTimeout_ (fn, delay) {
    var maxDelay = Math.pow(2,31)-1;

    if (delay > maxDelay) {
        var args = arguments;
        args[1] -= maxDelay;

        return setTimeout(function () {
            setTimeout_.apply(undefined, args);
        }, maxDelay);

    return setTimeout.apply(undefined, arguments);

This function preserves arguments and you can clearTimeout it within first 24.855 days.

I'll leave getting clearTimeout to work after 24.855 days as an exercise to my blog readers. And I'll also leave getting setInterval to work with large delay as an exercise.

Until next time!

Last month I launched a new webcomic about web developer jokes. It's called comic.browserling.com. The cartoons are getting very popular and are being viewed tens of thousands of times.

Last week I added a new cartoon called Java Cafe:

The programmer forgot to update Java, so he went to the coffee shop to get a fresh one.

All cartoons are licensed under the CC BY-NC license. You can share, remix, transform, copy, link to, redistribute cartoons and jokes but you can't sell them.

If you like these cartoons, please subscribe to webcomic updates and follow me and @browserling on Twitter!

Until next time!

More exciting news! I've joined Hackers/Founders (H/F) as Hacker in Residence. H/F is the largest network of entrepreneurs in the world with over 200,000 members in 40 countries.


Original blog post on Hackers/Founders blog Welcome to Peteris Krumins, H/F's New Hacker-in-Residence.

Hackers/Founders (H/F) is pleased to announce that Peteris Krumins has been named H/F Hacker-In-Residence. Peteris not only possesses exceptional technical knowledge, but openly shares that expertise with H/F Co-op companies. This appointment acknowledges the value of his ongoing commitment to the H/F community.

The H/F Co-op accelerator is a tight-knit cooperative, where concierge services are provided in exchange for equity, and where founders help each other and elect each other to the program.

Co-op coaches startup founders through a personalized 100+ item checklist. The agenda points founders toward product and pitch development to prepare them for fundraising. When fundraising launches, the Co-op team works with you to set up meaningful contacts with our large curated pool of investors.

It's a great honor to be joining Hackers/Founders. As a Hacker in Residence, I'll be helping H/F community and H/F Co-op startups with any and all possible technical and non-technical problems.

My company, Browserling, was the first company that was accepted in Co-op when it just started in 2011. You can read the full story about how Browserling started and joined H/F in my other blog post How I started Browserling.

My new H/F email is hacker@hf.cx. You can reach me any time. I'll be glad to help with any technical and startup questions that you've, even if you're not a H/F Co-op incubator company. I love helping people!

Onwards and upwards!

Exciting news! Earlier this year I joined a company called June as an advisor and we just launched! At June we're reinventing hiring. Job candidates get paid to hear job offers from the best recruiters in the world.

I know what's on your mind right now. You're probably thinking, why would a recruiter pay to speak with me?

That's a good question. Unfortunately, the recruiting industry's reputation has been tarnished over the years by unqualified individuals mass messaging talented IT professionals. This has pushed candidates away, fearful of these bad apples. We know better, there are great recruiters out there who work for dream companies. They are on June and they value your time. To prove this, they are willing to pay to speak with you.

June's solving a real problem in the recruiting industry and it's been already called the most disruptive tool in recruiting by WGN Chicago! Our launch partners are Amazon, Google, Microsoft, Rackspace, Hubspot, PayPal and several other huge tech companies. Sounds interesting? Go to June and sign up right now!

June was started by Lane Campbell. I've been good friends with Lane for many years. We met through one of my projects Digpicz that I did in 2007. Since then we've kept in touch and Lane's been sponsoring my open source work as well as helping at Browserling.

Here's an interview with Lane Campbell at WGN podcast Tomorrow's Business Today. He talks about his background and how he got an idea to start June.

Lane Campbell at WGN

Lane also recently did a Reddit IAMA where he was asked many tough questions about June, its business model, competitors and other topics.

As an advisor to June I provide advice on engineering, devops, security, marketing and even content publishing. I also help with interviewing and hiring new employees.

I'm very proud of June's team. I'm working with some of the smartest, most intelligent and motivated people. Check out June's about page to see everyone who's currently working at June.

It's been an exciting ride and I can't wait to see where we go next!

Sign up at June!

If you're interested, sign up at June! If you've any questions, check out June's FAQ. For any other questions feel free to reach out to me, peter@catonmat.net, or to Lane Campbell, lane@joinjune.com.

Onward and Upward!

I'll be sharing all exciting things happening at June on my blog, so make sure to subscribe to my blog, follow me on Twitter and follow June on Twitter.

Until next time!

Last Monday I launched a new webcomic about web developer jokes. It's called comic.browserling.com. It's been a lot of fun. The cartoons are getting really popular and are being viewed thousands of times.

I started with five cartoons:

Today, I just added a new cartoon called Where do you want to go today? I'll be adding one new cartoon every week.

Where do you want to go today?

All cartoons are licensed under the CC BY-NC licence. You can share, remix, transform, copy, link to, redistribute cartoons and jokes but you can't sell them.

If you like these cartoons, please subscribe to webcomic updates and follow me and @browserling on Twitter!

This blog post is a repost of A new webdev cartoon: Internet Explorer on Browserling's cross-browser testing blog.