Skip to content

Instantly share code, notes, and snippets.

View tuhuynh27's full-sized avatar

Tu Huynh tuhuynh27

View GitHub Profile
@tuhuynh27
tuhuynh27 / mini-compiler.ts
Last active May 18, 2021 03:57
"Mini Compiler"
const operators = ['=', '+', '-', '*', '/', '>', '<', '>=', '<=', '==', '!=']
function isOp(v: string) {
for (let i = 0; i < operators.length; i++) {
if (operators[i] == v) return true
}
return false
}
function isNum(v: any) {
@tuhuynh27
tuhuynh27 / react-rendering.md
Last active December 3, 2024 14:24
A (Mostly) Complete Guide to React Rendering Behavior

Translated from https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-mostly-complete-guide-to-react-rendering-behavior/, author: Mark Erikson (from Redux team)

A (Mostly) Complete Guide to React Rendering Behavior

Bài viết cung cấp chi tiết về cách mà React render hoạt động, và việc sử dụng Context và Redux ảnh hưởng thế nào tới quá trình render của React.

"Render" là gì

Rendering is the process of React asking your components to describe what they want their section of the UI to look like, now, based on the current combination of props and state.

@tuhuynh27
tuhuynh27 / Brewfile
Created October 26, 2020 04:03
Brewfile
tap "graalvm/tap"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
cask "adoptopenjdk8"
brew "autojump"
brew "cloc"
brew "deno"
@tuhuynh27
tuhuynh27 / time-calc.js
Created March 12, 2020 09:12
CFS Time Cost Calc
const axios = require('axios');
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Imh1eW5obWluaHR1ZnVAZ21haWwuY29tIiwibmlja25hbWUiOiJEYXJrbG9yZCIsImlhdCI6MTU4NDAwMTcxMCwiZXhwIjoxNTg0MDg4MTEwfQ.9FOV-LJMDuFfwFpQV3Kw1vXvK4alJnuzw9MLmA23HCg';
async function calAvgProcess(numberOfPosts, token) {
const { data } = await axios.get('https://api.fuhcm.com/api/v1/confessions?load=' + numberOfPosts, {
headers: {
'authorization': 'Bearer ' + token,
},
});
@tuhuynh27
tuhuynh27 / trua-nay-an-zi.go
Last active December 19, 2019 15:24
Trua nay an zi Slack - Run: brew install go && go run trua-nay-an-zi.go || go run trua-nay-an-zi.go
package main
import (
"bytes"
"container/list"
"encoding/json"
"errors"
"log"
"math/rand"
"net/http"
@tuhuynh27
tuhuynh27 / init.vim
Last active November 21, 2019 04:22
nvim
call plug#begin('~/.config/nvim/bundle')
Plug 'rking/ag.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'herringtondarkholme/yats.vim'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
Plug 'Yggdroot/indentLine'
"Plug 'yuttie/comfortable-motion.vim'
Plug 'scrooloose/nerdtree'
Plug 'alvan/vim-closetag'
Plug 'honza/vim-snippets'
import { db } from "@models";
async function pair() {
try {
const matchingCollection = db.collection("matchings");
const notMatchedArr = await matchingCollection
.find({
matched: false
})
package main
import (
"context"
"log"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
// Create the message queue
const importQueue = new Queue("importDB");
// Watch and Run job queue
// When have new job in queue (I mean when someone put some job in Redis),
// this will watch and do the job by call jobCallback()
importQueue.process(jobCallback);
// Describe what to do in the job
async function doJob(id) {
@tuhuynh27
tuhuynh27 / .eslintrc.js
Created April 17, 2019 10:55
Vue Linter
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "@vue/standard"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
quotes: ["error", "double"],