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 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
#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 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 | |
(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/base | |
(require racket/cmdline) | |
(define-syntax-rule | |
(while<> line body ...) | |
(let ([process-port | |
(lambda () | |
(for ([line (in-port read-line)]) | |
body ...))]) |
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 | |
; idea: use inspectors & parameters to protect values so they | |
; can't be used outside of approved dynamic extents. | |
; probably not fully baked? (continuations, etc) | |
; (define-values (b lock) (locked-box important-v key)) | |
; (parameterize ([lock key]) | |
; ; in here b can be used | |
; (less-trusted-code b)) |
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
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.HashMap; | |
public class KellysFavorite implements Player { | |
private ArrayList<Double> cache = new ArrayList<Double>(); |
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 | |
; A non-random Racket implementation of the algorithm given in: | |
; Small-Dimension Linear Programming and Convex Hulls Made Easy by R. Seidel | |
; There are a number of other documents floating around describing it, | |
; including another Seidel paper. I think all of them have at least typos, | |
; if not conceptual errors. The pseudo code at the end of the above paper | |
; is, I think, the least buggy. All the λ stuff is a bit odd; they seem | |
; to be mixing some numerical tolerance stuff with the variable bounds? |
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 scheme/gui | |
; $1 gesture recognizer | |
; Based on | |
; WOBBROCK J. O., WILSON A. D., LI Y.: Gestures without libraries, toolkits or training: a $1 recognizer for user interface prototypes. In UIST ’07: Proceedings of the 20th annual ACM symposium on User interface software and technology (New York, NY, USA, 2007), ACM, pp. 159–168. | |
; There's another paper that improves on recognition time: | |
; Reaver, Stahovich, Herold: How to make a Quick$: Using Hierarchical Clustering to Improve the Efficiency of the Dollar Recognizer. Eurographics Symposium on Sketch-Based Interfaces and Modeling (2011), pp. 103-108. | |
; Currently when it's run, it pops open a little window that will do the recognition. The mixin could certainly use more features. |
OlderNewer