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
from __future__ import print_function | |
import StringIO | |
import gzip | |
from boto.s3.connection import S3Connection | |
conn = S3Connection("<key_id>", "<secret>") | |
bucket = conn.get_bucket('<bucket>') | |
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 | |
''' | |
Send memory usage metrics to Amazon CloudWatch | |
This is intended to run on an Amazon EC2 instance and requires an IAM | |
role allowing to write CloudWatch metrics. Alternatively, you can create | |
a boto credentials file and rely on it instead. | |
Original idea based on https://github.com/colinbjohnson/aws-missing-tools | |
''' |
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 | |
ec2 = boto.connect_ec2() | |
groups = ec2.get_all_security_groups() | |
def get_groups_that_have_ingress_rules_to(groups, group_id): | |
result = [] | |
for group in groups: | |
for rule in group.rules: | |
for grant in rule.grants: |
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
# WRONG | |
def test_open_and_delete_file(): | |
f = open(FILEPATH) | |
content = f.read() | |
assert content == "hello world" | |
content.close() | |
# RIGHT | |
def test_open_and_delete_file(): |
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
FROM base | |
MAINTAINER Hugo Lopes Tavares <hugo@yipit.com> | |
RUN apt-get update | |
RUN apt-get install -y python3 expect-dev | |
EXPOSES 8000 | |
CMD ["unbuffer", "python3", "-m", "http.server"] |
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/java -jar /usr/share/logstash/logstash-1.1.13-monolithic.jar agent -f /etc/logstash/conf.d -w 1 | |
Exception in thread "LogStash::Runner" org.jruby.exceptions.RaiseException: (RegexpError) premature end of char-class: /^\\[/ | |
at org.jruby.RubyRegexp.initialize(org/jruby/RubyRegexp.java:1267) | |
at org.jruby.RubyRegexp.new(org/jruby/RubyRegexp.java:729) | |
at RUBY.compile(jar:file:/usr/share/logstash/logstash-1.1.13-monolithic.jar!/gems/jls-grok-0.10.11/lib/grok-pure.rb:137) | |
at RUBY.register(file:/usr/share/logstash/logstash-1.1.13-monolithic.jar!/logstash/filters/multiline.rb:146) | |
at RUBY.run_with_config(file:/usr/share/logstash/logstash-1.1.13-monolithic.jar!/logstash/agent.rb:472) | |
at org.jruby.ext.thread.Mutex.synchronize(org/jruby/ext/thread/Mutex.java:149) | |
at RUBY.run_with_config(file:/usr/share/logstash/logstash-1.1.13-monolithic.jar!/logstash/agent.rb:471) | |
at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613) |
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 Context | |
def self.path(fname) | |
puts "Creating file #{fname}" | |
end | |
end | |
def template(filename, &block) | |
context = Class.new(Context) | |
context.class_eval(&block) | |
context |
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
============================= test session starts ============================== | |
platform darwin -- Python 2.7.5 -- pytest-2.3.5 | |
plugins: growl | |
collected 2 items | |
test_equals_with_dicts.py FF | |
=================================== FAILURES =================================== | |
____________ test_assert_equals_with_dicts_and_all_values_different ____________ |
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
$ pip --version | |
pip 1.4.dev1 from /private/tmp/venv-test2/lib/python2.7/site-packages/pip-1.4.dev1-py2.7.egg (python 2.7) | |
$ time pip install --no-install coverage -vvvvv | |
Downloading/unpacking coverage | |
Getting page https://pypi.python.org/simple/coverage/ | |
URLs to search for versions for coverage: | |
* https://pypi.python.org/simple/coverage/ | |
Getting page http://nedbatchelder.com/code/modules/coverage.html | |
Getting page http://nedbatchelder.com/code/coverage | |
Getting page http://nedbatchelder.com/code/coverage/3.5.1b1 |
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
$ pip --version | |
pip 1.4.dev1 from /private/tmp/venv-test/lib/python2.7/site-packages (python 2.7) | |
$ time pip install --no-install coverage -vvvvv | |
Downloading/unpacking coverage | |
Getting page https://pypi.python.org/simple/coverage/ | |
URLs to search for versions for coverage: | |
* https://pypi.python.org/simple/coverage/ | |
Getting page http://nedbatchelder.com/code/modules/coverage.html | |
Skipping page http://nedbatchelder.com/code/modules/coverage-2.85.tar.gz (from https://pypi.python.org/simple/coverage/) because of Content-Type: application/x-tar | |
Skipping page http://nedbatchelder.com/code/modules/coverage-2.8.tar.gz (from https://pypi.python.org/simple/coverage/) because of Content-Type: application/x-tar |