Skip to content

Instantly share code, notes, and snippets.

@jasonrahm
jasonrahm / dgmgmt.py
Last active February 8, 2021 16:03
Manage Data-Group records individually through REST.This is accomplished not through the data-group endpoint, but through the cli/script endpoint, where data is passed to a tmsh script.
###################################################################################
# dgmgmt.py
#
# author: jason rahm
# tmsh script author: john alam
#
# usage: dgmgmt.py [-h] host user {add,modify,delete} datagroup dgvalues
#
# positional arguments:
# host BIG-IP IP/FQDN
@jasonrahm
jasonrahm / covidstats_refactor.py
Created June 23, 2020 17:50
Covid Stats analysis
import csv
from datetime import datetime
from datetime import timedelta
__author__ = 'Jason Rahm'
# Assumes this script is in a <scripts> folder inside a cloned version of https://github.com/CSSEGISandData/COVID-19
# Total Kansas City Metro Area Stats
# Population: 2646933
@jasonrahm
jasonrahm / sy.js
Last active January 31, 2021 18:11
Streamyard Keyboard Shortcuts
// ==UserScript==
// @name Streamyard_Hotkeys
// @version 0.13
// @description Enable hotkeys for keyboard shortcuts
// @author Jason Rahm
// @match https://streamyard.com/*
// @grant none
// ==/UserScript==
(async function() {
@jasonrahm
jasonrahm / pyGithub-interactive.txt
Created January 21, 2020 21:07
Python/PyGithub caching?
# Get the repo
>>> repo = gh.get_repo('f5devcentral/f5go')
# Get the repo commits
>>> commits = repo.get_commits()
# Print the last commit, but this fails as out of range
>>> print(commits[-1].committer.last_modified, commits[-1].committer.name)
Traceback (most recent call last):
File "<input>", line 1, in <module>
when HTTP_REQUEST {
if { [catch \[HTTP2::version\] result] == 1 } {
if { $result contains "Operation not supported" } {
log local0. "HTTP version is: [HTTP::version]"
} else {
log local0. "HTTP version is 2"
}
}
}
@jasonrahm
jasonrahm / runtime_calc_v2.py
Created September 10, 2019 15:23
This script will generate an Excel spreadsheet on iRule performance timing data
# coding=utf-8
#
# Copyright 2015-2019 F5 Networks Inc.
#
# 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
#
@jasonrahm
jasonrahm / runtime_calc.py
Created September 7, 2019 13:33
This script will grab an iRule and its stats from a BIG-IP and auto-generate the iRuleRuntimeCalculator spreadsheet
# coding=utf-8
#
# Copyright 2015-2019 F5 Networks Inc.
#
# 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
#
@jasonrahm
jasonrahm / sqlalchemy_conversion
Created December 30, 2016 14:00
working sql query, how to make this with sqlalchemy?
sql_text = '''SELECT *
FROM
CompetitionTeams ct
INNER JOIN
Teams t ON ct.teams = t.id
WHERE
ct.competitions = {}'''.format(comp)
result = db.engine.execute(sql_text)
@jasonrahm
jasonrahm / get-token.ps1
Created July 20, 2016 16:34
Get F5 auth token in powershell
#----------------------------------------------------------------------------
# The contents of this file are subject to the "END USER LICENSE AGREEMENT
# FOR F5 Software Development Kit for iControl"; you may not use this file
# except in compliance with the License. The License is included in the
# iControl Software Development Kit.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
@jasonrahm
jasonrahm / cert_install.py
Created November 16, 2015 23:37
Install certificate and key on BIG-IP, create the file objects, create an SSL profile
def _upload(host, creds, fp):
chunk_size = 512 * 1024
headers = {
'Content-Type': 'application/octet-stream'
}
fileobj = open(fp, 'rb')
filename = os.path.basename(fp)
uri = 'https://%s/mgmt/shared/file-transfer/uploads/%s' % (host, filename)