Skip to content

Instantly share code, notes, and snippets.

View LowerDeez's full-sized avatar
🇺🇦
Focusing

Oleg Kleshchunov LowerDeez

🇺🇦
Focusing
  • Kyiv, Ukraine
  • 05:07 (UTC +02:00)
View GitHub Profile
@darklow
darklow / celery_tasks_error_handling.py
Last active October 1, 2025 05:52
Celery tasks error handling example
from celery import Task
from celery.task import task
from my_app.models import FailedTask
from django.db import models
@task(base=LogErrorsTask)
def some task():
return result
class LogErrorsTask(Task):
@johtso
johtso / gist:5881137
Last active February 18, 2021 18:37
Django Rest Framework underscore <-> camelcase conversion
import re
from rest_framework import serializers, renderers, parsers
class JSONRenderer(renderers.JSONRenderer):
def render(self, data, *args, **kwargs):
if data:
data = recursive_key_map(underscore_to_camelcase, data)
return super(JSONRenderer, self).render(data, *args, **kwargs)
@bradmontgomery
bradmontgomery / week_range.py
Created March 7, 2013 19:27
Given a Date, calculate the first/last dates for the week. This assumes weeks start on Sunday and end on Saturday (common in the US).
from datetime import timedelta
def week_range(date):
"""Find the first & last day of the week for the given day.
Assuming weeks start on Sunday and end on Saturday.
Returns a tuple of ``(start_date, end_date)``.
"""
@sweenzor
sweenzor / gist:2933958
Created June 15, 2012 00:52
Kill all celery tasks (redis)
# nuke the queue
redis-cli FLUSHALL
# nuke anything currently running
pkill -9 celeryd
@formido
formido / bas64 sha1 encode
Created February 10, 2011 18:11
python: base 64 encode the sha1 hash of a string
>>> import base64
>>> import hashlib
>>> base64.b64encode(hashlib.sha1("test").digest())
'qUqP5cyxm6YcTAhz05Hph5gvu9M='