Skip to content

Instantly share code, notes, and snippets.

View hmtri1011's full-sized avatar
❤️
Follow your dreams and work hard

Tri Hoang hmtri1011

❤️
Follow your dreams and work hard
View GitHub Profile
@hmtri1011
hmtri1011 / typescriptsnippet.json
Last active June 15, 2023 04:12
VSCode TypeScript snippet
{
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"TypeScript React Function Component": {
"prefix": "rsct",
"body": [
"export interface ${TM_FILENAME_BASE}Props$1 {}",
@hmtri1011
hmtri1011 / setting.json
Last active November 4, 2024 08:08
VS Code settings
{
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"workbench.colorTheme": "Night Owl",
"workbench.iconTheme": "material-icon-theme",
"editor.fontFamily": "Dank Mono",
"editor.fontWeight": "300",
"editor.fontSize": 15.8,
"editor.lineHeight": 1.8,
"editor.fontLigatures": true,
@hmtri1011
hmtri1011 / uniqBy.ts
Last active July 2, 2020 15:31
Unique by without lodash
const uniqBy = (array, key) => {
const mapKey = array.reduce((prev, cur) => {
const keyValue = key ? cur[key] : cur
return {
...prev,
[keyValue]: cur
}
}, {})
return Object.values(mapKey)
@hmtri1011
hmtri1011 / axios.js
Last active May 3, 2019 08:48
Axios refresh token intercept
const refresh = axios.create()
let isRefreshing = false
let requestQueue = []
const processQueue = (error, token = null) => {
requestQueue.forEach(promise => {
if (error) {
promise.reject(error)
} else {
promise.resolve(token)
@hmtri1011
hmtri1011 / index.js
Last active January 8, 2020 01:54
Multiple range Calendar Component
import React, { PureComponent } from 'react'
import { View, StyleSheet, TouchableOpacity, Text } from 'react-native'
import { Calendar } from 'react-native-calendars'
import dateFnsFormat from 'date-fns/format'
import compareAsc from 'date-fns/compare_asc'
const theme = {
textSectionTitleColor: '#0D2421',
dayTextColor: '#0D2421',
arrowColor: '#065747',
@hmtri1011
hmtri1011 / Tab.js
Last active December 25, 2018 04:15
Dummy Tab Component which is allow its items not unmount after switching
import React, { Component } from 'react'
class CompA extends Component {
state = {
text: 'This is Component A'
}
componentDidMount() {
console.log('ahihi comp a did mount')
}
@hmtri1011
hmtri1011 / Tab2.css
Last active March 31, 2018 02:33
Dynamic Tab Component
.tab2-header-item {
display: inline-block;
margin-right: 5px;
}
.tab2-header-item.selected {
background: yellow;
}