Basic Auth for WordPress

I assume you have shell access to your wordpress installtion here.

Go to your wordpress directory and enter: (use your own name)

htpasswd -c .htpasswd klaus

Enter your password twice and then run:


Copy the printed directory into your clipboard and replace “your directory here” from the following lines with your path.

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile <your directory here!>/.htpasswd
Require valid-user

Now open .htaccess with your preferred editor like vim and copy/paste the above lines before it says # BEGIN WordPress

You’re done.

Flattr this!

Clone Ubuntu Server to new location

Imagine you have to move your server to another provider. It is a time-consuming task to set up a new server, install all the applications, databases, and so on… and then configure it all the same way as before.

Of course you would copy a lot of that from the old to the new server. You could even make an image from the old server and copy it to the new. But wait, is it that simple though? Well, considering a few things it isn’t all that hard. I didn’t fetch an image, but made a backup from the old server using rdiff-backup. Then I set up my new server with the same OS as the old server (Ubuntu 14.04). Then I would adapt a few things to the configs of the backup and play the backup back into the new server. Voil√†.

Remote Password-less Root Access

At first you need remote root access. For this to work you usually have to modify your ssh daemon config found at /etc/ssh/sshd_config

If you can access your remote server with ssh root@<your server> you’re good to go.


Install rdiff-backup on both machines (server and your local machine).

sudo apt-get install rdiff-backup

Then we backup our remote server. Create a directory where you can put the backup and ensure you have enough space left. Run this as the root user:

rdiff-backup --exclude '/tmp/*' --exclude '/proc/*' --exclude '/sys/*' --exclude '/media/*/*' <your server>::/ <your local backup folder>

Now we have a backup of our server.

Preparing the new server

You probably have some kind of control panel. Install the same OS as you had on the old server.

We then again need remote root access to the new server.


On your local machine as root user:

rdiff-backup --force -r now --exclude '/boot' --exclude '/dev' --exclude '/tmp' --exclude '/proc' --exclude '/sys' --exclude '/media' --exclude '/etc' <your local backup folder> <your new server>::/

You can see I excluded the etc directory to not overwrite some important configuration files that need to stay the same on the new server.

On your new server make a new temporary directory anywhere. From your local machine as root we now copy the old configuration files to the temporary directory. I use rsync for this:

rsync -av /etc <your new server>:<your tmp folder>

Then go back to the shell of your new server and copy the file system and network configuration back into the configuration from your old server.
cp -a /etc/network <tmp-folder>/etc/ # network configuration
cp -a /etc/fstab <tmp-folder>/etc/ # file system table
cp -a /etc/resolvconf <tmp-folder>/etc/ # nameserver information

Finally overwrite the etc folder from your new server:

cp -a <tmp-folder>/etc /

Everything should be up and running by now.

Flattr this!

SpiderOak upload never finishes

If you encounter problems with your SpiderOak installation never finishing (on Ubuntu 14.04) with the upload, but it’s always running then you may try the following.

At first download the SpiderOak package. Then open up a terminal and use the following commands.

Change to your home directory and remove the old installation: (this will not remove your files stored in SpiderOak!)

rm -r .config/SpiderOak 
sudo apt-get remove --purge SpiderOak spideroak:i386

Now reinstall SpiderOak:

sudo dpkg -i spideroak.deb 
SpiderOak --setup=-

This will hopefully reinstall your SpiderOak and synchronize it with the server again. The¬†last step can take a long time. So I actually faced this problem twice. Probably because I used the same device name on two different machines (which ‚Äď guess what ‚Äď you shouldn’t do ūüėČ ).

First time I encountered this problem this procedure resolved my problem, the second time the synchronize step never finished (and with never I mean like for 12 hours) even with a decent internet connection – so I cancelled it. I then repeated that procedure but set up a new device name. After an also quite long (few hours) synchronize period my SpiderOak finally came back to life.

Hope this helps you if you encounter similar problems.

Flattr this!

2D Selection Outline Shader in LibGDX

For our new and awesome action RTS game Asteroid Fight we wanted a nice selection outline for the units. Everything I found on the web so far was intended for use with 3D games where you could use e.g. the wireframe and render the wires with a thicker line and onto that the actual 3D model so you get the impression of an outline.


