Skip to content

Instantly share code, notes, and snippets.

View katopz's full-sized avatar
🦀
Rust me if you can

Todsaporn Banjerdkit katopz

🦀
Rust me if you can
View GitHub Profile
@katopz
katopz / setup-swapfile.sh
Last active May 14, 2016 10:02
Setup Swap file to 1GB enough for parse-dashboard to build. ref https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
# Set Swap 4GB, Swappiness 10.
# ref : https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
# Turn the swapfile off if has any.
sudo swapoff -a
# Check current disk usage.
df -h
# Create and Enable the Swap File 4GB.
sudo fallocate -l 4G /swapfile
@katopz
katopz / docker-cheat.sh
Created May 8, 2016 17:55
Docker cheat sheet
# Clear all docker log
truncate -s 0 /var/lib/docker/containers/*/*-json.log
@katopz
katopz / nginx_docker.partial.conf
Created May 2, 2016 05:18
Use nginx to forward proxy to Parse Docker at 192.168.99.100 // $ nano /usr/local/etc/nginx/nginx.conf // $ sudo nginx -t && sudo nginx -s relo
server {
listen 1337;
server_name localhost;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@katopz
katopz / free-mem.sh
Created April 18, 2016 17:22
Setup Ubuntu paging and swap file.
# https://help.ubuntu.com/community/CronHowto
# create script in daily cron folder
nano /etc/cron.hourly/free-mem.sh
# insert below line
# http://www.upubuntu.com/2013/01/how-to-free-up-unused-memory-in.html
# Free Up Unused Memory
sudo sysctl -w vm.drop_caches=3
# page cache, inodes, and dentries
@katopz
katopz / default.conf
Last active May 2, 2016 04:59
// proxy to gh-page // $ sudo nano /etc/nginx/conf.d/default.conf // $ sudo nano /etc/nginx/nginx.conf // sudo nginx -t && sudo nginx -s reload
server {
listen 80 default_server;
listen [::]:80 default_server;
add_header Content-Security-Policy "default-src 'self';";
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Xss-Protection "1";
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
@katopz
katopz / nginx.conf
Created April 16, 2016 16:08
Working?
worker_processes auto;
user www-data;
pid /run/nginx.pid;
daemon off;
events {
worker_connections 1024;
accept_mutex off;
}
@katopz
katopz / dns.md
Last active April 17, 2016 05:23
Handy nix command

To see DNS record.

$ dig rabbot.io +nostats +nocomments +nocmd
@katopz
katopz / rabbot.io-default.conf
Last active April 16, 2016 14:59
Optimized // $ sudo nano /etc/nginx/conf.d/default.conf // ref from https://gist.github.com/plentz/6737338
server {
listen 80 default_server;
listen [::]:80 default_server;
add_header Content-Security-Policy "default-src 'self';";
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Xss-Protection "1";
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
@katopz
katopz / nginx.conf
Last active April 6, 2016 10:29
Setup gzip via nginx rip form https://mattstauffer.co/blog/enabling-gzip-on-nginx-servers-including-laravel-forge // $ sudo nano /etc/nginx/nginx.conf
# Compression
# Enable Gzip compressed.
gzip on;
# Enable compression both for HTTP/1.0 and HTTP/1.1.
gzip_http_version 1.1;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
@katopz
katopz / default.conf
Last active April 11, 2016 18:17
HTTP2+SSL // sudo nano /etc/nginx/conf.d/default.conf
server {
listen 80;
listen 443 ssl http2;
server_name rabbot.io www.rabbot.io;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_certificate /etc/letsencrypt/live/rabbot.io/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rabbot.io/privkey.pem;
ssl_session_cache shared:SSL:128m;