Skip to content

Instantly share code, notes, and snippets.

View wboykinm's full-sized avatar

Bill Morris wboykinm

View GitHub Profile
@mbostock
mbostock / .block
Last active November 20, 2016 23:20
Dynamic Simplification IV
license: gpl-3.0
@mourner
mourner / tiles.js
Created February 5, 2014 15:21
Leaflet — get all tile URLs given geographic bounds, tile layer and zoom
function getTileUrls(bounds, tileLayer, zoom) {
var min = map.project(bounds.getNorthWest(), zoom).divideBy(256).floor(),
max = map.project(bounds.getSouthEast(), zoom).divideBy(256).floor(),
urls = [];
for (var i = min.x; i <= max.x; i++) {
for (var j = min.y; j <= max.y; j++) {
var coords = new L.Point(i, j);
coords.z = zoom;
// gmaps js api v2 polygon overlays -> geojson
overlayToGeoJSON = function(o){
var feature={type:'Feature', geometry:{ type:'Polygon', coordinates:[[]]}};
for (var i=0; i < o.latlngs.length; i++){
feature.geometry.coordinates[0].push([o.latlngs[i].lng + o.reflng, o.latlngs[i].lat + o.reflat])
}
feature.properties = {hint:o.hint, html: o.infohtml}
return feature;
}
var results={type: "FeatureCollection", features: []};
@wboykinm
wboykinm / hexgrid.sql
Created February 12, 2014 17:12
Hexgrid code
WITH hgrid AS
(SELECT CDB_HexagonGrid(ST_Expand(CDB_XYZ_Extent(/* INSERT TILE XYZ SOMEHOW */), CDB_XYZ_Resolution(/* CURRENT ZOOM */) * 15), CDB_XYZ_Resolution(/* CURRENT ZOOM */) * 15) AS cell)
SELECT hgrid.cell AS the_geom_webmercator,
count(i.cartodb_id) AS points_count,
count(i.cartodb_id)/power(15 * CDB_XYZ_Resolution(/* CURRENT ZOOM */), 2) AS points_density,
1 AS cartodb_id
FROM hgrid,
(SELECT *
FROM /* TABLE NAME HERE */) i
WHERE ST_Intersects(i.the_geom_webmercator, hgrid.cell)
@wolever
wolever / histogram.sql
Last active April 19, 2023 20:28
Functions to create and draw histograms with PostgreSQL.
-- Functions to create and draw histograms with PostgreSQL.
--
-- psql# WITH email_lengths AS (
-- -# SELECT length(email) AS length
-- -# FROM auth_user
-- -# LIMIT 100
-- -# )
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths))
-- bucket | range | count | bar | cumbar | cumsum | cumpct
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------
@pykerl
pykerl / README.md
Last active June 7, 2016 15:41
Creating static data visualizations with D3 & Node
@erikhazzard
erikhazzard / index.html
Last active November 13, 2015 06:42
Fog of War SVG Filter Mask Example
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<style>
html, body {
background: #ffffff;
font-family: Helvetica, Arial, Tahoma, sans-serif;
margin: 0;
@jeremyjbowers
jeremyjbowers / fix_ur_postgres.sh
Created February 11, 2015 16:32
A quickie shell script for fixing your Postgres installation on a Mac when migrating from 9.3.5 to 9.4.1 via homebrew.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
initdb /usr/local/var/postgres9.4 -E utf8
pg_upgrade -v \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.4 \
-b /usr/local/Cellar/postgresql/9.3.5_1/bin/ \
-B /usr/local/Cellar/postgresql/9.4.1/bin/
mv /usr/local/var/postgres /usr/local/var/postgres9.3
mv /usr/local/var/postgres9.4 /usr/local/var/postgres
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
{
"Arial Unicode MS": [
"Arial Unicode MS Regular",
"Arial Unicode MS Bold"
],
"Brokenscript OT": [
"Brokenscript OT Bold",
"Brokenscript OT Cond Bold"
],
"Brokenscript Rough OT": [
@robertsdionne
robertsdionne / deepdream-install.md
Last active February 15, 2021 16:07
Deepdream installation
#!/usr/bin/env bash

# Assuming OS X Yosemite 10.10.4

# Install XCode and command line tools
# See https://itunes.apple.com/us/app/xcode/id497799835?mt=12#
# See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
xcode-select --install