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
keycode 8 = | |
keycode 9 = Caps_Lock NoSymbol Caps_Lock | |
keycode 10 = 1 exclam 1 exclam onesuperior exclamdown | |
keycode 11 = 2 at 2 at twosuperior onehalf | |
keycode 12 = 3 numbersign 3 numbersign threesuperior threequarters | |
keycode 13 = 4 dollar 4 dollar sterling onequarter | |
keycode 14 = 5 percent 5 percent cent U2030 | |
keycode 15 = 6 dead_diaeresis 6 asciicircum notsign diaeresis | |
keycode 16 = 7 ampersand 7 ampersand dead_belowdot dead_abovedot | |
keycode 17 = 8 asterisk 8 asterisk dead_ogonek dead_horn |
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
(define (pre-condition assertion) 'noop) | |
(define (try . procs) | |
(let loop ([procs procs]) | |
(define proc (car procs)) | |
(define (make-pre-condition k) | |
(lambda (assertion) | |
(when (not assertion) | |
(k (lambda () (loop (cdr procs))))))) | |
(define (exec k) |
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
(define empty? null?) | |
(define empty '()) | |
(define first car) | |
(define rest cdr) | |
(define (split2 item lst) | |
(let loop ([remaining lst] | |
[left empty]) | |
(cond [(empty? remaining) (values (reverse left) empty)] | |
[(equal? item (first remaining)) (values (reverse left) (rest remaining))] |
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
(trace-define-syntax power-let | |
(syntax-rules (<-) | |
[(_ (v <- expr) rest ...) (let [(v expr)] (power-let rest ...))] | |
[(_ body0 body* ...) (begin body0 body* ...)])) | |
(define-syntax def | |
(syntax-rules () | |
((_ (name args ...) body ...) | |
(define (name args ...) | |
(power-let 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
function wordGame(words) { | |
let clicks = 0; | |
let correct = 0; | |
function updateScore() { | |
let score = document.querySelectorAll('.word-game-score-panel')[0]; | |
if (clicks == 0) { | |
score.innerHTML = "The Preposition Game<br>Accuracy: 0%"; | |
} else { | |
let accuracy = Math.round(correct / clicks * 100); |
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
function printSolution(element) { | |
let answer = element.getAttribute("data-answer"); | |
let selectedOptions = Array.from(element.selectedOptions).map(e => e.text); | |
if (selectedOptions.includes(answer)) { | |
element.style.border = "2px solid green"; | |
} else { | |
element.style.border = "2px solid red"; | |
} | |
} | |
let prepositions = ["", "on", "at", "in"]; |
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/env python3 | |
# -*- coding: utf-8 -*- | |
from itertools import count | |
import re | |
import numpy as np | |
import pandas as pd | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.cross_validation import train_test_split | |
from sklearn.svm import SVC |
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
def bootstrap(np_array, func, n_samples=1000, size=None): | |
size = size if size else len(np_array) | |
return np.apply_along_axis(func, 1, np.random.choice(np_array, size=(n_samples, size))) | |
# Example use | |
bootstrap(some_array, np.mean) |
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 | |
(module+ test | |
(require rackunit)) | |
(module+ test | |
(check-equal? (editions "" "") empty) | |
(check-equal? (editions "a" "a") (list (op-match #\a))) | |
(check-equal? (editions "ab" "ab") (list (op-match #\a) (op-match #\b))) | |
(check-equal? (editions "a" "") (list (op-insert #\a))) | |
(check-equal? (editions "" "b") (list (op-delete #\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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from itertools import takewhile | |
from random import random | |
MAX_VELOCITY = 5 | |
def space(): | |
return " " |