Skip to content

Instantly share code, notes, and snippets.

@YannBouyeron
YannBouyeron / rsa.py
Last active November 2, 2023 19:45
Algorithme pédagogique de chiffrement RSA avec python
import numpy as np
def isprem(n):
"""retourne True si n est premoer, False dans le cas contraire.
n doit etre un entier"""
@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 / 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 / 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 / Coffre_fort_gpg.md
Last active April 8, 2022 09:56
Faire un coffre fort numérique avec tar et gpg

Faire un coffre fort numérique avec tar et gpg.

Créer un fichier "mon_coffre".

Dans cet exemple je vais créer mon coffre dans mon répertoire /home/pi/Documents

pi@lebowski:~/Documents $ mkdir mon_coffre

Une fois le coffre créé, on peut y mettre ce que l'on souhaite (codes de lancement des missiles nucléaires nord-coréens, recette de la tarte aux pommes de grand mère, sa propre adresse si on est atteint d'Alzheimer...)

@YannBouyeron
YannBouyeron / GPG.md
Last active April 8, 2022 09:56
GPG.md

Chiffrer , déchiffrer et signer avec GPG

Chiffrer déchiffrer vos fichiers personnels (chiffrage symétrique)

Chiffrer:

gpg2 -c file

On vous demandera alors d'entrer une phrase de passe et de la confirmer. Un nouveau fichier serra alors créé sous le nom de file.gpg

@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 / Tutoriel Python.md
Last active October 4, 2022 01:07
Tutoriel Python: les bases du langage python

Tutoriel Python

Copyright (c) Yann Bouyeron.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".