Skip to content

Instantly share code, notes, and snippets.

View rubysolo's full-sized avatar

Solomon White rubysolo

View GitHub Profile
@rubysolo
rubysolo / garden.clj
Created June 13, 2013 17:28
Kindergarden Garden
(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))
(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))
@rubysolo
rubysolo / foo.clj
Last active December 17, 2015 18:29
(#(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))
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) ->
# 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
/*
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() {
<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],
@rubysolo
rubysolo / tablesorter-bootstrap.css
Created May 8, 2013 19:06
jQuery Tablesorter Bootstrap styles
/* 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;
// 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,