Skip to content

Instantly share code, notes, and snippets.

View fleon's full-sized avatar

fleonus fleon

View GitHub Profile
@fleon
fleon / add-jquery.js
Created February 20, 2015 17:37
Useful Bookmarklets for Developers
// javascript:
var script = document.createElement('script');
var protocol = window.location.protocol;
if (protocol.indexOf('file') >= 0) {
protocol = 'http:';
}
script.src = protocol + '//code.jquery.com/jquery-1.11.2.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
@fleon
fleon / observe-function.js
Last active August 29, 2015 14:16
Tell me when this updates
//javascript:
function observeFn(obj, fnName, before, after) {
var originalFn = obj[fnName],
noop = function () {};
before = typeof before === 'function' ? before : noop;
after = typeof after === 'function' ? after : noop;
obj[fnName] = function () {
var args = [].slice.call(arguments);
before({
args: args,
@fleon
fleon / DOMFootprint.js
Last active August 29, 2015 14:22
DOMFootprint
/**
* Creates a new DOMFootprint for the given HTML node.
* @param {Node} element The HTML node to create a footprint for.
*/
function DOMFootprint(element) {
this.element = element;
this.capture();
}
DOMFootprint.prototype = {
@fleon
fleon / Character Selection Scene
Last active December 12, 2015 02:28
A demonstration of how a non-linear storyline and a series of events/actions can be decoupled from a game's codebase using YAML. If any of the actions in the YAML are re-ordered, the gameplay changes without changing the codebase at all.
---
# Character Selection Scene
###
speakers:
- Dr. Cyrus:
normal: CharacterAvatar_DrCyrus.png
sad: CharacterAvatar_DrCyrus_Sad.png
@fleon
fleon / gist:4953492
Created February 14, 2013 15:20
jquery: get nearest element
/**
* Gets the immediate adjacent element node to this node. In order of priority,
* this would return a next sibling, previous sibling or the parent node.
* The returned node has two properties set on it:
* * relationship: either of 'previousSibling', 'nextSibling' or 'parentNode'.
* * proximity: the distance between this node and the nearest element node.
* (the number of non-element nodes in between plus one.)
*
* @return {jQuery} Returns a jquery object containing the adjacent node.
*/
@fleon
fleon / gist:4990685
Last active December 13, 2015 23:19
loc - major projects in the last 4 years
1. Editor
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Javascript 132 2280 4250 9462
HTML 33 0 0 585
-------------------------------------------------------------------------------
SUM: 165 2280 4250 10047
-------------------------------------------------------------------------------
@fleon
fleon / gist:5263474
Created March 28, 2013 14:20
Stackify
Function.prototype.stackify = function () {
var fn = this;
return function () {
fn = fn.toString();
var fns = fn.substring(fn.indexOf("{") + 1, fn.lastIndexOf("}")).split('\n');
fns.forEach(function (fn_str) {
fn = function() {
eval(fn_str);
};
setTimeout(function () {
@fleon
fleon / SPLGameScene.yaml
Created May 16, 2013 03:08
Demo map yaml
---
# Game Scene
Variables:
- Player:
- If PlayerGender = Male: Elric
- Else: Amy
Speakers:
- Elric:
@fleon
fleon / gist:5804029
Created June 18, 2013 09:38
Get position from a corner of the screen in cocos2d
typedef enum {
FLScreenCornerTopLeft = 0,
FLScreenCornerTopRight,
FLScreenCornerBottomLeft,
FLScreenCornerBottomRight
} FLScreenCorner;
CGPoint FLGetPositionFromScreenCorner(CGPoint offset, FLScreenCorner corner, CGSize windowSize)
{
if (corner == FLScreenCornerBottomLeft)
@fleon
fleon / animation.json
Created July 27, 2013 18:11
Flash animation to JSON
{ "instance1" : { "data" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAACvCAYAAACiubO3AAAHOklEQVR42u2dy49VRRDG71/n+4WvlRo36sDoII8ZBCUiysYRNDEIiTGiaKJgMNHBBTjEhSPGxBeJGoeIRomviGwUlq09ybnpezjnnq6qr7qrz6GTSmYxq1+6qr569Lkj19NzZvWs27X/gDt5+tPO/x31EcDbJ066ax9c7655YMYdfm9pWBD+vXzZ7X/nmLt+ZnYNwOAgeAC7Xn7F3fTwxjGAQUHwAOZf3O9u2zw/AWAwEDyA2Wf3ujsWto/jwKAg/PTrb2sA7nrscXfdQxuuAODtxMrp/kLwAO7fvcfdvWOnu3F2rhGAt6+/X+0nhCoGeAC3bNzcCqDXECoAt2/dNhWAt9//utA/CF4HeAB3btvRGAjrFnNGJQLwFgqiwUA4tPTBGEBdELXZ1sV9/YHw0edfjAE0CaLeQwgBtAmiNjvw1pHyIXz27XdjANMEUZvFqEXTEEIx5O2GDY+QAMSqRbMQ/rx4cQJAlyCSCCWzEHxJXAFYt2WBBSBWKJmEcHzlkzGAWEEk0QjmIIRu4ANhrCBqsnVzm8qEELpBrCCSagRTEEI3oAiiNlt89bWyIIRu4AWRFABFI5iBULkBRxC12bEPl8uBELoBRxBJNUJ2CL5DVLkBVxBJNUJ2CEeXT41vARIARSNkheCDYQUADWFm9zNlQAi7RDG9Qi2NkA2CrxDDW4CGQEmP2SCEynCQEL459+MEAG+3ProFCoGSHrNA8GOzOgR0evzh51/sQgj7hZoQqCcZhFAY1Q2pFO/9X3qbhRAKI00I1PSYDMK0W0CZJiHb7MkhhMKoyXKmxyQQ6vJYGwI1PSaBUBdGdfPN1FzVYxIITcKobmi1yDmqEKplilQQqNWjOoQ2YaQpmTnpURVCkzzWVouczKAGYZowqtvNc5tgEGIHsOoQuoSRplrkpEcVCOFaTW