Skip to content

Instantly share code, notes, and snippets.

View dankrause's full-sized avatar

Dan Krause dankrause

View GitHub Profile
@dankrause
dankrause / ssdp.py
Last active April 25, 2024 13:14
Tiny python SSDP discovery library with no external dependencies
# Copyright 2014 Dan Krause
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@dankrause
dankrause / custom-tinycore.sh
Last active April 13, 2024 10:50
Create a custom tinycore linux iso. Adjust the config at the beginning of the script, or supply a conf as the first arg. Requires xorriso.
#!/bin/bash
set -e
function cleanup() {
# clean up our temp folder
rm -rf "${TMPDIR}"
}
trap cleanup EXIT
@dankrause
dankrause / _hover_example.py
Last active March 8, 2024 18:31
Example code to use the (unofficial, unsupported, undocumented) hover.com DNS API.
import requests
class HoverException(Exception):
pass
class HoverAPI(object):
def __init__(self, username, password):
params = {"username": username, "password": password}
r = requests.post("https://www.hover.com/api/login", params=params)
@dankrause
dankrause / postgresql_recursive.sql
Last active February 26, 2024 16:03
An example of creating a recursive postgresql query to generate data about parent-child relationships within a single table.
CREATE TABLE test
(
id INTEGER,
parent INTEGER
);
INSERT INTO test (id, parent) VALUES
(1, NULL),
(2, 1),
@dankrause
dankrause / ipc.py
Last active February 16, 2024 16:23
Simple socket IPC in python
# Copyright 2017 Dan Krause
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@dankrause
dankrause / pagerduty.py
Last active May 30, 2023 00:43
Simple python client for the Pagerduty integration API
#!/usr/bin/env python
"""pagerduty.py
Usage:
pagerduty.py trigger [options] <description> [<incident_key>]
pagerduty.py acknowledge [options] <description> <incident_key>
pagerduty.py resolve [options] <description> <incident_key>
Options:
-c --conf=FILE A path to a config file
class _ExceptionHandlerBase:
def __init__(self, handler_map):
self._handler_map = handler_map
def __call__(self, func):
def wrapper(*args, **kwargs):
with self:
func(*args, **kwargs)
return wrapper
import builtins
import collections
import contextlib
import copy
import dis
import json
import socket
import struct
import types
@dankrause
dankrause / pngmeta.py
Created December 21, 2012 18:34
A command-line tool that manipulates png meta-data in a very Unix-like way. Requires the Python Imaging Library (PIL).
#!/usr/bin/env python
import json, optparse, sys
try:
import PIL.Image, PIL.PngImagePlugin
except:
print >> sys.stderr, "Unable to import Python Imaging Library. Please ensure that it is installed."
sys.exit(1)
### Keybase proof
I hereby claim:
* I am dankrause on github.
* I am dankrause (https://keybase.io/dankrause) on keybase.
* I have a public key ASBmYrX3pc6j-rDw3Yfm1F_mBjHX0SLjDc1izIvsgICs7wo
To claim this, I am signing this object: