1.0.0 - Remade structure for GNU Stow

This commit is contained in:
2020-09-30 10:39:09 +02:00
parent d5c2147ed1
commit af44571593
766 changed files with 131648 additions and 18 deletions

84
common/.aliases Normal file
View File

@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias cd..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# TODO: Make this conditional if using termux
#? maybe by using pwd (/data/data/com.termux/files)
# Shortcuts
alias sd="cd /mnt/sdcard"
alias dl="cd /mnt/sdcard/Download"
alias g="git"
alias h="history"
alias j="jobs"
# alternative to tail -f
alias lessf="less +F"
# List all files colorized in long format
alias l="ls -l"
alias ll="ls -lah"
# List all files colorized in long format, including dot files
alias la="ls -la"
# List only directories
alias lsd="ls -l | grep --color=never '^d'"
# Always use color output for `ls`
#alias ls="command ls --color=auto"
# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Enable aliases to be sudoed
alias sudo='sudo '
# Get week number
alias week='date +%V'
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# Dice for the undecided
alias dice='echo $[ 1 + $RANDOM % 6 ]'
alias yn='[ $[ $RANDOM % 2 ] == 0 ] && echo "Yes" || echo "No"'
# IP addresses
alias myip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ifconfig wlan0 | grep 'inet addr' | cut -d ':' -f 2 | cut -d ' ' -f 1"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Canonical hex dump; some systems have this symlinked
command -v hd > /dev/null || alias hd="hexdump -C"
# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
# Ring the terminal bell
alias badge="tput bel"
# Intuitive map function
# For example, to list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
alias map="xargs -n1"
# Reload the shell (i.e. invoke as a login shell)
alias reload="exec $SHELL -l"
# See if connection works
alias p="ping 1.1.1.1"
# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'

8
common/.curlrc Normal file
View File

@@ -0,0 +1,8 @@
# Disguise as IE 9 on Windows 7.
user-agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
# When following a redirect, automatically set the previous URL as referer.
referer = ";auto"
# Wait 60 seconds before timing out.
connect-timeout = 60

8
common/.editorconfig Normal file
View File

@@ -0,0 +1,8 @@
root = true
[*]
charset = utf-8
indent_style = tab
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

30
common/.exports Normal file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Make vim the default editor.
export EDITOR='vim';
# Enable persistent REPL history for `node`.
export NODE_REPL_HISTORY=~/.node_history;
# Allow 32³ entries; the default is 1000.
export NODE_REPL_HISTORY_SIZE='32768';
# Use sloppy mode by default, matching web browsers.
export NODE_REPL_MODE='sloppy';
# Make Python use UTF-8 encoding for output to stdin, stdout, and stderr.
export PYTHONIOENCODING='UTF-8';
# Highlight section titles in manual pages.
export LESS_TERMCAP_md="${yellow}";
# Less settings
if which less > /dev/null 2>&1;then
export PAGER="less"
export LESS="-R"
# nicer highlighting
if which src-hilite-lesspipe.sh > /dev/null 2>&1; then
export LESSOPEN="| src-hilite-lesspipe.sh %s"
fi
# Dont clear the screen after quitting a manual page.
export MANPAGER='less -X';
fi

323
common/.functions Normal file
View File

