multiline comment: /\\*.*?\\*/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nestedArray = [ | |
1, 2, 3, 2, | |
[23, 4, 5, 2, [2, 4, 5, 6, 5, 123, 3, [-2, 4, -4]]] | |
]; | |
const flatten = (nestedArray) => { | |
const stack = [...nestedArray]; | |
const result = []; | |
while(stack.length) { | |
const nextElement = stack.pop(); |
###Useful MongoDB commands
- MongoDB Reference
- get the mongo shell command
> mongo
- show all the available databases
> show dbs
##Creating object with literals
var car = {};
car.color = 'blue';
car['model'] = 'bmw';
car['build year'] = 2000;
Object.defineProperty(car, 'registrationNumber',{
Official Cheat Sheets from GitHub Gihub Cheatsheets
Add your user name and email
> git config --global user.name "Pallab Mahmud"
> git config --global user.email "pmahmud@uoregon.edu"
** Copied from http://stackoverflow.com/questions/7310521/node-js-best-practice-exception-handling **
Original Author: http://stackoverflow.com/users/130638/balupton
#####Safely "throwing" errors
Ideally we'd like to avoid uncaught errors as much as possible, as such, instead of literally throwing the error, we can instead safely "throw" the error using one of the following methods depending on our code architecture:
For synchronous code, if an error happens, return the error:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This gist is a work-around of the dependency injection issue of third party packages in an Angular project. | |
*/ | |
'use strict'; | |
angular.module('yourAppName') | |
.factory('thirdPartyPackageName',function( $window ) { | |
/* Get the package from $window */ | |
var thirdPartyPackageName = $window.thirdPartyPackageName; | |
delete( $window.thirdPartyPackageName ); |