Skip to content

Instantly share code, notes, and snippets.

@timcash
timcash / index.js
Created August 27, 2015 20:28
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
// Require a default instance of immstruct (singleton instance)
var immstruct = require('immstruct');
// Get the structure we previously defined under the ID `myKey`
var structure = immstruct('myKey', { a: { b: { c: 1 } } });
var cursor = structure.cursor(['a', 'b', 'c']);
/**
* Copyright 2012 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
class Planet
constructor: (@name,@size,@x,@y) ->
# I want an empty object to store ship in later
@ships = {}
battle: ->
#if more then one player has ships at this planet run the battle simulation
for p of @ships
damage = randint(@ships[p])
# todo, remove ships based on damage here
class Planet
constructor: (@name,@size,@x,@y) ->
@ships = {}
@damage_pool = {}
add_ships: (player,amount) ->
#add ships to an array based on the player who owns them
log("adding #{amount} ships to player #{player}")
if @ships[player]?
Planet = function(_a, _b, _c, _d) {
this.y = _d;
this.x = _c;
this.size = _b;
this.name = _a;
return this;
};
this.ships = {};
this.damage_pool = {};
@timcash
timcash / zeromq_pub.js
Created April 7, 2011 10:31
a test for publish speed of zeromq in nodejs
var cnt, mes, s, sender, util, zmq;
zmq = require('zeromq');
util = require('util');
s = zmq.createSocket('pub');
s.bind('tcp://127.0.0.1:5559', function(err) {
if (err) {
throw err;
}
util.puts('binding');
@timcash
timcash / Material Load
Created June 10, 2012 01:58
Material Load
using UnityEngine;
using System.Collections;
public class maker : MonoBehaviour {
// Use this for initialization
void Start () {
Material mat = Resources.Load("unlit",typeof(Material)) as Material;
if(mat == null)
@timcash
timcash / HarmonicSeries.cpp
Created December 9, 2012 20:55
Harmonic series
#include <iostream>;
#include <string>;
#include <cmath>;
using namespace std;
int main()
{
int n=0; //counter
int t=0; //user-input number of iterations
double young=0.0; //the new sum
@timcash
timcash / circle.yml.old
Created June 11, 2013 02:06
circle.yml
dependencies:
cache_directories:
- google_appengine # relative to the build directory
- pyyaml
pre:
- bash ./installAppEngine.sh
machine:
environment:
PYTHONPATH: $HOME/google_appengine:$HOME/pyyaml
#!/bin/bash
GAEPATH="$HOME/google_appengine"
PYYAMLPATH="$HOME/pyyaml"
if [ ! -d "$GAEPATH" ]; then
curl -O https://googleappengine.googlecode.com/files/google_appengine_1.8.0.zip
unzip -q -d $HOME google_appengine_1.8.0.zip
else
echo "already installed app engine"
fi