This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from datetime import date | |
from uuid import uuid4 | |
import asyncpg | |
async def get_connection(): | |
return await asyncpg.connect( | |
user='postgres', | |
password='1234', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from starlette.middleware.base import BaseHTTPMiddleware | |
from starlette.responses import JSONResponse | |
class UnknownExceptionMiddleware(BaseHTTPMiddleware): # https://www.starlette.io/middleware/#basehttpmiddleware | |
def __init__(self, app): | |
super().__init__(app) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuackBehavior: | |
def quack(self): | |
pass | |
class SwimBehavior: | |
def swim(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EndpointA: | |
def fetch(self): | |
pass | |
class EndpointB: | |
def fetch(self): | |
pass | |
class EndpointC: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyModel: | |
user_id: int = None | |
article_id: int = None | |
comment_id: int = None | |
def __init__(self, user_id, article_id=None, comment_id=None): | |
self.user_id = user_id | |
self.article_id = article_id | |
self.comment_id = comment_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any | |
from pydantic import BaseModel | |
class User: | |
id: int | |
is_admin: bool | |
username: str | |
password: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Getter | |
@NoArgsConstructor | |
@Entity | |
public class User { | |
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY) | |
private List<PartyUser> parties = new ArrayList<>(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Getter | |
@NoArgsConstructor | |
@Entity | |
public class User { | |
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY) | |
private List<PartyUser> parties = new ArrayList<>(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyaudio | |
import wave | |
chunk = 1024 # Record in chunks of 1024 samples | |
sample_format = pyaudio.paInt16 # 16 bits per sample | |
channels = 1 | |
fs = 44100 # Record at 44100 samples per second | |
seconds = 3 | |
filename = "output.wav" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from copy import deepcopy | |
class Num: | |
def __init__(self, num): | |
self.num = num | |
def __repr__(self): | |
return str(self.num) |
NewerOlder