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
# Data structures | |
## Polygon | |
- name : Big polygon (string, required) - name of the polygon | |
- points : [[[0, 0], [0, 5], [5, 5], [0, 5], [0, 0]], [[1, 1], [4, 1], [4, 4], [1, 4], [1, 1]]] (required) - list of lists of points (x, y) coordinate pairs. | |
First list is an enclosing polygon. Next ones are cut out areas. |
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 -*- | |
""" | |
An example flask application showing how to upload a file to S3 | |
while creating a REST API using Flask-Restful. | |
Note: This method of uploading files is fine for smaller file sizes, | |
but uploads should be queued using something like celery for | |
larger ones. | |
""" | |
from cStringIO import StringIO |
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 os | |
import asyncio | |
import sys | |
from asyncio.streams import StreamWriter, FlowControlMixin | |
reader, writer = None, None | |
@asyncio.coroutine | |
def stdio(loop=None): |
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 tornado import gen | |
from tornado.ioloop import IOLoop | |
from tornado.tcpclient import TCPClient | |
class Client(TCPClient): | |
msg_separator = b'\r\n' | |
@gen.coroutine | |
def run(self, host, port): |
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 concurrent.futures import ThreadPoolExecutor | |
from tornado import gen | |
from tornado.ioloop import IOLoop | |
from tornado.iostream import StreamClosedError | |
from tornado.tcpclient import TCPClient | |
class Client(TCPClient): | |
msg_separator = b'\r\n' |
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 signal | |
import asyncio | |
from tornado import gen | |
from tornado.ioloop import IOLoop | |
from tornado.iostream import StreamClosedError | |
from tornado.tcpserver import TCPServer | |
from tornado.platform.asyncio import AsyncIOMainLoop, to_asyncio_future | |
import aioredis |
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 itertools import groupby | |
from operator import itemgetter | |
from utils import outlier_threshold | |
def filter_view_deviations(data): | |
query_sorted_data = sorted(data, key=itemgetter('query')) | |
result = [] | |
for k, group in groupby(query_sorted_data, key=itemgetter('query')): |
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 math | |
from operator import lt | |
class Heap: | |
"""Binary heap, with pluggable comparison function.""" | |
def __init__(self, cmp=lt): | |
self.len = 0 | |
self.arr = [] |
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 is Python implementation of Repository pattern for accessing Data model | |
in an Object Oriented manner, simulating collection interface and abstracting | |
persistence operations. | |
The Repository also has Factory method for dealing with different Databases. Another | |
approach is to add direct engine string ingestion to the Repository __init__ method. | |
""" | |
from abc import ABC |