Skip to content

Instantly share code, notes, and snippets.

@mrabbitt
mrabbitt / get_keychain_pass.py
Last active July 26, 2024 18:17
Command line access to the Mac OS X Keychain (based on post: http://blog.macromates.com/2006/keychain-access-from-shell/#comment-979)
#!/usr/bin/env python3
import sys
import subprocess
import re
import logging
import argparse
# https://github.com/wooster/biplist (pip install biplist)
# FIXME Replace biplist with standard library `plistlib` which supports binary format in 3.4+
import biplist
@acdha
acdha / osx-keychain-via-security.py
Created February 9, 2012 20:50
Simple Python function for storing passwords in the Keychain portably
from subprocess import call, Popen, PIPE
from getpass import getpass
import sys
def keychain_wrapper(func):
@wraps(func)
def wrapper(service_name, username):
p = Popen(['security', 'find-internet-password', '-g', '-s', service_name, '-a', username],
shell=False, stdout=PIPE, stderr=PIPE)
rc = p.wait()
@brianhsu
brianhsu / gist.py
Created November 30, 2011 02:49
[Python] reStructuredText GitHub Gist directive.
class GitHubGist(Directive):
""" Embed GitHub Gist.
Usage:
.. gist:: GIST_ID
"""
required_arguments = 1
optional_arguments = 1
@fabiant7t
fabiant7t / s3_multipart_upload.py
Created April 17, 2011 14:54
Parallel S3 multipart upload with retries
import logging
import math
import mimetypes
from multiprocessing import Pool
import os
from boto.s3.connection import S3Connection
from filechunkio import FileChunkIO
apply plugin: 'groovy'
sourceCompatibility = 1.5
version = '0.1-SNAPSHOT'
repositories {
mavenRepo(urls: 'http://repository.codehaus.org/')
mavenCentral()
}