Add this in your ini file:
[alembic:exclude]
tables = spatial_ref_sys
In env.py
:
import re
<!-- | |
Use this snippet to add a google map location chooser to your form | |
Step 1: Get a google map api key and insert it in the first javascript tag | |
Step 2: In your html form, create two hidden elements, one for latitude, and one for longitude. Give the elements ids and set the LATITUDE_ELEMENT_ID and LONGITUDE_ELEMENT_ID to the appropriate variables | |
Done! | |
--> |
<?PHP | |
// Generates a strong password of N length containing at least one lower case letter, | |
// one uppercase letter, one digit, and one special character. The remaining characters | |
// in the password are chosen at random from those four sets. | |
// | |
// The available characters in each set are user friendly - there are no ambiguous | |
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option, | |
// makes it much easier for users to manually type or speak their passwords. | |
// | |
// Note: the $add_dashes option will increase the length of the password by |
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
## widget | |
import httplib2 | |
from urllib import urlencode | |
import colander | |
from colander import null | |
from colander import Invalid | |
from deform.widget import CheckedInputWidget |
input { | |
height: 34px; | |
width: 100%; | |
border-radius: 3px; | |
border: 1px solid transparent; | |
border-top: none; | |
border-bottom: 1px solid #DDD; | |
box-shadow: inset 0 1px 2px rgba(0,0,0,.39), 0 -1px 1px #FFF, 0 1px 0 #FFF; | |
} |
# -*- encoding: UTF-8 -*- | |
import smtplib | |
import json | |
from email.mime.text import MIMEText | |
MAILGUN_SMTP_LOGIN = "postmaster@revolunet.mailgun.org" | |
MAILGUN_SMTP_PASSWORD = "secret" | |
def send_message_via_smtp(from_, to, mime_string): |
def query2sql(query): | |
"""convert query object into non-prepared sql string in SQLAlchemy and psycopg2""" | |
compiler = query.statement.compile() | |
params = compiler.params | |
prepared_sql = compiler.string # or str(compiler) | |
psycopg2_cursor = query.session.connection().connection.cursor() | |
sql = psycopg2_cursor.mogrify(prepared_sql, params) | |
return sql |
Add this in your ini file:
[alembic:exclude]
tables = spatial_ref_sys
In env.py
:
import re
def get_count(q): | |
count_q = q.statement.with_only_columns([func.count()]).order_by(None) | |
count = q.session.execute(count_q).scalar() | |
return count | |
q = session.query(TestModel).filter(...).order_by(...) | |
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ... | |
print q.count() |
import psycopg2.extras | |
import sqlalchemy.dialects.postgresql | |
from sqlalchemy.types import TypeEngine | |
from sqlalchemy.types import String | |
from sqlalchemy.types import TypeDecorator | |
import uuid | |
# Required for PostgreSQL to accept UUID type. | |
psycopg2.extras.register_uuid() |