Skip to content

Instantly share code, notes, and snippets.

e2b30cb6b6b55e582a34e6362de09b42c7a564d6 55504
65cb7fd15dc70f1e3cd33fe79243ba07828d49de 55364
d9668bf2cbdb375ac008de053e2ed2e1c97f6d0e 55363
8ac2fc40f05b97510c4d6c489db746c337e6e9c0 55358
80704bc76e419aa343f0261d189a22989fa6fc5f 55277
bc64a09a0c8ee38b6fdf06e100f8c461894c02af 55279
fabecc784ee4ded951a53ae0c73e9cf7311e38a8 55279
43e25d03fb02313c990326408286e58ceced3443 55280
a8b6e3042244af1dd315e94c9349722450bca301 55875
9d5d5dcd26451fa194f4559b0cf645583bd7329c 55280
#!/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
@joliss
joliss / automatic-view-classes.coffee
Last active December 17, 2015 13:10
This is untested.
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()
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()
})
})
function MyError() {
Error.apply(this, arguments);
}
MyError.prototype = new Error();
MyError.prototype.constructor = MyError;
MyError.prototype.name = 'MyError';
console.log((new MyError('foo!')).stack)
@joliss
joliss / gist:5733886
Last active December 18, 2015 05:39
// 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()
  1. 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?

  2. 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 after import "foo".)

  3. Rails auto-loads all my Ruby files. That's super-convenient. Also for JavaScript, the Rails asset pipeline not only has //= require foo (which becomes import "foo"), but //= require_tree .. Obviously there is no 1:1 equivalent for require_tree, but do we have a

@joliss
joliss / benchmark.sh
Created November 14, 2013 16:01
Benchmark script for node-glob. Run from inside the `node-glob` repo.
#!/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
@joliss
joliss / gist:7469324
Created November 14, 2013 16:02
node-glob benchmark output
node-glob $ bash benchmark.sh
Setting up...
Bash timing:
100000
real 0m0.696s
user 0m0.266s
sys 0m0.432s
// 1
var obj = new C()
.chainedMethod1()
.chainedMethod2()
// 2
var obj = new C({
opt: true
})