Skip to content

Instantly share code, notes, and snippets.

View utarn's full-sized avatar

Utharn Buranasaksee utarn

View GitHub Profile
@utarn
utarn / .tmux.conf
Last active August 3, 2026 00:05
Modern Tmux Configuration for Remote SSH
# ==============================================================================
# Modern Tmux Configuration for Remote SSH (Windows & macOS clients)
# ==============================================================================
# --- General & Performance ---
set -g default-terminal "screen-256color"
set -as terminal-overrides ",xterm*:Tc,*:RGB" # Enable 24-bit True Color support
set -s escape-time 10 # Eliminate ESC key delay (great for Vim/Neovim over SSH)
set -g history-limit 50000 # Increase scrollback buffer size
set -g focus-events on # Pass focus events to terminal applications
@utarn
utarn / .tmux.conf
Created July 31, 2026 01:45
Optimized tmux configuration for remote SSH (Windows & macOS clients)
# ==============================================================================
# Modern Tmux Configuration for Remote SSH (Windows & macOS clients)
# ==============================================================================
# --- General & Performance ---
set -g default-terminal "screen-256color"
set -as terminal-overrides ",xterm*:Tc,*:RGB" # Enable 24-bit True Color support
set -s escape-time 10 # Eliminate ESC key delay (great for Vim/Neovim over SSH)
set -g history-limit 50000 # Increase scrollback buffer size
set -g focus-events on # Pass focus events to terminal applications
@utarn
utarn / gist:3dca14df5da87c974f8e700a7369d920
Created January 29, 2025 06:37
Add fail2ban to detect error 404
#!/bin/bash
# Script to add nginx-404 fail2ban configuration
FILTER_FILE="/etc/fail2ban/filter.d/nginx-404.conf"
JAIL_FILE="/etc/fail2ban/jail.d/nginx-404.local"
JAIL_LOCAL="/etc/fail2ban/jail.local"
JAIL_NAME="nginx-404"
# 1. Add filter file: nginx-404.conf
services.AddAuthentication()
.AddOpenIdConnect("Line", "Line", options =>
{
options.CallbackPath = "/signin-line";
options.Scope.Add("openid");
options.Scope.Add("profile");
options.Scope.Add("email");
options.RequireHttpsMetadata = true;
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
@utarn
utarn / ApplicationDbContextInitialiser.cs
Last active March 9, 2024 11:32
TimeScaleDb Initializer
using System.Reflection;
using VaultApi.Domain.Constants;
using VaultApi.Domain.Entities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Npgsql;
using VaultApi.Domain.Common;
@utarn
utarn / nextcloud.conf
Created February 19, 2024 09:11
Nextcloud nginx configuration
server {
server_name nextcloud.mydomain.com;
client_max_body_size 2G;
location / {
proxy_pass http://localhost:5001;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_cache_bypass $http_upgrade;
@utarn
utarn / docker-compose.yml
Last active February 20, 2024 02:44
Nextcloud docker-compose.yml
version: '3'
services:
db:
image: mariadb:10.6
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- ./database:/var/lib/mysql
environment:
@utarn
utarn / tbw.sh
Created October 7, 2023 07:06
Check total byte written
#!/bin/bash
declare -A custom_names
custom_names["8427e3af:14f642d8:316fd036:e279d458"]="/root"
custom_names["f2e76944:da560738:512c4030:54026dcf"]="/opt"
for drive in /dev/sd[a-e]; do
if smartctl -A "$drive" | grep -q 'Host_Writes_GiB'; then
md_name=$(mdadm --examine "$drive" | grep "Array UUID" | awk '{print $4}')
if [ -n "$md_name" ]; then
@utarn
utarn / autoUpdate.sh
Last active September 12, 2023 22:54
Auto update docker compose if new image is found for all subdirectories on given base path
## Add to crontab
# */5 * * * * /root/autoUpdate.sh | ts | tee -a /var/log/updater/updater-$(date +'\%Y-\%m-\%d').log
#!/bin/bash
# Define a function for null coalescing
coalesce() {
if [ -n "$1" ]; then
echo "$1"
else
echo "$2"
@utarn
utarn / install.sh
Last active August 16, 2023 02:50
Systemd Wireguard auto re-resolve DNS for dynamic DNS wireguard server
#!/bin/bash
# This script installs a systemd timer template named WireguardReResolveDNS.(service|timer)
# to run every 30 seconds. Requires that wireguard-tools is installed.
# Enable using e.g. systemctl enable --now wg-reresolve-dns@wg0.timer
# You need to do that separately for each wireguard interface
export NAME=wg-reresolve-dns@
cat >/etc/systemd/system/${NAME}.service <<EOF
[Unit]