This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.addEvent = function(evt, handler, useCapt) { | |
//JUST A CHECK TO HANDLE “onclick” and “click” as evt | |
if(evt.match(“^on”)) | |
evt = evt.substr(2); | |
if(this.attachEvent) | |
return this.attachEvent('on' + evt, handler); // FOR IE | |
else if(this.addEventListener) | |
return this.addEventListener(evt, handler, useCapt); // OTHERS | |
else { | |
//IF BOTH FAILS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Function to sanitize values received from the form. Prevents SQL injection */ | |
function clean($str) { | |
$str = @trim($str); | |
if(get_magic_quotes_gpc()) { | |
$str = stripslashes($str); | |
} | |
return mysql_real_escape_string($str); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Usage: | |
var x = //Some DOM Element | |
var attr = { | |
style: "position: absolute; top: 0", | |
width: "500", | |
onmouseover: "this.style.background='#ddd'" | |
} | |
setAttributes(x,attr); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Boopathi | |
* @description Debounce a function call. | |
* @usage function(){}.debounce() | |
*/ | |
Function.prototype.debounce = function(threshold, execAsap) { | |
var func = this, timeout; | |
return function debounced(){ | |
var obj= this, args = arguments; | |
function delayed() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// everyone's new favorite closure pattern: | |
(function(window,document,undefined){ ... })(this,this.document); | |
// when minified: | |
(function(w,d,u){ ... })(this,this.document); | |
// which means all uses of window/document/undefined inside the closure | |
// will be single-lettered, so big gains in minification. | |
// it also will speed up scope chain traversal a tiny tiny little bit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Use socat to proxy git through an HTTP CONNECT firewall. | |
# Useful if you are trying to clone git:// from inside a company. | |
# Requires that the proxy allows CONNECT to port 9418. | |
# | |
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run | |
# chmod +x gitproxy | |
# git config --global core.gitproxy gitproxy | |
# | |
# More details at http://tinyurl.com/8xvpny |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name UTM param stripper | |
// @author Paul Irish | |
// @namespace http://github.com/paulirish | |
// @version 1.1 | |
// @description Drop the UTM params from a URL when the page loads. | |
// @extra Cuz you know they're all ugly n shit. | |
// @include http://* | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- so it turns out that the object tag can act like an iframe | |
but the cool thing is you can nest object tags inside eachother for a fallback path. | |
what this means is you can "objectframe" a site.. and if it fails.. (site down, offline, whatever).. it'll use the next one. | |
so you can objectframe the live site and fallback to a screenshot. | |
or something. | |
demo at : http://jsfiddle.net/paul/CY2FQ/1/ | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defining constructor function | |
function ObjectConstructor(message) { | |
// TODO: Add your own initialization code here | |
this.message = message || 'Hello Prototype World!'; | |
}; | |
// Defining an instance function | |
ObjectConstructor.prototype.sayHello = function() { | |
alert(this.message); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce(fn, wait) { | |
var timeout = null; | |
return function () { | |
clearTimeout(timeout); | |
var args = arguments; | |
var ctx = this; | |
timeout = setTimeout(function () { | |
fn.apply(ctx, args); | |
}, wait); | |
} |
OlderNewer