Skip to content

Instantly share code, notes, and snippets.

View colingourlay's full-sized avatar

Colin Gourlay colingourlay

View GitHub Profile
@colingourlay
colingourlay / gist:1983272
Created March 6, 2012 03:44
The best of Simon
SCRUM-3245: I do not know what to log so I remove my useless logs UT:404 http://trac.online.apn.au/finda/changeset/21603
SCRUM-3269: how can I fuck up so badly this simple method, all apologizes UT:402 http://trac.online.apn.au/finda/changeset/21114
SCRUM-2838: deleting what I dont understand UT:0 http://trac.online.apn.au/finda/changeset/20674
SCRUM-2575: I cant believe I did this. Tests were being ran twice because of this accident commit UT:0 http://trac.online.apn.au/finda/changeset/19455
NO-SCRUM: I commited on the wrong branch, what a loser UT:0 http://trac.online.apn.au/finda/changeset/18776
SCRUM-2364: UGC form. Did a manual merge from hell, hope I didnt forget any changest UT:0 http://trac.online.apn.au/finda/changeset/18440
NO-SCRUM: I am tired, I keep doing mistakes UT:0 http://trac.online.apn.au/finda/changeset/18124
SCRUM-2304: Balls of steal. I have no clue of what I am doing. I use the force UT:0 http://trac.online.apn.au/finda/changeset/17643
SCRUM-2304: I made a typo. I guess I dont have the
@colingourlay
colingourlay / namespace.js
Created April 14, 2012 09:06
JavaScript namespacing (depends on jQuery)
(function (global, $) {
global.namespace = function (nsName, obj) {
var level, names, name;
level = global;
names = nsName.split('.');
while(name = names.shift()) {
level[name] = level[name] || {};
level = level[name];
}
$.extend(level, obj);
@colingourlay
colingourlay / roman.js
Created April 18, 2012 22:24
Roman numerals generator
(function () {
function romanify(value) {
var numbers, numerals, result, i, len;
numbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];
numerals = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
result = "";
for (i = 0, len = numbers.length; i < len; i++) {
@colingourlay
colingourlay / index.js
Created February 16, 2013 08:57
voxel.js game
var createGame = require('voxel-engine')
function sphereWorld(x, y, z) {
// return the index of the material you want to show up
// 0 is air
if (x*x + y*y + z*z > 15*15) return 0
return 3
}
var game = createGame({
@colingourlay
colingourlay / example.txt
Last active December 26, 2015 04:49
Grunt task for cycling through each item in a directory on an interval and creating a symlink which points to it. This is helpful for cycling through logs, or an archive of data captured over time. Coupled with a server, it serves as a good simulated data endpoint. This should be defined after grunt.initConfig inside your Gruntfile, or you can r…
$ grunt link-cycler --root=archive/json --interval=30000 --link=current --verbose --initial=10
Running "link-cycler" task
Cycling through last 3 of 12 children, 1 per 30000ms...
Child 10/12:
Linking archive/json/current to archive/json/2013-09-23_12-28-32
Child 11/12:
@colingourlay
colingourlay / LICENSE
Last active January 5, 2021 19:43
Standalone getScript. This performs the same ability as jQuery.getScript, including the optional callback, but doesn't support the Promises implementation shared with all the other jQuery.ajax methods.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
@colingourlay
colingourlay / onlyWhen.js
Created November 4, 2013 02:03
onlyWhen - run a function with its original arguments once a condition is met.
/**
* Creates a wrapped version of a funtion that will run with the original
* arguments, once a condition is met. If the condition is not met, it will
* be checked on a set interval until it is met.
*
* @param {Boolean} condition function you expect to eventually return a truthy value
* @param {Function} func original function to resolve
* @param {Number} interval time to wait between checks
* @return {Function} wrapped function you call can call as it it was the original function
*/
@colingourlay
colingourlay / 0_reuse_code.js
Created November 6, 2013 02:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@colingourlay
colingourlay / Array.apply
Last active May 28, 2018 09:35
Function.prototype.apply 's handling of an object instead of an array. It forces the object through Array.prototype.slice function as 'this' to create an array, pretty much what we do to turn an arguments object into a real array.
Array.apply(null, [1, 2, 3])
> [1, 2, 3]
Array.apply(null, [1, 2, 3]).length
> 3
Array.apply(null, {length:3})
> [undefined, undefined, undefined]
Array.apply(null, {length:3}).length