This file contains hidden or 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 django.db import transaction | |
from django.test import TestCase | |
from users.models import User | |
from . import models | |
class MyTestCase(TestCase): | |
def test_create_expense(self): | |
user = User.objects.create(email="[email protected]") |
This file contains hidden or 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
@task | |
def install_elasticsearch(): | |
run( | |
'wget --no-check-certificate -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -') | |
run( | |
'echo "deb http://packages.elastic.co/elasticsearch/1.4/debian stable main" | sudo tee -a /etc/apt/sources.list') | |
run("sudo apt-get -qq update") | |
run("sudo apt-get -q upgrade -y") | |
run("sudo apt-get -q install -y openjdk-7-jre elasticsearch") | |
run("sudo update-rc.d elasticsearch defaults 95 10") |
This file contains hidden or 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
SEP_RE = re.compile(r'\n+-{5,}\n+') | |
def read_file(name): | |
with (pathlib.Path(__file__).parent / 'content' / '{}.md'.format( | |
name)).open() as f: | |
return f.read() | |
def get_item(txt): | |
md = markdown.Markdown(extensions=['markdown.extensions.meta']) | |
html = md.convert(txt) |
This file contains hidden or 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
# http://wsgi.tutorial.codepoint.net/environment-dictionary | |
# ================================================================= | |
# THE WSGI APPLICATION | |
# ================================================================= | |
def simple_app(environ, start_response): | |
status = '200 OK' | |
response_headers = [ | |
('Content-type', 'text/plain'), |
This file contains hidden or 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 bottle import route, run, template | |
@route('/hello/<name>') | |
def index(name): | |
return template('<b>Hello {{name}}</b>!', name=name) | |
if __name__ == "__main__": | |
run(debug=True, reloader=True) |
This file contains hidden or 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 requests | |
import secrets | |
URL = "https://graph.facebook.com/oauth/access_token" | |
r = requests.get(URL, { | |
'client_id': secrets.APP_ID, | |
'client_secret': secrets.APP_SECRET, | |
'grant_type': 'client_credentials', |
This file contains hidden or 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 pprint import pprint | |
import pymongo | |
client = pymongo.MongoClient() | |
db = client.get_database('socialagg') | |
# db = client['socialagg'] | |
pages = db.get_collection('pages') |
This file contains hidden or 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 pprint import pprint | |
import pymongo | |
client = pymongo.MongoClient() | |
db = client.get_database('socialagg') | |
# db = client['socialagg'] | |
pages = db.get_collection('pages') |
This file contains hidden or 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 python3 | |
import random | |
from PIL import Image | |
def main(source, target, cols, rows): | |
im = Image.open(source) | |
print("Original image size: {}x{}".format(*im.size)) | |
w, h = im.size |
This file contains hidden or 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 random | |
import datetime | |
import collections | |
import pymongo | |
client = pymongo.MongoClient() | |
db = client.get_database('udi123') |