Skip to content

Instantly share code, notes, and snippets.

View kayluhb's full-sized avatar

Caleb Brown kayluhb

View GitHub Profile
from nose.tools import set_trace
set_trace()
@kayluhb
kayluhb / JavaScript
Created August 25, 2016 19:32 — forked from hugeuser/JavaScript
"Scroll-Jacking" in Full Screen.
var delta;
var currentSlideIndex = 0;
function elementScroll (e) {
// --- Scrolling up ---
if (e.originalEvent.detail < 0 || e.originalEvent.wheelDelta > 0) {
delta--;
@kayluhb
kayluhb / offline-swer.js
Last active August 24, 2016 16:00 — forked from deanhume/offline-swer.js
Offline SW example
/**
* Helper method to determine the filename from the URL
* @param {url} the path to match
* @return {String} the path for caching
**/
function getFilenameFromUrl(url){
var path = url.substring(path.lastIndexOf("/")+ 1);
return (path.match(/[^.]+(\.[^?#]+)?/) || [])[0];
}
@kayluhb
kayluhb / offline-notification.js
Last active August 24, 2016 15:49 — forked from deanhume/offline-notification.js
Offline toast notifications
var urlToCheck = 'https://deanhume.github.io/beer' + createStyleUrl(styleId, pageId, false);
/**
* Display the offline notification.
* @return {void}
**/
function showOfflineNotification() {
// return if there is no service worker
if (!'serviceWorker' in navigator) {
return;
@kayluhb
kayluhb / Mobile
Created August 10, 2016 18:47 — forked from hugeuser/Mobile
"Scroll-Jacking in Full Screen."
var delta;
dragThreshold = 0.15;// "percentage" to drag before engaging
dragStart = null; // used to determine touch / drag distance
percentage = 0,
target,
previousTarget;
function touchStart(event) {
if (dragStart !== null) { return; }
@kayluhb
kayluhb / break.py
Last active June 20, 2017 22:55 — forked from obfusk/break.py
python equivalent of ruby's binding.pry
import code; code.interact(local=dict(globals(), **locals()))
@kayluhb
kayluhb / font.sh
Created January 15, 2015 20:05
replace fontname
for i in proximanova-*-webfont.*; do mv $i $(echo $i | sed 's/proxima-//g' | sed 's/-webfont//g'); done;
@kayluhb
kayluhb / quick_sort.py
Last active August 29, 2015 14:11
Quick Sort python
def quick_sort(lst):
if len(lst) <= 1:
return lst
low, middle, high = [], [], []
pivot = lst[0]
for num in lst:
if num < pivot:
low.append(num)
elif num > pivot:
high.append(num)
@kayluhb
kayluhb / merge_sort.py
Last active August 29, 2015 14:11
Merge sort!
def merge(arr, arr_ptr, half, half_ptr):
while half_ptr < len(half):
arr[arr_ptr] = half[half_ptr]
half_ptr = half_ptr + 1
array_ptr = array_ptr + 1
return array_ptr
def merge_sort(arr):
print("Splitting ", arr)
if len(arr) > 1:
@kayluhb
kayluhb / multiplication_tables.rb
Last active August 29, 2015 14:11
Multiplication tables in Ruby
multipliers = (1..9)
multipliers.each do |x|
print multipliers.map {|y|
s = y * x
"#{s < 10 ? ' ' : ''}#{s}"
}.join(' ')
print "\n"
end