Skip to content

Instantly share code, notes, and snippets.

View akkartik's full-sized avatar

Kartik Agaram akkartik

View GitHub Profile
("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
(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.
@akkartik
akkartik / ac.scm
Created July 24, 2010 03:54
Bare-bones implementation to compile def and mac and list (http://arclanguage.org/item?id=12057).
(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))
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
@akkartik
akkartik / gist:1218667
Created September 15, 2011 06:27
Nakamura - Fierro Baquero, Kings vs Queens Tournament, 2011
from sys import stdout, stdin
from string import atoi
import copy
p = 'p'
r = 'r'
n = 'n'
b = 'b'
q = 'q'
k = 'k'
@akkartik
akkartik / 090chessboard.wart
Last active September 27, 2015 15:27
Simple chessboard app. Nothing funky, just putting wart through its paces. (Compare with python version at http://gist.github.com/1218667)
# 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
@akkartik
akkartik / time_magazine_covers.py
Created November 26, 2011 12:57
Generate URLs for the pages containing the covers of all editions of Time Magazine
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']
@akkartik
akkartik / 099cargobot.wart
Created May 19, 2012 17:52
William Tozier's Cargo-Bot error heuristic
;; 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
@akkartik
akkartik / 080qq.test
Created October 29, 2012 06:27
Porting fallintothis's quasiquote implementation
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)