Skip to content

Instantly share code, notes, and snippets.

View hshoff's full-sized avatar
📊

Harrison Shoff hshoff

📊
View GitHub Profile
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;
SELECT d, COUNT(*)
FROM test_table
WHERE d >= '2012-05-01'
GROUP BY d
ORDER BY d ASC;
// module1.js
;(function() {
console.log('module1');
})()
// crockford module1.js
;(function(){
console.log('module1');
}())
// module1.js
(function() {
console.log('module1');
})();
// module2.js
(function() {
console.log('module2');
})();
// 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
// new module1.js
(function() {
console.log('module1');
// return a function that logs it's
// arguments when invoked
return function(){
console.log(arguments);
};
})()
(function(){ return undefined; })()();
// => TypeError: undefined is not a function
// equivalent
(undefined)();
// crockford
(function(){ return undefined; }())();
// => TypeError: undefined is not a function
// 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)
// new crockford module1.js
(function(){
console.log('module1');
// return a function that logs it's
// arguments when invoked
return function(){
console.log(arguments);
};
}())
// 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