Montag, 24. Februar 2014

Fix bad/wrong colors on external monitor connected to a MacBook

Recently we bought a new Apple MacBook Pro Retina 13’. But after connecting it to an external monitor we were a bit surprised. The colors looked bad and the contrast was low. On Windows the same monitor works fine. After searching the web we found this blog post with instructions to solve the problem. Short answer: The Mac identifies the external monitor as television. After executing the steps described in the blog post, all was looking fine.

Find out if your monitor is identified correctly

  • click on Apple icon upper left corner
  • click on About this Mac
  • click on More info
  • click on system Report
  • click on Graphics/Displays
  • find the section with the external display
  • if there is a setting ‘Television: Yes’, your monitor is identified wrong

How to fix it


http://www.ireckon.net/2013/03/force-rgb-mode-in-mac-os-x-to-fix-the-picture-quality-of-an-external-monitor/comment-page-3

Mittwoch, 11. Dezember 2013

karma-mocha-reporter - Deutsch


Das Testen von Code ist ein fester Bestandteil in unserem täglichen Arbeitsprozess. Für die client-seitigen JavaScript Tests verwenden wir den karma test runner. Dabei laufen die Tests in einem Browser. Die Ergebnisse werden in die Konsole geschrieben. Dazu sind schon einige reporter in karma integriert. Wir wollten aber eine etwas hübschere Ausgabe. Kein Problem dank der Plugin Architektur in karma. Also haben wir einen eigenen reporter entwickelt.

So sieht das Ergebnis aus




Installation

$ npm install karma-mocha-reporter

Verwendung

Die Konfiguration ist wirklich einfach und wird über die config Datei von karma gemacht. Man fügt 'mocha' in das reporters array und 'karma-mocha-reporter' in das plugins array ein. Hier eine beispielhafte karma config Datei.

// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],

    // reporters configuration
    reporters: ['mocha'],

    plugins: [
      'karma-jasmine',
      'karma-mocha-reporter'
    ]
  });
};

karma-mocha-reporter - English


Testing is an important task of our daily work. For the client JavaScript tests we use the karma test runner. It runs all the test in a real browser. The results are logged in the console. There are some reporters included, but we would like to have a more ‘fancy’ one. Thanks to the plugin architecture of karma it is an easy task to create a new reporter.

So how does it look like




Install

$ npm install karma-mocha-reporter

Usage

So the configuration is really simple. It is all done in the karma config file. You just add 'mocha' to the reporters array and 'karma-mocha-reporter' to the plugins array. Here is a sample karma config file.

// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],

    // reporters configuration
    reporters: ['mocha'],

    plugins: [
      'karma-jasmine',
      'karma-mocha-reporter'
    ]
  });
};

Dienstag, 12. November 2013

log4js-node-mongodb appender - English



We are using log4js-node for logging in our node.js applications. It includes a bunch of log appenders, like console or file. But since we need an audit trail in our applications, we have to log into the database. So we wrote a log4js-node appender for logging into mongodb.

Install

Business a usual…
$ npm install log4js-node-mongodb

Usage

You can use this appender like all other log4js-node appenders. It just needs the connection-string to the mongo db. The default collection used is log. You can log a string or any kind of object. The objects are stored as they are and not converted to strings.
var log4js = require('log4js'),
    mongoAppender = require('log4js-node-mongodb');

log4js.addAppender(
    mongoAppender.appender({
        connectionString: 'localhost:27017/logs'
    }),
    'cheese'
);

var logger = log4js.getLogger('cheese');
logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Gouda.');
logger.warn('Cheese is quite smelly.');
logger.error('Cheese is too ripe!');
logger.fatal('Cheese was breeding ground for listeria.');

// log objects
logger.info({id: 1, name: 'wayne'});
logger.info([1, 2, 3]);
Or you can use the configure method.
var log4js = require('log4js');

