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
@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 = '#';
@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 / 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 / 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 / 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
const getState = () => {
if (document.visibilityState === 'hidden') {
return 'hidden';
}
if (document.hasFocus()) {
return 'active';
}
return 'passive';
};
@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 *************************************************************************
:root {
--text-gradient-stop-1: #4285f4;
--text-gradient-stop-2: #9b72cb;
--text-gradient-stop-3: #d96570;
--color-surface: #fff;
}
div {
background: linear-gradient(
74deg,
/* end here (2) */ var(--text-gradient-stop-1) 0,
@trinhvanminh
trinhvanminh / removeHolaVPNOverlay.js
Last active June 5, 2024 08:10
remove Hola VPN extension loading time overlay, without need to wait
// ==UserScript==
// @name remove Hola VPN overlay
// @namespace http://tampermonkey.net/
// @version 2024-06-05
// @description try to take over the world!
// @author You
// @match https://*.medium.com/*
// @match *://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=medium.com
// @grant none