Skip to content

Instantly share code, notes, and snippets.

@markhamilton1
markhamilton1 / daemon.py
Created March 23, 2014 23:26
daemon is a Python module that helps in the development of daemon processes.
"""
The daemon module implements the support classes for creating daemon processes.
Classes:
Daemon - base class for constructing a daemon process
"""
import sys, os, time, atexit
from signal import SIGTERM
@markhamilton1
markhamilton1 / prime.py
Created March 23, 2014 00:55
prime is a Python script that calculates prime numbers and then looks for prime types.
"""
Functions:
calc - calculate the specified number of primes starting with 2
findTypes - find the types in the current list of primes
"""
from math import sqrt
primeList = [2]
gapList = []
@markhamilton1
markhamilton1 / pi.py
Created March 23, 2014 00:48
pi is a Python script that computes each digit of the value of pi. As long as this script runs it continues to generate digits. As a matter of full disclosure, I did not write this. I am posting it here as a means of preserving the algorithm and making it available to others.
import sys
def calcPi():
q, r, t, k, n, l = 1, 0, 1, 1, 3, 3
while True:
if 4*q+r-t < n*t:
yield n
nr = 10*(r-n*t)
n = ((10*(3*q+r))//t)-10*n
q *= 10