Skip to content

Instantly share code, notes, and snippets.

@YannBouyeron
YannBouyeron / harmony.py
Created January 10, 2018 16:03
harmony.py
blues_m = ['T', 'b3', 'P4', 'b5', 'P5', 'b7']
mh = ['T', 'M2', 'b3', 'P4', 'P5', 'b6', 'M7']
mm = ['T', 'M2', 'b3', 'P4', 'P5', 'P6', 'M7']
m = ['T', 'M2', 'M3', 'P4', 'P5', 'P6', 'M7']
@YannBouyeron
YannBouyeron / recurlist.py
Last active January 11, 2018 08:47
Liste récursive des fichiers et dossiers d’un répertoire - alternative à glob.glob pour python < 3.5
import os
import fnmatch
import sys
def recurlist(path):
"""
path est une chaine de caractere
retourne une liste recursive des dossiers et fichiers contenus dans path.
@YannBouyeron
YannBouyeron / md2html2pdf.py
Last active January 11, 2018 08:57
markdown to html to pdf
import markdown2
from xhtml2pdf import pisa
from xhtml2pdf.default import DEFAULT_CSS
import os
def mdht(md, ht = None):
"""convertion du fichier .md en .html
@YannBouyeron
YannBouyeron / gpconv.py
Created January 12, 2018 14:28
gpconv.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
# Copyright (c) 2017 Yann BOUYERON
#
#
# licensed under GNU GPL version 3 (or later)
#
#
@YannBouyeron
YannBouyeron / loto.py
Last active January 23, 2018 13:25
loto.py
#version pour python >= 3.5
import random
#l'utilisateur entre ses 3 numeros
n1 = int(input('entrez votre premier numero (entre 0 et 20): '))
n2 = int(input('entrez votre second numero (entre 0 et 20): '))
n3 = int(input('entrez votre troisieme numero (entre 0 et 20): '))
@YannBouyeron
YannBouyeron / Lire et écrire avec Python.md
Last active February 7, 2018 09:08
Python: Lire et écrire un fichier.

Lire et écrire un fichier avec Python 2.7 et avec Python 3

Lire et écrire un fichier avec Python 2.7

Ecrire dans un fichier avec Python 2.7

# coding: utf-8

x = 'salut, ca va ?'
@YannBouyeron
YannBouyeron / Formulator.py
Last active August 22, 2018 11:40
Module python pour créer des formulaires html automatiques
# Formulator.py
# Copyright (C) 2018 Yann Bouyeron
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# any later version.
# This program is distributed in the hope that it will be useful,
@YannBouyeron
YannBouyeron / xlpy.py
Last active September 7, 2018 18:53
Excel reader / Excel writer
from xlwt import Workbook
import xlrd
def col2lin(col):
"""col est une liste de tuple de colonne. """
return [tuple([c[i] for c in col]) for i in range(len(col[0]))]
@YannBouyeron
YannBouyeron / Gestion Session Bottle.md
Last active November 16, 2018 13:34
Gestion Session Bottle.md

Gestion des utilisateurs d'un site web : connections et inscriptions.

Le principe:

Pour presenter le principe simplifié, on utilisera un fichier json pour stocker les données. (On devrait normalement utiliser une base de données. La gestion des utilisateur avec sqlite est presentée ici : https://github.com/YannBouyeron/bottle-session)

1: Créer une page index: ’/‘

  • rechercher si un cookie de connection est présent.
  • si il est présent, recuperer son contenu (le mail de l’user) et retourner un texte personnalisé + un bouton de déconnection (action = /logout)
@YannBouyeron
YannBouyeron / BaseK.py
Created December 8, 2018 22:21
Convertisseur de bases
from decimal import Decimal
from attrdict import AttrDict
def d2k(d, k):
"""
d base 10 [int] to [str] base k [int]