Skip to content

Instantly share code, notes, and snippets.

View metehansenol's full-sized avatar

Metehan Senol metehansenol

View GitHub Profile
@gnurgeldiyev
gnurgeldiyev / api.js
Last active November 25, 2023 07:58
How to get the response time from Axios
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
@amiantos
amiantos / index.js
Last active April 26, 2024 21:09
Zip Multiple Files from S3 using AWS Lambda Function
// 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)
@WrathChaos
WrathChaos / componentWillReceiveProps.md
Created November 7, 2019 20:29
React Hooks: componentWillReceiveProps
// Class
componentWillReceiveProps(nextProps) {
    if (nextProps.data !== this.props.data) {
        console.log('Prop Received: ', nextProps.data);
    }
}

// React Hooks: componentWillReceiveProps
useEffect(() => {
@bowin
bowin / node.js PassThrough stream.md
Last active November 15, 2022 00:02
Node.js Stream PassThrough Usage
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
@mwrouse
mwrouse / Autocomplete.js
Last active April 25, 2024 08:47
Autocompletion for an object in the monaco editor
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":
@gabriel-dehan
gabriel-dehan / component.jsx
Created October 4, 2016 10:05
[React + Lodash] onClick and onDoubleClick events on the same element
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
@kebman
kebman / checkFileDupes.js
Created October 2, 2015 02:12
Check for duplicate files with Node.js
// 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!
@paulirish
paulirish / what-forces-layout.md
Last active May 21, 2024 09:11
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

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.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active May 21, 2024 05:35
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k