Tired of people on your wall having no critical thinking at all?

This is going to be a short and somewhat ranting post about a new site I set up today.

As you have probably noticed if you are active in any kind of social network some people tend  to share a lot of stuff with no critical thinking what so ever, some of which is far over the line of being slander or even hatespeech with no proof what so ever about the validity of the statement. As someone who grew up in Sweden in the 90s this is completely unbelievable to me since I’ve had critical thinking pushed on me over and over again during my school years but now I have heard the excuse “We weren’t told to do critical thinking when I went to school” one to many times and I am getting sick and tired of it. Usually I just ignore them but some of them are so far over the line that I just can’t, however arguing about it is not how I want to spend my evenings so today I set up a new website and from now on instead of pointing out the importance of critical thinking I am just going to post the link instead. The site just contains six steps to source criticism and is available in Swedish and English. Feel free to use it if you want.

Is this going to change someones mind? No, probably not but at last it feels good.



The top photo in this post was taken by Tim Dobbelaere and is released under the CC-BY-SA Licence. It has been cropped a bit and the original is available on this flickr page.

Read More

How to stream audiobooks to your phone with Booksonic

If you are like me then you probably love audiobooks and services like Amazon’s Audible that lets you stream your books directly to your phone. Audible is great but what about all those other books that you buy on cd in the store or as mp3 downloads online, or how about those that you download for free from sites like Librivox? Those you need to put on your phone before you can listen to them right? No, you actually don’t anymore.

Until recently I used a software called Subsonic to stream audiobooks to my phone. Subsonic is a great piece of software but it’s aimed at music so there are some problems with using it for streaming audiobooks, for example you can’t get book descriptions in the app. Back in October this lead me to start looking for a replacement but surprisingly it seems there really aren’t any, or at least there wasn’t back then. Now there is Booksonic, the fork of Subsonic and DSub that I started working on when I realized that was going to be stuck with Subsonic for my streaming needs.

So what is Booksonic then, well the short version is that it’s Subsonic for audibooks. You install a server software on your home PC and then you connect to it with your android phone and it will allow you to stream all your audiobooks to your phone regardless of if you are at home or not. The server is completely free but the Android app will cost you a one time fee of $3, well worth it if you ask me but you probably should ask someone else since I’m a bit partial, being the developer and all.


So, now that we know what Booksonic is lets get started installing it. In this guide we will be installing it on a windows machine but it’s also available for Debian based Linux like Ubuntu and Mint. For mac and other systems there is a war file so you can run it with tomcat.


Step 1. Getting the server

The server is available for download at booksonic.org, since we are installing it on a windows machine we will be downloading the Windows Installer version.

Step 2. Installing the server

Once the file has been downloaded you double click it to start the installation. The installer will start to look for java on your machine and if it can’t find it it will ask if you want to install it, hit yes. Once it finds java you will get a welcome screen, here you should click the next button. The next screen will allow you to change where to install booksonic, unless you have a specific reason for changing it you can leave it as it is and click Install. Now uncheck the view getting started document checkbox and hit finish. Congratulations, you have installed the Booksonic server!

Step 3. Setting up the audiobook files

Now it’s time to start setting your up audiobooks. Find somewhere on your computer where you want to store them and go there. I have a folder called Ljudbocker on an external drive called F so for me the location would be F:\Ljudbocker\. In your folder create a new folder for every author you have. It will look something like this

Now go into into the author folders and create new folders for every book. I like to use the format “year – Bookname”, that way I can quickly see what order they should be listened to directly in my file manager but you can use just the bookname as well if you want. Booksonic will get the year from the tags inside the files. As an example my folder for Arthur Conan Doyle looks like this.

Now it’s time to put in your files. Booksonic can handle all major audio file formats. Put your audio files into the books folder, to add a cover put it in as a jpg called cover, if you want to add a book description create a file called desc.txt and put you description in that. To add a narrator you create a file called reader.txt and put in your narrator there. As an example here is my directory for A Study in Scarlet.

As a last step we are going to set the tags of the music files. For editing those I am going to use a free piece of software called Mp3Tag, it can handle a lot of different formats including mp3, m4a and m4b.

How you prefer to tag the files is up to you but for me I do it like this. If I have a chapter name I set that as the title, if not I set the books name as the title. I set the Author as both Artist and Album artist. The Album is of course the book name, the year I prefer to set as the year the book was released but if you want to use the year the audiobook was released then go for it. Then I set the track number and the cover image. If you want to save some space you don’t have to set the cover in the tags since you already have the jpg in the folder but I recommend you set it anyway in case you want to use it somewhere else. To make it a bit easier for you here is what it looks like for my track 1 of A Study in Scarlet.

