Note to self on updating Wordpress plugins via git-svn

I host my Two Factor Auth Wordpress Plugin on Github and I run git svn locally to be able to sync the Github git repo with the Wordpress plugins SVN repo.

But, it’s a bit of a hassle and I don’t update the plugin often enough to remember what step to take.

The assumption is that you’ve followed this guide to setup you local repo with svn and git remotes.


Write code in local git feature branches as usual. Push the finished code to Githubs master branch and add a git tag.


Create a new local git branch (or use a clean old one) and merge local master branch (remember to squash all commits!) into this one. It has to have a straight history.


Run git svn rebase the see that the history matches with the remote Worpress svn repo.


Run git svn dcommit --username yourusername to push the code to Wordpress svn repo. Remember that you have to change all the tags in your readme.txt and you main plugin file to match the new release version.


Run git svn tag x.x to copy trunk and create a new remote tag/release from it.

Use your Synology as a local DNS cache

It is totally unnecessary to have all your computers, iPad’s and iPhone’s ask your router to resolve domain names to an external DNS server whenever you click a link or enter a domain name.

Why not have something that sits on your local network and forwards unknown DNS requests and then saves the cache so the next time that request would take ≈ 1 ms instead of ≈ 50 ms (or ever more if you use your ISP’s DNS service)?

Make:r - How I did a fishing lure / jerk bait

This is going to be a odd post in contrast to all other posts I’ve written. I like to make things, it doesn’t matter if it’s software or hardware. Recently I started to fish again after a few years on hold.

This time I wanted to fish for pike with a method called jerk bait fishing. These baits/lures does not have their own movement pattern like most lures has. These baits you have to jerk to get them moving in a, for the fish, compelling way. So it’s one step back to a more manual way of fishing.

To be able to jerk efficiently you have to have a really stiff and short pole (pun intended) and a non elastic wire.

What’s nice with these baits is that you quite easily can make your own since they don’t have to move by them selves in a specific way.

Angular.JS filter to make url:s in text clickable

This is a simple filter I made for Angular.JS to make url’s in text clickable. Make sure you place the content and filter in the ng-bind-html attribute of the HTML element. Otherwise the HTML won’t be parsed.

E.g. <p ng-bind-html="comment.body | parseUrl"></p>

Here’s the parseUrl filter:

angular.module('filters', [])
.filter('parseUrl', function() {
    var urls = /(\b(https?|ftp):\/\/[A-Z0-9+&@#\/%?=~_|!:,.;-]*[-A-Z0-9+&@#\/%=~_|])/gim
    var emails = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim

    return function(text) {        
        if(text.match(urls)) {
            text = text.replace(urls, "<a href=\"$1\" target=\"_blank\">$1</a>")
        if(text.match(emails)) {
            text = text.replace(emails, "<a href=\"mailto:$1\">$1</a>")

        return text       

Also, make sure you inject filters in your main module / app.

Docker image "Wordpress NGiNX SSH" updated

Yesterday I updated my Docker image docker-wordpress-nginx-ssh github so it adds memcached and the superb Wordpress plugin WP-FFPC to Wordpress.

This makes NGiNX serve cached pages straight from memcached without going into PHP and Wordpress. It’s amazingly fast (try to reload this page you’re on now).

One thing though, you have to login and press the “Save” button on the settings page of WP-FFPC to activate it. But that’s all there’s to it, all NGiNX settings are already there.

To try it, just type docker pull oskarhane/docker-wordpress-nginx-ssh or to start a container straight away: sudo docker run -p 80 -p 22 -d -t oskarhane/docker-wordpress-nginx-ssh

Matrix in the terminal

Paste this your terminal.

echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|awk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'

Inspecting the firmware of a D-Link DWR-923 4G Modem

This will be a step by step on how to extract different parts of the firmware on a D-Link 4G router. This is just for fun and out of curiosity to see what they are using.

First, let get some tools. When inspecting/extracting and reverse engineering something you can’t live without a tool called binwalk. I downloaded 1.2.2 from here and after brew install libmagic I got it to compile on OS X Mavericks.

Remember to edit your ~/.bash_profile and add export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH to it to get it to compile.

The firmware for the modem I got from this Swedish tech site.

Nginx as a reverse proxy in front of your Docker containers

I have and create a lot of Wordpress sites for clients. As of now, I manually create new Docker container, create a nginx (or HAProxy) config file so the site can be reached on port 80 from the outside. And it’s a pain.

So I created this Python script that takes care of the container and config file creation. All you have to do i to reload nginx and the site will be up.

Check it out: Script to create wordpress docker container and nginx config file as reverse proxy.

This image illustrates what the setup will look like.

nginx reverse proxy

Here’s how you use it.

Going from audio to waveform image and back to audio

In my last post I showed how I found a great audio to waveform plugin and I also created a .PNG image with the waveform so I could save it.

But what if I wanted to read the waveform and create audio from it, i.e. convert it back.

The sampling frequency / resolution of the waveform plays a important role of course. In my last post the resolution was 100 pixels / second which is way too low (CD quality would be 44100 px/s).

Since it’s Javascript run in the browser it takes some time to generate an waveform image of decent resolution. My MBA seemed to take a resolution of 4000 px/s but not more.

So, I had to go with that.

Visualize sound

I find the visualization of sound interesting and I’ve found this fantastic js library to draw an audio file’s waveform on a canvas. Really cool stuff!

I converted it to an image as well, just for fun.
Now I want an audio player that can play a waveform image, so if you’ve ever heard of one please let me know!