Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active August 2, 2019 22:07
Ordinal Brushing
license: gpl-3.0
redirect: https://observablehq.com/@d3/ordinal-brushing
@jstcki
jstcki / nest.rb
Created October 29, 2012 16:35
D3.js's nest operator in Ruby
# D3.js's nest operator in Ruby
class Nest
def initialize
# var nest = {}, keys = [], sortKeys = [], sortValues, rollup;
@nest = {}
@keys = []
@sort_keys = []
end
@vlandham
vlandham / console_2_json.js
Created August 21, 2012 18:38
Output Javascript variable from console to json
console.log(JSON.stringify(object_or_function));
@tmcw
tmcw / foursquare_to_geojson.py
Created August 20, 2012 20:53
Turn your Foursquare Data Archive into a GeoJSON file
import glob, json
# this script loves this script
# https://gist.github.com/3350235
points = []
vids = set()
places = glob.glob("checkins/*.json")
for p in places:
@tmcw
tmcw / foursquare_archive.py
Created August 14, 2012 15:19
Simple Foursquare Checkins Archive of one User
import requests, os, glob, json, sys, webbrowser
you = 'self'
data = 'checkins'
try: os.mkdir(data)
except Exception: pass
cid = 'YOUR_CLIENT_ID'
@drio
drio / README.md
Created January 22, 2012 14:53
Playing with pthreads

What's this?

I was/am in the process of adding multithreading capabilities to a tool I am working on (more on that soon). The tool is written in C/C++. My first option was using POSIX threads (pthreads) before going into higher level options like boost.

I first read this

@mbostock
mbostock / server.js
Created December 12, 2011 18:38
Node + MySQL + JSON
process.env.TZ = "UTC";
var util = require("util"),
express = require("express"),
gzip = require("connect-gzip"),
mysql = require("mysql");
var client = mysql.createClient({
host: /* mysql host, e.g., "host.example.com" */,
port: /* mysql port, e.g., 3306 */,
@vlandham
vlandham / parse_interviews.rb
Created October 2, 2011 20:03
parse usesthis.com
#!/usr/bin/env ruby
require 'yaml'
require 'json'
input_dirname = ARGV[0]
output_filename = "parsed_interviews.json"
class Categorizer
HW_CATEGORIES = [[/.*dell.*/, ["pc","system"]],
@caged
caged / gist:1173725
Created August 26, 2011 15:50
d3.js experiment - Donuts, Bars and Crime.
#
# CoffeeScript for http://dealloc.me/demos/crime/2011.html
# Copyright (c) 2011 Justin Palmer <http://github.com/Caged>
# LICENSE: http://www.opensource.org/licenses/mit-license.php
$ ->
hash = document.location.hash
year = if hash then hash.replace('#', '') else 2011
[pt,pl,pb,pr] = [35, 20, 20, 20]
w = (900 - (pl + pr)) / 2
h = w
@huyng
huyng / matplotlibrc
Created February 8, 2011 15:50
my default matplotlib settings
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).