Skip to content

Instantly share code, notes, and snippets.

View danking's full-sized avatar

Dan King danking

View GitHub Profile
@danking
danking / gist:4726605
Created February 6, 2013 22:47
Change the volume!
from http.server import HTTPServer, BaseHTTPRequestHandler
from subprocess import check_output
def respond(out, s):
html_begin = "<html><head></head><body><pre>"
html_end = "</pre></body></html>"
response = html_begin + out.decode('utf-8') + html_end
print(out)
s.send_response(200)
s.send_header("Content-type", "text/html")
@danking
danking / gist:4720774
Last active December 12, 2015 05:18
continuation hackery
#lang racket
;; 03. pvar a = 0;
;; 04. [lbl] topOfLoop:
;; 05. a++;
;; 06. if (a < 292 ) {
;; 07. goto topOfLoop;
;; 08. }
(let ((a 0))
danking@danking-netbook:~/development/haskell-imagemagick/c 21:21 $ ld -z relro --hash-style=gnu --as-needed --build-id --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o wand /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i686-linux-gnu/4.6/crtbegin.o -L/usr/lib/gcc/i686-linux-gnu/4.6 -L/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu -L/lib/i386-linux-gnu -L/usr/lib/i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.6/../../.. -L/lib/i386-linux-gnu -L/lib -L/usr/lib/i386-linux-gnu -L/usr/lib -lMagickWand -lMagickCore wand.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-linux-gnu/4.6/crtend.o /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crtn.o
wand.o: In function `main':
wand.c:(.text+0x3b): undefined reference to `MagickWandGenesis'
wand.c:(.text+0x40): undefined reference to
danking@danking-netbook:~/development/haskell-imagemagick/c 21:11 $ cc -o wand `pkg-config --cflags --libs MagickWand` wand.c
/tmp/ccee4InW.o: In function `main':
wand.c:(.text+0x3b): undefined reference to `MagickWandGenesis'
wand.c:(.text+0x40): undefined reference to `NewMagickWand'
wand.c:(.text+0x5c): undefined reference to `MagickReadImage'
wand.c:(.text+0x7b): undefined reference to `MagickGetException'
wand.c:(.text+0xc1): undefined reference to `MagickRelinquishMemory'
wand.c:(.text+0xdd): undefined reference to `MagickResetIterator'
wand.c:(.text+0x109): undefined reference to `MagickResizeImage'
wand.c:(.text+0x115): undefined reference to `MagickNextImage'
(define-struct just-a-function ([l #:mutable] r) #:property prop:procedure 2)
(define (define#-help proc)
(let* ((me (box #f))
(f (just-a-function proc (lambda args (apply (just-a-function-l (unbox me)) args)))))
(set-box! me f)
(values f (lambda (new-proc) (set-just-a-function-l! f new-proc)))))
(define-syntax define# (syntax-rules () ((_ ((name magic) args ...) body)
(define-values (name magic)
(define#-help (lambda (args ...) body))))))
@danking
danking / gist:2728497
Created May 19, 2012 01:30
A hack to get multiple auto-values
#lang racket
(require (for-syntax racket racket/syntax))
(provide (all-defined-out))
(define-syntax (struct* stx)
(syntax-case stx ()
((_ name (args ...) others ...)
(with-syntax (((arg-list ...) (build-arg-list #'(args ...) (get-autos #'(others ...))))
((others ...) (remove-autos #'(others ...)))
#lang racket
(require (for-syntax racket racket/syntax))
(provide (all-defined-out))
(define-syntax (struct* stx)
(syntax-case stx ()
((_ name (args ...) (defaults ...) others ...)
(with-syntax ((arg-list (datum->syntax #'(args ...)
(for/list ((arg (syntax->list #'(args ...)))
(define-syntax (singleton-struct stx)
(syntax-case stx ()
((_ name others ...)
(let-syntax ((name? (syntax-append #'name #'?)))
#'(define-values
(name name?)
(let ()
(struct name () others ...)
(values (name) name?)))))))
Economy Chevy Aveo or similar $ 49.99 USD / day
$ 65.61 USD Total
Compact Nissan Versa, Toyota Yaris or similar $ 51.99 USD / day
$ 67.74 USD Total
Intermediate Toyota Corolla, Nissan Sentra or similar $ 53.99 USD / day
$ 69.86 USD Total
Standard Ford Fusion or similar $ 56.99 USD / day
@danking
danking / gist:2589549
Created May 3, 2012 21:12
set equality is not as expected
[email protected]> (let* ((a-box (box #f))
(b-box (box #f))
(a (set 1 a-box))
(b (set 1 b-box)))
(set-box! a-box a)
(set-box! b-box b)
(displayln a)
(displayln b)
(equal? a b))
#0=#<set: 1 #&#0#>