Skip to content

Instantly share code, notes, and snippets.

View wrigby's full-sized avatar

Will Rigby wrigby

View GitHub Profile
@wrigby
wrigby / honeycomb_example.php
Last active May 13, 2020 23:23
Submitting data to Honeycomb from PHP 5
<?php
// Send some data to Honeycomb, where $data is just an associative array
// that can be JSON encoded. Wire this up in a callback with
// `register_shutdown_function` to ship data off after your request is finished.
function send_data($dataset, $data) {
$url = 'https://api.honeycomb.io/1/events/'.$dataset;
$team_id = 'secret';
$timestamp = microtime(True);
$options = array(
@wrigby
wrigby / 24bitwav.py
Created December 22, 2016 06:11
Reading a 24-bit wave file in Python
def sign_extend(bits, value):
""" Sign-extend from http://stackoverflow.com/questions/32030412/twos-complement-sign-extension-python """
sign_bit = 1 << (bits - 1)
return (value & (sign_bit - 1)) - (value & sign_bit)
def get_samples(w):
w.rewind()
num_samples = w.getnframes()
sample_depth = w.getsampwidth()

Keybase proof

I hereby claim:

  • I am wrigby on github.
  • I am wrigby (https://keybase.io/wrigby) on keybase.
  • I have a public key whose fingerprint is 47E0 AE95 3A5A E818 4805 9A03 A5AB 9C37 F71B 6BCE

To claim this, I am signing this object:

@wrigby
wrigby / recolor_background.css
Last active January 25, 2016 22:02
Applying CSS filters to background images
/* Some elements may need this to make sure they are the
* position parent of the child pseudo-element we'll create
* below
*/
your_element {
position: relative;
}
/* This pseudo-element copies the background from its parent,
* allowing you to apply CSS filters just to the background image.
@wrigby
wrigby / Axis Session Plugin.md
Last active July 18, 2016 14:55
Python suds plugin for Apache Axis sessions

Why?

  • Because the MultiRef support in Suds doesn't handle references in the header of the reply, but it does remove all the multirefs from the body, so it eats the session ID before you can do anything about it.
  • Because with this plugin, you don't even have to think about handling sessions
  • Because I was trying to figure out how to use Diamond IP's IPControl SOAP API, and had to write this to make it work

How to use it?

session_plugin = AxisSessionPlugin()
c = Client(..., plugins=[session_plugin])