Skip to content

Instantly share code, notes, and snippets.

View peerasan's full-sized avatar

Patrickz peerasan

View GitHub Profile
@peerasan
peerasan / sysctl.conf
Created August 4, 2020 07:10
sysctl.conf for haproxy
## tuning by patrickz ##
## inspire from https://klaver.it/linux/sysctl.conf
## inspire from https://gist.github.com/voluntas/bc54c60aaa7ad6856e6f6a928b79ab6c
fs.file-max = 209708
fs.suid_dumpable = 0
kernel.core_uses_pid = 1
kernel.exec-shield = 1
kernel.kptr_restrict = 1
kernel.maps_protect = 1
@peerasan
peerasan / ms-diff.pl
Last active July 23, 2020 03:42
millisecond diff
# Millisecond Difference
# keyword: Millisecond, ms, diff, time, timediff
# Online Perl: https://rextester.com/l/perl_online_compiler, https://www.onlinegdb.com/online_perl_compiler
my $t1 = "00:01:25.652";
my $t2 = "00:01:22.932";
print to_milli($t2) - to_milli($t1);
sub to_milli {
my @components = split /[:\.]/, shift;
@peerasan
peerasan / sysctl.conf
Last active June 17, 2020 09:08
high performance tuning
## tuning by patrickz ##
## inspire from https://klaver.it/linux/sysctl.conf
## inspire from https://gist.github.com/voluntas/bc54c60aaa7ad6856e6f6a928b79ab6c
fs.file-max = 209708
fs.suid_dumpable = 0
kernel.core_uses_pid = 1
kernel.exec-shield = 1
kernel.kptr_restrict = 1
kernel.maps_protect = 1
@peerasan
peerasan / nginx.conf
Created May 28, 2020 09:40
Nginx-php-multi-pool
upstream php-pools {
server 203.128.86.100:9000;
server 203.199.86.101:9000;
server 203.199.86.102:9000;
server 203.199.86.103:9000;
}
server {
listen 8080;
server_name patrickz.iiwnz.com;
@peerasan
peerasan / Nginx-check-cache-rate
Last active May 25, 2020 02:59
nginx log HIT and MISS status
log_format rt_cache '$remote_addr - $upstream_cache_status [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
server {
access_log /var/log/nginx/domain.cache.log rt_cache;
}
# OUTPUT domain.cache.log
# xxx.xxx.xxx.xxx - HIT [25/May/2020:07:13:49 +0700] "GET /mediacache/........."
@peerasan
peerasan / IncompatibleAppsList.plist
Created October 13, 2019 14:21
235 Incompatible apps on MacOS Catalina
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IncompatiblePaths</key>
<array>
<dict>
<key>Application Name</key>
<string>Sxs Memory Card Driver</string>
<key>Blurb</key>
@peerasan
peerasan / mailgun with curl
Created June 12, 2019 04:42
send email by mailgun API
curl -s --user 'api:key-##############################' \
https://api.mailgun.net/v3/{YOUR-DOMAIN}/messages \
-F from='Monitor <postmaster@{YOUR-DOMAIN}>' \
-F to=peerasan@{DOMAIN} \
-F subject='Hello' \
-F text='Testing some Mailgun awesomness!'
@peerasan
peerasan / patrickz.yml
Created June 11, 2019 04:10
docker-compose with system environment
version: '3'
services:
patrickz:
image: patrickz/ubuntu
container_name: patrickz
restart: always
hostname: $HOSTNAME
ports:
- 19999:19999
environment:
@peerasan
peerasan / sysctl.conf
Created June 8, 2019 14:38
Tweaked sysctl.conf (Ubuntu)
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
@peerasan
peerasan / nginx-rtmp.sh
Created June 8, 2019 14:36
compile nginx + rtmp
#compile nginx
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
mkdir /root/src
cd /root/src
wget https://nginx.org/download/nginx-1.13.8.tar.gz
tar -xvf nginx-1.13.8.tar.gz
cd nginx-1.13.8
./configure