Skip to content

Instantly share code, notes, and snippets.

View narainsagar's full-sized avatar
👋
email me for projects or relocation roles!!

Narain M. narainsagar

👋
email me for projects or relocation roles!!
View GitHub Profile
@narainsagar
narainsagar / makeGitTree.js
Last active May 24, 2016 18:16
parses and convert the array data into tree view (directory) format.
/*
// sample data format (contains info. of nodes of git branches).
var sampleData = [{
branchName : 'feature/feat1/temp-develop1',
status : 'tracked'
},
{
branchName : 'tempo-branch',
status : 'false'
},
@narainsagar
narainsagar / rm_mysql.md
Created April 12, 2016 07:41 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@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.
@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 / 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 / php_export_html_to_excel_via_phpexcel
Last active May 8, 2019 07:52
Export Html contents to Excel file using PHPExcel
<?php
/*
// save this file to: ExcelService.class.php
Create new folder 'libs' under your project dir, and download PHPExcel-1.8 library .zip from here..
use this clone url: git@github.com:PHPOffice/PHPExcel.git
OR https://github.com/PHPOffice/PHPExcel.
*/
define('TMP_FILES', "../temp/"); // temp folder where it stores the files into.
@narainsagar
narainsagar / dom_jquery_swap_elements
Last active October 8, 2016 23:33
Swap two DOM elements using jQuery (Events and a possible focus or Bindings wouldn't be lost during/after swapping!)
/* A very simple and nice function to swap DOM elements */
// Solution #1
function swap($elementA, $elementB) {
var temp = $('<div>').insertAfter($elementA);
$elementA.insertAfter($elementB);
$elementB.insertBefore(temp);
temp.remove();
}
@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 / 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);