Skip to content

Instantly share code, notes, and snippets.

View aodag's full-sized avatar

Atsushi Odagiri aodag

View GitHub Profile
@aodag
aodag / myenv.py
Created October 26, 2013 05:26
pyvenv, setuptools, pip
#!/usr/bin/python3
import argparse
import os
import subprocess
import sys
import tempfile
import urllib.request
import venv
setuptools_version = "1.1.6"
@aodag
aodag / guestbook.py
Last active December 26, 2015 15:29
guestbook作ってみた!
# -*- coding: utf-8 -*-
import os
from datetime import datetime
from babel.dates import format_datetime
import sqlalchemy as sa
import sqlalchemy.orm as orm
from sqlalchemy.ext.declarative import declarative_base
from zope.sqlalchemy import ZopeTransactionExtension
[buildout]
extensions = mr.developer
parts = zope2
instance
zopeskel
extends = http://download.zope.org/Zope2/index/2.13.20/versions.cfg
[sources]
;guestbook = fs guestbook
@aodag
aodag / guestbook.py
Last active December 26, 2015 23:58
TurboGears2で作ったやつです
import os
from datetime import datetime
from babel.dates import format_datetime
from markupsafe import escape, Markup
from tg import expose, TGController, AppConfig, redirect
import sqlalchemy as sa
import sqlalchemy.orm as orm
@aodag
aodag / base.cfg
Created November 5, 2013 14:58
circusデーモン、開発サーバー、テスト、ドキュメンテーションとかのひとまとめな zc.buildout用のベース設定
[app]
recipe = zc.recipe.egg
eggs = ${eggs:main}
pyramid
interpreter = py
[dev-app]
recipe = zc.recipe.egg
eggs = ${eggs:main}
@aodag
aodag / base.cfg
Last active December 27, 2015 11:39
[app]
recipe = zc.recipe.egg
eggs = ${eggs:main}
interpreter = py
[paster_ini]
recipe = z3c.recipe.template
input = production.ini.in
output = ${buildout:parts-directory}/etc/production.ini
@aodag
aodag / pypa.py
Last active December 31, 2015 02:49
ainsible module to install setuptools and pip.
# -*- coding: utf-8 -*-
"""
install setuptools, pip, virtualenv
- ez_setup.py
- get-pip.py
"""
import re
@aodag
aodag / get-pip-session
Created January 21, 2014 04:49
ez_setup.py がいらなくなりました
$ python get-pip.py
Downloading/unpacking pip
Using download cache from /home/aodag/.pip/eggs/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fpy2.py3%2Fp%2Fpip%2Fpip-1.5.1-py2.py3-none-any.whl
Downloading/unpacking setuptools
Downloading setuptools-2.1-py2.py3-none-any.whl (540kB): 540kB downloaded
Storing download in cache at /home/aodag/.pip/eggs/https%3A%2F%2Fpypi.python.org%2Fpackages%2F3.4%2Fs%2Fsetuptools%2Fsetuptools-2.1-py2.py3-none-any.whl
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...
@aodag
aodag / asyncweb.py
Created February 2, 2014 14:09
asyncio + tornado.web python3.3以上で実行できます
import tornado.web
from tornado.platform.asyncio import AsyncIOMainLoop
import asyncio
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello")
@aodag
aodag / consolehello.py
Created February 18, 2014 13:00
asyncio + aiohttpでwsgiアプリケーションを実行。せっかくなのでexecutorを使ってコンソール入力をレスポンスで表示とか。python3.4.0b1
import logging
import asyncio
from aiohttp.wsgi import WSGIServerHttpProtocol
logger = logging.getLogger(__name__)
def index(environ, start_response):
logger.info("GET")
start_response("200 OK",
[('Content-type', 'text/plain')])