Skip to content

Instantly share code, notes, and snippets.

View okovalov's full-sized avatar
🏠
Working from home

Oleksandr Kovalov okovalov

🏠
Working from home
View GitHub Profile
Set UP Eslint + Prettier in VSCode
// Docs (JS only) - https://github.com/wesbos/eslint-config-wesbos
// Anoter docs (TS and JSX) - https://github.com/sarpik/eslint-config-sarpik
https://gist.github.com/okovalov/aaf8bc5d05b59caa98eeec5e89612bd3
1. Create react app
npx create-react-app react-ts --template typescript
@okovalov
okovalov / axios_send_auth_token.js
Created January 22, 2020 14:54
Learn how to send the authorization header using Axios (from https://flaviocopes.com/axios-send-authorization-header/)
const username = ''
const password = ''
const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64')
const url = 'https://...'
axios.post(url, {
headers: {
'Authorization': `Basic ${token}`
@okovalov
okovalov / .eslintrc.js
Last active January 22, 2020 02:49
temporary fork from eslint-config-sarpik
#!/usr/bin/env node
// .eslintrc.js
/**
* The ESLint + Prettier config from Kipras <[email protected]> (https://kipras.org)
*
* Supports TypeScript!
* (
* https://javascriptplayground.com/typescript-eslint/
* & https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project
@okovalov
okovalov / index.js
Created January 22, 2020 01:35 — forked from zkat/index.js
npx is cool
#!/usr/bin/env node
console.log('yay gist')
@okovalov
okovalov / React-PropTypes-to-prop-types.js
Created January 22, 2020 01:35 — forked from ilio/React-PropTypes-to-prop-types.js
React-PropTypes-to-prop-types
#!/usr/bin/env node
console.log('v6', process.argv, process.cwd(), __dirname);
const {exec} = require('child_process');
const path = require('path');
exec('npm bin', {cwd: __dirname}, (err, stdout, stderr) => {
if (err) {
console.error(err);
} else {
I think above can be simplified using following commands.
git submodule deinit <path_to_submodule>
git rm <path_to_submodule>
git commit-m "Removed submodule "
rm -rf .git/modules/<path_to_submodule>
taken from https://gist.github.com/myusuf3/7f645819ded92bda6677#gistcomment-3141323
@okovalov
okovalov / derive_keypair.ts
Last active January 14, 2020 20:05
an example of derriving keypairs with factories
interface CurrencyKey {
keyIndex: number;
privateKey: string;
publicKey: string;
address?: string;
getKeyIndex(): number;
getPrivateKey(): string;
getPublicKey(): string;
getAddress(): string;
}
@okovalov
okovalov / index.css
Last active December 20, 2019 23:44
web1
body {
background-color: aqua;
}
// 1. quick convert Number to String
const age = 18 + ""
console.log(typeof age) // string
// 3. fill arrays
const users = Array(5).fill('')
console.log(users); // [ '', '', '', '', '' ]
const name = 'Hi my name is Flavio'
name.replace(/\s/g, '') //HimynameisFlavio
// https://flaviocopes.com/how-to-replace-whitespace-javascript/