Skip to content

Instantly share code, notes, and snippets.

View sagardere's full-sized avatar
🎯
Focusing

Dere Sagar sagardere

🎯
Focusing
View GitHub Profile
var nodemailer = require('nodemailer');
//send mail using nodemailer via gmail service
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'yourEmail',
pass: 'yourPassword'
}
});
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
//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;
}
class Animal{
constructor(name , height){
this.name = name;
this.height = height;
}
Hello(){
console.log("Hello from Animal");
}
}
//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);
// 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:
//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];
/*Input Value : Any number n = 5;
Output:
5555555555
4444**4444
333****333
22******22
1********1
*/
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) {
//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){