In this post I will present a way of creating a JavaScript-based DoS attack that utilizes the bad implementation of tabs in most (if not all) web browsers. The attack will make the browser unresponsive and force the user to kill its process. This attack is based on the following JavaScript code:
Continue reading A JavaScript DoS Attack
Month: November 2007
C’s “Goes To” Operator
Well, it isn’t really an operator, but this is a nice C code construct I ran into. It doesn’t seem to have any benefit except as a nice way to create a reverse loop:
int count = 100;
while (count-->0) {
//some work
}
As I said, I don’t think I’ll find any performance benefit in using this code snippet. On the other hand, it is always fun to see the puzzled face other programmers have the first time they see the code.
Optimizing for Loops: Reverse Loops
for loops are basic language constructs in many languages. One of the first things to look at when optimizing code is loops, as they do considerable amounts of work (like going through a very large amount of data) in very little code.
If you use a for loop, but you don’t really care about the order in which the loop is executed – to be more precise, if you can afford reversing the loop – you can save quite some time. By reversing the loop, I mean that instead of giving the index values from 0 to 10, for example, you go from 10 downward to zero. This doesn’t seem like a big change, but when carefully implemented, this can easily improve the performance of your for loops.
Continue reading Optimizing for Loops: Reverse Loops