This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'), | |
fs = require('fs'); | |
var writeStream = fs.createWriteStream('bz2.bz2'); | |
request({ | |
url: 'http://planet.openstreetmap.org/changesets-120801.osm.bz2', | |
proxy: process.env.HTTP_PROXY | |
}, function() {}).pipe(writeStream); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Gyp = require('node-gyp') | |
var gyp = Gyp() | |
gyp.parseArgv([]) | |
// run "clean", "configure", then "build" | |
gyp.commands.clean([], function (err) { | |
console.error('clean', arguments); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mitsuhiko at atherton in ~ exited 2 on git:master? workon fireteam-sandbox | |
$ python -mtimeit -s 'from marshal import dumps, loads; x = [[1, 2, 3], [4, 5, 6]]' 'loads(dumps(x))' | |
1000000 loops, best of 3: 1.16 usec per loop | |
mitsuhiko at atherton in ~ on git:master? workon fireteam-sandbox | |
$ python -mtimeit -s 'from copy import deepcopy; x = [[1, 2, 3], [4, 5, 6]]' 'deepcopy(x)' | |
10000 loops, best of 3: 20 usec per loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, os, glob, json, codecs | |
# requires requests. pip install requests | |
you = 'tmcw' | |
data = 'gists' | |
try: os.mkdir(data) | |
except Exception: pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To make the benchmark results predictable, we replace Math.random | |
// with a 100% deterministic alternative. | |
Math.random = (function() { | |
var seed = 49734321; | |
return function() { | |
// Robert Jenkins' 32 bit integer hash function. | |
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; | |
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; | |
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; | |
seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD 150,000 ns 0.15 ms | |
Read 1 MB sequentially from memory 250,000 ns 0.25 ms | |
Round trip within same datacenter 500,000 ns 0.5 ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#countries { | |
::shadow1, ::shadow2, ::shadow3 { | |
line-color: #024; | |
line-join: round; | |
} | |
::shadow1 { | |
line-opacity: 0.03; | |
line-width: 7; | |
} | |
::shadow2 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load some built-in modules | |
var HTTP = require('http'), | |
HTTPS = require('https'), | |
ChildProcess = require('child_process'), | |
QueryString = require('querystring'), | |
FS = require('fs'); | |
// Load some npm community modules | |
var Stack = require('stack'), | |
Wheat = require('wheat'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OSMUSER="coleman"; curl -s "www.overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D%3B%28node%28user%3A%22$OSMUSER%22%29%3Bway%28user%3A%22$OSMUSER%22%29%3Brelation%28user%3A%22$OSMUSER%22%29%3B%29%3Bout%3B" | ruby -e "require 'json'; osm = JSON.parse(STDIN.read); nodes = osm['elements'].select {|e| e['type'] == 'node'}; ways = osm['elements'].select {|e| e['type'] == 'way'}; relations = osm['elements'].select {|e| e['type'] == 'relation'}; puts ''; puts 'stats for $OSMUSER:'; puts 'nodes: ' + nodes.count.to_s; puts 'ways: ' + ways.count.to_s; puts 'relations: ' + relations.count.to_s; puts ''" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var serverConnections = 0; | |
var clientConnections = 0; | |
// Server: accept connections and set keep-alive | |
net.createServer(function(socket) { | |
socket.setKeepAlive(true, 0); // <----- | |
serverConnections++; | |
console.log(serverConnections); |