Skip to content
Dec 19 14

Three-way merge in TFS

by drphrozen

Hi there!

For some year i have been working with Visual Studio and all sorts of revision systems (cvs, svn, git, dropbox *oops* and tfs).
Lately our projects has been using TFS, but some are starting to enjoy Git (although mostly hipsters and other command line fanatics). Personally i use Git at home and TFS at work.

Well enough blabber, this post is about three-way merges in TFS *hint: see title*.

I’m normally a fan of the tools in Visual Studio, but i never liked how their file comparison looked.
Personally i like Perforces p4merge way better. It seems to handle merge conflicts way better than the built in tools (at least compared to 2012 and 2013). It has some neat options for whitespace handling, and the only drawbacks are file encodings (but this might just be the way that Visual Studio by default uses BOM) and the annoying/lack of integration in Visual Studio.

I have been using this guide when i had to setup p4merge in Visual Studio, which results in a command line pop up followed by p4merge. It works, but that command line thing is just annoying :)

So i created an exe instead and copied the logic from the bat files (and merged it into one exe to rule them both: merge and diff).

Next i created a simple Powershell script that makes Visual Studio use: p4merge_vs.exe.


Download p4merge_vs_install.exe and run it.

Warning, this will overwrite all the .* extension for your User Tools in all installed versions of Visual Studio, if you have any.

That’s it, enjoy!

Manual Install

Copy only p4merge_vs.exe to Perforce folder and configure it in Options > Source Control > Visual Studio Team Foundation Server > User Tools

Visual Studio User Tools Diff

Visual Studio User Tools Merge



Aug 3 12

Processing large arrays in javascript

by drphrozen

Today i was debugging some Javascript code, where a long running script made Firefox cry (Chrome took it like a man ;-) ). The problem was that i had to process a large array and inject it into an existing table in the DOM. And although i did some optimizations (removed jQuery element creations and used direct id lookup) it was still not fast enough.

Knowing that Javascript behaves somewhat similar to old school winforms (one thread for event processing) i knew i had to free this process. Apparently this is done using setTimeout or setInterval. These are not compatible with jQuery’s $.each function so i decided to make my own:

