Tag Archive: code


Here’s my entry for the The Daily WTF‘s Programming Praxis: Russian Peasant Multiplication:

function peasant1(a, b) {
  var value = a & 1 ? b : 0;
  while(a > 1) {
    a >>= 1;
    b <<= 1;
    if (a & 1)
      value += b;
  }
  return value;
}

function peasant2(a, b) {
  var value = a & 1 ? b : 0;
  if(a > 1)
    value += peasant2(a >> 1, b << 1);
  return value;
}

function peasant3(a, b) {
  return a > 1 ? (a & 1 ? b : 0) + peasant3(a >> 1, b << 1) : a & 1 ? b : 0;
}

function peasant4(a, b) {
  return a & 1 ? value = a > 1 ? value = b + peasant4(a >> 1, b << 1) : b : value = peasant4(a >> 1, b << 1);
}

Unicode character 2026 – “Horizontal Ellipsis”

In Windows: Alt-0133

In Java: \u2026
Example:
String ellipsis = "\u2026";

In HTML: &#8230; or &#133; or &hellip;
Example:
… or … or …

In Javascript: \u2026
Example:
var ellipsis = "\u2026";
alert(ellipsis);

Ricola log: \u2026
Example:
Ricola.log.debug("\u2026")
will output 11:31:08 DEBUG - …

Ricola showPleaseWait: any of the HTML entities: &#8230; or &#133; or &hellip;
Example:
Ricola.page.showPleaseWait("Creating train documents&hellip;");

I love this kind of stuff.


Excerpts:

Wife
It’s a subclass of girlfriend that has unlimited access to your private members but doesn’t make good use of it, hogs all available resources, and spawns child processes that you aren’t allowed to kill off. – Pesto
All views expressed here are of Adam Koch solely and do not represent his employer's.