Skip to content

Instantly share code, notes, and snippets.

View pinalbhatt's full-sized avatar
💭
from the desk of Pinal Bhatt

Pinal Bhatt pinalbhatt

💭
from the desk of Pinal Bhatt
View GitHub Profile
@pinalbhatt
pinalbhatt / gist:2fc114f817a1d294e6ea
Last active September 12, 2015 01:36 — forked from cakebaker/gist:823574
Nicer interface for removing query string params with Node.js
var urlLib = require('url');
function UrlAdapter(urlString) {
this.urlObj = urlLib.parse(urlString, true);
// XXX remove the search property to force format() to use the query object when transforming the url object to a string
delete this.urlObj.search;
}
exports.UrlAdapter = UrlAdapter;
@pinalbhatt
pinalbhatt / JSTips.js
Last active May 28, 2016 20:21
JavaScript Snippets
// Empty an Array http://davidwalsh.name/empty-array
myArray = []; // bad
myArray.length = 0; // good!
//http://www.w3schools.com/js/js_performance.asp
//bad
for (i = 0; i < arr.length; i++) {}
//good
var l = arr.length;
@pinalbhatt
pinalbhatt / isNullOrWhitespace.js
Created June 22, 2015 12:05
Javascript isNullOrWhitespace
function isNullOrWhitespace( input ) {
if (typeof input === 'undefined' || input == null) return true;
return input.replace(/\s/g, '').length < 1;
}
@pinalbhatt
pinalbhatt / meteorjs.sh
Last active August 29, 2015 14:22
MeteorJS
#install/reinstall/update
curl https://install.meteor.com/ | sh
#Version Check
meteor --version
@pinalbhatt
pinalbhatt / SelectAllCB.js
Created June 9, 2015 13:43
Select-All-Checkboxes
//http://stackoverflow.com/questions/14245769/check-all-checkboxes-in-page-via-developer-tools
//run this in developer console.
(function() {
var aa = document.querySelectorAll("input[type=checkbox]");
for (var i = 0; i < aa.length; i++){
aa[i].checked = true;
}
})()
@pinalbhatt
pinalbhatt / gem.sh
Created May 26, 2015 02:21
gem commands
#http://guides.rubygems.org/command-reference/
gem install <gemName>
gem uninstall <gemName>
sudo gem install jekyll-contentblocks
gem list #LISTING INSTALLED GEMS
sudo gem update #Update installed gems to the latest version
@pinalbhatt
pinalbhatt / nvm.sh
Created May 19, 2015 13:58
NVM - Node Version Manager
#https://github.com/creationix/nvm
nvm ls #If you want to see what versions are installed
nvm ls-remote #If you want to see what versions are available to install
nvm current
nvm install <version>
nvm install 0.12.3
nvm install iojs 2.0.2
@pinalbhatt
pinalbhatt / tsd.sh
Created May 19, 2015 13:39
Type Script Defs
npm install tsd -g
tsd -h
tsd --version
#Install Packages/Libs
tsd query <itemName> --resolve --overwrite --save --action install
tsd query node --resolve --overwrite --save --action install
tsd query express body-parser cookie-parser morgan --resolve --overwrite --save --action install
#install bower
sudo npm install bower -g
#bower.json https://github.com/bower/bower.json-spec
bower init
#bower-installer Tool for installing bower dependencies that won't include entire repos
#https://www.npmjs.com/package/bower-installer
npm install -g bower-installer
@pinalbhatt
pinalbhatt / codeVettingTasks.js
Created May 19, 2015 13:34
Gulp Code Review
'use strict';
var gulp = require('gulp');
var gUtil = require('./../gulp.utils.js')();
gulp.task('codeReview', function() {
gUtil.log('Analyzing source .JS files with JSCS & JSHint');
return gulp
.src(gUtil.configs.serverJS)
.pipe(gUtil.GP.if(gUtil.args.verbose, gUtil.GP.print()))