Skip to content

Instantly share code, notes, and snippets.

View NamesMT's full-sized avatar
👋

Trung Dang NamesMT

👋
View GitHub Profile
@NamesMT
NamesMT / EmblaCarouselScrollBar.vue
Created November 1, 2025 09:18
shadcn-vue Embla Carousel Scrollbar
<script setup lang="ts">
import type { EmblaCarouselType } from 'embla-carousel'
import { onBeforeUnmount, ref, watch } from 'vue'
import { useCarousel } from '@/lib/shadcn/components/ui/carousel/useCarousel'
const { carouselApi } = useCarousel()
const snapList = ref<number[]>([])
/**
* Refs / state
@NamesMT
NamesMT / uidHexToDuplicatorDecimal.js
Created August 26, 2025 05:17
RFID tag UID to dual 125khz / 13.56mhz duplicator decimal format
function uidHexToDecimal(uidHex) {
// Ensure the input is 8 hex chars (4 bytes)
if (uidHex.length !== 8 || /[^0-9A-Fa-f]/.test(uidHex)) {
throw new Error("UID must be a 4-byte hex string (8 hex digits).");
}
// Parse the bytes from the hex string
const b0 = parseInt(uidHex.slice(0, 2), 16); // first byte
const b1 = parseInt(uidHex.slice(2, 4), 16); // second byte
const b2 = parseInt(uidHex.slice(4, 6), 16); // third byte
const b3 = parseInt(uidHex.slice(6, 8), 16); // fourth byte (may be ignored)
The keyword is "Mark"
@NamesMT
NamesMT / Button.vue
Last active November 1, 2025 08:24
Shadcn/vue Button with ripple
<script setup lang="ts">
import { ref, watchEffect, type HTMLAttributes } from "vue";
import { Primitive, type PrimitiveProps } from 'reka-ui'
import { cn } from '@/lib/shadcn/utils'
import { type ButtonVariants, buttonVariants } from '.'
interface Props extends PrimitiveProps {
variant?: ButtonVariants['variant']
size?: ButtonVariants['size']
class?: HTMLAttributes['class']
ripple?: boolean
@NamesMT
NamesMT / instructions.md
Last active May 28, 2025 04:38
boomerang_with-rooflow-compatibility

Mode important instructions:

IMPORTANT NOTE: Adherence to the rules listed in this Mode important instructions block, (e.g: MEMORY BANK COLLABORATION), adherence to the rules takes precedence and should not be forgotten.

MEMORY BANK COLLABORATION:

NOTE: While in this preload process, communication with the user should be short, concise and to the point, e.g: Memory setup found, Do you want to preload the memory bank?, etc.

  1. Check: Try to do a quick check to see if other modes instructions have any kind of memory bank setups, prioritize the setup of default mode if found.
  2. Additional check: If no or multiple setups pattern was found during step 1, look for a memory bank setup at the root repository level, refer to #known-setups for more details, proceed with the setup that is most relevant.
@NamesMT
NamesMT / steam-audio-manager.bat
Last active February 11, 2025 11:41
Apollo/Sunshine steam streaming audio device enable/disable prep batch
@echo off
setlocal enabledelayedexpansion
REM Allow the script to load relative SoundVolumeView.exe
cd /D "%~dp0"
REM Check if an action argument is provided
if "%~1"=="" (
echo Usage: %0 [enable^|disable]
exit /b 1
@NamesMT
NamesMT / alpine.docker.service.sh
Created September 15, 2024 16:57
Custom docker service start stop script
BASE=docker
DOCKERD=/usr/bin/dockerd
# This is the pid file managed by docker itself
DOCKER_PIDFILE=/var/run/$BASE.pid
# This is the pid file created/managed by start-stop-daemon
DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS=
DOCKER_DESC="Docker"
@NamesMT
NamesMT / static-site-with-backend.ts
Created April 26, 2024 19:07
SST Ion prototype for Static frontend + backend
import fs from "fs";
import path from "path";
import crypto from "crypto";
import * as aws from "@pulumi/aws";
import {
ComponentResourceOptions,
all,
interpolate,
output,
} from "@pulumi/pulumi";
## What this?
## Script to setup docker in a fresh alpine instance :D
## Credit goes to richart24se's gist: https://gist.github.com/richard24se/336cb2502400a63f4670c751eaca1929, is modified to add login script for zsh.
# change to root and install packages
su -c "apk add sudo openrc curl python3 python3-dev nload htop"
# if your user doesn't exists then remove sudo passwords
USERNAME=$(whoami)
su -c "grep -qxF '${USERNAME} ALL=(ALL) NOPASSWD: ALL' /etc/sudoers || echo '${USERNAME} ALL=(ALL) NOPASSWD: ALL' | tee -a /etc/sudoers"
# install compilers