Skip to content

Instantly share code, notes, and snippets.

View wittawasw's full-sized avatar

Wittawas W wittawasw

View GitHub Profile
AI Software Engineering
==================================================
1 — AI Engineering
==================================================
Mental model
- Probability and Entropy
Topics
@wittawasw
wittawasw / checksum.sh
Created August 4, 2026 03:10
Create a checksum for all files in specific dir
MANIFEST=/tmp/data_$(date +%Y%m%d%H%M%S).manifest; find /data -type f -exec sha256sum {} \; | sort > "$MANIFEST" && sha256sum "$MANIFEST" | awk '{print $1}'
@wittawasw
wittawasw / cloudflare_ufw_setup.sh
Created March 10, 2026 06:22
Setup UFW for app instance with Cloudflare DNS
#!/usr/bin/env bash
set -e
# Allow only Cloudflare to access HTTP/HTTPS using UFW
CF_IPV4_URL="https://www.cloudflare.com/ips-v4"
CF_IPV6_URL="https://www.cloudflare.com/ips-v6"
SSH_PORT=22
# Fix permission denied while trying to connect to the Docker daemon socket
# at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.47/containers/json":
# dial unix /var/run/docker.sock: connect: permission denied
# source: https://github.com/rancher-sandbox/rancher-desktop/issues/1156#issuecomment-1017042882
sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
# And something needs to be done so $USER always runs in group `docker` on the `Ubuntu` WSL
sudo chown root:docker /var/run/docker.sock
// Generate with these commands
//
// rails new <app_name> && cd <app_name>
// rails g scaffold courses name:string description:text summary:string{500}
// rails g scaffold student name:string email:text
// ruby <relative_path>/generate_tests.rb
{
"id": "test-rails-example-app-1723988622",
"tasks": [
@wittawasw
wittawasw / deer.cow
Created August 2, 2024 23:53 — forked from LunaticNeko/deer.cow
Deer for Cowsay
$the_cow = <<"EOC";
$thoughts\\_\\_ _/_/
$thoughts \\__/
$thoughts ($eyes)\\_______
-- \\ )\\/\\
$tongue ||-----||
|| ||
EOC
function ks() {
kgpo | awk 'NR>1 {print $1}' | grep "$1" | while read -r POD_NAME; do
echo "$POD_NAME"
done
}
function krrm() {
kgpo | awk 'NR>1 {print $1}' | grep "$1" | while read -r POD_NAME; do
krm pod "$POD_NAME"
# merge branch into main, develop then tag and push all.
ghf () {
# hotfix/{VERSION}
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
git checkout develop
git merge $BRANCH_NAME
git checkout main
#!/bin/bash
# Go into every directory 1 level inside current directory
for dir in */; do
# Move files with extension .parquet from sub-directory to current directory
find "$dir" -maxdepth 1 -type f -name "*.parquet" -exec mv -t . {} +
done
# Rename those files by removing sub-string -parquet- from their names
for file in *.parquet; do mv "$file" "${file/-parquet-/}"; done
@wittawasw
wittawasw / gitignore.sh
Last active February 14, 2024 07:31
Setup global .gitignore
# todo will be ignored in all git repos
echo "todo" >> ~/.gitignore
git config --global core.excludesfile ~/.gitignore