Skip to content

Instantly share code, notes, and snippets.

View cadorn's full-sized avatar

Christoph cadorn

View GitHub Profile
@wilsonpage
wilsonpage / module.js
Created March 3, 2012 17:55
How to define a module for both AMD and CommonJS compatibility
/**
* Registers module as CommonJS or AMD if support is found
* and creates an exports object for the module to use
*
* @param {boolean} cjs
* @param {boolean} amd
* @param {Object} ex
* @return {Object}
*/
var exports = (function(cjs, amd, ex){
@pmuellr
pmuellr / LICENSE
Created February 29, 2012 14:55
wip - Apache LICENSE file for weinre
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
@creationix
creationix / jsonparse.js
Created February 13, 2012 23:20
event-only version of jsonparse
// Named constants with unique integer values
var C = {};
// Tokenizer States
var START = C.START = 0x11;
var TRUE1 = C.TRUE1 = 0x21;
var TRUE2 = C.TRUE2 = 0x22;
var TRUE3 = C.TRUE3 = 0x23;
var FALSE1 = C.FALSE1 = 0x31;
var FALSE2 = C.FALSE2 = 0x32;
var FALSE3 = C.FALSE3 = 0x33;
@domenic
domenic / README.md
Last active June 24, 2021 16:37
Using promises in a UI context

The scenario:

  • We are writing a digital textbook-reading app.
  • Most of the time you have a "basic" license for your textbook, but one (and only one) of your computers can request an "enhanced" license.
  • You can only print from the computer with the enhanced license.

The problem statement:

@kriskowal
kriskowal / module-proposal-diffs.md
Created December 9, 2011 18:43
(Un)CommonJS Asynchronous Module Proposal Differences

In both cases below, ID is the exports object of the "id" module.

require.ensure(["id"], function (require) {
    var ID = require("id");
})
@domenic
domenic / gist:1370488
Created November 16, 2011 16:08
Discussion of AMD vs. CommonJS Modules/2.0

Just want to chime in that I'm glad people are still interested in CommonJS Modules/2.0. We have a working implementation that hopefully will be of interest, and have factored out the generally applicable parts of our test suite. Also see the announcement thread on the CommonJS list.

That said, personally I've been a bit disappointed with the CommonJS community's lack of enthusiasm on Modules/2.0. We picked it up early in our project lifecycle, and ran with it full speed. At the time it seemed like a more standardized alternative to AMD.

However, over time it's become clear that AMD has not only won mindshare but also has a much more active group of maintainers and a better, more egalitarian standards process. Whereas, Modules/2.0 has only the perennially busy Wes Garland, leaving a self-hosted PDF s

@akiellor
akiellor / main.js
Created November 14, 2011 02:19
CommonJS implementation of Polyglot for Rhino.
var polyglot = require('polyglot');
polyglot.register('coffee', require('coffee-script').CoffeeScript.compile);
polyglot.require('math').square(2);
@tlrobinson
tlrobinson / better-twitter.js
Created May 27, 2011 23:17
Hack to make NewTwitter use HTML5 pushState instead of annoying hash fragments.
twttr.secrets.html5Routing = true;
twttr.router._changeUrlAndCallAction = function(p) {
return twttr.Router.prototype._changeUrlAndCallAction.call(this, p.replace("#!/", ""));
}
twttr.router._changeUrlAndCallAction(window.location.hash);
@140bytes
140bytes / LICENSE.txt
Created May 9, 2011 16:13
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@guybrush
guybrush / nodeconf_2011.md
Created May 6, 2011 07:22
a list of slides from nodeconf 2011