Skip to content

Instantly share code, notes, and snippets.

View biggers's full-sized avatar

Mark Biggers biggers

View GitHub Profile
@smoser
smoser / apt-go-fast
Last active February 13, 2017 16:17
user-data for setting up devstack
#!/bin/sh
#
# copied from https://gist.github.com/smoser/5823699
#
set -e
[ -e "/usr/bin/apt-get.distrib" ] ||
sudo dpkg-divert --local --rename --add /usr/bin/apt-get
sudo tee /usr/bin/apt-get >/dev/null <<"EOF"
@dgarnier
dgarnier / nfs_add_automount.sh
Last active April 12, 2017 19:56
Get a Debian Jessie Beaglebone to mount an NFS share...
#!/bin/bash
usage="$(basename "$0") [-h] mountpoint nfs_server:directory"
while getopts ":h" opt; do
case $opt in
h)
echo $usage >&2
exit 1
;;
@davebshow
davebshow / a_aioclient.py
Last active July 24, 2017 01:28
This gist details some simple profiling that I did to compare compare a Tornado based client implementation vs. a Aiohttp based implementation of gremlinclient. To do so, I simply dropped the Aiohttp websocket client in the place of the Tornado client in gremlinclient like shown in the following file. Next I did a simple IPython %timeit, followe…
import asyncio
import collections
import json
import uuid
import aiohttp
Message = collections.namedtuple(
"Message",
@biggers
biggers / recipe-pyenv.sh
Created September 26, 2017 17:46
shell-recipe for pyenv install of Python 3.6.2 on CentOS / Redhat 6.7
# REF: https://github.com/pyenv/pyenv/blob/master/README.md
# ... building Python 3.6.2 on Bastion, "locally"
# yum install [Python3 build pre-reqs, on CentOS 6.7]
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
tee -a $HOME/.bash_profile <<EOF
export PATH="\$HOME/.pyenv/bin:\$PATH"
eval "\$(pyenv init -)"
#!/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
@mivade
mivade / coroutinify.py
Created August 3, 2015 17:53
Adapting blocking calls to Tornado coroutines with run_on_executor decorators
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()
@jianingy
jianingy / iodatagram.py
Last active November 15, 2017 12:11
udp / raw socket for python tornado
#
# 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~
@biggers
biggers / tcpclient.py
Last active January 2, 2018 15:01
"continously-running" Tornado TCP client example -- sends to 'tornado/demos/tcpecho/server.py'
import time
import logging
from tornado.options import options, define
from tornado import gen
from tornado.tcpclient import TCPClient
from tornado.iostream import StreamClosedError
from tornado.ioloop import IOLoop
define("host", default="127.0.0.1", help="TCP server host")
define("port", default=9888, help="TCP port to connect to")
@biggers
biggers / torpeewee_ex01.py
Last active May 18, 2018 23:01
torpeewee -- fixed example from torpeewee/README.rst -- async peewee for Tornado
# -*- coding: utf-8 -*-
# REWORKED by biggers@utsl.com, from:
# 16/7/7
# create by: snower
import datetime
from tornado import gen
from tornado.ioloop import IOLoop
from torpeewee import (
Model,
@cessor
cessor / serve.py
Last active June 4, 2018 19:52
Simple Tornado App Skeleton
import logging
import os
import uuid
from tornado import gen
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.options import define, options
from tornado.web import Application, StaticFileHandler, url