Skip to content

Instantly share code, notes, and snippets.

@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).
@emeeks
emeeks / edgelist.csv
Last active Mar 1, 2021
Arc Diagram with Directed Edges
View edgelist.csv
source target weight
sam tully 3
sam pat 8
sam kim 2
sam pris 1
roy pris 5
roy sam 1
tully sam 1
tully pris 5
tully kim 3
@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 */,
@mjhoy
mjhoy / Makefile
Last active Sep 30, 2019
Costa Rica shaded relief
View Makefile
all: hill-relief.jpg costarica_min_topo.json
# -------------
# Relief raster
# -------------
#
# Notice the `zip` file requirements here have no download.
# You will need to search for them online. They are from the
# SRTM project: http://www2.jpl.nasa.gov/srtm/
# (which appears to have multiple versions of files).
@mbostock
mbostock / .block
Last active Aug 2, 2019
Ordinal Brushing
View .block
license: gpl-3.0
redirect: https://observablehq.com/@d3/ordinal-brushing
@emeeks
emeeks / edgelist.csv
Last active Jul 6, 2019
Adjacency Matrix from Node/Edge List
View edgelist.csv
sam tully 3
sam pat 8
sam kim 2
sam pris 1
roy pris 5
roy sam 1
tully sam 1
tully pris 5
tully kim 3
@gka
gka / textWidth.js
Created Nov 14, 2013
Approximate text width based on estimated character widths...
View textWidth.js
var textWidth = (function() {
function charW(w, c) {
if (c == 'W' || c == 'M') w += 15;
else if (c == 'w' || c == 'm') w += 12;
else if (c == 'I' || c == 'i' || c == 'l' || c == 't' || c == 'f') w += 4;
else if (c == 'r') w += 8;
else if (c == c.toUpperCase()) w += 12;
else w += 10;
return w;
}
@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