Skip to content

Instantly share code, notes, and snippets.

View coltenkrauter's full-sized avatar
🔥
Fire

Colten Krauter coltenkrauter

🔥
Fire
  • Stevensville, MT
View GitHub Profile
@coltenkrauter
coltenkrauter / normalize-audio.py
Created October 24, 2019 00:51
Python code for normalizing audio files.
# Credit: https://stackoverflow.com/questions/42492246/how-to-normalize-the-volume-of-an-audio-file-in-python-any-packages-currently-a#answer-42496373
# pip install pydub
from pydub import AudioSegment
def match_target_amplitude(sound, target_dBFS):
change_in_dBFS = target_dBFS - sound.dBFS
return sound.apply_gain(change_in_dBFS)
sound = AudioSegment.from_file("yourAudio.m4a", "m4a")
@coltenkrauter
coltenkrauter / pretty_json.py
Last active November 15, 2019 23:46
A simple helper function for formatting/indenting a Python object as JSON.
import json
# Example usage: print(pretty_json(some_dict))
def pretty_json(object):
try:
return json.dumps(object, indent=4)
except Exception as exception:
print("---> Unable to parse object as JSON")
return str(object)
@coltenkrauter
coltenkrauter / fix-chmod-wsl2.sh
Last active November 29, 2019 19:45
Remount NTSF drive in WSL2 with the metadata option so chmod will work.
# Remount NTSF drive in WSL2 with the metadata option so chmod will work.
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata
# If you get an error "target is busy" then try to cd / before running the above commands. You may also have to exit other terminals that are using WSL2.
@coltenkrauter
coltenkrauter / git-automatic-commit-signing
Last active December 27, 2019 23:58
Quickly start signing GitHub git commits - GPG Key Generation, global automatic commit signing
# I am using WSL2 on Windows 10
# Generate GPG key
gpg --full-generate-key
# List keys, find the one you just made and grab the key id
gpg --list-secret-keys --keyid-format LONG
# OUTPUT
# sec rsa4096/1124F0AFF0B78C69 2019-10-16 [SC] # LONG key id in this case is 1124F0AFF0B78C69
@coltenkrauter
coltenkrauter / .zprofile
Last active May 1, 2020 19:13
Zsh startup script: make some aliases, install some packages, export some certs from keychain and set environment variables.
# Setup subl
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl > /dev/null 2>&1
# Helper functions
commit() {
echo '\nCommit message: '
local temp
vared temp
echo ''
@coltenkrauter
coltenkrauter / docker-pip3-cryptography-dependency
Last active September 29, 2020 03:12
Resolve issues where docker pip install fails due to a cryptography dependency.
# https://github.com/odoo/odoo/issues/8849#issuecomment-322115976
# For APT
apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
# For APK
apk add python3-dev libffi-dev libressl-dev openldap-dev
# Example alpine docker file
FROM python:3.7-alpine
@coltenkrauter
coltenkrauter / terminus.sublime-keymap
Created February 28, 2020 17:26
Sublime Terminus key bindings
[
{
"keys": ["ctrl+t"], "command": "toggle_terminus_panel",
"args": {
"config_name": "Default",
"panel_name": "output",
}
},
{
"keys": ["ctrl+w"], "command": "terminus_close", "context": [{ "key": "terminus_view"}]
@coltenkrauter
coltenkrauter / .profile
Last active March 2, 2021 12:20
WSL2 .profile
# ~/.profile
cd ~/Repositories
# Useful aliases
alias subl="/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe"
alias chrome="/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe"
alias github="chrome https://github.com/coltenkrauter?tab=repositories"
alias downloads="echo /mnt/c/Users/Colten/Downloads/"
alias clo="git clone"
@coltenkrauter
coltenkrauter / docker-compose-home-assistant.yml
Last active September 11, 2022 16:47
Docker compose file for setting up Home Assistant with ZWAVEJS in order to support Aeotec Z-Stick Gen5 Z-Wave Plus USB Gateway
# docker-compose-home-assistant.yml or docker-compose.yml
# Before running 'docker-compose up -d', ensure that all directories exist and bash variables are set
# Here is an example of how you could create the dirs and set the vars needed in this file:
# Resource: https://zwave-js.github.io/zwavejs2mqtt/#/getting-started/docker?id=installation
# BOOTSTRAP_Z_STICK_USB_ID="$(l /dev/serial/by-id/ | head -c -2)"
# BOOTSTRAP_ZWAVEJS_SESSION_SECRET="$(cat /dev/urandom | env LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
# echo "export BOOTSTRAP_Z_STICK=$BOOTSTRAP_Z_STICK" >> $HOME/.bashrc
# echo "export BOOTSTRAP_ZWAVEJS_SESSION_SECRET=$BOOTSTRAP_ZWAVEJS_SESSION_SECRET" >> $HOME/.bashrc
@coltenkrauter
coltenkrauter / one-liners-append-to-file.sh
Created September 11, 2022 20:11
Bash/sh/zsh one liners, append to a file with sudo
# 1. One liner, append to a file
echo "A new line at the end of the file" >> file.txt
# 2. One liner, append to a file including newlines
echo -e "\n\nA new line at the end of the file that is preceeded by some new lines" >> file.txt
# 3. One liner, append to a file the requires sudo
echo "A new line at the end of the file that requires sudo" | sudo tee -a /etc/fstab
---