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
#!/bin/sh | |
# copied from https://gist.github.com/sos4nt/5245210 | |
# In iTerm's Preferences > Profiles > Default > Advanced > Semantic History, | |
# choose "Run command..." and enter "/your/path/to/iterm_open_with \1 \2". | |
file "$1" | grep -q "text" | |
if [ $? -ne 0 ]; then | |
/usr/bin/open $1 | |
else |
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
//http://repl.it/IOn | |
function problem(colors, prisoners) { | |
function randomHat() { | |
return Math.floor(Math.random() * colors); | |
} | |
function randomHats() { | |
var hats = []; | |
for (var i = 0; i<prisoners; i++) { |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
var helperFuncs = { | |
center: function (robot, helper) { | |
return {x: robot.arenaWidth/2, |
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) { | |
robot.rotateCannon(-90); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(); | |
//i'll add a clone but i need to refactor collision | |
//robot.clone(); | |
}; |
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
// The code below will extend underscore.js adding the groupByAndMap function. | |
// groupByAndMap works like the regular groupBy, but it accepts an optional third "selector" argument. | |
// The 'selector' is used to select values inside each group. | |
// As usual in underscore, you can either pass a function or a string with the name of an attribute you want. | |
// groupByAndMap is useful when you don't want the key to be present in the values inside the group. | |
// Also, it completely covers the groupBy functionality because the last argument is optional. | |
// If you want, you can replace groupBy instead of defining a new function. | |
_.mixin({ | |
groupByAndMap: function(list, keySelector, valueSelector) { |
NewerOlder