Skip to content

Instantly share code, notes, and snippets.

View drhayes's full-sized avatar
🐱

David Hayes drhayes

🐱
View GitHub Profile
@drhayes
drhayes / eventChain.js
Created January 14, 2013 16:38
EventChain's every method
update.every = function(sec, doThis) {
update.during(
new EventChain()
.wait(sec)
.then(doThis)
.repeat()
);
return this;
};
@drhayes
drhayes / eventChain.js
Created January 15, 2013 05:48
EventChain's last lines
// Returned from this constructor thing.
return update;
};
});
@drhayes
drhayes / eventChain.js
Created January 15, 2013 07:14
EventChain's repeat method
update.repeat = function(times) {
times = times || Infinity;
var originalTimes = times;
var stepsCopy;
steps.push(function() {
times -= 1;
if (times > 0) {
var args = stepsCopy.slice(0);
args.unshift(1, 0);
[].splice.apply(steps, args);
@drhayes
drhayes / gist:4997048
Created February 20, 2013 16:55
Pre-commit hook to remove trailing whitespace on lines you've actually changed
#
# Shamelessly copied from http://blog.yesmeck.com/archives/make-git-automatically-remove-trailing-whitespace-before-committing/
#
# What's distinct about this version, as opposed to several I've seen,
# is that it only fixes the whitespace on lines you've actually changed,
# so avoids making you the blamee of code you didn't change.
# Find files with trailing whitespace
for file in `git diff --check --cached | grep '^[^+-]' | grep -o '^.*[0-9]\+:'` ; do
file_name=`echo ${file} | grep -o '^[^:]\+'`
@drhayes
drhayes / Gruntfile.js
Last active December 16, 2015 06:39
Custom sprite multitask
var NUM_SPRITE_COLS = 6;
var gm = require('gm');
grunt.registerMultiTask('sprite', 'Sprite images', function() {
var images = this.data;
var numRows = Math.ceil(images.length / NUM_SPRITE_COLS);
var sprite = gm('');
sprite.tile(NUM_SPRITE_COLS + 'x' + numRows);
sprite.quality('100');
sprite.background('transparent');
@drhayes
drhayes / Gruntfile.js
Created April 16, 2013 04:39
sprite multitask config
sprite: {
'media/player.png': [
'build/player-idle001.png',
'build/player-kneel001.png',
'build/player-kneel002.png',
'build/player-kneel003.png',
'build/player-kneel004.png',
'build/player-kneel005.png',
'build/player-walk001.png',
'build/player-walk002.png',
@drhayes
drhayes / gist:9513977
Created March 12, 2014 19:04
How I'm scaling my 2d Phaser game right now
preload: function() {
game.stage.scale.minWidth = 320;
game.stage.scale.minHeight = 240;
game.stage.scale.maxWidth = 640;
game.stage.scale.maxHeight = 480;
game.stage.scale.pageAlignHorizontally = true;
game.stage.scale.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
game.stage.scale.setShowAll();
@drhayes
drhayes / keybase.md
Created June 12, 2014 21:21
keybase.md

Keybase proof

I hereby claim:

  • I am drhayes on github.
  • I am drhayes (https://keybase.io/drhayes) on keybase.
  • I have a public key whose fingerprint is 17C5 BB89 6584 45B1 B431 D800 78E4 6D79 D295 413E

To claim this, I am signing this object:

@drhayes
drhayes / gist:efcc999154ce2c256a35
Created July 23, 2014 21:32
onename verification
Verifying myself: My Bitcoin username is +drhayes. https://onename.io/drhayes