Skip to content

Instantly share code, notes, and snippets.

View pulkitsinghal's full-sized avatar

Pulkit Singhal pulkitsinghal

View GitHub Profile
@pulkitsinghal
pulkitsinghal / notes.md
Created October 9, 2016 20:01
.git/hooks/post-checkout: line 9: ./node_modules/.bin/post-checkout: No such file or directory

Error:

.git/hooks/post-checkout: line 9: ./node_modules/.bin/post-checkout: No such file or directory

This happens when you jump between installing different versions of pre-git ... the file .git/hooks/post-checkout gets left behind as an artifact placed by one of the installs just delete/remove it and move on with life.

@pulkitsinghal
pulkitsinghal / ListMatchingProductsResponse.js
Last active September 14, 2016 18:10
Attempt at creating a schema for ListMatchingProductsResponse (amazon/mws)
var ListMatchingProductsResponse_Module_Factory = function () {
var ListMatchingProductsResponse = {
name: 'ListMatchingProductsResponse',
defaultElementNamespaceURI: 'http:\/\/mws.amazonservices.com\/schema\/Products\/2011-10-01',
typeInfos: [{
localName: 'OfferType',
propertyInfos: [{
name: 'buyingPrice',
required: true,
elementName: 'BuyingPrice',
@pulkitsinghal
pulkitsinghal / notes.md
Last active April 9, 2017 21:49
How it all ties together: cli, npm, package.json, pretest, test, mocha

Both configurations of package.json hare equally valid:

  1. npm test will run linting and then testing:
"test": "jshint . && mocha",
  1. npm test will still run linting and then testing:
@pulkitsinghal
pulkitsinghal / future.json
Created August 20, 2016 15:19
Multiple logins for Docker Hub - part2
{
"auths": {
"https://index.docker.io/v1/": [
"myWork/repos": {"auth": "xxx"},
"me/repos": { "auth": "xxx" }
]
}
}
@pulkitsinghal
pulkitsinghal / current.json
Last active August 20, 2016 15:19
Multiple logins for Docker Hub - part1
{
"auths": {
"https://index.docker.io/v1/": {"auth": "xxx"}
}
}
@pulkitsinghal
pulkitsinghal / shortcuts.md
Last active May 14, 2023 12:07
mac: WebStorm to Visual Studio (VSCode) key mappings
@pulkitsinghal
pulkitsinghal / sample.sh
Last active January 3, 2018 18:47
combine find and grep
# (a) ignore certain folders
# like: `node_modules, .cache, .cordova, .heroku, .a127, .npm` etc.
# (b) look in package.json only
# (c) find case-insensitve matches to the word: commit
# (d) `-o` means "OR" ... for example, given: `expr1 -o expr2`, expr2 is not evaluated if expr1 is true.
find ~/ \( \
-name node_modules \
-o -name '.cache' \
-o -name '.cordova' \
-o -name '.heroku' \
@pulkitsinghal
pulkitsinghal / KPIndex.test.js
Created July 8, 2016 18:35
Use `loopback-testing` module with mongodb
// path: <project>/test/KPIndex.test.js
require('debug').enable('loopback:connector:*'); //enable namespace
var debug = require('debug')('loopback:connector:*'); //reload debug
var lt = require('loopback-testing');
var assert = require('assert');
var app = require('../server/server.js'); //path to app.js or server.js
var KpIndex;
@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 / sample.js
Last active August 15, 2017 16:38
Using bluebird to scroll through (in pages/chunks) a large dataset in mongodb and nodejs
/**
* Motivation:
* Wanted to put together some code that used:
* - BlueBird (promises)
* - MongoDB NodeJS Driver
* - and paging that did not rely on skip()
*
* References:
* Based on articles such as:
* https://scalegrid.io/blog/fast-paging-with-mongodb/