Magic words:
psql -U postgres
If run with -E
flag, it will describe the underlaying queries of the \
commands (cool for learning!).
Most \d
commands support additional param of __schema__.name__
and accept wildcards like *.*
# In case of SSL errors in Python requests library: | |
# (myenv)$ pip install certifi | |
# Then add the following to your Django settings: | |
import os, certifi | |
os.environ['REQUESTS_CA_BUNDLE'] = certifi.where() |
/** | |
* Add CSS rules dynamically | |
* Example: | |
* dyn_css_rule("#menu li:hover", "color: red") | |
*/ | |
window.dyn_css_rule = function(sSelector, sCssText) { | |
try { | |
var aSS = document.styleSheets; | |
var i; | |
for (i=aSS.length-1; i>=0; i--) { |
# -*- coding: UTF-8 -*- | |
from django.contrib import admin | |
from django.core.urlresolvers import reverse | |
from django.utils.translation import ugettext_lazy as _ | |
from django.utils.text import force_text | |
from .models import Painter, Picture, Review | |
def get_picture_preview(obj): | |
if obj.pk: # if object has already been saved and has a primary key, show picture preview |
#! /usr/bin/env bash | |
SECONDS=0 | |
PROJECT_PATH=/home/example | |
CRON_LOG_FILE=${PROJECT_PATH}/logs/backup_db.log | |
BACKUP_PATH=${PROJECT_PATH}/db_backups/$(LC_ALL=en_US.UTF-8 date +"%w-%A").sql | |
USER=dbusername | |
DATABASE=dbname | |
PASS=dbpassword | |
EXCLUDED_TABLES=( |
#!/usr/bin/env bash | |
SECONDS=0 | |
PROJECT_PATH=/home/myproject | |
CRON_LOG_FILE=${PROJECT_PATH}/logs/cleanup.log | |
echo "Cleaning up the database" > ${CRON_LOG_FILE} | |
date >> ${CRON_LOG_FILE} | |
cd ${PROJECT_PATH} | |
source bin/activate |
# -*- coding: UTF-8 -*- | |
from __future__ import unicode_literals | |
import shortuuid | |
from django.conf import settings | |
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
RANDOM_UNIQUE_ID_LENGTH = getattr(settings, "RANDOM_UNIQUE_ID_LENGTH", 12) |
# -*- coding: UTF-8 -*- | |
from __future__ import unicode_literals | |
from ._base import * | |
# ... | |
class DisabledMigrations(object): | |
def __contains__(self, item): | |
return True | |
def __getitem__(self, item): |
{% blocktrans with username=request.user.username link=request.user.get_url_path css_class="btn btn-link" %} | |
Hello <a href="{{ link }}" class="{{ css_class }}">{{ username }}</a>! | |
{% endblocktrans %} |
SetEnvIf User-Agent ^VipAgent1 vip_agent | |
SetEnvIf User-Agent ^VipAgent2 vip_agent | |
Order Allow,Deny | |
Allow from env=vip_agent | |
AuthType Basic | |
AuthName "Protected Login" | |
AuthUserFile /path/to/htpasswd | |
Require valid-user |