Skip to content

Instantly share code, notes, and snippets.

View rubysolo's full-sized avatar

Solomon White rubysolo

View GitHub Profile
@rubysolo
rubysolo / view.sql
Created June 26, 2013 16:47
cfd query
SELECT d.day, s.description, SUM(1) AS count
FROM (SELECT current_date - days.day AS day FROM generate_series(0,
(SELECT CAST(EXTRACT(epoch FROM NOW() - DATE(MIN(start_date))) / 86400 AS integer) FROM pivotal_tracker_story_histories)
,1) AS days(day)) d INNER JOIN pivotal_tracker_story_histories h ON d.day BETWEEN h.start_date AND COALESCE(h.end_date, current_date)
INNER JOIN pivotal_tracker_story_statuses s ON s.id = h.status_id
GROUP BY d.day, s.description
ORDER BY d.day, s.description
@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;