Skip to content

Instantly share code, notes, and snippets.

View diiq's full-sized avatar

Sam Bleckley diiq

View GitHub Profile
@diiq
diiq / truthandbeauty.psy
Created July 17, 2011 17:26
Test for psybas conversation

Verifying my understanding of psychotic bastard:

set x: fn (b) : cons : 't (cons 'b ())

is a valid way to say

(set x (fn (b) (cons (' t) (cons (' b) ()))))

Correct?

@diiq
diiq / 1-make-account.scm
Created July 31, 2011 01:01
SICP make-account in Tainted Oyster
;; This is some code from chapter 3 of SICP. I chose it by going to
;; http://mitpress.mit.edu/sicp/code/index.html , clicking at random
;; and picking the first good, meaty function that caught my eye. It
;; is a demonstration of object orientation by way of functional
;; closures.
(define (make-account balance)
(define (withdraw amount)
(if (>= balance amount)
(begin (set! balance (- balance amount))
@diiq
diiq / gist:1660566
Created January 23, 2012 04:21
Things no one told me about drawing stuff

I have a friend who asked for some thoughts about his drawings. It was gonna be pretty public anyway, so once I realized that I needed half a dozen pictures to make my point, I asked if I could put my reply here.

I am qualified to say things about drawing because I am mediocre. Being mediocre is the best qualification, because it means I've had to really work to learn to make a nice drawing. Naturally talented people make poor teachers, because they haven't made all the mistakes. I've made plenty of them, and I'll make plenty more, but I am slowly mapping the minefield.

I'm gonna skip basics, 'cause you've heard them. (If you haven't, try reading Andrew Loomis: Drawing the Head and Hands, and Figure Drawing for All Its Worth; and Betty Edwards: Drawing on the Right Side of the Brain. The first two are free online.) Rather than say the same thing that every drawing book says, I wanna say the things that no one ever told me. I'm also gonna skip the complement sandwich --- you're doing fine. Your instincts

@diiq
diiq / initial
Created August 8, 2012 07:17
Gists for diiq.org
B
B
C
C
Car! Bar! Fooo!
@diiq
diiq / gist:3773552
Created September 24, 2012 00:23
It's a lisp in js.
Array.prototype.map = function(func) {
var ret = [];
for (var i = 0; i < this.length; i++)
ret[i] = func(this[i]);
return ret;
}
var lisp = function() {
var builtin = {
cns: function(args) {
@diiq
diiq / alpha.py
Created November 8, 2012 22:14
Fixed point alphabet
alphabet = [("a", "a"), ("bee", "b"), ("see", "c"), ("dee", "d"),
("e", "e"), ("ef", "f"), ("gee", "g"), ("aitch", "h"),
("i", "i"), ("jay", "j"), ("kay", "k"), ("ell", "l"),
("em", "m"), ("en", "n"), ("o", "o"), ("pee", "p"),
("cue", "q"), ("ar", "r"), ("ess", "s"), ("tee", "t"),
("u", "u"), ("vee", "v"), ("double-u", "w"), ("ex", "x"),
("wye", "y"), ("zee", "z")]
def alpha_ind(a):
for i in range(len(alphabet)):
@diiq
diiq / interpreter.py
Created November 25, 2012 19:01
Evaluator
FAIL = Symbol("Fail")
def eval(code, env):
ret = FAIL
if isinstance(code, Call):
function = eval(code.call, env)
new_env = function.bindings
for arg in function.lambda_list:
if arg.code:
new_env[arg.name] = code.args[arg.name]
from mongoengine import *
from mongoengine import signals
__all__ = ["SellOrderItem"]
REJECTION_REASONS = [
"Hole",
"Staining",
"Overall wear",
"Loose hem",
"""Builds a character/word-indexed tree of files."""
import itertools
import glob
punctuation = ".,;:/?<>{}[]()-_=+!@#$%^&*\/\\~*" # TODO be more systematic
def words_in_file(handle, max_len):
"""Returns an alphabetized list of unique words in the file.
#include <stdio.h>
float rstr[20];
static void doflasha()
{
int err;
double tt,p1,p2,t2;
double volg, voll, volgm, dgm, zmw, ymw, xmw;
char *ptr;