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 sys | |
| import gevent | |
| from gevent.monkey import patch_all; patch_all() | |
| from gevent import server, event, socket | |
| from multiprocessing import Process, current_process, cpu_count | |
| """ | |
| Simple multiprocess StreamServer that proxies messages between clients. | |
| Avoids using a multiprocessing.Event since it blocks on a semaphore. |
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 functools import update_wrapper | |
| import zmq | |
| class Socket(zmq.Socket): | |
| def __init__(self, ctx, type, default_timeout=None): | |
| zmq.Socket.__init__(self, ctx, type) | |
| self.default_timeout = default_timeout | |
| def on_timeout(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
| ## credit: http://fabian-affolter.ch/blog/the-lineinfile-module-of-ansible/ | |
| --- | |
| - hosts: alpine_install | |
| user: root | |
| tasks: | |
| # - name: create a complete empty file | |
| # command: /usr/bin/touch /test/test.conf | |
| - name: create a new file with lineinfile |
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
| --- | |
| # ^^^ YAML documents must begin with the document separator "---" | |
| # | |
| #### Example docblock, I like to put a descriptive comment at the top of my | |
| #### playbooks. | |
| # | |
| # Overview: Playbook to bootstrap a new host for configuration management. | |
| # Applies to: production | |
| # Description: | |
| # Ensures that a host is configured for management with Ansible. |
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
| logger = logging.getLogger(__name__) | |
| ch = logging.StreamHandler() | |
| ch.setLevel(logging.DEBUG) | |
| formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
| ch.setFormatter(formatter) | |
| logger.addHandler(ch) |
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 flask import Flask | |
| from flaskext.sqlalchemy import SQLAlchemy, models_comitted | |
| app = Flask(__name__) | |
| db = SQLAlchemy(app) | |
| class Post(db.Model): | |
| id = db.Column('post_id', db.Integer, primary_key=True) | |
| title = db.Column(db.String(200)) | |
| text = db.Column(db.String) |
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
| ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArmMOfgGJ8o7bBYz0s+OW/zkXRcfma/felnuxaBxr+QdILQR/u2ZaNnatIpfIZEJIpZvmnbWIcOYxjlTnHMv/uHkhIigoE85l40+Uj7On+dDiJG5/c4AGS3uX1GQFeltJaWUW3ghUHOaReYyTnsp6+htvLdPnfHJJl2XaGzLz0cWTHnBD26CBBUHU2fFDj9shWMeTc/iHKFcxlKUrDLPS1gG8/NfqDlynhh/6QMgCyaX696EFZ5QP3aAuB3umsWwv37naKLGt3lUmWtXl5Nc3xIJKZ2CIlc/Hx+/jvtuCvULt/NdWotxp9kbgJRh2G+uonRvDJK1uinohv8Z0B+C+0w== max@explorer |
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 json | |
| import math | |
| import os | |
| import time | |
| import webbrowser | |
| import zmq.green as zmq | |
| import gevent | |
| #from geventwebsocket import WebSocketApplication | |
| from geventwebsocket.handler import WebSocketHandler | |
| from paste.urlparser import StaticURLParser |
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
| logger = logging.getLogger(__name__) | |
| logger.setLevel(logging.DEBUG) | |
| ch = logging.StreamHandler() | |
| ch.setLevel(logging.DEBUG) | |
| formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
| ch.setFormatter(formatter) | |
| logger.addHandler(ch) |
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 sys | |
| import zmq | |
| # None of these operations will block, regardless of peer: | |
| context = zmq.Context() | |
| socket = context.socket(zmq.REQ) | |
| socket.setsockopt(zmq.LINGER, 0) | |
| socket.connect("tcp://127.0.0.1:12346") | |
| socket.send_json({"msg": "testmsg"}) # send can block on other socket types, so keep track | |
| # use poll for timeouts: |