Skip to content

Instantly share code, notes, and snippets.

View khanhtran3005's full-sized avatar

Khanh Tran khanhtran3005

  • Inspectorio
  • Vietnam
View GitHub Profile
@khanhtran3005
khanhtran3005 / _sqlite3-error.md
Created February 4, 2020 04:51
ModuleNotFoundError: No module named '_sqlite3'

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

@khanhtran3005
khanhtran3005 / delete-branches.md
Created November 20, 2019 03:57
Delete remote branches from local

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

@khanhtran3005
khanhtran3005 / install-schema-spy.md
Last active July 16, 2021 10:14
Install and configure SchemaSpy to generate Postgres schema
@khanhtran3005
khanhtran3005 / gist:81c8758743964b7802a0d91e4ca90835
Created January 23, 2018 10:26
Get Postfix email credentials
/usr/local/psa/admin/bin/mail_auth_view | grep [email protected]
@khanhtran3005
khanhtran3005 / scrollTop.js
Created December 18, 2017 12:29
A properly way to do scrollTop. It's correct for positive and negetive element's offsetY
var body = $('.modal-body');
body.animate({
scrollTop: body.scrollTop() + error.offset().top - 65
}, 500);
@khanhtran3005
khanhtran3005 / dateValidation.js
Created December 15, 2017 09:39
dd/mm/yyyy validation. Including leap year check
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 June 28, 2019 08:04
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
khanhtran3005 / gist:b45ad2fdc138e0ba6ed3e782787daa61
Created November 24, 2017 09:22 — forked from Steven-Rose/gist:3943830
VI: Select all + delete, select all + copy
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 November 24, 2017 06:42 — forked from subfuzion/curl.md
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
khanhtran3005 / process-checking.md
Created May 22, 2017 03:23
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;
}