Skip to content

Instantly share code, notes, and snippets.

View joubertnel's full-sized avatar

Joubert Nel joubertnel

  • Netflix
  • Los Angeles, CA
View GitHub Profile
@joubertnel
joubertnel / gist:1879571
Created February 21, 2012 22:46
verbose increment
var count = this.get('count') + 1;
this.set('count', count);
@joubertnel
joubertnel / gist:1879499
Created February 21, 2012 22:35
prepare balls
prepare: function() {
var i;
var balls = [];
for (i=0; i < 100; i++) {
balls.push(new Demo.Ball({ number:i }));
}
this.set('balls', balls);
Demo.BallAreaView.create().appendTo('body');
},
@joubertnel
joubertnel / gist:1879483
Created February 21, 2012 22:31
gotballs template
<script type="text/x-handlebars" id="handlebars-template" data-template-name="ball_area">
{{#each Demo.balls}}
<div class="ball-view">
<div class="ball" {{bindAttr style="style"}}>
{{content}}
</div>
</div>
{{/each}}
</script>
@joubertnel
joubertnel / gist:1605809
Created January 13, 2012 12:13
Private function - values via closure - Google Closure Compiler optimization
enter:function(a){
var b=get(this,"view"),
c=function(){b.appendTo(a.get("rootElement")||"body")};
b&&(Ember.$.isReady===YES?c():Ember.$(document).ready(function(){c()}))},
@joubertnel
joubertnel / gist:1605803
Created January 13, 2012 12:12
Private function - argument passing - Google Closure Compiler optimization
var b=get(this,"view");
b&&(Ember.$.isReady===YES?b.appendTo(a.get("rootElement")||"body"):Ember.$(document).ready(function(){b.appendTo(a.get("rootElement")||"body")}))}
pmap: function(operation, mapping, then) {
var ret = new Array(this.length);
var remainingWork = this.length;
this.forEach(function(x, idx, i) {
operation.call(null, x, function() {
var extendedArgs = Array.prototype.slice.call(arguments);
var mappedVal;
extendedArgs.push(x);
@joubertnel
joubertnel / gist:1597102
Created January 11, 2012 22:15
parallel map (pmap) over file names, reading them asynchronously
function readSource(after) {
console.log('Reading source files...');
settings.src.pmap(fs.readFile, function(err, data, filename) {
return {'file': filename,
'data': data};
}, after);
}
@joubertnel
joubertnel / gist:1596981
Created January 11, 2012 21:53
verbose coordination of async operations on a sequence
function readSource(after) {
var remainingWork;
var fileContents;
console.log('Reading source files...');
remainingWork = settings.src.length;
fileContents = new Array(remainingWork);
settings.src.forEach(function(f, index) {
fs.readFile(f, function(err, data) {
@joubertnel
joubertnel / buildjs.json
Created January 10, 2012 10:17
buildjs.json for ember-runtime
{
"build_dir": "build",
"app_file": "build/ember-runtime.js",
"src": [ "lib/core.js",
"lib/system/string.js",
"lib/ext/string.js",
"lib/ext/function.js",
@joubertnel
joubertnel / buildjs.json
Created January 10, 2012 10:16
buildjs.json for ember-metal
{
"build_dir": "build",
"app_file": "build/ember-metal.js",
"src": [ "lib/core.js",
"lib/platform.js",
"lib/utils.js",
"lib/accessors.js",
"lib/properties.js",
"lib/computed.js",