Skip to content

Instantly share code, notes, and snippets.

View bourdeau's full-sized avatar

Pierre-Henri bourdeau

View GitHub Profile
import asyncio
from random import randint
import aiofiles
import request
import aiohttp
async def async_http_request():
"""
I'm using aiohttp lib to make the http request and it's
"""
The Session.commit() operation unconditionally issues Session.flush() before emitting COMMIT on relevant database

There are only 2 scenarios I see when session.flush() could be call manually:
- `autoflush = False`: then flush might been needed if the object need to be query in the Session
- to get the AUTOINCREMENT ID which are EVIL (🔪🔪🔪🐱)

I wrote a few examples to illustrate this.
"""
import pandas as pd
import time
from contextlib import contextmanager
import dask.dataframe
import redis
import struct
import numpy as np
import pickle
@bourdeau
bourdeau / sources.md
Last active June 11, 2019 13:49
Sources
@bourdeau
bourdeau / Python_Stuff.md
Last active April 21, 2023 05:58
Python Stuff

Inheritance & DI

Multiple inheritance can lead to multi level diamond diagram. In Python it is solved by C3 linearization.

Python doesn't need DI because it has super(). It doesn't work like parent() in other Typed programming languages such as Java or PHP.

In multiple inheritance super() doesn't call the parents but the ancestors:

class Adam(): pass

APPLICATION DESIGN

Inheritance & Composition 😱

Don't use inheritance as another way to copy/paste code.

class EmailRubbish
{
 public function sendEmail(string $email, string $subject): void
import sys
import hashlib
difficulty = 8
block = "alice:0.0001:bob:whatever"
nonce = 0
zeros = ""
for i in range(difficulty):
zeros += "0"