Skip to content

Instantly share code, notes, and snippets.

View hungdev's full-sized avatar
💭
I may be slow to respond.

Hung Vu hungdev

💭
I may be slow to respond.
View GitHub Profile
@hungdev
hungdev / sort text and number.md
Created November 26, 2020 16:50
sort text and number
export const sortTable = (data, sortKey, direction) => {
  const reverse = direction === "ascending" ? 1 : -1;
  const so = data.sort((nameA, nameB) => {
    const isString = Number.isNaN(Number(nameA)) // true => string
    if (isString) {
      if (nameA?.[sortKey]?.toUpperCase() < nameB?.[sortKey]?.toUpperCase()) {
        return -1 * reverse;
      }
 if (nameA?.[sortKey]?.toUpperCase() &gt; nameB?.[sortKey]?.toUpperCase()) {
@hungdev
hungdev / Setting Content-Type for multipart form-data values.md
Created October 19, 2020 06:26
Setting Content-Type for multipart/form-data values
<link rel="stylesheet" href="%PUBLIC_URL%/css/bootstrap.css">
<link rel="stylesheet" href="%PUBLIC_URL%/css/home.css">
<link rel="stylesheet" href="%PUBLIC_URL%/css/product.css">
<link rel="stylesheet" href="%PUBLIC_URL%/css/cart.css">
<link rel="stylesheet" href="%PUBLIC_URL%/css/success.css">
<script src="%PUBLIC_URL%/js/jquery-3.3.1.js"></script>
<script src="%PUBLIC_URL%/js/bootstrap.js"></script>
@hungdev
hungdev / Change zsh to bash shell.md
Created June 26, 2020 03:43
Change zsh to bash shell

chsh -s /bin/bash

@hungdev
hungdev / fixed last or first column table.md
Created May 11, 2020 10:42
fixed last or first column table
@hungdev
hungdev / toFixedNoRounding.md
Created April 1, 2020 07:44
toFixedNoRounding
/**
 *
 * @param num : number need formatting
 * @param n : to fixed ( number digit behind point number format), default = 2
 */
export function toFixedNoRounding(num, n = 2) {
  const reg = new RegExp('^-?\\d+(?:\\.\\d{0,' + n + '})?', 'g');
  const a = num.toString().match(reg)[0];
 const dot = a.indexOf('.');
https://anhdev.com/2020/03/17/quan-ly-anh-trong-react-native/
@hungdev
hungdev / installing-node-with-nvm.md
Last active February 20, 2020 10:15 — forked from d2s/installing-node-with-nvm.md
Installing Node.js to Linux & macOS & WSL with nvm

Installing Node.js with nvm to Linux & macOS & WSL

A quick guide on how to setup Node.js development environment.

Install nvm for managing Node.js versions

nvm allows installing several versions of Node.js to the same system. Sometimes applications require a certain versions of Node.js to work. Having the flexibility of using specific versions can help.

  1. Open new Terminal window.
@hungdev
hungdev / three dot css text.md
Last active December 30, 2019 04:41
three dot css text
.three-dot {
  text-overflow: ellipsis;
  overflow: hidden;
  line-height: 25px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}