This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -i | |
/opt/aws/opsworks/current/bin/chef-zero & | |
cd /var/chef/runs/*/ | |
opsworks-agent-cli get_json > attributes.json | |
/opt/aws/opsworks/current/bin/chef-shell -c client.rb -j attributes.json -z -S http://localhost:8889 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker stats $(docker ps|grep -v "NAMES"|awk '{ print $NF }'|tr "\n" " ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import argparse | |
API_ENDPOINT = "https://api.github.com/repos/adsabs/{repo}/branches/master" | |
DOCKERHUB = "https://registry.hub.docker.com/v1/repositories/adsabs/{repo}/tags" | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
"--repos", | |
nargs='*', | |
dest='repos', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChangeDir: | |
"""Context manager for changing the current working directory""" | |
def __init__(self, newPath): | |
self.newPath = os.path.expanduser(newPath) | |
def __enter__(self): | |
self.savedPath = os.getcwd() | |
os.chdir(self.newPath) | |
def __exit__(self, etype, value, traceback): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar_fileobj = io.BytesIO() | |
with tarfile.open(fileobj=tar_fileobj, mode="w|") as tar: | |
my_content = "abdef".encode('utf-8') | |
tf = tarfile.TarInfo("my_file_name") | |
tf.size = len(my_content) | |
tar.addfile(tf, io.BytesIO(my_content)) | |
tar_fileobj.seek(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def with_retry_connections(max_tries=3, sleep=0.05): | |
""" | |
Decorator that wraps an entire function in a try/except clause. On | |
requests.exceptions.ConnectionError, will re-run the function code | |
until success or max_tries is reached. | |
:param max_tries: maximum number of attempts before giving up | |
:param sleep: time to sleep between tries, or None | |
""" | |
def decorator(f): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing,os | |
APP_NAME = 'foobar' | |
bind = "0.0.0.0:5000" | |
#bind = "unix:/tmp/gunicorn-%s.sock" % APP_NAME | |
workers = multiprocessing.cpu_count() * 2 + 1 | |
max_requests = 200 | |
preload_app = True | |
chdir = os.path.dirname(__file__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pika | |
class GenericWorker: | |
def __init__(self,url='amqp://admin:password@localhost:5672/%2F'): | |
self.connection = pika.BlockingConnection(pika.URLParameters(url)) | |
self.channel = self.connection.channel() | |
self.channel.exchange_declare(exchange='TestExchange',exchange_type='direct',passive=False,durable=False) | |
self.channel.queue_declare(queue='TestQueue') | |
self.channel.queue_bind(queue='TestQueue',exchange='TestExchange',routing_key='TestQueueRoute') | |
def run(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker rm $(docker ps -a -q) | |
docker rmi $(docker images | awk '/^<none>/ {print $3}') |
NewerOlder