Skip to content

Instantly share code, notes, and snippets.

View sisco70's full-sized avatar

Francesco Guarnieri sisco70

View GitHub Profile
@sisco70
sisco70 / gist:71f4a4d93a3ecf644a958481d4d887fa
Last active August 21, 2021 09:35
PAM Time login access
# UBUNTU 20.04 LTS Allow access to USERNAME only from 18.30 to 21.00 every day
# Add to /etc/pam.d/common-auth
account required pam_time.so
# Add to /etc/security/time.conf
*;*;USERNAME;Al1830-2100
@sisco70
sisco70 / dialog.sh
Created May 31, 2021 22:40
Bash dialog with return values (esc, extra button) using pipes redirection
check_return_value() {
retval=$?
case $retval in
0|3) return ;;
*) clear
prompt -i "\n Operation canceled by user, Bye!"
exit 1 ;;
esac
}
@sisco70
sisco70 / build_docker.sh
Last active May 28, 2021 13:25
Dockerfile for Python Playwright (Ubuntu 20.04LTS). You can choose the browser to install. Custom user UID:GID when you build the image, useful for Synology Docker.
#!/usr/bin/env bash
docker image build --build-arg BROWSER=chromium --build-arg TZ='Europe/Rome' --build-arg GROUP_ID=65542 --build-arg USER_ID=1026 -t ubuntu:python-playwright -f Dockerfile .
@sisco70
sisco70 / AsyncSpinnerButton.js
Last active May 26, 2021 13:32
While waiting for a slow file download, shows a spinner on the submit button.. Vanilla Javascript (Bootstrap not mandatory).
document.getElementById('submit_form').addEventListener('submit', async function (event) {
event.preventDefault();
let sub_btn = document.getElementById('submit_btn');
sub_btn.setAttribute('disabled', '');
let sub_btn_html = sub_btn.innerHTML;
sub_btn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> ' + sub_btn_html;
try {
let response = await fetch(this.action, { method:'post', body: new FormData(this) });
if (response.ok) {
let [, filename] = response.headers.get('content-disposition').split('filename=');