Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block 0xBADC0FFEE

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View contacts.js
// Don't care much about inheritance at this point, but I'll probably attempt it at
// some point via cloning ancestor schema's
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var Contact = new Schema({
_type: String,
name: String
var should = require('chai').should();
db.get(1234, function (err, doc) {
0xBADC0FFEE / extend.js
Created Apr 19, 2014
Backbone's extend method
View extend.js
// Helper function to correctly set up the prototype chain, for subclasses.
// Similar to `goog.inherits`, but uses a hash of prototype properties and
// class properties to be extended.
var extend = function(protoProps, staticProps) {
var parent = this;
var child;
// The constructor function for the new subclass is either defined by you
// (the "constructor" property in your `extend` definition), or defaulted
// by us to simply call the parent's constructor.
Created Apr 19, 2014
AngularJS + Coffeescript Constructor Class with Inheritance
app = angular.module 'myapp', []
# simple class exemple - minification safe
class MySimpleCtrl
@$inject: ['$scope']
constructor: (@scope) ->
# attach viewmodel data to the scope:
@scope.demo = 'Simple class demo'
View crossbrowser-xhr.js
function getXmlHttp(){
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
0xBADC0FFEE / lazy-html.js
Created Apr 24, 2014
Lazy loading expensive DOM
View lazy-html.js
directive('lazyHtml', function() {
return {
transclude: 'element',
priority: 1200,
terminal: true,
restrict: 'A',
compile: function(element, attr, linker) {
return function ($scope, $element, $attr) {
var visible = false;
var stopWatching = $scope.$watch($attr.lazyHtml, function(value){
0xBADC0FFEE / jquery-live.js
Created Apr 24, 2014
$.live() like function in pure js
View jquery-live.js
var live = (function () {
var eventRegistry = {};
function dispatchEvent(event) {
var targetElement =;
eventRegistry[event.type].forEach(function (entry) {
var potentialElements = document.querySelectorAll(entry.selector);
var hasMatch =, targetElement) >= 0;
View ngd.js
directive('$directiveName$', function factory($injectables$) {
return {
// priority: 0,
// restrict: 'A', // Attribute (default): <div my-directive="exp"></div>
// restrict: 'E', // Element name: <my-directive></my-directive>
// restrict: 'C', // Class: <div class="my-directive: exp;"></div>
spctl --add /Path/To/
You can’t perform that action at this time.