Skip to content

Instantly share code, notes, and snippets.

View hayd's full-sized avatar
😎
chillin'

Andy Hayden hayd

😎
chillin'
View GitHub Profile
@hayd
hayd / inspect.py
Created March 27, 2015 23:10
inspect.py
"""Get useful information from live Python objects.
This module encapsulates the interface provided by the internal special
attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion.
It also provides some help for examining source code and class layout.
Here are some of the useful functions provided by this module:
ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),
isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),
def foo():
print("one tab")
print("eight spaces")

test

@hayd
hayd / README.md
Created December 13, 2013 00:59 — forked from mbostock/.block
@hayd
hayd / README.md
Last active December 31, 2015 04:59

test

@hayd
hayd / week1
Last active December 18, 2015 09:49
spectral stuff
import numpy as np
from numpy.fft import fft, fftshift, ifft, fftfreq
L = 10
n = 128
x2 = np.linspace(-L, L, n + 1)
x = x2[1:]
# k = (2 * np.pi / L) * np.concatenate((np.arange(0, n/2), np.arange(-n/2 + 1, 1)))
@hayd
hayd / python-primes-generator.py
Created September 14, 2012 11:54
Primes generator function
class primes():
def __init__(self):
self.primes_list = [2,3]
self.generator = self.generator()
def _append_if_no_prime_divides(self,q):
is_prime = not any( q % p == 0 for p in self.primes_list)
if is_prime:
self.primes_list.append(q)
return is_prime
@hayd
hayd / pdf_fuzz.py
Created July 20, 2012 09:15 — forked from kedarbellare/pdf_fuzz.py
PDF Fuzzer
file_list = ["10.1.1.111.1781.pdf", "10.1.1.111.5264.pdf", "10.1.1.39.1596.pdf", "10.1.1.41.8589.pdf", "10.1.1.42.5619.pdf"]
apps_list = [
"/Applications/Adobe Reader 9/Adobe Reader.app/Contents/MacOS/AdobeReader",
"/Applications/Adobe Reader.app/Contents/MacOS/AdobeReader",
"/Applications/Preview.app/Contents/MacOS/Preview"]
fuzz_output = "fuzz.pdf"
FuzzFactor = 250
@hayd
hayd / EnvironmentHierarchy.py
Created July 19, 2012 14:07
Environment hierarchy - g can see f's variable a
def f():
a=1
def g():
print a
g()
f()
@hayd
hayd / scope_test.py
Created July 19, 2012 11:55
grabbing f's environment from within g
def f():
a = 2
b = 1
def g():
#a = 3
b = 2
c = 1
print dict(globals(), **locals()) #prints a=1, but we want a=2 (from f)
g()
a = 1