Skip to content

Instantly share code, notes, and snippets.

@austinjp
austinjp / Wordpress-inside-LXC.md
Last active September 7, 2023 12:04
An *unprivileged* LXC container dedicated to running Wordpress

What and why

Create an unprivileged Linux container (LXC) dedicated to running Wordpress websites.

If you install Wordpress regularly on Linux you can instead simply clone this container.

The Wordpress installation is nothing fancy. It's not multi-site, it's not SSL enabled by default, or anything like that. Just a plain bog-standard Wordpress installation serving a single domain.

Warning!

@austinjp
austinjp / openpgp.md
Last active July 5, 2023 13:13
openpgp.md

openpgp4fpr:C70D98C80C6F4A7FB4A8CC6D5DED1B0FE6F13374

@austinjp
austinjp / README.md
Last active April 1, 2023 14:17
A silly deterministic shuffle.

Just a note-to-self to prevent me from reinventing the wheel again.

A shuffle that always produces a predictable output.

e.g.

>>> x = [0,1,2,3,4,5,6,7,8,9]
>>> dshuffle(x)
[7, 8, 1, 5, 3, 4, 2, 0, 9, 6]
! 2023-03-30 https://www.youtube.com
www.youtube.com###secondary
www.youtube.com##.ytd-popup-container.style-scope > .yt-mealbar-promo-renderer.style-scope
www.youtube.com###comments > .ytd-comments.style-scope
www.youtube.com###actions
www.youtube.com###subscribe-button > .ytd-watch-metadata.style-scope
! 2023-04-01 https://www.theguardian.com
www.theguardian.com##body > .dcr-1uyetce
www.theguardian.com##main > .dcr-v339xn
@austinjp
austinjp / wifi-on-ubuntu-server-18.md
Last active February 10, 2023 10:10
Enabling wifi on Ubuntu server 18

Wifi on Ubuntu 18 server

TLDR

  1. Install wpasupplicant
  2. Turn on wifi radios: sudo nmcli radio wifi on
  3. Check your devices are recognised even if they're not "managed": sudo iwconfig
  4. Check your wifi (here called "wlp3s0") is capable of detecting nearby routers: sudo iwlist wlp3s0 scan
  5. Configure netplan by dropping a file called 01-netcfg.yaml into /etc/netplan/ or edit existing file there. See example below.
  6. netplan try, netplan generate, netplan apply.
@austinjp
austinjp / Zotero configs.md
Last active December 23, 2022 11:37
Zotero configs

I have Zotero installed on several machines: Windows at work and Ubuntu Linux at home. By ensuring the configs match on all machines, behaviours should be reliable.

Better BibTex config

I'm currently using the default setting (as of Zotero version 6.0.18):

zotero.clean
BEGIN MESSAGE.
gnXvwmSxwM9nDQY 6wQ0wgkEAMtRn1B 8gZHsOpAs8O09Af bbQW6dUqGEWpPT4
olQ3eL4ub5vEAsP eQVBjkLJSSNTCKq 6Xr2MZHgg4cAxZ3 xGkRmNk1xNLoRNk
ArYOC4c44CCQvgd ZdKEsIaBTwqJaV1 0XbOp0OoYtB8QuL kPyqSfNCfRHyLPC
8BrwHFbhag1VAwy 0OvLQs5T0rhkyWp uwoxJ0Qz5Z.
END MESSAGE.
-- Extension of answer by Tarleb on Stackoverflow (https://stackoverflow.com/a/52131435/3888000) to include docx section ends with portrait/landscape orientation changes.
-- Also uses officer package syntax to create sections breaks
local function newpage(format)
if format == 'docx' then
local pagebreak = '<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"><w:r><w:br w:type="page"/></w:r></w:p>'
return pandoc.RawBlock('openxml', pagebreak)
else
return pandoc.Para{pandoc.Str '\f'}
end
@austinjp
austinjp / a-test.py
Last active December 22, 2021 10:28
Pony ORM with SQLite uses shorthand foreign key syntax instead of explicit
#!/usr/bin/env python
from pony.orm import Database, Optional, Required, Set
db = Database()
@db.on_connect(provider="sqlite")
def pragmas(db, connection):
cursor = connection.cursor()
cursor.execute('PRAGMA foreign_keys = true')
@austinjp
austinjp / .emacs
Last active August 5, 2021 07:38
.emacs config using el-get
;; Set TLS to use version 1.2 for elpa.gnu.org.
;; TLS version 1.1 also works, but 1.3 does NOT.
;; Note this must be BEFORE package-initialize.
;; May need to do: sudo apt install gnutls-bin libgnutls28-dev
;; Some background: https://emacs.stackexchange.com/a/51772
;; Check supported TLS versions here:
;; https://www.ssllabs.com/ssltest/analyze.html?d=elpa.gnu.org&hideResults=on
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")