Skip to content

Instantly share code, notes, and snippets.

@brian9206
brian9206 / loki.yml
Last active September 23, 2022 19:11
Single-node small & lightweight Grafana Loki deployment
auth_enabled: false
analytics:
reporting_enabled: false
server:
http_listen_port: 3100
common:
path_prefix: /var/loki
@brian9206
brian9206 / 10-diskspace.sh
Created April 5, 2022 09:32
Disk space alert
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Disk Space Alert' [email protected] << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi
@brian9206
brian9206 / InstallDockerOnRockyLinux.sh
Last active June 8, 2022 11:37
Install Docker on Rocky Linux
#!/bin/sh
# From https://www.tecmint.com/install-docker-in-rocky-linux-and-almalinux/
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf update -y
dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl enable --now docker
echo 'alias docker-compose="docker compose"' >> /etc/profile.d/docker-compose.sh
@brian9206
brian9206 / mac-simplex-halfwidth-punctuations.cin
Created December 23, 2021 13:09
macOS 簡易 (半型符號) for OpenVanilla
# This file includes CNS11643 and Unicode compatible characters based on
# opendesktop.org.tw's simplex.cin.
# This work has been done by yylin and b6s.
#
# codepoints not supported by OS X 10.6's built-in fonts are filtered
#
%gen_inp
%ename SimplexHalfwidthPunctuations
%cname 簡易 (半型符號)
%tcname 簡易 (半型符號)
@brian9206
brian9206 / nginx.conf
Last active April 25, 2020 07:15
nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
[Unit]
Description=OpenVPN tunnel for %I
After=syslog.target network-online.target
[email protected]
Wants=network-online.target
[email protected]
[Service]
Type=notify
PrivateTmp=true
@brian9206
brian9206 / [email protected]
Last active April 25, 2020 05:36
/usr/lib/systemd/system/[email protected]
[Unit]
Description=OpenVPN dhclient for tunnels with External DHCPD (%I)
After=syslog.target network-online.target [email protected]
[email protected]
Wants=network-online.target
[Service]
Type=forking
PrivateTmp=true
WorkingDirectory=/etc/openvpn/client
[Unit]
Description=%i service with docker compose
Requires=docker.service
After=docker.service
[Service]
Restart=always
WorkingDirectory=/etc/docker/compose/%i
# Compose up
@brian9206
brian9206 / create_cert.sh
Last active August 2, 2018 20:44
Create certificate with custom CA
#!/bin/bash
# Config
COUNTRY="HK"
STATE="Hong Kong"
ORGANIZATION="Brian Choi"
# Create cert folder
mkdir -p cert
# Get domains