What is the best way to profile javascript execution?

Firebug Firebug provides a highly detailed profiling report. It will tell you how long each method invocation takes in a giant (detailed) table. You need to call console.profileEnd () to end your profile block. See the console API here: http://getfirebug.com/wiki/index.php/Console_API Blackbird Blackbird (official site) also has a simpler profiler (can be downloaded from here)

What is a unicode string?

Update: Python 3 In Python 3, Unicode strings are the default. The type str is a collection of Unicode code points, and the type bytes is used for representing collections of 8-bit integers (often interpreted as ASCII characters). Here is the code from the question, updated for Python 3: Working with files: Historical answer: Python 2 In Python 2, … Read more

Changing the image source using jQuery

You can use jQuery’s attr() function. For example, if your img tag has an id attribute of ‘my_image’, you would do this: Then you can change the src of your image with jQuery like this: To attach this to a click event, you could write: To rotate the image, you could do this:

What is the difference between random.randint and randrange?

The docs on randrange say: random.randrange([start], stop[, step]) Return a randomly selected element from range(start, stop, step). This is equivalent to choice(range(start, stop, step)), but doesn’t actually build a range object. And range(start, stop) returns [start, start+step, …, stop-1], not [start, start+step, …, stop]. As for why… zero-based counting rules and range(n) should return n elements, I suppose. Most useful for getting a random index, I suppose. While randint is documented … Read more

Can’t understand the working of getint() in C as per K&R

The getint() function only reads digits from the input. If it gets a character that is not a digit or a + – sign at the beginning it will call ungetch() to push the character back into the input buffer so it could be read by some other function call. getint() will go on returning … Read more

Categories c Tags