Skip to content

Instantly share code, notes, and snippets.

View copernicus's full-sized avatar

Nicolaus Copernicus copernicus

View GitHub Profile
from boto.cloudfront import CloudFrontConnection
def update_default_root_object(searched_origin, aws_access_key_id, aws_secret_access_key, default_root_object='index.html'):
""" sets default_root_object of an aws cloud front distribution
for futher information checkout http://boto.s3.amazonaws.com/ref/cloudfront.html
or http://github.com/boto/boto/tree/master/boto/cloudfront
"""
connection = CloudFrontConnection(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
#!/usr/bin/env ruby
require 'rubygems'
require 'chef'
require 'chef/client'
require 'chef/run_context'
Chef::Config[:solo] = true
Chef::Config[:log_level] = :info
Chef::Log.level(:info)
@copernicus
copernicus / s3mirror.sh
Created December 10, 2011 05:37 — forked from panupan/s3mirror.sh
Mirror all Amazon S3 buckets with daily cron script using s3cmd
#!/bin/bash
BACKUP_DIR='/backups/S3 Mirror/'
BUCKETS=$(s3cmd ls | grep s3 | awk '{ print $3 }')
for i in $BUCKETS; do
CURRENT_DIR=$BACKUP_DIR${i//s3:\/\//}
echo Mirroring $i to $CURRENT_DIR
mkdir -p "$CURRENT_DIR"
s3cmd sync $i "$CURRENT_DIR"
@copernicus
copernicus / sync_aws_buckets
Created December 10, 2011 05:40 — forked from ipoval/sync_aws_buckets
sync_aws_buckets
#!/usr/bin/env ruby
# encoding: utf-8
##
# @example
# ruby -rubygems `__FILE__` `source_bucket_name` `target_bucket_name`
#
# @author @ipoval
#
# @see https://github.com/ipoval
@copernicus
copernicus / populate.rb
Created January 8, 2012 18:44 — forked from kazjote/populate.rb
FnordMetric data generator
# Copy it to fnordmetric directory and run with
# bundle exec ruby -Ilib populate.rb live
require "securerandom"
require "socket"
require "json"
class User < Struct.new :username, :avatar
def session_id
"session_#{username}"
@copernicus
copernicus / gist:1663171
Created January 23, 2012 13:41 — forked from asmuth/gist:1557137
FnordMetric: setting user picture/name and unique gauges
# i hope this helps...
# to set the username and picture send these events to fm
# -> you don't need to define any event handlers
# -> the session token (_session) could be your unique session id
# or the unique user id (it's hashed)
# set the user name
{ "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" }
@copernicus
copernicus / gist:1808625
Created February 12, 2012 13:42 — forked from ehazlett/gist:1754289
AWS EBS Volume Cleanup
#!/usr/bin/env python
from optparse import OptionParser
import boto.ec2
import logging
import sys
def get_ec2_connection(aws_key=None, aws_secret=None, region='us-east-1'):
"""
Returns an EC2Connection to the specified region
@copernicus
copernicus / s3_multicopy.py
Created February 12, 2012 13:44 — forked from nukemberg/s3_multicopy.py
s3 multithreaded bucket copy
#! /usr/bin/python
import threading, Queue
import boto, sys, time
import argparse
import logging
parser = argparse.ArgumentParser(description="Multithreaded mass copier for Amazon S3")
parser.add_argument("-s", help="Source bucket", dest="src_bucket", type=str, required=True)
parser.add_argument("-d", help="Destination bucket", dest="dst_bucket", type=str, required=True)
@copernicus
copernicus / ebs_stats.py
Created February 16, 2012 14:16 — forked from beaufour/ebs_stats.py
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
@copernicus
copernicus / backup_sdb.rb
Created March 21, 2012 21:05 — forked from wr0ngway/backup_sdb.rb
script to backup all simpledb tables from a given aws account
#!/usr/bin/env ruby
# Add your gems here
#
gemfile_contents = <<-EOF
source "http://rubygems.org"
gem "fog"
gem "yajl-ruby"
EOF