Skip to content

Instantly share code, notes, and snippets.

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

Mike grabbou

💭
🇦🇪🇺🇸
View GitHub Profile
@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
var Promise = require('bluebird');
function doSomethingAsync(data, callback) {
return $blueBirdPromise
.tap(function() {
console.log('Op is successful');
})
.nodeify(callback);
};
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 ] },
var _ = require('lodash');
Statuses
.findAll()
.sort({
'$date': -1 //check if $ should be here and if -1 is the order you want
})
.then(function(statuses) {
var timeOn = 0;
Line;Direction;StationA;StationB;Distance;Time
Bakerloo ;Southbound;HARROW & WEALDSTONE;KENTON;1,74;2,23
Bakerloo ;Southbound;KENTON;SOUTH KENTON;1,40;1,88
Bakerloo ;Southbound;SOUTH KENTON;NORTH WEMBLEY;0,90;1,50
Bakerloo ;Southbound;NORTH WEMBLEY;WEMBLEY CENTRAL;1,27;1,92
Bakerloo ;Southbound;WEMBLEY CENTRAL;STONEBRIDGE PARK;1,71;2,23
Bakerloo ;Southbound;STONEBRIDGE PARK;HARLESDEN;1,53;2,13
Bakerloo ;Southbound;HARLESDEN;WILLESDEN JUNCTION;1,05;1,65
Bakerloo ;Southbound;WILLESDEN JUNCTION;KENSAL GREEN;1,50;2,47
Bakerloo ;Southbound;KENSAL GREEN;QUEENS PARK;1,32;2,65
@grabbou
grabbou / gist:8d414150e99e208d820a
Last active August 29, 2015 14:21
X-Powered-By: Este
// middleware.js
import onHeaders from 'on-headers';
export default function setupMiddleware(headers = [], options = {}) {
return function onRequest(req, res, next) {
// Do the action when headers are emitted for given res
onHeaders(res, _ => {
Minutes;Value
0.000000;0.060563
0.008333;0.061365
0.016667;0.062198
0.025000;0.063057
0.033333;0.063888
0.041667;0.064706
0.050000;0.065535
0.058333;0.066328
0.066667;0.067090
Minutes;Value
0.000000;0.004045
0.008333;0.004052
0.016667;0.004097
0.025000;0.004189
0.033333;0.004260
0.041667;0.004290
0.050000;0.004309
0.058333;0.004332
0.066667;0.004360
import PureComponent from 'react-pure-render/mixin';
import React from 'react-native';
import {
View,
Text
} from 'react-native';
import TrackKeyboard from '../components/trackKeyboard.react';
const CreateOrder = React.createClass({
// Some predefined animations for you usage
export const animations = {
layout: {
spring: {
duration: 500,
create: {
duration: 300,
type: LayoutAnimation.Types.easeInEaseOut,
property: LayoutAnimation.Properties.opacity
},