Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
#
# find-duplicates
# by Keith Gaughan <http://talideon.com/>
#
# Finds an lists any duplicate files in the given directories.
#
# Copyright (c) Keith Gaughan, 2008.
# All Rights Reserved.
#
@michalmarczyk
michalmarczyk / sieve.py
Created January 7, 2010 22:40
priority queue-based, wheel-using incremental prime number sieve in Python
# A priority queue-based, wheel-using incremental Sieve of Eratosthenes.
# See `The Genuine Sieve of Eratosthenes' by Melissa E. O'Neill
# (http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf)
# for the Haskell incremental sieve which inspired this implementation
# (along with detailed analyses of performance of several Haskell
# sieves).
#
# Usage:
# Sieve() -> simple SoE
# Sieve(Wheel(4)) -> SoE + a wheel based on 4 initial primes
@chrisjacob
chrisjacob / README.md
Created February 18, 2011 03:44
Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Intro

Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Author: Chris Jacob @_chrisjacob

Tutorial (Gist): https://gist.github.com/833223

The Result

Copyright (c) 2012, Miguel Araujo
All rights reserved.
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 notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
@rubik
rubik / badmo.py
Created April 20, 2011 10:38
Bad modules detector (modules imported but not used)
import re
import os
import ast
import glob
import collections
class ImportVisitor(ast.NodeVisitor):
def __init__(self):
self.imports = []
self.modules = collections.defaultdict(list)
@rik0
rik0 / AtkinSieveArray.java
Created July 22, 2011 11:16
Lots of Atkin and some Erat
import java.lang.Boolean;
import java.lang.Integer;
public class AtkinSieveArray {
static private int count(boolean[] buffer) {
int counter = 0;
for(int i = 2; i < buffer.length; ++i) {
if(buffer[i]) {
counter++;
@sontek
sontek / snowjob.py
Created December 22, 2011 04:24
Make your terminal snow with python
#!/usr/bin/env python
import os
import random
import time
import platform
snowflakes = {}
try:
# Windows Support
@rubik
rubik / gisty.py
Created July 9, 2012 19:53
Example command line program powered by Baker and other cool libraries (pathlib, slumber & colorama)
import sys
import baker
import slumber
import pathlib
import colorama
API_URL = 'https://api.github.com/'
def get_api(auth=None):
@mikelikespie
mikelikespie / argbase.py
Created July 28, 2012 05:34
Interface for Argparse Similar to Declarative base
import abc
import re
import argparse
class ArgBaseError(Exception): pass
def _inject_vals(name, bases, dict):
expected_args = {}
@ndarville
ndarville / secret-key-gen.py
Created August 24, 2012 17:01
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`