Skip to content

Instantly share code, notes, and snippets.

View rao123dk's full-sized avatar
🎯
Focusing

Dheeraj kumar Rao rao123dk

🎯
Focusing
View GitHub Profile
const customMiddleWare = storeAPI => next => action => {
console.log("prev state:", storeAPI.getState())
console.log("dispatching Actions", action);
console.log("next state:", storeAPI.getState())
return next(action);
}
git submodule add https://github.com/rao123dk/rao123dk.github.io
git submodule update --init --recursive
git submodule foreach git checkout develop
git submodule foreach git pull origin develop
[
{ fNumner: 'Air222', fName: 'Air india', email: 'AirIndia@demo.com', departure: '7:30', from: 'London', to: 'Delhi', arrival: "18:30 Next Day", price: "$430.00", seatAvaible: 34, duration:'12 hrs'},
{ fNumner: 'Air333', fName: 'Air india', email: 'AirIndia@demo.com', departure: '12:30', from: 'London', to: 'Delhi', arrival: "8:30 Next Day", price: "$430.00", seatAvaible: 17, duration:'12 hrs'},
{ fNumner: 'Air444', fName: 'Air india', email: 'AirIndia@demo.com', departure: '9:30', from: 'London', to: 'Delhi', arrival: "8:30 Next Day", price: "$430.00", seatAvaible: 44, duration:'12 hrs'},
{ fNumner: 'Air021', fName: 'Air india', email: 'AirIndia@demo.com', departure: '7:30', from: 'France', to: 'Delhi', arrival: "18:30 Next Day", price: "$412.00", seatAvaible: 14 , duration:'15 hrs' },
{ fNumner: 'BJ001', fName: 'Britesh Jet', email: 'British@demo.com', departure: '12:30', from: 'London', to: 'France', arrival: "12:30 Next Day", price: "$444.00", seatAvaible: 312,duration:'14 hrs' },
const express = require('express');
const app = express();
// Application
app.get('/', function(req, res) {
if (process.env.NODE_ENV === 'development') {
for (var key in require.cache) {
delete require.cache[key];
}
}
const { Readable } = require('stream');
function bufferToStream(binary) {
const readableInstanceStream = new Readable({
read() {
this.push(binary);
this.push(null);
}
});
return readableInstanceStream;
@rao123dk
rao123dk / node_modules.txt
Created August 14, 2019 07:14
delete all node_modules in your system
(A) This command will print out each folder, and even show us how much space the folder is occupying
// Mac / Linux:
find . -name "node_modules" -type d -prune -print | xargs du -chs
//Windows:
FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" echo %d"
const crypto = require('crypto');
const ENCRYPTION_KEY = "XwPp9xazJ0ku5CZnlmgAx2Dld8SHkAeT" //Must be 256 bits(32 byte) (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
let encrypted = cipher.update(text);
const checkDevice = () => {
let check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|
(A)Array.prototype.unique = function(){
return this.filter((value, index, self)=>(
self.indexOf(value) === index
));
}
var names = ["dk", "rao","dk","jsk"];
console.log(names.unique());
(B) var j = [...new Set(names)]
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
var mongoose = require('mongoose');
var myobj = {
"billPlan" : "Annual",
"code" : 20003,
"rating" : {
"totalFees" : "27K",
"Code" : 201704,