Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View briancavalier's full-sized avatar

Brian Cavalier briancavalier

  • Pittsburgh
View GitHub Profile
@briancavalier
briancavalier / _background.md
Created November 29, 2012 13:48 — forked from unscriptable/_fast-curl-boot.md
fast ways to boot apps with curl

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.
@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 June 6, 2012 19:55 — forked from scothis/gist:2884321
toHulkCase polyfill
define(function() {
String.prototype.toHulkCase = function(str) {
return 'HULK SMASH PUNY ' + str.toUpperCase() + ' ARRRRRRRRRRRRR';
}
});
@briancavalier
briancavalier / builder.js
Created March 6, 2012 12:47 — forked from pieterv/builder.js
Builder plugin for r.js to build Wire.js files
/**
* @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() {
define({
plugins: [
{ module: "wire/debug" }
],
somethingFromTheParent: { $ref: 'somethingFromTheParent' }
});
define(["my/module"], function(module){
return {
wire$plugin: function authPlugin(ready, destroyed, options){
var providers = options.providers || [];
return {
ready: function(resolver, proxy, wire){
function maskCreditCardNumber(value) {
function multiply(x, y) {
return x * y;
}
function identyOf(number) {
return multiply(number, 1);
}
function toArrayOfIndividualDigits(value) {
@briancavalier
briancavalier / ZZZ_MyView.js
Created November 23, 2011 12:40 — forked from unscriptable/ZZZ_MyView.js
cujo-ish view/widget
// 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 November 9, 2011 03:18 — forked from unscriptable/bp1.js
boilerplate for CommonJS, AMD, plain old global hackfest
(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 September 30, 2011 18:02 — forked from millermedeiros/universal-module.js
Universal JavaScript Module, supports AMD (RequireJS), Node.js, and the browser.
// 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)) {