Skip to content

Instantly share code, notes, and snippets.

View briancline's full-sized avatar

Brian Cline briancline

  • SoftLayer / IBM Cloud
  • Dallas, Texas
View GitHub Profile
@jasonjohnson
jasonjohnson / python.md
Last active August 29, 2015 13:55
A collection of resources for learning Python.

Introduction

The best way to learn Python is to write Python, but these guides will provide an excellent starting point for the library landscape, coding standards, and community. This is by no means comprehensive! Once this is in an actual repository I will gladly accept relevant modifications.

Guides

The Hitchhiker’s Guide to Python!

"This opinionated guide exists to provide both novice and expert Python developers a best-practice handbook to the installation, configuration, and usage of Python on a daily basis."

@sudorandom
sudorandom / import_stuff.py
Created March 5, 2014 23:56
Multi Multiple Import
PARSERS = [('pkg_resources', 'parse_version'), ('distutils.version', 'StrictVersion')]
def get_parse_fn():
for parser_module, parser in PARSERS:
try:
return getattr(importlib.import_module(parser_module), 'parser')
except ImportError:
pass
raise Exception("Couldn't find a thing to do the thing")
@gilv
gilv / migration_from_file_system
Created July 31, 2014 06:52
migration_from_file_system
'''
Created on Dec 16, 2013
@author: Gil Vernik
'''
from swiftclient import client as c
import os
import tempfile
import random
# This is a nginx config snippet showing how to inherit an http header
# or defaulting it to a specific value. This is useful because it allows
# upstream load balancers to set specific headers, but if they're missing
# the app LB will know how to default it.
# This will inherit the previously set X-Scheme variable, or otherwise
# default it to the current `$scheme`. Requires nginx 0.9.0+.
#
# Docs: http://wiki.nginx.org/HttpMapModule#map
map $http_x_scheme $x_scheme {
@mitchellh
mitchellh / gist:1171262
Created August 25, 2011 17:44
They see me wiresharkin'... they hatin'...
#!/usr/bin/env python
"""
This Python scripts listens for all HTTP requests to the
Turntable CDNs and downloads the file requested into the
current directory.
Disclaimer: This is a proof of concept. The author of this
script is not responsible for how this is used.
"""
@mlavin
mlavin / fabfile.py
Created January 11, 2012 16:44
Fabric Package Install
import ConfigParser
import os
from fabric.api import env, sudo
from fabric.contrib import files
SERVER_ROLES = ['dbmaster', 'app', 'lb', ]
env.roledefs = dict.fromkeys(SERVER_ROLES, [])
# Directory structure
@alq666
alq666 / iostat.py
Created August 7, 2012 23:12
iostat.py
from statsd import statsd
import sys
device = sys.argv[1]
while True:
a = sys.stdin.readline().strip()
data = a.split()
if len(data) == 3:
try:
@briancline
briancline / cookie.scala
Created October 11, 2012 18:46
Munch cave concurrency with glitter
@stefanozanella
stefanozanella / enable_serial_console.sh
Created January 16, 2013 18:26
Enable serial console output in CentOS (useful for OpenStack + KVM)
echo "ttyS0" > /etc/securetty
vi /etc/grub.conf
# Add console=ttyS0 to the end of kernel line(s)
vi /etc/sysconfig/init
# Edit ACTIVE_CONSOLES to look like:
ACTIVE_CONSOLES="/dev/tty[1-6] /dev/ttyS0"
# If on a live system, do the following
@sudorandom
sudorandom / network_graphs.py
Last active December 12, 2015 02:38
Generates graphs of VLANs/hardware/CCIs/firewalls from data in the SoftLayer API.
#!/usr/bin/env python
"""
Generates graphs of VLANs and connected hardware/CCIs from data in the
SoftLayer API.
"""
import argparse
import time
import math
import matplotlib.pyplot as plt