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 / _sqlite3-error.md
Created Feb 4, 2020
ModuleNotFoundError: No module named '_sqlite3'
View _sqlite3-error.md

CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 3.7.0

@khanhtran3005
khanhtran3005 / delete-branches.md
Created Nov 20, 2019
Delete remote branches from local
View delete-branches.md

git remote show origin | grep {pattern} | awk '{print $1}' | xargs git push origin -d

@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;
}
You can’t perform that action at this time.