Skip to content

Instantly share code, notes, and snippets.

View dineshsprabu's full-sized avatar

Dineshprabu S dineshsprabu

  • Bangalore, India.
View GitHub Profile
@dineshsprabu
dineshsprabu / isString.js
Created February 21, 2016 16:18
[NodeJS] Check a variable String or not in NodeJS
/* Best way to check whether a variable is string or not */
function isString(o) {
return typeof o == "string" || (typeof o == "object" && o.constructor === String);
}
@dineshsprabu
dineshsprabu / starting_mongodb_wiredtiger_storage_engine.txt
Last active February 26, 2016 09:50
[Mongo] Starting MongoDB with wiredTiger Storage Engine
/* mongodb version 3.2 */
mongod --storageEngine wiredTiger --dbpath="./data/"
/* Migrate data from mmapv1 by taking a dump of data from db using mmapv1 and restore on wiredTiger */
/* Ref: https://gist.github.com/dineshsprabu/06f2ede79753ff4f43f5 */
@dineshsprabu
dineshsprabu / oops_example_nodejs.js
Created February 29, 2016 05:43
[NodeJS] OOPS example for NodeJS
var crawler = function(initialIPPool){
//private variable
var privateVariable = 10;
//instance variable;
this.pool = initialIPPool;
//private function
var privateCrawler = function(privatePool){
@dineshsprabu
dineshsprabu / return_monk_existing_promise.js
Created March 10, 2016 07:22
[NodeJS] Using Monk existing Promise
/*Insert collection returns promise*/
var insertCollection = function(collectionName,doc){
var collection = db.get(collectionName);
return collection.insert(doc);
}
/* using the function which returns promise */
insertCollection('collection_name',{'key':'value'})
.success(function(){
@dineshsprabu
dineshsprabu / insert_multiple_document_monk.js
Last active March 10, 2016 08:27
[NodeJS] Inserting Multiple Documents using Monk
var Promise = require('bluebird');
var monk = require('monk');
var db = //your db connection;
/*Inserting multiple doc is possible collection.col.insert
But it will not return promise, so returning our own promise*/
var insertMultiple = function(collectionName, docArray){
return new Promise(function(resolve,reject){
@dineshsprabu
dineshsprabu / jekyll_install_ubuntu_14_04.txt
Last active March 13, 2016 11:46
[JEKYLL] Installing jekyll on ubuntu 14.04
Dependencies
sudo apt-get install ruby ruby-dev make gcc nodejs
Jekyll Installation:
sudo gem install jekyll --no-rdoc --no-ri
If jekyll installation fails use the below command to install.
@dineshsprabu
dineshsprabu / github_pages_adding_cname.txt
Last active March 13, 2016 12:34
[GITHUB-PAGES] Adding custom domain name to github pages
1. Create a file CNAME on the gh-pages Branch.
2. Type your domain name and save the CNAME file. eg. dppages.com
3. Goto you domain settings on domain registered site (godaddy, bigrock, etc.,).
4. Add the IPs below on the 'A' record.
192.30.252.153
192.30.252.154
@dineshsprabu
dineshsprabu / jekyll_outside_access.md
Last active March 15, 2016 03:37
[JEKYLL] Making jekyll site accessible from outside

By Default 'jekyll serve' makes jekyll accessible on 127.0.0.1 (localhost).

To make it accessible by outsiders, use --host 0.0.0.0 with it.

jekyll serve --host 0.0.0.0

@dineshsprabu
dineshsprabu / finding_document_size_mongodb.js
Created March 21, 2016 12:41
[Mongo] Finding Document Size in MongoDB
/* This will return size of document object in bytes */
Object.bsonsize(<document>);
@dineshsprabu
dineshsprabu / shadow_div.css
Created March 24, 2016 14:05
[CSS] Div with Shadow
.shadow-div{
-moz-box-shadow:5px 5px 7px rgba(33,33,33,1);
/* Safari+Chrome */
-webkit-box-shadow: 5px 5px 7px rgba(33,33,33,.7);
/* Opera */
box-shadow: 5px 5px 7px rgba(33,33,33,.7);
}