-
We talked about modules exporting their objects, rather than tacking them onto some global namespace object (
window.Ember
) as a side effect of loading the module. Do we have any nice patterns to translate a modules that register stuff (e.g. https://github.com/SlexAxton/require-handlebars-plugin/blob/master/demo/template/helpers/yeller.js) into a side-effect-free syntax? -
Let's assume module "foo" registers something global as a side effect. Do I read http://wiki.ecmascript.org/doku.php?id=harmony:modules#external_module_load correctly that
import "foo"
will not only fetch "foo" at compile time, but also run the "foo" module at run time, if it hasn't already run? (So any global side effects will have happened afterimport "foo"
.) -
Rails auto-loads all my Ruby files. That's super-convenient. Also for JavaScript, the Rails asset pipeline not only has
//= require foo
(which becomesimport "foo"
), but//= require_tree .
. Obviously there is no 1:1 equivalent forrequire_tree
, but do we have a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e2b30cb6b6b55e582a34e6362de09b42c7a564d6 55504 | |
65cb7fd15dc70f1e3cd33fe79243ba07828d49de 55364 | |
d9668bf2cbdb375ac008de053e2ed2e1c97f6d0e 55363 | |
8ac2fc40f05b97510c4d6c489db746c337e6e9c0 55358 | |
80704bc76e419aa343f0261d189a22989fa6fc5f 55277 | |
bc64a09a0c8ee38b6fdf06e100f8c461894c02af 55279 | |
fabecc784ee4ded951a53ae0c73e9cf7311e38a8 55279 | |
43e25d03fb02313c990326408286e58ceced3443 55280 | |
a8b6e3042244af1dd315e94c9349722450bca301 55875 | |
9d5d5dcd26451fa194f4559b0cf645583bd7329c 55280 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Log the sizes of the Ember distribution like on | |
# https://gist.github.com/joliss/5570851 | |
for i in {0..1000}; do | |
rm -r dist >&2 | |
git submodule update --init >&2 | |
bundle install --quiet >&2 | |
bundle exec rake dist >&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Em.View.reopen | |
classNameBindings: ['testingClass'] | |
testingClass: (-> | |
if Em.testing | |
if testingClass = this.valueBinding?._from?.match(/[\w|\d]+\.[\w|\d]+$/)?[0] | |
testingClass.replace('context.', '').replace('.', '__') | |
).property() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var through = require('through') | |
getSomeStream(function(err, stream) { | |
stream.pause() // pause until we are ready to attach handlers | |
process.nextTick(function() { // could be setTimeout | |
stream.pipe(process.stdout) // now we're ready to consume the stream... | |
stream.resume() | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyError() { | |
Error.apply(this, arguments); | |
} | |
MyError.prototype = new Error(); | |
MyError.prototype.constructor = MyError; | |
MyError.prototype.name = 'MyError'; | |
console.log((new MyError('foo!')).stack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I want to pass a stream containing 'your string' into a callback. | |
// Here is the working streams1 code: | |
var through = require('through') | |
// Create a paused stream and buffer some data into it: | |
var stream = through().pause().queue('your string').end() | |
// Pass stream around: | |
callback(null, stream) | |
// Now that a consumer has attached, don't forget to resume the stream: | |
stream.resume() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir benchmark.$$.tmp | |
cd benchmark.$$.tmp | |
( | |
set -e | |
echo Setting up... | |
dirnames=`echo {0..9}/{0..9}/{0..9}/{0..9}` # 10000 dirs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node-glob $ bash benchmark.sh | |
Setting up... | |
Bash timing: | |
100000 | |
real 0m0.696s | |
user 0m0.266s | |
sys 0m0.432s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
var obj = new C() | |
.chainedMethod1() | |
.chainedMethod2() | |
// 2 | |
var obj = new C({ | |
opt: true | |
}) |