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
var nodemailer = require('nodemailer'); | |
//send mail using nodemailer via gmail service | |
var transporter = nodemailer.createTransport({ | |
service: 'gmail', | |
auth: { | |
user: 'yourEmail', | |
pass: 'yourPassword' | |
} | |
}); |
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
var Cryptr = require('cryptr'), | |
cryptr = new Cryptr('secretKey'); | |
var encryptedString = cryptr.encrypt('sagar'), | |
decryptedString = cryptr.decrypt(encryptedString); | |
console.log(encryptedString); // 0ed11b7de924ff2a81260fb5d44a954c | |
console.log(decryptedString); // sagar |
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
//If you create the static methods in classes, then you call static methods without creating the class instances. | |
class Tasks{ | |
static Addition(a , b){ | |
return a+b; | |
} | |
static Subtraction(a , b){ | |
return a-b; | |
} |
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
class Animal{ | |
constructor(name , height){ | |
this.name = name; | |
this.height = height; | |
} | |
Hello(){ | |
console.log("Hello from Animal"); | |
} | |
} |
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
//Diffrent way to generate password in Nodejs | |
// 1 | |
var CryptoJS = require("crypto-js"); | |
var text = 'sagar'; | |
var password = 'sagar'; | |
var encrypted = CryptoJS.AES.encrypt(text, password); | |
encrypted = encrypted.toString(); | |
console.log('@encrypted ' + encrypted); |
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
// In switch statements if you are not add break statements | |
// after the end of case statements then all cases are executed by defaults | |
var number = 3; | |
switch(number){ | |
case 1: | |
console.log("The number is one"); | |
break; | |
case 2: |
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
//Swap "1-st Array elements to last" and "Last element of array to 1-st" | |
var array = [33,535,5,345,3,4,5,3,5,34,5,435]; | |
console.log("Before Swapping : " , array); | |
if(array.length != 0){ | |
var last = array.pop(); | |
var first = array[0]; |
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
/*Input Value : Any number n = 5; | |
Output: | |
5555555555 | |
4444**4444 | |
333****333 | |
22******22 | |
1********1 | |
*/ |
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
import java.util.Scanner; | |
public class pattern { | |
public static void printTriagle(int n) | |
{ | |
int temp = n; | |
for(int i=0;i<n;i++) { | |
for(int j=0;j<n*2;j++) { | |
if(i==0) { |
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
//Input | |
var arr1 = [1,3,2,4,0,9,3,5]; | |
var arr2 = [0,9,2,2,7,5]; | |
//output | |
var outputData = [ 2, 0, 9, 5 ]; | |
//Answer | |
//1st way | |
var answer2 =[]; | |
for(var num in arr1){ |
OlderNewer