The best terminal emulator for Windows 10's Bash or how to run X applications

update as of 03/2017
As this article is by far the most popular on my site right now I feel that an update is necessary, as the landscape evolved a bit since the original publish date.
Conemu started to support Bash on Windows properly now and this is what I settled on in the end.
The article below is still relevant for the running X applications on Windows part though.

I've been playing a bit with GNU/kWindows a.k.a. Bash on Windows a.k.a Windows Subsystem for Linux (Beta). I was especially interested whether I can use my regular Linux dotfiles to recreate my working environment of zsh + tmux + vim. The biggest troubles I had were with the terminal emulator. While the default one, invoked by saying bash is much better than powershell or cmd.exe already - it lacks some things I've learned to rely on, like 256-colour palette support. Thus the search for the ultimate terminal emulator begun. I tried ConEmu, cmder and their spinoffs to no avail. Either the colours were lacking, or the emulator would swallow up certain strokes like the arrow keys. Then I thought - hey, I use terminator on Linux, maybe it would be possible to use it here as well. To my surprise the answer was - yes !

  • install Windows Subsystem for Linux
  • restart Windows
  • install VcXsrv
  • run VcXsrv
  • invoke the following from the bash console:
sudo apt-get install terminator
DISPLAY=:0 terminator -u
  • profit !


The font rendering is not ideal and the borderless mode does not work, but hey, it is quite usable nonetheless ! It even has bidirectional clipboard sharing with Windows' windows, which is good. P.S. konsole and gnome-terminal do seem to have troubles launching (crashy-crashes there)

Don't throw away. Fix.

Try fixing your things. It's already broken - no need to sweat.
You might learn something.
Level 2 - push for things to be easily fixable.
It's good for you. It's good for the planet.

image0 image1 image2 image3 image4

Conferences you did not know existed and now you know you just need to go to

Go to conferences. It's good for you.

Ever wondered why to go to conferences ? Is it worth it, especially if you do not feel confident that the conference is on something that would be in an immediate realm of your day-to-day interests ? Just go ! You might end up learning something and meeting new people. And new people mean more variables to mix up your life. A bit scary, I know. Still worth it though. Wondered what conference in Europe are weird enough so people wouldn't mind having another misfit ? Here you go.

Now imagine something niche within the industry. To me, AI comes to mind. Mages in robes in their towers, sending out autonomous robot armies against each other. Right ? There's a conference for that ! At, in July, in Vienna, you can meet AI professionals from academia and industry alike, most of them coming from game development background. The atmosphere is very newcomer-friendly, the only requirement is that you're interested in AI, not necessarily having anything to do with it professionally. Petra and Alex, the organizers, are wonderful people that make this conference quite unique. It's happy fun to see ideas floating from academia to the industry and vice versa. Don't forget the presentations on work-in-progress major AAA games ! I've learned there that the everyday programming in the games industry is quite different than the one I do in terms of best practices and patterns. Definitely worth a try !

Erlang User Conference

Speaking of something completely different. Erlang ! Was functional before being functional was considered cool. Very practical, very fast, parallelize everything ! Processes everywhere ! Message passing ! Want to feel the groove as well ? Visit Stockholm in September for Erlang User Conference. Meet creators of the language, talk about massive scale deployments. Other FP languages are welcome. I would even say, the more strange the better. Idris seems to be the topic of interest as well.  Eat good food, walk the city of dynamite. Erlang has a quite close-knit community which gives you this warm family feeling.


Speaking of family. There's a family of conferences known as SoCraTes. Software Crafstmanship and Testing. SoCraTes. Get it ? :D As it's more than one conference a year, it's harder to go to all of them. I only went to Codefreeze, in Finland, in January, and only once, but loved it already. Codefreeze, Finland, in January. Get it ?! :D First thing is that you don't know what will happen there. You just go, meet the people and then you sit down and everyone talks about what they would like to learn and what they can share. This way you come up with some loose agenda you follow more or less. One track, very intense. Talking, swimming in ice water, learning, sauna going. Very intimate feel, not many people, lots of things to learn.

Chaos Communication Congress

