Skip to content

Instantly share code, notes, and snippets.

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

Thinh Vu ThinhVu

💭
I may be slow to respond.
View GitHub Profile
@ThinhVu
ThinhVu / naspas.js
Created October 14, 2023 02:52
NASPAS
const _ = require('lodash')
const crc = require('crc')
// RFU: Reserved for Future Use
// https://vietqr.net/portal-service/resources/icons/ABB.png
const range = (first, last) => _.range(first, last, 1).map(v => _.padStart(v, 2, '0'))
const bankLists = [
{
"id": 1,
"name": "Ngân hàng TMCP An Bình",
@ThinhVu
ThinhVu / gist:d1fe813b67944e85418f85cba93e1b62
Created October 20, 2022 06:58
Save current frame of a video into an image
function captureVideo(video) {
var canvas = document.createElement("canvas");
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
var canvasContext = canvas.getContext("2d");
canvasContext.drawImage(video, 0, 0);
const image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
window.location.href=image;
}
@ThinhVu
ThinhVu / intellij-in-bash.txt
Created June 1, 2022 10:46
Open Intellij in current folder
terminal: alias idea='open -a "`ls -dt /Applications/IntelliJ\ IDEA*|head -1`"'
use: idea .
public void updateAudioDeviceState() {
ThreadUtils.checkIsOnMainThread();
// Log.d(TAG, "--- updateAudioDeviceState: "
// + "wired headset=" + hasWiredHeadset + ", "
// + "BT state=" + bluetoothManager.getState());
Log.d(TAG, "Device status: "
+ "available=" + audioDevices + ", "
+ "selected=" + selectedAudioDevice + ", "
+ "user selected=" + userSelectedAudioDevice);
@ThinhVu
ThinhVu / imgLazyload.js
Created May 9, 2019 12:57
Image lazyload
function lazy(className, threshold) {
var imgs = [],
offset = screen.height + threshold,
targetEvent = 'wheel',
body = document.getElementsByTagName("body")[0];
var shownShow = function(img) {
var imgTop = img.getClientRects()[0].top,
viewportTop = -body.getClientRects()[0].top,
minDistance = viewportTop + offset,
const removeAccents = (function () {
const dictionary = {
a: 'àáảãạăằắẳẵặâầấẩẫậ', e: 'èéẻẽẹêềếểễệ', i: 'ìíỉĩị', o: 'òóỏõọôồốổỗộơờớởỡợ', u: 'ùúủũụưừứửữự', d: 'đ',
A: 'ÀÁẢÃẠĂẰẮẲẴẶÂẦẤẨẪẬ', E: 'ÈÉẺẼẸÊỀẾỂỄỆ', I: 'ÌÍỈĨỊ', O: 'ÒÓỎÕỌÔỒỐỔỖỘƠỜỚỞỠỢ', U: 'UÙÚỦŨỤƯỪỨỬỮỰ', D: 'Đ'
}
const convertMap = {}
for (const key of Object.keys(dictionary)) {
for (const char of dictionary[key]) {
convertMap[char] = key
}