From 31d49743a0022eff73defd907579f106612c8df5 Mon Sep 17 00:00:00 2001 From: thomasba Date: Sat, 18 Jul 2015 13:02:44 +0200 Subject: [PATCH] Init --- .gitignore | 2 + README.md | 5 + bin/abuse | 76 ++++++++++++ bin/dice | 11 ++ bin/extremedownload.py | 71 +++++++++++ bin/ff-opt.sh | 18 +++ bin/mail_cron.sh | 20 ++++ bin/mkd | 90 ++++++++++++++ bin/pandoc-html5 | 19 +++ bin/paste42 | 111 ++++++++++++++++++ bin/ssp | 35 ++++++ bin/tm | 31 +++++ bin/tso | 59 ++++++++++ bin/vim-highlight | 40 +++++++ bin/volume.sh | 24 ++++ gitconfig | 7 ++ i3/autostart | 18 +++ i3/config | 241 ++++++++++++++++++++++++++++++++++++++ i3/i3status.conf | 44 +++++++ i3/speedswapper | 5 + install | 139 ++++++++++++++++++++++ opt/.keep | 0 pentadactylrc | 8 ++ tmux/tmux.conf | 96 +++++++++++++++ vim/bundle/.keep | 0 vim/colors/elflord2.vim | 51 ++++++++ vim/ftdetect/filetype.vim | 4 + vim/ftplugin/html.vim | 6 + vim/ftplugin/markdown.vim | 17 +++ vim/ftplugin/php.vim | 7 ++ vim/ftplugin/python.vim | 20 ++++ vim/ftplugin/tex.vim | 74 ++++++++++++ vim/spell/.keep | 0 vim/vimrc | 183 +++++++++++++++++++++++++++++ vim/vundle.vim | 65 ++++++++++ xinitrc | 21 ++++ zsh/commands | 121 +++++++++++++++++++ zsh/commands-pc | 44 +++++++ zsh/commands-server | 42 +++++++ zsh/git-commands | 14 +++ zsh/programs | 75 ++++++++++++ zsh/rbenv | 19 +++ zsh/thomasba.zsh-theme | 161 +++++++++++++++++++++++++ zsh/zshrc | 99 ++++++++++++++++ 44 files changed, 2193 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 bin/abuse create mode 100755 bin/dice create mode 100755 bin/extremedownload.py create mode 100755 bin/ff-opt.sh create mode 100755 bin/mail_cron.sh create mode 100755 bin/mkd create mode 100755 bin/pandoc-html5 create mode 100755 bin/paste42 create mode 100755 bin/ssp create mode 100755 bin/tm create mode 100755 bin/tso create mode 100755 bin/vim-highlight create mode 100755 bin/volume.sh create mode 100644 gitconfig create mode 100755 i3/autostart create mode 100644 i3/config create mode 100644 i3/i3status.conf create mode 100644 i3/speedswapper create mode 100755 install create mode 100644 opt/.keep create mode 100644 pentadactylrc create mode 100644 tmux/tmux.conf create mode 100644 vim/bundle/.keep create mode 100644 vim/colors/elflord2.vim create mode 100644 vim/ftdetect/filetype.vim create mode 100644 vim/ftplugin/html.vim create mode 100644 vim/ftplugin/markdown.vim create mode 100644 vim/ftplugin/php.vim create mode 100644 vim/ftplugin/python.vim create mode 100644 vim/ftplugin/tex.vim create mode 100644 vim/spell/.keep create mode 100644 vim/vimrc create mode 100644 vim/vundle.vim create mode 100644 xinitrc create mode 100644 zsh/commands create mode 100644 zsh/commands-pc create mode 100644 zsh/commands-server create mode 100644 zsh/git-commands create mode 100644 zsh/programs create mode 100644 zsh/rbenv create mode 100644 zsh/thomasba.zsh-theme create mode 100644 zsh/zshrc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c636a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +opt +vim/bundle diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c84a71 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# dot-files + +This are my dot-files :-) + +Installing them is easy. Just execute the `install` script. diff --git a/bin/abuse b/bin/abuse new file mode 100755 index 0000000..b65acde --- /dev/null +++ b/bin/abuse @@ -0,0 +1,76 @@ +#!/usr/bin/env ruby +require 'getopt/std' +require 'terminal-table' +require 'whois' + +headings = ["weight", "email"] +$emails = [] +$counter = 0 + +opt = Getopt::Std.getopts("hHpl:w") + +if ( (opt["l"] and ( not (/^[1-9][0-9]*$/.match(opt["l"])) or opt["l"].to_i < 1 ) ) or opt["h"] or opt["H"] ) + puts "#{$0} [options] [ip|hostname]" + puts " -p No table, just text" + puts " -l Maximum lines" + puts " -w only matches with highest priority" + exit 0 +end + +def insert(value, email) + if $emails.select{|a| a[1] == email}.count == 0 + $emails.push( [value + $counter, email] ) + $counter = $counter + 1 + elsif ( $emails.select{|a| a[1] == email}[0][0] > value+$counter ) + $emails.select{|a| a[1] == email}[0][0] = value+$counter + $counter = $counter + 1 + end +end + +if ( ARGV.length == 1 ) + w = Whois::Client.new + input = w.lookup(ARGV[0]).to_s +else + input = ARGF +end + + +input.each_line do |line| + line = line.force_encoding("BINARY").encode("UTF-8", invalid: :replace, undef: :replace, replace: "?").force_encoding("UTF-8").gsub("\n",'') + + if ( /% Abuse contact for '.*' is '(?[\-\w.]+@([a-z0-9][a-z\-0-9]+\.)+[a-z]{2,4})'/i =~ line ) + insert(0, mail.downcase) + elsif ( /^OrgAbuseEmail:\s+(?[\-\w.]+@([a-z0-9][a-z\-0-9]+\.)+[a-z]{2,4})/i =~ line ) + insert(100000, mail1.downcase) + elsif ( /^abuse\-mailbox:\s+(?[\-\w.]+@([a-z0-9][a-z\-0-9]+\.)+[a-z]{2,4})/i =~ line ) + insert(200000, mail2.downcase) + elsif ( /^RAbuseEmail:\s+(?[\-\w.]+@([a-z0-9][a-z\-0-9]+\.)+[a-z]{2,4})/i =~ line ) + insert(300000, mail3.downcase) + elsif ( /^OrgTechEmail:\s+(?[\-\w.]+@([a-z0-9][a-z\-0-9]+\.)+[a-z]{2,4})/i =~ line ) + insert(400000, mail4.downcase) + elsif ( /e\-?mail.*(?abuse@([a-z0-9][a-z\-0-9]+\.)+[a-z]{2,4})/i =~ line ) + insert(500000, mail5.downcase) + elsif ( /(?[\-\w.]+@([a-z0-9][a-z\-0-9]+\.)+[a-z]{2,4})/i =~ line ) + insert(700000, mail6.downcase) + end +end + +$emails = $emails.sort_by {|a,b| a[0] <=> b[0]} + +if opt["l"] + $emails = $emails.first(opt["l"].to_i) +end + +if opt["w"] + weight = $emails.first[0]-($emails.first[0]%100000); + $emails.delete_if { |x| x[0]-(x[0]%100000) != weight } +end + +if ( opt["p"] ) + $emails.each do |l| + puts l[1] + end +else + table = Terminal::Table.new(rows: $emails, headings: headings) + puts table +end diff --git a/bin/dice b/bin/dice new file mode 100755 index 0000000..9533e97 --- /dev/null +++ b/bin/dice @@ -0,0 +1,11 @@ +#!/bin/bash +z=$(($RANDOM % 6 +1)) +case $z in + 1) echo "1: ⚀" ;; + 2) echo "2: ⚁" ;; + 3) echo "3: ⚂" ;; + 4) echo "4: ⚃" ;; + 5) echo "5: ⚄" ;; + 6) echo "6: ⚅" ;; + *) echo "The dice is rollin’ and rollin’ and..." +esac diff --git a/bin/extremedownload.py b/bin/extremedownload.py new file mode 100755 index 0000000..4427e90 --- /dev/null +++ b/bin/extremedownload.py @@ -0,0 +1,71 @@ +#!/bin/python +# vim:set ts=8 sts=8 sw=8 cc=80 tw=80 noet: + +import os +import sys +import re +import json +import urllib.request + +def get_page(url): + f = urllib.request.urlopen(url) + return f.readall().decode("utf-8") + +def retrieve(url, filename): + urllib.request.urlretrieve(url, filename) + +def api_call(method, extreme_env): + url = "http%s://%s%s%s" % \ + ("s" if extreme_env["API_USE_SSL"] == "yes" else "", + extreme_env["API_HOST"], + extreme_env["API_PATH"], method) + authtoken = extreme_env["API_AUTH"] + request = urllib.request.Request(url, headers={"X-API-Auth": authtoken}) + f = urllib.request.urlopen(request) + return json.loads(f.readall().decode("utf-8")) + +def get_extreme_env(url): + page = get_page(url) + pattern = r"" + result = re.search(pattern, page) + return json.loads(result.group(1)) + +def get_album(album_id, extreme_env): + return api_call("albums/%s" % album_id, extreme_env) + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("usage: %s album-id" % sys.argv[0]) + sys.exit(1) + album_id = sys.argv[1] + print("ripping album id %s" % album_id) + extreme_env = get_extreme_env("https://www.extrememusic.com") + album = get_album(album_id, extreme_env) + album_title = album["album"]["title"] + album_no = album["album"]["album_no"] + print("album's title: %s (%s)" % (album_title, album_no)) + output_directory = "%s - %s" % (album_no, album_title) + if not os.path.exists(output_directory): + os.makedirs(output_directory) + tracks = album["track_sounds"] + try: + for track in tracks: + version = track["version_type"] + no = track["track_sound_no"] + title = track["title"].strip() + preview = track["assets"]["audio"]["preview_url"] + suffix = (" (%s)" % version) \ + if version != "Full Version" else "" + filename = "%s %s%s" % (no, title, suffix) + filename = filename.replace("/", "-") + print(filename) + try: + retrieve(preview, "%s/%s.mp3" % \ + (output_directory, filename)) + except urllib.error.HTTPError as e: + print("%d @ URL: '%s'" % (e.code, preview)) + print("reason: '%s'" % e.reason) + if e.code != 404: + raise e + except KeyboardInterrupt: + print("download cancelled") diff --git a/bin/ff-opt.sh b/bin/ff-opt.sh new file mode 100755 index 0000000..ed3dccd --- /dev/null +++ b/bin/ff-opt.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# optimize firefox sqlite databases + +if [ `ps aux | grep -v grep | grep -c firefox` = "0" ] ; then + IFS=" +" + for i in `find ~/.mozilla -name \*.sqlite`; do + echo "Optimizing \"$i\"..." + sqlite3 $i vacuum + sqlite3 $i reindex + done + echo "done" +else + echo "Firefox is running..." + exit 1 +fi + diff --git a/bin/mail_cron.sh b/bin/mail_cron.sh new file mode 100755 index 0000000..f1367b1 --- /dev/null +++ b/bin/mail_cron.sh @@ -0,0 +1,20 @@ +#!/bin/sh +PID=$(pgrep offlineimap) +#FPID=$(pgrep imapfilter) +WPID=$(pgrep wvdial) + +if [ -n "$PID" ] ; then + echo "It’s up :-P" + exit 1 +fi + +# UMTS Syncing once… +if [ -n "$WPID" ] ; then + echo Syncing once! + offlineimap -o -u Noninteractive.Quiet &>/dev/null & + exit 0 +fi + +#imapfilter &> /dev/null +offlineimap -u Noninteractive.Quiet &>/dev/null & + diff --git a/bin/mkd b/bin/mkd new file mode 100755 index 0000000..b867ab8 --- /dev/null +++ b/bin/mkd @@ -0,0 +1,90 @@ +#!/bin/bash + +O_LINK=0 +O_PLAIN=0 + +if command -v multimarkdown >> /dev/null ; then + MKD="multimarkdown" +elif command -v markdown >> /dev/null ; then + MKD="markdown" +else + echo "Markdown not found!" + exit 2 +fi + +usage() { + echo "Usage:" + echo " $0 [options] " + echo "Options:" + if [ "$MKD" = "markdown" ] ; then + echo " -l Make Headers clickable (Only with multimarkdown)" + else + echo " -l Make Headers clickable" + fi + echo " -o Specify an outfile" + echo " -t Specify a title" + echo " -p Plain HTML, no css" + exit 1 +} + +OUTFILE="" +TITLE="" + +# Read options +while getopts lphHo:t: opt ; do + case "$opt" in + \-) break;; + l) O_LINK=1 ;; + p) O_PLAIN=1 ;; + o) OUTFILE="$OPTARG";; + t) TITLE="$OPTARG";; + [hH]) usage ;; + esac +done +shift $(expr $OPTIND - 1) + +INFILE="$1" + +if [ ! -f "$INFILE" ] ; then + usage +fi + +BASENAME="$(basename $INFILE)" +T_="$(echo -n $BASENAME|sed -re 's/\.(markdown|mkd|mk|md)$//')" +[ "$OUTFILE" = "" ] && OUTFILE="${T_}.html" +[ "$TITLE" = "" ] && TITLE="$(echo -n ${T_}|tr '_' ' ')" + + +echo "" > $OUTFILE +echo "" >> $OUTFILE +echo " " >> $OUTFILE +echo " $TITLE" >> $OUTFILE +if [ $O_PLAIN -eq 0 ] ; then + echo " " >> $OUTFILE +fi +if [ "$MKD" = "multimarkdown" -a $O_LINK -eq 1 ] ; then + echo " " >> $OUTFILE + echo " " >> $OUTFILE +fi +echo " " >> $OUTFILE +echo " " >> $OUTFILE +$MKD $INFILE >> $OUTFILE +echo " " >> $OUTFILE +echo "" >> $OUTFILE diff --git a/bin/pandoc-html5 b/bin/pandoc-html5 new file mode 100755 index 0000000..f8f8f2b --- /dev/null +++ b/bin/pandoc-html5 @@ -0,0 +1,19 @@ +#!/bin/bash + +cat << EOS + + + + ##title## + + + + +EOS +pandoc -f markdown -t html5 $@ +cat << EOS + + +EOS diff --git a/bin/paste42 b/bin/paste42 new file mode 100755 index 0000000..1792bbd --- /dev/null +++ b/bin/paste42 @@ -0,0 +1,111 @@ +#!/bin/bash +# Aufrufsyntax: +# paste42.sh [-s] [-t "filetype"] [-l] [-h] [-u] file + +# Variablen initialisieren & defaults setzen +VERSION="20110621.1" +ATTR='' +OPTS="" +EXP='0' +TYPE="text" +TYPES="4cs 6502acme 6502kickass 6502tasm 68000devpac abap actionscript3 actionscript ada algol68 apache applescript apt_sources asm asp autoconf autohotkey autoit avisynth awk bascomavr bash basic4gl bf bibtex blitzbasic bnf boo caddcl cadlisp cfdg cfm chaiscript cil c_loadrunner clojure c_mac cmake cobol coffeescript c cpp cpp-qt csharp css cuesheet dcs delphi diff div dos dot d ecmascript eiffel email epc e erlang euphoria f1 falcon fo fortran freebasic fsharp gambas gdb genero genie gettext glsl gml gnuplot go groovy gwbasic haskell hicest hq9plus html4strict html5 icon idl ini inno intercal io java5 java javascript j jquery kixtart klonec klonecpp latex lb lisp llvm locobasic logtalk lolcode lotusformulas lotusscript lscript lsl2 lua m68k magiksf make mapbasic matlab mirc mmix modula2 modula3 mpasm mxml mysql newlisp nsis oberon2 objc objeck ocaml-brief ocaml oobas oracle11 oracle8 oxygene oz pascal pcre perl6 perl per pf php-brief php pic16 pike pixelbender pli plsql postgresql povray powerbuilder powershell proftpd progress prolog properties providex purebasic pycon python qbasic q rails rebol reg robots rpmspec rsplus ruby sas scala scheme scilab sdlbasic smalltalk smarty sql systemverilog tcl teraterm text thinbasic tsql typoscript unicon uscript vala vbnet vb verilog vhdl vim visualfoxpro visualprolog whitespace whois winbatch xbasic xml xorg_conf xpp yaml z80 zxbasic" +pw=0 + +trap 'stty echo;exit 1;' 3 9 15 + +usage() { + echo "Usage:" + echo " $0 [-s] [-t \"type\"] [-l] [-e 10m|1h|1d|1w|4w|1y|date] file" + echo " -s not \"public\"" + echo " -t file type" + echo " -l filetypes" + echo " -h this help" + echo " -u check for update" + echo " -e