Skip to content

Instantly share code, notes, and snippets.

View RandomEtc's full-sized avatar
🦕

Tom Carden RandomEtc

🦕
View GitHub Profile
@RandomEtc
RandomEtc / tile_maps.rb
Created December 30, 2013 07:40
Mercator Map Tile functions for Ruby
TILE_SIZE = 256.0
PX_TO_COORD = 1.0 / TILE_SIZE
RAD_2_DEG = 180.0 / Math::PI
DEG_2_RAD = Math::PI / 180.0
TWO_PI = Math::PI * 2.0
MAX_ZOOM = 20
module TileMaps
def lng_lat_to_mercator(lng, lat)
# turn degrees into radians
@RandomEtc
RandomEtc / circles.js
Created August 12, 2013 16:35
Sketch for a 'watch' function on d3 selctions...
var data = [ ],
width = 500,
height = 500,
id = 0;
function addRandom() {
data.push({
x: width * Math.random(),
y: height * Math.random(),
r: 10 * Math.random(),
@RandomEtc
RandomEtc / README.md
Last active December 17, 2015 05:59 — forked from mbostock/.block

An exploration of Mike Bostock's take on Ben Fry’s zipdecode, inspired by Nelson Minar’s reimplementation. This one uses deeply nested SVG elements and classes to target only the things that need to change.

Nesting the SVG made DOM creation bearable, but this is still too slow. Use Mike's canvas approach if you're looking for the "best" way to do this.

@RandomEtc
RandomEtc / README.md
Last active February 12, 2017 15:39
Advanced object constancy.

Fine-grained control of randomly entering and exiting things in D3.js, for impeccable object constancy. Adapted from an example co-authored with Mike Bostock.

@RandomEtc
RandomEtc / README.md
Last active October 12, 2015 16:08 — forked from mbostock/.block
Tissot's Indicatrices
@RandomEtc
RandomEtc / convert.js
Created October 26, 2012 01:13
Simplify GeoJSON using d3-plugins/simplify (thanks @jasondavies for preserving topology!)
// TODO: options parser with overrides for projection, area etc.
if (process.argv.length != 4) {
console.error("usage: node convert.js <input.json> <output.json>");
process.exit(1);
}
require('d3')
require('./node_modules/d3-plugins/simplify/simplify.js')
var fs = require('fs');
@RandomEtc
RandomEtc / README.md
Created October 18, 2012 18:37 — forked from johan/README.md
California earthquake responses by zip code
@RandomEtc
RandomEtc / config
Created August 1, 2012 23:45 — forked from bf4/config
campfire transcript export
---
BUNDLE_WITHOUT: ""
@RandomEtc
RandomEtc / shader.frag
Created July 26, 2012 23:53
direction shader for OpenCV flows
uniform sampler2D camTex;
uniform sampler2D xTex;
uniform sampler2D yTex;
// HSL functions from http://code.google.com/p/glmixer/source/browse/trunk/shaders/imageProcessing_fragment.glsl?spec=svn195&r=195
float HueToRGB(in float f1, in float f2, in float hue)
{
if (hue < 0.0)
hue += 1.0;