Skip to content

Instantly share code, notes, and snippets.

View totty90's full-sized avatar

Totty totty90

View GitHub Profile
@totty90
totty90 / gruntfile.js
Last active January 4, 2016 06:58
gruntfile.js
// Generated on 2013-09-17 using generator-webapp 0.4.2
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
@totty90
totty90 / Code
Created January 8, 2014 00:50
Games: generate units based on money and unit number limitation; Most elegant way to generate units for a game. Just say how many units you want, how much money (in this case hardness) you want to spend and then specify in each unit how much money (hardness) cost. This will create an array of 50 units with all the money you allow him to spend. I…
// limit max unit per wave to 50
// begin by creating the cheapest units, when it reach 50 units and you still have hardness to spend
// then remove the first in the array and build a harder one. When all of the units are of one type it migrates
// to the other level.
var toSpawn = [];
var l = 0;
var max = 50;
var currentLevel = 0;
while(remainingHardness > 0){
if(l < max){
@totty90
totty90 / jquery-backbone version
Created January 1, 2014 16:32
React example vs jquery in pure javascript
var BuildTemplate = ' \
<h2 class="small-caps">build</h2> \
';
var BuildV = BaseV.extend({
className: 'btn-group-vertical',
initialize: function(o){
this.__player = o.player;
@totty90
totty90 / JS Signals
Created January 25, 2011 01:23
Javascript: inspired from actionscript 3 signals
var Signal = function(){}
Signal.prototype = {
init: function(){
this.listeners = [];
this.looping = false;
this.length = 0;
},
add: function(method, applyOn){