flowchart TD
B{Documented entity?}
B -- Yes --> C[NoSQL]
C --> D{CRUD?}
B -- No --> E[RDBMS]
E --> F{CRUD?}
D -- Yes --> K[FastAPI + Firestore]
D -- No ----> H[gRPC + Firestore]
F -- Yes --> I{Use Python libalies?}
This file contains 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 { API_URL, ENDPOINT_TOKEN } from '../../components/const'; | |
import type { NextApiRequest, NextApiResponse } from "next"; | |
type Todo = { | |
userId: number; | |
id: number; | |
title: string; | |
completed: boolean; | |
}; |
This file contains 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
#!/usr/bin/env python3 | |
import os | |
from sqlalchemy import create_engine | |
## assertion | |
for key in ['USERNAME', 'PASSWORD', 'HOST', 'DATABASE']: | |
assert os.getenv(key), f'{key} is empty' | |
「依存性の注入」=「依存されるオブジェクトの注入」
依存する実装を定義したinterfaceをつくり、そのinterfaceをstruct(構造体)のフィールドとして持たせる
This file contains 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 React from 'react'; | |
import AppContainer from './appcontainer'; | |
export default function App() { | |
return ( | |
<AppContainer /> | |
) | |
} |
This file contains 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
λ(n : Natural) -> [ n, n + 1 ] |
This file contains 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
{ | |
Type = { | |
key : Text, | |
}, | |
default = { | |
key = "default", | |
} | |
} |
This file contains 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 logging | |
import aioredis | |
class RedisConn: | |
_pool = {} | |
# Singleton | |
def __new__(cls, *args, **kwargs): | |
if not hasattr(cls, "_instance"): |
This file contains 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 dict2(dict): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.__dict__ = self |
This file contains 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 multiprocessing import Process, Manager | |
class MyMap(): | |
def __new__(cls): | |
self = Manager().dict() | |
return self | |
def f(d): | |
d[1] += '1' | |
d['2'] += 2 |