Skip to content

Instantly share code, notes, and snippets.

View tebemis's full-sized avatar

Ale Gnoli tebemis

  • Google
  • Bay Area
View GitHub Profile
require_relative '../../lib/config/runlist'
require_relative '../../lib/config/config'
require_relative '../../nutella_lib/framework_core'
# Framework bots can access all the parameters they need directly
# from the configuration file and the runlist,
# to which they have full access to.
# Access the config file like so:
# Nutella.config['broker']
# Access the runs list like so:
@tebemis
tebemis / mongoIDsAndDatesUtils.js
Created February 4, 2015 14:45
Extract object creation timestamps from Mongo object IDs and create Mongo ID with certain timestamps to query date ranges
// Cretes a Mongo ID form a timestamp
// Useful when we want to query a collection on date ranges
function idWithTimestamp(timestamp) {
// Convert string or unix time date to Date object (otherwise assume timestamp is a date)
if ( typeof(timestamp) == 'string' || typeof(timestamp) == 'number' ) {
timestamp = new Date(timestamp);
}
// Convert date object to hex seconds since Unix epoch