Skip to content

Instantly share code, notes, and snippets.

View grabbou's full-sized avatar
💭
🇦🇪🇺🇸

Mike grabbou

💭
🇦🇪🇺🇸
View GitHub Profile
FeedItem.aggregate({
// you want to group all the things by status key
$group: {
_id: '$statusName', // assuming you have `statusName` field in your collections, prefix with `$`.
timeOn: {
// $cond takes 3 arguments as an array, cond expression, true expression and false expression
$cond: [
// if event was active, we want to add the milliseconds to timeOn
{ $eq: [ "$wasActive", true ] },
@grabbou
grabbou / gist:ead3e217a5e445929f14
Last active March 24, 2017 02:13
How to use ES6 generators with Hapi.js <3
import co from 'co'
// Generator controller,
// this.models refers to Sequelize models added with server.bind()
function* loginController(request) {
let user = yield this.models.User.find({
where: {
email: request.payload.email
}
var Promise = require('bluebird');
function doSomethingAsync(data, callback) {
return $blueBirdPromise
.tap(function() {
console.log('Op is successful');
})
.nodeify(callback);
};
@grabbou
grabbou / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@grabbou
grabbou / .travis.yml
Created August 19, 2014 08:27
Code coverage integration for CodeClimate / TravisCI & Mocha
language: node_js
node_js: ["0.11", "0.10"]
env:
CODECLIMATE_REPO_TOKEN: <your_token>
before_script:
- npm install -g istanbul
- npm install -g mocha
- npm install -g codeclimate-test-reporter