Skip to content

Instantly share code, notes, and snippets.

@Ayrx
Ayrx / prime_sieve.py
Created June 25, 2013 12:46
Sieve of Eratosthenes
def gen_prime_sieve(n):
# Implementation uses the Sieve of Eratosthenes
# Optimized code from: http://stackoverflow.com/a/3941967/1170681
a = [True] * n
a[0] = a[1] = False
for (i, isprime) in enumerate(a):
if isprime:
@Ayrx
Ayrx / scrapecomments.py
Created June 16, 2013 08:23
This is a simple python script to scrape comments from a web page.
#!/usr/bin/env python
import argparse
import urllib
import urlparse
from HTMLParser import HTMLParser
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('url')
args = arg_parser.parse_args()