Skip to content

Instantly share code, notes, and snippets.

View thetrung's full-sized avatar

thetrung

View GitHub Profile
@thetrung
thetrung / install_udev.sh
Last active August 10, 2026 09:10
Xgpro UDev Rules for Xgecu T48 on Linux/Wine
# 1. Create the missing plugdev group
sudo groupadd plugdev
# 2. Add your user to it
sudo usermod -aG plugdev $USER
# 3. Apply the group change immediately to your current terminal
newgrp plugdev
# 4. Add current user to the required USB access groups
; ==============================================================================
; Minimal Z180 Boot & Serial Test Code
; Target: Z8S180
; ==============================================================================
; Z180 Internal I/O Register Addresses (Default Map: 00h - 3Fh)
DREQ0 equ 04h ; DMA Request 0
STAT0 equ 08h ; ASCI Status Register Channel 0
TDR0 equ 09h ; ASCI Transmit Data Register Channel 0
CNTLA0 equ 00h ; ASCI Control Register A Channel 0
@thetrung
thetrung / boot_eZ80.asm
Created July 15, 2026 03:51
Sample Asm code for eZ80
; =========================================================================
; Minimal eZ80 Assembly Boot Code
; Targets: eZ80F91 / General eZ80 Series
; =========================================================================
ASSUME ADL = 1 ; Instruct assembler to output 24-bit ADL opcodes
ORG $000000 ; Power-On Reset Vector
reset_vector:
@thetrung
thetrung / hypridle.conf
Last active January 5, 2026 05:43
Update Omarchy / HyprIdle to suspend after 10 mins @ ~/.config/hypr/hypridle.conf
general {
lock_cmd = omarchy-lock-screen # lock screen and 1password
before_sleep_cmd = loginctl lock-session # lock before suspend.
after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display.
inhibit_sleep = 3 # wait until screen is locked
}
listener {
timeout = 150 # 2.5min
on-timeout = pidof hyprlock || omarchy-launch-screensaver # start screensaver (if we haven't locked already)
@thetrung
thetrung / monitors.conf
Created December 21, 2025 02:45
Hyprland Monitors config for Laptop : auto disable/enable on lid open/close
# See https://wiki.hyprland.org/Configuring/Monitors/
# List current monitors and resolutions possible: hyprctl monitors
# Format: monitor = [port], resolution, position, scale
# Optimized for retina-class 2x displays, like 13" 2.8K, 27" 5K, 32" 6K.
env = GDK_SCALE,1.75
monitor=,preferred,auto,auto
# monitor=eDP-1,disable
# monitor=HDMI-A-1,2560x1440@120,auto,1#,mirror,eDP-1
@thetrung
thetrung / config.toml
Created November 1, 2025 15:22
Helix Config to make it more "Vim-like"
# Use Ctrl-C to exit insert mode and return to normal mode
[keys.insert]
"C-c" = "normal_mode"
# Also use Ctrl-C to exit select mode
[keys.select]
"C-c" = ["normal_mode", "keep_primary_selection", "collapse_selection"]
#[keys.normal]
# ... other existing keybindings ...
@thetrung
thetrung / qclock.html
Created February 13, 2025 13:34
Clock Displayed by its own code.
<script>
(r=()=>setInterval(t=>{for(j=o="\n",y=5;y--;document.body["inn"
+"erHTML"]="<pre>&lt"+(S="script>\n")+o+"\n\n&lt/"+S)for(x=-01;
63-!y>x++;o+=`(r=${r})()`[j++].fontcolor(c?"#FF0":"#444"))c=x/2
%4<3&&parseInt("odRFacb67o2vi5gmOZmwFNteohbOh3sw".slice(i="9"<(
D=Date()[16+(x/8|0)])?30:D*3,i+3),36)&1<<(x/2|0)%4+3*y},100))()
</script>
@thetrung
thetrung / qlock.c
Created February 12, 2025 01:35 — forked from rexim/qlock.c
// cc -w -include time.h -o qlock qlock.c // MIT Copyright (c) Tsoding
char*s="// cc -w -include time.h -o qlock qlock.c // MIT Copyright (c) Tsoding\n"
"char*s=\"?\";x,y,d[8],i,dx;f[]={31599,19812,14479,31207,23524,29411,29679,\n"
"30866,31727,31719,1040};char*so,*si;p(ch){i=x/2/(3+2);dx=x/2%(3+2);if(i<8&&(y-5)\n"
"/2<5&&dx<3&&(f[d[i]]>>((5-(y-5)/2-1)*3+dx))&1)printf(\"\\033[1;41;30m%c\\033[0m\",ch\n"
");else printf(\"%c\",ch);if(ch=='\\n'){y+=1;x=0;}else x+=1;}gd(){time_t t=time(NULL);struct\n"
" tm*tm=localtime(&t);d[0]=tm->tm_hour/10;d[1]=tm->tm_hour%10;d[2]=10;d[3]=tm->tm_min\n"
"/10;d[4]=tm->tm_min%10;d[5]=10;d[6]=tm->tm_sec/10;d[7]=tm->tm_sec%10;}main(){for\n"
"(gd();;printf(\"\\n\\033[%dA\\033[%dD\",y+1,x),sleep(1),gd())for(so=s,x=0,y=0;*so;so++\n"
")if(*so==63)for(si=s;*si;si++)switch(*si){case'\\n':p('\\\\');p('n');p('\"');p('\\n')\n"
@thetrung
thetrung / hdmi_forward.sv
Created February 11, 2025 14:02
Forward HDMI signal on FPGA in SystemVerilog
module hdmi_forward (
input logic clk, // System clock
input logic reset, // Asynchronous reset
// HDMI inputs
input logic [2:0] tmds_i_red,
input logic [2:0] tmds_i_green,
input logic [2:0] tmds_i_blue,
input logic hsync_i,
input logic vsync_i,
@thetrung
thetrung / main.c
Created September 26, 2024 16:34
ESP32 Fetch BTC price from CoinDesk API
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ArduinoJson.h>
// Change ID/PWD
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C Address of LCD 16x02