Skip to content

Instantly share code, notes, and snippets.

@raymondbutcher
raymondbutcher / ITunes.py
Created August 21, 2011 12:27
iTunes plugin for Server Density
from ScriptingBridge import SBApplication
class ITunes(object):
"""
Display the total duration (in hours) of your music libraries in iTunes.
This is admittedly pretty dumb.
"""
@raymondbutcher
raymondbutcher / get_method_info.py
Created March 12, 2012 17:25
Gets method information from the docstring
"""
Returns this:
{
'help_text': 'Returns a list of sites for which the given user has access.',
'returns': {'type': 'array', 'desc': 'list of blog dicts'},
'args': {
'username': {'type': 'string', 'desc': 'your username'},
'password': {'type': 'string', 'desc': 'plain text password'}
}
@raymondbutcher
raymondbutcher / time_elapsed.py
Last active December 14, 2015 23:49
A Python context which can be used to easily time blocks of code.
import sys
import time
from contextlib import contextmanager
@contextmanager
def time_elapsed(name=''):
"""
A context manager for timing blocks of code.
@raymondbutcher
raymondbutcher / sluggish_cache.py
Last active December 15, 2015 12:48
A partial wrapper for a Django cache object. It will remember cache values in local memory for the specified delay time (in seconds) to avoid accessing the cache backend. This might be useful for a small number of keys which get accessed very frequently.
import time
class SluggishCache(object):
"""
A partial wrapper for a Django cache API object. It will remember cache
values in local memory for the specified delay time (in seconds) to
avoid accessing the cache backend. This might be useful for a small
number of keys which get accessed very frequently.
@raymondbutcher
raymondbutcher / waitfor
Last active August 29, 2015 14:02
A shell script that waits until a command returns successfully.
#!/usr/bin/env bash
#
# Usage: waitfor <command>
# Example: waitfor sudo service httpd status
#
# Waits until a command returns true (exit code: 0)
#
# Save or link this file as "waitwhile" to reverse the check,
# and wait while the command returns true.
#

Keybase proof

I hereby claim:

  • I am raymondbutcher on github.
  • I am rbutcher (https://keybase.io/rbutcher) on keybase.
  • I have a public key whose fingerprint is CBE2 0B2D DA8D E1F5 1AD0 C4E3 E38B D102 BABD EE8E

To claim this, I am signing this object:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DescribeAssociation",
"ssm:GetDeployablePatchSnapshotForInstance",
"ssm:GetDocument",
"ssm:GetManifest",
@raymondbutcher
raymondbutcher / ssm-sshuttle.md
Last active March 17, 2024 20:33
How to use sshuttle with AWS SSM session agent