Skip to content

Instantly share code, notes, and snippets.

View utarn's full-sized avatar

Utharn Buranasaksee utarn

View GitHub Profile
@utarn
utarn / install-macos.sh
Last active November 14, 2026 23:48
Cloud Fuse macOS installer (Docker + Samba)
#!/usr/bin/env bash
# install-macos.sh — Cloud Fuse macOS installer (core).
#
# Installs, or repairs, the Cloud Fuse Docker + Samba stack on macOS and writes
# a self-contained Compose project under the config root. This file is
# designed to be published as a public gist: it contains no secrets, no account
# email, no OAuth client credentials, and no License.
#
# The script is macOS Bash 3.2 compatible (the system /bin/bash). It does not
# clone or read the source repository at runtime.
@utarn
utarn / README.md
Last active November 12, 2026 04:02
Auto-adjust Linux TTY console font size when swapping between 32-inch monitor and HDMI dongle

Auto Console Display & Font Switcher for Linux TTY

Automatically detects whether a real monitor (e.g. 32" 4K screen) or an HDMI dummy dongle is connected to your Linux machine, and dynamically adjusts the Linux virtual console (TTY) font size and configuration.

Features

  • Automatic DRM & EDID Detection: Reads EDID data from /sys/class/drm/ to identify display manufacturer, monitor model name, and native resolution.
  • Smart Profiles:
    • MONITOR Profile (32" / HiDPI / 4K): Applies ter-v32b (32px Terminus Bold) or latarcyrheb-sun32 for large, clear, easily readable text on high-resolution screens.
  • DONGLE Profile (1080p dummy plug / headless): Applies ter-v16n (16px Terminus) or latarcyrheb-sun16 for standard compact terminal density.
@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