Skip to content

Instantly share code, notes, and snippets.

View rm--'s full-sized avatar

René rm--

View GitHub Profile
@rm--
rm-- / man2pdf.md
Last active November 28, 2015 14:59
covert man page (eg. bash) to pdf
  man -T bash bash | ps2pdf - bash.pdf

first bash is the page you are looking for

@rm--
rm-- / rename files.py
Created November 21, 2015 11:17
list comprehension to bulk rename files
pip install natsort
import os
src_dir = '/tmp/in'
dst_dir = '/tmp/out'
starting_nb = 11 # new filename starting with this number
[os.rename(src_dir + os.sep + f,dst_dir + os.sep + str(i) + '.' + f.split('.')[1]) for (i,f) in enumerate(natsort.natsorted(os.listdir(src_dir)),starting_nb)]
@rm--
rm-- / git_rm_local_and_remote_branches.md
Last active November 5, 2015 21:47
remove local and remote branches
merged_branches(){
local red=`tput setaf 1`
local green=`tput setaf 2`
local bold=`tput bold`
local reset=`tput sgr0`
local current_branch=$(git rev-parse --abbrev-ref HEAD)
for branch in $(git branch --merged | cut -c3-)
do
if [[ $branch = $current_branch ]]; then
@rm--
rm-- / most_used_zsh_cmds.md
Created October 7, 2015 22:06
summarize most used zsh cmds to find out alias candidates

cat ~/.zsh_history | awk -F\; '{ print $2 }' | sort | uniq -c | sort -n

@rm--
rm-- / git_mergetool.md
Last active October 7, 2015 21:51
manual mergetool selection

osx

git mergetool -t opendiff

ubuntu linux

git mergetool -t meld

@rm--
rm-- / gist:5711fe816784048f27f6
Created August 27, 2015 07:27
git remote prune origin
# delete unused remote branches
git remote prune origin
@rm--
rm-- / git diff with stash
Created June 27, 2015 17:47
git diff with stash
git stash show -p stash@{0}
@rm--
rm-- / salt state debug
Created June 24, 2015 16:33
salt state debug
# debug salt states:
`sudo salt-call state.sls <your-salt-state-to-debug> test=True`
{
"url": "http://example.com/api/23/",
"author": 1,
"date_created": "2015-03-26T11:01:23.262391Z",
"date_updated": "2015-03-26T11:01:23.262391Z",
"html": "<form></form>",
"javascript": "<script></script>",
"form": {
"id": 123,
"method": "POST",