Skip to content

Instantly share code, notes, and snippets.

@ericsoco
ericsoco / wtfjs_-%=.js
Created October 1, 2014 17:29
wtfjs: negative mod, equality
// Check if a thing is rotated 90°.
function isRotatedOffAxis (rotation) {
return rotation % 180 !== 0;
}
// Hm, what about -180?
console.log(-180 % 180); // -0. wtf #a
// So then why is this ok?
isRotated(-180); // false
@ericsoco
ericsoco / ObjectID.as
Created April 2, 2012 22:41
Update of Mongo's ObjectID for ActionScript (from ActionBSON)
/*
* Copyright (c) 2010 Claudio Alberto Andreoni.
* Modifications by Eric Socolofsky: http://transmote.com.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@ericsoco
ericsoco / gist:c42ec1fa7582a968904f
Created October 30, 2015 22:28
richmond-canals npm ls
├─┬ @panorama/toolkit@0.0.12
│ ├── koto@0.1.3
│ └─┬ topojson@1.6.19
│ ├── d3-geo-projection@0.2.15
│ ├─┬ optimist@0.3.7
│ │ └── wordwrap@0.0.3
│ ├── rw@0.1.4
│ └─┬ shapefile@0.3.0
│ └── iconv-lite@0.2.11
├─┬ babel-eslint@4.1.3
@ericsoco
ericsoco / gist:44efa8d033588324b337
Last active December 1, 2015 23:13
interpolator in need of interpolation
// use of interpolator:
selection.transition()
.attrTween('d', areaGenerator)
// interpolator:
areaGenerator = function (d) {
// do I need a d3.interpolate call here, sim. to https://gist.github.com/mbostock/5100636#file-index-html-L66 ?
return function (t) {
return d3.svg.area()
.x(d => xScale(d.x))
@ericsoco
ericsoco / README.md
Last active December 18, 2015 17:30
Polar Plot

This example demonstrates the construction of a polar plot of a parametric function, sin(2t)cos(2t). A d3.svg.line.radial is used to draw the red line. Note the definition of the line’s angle: D3’s radial lines and areas proceed clockwise starting at 12 o’clock, while this plot proceeds counterclockwise starting at 3 o’clock!

forked from mbostock's block: Polar Plot

bgw-test-geojson ericsocolofsky$ rm -rf bluegreenway/
bgw-test-geojson ericsocolofsky$ git clone git@github.com:stamen/bluegreenway.git
Cloning into 'bluegreenway'...
remote: Counting objects: 1399, done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 1399 (delta 14), reused 0 (delta 0), pack-reused 1357
Receiving objects: 100% (1399/1399), 43.02 MiB | 5.64 MiB/s, done.
Resolving deltas: 100% (891/891), done.
Checking connectivity... done.
bgw-test-geojson ericsocolofsky$ cd bluegreenway/
@ericsoco
ericsoco / gist:5712076f69f9068b11d41262b9e93666
Created July 13, 2016 19:28
eliminate map tile seams in Leaflet 1.0
import leaflet from 'leaflet';
// ...
patchMapTileGapBug();
// ...
function patchMapTileGapBug () {
// Workaround for 1px lines appearing in some browsers due to fractional transforms
// and resulting anti-aliasing. adapted from @cmulders' solution:
// https://github.com/Leaflet/Leaflet/issues/3575#issuecomment-150544739
let originalInitTile = leaflet.GridLayer.prototype._initTile;
@ericsoco
ericsoco / .block
Created August 3, 2016 04:32
Brush Snapping
license: gpl-3.0
@ericsoco
ericsoco / .block
Last active September 22, 2016 06:13
Hexagon Mesh
license: gpl-3.0
@ericsoco
ericsoco / .block
Last active September 24, 2016 06:17
Simulation.find() multiple
license: mit