Skip to content

Instantly share code, notes, and snippets.

@dahu
dahu / shay.vim
Created August 19, 2015 23:40
database lookup -- AWKish example in VimL for shay_shay
" AWKish example in VimL for shay_shay
" Barry Arthur, Aug 2015
let db = {}
for l in readfile('utiluqotic.txt')
let recs = split(l, '|')
let db[recs[0]] = recs
endfor
iabbrev db <c-r>=db[expand('%:r')][5]<cr>
@dahu
dahu / gist:9946b83850d5992332d6
Last active August 29, 2015 14:27
Vim: Moving habits into maps
" Barry Arthur, August 2015
" Moving habits into maps
"
" A regular editing sequence I caught myself
" doing was: <c-v>}kwI<some-text><esc>
" to prepend a common string to all of
" the lines within the current indent.
" These maps make that much simpler:
" <leader>K<some-text><esc>
"
@dahu
dahu / gist:fcc3a1773c3258e33546
Created August 9, 2015 12:37
simple syntax test case
syn match Element "^Test" nextgroup=Other
syn match Other "Case" contained
hi def link Element String
hi def link Other Number
finish
Test Case
@dahu
dahu / gist:1d52ee4953c67711450f
Created August 8, 2015 08:37
A snapshot of my plugged <leader> maps
nmap <leader><Space> <Plug>BuffaloTrigger
nmap <leader>dc <Plug>diffo_close
nmap <leader>do <Plug>diffo_open
nmap <leader>du <Plug>diffo_update
nmap <leader>gw <Plug>GripeWord
nmap <leader>n <Plug>KweasyAgain
nmap <leader>f <Plug>KweasyJump
@dahu
dahu / gist:18b48c70444d8078f7d7
Last active August 29, 2015 14:25
emulating comments in vim's dict literals
" Barry Arthur, July 2015
" Kludge emulating comments in dict literals
" :-0 surprised?!
function! StripComments(comment_leader, dict)
return filter(a:dict, 'v:key !~ "^" . escape(a:comment_leader, "\"")')
endfunction
let x = StripComments('REM', {
\ 'a' : 1
@dahu
dahu / gist:867412256afee141b328
Created July 18, 2015 08:57
Newlisp (human bytes) function
(define (human b , (radix 0))
(while (> (/ b 1024) 0)
(set 'b (div b 1024))
(inc radix))
(format "%.2f %s" b (nth radix magnitudes)))
@dahu
dahu / gist:48f2223dc3e2a5282902
Created July 16, 2015 03:54
iterating a dict's items
let x = {'one' : 1, 'two' : 2}
for [k, v] in items(x)
echo k . ' -> ' . v
endfor
@dahu
dahu / gist:433cadb528b601b930f7
Created July 11, 2015 02:57
grope, definition
5 definitions found
From The Collaborative International Dictionary of English v.0.48 [gcide]:
Grope \Grope\, v. t.
1. To search out by feeling in the dark; as, we groped our
way at midnight.
[1913 Webster]
2. To examine; to test; to sound. [Obs.] --Chaucer.
@dahu
dahu / gist:11990647a61d20c6fbb0
Last active August 29, 2015 14:24
namespace ensemble version of tclmr
#!/usr/bin/env tclsh
package require cmdline
package require struct::set
namespace eval ::tclmr {
namespace path [list ::cmdline ::struct::set]
namespace export {[a-z]*}
namespace ensemble create -unknown tclmr::unknown
@dahu
dahu / gist:697a5c4da2fb9864b58f
Last active August 29, 2015 14:24
multi repos command-line tool in Tcl
#!/usr/bin/env tclsh
package require cmdline
package require struct::set
oo::class create tclmr {
constructor {} {
namespace path [list {*}[namespace path] ::cmdline ::struct::set]
}