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
@briancavalier
briancavalier / _background.md
Created Nov 29, 2012 — forked from unscriptable/_fast-curl-boot.md
fast ways to boot apps with curl
View _background.md

There are a couple of things that bug me about RequireJS's data-main method of single-script loading:

<script src="js/requirejs/require.js" data-main="app/main.js"></script>
  1. the built file (bundle) must be named "require.js". WAT.
  2. it just seems backwards.
  3. data-main does not follow w3c recommendations since it's not name-spaced.
View mq.css
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@briancavalier
briancavalier / poly-hulk.js
Created Jun 6, 2012 — forked from scothis/gist:2884321
toHulkCase polyfill
View poly-hulk.js
define(function() {
String.prototype.toHulkCase = function(str) {
return 'HULK SMASH PUNY ' + str.toUpperCase() + ' ARRRRRRRRRRRRR';
}
});
@briancavalier
briancavalier / builder.js
Created Mar 6, 2012 — forked from pieterv/builder.js
Builder plugin for r.js to build Wire.js files
View builder.js
/**
* @license Copyright (c) 2010-2011 Brian Cavalier
* LICENSE: see the LICENSE.txt file. If file is missing, this file is subject
* to the MIT License at: http://www.opensource.org/licenses/mit-license.php.
*/
/**
* Builder plugin for r.js
*/
define([ 'wire/base' ], function() {
View app.spec.js
define({
plugins: [
{ module: "wire/debug" }
],
somethingFromTheParent: { $ref: 'somethingFromTheParent' }
});
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){
View maskCreditCardNumber.js
function maskCreditCardNumber(value) {
function multiply(x, y) {
return x * y;
}
function identyOf(number) {
return multiply(number, 1);
}
function toArrayOfIndividualDigits(value) {
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);
}
});
@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;
}
@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)) {
You can’t perform that action at this time.