Update: 2023/11/30 Bruce Momjian's take on things: https://momjian.us/main/blogs/pgblog/2023.html#November_22_2023
Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
from flask import Flask, request, session, url_for, redirect, \ | |
render_template, abort, g, flash | |
from werkzeug.contrib.sessions import Session, SessionStore | |
from cPickle import HIGHEST_PROTOCOL | |
from random import random | |
from flask import json | |
class MemcachedSessionStore(SessionStore): | |
def __init__(self, servers=None, key_prefix=None, default_timeout=300): |
# Public Domain, i.e. feel free to copy/paste | |
# Considered a hack in Python 2 | |
import inspect | |
def caller_name(skip=2): | |
"""Get a name of a caller in the format module.class.method | |
`skip` specifies how many levels of stack to skip while getting caller | |
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. |
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
import os | |
import sys | |
# Install venv by `virtualenv --distribute venv` | |
# Then install depedencies: `source venv/bin/active` | |
# `pip install -r requirements.txt` | |
activate_this = '/var/www/apache/csshat.com/csshat.com/venv/bin/activate_this.py' | |
execfile(activate_this, dict(__file__=activate_this)) | |
path = os.path.join(os.path.dirname(__file__), os.pardir) |
Update: 2023/11/30 Bruce Momjian's take on things: https://momjian.us/main/blogs/pgblog/2023.html#November_22_2023
Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
python_3_email_with_attachment.py | |
Created by Robert Dempsey on 12/6/14. | |
Copyright (c) 2014 Robert Dempsey. Use at your own peril. | |
This script works with Python 3.x | |
NOTE: replace values in ALL CAPS with your own values |
This gist contains lists of modules available in
in AWS Lambda.