Skip to content

Instantly share code, notes, and snippets.

View grauwoelfchen's full-sized avatar
🐺
Typing with carved wooden keyboard ᕕ( ᐛ )ᕗ

Yasha grauwoelfchen

🐺
Typing with carved wooden keyboard ᕕ( ᐛ )ᕗ
View GitHub Profile
@grauwoelfchen
grauwoelfchen / gist:6284515
Last active December 21, 2015 09:19
Test suite for JavaScript Ninja :-D
(function() {
var queue = [], paused = false, results;
this.test = function(name, fn) {
queue.push(function() {
results = document.getElementById("results");
results = assert(true, name).appendChild(
document.createElement("ul"));
fn();
});
runTest();
@grauwoelfchen
grauwoelfchen / st-branch
Created June 23, 2013 18:01
Displays behind/ahead like GitHub's Branches view :)
function st-branch() {
local branch remote ahead behind
if [[ -n $1 ]]; then
remote=$1
else
remote="upstrm"
fi
git for-each-ref --format="%(refname:short)" refs/heads refs/remotes | \
while read branch
do
(define t-size
(lambda (t)
(if (t-empty? t)
0
(+ 1
(t-size (t-left t))
(t-size (t-right t)))) ))
(define t-size-r
(lambda (t)
(define t-post-order
(lambda (t)
(if (t-empty? t)
'()
(append (t-post-order (t-left t))
(t-post-order (t-right t))
(list (t-value t)))) ))
(define t-post-order-r
(lambda (t)
(define t-in-order
(lambda (t)
(if (t-empty? t)
'()
(append (t-in-order (t-left t))
(list (t-value t))
(t-in-order (t-right t)))) ))
(define t-in-order-r
(lambda (t)
(define t-pre-order
(lambda (t)
(if (t-empty? t)
'()
(append (list (t-value t))
(t-pre-order (t-left t))
(t-pre-order (t-right t)))) ))
(define t-pre-order-r
(define (bst-insert e bst)
(cond
[(t-empty? bst) (t-node e t-empty t-empty)]
[(< e (t-value bst))
(t-node
(t-value bst)
(bst-insert e (t-left bst))
(t-right bst))]
[else
(t-node
(define my-tree
(t-node 1
(t-node 2
(t-node 4 t-empty t-empty)
(t-node 5
(t-node 7 t-empty t-empty)
(t-node 8 t-empty t-empty)))
(t-node 3
t-empty
(t-node 6
(define t-empty #f)
(define t-value car)
(define t-left cadr)
(define t-right caddr)
(define (t-node value l-node r-node)
(list value l-node r-node))
(define (t-empty? node)
(equal? node t-empty))
@grauwoelfchen
grauwoelfchen / gist:5579295
Last active December 17, 2015 08:19
Hello Racket ;)
(require racket/tcp)
(let-values ([(inp outp) (tcp-connect "racket-lang.org" 80)])
(display "GET / HTTP/1.0\n\n" outp)
(close-output-port outp)
(let ([o (open-output-string)])
(let aux ([r (read inp)])
(if (eof-object? r)
(display (get-output-string o))
(begin (display r o)