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
# coding=utf-8 | |
from __future__ import absolute_import | |
from boto3 import Session | |
from flask import current_app | |
from dodo.app import app | |
known_devices = { |
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 functools import wraps | |
from collections import namedtuple | |
from sqlalchemy.schema import Column | |
from sqlalchemy.sql import or_, expression as expr | |
from sqlalchemy.sql.expression import literal, ColumnClause | |
from sqlalchemy.types import String, Integer | |
from sqlalchemy.orm.query import Query | |
from sqlalchemy.orm.attributes import InstrumentedAttribute | |
from flask import request |
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
#Stack is LIFO(Last In First Out) | |
#Queue is FIFO(First In First Out) | |
import sys | |
stack = [] #Stack create | |
queue = [] #Queue create | |
def main(): | |
print '1. Insert Stack' | |
print '2. Delete Stack' |
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
(defmacro defentity [type args & body] | |
(let [name (docname type) | |
constructor (symbol (str type "/create")) | |
fn-get-by-id (symbol (str "get-" name "-by-id")) | |
fn-get (symbol (str "get-" name)) | |
fn-gets (symbol (str "get-" name "s")) | |
mc-with-col (symbol (str "with-" name "s"))] | |
`(do | |
(defrecord ~type ~args | |
~@body) |
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
(defmacro external-url-for [& args] | |
`(let [url# (url-for ~@args)] | |
(str (name (:scheme *request*)) | |
"://" | |
(:server-name *request*) | |
":" | |
(:server-port *request*) | |
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
(defprotocol IDocumentable | |
"Representable protocol for mongodb's document name" | |
(docname [e])) | |
(defprotocol IEntity | |
"Protocol of whole entity." | |
(add! [e]) | |
(edit! [e]) | |
(remove! [e])) |
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, render_template | |
app = Flask(__name__) | |
@app.route("/") | |
def index(): | |
return render_template("template.html", | |
msg="hello word") | |
if __name__ == "__main__": | |
for name in app.jinja_env.list_templates(): |
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
@admin.route('/stores/<place:place>/pdf') | |
def pdf_creation_request(place): | |
pdf_stream = place.get_pdf() | |
headers = {} | |
headers["Content-Disposition"] = u'attachment; filename="{0}.pdf"' \ | |
.format(place.name).encode("utf-8") | |
headers["Content-Type"] = "application/pdf" | |
headers["Cache-Control"] = "no-cache" | |
return Response(pdf_stream, headers=headers) |
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 jinja2.nodes import If, Getattr | |
def _find_all_permission_nodes(env, folder=admin.template_folder): | |
for name in env.list_templates(): | |
template = env.get_template(name) | |
filename = template.filename | |
if filename.find(folder) == -1: | |
continue |
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 reportlab.pdfgen import canvas | |
from reportlab.pdfbase import pdfmetrics | |
from reportlab.pdfbase.ttfonts import TTFont | |
pdfmetrics.registerFont(TTFont('avenir-demi', 'avenir-demi.ttf')) | |
pdfmetrics.registerFont(TTFont('avenir-regular', 'avenir-regular.ttf')) | |
pdfmetrics.registerFont(TTFont('yoon340', 'yoon340.ttf')) | |
c = canvas.Canvas("hello.pdf") |