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(),
...
);
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(),
...
);
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french ); | |
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING | |
FOR hword, hword_part, word WITH unaccent, french_stem; | |
CREATE TEXT SEARCH CONFIGURATION en ( COPY = english ); | |
ALTER TEXT SEARCH CONFIGURATION en ALTER MAPPING | |
FOR hword, hword_part, word WITH unaccent, english_stem; | |
CREATE TEXT SEARCH CONFIGURATION de ( COPY = german ); | |
ALTER TEXT SEARCH CONFIGURATION de ALTER MAPPING |
uWSGI logging configuration that could be used with central logging servers such as Logstash, Fluentd, etc.
[uwsgi]
project = some_project
...
# file: prefix is required for req-logger
req-logger = file:/var/log/%(project)/%(project)_access.log
log-format = "method": "%(method)", "uri": "%(uri)", "proto": "%(proto)", "status": %(status), "referer": "%(referer)", "user_agent": "%(uagent)", "remote_addr": "%(addr)", "http_host": "%(host)", "pid": %(pid), "worker_id": %(wid), "core": %(core), "async_switches": %(switches), "io_errors": %(ioerr), "rq_size": %(cl), "rs_time_ms": %(msecs), "rs_size": %(size), "rs_header_size": %(hsize), "rs_header_count": %(headers)
from rest_framework.permissions import BasePermission | |
class IsAjaxPermission(BasePermission): | |
""" | |
Check is request is ajax. | |
""" | |
def has_object_permission(self, request, view, obj): | |
return request.is_ajax() |
# coding:utf-8 | |
import gc | |
import inspect | |
import weakref | |
from django.core.management.base import BaseCommand, CommandError | |
from django.dispatch import Signal | |
from django.dispatch.weakref_backports import WeakMethod | |
from optparse import make_option |
False
'managed': False
python manage.py test
, tell Django to set "managed" to True
True
during tests:#! /usr/bin/env python3 | |
"""Fixing bluetooth stereo headphone/headset problem in debian distros. | |
Workaround for bug: https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197 | |
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone. | |
This will be only fixes the bluez5 problem mentioned above . | |
Licence: Freeware |
# -*- coding: utf-8 -*- | |
# XXX this is actually useful for very special use cases, e.g. misspel suggestions: | |
# https://www.postgresql.org/docs/9.6/static/pgtrgm.html#AEN180626 | |
from __future__ import unicode_literals | |
from django.db import migrations | |
from django.contrib.postgres.operations import TrigramExtension | |
class Migration(migrations.Migration): | |
operations = [ |
""" | |
License: MIT - https://opensource.org/licenses/MIT | |
ChromeLogger is a protocol which allows sending logging messages to the Browser. | |
This module implements simple support for Django. It consists of two components: | |
* `LoggingMiddleware` which is responsible for sending all log messages | |
associated with the request to the browser. | |
* `ChromeLoggerHandler` a python logging handler which collects all messages. |