Skip to content

Instantly share code, notes, and snippets.

View rickardp's full-sized avatar

Rickard rickardp

  • Gothenburg, Sweden
View GitHub Profile
@rickardp
rickardp / tfstate.py
Last active September 13, 2022 20:48
when your tf state is f*cked
import sys
import re
s=sys.stdin.read()
m = re.compile(r"Error: A resource with the ID \"([^\"]+)\"")
n = re.compile(r" with (.+)$")
x = False
val = None
for l in s.split("\n"):
f = m.match(l)
if f:
@rickardp
rickardp / cardinality.py
Created December 4, 2019 15:33
Cardinality from imfluxdb
import requests
import base64
import json
import sys
from urllib.parse import urlencode
def influx_query(q):
PASS='xxxx'
@rickardp
rickardp / smsnotify
Created December 5, 2015 11:42
Trivial command line interface to 46elks for SMS notification sending
#!/bin/sh
#
# How to use:
# * Sign up for account at 46elks.com. Note down API user/password (not same as account credentials)
# * Install this script and chmod 755 it
# * Put the credentials in the file /etc/sms.conf OR ~/.smsconf
#
# Now you can run the script e.g. echo "My message" | smsnotify [-f from_name] to_number1 to_number2...
@rickardp
rickardp / devicecopy.py
Created December 13, 2014 17:03
Busybox file copy tool
#!/usr/bin/python
#
# Tool to copy files/directory trees to/from devices where the only opening
# is a telnet/serial shell and there is nothing other than a basic busybox on the device.
#
import sys, socket, tempfile, shutil, re, time
import telnetlib as T
@rickardp
rickardp / qt_connection.py
Created May 15, 2014 21:34
pika QtConnection -- async RabbitMQ/Pika with QT run loop
"""Use pika with the QT socket notifier
To use:
import qt_connection
instead of e.g. pika.SelectConnection(...)
use qt_connection.QtConnection(appObject, ...)
"""
import logging
import time