Skip to content

Instantly share code, notes, and snippets.

@khoatran
khoatran / gist:75da6485ec690662e7f77e1952d89b5d
Created October 3, 2017 06:38
Fix Laravel mix strange issue spawn webpack.js ENOENT
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
@khoatran
khoatran / rsync-options.sh
Created September 29, 2017 07:25
Rsync with options
#sync allows deleting files in target folder if the files in the source folder are deleted
rsync -rtvu --delete source_folder/ destination_folder/
#Compressing the files while transferring them
rsync -rtvz source_folder/ destination_folder/
#Transferring files between two remote systems
rsync -rtvz source_folder/ user@domain:/path/to/destination_folder/
rsync -rtvz source_folder/ user@xxx.xxx.xxx.xxx:/path/to/destination_folder/
rsync -rtvz source_folder/ server_name:/path/to/destination_folder/
@khoatran
khoatran / rsync-remote.sh
Created September 29, 2017 07:11
Rsync from remote
rsync -avz --progress -e "ssh -i ssh_key" root@ip_of_the_remote:/folder/* /target-folder
@khoatran
khoatran / october.conf
Created June 26, 2017 14:14
Nginx fast cgi cache for OctoberCMS
#Set the path where the cache is stored; Set the zone name, totalsize (400m),and max life time(60m)
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=AICUNGXINH:400m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
#fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
@khoatran
khoatran / scaling_php_application.conf
Last active December 28, 2021 13:20
Configuring Nginx to be a Cache for PHP-FPM
# This is the sample from Scaling PHP applications book
#Set the path where the cache is stored; Set the zone name(my_app), totalsize (100m),and max life time(60m)
fastcgi_cache_path /tmp/cachelevels=1:2keys_zone=my_app:100minactive=60m;
#Set the cache key used,in this case: httpsGETtest.com/somepage.html
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server{
listen 80;
@khoatran
khoatran / remember-passphrase.sh
Created June 2, 2017 06:00
Remember passphrase of your ssh key
ssh-add ~/.ssh/id_rsa &>/dev/null
@khoatran
khoatran / fix-short-ssh-timeout.sh
Created June 2, 2017 04:50
Fix the issue short SSH timeout on Linux server
It helps to add ClientAliveInterval of 60 mins into SSH config
sudo echo 'ClientAliveInterval 60' >> /etc/ssh/sshd_config
#Then, restart SSH
#Below is the command to restart ssh on Ubuntu based
sudo service ssh restart
#Other Linux distribution
sudo service sshd restart
@khoatran
khoatran / git-delete-merged-branches.sh
Created June 2, 2017 04:49
Git - delete remote branches merged to master and keep important branches
git branch -r --merged | grep -v '\*\|master\|dev\|DTP-263' | sed 's/origin\///' | xargs -n 1 git push --delete origin
@khoatran
khoatran / Plugin.php
Last active December 4, 2020 16:27
Customize OctoberCMS sidebar navigation for your plugin
<?php namespace Author\PluginName;
use System\Classes\PluginBase;
use Backend\Facades\BackendMenu;
class Plugin extends PluginBase
{
public function register() {
BackendMenu::registerContextSidenavPartial('Author.PluginName',
'sidebar-menu',
@khoatran
khoatran / delete-all-except-one.sh
Created May 23, 2017 06:08
Delete all files and folder except one
shopt -s extglob
rm -rf !(file-or-folder-name-to-keep)