Skip to content

Instantly share code, notes, and snippets.

View duhaime's full-sized avatar

Douglas Duhaime duhaime

View GitHub Profile
@DavidBruant
DavidBruant / gist:6489486
Last active May 28, 2016 19:28
Breaking down attribute moves in d3 to fit in requestAnimationFrame
var moveItems = (function(){
var todoNode = 0;
var todoLink = 0;
var MAX_NODES = 240;
var MAX_LINKS = MAX_NODES/2;
var restart = false;
function moveSomeNodes(){
var n;
@anandology
anandology / seeds_view.py
Created November 10, 2010 04:49
Python Script to add design document to couchdb database
import couchdb
view = {
"_id": "_design/seeds",
"fulltext": {
"by_seed": {
"index": """function(doc) {
if (doc.seeds) {
var d = new Document();
for (var i=0; i<doc.seeds.length; i++) {
@ebidel
ebidel / gist:3723309
Created September 14, 2012 17:14
Spotlight bookmarklet
// Save this in a bookmarklet and click it on a page:
javascript:(function(){function d(a,c){document.body.style.webkitClipPath="circle("+a+"px, "+c+"px, "+b+"px)"}var b=90;window.addEventListener("mousemove",function(a){d(a.pageX,a.pageY)});window.addEventListener("mousewheel",function(a){if(a.shiftKey){a.preventDefault();var c=a.wheelDeltaY;b+=-c;b=0<c?Math.max(90,b):Math.min(b,window.innerHeight/2);d(a.pageX,a.pageY)}})})();
// Or paste this in the console and mouse over the page.
// SHIFT+mousewheel scroll makes the circle bigger/smaller.
(function() {
var radius = 90; // px
@DukeyToo
DukeyToo / decoded.js
Last active October 31, 2016 19:27
Optimized filter in es6 for decoding html values for angularjs when displaying in input or options
//simple filter to decode html-encoded values, for display in options or inputs
//optimized so that it doesn't redo the expensive decoding every time
myApp.filter('decoded', function() {
"use strict";
let e = null; //only init as-needed, and keep around
let cache = {};
function htmlDecode(input) {
if (cache[input]) {
@grossbart
grossbart / README.md
Last active September 8, 2017 11:21
Kinetoscope

A short code excerpt from this visualization I created for the longform article “Iouri Podladtchikov – You only fly once” by the Neue Zürcher Zeitung.

It's a very simple way to create an interactive animation based on video material. Hover over the image to go through the animation.

I used Final Cut Pro to crop and export the frames of a short video sequence, which I then stitched together into a single film strip using ImageMagick: convert folder-of-stills/* +append filmstrip.jpg

@Fil
Fil / .block
Last active September 9, 2017 02:09
K-Means as a force
license: gpl-3.0
height: 960
@puzzler10
puzzler10 / README.md
Last active September 12, 2017 02:30
Dancing Madness

This was made as an example of how to add elements to a SVG container upon mouse-click. Click in the rectangle and see what happens!

See http://www.puzzlr.org/?p=46 for a more detailed explanation and walkthrough of the code.

@mbostock
mbostock / README.md
Last active September 21, 2017 11:37
Force Dragging II

This example demonstrates using d3.drag with d3.forceCollide to implement draggable circles with collision detection.

@kylemcdonald
kylemcdonald / t-SNE Implementation Comparison.ipynb
Last active December 20, 2017 01:47
Comparison of different t-SNE implementations for speed and results.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@veltman
veltman / index.html
Created May 3, 2017 23:46
Gradual pixelation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<canvas width="960" height="500"></canvas>
<script>
var canvas = document.querySelector("canvas"),