Skip to content

Instantly share code, notes, and snippets.

@markusfisch
markusfisch / README.md
Last active Dec 19, 2018
Explore a random snippet from five different popular open source projects like a dungeon in a roguelike
View README.md

Guess the file

Explore a random snippet from five different popular open source projects like a dungeon in a Roguelike.

Can you guess what programming language or project a file is from?

Run it like this:

$ bash what_file.sh
@markusfisch
markusfisch / emojize-swift.sh
Last active Dec 16, 2017
Replace that boring variable names with funny emojis in your Swift code
View emojize-swift.sh
#!/usr/bin/env bash
# Replace that boring variable names with funny emojis in your Swift code
#
# @param 1 - file to emojize
emojize() {
local FILE=$1
local EMOJI=(😀 😬 😁 😂 😃 😄 😅 😆 😇 😉 😊 🙂 🙃 😋 😌 😍 😘 😗 😙 😚 😜 😝 😛 🤑 🤓 😎 🤗 😏 😶 😐 😑 😒 🙄 🤔 😳 😞 😟 😠 😡 😔 😕 🙁 😣 😖 😫 😩 😤 😮 😱 😨 😰 😯 😦 😧 😢 😥 😪 😓 😭 😵 😲 🤐 😷 🤒 🤕 😴 💤 💩 😈 👿 👹 👺 💀 👻 👽 🤖 😺 😸 😹 😻 😼 😽 🙀 😿 😾 🙌 👏 👋 👍 👊 👌 💪 🙏 👆 👇 👈 👉 🖕 🤘 🖖 💅 👄 👅 👂 👃 👁 👀 👤 🗣 👶 👦 👧 👨 👩 👱 👴 👵 👲 👳 👮 👷 💂 🕵 🎅 👼 👸 👰 🚶 🏃 💃 👯 👫 👬 👭 🙇 💁 🙅 🙆 🙋 🙎 🙍 💇 💆 💑 💏 👪)
local EMOJI_LEN=${#EMOJI[@]}
local I=0
@markusfisch
markusfisch / smoke.glsl
Last active Feb 10, 2017
Wallpaper smoke shader; set in on Android with Shader Editor; for best performance run with 1/8 size
View smoke.glsl
// from http://editor.thebookofshaders.com/?log=170202213311
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
uniform vec2 resolution;
uniform float time;
uniform vec2 offset;
@markusfisch
markusfisch / center.sh
Last active Jan 20, 2017
Center input from stdin in terminal or return 1 if it doesn't fit
View center.sh
#!/usr/bin/env bash
# Print n blank lines
#
# @param 1 - number of blank lines to print (default 1)
blanks() {
local I
for (( I=${1:-1}; I--; ))
do
echo
@markusfisch
markusfisch / SystemBarMetrics.java
Created Jan 14, 2017
Get the size of the status, tool and navigation bar on Android
View SystemBarMetrics.java
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 Dec 21, 2018
Generate an annual commit report
View README.md

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 Jan 31, 2017
Add, commit, tag and push in one go
View avup.sh
#!/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 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 Oct 6, 2016
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.

You can’t perform that action at this time.