This file contains 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
#!/usr/bin/env python | |
#coding=utf-8 | |
import socket | |
import os | |
import errno | |
from tornado.ioloop import IOLoop | |
from tornado.platform.auto import set_close_exec | |
class UDPServer(object): | |
def __init__(self, io_loop=None): |
This file contains 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
"""A simple demonstration of running background tasks with Tornado. | |
Here I am using a basic TCP server which handles streams and keeps | |
them open while asynchronously performing a fake task in the | |
background. In order to test it, simply telnet to localhost port 8080 | |
and start typing things to see that the server receives the messages. | |
The advantage to running on an executor instead of conventional | |
threads is that we can more easily shut it down by stopping the | |
tornado IO loop. |
This file contains 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 random | |
import time | |
from tornado import gen | |
from tornado.concurrent import run_on_executor, futures | |
from tornado.ioloop import IOLoop | |
class TaskRunner(object): | |
def __init__(self, loop=None): | |
self.executor = futures.ThreadPoolExecutor(4) | |
self.loop = loop or IOLoop.instance() |
This file contains 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 asyncio | |
import collections | |
import json | |
import uuid | |
import aiohttp | |
Message = collections.namedtuple( | |
"Message", |
This file contains 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
## -*- makefile -*- | |
## biggers@utsl.com, Mark Biggers | |
## GNU Makefile for docker-compose build & run of a Python or other Project | |
## | |
## REFs: | |
## https://docs.docker.com/compose/reference/ | |
## https://github.com/docker/compose/releases | |
## |
This file contains 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
# | |
# This piece of code is written by | |
# Jianing Yang <jianingy.yang@gmail.com> | |
# with love and passion! | |
# | |
# H A P P Y H A C K I N G ! | |
# _____ ______ | |
# ____==== ]OO|_n_n__][. | | | |
# [________]_|__|________)< |YANG| | |
# oo oo 'oo OOOO-| oo\\_ ~o~~o~ |
This file contains 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
#!/usr/bin/env python | |
'''Script to pull data out of GitHub and push into Elasticsearch''' | |
import os | |
import sys | |
import requests | |
import httplib | |
import json # NOQA | |
from urlparse import urljoin | |
from uritemplate import expand |
This file contains 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
## better, working "shell-recipe" for installing a tagged | |
## Ansible release, from Git source | |
## https://github.com/ansible/ansible/tags | |
sudo aptitude install python-yaml python-jinja2 python-paramiko | |
cd ~/git/Python | |
tag_name='v1.9.4-1' | |
git clone git://github.com/ansible/ansible.git --recursive |
This file contains 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
#!/bin/sh | |
VNC_SERVER=/usr/bin/x11vnc | |
VNC_DISPLAY=:0 | |
LOG_FILE=/tmp/x11vnc-run.log | |
case "$1" in | |
start|restart) | |
killall ${VNC_SERVER} |
This file contains 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 re | |
import sys | |
import requests | |
filename_matcher = re.compile(r'http://www.oreilly.com/(.*)/free/(.*).csp') | |
def main(): | |
categories = sys.argv[1:] | |
urls = map(lambda x: 'http://www.oreilly.com/{}/free/'.format(x), categories) |