Skip to main content

Building Powershell GUIs that won’t freeze when you use them

A few days ago I wrote about how important I think it is that you build a GUI for your scripts if they are to be used by anoyone else.

If you have ever built a GUI using Powershell however, you know there is a problem with it that I didn’t mention, that is, whenever your script is actually doing anything the GUI will freeze and windows will tell you it isn’t responding. This is not good as most users will then try to close it and try again. We don’t want that.

The reason this happens is because you are running your form (GUI) and logic in the same thread, something you should never do, problem is, Powershells support for multithreading is limited at best.

In the last post I also talked about my module EasyGUI and mentioned that there are features I wouldnt go in to in that post, one of those features is an easy way to use threads.

There are two ways to use threads in EasyGUI, I go through both of them below as well as a tip on how I prefer to use them.

Method 1.

Passing in a scriptblock to the thread, here I am creating it on the fly but you could also store the scriptblock in a variable and pass that to the function instead

New-Thread {
    0..60|Foreach-Object{
        $SYNC.myLabel.Text = $_
    }
}

Method 2.

You could also write the code for the thread in a separate script file and then pass that to the New-Thread function like this

New-Thread "D:\Program\Powershell\myThread.ps1"

One thing to be aware of is that the threads will start running emediatly when you create them. Often you might not want that. What I usually do is create the threads inside a scriptblock that I store in a variable, then when I need the tread to run I run that scriptblock. That would look something like this.

$myThread = {
    New-Thread {
        0...60|Foreach-Object{
            $SYNC.myLabel.Text = $_
        }
    }
}

#Now it's time to run the thread, simply type the & sign and then the variable containing the scriptblock
&$myThread

$SYNC ? Where did that come from?

Noticed that did you?

This is a variable that’s automatically created when you initialize the EasyGUI module. It’s a hashtable that’s synced between all threads so you can communicate between them. In the examples you see that I am using $SYNC.myLabel. This is created in the GUI like this.

$SYNC.myLabel = New-Label @{
    Location = "15, 15"
}

or like this

$myLabel = New-Label @{
    Location = "15, 15"
}
$SYNC.myLabel = $myLabel

If you want to see a complete example of a GUI script with threading implemented there is an example availiable in the Easy GUI repository.

Share

Booksonic Bridge Preview

As part of communicating more what happens with the Booksonic project I thought it might be a good idea to show what the Bridge will look like.
Important to know is that most parts of the bridge currently doesn’t have an interface but as they are created I’ll add them to this post.

If you have any suggestions or ideas for improvements to the design let me know in a comment here, at reddit.com/r/booksonic or at [email protected]

Share

Writing Powershell GUIs the easy way

One of the most important tools for any IT professional or service desk technician that works in a Windows environment is without a doubt Powershell. Not only is it extremely powerful but it is also very fun to work with if you ask me.

One of the great features of Powershell that I feel doesn’t get enough love from the Powershell community is the ability to write scripts with graphical user interfaces. Yeah, yeah, I know, you want to be able to do a quick change in the script and then rerun it inside ISE and anyone that doesn’t know how to use a console shouldn’t be in IT anyway, right? Wrong!

It is my firm belief that a clear and easy to use interface is just as important as the logic itself when you write a script that is going to be used by someone else. For most people, that means the interface needs to be graphical. I base this belief on having worked in an IT department at a large company for several years as well as maintained the Booksonic project since the start in late 2015. If you want to change my mind, feel free to try and do so in the comments below.

Now with that out of the way I will stop trying to convince you about writing user interfaces for your scripts, the fact that you are reading this post probably means that you are already doing it or thinking about doing it. Instead I am going to focus on how to do it in a way so the code is easy to read and maintain even once you start writing more complex UIs.

When I first started writing powershell I noticed that most examples of people writing powershell UIs get really messy real fast.

A typical example you may find online looks something like this

Add-Type -AssemblyName System.Windows.Forms
Add-Type -Name Window -Namespace Console -MemberDefinition '
        [DllImport("Kernel32.dll")]
        public static extern IntPtr GetConsoleWindow();     
        [DllImport("user32.dll")]
        public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);

[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0)       '

$font = New-Object System.Drawing.Font("Times New Roman",24,[System.Drawing.FontStyle]::Bold)

$label = New-Object System.Windows.Forms.Label
$label.Cursor = [System.Windows.Forms.Cursors]::Hand
$label.Text = "Click me to open popeen.com" 
$label.BackColor = "Transparent"
$label.ForeColor = "Blue" 
$label.AutoSize = $true
$label.Location.X = 15
$label.Location.Y = 15
$label.Add_Click = { Start-Process -FilePath iexplore  -ArgumentList "https://popeen.com" }

$form = New-Object system.Windows.Forms.Form
$form.Width = 600
$form.Height = 200
$form.Text = "Example form"
$form.Font = $font
$form.Controls.Add($label)
$form.ShowDialog() 

