Skip to content

Instantly share code, notes, and snippets.

View trinhvanminh's full-sized avatar
🎲
haha

Minh trinhvanminh

🎲
haha
  • Ho Chi Minh City, Viet Nam
View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

<div style="background: center top / cover no-repeat, linear-gradient(180deg, rgba(3, 120, 124, 0.2) 0%, rgba(3, 120, 124, 0.8) 100%);">
<div style="height: 100vh;background: linear-gradient(transparent 5%, rgba(3, 120, 124, 0.06) 30%, rgba(3, 120, 124, 0.06)), linear-gradient(transparent 5%, rgba(255, 255, 255, 0.9) 30%, rgba(255, 255, 255, 0.9));" />
</div>
@trinhvanminh
trinhvanminh / git-branch-command-multiple-respo.cmd
Created September 22, 2023 04:16
Work with multiple git repository. Enter branch, enter git command and let it work.
@echo off
set /p branch=Branch (master):
set /p git_command=Git command (fetch):
if "%branch%"=="" set branch=master
if "%git_command%"=="" set git_command=fetch
for /d %%i in (%cd%\*) do (
echo *************************************************************************
const getState = () => {
if (document.visibilityState === 'hidden') {
return 'hidden';
}
if (document.hasFocus()) {
return 'active';
}
return 'passive';
};
@trinhvanminh
trinhvanminh / customMuiDateRangePicker.js
Last active August 18, 2023 04:25
custom mui date range picker (mobile and desktop)
============================================components/PickersActionBar.js============================================
import { Button, Stack } from '@mui/material';
import { useLocaleText } from '@mui/x-date-pickers/internals';
export default function PickersActionBar({ onCancel, onAccept, disabled }) {
const { cancelButtonLabel, okButtonLabel } = useLocaleText();
return (
<Stack
@trinhvanminh
trinhvanminh / multipull.sh
Created July 5, 2023 07:38
multipull all git in folder
alias multipull="find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} pull \;"
multipull
@trinhvanminh
trinhvanminh / viFormatter.js
Created July 5, 2023 07:27
Vietnamese number formatter
import dayjs from "dayjs";
import { round, isNil } from "lib/utils"; // from lodash
import numeral from "numeral";
numeral.register("locale", "vi", {
delimiters: {
thousands: ".",
decimal: ",",
},
abbreviations: {
@trinhvanminh
trinhvanminh / stringFormat.js
Last active July 5, 2023 07:19
python string format method for javascript
// function ----------------------------------------------------------
// ex: stringFormat("its like python{0} format", 3) ==> its like python3 format
export function stringFormat(string) {
[...Array(arguments.length)].forEach(
(_, i) => (string = string.replace("{" + (i - 1) + "}", arguments[i]))
);
return string;
}
// add to String prototype -------------------------------------------
@trinhvanminh
trinhvanminh / stringToColor.js
Created August 22, 2022 17:39
string to color | use for generating color for "TextAvatar" from username: string
function stringToColor(string) {
let hash = 0;
let i;
for (i = 0; i < string.length; i += 1) {
hash = string.charCodeAt(i) + ((hash << 5) - hash);
}
let color = '#';