Archiving Code
-
Pack the difference
git archive HEAD $(git diff $commit --diff-filter=d --name-only)
-
Pack the modified files
tar -cvf - $(git ls-files --m )
An coding monkey who reject all your request
some of useful git snippets
git archive HEAD $(git diff $commit --diff-filter=d --name-only)
tar -cvf - $(git ls-files --m )
As bootstrap only support one `Modal` show as the same time. This snippets will help with close the old one.
As bootstrap only support one Modal
show as the same time. This snippets will help with close the old one.
(function () {
let deferredModal = null;
$(document.body).on('show.bs.modal', '.modal', function (e) {
let $modal = $('.modal.show').not(this);
if ($modal.length > 0) {
e.preventDefault();
e.stopPropagation();
deferredModal = this;
$modal.modal('hide');
}
})
.on('hidden.bs.modal', '.modal', function(){
if (!deferredModal) {
return;
}
$(deferredModal).modal('dispose').modal('show');
deferredModal = null;
});
})();
Some useful SQL snippets for MySQL
create super admin
CREATE USER 'superadmin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'superadmin'@'localhost' WITH GRANT OPTION;
Create Database
CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
snippets for copy text to clipboard
let input = document.createElement('input');
document.body.appendChild(input);
input.style.position = 'fixed';
input.style.left = 0;
input.style.right = 0;
input.value = window.location.href;
if (window.navigator.userAgent.match(/ipad|iphone|ipod/i)) {
let range = window.document.createRange();
let selection = window.getSelection();
range.selectNodeContents(input);
selection.removeAllRanges();
selection.addRange(range);
input.readOnly = true;
input.setSelectionRange(0, 999999);
input.readOnly = false;
} else {
input.select();
}
document.execCommand('copy');
input.remove();
some useful shell script commands
show and sort the disk usage
du -sh * | sort -rn
Create an user with www-data as group
useradd -mg www-data $USER
Add user to sudo
usermod -aG sudo $USER