Modern Programming

This is the code for a Mozilla Extension to get its version number out of its own configuration:

try {
  // Firefox 4 and later; Mozilla 2 and later
  AddonManager.getAddonByID("extension-guid@example.org", function(addon) {
    alert("My extension's version is " + addon.version);
} catch (ex) {
  // Firefox 3.6 and before; Mozilla 1.9.2 and before
  var em = Components.classes["@mozilla.org/extensions/manager;1"]
  var addon = em.getItemForID("extension-guid@example.org");
  alert("My extension's version is " + addon.version);

This is one twitter session id:


This is a part of the Wikipedia Page for Jabber:

Because XMPP is not yet encoded as Efficient XML Interchange but as a single long XML document, binary data must be first base64 encoded before it can be transmitted in-band. Therefore any significant amount of binary data (e.g., file transfers) is best transmitted out-of-band, using in-band messages to coordinate. The best example of this is the Jingle XMPP Extension Protocol, XEP-0166.

This is Java code that does absolutely nothing at all:

public class ServerFacade
    public <K, V> V respondToRequest(K request, DAO dao) {
        return dao.getData(request);

This is a new way to implement singletons in PHP 5.4, using a feature called "traits":

trait Singleton {
  public static function getInstance() { ... }
class MySingleton extends SomeUnrelatedSuperClass {
  use Singleton;

This is a sane API to retrieve a version number:

version_number = config.version;

This is a number a hundred times bigger than the current world population in hexadecimal:


This picture was transmitted in a binary form, over HTTP:

This is - among others - Java, Javascript, C and C++ code that does nothing at all:


This is a global, stateful object in PHP (any version):


People are strange.

comments powered by Disqus