Skip to content

Instantly share code, notes, and snippets.

Patrick Kranzlmueller sehmaschine

Block or report user

Report or block sehmaschine

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sehmaschine
sehmaschine / now.json
Created Jul 4, 2019
Custom 404 with Gatsby and Now
View now.json
{
"version": 2,
"name": "xxx",
"builds": [
{
"src": "package.json",
"use": "@now/static-build",
"config": { "distDir": "public" }
}
],
@sehmaschine
sehmaschine / related.py
Created Sep 7, 2017
ModelAdmin.get_queryset with django-grappelli
View related.py
@sehmaschine
sehmaschine / models.py
Created Nov 23, 2015
Signals for FileBrowseUploadField
View models.py
from apps.images.signals import image_callback
def entry_upload_path(instance, filename):
return os.path.join("uploads", "blog", str(instance.id), filename)
class Entry(models.Model):
image = FileBrowseUploadField(max_length=250, upload_to=entry_upload_path)
post_save.connect(image_callback, sender=Entry)
@sehmaschine
sehmaschine / filters.py
Created Sep 14, 2015
OrderingFilter for Django Rest Framework
View filters.py
# coding: utf-8
# PYTHON IMPORTS
from django.utils import six
from django.core.exceptions import ImproperlyConfigured
# REST IMPORTS
from rest_framework.settings import api_settings
from rest_framework.filters import BaseFilterBackend
@sehmaschine
sehmaschine / navigation.jsx
Created Jun 23, 2015
react router context
View navigation.jsx
var NavigationView = React.createClass({
childContextTypes: {
router: React.PropTypes.func.isRequired
},
showGroups: function(event) {
React.render(<NavigationGroup />, document.getElementById('menu'));
},
render: function() {
return (
<div id="parent">
@sehmaschine
sehmaschine / test_base64.html
Last active Aug 29, 2015
wkhtmltopdf with custom font (font-face)
View test_base64.html
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: "CustomFont";
src: url(data:font/opentype;charset=utf-8;base64,d09GRgABAAAAAJ2bABAAAAABU8wAAQAAAACanAAAAv8AAAYEAAAAAAAAAABPUy8yAAABbAAAAFgAAABgZpABsVZETVgAAAHEAAADfgAABeBvK3avY21hcAAABUQAAACpAAAA5LmCs2VjdnQgAAAF8AAAACAAAAAgBLgBVWZwZ20AAAYQAAABAgAAAXMGWZw3Z2FzcAAABxQAAAAIAAAACP//AARnbHlmAAAHHAAAcCsAAPo4D+TPemhlYWQAAHdIAAAANgAAADbxqmcSaGhlYQAAd4AAAAAgAAAAJAb8BA1obXR4AAB3oAAAAiEAAAO0yak2cGtlcm4AAHnEAAAWlQAANFya657HbG9jYQAAkFwAAAKHAAADuACGVGBtYXhwAACS5AAAACAAAAAgAwYEuG5hbWUAAJMEAAAG9QAAEp6VPrU+cG9zdAAAmfwAAAATAAAAIP+4ADJwcmVwAACaEAAAAIoAAADBPju7qXicY2Bm/MI4gYGVgYNpD1MXAwNDD4RmvMtgxPCLgYGJn5WZiYmZlYm5gYFhPVCeiwEKfDz9/IEUr6IS08v/jAwnmKcxXAHyGUFyjE+Y1jIoACEDAAaCD5t4nB3NU3AeChCG4bdXJ7Vt27Zt27Zt27Zt2z1F7MZO2qRu0zZN0+75zr8788w7sxdLKrT/D+lIcjKc+Mf+khonmYbUMi1p7I+uadXpSafOQHqZkQwyExllZjJZClnIrM4qU8hGFpmdrPabHGRT5yS7Ohc5ZG5yyjzksmTyklvmI4/MT15ZgHz2i4IymULkVxemgCxCQVmUQrIYhS2J4hSRJSgqS1JMlqK4/aQ0JdRlKKku67AcpWR5SssKlLEfVKSsu
@sehmaschine
sehmaschine / tests.py
Created May 19, 2013
simplified TestClient with rest framework
View tests.py
import time
from urlparse import urlparse
from django.conf import settings
from django.test import TestCase
from django.test.client import FakePayload, Client
class TestApiClient(object):
def __init__(self):
"""
@sehmaschine
sehmaschine / export.py
Created Mar 2, 2013
celery update_state issue
View export.py
from tasks import full_export_task
def export_year_zip(user):
full_export_task.update_state(state="PROGRESS", meta={})
@sehmaschine
sehmaschine / base.py
Created Jan 22, 2013
FileBrowser ... updated walk for FileSubmit with SEARCH_TRAVERSE
View base.py
def _walk(self, path, filelisting):
"""
Recursively walks the path and collects all files and
directories.
Danger: Symbolic links can create cycles and this function
ends up in a regression.
"""
dirs, files = self.site.storage.listdir(path)
@sehmaschine
sehmaschine / gist:2491298
Created Apr 25, 2012
Multiple FileBrowser Sites
View gist:2491298
from filebrowser.sites import site
from django.core.files.storage import DefaultStorage, default_storage, FileSystemStorage
site_1 = site(name="First FB Site", app_name="filebrowser", storage=default_storage) # default filebrowser site
site_2 = site(name="Second FB Site", app_name="filebrowser", storage=FileSystemStorage)
You can’t perform that action at this time.