Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View JBKahn's full-sized avatar

Joseph Kahn JBKahn

View GitHub Profile
@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)
@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: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 / requirements.txt
Last active August 29, 2015 14:02
Success
beautifulsoup4==4.3.2
requests==2.3.0
@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 / 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 / requirements.txt
Created July 3, 2014 18:42
Street Fighter Requirements
beautifulsoup4==4.3.2
requests==2.3.0
@JBKahn
JBKahn / movie_recs.md
Last active August 29, 2015 14:03
Movie Reccomendations
Seen Not yet seen
A Bronx Tale 30 for 30: The Two Escobars
Adaptation All Joel Coen movies
Apocolypto Barbarian at the Gate
Batman The Animated Series Blankman
Being John Malkovich Boys in the Hood?
Conspiracy Theory BUSHWHACKED?!??!
Dazed and Confused Clerks II
Demolition Man Cocaine Cowboys
@JBKahn
JBKahn / File Structure
Last active August 29, 2015 14:04
Ansible Post
setup.yml # master playbook
HOSTS # HOSTS file which defines where the script will run. This points to localhost.
requirements.txt # the requierments for running this playbook, including ansible
run.sh # one command script for install requirements, cloning the repo and provisioning.
roles/
common/ # this hierarchy represents a "role"
tasks/ #
*.yml # <-- tasks files i'll talk about later
files/ #
@JBKahn
JBKahn / Output.txt
Created July 28, 2014 04:22
Ansible Output
joseph@Batcave-Ubuntu:~/dev/provisioning-local$ sudo rm -fr ../../setup/base16-gnome/
[sudo] password for joseph:
joseph@Batcave-Ubuntu:~/dev/provisioning-local$ ansible-playbook setup.yml -i HOSTS --ask-sudo-pass
sudo password:
PLAY [a playbook to setup my local machine with my basic customizations] ******
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]