This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
import boto.s3 | |
import os.path | |
import sys | |
# Fill these in - you get them when you sign up for S3 | |
AWS_ACCESS_KEY_ID = '' | |
AWS_ACCESS_KEY_SECRET = '' | |
# Fill in info on data to upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "Mac OS Mouse Browser", | |
"rules": [{ | |
"description": "Use button 4 and 5 on Mac OS for browser", | |
"manipulators": [{ | |
"type": "basic", | |
"from": { | |
"pointing_button": "button4" | |
}, | |
"to": [{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExDict(dict): | |
""" | |
Extended Dictionary | |
""" | |
def __init__(self,*arg,**kw): | |
super( ExDict , self).__init__(*arg, **kw) | |
def __setattr__(self, k, v): | |
if k in self.keys(): | |
self[k] = v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# values are highest first | |
def assignValuesToKeysEvenly(keys, values): | |
""" keys are a list containing key names | |
values are a list of values | |
""" | |
keynames = {} | |
# make keynames a dict of keynames containing a list of assigned values | |
for key in keys: | |
keynames[key] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split_file(file, prefix, max_size, buffer=1024): | |
""" | |
filename: the input filename | |
max_size: maximum size of each created file in bytes | |
buffer: buffer size in bytes | |
Returns the number of parts created. | |
""" | |
with open(file, 'r+b') as src: | |
suffix = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto.utils | |
print boto.utils.get_instance_metadata()['network']['interfaces']['macs'].values()[0]['public-hostname'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#boto libraries | |
import boto.ec2 | |
import boto.utils | |
import boto.s3.connection | |
#python libraries | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import boto.ec2 | |
import sys | |
def _progressBar(state): | |
progress_bar = '=' * state | |
sys.stdout.write('\r'+progress_bar) | |
sys.stdout.flush() | |
# recursive function to wait until the ssh connection is ready |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import boto | |
import boto.ec2 | |
def _launchAWSInstances(): | |
connection = boto.ec2.connect_to_region(AWS_REGION, aws_access_key_id = AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_ACCESS_KEY_SECRET) | |
global reservation | |
reservation = connection.run_instances(AWS_AMI, | |
key_name=AWS_SSH_KEY_NAME, | |
instance_type=AWS_INSTANCE_SIZE, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def _progressBar(state): | |
progress_bar = '=' * state | |
sys.stdout.write('\r'+progress_bar) | |
sys.stdout.flush() |
NewerOlder