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
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
# | |
# Use this file to build your own SSCCE | |
# SSCCE = Short, Self Contained, Correct (Compatible) Example | |
# see http://sscce.org/ | |
# | |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
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
import sqlparse | |
from sqlalchemy.dialects import postgresql as dialect_postgresql | |
# ------------------------------------------------------------------------------ | |
def print_query(q): | |
"""prints a sqlalchemy query""" | |
print "-" * 30 |
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
-- modified from http://stackoverflow.com/questions/6777456/get-the-list-all-index-names-its-column-names-and-its-table-name-of-a-postgresq | |
SELECT | |
idx.indrelid::regclass as indexed_tabled, | |
i.relname as index_name, | |
ARRAY( | |
SELECT pg_get_indexdef(idx.indexrelid, k + 1, true) | |
FROM generate_subscripts(idx.indkey, 1) as k | |
ORDER BY k | |
) as indkey_names | |
FROM pg_index as idx |
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 sqlalchemy import * | |
from sqlalchemy.orm import * | |
from sqlalchemy.ext.declarative import declarative_base | |
import sqlalchemy.exc | |
import pdb | |
from sqlalchemy.dialects import postgresql | |
INTERACTIVE = False |
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
CREATE TABLE stream_user( | |
id SERIAL PRIMARY KEY NOT NULL | |
); | |
CREATE TABLE resource( | |
id SERIAL PRIMARY KEY NOT NULL, | |
condition_1 BOOLEAN, | |
condition_2 BOOLEAN, | |
condition_3 BOOLEAN, | |
condition_4 BOOLEAN, | |
condition_5 BOOLEAN, |
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
import time | |
from sqlalchemy import event | |
from sqlalchemy.engine import Engine as SaEngine | |
from sqlalchemy.orm import Session as SaSession | |
logger = logging.getLogger("sqlalchemy.engine.base.Engine") | |
@event.listens_for(SaEngine, "before_cursor_execute") | |
def before_cursor_execute(conn, cursor, statement, |
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 sqlalchemy import * | |
from sqlalchemy.orm import * | |
from sqlalchemy.ext.declarative import declarative_base | |
import sqlalchemy.exc | |
import base64 | |
Base = declarative_base() | |
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
import bleach | |
sample_text = """<button class="navbar-toggle collapsed" data-target=".navbar-collapse" data-toggle="collapse" type="button"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button>""" | |
tags_ok = [ 'button', 'span', ] |
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
<% | |
## a list of available tabs | |
tabs_available = ['one', 'two', 'three'] | |
## create an 'empty' dict | |
tab_panes = dict([(i,'') for i in tabs_available]) | |
## what should be our selected tab | |
if request.tab_active and request.tab_active in tabs_available : | |
tab_selected = request.tab_active |
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
session.framework = beaker | |
session.key = SessionID | |
session.type = file | |
session.data_dir = %(here)s/data/ssessions/data | |
session.lock_dir = %(here)s/data/ssessions/lock | |
session.secret = 123 |