| Models | Examples |
|---|---|
| Display ads | Yahoo! |
| Search ads |
This file contains hidden or 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
| YUI.add('multi', function (Y) { | |
| /** | |
| Loads different versions of YUI in sandboxed iframes and makes them available | |
| for use in the parent frame by exposing them as properties on a `Y.Multi` | |
| instance. | |
| This is primarily intended to be used for testing. You probably shouldn't use it | |
| for anything real. |
This file contains hidden or 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
| // Lack of tail call optimization in JS | |
| var sum = function(x, y) { | |
| return y > 0 ? sum(x + 1, y - 1) : | |
| y < 0 ? sum(x - 1, y + 1) : | |
| x | |
| } | |
| sum(20, 100000) // => RangeError: Maximum call stack size exceeded | |
| // Using workaround |
This file contains hidden or 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 maybe(value) { | |
| var obj = null; | |
| function isEmpty() { return value === undefined || value === null } | |
| function nonEmpty() { return !isEmpty() } | |
| obj = { | |
| map: function (f) { return isEmpty() ? obj : maybe(f(value)) }, | |
| getOrElse: function (n) { return isEmpty() ? n : value }, | |
| isEmpty: isEmpty, | |
| nonEmpty: nonEmpty | |
| } |
This file contains hidden or 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
| YUI().use("singleton-class", function (Y) { | |
| var instance1 = new Y.SingletonClass(), | |
| instance2 = new Y.SingletonClass(); | |
| Y.log(instance1 === instance2); // true! | |
| window.instance1 = instance1; | |
| }); | |
| YUI().use("singleton-class", function (Y) { |
This file contains hidden or 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
| :+1: | |
| :-1: | |
| :airplane: | |
| :art: | |
| :bear: | |
| :beer: | |
| :bike: | |
| :bomb: | |
| :book: | |
| :bulb: |
This file contains hidden or 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
| var flattenObject = function(ob) { | |
| var toReturn = {}; | |
| for (var i in ob) { | |
| if (!ob.hasOwnProperty(i)) continue; | |
| if ((typeof ob[i]) == 'object') { | |
| var flatObject = flattenObject(ob[i]); | |
| for (var x in flatObject) { | |
| if (!flatObject.hasOwnProperty(x)) continue; |
NewerOlder