Skip to content

Instantly share code, notes, and snippets.

core.register('myModule', function(sandbox){
sandbox.subscribe('init', function(){
//do stuff
});
});
var o = p.object({ x: 3 })
// adding
var o2 = o.merge({ y: 3 })
var o2 = o.union({ y: 3 })
var o2 = o.plus({ y: 3 })
var o2 = o.assoc({ y: 3 })
var o2 = o.mix({ y: 3 })
var o2 = o.add({ y: 3 })
var o2 = o.fuse({ y: 3 })
// to create immutable objects all the way down, then assign that to an identifier.
var o = #{
myFoo: #[1, 2, 3, 4],
myBar: #{ name: 'hugh' }
}
var MyModel = Backbone.Model.extend({
urlRoot: '/wibble',
clone: function(){
var attrs = _.chain(this.attributes).omit('id', 'cid').clone().value()
return new this.constructor(attrs)
}
})
var m1 = new MyModel()
var extend = function(t, f){ for ( var p in f ) t[p] = f[p]; return t }
// a Pub/Sub mixin
var Hub = {
sub: function(name, cb){
if ( ! this.channels ) this.channels = {}
if ( ! this.channels[name]) this.channels[name] = []
this.channels[name].push(cb)
return this
},
// creating a new function without members that fail a truth step
var arr = [0, 1, 2, 3]
// imperative
var arrIm = [],
isEven = function(a){ return a % 2 === 0 }
for ( var i = 0; i < arr.length; i += 1 ) {
if ( isEven(arr[i]) ) arrIm.push(arr[i])
}
var uniqWith = function(arr, fn){
return arr.reduce(function(a, item){
if ( a.some(fn.bind(null, item)) ) return a
a.push(item)
return a
}, [])
}
var arrEq = function(arr1, arr2){
return arr1.every(function(val, i){ return val === arr2[i] })
var intersectWith = function(a, b, fn){
return a.filter(function(i){
return b.some(fn.bind(null, i))
})
}
intersectWith([1, 2, 3, 4], [{id: 3}], function(a, b){ return a == b.id })
@hughfdjackson
hughfdjackson / concat-with-void.js
Last active December 10, 2015 02:19
Why void is better for iifes.
// This is our first js file. We haven't put a trailing ; on the end
var a = 3
alert(a)
// this is our second file, which we've concated on to the end of the first file to HTTP requests
void function(){
alert('hi')

From google cache: http://webcache.googleusercontent.com/search?q=cache:wwBFypSJwVUJ:www.apppicker.com/app-review/2012/07/14/teething-app-review-edited/+&cd=1&hl=en&ct=clnk&gl=us

Price: $0.99

For: iPhone 3GS, iPhone 4, iPhone 4S, iPod touch 3rd generation/4th generation, iPad

Combine the tools of good oral hygiene with a puzzle-like app with TEETHING by William Robinson. This game has you navigating your tooth between falling sweets, testing your reflexes as you go. Watch out, because if you make contact with your arch nemesis, aka sugar, your tooth will dissolve. Not to worry though, if this happens toothpaste will save the day and bring back the health of your tooth. The app is not one of the slick graphics-heavy ones like so many out there today. It was created to look and feel like an old-school eight-bit video game. This was further achieved by using only one scene. Even though it’s definitely a throw-back in the looks department, it packs a punch by being very fast-paced. You get to maneuver this to