// Class
componentWillReceiveProps(nextProps) {
if (nextProps.data !== this.props.data) {
console.log('Prop Received: ', nextProps.data);
}
}
// React Hooks: componentWillReceiveProps
useEffect(() => {
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 axios = require('axios').default | |
const API_BASE_URL = 'https://api.spacexdata.com/v3' | |
const API = axios.create({ | |
baseURL: API_BASE_URL | |
}) | |
/* | |
* setting interceptors to be able | |
* to know response time of the each request |
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
// Lambda S3 Zipper | |
// http://amiantos.net/zip-multiple-files-on-aws-s3/ | |
// | |
// Accepts a bundle of data in the format... | |
// { | |
// "bucket": "your-bucket", | |
// "destination_key": "zips/test.zip", | |
// "files": [ | |
// { | |
// "uri": "...", (options: S3 file key or URL) |
const {PassThrough} = require('stream')
const fs = require('fs')
const d = new PassThrough()
fs.createReadStream('tt2.js').pipe(d) // can be piped from reaable stream
d.pipe(process.stdout) // can pipe to writable stream
d.on('data', console.log) // also like readable
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
function ShowAutocompletion(obj) { | |
// Disable default autocompletion for javascript | |
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ noLib: true }); | |
// Helper function to return the monaco completion item type of a thing | |
function getType(thing, isMember) { | |
isMember = (isMember == undefined) ? (typeof isMember == "boolean") ? isMember : false : false; // Give isMember a default value of false | |
switch ((typeof thing).toLowerCase()) { | |
case "object": |
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
var ReadTable = React.createClass({ | |
// ... | |
onClicked() { | |
// Array of debounced click events | |
this.debouncedClickEvents = this.debouncedClickEvents || []; | |
// Each click we store a debounce (a future execution scheduled in 250 milliseconds) | |
const callback = _.debounce(_ => { | |
// YOUR ON CLICKED CODE |
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
// find duplicate files with Node.js, cuz, you know, it's useful | |
var Promise = require('bluebird'); | |
var fs = Promise.promisifyAll(require('fs')); | |
var crypto = require('crypto'); | |
var path = require('path'); | |
var pathA = "."; // folder you're in, wherever that might be | |
var pathB = "/path/to/the/directory/you/want/to/compare/it/to"; // yes, yes, argv, etc, but I haven't bothered yet, ok! |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent