전체 글
-
method 이름은 같은데 param, return 타입을 다르게 구현하기scala/basic 2024. 3. 7. 17:06
case class GoogleRaw(content: String, crawlId: String) case class NaverRaw(content: String) case class GoogleParsed(sections: Seq[String], crawlId: String) case class NaverParsed(sections: Seq[String]) trait Cralwer { type Raw type Parsed def fetch(url: String): Raw def parse(raw: Raw): Parsed def save(raw: Raw, parsed: Parsed): Int } object GoogleCrawler extends Cralwer { type Raw = GoogleRaw t..
-
conda commandspython/conda 2024. 2. 14. 14:29
miniconda install가이드 문서: https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.htmlubuntu 에 설치하기: https://docs.anaconda.com/free/miniconda/#quick-command-line-install 기본 명령어env 생성 / 삭제conda env listconda init bash # .bashrc 환경 설정conda create -y -n kjm_env conda-pack python=3.8.15conda activate kjm_envconda deactivateconda env remove -n kjm_env env 생성하는 또 다른 방법 -..
-
git command 모음git 2024. 2. 8. 18:41
Remote 연결local repo 를 remote repo 와 연결한다.# local repo 에서git remote add origin https://github.com/windbird123/my-repo.git Profile 설정git config --global user.name jm.kimgit config --global user.email jm.kim@mycorp.com 작업 했던 모든 것을 되돌릴 때git resetgit checkout . 특정 파일을 tracking 에서 제외할 때git rm --cached .idea/misc.xml git add 로 staged 상태인 파일을 원래대로 돌릴 때git restore --staged my_file.txt 특정 branch 만 clone 할..
-
python MixInpython/응용 2024. 1. 31. 17:07
scala 의 trait mixin 과 비슷한 것 같다. 상속을 통해 공통으로 사용할 member, method 를 클래스에 추가함? 예제 코드 class ToDictMixin: def to_dict(self): return {key: value for key, value in self.__dict__.items()} class MyClass(ToDictMixin, BaseClass): pass 다중 상속일 경우 Q: Under multiple inheritances, if two parent classes have the same methods or attributes, what will happen? A: If two parent classes have the same method or attribu..
-
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..