Skip to content

Instantly share code, notes, and snippets.

var dupEntry = function(array, index){
var head = array.slice(0, index)
var val = array[index]
var tail = array.slice(index + 1)
return head.concat([val, val]).concat(tail)
}
var build = function(){
var args = Array.prototype.slice.call(arguments)
var obj = {}
for ( var i = 0, len = args.length; i < len; i += 2 ) obj[args[i]] = args[i + 1]
return obj
}
var name1 = 'x'
var name2 = 'y'
cd () {
if [[ "x$*" = "x..." ]]
then
cd ../..
elif [[ "x$*" = "x...." ]]
then
cd ../../..
elif [[ "x$*" = "x....." ]]
then
cd ../../../..
var OR = function(a, b){
return function(val){ return a(val) || b(val) }
}
var AND = function(a, b){
return function(val){ return a(val) && b(val) }
}
var XOR = function(a, b){
return function(val){ return !a(val) === b(val) }
define([
'Backbone'
], function(
Backbone
){
// I've evalled the entire file at this point, using cmd + A, cmd + Enter
Backbone // cmd + Enter returns me `undefined`, although in the application, it would be the Backbone library object
})
// basically boo.js, but with all the fluffy stripped away :3
var extend = function(to, from){
for ( var p in from ) to[p] = from[p]
return to
}
var Base = {
extend: function(props){
return extend(Object.create(this), props)
var poly = require('poly')
// The Haskell Eq Typeclass
var Eq = poly({
eq: function(a, b){ return !Eq.notEq(a, b) },
notEq: function(a, b){ return !Eq.eq(a, b) }
})
// tag the prototype with a unique value
var arrSplit = function(arr, i){
return [arr.slice(0, i), arr.slice(i)]
}
arrSplit([1, 2, 3, 4, 5], 1)
  1. foo

bar

  1. foo bar
var bind = function(fn){
var args = [].slice.call(arguments, 1)
return function(){
var args2 = [].slice.call(arguments)
return fn.apply(this, args.concat(args2))
}
};
bind(function(a, b, c){ return a + b + c }, 1, 2)(3) //= 6