Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active February 9, 2016 01:52
Extending Arcs
license: gpl-3.0
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
var Collection = require("ampersand-rest-collection");
var Model = require("ampersand-model");
var Product = Model.extend({
props: {
name: 'string',
price: 'integer'
}
});
@monsieurBelbo
monsieurBelbo / caba.json
Last active March 31, 2017 10:48
Calculate area of clipped Voronoi region
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbostock
mbostock / .block
Last active May 14, 2026 18:02
Perspective Transformation
license: gpl-3.0
@llb4ll
llb4ll / README.md
Last active June 17, 2023 09:48 — forked from patricksurry/README.md
k-nearest-neighbor search using D3 quadtrees

This example was inspired by patricksurry's D3JS quadtree nearest neighbor algorithm and finds the k-nearest neighbors (shown red) of a new point (shown yellow) using D3's Quadtrees. Orange points are visited but not selected. k is fixed to 10 for this demo.

Choose a new point to classify by clicking on the diagram.

The algorithm is based on one very simple but effective incremental approach first proposed by Hjaltason and Samet in their Ranking in Spatial Databases in 1995.

@mbostock
mbostock / .block
Last active July 17, 2020 06:44 — forked from mbostock/.block
Multi-Line Voronoi
license: gpl-3.0
redirect: https://observablehq.com/@d3/multi-line-chart
@dgerber
dgerber / Makefile
Last active May 2, 2017 22:00
Reusable Non-Contiguous Cartogram
swiss-cantons.topo.json: lib/swiss-maps/topojson/swiss-cantons.json
topojson --properties --id-property abbr \
-o $@ \
lib/swiss-maps/topojson/swiss-cantons.json
@balamuru
balamuru / gensim_scikit_kmeans.py
Last active December 27, 2019 10:52
gensim + scikit clustering vs scipy clustering (DEBUG)
import logging
from scipy.odr import models
from sklearn import metrics
import unittest
import os
import os.path
import tempfile
import numpy
from matplotlib.pyplot import plot, show
@mbostock
mbostock / .block
Last active October 22, 2018 01:30 — forked from mbostock/.block
Hexagonal Binning (Area)
license: gpl-3.0
redirect: https://beta.observablehq.com/@mbostock/d3-hexbin-area