Binomial Coefficients

I have found myself writing a program the needs getting at hand a whole range of binomial coefficients from C(0,0) to C(n,m) for some given values of n and m.

In this case the most efficient way to get them is by using the Pascal’s triangle (triangolo di Tartaglia, in Italy).

I wrote this java class that implements it, with a few optimizations to avoid storing obvious values.
Each coefficient is stored as a BigInteger.
Continue reading

adsttnmq1/sdioyslkjs2 attack

I’ve just found the my website has been hacked.
I’ve found a new directory “guiex” (but the name can change) containing two files: “m” a text file just listing “index.php” and a php file named “mnq.php” (the code of this file is at the end of this post).

Now we have two questions to answer:
1) How the hell these files have arrived here?
2) What the f**k are these files doing here?
Continue reading

Small Javascript, great annoyance

What happens if a browser loads an HTML page like this one?

<html>
<head>
<title>Test 1</title>
<script language="JavaScript">
while(true);
</script>
</head>
<body>
</body>
</html>

Or this one?

<html>
<head>
<title>Test 2</title>
<script language="JavaScript">
while(true)
    alert("free porn movies one click ahead ;) ");
</script>
</head>
<body>
</body>
</html>

Or this one?

<html>
<head>
<title>Test 3</title>
<script language="JavaScript">
var x = new Array();
var y = x;
while(true) {
	y[0] = new Array();
	y = y[0];
}
</script>
</head>
<body>
</body>
</html>

Continue reading

Keeping things in (partial) order

I this thread I will discuss about making order in our life… well… at least in a long vector of objects… OK, just a small part of that vector.

This is a fundamental aspect of search engines: you are interested in getting only the k most relevant results, whatever the size of the collection you are searching on is.
The k value is usually very small with respect to the collection size, e.g. on the Web one is likely to look at just the first ten-twenty results. Search engines typically set a z value of maximum returned results that is designed to be larger than the largest part of possible k values, e.g. Google returns at most one thousand results.
Continue reading