log4js.configure({
    appenders: [
        {
            type: 'console'
        },
        {
            type: 'log4js-node-mongodb',
            connectionString: 'localhost:27017/logs',
            category: 'cheese'
        }
    ]
});
The log data is stored in the following format.
{
    _id: ObjectID,
    timestamp: loggingEvent.startTime,
    data: loggingEvent.data,
    level: loggingEvent.level,
    category: loggingEvent.logger.category
}
Here some examples.
var log4js = require('log4js'),
    mongoAppender = require('log4js-node-mongodb');

log4js.addAppender(
    mongoAppender.appender(
        {connectionString: 'localhost:27017/logs'}),
    'audit'
);

var logger = log4js.getLogger('audit');
logger.debug('Hello %s, your are user no %d!', 'wayne', 10);

// saved as
{
    _id: new ObjectID(),
    timestamp: new Date(),
    data: 'Hello wayne, your are user no 10!',
    level: {
        level: 10000,
        levelStr: 'DEBUG'
    },
    category: 'audit'
}

logger.info({id: 1, name: 'wayne'});

// saved as
{
    _id: new ObjectID(),
    timestamp: new Date(),
    data: {
        id: 1,
        name: 'wayne'
    },
    level: {
        level: 20000,
        levelStr: 'INFO'
    },
    category: 'audit'
}

Options

There are some options which can by set through the config object.

name type default value required
connectionString string undefined yes
collectionName string 'log' no
write string 'fast' no
layout string 'messagePassThroughLayout' no

var log4js = require('log4js'),
    mongoAppender = require('log4js-node-mongodb');

log4js.addAppender(
    mongoAppender.appender({
        connectionString: 'localhost:27017/logs', 
        collectionName: 'audit', 
        write: 'safe'
    }),
    'audit'
);

var logger = log4js.getLogger('audit');
logger.info('User %s logged in', 'wayne');
The complete documentation can be found in the github repo.

log4js-node-mongodb appender - Deutsch



Wir benutzen log4js-node für das Logging in unseren node.js Anwendungen. Log4js bringt schon eine Menge an Appendern mit, z.B. File oder Console. Da wir aber in unseren Anwendungen auch ein Audit brauchen, ist es wichtig,in eine Datenbank loggen zu können. Deshalb haben wir einen log4js Appender entwickelt, der in eine MongoDB loggen kann.

Installation

So wie immer…
$ npm install log4js-node-mongodb

Verwendung

Benutzt wird dieser Appender wie jeder andere log4js Appender. Man muss nur den connection-string zu der Mongo Datenbank übergeben. Die Standard collection, welche benutzt wird, ist log. Man kann einen string oder alle Arten von object loggen. Objekte werden so gespeichert wie sie sind, und nicht in einen string konvertiert.
var log4js = require('log4js'),
    mongoAppender = require('log4js-node-mongodb');

log4js.addAppender(
    mongoAppender.appender({
        connectionString: 'localhost:27017/logs'
    }),
    'cheese'
);

var logger = log4js.getLogger('cheese');
logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Gouda.');
logger.warn('Cheese is quite smelly.');
logger.error('Cheese is too ripe!');
logger.fatal('Cheese was breeding ground for listeria.');

// log objects
logger.info({id: 1, name: 'wayne'});
logger.info([1, 2, 3]);
Oder man benutzt die Methode configure.
var log4js = require('log4js');

log4js.configure({
    appenders: [
        {
            type: 'console'
        },
        {
            type: 'log4js-node-mongodb',
            connectionString: 'localhost:27017/logs',
            category: 'cheese'
        }
    ]
});
Die log Daten werden in folgendem Format gespeichert.
{
    _id: ObjectID,
    timestamp: loggingEvent.startTime,
    data: loggingEvent.data,
    level: loggingEvent.level,
    category: loggingEvent.logger.category
}
Hier ein paar Beispiele.
var log4js = require('log4js'),
    mongoAppender = require('log4js-node-mongodb');

