Skip to content

Instantly share code, notes, and snippets.

@JimHaughwout
JimHaughwout / round_isotime.py
Last active July 8, 2017 16:06
Rounds ISO8601 timestamp to nearest second. Useful for time series stitching (as Hive UDF, etc.)
from dateutil.parser import parse
from datetime import timedelta
def round_b(x, base=5):
"""
Rounds a number to base X
"""
return int(base * round(float(x) / base))
@JimHaughwout
JimHaughwout / softmax.py
Created December 14, 2016 12:23
Simple softmax implementation
import numpy as np
from math import exp
def softmax(x):
"""Compute softmax values for each sets of scores in x."""
# S(yi) = e^/yi / sum(ey2)
y = np.array(x)
f = np.vectorize(exp)
n = f(y)
@JimHaughwout
JimHaughwout / airport.sh
Created September 11, 2016 16:55
BBIDs from MAC
ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport /usr/local/bin/airport
airport -s
A aboard, about, above, across, after, against, ahead of, along, amid, amidst, among, around, as, as far as, as of, aside from, at, athwart, atop
B barring, because of, before, behind, below, beneath, beside, besides, between, beyond, but, by, by means of
circa, concerning
D despite, down, during
E except, except for, excluding
F far from, following, for, from
I in, in accordance with, in addition to, in case of, in front of, in lieu of, in place of, in spite of, including, inside, instead of, into
L like
M minus
N near, next to, notwithstanding
@JimHaughwout
JimHaughwout / isAny.py
Created July 3, 2016 15:21
any vs. all vs. iteration with break
from datetime import datetime
from random import randint
data = list()
for i in range(100000):
j = randint(1,20)
if j == 20:
data.append(j)
else:
@JimHaughwout
JimHaughwout / display_geojson.py
Last active April 2, 2016 19:29
Display GeoJSON on http://geojson.io via command line
#!/usr/bin/python
import json
from sys import argv, exit
from geojsonio import display
CMD_NAME = argv[0]
HELP_TEXT = """
%s - Displays GeoJSON FeatureCollection or Geometry object via http://geojson.io
Usage:
@JimHaughwout
JimHaughwout / .bash_profile
Created March 25, 2016 12:21
El Capitan Work-around alias for pip
# To add
alias superpip="sudo -H pip install --ignore-installed "
@JimHaughwout
JimHaughwout / MeetupPost.md
Created March 5, 2016 14:48
Hiring (and Referral Bonus): Kafka, Spark + Hadoop for the Industrial IoT

[b]The What:[/b] We're hiring Software Engineers, Data Engineers and Data Scientists to build real-time, machine learning-based analytics for the Industrial Internet of Things.

[b]What's In It For You?[/b] [u][i]If you are an engineer or data scientist:[/i][/u] You get to use some of the latest technologies (Spark, Kafka, Hadoop, Parquet, Cassandra) in production, at scale, to solve hard problems for real customers (vs. just playing with Twitter Word Count tutorials).

[u][i]Everyone Else:[/i][/u] If you refer someone that we hire you get $3,000. Just use the links below: [list] [][b]Data Engineer, Software Engineer:[/b] http://app.jobvite.com/m?3inFQhwW [][b]Data Scientist:[/b] http://app.jobvite.com/m?3NqFQhwu

@JimHaughwout
JimHaughwout / foo.json
Last active February 13, 2016 16:17
Geostuff
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JimHaughwout
JimHaughwout / nr.py
Created September 6, 2015 20:52
Newton-Raphson for square root
epsilon = 0.00001
y = 25.0
guess = y/2.0
while abs(guess*guess - y) >= epsilon:
guess = guess - (((guess**2) - y)/(2*guess))
print(guess)
print('Square root of ' + str(y) + ' is about ' + str(guess))