Skip to content

Instantly share code, notes, and snippets.

@JogoShugh
JogoShugh / move.js
Created February 1, 2015 20:05
move.js
function move(spaces, direction) {
playerCurrent.p.direction = direction;
playerCurrent.p.speed = 100;
console.log(playerCurrent.p.x);
var timeOut = 317;
var lastStep = function() { playerCurrent.p.speed = 0; console.log(playerCurrent.p.x); };
var step = function() { playerCurrent.p.speed = 100; };
var runStep = function() {
step();
spaces--;
@JogoShugh
JogoShugh / outerCount.json
Last active August 29, 2015 14:14
inboxes list HAL
{
"_links": {
"self": {
"href": "http://localhost:6565/api/digests/f4b72f3b-aab6-4481-b3b2-ef57ea81f080/inboxes",
},
"digest": {
"href": "http://localhost:6565/api/digests/f4b72f3b-aab6-4481-b3b2-ef57ea81f080"
},
"inbox-create": {
"href": "http://localhost:6565/api/inboxes",
@JogoShugh
JogoShugh / digestInboxes.js
Created February 5, 2015 18:18
digestsInboxes
app.get('/api/digests/:uuid/inboxes', function(req, res, next) {
function href(path) {
var protocol = config.protocol || req.protocol;
var host = req.get('host');
return protocol + "://" + host + path;
}
function createHyperMediaResponse(digestId, state) {
var inboxIds = _.keys(state.inboxes);
@JogoShugh
JogoShugh / test.js
Created February 9, 2015 19:55
digestsController.tests.js
var chai = require('chai'),
should = chai.should(),
sinon = require('sinon'),
sinonChai = require('sinon-chai'),
_ = require('underscore'),
request = require('request'),
uuid = require('uuid-v4'),
EventStore = require('eventstore-client');
chai.use(sinonChai);
var worldBuild = {
groups : [
{
start: '2,2',
repeat: '4 y',
sprites: [
'..g..',
'.ggg.',
'ggggg',
'.ggg.',
@JogoShugh
JogoShugh / JSONForm.json
Created February 14, 2015 17:37
JSONForm values for SpaceMiner
{
"schema": {
"title": "World",
"type": "object",
"properties": {
"worldName": {
"type": "string",
"title": "World name",
"description": "A creative name for your world",
@JogoShugh
JogoShugh / boxStepGeneric.js
Last active August 29, 2015 14:15
pickUpGems function for Space Miner
// This function will take a sprite that has a move method and move it along a path around a box of arbitary width,
// and continue that for boxes placed at repeating x and y distances from each other.
function boxStep(sprite, startX, startY, boxWidth,
xDistance, yDistance,
numberOfBoxesTotal, numberOfBoxesOnXAxis, moves) {
sprite.move(startX + ' ' + startY);
if (!moves || moves.length < 4) {
moves = ['r', 'd', 'l', 'u'];
}
namespace Bowling
{
public class Game
{
private int[] rolls = new int[21];
private int currentRoll = 0;
public void Roll(int pins)
{
rolls[currentRoll++] = pins;

Background info

Given a Customer ID: VersionOne-suhefuishf8y324342423 and an InstanceId: qwer12345 and an Instance URL: https://www7.v1host.com/v1production

Then, API routes now need to take the InstanceId into account, like:

/api/qwer12345/etc...

@JogoShugh
JogoShugh / boxStepPromise.js
Last active August 29, 2015 14:16
boxStep with Promises
// For boxStep:
/*
* Returns a Promise or a function that returns a Promise to do a single rectangular
* job or a straight line when the height or width is only 1
* When height and width are both 0, then just resolves immediately.
*/
function get(startX, startY, width, height, startNow) {
width--;
height--;