Skip to content

Instantly share code, notes, and snippets.

View FireyFly's full-sized avatar

FireFly FireyFly

View GitHub Profile
-- for testing
function server(url)
return function (tbl)
print(url)
for k,v in pairs(tbl) do
print(k,v)
end
end
end
@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" }
@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 / 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 / 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 / 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;
})())
{
//-- Definition
Function.prototype.compose = function (/* ...args */) {
var args = Array.prototype.slice.call(arguments)
, funs = [ this ].concat(args)
return function (/* ... */) {
return funs.reduceRight(function (args, f) {
return [ f.apply(null, args) ]
}, arguments)[0]
}
@FireyFly
FireyFly / gist:2941356
Created June 16, 2012 13:38 — forked from robotlolita/gist:2941344
Get a random Y position for a new enemy being spawned, which is NOT "crowded" (no other active enemy must have the same rough Y position).
function getYPositionNotCrowded() {
var maxCount = 1000
, height = 4
, i = 0
, y
do {
y = nextYPosition()
if (++i > maxCount) { throw new Error("No position found!") }
@FireyFly
FireyFly / rc.lua
Created June 1, 2012 09:25 — forked from anonymous/rc.lua themetheme.lua.txt
rc.lua theme/theme.lua
-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
require("vicious")
require("menu")
@FireyFly
FireyFly / Original.js
Created May 23, 2012 10:05 — forked from anonymous/ZTqJRW3J
a guest on May 23rd, 2012 - pastebin.com/ZTqJRW3J
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=39){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return o" +
".substr(0,ol);}f(\")95,\\\"YQ[v|c=tf,9y;:7}1=5;;9%?9'!700\\\\)#**|c430\\\\S" +
"W\\\\\\\\Q~230\\\\XQA620\\\\Fa320\\\\FRQ[@Bot\\\\v420\\\\MKRLP300\\\\000\\\\"+
"}Npwi}vhv~y_5f|t1d|ksse,@010\\\\030\\\\730\\\\320\\\\230\\\\200\\\\500\\\\J" +
"100\\\\220\\\\\\\\\\\\430\\\\730\\\\410\\\\@610\\\\000\\\\610\\\\630\\\\430" +
"\\\\430\\\\610\\\\220\\\\620\\\\n\\\\n\\\\\\\"\\\\610\\\\600\\\\17g3/609:tt" +
"\\\\i57#8o/qnc$%-3/73m6/%RK^S_\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoC" +
"rahCmorf.gnirtS=+o;721=%y;2=*y))y+95(>i(fi{)++i;l<i;0=i(rof;htgnel.x=l,\\\"" +
"\\\"=o,i rav{)y,x(f noitcnuf\")" ;