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
/* | |
Let’s say you have a publisher paper, which publishes a daily newspaper and a monthly magazine. A subscriber joe will be notified whenever that happens. | |
The paper object needs to have a property subscribers that is an array storing all sub- scribers. | |
The act of subscription is merely adding to this array. | |
When an event occurs, paper loops through the list of subscribers and notifies them. | |
The notification means calling a method of the subscriber object. | |
Therefore, when subscribing, the subscriber provides one of its methods to paper’s subscribe() method. | |
The paper can also provide unsubscribe(), which means removing from the array of subscribers. |
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
/** | |
* @constructor Animate | |
* @param {HTMLElement} el the element we want to animate | |
* @param {String} prop the CSS property we will be animating | |
* @param {Object} opts a configuration object | |
* object properties include | |
* from {Int} | |
* to {Int} | |
* time {Int} time in milliseconds | |
* callback {Function} |
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
var $ = (function (s) { | |
return function $(q) { | |
return s.call(document.querySelectorAll(q)) | |
} | |
}([].slice)); |
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(window, document, undef) { | |
// Generic library | |
var mylib = (function(){ | |
// Private implementation | |
var __mylib = { | |
/** | |
* Following property indicates whether the current rendering engine is Trident (i.e. Internet Explorer) |
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
/* | |
* jsFiddle: http://jsfiddle.net/integralist/fL2Xv/ | |
* Original: http://twitter.com/#!/ded/status/90531502097575936 | |
*/ | |
if (!Array.prototype.indexOf) { | |
Array.prototype.indexOf = function(item) { | |
return ( Math.abs( ~this.indexOf(item) ) )-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
/* | |
* The following script should be run on window.onload | |
*/ | |
/******************************************************* | |
* VARIABLE SET-UP/CACHING | |
*******************************************************/ | |
var doc = document, | |
body = doc.body, |
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
/* Rule (the entire chunk of code below can just be referred to as a single 'rule') */ | |
/* Selectors */ | |
#myID, .myClass | |
/* Declaration Block */ | |
{ | |
/* Declaration */ | |
/* Property */border: /* Value */1px solid #DCDDDE; | |
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
# taken from http://www.regular-expressions.info/lookaround.html | |
"The bad news is that most regex flavors do not allow you to use just any regex inside a lookbehind, because they cannot apply a regular expression backwards. Therefore, the regular expression engine needs to be able to figure out how many steps to step back before checking the lookbehind. | |
Therefore, many regex flavors, including those used by Perl and Python, only allow fixed-length strings. You can use any regex of which the length of the match can be predetermined. This means you can use literal text and character classes. You cannot use repetition or optional items. You can use alternation, but only if all options in the alternation have the same length. | |
PCRE is not fully Perl-compatible when it comes to lookbehind. While Perl requires alternatives inside lookbehind to have the same length, PCRE allows alternatives of variable length. Each alternative still has to be fixed-length. | |
Java takes things a step further by allowing finite repet |
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
body { | |
font: normal small Helvetica, Arial, Verdana, sans-serif; | |
} | |
h1 { | |
border-bottom: 1px solid #C00; | |
color: #666; | |
font-weight: bold; | |
margin-bottom: 10px; | |
} |
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
body { | |
font: normal small Helvetica, Arial, Verdana, sans-serif; | |
} | |
h1 { | |
border-bottom: 1px solid #C00; | |
color: #666; | |
font-weight: bold; | |
margin-bottom: 10px; | |
} |
OlderNewer