Skip to content

Instantly share code, notes, and snippets.

@lmlsna
lmlsna / container-to-host-proxy.yaml
Last active February 5, 2025 04:08
Alternative LXD/incus default profile for a Wireguard only interface.
# The best way to access the host is through the exec command using sockets, but you can also add limited
# network connectivity between the host and container on specified ports with lxd proxy devices.
#
# This is an example profile giving the host access to port 8080 of the containers network.
#
name: container-to-host-proxy
description: "Give the host access (on the host's localhost:8080) to container's port 8080"
config: {}
devices:
webproxy:
@lmlsna
lmlsna / install-nvm-latest
Created February 3, 2025 16:22
Install the latest nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$(basename $(curl -Ls -o /dev/null -w %{url_effective} https://github.com/nvm-sh/nvm/releases/latest))/install.sh | bash
@lmlsna
lmlsna / install-mdcat
Last active January 28, 2025 05:18
Install `mdcat` from latest source
#!/bin/bash
sudo apt install -y git curl openssl libssl-dev pkg-config # need rust v1.83 or better
if [[ "$(which rustc)" == "" ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env" # For sh/bash/zsh/ash/dash/pdksh
rustc --version
if [[ $? -ne 0 ]]; then
echo "Unknown problem installed rust (dependency). Exiting."
exit 1
@lmlsna
lmlsna / install-nvidia-cuda-repo-verbose.sh
Last active August 8, 2023 17:12
Automatically configure nvidia's deb repo for CUDA, and update with apt.
#!/bin/bash
# An nvidia and cuda installer for Ubuntu
# Set env DEBUG_MODE=1 (up to 4) for more verbosity
if [[ "$DEBUG_MODE" == "" ]] || [ $DEBUG_MODE ! -gt 0 ]; then export DEBUG_MODE=0; fi
# Set env ASSUME_YES=-y for less interactivity
if [[ "$ASSUME_YES" != "" ]]; then export ASSUME_YES="-y"; else export ASSUME_YES=''; fi
## Pretty Print
@lmlsna
lmlsna / example.keybase.env
Last active November 12, 2022 12:42
All keybase/client environmental variables (and a script to retrieve them)
#KEYBASE_ALLOW_PTRACE=
#KEYBASE_ALLOW_ROOT=
#KEYBASE_API_DUMP=
#KEYBASE_API_TIMEOUT=
#KEYBASE_APP_TYPE=
#KEYBASE_ATTACHMENT_DISABLE_MULTI=
#KEYBASE_ATTACHMENT_HTTP_START=
#KEYBASE_AUTO_FORK=
#KEYBASE_AUTOSTART=
#KEYBASE_AVATAR_SOURCE=
@lmlsna
lmlsna / force-release-upgrade.sh
Last active March 23, 2022 07:18
Upgrade EOL version of Ubuntu
#!/bin/bash
# This script will perform the same function as `do-release-upgrade` when that tool is giving
# an error for an EOL verison of Ubuntu, or some other "cannot upgrade from <current> to <next>".
# It does this safely by downloading the release-upgrade meta-pacakge from your target distribution.
#
# See https://help.ubuntu.com/community/EOLUpgrades/ for more information.
# Make sure a release is given as argument
if [[ "$1" == "" ]]; then
@lmlsna
lmlsna / ultrawide.sh
Created February 21, 2022 03:33
Setup weird resolution for ultrawide monitor on Ubuntu
#!/bin/bash
#
# Set a nonstandard resolution (ultrawide) interactively
#
###
# Define default resolution (and monitor ID if multiple monitors)
# Will be overridden is passed to script as arguments
#
#
@lmlsna
lmlsna / ps1_color
Last active February 6, 2022 23:37
Source BASH one liner to change prompt color
#!/bin/bash
#
# Source this file with an to change the current prompt color
# No arguments for normal (green) and red (root) defaults
# Include an integer 0 - 255 after for an x256term color prompt
#
# You can also paste into .bashrc with $1 replace with an integer or variable
#
# Examples:
#
@lmlsna
lmlsna / kbfs-private-dir
Created October 14, 2021 07:26
BASH oneliner to get current user's private Keybase kbfs mount
#!/bin/bash
privdir="$(keybase config get -d -b mountdir)/private/$(keybase config get -d -b current_user)"
@lmlsna
lmlsna / dl-and-parse.sh
Last active January 21, 2022 20:19
Download a PGP key and parse key, fingerprint, and email into variables in BASH
#!/bin/bash
# First argument passed to script is pgp key url
# Download key to memory with curl or wget (fallback)
key="$(curl -sSL "$1" 2>/dev/null || wget --quiet -O - "$1" 2>/dev/null)"
# Parse just the fingerprint and email, then separate into their own variables
both="$(gpg --show-keys --keyid-format=long --list-options show-only-fpr-mbox=yes <<< "$key")"
fingerprint="$(echo "$both" | cut -d' ' -f1)"
email="$(echo "$both" | cut -d' ' -f2)"