Skip to content

Instantly share code, notes, and snippets.

from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype('/Users/jrahm/Library/Fonts/PreCursive-RailsDashed.otf', 120)
text = "I like Dory helping Nemo."
image = Image.new("RGB", (1920, 1080), (255, 255, 255))
draw = ImageDraw.Draw(image)
@jasonrahm
jasonrahm / khoros_forum_body_update.py
Created November 22, 2022 19:34
Khoros API Message Updates Script
'''
This script does a general query using LiQL against Khoros API for "code",
which is not at all case specific and doesn't seem to match "<", which
would have been extremely helpful.
It loops through message offsets 50 at a time, then attempts to update the
editor code from <CODE></CODE> to <li-code lang="tcl"></code> and then
issues a PUT to the /api/2.0/messages/<msg-id> endpoint with a json payload
of {'data': {'type': 'message', 'body': <new_body>}}
@jasonrahm
jasonrahm / bigip_syslog.py
Created October 19, 2022 20:37
updating system syslog parameters on BIG-IP
import sys
from urllib3.exceptions import InsecureRequestWarning
from urllib3 import disable_warnings
disable_warnings(InsecureRequestWarning)
from bigrest.bigip import BIGIP
syslog_include = """
filter f_remote_loghost {
@jasonrahm
jasonrahm / intersect_test.py
Created July 9, 2022 17:51
evaluating intersection approaches
import timeit
from statistics import mean
l1 = [1,2,3,4,5]
l2 = [3,4,5,6,7]
def intersect1(lst1, lst2):
res, lst2_copy = [], lst2[:]
for el in lst1:
@jasonrahm
jasonrahm / asn_info.py
Created June 8, 2022 20:21
BGP ASN Info - credit to showipintbri
import bgpstuff
import argparse
import re
def get_as_name(client, as_number):
client.get_as_name(as_number)
if client.status_code == 200 and client.exists:
print(f"{as_number} = {c.as_name}")
@jasonrahm
jasonrahm / fearless_leader.py
Created February 3, 2022 19:10
Alternative titles for those who can't stand being called "Fearless Leader"
import random
wl_fearless = ['assured', 'aweless', 'bodacious', 'bold', 'cheeky', 'cocky', 'confident', 'cool hand', 'courageous',
'daring', 'dashing', 'dauntless', 'doughty', 'gallant', 'game', 'gritty', 'gutsy', 'heroic', 'intrepid',
'icy', 'indomitable', 'lionhearted', 'nervy', 'plucky', 'salty', 'sanguine', 'sassy', 'smart', 'spunky',
'sure', 'temerarious', 'unabashed', 'undaunted', 'unflinching', 'valiant', 'valorous']
wl_leader = ['chief', 'commander', 'director', 'head', 'manager', 'officer', 'ruler', 'President', 'boss', 'captain',
'chieftain', 'conductor', 'controller', 'counsellor', 'dean', 'dignitary', 'doyen', 'eminence', 'exec',
'forerunner', 'general', 'governor', 'guide', 'harbinger', 'herald', 'lead', 'lion', 'luminary',
'notable', 'pacesetter', 'pilot', 'pioneer', 'precursor', 'principal', 'rector', 'ringleader', 'shepard',
import os
import smtplib
import ssl
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@jasonrahm
jasonrahm / temps.py
Created September 15, 2021 19:45
converting celsius, fahrenheit, and kelvin
import argparse
def c2f(val: float) -> float:
return val * 1.8 + 32
def f2c(val: float) -> float:
return (val - 32) / 1.8
@jasonrahm
jasonrahm / dgmgmt_update.py
Created January 13, 2021 00:28
This update removes the need for the tmsh script on BIG-IP by using the options query parameter to pass the record data directly to the tmsh command. This removes complexity and should be preferred over the previous solution.
###################################################################################
# dgmgmt.py
#
# author: jason rahm
#
# usage: dgmgmt.py [-h] host user {add,modify,delete} datagroup dgvalues
#
# positional arguments:
# host BIG-IP IP/FQDN
# user BIG-IP Username
@jasonrahm
jasonrahm / resolver_demo.tcl
Created November 18, 2020 05:08
Example to do reverse lookups on IP addresses using the RESOLVER::name_lookup command, which replaces the deprecated RESOLV::lookup.
#####################################################
### Required net resolver - example configuration ###
#####################################################
#net dns-resolver r1 {
# forward-zones {
# . {
# nameservers {
# 8.8.8.8:domain { }
# 9.9.9.9:domain { }