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
("aaaa://aaaaa.aaaaaaaaaaaa.aaa/aaaaaaaaaaaa" "aaa" "aaaaaaaaa" "aaaa://aaa.aaaaaaaaaaaa.aaa/" "aaaa" "aaa" "aaa" "aaaa" "aaa" "aaaaaaaaa," "aa" "aa" "aaaa" "aa" "aaaa" "aaaaaa," "aaa" "aaaaa" "aaaaaaa." "aaaa" "aaaa" "aaaaaaaaaa" "a" "aaaaaaaa" "aaaaaaaaaa," "aaa" "aaaaaa" "aa" "a" "aaaa." "aaaa://aaaaa.aaaaaaaaaa.aaa/aaaaaaaaaaaaaaaaaaaaaa" "aaa" "aaaaaaaa" "aaaaaaaaaaa" "aaaa://aaaaaa.aaaaaaaa.aaa/aaaaa/aaaaaaaa/aaaaaaa.aaaa" "<a>aaaaaaaa" "aaaaaaa" "aaaa" "aaaaa" "aa:a" "aaaaaaaaaaa" "aa" "aaaaaaaaaaaa" "aaa" "aaaaaaa" "aaaaa" "aaaaaaaaaaa" "aaa" "aaaa" "aaaaa" "aaaaa." "aaaa" "aaaa" "aaaaaaaa" "aaaaa" "aaaaaaaaa'a" "aaaaaaaa" "aaaaa" "aaa" "aa" "aaaa" "aaaaaa" "aaa" "&aaaa;aa&aaaa;" "aaaa" "aa" "aaaa" "aa:a" "aaaaa.</a><a" "aaaa=\"aaaa://aaaaaaaaaa.aaa/aaaaa?aaa=aaaaaaaaa&aaa;aaa=aaaa://aaaaa.aaaaaaaa.aaa/aaaaa/aaaaaaaa/aaaaaaa.aaaa\"><aa" "/>aaa" "aa" "aaaaaaaaaa" "aaaaaaaaa</a><aa" "/>" "<a" "aaaa=\"aaaa://aaa.aaaaaaaa.aaa/aaaaa/aaaaa-aaaaaaaaa/aaaaaaaaaaaa\">aaaaa" "aaaaaaaaa" "aa" "aaaaaaaa</a>" "aaa |
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 (lib "mzlib/pregexp")) | |
; Repeatedly run regexp-replace over a list of words. | |
(let ((words (call-with-input-file "ztmp.words2" | |
(lambda(f) (read f))))) | |
(letrec ((fn (lambda() | |
(print "iter") (newline) | |
(map (lambda(x) (regexp-replace (pregexp "b.*") x "")) | |
; You can replace b with any letter. The input doesn't | |
; even have any b'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
# http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent | |
A = [0, 34, 100] | |
def binary_search(i, j, v): | |
if j-i <= 2: | |
for k in range(i,j): | |
if A[k] == v: | |
return j | |
return -1 | |
# j > i+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
(define (ac s env) | |
(cond ((string? s) (ac-string s env)) | |
((literal? s) s) | |
((eqv? s 'nil) (list 'quote '())) | |
((symbol? s) (ac-var-ref s env)) | |
((eq? (xcar s) 'quote) (list 'quote (cadr s))) | |
((eq? (xcar s) 'quasiquote) (ac-qq (cadr s) env)) | |
((eq? (xcar s) 'if) (ac-if (cdr s) env)) | |
((eq? (xcar s) 'fn) (ac-fn (cadr s) (cddr s) env)) | |
((eq? (xcar s) 'assign) (ac-set (cdr s) env)) |
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 create | |
@user = User.find_by_email(params[:user][:email]) || User.create(params[:user]) | |
return render(:action => 'new') if @user.new_record? # redisplay form | |
log('Created', @user) | |
session[:user] = @user | |
end |
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
from sys import stdout, stdin | |
from string import atoi | |
import copy | |
p = 'p' | |
r = 'r' | |
n = 'n' | |
b = 'b' | |
q = 'q' | |
k = '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
# Requirements: g++ | |
# $ git clone http://github.com/akkartik/wart.git | |
# $ cd wart | |
# $ git checkout b5fb9cbccb | |
# $ wget --no-check-certificate https://raw.github.com/gist/1291243/080chessboard.wart | |
# $ wart | |
# Use the 'm' function to make a move. P-K4 is m.5254, etc. m.-1 is undo. | |
# type chessboard | |
# Uppercase is white, lowercase is black |
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
from BeautifulSoup import BeautifulSoup | |
from urllib2 import urlopen | |
url = '/time/magazine/current' | |
while 1: | |
url='http://www.time.com'+url | |
soup = BeautifulSoup(urlopen(url)) | |
print url, '--', soup.find('time').renderContents() | |
url = soup.find(text='Previous Issue').parent['href'] |
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
;; Draft solution of William Tozier's Cargo-Bot problem: | |
;; http://www.vagueinnovation.com/pragmatic_gp/more-on-moving-blocks | |
;; | |
;; Built in a private lisp dialect I've been working on: | |
;; http://github.com/akkartik/wart#readme | |
;; Requires gcc and linux/macos. | |
;; | |
;; Instructions to run tests: | |
;; $ git clone http://github.com/akkartik/wart.git | |
;; $ cd wart |
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
map (fn((input expected)) (test "" :valueof qq_expand.input :should be expected)) | |
pair:list 1 ''1 # force paren | |
'(x) | |
''(x) | |
'(,x) | |
'(list x) | |
'(,x ,y) | |
'(list x y) |
OlderNewer