Skip to content

Instantly share code, notes, and snippets.

View ifandelse's full-sized avatar

Jim Cowart ifandelse

View GitHub Profile
@ifandelse
ifandelse / main.js
Created May 15, 2014 22:15
Using Lodash with Postal in place of underscore
// Let's pretend we wanted to take the require js configuration from
// https://github.com/postaljs/postal.js/blob/master/example/amd/js/main.js
// and tell it to use lodash instead of underscore.
// Since postal 0.9.0 and earlier expect the module ID (in AMD
// environments) to be "underscore", all you have to do is define a path
// for "underscore" and point it to lodash:
require.config( {
paths : {
underscore : "../../../bower/lodash/lodash",
/** @jsx React.DOM */
define([
"react",
"machina",
"mousetrap"
], function(React, machina, Mousetrap) {
return machina.Fsm.extend({
initialize: function() {
@ifandelse
ifandelse / webpack.md
Last active August 29, 2015 14:04
Webpack Shim Question

In Require.js, it's possible to take a dependency on a "plain JS" lib (i.e. - it places a value on the window). For example, in the require.config, you'd do something along these lines:

  require.config({
      paths: {
        myAmdModule: "/path/to/my/amd/module",
        thirdPartyJS: "/path/to/plain/global/lib",
        jquery: "/path/to/jquery"
      },
 
@ifandelse
ifandelse / AMDOutput.js
Last active August 29, 2015 14:05
Trying to understand traceur's module transpilation output
define([], function() {
"use strict";
var myVar = {};
var $__default = myVar;
return {
get default() {
return $__default;
},
__esModule: true
};
@ifandelse
ifandelse / when_gen.js
Created August 25, 2014 18:07
Adapting ES6 presentation example from Q to when.js
var gen = require('when/generator');
gen.call(function* () {
try {
var [pratt, ferrell] = yield when.all([
read("emmet.json"),
read("lordbusiness.json")
]);
render(pratt);
render(ferrell);
} catch (e) {