Skip to content

Instantly share code, notes, and snippets.

@raymondbutcher
raymondbutcher / ssm-sshuttle.md
Last active Jun 7, 2021
How to use sshuttle with AWS SSM session agent
View AmazonEC2RoleforSSM.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DescribeAssociation",
"ssm:GetDeployablePatchSnapshotForInstance",
"ssm:GetDocument",
"ssm:GetManifest",
View keybase.md

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:

@raymondbutcher
raymondbutcher / waitfor
Last active Aug 29, 2015
A shell script that waits until a command returns successfully.
View waitfor
#!/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.
#
@raymondbutcher
raymondbutcher / sluggish_cache.py
Last active Dec 15, 2015
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.
View sluggish_cache.py
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 / time_elapsed.py
Last active Dec 14, 2015
A Python context which can be used to easily time blocks of code.
View time_elapsed.py
import sys
import time
from contextlib import contextmanager
@contextmanager
def time_elapsed(name=''):
"""
A context manager for timing blocks of code.
@raymondbutcher
raymondbutcher / get_method_info.py
Created Mar 12, 2012
Gets method information from the docstring
View get_method_info.py
"""
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 / ITunes.py
Created Aug 21, 2011
iTunes plugin for Server Density
View ITunes.py
from ScriptingBridge import SBApplication
class ITunes(object):
"""
Display the total duration (in hours) of your music libraries in iTunes.
This is admittedly pretty dumb.
"""