Monthly Archives: May 2015

May 13, 2015

Bloom Filter for JavaScript

I wrote a very fast bloom filter implementation in JavaScript called bloomfilter.js. It uses the non-cryptographic Fowler–Noll–Vo hash function for speed. We can get away with using a non-cryptographic hash function as we only care about having a uniform distribution of hashes.

The implementation also uses JavaScript typed arrays if possible, as these are faster when performing low-level bitwise operations.

stamp

Format dates and times based on human-friendly examples, not arcane strftime directives.

Such tools should be available for every language under the sun.

May 12, 2015

An oldy but a goody: save the following into a file called Hello.java. It will compile just fine and if you run it, it will print Hello, World! to standard output.

/*u002Au002Fu0070u0075u0062u006Cu0069u0063u0020u0063u006Cu0061u0073u0073u0020u0048u0065u006Cu006Cu006Fu007Bu0070u0075u0062u006Cu0069u0063u0020u0073u0074u0061u0074u0069u0063u0020u0076u006Fu0069u0064u0020u006Du0061u0069u006Eu0028u0053u0074u0072u0069u006Eu0067u005Bu005Du0020u0061u0072u0067u0073u0029u007Bu0053u0079u0073u0074u0065u006Du002Eu006Fu0075u0074u002Eu0070u0072u0069u006Eu0074u006Cu006Eu0028u0022u0048u0065u006Cu006Cu006Fu002Cu0020u0057u006Fu0072u006Cu0064u0021u0022u0029u003Bu007Du007Du002Fu002A*/

This is because according to the Java Language Specification (JLS 3.2, specifically), Unicode escapes must be translated by the compiler before just about any other operation, including stripping comments.

Here’s what the code looks like prettified and with translated escapes:

/**/
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}
/**/
May 11, 2015
May 8, 2015

Keurig says it was wrong to force users to buy single-serving pods

Last year, Keurig drew the ire of the Internet by incorporating a scheme similar to the Digital Rights Management (DRM) you see on e-books and video games into its Keurig 2.0 coffee maker. The next-generation machine forced users to brew with Keurig-approved coffee pods exclusively, using a digital scanner that looks for an ink marker on authorized K-cups. The company also discontinued its “My K-Cup” reusable pod, which meant that customers could no longer use their own coffee in a Keurig.

Good to see them finally acknowledge what a shitty idea this was.

May 6, 2015

Hound

Hound is an extremely fast source code search engine. The core is based on this article (and code) from Russ Cox: Regular Expression Matching with a Trigram Index. Hound itself is a static React frontend that talks to a Go backend. The backend keeps an up-to-date index for each repository and answers searches through a minimal API.

From the engineers at Etsy. To say this kind of tool is useful is a bit of an understatement.