Skip to content

Instantly share code, notes, and snippets.

View bahostetterlewis's full-sized avatar

Barrett bahostetterlewis

  • Zscaler
  • Chico, California
View GitHub Profile
@bahostetterlewis
bahostetterlewis / git_aliases.txt
Last active December 17, 2015 00:19
useful git shit
git config --global alias.ignorechanges = update-index --assume-unchanged
git config --global alias.noticechanges = update-index --no-assume-unchanged
@bahostetterlewis
bahostetterlewis / pingalert.py
Last active December 16, 2015 16:49
My internet sucks and randomly cuts out. This lets me know when I'm connected again. simple and sweet so I don't have to ever type ping again.
import winsound
from subprocess import call, DEVNULL
print('Begin Ping Alert')
while call(["ping", "google.com"], stdout=DEVNULL, stderr=DEVNULL) != 0:
print('No net yet :(')
print('Web Back!!!')
import win32api, win32con, time
def click(x, y):
win32api.SetCursor((X,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
def clean():
click(1050, 200)
click(1050, 220)
@bahostetterlewis
bahostetterlewis / undo-redo-proof.py
Last active December 14, 2015 11:19
Proof of concept for an undo and redo function using python functions. This is for use in the pyrrhic-ree project. By using properties it is possible to build the undo stack just by setting the string. Once a stack is built calling the undo function builds a redo stack that is emptied once a person decides to type manually. I don't think there i…
class Proof:
def __init__(self):
self._redo = []
self._undo = []
self._mystr = ''
def mystr():
def fget(self):
return self._mystr
@bahostetterlewis
bahostetterlewis / Levenshtein-Damerau
Last active December 12, 2015 08:38
Levenshtein-Damerau, found originally in my sublime text 2 gist account (giststhebearbear) This is a memory/time optimized solution of the Levenshtein-Damerou distance algorithm. There are some non idiomatic things in the code, but it is pure standard python and can be used freely by anyone.
def leven(s1, s2, maxDistance):
# get smallest string so our rows are minimized
s1, s2 = (s1, s2) if len(s1) <= len(s2) else (s2, s1)
# set lengths
l1, l2 = len(s1), len(s2)
# We are simulatng an NM matrix where n is the longer string
# and m is the shorter string. By doing this we can minimize
# memory usage to O(M).
# Since we are simulating the matrix we only maintain two rows