Skip to content

Instantly share code, notes, and snippets.

View jtorvald's full-sized avatar
🤓
coding

Jørgen jtorvald

🤓
coding
View GitHub Profile
@jtorvald
jtorvald / normalize_chars.go
Created November 26, 2020 13:44
Normalize special characters in Go
package main
import (
"fmt"
"strings"
)
// https://play.golang.org/p/-U255E1eOf_O
func main() {
org := "ÀØėÿᾜὨζὅБю Yoùr Śtring šđč枊ĐČĆŽèàì - øÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ"
@jtorvald
jtorvald / reset-audio.command
Last active March 29, 2022 11:09
Fix annoying popping crackling sound on the new MacBook Pro 16inch. Save this file and run it or copy and paste the onliner and run it in a terminal.
# if you don't understand how to save this file and execute it (open reset-audio.command)
# then copy and paste this oneliner and enter your password for privileged access:
# sudo kill -9 $(ps axc|awk "{if (\$5==\"coreaudiod\") print \$1}");
# get the process ID of coreaudio
PID=$(ps axc|awk "{if (\$5==\"coreaudiod\") print \$1}")
if [ $PID != "" ]
then
echo "Killing coreaudiod process on $PID"
@jtorvald
jtorvald / socks.sh
Last active February 8, 2019 14:44
Setup socks proxy through ssh and change proxy settings on Mac OSX
# connect to ssh host on a specific port and open the local port (8123 in this case)
ssh -D 8123 -f -C -q -N user@example.com -p 1022
# setup the socks proxy for the Wi-Fi adapter to connect to port 8123
networksetup -setsocksfirewallproxy "Wi-Fi" localhost 8123
# wait till user presses a key to revert changes
read -p "Setup. Please connect. Press enter key to disconnect"
# turn off socks proxy
networksetup -setsocksfirewallproxystate "Wi-Fi" off
# kill the ssh command
kill -15 $(ps aux | grep "[s]sh -D" | awk '{ print $2}')