Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active April 6, 2020 10:58
Constrained Zoom
license: gpl-3.0
@freeformz
freeformz / WhyILikeGo.md
Last active October 6, 2022 23:31
Why I Like Go

A slightly updated version of this doc is here on my website.

Why I Like Go

I visited with PagerDuty yesterday for a little Friday beer and pizza. While there I got started talking about Go. I was asked by Alex, their CEO, why I liked it. Several other people have asked me the same question recently, so I figured it was worth posting.

Goroutines

The first 1/2 of Go's concurrency story. Lightweight, concurrent function execution. You can spawn tons of these if needed and the Go runtime multiplexes them onto the configured number of CPUs/Threads as needed. They start with a super small stack that can grow (and shrink) via dynamic allocation (and freeing). They are as simple as go f(x), where f() is a function.

@mbostock
mbostock / .block
Last active October 2, 2023 22:14
Zoom to Bounding Box
license: gpl-3.0
redirect: https://observablehq.com/@d3/zoom-to-bounding-box
@mbostock
mbostock / .block
Last active July 14, 2019 14:12 — forked from mbostock/.block
Gradient Encoding
license: gpl-3.0
redirect: https://observablehq.com/@d3/gradient-encoding
@ZJONSSON
ZJONSSON / README.md
Created October 19, 2012 13:59 — forked from mbostock/.block
d3.legend example

d3.legend

d3.legend is a quick hack to add a legend to a d3 chart. Simply add a g and .call(d3.legend). Any elements that have a title set in the "data-legend" attribute will be included when d3.legend is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.

Color

By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"

Order

The order of items in the legend will be sorted using the top of the bounding box for each included item. The order can be explicitly defined by attribute "data-legend-pos"

@mbostock
mbostock / .block
Last active December 6, 2019 22:03
Circular Segment
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/circular-segment
@bycoffe
bycoffe / README.md
Created August 20, 2012 14:39
Placing n elements around a circle with radius r

This demonstrates the math used to create the "seating chart"-style shapes on our House Outlook page.

@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@syntagmatic
syntagmatic / gist:2202660
Created March 26, 2012 03:30
Export CSV with Javascript
// assumes variable data, which is a homogenous collection of objects
// get keys
var keys = _.keys(data[0]);
// convert to csv string
var csv = keys.join(",");
_(data).each(function(row) {
csv += "\n";
csv += _(keys).map(function(k) {
@mbostock
mbostock / .block
Last active June 1, 2021 21:40
Histogram Chart
license: gpl-3.0