View this code at http://livecoding.io/5814072
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 default-students ["Alice" "Bob" "Charlie" "David" "Eve" "Fred" "Ginny" | |
"Harriet" "Ileana" "Joseph" "Kincaid" "Larry"]) | |
(def seeds { "G" :grass "C" :clover "R" :radishes "V" :violets }) | |
(defn row-to-seeds [row-string] | |
(map seeds (rest (clojure.string/split row-string #"")))) | |
(defn garden-to-rows [garden] | |
(clojure.string/split-lines garden)) |
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
(defn pack [coll] | |
"pack duplicates into sublists" | |
(loop [acc '(()) | |
fst (first coll) | |
rst (rest coll)] | |
(let [current (first (first acc)) | |
added-to-current (cons (cons fst (first acc)) (rest acc)) | |
added-new-sublist (cons (list fst) acc)] | |
(if (seq rst) | |
(if (or (nil? current) (= current fst)) |
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
(#(map (fn [i] (take i %1)) (range 1 (inc (count %1)))) '(1 2 3)) | |
# => ((1) (1 2) (1 2 3)) | |
(#(map (fn [i] (take i %1)) (range 1 (inc (count %1)))) [:a :b :c]) | |
# => ((:a) (:a :b) (:a :b :c)) |
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
casper = require('casper').create | |
logLevel: 'debug' | |
fs = require('fs') | |
username = casper.cli.args[0] | |
password = casper.cli.args[1] | |
currentProblem = 1 | |
problemCount = 173 | |
getProblem = (number) -> |
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
# prerequisites: Ruby 1.9.3, Rails 3.2.something recent | |
### | |
### Setup rails app w/haml and opal | |
### | |
# create app | |
rails new opal_test | |
# add to Gemfile below rails |
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
/* | |
Newtonian collision checking (draft) | |
based on the paper: http://www.vobarian.com/collisions/2dcollisions2.pdf | |
[email protected] | |
*/ | |
if (typeof d3.z != "object") d3.z = {}; | |
(function() { |
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
<html> | |
<body> | |
<script type="text/javascript" src="http://raw.github.com/mbostock/d3/v2.10.3/d3.v2.min.js"></script> | |
<script type="text/javascript"> | |
var svg = d3.select('body').append('svg') | |
.attr('width', '100%') | |
.attr('height', '100%') | |
.attr('viewBox', '0 0 280 200'); | |
var data = [[5, 15], |
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
/* see http://joshmcarthur.com/2012/05/14/bootstrap-tablesorter-styles.html */ | |
table .header { | |
cursor: pointer; | |
} | |
table .header:after { | |
content: ""; | |
float: right; | |
margin-top: 7px; | |
border-width: 0 4px 4px; | |
border-style: solid; |
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
// Inspired by http://dmitry.baranovskiy.com/work/github/ | |
d3.chart.impact = function() { | |
var width = 1, | |
height = 1, | |
duration = 0, | |
domain = null, | |
values = Object, | |
key = d3_chart_impactKey, | |
value = d3_chart_impactValue, | |
sort = null, |