Skip to content

Instantly share code, notes, and snippets.

View mrs83's full-sized avatar

Massimo R. S. mrs83

  • Berlin, Germany
View GitHub Profile
@bdarnell
bdarnell / django_tornado_handler.py
Created October 29, 2010 18:59
django_tornado_handler.py
# NOTE: This code was extracted from a larger class and has not been
# tested in this form. Caveat emptor.
import django.conf
import django.contrib.auth
import django.core.handlers.wsgi
import django.db
import django.utils.importlib
import httplib
import json
import logging
@tkaemming
tkaemming / autocache.py
Created April 20, 2012 20:06
self-versioning and argument-hashing cache decorator for python (django/flask)
#!/usr/bin/env python
"""
Self-versioning and argument-hashing cache decorator for deterministic functions.
Designed to be extensible and API-compliant with Django and Flask cache backends.
For examples and caveats, see the bottom of the file.
Ted Kaemming: https://github.com/tkaemming
Mike Tigas: https://github.com/mtigas
"""
@soundkitchen
soundkitchen / bytecodecache.py
Created June 2, 2012 11:05
redis な jinja2 の BytecodeCache など。
import logging
from jinja2 import BytecodeCache
from redis import Redis
class RedisBytecodeCache(BytecodeCache):
"""bytecode cache on redis for jinja2
"""
def __init__(self, host='localhost', port=6379, db=0, expire=0):
self._conn = Redis(host=host, port=port, db=db)
@evanscottgray
evanscottgray / docker_kill.sh
Last active November 7, 2023 03:40
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 20, 2024 05:42
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@marteinn
marteinn / info.md
Last active January 21, 2024 06:57
Using the Fetch Api with Django Rest Framework

Using the Fetch Api with Django Rest Framework

Server

First, make sure you use the SessionAuthentication in Django. Put this in your settings.py

# Django rest framework
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
 'rest_framework.authentication.SessionAuthentication'
@rochacbruno
rochacbruno / Makefile
Last active June 22, 2022 23:35
Python Setup Tips and Tricks http://j.mp/setup_py
.PHONY: test install pep8 release clean
test: pep8
py.test --cov -l --tb=short --maxfail=1 program/
install:
python setup.py develop
pep8:
@flake8 program --ignore=F403 --exclude=junk
@marteinn
marteinn / filters.py
Last active November 28, 2019 09:19
Sorting by distance filter for django-restframework-gis. MIT license.
# -*- coding: utf-8 -*-
"""
This is an extension to django-restframework-gis that extends on
DistanceToPointFilter and adds sorting by distance.
It is also possible to add a extra distance field to the returned queryset by
adding the flag distance_filter_add_distance = True to the DRF View.
"""
@c9s
c9s / .babelrc
Last active October 21, 2023 14:04
webpack + babel + typescript + es6 - total solutions!
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}

DraftJS Preact Demo

Start

npm install

npm start

Go to localhost:8080