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
call plug#begin('~/.config/nvim/vim-plug') | |
" Fold where saves plugins data | |
" syntax | |
Plug 'sheerun/vim-polyglot' | |
Plug 'styled-components/vim-styled-components', { 'branch': 'main' } | |
Plug 'norcalli/nvim-colorizer.lua' | |
" status bar | |
Plug 'maximbaz/lightline-ale' |
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 { useEffect } from 'react' | |
import { AxiosResponse } from 'axios' | |
export const useAsync = ( | |
asyncFn: () => Promise<AxiosResponse<any, any>>, | |
successFunction: Function, | |
returnFunction: Function, | |
dependencies: any[] = [] | |
) => { | |
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 httpStatus = { | |
// 1xx Informational | |
100: "Continue", | |
101: "Switching Protocols", | |
102: "Processing", | |
103: "Early Hints", | |
// 2xx Success | |
200: "Ok", | |
201: "Created", | |
202: "Accepted", |
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 deepCopy(subject) { | |
if (typeof subject !== "object" || subject === null) { | |
return subject; | |
} | |
const copySubject = Array.isArray(subject) ? [] : {}; | |
for (const key of Object.keys(subject)) { | |
copySubject[key] = deepCopy(subject[key]); | |
} |
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
// Objects: | |
const emptyObj = {} | |
const noEmptyObj = { foo: 'bar'} | |
// Option 1: | |
function isObjEmpty(obj) { | |
return (Object.keys(obj).length) | |
? 'No empty' | |
: 'Empty' |
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 deleteNth(arr,n){ | |
const result = [] | |
const dict = {} | |
for (const num of arr) { | |
if (num in dict) { | |
if (dict[num] < n) { | |
result.push(num) | |
} | |
dict[num]++ | |
} else { |
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 obj = { a: 1, b: 2, c: 3 }; | |
const array = ['a', 'b', 'c'] | |
const str = 'abc' | |
// FOR OF OBJECT | |
for (const property of obj) { | |
console.log(property); | |
} | |
// Output: |
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 sortBy(array, keys) { | |
let i = 0 | |
return [...array].sort((a,b) => compareBy(a, b, keys, i)) | |
} | |
function compareBy(a, b, keys, i) { | |
if (a[keys[i]] > b[keys[i]]) return 1 | |
if (a[keys[i]] < b[keys[i]]) return -1 | |
i++ | |
if (!keys[i]) return 0 |
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
call plug#begin('~/AppData/Local/nvim/plugins') | |
" Fold where saves plugins data | |
" syntax | |
Plug 'sheerun/vim-polyglot' | |
Plug 'styled-components/vim-styled-components', { 'branch': 'main' } | |
Plug 'norcalli/nvim-colorizer.lua' | |
" status bar | |
Plug 'maximbaz/lightline-ale' |
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 aNumber = 13254 | |
const aString = 'aa' | |
// We add a method in the prototype of Number and String | |
Number.prototype.sort = function() { | |
return Number(this.toString().split('').sort((a,b)=>a-b).join('')) | |
} | |
String.prototype.capitalize = function() { | |
return this.charAt(0).toUpperCase() + this.slice(1) | |
} |
NewerOlder