Skip to content

Instantly share code, notes, and snippets.

@bmcbm
bmcbm / .bash_aliases
Created November 22, 2022 11:51
Aliases to defang and "refang" IP-addresses and domains in Linux bash
#!/bin/bash
#
# Aliases to defang IP-addresses/domains and remove the defanging again - "refang" for lack of a better word.
#
# Add the aliases to ~/.bash_aliases
# Then source the file: source ~/.bash_aliases
#
# Takes arguments from command line or STDIN (one per line)
#
# Examples:
@bmcbm
bmcbm / reparer_ubuntu.md
Created January 12, 2021 15:30
Reparer Ubuntu på LUKS krypteret harddisk

Reparer Ubuntu

Hvis Ubuntu ikke kan startes og fx blot efterlader opstarten i en (initramfs) prompt, kan disse skridt hjælpe med at reparere systemet.

I dette eksempel er systemet installeret på en 1TB M2 SSD (/dev/nvme0n1) med LUKS og LVM.

Live USB boot

Boot systemet på en Live CD/USB

@bmcbm
bmcbm / setup-nvdia-suspend.sh
Last active April 24, 2024 22:18
NVIDIA Suspend fix
# Use systemd for managing NVIDIA driver suspend in drivers ====>>> PRIOR to version 470 <<<=====
# https://download.nvidia.com/XFree86/Linux-x86_64/450.66/README/powermanagement.html
# https://forums.developer.nvidia.com/t/unable-to-set-nvidia-kernel-module-parameters/161306
# Please note: In Fedora Linux you may need to just install the xorg-x11-drv-nvidia-power pakage
# as sugested by @goombah88 in the comments below.
TMP_PATH=/var/tmp
TMPL_PATH=/usr/share/doc/nvidia-driver-460/
echo "options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=${TMP_PATH}" | sudo tee /etc/modprobe.d/nvidia-power-management.conf
@bmcbm
bmcbm / .bash_aliases
Last active April 4, 2018 12:21
# Timestamped, Git enabled Prompt
#!/bin/bash
# Timestamped, Git enabled Prompt
export PS1='\[\e[01;30m\]\t\[\033[01;32m\] \u\[\e[0m\]@\[\e[01;95m\]\h\[\033[00m\]:\[\e[01;34m\]\w\[\e[00m\]`[[ $(git status 2> /dev/null) =~ Changes\ to\ be\ committed: ]] && echo "\[\e[38;5;202m\]" || echo "\[\e[31m\]"``[[ $(git status 2> /dev/null) =~ untracked\ files\ present ]] && echo "\[\e[33m\]"``[[ ! $(git status 2> /dev/null) =~ nothing\ to\ commit,\ working\ .+\ clean ]] || echo "\[\e[32m\]"`$(__git_ps1 "(%s)")\[\e[00m\]\$ '
@bmcbm
bmcbm / .emacs
Last active January 16, 2018 07:26
.emacs file
;; Sæt (netværks)printer sti
;(setq lpr-switches nil) ; Stop printing headers
;(setq printer-name "HPLJ6MP")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; start gnuserv stuff. Put it up front so you don't get into a
;; timeout problem when starting emacs from gnuclient or gnudoit,
;; according to Cristian Ionescu-Idbohrn
@bmcbm
bmcbm / gnome3-unity-settings.sh
Last active August 29, 2022 10:52
Gnome3 Unity settings
#!/bin/bash
# Add date and weekeday to clock to Gnome Shell
gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.desktop.interface clock-show-weekday true
# Move window control buttons to the left, Unity Style
gsettings set org.gnome.desktop.wm.preferences button-layout close,minimize,maximize:
# Move show application button from bottom of dash to top
@bmcbm
bmcbm / .bash_aliases
Last active February 1, 2018 13:58
Add scp and snapshot (ie. shorthand for vboxmanage snapshot) to vagrant command
#!/bin/bash
function vagrant() {
if [ -x /usr/bin/vagrant ] ; then
if [ "$1" = 'scp' ]; then
# Inspired by https://gist.github.com/colindean/5213685
TMPFILE=$(mktemp)
HOST=$( echo "${@: -1}" | cut -d: -f1)
/usr/bin/vagrant ssh-config $HOST > $TMPFILE
if [ $? -eq 0 ] ; then