- Single Responsibility Principle: Each module, class, or function should have a single, well-defined responsibility.
- Don't Repeat Yourself (DRY): Avoid duplication of logic across the codebase.
- Separation of Concerns: Do not mix different levels of abstraction in a single file (e.g., keep low-level utilities separate from high-level orchestrators).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :%s/\(\u\l\+\)\{2,\}/`&`/g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| brew install ffmpeg yt-dlp | |
| yt-dlp -x --audio-format mp3 https://youtu.be/<video-path> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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 |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function* takeWithTimerTask( | |
| eventName: AnyEvent['type'], | |
| timeoutEventName: AnyEvent['type'], | |
| timeout: number | |
| ) { | |
| const timerTask = yield* fork( | |
| fireEventAfterDelayTask, | |
| timeoutEventName, | |
| timeout | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| xcrun simctl list devices | |
| # Remove old devices stored under ~/Library/Developer/CoreSimulator/Devices (and clogging the disk) | |
| xcrun simctl delete unavailable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| sudo findmnt --verify --verbose |
NewerOlder