Skip to content

Instantly share code, notes, and snippets.

@rmyers
rmyers / mkappenginevenv.sh
Created June 7, 2011 18:01
Setup virtual env for appengine with python 2.5
#!/bin/bash
#
# Build a virtual environment suitable for running appengine.
# This uses virtualenvwrapper to make the virtual environment.
# Which you can activate with 'workon appengine'
#
# Everyone loves one-liners!
# Mac one-liner:
# $ curl -s https://raw.github.com/gist/1012769 | bash
#
@rmyers
rmyers / install_homebrew.rb
Created June 12, 2011 01:10 — forked from mxcl/install_homebrew.markdown
Installs Experimental Solaris Homebrew to /usr/local so you don't need sudo to `brew install`
#!/usr/bin/ruby
#
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
#
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
# versions of OS X. I cannot verify that for sure, and it was tested on
@rmyers
rmyers / appengine.sh
Last active October 5, 2015 16:48
Create a Virtual ENV for appengine and python2.7
#!/bin/bash
#
# Build a virtual environment suitable for running appengine.
# This uses virtualenvwrapper to make the virtual environment.
# Which you can activate with 'workon appengine'
#
# Everyone loves one-liners!
# Mac one-liner:
# $ curl -s https://raw.github.com/gist/2839803 | bash
#
import struct
import SocketServer
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
class WebSocketsHandler(SocketServer.StreamRequestHandler):
magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
@rmyers
rmyers / backup.py
Last active December 15, 2015 12:09
Manual streaming backup of a CloudDB Instance to CloudFiles
#!/bin/env python2.6
"""
Manual Backup Script
====================
This script is called by the agent to run a backup and stream to swift.
Setup Requires:
* Python >= 2.6
* Requests
def gen():
print 'foo'
class Test(object):
@classmethod
def _uuid(cls):
return gen()
class DatabaseModelBase(models.ModelBase):¬
_auto_generated_atts = ['id']
¬
@classmethod¬
def create(cls, **values):¬
values = cls.get_auto_generated_values(**values)¬
if hasattr(cls, 'deleted') and 'deleted' not in values:¬
values['deleted'] = False¬
values['created'] = utils.utcnow()¬
instance = cls(**values).save()¬
@rmyers
rmyers / meta.py
Created July 10, 2013 14:07
Metaclass example
import os
class DebianPackagerMixin:
def boo(self):
print('debian')
class RedhatPackagerMixin:
def boo(self):
print('redhat')
@rmyers
rmyers / gist:7420845
Created November 11, 2013 21:36
horizon api
try:
from troveclient import auth
from troveclient import client
with_trove = True
except ImportError:
try:
from troveclient.compat import auth
from troveclient.compat import client
with_trove = True
except ImportError:
@rmyers
rmyers / gist:7454185
Created November 13, 2013 18:46
commit
Externalization of heat template
Reasons: preparing trove to support multi-datastores
Changes: template loading, heat-support update
This refactors the earlier code of instance creation using heat.
- Reorganize templates by datastore
- Config: trove/templates/<datastore_type>/config.template
- Heat: trove/templates/<datastore_type>/heat.template
- New parameter - ImageId