Now functionally speaking there is nothing wrong with that script and in fact it may not look that bad either but remember, all we have done is created a window and added one label to it. Imagine how cluttered this would become once you started doing some more advanced UIs. A better way to write the above that I have actually never seen anyone use other than me and some of my colleages would be using -Properties like this.

Add-Type -AssemblyName System.Windows.Forms
Add-Type -Name Window -Namespace Console -MemberDefinition '
        [DllImport("Kernel32.dll")]
        public static extern IntPtr GetConsoleWindow();     
        [DllImport("user32.dll")]
        public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);

[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0)

$label = New-Object System.Windows.Forms.Label -Properties @{
    Cursor = [System.Windows.Forms.Cursors]::Hand
    Text = "Click me to open popeen.com" 
    BackColor = "Transparent"
    ForeColor = "Blue"
    AutoSize = $true
    Location = "15, 15"
    Add_Click = { Start-Process -FilePath iexplore  -ArgumentList "https://popeen.com" }
}

$form = New-Object system.Windows.Forms.Form -Properties @{
    Size = "600, 200"
    Text = "Example form"
    Font = New-Object System.Drawing.Font("Times New Roman", 24, [System.Drawing.FontStyle]::Bold)
}
$form.Controls.Add($label)
$form.ShowDialog() 

While this takes up about the same space it looks much better right? This way a quick glance at the code gives you a much better understanding of what it is you are looking at.

If you choose to stop reading here and start writing your UIs in this way I beleive you will have a much easier time maintaining that script then you had before. However, I have taken it a step further in my scripts.

When I write a script I use a specific framework that makes the code even quicker to read and also includes some other nice features that I won’t go in to in this post but might make future posts about. One of the most important parts of this framework is a module I call EasyGUI and that you can download at https://gitlab.com/Popeen/EasyGUI

This module builds on the second example above and simplifies it even more. It also includes some other cool stuff that I also won’t go in to here but again, might make another post about. If we decided to use EasyGUI to write the example above it would look like this

Import-Module EasyGUI

Initialize-EasyGUI
Hide-Console

$form = New-Form @{
    Size = "600, 200"
    Text = "Example form"
    Font = New-Font -Font "Times New Roman" -Size 24 -Style $FONTSTYLE.Bold
}

$label = New-Label @{
    Cursor = $CURSOR.Hand
    Text = "Click me to open popeen.com" 
    BackColor = "Transparent"
    ForeColor = "Blue"
    AutoSize = $true
    Location = "15, 15"
    Add_Click = { Start-Process -FilePath iexplore  -ArgumentList "https://popeen.com" }
}

$form.Controls.Add($label)

Show-Form $form
Stop-Console 

I dont know about you but I find that to be much more readable then the first example we looked at, especially when you are working with a lot more then just a label.

It should be noted that not every forms object is in EasyGUI yet as I add them when I need them but adding them yourself should be very easy even for someone new to Powershell and if not just post a comment below and let me know what object you would like added.

I would love to hear your thoughts on this, is it something you would ever use or do you think I’m just talking rubbish when I say that UIs are this important or that a simple module like this can make it a lot more quick, fun and easy to code and maintain UIs.

Share

Booksonic FAQ

Last updated: February 15, 2018

Here I try to answer the most common questions I get regarding Booksonic. Depending on what the problem you are experiencing is the answers may not always apply to you. If the answer doesn’t help you or you have a problem that is not mentioned here do the following

  • Restart the app
  • Do the thing that fails
  • Go to the main screen of the app
  • Tap the dots at the top right
  • Tap “Send Log”
  • Enter a description of the problem and then send it to me, I will get back to you as soon as I can.

Another great resource for getting help with Booksonic is to go to the Booksonic Reddit and ask the question there. You can find it at https://reddit.com/r/booksonic


The app is just showing white and then crashes when I open it

This can sometimes happen if you dont have a profilepicture set on the server.
Go to the server in the browser and then Settings -> Personal then select a Profile/Personal image and click save.
There will be a fix for this in a later version of the app.


I can’t connect to the server outside of my network

Make sure that you have portforwarded the port you are using in your router. The default port is 4040. Also make sure that you are specifying the port when you try to go to the server. It should look something like this http(s)://example.com:4040


I can connect to the server in the browser but not in the app

Make sure that you enter http:// or https:// at the beginning of the adress and :4040 at the end. If you are using docker or tomcat, make sure to also include /booksonic at the end.


The app keeps crashing when I do X, please help

To be able to help you I need to see the log file. See the list at the top of this post for instructions on how to send me one.


The server sais “Folder not found” when I try to use a network location

This is due to how windows handles permissions. I have posted instructions on how to fix it at https://popeen.com/2016/05/27/using-a-network-shared-folder-in-booksonic/


Casting to Chromecast fails

This will happen if you use a self signed certificate as Chromecast does not support those. There is a workaround for it in the app that you can enable. Go to Settings -> Playback and enable Use device as a proxy, this should fix your problem.


What is the difference between cache and permanent cache?

Files that are cached by Booksonic will normally be automatically removed to make space for newer files once you have reached your cache limit. If you download them using permanent cache they will never be deleted automatically.


