Skip to content

Instantly share code, notes, and snippets.

View philipsd6's full-sized avatar

Philip Douglass philipsd6

View GitHub Profile
@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
@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 / 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
gitlab-dirs:
file.directory:
- names:
- gitlab-satellites
- gitlab/tmp/pids
- gitlab/tmp/sockets
- gitlab/public/uploads
- user: git
- group: git
- mode: 755
@philipsd6
philipsd6 / sync pythonista scripts.py
Last active August 29, 2015 14:16
This will synchronize my pythonista scripts with Dropbox
# https://gist.github.com/philipsd6/3646b2856d2d6aaa2826
import dropboxlogin
@philipsd6
philipsd6 / keybase.md
Last active August 17, 2018 19:30
Proving my GitHub identity on Keybase.io

Keybase proof

I hereby claim:

  • I am philipsd6 on github.
  • I am philipsd6 (https://keybase.io/philipsd6) on keybase.
  • I have a public key whose fingerprint is 0CE0 D71F 0491 3A03 AF2A D02E E66F DBF7 D927 3C2C

To claim this, I am signing this object:

@philipsd6
philipsd6 / _tmux_pane_words.zsh
Last active January 17, 2016 02:25 — forked from blueyed/_tmux_pane_words.zsh
ZSH configuration to complete words from tmux pane(s) Based on http://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html
# complete words from tmux pane(s) {{{1
# Source: http://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html
_tmux_pane_words() {
local expl
local -a w
if [[ -z "$TMUX_PANE" ]]; then
_message "not running inside tmux!"
return 1
fi
# capture current pane first
# http://nparikh.org/notes/zshrc.txt
# Usage: smartextract <file>
# Description: extracts archived files / mounts disk images
# Note: .dmg/hdiutil is Mac OS X-specific.
smartextract () {
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar -jxvf $1 ;;
*.tar.gz) tar -zxvf $1 ;;
*.bz2) bunzip2 $1 ;;
# [Previewing Markdown Files from the Terminal][1]
# [1]: http://blog.metamatt.com/blog/2013/01/09/previewing-markdown-files-from-the-terminal/
mdless () {
pandoc -s -f markdown -t man $1 | groff -T utf8 -man| grep -v '()$' | less
}
@philipsd6
philipsd6 / install-tmux
Last active February 22, 2021 14:41 — forked from rothgar/install-tmux
Install tmux 2.3 on rhel/centos 7
# Install tmux on rhel/centos 7
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
tar -xvzf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local