Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# https://gauvain.pocentek.net/docs/raspbian-chroot/
apt install schroot
echo \
[jessie] \
description=Raspbian armhf \
directory=/var/chroot \
@birgersp
birgersp / install-programs.sh
Last active February 6, 2023 12:17
Linux Ubuntu (or Mint) setup
#!/bin/sh
. /etc/upstream-release/lsb-release
# pg admin
PGADMIN_URL="https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$DISTRIB_CODENAME"
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg --yes
sudo sh -c "echo \"deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] $PGADMIN_URL pgadmin4 main\" > /etc/apt/sources.list.d/pgadmin4.list"
# vs code
@birgersp
birgersp / refind-set-default.py
Created January 13, 2024 20:41
rEFInd: set or unset "Microsoft" as default
#!/usr/bin/python3
from argparse import ArgumentParser
from os.path import basename
from pathlib import Path
from typing import List
TARGET_FILE = "/boot/efi/EFI/refind/refind.conf"
TARGET_TEXT = "default_selection Microsoft"
@birgersp
birgersp / mirror-repos.py
Last active April 17, 2024 08:43
Mirror your Github repos
from os import getenv, makedirs, rename
from shutil import rmtree
import subprocess
from dotenv import load_dotenv
import requests
from typing import List
from pathlib import Path
from os.path import join
def get_github_repos(token: str) -> List[str]:
@birgersp
birgersp / retrofit-foreign-key-constraint.sql
Last active March 20, 2024 06:56
Add (change) foreign key constraint to an existing column in PostgreSQL
-- https://dba.stackexchange.com/questions/323851/add-foreign-key-constraint-to-existing-column-while-auto-generating-the-key-nam
alter table "Message"
-- drop the old constraint
drop constraint "Message_sender_fkey",
-- (re)add constraint but this time with cascading
add foreign key ("sender") references "Sender"("id") on delete cascade;