Skip to content

Instantly share code, notes, and snippets.

View pulkitsinghal's full-sized avatar

Pulkit Singhal pulkitsinghal

View GitHub Profile
@pulkitsinghal
pulkitsinghal / dropbox
Created July 19, 2017 06:22 — forked from thisismitch/dropbox
/etc/init.d/dropbox
#!/bin/sh
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: dropbox service
### END INIT INFO
@pulkitsinghal
pulkitsinghal / migrate.js
Created June 2, 2016 04:10 — forked from ReedD/migrate.js
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;
@pulkitsinghal
pulkitsinghal / readme.md
Created April 28, 2016 14:01 — forked from felippenardi/readme.md
Benchmarking AngularJS performance

Benchmarking AngularJS performance

Things to optmize

  • Use one-time-bind on expressions ( {{::value}} )
  • Replace $scope.$apply() with $scope.$digest() whenever possible
  • Move filters to controllers

Measuring Watch list

To get the total watchers on the current page, you can run this script on the browser console:

@pulkitsinghal
pulkitsinghal / 01_chat.md
Last active November 28, 2016 03:36 — forked from doublemarked/1:middleware.json
Bunyan Loopback logging
doublemarked 09:50
@pulkitsinghal here’s a gist of the core of it all:
https://gist.github.com/doublemarked/e4bf329d11c55baf468f

@pulkitsinghal this will log access tokens with all log messages.
Bunyan produces JSON, so you’re essentially going to need to parse
the log to fish out things, but JSON makes it easy to do that.

For simple things (like access tokens) you can also use grep
@pulkitsinghal
pulkitsinghal / gist:2306f3f6964520e376a9
Last active August 29, 2015 14:27 — forked from klovadis/gist:2549131
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
@pulkitsinghal
pulkitsinghal / commit-msg
Last active August 29, 2015 14:26 — forked from nicoverbruggen/commit-msg
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 = /issues?\s+#(\d+)/
if !$regex.match(message)
puts "[POLICY] Please reference an issue in your commit."
exit 1
end
@pulkitsinghal
pulkitsinghal / pre-commit.rb
Last active August 29, 2015 14:26 — forked from brnrdog/pre-commit.rb
Hook to force commits to have an existant issue number related
#!/usr/bin/env ruby
require 'net/http'
require 'json'
message_file = ARGV[0]
message = File.read(message_file)
$regex = /#(\d+)/
def get_issues
uri = URI('github.com/user/repo/issues')
@pulkitsinghal
pulkitsinghal / prepare-commit-msg
Last active August 29, 2015 14:26 — forked from huguesbr/prepare-commit-msg
Git Hook - prepare-commit-msg - auto suffix commit message with issue id
#!/usr/bin/ruby
#
# Called by "git commit" with the
# name of the file that has the
# commit message, followed by
# the description of the commit
# message's source. The hook's
# purpose is to edit the commit
# message file. If the hook fails
# with a non-zero status,
@pulkitsinghal
pulkitsinghal / bootstrap.sh
Created May 29, 2012 00:14 — forked from karmi/.gitignore
Bootstrap, install and configure ElasticSearch with Chef Solo
echo -e "\nInstalling development dependencies and essential tools..." \
"\n===============================================================================\n"
yum install gcc gcc-c++ make automake install ruby-devel libcurl-devel libxml2-devel libxslt-devel vim tree curl git -y
echo -e "\nInstalling Rubygems..." \
"\n===============================================================================\n"
yum install rubygems -y
echo -e "\nInstalling and bootstrapping Chef..." \
"\n===============================================================================\n"