Skip to content

Instantly share code, notes, and snippets.

View paulwe's full-sized avatar

Paul Wells paulwe

  • Mountain View, California
View GitHub Profile
@paulwe
paulwe / lossy_counting.py
Last active August 29, 2015 14:27 — forked from kurtbrose/lossy_counting.py
"Lossy Counting" Heavy-Hitters algorithm from "Approximate Frequency Counts over Data Streams" by Manku & Motwani
class LossyCounting(object):
'''
Implements the "lossy counting" algorithm from
"Approximate Frequency Counts over Data Streams" by Manku & Motwani
Experimentally run-time is between 1-3 microseconds on core i7
'''
def __init__(self, epsilon=0.001):
self.n = 0
self.d = {} # {key : (count, error)}
<script src="http://www.cedexis.com/widget.js"></script>
<a class="radar-report" width="320" href="http://cedexis.com/country-reports">Cedexis Radar Reports</a>
var express = require('express')
, cp = require('child_process')
, app = express()//require('app')
, router = ''//require('./lib/proxy-client').connect('10.0.0.4')
, hostname = '';
router = new (function() {
return {
allocate: function() {
console.log('...');
@paulwe
paulwe / page.htm
Created April 9, 2012 03:04
page and post templates
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>elowel.org: have fun, be creative, don't die</title>
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=utf-8" />
<link rel="stylesheet" media="screen" href="/elowelcss9_27_07.css" type="text/css" />
<link rel="stylesheet" media="handheld" href="/elowelcss9_27_07hh.css" type="text/css" />
</head>
<body class="logged_%logged_in%">
var Q = require('q')
, components = {}
, dependencies = {};
module.exports.require = function(dependency, callback) {
Q.all(getDependencies(dependency)).then(callback);
}
module.exports.resolve = function(dependency) {
var value = dependency in dependencies ? Q.all(dependencies[dependency]) : true;
var mongoose = require('mongoose');
var TestSchema = new mongoose.Schema();
TestSchema.static('test', function(schema) {
schema.static('subTest', function() {
console.log('win');
});
});
@paulwe
paulwe / gist:1384326
Created November 21, 2011 23:25
express dateFormat helper
app.helper({
dateFormat: function(date) {
return dateFormat(date, "dddd, mmmm dS, yyyy, h:MM:ss TT");
}
});
var http = require('http')
, net = require('net');
var proxy = http.createServer(function(req, res) {
handleRequest(req, req.connection);
}).on('upgrade', handleRequest);
function handleRequest(req, sock, head) {
var sub = net.createConnection(8008, '10.0.0.208')