Skip to content

Instantly share code, notes, and snippets.

View SK-CSE's full-sized avatar
🇮🇳
job( write scalable code || Review PRs );

Saurabh Kumar SK-CSE

🇮🇳
job( write scalable code || Review PRs );
View GitHub Profile
@SK-CSE
SK-CSE / twistedDeepclone.js
Created July 7, 2023 11:10
Deep Clone million of nested object without throwing call stack exceeded
function deepClone(obj) {
const stack = [{ source: obj, target: {} }];
const map = new WeakMap();
while (stack.length > 0) {
const { source, target } = stack.pop();
map.set(source, target);
for (let key in source) {
if (source.hasOwnProperty(key)) {
@SK-CSE
SK-CSE / thread2.js
Created September 26, 2020 09:43
worker thread demo
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
if(isMainThread) {
console.log('main thread start...');
const worker = new Worker(__filename, {
workerData: {
prefix: 'Received message',
timeInSecond: 1000
}
@SK-CSE
SK-CSE / thread1.js
Last active September 14, 2020 09:24
const { Worker, isMainThread, parentPort } = require('worker_threads');
if(isMainThread) {
console.log('main thread start...');
const worker = new Worker(__filename);
worker.on('message', (msg) => {
console.log(`Worker: ${msg}`);
});
console.log("doing some random work in main thread..!!");
}else{
body {
background:#efefef;
}
form {
padding:30px;
border-radius:3px;
margin:50px auto;
width:150px;
background:#fff;
border-top:6px solid #ec1d3d;
@SK-CSE
SK-CSE / call-bind-apply.js
Created July 2, 2019 11:58
call bind apply example
// example 1
let name= {
f: "Saurabh",
l: "Kumar",
printName: function(){
console.log(this.f+ " "+this.l);
}
}

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@SK-CSE
SK-CSE / README.md
Created September 7, 2018 07:05 — forked from CodingDoug/README.md
Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

If you're trying to do this, you came to the right place!

Watch this code work in real time: https://twitter.com/CodingDoug/status/945035556555186176

Setup

These instructions assume that you already have a Firebase project, and billing is enabled. Billing is required to use the Vision API.

@SK-CSE
SK-CSE / bulkUpdate.js
Created August 7, 2018 05:40 — forked from davideast/bulkUpdate.js
Bulk update with .push()
/**
* Send a bulk update to Firebase from an array or an object literal.
*
* When .push() is called on a Firebase reference without a parameter passed no
* trip to the server is made.
*
* ex:
* var childRef = ref.push();
*
* A reference is returned which has a push-id that can be returned by calling .name().
/**
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@SK-CSE
SK-CSE / gypErrSolution.md
Created July 5, 2018 07:11
gyp ERR! build error gyp ERR! stack Error: not found: make

if You are using Ubuntu you'll need to install the build-essential package:

sudo apt-get install build-essential

Then try to install the package again.