Skip to content

Instantly share code, notes, and snippets.

View markusfisch's full-sized avatar

Markus Fisch markusfisch

View GitHub Profile
@markusfisch
markusfisch / SystemBarMetrics.java
Created January 14, 2017 14:37
Get the size of the status, tool and navigation bar on Android
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Point;
import android.os.Build;
import android.util.TypedValue;
public class SystemBarMetrics {
public static int getStatusBarHeight(Resources res) {
return getIdentifierDimen(res, "status_bar_height");
@markusfisch
markusfisch / README.md
Last active October 8, 2022 06:21
Generate an annual commit report

Generate an annual commit report

Prints something like this:

In 2018 you made 2488 commits in 134 projects.
The average length of a commit message was 62 characters.

Commits per weekday
    Monday     334 ******************************************
@markusfisch
markusfisch / avup.sh
Last active June 29, 2019 00:44
Add, commit, tag and push in one go
#!/usr/bin/env bash
# Add, commit, tag and push
tag_and_push()
{
# find version (x.x.x) in uncommitted changes
local VERSION=''
VERSION=$(git diff -U0 |
grep -E "^\+.*([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2})")
@markusfisch
markusfisch / horizontal_check_sum.c
Created November 25, 2016 13:17
Calculate a horizontal check sum
static int horizontal_check_sum(int number) {
int sum = 0;
for (int i = 1, mod = 0; mod != number; i *= 10) {
mod = number % (i * 10);
sum += mod / i;
}
return sum;
}
@markusfisch
markusfisch / keybase.md
Created November 4, 2016 10:04
keybase.md

Keybase proof

I hereby claim:

  • I am markusfisch on github.
  • I am markusfisch (https://keybase.io/markusfisch) on keybase.
  • I have a public key whose fingerprint is C87D EB20 EEF3 E854 BCEB 9883 32D7 D983 E2F0 EBD2

To claim this, I am signing this object:

@markusfisch
markusfisch / README.md
Last active June 29, 2019 00:46
Synchronize just the contents of a repository with a local directory

Manually embed sub repositories

Synchronize (the contents of) a repository with a local directory. Can be used to manually update "embedded" repositories (aka subtree's).

Does not touch the host repository's stage or history. You have to add and commit the changed files manually. Write a good commit message and have a clean history.

@markusfisch
markusfisch / README.md
Created September 24, 2016 19:14
Convert Wavefront OBJ to JavaScript arrays

Convert Wavefront OBJ to JavaScript arrays

Naive bash script to convert a Wavefront OBJ (as created by Blender) into JavaScript arrays:

$ ./obj2js < model.obj > model.js

Will print something like:

@markusfisch
markusfisch / review.sh
Created August 16, 2016 07:51
Script to quickly review (and potentially remove) files in a cache directory (read your Downloads folder)
#!/usr/bin/env bash
for FILE in ${*:-*}
do
echo ">>> $FILE"
while true
do
read -r -n 1 -p '[s]kip, [r]emove, [i]nspect or [q]uit? '
echo
@markusfisch
markusfisch / badge.sh
Last active June 29, 2019 00:48
Put a badge on the launcher icons for another Android build
#!/usr/bin/env bash
# Put given badge on launcher icons for another build
#
# @param 1 - badge overlay
# @param 2 - build name (and local directory)
badge()
{
local BADGE=$1
local BUILD=$2
@markusfisch
markusfisch / practical-coding-tips.md
Last active June 29, 2019 00:49
Practical Coding Tips

Practical Coding Tips

A short list of language independent tips to make your coding life easier. And that of everyone working with you.

Every tip is meant to be just that: a tip. This is neither a rule book nor a style guide.

If you disagree with something, that's fine.