This file contains 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
find_broken_links(Urls) -> | |
lists:foreach(fun(Url) -> spawn(url_checker, is_working_url, [self(), Url]) end, Urls) | |
get_results(length(Urls)). | |
get_results(N) -> get_results(0, N, []). | |
get_results(N, N, BrokenLinks) -> {ok, BrokenLinks}; | |
get_results(Cnt, N, BrokenLinks) -> | |
receive | |
{_Client, Url, true} -> get_results(Cnt + 1, N, BrokenLinks); |
This file contains 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 handleSearchRequests(req, res) { | |
if (req.params['toggle'] === 'A') { | |
doToggleSearch(req.params, res); | |
} else { | |
doRegularSearch(req.params, res); | |
} | |
} |
This file contains 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 handleSearchRequests(req, res) { | |
var isAToggleSearch = (req.params['toggle'] === 'A'); | |
if (isAToggleSearch) { | |
doToggleSearch(req.params, res); | |
} else { | |
doRegularSearch(req.params, res); | |
} | |
} |
This file contains 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 add = function(a,b) { return a + b; } | |
var add5 = _.partial(add, 5); | |
var fourTwenty = add5(415); //Add 5 to 415 |
This file contains 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 runsLater = function(runAfterTime) { | |
return function(func) { | |
setTimeout(func, runAfterTime); | |
} | |
} |
This file contains 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 runsIn10Seconds = runsLater(10*1000); | |
runsIn10Seconds(function() { | |
console.log("I am running 10 seconds later, son!"); | |
}); |
This file contains 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 add5 = add(5, <second-argument-will-come-later>); |
This file contains 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 setVar(arg) { | |
this.var = arg; | |
} | |
var obj = Object.create(null); | |
obj.setVar = setVar; | |
obj.setVar('hello'); | |
console.log(obj.var); // => 'hello' |
This file contains 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 setVar(arg) { | |
this.var = 'hello'; | |
} | |
var obj = Object.create(null); | |
setVar.call(obj, 'hello'); | |
console.log(obj.var); // => 'hello' |
This file contains 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 outer() { | |
this.foo = 'blah'; | |
function inner() { | |
console.log(this.foo); | |
} | |
inner(); | |
} | |
var obj = Object.create(null); | |
outer.call(obj); |