Skip to content

Instantly share code, notes, and snippets.

View amitkulhari26's full-sized avatar
🎯
Focusing

Amit Kulhari amitkulhari26

🎯
Focusing
View GitHub Profile
const loggerFunc = () => {
console.count("Throttled Function");
}
const throttle = (fn, limit) => {
let flag = true;
return function(){
let context = this;
let args = arguments;
if(flag){
// Debouncing in Javascript
let counter = 0;
const getData = () => {
// calls an API and gets Data
console.log("Fetching Data ..", counter++);
}
const debounce = function (fn, d) {
let timer;
return function () {
https://codesandbox.io/s/react-codesandboxer-example-forked-01wmv?file=/docs/data.js
const processActionClick = () => {
// for progress bar
const options = {
onUploadProgress: (progressEvent) => {
const { loaded, total } = progressEvent;
let percent = Math.floor((loaded * 100) / total);
setUploadPercentage(percent);
},
headers: {
"rx-a": token,
//https://stackoverflow.com/questions/51938654/how-to-pipe-an-archive-zip-to-an-s3-bucket
exports.downloadFromS3AndZipToS3 = () => {
// These are my input files I'm willing to read from S3 to ZIP them
const files = [
`${s3Folder}/myFile.pdf`,
`${s3Folder}/anotherFile.xml`
]
// https://menno.io/posts/listing-s3-objects-with-nodejs/
async function allBucketKeys(s3, bucket) {
const params = {
Bucket: bucket,
};
var keys = [];
for (;;) {
var data = await s3.listObjects(params).promise();
// s3.listObjects(params, async (err, data) => {
// if (err) {
// console.log('s3ListObjects error')
// console.log(err);
// }
// else {
// const { Contents } = data
// console.log('Contents');
// console.log(Contents);
// // Set filenames for each object to go into the zip.
Disable right click
<body oncontextmenu="return false">
<div></div>
</body>
// get last items of array
let array = [0, 1, 2, 3, 4, 5, 6, 7]
console.log(array.slice(-1));
>>>[7]
console.log(array.slice(-2));
import React, {
useState,
useEffect,
forwardRef,
useImperativeHandle,
} from "react";
import Select from "react-select";
import makeAnimated from "react-select/animated";
import Button from "@material-ui/core/Button";
import { Grid } from "@material-ui/core";
// https://stackoverflow.com/questions/21987909/how-to-get-the-difference-between-two-arrays-of-objects-in-javascript
//Find values that are in result1 but not in result2
var uniqueResultOne = result1.filter(function(obj) {
return !result2.some(function(obj2) {
return obj.value == obj2.value;
});
});
//Find values that are in result2 but not in result1