Speaking of lots of people and intimate feel. Chaos Communication Congress is, I think, the biggest gathering of all nerds and freaks in Europe, yet being there feels quite at home. The best organized conference I've been to. Friendly people showing their wares on their humble tables, 4 simultaneous tracks, huge building with intricate hallways. It's cyberpunk, it's inclusive, it's about hardcore infosec topics, it's about politics. Everything's there, everyone's there. 4 days of data being constantly uploaded to your brain, on the waves of Club Mate. Feels like an extended holiday present, as it's happening in the last week of December.

The Camps

Chaos Communication Camp and The Dutch Camp. Imagine CCC, the Congress, but in the woods. Middle of nowhere, multigigabit internet connection. sleeping in the tent, then going to a world-class lecture. Both CCC, the camp, and The Dutch Camp, the camp, are happening every 4 years, each of them taking alternating slots. So every 2 years there is a camp somewhere. Did I mention that the location changes every event ? Happy camping !


So go out there. Explore. Meet people. Learn. Have fun. None of the above are much expensive and most of the events have a policy of "write to us if you want to go but can't afford the ticket". Friendly people fixing problems together. July, tickets around 250EUR
EUC: September, tickets around 350EUR
SoCraTes: the cost and the time depend on the event
CCC: last week of December, tickets around 100EUR
The Camps: summer, tickets around 125EUR

Productive New Year's Eve

It turns out that the last day of the year can be quite productive. I've managed to sneak in a PCB layout for the input measurement and protection board for my sunpowered server . Got it ordered, can't wait to test it ! I got carried away with via stitching there a bit - we'll see how hard it will be to solder the larger components because of that. The whole project is hosted here - it's open hardware so please do take a look.

image0 image1 image2

Sporting Let's Encrypt certificate

Let's Encrypt is soon to be publicly available service to provide TLS certificates for free and in automated fashion. I'm helping them test their systems by participating in the beta program. Because of that this site is now sporting, publicly recognizable certificate from Let's Encrypt. Yay ! The work they are doing I believe is of much importance. Lack of easy path for getting TLS certificate was a major hurdle for the most of the website owners, otherwise keen on getting their traffic encrypted. This, in turn, is important for two reasons. Not allowing the content you are viewing on the internet to be snooped at, not leaking you private data is one thing. Other, less known, but as much important, is countering the ability of injecting any malicious code/data into the responses from the servers you got and in turn preventing lots of man in the middle attacks. Hopefully, when Let's Encrypt becomes publicly available we would be on the path to much more friendly internet for all.

Fixing timeouts running Android integration tests

The main problem with Android CI I had recently is that, after switching to Lollipop, the integration tests wouldn't run. Invoking androidConnectedTest gradle target always resulted in crashing with ShellCommandUnresponsiveException. Internet says that in such a case ou just need to set ADB_INSTALL_TIMEOUT. Set and then nothing. Sourcediving it is then !

A long while after that I got to this file: [Linking to master, here's the commit hash:1cb1a4c2976b99ae53d28d7f01d975232c85f990, as I don't seem to be able to find how to link to that hash directly] What do we see there ? That indeed ADB_INSTALL_TIMEOUT is being used:

