Press "Enter" to skip to content

Category: Code Examples

Examples of code you can use wherever and for whatever you want!

Package tracking state card in HomeAssistant (using Aftership)

Recently I felt the need for a HomeAssistant component which would allow me to track all my parcels I am expecting. As with all DIY people out there this list can get lengthy. I found some others attempting to do something similar, but this would only cause more and more problems for my specific case (logs getting flooded on missing packages, losing the overview on the HomeAssistant homepage, …)

I am using AfterShip as this is a platform that allows me to add (for free!) all my packages and automatically look for missing information. And they have a very easy to use API!

Behold the AfterShip HomeAssistant State Card!

This allow you to view all your tracked packages in a single card. For now it is still very basic and will need to be installed separately from HomeAssistant, but let’s see where I take this.


22 June 2018: Just finished developing the plug-in. I am planning on making some clean-up changes and then releasing it to the public.

24 June 2018: I have released the initial code on GitHub. I will still try to make some small fixes of issues I see during my initial usage!

Leave a Comment

Increase cache size in Kodi Krypton(V17) for faster and smooth playback

When you are streaming videos from a network device to Kodi, you may feel some slowness, stuttering, buffering or complete interrupts in your video. This is not enjoyable at all. In Kodi Jarvis(V16) you were able to change the cache, but in the new version the tags have changed!

Create the file “advancedsettings.xml” in the userdata directory of Kodi. Depending on what system you are using, find the location below:

Operative system File path
Android Android/data/org.xbmc.kodi/files/.kodi/userdata
iOS /private/var/mobile/Library/Preferences/Kodi/userdata/
Linux ~/.kodi/userdata/
Mac /Users/<your_user_name>/Library/Application Support/Kodi/userdata/
LibreELEC/OpenELEC /storage/.kodi/userdata/
Windows  %APPDATA%\kodi\userdata

Using the following code in the advancedsettings.xml file, your Kodi will buffer the data into your ram and speed up buffering in general. Note that you need 3 times the amount of available ram as is defined in “memorysize”(in bytes). For the example below you would need around 400Mb of free ram.

Happy watching!


Share your Unity game’s URL every build!

As a game developer I want to share my current game quickly with friends and testers. As going to the build page, clicking the share-link and then updating a webpage is a lot of work, I went looking for other ways.

Luckily Unity Build has an API. It also has a webhook to notify when the build is completed. Putting these all together, my website buttons now automatically link to the latest build on the Unity Build platform. Unfortunately I spent a lot of item trying to figure out what parameters were the correct ones, which took more time than which I had hoped. For that reason, please find the references in step 4.


  • A webserver with php installed (MySQL optional)
  • A Unity cloud build project with automated builds set-up



  1. Go to your webserver and create 2 files: webhook.php and index.php
  2. Open webhook.php and paste in the following code (explanation will follow)

  3. Paste the following code in index.php
  4. Now we can look up the required information:
    1. Your api-key can be found in your cloud build > Preferences > API-key
    2. Your organisation, project and build id’s can be found by making the following API get-request

      From there you can find all the required ids from above (per project).
    3. Your build target is the name of your target system in small letters (eg. webgl)
  5. Now it is time to set up the actual webhooks. Go to the notifications tab of your cloud build project and choose “Add new”. Fill in the URL of your php script on your web server and keep the json content type.  Click the check boxes so only “ProjectBuildSuccess” remains and use SSL only if your site has https.


After filling everything in, start a new build (or commit a change). The cloud should send a post message to your website and the URL in the text file will be updated. When you go to your index.php page, you will be redirected to the build of your game’s latest commit!

Leave a Comment

Remove torrents that finished downloading in transmission (WebUI)

Ever found your transmission queue filling up with torrents that have been completed which makes you lose the overview? I have, and coming home to start removing these files was a major waste of time, so I stared writing my first ever Bash script to solve this issue.

First thing you have to do is ensure you have “transmission-remote” installed. For me it was included when I installed transmission on my raspberry pi.

Once you have verified you have this installed you can continue with the creation of the script. Create a new file using you favorite text editor (for example “nano”) and paste the following code:

This is assuming you are running transmission and this script on the same server, and transmission-daemon is listening on localhost:9091. For other hosts/ports you need to pass additional parameters to the transmission-remote command.

Now that you have your script in place, remember to call it using crontab. In below example it is getting called once a day at noon.

The reason I am using this instead of the ability to call a script once a download completes, is because I had to clean up a whole chunk of backlog torrents that were still in my queue. This script will clean up ALL torrents that have status “Finished” once a day.


Note: In case your torrents never have status “Finished”, this will not work. Torrents are only set to status Finished if they are not seeding or downloading anymore. This can be forced in transmission by changing the options under “Seeding”.

transmission settings

Leave a Comment

WordPress Multisite WWW-redirect

During the set-up of my new site configuration I stumbled upon an issue that prevented my from visiting my root domain without using the “www” prefix. This bothered me as I never use this prefix manually. After some googling around I found a quick and simple solution that automatically redirects the user to the www-prefixed domain.

In the “.htaccess” file in your root folder add the following code segment at the start of your file above the part you replaced in the WordPress MultiSite installation:

Replace “” with your domain (e.g. Your root domain is now accessabel without the www prefix! Thanks to this post for the clarification.

Leave a Comment

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.