Skip to content

Instantly share code, notes, and snippets.

View JBKahn's full-sized avatar

Joseph Kahn JBKahn

View GitHub Profile
@JBKahn
JBKahn / requirements.txt
Created July 3, 2014 18:42
Street Fighter Requirements
beautifulsoup4==4.3.2
requests==2.3.0
@JBKahn
JBKahn / streetfighter.py
Last active August 29, 2015 14:03
Street Fighter
import random
import requests
from bs4 import BeautifulSoup
if __name__ == "__main__":
wiki_page = "http://streetfighter.wikia.com/wiki/List_of_moves_in_Street_Fighter_II"
r = requests.get(wiki_page)
soup = BeautifulSoup(r.content)
games = soup.find_all("tr")
while True:
@JBKahn
JBKahn / pre-commit
Last active August 29, 2015 14:03
Example pre-commit hook
#!/bin/sh
# Allows for colors and such
export TERM=xterm-256color
FILES="git diff --cached --name-only --diff-filter=ACM"
ROOT=$(git rev-parse --show-toplevel)
RETVAL=0
@JBKahn
JBKahn / requirements.txt
Last active August 29, 2015 14:02
Success
beautifulsoup4==4.3.2
requests==2.3.0
@JBKahn
JBKahn / gist:250a28288c309fa61bef
Created May 1, 2014 18:14
Drag & Drop Attempt 3
getDirectionMoved: (e, collectionLength, mousePos, spacerHeight) =>
spacerOffsetTop = @$spacer.offset().top
isOnTopOfSpacer = mousePos > spacerOffsetTop and mousePos < spacerOffsetTop + spacerHeight
isAboveSpacer = mousePos < spacerOffsetTop
isBelowSpacer = not isAboveSpacer and not isOnTopOfSpacer
spacerIsAtTop = Data.FinancialTransactions.dragCurrentIndex is 0
spacerIsAtBottom = Data.FinancialTransactions.dragCurrentIndex is collectionLength
@JBKahn
JBKahn / gist:ac1a09ae90d50c82ba3b
Created May 1, 2014 18:14
Drag & Drop Safari Fix
isFlipping: (positions) =>
if positions.length < 4
return false
invalidA = ['above', 'below', 'above', 'below']
invalidB = ['below', 'above', 'below', 'above']
lastThree = _.last(positions, 4)
return _.isEqual(lastThree, invalidA) or _.isEqual(lastThree, invalidB)
@JBKahn
JBKahn / gist:5e5fd25a1f4871319863
Created May 1, 2014 18:12
Drag & Drop Attempt 2
handleDragEvent: (e, ui) =>
currentMousePosition = e.clientY
startingIndex = Collection.indexOf(currentlyDraggingData.model)
dragOverIndex = Collection.indexOf(@model)
currentIndexOfDraggingTransaction = Collection.indexOf(Collection.dragModel)
transactionTop = $($('.financial-transaction-item')[currentIndexOfDraggingTransaction]).offset().top - $(window).scrollTop()
if Collection.dragModel isnt @model
Collection.dragView.$el.detach()
if dragOverIndex > currentIndexOfDraggingTransaction
@$el.after(Collection.dragView.$el)