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
''' communicating to openbts through zeromq | |
''' | |
import json | |
import zmq | |
address = 'tcp://127.0.0.1:45060' | |
context = zmq.Context() | |
socket = context.socket(zmq.REQ) | |
socket.connect(address) | |
payload = { |
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
# via | |
# https://mail.python.org/pipermail/python-list/2010-August/586080.html | |
import random | |
import timeit | |
with open('/usr/share/dict/words') as infile: | |
words = [line.strip() for line in infile] | |
sample = random.sample(words, 501) |
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 Ch2 of think complexity.""" | |
class Graph(dict): | |
def __init__(self, vertices=[], edges=[]): | |
for vertex in vertices: | |
self.add_vertex(vertex) | |
for edge in edges: | |
self.add_edge(edge) | |
def add_vertex(self, vertex): |
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
# run the ubuntu setup script first | |
# note that this isn't quite a true shell script -- some paths will need modification | |
# setup and activate a venv | |
virtualenv /path/to/venv | |
source /path/to/venv/bin/activate | |
# order seems to matter here :| |
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
package graph | |
type Vertex struct { | |
Label string | |
} | |
type Edge struct { | |
Start Vertex | |
End Vertex | |
} |
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
"""plot_shp.py | |
Plots a shapefile with fiona, decartes and matplotlib. | |
""" | |
import descartes | |
import fiona | |
from matplotlib import pyplot | |
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
""" Placing points in a polygon evenly with simulated annealing. | |
""" | |
import math | |
import random | |
import descartes | |
from matplotlib import pyplot | |
import scipy.optimize | |
import shapely.geometry |
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 sys | |
import urllib | |
# Read. | |
with open(sys.argv[1]) as cdr_file: | |
cdr_data = cdr_file.read() | |
# Decode. | |
decoded_data = urllib.unquote(cdr_data).decode('utf8') | |
print decoded_data |
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 requests | |
good_hosts = ('www.endaga.com', 'endaga.com', 'staff.endaga.com', | |
'staging.endaga.com') | |
bad_hosts = ('www.bad-host.com', 'bad-host.com') | |
url = 'https://staging.endaga.com' | |
print 'GET %s' % url |
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
"""Continuously records the output of "gprs list" from OpenBTSCLI. | |
Run as follows (then you can logout of the session and it'll keep going): | |
$ nohup python gprs_lister.py & | |
""" | |
import time | |
import envoy |
OlderNewer