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
(fn [sos] | |
(letfn [ | |
(combine [x y] | |
(let [diff [nil (.toUpperCase (str (clojure.set/difference x y)))] ] | |
(conj (clojure.set/intersection x y) diff))) | |
(remove-dontcares [minterms] (set (remove vector? minterms))) | |
(get-off-by-ones [all-minterms [current-key current-vals]] | |
(let [ | |
off-by-one | |
(map #(combine current-key %) |
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
// Investigating http://www.w3.org/2010/05/video/mediaevents.html | |
// Firefox creates pause and play events when seeking / seeked on a playing video, Chrome does not. | |
// Execute this script in Firebug console or similar to capture events | |
var script = document.createElement("script"); | |
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
$("#video").bind("play", function() {console.log("play " + new Date()); }) | |
$("#video").bind("pause", function() {console.log("pause " + new Date()); }) |
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
(ns scratch.core | |
(:use midje.sweet | |
[clojure.set :only [union intersection difference]] | |
)) | |
(def east [1 0]) | |
(def north [0 1]) | |
(def west [-1 0]) | |
(def south [0 -1]) |
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
(ns scratch.core | |
(:use midje.sweet | |
[clojure.set :only [union intersection]] | |
)) | |
(unfinished booking-transaction bookings) | |
(defn empty-history [] | |
[ [] ]) |
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
(ns scratch.core | |
(:use midje.sweet | |
[clojure.set :only [union intersection]] | |
:reload)) | |
(unfinished newborns) | |
(defn survivable? [cell living-cells]) | |
;; (fact "A cell is survivable if 2 or 3 of its neighbors are alive" |
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 Object | |
def _(name, *partial_args) | |
Proc.new do |*new_args| | |
send name, *partial_args.map {|arg| arg == :_ ? new_args.shift : arg} | |
end | |
end | |
end | |
# Practical examples: | |
[1,2,3].each &_(:puts, :_) |
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
server { | |
listen 443; ## listen for ipv4 | |
listen [::]:443 default ssl ipv6only=on; ## listen for ipv6 | |
ssl on; | |
ssl_certificate /etc/ssl/certs/www.varnish-cache.org-http.pem; | |
ssl_certificate_key /etc/ssl/private/www.varnish-cache.org-http.pem; | |
server_name www.varnish-cache.org; | |
access_log /var/log/nginx/localhost.access.log; |
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
This example shows how to setup an environment running Rails 3 beta 3 under 1.9.2-head with a 'rails3' gem set. | |
∴ rvm update --head | |
# ((Open a new shell)) or do 'rvm reload' | |
# If you do not already have the ruby interpreter installed, install it: | |
∴ rvm install 1.9.2-head | |
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist. | |
∴ rvm --create use 1.9.2-head@rails3 |
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
/* Use this to cause a function to fire no more than once every 'ms' milliseconds. | |
For example, an expensive mousemove handler: | |
$('body').mouseover(ratelimit(function(ev) { | |
// ... | |
}, 250)); | |
*/ | |
function ratelimit(fn, ms) { | |
var last = (new Date()).getTime(); |
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
// Inmperative version | |
// | |
def selectionSort(list: Array[Int]): Unit { | |
def swap(list: Array[Int], i: Int, j: Int) { | |
var tmp = list(i) | |
list(i) = list(j) | |
list(j) = tmp | |
} | |
var i = 0 |
NewerOlder