This file contains hidden or 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
| const loggerFunc = () => { | |
| console.count("Throttled Function"); | |
| } | |
| const throttle = (fn, limit) => { | |
| let flag = true; | |
| return function(){ | |
| let context = this; | |
| let args = arguments; | |
| if(flag){ |
This file contains hidden or 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
| // 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 () { |
This file contains hidden or 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
| https://codesandbox.io/s/react-codesandboxer-example-forked-01wmv?file=/docs/data.js |
This file contains hidden or 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
| 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, |
This file contains hidden or 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
| //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` | |
| ] |
This file contains hidden or 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
| // 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(); |
This file contains hidden or 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
| // 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. |
This file contains hidden or 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
| 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)); |
This file contains hidden or 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 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"; |
This file contains hidden or 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
| // 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 |
NewerOlder