Featured on Codementor – 25 PHP Interview Questions

I’m glad to be part of the amazing community at codementor.io. In the past years I’ve been able to talk and help many different people with a range of problems. Often some hints and good advice was enough to point them in the right direction and I really enjoy teaching other people. Codementor recently approached me and asked me if I could contribute some questions from my experience in the last years to their blog post “25 PHP Interview Questions”. I’m happy they found my suggestions useful and featured me in that article! Hope it helps some developers that are just getting to know the world of PHP and all its hiccups. Don’t forget to check out my profile on codementor!

Properly setup proguard for an Android project

When dealing with an Android project you want to use Proguard to minify, shrink and possibly even obfuscate the code. The gains from this are huge and many smart minds have put a lot of thought into Proguard. We encountered that the TUM Campus App shrinked from 20 Megabytes to just 9 Megabytes with all the optimization in place – huge savings if you deploy it to 10k+ clients! Really if you are not using this in your project currently you must be insane! Anyways if you rely on external Libraries like Retrofit (Which is totally awesome, use it!) then you need to add some proguard rules in order to tell it what not to remove from those libs because it is really required but maybe not directly used. Mostly that is some models which get serialized and you might encounter some warnings but those don’t really are not interesting to you as a lib user. This repository has a great collection on proguard files for various libs. Use it, don’t reinvent the wheel!

Git command of the day: git remote prune

In this series of posts I’ll document useful git commands ready to copy&paste which nobody knows by heart but you need once in a while. Today:

git remote prune <name>

From the docs:


Deletes all stale remote-tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in “remotes/<name>”.

    With --dry-run option, report what branches will be pruned, but do not actually prune them.

Very useful when working with Github and you just merged a PR then usually you also delete the branch on the remote immediately after. This does not however delete the branch from your local repository and over time it can get messy. With this simple command you delete all local references tracking upstream branches which were deleted on the server. If your remote is called origin then just type enter it like so::

git remote prune origin

Der Erfolg von Cities: Skylines

Nachdem das Sim City von EA so ein Flopp war, ergab sich eine große Marktlücke. Mit Aktionen wie ‘nur Online spielbar’ und limitierter Spielfläche, die eher sehr mager war, hat man einfach nicht bei den Spielern Punkten können. Zwar wurden viele Dinge verbessert, aber gewisse Trade-Offs gemacht, welche das Spiel nicht zu einem Kassenschlager gemacht hat, obwohl die Vorfreude und Hoffnungen im Vorfeld enorm waren. Colosssal Order, hat in dem Moment die Ohren offen gehalten und mit dem Vorgänger Cities in Motion, der eher in Richtung von Transport Tyccon geht, eine solide Basis für ein Sim City gehabt. Folgende Punkte waren die größten Kritiken am alten Spiel: Online Zwang Limitierte Städte Größen Crappy traffic management City Interaktion ist zwar ein nettes Feature, aber keiner hat lust den Kontext zu wechseln und komplett von null anzufangen. Geld aus der Tasche ziehen mit DLC, der ein paar Wochen nach der Veröffentlichung verfügbar war Das Problem dabei ist folgendes: Gamer die solche Sims bzw. Strategie spiele zocken, sind Gelegenheitsspieler. Es geht nicht darum, immer die neueste Version zu spielen, sondern das Spiel muss gut und flüssig funktionieren. Der Trick mit DLC und Jährlich ‘neuer’ Shooter Edition (Siehe Call of Duty und Konsorten), funktioniert bei […]

Mikrofon Fail Ubuntu 14.10

Seit ich auf Ubuntu Gnome gewechselt bin, ging mein Mikro nicht mehr. Heute hab ich mir mal Zeit genommen das zu erörtern. Treiber wechseln, neu starten, etc. brachte alles nichts. Die Mikro Skala blieb auf null. Dann errinerte ich mich, dass mein Dell Notebook viele Optionen im BIOS hat, darunter auch eine die das Mikro deaktiviert. Windows hat diese Einstellung ignoriert, Linux machte das richtig. Nach dem aktivieren im BIOS, lief dann alles ohne Probleme. Top! Linux rocks!

Encoding videos for streaming on an Android device

I’ve been getting random hickups in playback when including a video in a webview on Android Kitkat (4.4.4). So I’ve been on this issue for quite some time now and couldn’t figure out why I was getting these messages in the verbose logcat: 2987-2998/com.xxx W/MediaPlayer﹕ info/warning (703, 38137) 2987-2987/com.xxx I/MediaPlayer﹕ Info (700,595) 2987-2998/com.xxx W/MediaPlayer﹕ info/warning (701, 0) 2987-2998/com.xxx W/MediaPlayer﹕ info/warning (702, 0) Especially the 700 error was what I focused on, cause it made no sense really. I’ve used Handbrake to encode the videos and selected the “android” preset. Unfortunately they’ve set the profile to ‘main’ instead of the suggested ‘baseline’ profile which is recommended. Took me a while to figure this out and including a lot of trial and error =/ Working now, anyways. Read more on the optimal settings here….

Serving files with access control (Apache/PHP)

When serving files over PHP often people end up using an incorrect implementation which is open to attacks or has really bad performance (especially with big files). Well you shouldn’t reinvent the wheel every time! When you are using Apache in the first place, why do you need to re-implement the feature, that Apache is best at? To avoid having to deal with complicated RFCs for HTTP Ranges and Caching use the Apache Module called xsendfile. Some apt magic and you are up an running: apt-get install libapache2-mod-xsendfile service apache2 restart Then add this to your vhost configuration: XSendFile on XSendFilePath /var/atis/Storage All set! To send a file via. PHP simply do this: header(‘X-Sendfile: ‘ . $file); header(‘Content-Type: ‘ . contentType($file)); header(‘Content-Disposition: inline;’); (Make sure you have a function to determine the contenttype of your file)