Skip to content

Instantly share code, notes, and snippets.

@dahu
dahu / fossil_name.sh
Created August 6, 2017 08:16
Script to set a fossil repository's project-name and description fields
#!/bin/sh
# Attribution: unknown. Probably taken from the fossil-users mailing list.
usage() { echo usage: $0 'archive.fossil "project name" "project description"' ; exit 1 ; }
dbname="$1"
pname="$2"
pdesc="$3"
@dahu
dahu / ack.red
Created October 10, 2016 06:28
Ackerman function causes stack overflow in Red (and not Rebol)
Red []
; https://rosettacode.org/wiki/Ackermann_function
ack: func [m n] [
case [
0 = m [n + 1]
0 = n [ack m - 1 1]
true [ack m - 1 ack m n - 1]
]
]
;
@dahu
dahu / roman.rebol
Created October 7, 2016 03:22
Adaptation of Java+ANTLR Roman Number parser in Rebol
Rebol []
; Parse Roman Numerals
; Barry Arthur, 2016-10-07
; From Nigel Galloway's Java + ANTLR version, March 16th, 2012
; (https://www.rosettacode.org/wiki/Roman_numerals/Decode#ANTLR)
;
inc: func ['word amount] [set word amount + get word]
inc1: func ['word] [inc :word 1]
;
parseRN: [(number: 0 err: copy "") rn]
@dahu
dahu / roman_forth.rebol
Created October 6, 2016 10:42
Roman numerals in non-idiomatic Rebol
Rebol [
Title: "Roman Numbers"
Source: "Thinking in Forth (Ans, 2004) by Leo Brodie, Figure 4.9, Page 153"
]
romans: [I V X L C D M]
col: 0
ones: does [col: 1]
tens: does [col: 3]
hundreds: does [col: 5]
thousands: does [col: 7]
@dahu
dahu / jellybeans_respect_cterm_overrides.diff
Created October 31, 2015 04:53
jellybeans respect cterm overrides
diff --git a/colors/jellybeans.vim b/colors/jellybeans.vim
index f9d5397..a1535ec 100644
--- a/colors/jellybeans.vim
+++ b/colors/jellybeans.vim
@@ -275,9 +275,15 @@ fun! s:X(group, fg, bg, attr, lcfg, lcbg)
else
let l:fge = empty(a:fg)
let l:bge = empty(a:bg)
+ let l:lcfge = empty(a:lcfg)
+ let l:lcbge = empty(a:lcbg)
@dahu
dahu / signature.vim
Created October 23, 2015 10:10
(ab)using the command message window for function signatures
" (ab)using the command message window for function signatures
" Barry Arthur, Oct 2015
function! Signature(msg)
let m = filter(string#scanner(a:msg).split('.\{80}', 1), 'v:val != ""')
let len = len(m)
let msg = join(m, "\n")
let old_cmdheight = &cmdheight
let &cmdheight = len
echo msg
@dahu
dahu / interface.vim
Created October 23, 2015 03:01
Messing with interfaces in VimL
" Messing with interfaces
" Barry Arthur, Oct 2015
function! Foo()
let obj = {}
func obj.register(a, b)
echo string(a:a) . ' and ' . string(a:b)
endfunc
return obj
endfunction
@dahu
dahu / 01_intro.adoc
Created September 16, 2015 21:55
Sample first few slides of a typical EFL lesson

English Fluency

@dahu
dahu / collapse_pairs.vim
Created September 11, 2015 00:58
Collapse key\tvalue pairs into key\tvalue1,value2,...
" Barry Arthur Sep 2015
" Convert possibly repeating key\tvalue pairs into key\tvalue1,value2,...
function! CollapsePairs()
let stuff = {}
g/\t/let pair = split(getline('.'), '\t') | let stuff[pair[0]] = add(get(stuff, pair[0], []), pair[1]) | d
call append('$', map(sort(items(stuff)), 'v:val[0] . "\t" . join(v:val[1], ",")'))
endfunction
call CollapsePairs()
@dahu
dahu / statusline_annotations.vim
Last active September 8, 2015 07:33
Example statusline function collecting annotations from buffer
" Barry Arthur 2015-9-8
" Example statusline function collecting annotations from buffer
" embedded annotations are expected to be enclosed in square brackets
" and all upper-case, as in:
" [DESIGN]
" [IMPLEMENTATION]
" [NAMING]
" [OVERALL]
" [STYLE]