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 / pgautoupgrade.sh
Created October 20, 2024 08:27
pgauto docker script to update postgres database version
#!/usr/bin/env bash
docker run --name pgauto -it \
--mount type=bind,source=${PGDATA},target=/var/lib/postgresql/data \
-e TZ="Asia/Bangkok" \
-e LANG="C.UTF-8" \
-e POSTGRES_USER="${POSTGRES_USER}" \
-e POSTGRES_PASSWORD="${POSTGRES_PASSWORD}" \
-e PGAUTO_ONESHOT=yes \
pgautoupgrade/pgautoupgrade:17-bookworm
@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 September 10, 2024 14:17
AWS CloudFront function for static web app on Amazon S3
async function handler(event) {
const request = event.request;
const uri = request.uri;
// Extract pathname and check conditions
const hostnameWithPath = uri.split('//').pop();
const hasQuery = uri.indexOf('?') !== -1;
const hasExtension = uri.indexOf('.') !== -1 && uri.lastIndexOf('.') > uri.lastIndexOf('/');
const pathEndWithSlash = uri.charAt(uri.length - 1) === '/';
const isRootUrl = hostnameWithPath.indexOf('/') === -1 || hostnameWithPath.indexOf('/') === (hostnameWithPath.length - 1);
@bouroo
bouroo / convert_latin1_to_utf8mb4.sql
Last active September 10, 2024 05:34
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.
-- Set the database name
SET @db_name = :database_name;
-- Prepare a cursor to iterate through each relevant column
DROP PROCEDURE IF EXISTS convert_latin1_to_utf8mb4;
DELIMITER //
CREATE PROCEDURE convert_latin1_to_utf8mb4()
BEGIN
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
Created July 16, 2024 14:47
vault centos 6
#!/usr/bin/env bash
cat <<-'EOF' > /etc/yum.repos.d/CentOS-Base.repo
[C6.10-base]
name=CentOS-6.10 - Base
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
metadata_expire=never
@bouroo
bouroo / config.spa.unit.json
Created July 14, 2024 07:28
simple nginx/unit config to serve SPA
{
"listeners": {
"*:8080": {
"pass": "routes/main"
}
},
"routes": {
"main": [
{
"action": {
@bouroo
bouroo / docker-compose.yaml
Last active August 7, 2024 03:13
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
Created June 4, 2024 06:03
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)
// Turtle Trading Parameters
length1 = input.int(20, title="Donchian Channel Length (Breakout)")
length2 = input.int(10, title="Donchian Channel Length (Exit)")
risk_pct = input.float(2.0, title="Risk Percentage per Trade")
@bouroo
bouroo / speedtest.sh
Created May 30, 2024 11:22
speedtest-cli script
#!/usr/env/bash
# Thailand
speedtest -s 27203
# Singapore
speedtest -s 2054