This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 falsy values in JS: | |
- false | |
- null | |
- undefined | |
- '' // empty string | |
- 0 // number 0 | |
- NaN | |
all other values are truthy (including "false") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.method = function (name, func) { | |
if (!this.prototype[name]) { | |
this.prototype[name] = func; | |
return this; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var constructor = function (spec, my) { | |
var that, other private instance variables; | |
my = my || {}; | |
Add shared variables and functions to my | |
that = a new object; | |
Add privileged methods to that | |
return that; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var memoizer = function (memo, formula) { | |
var recur = function (n) { | |
var result = memo[n]; | |
if (typeof result !== 'number') { | |
result = formula(recur, n); memo[n] = result; | |
} | |
return result; | |
}; | |
return recur; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo1 = { | |
name: "hello from foo1", | |
print: function () { | |
return this.name; | |
} | |
}; | |
var foo2 = { | |
name: "hello from foo2" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof Array.isArray === "undefined") { | |
Array.isArray = function (arg) { | |
return Object.prototype.toString.call(arg) === "[object Array]"; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doThisDoThat = function () { | |
console.log("do this"); | |
doThisDoThat = function () { | |
console.log("do that"); | |
}; | |
}; | |
doThisDoThat() // do this | |
doThisDoThat() // do that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inherit(C, P) { | |
var F = function () {}; | |
F.prototype = P.prototype; | |
C.prototype = new F(); | |
C._super = P.prototype; | |
C.prototype.constructor = C; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://gist.github.com/854622 | |
(function(window,undefined){ | |
// Prepare our Variables | |
var | |
History = window.History, | |
$ = window.jQuery, | |
document = window.document; | |
// Check to see if History.js is enabled for our Browser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/processing/rmagick.rb:248: [BUG] Segmentation fault | |
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] | |
-- control frame ---------- | |
c:0112 p:---- s:0553 b:0553 l:000552 d:000552 CFUNC :read | |
c:0111 p:0054 s:0549 b:0549 l:000548 d:000548 METHOD /Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/processing/rmagick.rb:248 | |
c:0110 p:0011 s:0540 b:0540 l:000539 d:000539 METHOD /Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/processing/rmagick.rb:132 | |
c:0109 p:0015 s:0535 b:0535 l:000525 d:000534 BLOCK /Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/uploader/processing.rb:77 | |
c:0108 p:---- s:0531 b:0531 l:000530 d:000530 FINISH | |
c:0107 p:---- s:0529 b:0529 l:000528 d:000528 CFUNC :each |