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
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 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
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
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
# jruby 1.6.2 (ruby-1.9.2-p136) (2011-05-23 e2ea975) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [darwin-x86_64-java] | |
Michal:rice-on-rails mkuklis$ bundle exec warble config --trace | |
warble aborted! | |
stack level too deep | |
org/jruby/RubyArray.java:1602:in `each' | |
/Users/mkuklis/.rvm/gems/jruby-1.6.2@rice-on-rails/gems/railties-3.0.8/lib/rails/plugin.rb:51:in `load_deprecated_tasks' | |
/Users/mkuklis/.rvm/gems/jruby-1.6.2@rice-on-rails/gems/railties-3.0.8/lib/rails/plugin.rb:44:in `load_tasks' | |
/Users/mkuklis/.rvm/gems/jruby-1.6.2@rice-on-rails/gems/railties-3.0.8/lib/rails/application.rb:140:in `load_tasks' | |
org/jruby/RubyArray.java:1602:in `each' |
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 eqToAny (el /*, args */) { | |
var args = [].slice.call(arguments, 1); | |
if (args.length == 0) return false; | |
for (var i = 0, l = args.length; i < l; i++) { | |
if (el === args[i]) { | |
return true; | |
} | |
} | |
return 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
//1. variable declaration: | |
// declaration | |
function foo() { | |
return true; | |
var x = 1; | |
} | |
// interpretation | |
funciton foo() { |
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 debounce(fn, wait) { | |
var timeout = null; | |
return function () { | |
clearTimeout(timeout); | |
var args = arguments; | |
var ctx = this; | |
timeout = setTimeout(function () { | |
fn.apply(ctx, args); | |
}, wait); | |
} |
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 editor = new TINY.editor.edit('editor', { | |
id: "editor", | |
width: 400, | |
height:200, | |
cssclass:'te', | |
controlclass:'tecontrol', | |
rowclass:'teheader', | |
dividerclass:'tedivider', | |
controls:['bold','italic','link','unlink','image','orderedlist','unorderedlist','undo','redo'], | |
footer:false, |