Skip to content

Instantly share code, notes, and snippets.

@s2t2
s2t2 / metro-north-station-map.png
Last active December 9, 2015 18:18
metro north station map
metro-north-station-map.png
@s2t2
s2t2 / _form.html.erb
Last active September 23, 2021 13:49
files generated by rails scaffold controller (for reference)
<%= form_for(@thing) do |f| %>
<% if @thing.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@thing.errors.count, "error") %> prohibited this thing from being saved:</h2>
<ul>
<% @thing.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@s2t2
s2t2 / git_remove_all.md
Last active December 24, 2015 22:59
helpful mac terminal, git, and textmate commands
git rm $(git ls-files --deleted)

source

def multiples_of_x_less_than_y(x, y)
(1..(y / x)).to_a.map {|z| x * z}
end
(multiples_of_x_less_than_y(3,80) + multiples_of_x_less_than_y(5,80)).uniq.sort.sum
@s2t2
s2t2 / colors.rb
Last active August 29, 2015 13:57
color hexes for data vizualizations
#http://colorbrewer2.org/
COLOR_BREWER_SEQUENTIAL_BLUES = ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]
COLOR_BREWER_SEQUENTIAL_GREENS = ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]
COLOR_BREWER_SEQUENTIAL_GREYS = ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]
COLOR_BREWER_SEQUENTIAL_ORANGES = ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]
COLOR_BREWER_SEQUENTIAL_PURPLES = ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]
COLOR_BREWER_SEQUENTIAL_REDS = ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]
COLOR_BREWER_QUALITATIVE_VIBRANTS = ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99"]
COLOR_BREWER_QUALITATIVE_PASTELS = ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3
@s2t2
s2t2 / how to create a mysql database schema vizualization.md
Last active August 29, 2015 14:00
how to create a mysql database schema visualization in ruby on rails.

Step 1: Query the metadata

SELECT 
  table_schema
  ,TABLE_NAME
  ,COLUMN_NAME
  ,ordinal_position
  ,is_nullable
  ,data_type

,column_type

find . -name "*passenger*" -print
@s2t2
s2t2 / README.md
Last active August 29, 2015 14:06 — forked from simzou/README.md
@s2t2
s2t2 / README.md
Last active August 29, 2015 14:06 — forked from mbostock/.block

Some of these files are from the us-atlas:

  • us.json - make topo/us-10m.json
  • us-congress-113.json - make topo/us-congress-10m.json

Others are from the world-atlas:

  • world-50m.json - make topo/world-50m.json
  • world-110m.json - make topo/world-110m.json
@s2t2
s2t2 / README.md
Last active August 29, 2015 14:06 — forked from mbostock/.block

These county, state and country boundaries are extracted from a single TopoJSON file. Counties are stroked in thin gray, states in thin black, and the country in thick black.