Skip to content

Instantly share code, notes, and snippets.

@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)"
@lmlsna
lmlsna / install.sh
Created May 8, 2020 12:47
server keybase install
#!/bin/bash
deb="$(mktemp --suffix='.deb')"
curl --output "$deb" 'https://prerelease.keybase.io/keybase_amd64.deb'
sudo apt install "$deb"
run_keybase -g
@lmlsna
lmlsna / list-ubuntu-apps.sh
Created February 23, 2019 02:38
Get a list of what is being shown in the Ubuntu Desktop's applications menu
#!/bin/bash
grep -Li 'nodisplay=true' /usr/share/applications/*.desktop
@lmlsna
lmlsna / json2yaml.py
Created February 7, 2019 04:17
Convert JSON to YAML
#!/usr/bin/env python3
#
# Accepts a JSON file path as an optional argument, otherwise reads stdin
import os
import simplejson
import sys
import yaml
# If valid path to json file is passed