Skip to content

Instantly share code, notes, and snippets.

View AndyMoreland's full-sized avatar

Andrew Moreland AndyMoreland

View GitHub Profile
@AndyMoreland
AndyMoreland / gist:5394654
Last active December 16, 2015 06:49
Expects socket.io-client, mongodb and ws to be installed with npm.
var WebSocket = require('ws')
var io = require('socket.io-client');
var MongoClient = require('mongodb').MongoClient;
console.log("Building websocket");
ws = io.connect('https://socketio.mtgox.com/mtgox')
console.log(ws);
// FOUND IN src/java/com/andymoreland/GoogleSpreadsheet/
package com.andymoreland.GoogleSpreadsheet;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import com.google.gdata.client.Service;
import com.google.gdata.client.spreadsheet.SpreadsheetService;
var html = require('fs').readFileSync(__dirname+'/index.html');
var fs = require('fs');
var server = require('http').createServer(function(req, res){
res.end(html);
});
server.listen(8080);
$( function () {
var ws = new WebSocket("ws://localhost:3001/sockjs/websocket");
ws.onopen = function() {
ws.send('{"msg":"connect","id":"1"}');
ws.send('{"msg":"method","method":"pageHit","params":["'+window.location.href+'","'+document.referrer+'","'+document.title+'"],"id":"2"}');
ws.close();
}
}
|------------------------------
| \ |
| \ x x \ \ G |
| \ \ \ |
| \ x x \ \|
|\ \ \ |
| \ \ x x \ |
| \ \ x x \ |
| \ \ \ |
| G \ \ \ |
Let's assume optimal strategy. If there is only one stack, then the first player to move can win if he wants to by taking all of the stones. IF both players want to lose, then the first player still wins because the second player can take all of the stones except for one that the first player leaves.
Okay, so how does this transfer to a two stack game?
The first person to make a move on the last stack remaining wins.
So basically, if you want to win, you need to lose the first stack.
As shown above, the first player always wins the first stack, regardless of his decision.
$.post(this.action+ ".js", data).complete(function () { alert("yo?"); }).success(
function () {
alert("Hello");
$(this).parent().hide().prev("tr").show();
});
this.model.save().success( _.bind(function(){
console.log("Success finished");
var foo = $(this.el);
console.log("Found the element");
foo.fadeOut(500, _.bind(function(){
console.log("Starting fade");
this.model.collection.fetch();
$(this.el).remove();
}, this));
}, this));
context.clearRect 0, 0, window.innerWidth - 10, window.innerHeight - 30
for _, t of @list
t.paint()
l = (msg) ->
console.log msg
$ ->
class Triangle
constructor: (@context) ->
@paint()
@x = 0
@y = 0
@xdir = 0
@ydir = 0