Skip to content

Instantly share code, notes, and snippets.

khanhtran3005 /
Created Feb 4, 2020
ModuleNotFoundError: No module named '_sqlite3'

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

khanhtran3005 /
Created Nov 20, 2019
Delete remote branches from local

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

khanhtran3005 /
Last active Jul 16, 2021
Install and configure SchemaSpy to generate Postgres schema
View gist:81c8758743964b7802a0d91e4ca90835
/usr/local/psa/admin/bin/mail_auth_view | grep
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');
scrollTop: body.scrollTop() + error.offset().top - 65
}, 500);
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 /
Last active Jun 28, 2019
pt-kill example

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 / 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)
Select all and copy to buffer
Use p to paste the buffer.
khanhtran3005 /
Created Nov 24, 2017 — forked from subfuzion/
curl POST examples

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 /
Created May 22, 2017
Check a process whether running for not using PHP
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;