So here I will present you a simple fragment shader that you can use to add a nice selection outline to your 2D game.

I will assume that you know LibGDX and that you know how to use shaders with this framework. If not I recommend you go to first and work through this tutorial.

GLSL fragment shader code:

#ifdef GL_ES
precision mediump float;
precision mediump int;

uniform sampler2D u_texture;

// The inverse of the viewport dimensions along X and Y
uniform vec2 u_viewportInverse;

// Color of the outline
uniform vec3 u_color;

// Thickness of the outline
uniform float u_offset;

// Step to check for neighbors
uniform float u_step;

varying vec4 v_color;
varying vec2 v_texCoord;


void main() {
   vec2 T = v_texCoord.xy;

   float alpha = 0.0;
   bool allin = true;
   for( float ix = -u_offset; ix < u_offset; ix += u_step )
      for( float iy = -u_offset; iy < u_offset; iy += u_step )
          float newAlpha = texture2D(u_texture, T + vec2(ix, iy) * u_viewportInverse).a;
          allin = allin && newAlpha > ALPHA_VALUE_BORDER;
          if (newAlpha > ALPHA_VALUE_BORDER && newAlpha >= alpha)
             alpha = newAlpha;
   if (allin)
      alpha = 0.0;

   gl_FragColor = vec4(u_color,alpha);

So what I essentially do is I check every neighboring pixel in the range of u_offset and get the maximum alpha value from those pixels, but if every pixel I check has an alpha value above ALPHA_VALUE_BORDER I set the alpha value to zero, so that means we are completely inside our object, but we only want the outline.

My vertex shader looks as following:

uniform mat4 u_projTrans;

attribute vec4 a_position;
attribute vec2 a_texCoord0;
attribute vec4 a_color;

varying vec4 v_color;
varying vec2 v_texCoord;

uniform vec2 u_viewportInverse;

void main() {
    gl_Position = u_projTrans * a_position;
    v_texCoord = a_texCoord0;
    v_color = a_color;

It’s more or less the default vertex shader. Nothing special here.

Loading the shader:

public ShaderProgram shaderOutline;
public void loadShader() {
String vertexShader;
String fragmentShader;
vertexShader = Gdx.files.internal("shader/df_vertex.glsl").readString();
fragmentShader = Gdx.files.internal("shader/outline_border_fragment.glsl").readString();
shaderOutline = new ShaderProgram(vertexShader, fragmentShader);
if (!shaderOutline.isCompiled()) throw new GdxRuntimeException("Couldn't compile shader: " + shaderOutline.getLog());

As you can see, in my setup I saved the vertex shader as shader/df_vertex.glsl and the fragment shader as shader/outline_border_fragment.glsl .

And this is how you can use the shader:

// ... previous draw calls ...
shaderOutline.setUniformf("u_viewportInverse", new Vector2(1f / width, 1f / height));
shaderOutline.setUniformf("u_offset", outlineSize);
shaderOutline.setUniformf("u_step", Math.min(1f, width / 70f));
shaderOutline.setUniformf("u_color", new Vector3(red, green, blue));
batch.draw(textureRegion, x, y, width, height, width, height, 1f, 1f, angle);
// ... next draw calls ...

I hope I could end your search for the 2D outline rendering. Hit the Flattr button below if I could help you.

Happy coding and have a nice day! ūüôā

Flattr this!

Create virtual machine in VirtualBox from real partition

If you already have Windows 10 (Technical Preview) installed on a real partition and you want to boot it from Linux Ubuntu you can do so very easily. I assume you have VirtualBox installed. Get it at otherwise.

At first find out what your Windows 10 parition is. You can use blkid for that.

It will give you output similar to the following:

/dev/sde1: LABEL="win10" UUID="75C..." TYPE="ntfs"
/dev/sdd1: LABEL="Data" UUID="723..." TYPE="ntfs"

When I partitioned my drives I already named the partition “win10” so it is easy to spot later on. In my case the partition is sde1 and the disk is sde.

sudo VBoxManage internalcommands createrawvmdk -filename win10.vmdk -rawdisk /dev/sde

This will create our virtual machine disk from the real partition.

Hit Alt-F2 and enter gksudo VirtualBox (we have to run it as root for physical partitions)

Create a new virtual machine and use Windows 8.1 (64-Bit) as your operating system. (“Other Windows” won’t work and will give you the error 0x0000005D if you try to boot it)

Assign it a proper amount of RAM. Then select “Use an existing virtual hard drive file” and select the previous created vmdk-file. Now boot into your virtual machine. Windows 10 now needs to repair (don’t worry, it’s because of the changed file system) and restart.

You should now be able to boot into Windows 10 from Ubuntu.

Flattr this!

Create a bootable Windows 10 USB drive from Linux Ubuntu

If you want to try out Windows 10 on your machine (and not within a virtual machine) and only have Linux operating systems around you and no DVD burner (or don’t want to spend a blank DVD) and a 4.3 GB USB drive¬†you may want to follow this guide.

You can download the “Windows 10 Technical Preview ISO” from Microsoft for free as long as it isn’t released. Grab it from

As the current version of UNetbootin obviously is missing the required “show all drives”-feature to copy to a user-selected partition you need to download the older Version 494 from

At first we need to create a NTFS partition on the drive. I used gparted for that. Find the current partition of your USB drive, unmount and remove it and create a new one¬†with NTFS as the file system type. Remember the device name of your USB drive as stated in gparted. In my case it was “/dev/sdl1”.

Now mount the USB drive again. Mark the previously downloaded unetbootin as executable and start it.

Choose diskimage and find the downloaded Windows 10 ISO.

Then check “Show all drives” and select the device name from your USB drive. Press “OK” and we’re almost done.

Depending on the possible transfer speed the copy step will require some time to finish and will stay at 55% for quite some time. So don’t abort the copy process without waiting a little bit.

Flattr this!

Starting Ubuntu Server with Chromium as the only graphical application

I have a personal server at home with JIRA, Stash, Jenkins, Nagios and the like installed on it. I wanted to frequently see the status of those applications and also the visitor count from my Piwik installation.

My server:

Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty

So I decided that my server should start up with the chromium browser that will open a custom html page which will switch between the various sites automatically.

We start with installing the required packages:

sudo apt-get install xorg chromium-browser

Then set up an init script that will be invoked on startup.

sudo vim /etc/init.d/monitor

In this script we basically just start the X server with the browser: (wrapped in an usual service script)

xinit /usr/bin/chromium-browser --app=http://localhost/monitor/monitor.html --user-data-dir=/home/klaus/.config/chromium &

Now we add the script to the runlevels:

update-rc.d monitor defaults 99 01

This will start the monitor as the last item and kills it the first. More information can be found here.

The browser will not start in fullscreen. For this to work, you have to edit the following file (adapt path accordingly of course):

sudo vim /home/klaus/.config/chromium/Default/Preferences


Flattr this!

Check_mk and Ubuntu 14.04 Server

If you want a quick monitoring solution with a comprehensive list of automatically generated checks then check_mk is the way to go.

Requirements for this guide

  • Ubuntu 14.04 Server
  • Running Nagios3 installation


On the systems that you want to monitor you have to install the check-mk-agent and the xinetd package from the Ubuntu repos. Also recommended is the check-mk-agent-logwatch package.

Open the /etc/xinetd.d/check_mk file and change the disabled attribute from yes to no. Also uncomment the only_from attribute and adapt accordingly.

Restart the xinetd daemon:

/etc/init.d/xinetd restart

And check if the agent port is open:

netstat -tulpn | grep 6556



On the system where the Nagios installation is running, install the check-mk-server package.

Adapt the check_mk configuration found at:

vim /etc/check_mk/

Insert the hosts you want to monitor.

Make an inventory of the hosts by running the following command:

su nagios -c "check_mk -I"

Check_mk will now automatically retrieve the possible checks for the hosts! Awesome! ūüėČ

Write out the configuration by running the following:

su nagios -c "check_mk -O"

And restart Nagios. Voil√°!

If you want nice visualizations of your data, then you also have to install the pnp4nagios package.

Flattr this!