Skip to content

Instantly share code, notes, and snippets.

View fdemmer's full-sized avatar
🌱
developing

Florian Demmer fdemmer

🌱
developing
  • Vienna, Austria
  • 07:21 (UTC +02:00)
View GitHub Profile
@fdemmer
fdemmer / LICENSE
Last active March 6, 2021 19:00
This license applies to all public gists https://gist.github.com/fdemmer/
MIT License
Copyright (c) 2017-2021 Florian Demmer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@fdemmer
fdemmer / celery-tzcron.py
Last active May 15, 2019 09:20
Alternative crontab schedule for Celery
import logging
import pytz
import six
import tzcron
from kombu.utils import cached_property
from pytz import AmbiguousTimeError, NonExistentTimeError
from celery import schedules
from celery.utils.time import is_naive
@fdemmer
fdemmer / synology.md
Last active October 22, 2023 12:09
Random notes about my Synology NAS

user has no home: Could not chdir to home directory /var/services/homes/admin: No such file or directory

Enable the "user home service" in Control Panel - User - Advanced (at the very bottom)

rsync does not work: Permission denied, please try again.

Trying to sync files to the NAS like this:

$ rsync -av ./<src-dir>/ admin@<dest-ip>:/<dest-dir>/
@fdemmer
fdemmer / switch_language.py
Last active January 6, 2018 15:21
a django template tag to switch/link the current django or wagtail view/url to another language
# example usage:
#
# {% if request.LANGUAGE_CODE == 'de' %}
# <a href="{% switch_language 'en' %}">English</a>
# {% else %}
# <a href="{% switch_language 'de' %}">Deutsch</a>
# {% endif %}
#
@register.simple_tag(takes_context=True)
@fdemmer
fdemmer / s3sqlite.py
Created October 20, 2017 18:16
Django SQLite database backend storing the db file on s3.
# -*- coding: utf-8 -*-
import logging
import os
from tempfile import gettempdir
import boto3
import botocore
from django.db.backends.sqlite3.base import DatabaseWrapper
log = logging.getLogger(__name__)
server {
listen *:80 default;
server_name _;
location / {
client_max_body_size 1G;
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

Keybase proof

I hereby claim:

  • I am fdemmer on github.
  • I am fdemmer (https://keybase.io/fdemmer) on keybase.
  • I have a public key ASCiBr9zi9OQD16UTcnY22aXZV6tXFeGaktjSocFWUD0_Qo

To claim this, I am signing this object:

@fdemmer
fdemmer / marshmallow_query_param_parser.py
Last active July 23, 2016 10:58
Using marshmallow to parse/validate query parameters with a mixin for Django views
# -*- coding: utf-8 -*-
from marshmallow import Schema, fields
from django.utils.functional import cached_property
class ParameterMixin(object):
"""
Mixin for a View-like class for URL parameter parsing and validation using
marshmallow (works well with Django views or DRF ViewSets).
@fdemmer
fdemmer / tornadofront.py
Last active September 16, 2015 16:41
Very primitive simulation of a caching cdn like cloudfront.
# -*- coding: utf-8 -*-
"""
Very primitive simulation of a caching cdn like cloudfront.
"""
import logging
import requests
import sys
from concurrent.futures import ThreadPoolExecutor
from functools import partial
from urlparse import urlunparse
@fdemmer
fdemmer / logging_basicconfig.py
Created September 9, 2015 18:45
Configure basic logging for stdout in scripts or quick and dirty stuff...
import logging
import sys
logging.basicConfig(
stream=sys.stdout,
level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(name)s %(funcName)s(%(lineno)d): %(message)s'
)