Skip to content

Instantly share code, notes, and snippets.

Markus Fisch markusfisch

Block or report user

Report or block markusfisch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@markusfisch
markusfisch / horizontal_check_sum.c
Created Nov 25, 2016
Calculate a horizontal check sum
View horizontal_check_sum.c
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;
}
View 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 Jun 29, 2019
Synchronize just the contents of a repository with a local directory
View README.md

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 Sep 24, 2016
Convert Wavefront OBJ to JavaScript arrays
View README.md

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 Aug 16, 2016
Script to quickly review (and potentially remove) files in a cache directory (read your Downloads folder)
View review.sh
#!/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 Jun 29, 2019
Put a badge on the launcher icons for another Android build
View badge.sh
#!/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 Jun 29, 2019
Practical Coding Tips
View practical-coding-tips.md

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.

@markusfisch
markusfisch / pullall.sh
Last active Jun 29, 2019
Run "git pull" in all subdirectories that contain a git repository
View pullall.sh
#!/usr/bin/env bash
# Pull all respositories in all direct subdirectories
#
# @param ... - directories to pull (optional)
pull_all()
{
local D
# don't quote @ because it will prevent globbing
@markusfisch
markusfisch / cleanimports.sh
Last active Jun 29, 2019
Shell script to remove unused java imports
View cleanimports.sh
#!/usr/bin/env bash
# Print unused import statements
#
# @param 1 - source file to check
find_unused_imports()
{
grep '^import' "$1" | while read
do
NAME=${REPLY##*.}
@markusfisch
markusfisch / xml.sh
Last active Jul 9, 2019
Basic XML parser in nothing but BASH
View xml.sh
#!/usr/bin/env bash
# Read XML from STDIN
read_xml()
{
# concatenate lines
local XML
while read -r
do
You can’t perform that action at this time.