Skip to content

Instantly share code, notes, and snippets.

JSON.stringify(o, function (k,v) {
if (v && typeof v === 'object' && !isArray(v)) { // assumes an isArray function
var sorted = {},
keys = [],
key,i,len;
for (key in v) {
if (v.hasOwnProperty(key)) {
keys.push(key);
}
function increment() {
count++;
}
var a = new Y.EventTarget(),
b = new Y.EventTarget({
bubbles: true,
emitFacade: true,
prefix: 'foo'
}),
function A() { Y.Widget.apply(this,arguments); };
Y.extend(A, Y.Widget);
A.NAME = 'a';
function B() { Y.Widget.apply(this,arguments); };
Y.extend(B, Y.Widget);
B.NAME = 'b';
var a = new A(),
b = new B();
YUI.add('prop.mod-a', function (Y) {
/* Your module code here */
// shortcut to ensure Y.config.modules object is in place
Y.namespace('config.modules')['yui2-utilities'] = {
fullpath: 'http://yui.yahooapis.com/2.8.0r4/build/utilities/utilities.js'
};
Y.use('yui2-utilities', function (Y) {
var options = '', i, len;
for (var i = 0, len = ddActionsMenuData.length; i < len; ++i) {
options += '<option value="' + ddActionsMenuData[i].value + '">' +
ddActionsMenuData[i].text + '</option>';
}
var div = document.createElement('div');
div.innerHTML = '<select name="foo">' + options + '</select>';
YUI().use('node-base', function(Y) {
Y.on('click', handler(1), document);
Y.on('click', handler(2), document);
Y.on('click', handler(3), document);
if (document.addEventListener) {
document.addEventListener('click', dhandler(1), false);
document.addEventListener('click', dhandler(2), false);
document.addEventListener('click', dhandler(3), false);
myAutoComplete._isIgnoreKey = (function (original) {
return function (keyCode) {
return (keyCode > 47 && keyCode < 58) || original.apply(this, arguments);
}
})(myAutoComplete._isIgnoreKey);
// OR
YAHOO.util.Number.format = function (n, cfg) {
if (!isFinite(+n)) {
return '';
}
n = !isFinite(+n) ? 0 : +n;
cfg = YAHOO.lang.merge(YAHOO.util.Number.format.defaults, (cfg || {}));
var neg = n < 0,
absN = Math.abs(n),
<script>
/* Alternate snippet to asynchronously embed the Google Analytics script.
* This requires the following things of the pages that will contain it:
* 1. the page only include one GA tracker (common case),
* 2. the page is not be behind SSL (http, not https),
*/
var _gaq = [['_setAccount', 'UA-XXXXXX-X'],['_trackPageview']];
(function(d) {
var script = d.createElement('script'),