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
import Direction from './direction'; | |
function randomCoords(xMax, yMax) { | |
return {x: Math.floor(Math.random() * xMax), y: Math.floor(Math.random() * yMax)}; | |
} | |
var SnakeGameLogic = function SnakeGameLogic(rows, cols, initialSnakePoints, initialDirection) { | |
var appleCoords = randomCoords(cols, rows); | |
var getApplePoint = function getApplePoint() { | |
return appleCoords; |
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
[ | |
{ | |
"date": "10/1/2015", | |
"miles_driven": 35, | |
"trips": [ | |
{ | |
"miles_driven": 17, | |
"time": "13:26" | |
}, | |
{ |
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
def rotx(x, string, encrypt=true) | |
i = 0 | |
alpha = 'abcdefghijklmnopqrstuvwxyz' | |
newStr = '' | |
alpha.reverse! unless encrypt | |
# convert to one cycle | |
x = x > 26 ? x % 26 : x | |
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
def rotx(x, string, encrypt=true) | |
i = 0 | |
alpha = 'abcdefghijklmnopqrstuvwxyz' | |
newStr = '' | |
alpha.reverse! unless encrypt | |
# convert to one cycle | |
x = x > 26 ? x % 26 : x | |
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 Promise(){ | |
this._callbacks = []; | |
} | |
Promise.prototype.resolve = function (data) { | |
if (typeof this._data !== 'undefined') { | |
// assuming console | |
console.error('This promise has already been resolved'); | |
return; | |
} |
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
// works in private scope w/ es5 | |
function resolve (str) { | |
return str.split('.').reduce(function (prev, curr, ind) { | |
return ind < 2 ? eval(prev)[curr] : prev[curr]; | |
}); | |
} |
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 resolve (str) { | |
return str.split('.').reduce(function (prev, curr, ind) { | |
return ind < 2 ? eval(prev)[curr] : prev[curr]; | |
}); | |
} |
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 clone = robot.clone(); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(100); |