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 subprocess | |
DEPENDENCIES = ['cqlsh', 'ttab', 'kafka'] | |
def check_dependency(program): | |
"""TODO""" | |
try: | |
subprocess.check_output(["which", program]) | |
except: | |
msg = "%s not installed. Please install" % program |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/python | |
import sys | |
import json | |
import getopt | |
import webbrowser | |
html_header = """<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"> |
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 try_dict_extract(dictionary, key_list): | |
""" | |
Iterates through a list of nested keys to try to return a dictionary key value. | |
On exception, returns NoneType | |
""" | |
try: | |
x = dictionary | |
for key in key_list: | |
x = x[key] | |
return x |
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
#! /usr/bin/env python | |
""" | |
Using dictionaries for mapping lookups | |
See: http://www.tutorialspoint.com/python/python_dictionary.htm | |
""" | |
# Use a Python Dictionary for mapping | |
mapping = { | |
'CB' : 'Cobra', | |
'foo' : 'bar', |
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 getopt | |
import sys | |
from datetime import datetime | |
from time import sleep | |
import pytz | |
#### CRC-16 MODBUS Stuff. Included so we do all in one script #### | |
INITIAL_MODBUS = 0xFFFF |
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
from sys import argv | |
import csv | |
import dateutil.parser | |
from geopy.distance import vincenty | |
''' | |
Input file is downloaded movements from Savi Tracking | |
column 1 (a.k.a. row[0]) = lat | |
column 2 (a.k.a. row[1]) = lng | |
column 3 (a.k.a. row[2]) = utc time | |
''' |
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
from datetime import date, datetime | |
def oracle_weekday(dt): | |
''' | |
Takes a python datetime or date object. | |
Returns Day of Week in Oracle model | |
Day python oracle | |
Mon 0 2 | |
Tue 1 3 | |
Wed 2 4 |
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
from sys import argv, exit | |
import datetime as dt | |
import dateutil.parser | |
import random | |
from bisect import bisect_left | |
from utils import ts_diff_in_seconds as time_diff | |
def built_test_ts_list(length=1, min_diff=60, max_diff=60, start_dt=None): |
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
from scipy.spatial import KDTree | |
import numpy as np | |
from sys import argv, exit | |
''' | |
One-dimensional KDTree to lookup ts with nearest value | |
usage = "Usage: python %s value_to_seek optional_distance" % argv[0] | |
if len(argv) != 2: |