Skip to content

Instantly share code, notes, and snippets.

View hannesstruss's full-sized avatar
🤖

Hannes Struß hannesstruss

🤖
View GitHub Profile
(gidsy)hannes@tpHannes:~/code/Gidsy$ grep alias ~/.bashrc
# ~/.bash_aliases, instead of adding them here directly.
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
# enable color support of ls and also add handy aliases
alias ls='ls --color=auto'
#alias dir='ls --color=auto --format=vertical'
#alias vdir='ls --color=auto --format=long'
# some more ls aliases
alias ll='ls -lh'
@hannesstruss
hannesstruss / gist:3699834
Created September 11, 2012 17:00
Git PDB Pre Commit Hook
#!/bin/bash
git diff --cached | grep ^+ | grep 'pdb.set_trace()' > /dev/null
if [ $? = '0' ]; then
echo "You're about to commit code with pdb statements. Please remove them!"
echo "Run 'git diff --cached' to see what you're about to commit."
exit 1
fi
@hannesstruss
hannesstruss / gist:3992673
Created November 1, 2012 09:20
Python String concat
In [11]: timeit.timeit("""
....: a = "asd"
....: b = "dsa"
....: a + b""", number=10**8)
Out[11]: 8.79588794708252
In [12]: timeit.timeit("""
....: a = "asd"
....: b = "dsa"
....: "%s%s" % (a, b)""", number=10**8)
@hannesstruss
hannesstruss / gist:4597875
Created January 22, 2013 19:54
android video
ffmpeg -y -i input.avi -c:v libx264 -preset fast -c:a copy -r 15 output.mp4
@hannesstruss
hannesstruss / gist:4761410
Created February 12, 2013 10:22
get a list of postgres table and index sizes
DBNAME=
QUERY="select tablename from pg_catalog.pg_tables where tablename not like 'sql_%' and tablename not like 'pg_%';"
for table in `psql $DBNAME -t -c "$QUERY"`; do
TABLE_QUERY="select pg_size_pretty(pg_relation_size('$table'));"
TABLE_SIZE=`psql $DBNAME -t -c "$TABLE_QUERY"`
TOTAL_QUERY="select pg_total_relation_size('$table');"
TOTAL=`psql $DBNAME -t -c "$TOTAL_QUERY"`
INDEX_QUERY="select pg_size_pretty(pg_total_relation_size('$table') - pg_relation_size('$table'));"
#!/bin/sh
SOURCE="/PFAD/ZU/Apps Native/Android/_Assets"
TARGET=/PFAD/ZU/openfish/GYG_Android/res
set -x
cp "$SOURCE/mdpi/$1" "$TARGET/drawable-ldpi/"
cp "$SOURCE/mdpi/$1" "$TARGET/drawable-mdpi/"
cp "$SOURCE/hdpi/$1" "$TARGET/drawable-hdpi/"
@hannesstruss
hannesstruss / build.gradle
Created June 24, 2014 14:23
What fixed Android Instrumentation Tests on Gradle for me
configurations {
androidTestCompile.exclude group: 'com.android.support', module: 'support-v4'
}
@hannesstruss
hannesstruss / gist:827dad670971456adb8b
Last active August 29, 2015 14:09
Treat an object as a singleton in one scope, the Yo-Dawg way
@Module(injects = MyActivityModule.class)
class MotherModule {
// ...snip
}
@Module(
addsTo = MotherModule.class,
injects = {MyActivity.class, MyFragment.class}
)
class MyActivityModule {
import android.util.Log;
import rx.Observable;
import rx.Observer;
class Either<T> {
private final T value;
private final Throwable throwable;
public static <T> Either<T> ofValue(T value) {