Skip to content

Instantly share code, notes, and snippets.

Alexander Jung-Loddenkemper alexanderjulo

Block or report user

Report or block alexanderjulo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Please publicly post the following Gist, and name it

Keybase proof

I hereby claim:

  • I am alexanderjulo on github.
  • I am alexanderjulo ( on keybase.
  • I have a public key ASApykm6Lzuffp-X-V2GUOg_Nmq-mhb5zkQI0fpCxE-WGAo
alexanderjulo /
Created Nov 25, 2015
flask application factory with celery
from flask import Flask
from celery import Celery
def create_app():
app = Flask(__name__)
TaskBase = celery.Task
class Task(TaskBase):
alexanderjulo /
Last active Aug 29, 2015
Customized WTForms widget for Selects with Chosen
import json
from wtforms.widgets import Select, HTMLString
class ChosenSelect(Select):
def __init__(self, multiple=False, renderer=None, options={}):
Initiate the widget. This offers you two general options.
First off it allows you to configure the ChosenSelect to
alexanderjulo /
Created Jan 24, 2014
A GroupedQuerySelectMultipleField for wtforms. Will create a select with optgroups of selects using a sqlalchemy backed query. Basically a QuerySelectMultipleField with grouping support.
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()`.
View chosen-bootstrap.css
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;
alexanderjulo /
Created Dec 4, 2012
find common elements in in a many-to-many helper table
def find_common(*user_ids):
queries = []
for user_id in user_ids:
query = db.session.query(participants.c.thread_id) \
thread_ids = [r[0] for r in db.session.query(participants.c.thread_id) \
threads = Thread.query.filter(
return threads
alexanderjulo / gist:4073388
Created Nov 14, 2012
Python Tuple Lists with language codes (as of ISO 639-1) and country codes (as of ISO 3166)
View gist:4073388
languages = [
('aa', 'Afar'),
('ab', 'Abkhazian'),
('af', 'Afrikaans'),
('ak', 'Akan'),
('sq', 'Albanian'),
('am', 'Amharic'),
('ar', 'Arabic'),
('an', 'Aragonese'),
('hy', 'Armenian'),
def questionnaire_suitability(uid, suitable, treatment, explanation):
View output
% python
teardown request.
teardown app context.
alexanderjulo /
Created Sep 1, 2012
with request context decorator
class with_request_context(object):
def __init__(self, f, app=None, request=None):
self.f = f
if app: = app
else: = www
if request:
self.request = request
You can’t perform that action at this time.