Skip to content

Instantly share code, notes, and snippets.

View critmcdonald's full-sized avatar

Christian McDonald critmcdonald

View GitHub Profile
@critmcdonald
critmcdonald / keybase.md
Created April 13, 2019 19:57
Keybase proof

Keybase proof

I hereby claim:

  • I am critmcdonald on github.
  • I am crit (https://keybase.io/crit) on keybase.
  • I have a public key ASDGeqjXZCWp2BjnBj0N0FPeFKy156I-3t_iqopGghQTmQo

To claim this, I am signing this object:

@critmcdonald
critmcdonald / 01-mixbev-import.Rmd
Last active March 19, 2019 17:03
RNotebook code to download Mixed Beverage data
---
title: "Mixed beverage download"
output: html_notebook
---
## Setup
You might need to install the [RSocrata](https://cran.r-project.org/web/packages/RSocrata/index.html) package (run `install.packages("RSocrata")` in your R Console). [Documentation is here](https://github.com/Chicago/RSocrata).
@critmcdonald
critmcdonald / pym-in-jquery
Created August 15, 2018 20:33
sendHeight within query to set pym
<script type="text/javascript" src="https://pym.nprapps.org/pym.v1.min.js"></script>
<script>
var pymChildRoster = new pym.Child();
$(document).ready(function(){
... stuff here ...
pymChildRoster.sendHeight();
});
</script>
@critmcdonald
critmcdonald / geoid.json
Last active February 9, 2018 05:36
Use this OpenRefine extract to add a geoid column to the census tract data for AP Redlining data. Edit line 127 and 135 to change "48" to your state FIPS number.
[
{
"op": "core/column-addition",
"description": "Create column tract_fix at index 6 based on column census_tract using expression grel:value",
"engineConfig": {
"mode": "row-based",
"facets": []
},
"newColumnName": "tract_fix",
"columnInsertIndex": 6,
@critmcdonald
critmcdonald / normalize_working.py
Created September 13, 2017 12:44
I thought you couldn't filter a normalized table in agate, but this example works
import agate
column_names = ['letter', 'number', 'state', 'city']
column_types = [agate.Text(), agate.Number(), agate.Text(), agate.Text()]
rows = [
('a', 1, 'TX', 'Austin'),
('b', 2, 'NY', 'Buffalo'),
('c', None, 'CA', 'Los Angeles')
]
@critmcdonald
critmcdonald / gist:32a52745275d9ecdb2c2
Last active August 29, 2015 14:24
Using Python Dataset to udpate mysql data
"""
This script uses the datatset library to udpate data in a mysql/mariadb database.
In this use case, I'm taking the field RaceSex (Example: 'White Male')
and updating the Race field with the first letter of the first word
and updating the Gender field with the first letter of the last word
If RaceSex is null or blank, a 'U' is used.
"""
import dataset
@critmcdonald
critmcdonald / Passing Caspio variable for Facebook sharing
Last active August 29, 2015 13:57
Passing Caspio variable for Facebook sharing
// First, in my Caspio search result, I don't include the
// detail page in the report, but instead create an HTML field that links
// to the report and passes two fields: the VenueID, which is used to pull
// the right record, and the SVenue, which is the name of the venue that
// I need for sharing.
<a href="venue.php?VenueID=[@field:VenueID]&Venue=[@field:SVenue]">[@field:SVenue]</a><br />
// This gives me a url like this:

Just a test, really.