Skip to content

Instantly share code, notes, and snippets.

@bmcbm
bmcbm / Scale_video_and_photos_on_smartphone.txt
Last active November 30, 2024 15:00
Scale video and images to save size on phone
So I was running out of space on my cell phone a Google Pixel 6a with 128 GB og storage.
Years of photos and videoes in particular was taking up almost all storage.
So either I could get a new phone with more storage or reduce the size of the files
(since I dont want to store my stuff on Google Cloud storage)
I went for the latter since the phone is working fine and to my liking.
To resize the images I use GNU parallel to run Imagemagick convert to reduce resolution
to 1080p (I do not convert the panoramas)
$ ls *jpg | grep -v PANO | parallel -j 16 convert {} -resize 1920x1920 ../scaled/{.}.scaled.jpg
@bmcbm
bmcbm / gist:91d92395c5b26f9dcd76b47dd3161fa0
Created October 22, 2024 09:01
Ubuntu - Reverse stereo output on a sink
# Reverse stereo output
# Get the sinks:
pacmd list-sinks | grep name: | sed -E 's/.*name: <(.*)>/\1/'
# Set switched stereo channels for the desired sink (here "alsa_output.pci-0000_28_00.3.analog-stereo")
# Set name Ombyt-Stereo
pacmd load-module module-remap-sink master=alsa_output.pci-0000_28_00.3.analog-stereo sink_name=Ombyt-Stereo sink_properties=device.description=Ombyt-Stereo channels=2 channel_map=front-left,front-right master_channel_map=front-right,front-left
@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 November 17, 2024 23:32
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