Skip to content

Instantly share code, notes, and snippets.

View geddski's full-sized avatar

Dave Geddes geddski

View GitHub Profile
@geddski
geddski / service-demystification-test.js
Created June 19, 2013 16:40
Demystification of Angular's services.
var expect = chai.expect;
describe('services', function(){
var goat, monkey, monkey2, Donkey, tiger1, tiger2, lion;
beforeEach(function(){
//load the module
module('app');
//configure providers
@geddski
geddski / oo-pattern.js
Created January 8, 2013 08:53
Pattern for Object Oriented JavaScript. You can run these tests with Mocha and play around with it. You'll need node installed, and then install should (locally) and mocha (globally): 1. download oo-pattern.js somewhere (~/js for example) 2. $cd ~/js 3. npm install should 4. $npm install -g mocha 5. mocha oo-pattern.js NOTE: I think inheritance …
/* Pattern for OOP in JavaScript */
//TODO see if safe way to add inheritsFrom to Function
var should = require('should');
function inherit(C, P){
var F = function(){}; //intermediary function between Parent and Child
F.prototype = P.prototype; //link intermediary function to Parent
var funcs = C.prototype; //keep track of any existing functions on the Child prototype
C.prototype = new F(); //link child to intermediary function
for (var attrname in funcs) {
@millermedeiros
millermedeiros / gist:882682
Created March 23, 2011 05:47
RequireJS Async Load Plugin
/*!
* RequireJS plugin for async dependency load like JSONP and Google Maps
* @author Miller Medeiros
* @version 0.0.1 (2011/03/23)
* Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
define(function(){
function injectScript(src){
var s, t;