Skip to content

Instantly share code, notes, and snippets.

View chris-kobrzak's full-sized avatar

Chris Kobrzak chris-kobrzak

View GitHub Profile
@chris-kobrzak
chris-kobrzak / wrap-pascalcase.vim
Created April 15, 2026 09:23
Wrap PascalCase words in backticks to highlight them in Markdown
:%s/\(\u\l\+\)\{2,\}/`&`/g
@chris-kobrzak
chris-kobrzak / rip-yt-audio.sh
Created November 23, 2025 14:49
Ripping YouTube audio
#!/usr/bin/env bash
brew install ffmpeg yt-dlp
yt-dlp -x --audio-format mp3 https://youtu.be/<video-path>
@chris-kobrzak
chris-kobrzak / .hammerspoon [slash] init.lua
Last active October 21, 2025 09:56
Hammerspoon script enabling a Mac Shortcuts workflow when an external monitor gets connected
-- Mac Shortcuts workflow name
local workflowName = "Home Bluetooth"
hs.logger.defaultLogLevel = "info"
local log = hs.logger.new("DisplayWatcher", "info")
local function runWorkflowIfExternalDisplay()
local hasExternal = false
for _, screen in ipairs(hs.screen.allScreens()) do
if screen:name() ~= "Built-in Retina Display" then
@chris-kobrzak
chris-kobrzak / touchid-in-iterm.md
Created January 8, 2025 15:54
Enable TouchID from within iTerm2 (sudo)

sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local

Add the line auth sufficient pam_tid.so to the beginning of /etc/pam.d/sudo

Save the file and open a new iTerm2 session

@chris-kobrzak
chris-kobrzak / takeWithTimerSaga.ts
Created March 1, 2024 11:15
Generic Redux Saga task that waits for an event and triggers another timeout event if the former never gets dispatched
function* takeWithTimerTask(
eventName: AnyEvent['type'],
timeoutEventName: AnyEvent['type'],
timeout: number
) {
const timerTask = yield* fork(
fireEventAfterDelayTask,
timeoutEventName,
timeout
)
@chris-kobrzak
chris-kobrzak / kill-high-cpu-processes.sh
Last active January 31, 2024 17:53
Shell script for detecting Linux processes consuming extensive amounts of processing power. Intended to be run on schedule.
#!/usr/bin/env bash
# 95% CPU utilisation
threshold=0.95
log_file="/var/log/kill-high-cpu-processes.log"
get_process_info() {
process_id=$1
ps -p "$process_id" -o pid,ppid,cmd,%cpu,%mem,stat --no-header | awk '{$1=$1};1'
@chris-kobrzak
chris-kobrzak / xcode-device-cleanup.sh
Created February 25, 2023 19:45
Xcode devices clean-up
xcrun simctl list devices
# Remove old devices stored under ~/Library/Developer/CoreSimulator/Devices (and clogging the disk)
xcrun simctl delete unavailable
@chris-kobrzak
chris-kobrzak / find-duplicates.sh
Created January 17, 2023 18:50
Find duplicated files sharing names but with different extensions (e.g. Nikon .nef and .jpg files)
# in this example we are removing JPG files sitting alongside .nef files
for name in `ls * | sed 's/.\{4\}$//' | sort | uniq -d`
do
# Remove echo below to actually delete files
echo rm $name.jpg
done
@chris-kobrzak
chris-kobrzak / verify-fstab.sh
Created January 5, 2023 18:05
Verify /etc/fstab entries
#!/usr/bin/env sh
sudo findmnt --verify --verbose
@chris-kobrzak
chris-kobrzak / readonlyDecorator.ts
Created November 11, 2022 12:01
JS decorators example
function readonly(target: any, name: string, descriptor: TypedPropertyDescriptor<() => void>) {
descriptor.writable = false
return descriptor
}
class Example {
a: number
@readonly
b() {}