Skip to content

Instantly share code, notes, and snippets.

View jonperron's full-sized avatar

Jonathan Perron jonperron

View GitHub Profile
@dstufft
dstufft / decorators.py
Created September 15, 2011 21:22
Mixins vs Decorators for Django
from functools import wraps
class ViewDecorator(object):
def __init__(self, decorator_class):
self.decorator_class = decorator_class
def __call__(self, *args, **kwargs):
# Pretend that there is a generic decorator wrapper here
pass
@keningle
keningle / decorator.py
Created July 2, 2013 19:43
Example of how to pass URL parameters to a decorator in Django
from django.utils.functional import wraps
...
def check_company_admin(view):
@wraps(view)
def inner(request, slug, *args, **kwargs):
# Get the company object
company = get_object_or_404(Company, slug=slug)
# Check and see if the logged in user is admin
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 13, 2024 23:36
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kaajavi
kaajavi / gist:c963f18a37ef854a3e47
Created January 22, 2016 13:56
Example: "How to use multiple databases django"
You can easy do this by appearing custom attribute to model:
class A(models.Model):
_DATABASE = "X"
class B(models.Model):
_DATABASE = "X"
...
@valyala
valyala / README.md
Last active June 3, 2024 17:00
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:

Mettre en production un projet Symfony 4 sur un VPS OVH

VPS OVH | Ubuntu 16.04.3 LTS | LAMP | SYMFONY 4

Pré-requis

  • Votre projet doit être versionné avec git et hébergé (Github, Bitbucket...).
  • Vous devez avoir acheté un VPS et un nom de domaine.
  • Vous devez également générer une clé SSH sur votre ordinateur. (explications ci-dessous)

Création et ajout de la clé SSH au profil OVH