Skip to content

Instantly share code, notes, and snippets.

View utdrmac's full-sized avatar

Matthew utdrmac

View GitHub Profile
@utdrmac
utdrmac / mysql_queries_prod_consumer.py
Last active September 27, 2023 21:52
Execute queries in parallel on MySQL; Producer-Consumer in Python
import sys
import argparse
import mysql.connector
from queue import Queue
from concurrent.futures import ThreadPoolExecutor
def parseargs():
parser = argparse.ArgumentParser(prog="mysql_queries_prod_consumer.py", add_help=False)
@utdrmac
utdrmac / rds-repl-restart.py
Last active November 23, 2023 02:42
Quick-n-dirty script for watching RDS replication and skipping on specific error codes
import sys
import mysql.connector
from mysql.connector.errors import InterfaceError
from time import sleep
mydb = mysql.connector.connect(host="", user="", password="", database="mysql")
cursor = mydb.cursor(dictionary=True)
while True:
/*
* To compile and install, execute the following commands. This will create a
* build location for MySQL and this plugin.
*
** Get Percona MySQL source code:
* cd ~
* wget https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.32-24/source/tarball/percona-server-8.0.32-24.tar.gz
* tar -xvzf percona-server-8.0.32-24.tar.gz
*
** Create plugin dir, clone C++ ULID library
# -*- coding: utf-8 -*-
# Description: speedtest netdata python.d module
# Author: utdrmac
# SPDX-License-Identifier: GPL-3.0-or-later
# Runs a network speed test using speedtest.net every hour (by default)
# Requires: speedtest-cli
# apk add speedtest-cli
from bases.FrameworkServices.ExecutableService import ExecutableService
@utdrmac
utdrmac / headcheck.py
Created September 29, 2019 15:18
check current block head level from multiple sources
#!/bin/env python36
import requests
import json
from time import sleep
from datetime import timedelta, datetime as dt
from requests.exceptions import Timeout, HTTPError, ConnectionError
from concurrent.futures import TimeoutError, ThreadPoolExecutor
nodes = [
#!/bin/sh
##
## For EdgeRouter Lite
## chmod 755 /etc/cron.weekly/dns-blacklist
##
BLACKLIST_URL=https://raw.githubusercontent.com/oznu/dns-zone-blacklist/master/dnsmasq/dnsmasq-server.blacklist
BLACKLIST_PATH=/etc/dnsmasq.d/blacklist.conf
WHITELIST_PATH=/config/dnsmasq-server.whitelist
@utdrmac
utdrmac / imdb_comments.py
Last active September 27, 2023 21:49
Insert english-like comment strings
#
# pip3 install mysql-connector-python
"""
CREATE TABLE comments (
id int unsigned primary key auto_increment,
user_id int unsigned not null,
comment varchar(200) not null,
type varchar(10) not null,
type_id int unsigned not null);
if sysbench.cmdline.command == nil then
error("Command is required. Supported commands: run")
end
sysbench.cmdline.options = {
point_selects = {"Number of point SELECT queries to run", 5},
skip_trx = {"Do not use BEGIN/COMMIT; Use global auto_commit value", false}
}
local page_types = { "actor", "character", "movie" }
#!/bin/bash
#
# 20210119 - Use the new --endpoint flag
# - Added verbose logging
#
# 20200608 - Updated to TzKt API
#
# 20191029 - Added /v3/network back in.
# Thanks to Baking-Bad and their Mystique API
@utdrmac
utdrmac / mysql_autoinc_checker.go
Created April 12, 2018 23:36
Checks AUTO_INCREMENT fields in MySQL to see if near MAXVALUE
/*
Copyright (c) 2014, Percona LLC and/or its affiliates. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of