Skip to content

Instantly share code, notes, and snippets.

View rbellamy's full-sized avatar

Richard Bellamy rbellamy

View GitHub Profile
@rbellamy
rbellamy / podman_arch_rootless.md
Created January 6, 2024 16:32 — forked from lbrame/podman_arch_rootless.md
Running rootless unprivileged Podman containers on Arch Linux

Setting up podman rootless containers on Arch Linux

Podman is a container engine that is similar to and fully compatible with Docker that has the peculiarity of not requiring a daemon to run and to allow for rootless containers, which are often deemed safer than privileged containers running as root. Podman is a drop-in replacement for Docker that even supports the same syntax and it has good support from Red Hat.

However, running podman rootless containers on Arch Linux may not be obvious, so I'm writing the instructions I have used to achieve that here.

Podman works using control groups and users from which said containers need to be launched need to be assigned an appropriate range of subordinate user and group IDs. On Arch Linux, these files are not present and they need to be created.

From a root shell:

@rbellamy
rbellamy / boorkmarklet.md
Created June 4, 2023 16:45 — forked from 71/boorkmarklet.md
Lists all participants in a Google Meet meeting.

The following bookmarket shows a popup with the name of the participants separated by newlines.

javascript:-function(maxStrLength = 2000) { try { function findParticipants(current, depth = 0) { if (depth > 7) return; if (typeof current !== "object" || current === null || current === window) return; const descriptors = Object.getOwnPropertyDescriptors(current); for (const prop in descriptors) { if (prop.startsWith('["spaces/')) return Object.values(current); const item = findParticipants(descriptors[prop].value, depth + 1); if (item !== undefined) return item; } } const rootState = Object.entries(window).find(x => x[0].startsWith("closure_lm_"))[1], participants = findParticipants(rootState), names = []; function findName(obj) { for (const prop in obj) { const value = obj[prop]; if (typeof value === "object" && value !== null && typeof value[1] === "string") return value[1]; } } for (let i = 0; i < participants.length; i++) { const name = findName(participants[i]); if (names.indexOf(name) === -1) names.
@rbellamy
rbellamy / socks-create.sh
Created July 11, 2021 22:57 — forked from AfroThundr3007730/socks-create.sh
Create an on-demand SSH-based SOCKS5 proxy via systemd socket activation
#!/bin/bash
# These steps will allow the setup of an on-demand SSH proxy
# Three unit files will be created to serve this purpose:
# ssh-socks-helper.socket - The listening socket providing activation
# ssh-socks-helper.service - A systemd proxy to pass the socket fd
# ssh-socks.service - The actual SSH service providing the tunnel
cat <<'EOF' > ~/.config/systemd/user/ssh-socks-helper.socket
[Unit]
Description=Proxy Helper Socket for Bastion SOCKS5 Proxy
@rbellamy
rbellamy / btrfs-undelete
Created August 22, 2018 00:12 — forked from Changaco/btrfs-undelete
btrfs-undelete
#!/bin/bash
# btrfs-undelete
# Copyright (C) 2013 Jörg Walter <info@syntax-k.de>
# This program is free software; you can redistribute it and/or modify it under
# the term of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or any later version.
if [ ! -b "$1" -o -z "$2" -o -z "$3" ]; then
echo "Usage: $0 <dev> <file/dir> <dest>" 1>&2
echo
@rbellamy
rbellamy / postgres_queries_and_commands.sql
Created August 5, 2018 00:13 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@rbellamy
rbellamy / check_python_interpreter.py
Last active November 8, 2017 20:44 — forked from vlasovskikh/check_python_interpreter.py
Information about Python interpreter and environment
import sys
import os
import pkg_resources
from pprint import pprint
pprint({
'sys.version_info': sys.version_info,
'sys.prefix': sys.prefix,
'sys.path': sys.path,
@rbellamy
rbellamy / pg_schema_split.py
Created April 8, 2016 18:54
Split schema-only PostgreSQL dumps for source control
#! /usr/bin/python
import os, re, sys
# Split pg_dump files to schema/type file hierarchy
# Use with files produced by pg_dump -s
#TODO: Identify dropped objects and delete from tree
# Detect object header lines
re_obj = re.compile(r'-- Name: ([-\w\s\.]+)(?:\([-\w\s\[\],]*\))?; Type: ([-\w\s]+); Schema: ([-\w]+); Owner: ([-\w]*)(?:; Tablespace: )?([-\w]*)\n', flags=re.IGNORECASE)
#!/usr/bin/env bash
size=1024 # MB
mount_point=$HOME/tmp
name=$(basename "$mount_point")
usage() {
echo "usage: $(basename "$0") [mount | umount | remount | check | orphan]" \
"(default: mount)" >&2
}
# Install OpenJDK 1.7
sudo yum install java-1.7.0-openjdk
# Check if the default java version is set to sun jdk
java -version
# If not then lets create one more alternative for Java OpenJDK 1.7
alternatives --install /usr/bin/java java /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/bin/java 20000
alternatives --install /usr/bin/java java /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/bin/java 20000
@rbellamy
rbellamy / aergo
Last active December 17, 2015 17:29 — forked from THemming/gist:2173037
#!/bin/bash
# chkconfig: 345 20 80
# description: Play start/shutdown script - used by aergo-server
# processname: aergo
#
# Instalation:
# copy file to /etc/init.d
# chmod +x /etc/init.d/aergo
# chkconfig --add /etc/init.d/aergo
# chkconfig aergo on