Skip to content

Instantly share code, notes, and snippets.

View SebDeclercq's full-sized avatar

Sébastien Declercq SebDeclercq

View GitHub Profile
#!/usr/bin/env python3
import time
import pytest
from app.Simple import Simple
@pytest.fixture()
def var() -> None:
return Simple(azerty=1, uiop=2)
@SebDeclercq
SebDeclercq / OCP6.sql
Last active December 7, 2018 19:41
Script populating an OCP6 Database with fake data
-- ENTITIES
CREATE TABLE address (
id SERIAL PRIMARY KEY,
street_name TEXT NOT NULL,
home_number TEXT NOT NULL,
zip_code TEXT NOT NULL,
country TEXT
);
CREATE TABLE role (
id SERIAL PRIMARY KEY,
#!/usr/bin/env python3
from typing import NoReturn, Dict, Any, Optional, List
import requests
import json
class QwantData:
def __init__(self, json_str: bytes, wished_data: str) -> NoReturn:
parsed_json: Dict = json.loads(json_str)
if wished_data == 'artist':
#!/usr/bin/env python3
"""
Brangelina
The task of combining first names of celebrities into
a short catchy name for media consumption turns out
to be surprisingly simple to automate. Start by counting
how many groups of consecutive vowels (aeiou) there are
inside the first name. For example, "brad" and "ben" have
@SebDeclercq
SebDeclercq / creeTocMarkDown.py
Last active August 28, 2018 09:14
Crée une table des matières sur base d'un fichier markdown
#!/usr/bin/env python3
import os
import re
entree = os.path.join('chemin', 'vers le', '.md')
sortie = os.path.join('chemin', 'vers le', '.toc.md')
with open(entree) as md, open(sortie, 'w') as out:
for ligne in md:
if ligne[0] == '#':
@SebDeclercq
SebDeclercq / ex11.py
Created July 24, 2018 12:57
Exercice 11 PAIR LEARNING
#!/usr/bin/env python3
import random
class Carte():
couleurs = {'carreau': '♦', 'coeur': '♥', 'pique': '♠', 'trefle': '♣'}
noms = {"2" : 1, "3" : 2, "4" : 3, "5" : 4, "6" : 5, "7" : 6,
"8" : 7, "9" : 8, "10" : 9, "valet" : 10, "dame" : 11,
"roi" : 12, "as" : 13}
def __init__(self, nom, couleur):
@SebDeclercq
SebDeclercq / dict2obj.py
Created June 6, 2018 11:17
Essai pour voir si c'est faisable pour CHBO
#!/usr/bin/env python3
class Struct(): pass
def toObject(dictionnaire):
object = Struct()
for nom, element in dictionnaire.items():
if isinstance(element, dict):
setattr(object, nom, toObject(element))
else:
setattr(object, nom, element)
#!C:/Users/SDQ/AppData/Local/Programs/Python/Python36/python.exe
"""
Permet la création d'un tableau MarkDown
sur base d'une liste de valeurs données ligne par ligne
(24 données, 4 colonnes)
"""
liste, i, flag = [], 0, False
for lg in open(__file__): # Pour chaque ligne du fichier
@SebDeclercq
SebDeclercq / 009_JeuxDeCartes.py
Last active July 31, 2024 22:33
Jeux de cartes
#!/usr/bin/env python3
import random
import time
import sys
# Classe qui définit un jeu de cartes
class JeuDeCartes:
def __init__(self):
# Un jeu possède des cartes de 4 couleurs
# mais est généralement utilisé en un seul paquet
#!/usr/bin/env python3
class Personne():
def __init__(self, block):
block(self)
def __str__(self):
return "La personne s'appelle "+self.prenom+" "+self.nom.upper()
def init(pers):
pers.prenom = 'Seb'
pers.nom = 'Declercq'