Skip to content

Instantly share code, notes, and snippets.

@climyao
climyao / zen-quiz_markup
Created October 15, 2010 20:48
Zen - Quiz Markup
ol.test>li.question*25>ul.answers>input[type="radio" value="" name="" style="display:none;"]+li.answer*4>input[type="radio" value="" name=""]
@climyao
climyao / routing_haxxample.rb
Created February 20, 2012 22:26
Hacked out general route handling in Sinatra against a model
# General routes
# uses ActiveSupport::Inflector
get '/:model.json' do
content_type :json
begin
klass = params[:model].singularize.camelize.constantize
klass_presenter = "#{klass.name}Presenter".constantize
rescue
404
@climyao
climyao / gist:2591572
Created May 4, 2012 02:49
output column name and type
klass.columns.each do |column|
puts "# #{column.name} \t#{column.type}"
end
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>d3.js scatterplot</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' src="https://raw.github.com/mbostock/d3/master/d3.v2.min.js"></script>
@climyao
climyao / blank_us_map.svg
Created July 9, 2012 17:49
Blank US Map SVG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@climyao
climyao / index.html
Created July 9, 2012 19:56
d3 choropleth example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>d3.js choropleth example</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' src="https://raw.github.com/mbostock/d3/master/d3.v2.min.js"></script>
@climyao
climyao / iowa-counties.svg
Created July 9, 2012 21:51
Iowa Counties SVG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@climyao
climyao / index.html
Created July 10, 2012 17:10
d3 iowa choropleth example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>d3.js iowa</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' src="https://raw.github.com/mbostock/d3/master/d3.v2.min.js"></script>
<script type='text/javascript'>
// tipsy, facebook style tooltips for jquery
@climyao
climyao / index.html
Created July 11, 2012 15:35
crappy pie chart
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>d3.js pie!</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' src="https://raw.github.com/mbostock/d3/master/d3.v2.min.js"></script>
<style type='text/css'>
@climyao
climyao / payroll.rb
Created January 24, 2013 21:18
Calculate beginning and end of payroll given an arbitrary date
def beginning_of_payroll(given_date)
payroll_start_seed = Date.new(2011,12,02)
given_date - ( (given_date - payroll_start_seed).abs % 14 )
end
def end_of_payroll(given_date)
beginning_of_payroll(given_date) + 13
end