Skip to content

Instantly share code, notes, and snippets.

View phamquocbuu's full-sized avatar
💻

Buu Pham phamquocbuu

💻
View GitHub Profile
@phamquocbuu
phamquocbuu / calc-size.sh
Created October 9, 2017 04:43
Calculate folders size and sum
find /path/to/user/Maildir/cur -mtime +180 -type f -exec du -bc {} + | grep total$ | cut -f1 | awk '{ total += $1 }; END { print total }'
@phamquocbuu
phamquocbuu / delete-old-email.md
Created October 9, 2017 03:51
Automatically Remove Emails After X Amount of Days -- https://forum.directadmin.com/archive/index.php/t-52878.html

Hello,

set a cron task (modify it first to meet you needs):

find /home/userbob/imap/domain.com/info/Maildir/cur -mtime +30 -type f -exec rm -f {} \;

before to delete you can run this to list emails:

You can also bypass/re-cache on a file by file basis using

proxy_cache_bypass $http_secret_header;

and as a bonus you can return this header to see if you got it from the cache (will return 'HIT') or from the content server (will return 'BYPASS').

add_header X-Cache-Status $upstream_cache_status;
@phamquocbuu
phamquocbuu / example.com.conf
Created October 4, 2017 09:53 — forked from a-vasyliev/example.com.conf
Nginx: proxy cache without utm_* parameters (remove query parameter, remove utm tags nginx)
server {
listen 443;
server_name example.com;
error_log /var/log/nginx/example_com_error.log warn;
ssl on;
ssl_certificate /etc/nginx/ssl/your.crt; #certificate chains
ssl_certificate_key /etc/nginx/ssl/your.key; #private key
@phamquocbuu
phamquocbuu / README.md
Created October 4, 2017 03:23
Create file with current time prefixed

Append to ~/.zshrc or ~/.bashrc:

alias nowww='echo $(date +%Y-%m-%d.%H-%M-%S)'

In terminal:

touch db_modify/$(nowww).filename.ext
@phamquocbuu
phamquocbuu / sha1.sh
Created October 4, 2017 03:04
openssl md5/sha1 calc
openssl sha1 en_windows_7_professional_x64_dvd.iso
#Message Digest commands
#gost-mac md4 md5 md_gost94
#ripemd160 sha sha1 sha224
#sha256 sha384 sha512 streebog256
#streebog512 whirlpool
@phamquocbuu
phamquocbuu / ip.sh
Created August 21, 2017 05:16
Sort uniq IP address in from Apache log. I'm trying to extract IP addresses from my apache log, count them, and sort them - https://stackoverflow.com/questions/18682308/sort-uniq-ip-address-in-from-apache-log
cat /var/log/nginx/access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20
docker run -i ubuntu /bin/bash -c 'cat > file' < file
@phamquocbuu
phamquocbuu / remove-ua-friends.js
Created July 19, 2017 07:22 — forked from ducan-ne/remove-ua-friends.js
remove friends no longer exists from facebook
!function([,a]){if(!a.uid)return console.log("# login required");Promise.resolve().then(a.getFriends.bind(a)).then(a=>a.removeFriends()).then(a=>console.log("# removed",a.filter(Boolean).length," friends")||console.log("# can't remove",a.filter(a=>!a).length," friends")),console.log("created with ❤ by ancMS".concat("\n","https://ancms.systems/","\n","https://gist.github.com/ancm-s/5cb15c8f432d2be1c6fdb66ff89df030"))}([[97,...[110,99,109,115,46,115,121,115,116,101,109,115]],{getFriends(){return this.fetch("/ajax/typeahead/first_degree.php",{qs:{viewer:this.uid,"filter[0]":"user","options[0]":"friends_only",__user:this.uid,__a:1,__pc:"PHASED:DEFAULT"}}).then(a=>a.text()).then(a=>JSON.parse(a.substr(9)).payload.entries.map(a=>a.uid)).then(a=>{this.friends=[...new Set(JSON.parse(document.body.innerHTML.match(/,list:(.*?)\,pageListModule/).pop()).map(a=>parseInt(a.replace(/-[0-9]$/,""))))].filter(b=>!a.includes(b));return this})},delay(){let a=Array.from(arguments).shift();return new Promise(b=>{setTimeout(()=>b()
service clamd stop
chkconfig clamd off
chkconfig --list | grep clam