Skip to content

Instantly share code, notes, and snippets.

View narainsagar's full-sized avatar
👋
email me for projects/work!!

Narain S. narainsagar

👋
email me for projects/work!!
View GitHub Profile
@narainsagar
narainsagar / mac-apps.md
Last active September 17, 2015 13:23 — forked from erikreagan/mac-apps.md
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

alias glp="git log --color -p | less -R"
alias glg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | less -R"
alias hlog='git log --date-order --all --graph --format="%C(green)%h %Creset%C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset %s"'
alias cdg="cd \$(git rev-parse --show-toplevel)"
'use strict';
/*
# Javascript Prototyping Best Practices
* To create a class, create a constructor function with a `Name` and assign
it to a variable of the same `Name`.
* In this constructor only define properties using `this.prop` notation
@narainsagar
narainsagar / JavaScriptTestingWithGruntMochaAndChai.md
Created October 17, 2015 11:21
JavaScript Testing with Grunt, Mocha and Chai

JavaScript Testing with Grunt, Mocha and Chai

In the following post I would like to introduce one way how you can setup your testing workflow for JavaScript development. The central components in the testing environment are Grunt, Mocha and Chai that I will cover from the introduction and installation of each component to the cooperation of all components for the execution of tests.

If you are already an experienced Grunt user and just look for the Gruntfile.js and the Mocha / Chai setup just skip the central components section and skip to the installing components part.

You can find the sample project with all code at GitHub on: https://github.com/maicki/sample-js-testing-grunt-mocha-chai

Central Components

@narainsagar
narainsagar / detect-private-browsing.js
Created October 26, 2015 11:32 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@narainsagar
narainsagar / PHPExcel_Basics.md
Created November 9, 2015 06:43 — forked from r-sal/PHPExcel_Basics.md
PHPExcel Notes and code snippets

Basics

Creating a new PHPExcel Object.

    $this->PHPExcel = new PHPExcel();

Working with sheets

Creating a new sheet:

@narainsagar
narainsagar / mongodb-date-range
Created February 8, 2016 20:07
Finding number of records where date is in date range?
This is the easiest way you can:
var thisDate = ISODate("2016-01-07T00:00:00Z");
Model.find({
startDate: {
'$lte': thisDate
},
endDate: {
'$gte': thisDate
@narainsagar
narainsagar / mongodb_basic_commands.md
Created February 9, 2016 05:15 — forked from leommoore/mongodb_basic_commands.md
MongoDB - Basic Commands

#MongoDB - Basic Commands

##Saving Data

db  //Tells you the current database

show collections //Shows the collections available in the current db

db.foo.save({_id:1, x:10}) //Save the document into the foo collection  

db.bar.save({_id:1, x:10}) //Save the document into the bar collection

@narainsagar
narainsagar / README
Created February 9, 2016 10:15 — forked from adilapapaya/README
Export Table Data to CSV using Javascript
Example code for exporting data in a table to a csv file.