- npm install parse --save
- tsd install parse --save // if you use Typescript
gulpfile.js
| function map() { | |
| emit(1, { | |
| sum: this.value, // the field you want stats for | |
| min: this.value, | |
| max: this.value, | |
| count: 1, | |
| diff: 0 | |
| }); | |
| } |
| // derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm | |
| function map() { | |
| emit(1, // Or put a GROUP BY key here | |
| {sum: this.value, // the field you want stats for | |
| min: this.value, | |
| max: this.value, | |
| count:1, | |
| diff: 0, // M2,n: sum((val-mean)^2) | |
| }); |
| pragma solidity ^0.4.11; | |
| /** | |
| * @title SafeMath | |
| * @dev Math operations with safety checks that throw on error | |
| */ | |
| library SafeMath { | |
| function mul(uint256 a, uint256 b) internal returns (uint256) { | |
| uint256 c = a * b; |
| # Committing changes to a repo via the Github API is not entirely trivial. | |
| # The five-step process is outlined here: | |
| # http://developer.github.com/v3/git/ | |
| # | |
| # Matt Swanson wrote a blog post translating the above steps into actual API calls: | |
| # http://swanson.github.com/blog/2011/07/23/digging-around-the-github-api-take-2.html | |
| # | |
| # I was not able to find sample code for actually doing this in Ruby, | |
| # either via the HTTP API or any of the gems that wrap the API. | |
| # So in the hopes it will help others, here is a simple function to |
| var mongoose = require('mongoose'); | |
| var Schema = mongoose.Schema; | |
| //Database connection | |
| var uristring = 'mongodb://localhost/test'; | |
| var mongoOptions = { }; | |
| mongoose.connect(uristring, mongoOptions, function (err, res) { | |
| if (err) { | |
| console.log('Error when connecting to: ' + uristring + '. ' + err); |
| // NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension | |
| { | |
| // Settings | |
| "passfail" : false, // Stop on first error. | |
| "maxerr" : 100, // Maximum error before stopping. | |
| // Predefined globals whom JSHint will ignore. | |
| "browser" : true, // Standard browser globals e.g. `window`, `document`. |
| module['exports'] = function bot (hook) { | |
| var request = require('request'); | |
| var TOKEN = hook.env.bot_scheduler_token; | |
| var ENDPOINT = 'https://api.telegram.org/bot' + TOKEN; | |
| console.log(hook.params); | |
| // generic handler to log api call responses | |
| var handler = function (err, httpResponse, body) { | |
| var response = JSON.stringify({ |
| var dbh = require("../migrations"), | |
| relationName = "time_zones"; | |
| exports.up = function (next) { | |
| dbh.schema.createTable( | |
| relationName, | |
| function (table) { | |
| table.string("code", 50).primary(); | |
| table.timestamps(); | |
| table.integer("utc_offset").notNullable(); |
| var socketIO = require('socket.io'), | |
| io; | |
| // hapi plugin registration | |
| exports.register = function(plugin, options, next) { | |
| // this is the hapi specific binding | |
| io = socketIO.listen(plugin.servers[0].listener); | |
| io.sockets.on('connection', function(socket) { | |
| socket.emit({msg: 'welcome'}); |