Skip to content

Instantly share code, notes, and snippets.

@pjaudiomv
pjaudiomv / suffolk
Created April 11, 2023 19:36
suffolk
Suffolk Area has [group_count service_body="1001" root_server="https://bmlt.newyorkna.org/main_server"] groups with [meeting_count] meetings in [list_locations root_server="https://bmlt.newyorkna.org/main_server" services="1001" state="0"]
[bmlt_tabs service_body="1001" root_server="https://bmlt.newyorkna.org/main_server"]
@pjaudiomv
pjaudiomv / zshrctf.sh
Last active May 19, 2023 19:21
zshrc tf info
# terraform info
local tf_info='$(tf_workspace)'
function tf_workspace {
if [ -f ".terraform/environment" ]; then
local workspace=$(cat .terraform/environment);
echo -n "%{$fg_bold[green]%}tf:%{$fg[cyan]%}${workspace}%{$fg_bold[green]%}%{$reset_color%}"
else
echo -n ""
fi
}
@pjaudiomv
pjaudiomv / zshrc
Last active May 19, 2023 19:51
zshrc
export GPG_TTY=$(tty)
alias ll='ls -al'
alias h='history'
alias hg='history | grep $1'
alias c='clear'
alias ns='arp -a | grep :'
alias gs='git status'
alias tf='terraform fmt -recursive'
alias account='{ aws sts get-caller-identity & aws iam list-account-aliases; } | jq -s ".|add"'
@pjaudiomv
pjaudiomv / gt_1_tz_countries.json
Created May 31, 2023 15:52
gt_1_tz_countries.json
{
"Antarctica": {
"long_name": "Antarctica",
"short_name": "Antarctica"
},
"AU": {
"long_name": "Australia",
"short_name": "AU"
},
"BR": {
@pjaudiomv
pjaudiomv / kx.sh
Created September 21, 2023 17:51
Kubeconfig Context Switcher
#!/usr/bin/env bash
usage () {
echo "Usage: kx [OPERATION]"
echo " -h Help. Displays this message."
echo " -l list contexts"
echo " -c get current context"
echo " -s set context"
echo " -d delete context"
}
@pjaudiomv
pjaudiomv / langDays.php
Last active October 18, 2023 01:27
Language Names with Days of Week
<?php
function getLangInfo()
{
$langs = ['da', 'de', 'en', 'es', 'fa', 'fr', 'it', 'pl', 'pt', 'ru', 'sv'];
$ret = [];
foreach ($langs as $lang) {
$daysOfWeek = [];
$lang_name = \Locale::getDisplayLanguage($lang, $lang);
@pjaudiomv
pjaudiomv / http.php
Created October 27, 2023 01:54
http
<?php
private function httpGet(string $url): string
{
if (defined('WP_CONTENT_DIR')) {
return $this->wordpressGet($url);
} else {
return $this->guzzleGet($url);
}
}
@pjaudiomv
pjaudiomv / get_all_images.py
Created November 3, 2023 17:28
Get All Images in a Cluster
import yaml
import re
from kubernetes import client, config
def parse_name(name):
if len(name.split("/")) > 1:
registry = name.split("/")[0]
if not (
re.search("\.", registry) or re.search("localhost:[0-9]+", registry)
@pjaudiomv
pjaudiomv / get-all-images.sh
Last active April 9, 2024 16:14
Get All Images in a Cluster
#!/usr/bin/env bash
normalize_image_name() {
local name="$1"
local registry
if [[ "$name" == *\/* ]]; then
registry=${name%%/*}
if ! [[ "$registry" == *.* || "$registry" == localhost:[0-9]* ]]; then
name="docker.io/${name}"
fi
@pjaudiomv
pjaudiomv / aws-assumerole.sh
Last active December 4, 2024 15:07
Get EC2 Assume Role STS Creds and set them locally - useful for testing ec2 role or when you have ssh access to an ec2 but no aws credential accesss
#!/usr/bin/env bash
# Fetches AWS credentials from a EC2 IAM role and configures them locally for multiple profiles.
# Script expects input parameter to be a named Host in your SSH config, then sets AWS creds name using that Host name.
#
# Configuration
# Check for SSH_CONFIG_FILE env var then default to users home dir
SSH_CONFIG_FILE="${SSH_CONFIG_FILE:-$HOME/.ssh/config}"
readarray -t ssh_hosts < <(grep 'Host ' "$SSH_CONFIG_FILE" | awk '{print $2}' | sort -u)
# ANSI color codes for pretty output