Skip to content

Instantly share code, notes, and snippets.

View davidverweij's full-sized avatar
🧤

David davidverweij

🧤
View GitHub Profile
@davidverweij
davidverweij / json_dot_notation_accessor.py
Last active November 29, 2021 17:17
Access key's in a nested dict/list (e.g., json payload) using a dot.notation string
from functools import reduce
import re
from typing import Any, Optional
def find_key(dot_notation_path: str, payload: dict) -> Any:
"""Try to get a deep value from a dict based on a dot-notation"""
def get_despite_none(payload: Optional[dict], key: str) -> Any:
"""Try to get value from dict, even if dict is None"""
if not payload or not isinstance(payload, (dict, list)):
@davidverweij
davidverweij / bluetooth.scpt
Last active June 15, 2021 16:41
Turn Bluetooth on/off - quick action for Apple Touch Bar
(* Open Automator, add quick action, run AppleScript and paste this AppleScript. Specific 'button' and 'window' might differ per MacOS. I'm on 10.15.7 *)
on run {input, parameters}
tell application "System Preferences"
reveal pane "com.apple.preferences.Bluetooth"
end tell
tell application "System Events" to tell process "System Preferences"
click button 3 of window 1
end tell
@davidverweij
davidverweij / batch_commands.md
Last active August 31, 2021 13:16
Personal common terminal commands (and their libraries) for batch processing

Terminal Cheat Sheet

A little Gist to keep terminal commands I have used, and will likely re-use, for batch processing files (semi-everyday use). Let me know if I am missing out on some.

Ps. I'm on MacOS

Convert multiple .wav to .mp3

Required: lame

cd /folder/containing/.wav/files
for f in *.wav; do lame --preset insane "$f" "${f%.wav}.mp3"; done