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
package main | |
import ( | |
"fmt" | |
"github.com/go-martini/martini" | |
"io/ioutil" | |
"log" | |
"math/rand" | |
"net/http" | |
"os" |
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
(defun list-sample (lst &optional (amt 1 amt-supplied-p)) | |
"Choose a random element or n random elements from the collection." | |
(labels ((sample-inner (lst amt res) | |
(if (not (and lst (plusp amt))) | |
(if (and (= (length res) 1) (not amt-supplied-p)) | |
(car res) | |
res) | |
(let ((elem (elt lst (random (length lst))))) | |
(sample-inner (remove elem lst :count 1) (1- amt) | |
(nconc res (list elem))))))) |
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
;; Color numeric constants. | |
(make-face 'font-lock-number-face) | |
(set-face-foreground 'font-lock-number-face "#cf6a4c") | |
(setq font-lock-number-face 'font-lock-number-face) | |
(defvar font-lock-number | |
(concat "\\b[0-9]+\\(_+[0-9]+\\)*" | |
"\\(\\.[0-9]+\\(_+[0-9]+\\)*\\)?" | |
"\\([eE][+-]?[0-9]+\\(_+[0-9]+\\)*\\)?" | |
"[dDfFlLuU]?\\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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Blue Component</key> | |
<real>0.0</real> | |
<key>Green Component</key> | |
<real>0.0</real> |
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
require 'test/unit' | |
def itoa(n) | |
s = '' | |
neg = n < 0 | |
n = -n if neg | |
while true | |
r = n % 10 | |
n /= 10 | |
s = ('0'.ord + r).chr << s |
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 | |
# ISB AQI checker. | |
# TODO: Better error checking. | |
import time | |
import traceback | |
INTERVAL = 60 | |
TABLE = [ | |
['Good', 0, 12.0, 0, 50], |
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
(defun rot13 (s) | |
"Rotate each character by thirteen places." | |
(map 'string (lambda (c) | |
(let ((n (char-code c))) | |
(cond ((and (char-not-lessp c #\n) (char-not-greaterp c #\z)) | |
(code-char (- n 13))) | |
((and (char-not-lessp c #\a) (char-not-greaterp c #\m)) | |
(code-char (+ n 13))) | |
(t c)))) s)) |
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
(defconstant +pb-site+ "http://www.powerball.com/powerball/winnums-text.txt") | |
(defun pb-values () | |
(multiple-value-bind (body sts h uri stream close reason) | |
(drakma:http-request +pb-site+) | |
(cdr (split-sequence:split-sequence #\Newline body)))) | |
(defun occurs (lines &optional (occur (make-hash-table))) | |
(dolist (line lines) | |
(when (plusp (length line)) |
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
;; Knight's tour using Warnsdorff's rule. | |
;; https://en.wikipedia.org/wiki/Knight%27s_tour | |
(defconstant +board-sz+ 8) | |
(defparameter *board* (make-array `(,+board-sz+ ,+board-sz+) :initial-element 0)) | |
(defconstant +knight-moves+ | |
'(#(1 -2) #(2 -1) #(2 1) #(1 2) #(-1 2) #(-2 1) #(-2 -1) #(-1 -2))) |
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
;;; The following lines added by ql:add-to-init-file: | |
#-quicklisp | |
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname)))) | |
(when (probe-file quicklisp-init) | |
(load quicklisp-init))) | |
(when (interactive-stream-p *standard-input*) | |
(ql:quickload "linedit") | |
(funcall (intern "INSTALL-REPL" :linedit))) |
NewerOlder