(function( $ ) {
    $.eachWait = function(arr, callback, interval, bulksize) {
        interval = interval || 10;
        bulksize = bulksize || 1;
        var index = 0;
        var intervalObj = setInterval(function() {
            for(var j = 0; j<bulksize; j++) {
                if (index < arr.length) {
                    try {
                        callback(index, arr[index]);
                    } catch(e) {
                        throw e;
                } else {
        }, interval);
})( jQuery );

// Usage:
$(function() {
    var arr = [0,1,2,3,6,5,6,7,8,9];
    $.eachWait(arr, function(index, value) {
        if(arr[index] != index)
            throw "noooo";

Im not sure this is the correct way to do things, but it works… The additional parameters are interval: time to wait between executions (in ms, see setInterval) and bulksize: number of elements to process between timeouts.

Now i need some coffee :-)

Jul 19 12

Dependency management (Java, Apache Ivy)

by drphrozen

Today i had some spare time and decided to play a little with dependency management. I am a BIG fan of NuGet (package manager for Visual Studio) but since im also a big fan of Eclipse, i decided to see what options i had in the Java world.

I did some research into dependency/package managers for java, and found Apache Maven and Apache Ivy as possible candidates. At first i tried Maven, since this seems to be the industries most popular choice. I had some experience using Maven to build libraries i needed (like protobuf) and it was easy to use from the command line. Next i tested the integration with Eclipse (m2e). Integration seems to be working fairly well, but it isn’t to user friendly (especially not compared to NuGet).

Next up was Apache Ivy™… Trademarked, didn’t notice that before :-) … Well, Apache Ivy works as a task for Apache Ant™ and i know that Eclipse has a builder for Ant build files and is somewhat easy to setup. At first Ivy was looking a lot like Maven, but instead of a dedicated “mvn” command i had to create a task in an ant build.xml. Then just run “ant” and watch Ivy download dependencies and their javadoc/sources. The tutorial at Apache Ivy’s homepage are of high quality, but just to show how simple it is to configure Ivy, look at this (ivy.xml):

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" 
  <info organisation="org.apache" module="hello-ivy"/>
    <dependency org="commons-lang" name="commons-lang" rev="2.0"/>
    <dependency org="commons-cli" name="commons-cli" rev="1.0"/>

So simple. And then just add this (build.xml):

<project xmlns:ivy="antlib:org.apache.ivy.ant" ... >
  <import file="ivyinit.xml" />
  <target name="retrieve-libs">
    <ivy:retrieve />

This will retrieve the dependencies using the ivy.xml. Easy!

The import task is not actually necessary, but i wanted to have an environment with a minimal set of required tools to be able to build this, and the import task actually runs an ant build file that retrieves ivy.jar from and registers Ivy for use in the rest of the build file. That’s awesome!

The next step was to see hoe well Ivy integrates in Eclipse using Apache IvyDE™. A need thing about the plugin is that now we can add a reference to an Ivy Library and this one is automatically populated using ivy.xml. This is very handy since Eclipse’s Ant integration seems to only add classpath entries on import the Ant build file.

I am definitely going to recommend Ivy over Maven, mostly because of the simplicity, but also because Ivy is able to use both Maven repositories but also a lot of other resolvers (like ftp, http or custom ones). Although it is very easy to setup Ivy and to maintain the dependencies, it is not as easy as NuGet. So maybe my next project should be to develop an Ivy plugin to automatically search for and configure dependencies. :-)

May 14 12

Fixing TabOne2

by drphrozen

Today i played a little with a TabOne2, an Android tablet from Jecopix (now bankrupt). The tablet was released with a lot of bugs and before the company could release a patch they went bankrupt.

Some of the bugs prevents the usage of what i would call “essential” features, such as Google Calendar sync and Facebook.

I started my quest by identifying the SoC it is based upon, and “luckily” it wasn’t that hard: Allwinner A10. This is a very popular SoC in China and there are several sites and forums discussing all the different tablets based on this SoC. The Google Calendar was somewhat easy to fix since all i did was install the GoogleCalendarSyncAdapter.apk from The Facebook fix was a bit harder to locate, i had an idea that this was due to the the lack of a GPS in the tablet. After several different attempts i found a solution here It didn’t work after i restarted so i tried resetting both Google Play Store and Google Services Framework and then it worked after another restart.

There are still some issues, most of them performance/battery related, but those are not fixable as such, unless the kernel is rebuild and replaced. This could probably be done if someone wan’ts to risk testing the following solution with their tablet:

Also, next up i think i wan’t to try replacing the entire gapps collection using the package from cyanogenmod.

Update: updating gapps seemed to solve almost all existing problems.. The system is still slow, and some minor errors exists, but the system is now much more complete.

May 10 12

Exchange on Ubuntu

by drphrozen

I just upgraded to Ubuntu 12.04 and wanted to setup my development environment. I find myself using Outlook more often to manage tasks, but im not a fan of the web based approach (although Exchange 2010 web interface has improved a lot!).

I then did some googling, and found davmail. I think i tried this aproach before and was disappointed, but i thought “what the heck” and tried it again.

The install of davmail was fine, i left all settings as per default and only changed the path to the exchange web interface. There were one issue, a missing tray icon, this is because of Unity

Here is a summary of the settings i used:











More information is available at DavMail’s homepage:

Mar 4 12

Display IP before login

by drphrozen

I wanted to be able to display IP address before user login on my virtual Ubuntu Server. My use case is that i use VirtualBox to host a LAMP (using Ubuntu Server 12.04 beta 1), and i wan’t to distribute this easily with my colleagues/friends. To ease connection i wanted to display the IP of the virtual machine before login, this info is shown after login, but i just find it a bit annoying, that i have to login just to find the IP of the server. That’s why i created the following Upstart script and placed it in /etc/init/loginscreen.conf:

start on stopped networking RESULT=ok


exec /usr/bin/landscape-sysinfo &gt;&gt; /etc/issue

The following output is displayed when the VM has started:

  System load: 0.0 Processes: 70
  Usage of /: 7.7% of 17.68GB Users logged in: 1
  Memory usage: 4% IP address for eth0:
  Swap usage: 0% IP address for eth1:


Dec 21 11

Git on VPS

by drphrozen

A couple of month ago i bought a Rackspace Cloud Server instance. I set it up using Ubuntu 11.10 (Oneiric) and tried using UberSVN which is very simple to setup and manage. Unfortunately UberSVN uses Apache HTTP Server and Tomcat, which are too demanding for my memory constrained VPS (Virtual Private Server). Instead i tried manually setting up apache and svn, but this also ate a lot of my memory. Instead i ended up replacing apache with nginx (first i tried lighttpd, but it had some issues). I used toofishes blog (and comments) as my guide, here.
Below is the configuration that worked for me:

location ~ /git(/.*) {
  auth_basic                        "Restricted";
  auth_basic_user_file              /svn/.htpasswd;

  fastcgi_split_path_info           ^(.*/git)(/.*)$;
  fastcgi_param SCRIPT_FILENAME     /usr/lib/git-core/git-http-backend;

  # export all repositories under GIT_PROJECT_ROOT
  fastcgi_param GIT_HTTP_EXPORT_ALL "";
  fastcgi_param DOCUMENT_ROOT       /usr/lib/git-core/;
  fastcgi_param GIT_PROJECT_ROOT    /var/lib/gitolite/repositories;
  fastcgi_param PATH_INFO           $fastcgi_path_info;

  include                           /etc/nginx/fastcgi_params;
  fastcgi_pass                      unix:/var/run/fcgiwrap.socket;
May 30 11

Serial port on Android

by drphrozen

At work we had a problem connecting an embedded device to a smartphone, but solved it rather nicely using an Android phone (Nexus One). This guide will show you how i solved the problem using an idea stolen from

The recipe is as follows:

Install (using binaries)




  1. Install CyanogenMod (IMPORTANT: do not boot into android after this)
  2. Mount /system from recovery
  3. Extract content of the modified kernel package
    $ adb push bcm4329.ko /system/lib/modules
  4. Boot into fastboot (hold trackball when rebooting/powering)
    $ fastboot flash zimage zImage
  5. Test connection using Android SerialPort API.

Compile (from source)

Kernel Modifications

Verify that the following options are set:

  • CONFIG_CMDLINE="mem=64M console=null"

Change a line in drivers/serial/msm_serial.c:

static struct console msm_console = {


Fastboot is available at, to start Nexus One in fastboot mode, hold trackball while powering up.

  • fastboot oem unlock (used to unlock the phone)
  • fastboot boot /path/to/zImage (used to test a new kernel)

Reference blog: Enabling the Serial Port on a Nexus One


I had to recompile this project without O_DIRECT at:

fd = open(path_utf, O_RDWR | O_DIRECT | O_SYNC);


Usb connection

The hardware is described on

pin 1, VBus must be left open (red)
pin 2, D-: TX (white)
pin 3, D+: RX (green)
pin 5: GND (black)
Jul 15 10

Ubuntu “Snap” Effect

by drphrozen

I wanted a snap effect like the one in Windows 7, although not the drag and snap kind, but the Windows Key + Left|Top|Right|Down kind. I followed this guide on OMG! Ubuntu, but it wasn’t exactly what i wanted.

Here is my recipe:

Install the required components:

sudo apt-get install compizconfig-settings-manager wmctrl

Open the Compiz Config Settings Manager (ALT+F2 ccsm or System > Preferences > CompizConfig…, etc).

Insert the following commands (Commands > Commands > Command line 0-3):

WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` &amp;&amp; HALF=$(($WIDTH/2)) &amp;&amp; wmctrl -r :ACTIVE: -b add,maximized_vert &amp;&amp; wmctrl -r :ACTIVE: -b remove,maximized_horz &amp;&amp; wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` &amp;&amp; HALF=$(($WIDTH/2)) &amp;&amp; wmctrl -r :ACTIVE: -b add,maximized_vert &amp;&amp; wmctrl -r :ACTIVE: -b remove,maximized_horz &amp;&amp; wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz

Now map the keys (Commands > Key Bindings > Run command 0-3):

  • <Super>Left
  • <Super>Right
  • <Super>Up
  • <Super>Down


Jun 20 10

Compress Virtual OS Image

by drphrozen

Here is a simple guide for those who need to export an “Virtual Appliance” from VirtualBox, Xen, VMware Workstation/Player or others. With this guide it is possible to compress images even further, by cleaning the targets partitions. This guide is for Ubuntu, but should work for any Linux machine.
I use zerofree instead of dd for ext partitions because it is faster, and dd for swap. A simple way to do this could be booting from a Ubuntu live disk in the Virtual Appliance instance, apt-get zerofree (universe) and then follow these steps:

$ sudo fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009e93c

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2497    20051968   83  Linux
/dev/sda2            2497        2611      916481    5  Extended
/dev/sda5            2497        2611      916480   82  Linux swap / Solaris
$ sudo zerofree /dev/sda1
$ sudo swapoff /dev/sda5
$ sudo dd if=/dev/zero of=/dev/sda5
dd: writing to `/dev/sda5': No space left on device
1832961+0 records in
1832960+0 records out
938475520 bytes (938 MB) copied, 25.5471 s, 36.7 MB/s
$ sudo mkswap /dev/sda5
Setting up swapspace version 1, size = 916476 KiB
no label, UUID=fb59e480-e471-405e-98e9-37fd16fe5ac6