Skip to content

Instantly share code, notes, and snippets.


Thom Chiovoloni thomcc

View GitHub Profile
View a_scheme.scm
; racket
(#%require srfi/69 srfi/23)
; chicken
;(require-extension (srfi 69))
(define raise-user-error error)
(define apply-scm apply)
(define (new-eval exp env)
((analyze exp) env))
View thom.zsh-theme
autoload -U add-zsh-hook
autoload colors
function zsh_prompt_command() {
local pwdmaxlen=25
local trunc_symbol=".."
local dir=${PWD##*/}
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
thomcc / gist:1411486
Created Nov 30, 2011
icarus-verilog build failure
View gist:1411486
thom /usr/local $ brew install -v icarus-verilog
==> Downloading
File already downloaded in /Users/thom/Library/Caches/Homebrew
/usr/bin/tar xf /Users/thom/Library/Caches/Homebrew/icarus-verilog-0.9.3.tar.gz
==> ./configure --disable-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/icarus-verilog/0.9.3
./configure --disable-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/icarus-verilog/0.9.3
checking build system type... i386-apple-darwin11.2.0
checking host system type... i386-apple-darwin11.2.0
checking for gcc... /usr/bin/llvm-gcc
checking for C compiler default output file name... a.out
thomcc / bf.rkt
Created Dec 5, 2011
brainfuck interpreter in scheme
View bf.rkt
(define (new-bf)
(let ((tape (make-vector 30000 0))(ptr 0))
(define (reset [sz 30000]) (set! tape (make-vector sz 0)) (set! ptr 0))
(define (b>) (set! ptr (add1 ptr)))
(define (b<) (set! ptr (sub1 ptr)))
(define (b+) (vector-set! tape ptr (add1 (vector-ref tape ptr))))
(define (b-) (vector-set! tape ptr (sub1 (vector-ref tape ptr))))
(define (p) (write-byte (vector-ref tape ptr)))
(define (g) (vector-set! tape ptr (read-byte)))
(define ops `((#\..,p)(#\,.,g)(#\>.,b>)(#\<.,b<)(#\+.,b+)(#\-.,b-)))
thomcc / jash.rkt
Created Dec 6, 2011
just another scheme hacker
View jash.rkt
((λ(f)((λ(>)(f(λ(^)((> >)^))))(λ(>)(f(λ(^)((> >)^))))))(λ
(f)(λ(^)(let ~((< 0))(cond((>= <(_ ^))(void))((eq?(.# ^ <
)#\[)((λ(>)((λ(^)(let ~()(unless(= --(! $ *))(f ^)(~)))(~
(+ > %)))(substring ^(+ % <)>)))((λ(o)((λ(f)(let ~((++ --
)(f(+ f %)))((λ(<)(if(= <(- %))f(~ < (+ f %))))(case(.# o
f)((#\[)(+ % ++))((#\])(- ++ %))(else ++)))))<))^)))(#t(d
(.# ^ <))(~(+ % <)))))))))(λ(>)(cond((assoc >`((#\..,(λ @
(write-byte(! $ *))))(#\,.,(λ()(~ $ *(read-byte))))(#\>.,
(λ .(set! *(+ % *))))(#\<.,(λ()(set! *(- * %))))(#\+.,(λ(
View snake.rkt
#lang racket/gui
(require data/queue)
(define snake%
(class object%
(init w h)
(define x (inexact->exact (floor (/ w 2))))
(define y (inexact->exact (floor (/ h 2))))
(define dir 'E)
(define body (let ((q (make-queue)))
View donut.rkt
(define *theta-spacing* 0.07)
(define *phi-spacing* 0.02)
(define *screen-width* 300)
(define *screen-height* 240)
(define R1 1)
(define R2 2)
(define K2 5)
(define K1 (/ (* 3 K2 *screen-width*) (* 8 (+ R1 R2))))
(define (clip n min max) (if (< n min) min (if (> n max) max n)))
(define donutcvs
thomcc / gist:1507796
Created Dec 21, 2011
show an image snip on a canvas in a new frame
View gist:1507796
#lang racket/gui
(define (show-image-snip-in-new-frame snip)
(define bmp (send snip get-bitmap))
(define f (new frame% [label "image snip"]
[width (send bmp get-width)]
[height (send bmp get-height)]))
(define c
(new canvas%
[paint-callback (λ (c dc) (send dc draw-bitmap bmp 0 0))]
[parent f]))
thomcc / snake.clj
Created Jan 2, 2012
Snake game in clojure
View snake.clj
(ns snake
(:import (java.awt Color Graphics Dimension Font)
(javax.swing JFrame JPanel)
(java.awt.event KeyEvent KeyAdapter)))
(def field [80 48]) ; [width height]
(def scale 10)
(def screen (Dimension. (* scale (field 0)) (* scale (field 1))))
(def on? true)
(def tick-speed 100)
View gist:1603487
(def sets
{:vowel #{:a :e :i :o :u}
:consonant #{:b :c :d :f :g :h :j} ; ... etc.
:other #{:y}})
(defn categorize [thing]
(condp #(% %2) thing
(sets :vowel) :vowel
(sets :consonant) :consonant
(sets :other) :other