Skip to content

Instantly share code, notes, and snippets.

View samth's full-sized avatar

Sam Tobin-Hochstadt samth

View GitHub Profile
@samdphillips
samdphillips / raco-pkg-env.rkt
Created April 2, 2021 02:47
Not quite virtualenv type thing in Racket
#lang racket/base
(require racket/file
racket/format
racket/pretty
setup/dirs)
(define env-dir (build-path (current-directory) "_raco-env"))
(define env-config-dir (build-path env-dir "etc"))
@tonyg
tonyg / mtl2.rkt
Last active December 18, 2015 22:59
From zero to cooperative threads in 15 lines of Racket code (after <http://www.haskellforall.com/2013/06/from-zero-to-cooperative-threads-in-33.html>)
#lang racket/base
(require data/queue)
(provide fork yield done run-threads)
(define current-runqueue (make-parameter #f))
(define (fork thunk)
(enqueue! (current-runqueue) (lambda () (thunk) (done))))
(define (yield)
@samth
samth / test.rkt
Created June 10, 2013 21:20
test
#lang racket
"Posted from Racket!"
@rwaldron
rwaldron / emitter.js
Last active December 15, 2015 07:39
Simple Event Emitter class that uses a Symbol for event binding storage
// In Chrome Canary, with Experimental JavaScript enabled...
(function( exports ) {
// Create a reusable symbol for storing
// Emitter instance events
var sym = new Symbol();
function Emitter() {
this[ sym ] = {

Goals

The goals of this project are to define a layered architecture for the client-side web platform[1] that W3C working groups can use to define new platform features and refine existing platform features.

Specifically, this architecture defines a clear relationship between markup and imperative code.

@dherman
dherman / example.js
Created December 12, 2012 05:43
struct view approach
var IPAddress = new StructType({
f0: uint8,
f1: uint8,
f2: uint8,
f3: uint8
});
var Packet = new StructType({ addr: IPAddress, ... });
var PacketArray = new ArrayType(Packet);
@dherman
dherman / example.js
Created December 12, 2012 05:04
pointer type approach
var IPAddress = new ArrayType(uint8, 4);
var P_IPAddress = new PointerType(IPAddress);
var Packet = new StructType({ addr: IPAddress, ... });
var P_Packet = new PointerType(Packet);
var PacketArray = new ArrayType(Packet);
var lotsOfPackets = new PacketArray(LOTS);
for (let p of lotsOfPackets.cursor("addr")) {
#lang racket
(require sgl
sgl/gl
sgl/gl-vectors
slideshow
racket/gui)
; make a texture!
(define *size* 128)
(define b (instantiate bitmap% (*size* *size*)))