컴퓨터
-
Rust: Generic Associated Types (GAT)컴퓨터/Rust 2022. 12. 19. 00:09
Rust 언어에선 Associated Type (연관 유형, 이하 AT) 은 trait에 정의된 유형 (type)의 placeholder (자리 표시)이며 trait가 구현될 때 조금 더 구체적인 type으로 대체될 수 있다. AT는 일반 형식의 매개 변수를 사용하여 구조 또는 함수 정의의 형식에 대해 추상화할 수 있는 방법과 유사한 trait 정의 형식에 대해 추상화할 수 있다. 또 AT는 하나 이상의 type 멤버가 있는 trait를 정의하려는 경우에 유용하지만 이러한 멤버들의 특정 type은 trait가 구현될 때까지 알 수 없다. (런타임) trait에 AT가 있는 간단한 예제이다: trait Iterator { type Item; fn next(&mut self) -> Option; } 위 예제..
-
Smart Contract <-> Svelte 프론트엔드 연동컴퓨터/Solidity 2022. 11. 28. 19:33
Svelte Web3 clbrge/svelte-web3 web3.js library integration as a Svelte store. Contribute to clbrge/svelte-web3 development by creating an account on GitHub. github.com 소개 Web3 dApp을 Svelte로 만들 수 있게 도와준다. npm i svelte-web3 yarn install svelte-web3 index.html 아래를 head에 추가한다. 예제 App.svelte 연동 아래는 MetaMask에 연동된다. 알맞은 provider 선택해서 하면 된다. onMount에서 connect 하거나 await connect() pending 해서 렌더링 시킨다. {#if..
-
Brownie: Smart Contract 파이썬으로 테스트 하기컴퓨터/Solidity 2022. 11. 21. 19:11
Brownie GitHub - eth-brownie/brownie A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine github.com 소개 ETH Brownie는 Ethereum Virtual Machine (EVM) 환경에서 스마트 컨트랙트를 파이썬으로 테스트할 수 있게 도와준다. 설치는 pip으로 하면 끝난다. (C/C++ Build tools 최신 버전 설치 필요할 수 있음) 네트워크를 지정할 수도 있지만 기본적으로 Ganache [가나슈]를 이용하면 편하다. (account 100 ETHER 있는 10개의 계정을 받음) npm install ganache..
-
JS: valueOf, toString, toPrimitive컴퓨터/HTML & JS & TS 2022. 10. 14. 17:26
Javascript 기능 중 valueOf, toString, toPrimitive를 이용하면 말이 안 되는 것을 할 수 있다. // 기본적으로 toString은 아래처럼 쓰일 수 있다. let a = { id: '123oij21312838', toString() { return '한글'; }, }; if (a == '한글') { console.log('a는 한글'); } // 결과: a는 한글 출력됨 위에 따르면 아래처럼 진행된다. // a가 string 'a' == a is True // a가 boolean True == 1 is True // a가 object => conversion toPrimitive @객체를 원시형으로 변환하기 object가 숫자형이나 문자형으로 형 변환시 toPrimitiv..
-
Sanic: FastAPI와 비슷한 파이썬 웹프레임워크컴퓨터/파이썬 2022. 8. 30. 20:35
sanic Home Trusted by millions Sanic is one of the overall most popular frameworks on PyPI, and the top async enabled framework sanic.dev 소개 쓸만한 웹 프레임워크 중 가장 빠르게 성능이 나온 Sanic FastAPI, django 등과 비교해서 단점도 있겠지만 속도만으로 봤을 때 나쁘진 않은 것 같다. 설치 pip install sanic 기본 틀 from sanic import Sanic from sanic.response import text app = Sanic("MyHelloWorldApp") @app.get("/") async def hello_world(request): return ..
-
Flet: Python Flutter GUI 앱컴퓨터/파이썬 2022. 8. 30. 20:21
Flet The fastest way to build Flutter apps in Python | Flet Build internal web apps quickly in the language you already know. flet.dev 소개 이 라이브러리는 Flutter 앱을 파이썬으로 쉽게 만들 수 있게 도와준다. 써보니 생각보다 나쁘지 않고 속도도 괜찮다. 여러 플랫폼을 지원하니 사용도 편리하다. 사용 후기 아래처럼 Navigation, ListView, SnackBar 등을 쉽게 만들 수 있었다. 아이콘도 내장되어 있어서 @여기서 찾아쓰면 된다. 참고 @위 직접 만든 예제 소스 Python Flet Study Alfex4936/Flet-Example on GitHub. github.com
-
Rust: Go와 비슷하게 멀티쓰레딩 짜기컴퓨터/Rust 2022. 8. 29. 14:37
my_map := make(map[string]string) var wg sync.WaitGroup wg.Add(len(my_map )) for key := range my_map { go func(key string) { defer wg.Done() stdout, _ := exec.Command(key, "some command").Output() lock.Lock() defer lock.Unlock() my_map[key] = "updating map value while iterating" // eg stdout }(key) } 어느 날 위와 같이 Go언어로 작성한 것을 Rust로 옮기려다가 배운 것이다. 위 Go언어으로 짠 걸 보면 우선 Map을 만들고 key마다 돌면서 thread를 spawn ..