Skip to content

Instantly share code, notes, and snippets.

View FireyFly's full-sized avatar

FireFly FireyFly

View GitHub Profile
@FireyFly
FireyFly / gist:3137013
Created July 18, 2012 15:41 — forked from ailabs-software/gist:3136976
Is this ECMAScript okay?
var __objectInheritanceCalculated = [];
while((function()
{
/* There is a object class that has not been processed */
var __t = 0;
for (var m in objectclasses) { __t++; }
if (__t <= __objectInheritanceCalculated.length) return false;
return true;
})())
{
@FireyFly
FireyFly / am-i-being-dumb.js
Created July 24, 2012 17:15 — forked from cowboy/am-i-being-dumb.js
JavaScript: split on :, handling escaped \:
// Split colon-separated parts, unescaping (but not splitting on) any \:
function split(str) {
return str.match(/(?:\\:|[^:])+/g).map(function(part) {
return part.replace(/\\:/g, ':')
});
}
// Eg.
@FireyFly
FireyFly / a
Created August 16, 2012 22:25 — forked from gkatsev/gist:3374141
JS: The Hip Parts.
Chapters =
[ Comma-First is Comma Right
, !function Expressions!
, <!--Comments with Style-->
, Blow it Out Your Semi-Colon ]
@FireyFly
FireyFly / ternary.js
Created December 4, 2012 16:00
nested ternary formatting
function foo(bar) {
return bar === baz? 'hello'
: bar === quux? 'hey'
: /*otherwise*/ 'hi'
}
@FireyFly
FireyFly / rps.js
Last active December 16, 2015 11:19 — forked from yorickvP/rps.js
function RPS(count) {
this.players = count
this.score = range(count).map(Const(0))
this.moves = range(count).map(limit(Array,0))
}
RPS.prototype.beats = { "rock": "scissors",
"paper": "rock",
"scissors": "paper" }
-- for testing
function server(url)
return function (tbl)
print(url)
for k,v in pairs(tbl) do
print(k,v)
end
end
end