This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .zsh/function/vcs_status | |
# | |
# Modify .zshrc: | |
# | |
# fpath=(~/.zsh/function $fpath) | |
# | |
# autoload vcs_status | |
# zle -N vcs_status | |
# bindkey '\es' vcs_status | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save this file to ~/.config/fish/functions/push-line.fish | |
# Bind the function by using this in ~/.config/fish/functions/fish_user_key_bindings.fish | |
# function fish_user_key_bindings | |
# # For example alt+q | |
# bind \eq push-line | |
# end | |
function push-line | |
commandline -f kill-whole-line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo: foo.cpp bar.o | |
$(info @ is $@ ) | |
$(info % is $% ) | |
$(info < is $< ) | |
$(info ? is $? ) | |
$(info ^ is $^ ) | |
$(info + is $+ ) | |
$(info | is $| ) | |
$(info * is $* ) | |
${CXX} ${CXXFLAGS} -o $@ $< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# deps: | |
# - have oracle jdk >= 7 build with java-package | |
# see https://wiki.debian.org/JavaPackage if you don't know how | |
# - apt-get install equivs | |
# | |
# Debian actually kind of suggests it but the doc ist kind of old: | |
# https://www.debian.org/doc/manuals/debian-java-faq/ch13.html | |
# | |
# inspired by RJ <[email protected]> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
#set -x | |
# Tested on debian jessie | |
# Install goaccess | |
# Define your log format in /etc/goaccess.conf | |
# e.g log-format %h %^[%d:%^] "%r" %s %b "%R" "%u" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
BASEDIR=/opt/seafile/mysite | |
OUTDIR=${BASEDIR}/backup/db | |
mkdir -p ${OUTDIR} | |
SUFFIX=.`date +"%Y-%m-%d-%H-%M-%S"` | |
sqlite3 ${BASEDIR}/ccnet/GroupMgr/groupmgr.db .dump | gzip > ${OUTDIR}/groupmgr.db.bak${SUFFIX}.gz | |
sqlite3 ${BASEDIR}/ccnet/PeerMgr/usermgr.db .dump | gzip > ${OUTDIR}/usermgr.db.bak${SUFFIX}.gz | |
sqlite3 ${BASEDIR}/seafile-data/seafile.db .dump | gzip > ${OUTDIR}/seafile.db.bak${SUFFIX}.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Generate a free icons.c for minidlna from Debian's SVG logo | |
# | |
# Copyright (C) 2011 Benoît Knecht <[email protected]> | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions | |
# are met: | |
# 1. Redistributions of source code must retain the above copyright |