stopBefore(document, 'getElementById')
stopBefore('document.getElementById') // the same as the previous
stopBefore(Element.prototype, 'removeChild')
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 | |
// Stupidly simple PHP proxy for AJAX (HTTP GET) requests. Written by Kevin Lanni. | |
$dest = ''; // Set to the remote script URL (i.e. http://remotehost.com/some.php) | |
$a = array(); | |
foreach ($_GET as $k=>$v) { | |
$a[] = "{$k}={$v}"; | |
} |
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 | |
/* JSONP_Example.php | |
* Author: Kevin Lanni | |
* Description: Demonstrates how to create a simple public Web API using JSONP responses | |
* This is useful for opening Web APIs for public use without the need for proxying or other SOP work-arounds. | |
* This example does not demonstrate API keys or any other method of authentication. | |
*/ | |
// Supply a header to set the proper expectation for the client browser | |
header('Content-Type: application/json'); |
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
json2html = function(o, e) { | |
var ret, obj, n, t = '<ul/>'; | |
if (!e && $('#json_root').length === 0) { | |
e = $(t,{ | |
"id": "json_root", | |
"class": "array" | |
}).appendTo('body') | |
} else if (!e) { | |
e = $('#json_root'); |
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
xml2json = function(xml, extended) { | |
var root, out, | |
jsVar = function(s) { | |
return String(s || "").replace(/-/g,"_"); | |
}, | |
isNum = function(s) { | |
return (typeof s === "number") || String((s && typeof s === "string") ? s : "").test(/^((-)?([0-9]*)((\.{0,1})([0-9]+))?$)/); | |
}, | |
myArr = function(o) { | |
if (!o.length) { |
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
json2xml = function(o, ns, tab) { | |
if (!Array.prototype.j) Array.prototype.j = function (a) { return this.join(a||"") }; | |
var ns = ns+":"||"", m, xml = '', | |
toXml = function(v, name, ind) { | |
var i, n, m, s, hasChild, xml = ""; | |
if (v instanceof Array) { | |
for (i = 0, n = v.length; i < n; i++) { | |
xml += [ind,toXml(v[i], name, ind + '\t'),'\n'].j(); | |
} |
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 | |
class RESTRequest | |
{ | |
public $response; | |
public $code; | |
private $handle; | |
private $session; | |
private $curlopts; |
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
/** | |
* Simple CSS3 Tooltip | |
*/ | |
.tooltip{ | |
display: inline; | |
position: relative; | |
} | |
.tooltip:hover:after{ |
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
/*global document*/ | |
//a function to get DOM nodes by nodeType property. | |
//If you do not supply a value I will give you every DOM node. | |
// | |
//example: | |
// var allComments = document.getNodesByType(8); | |
// or | |
// var allComments = document.getNodesByType("COMMENT_NODE"); | |
// | |
//The accepted string values are the actual node type names, so that the |
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
// Found myself needing to do this the other day... | |
// | |
// Map an array of objects down to a single object in one pass | |
function distill (a, b) { | |
a[b.name] = b.value; | |
return a; | |
} | |
// Say you have objects that follow this format | |
var obj1 = { |
OlderNewer