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 pprint import pprint | |
import array | |
import time | |
# Ancillary functions | |
def timing(function=None, loops=50, input_data): | |
print function.__name__, | |
r = range(loops) | |
t1 = time.clock() | |
for i in r: |
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
known_primes = [ 2, 3, 5, 7, 11, 13] | |
#known_primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, | |
# 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] | |
import itertools as it | |
def give_me_primes(limit=100000000000000000000000L): | |
last_prime = 1 | |
for n in it.ifilter(lambda x: x<limit, known_primes): | |
last_prime = n | |
yield last_prime | |
for p_candidate in it.takewhile(lambda x: x<limit,it.ifilter(lambda x: x%2==1, it.count(n+1))): |
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
def fibonacci(): | |
a, b = 1, 1 | |
while True: | |
yield a | |
a, b = b, a + b |
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
# This function allows you to drag and drop a file to the terminal, and use cdf to cd to the path containing the file. | |
# cdf (cd to file) | |
cdf() { | |
dest_dir=`dirname "$1"` | |
cd "$dest_dir" | |
} | |
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 | |
from jama import API as jama_api | |
import sys | |
from pprint import pprint | |
import webbrowser | |
# See the needs for the jama.API constructor in the project page: | |
# https://github.com/DynamicControls/python-jama | |
jama_client = jama_api() |
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 | |
# Trying to create the transformation from scratch | |
import sys # For getting stdin | |
from string import maketrans # For creating the transformation | |
# build the lowercase letters from a to z | |
letters = "".join([chr(ord("a")+x) for x in xrange(0,26)]) | |
# rotate them by taking the last 13, and the first 13 | |
rot13letters = letters[13:]+letters[:-13] | |
# concatenate the uppercase version of both strings after the lowercase |
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
#!/bin/bash | |
# Encode a WAV to a finalized podcast MP3 with metadata, in the current directory | |
# Requires lame | |
# With Homebrew on Mac OS X: brew install lame | |
SHOW_AUTHOR="ATP" | |
EPISODE_NUMBER=104 | |
EPISODE_TITLE="Minutiæ" |
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
import numpy as np | |
randomFile = open("/dev/random", "rb") # open for reading, binary | |
#define an integer type for reading | |
intType = np.dtype([('random', int)]) | |
randomList = np.fromfile(randomFile,dtype=intType, count=10) | |
# Random generator | |
def random_int_generator(randomFile=randomFile): | |
yield np.fromfile(randomFile,dtype=intType, count=1)[0][0] |
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
# -*- coding: utf-8 -*- | |
"""magics for using blockdiag.com modules with IPython Notebook | |
The module provides magics: %%actdiag, %%blockdiag, %%nwdiag, %%seqdiag | |
Sample usage (in IPython cell): | |
%%blockdiag | |
{ | |
A -> B -> C; |
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
digraph Organigram { | |
/* General Layout */ | |
rankdir = LR; | |
/* Layout Nodes */ | |
OlderNewer