Skip to content

Instantly share code, notes, and snippets.

View datapolitan's full-sized avatar

Datapolitan datapolitan

View GitHub Profile
@datapolitan
datapolitan / ssh_config_example_macOS.sh
Created January 8, 2018 02:50
Example SSH config file for two Github hosts
#user1 account
Host github.com-user1
HostName github.com
User git
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
#user2 account
Host github.com-user2
@datapolitan
datapolitan / setup.sh
Created July 14, 2017 22:36
How to setup the Protobuf Files to parse the NYCT GTFS-RT Feeds (because they don't make it easy)
# Download the proto files
wget http://datamine.mta.info/sites/all/files/pdfs/nyct-subway.proto.txt
wget https://developers.google.com/transit/gtfs-realtime/gtfs-realtime.proto
# rename the NYCT proto file to drop the .txt extension
mv nyct-subway.proto.txt nyct-subway.proto
# install the protobuf-compiler
sudo yum install protobuf-compiler
@datapolitan
datapolitan / idea.md
Last active March 7, 2023 03:17 — forked from chriswhong/idea.md
Idea for git-powered distributed dataset management

The Problem:

If you follow the open data scene, you'll often hear about how the "feedback loop" for making corrections, comments, or asking questions about datasets is either fuzzy, disjointed, or nonexistent. If I know for a fact that something in a government dataset is wrong, how do I get that record fixed? Do I call 311? Will the operator even know what I am talking about if I say I want to make a correction to a single record in a public dataset? There's DAT. There's storing your data as a CSV in Github. These approaches work, but are very much developer-centric. (Pull requests and diffs are hard to wrap your head around if you spend your day analyzing data in Exce

@datapolitan
datapolitan / Design_thinking_Outline.md
Last active March 7, 2023 03:18
Outline for curriculum design using design thinking

Welcome (1 min)

Introductions (10 mins)

  • Name
  • Short background
  • One thing you enjoy about teaching

Student profile (4 mins)

/* Function: ST_Buffer_Meters(geometry, double precision)
DROP FUNCTION ST_Buffer_Meters(geometry, double precision);
Usage: SELECT ST_Buffer_Meters(the_geom, num_meters) FROM sometable; */
CREATE OR REPLACE FUNCTION ST_Buffer_Meters(geometry, double precision)
RETURNS geometry AS
$BODY$
DECLARE
orig_srid int;
/* Function: utmzone(geometry)
DROP FUNCTION utmzone(geometry);
Usage: SELECT ST_Transform(the_geom, utmzone(ST_Centroid(the_geom))) FROM sometable; */
CREATE OR REPLACE FUNCTION utmzone(geometry)
RETURNS integer AS
$BODY$
DECLARE
geomgeog geometry;
zone int;
@datapolitan
datapolitan / legend_snippet.html
Created September 8, 2015 13:37
Snippet of HTML and CSS for the legend box
<html>
<head>
<style>
#legend {
position:absolute;
bottom:20px;
right: 5px;
background: #D3D3D3;
border-radius: 10px;
display: block;
@datapolitan
datapolitan / map_snippet.js
Last active March 7, 2023 03:21
A snippet for creating a map with multiple layers in CartoDB
// the center point of the map on load. Change this to adjust the center point of the map.
var map_centerpoint = [40.712784, -74.005941];
// zoom level of the map on load. Higher number zooms the map in closer
var zoom_level = 11
// your visualization layer from CartoDB
var myVizLayer = 'https://richard-datapolitan.cartodb.com/api/v2/viz/c35e85b2-5370-11e5-b844-0e9d821ea90d/viz.json';
// the name of the CartoDB table you want to query against
var point_table_name = 'map_data_sgr';
var line_table_name = 'nyct_routes_1';
var sublayers=[];
@datapolitan
datapolitan / matplotlib_pandas_ec2.sh
Last active March 7, 2023 03:21
Installation of packages to get matplotlib and pandas installed on Amazon EC2 instance
#!/bin/bash
sudo yum install update
sudo yum groupinstall "Development Tools"
sudo yum install python-devel libpng-devel freetype-devel
#the last two are necessary for pip to run without failing with error 'Command "python setup.py egg_info" failed with error code 1'
sudo pip install matplotlib pandas #Finally it works!
@datapolitan
datapolitan / load_dmp_2_cartodb.sh
Last active March 7, 2023 03:21 — forked from emacgillavry/load_dmp_2_cartodb.sh
Use Postgres dump files to populate CartoDB instance
#!/bin/bash
#------------------------------------------------------------
# We assume the dump files have been generated using pg_dump:
#
# pg_dump -a --column-inserts -x -O -t table_name database_name -f /tmp/dmp_file_name
#
#------------------------------------------------------------
# Provide details of your CartoDB account: