God is in Emacs

So I was going to my friend’s place to pick up some stuff and then suddenly I got this urge to do some programming. It was weird and awesome, at the moment I really wanted to write some code, not matter what — just code.

Luckily I live almost next door so I ran back to my apartment and worked for a little bit. Feels good now, although that feeling is still with me.

Comments

Lost stashed changes

Just lost my stashed changes. This will be a lesson to make a lot of small commits instead of a single big one.

Comments

That is right, Rob Pike signed my copy of The Practice of Programming.

That is right, Rob Pike signed my copy of The Practice of Programming.

Comments

The Go Programming Language

Was in a discussion with Andrew Gerrand and (!!!) Rob Pike about Go earlier today and as a result, I am much more interested in it now.

Comments

High Performance JavaScript

This is a very nice book with tons of interesting tips and tricks.

Comments

The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. —John Carmack

Another way to restore built-in method in Chrome/Safari

A short follow-up to this post. Apparently, both Chrome and Safari restore built-in method if you try to delete it from the prototype. In other words:

Array.prototype.map = null;
[].map
> null

delete Array.prototype.map
[].map
> function map() { [native code] }

Comments

Brewer’s CAP Theorem

Brewer’s Theorem is pretty neat. It essentially states that you cannot have a clustered system that supports consistency, availability and partition-tolerance at the same time. So, if you want to build a nice clustered system you have to stop partitions from happening, or accept the fact that from time to time affected services will either be unavailable or inconsistent.

Eric Brewer presented this theorem in 2000 and two years later it was proved to be correct by Seth Gilbert and Nancy Lynch of MIT.

I was introduced to this theorem through a pretty good article by Julian Browne: Brewer’s CAP Theorem. Also, there is another interesting article—A CAP Solution (Proving Brewer Wrong)—in which author claims that consistency, availability and partition-tolerance is possible if we loosen the at the same time condition.

Comments

ACM ICPC 2010 World Finals

Gold medals go to teams from Shanghai Jiaotong, Moscow State, National Taiwan and Taras Shevchenko Kiev National universities.

Comments

Quick JavaScript profiling

The text below was posted on my old blog in August, 2008. Since I still use this technique, I think it is worth moving it here.

Sometimes, you need to know how many times a function was executed and how much time did it take. It is not a problem if you have good profiling tools, but sometimes they are not available. A few months ago I was optimizing my code in some very early Fx3 build and the tools I use were not ready yet (Firebug was too buggy to use and Venkman didn’t work at all). So I was on my own. Fortunately, in javascript, you can monkey patch already created functions and insert your profiling code there:

function p_register(func_name) {
  var func = window[func_name];
  var h_name = "__" + func_name + "__";
  window[h_name] = func;
  window[func_name] = function() {
    // start profiling
    var result = window[h_name].apply(window, arguments);
    // store profiling results
    return result;
  };
}

In the code above, I’ve copied the function and replaced the original with a new one which contains my profiling code and a call to the hidden copy. So, every call to a function I wanted to profile was counted. As for the bottleneck, it was about prototype.js, its `Element.hasClassName` method and elements extension: it was too expensive to use them with a lot of elements, so I wrote a tiny func which acted just as `.hasClassName` but without element extension.

Comments

Want more?

1 2 Older

Full archive