Random commands I've used for various things.
mca-ctrl -t dump-cfg
renew dhcp interface eth0
show interfaces
#!/usr/bin/env sh | |
# stuff to do when setting up a fresh install of MacOS | |
set -o errexit -o nounset -o noclobber | |
[ -e /etc/pam.d/sudo_local ] || \ | |
echo 'auth sufficient pam_tid.so' \ | |
| sudo tee /etc/pam.d/sudo_local | |
softwareupdate --install-rosetta --agree-to-license |
-- I needed a way to safely pull a bunch of sequence values to my client in order to bulk | |
-- insert many thousands of rows. I'm doing this because I don't want to use 128-bit keys. | |
-- I found this: | |
-- https://www.depesz.com/2008/03/20/getting-multiple-values-from-sequences/ | |
select pg_advisory_lock(123); | |
alter sequence seq increment by 1000; | |
select nextval('seq'); | |
alter sequence seq increment by 1; | |
select pg_advisory_unlock(123); |
version: "3.8" | |
services: | |
unifi-controller: | |
image: lscr.io/linuxserver/unifi-network-application:7.5.187 | |
restart: unless-stopped | |
depends_on: | |
- ferretdb | |
environment: | |
PUID: 1000 | |
PGID: 1000 |
/* | |
* Quick demonstration of `id = LAST_INSERT_ID(id)` being the key to returning | |
* the existing id when doing `ON DUPLICATE KEY UPDATE`. The unfortunate side | |
* effect of this approach is that the sequence number for `id` increments on | |
* every update, even though the value for the updated row does not change. On | |
* update-heavy systems with 32-bit id`s, the sequence could be exhausted in a | |
* fairly short amount of time. | |
* | |
* Just switch to MariaDB and use `RETURNING id` instead. PostgreSQL got this | |
* keyword in 2006. Oracle was doing this in procedural code no later than 1997. |
-- The array_position function was added in Postgres 9.5. | |
-- For older versions, you can get the same behavior with this function. | |
create function array_position(arr ANYARRAY, elem ANYELEMENT, pos INTEGER default 1) returns INTEGER | |
language sql | |
as $BODY$ | |
select row_number::INTEGER | |
from ( | |
select unnest, row_number() over () | |
from ( select unnest(arr) ) t0 | |
) t1 |
#!/bin/sh | |
# Manually free up local copies of files backed up to iCloud. | |
path=${1:-*} | |
pushd "~/Library/Mobile Documents/com~apple~CloudDocs" \ | |
&& brctl evict $path |
IdentitiesOnly=yes | |
ConnectTimeout=10 | |
ConnectionAttempts=1 | |
Host * | |
UseKeychain yes | |
GSSAPIAuthentication no | |
Host 10.245.* | |
User ec2-user | |
IdentityFile ~/.ssh/aws.pem |
# First install database | |
brew install postgres | |
# Clone and build the PL/pgSQL server-side debugger | |
srcdir=/usr/local/src | |
[ -e "$scrdir" ] || \ | |
sudo sh -c "mkdir $srcdir && chgrp admin $srcdir && chmod g+w $srcdir" | |
cd "$srcdir" |
#!/bin/sh | |
# It seems it's very hard to set resample output quality with Ghostscript. | |
# So instead rely on `prepress` preset parameter to select a good /QFactor | |
# and override the options we don't want from there. | |
gs \ | |
-o resampled.pdf \ | |
-sDEVICE=pdfwrite \ | |
-dPDFSETTINGS=/prepress \ |