Skip to content

Instantly share code, notes, and snippets.

View iloveitaly's full-sized avatar

Michael Bianco iloveitaly

View GitHub Profile
if (( $+commands[az] )); then
autoload -U +X bashcompinit && bashcompinit
source $(brew --prefix)/etc/bash_completion.d/az
fi
# make sure you execute this *after* asdf or other version managers are loaded
if (( $+commands[ov] )); then
eval "$(ov --completion zsh)"
fi
@iloveitaly
iloveitaly / openai_log_to_file.py
Created March 25, 2024 21:49
funnel all the OpenAI logs to a specific file.
def setup():
"""
Config below is subject to change
https://stackoverflow.com/questions/76256249/logging-in-the-open-ai-python-library/78214464#78214464
https://github.com/openai/openai-python/blob/de7c0e2d9375d042a42e3db6c17e5af9a5701a99/src/openai/_utils/_logs.py#L16
"""
openai_log_path = taxdocs.root / "openai.log"
openai_file_handler = logging.FileHandler(openai_log_path)
# make sure you execute this *after* asdf or other version managers are loaded
# bun completions are strange: running `bun completions` installs ~/.bun/_bun and does not output the completion source code
# this is a hack until bun fixes their completion setup https://github.com/oven-sh/bun/issues/1272
if (( $+commands[bun] )); then
[ -s ~/.bun/_bun ] || bun completions
# cannot source directly, must add fpath to completions
fpath+=~/.bun/
# make sure you execute this *after* asdf or other version managers are loaded
# the default docker completion is not as advanced as this one, you'll want to remove it:
# rm $(brew --prefix)/share/zsh/site-functions/_docker
# https://github.com/docker/compose/issues/8550
if (( $+commands[docker] )); then
eval "$(docker completion zsh)"
fi
@iloveitaly
iloveitaly / categorize.py
Created February 9, 2024 00:10
Example of how to categorize emails using openai
import click
import sqlite_utils
import json
import logging
SERVICE = "openai"
PREFIX = ""
logger = logging.getLogger(__name__)
@iloveitaly
iloveitaly / logout_twitter.applescript
Created November 25, 2023 00:37
Logout of Twitter with an Applescript. Fight distraction.
tell application "Safari"
activate
open location "https://twitter.com/logout"
end tell
tell application "System Events"
tell process "Safari"
delay 0.5
click button "Log out" of group 1 of group 1 of group 1 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1
end tell
# make sure you execute this *after* asdf or other version managers are loaded
if (( $+commands[pack] )); then
source "$(pack completion --shell zsh)"
fi
@iloveitaly
iloveitaly / 1password.zsh
Last active October 31, 2023 14:43
a zsh plug-in to load the one password shell completions and plugin environment variables
# make sure you execute this *after* asdf or other version managers are loaded
if (( $+commands[op] )); then
eval "$(op completion zsh)"
compdef _op op
# load plugins configuration
if [[ -f ~/.config/op/plugins.sh ]]; then
source ~/.config/op/plugins.sh
fi
fi