Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
-> The Band Red

Colten Krauter coltenkrauter

🎧
-> The Band Red
View GitHub Profile
@coltenkrauter
coltenkrauter / nginx.conf
Created Jan 23, 2021
Nginx configuration for SPAs (Single page applications) such as React or Angular
View nginx.conf
# https://www.zeolearn.com/magazine/setting-caching-headers-for-a-spa-in-nginx-cache
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
# X-Frame-Options is to prevent from clickJacking attack
add_header X-Frame-Options SAMEORIGIN;
@coltenkrauter
coltenkrauter / docker-compose.yaml
Last active May 31, 2021
Traefik V2 Docker Compose file with LetsEncrypt and HTTPS redirect - Traefik dashboard and simple whoami service
View docker-compose.yaml
# Tutorial: https://blog.creekorful.com/2020/01/how-to-expose-traefik-2-dashboard-securely-docker-swarm/
version: '3'
services:
reverse-proxy:
image: traefik:2.3
command:
# - '--log.level=DEBUG'
- '--api=true'
- '--api.dashboard=true'
@coltenkrauter
coltenkrauter / terminus.sublime-keymap
Created Feb 28, 2020
Sublime Terminus key bindings
View terminus.sublime-keymap
[
{
"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 / README.md
Last active Feb 4, 2020
Toggle Airport: Disable Wi-Fi when connected to ethernet
View README.md

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)
@coltenkrauter
coltenkrauter / .zprofile
Last active May 1, 2020
Zsh startup script: make some aliases, install some packages, export some certs from keychain and set environment variables.
View .zprofile
# 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 / pretty_json.py
Last active Nov 15, 2019
A simple helper function for formatting/indenting a Python object as JSON.
View pretty_json.py
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 / html-input-remove-chrome-autofill-background.css
Last active Nov 29, 2019
Remove Chrome's autofill background color on HTML inputs. This unique solution makes the background color to transparent rather then a solid color.
View html-input-remove-chrome-autofill-background.css
// 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 / normalize-audio.py
Created Oct 24, 2019
Python code for normalizing audio files.
View normalize-audio.py
# 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 / fix-wsl2-dns-resolution
Last active Sep 17, 2021
Fix DNS resolution in WSL2
View fix-wsl2-dns-resolution
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@coltenkrauter
coltenkrauter / git-automatic-commit-signing
Last active Dec 27, 2019
Quickly start signing GitHub git commits - GPG Key Generation, global automatic commit signing
View git-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