Skip to content

Instantly share code, notes, and snippets.

View jsoma's full-sized avatar

Jonathan Soma jsoma

View GitHub Profile
@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 / 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 / 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 / bootstrap-template.html
Last active July 2, 2023 19:07
A Bootstrap 4 template for a portfolio site (and other things, too). A handful of handy pieces in there, not as complicated or customized as the stuff on https://getbootstrap.com/.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
@jsoma
jsoma / matplotlib-fonts.py
Created July 10, 2018 03:37
See all of the fonts that matplotlib can access
import matplotlib.font_manager
from IPython.core.display import HTML
def make_html(fontname):
return "<p>{font}: <span style='font-family:{font}; font-size: 24px;'>{font}</p>".format(font=fontname)
code = "\n".join([make_html(font) for font in sorted(set([f.name for f in matplotlib.font_manager.fontManager.ttflist]))])
HTML("<div style='column-count: 2;'>{}</div>".format(code))
@jsoma
jsoma / matplotlibrc
Created July 12, 2018 14:13
sample default matplotlibrc file from matplotlib
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overwritten in your next install.
# If you want to keep a permanent local copy that will not be
# overwritten, place it in the following location:
# unix/linux:
# $HOME/.config/matplotlib/matplotlibrc or
@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 / README.md
Last active December 17, 2022 02:54
Installing tweego and story-formats on OS X.

Installing tweego is a little more complicated than (I think) it should be, so here's a script to do it for you. If you'd like to one-line it, you can just cut and paste this in Terminal:

/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/jsoma/5ef3045b2004a610455f371479a6f0cf/raw/b6c9224faa18fd52f3e1bf7120af17eed6da8ec1/tweego.sh)"

Once it's installed, tweego docs are here. You'll probably want to read these twee docs, too.