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
SELECT u.country, COUNT(distinct user_id), COUNT(distinct hosting_id), COUNT(*) | |
FROM users u | |
JOIN hostings h ON (u.id = h.user_id) | |
JOIN reservations r ON (u.id = r.host_id) | |
WHERE h.has_availability = '1' AND r.status = '1' AND r.created_at >= '2011-01-01' | |
GROUP BY u.country; |
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
SELECT d, COUNT(*) | |
FROM test_table | |
WHERE d >= '2012-05-01' | |
GROUP BY d | |
ORDER BY d ASC; |
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
// module1.js | |
;(function() { | |
console.log('module1'); | |
})() | |
// crockford module1.js | |
;(function(){ | |
console.log('module1'); | |
}()) |
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
// module1.js | |
(function() { | |
console.log('module1'); | |
})(); | |
// module2.js | |
(function() { | |
console.log('module2'); | |
})(); |
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
// crockford problem | |
(function(){console.log('module1');}())(function(){console.log('module2');}()); | |
// => module1 | |
// => module2 | |
// => TypeError: undefined is not a function | |
// it invokes module1 | |
(function(){ console.log('module1'); }()) | |
// => module1 |
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
// new module1.js | |
(function() { | |
console.log('module1'); | |
// return a function that logs it's | |
// arguments when invoked | |
return function(){ | |
console.log(arguments); | |
}; | |
})() |
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(){ return undefined; })()(); | |
// => TypeError: undefined is not a function | |
// equivalent | |
(undefined)(); | |
// crockford | |
(function(){ return undefined; }())(); | |
// => TypeError: undefined is not a function |
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
// it invokes module1 | |
(function(){ console.log('module1'); return function(){ console.log(arguments); };}()) | |
// => module1 | |
//it invokes module2 | |
(function(){ console.log('module2'); }()); | |
// => module2 | |
// equivalent | |
(function(){ console.log(arguments); })(undefined) |
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
// new crockford module1.js | |
(function(){ | |
console.log('module1'); | |
// return a function that logs it's | |
// arguments when invoked | |
return function(){ | |
console.log(arguments); | |
}; | |
}()) |
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
// problem | |
(function(){console.log('module1');})()(function(){console.log('module2');})(); | |
// => module1 | |
// => TypeError: undefined is not a function | |
// crockford problem | |
(function(){console.log('module1');}())(function(){console.log('module2');}()); | |
// => module1 | |
// => module2 | |
// => TypeError: undefined is not a function |