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
| -- 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
| function* takeWithTimerTask( | |
| eventName: AnyEvent['type'], | |
| timeoutEventName: AnyEvent['type'], | |
| timeout: number | |
| ) { | |
| const timerTask = yield* fork( | |
| fireEventAfterDelayTask, | |
| timeoutEventName, | |
| timeout | |
| ) |
| #!/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' |
| xcrun simctl list devices | |
| # Remove old devices stored under ~/Library/Developer/CoreSimulator/Devices (and clogging the disk) | |
| xcrun simctl delete unavailable |
| # 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 |
| #!/usr/bin/env sh | |
| sudo findmnt --verify --verbose |
| function readonly(target: any, name: string, descriptor: TypedPropertyDescriptor<() => void>) { | |
| descriptor.writable = false | |
| return descriptor | |
| } | |
| class Example { | |
| a: number | |
| @readonly | |
| b() {} |
| CREATE OR REPLACE FUNCTION gen_random_string(_min_length INT = 3) | |
| RETURNS VARCHAR | |
| LANGUAGE SQL | |
| AS ' | |
| SELECT substring( | |
| md5(random()::TEXT), | |
| 0, | |
| _min_length + floor(random() * 10 + 1)::INT | |
| ) | |
| '; |
| # List all available database versions | |
| aws rds describe-db-engine-versions --query '*[].[EngineVersion]' --output text --region eu-west-1 --engine postgres | |
| aws rds describe-db-engine-versions --query '*[].[EngineVersion]' --output text --region eu-west-1 --engine aurora-postgresql | |
| # Connect to Postgres via SSH's ProxyJump | |
| ssh \ | |
| -L 5555:your.private.postgres.hostname:5432 \ | |
| -J your.proxy.hostname \ | |
| private.hostname.with.access.to.postgres |