Skip to content

Instantly share code, notes, and snippets.

View coltenkrauter's full-sized avatar
👩‍🌾
Husband, father of four, full-stack developer

Colten Krauter coltenkrauter

👩‍🌾
Husband, father of four, full-stack developer
  • Stevensville, MT
View GitHub Profile
@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-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 / 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 / fix-wsl2-dns-resolution.md
Last active June 9, 2025 17:07
Fix DNS resolution in WSL2

Permanent WSL DNS Fix (WSL 2.2.1+)

If you're encountering ping github.com failing inside WSL with a Temporary failure in name resolution, you're not alone — this has been a long-standing issue, especially when using VPNs or corporate networks.

This issue is now fixed robustly with DNS tunneling, which preserves dynamic DNS behavior and avoids limitations like WSL’s former hard cap of 3 DNS servers in /etc/resolv.conf.

DNS tunneling is enabled by default in WSL version 2.2.1 and later, meaning that if you're still seeing DNS resolution issues, the first and most effective fix is simply to upgrade WSL. Upgrading WSL updates the WSL platform itself, but does not affect your installed Linux distributions, apps, or files.

To upgrade WSL, follow these steps,

@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 / html-input-remove-chrome-autofill-background.css
Last active February 16, 2025 09:35
Remove Chrome's autofill background color on HTML inputs. This unique solution makes the background color to transparent rather then a solid color.
// Remove chrome autofill color from inputs
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
transition: background-color 5000000s ease-in-out 0s;
}
# Credit: https://stackoverflow.com/questions/2781549/removing-input-background-colour-for-chrome-autocomplete#answer-29350537
@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 / .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 / README.md
Last active April 3, 2024 12:04
Toggle Airport: Disable Wi-Fi when connected to ethernet

toggle-airport

Code for disabling Wi-Fi when docking (connecting an ethernet adapter) and enabling Wi-Fi when disconnecting from ethernet.

I am using MacBook Pro 15'' with macOS Catalina.

Quick start

  1. Put toggleAirport.sh in the correct location with the right permissions (see comment at the top of the file)
  2. Put com.mine.toggleairport.plist in the correct location with the right permissions (see comment at the top of the file)