Skip to content

Instantly share code, notes, and snippets.

View tchappui's full-sized avatar

Thierry Chappuis tchappui

View GitHub Profile
@tchappui
tchappui / multisite_page.py
Created June 8, 2022 06:41
Multi-site page model for wagtail with ability to resolve for site specific templates
from django.template.loader import select_template
class MultisitePage(Page):
"""
Page model to be used for mutli-site projects.
"""
class Meta:
abstract = True
@tchappui
tchappui / requirements.in
Last active September 29, 2021 09:26
Requirements file for the chemical reaction engineering course at HEIA-FR
pipx
pipenv
ipython
notebook
numpy
scipy
pandas
matplotlib
altair
seaborn
@tchappui
tchappui / README.md
Created September 19, 2021 21:50 — forked from 8area8/README.md
Django/Vue-cli coupling

Basic workflow to Django/Vue-cli coupling

The goal of this workflow is to couple vue-cli to Django, in a transparent way in dev and in prod. The hot-reload is active in the backend as well as in the frontend, and the frontend is accessed through Django, from the index page ;)

Note: We also use the router's historical mode, for a more professional integration.

Note²: Do not forget to build the vue-cli project for production!

Base

@tchappui
tchappui / placepython-header.svg
Last active September 13, 2021 12:36
placepython main illustration
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tchappui
tchappui / placepython-logo.svg
Created September 13, 2021 12:15
Logo PlacePython
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# import * from pygame
import env
from random import *
class World:
X_MIN = 0
X_MAX = env.MAP_WIDTH
Y_MIN = 0
Y_MAX = env.MAP_HEIGHT
@tchappui
tchappui / secret-key-gen.py
Created October 11, 2018 11:23 — forked from ndarville/secret-key-gen.py
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
<?php
// Tell PHP that we're using UTF-8 strings until the end of the script
mb_internal_encoding('UTF-8');
// Tell PHP that we'll be outputting UTF-8 to the browser
mb_http_output('UTF-8');
// Our UTF-8 test string
$string = 'Êl síla erin lû e-govaned vîn.';