Skip to content

Instantly share code, notes, and snippets.

View jbutko's full-sized avatar

Jozef Butko jbutko

View GitHub Profile
@jbutko
jbutko / chrome-dev-tools-snippets.md
Created March 12, 2021 07:43
Chrome dev tools snippets

search for multiple file types in network tab, put into search bar:

/.*png|jpg|webp+$/
@jbutko
jbutko / convert-images-to-webp.md
Created March 11, 2021 13:41
Convert png/jpg files to webp
@jbutko
jbutko / loop-promises-in-sequence.md
Created March 10, 2021 09:31
Loop promises in sequence (serially)
@jbutko
jbutko / start-stop-mongodb.md
Created February 2, 2021 09:33
Start or stop mongodb service on windows

Start: net start MongoDB

Stop: net stop MongoDB

@jbutko
jbutko / how-to-upgrade-cra.md
Last active January 26, 2021 07:36
How to update Create react app application

To get available versions:

npm view react-scripts versions --json

npm view react versions --json

npm view react-dom versions --json

and then upgrade:

@jbutko
jbutko / ga.ts
Created December 22, 2020 15:58
Google Analytics: React util (react-ga)
import ReactGA, { InitializeOptions, EventArgs } from 'react-ga';
const gaOptsDefault = {
debug: true,
siteSpeedSampleRate: 100,
};
export const GA_ID = 'G-XXXXXXXXXXX';
export const GA_EVENTS = {
@jbutko
jbutko / upgrade-yarn-packages.md
Created March 30, 2020 08:54
Upgrade yarn/npm packages interactively

yarn upgrade-interactive --latest

@jbutko
jbutko / handle-file-download-react-axios.js
Last active January 31, 2024 04:48
React, JS, Axios: Download blob file (PDF...)
import axios, { AxiosResponse } from 'axios';
import { get } from 'lodash-es';
const rest = axios.create({
baseURL: 'some base URL goes here',
});
// this one send file as Blob type
const getPdf = () => (
rest.get(`/get-pdf`, {
@jbutko
jbutko / react-js-to-ts-files-rename.md
Last active July 21, 2022 23:09
React: JavaScript to TypeScript files rename

Rename "js" to "tsx" files with exception to "index.js"|"*.test.js"

find . -type f \( -name "*.js" -and -not -name "*.styles.js" -and -not -name "index.js" -and -not -name "*.test.js" \) -exec sh -c 'mv "$1" "${1%.js}.tsx"' _ {} ;

Rename non "tsx" files to "ts" (index.js | *.styles.js) except *.test.js files

find . -type f \( -name "*.js" -and -not -name "*.test.js" \) -exec sh -c 'mv "$1" "${1%.js}.ts"' _ {} ;

Rename all "js" files containing text "import React from 'react'" to "tsx"

find . -type f \( -name "*.js" \) -exec grep -l "import React" {} ; -exec sh -c 'mv "$1" "${1%.js}.tsx"' _ {} ;

Rename all "js" files containing text "import * as React from 'react'" to "tsx"