- 24
- Battlestar Galactica
- Black Sails
- Breaking Bad
- Broadchurch
- Bron/Broen
- Community
-
Daredevil - Dead Like Me
- Death Note
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
# ... | |
[tool.mypy] | |
plugins = [ | |
"mypy_django_plugin.main", | |
] | |
python_version = "3.10" | |
check_untyped_defs = true | |
no_implicit_optional = true | |
warn_redundant_casts = 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
CREATE OR REPLACE FUNCTION pg_temp.get_scores(skip_days int) RETURNS TABLE ( | |
"user" varchar(60), | |
first_game_id int, | |
nb_games int, | |
first_game_day date, | |
nb_played_days int, | |
nb_expected_days int, | |
nb_missing_days int, | |
final_score float, | |
regularity_factor float, |
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
""" | |
Sometimes in your Django model you want to raise a ``ValidationError`` in the ``save`` method, for | |
some reason. | |
This exception is not managed by Django Rest Framework because it occurs after its validation | |
process. So at the end, you'll have a 500. | |
Correcting this is as simple as overriding the exception handler, by converting the Django | |
``ValidationError`` to a DRF one. | |
""" | |
from django.core.exceptions import ValidationError as DjangoValidationError |
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 expect a image file as first argument, and a destination directory as second. | |
# It will: | |
# - rotate the image 0.4deg | |
# - crop to a ratio for HD (1920*1080) | |
# - add the timestamp in the top right corner | |
# This timestamp is in the format "xXh yYm", and computed from a time of the day extracted from the first image | |
# of the directory. All images are the same day, so it's easier. | |
# It's printed in white with a soft black shadow. |
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
# Clean the sky: remove birds, planes... only work if each images are "close", and there is no cloud moving fast | |
# by @twidi | |
import glob, os, shutil, sys | |
from gimpfu import * | |
def run(source_dir='.', extension='JPG', threshold=30, mask=None, dest_dir=None): | |
""" |
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
# Real name of this file is README.rst but I don't want github to render the rst ;) | |
Blah blah blah | |
.. testsetup:: | |
# This prepare the django environment to run all the "testcode" in this file | |
# This is not visible in the rendered README | |
import os |
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
In [1]: from itertools import chain | |
In [2]: from collections import Counter | |
In [3]: x = [[True, False, True], [True]] | |
In [4]: y = list(chain.from_iterable(x)) | |
In [5]: c = Counter(y) |
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
"""A DB backend, based on ``django.db.backends.postgresql_psycopg2`` to cover a specific needs. | |
The need is to add the "DEFERRABLE INITIALLY DEFERRED" when defining a unique constraint | |
on `sort_order` fields, to make the ``Orderable`` base model works correctly. | |
""" |
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 Hashable(models.Model): | |
hash_method_prefix = 'compute_hash_' | |
default_hash_method = 'compute_hash_default' | |
hashable_fields = [] | |
class Meta: | |
abstract = True | |
def compute_hash_default(self, field_name, hash_function): |
NewerOlder