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 os | |
import select | |
import sys | |
import signal | |
from ptyprocess import PtyProcessUnicode | |
STDIN_FD = sys.stdin.fileno() | |
STDOUT_FD = sys.stdout.fileno() | |
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
# Copyright (c) 2011 Joshua D. Bartlett | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in |
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
.remoterunignore | |
.remoterun_lock | |
.remoterunrc | |
.git | |
.gitignore | |
.DS_Store |
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
HOST="user@host" | |
REMOTE_PATH="/remoth/path" | |
RUN_COMMAND="docker run --rm -v ${REMOTE_PATH}:/run -w /run debian:jessie echo 'hello world!'" | |
echo "connecting to ${HOST} and sycing files to the remote ..." | |
rsync -a ./ "${HOST}:${REMOTE_PATH}" | |
echo "running the script at the remote ..." | |
ssh ${HOST} "cd ${REMOTE_PATH} && ${RUN_COMMAND}" |
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
psutil |
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
from multiprocessing import Process | |
class CatchableProcess(Process): | |
def __init__(self, target, args=[], kwargs=dict()): | |
from multiprocessing import Queue | |
self.error = Queue(1) | |
self.result = Queue(1) | |
def wrapper(target, args, kwargs): | |
try: |
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 fasteners | |
import threading | |
class BindFreePort(object): | |
def __init__(self, start, stop): | |
self.port = None | |
import random, socket | |
self.sock = socket.socket() |
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
from database import pickledb | |
from os.path import exists, join, dirname | |
from os import makedirs | |
from null import Null | |
import uuid | |
class CacheObject: | |
def __init__(self, cacher, key, val): | |
assert isinstance(cacher, Cacher) |
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 window_slide(iter, size=2): | |
mem = [None] * size | |
for i, each in enumerate(iter): | |
mem[i % size] = each | |
if i >= size - 1: | |
yield mem[(i + 1) % size:] + mem[:(i + 1) % size] |
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
from Queue import Queue | |
from threading import Thread | |
''' | |
A single worker with queue and promise pattern | |
usage: worker.add_job(fn).then(callback_fn) | |
note: this might be anti-pattern | |
''' |