static {
    String installTimeout = System.getenv("ADB_INSTALL_TIMEOUT");
    long time = 4;
    if (installTimeout != null) {
        try {
            time = Long.parseLong(installTimeout);
        } catch (NumberFormatException e) {
            // use default value

So far so good, ADB_INSTALL_TIMEOUT system variable seems to be respected when invoking package installation tools. Are the above the only methods that can install a package though ? Going further on that hunch we see that in addition to installing single packages there is a possibility of having a multi-package installation session.

public void installPackages(List<String> apkFilePaths, int timeOutInMs, boolean reinstall, String... extraArgs) throws InstallException {
if (getApiLevel() < 21) {
        Log.w("Internal error : installPackages invoked with device < 21 for %s",Joiner.on(",").join(apkFilePaths));
        if (apkFilePaths.size() == 1) {
                installPackage(apkFilePaths.get(0), reinstall, extraArgs);
        Log.e("Internal error : installPackages invoked with device < 21 for multiple APK : %s", Joiner.on(",").join(apkFilePaths));
        throw new InstallException("Internal error : installPackages invoked with device < 21 for multiple APK : " + Joiner.on(",").join(apkFilePaths));
String sessionId = createMultiInstallSession(apkFilePaths, extraArgsList, reinstall);

Aha ! No-Lollipop check here, with a fallback to the old method - we may be onto something ! Some lines pass and we can see an invocation of createMultiInstallSession. What's there ?

private String createMultiInstallSession(List<String> apkFileNames, @NonNull Collection<String> extraArgs, boolean reinstall) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
String cmd = String.format("pm install-create %1$s -S %2$d", parameters.toString(), totalFileSize);
executeShellCommand(cmd, receiver, DdmPreferences.getTimeOut());

A different invocation of executeShellCommand, now using DdmPreferences.getTimeOut() as a timeout value source. Summarizing - this only happens if you install multiple applications for your androidConnectedTest and you are using android device to test on that has api version that is equal or greater to 21. That is all cool that we had this little Computer Science Investigation, but how to fix that - i.e. how to have proper timeouts for your installations ? Ideally from somewhere you configure and/or invoke your builds. It turns out that gradle supports invoking just enough Java for us to use there. In your as the very first lines:

println "setting global timeout for apk installation to 10 minutes"

android {
        compileSdkVersion compileSdk
        buildToolsVersion buildTools

That's it. Invoke your android tests with ADB_INSTALL_TIMEOUT env variable set AND have the DddPreference set in your as in the example above and you should be golden. Happy droiding !

Tools: precision test indicator holder

This is the second part in the series of the tools I use. Tools that are surprisingly useful, tools that are not that obvious to find. Check out the first part here. Today: how to calibrate the CNC axis without actually cutting anything ? Use a test indicator ! How to hold the meter steady though, ? Attach it to the frame of your router using the power of magnets ! Sample item on Amazon here [affiliate link warning]

image0 image1 image2

Despite being attached to the frame by its back instead of the bottom it still holds beautifully.

Enabling USB 3.0 in already existing Virtualbox VMs

Just a quick note on how to get USB 3.0 in Virtualbox for VMs that were created with USB 1.1 support only. First, download VirtualBox Extension Pack from here. Install it. Then quit Virtualbox completely. Go to your directory that contains your virtual machine and edit .vbox file. Replace the whole <USBController> section with the following:

        <Controller name="xHCI" type="XHCI"/>

That's it, let me know if it works for you !

When life gives you temp space - make lemonade !

Some VPS providers, e.g. Azure (I know..) provide you with 2 disks for your VPSes. One, of very limited size, system disk, and the other one, spacy but with not guarantees that the data survives reboot. Basically it means that you can have a small VPS, with a small amount of RAM but large temp disk space. Why this could be useful ? Imagine tasks with lots of mem requirements but that not need to be extra fast, where swapping is allowed. Like complex nightly builds. Here is a set of super simple scripts I've come up with to quickly boot up a system, and then in the background add a new swap file on the temp drive there. The temp drive is assumed to be under /mnt.

root@someazurehost:~# cat /etc/rc.local
#!/bin/sh -e
set -v

# do not wait for swap to become online,
# proceed with the boot further,
# with swap being created in the background
/etc/make_and_enable_swap &

exit 0
root@someazurehost:~# cat /etc/make_and_enable_swap
set -e
set -v
# create new 2GB swap file
dd if=/dev/zero of=/mnt/swap bs=1M count=2048
chmod 0600 /mnt/swap
mkswap /mnt/swap
swapon /mnt/swap

Don't forget to make /etc/make_and_enable_swap executable ! Do not add this swap file to fstab, as it is being read before rc.local, and this may certainly result in a boot failure, as the swap file would not be ready yet.

Containerized zombie spawner

Recently I was playing with a fully Dockerized setup of Jenkins at work and found a curious issue there. Whenever Jenkins was polling the git server the side effect was that it created a zombie ssh process. The issue is actually remediated by the Jenkins team now by explicitly using a tiny init system called ... tini, started as the main container's process instead of just starting Jenkins there. This tiny tini thing can properly adopt and reap the children. I was all like - wow, what a great blog entry is coming at me. I was planning to describe how zombies come to existence on Linux and why Docker should, in my opinion, provide an adopter-reaper by default and other very interesting things ! But then I found a really excellent article by the Phusion team here explaining all that and more. It is very good. You should read it. That is it. The end. Happy reaping !