Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active Aug 2, 2019
Ordinal Brushing
View .block
license: gpl-3.0
redirect: https://observablehq.com/@d3/ordinal-brushing
@herrstucki
herrstucki / nest.rb
Created Oct 29, 2012
D3.js's nest operator in Ruby
View nest.rb
# 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 Aug 21, 2012
Output Javascript variable from console to json
View console_2_json.js
console.log(JSON.stringify(object_or_function));
@tmcw
tmcw / foursquare_to_geojson.py
Created Aug 20, 2012
Turn your Foursquare Data Archive into a GeoJSON file
View foursquare_to_geojson.py
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 Aug 14, 2012
Simple Foursquare Checkins Archive of one User
View foursquare_archive.py
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 Jan 22, 2012
Playing with pthreads
View README.md

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 Dec 12, 2011
Node + MySQL + JSON
View server.js
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 */,
View parse_interviews.rb
#!/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 Aug 26, 2011
d3.js experiment - Donuts, Bars and Crime.
View gist:1173725
#
# 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 Feb 8, 2011
my default matplotlib settings
View matplotlibrc
### 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).