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 webapp2 | |
from functools import wraps | |
from google.appengine.api import memcache | |
def rate_limit(seconds_per_request=1): | |
def rate_limiter(function): | |
@wraps(function) | |
def wrapper(self, *args, **kwargs): | |
added = memcache.add('%s:%s' % (self.__class__.__name__, self.request.remote_addr or ''), 1, |
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
Select the runtime to download the base image for: | |
[1] Go | |
[2] Java | |
[3] Python27 | |
[4] All | |
Please enter your numeric choice (4): 3 | |
Pulling base images for runtimes [python27] from Google Cloud Storage | |
Pulling image: google/appengine-python27 | |
Traceback (most recent call last): |
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
[smartcd] | |
recipe = mr.scripty | |
install = | |
... import sys | |
... import os.path | |
... sys.path.insert(0, self.buildout['omelette']['location']) | |
... import pexpect | |
... | |
... script_dir = os.path.join( |
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 | |
import distutils.spawn | |
import re | |
import sys | |
if '/usr/local/lib/python2.7/site-packages' not in sys.path: | |
sys.path.insert(0, '/usr/local/lib/python2.7/site-packages') | |
if '/Library/Python/2.7/site-packages' not in sys.path: |
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
bash -c ' | |
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%> | |
if [ ! -f /usr/bin/chef-client ]; then | |
apt-get update | |
apt-get install -y libreadline5 libruby1.9.1 ruby1.9.1 ruby1.9.1-dev build-essential wget rubygems1.9.1 | |
fi | |
LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 export LC_CTYPE LANG |
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
#! /bin/sh | |
PATH=/usr/sbin:/sbin:/usr/bin:/bin | |
cat <<EOF > /etc/apt/apt.conf.noninteractive | |
APT::Get::Assume-Yes "true"; | |
APT::Get::Show-Upgraded "true"; | |
APT::Quiet "true"; | |
DPkg::Options {"--force-confmiss";"--force-confold"}; | |
DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";}; |
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 Chef | |
class Recipe | |
def has_remote_file_modified(uri, filepath) | |
require 'net/http' | |
http = Net::HTTP.new(uri.host, uri.port) | |
req = Net::HTTP::Head.new(uri.path) | |
if uri.user | |
req.basic_auth uri.user, uri.password | |
end |
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 argparse | |
parser = argparse.ArgumentParser(description='Spawn an army of test-robot ' | |
'agents for the purpose of automated testing') | |
parser.add_argument('-c', '--create-test', action='store_true', | |
help='Create a new test...') | |
parser.add_argument('-t', '--test-case', dest='testcase', | |
default="robot_script.json" help='Test case file name (i.e. robot_script.json)') | |
# the default action here is to store False in opts.dumptest, and is not |
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 json_diff(obj, other, order_matters=True): | |
""" This method assumes json types: dict, list, strings, numbers, booleans and null """ | |
if isinstance(obj, dict) and isinstance(other, dict): | |
if set(obj.keys()) != set(other.keys()): | |
return True | |
for key in sorted(obj.keys()): | |
if json_diff(obj[key], other[key], order_matters): | |
return True | |
elif isinstance(obj, list) and isinstance(other, list): |
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 Observable: | |
'''Mixin for objects that need to be observed.''' | |
_observers = None | |
def observe(self, observer): | |
if not self._observers: | |
self._observers = [] | |
self._observers.append(observer) |
OlderNewer