Please publicly post the following Gist, and name it keybase.md
I hereby claim:
- I am alexanderjulo on github.
- I am alexanderjulo (https://keybase.io/alexanderjulo) on keybase.
- I have a public key ASApykm6Lzuffp-X-V2GUOg_Nmq-mhb5zkQI0fpCxE-WGAo
# coding: utf8 | |
languages = [ | |
('aa', 'Afar'), | |
('ab', 'Abkhazian'), | |
('af', 'Afrikaans'), | |
('ak', 'Akan'), | |
('sq', 'Albanian'), | |
('am', 'Amharic'), | |
('ar', 'Arabic'), |
Please publicly post the following Gist, and name it keybase.md
I hereby claim:
from celery.schedules import crontab | |
from flask.ext.celery import Celery | |
CELERYBEAT_SCHEDULE = { | |
# executes every night at 4:15 | |
'every-night': { | |
'task': 'user.checkaccounts', | |
'schedule': crontab(hour=4, minute=20) | |
} | |
} |
class with_request_context(object): | |
def __init__(self, f, app=None, request=None): | |
self.f = f | |
if app: | |
self.app = app | |
else: | |
self.app = www | |
if request: | |
self.request = request |
from werkzeug.datastructures import OrderedMultiDict | |
from wtforms import widgets, ValidationError | |
from wtforms.compat import text_type | |
from wtforms.ext.sqlalchemy.fields import QuerySelectMultipleField | |
class GroupedSelectMultipleWidget(widgets.Select): | |
""" | |
Renders a select field with groups. Expects a list of tuples when | |
calling `field.iter_choices()`. |
select.form-control + .chosen-container.chosen-container-single .chosen-single { | |
display: block; | |
width: 100%; | |
height: 34px; | |
padding: 6px 12px; | |
font-size: 14px; | |
line-height: 1.428571429; | |
color: #555; | |
vertical-align: middle; | |
background-color: #fff; |
from flask import Flask | |
from celery import Celery | |
def create_app(): | |
app = Flask(__name__) | |
TaskBase = celery.Task | |
class Task(TaskBase): |
def find_common(*user_ids): | |
queries = [] | |
for user_id in user_ids: | |
query = db.session.query(participants.c.thread_id) \ | |
.filter(participants.c.user_id==user_id) | |
queries.append(query) | |
thread_ids = [r[0] for r in db.session.query(participants.c.thread_id) \ | |
.intersect(*queries).all()] | |
threads = Thread.query.filter(Thread.id.in_(thread_ids)).all() | |
return threads |
@celery.task(name='questionnaire.suitability') | |
@with_request_context | |
def questionnaire_suitability(uid, suitable, treatment, explanation): |
% python test.py | |
teardown request. | |
teardown app context. | |
% |