Husky lets us run commands or script before committing or pushing our code to git. It works as a pre runner before commiting anything.
yarn add -D husky prettier eslint list-staged
/* | |
ArrayUtil exposes a set of helper methods for working with | |
ReadableArray (by React Native), Object[], and JSONArray. | |
*/ | |
package com.iodine.start; | |
import com.facebook.react.bridge.Arguments; | |
import com.facebook.react.bridge.ReadableArray; |
const useDebounce = (value, delay) => { | |
const [debouncedValue, setDebouncedValue] = useState(value); | |
useEffect(() => { | |
const handler = setTimeout(() => { | |
setDebouncedValue(value); | |
}, delay); | |
return () => { | |
clearTimeout(handler); |
// --------------- LIBRARIES --------------- | |
import React, { memo } from 'react'; | |
import { View, Animated, StyleSheet, Easing, PanResponder } from 'react-native'; | |
// --------------- ASSETS --------------- | |
export const TRACK_HEIGHT = 32; | |
export const HOR_PAD = 10; | |
const Colors = { |
/** | |
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken | |
* It was requested to be introduced at as part of the jsonwebtoken library, | |
* since we feel it does not add too much value but it will add code to mantain | |
* we won't include it. | |
* | |
* I create this gist just to help those who want to auto-refresh JWTs. | |
*/ | |
const jwt = require('jsonwebtoken'); |
I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).
Use ssh keys and define host aliases in ssh config file (each alias for an account).
/** | |
* Encode string into Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]. | |
* As per RFC 4648, no newlines are added. | |
* | |
* Characters in str must be within ISO-8859-1 with Unicode code point <= 256. | |
* | |
* Can be achieved JavaScript with btoa(), but this approach may be useful in other languages. | |
* | |
* @param {string} str ASCII/ISO-8859-1 string to be encoded as base-64. | |
* @returns {string} Base64-encoded string. |
module.exports = { | |
bracketSpacing: true, | |
jsxBracketSameLine: true, | |
singleQuote: true, | |
jsxSingleQuote: true, | |
trailingComma: 'all', | |
usesTabs: true, | |
tabWidth: 4, | |
printWidth: 100, | |
}; |
import { Constants } from '../CommonConfig'; | |
import moment from 'moment'; | |
/** | |
* Return random number between inclusive and exclusive | |
* @param {Number} length - exclusive length for randome number | |
* @param {Boolean} countOne - add plus 1 count | |
*/ | |
const getRandomNumber = (exclusiveLength = 1, countOne = false) => { | |
if (countOne) { |