inline (short && sweet)

  • Send input to Android Device via ADB

    To send input to an Android Device, for example to write some text into a text-box, use the input-command on the device. This works via ADB Shell:

    adb shell
    input text [text-to-write]

    The input-command can also send other sorts of input, like keyboard or touch events. For more information, just run the command without any parameters.

  • Chocolatey installer fails in PowerShell

    The chocolatey installer might fail when run in PowerShell, saying something like

    [File] cannot be loaded. The script will not execute on the system. See about_Execution_Policies

    This is caused by the execution-policy of the shell. To allow the installer to work for this session only, the following command can be used:

    Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

    This will allow the installer to execute properly. When the shell is closed, everything is reset to normal. Subsequent installs of software from the chocolatey repositories does not need the policy set.

  • Complexity of Algorithms and Data-structures

    The cheat-sheet of all search and sort algorithms and common data-structures.

  • Flashing new ROM on Nexus 5X from Stock

    The Nexus 5X I started with was running a stock Android system without any updates made to it. This guide applies to Linux Ubuntu 17.04

    This requires a setup Android SDK! Step by step:

    1. Copy ROM, GApps and Root to Internal Storage
      • ROM in this example was Paranoid Android
      • Download suiting package from Open GApps (Nexus 5X is ARM64 arch!)
      • Download SuperSU (optional). (not done here!)
    2. Unlock Bootloader:
      • Reboot phone into fastboot: adb reboot bootloader or Hoold power and Volume Down together.
      • (as root) Check if device is found: fastboot devices
      • (as root) Unlock bootloader: fastboot oem unlock
      • (as root) Reboot device: fastboot reboot
    3. Install custom Recovery (TWRP):
      • Download from the official site
      • Reboot into fastboot (see above)
      • (as root) Flash new recovery: fastboot flash recovery path/to/twrp.img
      • Important: After the reboot, Android deletes TWRP automatically! We need to boot into recovery at least once, so it stays on the phone after reboots. After issuing the next command, hold Power and Volume Down immediatly!
      • (as root) Reboot the phone: fastboot reboot
      • After booting into fastboot again, use Volume Down to flip to “Recovery” and press Power to select it. TWRP should start.
    4. Flash new stuff
      • Click “Wipe” and wipe everything except “Internal Storage”
      • Select “Install” from the main menu
      • If you did wipe the internal storage or forgot to put the images on it, you can copy them over via adb: adb push /local/file /sdcard/remote-file.
      • Select the ROM, swipe to flash, follow instructions
      • Select GApps, swipe to flash, follow instructions
      • (Optional) Flash root
      • Wipe Dalvik for good measure (should prompt for it)
      • Select “Reboot” from the main menu.
    5. Profit!

    After the reboot, the system setup should launch. Check “Settings” > “About Phone” > “Paranoid Android Version” to verify everything worked.

  • Show a commit tree with Git

    An annotated, colored tree can be shown with git log --oneline --decorate --all --graph.

    See StackOverflow.

  • Changing the case of a git directory on a case-insensitive file system

    If you commit the file main.c in the directory Test to git on a case sensitive file system (such as ext4), git will write the path as Test/main.c.

    When checking that repository out on a system with a case insensitive file system (like NTFS) the explorer might tell you that your file is in test/main.c, but doing something like git log -- test/main.c will not yield any results. Whereas git log -- Test/main.c will work fine.

    To change the case of the directory containing the main.c file on such a case insensitive file system, you might run git mv Test test, but it will fail. The workaround is to first rename the directory to something else and then again to the name you want:

    git mv Test asd git mv asd test

    This should result in changes for all files in the directory. Committing these will fix the problem.

  • Initial Git setup on new machine

    The initial setup for a fresh git installation (bare minimum)

    $ git config --global "YOUR NAME"
    $ git config --global "YOUR EMAIL ADDRESS"

    See GitHub help.

  • Manage Gnome Startup Programs

    The command is gnome-session-properties.

  • Boot to the console/text mode

    The kernel parameters for booting into the console/text mode (run-level 3, without the X window system) is:

    linux   /boot/vmlinuz-xx root=... 3

    For debugging purposes, it also makes sense to remove the quite and splash options.

  • Find and kill a process from the terminal

    To find a running process on the machine the ps-command is used (with arguments to show all running processes) in combination with grep:

    $ ps aux | grep [process]

    Here, [process] is the name of the process you want to find. The name of the executable can be a good start for guessing the name if you’re not sure.

    In the resulting output, find the PID of the process. Then, the kill-command can be used to end it:

    # gracefully:
    $ kill -SIGTERM [pid]
    # force
    $ kill -SIGKILL [pid]

    This will then end the specified process.

    If the process you need to kill is owned by a different user, adding sudo might be necessary.

  • List installed packages

    On a Ubuntu/Debian system, installed packages can be listed with:

    dpkg --get-selections | grep -v deinstall

    From that list, grep any package name to check if the package is installed.

    See AskUbunut

  • Merge multiple MKV files together

    To merge multiple MKV files together into one big MKV file, make sure that the order of audio and video tracks is the same across all files. Add the files with the following command:

    mkvmerge -o output.mkv input1.mkv +input2.mkv

    See AskUbunut

  • Add time to MySQL dates

    The easiest way to move a collection of dates by a given amount of time is to use the DATE_ADD-function:

    UPDATE [table] SET [column] = DATE_ADD([column], INTERVAL [amount] {DAY|MONTH|MINUTE|...})

    This works with DATE and DATETIME columns. A full list of possible interval-units can be found here.

  • Dump and restore MySQL Database

    To dump a database into a SQL file, use the following command:

    mysqldump -u [user] -p[password] [database] > [file]

    The command will dump the SQL statements onto std-out, so we’re redirecting them into a file for save keeping. To resore a databse, use the following command:

    mysql -u [user] -p[password] < [file]

    This will simply execute all SQL instructions placed in the file.

  • Customize Nautilus context menu

    To add new entries to the context menu of Nautilus, use the nautilus-actions package from the official repositories.

    See AskUbuntu

  • Online Programming Tools

    Charts and Diagrams

    • Code2Flow - Create Flow-Charts with a simple, C-like markup language.
    • WebSequenceDiagrams - Sequence Diagrams from a simple markup language.

    Regular Expressions

    • Regex101 - Craft, visualize and validate regular expressions against example-data.


    • ExplainShell - Explains a shell command and it’s parameters.


    • - Creates a .gitignore-file for the used technologies.
  • Resource-id clashes with library modules

    When including an Android library as a module in IntelliJ (for example the cardview from the support-library), the following error might occur:

    Resource id [hex-id] is not of type [expected-type] (instead [actual-type])

    along with this exception at runtime:

    android.view.InflateException: Binary XML file line #[line]: Error inflating class [class]

    To fix this make sure that the module has the Library module-checkbox on the top-left in Project Structure -> Modules -> [Expand Module Name] -> Android is ticked!

  • Security and usability

    Keep this in mind when designing new systems:

    Security at the expense of usability, comes at the expense of security.


  • Looping over files with the shell

    To loop over a set of files, do:

    # files can have wildcards (*.c or article-*.md)
    for F in files
        # do something with $F
  • Java libraries in WEB-INF/lib get corrupted

    When putting .jar-libraries into the WEB-INF/lib directory of an App Engine project, the file get’s corrupted (wrong size) and can’t be opened by the server (throwing ZipException: error in opening zip file) after compiling.

    Removing <filtering>true</filtering> from the org.apache.maven.plugins-plugin in the projects pom.xml-file fixes the problme. See StackOverflow.

  • Initial ZSH setup on a new machine
    1. Install the zsh-package via packagemanager
    2. Install Oh-My-Zsh via the provided install-script
    3. Install a patched symbol-font for more interesting ZSH themes
      • Pre-patched fonts are avialable in the patching-strategy branch of awesome-terminal-fonts
      • Download a font and it’s corresponding .sh-file from the patched/-folder of the repo
      • Install the font in the system (usually just by double-clicking it)
      • Copy the script to ~/.fonts
      • Add this to the ~/.zshrc file: source ~/.fonts/*.sh to get named font-mappings
      • Set the terminal emulator to use the newly installed font!
    4. Install the Powerlevel9k theme
      • Clone the repo to ~/.oh-my-zsh/custom/themes/powerlevel9k
      • Set the theme in the prfile (~/.zshr) via: ZSH_THEME="powerlevel9k/powerlevel9k"
      • Configure the theme to use the patched fonts by adding POWERLEVEL9K_MODE='awesome-patched' to the profile
    5. Configure the theme in the profile
    6. Change the terminal color-scheme. For gnome-terminal, see Gogh