This file contains hidden or 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
| // makeshift semantic version comparisons | |
| // standard compareFunction | |
| // Checks if semver a is greater than semver b | |
| function gtSemver(a, b) { | |
| // validate | |
| if (!a && !b) { return 0; } | |
| if (!a) { return -1; } | |
| if (!b) { return 1; } | |
| if (!_.isString(a) || !_.isString(b)) { | |
| throw new Error('Semver not valid "' + a + '", "' + b + '"'); |
This file contains hidden or 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
| 09#65#21 | |
| 06#72#03 | |
| Dec 26, 75 | |
| Jul 13, 07 | |
| Nov 21, 14 | |
| 15*10*1981 | |
| 13*02*1992 | |
| 10#51#16 | |
| 1964-01-10 | |
| 06*04*1965 |
This file contains hidden or 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
| Nerds | |
| Tootsie Roll | |
| Rock | |
| Nerds | |
| Skittles | |
| Lollipop | |
| Snickers | |
| Popcorn | |
| Tangy Taffy | |
| Sweet Tarts |
This file contains hidden or 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
| // helper to quickly create elements on the document | |
| function createElm(doc, type, props, attributes) { | |
| props = props || {}; | |
| attributes = attributes || {}; | |
| var elm = doc.createElement(type); | |
| var keys = Object.keys(props); | |
| // props are set directly on the elm | |
| keys.forEach(function(key) { | |
| elm[key] = props[key]; |
This file contains hidden or 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
| // polyfill for event.offsetX/offsetY | |
| // Firefox is the only browser that doesn't support it (IE has since 4) | |
| (function() { | |
| var evt = document.createEvent('MouseEvent'); | |
| if (evt.offsetX === void 0) { | |
| Object.defineProperties(MouseEvent.prototype, { | |
| 'offsetX': { | |
| get: function() { | |
| return this.layerX - this.target.offsetLeft; | |
| } |
This file contains hidden or 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
| // hand golfed the most common dice rolls. | |
| function rnd(max, min) { | |
| return 0| (Math.random() * max) + 0|min; | |
| } | |
| var d20 = rnd.bind(0, 20, 1); | |
| var d8 = rnd.bind(0, 8, 1) | |
| var d6 = rnd.bind(0, 6, 1) | |
| var d4 = rnd.bind(0, 4, 1); |
This file contains hidden or 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
| mycompany.Collections.MyCollection = Backbone.Collection.extend({ | |
| model: mycompany.Models.MyModel | |
| , url: '/rest/models' | |
| }) |
This file contains hidden or 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
| --[[ | |
| Animation Sheet | |
| Allows you to set up several animations from a single animation sheet and play them. | |
| This wil only play one animation at a time. | |
| By Chris Richards | |
| --]] | |
| module('AnimSheet', package.seeall) |
This file contains hidden or 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
| -- SpriteSheet | |
| -- Handles custom Zwoptex template: https://gist.github.com/4274146 | |
| module('SpriteSheet', package.seeall) | |
| local SpriteSheet = {} | |
| -- Loads and creates the sprite sheet from sheetName | |
| function SpriteSheet:new(sheetName) | |
| local ss = require(sheetName) | |
| setmetatable(ss, { __index = self }) |
This file contains hidden or 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
| -- Print contents of `tbl`, with indentation. | |
| -- `indent` sets the initial level of indentation. | |
| function tprint (tbl, indent) | |
| if not indent then indent = 0 end | |
| for k, v in pairs(tbl) do | |
| formatting = string.rep(" ", indent) .. k .. ": " | |
| if type(v) == "table" then | |
| print(formatting) | |
| tprint(v, indent+1) | |
| elseif type(v) == 'boolean' then |