10 KiB
10 KiB
Throw away pastebin
Just a place to throw away some text.
macOS
Never sleep:
caffeinate -u -t 3600
caffeinate -i
Use Touch ID in Terminal:
sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local
# Uncomment last line
sudo nano /etc/pam.d/sudo_local
Hide Developer in Spotlight:
cd /Applications
touch Xcode.app
# Xcode mini version
xcode-select --install
Reset launchpad:
defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
Reduce padding in menu bar (Log out then log in to apply):
defaults -currentHost write -globalDomain NSStatusItemSelectionPadding -int 6
defaults -currentHost write -globalDomain NSStatusItemSpacing -int 6
Tweak Finder:
# Use list view
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Show filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
killall Finder
Disable IPv6:
sudo networksetup -listallnetworkservices
sudo networksetup -setv6off Wi-Fi
Clean up leftover data:
/Library/Application Support
/Library/LaunchAgents
/Library/LaunchDaemons
/Library/Preferences
/Users/Shared
~/Library/Application Support
~/Library/Fonts (Removed)
~/Library/LaunchAgents
~/Library/Preferences
Clean up leftover shell:
/etc/bashrc
/etc/profile
/etc/zshrc
/etc/paths.d
Clean up clipboard:
pbcopy < /dev/null
Disable Smart zoom in Track pad settings to make right click instant
Fix OpenVPN Client 3
sudo launchctl unload -w /Library/LaunchDaemons/org.openvpn.client.plist
sudo launchctl load -w /Library/LaunchDaemons/org.openvpn.client.plist
Bluetooth stutter:
sudo rm /Library/Preferences/com.apple.Bluetooth.plist
sudo pkill bluetoothd
Thanks:
- Can Touch ID on Mac authenticate sudo in Terminal?
- Native fix for applications hiding under the MacBook Pro notch
- macOS: How to Disable IPv6
- How to fully uninstall Logitech G HUB on macOS via terminal/command line
- Hardening macOS
- Mac Setup
- https://github.com/OpenVPN/openvpn3/issues/243
- https://stackoverflow.com/q/15872666
- Reclaiming storage/space from 'System Data' in macOS: A tutorial on understanding the System Data usage
- Upgrading Homebrew and avoiding the failed to verify attestation error
Firefox
about:config
:
-
Disable unused features:
extensions.pocket.enabled
: falseidentity.fxaccounts.enabled
: falsereader.parse-on-load.enabled
: false
-
Good settings:
media.videocontrols.picture-in-picture.video-toggle.always-show
: truenetwork.IDN_show_punycode
: truebrowser.tabs.insertAfterCurrent
: true
-
Encrypted Client Hello (ECH):
network.dns.echconfig.enabled
: truenetwork.dns.use_https_rr_as_altsvc
: true
-
Experiment
image.jxl.enabled
: true
Thanks:
- My list of useful command line tools
- Useful Customizations for Firefox
- Encrypted Client Hello: the future of ESNI in Firefox
- Phishing with Unicode Domains
- https://sizeof.cat/links/
.gitignore
# macOS
.DS_Store
# Window
*.exe
# IntelliJ
.idea
# VSCode
.vscode
# Go
coverage.out
vendor
# GoReleaser
dist
GitHub Actions
dependabot.yml
:
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
go.yml
:
name: Go
on:
push:
branches:
- main
paths:
- "**.go"
- "go.mod"
- "go.sum"
pull_request:
branches:
- main
paths:
- "**.go"
- "go.mod"
- "go.sum"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "stable"
- run: go test -race -failfast ./...
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "stable"
- run: go build .
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: "stable"
- uses: golangci/golangci-lint-action@v3
with:
version: latest
Go
.golangci.yml
:
run:
timeout: 5m
tests: false
output:
sort-results: true
linters:
disable-all: true
enable:
# Default
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# Custom
- err113
- errchkjson
- errname
- errorlint
- forcetypeassert
- gocritic
- gofumpt
- gosec
- importas
- makezero
- nilnil
- noctx
- prealloc
- reassign
- sqlclosecheck
- unconvert
fast: true
linters-settings:
# Default
govet:
check-shadowing: false
disable-all: true
enable:
- assign
- atomic
- bools
- buildtag
- composites
- copylocks
- fieldalignment
- httpresponse
- loopclosure
- lostcancel
- nilfunc
- printf
- unmarshal
- unreachable
- unusedresult
staticcheck:
checks: ["all", "-SA1019"]
# Custom
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch
- unnamedResult
- whyNoLint
enabled-tags:
- diagnostic
- style
gosec:
excludes:
- G101
- G112
- G115
- G204
- G402
- G404
- G501
- G505
exclude-generated: true
reassign:
patterns:
- ".*"
issues:
exclude-dirs:
- ".*test.*"
- ".*mock.*"
- ".*example.*"
- ".*utils.*"
exclude-files:
- ".*Mock.*"
- ".*_mock.*"
.goreleaser.yml
:
before:
hooks:
- go mod tidy
builds:
- main: .
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
universal_binaries:
- replace: true
archives:
- format_overrides:
- goos: windows
format: zip
changelog:
skip: false
use: github
ssh config
Edit ~/.ssh/config
Host *
IdentitiesOnly yes
UseKeychain yes
Thanks:
- OpenSSH client side key management for better privacy and security
- Git keeps asking me for my ssh key passphrase
git clean up
# Delete untracked
git clean -fdx
git gc
Delete .DS_Store
With find:
find . -name ".DS_Store" -print -type f -delete
With fd:
fd -H '^\.DS_Store$' -tf -X rm
sd
Remove proto options:
sd -F 'import "validate/validate.proto";' '' api/raw/*.proto
sd -F 'import "marshal-zap.proto";' '' api/raw/*.proto
sd -f s '\s\[.*?];' ';' api/raw/*.proto
fdupes
Remove duplicated files:
fdupes -rdN .
rsync
# Result is dst/src
rsync -avzP src dst
# Result is dst/* with * is from src
rsync -avzP src/ dst
Commonly flags:
-v
: verbose-z
: compress-P
: enable both--partial
,--progress
to easily resume after interrupt-n
: dry run
Be careful flags (need dry run if not sure):
-u
: skip if files in dst is already newer than in src, if you want to sync both ways--delete
: delete files in dst if not exist in src, useful to sync dst with src
ffmpeg
# -crf: quality, 0 is lossless, more is lower quality
# -an: no audio
# -c:a aac -b:a 128k: audio codec and bitrate
ffmpeg -i input -c:v libx265 -crf 26 -preset fast -an output.mp4
Links:
libvips
Convert:
# Add --vips-progress to show progress
vips jxlsave filename.jpg filename.jxl --keep=none
vips jpegsave filename.png filename.jpg --keep=none
# Batch convert (require fd)
fd "jpg|jpeg|png|webp|gif" --exec vips jxlsave {} {.}.jxl --keep=none
fd "jpg|jpeg|png|webp|gif" --exec-batch rm
fd "png|webp|gif" --exec vips jpegsave {} {.}.jpg --keep=none
fd "png|webp|gif" --exec-batch rm
# Rotate
vips rot filename.jxl new_filename.jxl d90
yt-dlp
Download:
yt-dlp -f - "https://www.youtube.com/watch?v=video_id"
F2
Rename:
# If dry run, remove --exec
f2 --replace "{mtime.YYYY}{mtime.MM}{mtime.DD}_{mtime.H}{mtime.mm}{mtime.ss}_{hash.md5}{ext}" --exec
# Include ImageSize (require exiftool)
f2 --replace "{mtime.YYYY}{mtime.MM}{mtime.DD}_{mtime.H}{mtime.mm}{mtime.ss}_{xt.ImageSize}_{hash.md5}{ext}" --exec
# Not include time
f2 --exclude="\d+x\d+_[a-z\d]{32}" --sort=mtime --replace "{xt.ImageSize}_{hash.md5}{ext}" --exec
# Remove space in directory
f2 --find " " --replace "_" --string-mode --only-dir --exec