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
Python 2.7.8 (default, Oct 18 2014, 12:50:18) | |
[GCC 4.9.1] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> def distance(p1, p2): | |
... # this just uses the Pythagorean Theorem | |
... x = (p1[0] - p2[0]) ** 2 | |
... y = (p1[1] - p2[1]) ** 2 | |
... return (x + y) ** 0.5 | |
... | |
>>> def herons(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
Python 2.7.8 (default, Oct 18 2014, 12:50:18) | |
[GCC 4.9.1] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import sympy | |
>>> x1, x2, x3 = sympy.symbols('x1 x2 x3') | |
>>> y1, y2, y3 = sympy.symbols('y1 y2 y3') | |
>>> | |
>>> def distance(p1, p2): | |
... # still using the Pythagorean Theorem | |
... x = (p1[0] - p2[0]) ** 2 |
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/python2.7 | |
# imports and basic notebook setup | |
from cStringIO import StringIO | |
import numpy as np | |
import scipy.ndimage as nd | |
import PIL.Image | |
from IPython.display import clear_output, Image, display | |
from google.protobuf import text_format |
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/python2.7 | |
# imports and basic notebook setup | |
from cStringIO import StringIO | |
import numpy as np | |
import scipy.ndimage as nd | |
import PIL.Image | |
from IPython.display import clear_output, Image, display | |
from google.protobuf import text_format |
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
# imports and basic notebook setup | |
from cStringIO import StringIO | |
import numpy as np | |
import scipy.ndimage as nd | |
import PIL.Image | |
from IPython.display import clear_output, Image, display | |
from google.protobuf import text_format | |
import os | |
import sys |
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
# imports and basic notebook setup | |
from cStringIO import StringIO | |
import numpy as np | |
import scipy.ndimage as nd | |
import PIL.Image | |
from IPython.display import clear_output, Image, display | |
from google.protobuf import text_format | |
from random import randint |
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 script samples the distributions of the k closest peers to randomly | |
# selected addresses and saves these to data files | |
import datetime | |
from multiprocessing import Process, Event | |
import os | |
import pprint | |
import random |
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 functools import wraps | |
def _read_memo(fname="memo"): | |
with open(fname, "r") as f: | |
memo = eval(f.read()) | |
return memo | |
def _write_memo(memo, fname="memo"): |