Browse code
Adding several scripts and a stumpwm config
fiddlerwoaroof authored on 23/05/2016 18:36:59
Showing 9 changed files
Showing 9 changed files
- .vimrc
- scripts/choose-session
- scripts/filter_suffix
- scripts/git-ignore
- scripts/partial_sort
- scripts/random_run
- scripts/startmonad
- scripts/yeganesh_run
- stumpwmrc
... | ... |
@@ -52,6 +52,8 @@ NeoBundleFetch 'Shougo/neobundle.vim' |
52 | 52 |
|
53 | 53 |
|
54 | 54 |
|
55 |
+NeoBundle 'dbakker/vim-paragraph-motion' |
|
56 |
+ NeoBundle 'jceb/vim-editqf' |
|
55 | 57 |
NeoBundle 'mustache/vim-mustache-handlebars' |
56 | 58 |
NeoBundle 'davidoc/taskpaper.vim' |
57 | 59 |
NeoBundle 'altercation/vim-colors-solarized' |
... | ... |
@@ -85,7 +87,7 @@ NeoBundleFetch 'Shougo/neobundle.vim' |
85 | 87 |
NeoBundle 'othree/javascript-libraries-syntax.vim' |
86 | 88 |
NeoBundle 'pangloss/vim-javascript' |
87 | 89 |
NeoBundle 'raichoo/haskell-vim' |
88 |
- "NeoBundle 'rking/ag.vim' "Ag search utility |
|
90 |
+ NeoBundle 'rking/ag.vim' "Ag search utility |
|
89 | 91 |
NeoBundle 'rust-lang/rust.vim' |
90 | 92 |
NeoBundle 'scrooloose/nerdcommenter' |
91 | 93 |
NeoBundle 'scrooloose/nerdtree' |
... | ... |
@@ -361,12 +363,12 @@ if executable('ag') |
361 | 363 |
"Use ag in unite grep source. |
362 | 364 |
let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', '', '--ignore', '.git', '--ignore', '.sass-cache'] |
363 | 365 |
let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', '', '--ignore', '.git', '--ignore', '.sass-cache'] |
364 |
- "let g:unite_source_grep_command = 'ag' |
|
365 |
- "let g:unite_source_grep_default_opts = |
|
366 |
- " \ '--line-numbers --nocolor --nogroup --hidden --ignore ' . |
|
367 |
- " \ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'' ' . |
|
368 |
- " \ '--ignore ''**/*.pyc''' |
|
369 |
- "let g:unite_source_grep_recursive_opt = '' |
|
366 |
+ let g:unite_source_grep_command = 'ag' |
|
367 |
+ let g:unite_source_grep_default_opts = |
|
368 |
+ \ '--line-numbers --nocolor --nogroup --hidden --ignore ' . |
|
369 |
+ \ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'' ' . |
|
370 |
+ \ '--ignore ''**/*.pyc''' |
|
371 |
+ let g:unite_source_grep_recursive_opt = '' |
|
370 | 372 |
elseif executable('ack-grep') |
371 | 373 |
let g:unite_source_grep_command = 'ack-grep' |
372 | 374 |
" Match whole word only. This might/might not be a good idea |
0 | 10 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,22 @@ |
1 |
+#!/bin/python -u |
|
2 |
+import collections |
|
3 |
+import os |
|
4 |
+ |
|
5 |
+items = collections.OrderedDict() |
|
6 |
+ |
|
7 |
+import sys |
|
8 |
+ |
|
9 |
+def file_iter(fil): |
|
10 |
+ line = 0; |
|
11 |
+ while line != '': |
|
12 |
+ line = fil.readline() |
|
13 |
+ yield line |
|
14 |
+ |
|
15 |
+if __name__ == '__main__': |
|
16 |
+ for lin in file_iter(sys.stdin): |
|
17 |
+ head, _, tail = os.path.basename(lin).rpartition('__') |
|
18 |
+ items.setdefault(head, []).append(lin) |
|
19 |
+ |
|
20 |
+ for key in items: |
|
21 |
+ if len(items[key]) > 1: |
|
22 |
+ print '\n'.join(sorted(items[key])) |
0 | 23 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,31 @@ |
1 |
+#!/usr/bin/env python |
|
2 |
+import argparse |
|
3 |
+ |
|
4 |
+parser = argparse.ArgumentParser() |
|
5 |
+parser.add_argument('files_to_ignore', nargs='*') |
|
6 |
+args = parser.parse_args() |
|
7 |
+ |
|
8 |
+try: |
|
9 |
+ lines = [] |
|
10 |
+ |
|
11 |
+ if args.files_to_ignore != []: |
|
12 |
+ lines.extend(args.files_to_ignore) |
|
13 |
+ |
|
14 |
+ else: |
|
15 |
+ lines = [] |
|
16 |
+ try: |
|
17 |
+ getline = lambda: raw_input('? ').strip() |
|
18 |
+ line = getline() |
|
19 |
+ while line != '.': |
|
20 |
+ lines.append(line) |
|
21 |
+ line = getline() |
|
22 |
+ except EOFError: |
|
23 |
+ pass |
|
24 |
+ |
|
25 |
+ |
|
26 |
+ with open('.gitignore', 'a') as f: |
|
27 |
+ for line in lines: |
|
28 |
+ print 'ignoring %s' % line |
|
29 |
+ print >> f, line |
|
30 |
+except KeyboardInterrupt: |
|
31 |
+ pass |
0 | 32 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+#!/usr/bin/python -u |
|
2 |
+from __future__ import print_function |
|
3 |
+ |
|
4 |
+import heapq |
|
5 |
+ |
|
6 |
+def file_iter(fil): |
|
7 |
+ line = 0 |
|
8 |
+ while line != '': |
|
9 |
+ line = fil.readline() |
|
10 |
+ yield line |
|
11 |
+ |
|
12 |
+def sorter(gen, len_): |
|
13 |
+ buffer = [] |
|
14 |
+ |
|
15 |
+ for line in gen: |
|
16 |
+ heapq.heappush(buffer, line) |
|
17 |
+ if len(buffer) == len_: |
|
18 |
+ yield heapq.heappop(buffer) |
|
19 |
+ |
|
20 |
+if __name__ == '__main__': |
|
21 |
+ import sys |
|
22 |
+ for line in sorter(file_iter(sys.stdin), 10): |
|
23 |
+ print('>', line, end='') |
0 | 24 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,16 @@ |
1 |
+#!/usr/bin/python2 |
|
2 |
+import subprocess |
|
3 |
+import random |
|
4 |
+import argparse |
|
5 |
+ |
|
6 |
+p = argparse.ArgumentParser() |
|
7 |
+p.add_argument('probability', nargs=2) |
|
8 |
+p.add_argument('program') |
|
9 |
+ |
|
10 |
+args = p.parse_args() |
|
11 |
+ |
|
12 |
+prob = map(float, args.probability) |
|
13 |
+prob = prob[0]/prob[1] |
|
14 |
+ |
|
15 |
+if random.random() < prob: |
|
16 |
+ subprocess.call(args.program) |
67 | 66 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,15 @@ |
1 |
+#!/bin/sh |
|
2 |
+cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"} |
|
3 |
+if [ -d "$cachedir" ]; then |
|
4 |
+ cache=$cachedir/yeganesh_run |
|
5 |
+else |
|
6 |
+ cache=$HOME/.yeganesh_cache # if no xdg dir, fall back to dotfile in ~ |
|
7 |
+fi |
|
8 |
+( |
|
9 |
+ IFS=: |
|
10 |
+ if stest -dqr -n "$cache" $PATH; then |
|
11 |
+ stest -flx $PATH | sort -u | tee "$cache" | /home/edwlan/.local/bin/yeganesh "$@" |
|
12 |
+ else |
|
13 |
+ /home/edwlan/.local/bin/yeganesh "$@" < "$cache" |
|
14 |
+ fi |
|
15 |
+) | ${SHELL:-"/bin/sh"} & |
0 | 16 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,114 @@ |
1 |
+(in-package :stumpwm) |
|
2 |
+ |
|
3 |
+(eval-when (:load-toplevel :compile-toplevel :execute) |
|
4 |
+ (load "~/quicklisp/setup.lisp") |
|
5 |
+ (ql:quickload :swank)) |
|
6 |
+ |
|
7 |
+(defcommand start-swank () () |
|
8 |
+ (swank:start-server :port 4587 :dont-close t)) |
|
9 |
+ |
|
10 |
+ |
|
11 |
+(set-prefix-key (kbd "s-space")) |
|
12 |
+ |
|
13 |
+(defparameter *browser-command* "/usr/bin/google-chrome-beta") |
|
14 |
+ |
|
15 |
+(defun cat (&rest strings) |
|
16 |
+ (apply 'concatenate 'string strings)) |
|
17 |
+ |
|
18 |
+(defgeneric get-search-url (provider &rest strings) |
|
19 |
+ (:method-combination append :most-specific-last) |
|
20 |
+ (:method :around (provider &rest r) |
|
21 |
+ (declare (ignore r)) |
|
22 |
+ (apply #'concatenate 'string (call-next-method))) |
|
23 |
+ |
|
24 |
+ (:method append (provider &rest r) |
|
25 |
+ (declare (ignore r)) |
|
26 |
+ (list "https://duckduckgo.com/?q=")) |
|
27 |
+ (:method append ((provider (eql nil)) &rest strings) |
|
28 |
+ (list* (car strings) (loop for string in (cdr strings) nconcing (list "+" string)))) |
|
29 |
+ |
|
30 |
+ (:method append ((provider (eql :google)) &rest strings) |
|
31 |
+ (list* "%21google" (loop for string in strings nconcing (list "+" string))))) |
|
32 |
+ |
|
33 |
+(defmacro add-provider (name ddg-shortcut) |
|
34 |
+ `(defmethod get-search-url append ((provider (eql ,name)) &rest strings) |
|
35 |
+ (list* (concatenate 'string "%21" ,ddg-shortcut) |
|
36 |
+ (loop for string in strings nconcing (list "+" string))))) |
|
37 |
+ |
|
38 |
+(defmacro add-providers (&body definitions) |
|
39 |
+ `(progn |
|
40 |
+ ,@(loop for (name shortcut) in definitions |
|
41 |
+ collect `(add-provider ,name ,shortcut)))) |
|
42 |
+ |
|
43 |
+ |
|
44 |
+(add-providers |
|
45 |
+ (:amazon "a") |
|
46 |
+ (:php "php") |
|
47 |
+ (:python "python") |
|
48 |
+ (:stack-overflow "sof") |
|
49 |
+ (:lisp "lisp") |
|
50 |
+ (:wikipedia "w")) |
|
51 |
+ |
|
52 |
+(defcommand google (provider search-string) ((:string "Search Provider? ") (:string "Search Google for: ")) |
|
53 |
+ "Search google for a given string" |
|
54 |
+ (check-type search-string (or null string)) |
|
55 |
+ (when search-string) |
|
56 |
+ (run-shell-command (cat *browser-command* " " |
|
57 |
+ (get-search-url :google (substitute #\+ #\space search-string))))) |
|
58 |
+ |
|
59 |
+ |
|
60 |
+(defcommand do-search (provider search-string) ((:string "Provider: ") (:string "Search for: ")) |
|
61 |
+ "Run a search against a specified provider" |
|
62 |
+ (check-type provider (or null string)) |
|
63 |
+ (check-type search-string (or null string)) |
|
64 |
+ (when (and provider search-string) |
|
65 |
+ (let ((provider (intern (string-upcase provider) :keyword))) |
|
66 |
+ (run-shell-command (cat *browser-command* " " |
|
67 |
+ (get-search-url provider (substitute #\+ #\space search-string))))))) |
|
68 |
+ |
|
69 |
+(defcommand google (search-string) ((:string "Search Google for: ")) |
|
70 |
+ "Search google for a given string" |
|
71 |
+ (check-type search-string (or null string)) |
|
72 |
+ (when search-string |
|
73 |
+ (run-shell-command (cat *browser-command* " " |
|
74 |
+ (get-search-url :google (substitute #\+ #\space search-string)))))) |
|
75 |
+ |
|
76 |
+(defcommand duckduckgo (search-string) ((:string "Search DDG for: ")) |
|
77 |
+ "Search duckduckgo gor a given string" |
|
78 |
+ (check-type search-string (or null string)) |
|
79 |
+ (when search-string |
|
80 |
+ (run-shell-command (cat *browser-command* " " |
|
81 |
+ (get-search-url nil (substitute #\+ #\space search-string)))))) |
|
82 |
+ |
|
83 |
+(defcommand search-for-selection (provider) ((:string "Search Provider?")) |
|
84 |
+ "Search for the x selection with provider" |
|
85 |
+ (do-search provider (get-x-selection))) |
|
86 |
+ |
|
87 |
+(defparameter *selection-search-map* nil "selection search map") |
|
88 |
+(fill-keymap *selection-search-map* |
|
89 |
+ (kbd "g") "search-for-search google" |
|
90 |
+ (kbd "/") "search-for-search google" |
|
91 |
+ (kbd "s-/") "search-for-search google" |
|
92 |
+ (kbd "l") "search-for-selection lisp") |
|
93 |
+ |
|
94 |
+(defparameter *search-map* nil "search map") |
|
95 |
+(fill-keymap *search-map* |
|
96 |
+ (kbd "a") "do-search amazon" |
|
97 |
+ (kbd "h") "do-search php" |
|
98 |
+ (kbd "p") "do-search python" |
|
99 |
+ (kbd "o") "do-search stack-overflow" |
|
100 |
+ (kbd "y") "do-search youtube" |
|
101 |
+ (kbd "l") "do-search lisp" |
|
102 |
+ (kbd "w") "do-search wikipedia" |
|
103 |
+ (kbd "d") "do-search duckduckgo" |
|
104 |
+ (kbd "g") "do-search google" |
|
105 |
+ (kbd "s") *selection-search-map* |
|
106 |
+ (kbd "/") "do-search google" |
|
107 |
+ (kbd "Return") "search-for-selection google" |
|
108 |
+ (kbd "s-/") "do-search google") |
|
109 |
+ |
|
110 |
+(define-key *top-map* (kbd "s-/") *search-map*) |
|
111 |
+(define-key *top-map* (kbd "s-TAB") "fnext") |
|
112 |
+(define-key *top-map* (kbd "s-ISO_Left_Tab") "fother") |
|
113 |
+ |
|
114 |
+; vim: set ft=lisp: |