orreMBA 2014-07-29 kl. 15.10.43

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.

1

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

2

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.

3

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

4

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.

5

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

orreMBA 2014-06-30 kl. 15.25.55

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)?
Read more…

orreMBA 2014-06-12 kl. 11.01.37

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.
Read more…

orreMBA 2014-06-02 kl. 09.59.23

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.