Skip to content

Instantly share code, notes, and snippets.

View jsoma's full-sized avatar

Jonathan Soma jsoma

View GitHub Profile
@jsoma
jsoma / 2012.vrt
Created December 23, 2014 17:21
Converts stop-and-frisk data from New York State Plane to lat/lng. Make a vrt for every csv and run `ogr2ogr` on them - be sure to make backups, it deletes the original csv for god knows what reason.
<OGRVRTDataSource>
<OGRVRTLayer name="2012">
<SrcDataSource>2012.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs</LayerSRS>
<GeometryField encoding="PointFromColumns" x="xcoord" y="ycoord"/>
</OGRVRTLayer>
</OGRVRTDataSource>
@jsoma
jsoma / gist:2372039
Created April 13, 2012 00:06
LocalNotification Cordova callback fix
// When upgrading the LocalNotification plugin from PhoneGap to Cordova, you run
// into the error "Request for member 'webView' in something not a structure or union"
// from the LLVM GCC 4.2 compiler.
//
// The wonderful callback support is to blame!
//
// You just need to edit AppDelegate.m and replace all instances of this.webView
// with this.viewController.webView and you'll be good to go!
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
@jsoma
jsoma / gist:6136915
Last active December 20, 2015 13:09
NYC's apaprently-unreliable PLUTO data, grouped by year built for Brooklyn buildings from http://www.nyc.gov/html/dcp/html/bytes/dwn_pluto_mappluto.shtml. Houses seem to be invented in 1899? There's also a BuiltCode field that provides whether the date is an estimate or not, and according to it 19403 of the 19503 buildings from 1899 are estimates.
NULL 0
0 12886
1800 229
1804 1
1822 3
1824 4
1825 2
1826 4
1829 20
1830 9
@jsoma
jsoma / bubbles.js
Last active November 8, 2016 14:55
HTML file for YouTube video on d3 bubble charts
(function() {
var width = 500,
height = 500;
var svg = d3.select("#chart")
.append("svg")
.attr("height", height)
.attr("width", width)
.append("g")
.attr("transform", "translate(0,0)")
@jsoma
jsoma / matplotlibrc
Created July 12, 2018 14:45
Shortened list of matplotlibrc settings, maybe only the stuff that's important, maybe?
### MATPLOTLIBRC FORMAT
#
# See http://matplotlib.org/users/customizing.html#the-matplotlibrc-file for
# more details on the paths which are checked for the configuration file.
#
### LINES
# See http://matplotlib.org/api/artist_api.html#module-matplotlib.lines for more
# information on line properties.
@jsoma
jsoma / index.html
Last active November 16, 2018 23:36
voronoi map
<!DOCTYPE html>
<style>
.states :hover {
fill: red;
}
.state-borders {
fill: none;
stroke: #fff;
@jsoma
jsoma / stylebot.json
Created March 19, 2019 12:27
Stylebot custom CSS to make multiple-inboxes Gmail look more like Inbox (RIP)
{"mail.google.com":{"_enabled":true,"_rules":{".Cp":{"margin":"0 50px"},".aeJ, .no, .gb_7d.gb_Ce.gb_fe":{"background":"#f2f2f2"},".aia":{"margin":"0 auto","max-width":"840px"},".nK .byN":{"box-shadow":"none"},".oZ-jc.T-Jo.J-J5-Ji":{"margin-left":"0","padding-left":"0"},".oZ-x3::before":{"display":"none"},".zA":{"background":"#fff"},".zt":{"box-shadow":"0 -1px 0 #e0e0e0, 0 0 2px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.24)"},"body":{"font-family":"'Helvetica Neue',Helvetica,Arial,sans-serif"},"comment0":{"comment":"/* Background and general styles */"},"comment1":{"comment":"/* Spacing and groups */"},"comment2":{"comment":"/* Checkbox */"},"comment3":{"comment":"/* View All */"},"comment4":{"comment":"/* Date */"},"comment5":{"comment":"/* click-all/settings bar etc thingies */"},"div > div:nth-child(6) > div:nth-child(1) > .BltHke.nK .byN":{"display":"none"},"div.D.E.G-atb:not(.bP)":{"comment6":{"comment":"/*display: none; */"}},"div.nJ.A2":{"border-color":"#616161","font-size":"100%","font-weight":"normal","m
@jsoma
jsoma / README.md
Last active June 5, 2019 22:13
A few styling tips for the MapBox GL map

Setting the style for the MapBox GL map template

Using a color scale

If you have a property called rating that goes from 0-10, this code will fill in your shape based on it. 1 will be a very light blue, 5 will be a slightly darker blue, and 10 will be even more dark. Numbers in between will be estimated (interpolated). Note that including the 5 level was not necessary - if rating were 5, MapBox GL would have guessed a color in between the 1 color and the 10 color.

'fill-color': [
      'interpolate', ['linear'],
 ["to-number", ["get", "rating"]], 
@jsoma
jsoma / README.md
Created August 3, 2019 12:12
Design checklist

Data Studio Charting Checklist

You can see a few suggestions at http://designingviz.com/ which may or may not be reasonable. I also really recommend The Wall Street Journal Guide to Information Graphics, a pretty tiny book that is remarkably helpful at helping you not screw things up.

Micro-tutorials for Illustrator can be found at http://jonathansoma.com/lede/data-studio/, including how to open your Python files in Illustrator. Longer, detailed Illustrator tutorials can be found on Lynda.com, accessed for free through the Columbia portal.

Communicating successfully

Story

@jsoma
jsoma / README.md
Created August 12, 2019 18:55
Design Critique

You can make a design critique request using this Google form

Critique: Ministers leaving under Theresa May (line chart)