Step 4. Configuring the server

Now that you have the server and files in place we need to configure the server so it knows where to find your audiobooks and since we are going to make the server accessible from the Internet we are also going to change the default password. To do this click this URL and it will open Booksonic for you in a new tab. http://localhost:4040

Once the page has loaded sign in with both the username and password admin.

When you sign in for the first time you will be shown a getting started guide. The first thing on this guide is changing the password so lets do that, click on Change administrator password and it will take you to the manage users page. Make sure the user admin is selected and then check the change password box. Enter your new password in the textboxes that appear and hit save. You will be signed out, don’t worry about that, it is normal.

Sign back in with your new password and you will once again see the getting started guide. This time click on Set up media folders. You will see that there is already one folder added that is called music, you can rename that to whatever you want but I usually go Audiobooks, in the field for the folder put in the location to the folder containg your author folders, in my case this was F:\Ljudbocker\. Once that is done, scroll to the bottom and hit save. After this I recommend you do a scan, you can do this by clicking the link called Scan media folders now.

Click on home in the top navigation bar and you will be taken back to the getting started guide, at the bottom of the page you will see a link called Don’t show this again, click that. An alert box will pop up telling you how to get the guide again, click ok.

Step 5. Enable internet access

Congratulations, the server has been completely set up and if you only want to use it at home you are ready, if you want to use it from outside your own network you need to port forward port 4040. Since port forwarding is different on every router I am not going to shw you how to do that but you can find instructions for your router at this portforwarding.com page. You only need to forward port 4040 and should ignore port 80.

Step 6. Installing the Android app.

Now it is time to install the Android app. You can find it by searching for Booksonic on Google Play or clicking this link

Step 5. Configuring the app

It’s time to configure the app to use your server and doing so is very easy.

If you prefer video tutorials Kenneth Loebenberg made one that you can find here, otherwise continue reading.

Open your app and click the three lines at the top left, this will get you a sidemenu or drawer as it is called in the android world. Click on settings. Now click on servers. You will already have a demo server here so instead of adding a new one we are going to modify the one you already have. Click on the demo server. Now click on name and name it Audiobooks.

Before we set the server address we will need the IP of your server so on the machine you installed Booksonic go to popeen.com/tools/ip, this will show you your IP address. Now on your app hit server address and set it to http://IP:4040 where IP is the ip of your server. Remember to use both http:// and :4040 or it will not work.

Now set the username and password in the same way and hit Test connection. It should say Connection is OK, if you get anything else go back and redo step 5 and if you still can’t get it to work you can contact me and ask for help at [email protected] or leave a comment below. Once the tests sais Connection is OK you can hit the arrow at the top left corner a couple of times until you get the lines again, click them and the click home.

Congratulations, you are now ready to start streaming your own audiobooks.


I hope this guide has helped you understand how to use Booksonic and if you have any questions at all don’t hesitate to leave a comment below, send me an email at [email protected] or visit /r/Booksonic on reddit. If you have any suggestions on how to make Booksonic better I would love to hear them (once again, here, email or reddit), you can find all the planned features here

To end this post I would like to recommend you go and check out David Clarke at verysmallrocks.io. He is the reader of the free Sherlock Holmes books (LibriVox recordings) you saw in my collection and unlike some other LibriVox readers his recordings are every bit as good as you would get if you went to the store and bought an audiobook. If you are seeing this David, thank you once again for your amazing work!

Read More

Converting subitles from wsrt to srt

If you are from Sweden or are watching swedish TV anyway chances are that you have come across subtitle files with the extension wsrt. I know I have, and with that, prepare for one of my unnecessary long rants where I try and explain things, if you are only interested in the converter tool you can find it here.

For those that don’t know SubRip or srt is a popular subtitle format for videos on the internet. wsrt on the other hand is not, in fact as far as I know the only sites that use it are SVTPlay and ÖppetArkiv, both of which are run by Sveriges Television. This leads me to believe that wsrt is probably an in-house format for subtitles that Sveriges Television use. Well, that’s great but what if you want to play them in an external player like say VLC or Emby? Then you are out of luck, it wont work because they don’t support the format.

