Skip to content

Instantly share code, notes, and snippets.

@ben-ng
ben-ng / index.js
Created November 16, 2013 20:23
requirebin sketch
var Ribcage = require('ribcage-view')
, OuterView
, InnerView
, myView;
InnerView = Ribcage.extend({
events: {
'click a': 'handleClick'
}
, template: function () {
@ben-ng
ben-ng / jshint.json
Created January 8, 2014 19:28
Linting preferences
{
"browser": true,
"node": true,
"esnext": true,
"globals": {},
"globalstrict": true,
"laxcomma": true,
"strict": false,
"quotmark": true,
"smarttabs": true,
, getComments: function () {
if(!this.comments)
throw new Error('You need to loadComments before you can get comments');
return this.comments.map(function (comment) {
var obj = comment.toJSON();
obj.relativeDate = relative(obj.updated);
return obj;
});
@ben-ng
ben-ng / index.js
Created January 11, 2014 01:16
requirebin sketch
var Backbone = require('backbone')
, $ = require('jquery')(window)
, View
, myView
, testModel;
Backbone.$ = $;
testModel = new Backbone.Model();
@ben-ng
ben-ng / leaky.js
Last active January 3, 2016 10:59
var MyView = Ribcage.View.extend({
afterInit: function (opts) {
this.action = opts.action;
}
, beforeRender: function () {
this.button = new ButtonView({
action: this.action
});
}
, afterRender: function () {
func main() {
runloop := func() {
// Recovers from panics
defer func() {
if r := recover(); r != nil {
runloop() // why doesn't this compile?? "undefined: runloop"
}
}()
@ben-ng
ben-ng / gist:9500587
Created March 12, 2014 03:55
closure/asynchrony/hoisting
// 1 (closures/asyncrony)
function sleepsort (input) {
for(var i=0; i<input.length; i++) {
setTimeout(function () {
console.log(i);
}, i * 1000);
console.log('iterated');
}
};
var http = require('http')
, fs = require('fs');
http.createServer(function(request, response){
response.writeHead(200, {'Content-Type': 'text/html' });
fs.createReadStream('index.html').pipe(response);
}).listen(8080);
{{#selectTag options selected}}
{{/selectTag}}
#######################################
Finding jobs...
61 jobs found:
D0-D13012-MO
A thing some-thing
My new site 00-new
A test job FAKE-000
Office fakejob#
My apartment 00-house
D0-A13806-00