This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Freefall detection test</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
</head> | |
<body> | |
<div> | |
accel: x, y, z | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whenAllTriggered(tokens, callback) { | |
// returns a function that takes a single token | |
// once this function has been called with all tokens at least once, | |
// callback is invoked. | |
var triggeredStates = {}, | |
nTokens = 0, | |
nTriggered = 0; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hey, @addyosmani! Here's my #protip. | |
// Of all the JavaScript I've written in the past year, this is definitely | |
// my favourite. It uses some of JavaScript's awesome functional features | |
// (namely closure and functions as first-class objects) to create a clean | |
// interface for building specific event listeners from a general form. | |
// This particular snippet allows you to "subdue" the behaviour of some of | |
// the more excitable DOM events such as scroll and resize. With scroll, for | |
// example, your event listener will be called up to once for *every pixel* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What up, @mdo. You'll need a recent version of jQuery. | |
// You can try this out by pasting it into the console on http://api.jquery.com/jQuery.ajax/ | |
window.repoCallback = function (obj) { | |
console.log("Watchers:" + obj['repository']['watchers']); | |
console.log("Forks:" + obj['repository']['forks']); | |
} | |
$.ajax("http://github.com/api/v2/json/repos/show/twitter/bootstrap?callback=repoCallback", {dataType: "jsonp"}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python Startup File (from https://gist.github.com/955154) | |
Add this file to ~/.pythonrc.py to add history between sessions and | |
auto-completion via the ESC key to the interactive Python interpreter. After | |
adding this file, put something like the following line in your .bash_profile: | |
export PYTHONSTARTUP=$HOME/.pythonrc.py | |
Requires a recent version of Python and the readline package, which you can |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<style> | |
html { | |
height: 100%; | |
} | |
body{ | |
height: 100%; | |
} | |
.myDiv { | |
height: 100%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getjQuerySelector = (function() { | |
function siblingIndexPseudoSelector(el) { | |
var sibsBefore = 0, | |
sibsAfter = 0, | |
sib; | |
for (sib = el.previousSibling; sib; sib = sib.previousSibling) { | |
if(sib.nodeType == 1 && sib.tagName == el.tagName) { | |
sibsBefore += 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hello! I am Ben Hodgson. | |
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
// A: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROJECTS_DIR=$HOME/projects | |
function workon { | |
cd $PROJECTS_DIR/"$1"/; | |
cd "$1" > /dev/null 2>&1 && source ../bin/activate > /dev/null 2>&1; | |
} | |
complete -W '`ls $PROJECTS_DIR`' workon |