Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View aliwo's full-sized avatar
🏠
Working from home

정승원 aliwo

🏠
Working from home
View GitHub Profile
@aliwo
aliwo / except.py
Created May 4, 2022 01:45
catching exception
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)
class QuackBehavior:
def quack(self):
pass
class SwimBehavior:
def swim(self):
class EndpointA:
def fetch(self):
pass
class EndpointB:
def fetch(self):
pass
class EndpointC:
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
from typing import Any
from pydantic import BaseModel
class User:
id: int
is_admin: bool
username: str
password: str
@aliwo
aliwo / temp2.java
Last active October 24, 2021 10:52
@Getter
@NoArgsConstructor
@Entity
public class User {
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
private List<PartyUser> parties = new ArrayList<>();
}
@Getter
@NoArgsConstructor
@Entity
public class User {
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
private List<PartyUser> parties = new ArrayList<>();
}
@aliwo
aliwo / record.py
Created December 23, 2020 08:04
keyboardinterrupt 로 중간에 멈추는 녹음
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"
from copy import deepcopy
class Num:
def __init__(self, num):
self.num = num
def __repr__(self):
return str(self.num)
public class ManualBallsGenerator {
Scanner scanner;
public ManualBallsGenerator() {
this.scanner = new Scanner(System.in);
}
public BaseBalls generate() {
System.out.println("숫자 3개 입력");