Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am sduff on github.
  • I am sduff (https://keybase.io/sduff) on keybase.
  • I have a public key whose fingerprint is AF46 80FD 273B CEE0 FDEE 56B9 D2A5 9C26 9D71 78FB

To claim this, I am signing this object:

@sduff
sduff / splunk_modify_saved_search.py
Created September 5, 2017 07:16
Modify a Splunk Saved Search via Python, using Requests
import time # need for sleep
from xml.dom import minidom
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
base_url = 'https://localhost:8089'
username = 'admin'
password = 'changeme'
@sduff
sduff / .js
Last active October 3, 2017 04:09
Splunk Custom Visualisation code to convert data.fields and data.rows into a hash map
data.rows.map(function (row) {
var _row = {};
for (var f=0; f<data.fields.length; f++) {
fn = data.fields[f].name;
_row[fn] = row[f];
}
return(_row);
});
@sduff
sduff / elements.txt
Created July 28, 2020 01:48
List of all elements
Hydrogen
Helium
Lithium
Beryllium
Boron
Carbon
Nitrogen
Oxygen
Fluorine
Neon
@sduff
sduff / surname.txt
Created July 28, 2020 01:51
List of 20 most common Australian surnames
mith
jones
williams
brown
wilson
taylor
johnson
white
martin
anderson
@sduff
sduff / gist:f93e42795362552390482414b44dbb5e
Last active March 24, 2021 08:39
ANSI SQL Table joins and set operators - practice at https://livesql.oracle.com/
DROP table a;
DROP table b;
create table a (
aid NUMBER(10),
adiz VARCHAR2(10)
);
create table b (
bid NUMBER(10),
@sduff
sduff / ccloud-resource-identifiers-after-terraform.txt
Created October 6, 2021 06:29
Accessing Confluent Cloud resource identifiers after running the terraform provider
# Use jq to read the terraform state file
# all id's
jq '.resources[].instances[].attributes.id?' terraform.tfstate
# all display names
jq '.resources[].instances[].attributes.display_name?' terraform.tfstate
# all environment id's
jq '.resources[].instances[].attributes.environment[]?.id'
@sduff
sduff / rules.py
Last active March 30, 2022 23:24
Simple rules engine in python using eval and exec
#!/usr/local/bin/python3
rules = [
[
# A required field and default value
'not "replication_factor" in configuration',
'configuration["replication_factor"] = 1'
],
[
# production environments require at least 6 partitions
@sduff
sduff / splunk_search.py
Created September 5, 2017 06:04
Splunk search via Python, using Requests
import time # need for sleep
from xml.dom import minidom
import json, pprint
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
@sduff
sduff / rma.py
Created May 17, 2023 09:12
Rolling Moving Average
def r(new_value, old_values):
if len(old_values) > 10:
old_values.pop(0)
old_values.append(new_value)
average = sum(old_values) / len(old_values)
return average, old_values
history = []
for i in range(100):