Skip to content

Instantly share code, notes, and snippets.

View philipsd6's full-sized avatar

Philip Douglass philipsd6

View GitHub Profile
@philipsd6
philipsd6 / twemproxy-build.sls
Last active January 2, 2016 22:59
The first Salt state will download twemproxy and build it in /tmp and then install it. But it's not advisable to build software from source and just install it. A better solution is to use your distributions package manager tools to create a package which you then make accessible via a package repository. After that, you can use the much simpler…
twemproxy-source:
archive:
- extracted
- name: /tmp/
- source: https://twemproxy.googlecode.com/files/nutcracker-0.3.0.tar.gz
- source_hash: sha1=b17f973ff2de9bd5e21417786a1449bea1557fba
- archive_format: tar
- tar_options: z
- if_missing: /tmp/nutcracker-0.3.0
@philipsd6
philipsd6 / key_value_list_to_dict.py
Created December 18, 2013 22:59
Convert a flat list of key values into a dictionary
data = dict(line.split(None, 1) for line in '''
key1 value
key2 value
key3 another value
key4 yet another value
'''.strip().splitlines())
@philipsd6
philipsd6 / contrib.files.exists.py
Created February 17, 2012 21:11
Rewrite of Fabric contrib.files.exists to allow sudo'ing as specific user, not just root.
def exists(path, as_user=None, use_sudo=False, verbose=False):
"""
Return True if given path exists on the current remote host.
If ``as_user`` is set, will use `sudo` as that user instead of `run`. If
''as_user'' or ''use_sudo'' is True, will use 'sudo' as root.
`exists` will, by default, hide all output (including the run line, stdout,
stderr and any warning resulting from the file not existing) in order to
avoid cluttering output. You may specify ``verbose=True`` to change this