This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# recursive cat/print based on filetype | |
# requires fzf and bat | |
catr() { | |
# Calculate the maximum possible file depth in the current directory | |
local max_depth | |
max_depth=$(find . -type d | awk -F/ '{print NF-1}' | sort -nr | head -n1 || echo 0) | |
# Prompt for file depth if not provided as the first argument | |
local depth="${1}" | |
if [[ -z "$depth" ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# placed inside ~/.oh-my-zsh/custom/aliases.zsh | |
# requires fzf | |
sso() { | |
local profile_file="$HOME/.aws/config" | |
local profiles | |
# Check if ~/.aws/config exists | |
if [[ ! -f $profile_file ]]; then | |
echo "AWS config file not found: $profile_file" | |
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import instaloader | |
L = instaloader.Instaloader() | |
L.login("username", "password") | |
# Obtain profile metadata | |
profile = instaloader.Profile.from_username(L.context, "username") | |
# people who follow you |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This module provides functionality for making HTTP requests. It leverages the `aiohttp` | |
library for asynchronous HTTP requests, and the `backoff` library to implement exponential | |
backoff in case of failed requests. | |
The module defines a child logger for logging purposes and implements two methods, `on_backoff` | |
and `on_giveup`, which log information about the retry attempts and when the retry attempts are | |
given up respectively. | |
The `http_request` function is the primary function of the module, making an HTTP request with the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to package a Lambda function directory | |
# into a deployment zip that can be uploaded to S3 | |
# Usage: | |
# ./package.sh <lambda name/ dir name> | |
if ! command -v pip >/dev/null 2>&1 || ! command -v python3 >/dev/null 2>&1 || ! command -v zip >/dev/null 2>&1; then | |
echo "pip, python3, and/or zip are not installed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
protected_branch='main' | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [[ "$protected_branch" = "$current_branch" ]]; then | |
input='' | |
read -p "You're about to commit to master, is that what you intended? [y|n] " -n 1 -r </dev/tty | |
if [[ "$input" == [yY] || "$input" == [yY][eE][sS] ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl --help | |
Usage: curl [options...] <url> | |
--abstract-unix-socket <path> Connect via abstract Unix domain socket | |
--alt-svc <file name> Enable alt-svc with this cache file | |
--anyauth Pick any authentication method | |
-a, --append Append to target file when uploading | |
--basic Use HTTP Basic Authentication | |
--cacert <file> CA certificate to verify peer against | |
--capath <dir> CA directory to verify peer against | |
-E, --cert <certificate[:password]> Client certificate file and password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
convert webp images to png | |
''' | |
from sys import argv | |
from PIL import Image | |
# requirements: `pip install pillow` | |
# example usage: | |
# python main.py input.webp output.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
redis-viewer = [ | |
ibm_database.team1-redis-us-south-uat.id, | |
ibm_database.team3-redis-uat.id, | |
ibm_database.team1-redis-us-south-prod.id | |
] | |
# Processes out the resource_instance_id | |
redis-viewer-processed = [for infra in local.redis-viewer : element(split(":", infra), 7)] | |
rabbitmq-viewer = [ |
NewerOlder