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!

Asteroid Fight


Asteroid Fight is an online multiplayer action realtime strategy game played in outer space. You start with your hero and a mining probe at your warp gate and have to smash the enemy’s warp gate. The game is intended to be played with multiple players where you play 3-on-3 in a team.

Every team member can pick another hero with unique abilities to complement each others abilities. Throughout a game you can then build bases on asteroids and upgrade your hero with new and better abilities.

The game is still in the works, but a public alpha will be available soon!



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!