This file contains 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
class MyModel(models.Model): | |
name = models.CharField() | |
objects: models.QuerySet["MyModel"] | |
MyModel.objects.filter().first() |
This file contains 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
def pytest_configure(config): | |
config.addinivalue_line( | |
"markers", "enable_inline_css: run css postprocessing over generated emails" | |
) | |
@pytest.fixture(autouse=True) | |
def disable_inline_css(request, monkeypatch): | |
if "enable_inline_css" in request.keywords: | |
return |
This file contains 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
#!/bin/bash | |
# ~/.osx — http://mths.be/osx | |
# Close any open System Preferences panes, to prevent them from overriding | |
# settings we’re about to change | |
osascript -e 'tell application "System Preferences" to quit' | |
# Ask for the administrator password upfront |
This file contains 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
import pickle | |
import six | |
from django_redis.serializers.pickle import PickleSerializer | |
def compat_pickle_loads(value, **kwargs): | |
if six.PY2: | |
return _py2_pickle_loads(value) | |
return _py3_pickle_loads(value, **kwargs) | |
This file contains 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.core.management import call_command | |
from django.test import TestCase | |
class MigrationsTestCase(TestCase): | |
def test_no_outstanding_migrations(self): | |
"""No migrations need to be generated""" | |
try: | |
result = call_command("makemigrations", "--dry-run", "--check", "--no-input", "-v", "0") | |
except SystemExit: | |
self.fail("There were outstanding migrations") |
This file contains 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
#! /bin/bash | |
# This script reads rabbitmq statistics and report them as CloudWatch metrics. | |
# https://gist.github.com/GoodMirek/2dc39100d18c72eed3f0f3569e221f4f | |
# RabbitMQ::messages_ready | |
# RabbitMQ::messages_unacknowledged | |
# RabbitMQ::consumers | |
# Dimensions: QueueName, InstanceId, VHost |
This file contains 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
import functools | |
from django.conf import settings | |
from django.dispatch import receiver | |
def suspendingreceiver(signal, **decorator_kwargs): | |
""" | |
A wrapper around the standard django receiver that prevents the receiver | |
from running if the setting `SUSPEND_SIGNALS` is `True`. |
This file contains 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
module: { | |
rules: [ | |
// ... | |
// Rules for Style Sheets | |
{ | |
test: /\.(scss|sass)$/, | |
include: [path.resolve(__dirname, 'src'), path.resolve(__dirname, 'assets/scss')], | |
use: extractSass.extract({ | |
use: [ | |
// Process internal/project styles (from assets/scss folder) |
This file contains 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 -*- | |
from __future__ import absolute_import, print_function, unicode_literals | |
import time | |
from contextlib import contextmanager | |
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache | |
from django.utils.synch import RWLock | |
from lru import LRU # dependency: pip install lru-dict |
This file contains 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
// debug config for running project under vscode debugger | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"trace": true, | |
"name": "Chrome Debug", | |
"type": "chrome", | |
"request": "launch", | |
"url": "http://localhost:8000/", |
NewerOlder