Skip to content

Instantly share code, notes, and snippets.

View chrislkeller's full-sized avatar

Chris Keller chrislkeller

View GitHub Profile
@chrislkeller
chrislkeller / geocoder_code.py
Created December 30, 2014 18:31
Quick method of geocoding addresses...
# Uses wrapper found here: https://github.com/datadesk/python-googlegeocoder
# pip install python-googlegeocoder
import csv
import logging
import time
import datetime
from googlegeocoder import GoogleGeocoder
logger = logging.getLogger("root")
@chrislkeller
chrislkeller / data_primer.md
Last active November 1, 2015 18:50
Thinking through how we to pool knowledge on 1033 data? Is it possible to construct a living history or nerd box or cookbook for journalists going through the 1033 data? Especially the new stuff?

Maintained version moved here

Defense Logistics Agency's 1033 program data

Commonly known as the 1033 program, the Department of Defense surplus disposal program administered through the Defense Logistics Agency has its roots in the 1990 National Defense Authorization Act, which sets the federal budget for the Department of Defense every two years.

In the 1996 version of that budget, Congress created Section 1033 that allowed "all law enforcement agencies to acquire property for bona fide law enforcement purposes that assist in their arrest and apprehension mission."

The 24-year-old program received increased scrutiny in 2014 after several media report

@chrislkeller
chrislkeller / gist:c66ccd9cd677c148ccf9
Created November 21, 2014 23:28
Silly Javascript for backbone...
getCheckboxIds: function(event){
var activeCheckboxes = [];
if (!$("input:checkbox").is(":checked")) {
console.log("box is not checked");
}
$("input:checkbox").each(function(){
var $this = $(this);
if($this.is(":checked")){
var categoryId = $this.attr("id");
if (categoryId != undefined){
# Uses wrapper found here: https://github.com/datadesk/python-googlegeocoder
# pip install python-googlegeocoder
from googlegeocoder import GoogleGeocoder
import time
import logging
logging.basicConfig(format='\033[1;36m%(levelname)s:\033[0;37m %(message)s', level=logging.DEBUG)
def create_list_addresses_from_file():
@chrislkeller
chrislkeller / blogpost.md
Last active October 5, 2022 15:09
A quick Python script that implements "paging" -- or at least Twitter's version of it -- to search the social media platform's API for a given hashtag

I helped the folks at #wjchat a while back by writing a quick django app to pull tweets each week and save them to a database. The tweets were then accessible as formatted HTML that could be posted in the #wjchat Wordpress blog.

But something happened around the middle of April. The script pulled in 389 tweets on April 16, but the following week only caught 100. Same for the week after.

I did some hand-holding for a few weeks, but more and more of the same occurred.

#wjchat-transcript news: @ChrisLKeller & I are aware we’re a couple weeks behind. Pipes running the transcripts are a little clogged. Soon!

— P. Kim Bui (@kimbui) June 20, 2014
@chrislkeller
chrislkeller / pitch.md
Last active August 29, 2015 14:01
Adding statistics & analysis skills to the beginning data journo's toolbelt

Code allows us to make all kinds of visuals and tools that display data for analysis.

But when you're starting to mix code, data and journalism - and you lack a deep statistics background to draw upon - everything looks like a nail that you can whack with your shiny hammer. And everything - scatterplots to nearest neighbor to regression - seems important.

So how do you move from citing only the average, median & percent change in all of your work and begin to build skills and knowledge that can lead to a deeper analysis of datasets?

I propose a discussion that helps beginning data journalists/news apps developers better understand which analytical and statistical methods are best suited to different data situations.

For example:

  • What kind of data lends itself to a scatterplot & what does does the resulting graph tell you?
@chrislkeller
chrislkeller / webfaction-fabfile.py
Created May 6, 2014 19:06
webfaction-fabfile.py
from __future__ import with_statement
import os
import time, datetime
from fabric.operations import prompt
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.colors import green
env.hosts = ['{{YOUR WEBFACTION PATH}}']
year overall big_ten big_ten_finish big_ten_tournament ncaa_tournament date round opponent opponent_seed opponent_half opponent_final badgers_seed badgers_half badgers_final badgers_result url
2014 26-7 12-6 second 1-1 3/20/2014 First Round American 15 2
2013 23-12 12-6 2-1 0-1 3/22/2013 First Round Ole Miss 12 22 57 5 25 46 Loss http://espn.go.com/ncb/boxscore?gameId=330810275
2012 26-10 12-6 1-1 2-1 3/22/2012 Sweet Sixteen Syracuse 1 33 64 4 27 63 Loss http://espn.go.com/ncb/boxscore?gameId=320820183
2012 26-10 12-6 1-1 2-1 3/17/2012 Second Round Vanderbilt 5 31 57 4 32 50 Win http://espn.go.com/ncb/boxscore?gameId=320770275
2012 26-10 12-6 1-1 2-1 3/15/2012 First Round Montana 13 29 49 4 39 73 Win http://espn.go.com/ncb/boxscore?gameId=320750275
2011 25-9 13-5 0-1 2-1 3/24/2011 Sweet Sixteen Butler 8 33 61 4 24 54 Loss http://espn.go.com/ncb/boxscore?gameId=310830275
2011 25-9 13-5 0-1 2-1 3/19/2011 Second Round Kansas State 5 30 65 4 36 70 Win http://espn.go.com/ncb/boxscore?gameId=310780275
@chrislkeller
chrislkeller / capitol-words-demo.html
Last active August 29, 2015 13:57
Demo of a news application that searches the Capitol Words API for a term the user submits. Demo is here: http://projects.chrislkeller.com/demos/capitol-words-api/ LiveWeave is here: http://liveweave.com/jfzOa7
<!DOCTYPE html>
<html>
<head>
<title>Search the Congressional Record using Capitol Words API</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="meta-viewport" content="width=device-width,minimum-scale=1,maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="http://media.scpr.org/assets/images/icon.png">
<meta name="format-detection" content="telephone=no"/>
@chrislkeller
chrislkeller / nicar14_tweets.md
Last active August 29, 2015 13:57
Used tweepy and python to pull and store more than 13,000 #NICAR14 tweets between 2/25/13 and 3/4/13... I have no idea if these are all of them, but there are a lot. Let me know if you do anything fun with them...

Moved the csv file - about 4.5 mb - to github as it was too big for a gist. Find it here.