Skip to content

Instantly share code, notes, and snippets.

View springmeyer's full-sized avatar

Dane Springmeyer springmeyer

View GitHub Profile
@aaronpk
aaronpk / github-post-receive.rb
Created April 8, 2012 19:53
Automatically configure post-receive hooks on all your Github repositories
require 'json'
require 'uri'
require 'httpclient'
require 'redis'
require 'mw-irc'
# First, get an access token for your account on the command line
# curl -d '{"scopes":["repo"],"note":"Post-Receive Hooks"}' -u 'username:******' https://api.github.com/authorizations
# Paste your access token here
/*
In a child process, each of the stdio streams may be set to
one of the following:
1. A new file descriptor in the child, dup2'ed to the parent and
exposed to JS as a Stream object.
2. A copy of a file descriptor from the parent, with no other
added magical stuff.
3. A black hole - no pipe created.
@bmander
bmander / polyline.js
Created April 13, 2012 04:31
polynomial line fitting
function translate(tx, ty, func){
return function(x,y){
var xprime = x-tx;
var yprime = y-ty;
return func(xprime,yprime);
}
}
function rotate(theta, func){
@pamelafox
pamelafox / util.js
Created April 13, 2012 17:44
JavaScript Utility Libraries (Scroll down!)
var ED = ED || {};
// Utility functions
ED.util = (function() {
// Data structure functions
function each(object, callback) {
if (object === null) return;
// run with "node --expose_gc"
var weak = require('weak')
, util = require('util')
var count = 0
, countGc = 0
function dec () {
count--
@mojodna
mojodna / gist:2473893
Created April 23, 2012 21:10
Backup GitHub issues
"use strict";
var fs = require("fs"),
https = require("https"),
url = require("url"),
zlib = require("zlib");
/**
* Process HTTP responses. Handle compressed streams and convert to objects as
* appropriate.
@perrygeo
perrygeo / nearest_features.py
Created April 25, 2012 21:51
Find the nearest point features in a shapefile to a given coordinate
import numpy as np
from scipy.spatial import KDTree
from fiona import collection
def nearest_features(datasource, x, y, n=1):
"""
datasource: The ogr datasource path
x, y: coordinates to query for nearest
n: number of features (default = 1 or the single nearest feature)
var cluster = require('cluster')
if (cluster.isMaster) {
// spawn worker bees
cluster.fork()
cluster.fork()
cluster.fork()
cluster.fork()
} else {
// worker bees only need root to listen, and then downgrade
@tschaub
tschaub / split.js
Created May 4, 2012 14:21
quick implementation of polygon splitting process
// Execute method for js:split process expects polygon and line geometries as input
run: function(inputs) {
var merger = new LineMerger();
merger.add(inputs.poly._geometry);
merger.add(inputs.line._geometry);
var collection = merger.getMergedLineStrings();
var union = new UnaryUnionOp(collection).union();
var polygonizer = new Polygonizer();
polygonizer.add(union);
@brendangregg
brendangregg / gist:2670942
Created May 13, 2012 02:42
node.js fs.readFile analysis
Here's some more perf analysis: what was the limiter for node.js in the original fs.readFile benchmark,
causing large performance difference?
Examining thread microstates using prstat (SmartOS):
# prstat -mLcp 92432 1
Please wait...
[...]
PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID
92432 root 90 10 0.0 0.0 0.0 0.0 0.0 0.0 7 9 42K 0 node/1