Generic Makefile

Update: Now also supports C++, see the Github repository1 for the updated file.

In every single project, or even just test, I write the same simple Makefile over and over, by now I can write it without looking up anything. And if I forgot something, I would go through my old projects, to dig up the definition I need.
Today I got fed up with that, and decided to write one completely generic Makefile I can just reuse in all my projects. It only requires a reasonably new make, nothing else.

It features:

  • Automatic detection of changes in dependencies (eg header files)
  • Detection of system compiler / linker (via environment variables CC and LD)
  • Ability to amend CFLAGS, CPPFLAGS, LDFLAGS, or LDLIBS via cli
  • install and clean targets, the former also respects PREFIX
  • Generetion of gdb debug files
  • Sane compiler defaults

You can find the repository containing the file on GitHub2. Currently it only supports C, but I might add C++ support in the feature, be sure to keep an eye on my blog to be notified about any news.


Debug Messages in no$gmb and BGB

I've recently started working on a little side project, involving Gameboy development. While reading through the docs of BGB1, I noticed it supports printing debug messages to a debug console, I, however, couldn't get it working, since it was using the syntax of the no$gmb2 assembler. Thanks to the people of #gbdev on EFnet, especially beware, I've eventually got it working, and made an rgbds3 macro out of it.
Without further ado, here is a gist of the it:


; Prints a message to the no$gmb / bgb debugger
; Accepts a string as input, see emulator doc for support
        ld  d, d
        jr .end\@
        DW $6464
        DW $0000
        DB \1



SysInfo - Beautiful System Diagnosis


I've recently been reminded of a tool called Archey1, it's used to display system specs in a delightful manner. You often see it in screenshots of some other people desktops of the Arch Linux community.

I missed such a tool on OS X, and that's why I wrote SysInfo. It's available on Github2.


Fixing Slow Vim in Tmux and iTerm2

I've noticed my Vim got horribly slow once I had multiple panes in tmux open.
My initial investigation led to the fact, that tmux is slowing Vim down, and a quick Google search confirmed that.
After removing all plugins in Vim/tmux, I dug through the iTerm2 settings and found this:


Removing the tick at "Save lines to scrollback in alternate screen mode" and setting the scrollback to a reasonable amount (I chose 1000), the lag was nearly gone. I'll continue investigating, to improve the Vim performance.



I've resurrected my blog, and put my .io domain to a good use, and set-up a ghost blog.
So far, I've always had my personal websites cluttered on many domains, but this came to an end, everything is now on

You can expect new posts in the next few weeks, I already have something prepared.


Automatically exporting assets from Sketch into Android Studio

Matt Zanchelli wrote a blog post about automatically exporting assets from Sketch into Xcode, unfortunately this method can only be used with Xcode projects, but fortunately we have Gradle.

I ported this technique to use Gradle an achieve the same for Android Studio projects.

Installing Sketchtool

You have to install sketchtool first, it’s a tool by Bohemian Coding (the makers of Sketch), to work with .sketch tools on the command line.
Download the Sketchtool and move the content of the directory into /usr/bin.

Alternatively, you can use this shell script, which basically does the same for you:

curl -O;\  
sudo cp sketchtool/sketchtool /usr/bin/sketchtool;\  
sudo cp -R sketchtool/sketchtool\ resources.bundle/ /usr/bin/sketchtool\ resources.bundle/;\  
rm -r sketchtool/;\  


Setting up the project

To organize the Sketch files, I created a subfolder in the root directory of the project and moved the AppIcon.sketch file into it. To create the image files of from the artboards in the file, we need a shell script. Create a file and copy the code below into the file.


/usr/bin/sketchtool export artboards AppIcon.sketch

mv HDPI.png ../app/src/main/res/drawable-hdpi/ic_launcher.png  
mv XHDPI.png ../app/src/main/res/drawable-xhdpi/ic_launcher.png  
mv XXHDPI.png ../app/src/main/res/drawable-xxhdpi/ic_launcher.png  
mv XXXHDPI.png ../app/src/main/res/drawable-xxxhdpi/ic_launcher.png  

Modifying the build.gradle

This script has to be executed before every compilation of the project, to achieve this we have to modify our build.gradle file, by appending the following:

task copySketch(type:Exec) {  
    workingDir '../Graphics Resources'
    commandLine './'
preBuild.dependsOn copySketch  

It assumes, you use the same structure as described above. If you don't, adjust the paths accordingly (the default directory, is the directory where the build.gradle lives in).

Sample Project

You can download the sample project, or visit the Github repository.