Skip to content

Instantly share code, notes, and snippets.

View v0112358's full-sized avatar

Nguyen Tan Vy v0112358

  • Freelancer
  • Vietnam
View GitHub Profile
@v0112358
v0112358 / nginx_if.conf
Created January 6, 2014 07:23
Nginx multiple if statements
if ($uri = /) {
set $varnc A;
}
if ($http_cache_control ~ "max-age=0") {
set $varnc "${varnc}B";
}
if ($varnc = AB) {
set $not_cache_rq 1;
@v0112358
v0112358 / kill_sleep_mysql.php
Created January 6, 2014 15:46
Kill all mysql sleeping process
<?php
$result = mysql_query("SHOW processlist");
while ($myrow = mysql_fetch_assoc($result)) {
if ($myrow['Command'] == "Sleep") {
mysql_query("KILL {$myrow['Id']}");
}
}
?>
@v0112358
v0112358 / tcpdump_mysql.sh
Created January 13, 2014 06:55
Dump mysql query
sudo date
# password
export DT=`date +%y%m%d.%H%M%S`
sudo /usr/sbin/tcpdump -i any port 3306 -s 65535 -x -nn -q -tttt -c 10000 > ${DT}.tcp
./mk-query-digest --type tcpdump --limit 100%:50 ${DT}.tcp > ${DT}.out
more ${DT}.out
exit 0
@v0112358
v0112358 / System Design.md
Created April 19, 2016 02:42 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
#!/usr/bin/python
import sys
from pygtail import Pygtail
from pathlib2 import Path
try:
sys.argv[1]
except:
print "Usage: pygtail.py <path-to-log-file>"
else:
@v0112358
v0112358 / Install HP SSP repository on CentOS 6.9
Created August 3, 2018 09:50
Install HP SSP repository on CentOS 6.9
```bash
# wget http://downloads.linux.hpe.com/SDR/add_repo.sh
# sh add_repo.sh -d RHEL -r 6.9 spp
# yum install hp-snmp-agents hpssa hp-health hp-smh-templates hpsmh hpssacli
# hpssacli ctrl all show config
Smart Array P800 in Slot 2 (sn: PAFGF0T9SZ401Y)
Port Name: 1I
@v0112358
v0112358 / update-rsyncd-centos6.txt
Last active August 4, 2018 02:30
Disable reverse lookup in rsync daemon on CentOS 6
# yum install http://mirror.hmc.edu/rpmforge/redhat/el6/en/x86_64/extras/RPMS/rsync-3.1.1-1.el6.rfx.x86_64.rpm
# [root@srv ~]# cat /etc/rsyncd.conf
uid = root
gid = root
use chroot = false
max connections = 23
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
reverse lookup = no
@v0112358
v0112358 / Combine PHP with Percona 5.7
Created August 7, 2018 04:30
combine PHP with Percona 5.7
# ln -sf /usr/lib64/mysql/libmysqlclient.so.20.3.9 /usr/lib64/libmysqlclient.so
./configure
....
'--with-mysql=/usr' \
'--with-mysqli=/usr/bin/mysql_config' \
'--with-pdo-mysql=/usr' \
'--with-mysql-sock=/var/lib/mysql/mysql.sock'
@v0112358
v0112358 / Test virtualhost on EC2
Created August 7, 2018 07:37
Test virtualhost on EC2
curl --header "Host: example.com" http://172.16.0.10:8080/
@v0112358
v0112358 / new-svn-repository.txt
Created August 15, 2018 09:04
Create a new SVN repository on SVN server
Create a new SVN repository on SVN server:
- Step 1: svnadmin create /mnserver/svn-repo/vn-project01
- Step 2: Configure httpd.conf
<Location /vn-project01>
DAV svn
SVNParentPath /mnserver/svn-repo/vn-project01
AuthzSVNAccessFile /mnserver/svn-conf/vn-project01-authz-access
Satisfy Any
AuthType Basic