Archive for the ‘Tips’ Category

Runtime-replace implementations with Roboguice in functional tests

Thursday, October 18th, 2012

At work we're heavily depending on Unit and Functional Testing for our current Android application. For Unit testing we've set up a pure Java-based project that runs on Robolectric to provide a functional Android environment and we also added Mockito to the mix to ease some code paths with spied-on ...

Debugging with MacPorts PHP binaries and Eclipse PDT 3.0

Tuesday, September 27th, 2011

You know the times, when things should really go fast and easy, but you fall from one nightmare into another? Tonight was such a night... but lets start from the beginning. To debug PHP you usually install the excellent XDebug and so did I with the port command sudo port install ...

Exception chaining in Java

Monday, July 25th, 2011

If you catch and rethrow exceptions in Java, you probably know about exception chaining already: You simply give the exception you "wrap" as second argument to your Exception like this try { ... } catch (Exception e) { throw new CustomException("something went wrong", e); } and if you look at the stack trace ...

Access the Android menu in VirtualBox on a Mac host

Wednesday, July 13th, 2011

If you're desperately trying to get the Menu button in an Android x86 installation working under VirtualBox on a Mac OS X host - whose keyboard of course doesn't have this "context" / "menu" key Windows keyboards have on the right - you might find the touch-only-device mode in Android ...

ACLs on Mac OS X

Saturday, June 4th, 2011

This is a short follow-up of an earlier post where I explained how one can set ACLs on FreeBSD. Today now I'll do the same on another BSD variant, namely Mac OS X, and guess what, the guys from Cupertino implemented ACL management in a completely different manner. The first thing ...

SQLite to MySQL

Thursday, May 26th, 2011

Migrating a database dump from SQLite to MySQL can be somewhat of a hassle. After various trials I came up with the following that worked for me quite well: echo .dump | sqlite3 mydb.db |\ egrep -v "\b(BEGIN TRANSACTION|COMMIT|PRAGMA|sqlite_sequence)\b" |\ perl -pe 's/^([^'\''"]*)"([^"]+)"/\1`\2`/' |\ perl -pe 's/\bautoincrement\b/auto_increment/' |\ ...

Search and replace multiple lines across many files

Wednesday, August 11th, 2010

sed is usually my favourite tool to search and replace things from the command line, but sometimes Perl's regexes are far more convenient to use. Recently I found out another reason why Perls -pi -e is superior over plain sed: when you want to change multiple lines in a document! Imagine ...

Tip: Enforce specific key usage for a single SSH connection

Thursday, February 4th, 2010

In case you have to access a very restricted SSH server which only accepts a single key (ie. the one which is set up in ~/.ssh/authorized_keys) and otherwise fails, its the easiest to set the specific key in your local ~/.ssh/config file as follows: Host very.secure.server IdentityFile ~/.ssh/id_dsa ...

Tip: Logging with Symfony >= 1.2

Monday, January 25th, 2010

Imagine you have a business method in your model which needs to be accessed by two environments: once from a symfony task and once from the web. So far so good, now what if this business method should be able to log contents somewhere visibly, in case of the command ...

Configure Thunderbird 3′s indexing behaviour

Thursday, December 24th, 2009

The current version of Thunderbird comes with a terrific global search functionality, but sometimes its cumbersome to watch it reindex the email history if something corrupted the database or to get emails in the search results which you're absolutely not interested in (commit messages, f.e.). Unfortunately Thunderbird 3 has only a ...