Skip to content

Instantly share code, notes, and snippets.

View paxan's full-sized avatar

Pavel Repin paxan

  • aws.amazon.com
  • Seattle, WA
View GitHub Profile
@robcowie
robcowie / reservoir_sampling.py
Created August 27, 2012 11:29
Maintain a random sample from a sequence of unknown length (reservoir sampling)
from random import randint
from itertools import islice
def random_sample(sample_size, items):
"""Maintain an evenly distributed random sample of a population of
unknown size
The Reservoir Sampling Algorithm
(http://gregable.com/2007/10/reservoir-sampling.html)
"""
@lepture
lepture / emoji.py
Created March 10, 2012 15:54
emoji support in python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012, lepture.com
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
@cgbystrom
cgbystrom / node.js vs Python
Created December 1, 2010 20:56
node.js vs Python with Greenlets
/*
node.js vs Python with Greenlets (say gevent)
I don't get why node.js is being so hyped.
Sure, the idea of writing things in JavaScript both on the client and server-side is really nice.
And JavaScript really fit an event-driven environment with its browser heritage.
But why on earth is boomerang code so appealing to write? I don't get. Am I missing something obvious?
All examples of node.js I see are littered with callbacks yet Ryan Dahl thinks coroutines suck. It doesn't add up for me.