View example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bind keyboard and gamepad buttons | |
ig.input.bind( ig.KEY.X, 'shoot1'); | |
ig.input.bind( ig.GAMEPAD1.FACE_1, 'shoot1'); | |
ig.input.bind( ig.GAMEPAD2.FACE_1, 'shoot2'); | |
ig.input.bind( ig.GAMEPAD3.FACE_1, 'shoot3'); | |
ig.input.bind( ig.GAMEPAD4.FACE_1, 'shoot4'); |
View gist:8721419
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Ok, so let's say you've got a situation where one browser fires | |
two events and the other browser only fires one. | |
How about a specific example: IE does not fire the "change" event on | |
a text input when you press the enter key, whereas other browsers do. | |
Well, what if you want to execute some code both when an | |
input changes OR when a user presses enter? You don't want |
View gist:4659962
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Provide TextMate-like math eval support to Sublime Text 2 | |
# { "keys": ["super+shift+m"], "command": "filter_through_command", "args": { "cmdline": "~/st_math.sh" } }, | |
foo=$(cat /dev/stdin) | |
bar=$(echo "scale=4; $foo" | bc) | |
/bin/echo -n $bar |
View gist:4640634
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var preloadImages = [ | |
'path/to/image1.png', | |
'path/to/image2.png', | |
'path/to/image3.png' | |
], | |
toLoad = 0, | |
preload = function () { | |
var i = preloadImages.length; |
View gist:4118766
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Entity coordinates. Note requirement that 0 < x < 65535 ... same for y! | |
x = 54321; | |
y = 12345; | |
// x,y now stored in single 4 byte integer | |
pos = (x << 16) + y; | |
// Get back x and y | |
x = pos >>> 16; // unsigned right shift | |
y = pos & 65535; |
View gist:3955874
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Zachary Johnson | |
// http://www.zachstronaut.com | |
var x, y, z, i = 250; | |
while (i--) { | |
/* random distribution /* | |
x = -125 + Math.round(Math.random() * 125 * 2); | |
y = -125 + Math.round(Math.random() * 125 * 2); | |
z = -Math.round(Math.random() * 250); | |
*/ |
View gist:3843393
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Am I missing something obvious? Is there some flag for caching attachments or something? | |
* | |
* My actual use case is pulling all the posts from a custom post type... but the behavior is the same with good old plain posts, too. | |
* Your test posts will need Featured Images. | |
*/ | |
/** |
View gist:3838175
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resolve(obj, path) { | |
var prop; | |
path = path.split('.'); | |
while (obj = obj[path.shift()]) { | |
prop = obj; | |
} | |
return prop; |
View gist:1705796
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SLUGIFY - Attempts to match Django slugify filter: "Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace." | |
*/ | |
function SLUGIFY(str) { | |
return str.toString().toLowerCase().replace(/^\s+|\s+$/g,'').replace(/\s/g, '-').replace(/[^-_a-z0-9]/g, ''); | |
} | |
/** | |
* HTMLSAFE - Convert &<>" to HTML entities | |
*/ |
View gist:1208947
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// https://gist.github.com/1208947 | |
// Include this JS right after NKit.js in your HTML files. | |
// Now NKLog() will show you the contents of arrays and objects! | |
// | |
var NKLog1 = NKLog; | |
var NKLog = function (arg) { | |
NKLog1('\n' + NKInterogate(arg)); | |
} |
NewerOlder