Size of Postgres database:
SELECT pg_size_pretty( pg_database_size('dbname') );
Size of Postgres table:
from django.db.models import Lookup | |
from django.db.models.fields import Field | |
@Field.register_lookup | |
class NotEqual(Lookup): | |
lookup_name = 'ne' | |
def as_sql(self, compiler, connection): | |
lhs, lhs_params = self.process_lhs(compiler, connection) | |
rhs, rhs_params = self.process_rhs(compiler, connection) |
{ | |
"title": "My Finder", | |
"rules": [ | |
{ | |
"description": "Change Command-Q to Command-W in Finder", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "q", |
from django.apps import apps | |
for _class in apps.get_models(): | |
globals()[_class.__name__] = _class |
local hyper = {"cmd", "alt", "ctrl", "shift"} | |
local applicationHotkeys = { | |
e = 'Google Chrome', | |
t = 'iTerm2', | |
s = 'Slack', | |
x = 'Xcode', | |
v = 'VS Code', | |
p = 'System Preferences', | |
f = 'Firefox', |
# C-X C-R reload | |
set convert-meta off | |
set bell-style none | |
set mark-symlinked-directories on | |
#TAB: menu-complete | |
"\e[Z": "\e-1\C-i" | |
set colored-stats on | |
"\e[5~": history-search-backward | |
"\e[6~": history-search-forward |
class RenameFieldsSerializerMixin(object): | |
def rename_field_from(self, name): | |
return name.upper() | |
def rename_field_to(self, name): | |
return name.lower() | |
def to_internal_value(self, data): | |
instance = super().to_internal_value(data) | |
new_data = OrderedDict() |
class ReadWriteMethodField(fields.Field): | |
""" Read and write method field for DFR """ | |
def __init__(self, field_type=fields.Field, get_method_name=None, put_method_name=None, **kwargs): | |
self.field_type = field_type | |
self.get_method_name = get_method_name | |
self.put_method_name = put_method_name | |
self._field = field_type(**kwargs) | |
kwargs['read_only'] = False | |
kwargs['source'] = '*' | |
super(ReadWriteMethodField, self).__init__(**kwargs) |
from stdimage.utils import UploadToUUID | |
class UploadTo(UploadToUUID): | |
""" | |
Creates path file like `path/abc/abcdefabcdefabcdefabcdefabcdefab.ext` | |
""" | |
path_pattern = os.path.join('%(path)s', '%(name).3s') |
/** | |
* Wrap gulp streams into fail-safe function for better error reporting | |
* Usage: | |
* gulp.task('less', wrapPipe(function(success, error) { | |
* return gulp.src('less/*.less') | |
* .pipe(less().on('error', error)) | |
* .pipe(gulp.dest('app/css')); | |
* })); | |
*/ |