Skip to content

Instantly share code, notes, and snippets.

View shawnbutts's full-sized avatar

Shawn Butts shawnbutts

View GitHub Profile
#!/bin/bash
# turn a fresh centos 6 (vagrant) box into a dev box by installing python 2.6, 2.7, 3.5, and go 1.6
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@shawnbutts
shawnbutts / 7z+tar.md
Created June 4, 2016 16:53 — forked from kylemanna/7z+tar.md
Archive with tar + 7z + max compression

Overview

7-zip doesn't preserve the Linux/Unix owner/group of files and possibly other details. Use tar instead because it's designed to preserve these things, then just 7zip the tar archive.

Create the archive

tar cf - --exclude=\*.o -v directory | 7z a -si -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on directory.tar.7z
import netuitive
import time
ApiClient = netuitive.Client(api_key='aaaaaaa9956110211e594444697f922ec7b')
MyElement = netuitive.Element()
timestamp = int(time.mktime(time.gmtime()))
#!/usr/bin/env python
import os
import time
import datetime
def get_directory_structure(rootdir, strip=False):
"""
################################################################################
# Diamond Configuration File
################################################################################
################################################################################
### Options for the server
[server]
# Handlers for published metrics.
handlers = diamond.handler.netuitive_cloud.NetuitiveHandler, diamond.handler.graphite.GraphiteHandler
@shawnbutts
shawnbutts / testserver.py
Created October 9, 2015 14:25
@rochacbruno test webserver (damn handy)
#!/usr/bin/python
"""
Save this file as server.py
>>> python server.py 0.0.0.0 8001
serving on 0.0.0.0:8001
or simply
>>> python server.py
@shawnbutts
shawnbutts / gist:9451a2b6293d6ed7d626
Created May 30, 2014 13:29
ssh connection test
time ssh <SERVER> 'a=1; while true; do echo $a `date` ; let a=a+1; sleep 1; done'
def get_aws_account_id():
conn_iam = boto.connect_iam()
ret = conn_iam.get_all_users()['list_users_response']['list_users_result']['users'][0]['arn'].split(':')[4]
return(ret)
@shawnbutts
shawnbutts / gist:c75b3fa8839274c948d1
Last active August 29, 2015 14:01
EC2_INSTANCE_TYPES
EC2_INSTANCE_TYPES = {
'c3.2xlarge': {'ebs': {'optimized': True},
'ephemeral': {'number': '2',
'size': '80',
'type': 'SSD'},
'network': {'enhanced': True,
'performance': 'High'},
'processor': {'aes-ni': True,
'avx': True,
'speed': '2.8',
@shawnbutts
shawnbutts / gist:8339027
Last active January 2, 2016 17:49
flush cache and swap on linux
time sync; echo 3 > /proc/sys/vm/drop_caches
time swapoff -a
swapon -a