Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
#
# Example code for specifying multiple dimensions in a
# query of Amazon EC2 CloudWatch using the boto library.
#
# Boto may be downloaded here: http://code.google.com/p/boto
from datetime import datetime, timedelta
from boto import connect_cloudwatch
from boto.ec2.cloudwatch.metric import Metric
@girasquid
girasquid / s3store.py
Created February 9, 2010 19:46
Turn S3 into a key/value store for JSON objects.
import simplejson
from boto.s3.connection import S3Connection
from boto.s3.key import Key
class S3KeyStore(object):
def __init__(self, access_key, secret_key, bucket):
self.conn = S3Connection(access_key, secret_key)
self.bucket = self.conn.create_bucket(bucket)
def get(self, key):
@nicam
nicam / Shutdown Script
Created March 29, 2011 06:12
This Script can be used to start / stop instances on amazon EC2
<?php
require_once 'sdk/sdk.class.php';
$hosts = array(
'linux' => array('id' => 'i-123ee456', 'ip' => '1.2.3.4'),
'windows' => array('id' => 'i-123ee457', 'ip' => '1.2.3.5'),
);
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@diosmosis
diosmosis / example.py
Created August 15, 2011 22:41
Python decorator that catches exceptions and logs a traceback that includes every local variable of each frame.
import os
from log_exceptions import log_exceptions
def throw_something(a1, a2):
raise Exception('Whoops!')
@log_exceptions(log_if = os.getenv('MYAPP_DEBUG') is not None)
def my_function(arg1, arg2):
throw_something(arg1 + 24, arg2 - 24)
@douglasjarquin
douglasjarquin / s3_list_versions.py
Created September 27, 2011 17:03
List S3 object versions with Boto and Python
"""
List all S3 object versions
"""
import os
from boto.s3.connection import S3Connection
print '--- Connecting to S3'
c = S3Connection(aws_access_key_id=os.environ['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=os.environ['AWS_SECRET_ACCESS_KEY'])
@mhawksey
mhawksey / gist:1442370
Last active July 9, 2025 12:26
Google Apps Script to read JSON and write to sheet
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var dataAll = JSON.parse(response.getContentText()); //
var data = dataAll.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}
@steder
steder / aws_sg_recipe.py
Created December 19, 2011 19:11
Create and update AWS security groups using Python and Boto.
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto
@beaufour
beaufour / elb_cloudwatch.py
Created February 15, 2012 19:24
Get CloudWatch metrics for an Amazon ELB
#!/usr/bin/python
#
# Get Cloudwatch metrics for an ELB
#
# Inspired by http://onemoredigit.com/post/3263274796/single-instance-cloudwatch-stats-with-boto
#
import datetime
import sys
@beaufour
beaufour / ebs_stats.py
Created February 16, 2012 00:56
Get CloudWatch metrics for Amazon EBS volumes
#!/usr/bin/python
#
# Get Cloudwatch metrics for the EBS volumes attached to an instance
#
import datetime
import logging
import sys
import urllib