Skip to content

Instantly share code, notes, and snippets.

Khanh Tran khanhtran3005

Block or report user

Report or block khanhtran3005

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@khanhtran3005
khanhtran3005 / install-schema-spy.md
Last active Jan 16, 2019
Install and configure SchemaSpy to generate Postgres schema
View install-schema-spy.md
View gist:81c8758743964b7802a0d91e4ca90835
/usr/local/psa/admin/bin/mail_auth_view | grep email_address@abc.com
@khanhtran3005
khanhtran3005 / scrollTop.js
Created Dec 18, 2017
A properly way to do scrollTop. It's correct for positive and negetive element's offsetY
View scrollTop.js
var body = $('.modal-body');
body.animate({
scrollTop: body.scrollTop() + error.offset().top - 65
}, 500);
@khanhtran3005
khanhtran3005 / dateValidation.js
Created Dec 15, 2017
dd/mm/yyyy validation. Including leap year check
View dateValidation.js
function Validator() {}
Validator.min = function(number, min) {
return number >= min;
}
Validator.max = function(number, max) {
return number <= max;
}
@khanhtran3005
khanhtran3005 / pt-kill.md
Last active Jun 28, 2019
pt-kill example
View pt-kill.md

pt-kill user must have SUPER PROCESS permission.

The following command intends to kill queries which have execute time greater than 30s and save terminated queries to database.

pt-kill --host=localhost --user=pt_kill_user --password=pt_kill_pass \
--busy-time=30 --interval=5s \
--log-dsn=h=localhost,D=pt_kill,t=kill_log,P=3306,u=root,p=root \
--kill --daemonize --ignore-user=backup
@khanhtran3005
khanhtran3005 / gist:b45ad2fdc138e0ba6ed3e782787daa61
Created Nov 24, 2017 — forked from Steven-Rose/gist:3943830
VI: Select all + delete, select all + copy
View gist:b45ad2fdc138e0ba6ed3e782787daa61
Select all and delete (actually move to buffer)
:%d
Select all and copy to buffer
:%y
Use p to paste the buffer.
@khanhtran3005
khanhtran3005 / curl.md
Created Nov 24, 2017 — forked from subfuzion/curl.md
curl POST examples
View curl.md

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@khanhtran3005
khanhtran3005 / process-checking.md
Created May 22, 2017
Check a process whether running for not using PHP
View process-checking.md
function processExists($processName) {
    $exists= false;
    exec("ps -aux | grep -i $processName | grep -v grep | grep -v /bin/sh", $pids);
    if (count($pids) > 1) {
        $exists = true;
    }
    return $exists;
}
@khanhtran3005
khanhtran3005 / unix-commands.md
Last active Jun 26, 2018
Some useful Unix commands for SysAd
View unix-commands.md
  • Disable a service which starts automatically sudo update-rc.d -f nginx disable

  • Space investigation:

    • Find top biggest directories under particular partition: du -a /home/xxx | sort -n -r | head -n 5

    • To display the above result in human readable format: du -Sh /home/xxx | sort -rh | head -5

@khanhtran3005
khanhtran3005 / python-journey.md
Last active Sep 15, 2018
Learning Python's notes
View python-journey.md

String Formatting

# Basic usage
print('We are the {} who say "{}!"'.format('knights', 'Ni'))

# Using index of the passed object
print('Low limit: {0}, high limit: {1}'.format(10, 200))

# using the name of the argument.
You can’t perform that action at this time.