Skip to content

Instantly share code, notes, and snippets.

@GCheung55
GCheung55 / gist:73988
Created March 4, 2009 20:31 — forked from divoxx/gist:73976
dispatch some method everytime a dom change
var reapplyTimeoutId = null
$each(['insertBefore', 'replaceChild', 'removeChild', 'appendChild'], function(methodName) {
Node.prototype["_" + methodName] = Node.prototype[methodName]
Node.prototype[methodName] = function() {
var ret = this["_" + methodName](arguments[0], arguments[1])
if (reapplyTimeoutId) { clearTimeout(reapplyTimeoutId) }
reapplyTimeoutId = setTimeout(Attitude.applyDefinitions.bind(Attitude), 100)
return ret
}
Fx.Scroll.implement({
scrollToCenter: function(el, axes, offset){
axes = axes ? $splat(axes) : ['x', 'y'];
el = $(el);
var to = {},
pos = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize(),
edge = {
// -*- Mode: Javascript; tab-width: 4; -*-
/*
---
privides: [String.bound, String.prototype.bind]
description: Lets you bind to a method that doesn't exist yet, and then swap out methods without re-wiring all your codez
author: Thomas Aylott <subtlegradient.com>
copyright: 2009 Thomas Aylott
license: MIT Style
...
*/
@GCheung55
GCheung55 / Collection.js
Created December 2, 2009 23:37 — forked from keeto/Collection.js
Collection Native
function Collection(list){
this.list = $splat(list || []);
this.length = this.list.length;
};
new Native({name: 'Collection', initialize: Collection, generics: false});
(function() {
// Some browsers don't iterate over natives, so brute force is required.
/*
---
source: http://gist.github.com/133677
provides: document.write
description: MooTools based document.write replacement
requires: MooTools
author: Thomas Aylott -- SubtleGradient.com
thanks: Daniel Steigerwald -- daniel.steigerwald.cz
@GCheung55
GCheung55 / Queue.js
Created February 15, 2011 23:16 — forked from cpojer/Queue.js
cpojer's Queue (Chain)
(function(){
this.Queue = new Class({
Extends: Chain,
call: function(){
if (this.busy) return this;
this.busy = true;
@GCheung55
GCheung55 / FB.init.detector.js
Created October 25, 2011 19:26 — forked from jiggliemon/FB.init.detector.js
Facebook Init detector!
$(document).bind('FB.ready',function(){
console.log('FB is ready');
FB.api('/me',function(response){
console.log(response);
});
});
var _FB = {
count: 0
,interval : setInterval(function(){
@GCheung55
GCheung55 / Slick.Finder-lite.js
Created January 18, 2012 00:25 — forked from arian/Slick.Finder-lite.js
A lite version of Slick.Finder for modern browsers/mobile.
/*
---
name: Slick.Finder
description: The new, superfast css selector engine.
provides: Slick.Finder
requires: Slick.Parser
...
*/
(function(){
@GCheung55
GCheung55 / apf_release.prepend.js
Created March 21, 2012 18:21 — forked from SchizoDuckie/apf_release.prepend.js
Cloud9 IDE Touch Enabler Monkeypatch
/**
* A proof of concept monkeypatch to make Cloud9 IDE work on a tablet.
* Since i'm an extremely lazy bastard I prepended this snippet directly in package/client/js/apf_release.js
*
* What does it do?
* - It fires a doubleclick for a 2-finger tap
* - It fires a mousewheel up / down event for a 2-finger swipe up / down.
*
* How does it work?
* Prepend the functions below to <cloud9>/package/client/js/apf_release.js, save, load in tablet.
@GCheung55
GCheung55 / bootstrap.js
Created March 22, 2012 21:59 — forked from sebmarkbage/bootstrap.js
Using link.js options
var loader = require('../path/to/link');
loader.alias('package', '../path/to/package.js');
loader.alias('package2', '../path/to/package2.js');
loader.base('../path/to/my/root/folder/');
loader.load('main');