Skip to content

Instantly share code, notes, and snippets.

/* psql -E to see internal queries */
CREATE TEMP TABLE temp_objects AS
SELECT c.oid
,n.nspname
,c.relname
,c.relkind
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE 1=1
"""
module mydjangolib.bigint_patch
A fix for the rather well-known ticket #399 in the django project.
Create and link to auto-incrementing primary keys of type bigint without
having to reload the model instance after saving it to get the ID set in
the instance.
Logs:
import celery
from sorl.thumbnail import default
from sorl.thumbnail.images import ImageFile
from sorl.thumbnail.parsers import parse_geometry
from thumbnail import CustomBackend
backend = CustomBackend()
from time import time
from functools import wraps
MINUTE = 60
HOUR = MINUTE * 60
DAY = HOUR * 24
class Metrics(object):
def __init__(self, redis, keyspace='metrics'):
self.db = redis
@MikeVL
MikeVL / setup.sql
Created November 21, 2012 20:12 — forked from imperialwicket/setup.sql
PostgreSQL monthly table partitions
--
-- Setup - Add plpgsql, create a parent table, create an initial child table,
-- create the trigger and the initial trigger function.
--
-- We'll need plpgsql, so create it in your db if it's not already available.
CREATE LANGUAGE plpgsql;
-- Create a table to act as parent with the appropriate columns for your data.
CREATE TABLE my_schema.my_data (name varchar(24), create_date timestamp);