Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
if(typeof asyncRequest == 'undefined') {
asyncRequest = {};
}
asyncRequest.REQUEST = function() {
function handleReadyState(o,callback) {
o.onreadystatechange = function() {
function loadScript(url,callback){var script=document.createElement("script");script.type="text/javascript";if(script.readyState){script.onreadystatechange=function(){if(script.readyState=="loaded"||script.readyState=="complete"){script.onreadystatechange=null;callback();}};}else{script.onload=function(){callback();};}script.src=url;document.getElementsByTagName("head")[0].appendChild(script);}
LazyLoad=function(){var f=document,g,b={},e={css:[],js:[]},a;function j(l,k){var m=f.createElement(l),d;for(d in k){if(k.hasOwnProperty(d)){m.setAttribute(d,k[d])}}return m}function h(d){var l=b[d];if(!l){return}var m=l.callback,k=l.urls;k.shift();if(!k.length){if(m){m.call(l.scope||window,l.obj)}b[d]=null;if(e[d].length){i(d)}}}function c(){if(a){return}var k=navigator.userAgent,l=parseFloat,d;a={gecko:0,ie:0,opera:0,webkit:0};d=k.match(/AppleWebKit\/(\S*)/);if(d&&d[1]){a.webkit=l(d[1])}else{d=k.match(/MSIE\s([^;]*)/);if(d&&d[1]){a.ie=l(d[1])}else{if((/Gecko\/(\S*)/).test(k)){a.gecko=1;d=k.match(/rv:([^\s\)]*)/);if(d&&d[1]){a.gecko=l(d[1])}}else{if(d=k.match(/Opera\/(\S*)/)){a.opera=l(d[1])}}}}}function i(r,q,s,m,t){var n,o,l,k,d;c();if(q){q=q.constructor===Array?q:[q];if(r==="css"||a.gecko||a.opera){e[r].push({urls:[].concat(q),callback:s,obj:m,scope:t})}else{for(n=0,o=q.length;n<o;++n){e[r].push({urls:[q[n]],callback:n===o-1?s:null,obj:m,scope:t})}}}if(b[r]||!(k=b[r]=e[r].shift())){return}g=g||f.getElement
if(typeof asyncRequest == 'undefined') {
asyncRequest = {};
}
asyncRequest.REQUEST = function() {
function handleReadyState(o,callback) {
o.onreadystatechange = function() {
@thinkphp
thinkphp / gist:1384012
Created November 21, 2011 21:31
Inheritance ruby-style
def ("Human") ({
init: function(name) {
this.name = name;
this.isAlive = true;
this.energy = 1;
},
eat: function(){
this.energy++;
}
});
@thinkphp
thinkphp / gist:1388565
Created November 23, 2011 12:33
Class.extend Inheritance
var Human = Class.extend({
init: function(name) {
this.name = name;
this.energy = 1;
this.isAlive = true;
},
eat: function() {
this.energy++;
}
@thinkphp
thinkphp / gist:1388653
Created November 23, 2011 13:26
$extend(subClass,superClass)
var Human = function(name){
this.name = name;
this.isAlive = true;
this.energy = 1;
};
Human.prototype.eat = function() {
return this.energy++;
};
@thinkphp
thinkphp / gist:1393131
Created November 25, 2011 09:34
Dmitry A. Soshnikov Class
/**
* class.js
* @author Dmitry A. Soshnikov
*/
function Class(params) {
/**
* Constructor function
* If not specified, use default
@thinkphp
thinkphp / gist:1404261
Created November 29, 2011 10:04
currying
function addEvent(elem, evType, fn, useCapture) {
if(elem.addEventListener) {
return elem.addEventListener(evType, fn, useCapture);
} else if(elem.attachEvent){
var r = elem.attachEvent('on'+evType,fn);
return r;
} else {
elem['on'+evType] = fn;
}
}
@thinkphp
thinkphp / gist:1437638
Created December 6, 2011 10:06
inherit.py
#inherit.py
class SchoolMember:
'''Represents any school member'''
def __init__(self, name, age):
self.name = name
self.age = age
print 'Initialized SchoolMember constructor: %s' % self.name