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
| /* | |
| |-------------------------------------------------------------------------- | |
| | jQuery plugin | |
| |-------------------------------------------------------------------------- | |
| | By Ben Cooling (https://github.com/bencooling, http://bcooling.com.au) | |
| | | |
| | Plugin with: | |
| | - Public api for programitically calling plugin methods | |
| | - Options for overiding default configuration values | |
| | - AMD compatability |
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
| <!-- markup --> | |
| <img data-src="/image/to/lazy/load.jpg" src="" /> | |
| <script type="text/javascript"> | |
| lazyLoad : function($images){ | |
| $images.each(function(i, el){ | |
| var $el = $(el); | |
| if (!el.loaded){ | |
| $el.attr('src', $el.attr('data-src')); | |
| el.loaded=1; |
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(factory) { | |
| 'use strict'; | |
| if (typeof define === 'function' && define.amd) { | |
| define(['jquery'], factory); | |
| } else if (typeof exports !== 'undefined') { | |
| module.exports = factory(require('jquery')); | |
| } else { | |
| factory(jQuery); | |
| } |
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
| 'use strict'; | |
| /* | |
| |-------------------------------------------------------------------------- | |
| | Requirejs configuration | |
| |-------------------------------------------------------------------------- | |
| | | |
| | This file is used by both the browser & command line optomisation | |
| | tool (see gruntfile.js) | |
| | |
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 stream = require('stream'); | |
| var a = new stream.Readable({ | |
| read: function(){} | |
| }); | |
| var b = new stream.Transform({ | |
| transform: function (chunk, encoding, done) { | |
| var str = chunk.toString() + 'bah'; | |
| this.push(str); |
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
| "use strict"; | |
| var BbPromise = require('bluebird'); | |
| function delay(ms) { | |
| var deferred = BbPromise.pending(); | |
| setTimeout(function(){ | |
| deferred | |
| .fulfill("Hello "+ ms); | |
| }, ms); |
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
| // method on prototype | |
| function Foo(){} | |
| Foo.prototype.me = function(){ return "Foo"; }; | |
| function Bah(){} | |
| Bah.prototype = new Foo(); | |
| Bah.prototype.me = function(){ | |
| return Object.getPrototypeOf(Object.getPrototypeOf(this)).me() + ' & Bah'; | |
| }; |
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
| /* demonstrate process lifecycle | |
| --------------------------------*/ | |
| console.log('Start process'); | |
| // Event is fired when user kills process (ctl+d) | |
| process.on('SIGINT', function() { | |
| console.log('I\'m dying.'); | |
| setTimeout(function(){ | |
| process.exit(1); |
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
| # /etc/init/testjob.conf | |
| # Two basic stanzas that define purpose of job script and who created it | |
| description "A test job file for experimenting with Upstart" | |
| author "Ben Cooling" | |
| # Run after system services and processes have already loaded (to prevent any conflict) | |
| start on runlevel [2345] | |
| exec echo Test Job ran at `date` >> /var/log/testjob.log |