This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (distance a b) | |
(sqrt (for/sum ([a a] [b b]) | |
(expt (- a b) 2)))) | |
(define (greedy-tsp data #:start [start #f]) | |
(if (null? data) | |
'() | |
(if start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require ffi/unsafe) | |
(define llvm (ffi-lib "/usr/lib/x86_64-linux-gnu/libLLVM-3.7.so.1")) | |
(define get-global-context | |
(get-ffi-obj 'LLVMGetGlobalContext llvm | |
(_fun -> _pointer))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (for-syntax syntax/parse) | |
syntax/parse) | |
; why would you want infix syntax, when you can | |
; change your syntax to suit the task at hand? | |
(define-syntax ($ stx) | |
(syntax-parse stx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require graph plot) | |
(define (distance a b) | |
(sqrt (for/sum ([a a] [b b]) | |
(expt (- a b) 2)))) | |
(define (every-edge l) | |
(if (null? l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# resistor colors | |
colors = [ 'black', '#964b00', 'red', '#ffa500', 'yellow', | |
'#9acd32', '#6495ed', '#ee82ee', 'gray', 'white' ] | |
# borders around some of the lighter colors | |
border = [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 ] | |
out = open("labels.html","wb") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require openssl) | |
(define (make-sctx pem) | |
(define sctx (ssl-make-server-context 'tls)) | |
(ssl-load-default-verify-sources! sctx) | |
(ssl-set-ciphers! sctx "DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2") | |
(ssl-load-certificate-chain! sctx pem) | |
(ssl-load-private-key! sctx pem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# inspired by | |
# http://www.reddit.com/r/mathpics/comments/ookpa/i_decided_to_play_with_the_chaos_game_after_that/ | |
# also, not actually a cube | |
from OpenGL.GL import * | |
from OpenGL.arrays import vbo | |
from OpenGL.GL.shaders import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module nasm racket/base | |
(require racket/system | |
racket/file | |
racket/dict | |
ffi/unsafe | |
ffi/unsafe/alloc) | |
(define posix_memalign | |
; ((allocator free) ; can't auto free these pointers until we ensure that everything using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require ffi/unsafe) | |
(require ffi/unsafe/cvector) | |
(require ffi/vector) | |
(require (planet jaymccarthy/opencl:3:=4/c)) | |
(define count 1024000) | |
(define kernel_source | |
#" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Extremely simply OpenGL demo. | |
;; Draw a "planet" (OK, a textured sphere). | |
#lang racket/gui | |
(require ffi/unsafe) | |
(require (planet "rgl.rkt" ("stephanh" "RacketGL.plt" 1 4))) | |
(require ffi/vector) | |
(require "viewer.rkt") |