Skip to content

Instantly share code, notes, and snippets.

Brian Cavalier briancavalier

Block or report user

Report or block briancavalier

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 screening.js
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
View screening.js
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
View tiny Promise.js
// Promise implementation based on unscriptable's minimalist Promise:
// https://gist.github.com/814052/
function Promise () {
this._thens = [];
}
Promise.prototype = {
/* This is the "front end" API. */
@briancavalier
briancavalier / semantic tiny Promise.js
Created Feb 11, 2011 — forked from unscriptable/tiny Promise.js
An attempt at a more sematic promise API
View semantic tiny Promise.js
function Promise () {
this._resolve = [];
this._reject = [];
this._progress = [];
}
Promise.prototype = {
/* This is the "front end" API. */
@briancavalier
briancavalier / universal-module.js
Created Sep 30, 2011 — forked from millermedeiros/universal-module.js
Universal JavaScript Module, supports AMD (RequireJS), Node.js, and the browser.
View universal-module.js
// Define a global define() that works in the current environment
(function(global) {
var define;
define = global.define;
// If AMD, just use existing global.define
if(!(typeof define === 'function' && define.amd)) {
@briancavalier
briancavalier / bp1.js
Created Nov 9, 2011 — forked from unscriptable/bp1.js
boilerplate for CommonJS, AMD, plain old global hackfest
View bp1.js
(function (namespace, myLib) {
//Set up myLib here.
if (typeof define == 'function' && define.amd) {
define(myLib);
}
else {
namespace.myLib = myLib;
}
View ZZZ_MyView.js
// MyView.js when concatenated together using cram.js
// cram.js needs two new features to make this work:
// 1. an option to NOT normalize module ids
// 2. an option to more easily exclude modules from the build (wire plugins, for instance)
define('./myView/controller', {
_onClick: function (e) {
this.rootNode.classList.toggle(this.states.selected);
}
});
View maskCreditCardNumber.js
function maskCreditCardNumber(value) {
function multiply(x, y) {
return x * y;
}
function identyOf(number) {
return multiply(number, 1);
}
function toArrayOfIndividualDigits(value) {
View auth.js
define(["my/module"], function(module){
return {
wire$plugin: function authPlugin(ready, destroyed, options){
var providers = options.providers || [];
return {
ready: function(resolver, proxy, wire){
You can’t perform that action at this time.