Skip to content

Instantly share code, notes, and snippets.

View dword4's full-sized avatar

Drew Hynes dword4

View GitHub Profile
@dword4
dword4 / engine.py
Created October 4, 2022 17:46
very ugly and simplistic way to let people create plugins with only some json
#!/usr/bin/env python3 """ mockup language engine for plugins """
import json
js = '{"name":"command_name", "prompt": [{"question": "where do you want to ping", "var": "dest"},{"question": "ping from", "var": "src"}], "handler": "some_function", "query": "ping $dest from $src"}'
j = json.loads(js)
def some_function(j):
print(f"command: {j['name']}")
answer = {}
for q in j['prompt']:
@dword4
dword4 / code.py
Created August 24, 2022 18:45
decorator problems
#!/usr/bin/env python3
class command(object):
def ratelimit(*args, **kwargs):
limit = args[0]
def ratelimit_wrapper(func):
print(f"rate: {limit}")
print("begin: ratelimit_wrapper")
# some stuff
print("end: ratelimit_wrapper")
class Alpha(Cosmos):
def __init__(self):
self.name = "Alpha.class"
{
"agent": {
"run_as_user": "cwagent"
},
"metrics": {
"metrics_collected": {
"procstat": {
"pattern": "/usr/bin/java -jar report-service.jar",
"measurement": [
"pid_count"
- hosts: all
tasks:
- name: Installing git
become: true
become_user: root
yum:
name: git
state: latest
function JsonSettings()
set expandtab
set shiftwidth=2
set tabstop=2
endfunction
:command Json :call JsonSettings()
@dword4
dword4 / wat.py
Created April 28, 2018 04:00
say wat one more #$&!@ time, I dare you! this prints West African Time every time someone says just the word wat in any channel
__module_name__ = "wat"
__module_version__ = "1.0"
__module_description__ = "say wat!"
import hexchat
import re
from datetime import datetime
from datetime import timedelta
def count_words(somevar):
@dword4
dword4 / gist:7f02b1bd76fe4839f3f367fc945b9eda
Last active March 15, 2018 21:09
LibreNMS adding a device with salt
# adds a device forcefullly in LNMS via the API
lnms_api_add:
cmd.run:
- name: >-
curl -X POST --data-binary '{"hostname":"{{ salt['grains.get']('ip4_interfaces:ens18:0') }}","force_add":"true","port":"161","version":"v2c","community":"public"}' -k -v -H 'X-Auth-Token: SOMEAPITOKEN' 'http://192.168.1.85/api/v0/devices'
@dword4
dword4 / fun.py
Created March 3, 2018 03:31
using up alphabet characters via NATO phonetics
#!/usr/bin/python3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
chars = list(alphabet)
words = ['alpha','bravo','charlie','delta','echo','foxtrot','golf','hotel','india','juliett','kilo','lima','mike','november','oscar','papa','quebec','romeo','sierra','tango','uniform','victor','whiskey','xray','yankee','zulu']
for w in words:
# loop through each word specified
@dword4
dword4 / sadmoney.py
Created January 3, 2018 21:00
quick bit of python to figure out how much has been spent on any given thing
#!/usr/bin/python3
import pandas as pd
import numpy as np
import sys
target = sys.argv[1]
def getTargetTotal(target):
df = pd.read_csv('data.csv', header=None,names=['date','description','ammount','balance'])