This file contains 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
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) | |
""" |
This file contains 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
#!/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 |
This file contains 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
/* | |
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. |
NewerOlder