Skip to content

Instantly share code, notes, and snippets.

View pulkitsinghal's full-sized avatar

Pulkit Singhal pulkitsinghal

View GitHub Profile

Install Monit

On Ubuntu 16.04, 14.04

apt-get install monit

Monit Configuration

your /etc/monit/monitrc should look like the file monitrc above.

Restart Monit

service monit restart

Monit Status

@ReedD
ReedD / migrate.js
Created January 7, 2016 20:20
Algorithm to loop through a large MongoDB collection with concurrency support.
'use strict';
var _ = require('lodash'),
async = require('async'),
Bluebird = require('bluebird'),
mongodb = Bluebird.promisifyAll(require('mongodb')),
using = Bluebird.using;
var concurrency = 3;
var totalCount = 0;
@nicoverbruggen
nicoverbruggen / commit-msg
Created February 18, 2015 14:15
Git hook that checks if you reference an issue in your commit
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
$regex = /#(\d+)/
if !$regex.match(message)
puts "[POLICY] Please reference an issue in your commit."
exit 1
end
@raymondfeng
raymondfeng / create-admin-role.js
Created September 29, 2014 21:08
create-admin-role.js
var app = require('../app');
// Admin users
var adminUsers = require('../config/users.json').admins;
app.models.role.findOrCreate({where: {name: 'admin'}}, {name: 'admin'},
function (err, role) {
if (err) {
return console.error(err);
}
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created April 17, 2014 08:32
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@hkasera
hkasera / mongo-struc.js
Created March 6, 2014 10:12
A script for mongo shell to get the collection structure.
var conn = new Mongo();
db = conn.getDB(<DB_NAME>);
var cursor = db.<COLLECTION>.find();
var items = [];
items = cursor.toArray();
var dbstruc = {};
for (var i = 0; i < items.length; ++i) {
var target = items[i];
getKP(target,dbstruc);
}
@klovadis
klovadis / gist:2549131
Created April 29, 2012 10:03
How to use optional arguments in node.js
// example function where arguments 2 and 3 are optional
function example( err, optionalA, optionalB, callback ) {
// retrieve arguments as array
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
// first argument is the error object
@msmith
msmith / couchdb-ec2-install.sh
Created August 25, 2011 17:26
Set up CouchDB on EC2
#!/bin/bash
#
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance.
#
# Must be run with root privileges
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5)
#
export BUILD_DIR="$PWD"