Skip to content

Instantly share code, notes, and snippets.

View dedeibel's full-sized avatar

Benjamin Peter dedeibel

View GitHub Profile
@dedeibel
dedeibel / commit.fish
Last active May 23, 2017 10:01
fish function that prepares a git commit command with message containing the jira ticket number
# save as ~/.config/fish/functions/commit.fish
# Use:
# Assuming you are in a git repository of a bitbucket / jira branch using the atlassian jira git flow conventions
# example "feature/EXP-1337-cool-new-feature
#
# MAC USERS CHANGE "sed -r" to "sed -E"
#
# > commit
# will expand to
# > git commit -m 'EXP-1337: '
@dedeibel
dedeibel / vcs_commit
Last active October 8, 2019 19:00
zsh widget that prepares a git or svn commit command with message containing the jira ticket number if applicable
# save as ~/.zsh/function/vcs_commit
#
# In your ~/.zshrc
#
# fpath=(~/.zsh/function $fpath)
# autoload vcs_commit
# zle -N vcs_commit
# bindkey '\ec' vcs_commit
#
# Loads the widget and also binds it to Alt+c
@dedeibel
dedeibel / vcs_status
Last active October 8, 2019 19:04
git or svn status via keybindung in zsh
# .zsh/function/vcs_status
#
# Modify .zshrc:
#
# fpath=(~/.zsh/function $fpath)
#
# autoload vcs_status
# zle -N vcs_status
# bindkey '\es' vcs_status
#
@dedeibel
dedeibel / mget.py
Last active December 19, 2016 13:21
python get with nested structures and default
def mget(dic, *keys):
ret = dic
last_key = keys[-1]
for key in keys[:-1]:
ret = ret.get(key, {})
return ret[last_key]
def mgetd(dic, *keys):
ret = dic
last_key = keys[-2]
@dedeibel
dedeibel / Vagrantfile
Created December 20, 2016 15:41
Vagrant shared folders not on linux
use_nfs = ! RUBY_PLATFORM.downcase.include?("linux")
if (use_nfs)
node.vm.synced_folder ".", "/vagrant", type: "nfs"
else
node.vm.synced_folder ".", "/vagrant"
owner: "www-data", group: "www-data"
end
cat /proc/modules | cut -f 1 -d " " | while read module; do \
echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then \
ls /sys/module/$module/parameters/ | while read parameter; do \
echo -n "Parameter: $parameter --> "; \
cat /sys/module/$module/parameters/$parameter; \
done; \
fi; \
echo; \
done
@dedeibel
dedeibel / wait_for_postgres.sh
Created March 27, 2017 14:10
wait for postgresql server
#!/usr/bin/env bash
SERVICE="postgres"
DBNAME="mydb"
PORT="$1"
USER="$2"
PASS="$3"
MAX=30
IT=0
SLEEP_SECONDS=2
@dedeibel
dedeibel / Makefile
Last active April 8, 2017 21:50
list all make targets to mark them as phony
list-phony:
@perl -ne 'push @a, $$1 if m/^([\w\d-]+):\s/; END { print ".PHONY: ", join(" ", sort @a), "\n" }' Makefile
@dedeibel
dedeibel / convert-relative-ts-imports-to-absolute.pl
Created April 12, 2017 14:34
Converts module relative Agular 2 / Typescript Imports to tsconfig.json relative ones
#!/bin/perl
#
# Run on unix like Systems
#
# Execute this from the directory where your "tsconfig.json" and "app" resides as following:
#
# find . -name "*.ts" | xargs -n 1 perl convert.pl
#
# Add this to tslint.json 'compilerOptions'
#
@dedeibel
dedeibel / .zshrc
Created May 21, 2017 10:50 — forked from meise/.zshrc
Configure bash variables based on directories
if [[ -e $HOME/.zsh/chpwd_profiles.zsh ]]; then
source $HOME/.zsh/chpwd_profiles.zsh
zstyle ":chpwd:profiles:/home/${USER}/projects(|/|/*)" profile projects
zstyle ":chpwd:profiles:(|/|/*)" profile default
# configuration for profile 'projects':
chpwd_profile_projects() {
[[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
print "chpwd(): Switching to profile: $profile"