log4js.addAppender(
    mongoAppender.appender(
        {connectionString: 'localhost:27017/logs'}),
    'audit'
);

var logger = log4js.getLogger('audit');
logger.debug('Hello %s, your are user no %d!', 'wayne', 10);

// saved as
{
    _id: new ObjectID(),
    timestamp: new Date(),
    data: 'Hello wayne, your are user no 10!',
    level: {
        level: 10000,
        levelStr: 'DEBUG'
    },
    category: 'audit'
}

logger.info({id: 1, name: 'wayne'});

// saved as
{
    _id: new ObjectID(),
    timestamp: new Date(),
    data: {
        id: 1,
        name: 'wayne'
    },
    level: {
        level: 20000,
        levelStr: 'INFO'
    },
    category: 'audit'
}

Optionen

Es gibt ein paar Optionen welche man über das config object einstellen kann.

Name Typ Standardwert Benötigt
connectionString string undefined ja
collectionName string 'log' nein
write string 'fast' nein
layout string 'messagePassThroughLayout' nein

var log4js = require('log4js'),
    mongoAppender = require('log4js-node-mongodb');

log4js.addAppender(
    mongoAppender.appender({
        connectionString: 'localhost:27017/logs', 
        collectionName: 'audit', 
        write: 'safe'
    }),
    'audit'
);

var logger = log4js.getLogger('audit');
logger.info('User %s logged in', 'wayne');
Die komplette Dokumentation findet man in dem Github Repository.

Freitag, 6. September 2013

Baboonstack-Deutsch

Node.js + Mongo DB + RedisIO = Baboonstack!

Baboonstack bietet für die drei gängisten Betriebssysteme Linux, MacOS und Windows eine schnelle und unkomplizierte Alternative zur mühseligen manuellen Installation und Konfiguration von Node.js, Mongo DB und RedisIO.
So einfach startet man die Baboonstack Installation unter Linux und MacOS:
curl http://packages.litixsoft.de/installer.sh | sudo sh
Unter Windows benötigt man die Setup Routine. Diese kann man sich von der Seite http://litixsoft.de/products-baboonstack herunterladen.
Natürlich ist man nicht gezwungen, alle Komponenten zu installieren. Im Windows Installer lassen sich diese einfach abwählen. Unter Linux und MacOS gibt es den Parameter —without-. Dazu muss das Installations-Script einfach mit diesem Parameter aufgerufen werden.
curl http://packages.litixsoft.de/installer.sh > installer.sh
chmod +x installer.sh
sudo ./installer.sh --without-mongodb

MongoDB

Die Installation von MongoDB ist auf allen Systemen nicht sonderlich schwierig, jedoch kann man sich schnell in der Vielfältigkeit der Konfigurationsmöglichkeiten verlieren. Dank Baboonstack erhält man eine vorkonfigurierte und Ready-to-use Installation von MongoDB, welche als als Dienst/Daemon läuft.

RedisIO

Während es unter Linux und MacOS noch relativ einfach ist, RedisIO zu installieren, steht man unter Windows Betriebsystemen schnell vor einem großen Problem. Möchte man dann noch RedisIO unter Windows als Dienst betreiben, sucht man fast vergeblich nach einer funktionierenden Lösung. Auch hier bietet Baboonstack die Lösung. Auf allen Systemen lässt sich RedisIO bequem als Dienst/Daemon installieren und ist nach der Installation fertig zur Benutzung.

Node.js Versions Chaos bändigen

