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)
@iloveitaly
iloveitaly / hide_and_quit_apps.sh
Created January 6, 2023 23:09
Hide and quit macOS applications in bash/zsh using AppleScript via osascript
function quit_apps() {
for app in $@; do
echo "Quitting $app..."
osascript -e "with timeout of 30 seconds
quit app \"$app\"
end timeout"
if [ $? -ne 0 ]; then
# if the application did not quit on it's own, let's force it!
@iloveitaly
iloveitaly / capybara_fill_stripe_elements.rb
Created March 4, 2017 21:21
Fill in a Stripe Elements (https://stripe.com/docs/elements) credit card field using capybara
def fill_stripe_elements(card)
using_wait_time(15) { within_frame('stripeField_card_element0') do
card.to_s.chars.each do |piece|
find_field('cardnumber').send_keys(piece)
end
find_field('exp-date').send_keys("0122")
find_field('cvc').send_keys '123'
find_field('postal').send_keys '19335'
end }
@iloveitaly
iloveitaly / suitescript_utilities.js
Last active February 22, 2024 21:52
Simple utilities to help ease NetSuite SuiteScript development
// Author <mike@suitesync.io>
function isUserInterfaceContext() {
var context = nlapiGetContext();
var executionContext = context.getExecutionContext();
return executionContext == 'userinterface';
}
function startsWith(str, searchString) {
# 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/
@iloveitaly
iloveitaly / stripe_create_subscription_with_avalara.rb
Last active February 9, 2024 22:59
Create a Stripe Subscription with required information for Avalara's integration
# Michael Bianco <mike@suitesync.io>
# Description: Create a Stripe Subscription with required information for Avalara's
# Stripe Subscription integration.
# Learn more: https://gist.github.com/iloveitaly/7b9b288d203f6ac7f75d8eda14e07c18
# Usage:
#
# export STRIPE_KEY=sk_test
# gem install stripe
# ruby stripe_create_subscription_with_avalara.rb
# 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