« Back

Blog

Here is my small, simple micro-blog about my personal life. I will share everything from what I learned, my experience with technology and other daily struggles. I'm keeping it lite and straightforward.

i3blocks battery blocklet in Rust

Battery status in Rust

I have tried Rust and wrote a battery blocklet for i3blocks.

Read more »

Zillertal

Back home

Zillertal

How to use ssh as a socks5 proxy with autossh

Unsecure puplic networks are very common. Here is a simple shellscript, that using random hosts from ~/.ssh/config and create a socks5 proxy over autossh.

To randomized my ssh tunnels, I use a small script. This script looks at my ~/.ssh/config for hosts with the comment #socks5 after the Host and picks one out. I use autossh to maintain the connection.

AUTOSSH(1): autossh is a program to start a copy of ssh and monitor it, restarting it as necessary should it die or stop passing traffic.

#!/bin/bash

# ssh user config (http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config)
SSH_CONFIG=~/.ssh/config

# local port
PORT=8888

# export pid to file
export AUTOSSH_PIDFILE=/tmp/proxy.pid

# array with hosts from SSH_CONFIG.
# append "#socks5" at the end of the Host line.
# Example: "Host yourHost #socks5"
eval HOSTS=( $(awk '/^Host(.*?)#socks5$/ {print $2}' ${SSH_CONFIG}) )
N=1
for index in `shuf --input-range=0-$(( ${#HOSTS[*]} - 1 )) | head -${N}`
do
        echo -en "Host: ${HOSTS[$index]} Port: ${PORT}\n"
        # using autossh - Automatically restart SSH sessions and tunnels
        AUTOSSH_DEBUG=1
        AUTOSSH_GATETIME=0
        autossh -M 20000 -N -D ${PORT} ${HOSTS[$index]}
done

I start the script automatic on boot with Supervisor

/etc/supervisor.d/proxy.ini:

command=/path/to/proxy.sh
autostart=true
autorestart=true
startretries=3
user=YOURUSERNAME
stderr_logfile=/var/log/proxy.log
stdout_logfile=/var/log/proxy.log

Now you can set 127.0.0.1:8888 as a proxy when your application support SOCKS5

State Pattern example in PHP

The State pattern is a solution to the problem of how to make behavior depend on state. Here is a simple State Pattern example in PHP.

Read more »

Berlin

Brandenburger Tor, obviously.

Berlin

Paris

Louvre

Paris

Barcelona

View of Barcelona from the Port Cable Car.

Barcelona

Sint Maartenszee

Sint Maartenszee

Sint Maartenszee

Amsterdam

Amsterdam

Amsterdam

How to handle GPG encrypted files with VIM

How to easy encrypt and decrypt files with GPG and VIM's autocommand.

I like to write small notes in simple files with vim. Sometimes I want to encrypt these files, so that not everyone can everything read in there. I was looking for a solution and found this.

Read more »