Skip to content

Instantly share code, notes, and snippets.

View mozLz4.py
import sys
from lz4.block import compress as lz4_compress
from lz4.block import decompress as lz4_decompress
from argparse import ArgumentParser
class MozLz4aError(Exception):
pass
View serverfault-questions-888921
FROM centos:7
MAINTAINER Brian Ogden
# Not currently being used but may come in handy
ARG ENVIRONMENT
ENV NODE_VERSION 6.11.1
RUN yum -y update \
&& yum clean all \
&& yum -y install http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm \
View bash-function.sh
#!/bin/bash
http_code=0
function result_handling {
case "${http_code}" in
"401" | "403" | "404" )
echo "Error: httpd code ${http_code}"
;;
"200" | "301" )
View cheetah-template.py
from Cheetah.Template import Template
test = {
'VPCId': 'vpc-1234567',
'AssociatePublicIpAddress': 'false',
'EC2Subnets': 'subnet-1234567',
'ELBSubnets': 'subnet-7654321',
'SecurityGroups': 'sg-1234567',
'EC2KeyName': 'test',
'ManagedSecurityGroup': 'sg-1234567',
View gist:3d9ff7d90ec5c0198a608d238cd3b326
import cups
import subprocess
import time
conn = cups.Connection ()
printid = conn.printFile('ML2580N-1', '/tmp/test.txt', 'test', {})
print printid
stop = 0
View smart
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 115 089 006 Pre-fail Always - 84537541
3 Spin_Up_Time 0x0002 097 097 000 Old_age Always - 0
4 Start_Stop_Count 0x0033 099 099 000 Pre-fail Always - 1158
5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 18
7 Seek_Error_Rate 0x000f 078 060 030 Pre-fail Always - 17421499817
9 Power_On_Hours 0x0032 077 077 000 Old_age Always - 20888
10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0
View sed-multiline
if [[ "A" == "A" ]]; then
sed -r "s/^(#)?labels=.*/labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}/" newrelic.cfg | grep labels
fi
if [[ "A" == "A" ]]; then
sed -r "s/^(#)?labels=.*/labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}/" newrelic.cfg | grep labels
fi
View gist:52e77385128ee60695321a5e30f3f197
$ aws ec2 describe-instance-status --instance-ids i-0538dc72cc1baffdb --profile cardpool-dev --region us-east-1
{
"InstanceStatuses": [
{
"InstanceId": "i-0538dc72cc1baffdb",
"InstanceState": {
"Code": 16,
"Name": "running"
},
"AvailabilityZone": "us-east-1e",
View gist:b7d366434c8929e4f79bbdf3d722febe
$ aws ec2 describe-instance-status --instance-ids i-0538dc72cc1baffdb --region us-east-1
{
"InstanceStatuses": [
{
"InstanceId": "i-0538dc72cc1baffdb",
"InstanceState": {
"Code": 16,
"Name": "running"
},
"AvailabilityZone": "us-east-1e",