Skip to content

Instantly share code, notes, and snippets.

View bouroo's full-sized avatar
🏠
Remote Working

Kawin Viriyaprasopsook bouroo

🏠
Remote Working
View GitHub Profile
@bouroo
bouroo / reset_traffic.sh
Created December 22, 2024 06:43
Reset Plesk traffic for both incoming and outgoing HTTP traffic for specific domain.
#!/usr/bin/env bash
# Prompt user to enter the domain
read -p "Please enter the domain (e.g., example.com): " domain
# Get the current year and month
current_year=$(date +%Y)
current_month=$(date +%m)
# Get the first day of the current month
@bouroo
bouroo / upgrade_pg.sh
Last active November 27, 2025 06:26
pgauto docker script to update postgres database data version
#!/usr/bin/env bash
# PostgreSQL Auto Upgrade Script with Version and OS Selection
# Usage: ./upgrade_pg.sh [version] [os] [mount_type]
# Default values
DEFAULT_VERSION="18"
DEFAULT_OS="alpine"
DEFAULT_MOUNT_TYPE="bind"
@bouroo
bouroo / intel_pve_vgpu.sh
Last active September 19, 2024 04:58
Intel Gen 12/13 vGPU SR-IOV on Proxmox Host Enabler (Installer)
#!/usr/bin/env bash
# Print header information
cat << "EOF"
+----------------------------------------------------------------------+
| Intel Gen 12/13 vGPU SR-IOV on Proxmox Host Enabler (Installer) |
| https://github.com/Upinel/Intel-vGPU-SRIOV-on-Proxmox |
+----------------------------------------------------------------------+
| This source file is subject to version 2.0 of the Apache license, |
| that is bundled with this package in the file LICENSE, and is |
@bouroo
bouroo / rewrite.js
Last active June 15, 2025 13:49
AWS CloudFront function for static web app on Amazon S3
async function handler(event) {
const request = event.request;
const uri = request.uri;
// Determine if the URI has a query string.
const hasQuery = uri.indexOf('?') !== -1;
// Determine if the URI has a file extension.
// An extension is considered present if there's a dot, and the last dot
// appears after the last slash (indicating it's part of a filename, not a directory).
@bouroo
bouroo / convert_latin1_to_utf8mb4.sql
Last active May 12, 2025 04:18
A script that performs the conversion of `latin1` encoded strings to `utf8mb4` for all columns in all tables of a specific mariadb database. Make sure to back up your data before running scripts that modify it.
DELIMITER //
-- Drop the procedure if it already exists
DROP PROCEDURE IF EXISTS convert_chars_to_utf8mb4 //
-- Create the procedure to convert character set of columns
CREATE PROCEDURE convert_chars_to_utf8mb4(IN db_name VARCHAR(255))
BEGIN
-- Declare variables for cursor and loop control
DECLARE done INT DEFAULT FALSE;
@bouroo
bouroo / update-litespeed-cache.sh
Last active August 24, 2024 06:00
updates the LiteSpeed Cache plugin for all WordPress installations on a DirectAdmin server
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# Script Name: update-litespeed-cache.sh
# Description: This script updates the LiteSpeed Cache plugin for all WordPress
# installations on a DirectAdmin server. It checks for the WP-CLI
# tool and installs it if not found, then updates the specified plugin
# for each user's domains.
#
# Author: Kawin Viriyaprasopsook
@bouroo
bouroo / yum.repos.sh
Last active June 15, 2025 13:50
vault centos 6
#!/usr/bin/env bash
# Ensure the target directory exists before writing the repository file.
# This makes the script more robust, especially in minimal environments
# where /etc/yum.repos.d might not be pre-created.
mkdir -p /etc/yum.repos.d/
# Write the CentOS 6.10 repository configuration to the specified file.
# Using a 'here document' (heredoc) with quoted EOF ('-EOF') ensures
# the content is written verbatim, preserving '$basearch' for yum
@bouroo
bouroo / config.spa.unit.json
Last active May 12, 2025 04:20
simple nginx/unit config to serve SPA
{
"listeners": {
"*:8080": {
"pass": "routes/main"
}
},
"routes": {
"main": [
{
"action": {
@bouroo
bouroo / docker-compose.yaml
Last active January 8, 2026 17:03
pgcat and postgresql replication with docker compose
# Environment variables for PostgreSQL containers
x-default-pg-env: &default-pg-env
# Set the timezone to Asia/Bangkok
TZ: Asia/Bangkok
# Username for the PostgreSQL administrative account
POSTGRESQL_USERNAME: postgres
# Name of the default PostgreSQL database
POSTGRESQL_DATABASE: postgres
# Password for the PostgreSQL administrative account
POSTGRESQL_PASSWORD: mysecretpassword
@bouroo
bouroo / TurtleTrading.pine
Last active June 15, 2025 13:55
Turtle Trading Strategy with Supertrend Confirmation
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bouroo
//@version=5
strategy("Turtle Trading Strategy with Supertrend Confirmation", overlay=true, pyramiding=0) // Pyramiding set to 0 to prevent multiple entries for the same direction
// --- Strategy Parameters ---
// Turtle Trading Parameters
length1 = input.int(20, title="Donchian Channel Length (Breakout)", minval=1)
length2 = input.int(10, title="Donchian Channel Length (Exit)", minval=1)