Now here is the good part, wsrt just as the extension suggests is actually based on srt. In fact wsrt and srt files look almost identical but wsrt has a few extra features. Great, then I can just rename the file to have the srt extension and it will be fine you might be saying now, and well, you are partly right. For some players like for example VLC it will actually work but for some it won’t. The reason for this is a small but annoying change that was made to the time in the wsrt file format. Lets see if you can catch it.

00:00:42.640 –> 00:00:48.720
00:00:42,640 –> 00:00:48,720

Ok so the top one is in the wsrt format and the bottom one is in the srt format. The difference is very small but enough to make a lot of players out there say that no, I don’t know anything about this and if you are lucky just keep playing the video without subtitles or if you are unlucky, BAAM, the player will crash.

So what is the small difference, did you catch it? Ok, ok, I’ll tell you. In srt there is a comma, in wsrt this comma has been replaced by a dot. That’s it, well to be honest there are some other additions made to the wsrt format but they don’t seem to mess things up as long as you get those dots replaced. And replacing the dots, is an easy task, it’s just extremely time consuming. Considering the file I took the example from had about 5500 lines meaning there is probably about 1100 lines where you need to go in and replace the dot with a comma. There is no way that I am going to do that for every wsrt file I want to use, so how do we fix this?

Easy, we do  a quick search and replace and all the dots will become commas. Ohh, wait maybe not, don’t most sentences usually end with a dot? Yeah, silly mistake you might think, there is no way that happened, unfortunately you would be wrong, I am that stupid from time to time. So now that we have established that how will we go about doing it then? It’s actually pretty easy, what we do is we search for all the dots that have a character after them and then we replace that dot with a comma. And we are done.

To make this process a little bit easier in the future I made a small web utility that does this for you, the tool is available for anyone to use on my tools page and the source has been released on GitHub. At the moment the tool won’t do anything about the other improvements to the format, I might go back and add that later but it isn’t really a problem as far as I can tell so probably not.

Update: The tool will now also remove other wsrt specific meta data. I think all of it will get removed but if you should find anything that gets left please leave a comment and let me know so I can fix it.

Update 2: Apparently some players can’t handle files encoded in UTF-8. Should you get some weird characters when using the text try to encode it with windows-1252 instead. I added an option for this to the tool, I also fixed a problem with the file name that occurred on Firefox.

Read More

Hello world!

Hello world!

There it is, my first blog post, isn’t it lovely? Really? you don’ think so? Well ok then, lets start over.


Hello there!

My name is Patrik Johansson and this is my blog.

I am a geek from Sweden that loves programming and scripting, especially for the web.  My passion for coding came relatively late, when I was 16 I took a java class at school. I struggled with the abstract way of thinking and really didn’t like it but I still wanted to learn how to program so the next year I once again took a programming class, this time PHP. After the first lesson I was in love and I started coding a lot in my spare time. I really can’t tell if I had just wrapped my head around the abstract way of thinking during the last year (doubt it) or if there was something else that made me love PHP.

One of the first real things we where told to code in my PHP class was a guestbook. I did but when I was finished I kept coding the rest of the evening and what I ended up with was a complete forum. Looking back at it now I am sure actually using the forum in a real life scenario would have been a very very bad idea, I was just starting out and security was nothing I had started thinking about. Still, back then it was amazing to me how quickly something like this could be done and how fun it was to do.

The next big(ish) thing I remember working on was a blog platform to use on my website. It actually turned out pretty good and I was even able to create a screen reader for it using a hidden API in google translate. I used the platform on my website for a couple of years without any big problems, about a year after I started using it on my website the comments stated beeing flooded by spam, I remember that one day I actually got over 500 comments on a single post, all of them spam. Ouch! This was a big milestone for me, it was here I started looking in to security for real, it started out with just preventing spammers from automatically spamming my site but ended up with real security like preventing SQL injections, slowing down brute force attacks, 2-way authentication and stuff like that. Well that’s a bit of a stretch actually, adding 2-way authentication is relatively recent for me, I’m a bit embarrassed to say that I started using it in my projects in the late 2013.

So how bout now?

Today I no longer have a favorite language but tend to use whatever I think will be the most suitable for getting the job done, be it PHP for web projects or java for android apps. And of course powershell for writing remote administration tools at work.

Most recently I have started working on a project I call Booksonic, it is an android app for streaming audiobooks from your computer (or other server) to your phone and is forked from (based on) an app called DSub that does the same but for music. On the server side these apps connect to a server software called Subsonic. While Booksonic will work with the original Subsonic and all the forks of it out there for some of the Booksonic features you need more data from the server then it normally gives out. This means that I have also started working on a Subsonic fork called Booksonic Server.