When I try to reset my password it says reCaptcha v1 is shut down, can I still reset it?

To reset your password do the following

  • Log on to the machine hosting the server
  • Stop the server, verify that you can’t reach it in the browser
  • use notepad to open c:\booksonic\db\booksonic.script, make sure that you set notepad to Any file or you won’t see it.
  • Press CTRL + F and search for INSERT INTO USER VALUES
  • After your username you will see enc:lots of numbers
  • Replace all the numbers that are before the ‘ sign with 626f6f6b736f6e6963
  • Save the file and close notepad
  • Start the server

You can now sign in with the password booksonic, make sure the first thing you do is change your password.

If you are running it on a Linux machine the file is probably located at /var/booksonic/db/booksonic.script


Is Booksonic open-source?

Yes! Booksonic is indeed open source. The server is a fork of the Subsonic server and the Android app is a fork of the DSub app.
You can find the source code for Booksonic at https://github.com/popeen


I have a great idea for a feature, how do I contact you about it?

You can send it to my email at [email protected], open an issue at https://github.com/popeen/popeens-dsub or post it on https://reddit.com/r/booksonic
While I might sometimes be a bit inactive in posting on GitHub or Reddit I always keep up to date with what is posted.

If you know how to code and want to implement the feature yourself, go for it. Once you are done, send me a pull request on GitHub and as long as the feature doesn’t break compatibility with regular Subsonic servers I will most likely accept it.

Share

Using a network shared folder in Booksonic

I recently got a  question regarding using a network shared folder in Booksonic so I thought it would be a great idea to show how you can do this.

  1. Press the windows button and R at the same time
  2. Type services.msc and hit enter
  3. Look for the service called Subsonic, rightclick it anc click on properties
  4. Go to Log On and make sure the checkbox for This account is checked then enter the login information for an account that has access to the shared folder.
  5. Hit ok and then rightclick the Subsonic service and restart it.

Now you should be able to use your network share within Booksonic without problems.

 

UPDATE:

Obs, keep in mind that you can’t use a mapped location, you need to use the full path, as an example mine is \\PopeensDataServer\D\Audiobooks or \\192.168.1.4\D\Audiobooks

Share

Booksonic server is out of BETA. I celebrate with an app giveaway

Last night I released the first full release of the Booksonic server. So whats new in this new Booksonic server? Well check out the changelog

* m4b files are now supported out of the box!
* The server is installed as Booksonic instead of as Subsonic
* Book descriptions and narrators are shown in the web GUI
* Music only features has been hidden in the web GUI, they are still there and will work fine if you use them in other apps.
* Design tweaks
* Bugfixes
* The API has been updated to show if the server is up to date.

But it’s not only the server that is getting an update, so is the Android app. A few minutes ago I uploaded a new version of it to Google Play and it should be live in a couple of hours is live. Here’s the changelog for that.

* The app will tell you if the server is outdated
* If app is in Swedish it will look at boktipset.se before checking Google Books if the server has no book description
* Added a classic theme to bring back the old Booksonic design
* Design tweaks to drawer (sidebar)
* Sleeptimer will reset the counter if you shake the phone
* Server and account info can optionally be included in import/export
* Bugfixes

To celebrate the first none beta version of Booksonic I have decided to have a giveaway where the 10 first people to comment on this post will get the app for free on Google Play. To get the app you need to enter a valid email when you comment so I have somewhere to contact you, this email will not be published as long as you only enter it in the email field.

As usual if you have any questions/suggestions/bugreports regarding the new versions of Booksonic you are more then welcome to submit them to the issue trackers at GitHub. Here for the server and here for the app, or as a comment on this blog.

UPDATE:

No codes left but you can still get the app for only $3 at Google Play

Share

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.

https://kallkritik.info/?lang=en

Credits:
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.

Share

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 2015 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.

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. For more instructions about this, check out this guide by Luite posted in the comments

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 this is what 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. There is a third party tool called Booksonic Library Editor that can help you manage these txt files which has worked great for me.
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. I should probably note here that while m4a and m4b usually works with Booksonic there have been some reports about weird bugs with them so I would recommend using mp3 files if possible.

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 you 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 7. Configuring the app

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

When you open the app you will see a login prompt. It is prefilled with the information for the demo server but since we have just set up our own server we want to use that instead. Change the address, username and password so they match your server and then click on sign in. If you don’t know the address of your server, click demo and move on to the next paragraph where we go in to more detail about this.

If you want to add more servers or change the server you just added you can do so by tapping the three lines at the top of the left, this will get you a sidemenu or a drawer as it is called in the android world. Click on settings. Now click on servers. You will already have your server or a Demo server here. You can either set up another server or modify the one you already have.

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], visit /r/Booksonic on reddit or read the Booksonic FAQ. If you have any suggestions on how to make Booksonic better I would love to hear them (once again, here, email or reddit).

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 the quality of the recordings are just as good as the stories. If you are seeing this David, thank you once again for your amazing work!

Share

Converting subtitles 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.

Share

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 of the coding I do today that isn’t work related is 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.

Share