Node.js entwickelt sich rasant und erscheint fast wöchentlich eine neue Version. Schon kann man schnell vor der Hürde stehen, das Projekt A nur unter Node.js 0.8.X und Projekt B eben nur mit einer Version 0.10.X läuft. Problematisch ist es zwar nicht, verschiedene Node.js Versionen auf einem System zu betreiben. Jedoch verliert man dann auch schnell den Überblick. Dann wünscht man sich einen praktischen Manager, der die Verwaltung übernimmt. Das übernimmt das zum Baboonstack gehörende Tool lxManager (lxm).
lxm node switch 0.10.8
Schon wechselt man Systemweit auf die Node.js Version 0.10.8. Sollte mal eine Version nicht lokal vorhanden sein, kann man einfach mit
lxm node install 0.10.8
diese direkt vom Node.js Distributionsserver für alle Plattformen installieren. Hilfreich ist auch die Möglichkeit, seine Node.js Applikation direkt mit einer bestimmten Versionen zu starten.
lxm node run 0.10.8 app.js

Node.js Applikation als Dienst

lxm service install lxApplication 0.10.12 D:\Projects\lxApp1\app.js
So einfach kann es sein unter Windows und Debian basierenden Linux Systemen eine Node.js Applikation als Dienst zu registrieren. Auch dies ist möglich mit Baboonstack.

Immer auf dem neusten Stand

Baboonstack bietet ebenfalls die bequeme Möglichkeit eines Updates auf die neuste Version.
lxm update
startet den Download und die Installation der neuesten Version. Die vorhandenen Daten bleiben natürlich vorhanden.

BaboonStack-English

Node.js + Mongo DB + RedisIO = Baboonstack!

Baboonstack offers a fast and uncomplicated alternative to the troublesome manual installation and configuration of Node.js, MongoDB and RedisIO for the three well-established operating systems Linux, MacOS and Windows.
curl http://packages.litixsoft.de/installer.sh | sudo sh
That’s all to be done to easily start the Baboonstack installation for Linux and MacOS. The installation on a Windows based system is not much more of a challenge: just download the setup binary from http://litixsoft.de/products-baboonstack and start it.
You won’t be forced to install all of the stack’s components. The Windows installer let’s you chose during installation process, in Linux or MacOS the —without- parameter is used. Run it as shown below.
curl http://packages.litixsoft.de/installer.sh > installer.sh
chmod +x installer.sh
sudo ./installer.sh --without-mongodb

MongoDB

The MongoDB installation as it is not much of a hassle on all of the three operation systems. With using Baboonstack you still get the advantage of directly starting off with a pre-configured ready-to-use MongoDB installation without getting lost in configurability. It’s also installed as a service/ daemon.

RedisIO

Without running into too much trouble installing and running RedisIO on a Linux or MacOS system, you often step into problems on a Windows based systems e.g. when trying to run it as a service. This is where Baboonstack comes to your aid: it lets you install and run RedisIO as a service/ daemon in a simple and comfortable way on all three systems. And again ready-to-use directly after installation.

Node.js - taming the version chaos

Node.js is evolving very fast and with it lots of new versions appear. Soon you will face the situation to have project A work with Node 0.8.X only and projekt B with version 0.10.X. Though it’s not problematic to install different Versions of Node.js at the same time on the same system, you still can lose track of all the different versions very easily. Again Baboonstack comes in handy beeing a very easy to use manager. As part of Baboonstack the lxManager tool with it’s integrated Node.js version manager is the answer to your questions.
lxm node switch 0.10.8
Easy system-wide changing to Node.js version 0.10.8. If you are locally missing a certain version simply install it with
lxm node install 0.10.8
directly from the original Node.js distribution server - no matter if you are using Windows, Linux or MacOS. It might be necessary to run your application straight from a certain Node.js version, too.
lxm node run 0.10.8 app.js

Node.js applications as a service

lxm service install lxApplication 0.10.12 D:\Projects\lxApp1\app.js
That’s all to register your Node.js application as a service on Windows or a Debian based linux distributions - again easily done with Baboonstack.

Always up-to-date

Baboonstack comes with a comfortable way to update to the cutting-edge version. If existing,
lxm update
starts the download and installation of the newest version. Needless to say that your local data remains untouched.