Skip to content

Instantly share code, notes, and snippets.

@nbremer
nbremer / .block
Last active December 27, 2024 17:17
Spirograph drawer - Animating solid and dashed lines
height: 900
// This gist is deprecated, doesn't work with newer versions of JSDom.
// Instead, use https://www.npmjs.com/package/highcharts-jsdom
@mbostock
mbostock / .block
Last active January 16, 2020 09:23
Percentage Change II
license: gpl-3.0
@tmylk
tmylk / ldamodel.py
Last active May 2, 2016 22:08
heavily logged versions of LDA in sklearn and gensim to enable comparison
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Radim Rehurek <[email protected]>
# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html
#
# Parts of the LDA inference code come from Dr. Hoffman's `onlineldavb.py` script,
# (C) 2010 Matthew D. Hoffman, GNU GPL 3.0
@robinfhu
robinfhu / README.md
Last active September 10, 2023 10:53

Chart tooltips using quadtrees

Adding tooltip interactivity to charts is one of the most desired features, but also one of the tricker ones to implement. One common solution is to attach .on('mouseover') event handlers to each circle element. This will work okay, except when points start overlapping. You will also start using up lots of memory if the number of points is very large.

A more advanced technique is to use d3.geom.voronoi. This solves the problem of overlapping points, but you still run into performance issues. That's because

@mbostock
mbostock / .block
Last active March 23, 2018 08:44
Connected Particles II
license: gpl-3.0
@yelouafi
yelouafi / adt.js
Created April 24, 2015 11:31
Algebraic Data Types in javascript (see http://tech.pro/blog/6885/javascript-and-type-thinking)
function eachKey(obj, f) {
for(var key in obj) {
if( obj.hasOwnProperty(key) )
f(key, obj[key]);
}
}
function adtcase (base, proto, key) {
return (...args) => {
var inst = new base();
var AmpersandCollection = require('ampersand-collection'),
_ = require('underscore'),
AmpersandRestCollection = _.clone(require('ampersand-collection-rest-mixin')),
sync = require('./sync'),
Search = require('./search'),
EJSON = require('mongodb-extended-json'),
AmpersandModel = require('ampersand-model');
var MongoDBCollection = AmpersandCollection.extend(AmpersandRestCollection, {
fetched: false,
/*
The MIT License (MIT)
Copyright (c) 2014
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
@jdiaz5513
jdiaz5513 / ampersand-link-collection-state.js
Created January 16, 2015 18:24
Linked collection state for ampersand-state