Skip to content

Instantly share code, notes, and snippets.

View w8r's full-sized avatar
💭
learning

Alexander Milevski w8r

💭
learning
View GitHub Profile
@w8r
w8r / domtokenlist.js
Last active December 30, 2015 10:19
IE10+ DOMTokenList fix
/**
* IE 10 + supports ClassList, but the standards are vague. It is extremely
* convenient to add several classnames at once, FF and Chrome support that.
*
* @author Alexander Milevski <info@w8r.name>
*
* https://gist.github.com/w8r/fbdbfea078629ff913d4
*
* MIT License
*
@w8r
w8r / hosts
Last active August 29, 2015 14:08 — forked from dlo/hosts
255.255.255.255 006.free-counter.co.uk
255.255.255.255 006.freecounters.co.uk
255.255.255.255 06272002-dbase.hitcountz.net # Web bugs in spam
255.255.255.255 09killspyware.com
255.255.255.255 0stats.com
255.255.255.255 1.adbrite.com
255.255.255.255 1.httpads.com
255.255.255.255 1.primaryads.com
255.255.255.255 102.112.2o7.net
255.255.255.255 102.122.2o7.net
var simplifyPath = function( points, tolerance ) {
// helper classes
var Vector = function( x, y ) {
this.x = x;
this.y = y;
};
var Line = function( p1, p2 ) {
this.p1 = p1;
/**
*
* Hooking up Watchify with Google's Web Starter Kit
*
* The primary use cases for Browserify/Watchify are:
* - Node.js-style `require`s on the client-side
* - Use of npm modules on the client-side
* - No more new <script> tags for each new script/module
*
* 1. npm install --save-dev vinyl-source-stream browserify watchify gulp-notify
@w8r
w8r / README.md
Last active August 29, 2015 14:23 — forked from mbostock/.block

Click and drag above to paint red hexagons. A black outline will appear around contiguous clusters of red hexagons. This outline is constructed using topojson.mesh, part of the TopoJSON client API. A filter is specified so that the mesh only contains boundaries that separate filled hexagons from empty hexagons.

The hexagon grid itself is represented as TopoJSON, but is constructed on-the-fly in the browser. Since TopoJSON requires quantized coordinates, the hexagon grid is represented as integers, with each hexagon of dimensions 3×2. Then a custom projection is used to transform these irregular integer hexagons to normal hexagons of the desired size.

@w8r
w8r / index.js
Created July 3, 2015 07:58
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var L = require('leaflet');
console.log(L);
@w8r
w8r / map.geojson
Last active August 29, 2015 14:24
DOGE spotting
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
gistup
@w8r
w8r / L.SvgScaleOverlay.js
Last active January 11, 2016 15:57 — forked from Sumbera/L.SvgScaleOverlay.js
SVG scaled overlay in Leaflet
/*
Stanislav Sumbera, August , 2015
- scaled SVG draw prototype on top of Leaflet 1.0 beta
- note it uses L.map patch to get it working right
- SVG data are not modified, only scaled and optionaly radius/stroke width etc. can be specified on onScaleChange callback
- very experimental
*/
//-- Patch to get leaflet properly zoomed
@w8r
w8r / laplacian.js
Created January 6, 2017 12:36
Graph Laplacian
function laplacian(G, N) {
var L = new Array(N);
for (var i = 0; i < N; i++) {
var row = new Array(N);
var node = G.nodes[i];
for (var j = 0; j < N; j++) {
if (i === j) {
row[j] = node.edges.length;
} else {
row[j] = (node.edges.indexOf(j) === -1) ? -1 : 0;