Skip to content

Instantly share code, notes, and snippets.

Chris Whong chriswhong

Block or report user

Report or block chriswhong

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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
@chriswhong
chriswhong / index.html
Last active Jul 23, 2018
D3 Sankey Link with Variable Width
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Variable Width Sankey Link</title>
<style>
path {
fill: steelblue;
}
</style>
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 / .DS_Store
Last active May 29, 2019
Animated D3 Clock in Torque
@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)"'
You can’t perform that action at this time.