As a last note I should probably mention that I do freelance work both inside and outside Sweden and I invocie through a company called Firmify so if you ever need help with anything don’t hesitate to ask and I am sure we can find a price we will both be happy with. Prices starting at $0 😉

Read More

A walk-trough of setting up this blog

So I thought it would be nice to take you on a walk-trough on how this blog has been set up in case you might be might be interested in starting one yourself. In the post I will not go into details about the different configurations of the blog software but more into hosting, domain and how to actually get it online. In each step I will tell you a little about why I have chosen for example a specific service.


So lets get started.

1. Domain

For me, choosing a domain name for the blog was easy, actually I bought it long before this blog was even thought of. Popeen is my nickname both online and offline so it just feels natural to me that it should also be my home on the web. When I first wanted to register it back in 08 it was already taken but I kept my eye on it and when suddenly it became available I rushed to buy it. And here is the part you are probably here for, where did I buy it? I bought it from a company called Loopia and since then I have kept it there. A couple of other domains I had at Loopia I have actually moved over to GoDaddy, not because they are better in some way but because they where cheaper at the time the domain  needed renewal. So for buying a domain go for what is cheapest at the moment, just make that you pick a serious company and that they will allow you to change the nameservers yourself, if you are unsure go with Loopia. When its time for renewal, have a look and see if things have changed or keep using what you choose in the first place if you don’t care for a couple of bucks here and there and are happy with what you got. If you decide to switch just remember that there often is a transfer fee from your new registrar.


2. Hosting

When it comes to hosting there are a ton of alternatives out there and probably just as many opinions. But in my case I have one host that I use for everything and that I love, Inleed. The speed of the host is good and so is the price tag. At the moment prices start at 19SEK/month, that is less then $3. But speed and price in all honor, where Inleed really shines is the support. It’s not often that I have had to contact them about something but when it has happened the response has been blazing fast even at very uncomfortable office hours. An example of this was this new years eve when I contacted them by email in the evening, in three minutes I had a response and in five the problem was solved. They are always quick to help and you feel like they really care about you. I’m sure there are other hosts out there that are just as good but there are also a lot of them that are really bad so why take the chance, so I say go for Inleed. If you go for something other then Inleed make sure that they support PHP & mySQL and that you will have FTP access to the server.


3. DNS

DNS? What? Isn’t that included in my domain you may say, and yes, it usually is, although it actually costs extra for Loopia users if you want to use theirs (this is probably true for some other registrars as well). But the thing is, you don’t want to use their DNS. You want to use a service called CloudFlare. Why would I want to use that you are probably saying now, well there are a lot of reasons for it and it would take up at least a full blog post to mention them all so lets just summarize them with that CloudFlare makes your website faster, more secure and that the base plan is free. If you want to read more about it you should have a look at the CloudFlare overview page. When you have registered your domain at CloudFlare you will get two nameservers back, they look something like this:


Keep in mind that yours will probably not be the same as the ones above. Once you have yours you head over to where you registered your domain and head into the domain settings. Since this is a bit different for every registrar I can’t tell you exactly how it will look but what you want to do is find where to change the nameservers and then set them to the ones you got from CloudFlare, if you cant find the settings ask the support and they will help you.


4. Software

Now we are getting in to my favorite part, the software. First of all you will be needing an FTP Client so that you can upload your files to the server, I recommend the FileZilla Client, it’s really good and it’s free. Secondly you will be needing your blogging software, for this we will use WordPress. If your host comes with a One-Click Setup you could use that but to be sure that you get the latest version I would recommend you install it by yourself. Installing it is really easy and I will be putting together a blog post on how to do it soon and add a link here but for now if you need help you can have a look at the wordpress support site.


5. Themes and Plugins

If you have been reading this post to set up a blog on your own and following along then first of all shame on you, you should always be reading the complete instructions before starting, secondly congratulations on your new blog. While the blog is technically finished it might be a good idea to install a custom theme on it to make it look a little better. You can find a lot of both free and paid themes by using google or you can head to the theme section on the wordpress website


Thats it, now you know how this blog is set up and how to do it yourself should you ever want to set up your own blog.


The top photo in this post was taken by Torkild Retvedt and is released under the CC-BY-SA Licence. It has been cropped a bit and the original is available on this flickr page.

Read More