Skip to content

Instantly share code, notes, and snippets.

View spara's full-sized avatar

Sophia Parafina spara

View GitHub Profile
@spara
spara / fur_elise.ino
Created February 15, 2012 03:11
Caterina's Fur Elise on Arduino
void setup() {
pinMode(10, OUTPUT);
}
void loop() {
// play e4
delay(600);
tone(10, 329.63, 300);
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Tornadoes in the U.S. - 2010</title>
<script src='wax/ext/modestmaps.min.js' type='text/javascript'></script>
<script src='wax/dist/wax.mm.js' type='text/javascript'></script>
<link href='wax/theme/controls.css' rel='stylesheet' type='text/css' />
<style type='text/css'>
@spara
spara / gist:2279162
Created April 1, 2012 22:32
install opencv gem
$ git clone git://github.com/ser1zw/ruby-opencv.git
$ cd ruby-opencv
$ git checkout master # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead
$ ruby extconf.rb --with-opencv-dir=/path/to/opencvdir
$ make
$ make install
@spara
spara / create_census_db.sh
Created April 11, 2012 20:42
creating database of 2000 and 2010 Census
# create the database
createdb census_sf1
# create 2010 SF1 tables
psql census_sf1 -f create_SF1_2000_tables.sql
# create the 2010 geo_header table
create_geo_header_2010_table.sql
# load sf1_00017 and sf1_00001 tables
@spara
spara / get_logrecno_from_geographic_table.sql
Created April 25, 2012 19:55
retrieve logrecno from a set of TIGER census tracts
SELECT logrecno, t.*
FROM
geo_header_sf1 g,
(SELECT "TRACTCE10","NAMELSAD10", "COUNTYFP10" from tract_d3) t (tractce10, namelsad10, countyfp10 )
WHERE
g.tract = t.tractce10 AND g.sumlev='140'
AND g.name=t.namelsad10
AND g.county=countyfp10
ORDER BY g.tract;
@spara
spara / get_logrecno_from_list_of_census_tracts.sql
Created April 25, 2012 20:09
retrieve logrecno using a list of census tracts
SELECT g.logrecno
FROM
sf1geo g,
(VALUES ('150600'),('151400'),('151000'),('140500'),('140900'),('150300'),('140700'),('141000'),('140600'),
('141300'),('141200'),('141600'),('141500'),('150700'),('150900'),('151600'),('140200'),('140300'),
('150800'),('140400'),('141402'),('141900'),('141800'),('141700'),('140800'),('151900'),('152100'),
('151700'),('151500'),('151800'),('152000')) AS t00 (tractce00),
sf10001 s
WHERE g.tract = t00.tractce00
AND g.sumlev='140'
@spara
spara / create_female_pop_pyramid.sql
Created April 26, 2012 15:23
query to create a population pyramid from Census data
SELECT
SUM(PCT0120107+PCT0120108+PCT0120109+PCT0120110+PCT0120111) AS "0-4",
SUM(PCT0120112+PCT0120113+PCT0120114+PCT0120115+PCT0120116) AS "5-9",
SUM(PCT0120117+PCT0120118+PCT0120119+PCT0120120+PCT0120121) AS "10-14",
SUM(PCT0120122+PCT0120123+PCT0120124+PCT0120125+PCT0120126) AS "15-19",
SUM(PCT0120127+PCT0120128+PCT0120129+PCT0120130+PCT0120131) AS "20-24",
SUM(PCT0120132+PCT0120133+PCT0120134+PCT0120135+PCT0120136) AS "25-29",
SUM(PCT0120137+PCT0120138+PCT0120139+PCT0120140+PCT0120141) AS "30-34",
SUM(PCT0120142+PCT0120143+PCT0120144+PCT0120145+PCT0120146) AS "35-39",
SUM(PCT0120147+PCT0120148+PCT0120149+PCT0120150+PCT0120151) AS "40-44",
@spara
spara / get_2000_population_from_unchanged_tracts.sql
Created April 26, 2012 18:46
get 2000 population from unchanged tracts
SELECT g.logrecno,p001001
FROM
sf1geo g,
(VALUES ('150600'),('151400'),('151000'),('140500'),('140900'),('150300'),('140700'),('141000'),('140600'),
('141300'),('141200'),('141600'),('141500'),('150700'),('150900'),('151600'),('140200'),('140300'),
('150800'),('140400'),('141402'),('141900'),('141800'),('141700'),('140800'),('151900'),('152100'),
('151700'),('151500'),('151800'),('152000')) AS t00 (tractce00),
sf10001 s
WHERE g.tract = t00.tractce00
AND g.sumlev='140'
SELECT tract00, tract10, pop10
FROM tract_relationship_2010
WHERE tract10 = '192200'
OR tract10 = '151302'
OR tract10 = '152201'
OR tract10 = '151301'
OR tract10 = '141101'
OR tract10 = '141404'
OR tract10 = '141102'
OR tract10 = '141403'
@spara
spara / gnis.sql
Created May 1, 2012 06:42
load GNIS into sqlite3
sqlite3 GNIS
create table national (feature_id int,
feature_name varchar(120),
feature_class varchar(50),
state_alpha varchar(2),
state_numeric varchar(2),
county_name varchar(100),
county_numeric varchar(3),
primary_lat_dms varchar(7),