분류 전체보기
-
rustedpy result 소개python/result 2024. 1. 31. 15:34
github: https://github.com/rustedpy/result python Exception 대신에 Result 타입으로 리턴하자. scala 의 Either 와 비슷 dry-python 의 Result 와 비슷 Exception vs Result total function, explicit error check 등을 생각하면 Result 를 사용하는 것이 좋을 듯 한데.. code 가 좀 더 복잡해(어려워) 지고, Exception 사용을 python convention 이라고 생각해 저항이 있는 것 같다. 토론 링크 https://www.reddit.com/r/Python/comments/1897m0y/just_found_a_library_for_ruststyle_errors_in/ h..
-
기본 사용법scala/scala-cli 2024. 1. 27. 20:29
https://scala-cli.virtuslab.org/ 사용법 소개 (scala 2.13 을 사용 중인데, scala 3 survey 에 scala-cli 를 활용해 보았다.) Run scripts hello.sc def helloMessage(names: Seq[String]) = names match case Nil => "Hello!" case names => names.mkString("Hello: ", ", ", "!") println(helloMessage(args.toSeq)) println(os.pwd) 실행 scala-cli \ --jvm 21 \ --dep com.lihaoyi::os-lib:0.9.0 \ hello.sc -- James Candy Run scala code Test..
-
functools.singledispatch 로 typeclass 흉내 내기python/응용 2024. 1. 24. 18:10
https://docs.python.org/3/library/functools.html#functools.singledispatch https://news.ycombinator.com/item?id=22682219 functools.singledispatch 를 이용해 typeclass 처럼 만들어 보자 코드 import dataclasses import functools import math from typing import Any @dataclasses.dataclass class Circle: radius: float @dataclasses.dataclass class Rectangle: width: float height: float @functools.singledispatch def area(..
-
docker 로 jupyter lab 설치하기docker 2024. 1. 4. 18:45
docker image 만들기 requirements.txt 예시 jupyterlab pydantic email-validator python-dateutil pytz requests datamodel-code-generator shortcuts.jupyterlab-settings 파일 준비 (optional) jupyter python 커널에서 code auto-complete 기본 단축키가 TAB 인데, 여기에 Ctrl-space 로도 동작하도록 설정한다. Dockerfile FROM python:3.12.1 RUN pip install --upgrade pip RUN apt update && apt install -y nodejs COPY requirements.txt . RUN pip instal..
-
위치 속성 (position)web/css 2024. 1. 1. 23:18
https://developer.mozilla.org/ko/docs/Web/CSS/position 예제를 위해 공통으로 사용할 html, css 는 다음과 같다. div { width: 100px; height: 100px; background-color: beige; border: 2px solid black; margin: 10px; display: inline-block; } #middle { background-color: green; } ------------------------------------------------------------------------ static 일반적인 문서 흐름에 따라 배치함. top, right, bottom, left 속성이 아무런 영향을 주지 못한다. d..
-
CSS 단위web/css 2023. 12. 31. 19:44
단위1: % 기본적으로 parent element 의 백분율 font-size 의 백분율인 경우도 있음 예제1: parents element 를 기준으로 한 경우 section { background-color: blue; width: 400px; height: 400px; } div { background-color: red; width: 50%; height: 50%; } 예제2: font-size 를 기준으로 한 경우 CSS Units h1 { font-size: 40px; border: 1px solid black; line-height: 300%; } ------------------------------------------------------------------------ 단위2: em ..
-
CSS 박스 모델web/css 2023. 12. 29. 21:41
가로, 세로, 모서리 모양 div { width: 200px; background-color: bisque; border-width: 5px; border-style: solid; border-color: black; /* border: 5px solid black; */ /* 위의 세줄을 한줄로 표현하기 */ border-left-width: 10px; border-radius: 5px; /* 모서리를 둥글게 */ /*border-radius: 50%;*/ } 패딩 (padding) 콘텐츠와 이를 둘러싼 테두리(border) 사이의 공간 Pad ME 여기에 아래 CSS 를 적용하면 button { padding-left: 50px; /* right, top, bottom */ } 마진 (margin) ..