Basic JS Async Cookbook

// aXMLHttpRequest: an asynchronous XHR function function aXMLHttpRequest(method, location, responseType="", body=undefined) { // somewhat basic; improvements welcome return new Promise( (resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.open(method, location); xhr.responseType = responseType; xhr.onload = resolve; //xhr.onload = load => ((load.target.status / 100 | 0 == 2) ? resolve(load) : reject(load)); xhr.onerror = reject;…

[WIP] Namecheap let's encrypt

/opt/alt/python37/bin/python3 -m venv ~/virtualenv/simp_le bash . ~/virtualenv/simp_le/bin/activate pip install simp-le-client mkdir -v ~/ssl/simp_le pushd ~/ssl/simp_le ln -vs ../keys/{tls_key_id}.key key.pem exit Then, paste this somwhere #!/bin/sh set -e . ~/virtualenv/simp_le/bin/activate pushd "${workdir=$HOME/ssl/simp_le}" > /dev/null simp_le ${acme_endpoint+–server "${acme_endpoint}"}\ –email "${email-${USER}@${HOSTNAME}}"\ –default_root "${default_root=$HOME/public_html}"\ -f account_key.json\ -f account_reg.json\ -f key.pem –reuse_key\ -f cert.pem\ -f chain.pem\ "${@}" dd if=chain.pem status=none…

JS: Tail-call optimized recursive setTimeout

If you're writing some code on a time-delayed-loop in JavaScript, there are 2 main options: setInterval setTimeout, recursively However, each has a potential downside: setInterval schedules the code to run at the given interval, regardless of whether the last invocation has completed. This means that, if the function takes longer than the delay to execute,…

Installing Docker+Compose on CentOS 8

How to install Docker + Compose (and also grab Git and Nano while you're in there): This is mostly a tl;dr of the instructions: sudo dnf remove docker\* sudo dnf config-manager –add-repo https://download.docker.com/linux/$(. /etc/os-release;echo $ID)/docker-ce.repo sudo dnf install docker-ce docker-ce-cli git nano sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose…

[obsolete] Gab Social on CentOS 8 via Docker Compose

This post is not relevant anymore. Gab has permanently removed (and will not be re-enabling) Federation in any capacity, so there's no point to even considering running your own Gab Social-based site. These instructions cover the complete process, “all batteries included”, as I executed this on a VPS. First, install Docker+Compose. Then, grab the Gab…

selinux allow httpd access to folder

If, for instance, you are serving the internet stuff at /srv/stuff/TehInternetz instead of (or in addition to) the default /var/www, and selinux is preventing Apache/NGINX from accessing the files, run the following: dnf install policycoreutils-python-utils || yum install policycoreutils-python || apt install semanage-utils semanage fcontext -a -e /var/www /srv/stuff/TehInternetz restorecon -R -v /srv/stuff/TehInternetz