Skip to content

Instantly share code, notes, and snippets.

Query:

select 
  max(pin::bigint) as example, 
  count(*) num_properties, 
  ROUND(current_total/current_market_value::numeric, 2::int) as assessment_level 
from taxes 
where 
 current_market_value !=0 
@fgregg
fgregg / foia_counts
Created May 4, 2015 00:44
Chicago FOIA counts
Buildings,https://data.cityofchicago.org/resource/ucsz-xe6d.json?$select=date_trunc_y(date_received)%20as%20year,COUNT(*)&$group=year&$order=year
Revenue,https://data.cityofchicago.org/resource/zrv6-shhf.json?$select=date_trunc_y(date_received)%20as%20year,COUNT(*)&$group=year&$order=year
311,https://data.cityofchicago.org/resource/j2p9-gdf5.json?$select=date_trunc_y(date_received)%20as%20year,COUNT(*)&$group=year&$order=year
Transportation,https://data.cityofchicago.org/resource/u9qt-tv7d.json?$select=date_trunc_y(date_received)%20as%20year,COUNT(*)&$group=year&$order=year
Law,https://data.cityofchicago.org/resource/44bx-ncpi.json?$select=date_trunc_y(date_received)%20as%20year,COUNT(*)&$group=year&$order=year
@fgregg
fgregg / ctrl.md
Last active November 9, 2018 17:24
Civic Tech Reading List (CTRL)

#FG's list

Things I haven't read, but would like to

  • Tools for Conviviality
  • Some things about information systems within corporations, maybe something about Toyota and Walmart
  • Some things about modern public relations
  • Some things about the Rand Corporation
  • Some things about Herman Kahn and early Hudson Institute
  • http://www.culturemachine.net/index.php/cm/article/view/511/526
@fgregg
fgregg / path_model.R
Created March 9, 2015 21:12
Path model with logistic regression.
pums <- read.csv("small_pums.csv")
pums$ESR <- factor(pums$ESR,
labels=c("civilian employed, at work",
"civilian employed, with a job but not at work",
"unemployed",
"armed forces, at work",
"not in labor force"))
pums$college <- factor(pums$SCHL > 17, labels=c("no college", "some college"))
geoid10 | cases | person_years
-----------------+-------+--------------
170318390004004 | 470 | 1265
170318374002019 | 174 | 535
170318419002089 | 219 | 530
170318368002005 | 118 | 513
170313814001005 | 18 | 463
170310313004006 | 129 | 392
170314909022041 | 44 | 358
170312315005016 | 30 | 311
@fgregg
fgregg / inclass.R
Created February 17, 2015 20:13
Our running analysis of income gender inequality in Illinois.
pums <- read.csv("small_pums.csv")
hist(pums$WAGP)
male_income <- pums$WAGP[pums$SEX=="male"]
female_income <- pums$WAGP[pums$SEX=="female"]
plot(WAGP ~ SEX, data=pums)
summary(lm(WAGP ~ 1,data=pums))
@fgregg
fgregg / fdistribution.R
Created February 9, 2015 22:14
Sampling distribution of F statistic
pums <- read.csv("small_pums.csv")
# We want to test the hypothesis that standard deviation of earnings
# are the same for men and women in Illinois
#
# For this hypothesis, we will use the F statistic.
male.earnings <- pums$WAGP[pums$SEX=="male"]
n.male.earnings <- length(na.omit(male.earnings))
--------------------------------------------------------------------------------
Command: python mysql_example.py
Massif arguments: --massif-out-file=out.txt --depth=1
ms_print arguments: out.txt
--------------------------------------------------------------------------------
MB
686.3^ #
| @:: #::
import dedupe
records = dict([(i, {'name': 'Margret',
'age': '32'})
for i in xrange(10**4)])
deduper = dedupe.Dedupe([{'field' : "name", 'type' : 'String'}], ())
deduper.sample(records, 100000)