Skip to content

Instantly share code, notes, and snippets.

View mrs83's full-sized avatar

Massimo R. S. mrs83

  • Italy
View GitHub Profile
@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'
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 18, 2026 12:58
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)
@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
@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)
@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
"""
@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