This file contains hidden or 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
""" | |
::Eagle Eye Networks Inc.::: | |
::Python screening:: | |
The following script is purposley written poorly. | |
The City class depends on an external service that is really | |
slow. Improve the code below so that 'test1' is more performant | |
but preserves: | |
- the ability to get a City as a dict or string. |
This file contains hidden or 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
""" | |
::Eagle Eye Networks Inc.::: | |
::Python screening:: | |
The "SummertimeService" will drive you insane. | |
It throws random errors. Summertime it works | |
summertime it don't. | |
Some errors you can ignore and assume worked, | |
others you need to reset the service. |
This file contains hidden or 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
""" | |
::Eagle Eye Networks Inc.::: | |
::Python screening:: | |
The 'has_dups' function checks an array for | |
duplicate strings. It's pretty inefficient. | |
Improve the 'has_dups' function and explain | |
how you improved it. | |
""" |
This file contains hidden or 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
""" | |
::Eagle Eye Networks Inc.::: | |
::Python screening:: | |
The following script is purposley written poorly. | |
Fix the 'magic' function. | |
""" | |
def magic(X, additional=[]): |
This file contains hidden or 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
class DatabaseWrapper(BaseDatabaseWrapper): | |
SEARCH_PAGE_SIZE=999 | |
def __init__(self, *args, **kwargs): | |
super(DatabaseWrapper, self).__init__(*args, **kwargs) | |
self.charset = "utf-8" | |
self.creation = DatabaseCreation(self) | |
self.features = DatabaseFeatures(self) | |
if django.VERSION > (1, 4): | |
self.ops = DatabaseOperations(self) |
This file contains hidden or 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 connect(args): | |
con = initialize(args['NAME'], karma=0.001) | |
con.simple_bind_s(args['USER'], args['PASSWORD']) | |
return con | |
pool = DBPool.ConnectionPool( | |
connect, { | |
'NAME': 'ldap://ldapserver', | |
'USER': 'xxxxxxx', | |
'PASSWORD': 'xxxxx', |
This file contains hidden or 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 gevent | |
import timeit | |
from gevent.event import Event | |
from plotter import graph_latency, graph_ops | |
RUNS = [100, 500, 1000, 5000, 10000, 20000, 30000, 60000, 100000, 120000, 150000] | |
start_event = Event() | |
greenlets = [] | |
times = [] |
This file contains hidden or 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 gevent | |
import timeit | |
from gevent.event import Event | |
from plotter import graph_latency, graph_ops | |
RUNS = [100, 500, 1000, 5000, 10000, 20000, 30000, 100000] | |
SLEEP_TIME = float(sys.argv[1]) | |
LOAD_TIME = 3 |
This file contains hidden or 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 plotly.plotly as py | |
from plotly import tools | |
from plotly.graph_objs import * | |
from plotly.offline import plot | |
from numpy import * | |
# Make a gradient pattern of 12 colors. | |
N = 12 | |
colors = ['hsl('+str(h)+',50%'+',50%)' for h in linspace(0, 360, N)] |
This file contains hidden or 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
class Mapping(dict): | |
""" | |
Example: Map({'make': 'Toyota'}, model='Tacoma', year=1998, color='white') | |
""" | |
def __init__(self, *args, **kwargs): | |
super(Mapping, self).__init__(*args, **kwargs) | |
for arg in args: | |
if isinstance(arg, dict): | |
for k, v in arg.iteritems(): | |
self[k] = v |