MoinJS: rapid JavaScript micro service development

If you’re into node.js and micro services you should check out MoinJS by Torben Hartmann. It’s a fairly young project that is basically an application server with everything you need:

  • a service registry
  • an event system with timeouts, filters and all the snazz
  • extensibility
  • and automatic code reload

Especially the latter will save you time and nerves 🙂

Official page:
npm package:

String cast VS toString() VS String.valueOf()

A quick post about creating string objects from other objects. Here are my two key takeaways:

1. (String) cast is the fastest
If you’re 100% sure that an object is – and can only be – a string, a cast is the quickest option. This answer on stackoverflow suggests that the reason for this is that casting is a feature of the JVM itself while toString() and String.valueOf() are Java functions executed in the JVM runtime just like all Java bytecode. The JVM docs indicate that casting is part of the JVM’s instruction set.

Casting is not the same as a conversion. It’s a message to the compiler to treat an object as a different kind of object (check this answer on stackoverflow).

There is a benchmark on Cowtowncoder’s blog that suggests that casting is twice as fast as toString(). That said – it’s still pretty darn fast. You shouldn’t use casting for the sake of performance if you’re dealing with a string object.

2. String.valueOf() is safer than toString()
Calling myObject.toString() will throw a NullPointerException if myObject turns out to be null. Doing a

String myString = String.valueOf(myObject);

will not be problem if myObject is null, since String.valueOf() will check if the parameter is null before doing a myObject.toString() conversion. If myObject is null the String.valueOf() function will simply return null.

That seems very convenient, but it will not make a big difference in your code. If you use toString() and check for null before that, you’ll be fine. On the other hand, with String.valueOf() you will have to check for null afterwards, because you want use that string reference for something (why else create it?). So you will have to check if it’s null… I see nothing gained here – it’s a matter of taste.

Which Java process runs which application?

If you’re running more than one Java application the ps commandis not enough. It will list the Java processes, but not which Java process runs which Java application. The jps comes with the JDK and is your friend!

Found on StackOverflow in a post by user Nicolas Shushkin.

C and assembly on the Raspberry Pi

The Raspberry Pi is known for being a cheap and versatile board with lots of different use cases. It’s also an interesting device to get your feet wet with embedded programming since all you need is an SD card reader. Other systems usually require a dongle to flash your code to the device.

There are a few ressources for “bare metal” programming on the Raspberry Pi without any pre-installed operating system.

There’s also a Raspberry Pi emulator available and someone created a bare metal StarFox 64 remake demo.

I’d love to see some resources for the ODROID-X2 which has a lot more juice…

STICS: Improved web search backed by knowledge database

STICS is an interesting Internet search developed by the Max-Planck-Institute for Informatics. It is drawing information from knowledge database YAGO2 to refine and enrich your search experience. YAGO2 has been compiled from websites like Wikipedia to enable programs to discern different entities (i.e. persons, cities, countries, soccer teams, …) and how these are related to one another (i.e. a person is born on a specific date in a specific city).

Additionally, it is aware of categories of entities. For example, Angela Merkel belongs to the categories German physical chemists as well as German politicians. Through this knowledge the search engine is also aware of synonyms like “Chancellor of Germany” for Angela Merkel.


Use serial port as regular user in Ubuntu

By default a regular user does not have permission to use the serial port. In my case I wanted to use two USB-to-serial adapters:

By looking at output you can see that the owning group is dialout. So it is a matter of adding your user to that group (and logout/login as with every user rights change). The bash environment variable $USER contains your username.

Found on the Ubuntu help pages.

Identical acronyms with different meaning

Neat 🙂 LaTeX is really solid. There’s a solution for every problem…

Found this post by user cgnieder.