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 flask import Flask | |
app = Flask(__name__) | |
import boto | |
from moto import mock_s3 | |
@app.route("/") | |
def hello(): | |
conn = boto.connect_s3('the_key', 'the_secret') | |
bucket = conn.create_bucket('mybucket') |
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
# If we are in a Development folder, we're probably in a virtual env. Try to activate it based on our CWD. | |
IN=$PWD | |
if [[ "$IN" == */Development/* ]] | |
then | |
arrIN=(${IN//// }) | |
# This assumes Development is the third token and your project directory is the fourth | |
workon ${arrIN[3]} | |
fi |
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
Fixtures/Command line runner | |
It would be awesome if there were a command line runner. For example, imagine I run a django app that relies on a ton of external APIs. It would be great for development if I could run `httpretty manage.py runserver` and all of the calls would be mocked accordingly. `httpretty` would import a file named `.httpretty.py` which would setup all the routing configuration. | |
Happy to do some work on this if it sounds interesting. | |
Example `.httpretty.py` | |
```python |
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
- Have you accounted for any timing issues? Your pdb is probably running a second or two after the test assertions run. | |
- Could there be a unicode vs bytestring issues? It's possible that strings you type in your pdb are one thing while strings in your test files are another. This espcially applies if you use unicode_literals, since most pdb-like programs still use bytestrings as input. | |
- Could it be that in the pdb your code is running a function additional times and that function has side-effects? |
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 | |
conn = boto.connect_s3() | |
bucket = conn.get_bucket("{{ bucket }}") | |
key = bucket.new_key("{{ filename }}") | |
key.set_contents_from_filename("{{ filename }}") | |
url = key.generate_url({% if expires %}{{ expires }}{% else %}3600{% endif %}) | |
print url |
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
print "Hello, {{ name }}" |
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 codecs | |
import re | |
opened_file = open(filename, "r") | |
encoding_line = opened_file.readline() | |
opened_file.close() | |
encoding_regex = re.compile('# -\*- coding:(.*) -\*-') | |
results = re.search(encoding_regex, encoding_line) | |
if results: | |
encoding = results.groups()[0] | |
else: |
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 shlex | |
files = subprocess.check_output(shlex.split('git ls-files --full-name')).strip().split('\n') | |
py_files = [file for file in files if file.endswith(".py")] | |
len(py_files) | |
new_header = '# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n' | |
for the_file in py_files: | |
read_file = open(the_file, 'r') | |
lines = list(read_file) | |
result_lines = [] |
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
if [ ! -f /usr/local/bin/chef-client ]; then | |
# Become up to date | |
apt-get update | |
# Get our basics | |
apt-get install -y -q ruby1.9.1 ruby1.9.1-dev build-essential wget | |
fi | |
gem install ohai --no-rdoc --no-ri | |
gem install right_aws --no-ri --no-rdoc | |
gem install chef --no-rdoc --no-ri --version '10.16.4' |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot){ | |
robot.clone(); | |
this.direction = 1; | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; |
NewerOlder