import pandas as pd
import numpy as np
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db.models.expressions import CombinedExpression, F, Value | |
| from django.contrib.postgres.fields import JSONField | |
| expression = CombinedExpression( | |
| F('my_json_field'), | |
| '||', | |
| Value({'fizz': 'buzz'}, JSONField()) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # On Linux we can use native GNU time, on OSX we have to install gnu-time | |
| # manually, since native time doesn't measure memory. | |
| # http://man7.org/linux/man-pages/man1/time.1.html | |
| # http://braumeister.org/formula/gnu-time | |
| $ brew install gnu-time | |
| # can be called via gtime, since time is a bash command | |
| # %M - Maximum resident set size of the process during its lifetime, in Kbytes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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 = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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 |
- Django 1.9 application with two databases:
- Legacy database with readonly access via unmanaged models. Both Django models (models.py) and related migrations have "managed" set to
False'managed': False
- Default database holding django specific tables (e.g. auth_user, django_content_type, etc)
- Legacy database with readonly access via unmanaged models. Both Django models (models.py) and related migrations have "managed" set to
- For testing I want to re-create the legacy database tables. In other words, during
python manage.py test, tell Django to set "managed" toTrue- There are several excellent blog posts on how to set "managed" to
Trueduring tests:
- There are several excellent blog posts on how to set "managed" to
- http://blog.birdhouse.org/2015/03/25/django-unit-tests-against-unmanaged-databases/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
