Skip to content

Instantly share code, notes, and snippets.

Chris Whong chriswhong

View GitHub Profile
@chriswhong
chriswhong / getCurrentView.js
Last active Aug 29, 2015
Leaflet initial view helper
View getCurrentView.js
//Logs current map center and zoom level for use in map init options
//Use it to find that perfect intial view without having to use trial and error
map.on('dragend',getInit).on('zoomend',getInit);
function getInit() {
var c = map.getCenter();
console.log('center: [' + c.lat + ',' + c.lng + '],\nzoom: ' + map.getZoom());
}
@chriswhong
chriswhong / cartocssmaker.js
Created May 27, 2015
Torque CartoCSS Maker
View cartocssmaker.js
//node script for generating complex cartoCSS for torque
//as value increases, duration of marker gets longer,
//radius gets larger, and color moves up the ramp.
var breaks = [0,10,50,100]
var colors = ['#eff3ff','#bdd7e7','#6baed6','#2171b5'];
var data = {
"tableName":"#nepaltrends",
"valueCondition":0,
@chriswhong
chriswhong / sql.txt
Created Jul 20, 2015
Gaussian Distribution for Dummy Data in CartoDB
View sql.txt
/*
Given a table of census tracts, this query will generate a gaussian distribution of points offset from the tract's centroid.
Based on this example by Paul Ramsey: http://boundlessgeo.com/2014/10/postgis-training-creating-overlays/
*/
WITH tracts AS (
SELECT *, random() AS u1, random() AS u2, 25 AS f, generate_series(1,total_pop/100) FROM chriswhong.nytracts
)
SELECT
View index.html
<!DOCTYPE html>
<html lang="en">
<head profile="http://www.w3.org/2005/10/profile">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="./favicon.ico">
View texas-gis-workshop.md

##Real-Time Data in CartoDB texasGIS

About Chris: Solutions Engineer, Urbanist, Mapmaker, Open Data Junkie

cwhong@cartodb.com

@chris_whong

@chriswhong
chriswhong / index.html
Created Nov 13, 2015
Multiple CartoDB Named Maps on One Leaflet Map
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<style>
#map, html, body {
height:100%;
width:100%;
@chriswhong
chriswhong / alias.txt
Created Nov 19, 2015
Create an alias in the terminal to open the current directory in chrome via the local webserver
View alias.txt
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --url "http://localhost/~chriswhong/$(basename $PWD)"'
@chriswhong
chriswhong / gist:a4d1e6305ecaf2ad507a
Created Nov 20, 2015
Use cartodb.js to add a torque layer from a named map with auth_tokens enabled
View gist:a4d1e6305ecaf2ad507a
var layerSource = {
type: "torque",
options: {
auth_token: '{yourAuthToken}',
user_name: "{yourCartoDBUsername}",
tile_style:"{torqueCartoCSS}",
named_map: {
name: "{namedmap}"
}
}
View speedsensors.txt
NYC DOT Live Speed Sensors data:
http://207.251.86.229/nyc-links-cams/LinkSpeedQuery.txt
h/t https://twitter.com/5h15h/status/684116277586100224
You can’t perform that action at this time.