Skip to content

Instantly share code, notes, and snippets.

View panudetjt's full-sized avatar

Panudet Thammawongsa panudetjt

View GitHub Profile
@panudetjt
panudetjt / github-linguis-docker.sh
Last active February 20, 2026 02:16
How to check how Github evaluate your used "language" in repository
docker run --rm --user $(id -u):$(id -g) -v $(pwd):$(pwd):Z -w $(pwd) -t ghcr.io/github-linguist/linguist:latest github-linguist --breakdown
@panudetjt
panudetjt / crypto-builtin.ts
Last active August 2, 2025 07:26
Encrypt/Decrypt by AI
import { base64url } from 'jose'
async function getCrypto(): Promise<SubtleCrypto> {
if (typeof globalThis !== 'undefined' && globalThis.crypto?.subtle) {
return globalThis.crypto.subtle
}
if (typeof window !== 'undefined' && window.crypto?.subtle) {
return window.crypto.subtle
}
const { webcrypto } = await import('node:crypto')
@panudetjt
panudetjt / validate.js
Created October 27, 2024 11:33 — forked from jukbot/validate.js
Validate input number to allow only numeric, 1 decimal and max to 3 decimal places
export function validateNumberInput (e, min = 0, max = 1e10) {
const currentValue = e.target.value
const validKeys = ['ArrowLeft', 'ArrowRight', 'Backspace', 'Tab', 'Delete', '.']
// Allow valid control keys
if (validKeys.includes(e.key)) {
return
}
// Prevent entering non-numeric keys except '.'
@panudetjt
panudetjt / change-js-to-jsx.sh
Created October 6, 2022 14:19
This shell command change file .js to .jsx with only "JSX" file.
# https://github.com/vitejs/vite/discussions/3448#discussioncomment-1859773
find src -type f | grep "\.[jt]s$" | xargs -n1 grep -HE "^[^*\n]*(<\/?[a-zA-Z]*>)[\s\w]*$" | cut -d: -f1 | uniq | awk '{print "mv "$1" "$1"x"}' | sh
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a := 0
b := 1
n := 0
@panudetjt
panudetjt / rbenv build log
Last active November 19, 2015 19:02
rbenv build error on 14.04.3 LTS see issue tracker at https://github.com/sstephenson/ruby-build/issues/831
rbenv install 2.0.0-p645
#Downloading ruby-2.0.0-p645.tar.gz...
#-> https://dqw8nmjcqpjn7.cloudfront.net/5e9f8effffe97cba5ef0015feec6e1e5f3bacf6ace78cd1cdf72708cd71cf4ab
#Installing ruby-2.0.0-p645...
#
#BUILD FAILED (Ubuntu 14.04 using ruby-build 20151028-11-gbd22205)
#
#Inspect or clean up the working tree at /tmp/ruby-build.20151118185842.4045
#Results logged to /tmp/ruby-build.20151118185842.4045.log
#
@panudetjt
panudetjt / gist:2bd3cf8de5e3305b2673
Created October 14, 2015 10:48 — forked from noeldiaz/gist:0f9a2583a41579878764
Homestead 32-bit Version
## Making a 32 bit version of Homestead
# Clone the settler repository to a directory
git clone https://github.com/laravel/settler.git Ubuntu32
# In that directory edit the file called "Vagrantfile" to use a ubuntu 32 box instead of the 64 bit one
change this line:
config.vm.box = "ubuntu/trusty64"
@panudetjt
panudetjt / gist:030cda0185c8a6a9b992
Created June 26, 2015 10:10
จังหวัดในประเทศไทย แบบเรียงตามตัวอักษร (tis620)
$province = array(
'กระบี่', 'กรุงเทพมหานคร', 'กาญจนบุรี', 'กาฬสินธุ์', 'กำแพงเพชร',
'ขอนแก่น',
'จันทบุรี',
'ฉะเชิงเทรา',
'ชลบุรี', 'ชัยนาท', 'ชัยภูมิ', 'ชุมพร', 'เชียงราย', 'เชียงใหม่',
'ตรัง', 'ตราด', 'ตาก',
'นครนายก', 'นครปฐม', 'นครพนม', 'นครราชสีมา', 'นครศรีธรรมราช', 'นครสวรรค์', 'นนทบุรี', 'นราธิวาส', 'น่าน',
'บึงกาฬ', 'บุรีรัมย์',
'ปทุมธานี', 'ประจวบคีรีขันธ์', 'ปราจีนบุรี', 'ปัตตานี',
@panudetjt
panudetjt / gist:866c654a8462e7168f37
Created June 23, 2015 19:18
เขตในกรุงเทพ 50 เขต เรียงตามตัวอักษร
$district = array(
'คลองสาน', 'คลองสามวา', 'คลองเตย', 'คันนายาว',
'จตุจักร', 'จอมทอง', 'ดอนเมือง', 'ดินแดง', 'ดุสิต',
'ตลิ่งชัน', 'ทวีวัฒนา', 'ทุ่งครุ', 'ธนบุรี',
'บางกอกน้อย', 'บางกอกใหญ่', 'บางกะปิ', 'บางขุนเทียน', 'บางคอแหลม', 'บางซื่อ', 'บางนา', 'บางบอน', 'บางพลัด', 'บางรัก', 'บางเขน', 'บางแค', 'บึงกุ่ม',
'ปทุมวัน', 'ประเวศ', 'ป้อมปราบศัตรูพ่าย',
'พญาไท', 'พระนคร', 'พระโขนง',
'ภาษีเจริญ',
'มีนบุรี',
'ยานนาวา',