Skip to content

Instantly share code, notes, and snippets.

@cfv1984
cfv1984 / gist:4660968
Created January 29, 2013 01:46
Initial idea for a plastic HTML structure for the game
<!DOCTYPE html>
<html>
<head>
<title>Browser based RPG</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="./css/game.css">
</head>
<body>
<article>
<header>
project root
->js
--->ocanvas.min.js (go get it)
--->klass.min.js (go get it)
--->engine.js (we'll be making this one bit by bit later)
--->game.js (we'll be making this one bit by bit later)
->css
---->game.css (we'll be making this one bit by bit later)
->img (we'll be putting our images here)
->sound (we'll be putting our audio here)
You're a thick-glasses, khaki-shorts-white-shirt, boring-studies-major kind of geek.
Last night, you went to sleep in your "Match GoGoGo" themed bed, and you woke up when a weird looking cross somewhere between a dinosaur and a large pig bit you in the thigh.
After punting the... thing? and pinching yourself a couple times without success and crying for a while, you decide to take a look around and find high ground like those survival shows say you should.

Neutron/Auth

A pluggable authentication system that can be extended nearly infinitenly, works decently in PHP<5.3, and takes a granular (method-specific) approach to security.

Approach (high level)

As it stands now, the module is centered around enabling calls to a given method to require a series of things to happen before it can run.

@cfv1984
cfv1984 / pomo-usage.js
Last active December 15, 2015 07:09
This is how you use Pomo.js
window.onload = function() {
/*
Set a default domain for the Pomo.getText calls. If omitted,
all calls to getText need to pass the domain set on Pomo.load,
unless none was passed, in which case getText doesn't require a domain
*/
Pomo.domain = 'translation_domain';
//return a plain string instead of a translation object
Pomo.returnStrings = true;
@cfv1984
cfv1984 / aliasing_pomo_gettext.js
Last active December 15, 2015 07:29
This is how you alias Pomo.getText(msg_id, options = {}) to __(msg_id, options = {})
var __ = (function(){
var _ = !!window.Pomo? window.Pomo : (!!window.__Pomo? window.__Pomo: false); //is Pomo there? get it
var gettext_wrap = function(word, options){return _.getText(word, options)}; // aliases getText
gettext_wrap = !!_? gettext_wrap: false; //if Pomo can be found, alias it
if(!gettext_wrap){
throw new "Pomo can't be found";
}
return gettext_wrap;
})();
@cfv1984
cfv1984 / gist:239ef6f0a69987687d27
Created February 11, 2015 21:15
Caching a promise in a reproduceable way
function cachedPromising(){
var def = $q.defer();
if(!cachedPromising.cached_value)
promising().then(function(data){cachedPromising.cached_value = data; def.resolve(cachedPromising.cached_value) });
else def.resolve(cachedPromising.cached_value);
return def.promise;
}
function weightedRandomBoolean(odds){
var odds, rand;
rand = Math.random();
return rand < (odds / 100)? true : false;
}
function getFirstNPercentOfTime(number_1, number_2, odds){
return weightedRandomBoolean(odds)? number_1 : number_2;
}
var cfv = {};
// Original is (C) Andrea Giammarchi - Mit Style License
cfv.Array = (function(){
function extendedArray(length){
if(arguments.length === 1 && typeof length === "number") this.length = -1 < length && length === length << 1 >> 1 ? length : this.push(length);
else if(arguments.length) this.push.apply(this, arguments);
};
function Array(){};
Array.prototype = [];
extendedArray.prototype = new Array;
@cfv1984
cfv1984 / jquery-extend-without-jquery.js
Last active September 29, 2023 20:28
jquery extend, minus jQuery
var extend = function(){
function isFunction(fn){ return typeof(fn) === "function" && fn.constructor === Function }
function isArray(ar){ return ar instanceof Array }
function isPlainObject(obj){ return typeof obj == 'object' && obj.constructor == Object }
var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false;
if(typeof target === "boolean"){
deep = target;
target = arguments[i] || {};