Peasant Multiplication

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);
}

Ellipsis

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;");