Skip to content

Instantly share code, notes, and snippets.

View erny's full-sized avatar

Ernesto Revilla erny

  • www.nextbpm.es / Freelance
  • Sevilla, Spain
View GitHub Profile
@erny
erny / rundevel
Created October 30, 2013 19:15
Make gunicorn reload during code changes for development, based on http://stackoverflow.com/a/19502993/308351 . Pre-alpha script.
#!/bin/bash
PIDFILE=gunicorn.pid
EXTENSIONS="*.py;*.html;*.css;*.js"
APP=wsgiapp:application
WORKERS=3
function runserver() {
echo "Starting gunicorn"
PYTHONPATH=.:bin gunicorn $APP -w $WORKERS --pid $PIDFILE -D
echo "gunicorn started with PID $!"
@erny
erny / gist:19ee461d2f11a8777a26e656934fdad1
Last active May 13, 2019 15:16
Replace django STATIC_URL with {% static %} template tag.
# STATIC_URL must have one space before and one after (or change regex below). URLs must be enclosed with double quotes.
rgrep '{{ STATIC_URL }}' . -l | xargs perl -pi -e 's/"\{\{ STATIC_URL \}\}(.*?)"/"{% static '"'"'\1'"'"' %}"/'
@erny
erny / renderers.py
Last active December 18, 2023 09:14
FastAPI Simple content negotiation
"""Simple content negotiation
Usage:
Example 1:
from renderers import render
@router.post("/myapp/items/")
async def api_login(item: Item, accept: Optional[str] = Header(default='application/jwt')):
@erny
erny / gist:1599224404436c6740a256329b6c3701
Created June 14, 2021 09:14
Poetry minimal pyproject.toml
[tool.poetry]
name = "kk"
version = "0.1.0"
description = ""
authors = ["Ernesto Revilla <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.8"
[tool.poetry.dev-dependencies]