Skip to content

Instantly share code, notes, and snippets.

View UnknownPlatypus's full-sized avatar
🧗‍♂️

Thibaut Decombe UnknownPlatypus

🧗‍♂️
View GitHub Profile
headers = {
'Cache-Control':'max-age=604800', # 60 x 60 x 24 x 7 = 1 week
'Content-Type':content_type,
}
k = Key(self.get_bucket())
k.key = filename
k.set_contents_from_string(contents.getvalue(), headers)
if self.public: k.make_public()
TryMultipleViews.__code__ = TryMultipleViews.__call__.__code__
TryMultipleViews.__closure__ = TryMultipleViews.__call__.__closure__
egrep 'model_name=".*",' <file> | grep -o '".*"' |sort -u > m.txt
sed -i '$!s/$/,/' m.txt
pm makemigrations --empty extended_tag --name data_migration_image_fields
# Grep thing starting with
grep -oP 'name: "\K\w+' cron.yaml
import logging
logger = logging.getLogger("mysite.profiling")
# mysite/forms/fields/sg_or_image_field.py
logger.debug(f"SVG: {repr(self)} - field:{self.field} ")
# django/core/files/images.py
logger.debug(f"IMG: {repr(file_or_path)} - field:{file_or_path.field} ")
(function(){
var i = document.querySelector('#djdt-flamegraph-iframe');
var tpl = document.querySelector('#djdt-flamegraph-tpl');
i.contentWindow.document.write(tpl.innerHTML);
}())
.moving-pack__header--new {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
input.hw-checkbox:checked + label:before {
background: #039DE0 url('../../img/tick-white.svg') no-repeat center/80%;
border-color: #039DE0;
}
from django import forms
from django.db import models
from django.utils.translation import gettext_lazy as _
class RenovationConfirmationContent(models.Model):
faq_title = models.CharField(max_length=191)
faqCategory = models.ForeignKey("content.faq")
def clean(self):
if self.faqCategory and not self.faq_title:
from django.db import models
from django.forms import Textarea
class HowToItemInline(admin.StackedInline):
# All fields of a particular type
formfield_overrides = {
models.TextField: {"widget": Textarea(attrs={"rows": 1, "cols": 80})},
}
# Specific fields