Skip to content

Instantly share code, notes, and snippets.

View gustavi's full-sized avatar

Augustin LAVILLE gustavi

View GitHub Profile
@gustavi
gustavi / admin.py
Created September 3, 2018 07:19
Django - Use email as "username" field
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy as _
from yourprojectname.member.models import User
@admin.register(User)
class EmailUserAdmin(UserAdmin):
"""
@gustavi
gustavi / example.txt
Created August 17, 2018 10:59
explore dict
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo(path, struct):
... value = struct
... for x in path.split('.'):
... value = value[x]
... return value
...
>>> d = {'a': {'b': {'c': 42}, 'd': list()}}
@gustavi
gustavi / datetime.py
Last active July 12, 2017 13:53
Python Patterns
def get_first_day_of_week(day):
"""
Get the first day of week of a datetime (similar with a date).
""""
day.replace(hour=0, minute=0, second=0, microsecond=0) - timedelta(days=day.weekday())
@gustavi
gustavi / fix.txt
Created May 7, 2017 07:28
Fix ArchLinux openssl fail update
Error :
- Partial upgrade of system that contains openssl 1.1
- pacman: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
- Network is unreachable
Fix :
- On other device :
- Download previous package (1.0 in this case) at https://archive.archlinux.org/packages/o/openssl/
@gustavi
gustavi / rules.sh
Created March 24, 2017 16:44
ufw rules
# SSH
sudo ufw allow out 22/tcp
sudo ufw allow in 22/tcp
# HTTP/HTTPS
sudo ufw allow out 80/tcp
sudo ufw allow in 80/tcp
sudo ufw allow out 443/tcp
sudo ufw allow in 443/tcp
@gustavi
gustavi / psd_to_png_and_jpg.sh
Last active March 16, 2017 16:39
Convert PSD to JPG/PNG files
#!/bin/bash
for img in *.{psd,PSD}
do
imgname=`echo $img|cut -f1 -d.`
echo $imgname
mkdir $imgname
mkdir $imgname/png
mkdir $imgname/jpg
convert $img $imgname/jpg/$imgname.jpg
@gustavi
gustavi / proxy.sh
Created October 14, 2016 17:11
EFREI PROXY
#!/bin/bash
# Script pour lancer le proxy à l'EFREI
# Fonctionne avec bash et zsh
# Penser à utiliser `sudo -E` si besoin
assignProxy(){
export http_proxy=$1
export https_proxy=$1
export ftp_proxy=$1
@gustavi
gustavi / zds.md
Last active August 27, 2016 09:09
MEP et versions sur Zeste de Savoir

Créer une version

  • Changer la milestone « Version de développement » en « Version 19 » (sur GitHub)
  • Créer une nouvelle milestone « Version de développement » (sur GitHub)
  • Créer la banche « release-v19 »
  • Merger la branche « dev » dans « release-v19 » en forçant la création d'un commit de merge
  • Tagger le commit qui vient d'être créé : « v19-RC1 »

Créer une RC-n avec n>1

@gustavi
gustavi / ZEP-13-ROADMAP.md
Last active May 12, 2016 14:02
ZEP-13 - DEV ROADMAP

Version 1

Général

  • [OK] Création du contenu OPINION
  • [OK] Ajout du contenu et modification des templates
  • [OK] Interdiction de la validation/JsFiddle
  • [OK] Publication d'un billet
  • [OK] Affichage correct de la sidebar avec les billets
  • [OK] Dépublication d'un billet
@gustavi
gustavi / QA_ZDS.sh
Last active December 5, 2015 21:54
# SCRIPT POUR DÉPLOYER UN ENV DE QA POUR ZDS
##### VAR #####
PYTHON_DIR='/usr/bin/python2.7'
VIRTUALENV_DIR='/home/augustin/.virtualenvs'
QA_ID='3224'
QA_REPO='https://github.com/gustavi/zds-site.git'
QA_BRANCH='fix-872'