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 dateutil import rrule | |
from datetime import datetime | |
def get_schedule_holidays_rrules(): | |
return [ | |
rrule.rrule(rrule.YEARLY, dtstart=datetime.now(), bymonth=1, bymonthday=1), # New Years | |
rrule.rrule(rrule.YEARLY, dtstart=datetime.now(), bymonth=5, byweekday=rrule.MO(-1)), # Memorial | |
rrule.rrule(rrule.YEARLY, dtstart=datetime.now(), bymonth=7, bymonthday=4), # Independence | |
rrule.rrule(rrule.YEARLY, dtstart=datetime.now(), bymonth=11, byweekday=rrule.TH(4)), # Thanksgiving | |
rrule.rrule(rrule.YEARLY, dtstart=datetime.now(), bymonth=12, bymonthday=25), # Christmas |
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
# NOTE This is probably no longer needed, now DRF does this | |
# automatically if you have ATOMIC_REQUESTS enabled. | |
# https://github.com/encode/django-rest-framework/pull/2887 | |
from django.db import transaction | |
class AtomicMixin(object): | |
""" | |
Ensures we rollback db transactions on exceptions. |
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.db.models import SubfieldBase | |
from django.core.exceptions import ImproperlyConfigured | |
from django_extensions.db.fields import ShortUUIDField | |
class XidField(ShortUUIDField): | |
""" | |
XID stands for external ID. | |
Randomly generated IDs (base62 encoded UUID) used for public display purposes. | |
The random ID gets a short textual prefix for improved legibility, like Stripe's IDs. |
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 BaseCommand | |
from django.db import transaction | |
from django.db.models import DateTimeField, DateField | |
from django.db.models.loading import get_models | |
class Command(BaseCommand): | |
help = """ | |
One-time use script prepping for SQL strict mode. | |
Iterates through all models and fixes invalid date/datetime fields. |
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
# Context https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/Spotify-Does-not-Import-m4a-Files/td-p/1022795 | |
# This ZSH script converts every .mp4 file in current folder to .m4a | |
# Note: you need to have ffmpeg installed | |
for file in $(echo **.mp4); do ffmpeg -i "$file" -acodec copy -movflags faststart "$file".m4a; done |