Skip to content

Instantly share code, notes, and snippets.

@dahu
dahu / fossil_name.sh
Created Aug 6, 2017
Script to set a fossil repository's project-name and description fields
View fossil_name.sh
#!/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 Oct 10, 2016
Ackerman function causes stack overflow in Red (and not Rebol)
View ack.red
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 Oct 7, 2016
Adaptation of Java+ANTLR Roman Number parser in Rebol
View roman.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 Oct 6, 2016
Roman numerals in non-idiomatic Rebol
View roman_forth.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 Oct 31, 2015
jellybeans respect cterm overrides
View jellybeans_respect_cterm_overrides.diff
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 Oct 23, 2015
(ab)using the command message window for function signatures
View signature.vim
" (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 Oct 23, 2015
Messing with interfaces in VimL
View interface.vim
" 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 Sep 16, 2015
Sample first few slides of a typical EFL lesson
View 01_intro.adoc

English Fluency

@dahu
dahu / collapse_pairs.vim
Created Sep 11, 2015
Collapse key\tvalue pairs into key\tvalue1,value2,...
View collapse_pairs.vim
" 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 Sep 8, 2015
Example statusline function collecting annotations from buffer
View statusline_annotations.vim
" 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]
You can’t perform that action at this time.