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
const slottingMachine = { | |
initial: 'selectingSection', | |
states: { | |
selectingSection: { | |
on: { | |
SELECT_SECTION: 'slottingSection', | |
}, | |
}, | |
slottingSection: { | |
on: { |
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
# TODO: Don't delete from origin | |
git branch -vv | awk '$1 !~ /\*/ { print $1 }' | xargs git branch -D |
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
// TESSSSSSSSST | |
(function($) { | |
$.fn.cachedDelegation = function(event, selector, callback) { | |
var $context = $(this); | |
$context.on(event, selector, function(e) { | |
console.log('evaluating callback for ', this); | |
var $target = $(this); | |
var savedCallback = $(this).data('lazydelegation-callback'); | |
if (!savedCallback) { |
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 something() {} | |
function doSomethingExpensive() { | |
console.log('expensive!'); | |
return 42; | |
} | |
something.prototype.lazy = function() { | |
var value = doSomethingExpensive(); | |
return (this.lazy = function() { |
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
// From http://stackoverflow.com/a/12313690 | |
var | |
styleSheets = document.styleSheets, | |
totalStyleSheets = styleSheets.length; | |
for (var j = 0; j < totalStyleSheets; j++){ | |
var | |
styleSheet = styleSheets[j], | |
rules = styleSheet.cssRules, |
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
git diff --numstat | awk '{if ($1 == "-" && $2 == "-") print $3}' | xargs git checkout HEAD |
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
PS1="\h \e[30;1m\w\e[0m\n" | |
PS1="$PS1\$(parse_git_branch)\$ " |
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 Robot = function(robot) {}; | |
var strategies = { | |
scan: function(robot) { | |
robot.ahead(100); | |
robot.rotateCannon(360); | |
robot.back(100); | |
robot.rotateCannon(360); | |
}, | |
attack: function(robot) { |
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
class StateMachine | |
constructor: (@initial_state) -> | |
@current_state = @initial_state | |
transition_to: (state) -> | |
$.event.trigger "from_#{@current_state}.state_machine" | |
$.event.trigger "to_#{state}.state_machine" | |
$.event.trigger "#{@current_state}_to_#{state}.state_machine" | |
@current_state = state |
NewerOlder