@@ -0,0 +1,323 @@
#!/usr/bin/env bash
function calc() {
local result=""
# ┌─ default (when --mathlib is used) is 20
result="$( printf "scale=10;%s\n" "$*" | bc --mathlib | tr -d "\\\n" )"
# remove the tailing "\" and "\n" ─┘
# (large numbers are printed on multiple lines)
if [[ "$result" == *.* ]]; then
# Improve the output for decimal numbers.
printf "%s" "$result" |
sed -e "s/^\./0./" # Add "0" for cases like ".5".` \
-e "s/^-\./-0./" # Add "0" for cases like "-.5".`\
-e "s/0*$//;s/\.$//" # Remove tailing zeros.
else
printf "%s" "$result"
fi
printf "\n"
}
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
}
# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
function targz() {
local tmpFile="${@%/}.tar";
tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;
size=$(
stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat`
stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat`
);
local cmd="";
if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
# the .tar file is smaller than 50 MB and Zopfli is available; use it
cmd="zopfli";
else
if hash pigz 2> /dev/null; then
cmd="pigz";
else
cmd="gzip";
fi;
fi;
echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`…";
"${cmd}" -v "${tmpFile}" || return 1;
[ -f "${tmpFile}" ] && rm "${tmpFile}";
zippedSize=$(
stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat`
stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat`
);
echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}
# Use Gits colored diff when available
hash git &>/dev/null;
if [ $? -eq 0 ]; then
function diff() {
git diff --no-index --color-words "$@";
}
fi;
# Create a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1");
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8";
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
}
# Create a git.io short URL
function gitio() {
if [ -z "${1}" -o -z "${2}" ]; then
echo "Usage: \`gitio slug url\`";
return 1;
fi;
curl -i https://git.io/ -F "url=${2}" -F "code=${1}";
}
# Start an HTTP server from a directory, optionally specifying the port
#function server() {
# 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 doesnt 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";
#}
# Start a PHP server from a directory, optionally specifying the port
# (Requires PHP 5.4.0+.)
function phpserver() {
local port="${1:-4000}";
local ip=$(ipconfig getifaddr en0);
sleep 1 && open "http://${ip}:${port}/" &
php -S "${ip}:${port}";
}
# Compare original and gzipped file size
function gz() {
local origsize=$(wc -c < "$1");
local gzipsize=$(gzip -c "$1" | wc -c);
local ratio=$(LC_ALL="en_US" echo "$gzipsize * 100 / $origsize" | bc -l);
printf "orig: %d bytes\n" "$origsize";
LC_ALL="en_US" printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
}
# Syntax-highlight JSON strings or files
# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
function json() {
if [ -t 0 ]; then # argument
python -mjson.tool <<< "$*" | pygmentize -l javascript;
else # pipe
python -mjson.tool | pygmentize -l javascript;
fi;
}
# Run `dig` and display the most useful info
function digga() {
if alias colourify >/dev/null 2>&1
then
shopt -s expand_aliases
colourify dig +nocmd "$1" any +multiline +noall +answer;
else
dig +nocmd "$1" any +multiline +noall +answer;
fi
}
# UTF-8-encode a string of Unicode symbols
function escape() {
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u);
# print a newline unless were piping the output to another program
if [ -t 1 ]; then
echo ""; # newline
fi;
}
# Decode \x{ABCD}-style Unicode escape sequences
function unidecode() {
perl -e "binmode(STDOUT, ':utf8'); print \"$@\"";
# print a newline unless were piping the output to another program
if [ -t 1 ]; then
echo ""; # newline
fi;
}
# Get a characters Unicode code point
function codepoint() {
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))";
# print a newline unless were piping the output to another program
if [ -t 1 ]; then
echo ""; # newline
fi;
}
# Show all the names (CNs and SANs) listed in the SSL certificate
# for a given domain
function getcertnames() {
if [ -z "${1}" ]; then
echo "ERROR: No domain specified.";
return 1;
fi;
local domain="${1}";
echo "Testing ${domain}…";
echo ""; # newline
local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
| openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1);
if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
local certText=$(echo "${tmp}" \
| openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \
no_serial, no_sigdump, no_signame, no_validity, no_version");
echo "Common Name:";
echo ""; # newline
echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//";
echo ""; # newline
echo "Subject Alternative Name(s):";
echo ""; # newline
echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
| sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
return 0;
else
echo "ERROR: Certificate not found.";
return 1;
fi;
}
# `v` with no arguments opens the current directory in Vim, otherwise opens the
# given location
function v() {
if [ $# -eq 0 ]; then
vim .;
else
vim "$@";
fi;
}
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
# the `.git` directory, listing directories first. The output gets piped into
# `less` with options to preserve color and line numbers, unless the output is
# small enough for one screen.
function tre() {
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
}
# Copy w/ progress
cp_p () {
rsync -WavP --human-readable --progress "$1" "$2"
}
# transfer.sh from https://gist.github.com/nl5887/a511f172d3fb3cd0e42d
transfer() {
if [ $# -eq 0 ];
then
echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1
fi
tmpfile=$( mktemp -t transferXXX )
file=$1
if tty -s;
then
basefile=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
if [ ! -e $file ];
then
echo "File $file doesn't exists."
return 1
fi
if [ -d $file ];
then
# zip directory and transfer
zipfile=$( mktemp -t transferXXX.zip )
cd $(dirname $file) && zip -r -q - $(basename $file) >> $zipfile
curl --progress-bar --upload-file "$zipfile" "https://transfer.sh/$basefile.zip" >> $tmpfile
rm -f $zipfile
else
# transfer file
curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >> $tmpfile
fi
else
# transfer pipe
curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >> $tmpfile
fi
cat $tmpfile
rm -f $tmpfile
}
# movie goodies
# animated gifs from any video
# from alex sexton gist.github.com/SlexAxton/4989674
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 900x900\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
echo "proper usage: gifify <input_movie.mov>. You DO need to include extension."
fi
}
# turn that video into webm.
# brew reinstall ffmpeg --with-libvpx
webmify(){
ffmpeg -i $1 -vcodec libvpx -acodec libvorbis -isync -copyts -aq 80 -threads 3 -qmax 30 -y $2 $1.webm
}
ffconcat(){
if [ -e "$1" ]; then
echo "Error: First argument is the output file and it should _not_ exist ($1)"
else
ffmpeg -f concat -safe 0 -i <(printf "file '$PWD/%s'\n" "${@:2}") -c copy "$1"
fi
}
# weather forecast
#
weather(){
if [ -z "$1" ]; then
curl -4 -A Curl wttr.in
else
curl -4 -A Curl wttr.in/`urlencode "$*"`
fi
}

263
common/.gitconfig Normal file
View File

@@ -0,0 +1,263 @@
[branch]
autosetupmerge = true
[push]
default = upstream
[rerere]
enabled = true
[rebase]
autosquash = true
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "decorate"]
remoteBranch = blue bold
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[alias]
#LAZY VERSIONS OF BASIC COMMANDS
co = checkout
br = branch
ci = commit
st = status
#BETTER VERSIONS OF BASIC COMMANDS
purr = pull --rebase
puff = pull --ff-only
difff = diff --color-words #just words
bbranch = branch -v
branches = branch -avvl
sth = stash -u
unstage = reset HEAD --
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1 => \\2/' | grep -v 'alias'| awk 'BEGIN { FS = \"=>\" }{ printf(\"%-20s=>%s\\n\", $1,$2)}'|sort
makegitrepo = !git init && git add . && git commit -m \"initial commit\"
fpush = push --force-with-lease
#BASIC HISTORY VIEWING
hist = log --graph --date=relative \
--format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s'
histfull = log --graph --date=relative --name-status \
--format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s%n'
llog = log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=iso
changelog = log --pretty=format:'%Cgreen%d %Creset%s' --date=iso
ls = log --pretty=format:'%C(yellow)%p..%h %C(white dim)%cd %<|(49,trunc)%an %C(reset)%s' --date=short --abbrev=8 --no-merges
recent = for-each-ref --sort=-committerdate refs/heads/ --format='%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset))'
#BASIC REPO INFORMATION
whois = "!sh -c 'git log -i -1 --pretty=\"format::%an <%ae>\n\" --author=\"$1\"' -"
whatis = show -s --pretty='tformat::%h (%s, %ad)' --date=short
howmany = "!sh -c 'git log -a --pretty=oneline | wc -l'"
howmanybywhom = shortlog -sn
#WHAT WAS GOING ON, WHILE YOU WERE AWAY
anychanges = !sh -c 'git fetch' && git log --oneline HEAD..origin/$1
anychangesonmaster = !sh -c 'git fetch' && git log --oneline HEAD..origin/master
whoischanging = !sh -c 'git shortlog HEAD..origin/$0'
whoischangingmaster = !sh -c 'git shortlog HEAD..origin/master'
#what branches you have on origin, with info on who is guilty and how long ago. Useful for gitflow and feature branches in general. Requires fetch up-front.
showorigin = "!sh -c 'for branch in `git branch -r | grep -v HEAD`;do echo `git show -s --format=\"%Cred%ci %C(green)%h %C(yellow)%cr %C(magenta)%an %C(blue)\" $branch | head -n 1` \\\t$branch; done | sort -r'"
#get remote branches
trackallbranches = !sh -c "for branchname in `git branch -r `; do git branch --track $branchname; done"
updateallbranches = !sh -c "for branchname in `git branch -r `; do git checkout $branchname ; git pull; done"
#TAGS
showtags = show-ref --tags
pushtags = push --tags
tagwithdate = !sh -c 'git tag "$0"_$(date "+%y-%m-%d_%H-%M-%S")'
lasttag = describe --abbrev=0 --tags
checkoutlasttag = !sh -c 'git checkout `git describe --abbrev=0 --tags`'
# Pushes given tag to remote 'origin' repo (or the remote passed as the second parameter)
publishtag = "!sh -c 'git push ${2:-origin} $1' -"
# Removes given tag from remote 'origin' repo (or the remote passed as the second parameter)
unpublishtag = "!sh -c 'git push ${2:-origin} :refs/tags/$1' -"
#IGNORING
# fix .gitignore
fixgitignore = !git rm -r --cached . && git add . && git commit -m \"Just a .gitignore fix \"
# Ignore files only locally
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
#OTHER
#Finds a filename in the git repository. Gives absolute location (from the git root).
find = !sh -c 'git ls-tree -r --name-only HEAD | grep --color $1' -
#Deletes all branches that were safely merged into the master. All other are skipped (no worries).
#on osx xargs does not have -r argument, so it fail. If you remove -r, it will run at least once, making this not safe operation
cleanup = !git branch --merged=master | grep -Ev '^\\* | master$' | xargs -r git branch -d
#Deletes orphaned remote branches (.git/refs/remotes/origin), clean up reflog and remove all untracked files
cleanuplocal = !git remote prune origin && git gc && git clean -df
# Check if any file in repo has whitespace errors
# As described in http://peter.eisentraut.org/blog/2014/11/04/checking-whitespace-with-git/
check-whitespace = !git diff-tree --check $(git hash-object -t tree /dev/null) HEAD
# Check if any file in repo has windows line endings
#Currently do not work as alias, works from comand line directly. There is a problem with \r
check-eol = !git grep --files-with-matches $'\\r' HEAD
#Jira tickets (from: http://blogs.atlassian.com/2014/08/whats-new-git-2-1/)
issues = "!f() { : git log ; echo 'Printing issue keys'; git log --oneline $@ | egrep -o [A-Z]+-[0-9]+ | sort | uniq; }; f"
#version for git below 2.1
#issues = !sh -c 'git log --oneline $@ | egrep -o [A-Z]+-[0-9]+ | sort | uniq' -
# Gets the current branch name (not so useful in itself, but used in other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Pushes the current branch to the remote "origin" (or the remote passed as the parameter) and set it to track the upstream branch
publish = "!sh -c 'git push -u ${1:-origin} $(git branch-name)' -"
# Deletes the remote version of the current branch from the remote "origin" (or the remote passed as the parameter)
unpublish = "!sh -c 'set -e; git push ${1:-origin} :$(git branch-name);git branch --unset-upstream $(git branch-name)' -"
# Fetch PR from GitHub by number/id
fetchpr = "!sh -c 'git fetch origin pull/$0/head:pr/$0'"
#add all, commit with message and push to remote
apm = "!f() { git add --all && git commit -m \"$@\" && git push; }; f"
[apply]
whitespace = nowarn
[core]
pager = less -R
[help]
autocorrect = 1 #fucking magic!
#Kudos for (copied from):
#http://git-scm.com/book/en/Customizing-Git-Git-Configuration
#http://robots.thoughtbot.com/post/4747482956/streamline-your-git-workflow-with-aliases
#http://oli.jp/2012/git-powerup/#conclusion
#http://blog.blindgaenger.net/advanced_git_aliases.html
#https://gist.github.com/robmiller/6018582 (branch-name, publish, unpublish)
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "decorate"]
remoteBranch = blue bold
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[alias]
drzewokurwa = log --graph --date=relative \
--format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s'
duzedrzewokurwa= log --graph --date=relative --name-status \
--format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s%n'
komitykurwa = log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=iso
ktotokurwa = "!sh -c 'git log -i -1 --pretty=\"format::%an <%ae>\n\" --author=\"$1\"' -"
cotokurwa = show -s --pretty='tformat::%h (%s, %ad)' --date=short
cotamkurwa = !sh -c 'git fetch' && git log --oneline HEAD..origin/$1
cotammistrzukurwa = !sh -c 'git fetch' && git log --oneline HEAD..origin/master
ktotamkurwa = !sh -c 'git shortlog HEAD..origin/$0'
ktotammistrzukurwa = !sh -c 'git shortlog HEAD..origin/master'
tagikurwa = show-ref --tags
pchajtagikurwa = push --tags
tagujzdatakurwa = !sh -c 'git tag "$0"_$(date "+%y-%m-%d_%H-%M-%S")'
wyjebtag = !sh -c 'git tag -d "$0"'
wyjebtagwchuj = !sh -c 'git tag -d "$0" && git push --delete origin tag "$0"'
pojebalosiekurwa = reset --hard
ktonajebalkurwa = blame
kurwa = status
cokurwa = status
cojestkurwa = diff
howcanikurwa = help
nabokkurwa = stash
zbokukurwa = stash apply
sprzatajkurwa = clean
sprzatajwszystkokurwa = !sh -c 'git clean -x' && git reset --hard
wyjebzrobionekurwa = !sh -c 'git branch --merged' | grep -v "\\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
majonez = !sh -c 'branch="$(git rev-parse --abbrev-ref HEAD)" && git checkout master && git pull && git branch -d "$branch"'
dodajkurwa = add
takkurwa = commit
sciagajkurwa = pull
sciagajtegokurwa = !sh -c 'git pull origin $(git rev-parse --abbrev-ref HEAD)'
dalejkurwa = push
dalejnowociotokurwa = push -u origin master
pchajkurwa = push
pchajkurwayolo = push --force
sorrykurwa = commit --amend -m
spierdolwszystko = merge
cofnijwchuj = reset HEAD~100
wypierdolwchuj = reset HEAD~100 --hard
acomitamkurwa = push origin --force
walictokurwa = rm .* -rF
palisiekurwa = !sh -c 'git add . && git commit -m \"palilo sie\" --no-gpg-sign --no-verify && git push --force && echo \"Ok, now RUN!\"'
[apply]
whitespace = nowarn
[user]
name = VectorKappa
email = piotrpatalong@gmail.com
# URL shorthands
[url "git@github.com:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
insteadOf = "gist:"
[diff]
# Detect copies as well as renames
renames = copies
[diff "bin"]
# Use `hexdump` to diff binary files
textconv = hexdump -v -C

44
common/.inputrc Normal file
View File

@@ -0,0 +1,44 @@
# Make Tab autocomplete regardless of filename case
set completion-ignore-case on
# List all matches in case multiple possible completions are possible
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Use the text that has already been typed as the prefix for searching through
# commands (i.e. more intelligent Up/Down behavior)
"\e[B": history-search-forward
"\e[A": history-search-backward
# ctrl left, ctrl right for moving on the readline by word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# Do not autocomplete hidden files unless the pattern explicitly begins with a dot
set match-hidden-files off
# Show all autocomplete results at once
set page-completions off
# If there are more than 200 possible completions for a word, ask to show them all
set completion-query-items 200
# Show extra file information when completing, like `ls -F` does
set visible-stats on
# Be more intelligent when autocompleting by also looking at the text after
# the cursor. For example, when the current line is "cd ~/src/mozil", and
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
# Readline used by Bash 4.)
set skip-completed-text on
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
set input-meta on
set output-meta on
set convert-meta off
# Use Alt/Meta + Delete to delete the preceding word
"\e[3;3~": kill-word

378
common/.pythonrc Normal file
View File

@@ -0,0 +1,378 @@
# -*- coding: utf-8 -*-
"""Startup script that adds niceties to the interactive interpreter.
This script adds the following things:
- Readline bindings, tab completion, and history (in ~/.history/python,
which can be disabled by setting NOHIST in the environment)
- Pretty printing of expression output (with Pygments highlighting)
- Pygments highlighting of tracebacks
- Function arguments in repr() for callables
- A source() function that displays the source of an arbitrary object
(in a pager, with Pygments highlighting)
Python 2.3 and newer are supported, including Python 3.x.
Note: The default versions of Python that ship with Mac OS X don't
come with readline. To get readline support, you can try a stand-alone
readline library[1], or you can use a different Python distribution
(like the one from MacPorts).
[1]: http://pypi.python.org/pypi/readline
"""
def _pythonrc_enable_readline():
"""Enable readline, tab completion, and history"""
import sys
try:
import readline
import rlcompleter
except ImportError:
sys.stderr.write('readline unavailable - tab completion disabled.\n')
return
old_complete = readline.get_completer()
def complete(text, state):
if not text:
# Insert four spaces for indentation
return (' ', None)[state]
else:
return old_complete(text, state)
readline.parse_and_bind('tab: complete')
readline.set_completer(complete)
def _pythonrc_enable_history():
import atexit
import os
try:
import readline
except:
return
# "NOHIST= python" will disable history
if 'NOHIST' not in os.environ:
history_path = os.path.expanduser('~/.history/python')
has_written = [False]
def write_history():
if not has_written[0]:
readline.write_history_file(history_path)
print('Written history to %s' % history_path)
has_written[0] = True
atexit.register(write_history)
if os.path.isfile(history_path):
try:
readline.read_history_file(history_path)
except IOError:
pass
readline.set_history_length(-1)
def _pythonrc_enable_pprint():
"""Enable pretty printing of evaluated expressions"""
import pprint
import sys
try:
if sys.platform == 'win32':
raise ImportError()
from cStringIO import StringIO
from pygments import highlight
from pygments.lexers import PythonLexer, PythonTracebackLexer
from pygments.formatters import TerminalFormatter
def pphighlight(o, *a, **kw):
s = pprint.pformat(o, *a, **kw)
try:
sys.stdout.write(
highlight(s, PythonLexer(), TerminalFormatter()))
except UnicodeError:
sys.stdout.write(s)
sys.stdout.write('\n')
_old_excepthook = sys.excepthook
def excepthook(exctype, value, traceback):
"""Prints exceptions to sys.stderr and colorizes them"""
# traceback.format_exception() isn't used because it's
# inconsistent with the built-in formatter
old_stderr = sys.stderr
sys.stderr = StringIO()
try:
_old_excepthook(exctype, value, traceback)
s = sys.stderr.getvalue()
try:
s = highlight(
s, PythonTracebackLexer(), TerminalFormatter())
except UnicodeError:
pass
old_stderr.write(s)
finally:
sys.stderr = old_stderr
sys.excepthook = excepthook
except ImportError:
pphighlight = pprint.pprint
try:
import __builtin__
except ImportError:
import builtins as __builtin__
import inspect
import pydoc
import sys
import types
help_types = [types.BuiltinFunctionType, types.BuiltinMethodType,
types.FunctionType, types.MethodType, types.ModuleType,
type,
# method_descriptor
type(list.remove)]
if hasattr(types, 'UnboundMethodType'):
help_types.append(types.UnboundMethodType)
help_types = tuple(help_types)
def _ioctl_width(fd):
from fcntl import ioctl
from struct import pack, unpack
from termios import TIOCGWINSZ
return unpack('HHHH',
ioctl(fd, TIOCGWINSZ, pack('HHHH', 0, 0, 0, 0)))[1]
def get_width():
"""Returns terminal width"""
width = 0
try:
width = _ioctl_width(0) or _ioctl_width(1) or _ioctl_width(2)
except ImportError:
pass
if not width:
import os
width = os.environ.get('COLUMNS', 0)
return width
if hasattr(inspect, 'getfullargspec'):
getargspec = inspect.getfullargspec
else:
getargspec = inspect.getargspec
def pprinthook(value):
"""Pretty print an object to sys.stdout and also save it in
__builtin__.
"""
if value is None:
return
__builtin__._ = value
if isinstance(value, help_types):
reprstr = repr(value)
try:
if inspect.isfunction(value):
parts = reprstr.split(' ')
parts[1] += inspect.formatargspec(*getargspec(value))
reprstr = ' '.join(parts)
elif inspect.ismethod(value):
parts = reprstr[:-1].split(' ')
parts[2] += inspect.formatargspec(*getargspec(value))
reprstr = ' '.join(parts) + '>'
except TypeError:
pass
sys.stdout.write(reprstr)
sys.stdout.write('\n')
if getattr(value, '__doc__', None):
sys.stdout.write('\n')
sys.stdout.write(pydoc.getdoc(value))
sys.stdout.write('\n')
else:
pphighlight(value, width=get_width() or 80)
sys.displayhook = pprinthook
def _pythonrc_fix_linecache():
"""Add source(obj) that shows the source code for a given object"""
import os
import sys
from linecache import cache
# linecache.updatecache() replacement that actually works with zips.
# See http://bugs.python.org/issue4223 for more information.
def updatecache(filename, module_globals=None):
"""Update a cache entry and return its list of lines.
If something's wrong, print a message, discard the cache entry,
and return an empty list."""
if filename in cache:
del cache[filename]
if not filename or filename[0] + filename[-1] == '<>':
return []
fullname = filename
try:
stat = os.stat(fullname)
except os.error:
basename = os.path.split(filename)[1]
if module_globals and '__loader__' in module_globals:
name = module_globals.get('__name__')
loader = module_globals['__loader__']
get_source = getattr(loader, 'get_source', None)
if name and get_source:
try:
data = get_source(name)
except (ImportError, IOError):
pass
else:
if data is None:
return []
cache[filename] = (
len(data), None,
[line + '\n' for line in data.splitlines()],
fullname
)
return cache[filename][2]
for dirname in sys.path:
try:
fullname = os.path.join(dirname, basename)
except (TypeError, AttributeError):
pass
else:
try:
stat = os.stat(fullname)
break
except os.error:
pass
else:
return []
try:
fp = open(fullname, 'rU')
lines = fp.readlines()
fp.close()
except IOError:
return []
size, mtime = stat.st_size, stat.st_mtime
cache[filename] = size, mtime, lines, fullname
return lines
import linecache
linecache.updatecache = updatecache
def source(obj):
"""Display the source code of an object.
Applies syntax highlighting if Pygments is available.
"""
import os
import sys
from inspect import findsource, getmodule, getsource, getsourcefile
from pydoc import pager
try:
# Check to see if the object is defined in a shared library, which
# findsource() doesn't do properly (see issue4050)
if not getsourcefile(obj):
raise TypeError
s = getsource(obj)
except TypeError:
sys.stderr.write("Source code unavailable (maybe it's part of "
"a C extension?)\n")
return
# Detect the module's file encoding. We could use
# tokenize.detect_encoding(), but it's only available in Python 3.
import re
enc = 'ascii'
for line in findsource(getmodule(obj))[0][:2]:
m = re.search(r'coding[:=]\s*([-\w.]+)', line)
if m:
enc = m.group(1)
if hasattr(s, 'decode'):
try:
s = s.decode(enc, 'replace')
except LookupError:
s = s.decode('ascii', 'replace')
try:
# For now, let's assume we'll never have a proper terminal on win32
if sys.platform == 'win32':
raise ImportError
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import TerminalFormatter
s = highlight(s, PythonLexer(), TerminalFormatter())
except (ImportError, UnicodeError):
pass
# Display the source code in the pager, and try to convince less not to
# escape color control codes.
has_lessopts = 'LESS' in os.environ
lessopts = os.environ.get('LESS', '')
try:
os.environ['LESS'] = lessopts + ' -R'
if hasattr(s, 'decode'):
pager(s.encode(sys.stdout.encoding, 'replace'))
else:
pager(s)
finally:
if has_lessopts:
os.environ['LESS'] = lessopts
else:
os.environ.pop('LESS', None)
if __name__ == '__main__':
__doc__ = None
# Make sure modules in the current directory can't interfere
import sys
try:
try:
cwd = sys.path.index('')
sys.path.pop(cwd)
except ValueError:
cwd = None
sys.ps1 = "\001\033[0;32m\002>>> \001\033[1;37m\002"
sys.ps2 = "\001\033[1;31m\002... \001\033[1;37m\002"
# Run installation functions and don't taint the global namespace
try:
try:
import jedi.utils
jedi.utils.setup_readline()
del jedi
except:
print('No jedi here. Coming to the dark side.')
_pythonrc_enable_readline()
del _pythonrc_enable_readline
_pythonrc_enable_history()
_pythonrc_enable_pprint()
_pythonrc_fix_linecache()
del _pythonrc_enable_history
del _pythonrc_enable_pprint
del _pythonrc_fix_linecache
finally:
if cwd is not None:
sys.path.insert(cwd, '')
del cwd
finally:
pass

40
common/.wgetrc Normal file
View File

@@ -0,0 +1,40 @@
# Use the server-provided last modification date, if available
timestamping = on
# Do not go up in the directory structure when downloading recursively
no_parent = on
# Wait 60 seconds before timing out. This applies to all timeouts: DNS, connect and read. (The default read timeout is 15 minutes!)
timeout = 60
# Retry a few times when a download fails, but dont overdo it. (The default is 20!)
tries = 3
# Retry even when the connection was refused
retry_connrefused = on
# Use the last component of a redirection URL for the local file name
trust_server_names = on
# Follow FTP links from HTML documents by default
follow_ftp = on
# Add a `.html` extension to `text/html` or `application/xhtml+xml` files that lack one, or a `.css` extension to `text/css` files that lack one
adjust_extension = on
# Use UTF-8 as the default system encoding
# Disabled as it makes `wget` builds that dont support this feature unusable.
# Does anyone know how to conditionally configure a wget setting?
# http://unix.stackexchange.com/q/34730/6040
#local_encoding = UTF-8
# Ignore `robots.txt` and `<meta name=robots content=nofollow>`
robots = off
# Print the HTTP and FTP server responses
server_response = on
# Disguise as IE 9 on Windows 7
user_agent = Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
progress = bar