Skip to content

Instantly share code, notes, and snippets.

View timofurrer's full-sized avatar
Commits are my own. Powered by coffee.

Timo Furrer timofurrer

Commits are my own. Powered by coffee.
View GitHub Profile
[user]
name = Timo Furrer
email = [email protected]
[alias]
# generic
co = checkout
br = branch
ci = commit
st = status
__return_value()
{
ret=$?
if [[ "$ret" -ne "0" ]]; then
echo -e "\033[1;31m[Error: \033[0;31m$ret\033[1;31m]\033[00m "
fi
}
#!/bin/bash
if [ -z "$1" ]; then
echo Error: please specify a file >&2
exit 1
fi
for f in $@; do
if [ ! -f "$f" ]; then
echo "Error: file '$f' does not exist" >&2
@timofurrer
timofurrer / httpserver.sh
Created August 19, 2013 13:59
open http server in current directory in bash
httpserver()
{
local port="${1:-8000}"
sleep 1 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
@timofurrer
timofurrer / pydictobj.py
Created August 19, 2013 12:03
simple base object where you can inherit from and your object can be created from a dictionary. This can be useful if you want to convert some data from JSON or YAML to an object.
# -*- coding: utf-8 -*-
class DictObj(object):
def load(self, **data):
self.__dict__.update(data)
@classmethod
def create(cls, **data):
s = cls()
s.load(**data)
@timofurrer
timofurrer / .bash_aliases
Created June 15, 2013 13:33
cp and move commands with progress bar using rsync
# copy and move with progress bar
alias pcp='rsync -aP'
alias pmv='rsync -aP --remove-source-files'
@timofurrer
timofurrer / .bash_aliases
Created June 15, 2013 13:32
cat & less with syntax highlighting!
# cat & less with syntax highlighting
alias ccat="pygmentize -f terminal256 -O style=native -g"
function cless() {
ccat "$1" | less -R
}
@timofurrer
timofurrer / login_notify.sh
Created June 15, 2013 13:29
show notification when someone logs into your computer (maybe per ssh - whatever) File location should be: `/etc/profile.d/login_notify.sh`
DISPLAY=:0 notify-send -t 10000 -u critical "User loggin in:" `whoami`
@timofurrer
timofurrer / .tmux.conf
Created April 28, 2013 12:25
my tmux conf
# tuxtimo's tmux configuration
# Reload config
bind r source-file ~/.tmux.conf \; display "Configuration reloaded..."
# set terminal colors
set -g default-terminal "screen-256color"
# pane selection (vim style)
bind h select-pane -L
@timofurrer
timofurrer / .Xmodmap
Created March 24, 2013 17:33
Xmodmap for mac keyboard
! Swap Alt and Cmd keys.
keycode 37 = Control_L
keycode 49 = less greater less greater backslash brokenbar bar
keycode 133 = Alt_L Meta_L
keycode 64 = Super_L
keycode 108 = Super_R
keycode 134 = ISO_Level3_Shift Multi_key
keycode 105 = Control_R Multi_key
clear Shift
clear Lock