Skip to content

Instantly share code, notes, and snippets.

View greyhoundforty's full-sized avatar
🏠
Working from home

Ryan Tiffany greyhoundforty

🏠
Working from home
View GitHub Profile
@greyhoundforty
greyhoundforty / Taskfile.yml
Last active June 10, 2024 17:02
Python Taskfile
# https://taskfile.dev/
version: "3"
vars:
TERM: screen-256color
MAIN_PYTHON: python3
LOCAL_PATH:
sh: 'echo "$(cd "$( dirname -- "$0" )" && pwd)"'
venv_path: "{{.LOCAL_PATH}}/.venv"
venv_bin_path: "{{.LOCAL_PATH}}/.venv/bin"
@greyhoundforty
greyhoundforty / ce-icr-oc-mirror.md
Created June 6, 2024 17:28
Run oc adm registry mirror via Code Engine

Dockerfile

FROM ubuntu:22.04

WORKDIR /app

RUN apt-get update && \
    apt-get install -y -q --allow-unauthenticated \
 build-essential \
@greyhoundforty
greyhoundforty / functions.zsh
Created June 5, 2024 15:56
zsh-functions for remote load with zinit
function get_ubuntu_images() {
ibmcloud login -r "$@" -q >/dev/null 2>&1
vpc_region=$(ibmcloud target --output json | jq -r '.region.name')
printf "%b" "\e[1;34mGetting Ubuntu images in ${vpc_region}:.\e[0m"
printf '\n'
ibmcloud is images --visibility public --output json | jq -r '.[] | select(.status=="available") | select(.operating_system.architecture=="amd64") | select(.name | startswith("ibm-ubuntu")) | .name,.id'
}
function get_windows_images() {
ibmcloud login -r "$@" -q >/dev/null 2>&1
@greyhoundforty
greyhoundforty / Makefile
Created June 2, 2024 09:18
Python Makefile example
SHELL:=/bin/zsh
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
PY_VERSION = 3.11.0
VENV = .venv
PY = $$(if [ -f $(VENV)/bin/python ]; then echo $(VENV)/bin/python; else echo python; fi)
PIP = $(PY) -m pip
PWD = $(shell pwd)
@greyhoundforty
greyhoundforty / code-engine.md
Last active May 28, 2024 17:08
Code Engine and Github CLI

Overview

Terminal commands for setting up a Code Engine webhook and example application repository

Overview of workflow

Pre-reqs:

@greyhoundforty
greyhoundforty / main.py
Created May 9, 2024 20:36
IBM Cloud Code Engine python webhook function
import hmac
import os
import json
import hashlib
import httpx
def main(params):
"""Main parameter for function."""
ibmcloud_api_key = os.environ.get('IBMCLOUD_API_KEY')
@greyhoundforty
greyhoundforty / scan_ibmcloud.py
Last active May 2, 2024 16:10
Python based port scanner for IBM Cloud Account
#!/usr/bin/env python3
# Author: Ryan Tiffany
# Copyright (c) 2024
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@greyhoundforty
greyhoundforty / functions.zsh
Created April 19, 2024 14:39
Random-functions
# usage: get_ubuntu_images VPC_REGION
function get_ubuntu_images() {
ibmcloud login -r "$@" -q >/dev/null 2>&1
vpc_region=$(ibmcloud target --output json | jq -r '.region.name')
printf "%b" "\e[1;34mGetting Ubuntu images in ${vpc_region}:.\e[0m"
printf '\n'
ibmcloud is images --visibility public --output json | jq -r '.[] | select(.status=="available") | select(.operating_system.architecture=="amd64") | select(.name | startswith("ibm-ubuntu")) | .name,.id'
}
# usage: get_windows_images VPC_REGION
@greyhoundforty
greyhoundforty / list-classic-vsis.py
Created January 30, 2024 19:34
List Classic Virtual Guests with option datacenter filter
import SoftLayer
from prettytable import PrettyTable
import click
from datetime import datetime
from rich.console import Console
from rich.table import Column, Table
class VSIExample():
def __init__(self):
client = SoftLayer.Client()
@greyhoundforty
greyhoundforty / classicLBs.py
Last active January 30, 2024 20:37
List Classic Load Balancers with Python
import SoftLayer
from prettytable import PrettyTable
import click
class LBaasExample():
def __init__(self):
client = SoftLayer.Client()
self.lbaas_service = client['Network_LBaaS_LoadBalancer']
def get_list(self, dc=None):