This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
NewerOlder