Skip to content

Instantly share code, notes, and snippets.

@baztian
baztian / sqs-send-completion.bash
Last active December 11, 2024 14:45
Interactive AWS SQS command line tool
#!/usr/bin/env bash
_sqs_send_completions()
{
local cur=${COMP_WORDS[COMP_CWORD]}
# Don't consider colon (from url) as word break
_get_comp_words_by_ref -n : cur
COMPREPLY=( $( compgen -W "$(aws sqs list-queues --query 'QueueUrls' --output text)" -- $cur ) )
__ltrim_colon_completions "$cur"
}
@baztian
baztian / _aws-sso.sh
Last active July 10, 2024 15:05
Allows selecting an aws profile and logs into the account via sso
#!/bin/sh
PROFILE="$1"
if [ -z "$PROFILE" ]; then
PROFILE=$(aws-list-sso-profiles|fzf --preview "sed -n \"/\[profile \"{}\"/,/^\[/ { /^\[/!p; }\" ~/.aws/config | sed \"\$d\"")
if [ -z "$PROFILE" ]; then
echo No profile selected. Exiting. >&2
return 1
fi
fi
@baztian
baztian / xdospeech.py
Created February 19, 2024 13:04
Speech recognition and insert at cursor position
#!/usr/bin/env python3
import subprocess
import sys
import speech_recognition as sr
def get_audio_text(language=None):
language = language or "en-US"
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Say something:")
@baztian
baztian / update-github-deb.sh
Last active April 4, 2024 19:17
Update a debian package that's available as a download/realease on github
#!/bin/bash
set -e
# Check if sufficient arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <github-repo> <package-name>"
exit 1
fi
#!/usr/bin/env python3
import boto3
import urllib.parse
from concurrent.futures import ThreadPoolExecutor, as_completed
import os
import select
import sys
import termios
import tty
import argparse
@baztian
baztian / git-pager.sh
Created February 17, 2025 13:35
Use diff-highlight instead the default diff for git if available
#!/bin/sh
# Git pager script for using diff-highlight
# Path to the diff-highlight script
DIFF_HIGHLIGHT="/usr/share/doc/git/contrib/diff-highlight/diff-highlight"
# Check if diff-highlight is available and executable
if [ -f "$DIFF_HIGHLIGHT" ]; then
# Use diff-highlight in the pipeline
perl "$DIFF_HIGHLIGHT" | less -r