Skip to content

Instantly share code, notes, and snippets.

View davemcphee's full-sized avatar
💭
crying shamelessly

Alex Schmitz davemcphee

💭
crying shamelessly
  • Austin, Texas
View GitHub Profile
@davemcphee
davemcphee / prom_to_OpenTSDB.sh
Last active August 25, 2022 13:55
prometheus to OpenTSDB metrics formetter
#!/bin/sh
# curls a prometheus metrics endpoint, and awk's it into OpenTSDB format
JMX_URL="http://localhost:7070"
curl -s $JMX_URL | awk '
BEGIN { ts=systime() }
match($0, /{(.*)}/, a) {
@davemcphee
davemcphee / ble.py
Last active August 10, 2021 18:55
OW BLE handshake
# attach a callback to notify on SERIAL_READ_UUID reads
client.start_notify(SERIAL_READ_UUID, callback_handler)
# read the firmware value
fw_rev = await client.read_gatt_char(FW_REV_UUID)
# write the firmware value back
client.write_gatt_char(FW_REV_UUID, fw_rev)
# at this point, our callback receives a bytearray[20] in reply
# low level webdriver functions
import os
import time
from selenium import webdriver
from selenium.common.exceptions import StaleElementReferenceException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait

Keybase proof

I hereby claim:

  • I am davemcphee on github.
  • I am alexschmitz (https://keybase.io/alexschmitz) on keybase.
  • I have a public key ASCFSy_FK0Vakc_q0ebJINUPXL0y7w9A0oKlZy8F6iuVpAo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am davemcphee on github.
* I am alexschmitz (https://keybase.io/alexschmitz) on keybase.
* I have a public key ASCFSy_FK0Vakc_q0ebJINUPXL0y7w9A0oKlZy8F6iuVpAo
To claim this, I am signing this object:
@davemcphee
davemcphee / blah.py
Last active October 11, 2018 05:17
markov thing
#!/usr/bin/env python
from __future__ import division
from itertools import compress, starmap
from operator import mul
M = [[0, 2, 1, 0, 0], [0, 0, 0, 3, 4], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
class Fraction:
@davemcphee
davemcphee / ansible_cheats.yml
Last active August 1, 2018 19:46
ansible cheat sheet
# check if a string contains any substrings from a list
our_string: 'alexander graham cracker'
our_list: ['alex', 'barry', 'chris']
check_result_bool: '{{ our_list | select("in", our_string) | list | count > 0 }}'
# using a dictionary with version keys and selecting the highest appropriate key / options
our_version = '6.2.5'
version_options_dict:
'6.5': [ 'an option for 6.5', 'something else' ]