Skip to content

Instantly share code, notes, and snippets.

View calebmadrigal's full-sized avatar

Caleb Madrigal calebmadrigal

View GitHub Profile
@calebmadrigal
calebmadrigal / rewrite_strings.py
Created August 24, 2017 20:29
Example of changing the python AST
import ast
class StringWrapper(ast.NodeTransformer):
"""Wraps all strings in 'START ' + string + ' END'. """
def visit_Str(self, node):
return ast.Call(func=ast.Name(id='wrap_string', ctx=ast.Load()),
args=[node], keywords=[])
def wrap_string(s):
return 'START ' + s + ' END'
@calebmadrigal
calebmadrigal / get_milwaukee_traffic_cams.py
Created September 6, 2017 19:22
Milwaukee Traffic Cameras
import sys
from urllib.request import urlopen
CAM_RANGE = range(188)
CAM_URL_TEMPLATE = 'http://content.dot.wi.gov/travel/milwaukee/cameras/cam{}.jpg'
def get_camera_pic(cam_num, verbose=True):
if type(cam_num) != str or len(cam_num) != 3:
cam_num = str(cam_num).zfill(3)
import sys
from datetime import date,timedelta
def is_xkcd_day(d):
return d.weekday() in {0, 2, 4}
def find_date_by_xkcd_number(xkcd_num, current_xkcd=1964, start_date=date(2018, 3, 7)):
if not is_xkcd_day(start_date):
@calebmadrigal
calebmadrigal / parse_trackerjacker_wifi_map.py
Created August 10, 2018 21:11
parse_trackerjacker_wifi_map.py
import sys
import yaml
def parse_wifi_map(map_path):
with open(map_path, 'r') as f:
data = f.read()
wifi_map = yaml.load(data)
devices = set()
@calebmadrigal
calebmadrigal / output.txt
Last active April 2, 2019 20:29
sklearn to onnx
Prediction for [1, 1, 1, 1]: [[0.16937022 0.83062978]]
Prediction for [1, 2, 3, 4]: [[0.25071094 0.74928906]]
The maximum opset needed by this model is only 6.
The maximum opset needed by this model is only 1.
INPUT NAME: float_input
OUTPUTS: ['output_label', 'output_probability']
Prediction with ONNX for [1. 1. 1. 1.]: [[{0: 0.16937017440795898, 1: 0.830629825592041}]]
Prediction with ONNX for [1. 2. 3. 4.]: [[{0: 0.2507109045982361, 1: 0.7492890954017639}]]