Skip to content

Instantly share code, notes, and snippets.

View nbumbarger's full-sized avatar

Nick Bumbarger nbumbarger

View GitHub Profile
@nbumbarger
nbumbarger / gist:8a909f5d8e2d2526ade7
Created May 30, 2015 22:17
Custom social media icon in Jekyll.
<!--Add to _includes/footer.html, and define linkedin_username variable in _config.yml.-->
{% if site.linkedin_username %}
<li>
<a href="https://www.linkedin.com/in/{{ site.linkedin_username }}">
<span class="icon icon--twitter">
<svg viewBox="0 0 61 61">
<path fill="#828282" d="M49.265,4.667H7.145c-2.016,0-3.651,1.596-3.651,3.563v42.613c0,1.966,1.635,3.562,3.651,3.562h42.12 c2.019,0,3.654-1.597,3.654-3.562V8.23C52.919,6.262,51.283,4.667,49.265,4.667z M18.475,46.304h-7.465V23.845h7.465V46.304z M14.743,20.777h-0.05c-2.504,0-4.124-1.725-4.124-3.88c0-2.203,1.67-3.88,4.223-3.88c2.554,0,4.125,1.677,4.175,3.88 C18.967,19.052,17.345,20.777,14.743,20.777z M45.394,46.304h-7.465V34.286c0-3.018-1.08-5.078-3.781-5.078 c-2.062,0-3.29,1.389-3.831,2.731c-0.197,0.479-0.245,1.149-0.245,1.821v12.543h-7.465c0,0,0.098-20.354,0-22.459h7.465v3.179 c0.992-1.53,2.766-3.709,6.729-3.709c4.911,0,8.594,3.211,8.594,10.11V46.304z"/>
</svg>
</span>
@nbumbarger
nbumbarger / gist:53ef6f4d7576a2f4efb1
Created June 1, 2015 12:35
Convert a list of coordinates to KML
# From: http://www.nickbumbarger.com/2015/05/31/spatial_data_production.html
def placemark_template(name, lat, lng)
placemark = "<Placemark>\n<name>#{name}</name>\n<Point>\n<coordinates>\n#{lng},#{lat},0\n</coordinates>\n</Point>\n</Placemark>\n"
end
#Start with the raw text
data = "GA Washington DC\t38.90485\t-77.03394\nGA New York\t40.73930\t-73.98942\nGA Chicago\t41.89061\t-87.62688"
#Define an empty body and split the text into attributes
#Insert attributes into the placemark template and append result to the body
body = String.new
raw_data.split("\n").each do |line|
@nbumbarger
nbumbarger / gist:0a9615cca929e0a31029
Created June 1, 2015 12:39
Geocode a list of addresses
# From: http://www.nickbumbarger.com/2015/05/31/spatial_data_production.html
require "HTTParty"
def geocode(address)
results = HTTParty.get("https://maps.googleapis.com/maps/api/geocode/json?address="+address)["results"]
location = results.first["geometry"]["location"]
end
#Start with the original address data
data = "GA Washington DC\t1133 15th Street NW, 8th Floor Washington, DC 20005\nGA New York\t902 Broadway, 4th Floor New York, NY 10010\nGA Chicago\t444 N Wabash Ave, 5th Floor Chicago, IL 60611\n"
#Split into names and addresses, and send the address to the geocoder
#Reform the original text with coordinates in the place of addresses
@nbumbarger
nbumbarger / gist:a152517c2c7a9680f026
Last active August 29, 2015 14:22
Convert addresses to KML (geocoding API)
# From: http://www.nickbumbarger.com/2015/05/31/spatial_data_production.html
require "HTTParty"
def geocode(address)
results = HTTParty.get("https://maps.googleapis.com/maps/api/geocode/json?address="+address)["results"]
location = results.first["geometry"]["location"]
end
def placemark_template(name, lat, lng)
placemark = "<Placemark>\n<name>#{name}</name>\n<Point>\n<coordinates>\n#{lng},#{lat},0\n</coordinates>\n</Point>\n</Placemark>\n"
end
#Start with the address data
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://d3js.org/d3.v3.js"></script>
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
@nbumbarger
nbumbarger / index.html
Last active November 12, 2015 17:20
Gara Djebilet Band Ratio (Mapbox slider, image processing example)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Gara Djebilet Band Ratio</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@nbumbarger
nbumbarger / index.html
Created November 12, 2015 17:23
Gara Djebilet PCA (Mapbox slider, image processing example)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Gara Djebilet PCA</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>100m buffer</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Original</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Convex Hull</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }