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
/*global $,localStorage*/ | |
$.fn.draft = function () { | |
'use strict'; | |
if (!localStorage) { | |
return; | |
} | |
var form = $(this), | |
fields = form.find('input,select,textarea'), |
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
; pyramid of death | |
(defn baz [n1 n2] | |
(cond (> n1 n2) (+ n1 n2) | |
(< n1 n2) (cond (= n1 0) 1 | |
(= n2 0) 2 | |
:else 3) | |
:else 0)) | |
; internal extraction | |
(defn baz [n1 n2] |
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
; calculate the sum of odd numbers, the product of even ones and a list of the odds | |
; example extracted from the book "The Little Schemer" | |
; more info here http://stackoverflow.com/questions/10692449/the-little-schemer-evens-onlyco | |
(defn evens-only*&co [l col] | |
(cond | |
(empty? l) (col `() 1 0) | |
(number? (first l)) | |
(cond | |
(even? (first l)) (evens-only*&co | |
(rest l) |
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
; Tons of duplicated code :'( | |
(defn insert-l [a s l] | |
(cond | |
(empty? l) `() | |
(= (first l) s) (cons a l) | |
:else (cons (first l) (insert-l a s (rest l))))) | |
(defn insert-r [a s l] | |
(cond | |
(empty? l) `() |
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
//Module with boilerplate/duplicated code | |
var Module = function (elements) { | |
var | |
onLink1Click = function (callback) { | |
elements.link1.on("click", function (e) { | |
callback(); | |
e.preventDefault(); | |
}); | |
}, | |
onLink2Click = function (callback) { |
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
class HttpUrl | |
ALPHA = "[a-zA-Z]" | |
DIGIT = "[0-9]" | |
DIGITS = "#{DIGIT}+" | |
SAFE = "[-$_.+]" | |
EXTRA = "[!*'(),]" | |
ALPHADIGIT = "[a-zA-Z0-9]" | |
TOPLABEL = "#{ALPHA}(#{ALPHADIGIT}|-)*#{ALPHADIGIT}|#{ALPHA}" |
NewerOlder