본문 바로가기

전체 글343

[Svelte] Store Svelte has a store, so we don't need to use 3rd party modules. Writable Store A writable store is the most general store that can be read and written. Simple Example First, I will make a store. // store.ts import { writable } from 'svelte/store'; import type { Writable } from 'svelte/store'; export const count: Writable = writable(0); writable() function returns writable store object. Next, make.. 2021. 11. 13.
[Svelte] Lifecycle Svelte has four lifecycle functions. onMount onDestroy beforeUpdate afterUpdate Let's figure out them. Create Project Create svelte project. I added a component for a test. Test Component And, I added this component into index.svelte. { toggleTest = !toggleTest; }} > Toggle {#if toggleTest} {/if} The test component will be toggled when we click the Toggle button. onMount onMount() lifecycle is c.. 2021. 11. 12.
개발 관련 책 추천 개인 적으로 보고 좋았던 책들을 기록해 놓으려고 만든 포스팅 입니다. 대부분은 소장 중입니다. ^^ 혹시 데이터가 쌓이면 다른 분들께도 도움이 되지 않을까 ^^;; Python 더보기 Language > 효율적 개발로 이끄는 파이썬 실천 기술 입문자에게나 중급자에게나 꼭 보시길 권합니다. 기초부터 꿀팁까지 가득하네요. > 파이썬 스킬업 파이썬 기초를 익힌 후, 바이블 겸 한 단계 업그레이드가 필요한 분들이 보시면 좋을 거 같네요. > 진지한 파이썬 필요한 주제가 있을 때, 깊이있게 찾아보기 위해 먼저 선행으로 볼만 합니다. > 클린 파이썬 "진지한 파이썬"과 유사하지만 각 주제에 대해 클린 코드 관점에서 파이썬을 작성하는 방법을 다루고 있습니다. > 파이썬으로 배우는 수학적 프로그래밍 프로그래밍 사고를 .. 2021. 11. 7.
[Python] Singleton Pattern Singleton is a creational design pattern, which ensures that only one object of its kind exists and provides a single point of access to it for any other code. Singleton is alike to the global variable. Code class SingletonMeta(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls._instances: instance = super().__call__(*args, **kwargs) cls._instances[cls] = instance retur.. 2021. 11. 2.
[Python] String Let's take a look at the string in Python. Changing Case We can simply change the case of string via upper() and lower() functions. test_string = "Hello, World" print(test_string.upper()) # HELLO, WORLD print(test_string.lower()) # hello, world It works well in the English alphabet case. What about the other language in Unicode? test_string = "ß" print(test_string.upper()) # SS print(test_string.. 2021. 10. 31.
[Python] Testing The test is the one of most important parts of development. pytest and unittest are generally used for testing in Python. Example of unittest Module Let's use unittest module. This is a built-in module, so you just use it. It is highly recommended as follows: The name of the test module starts with test. Test class inherits from unittest.TestCase. The name of the test method starts with test. Te.. 2021. 10. 30.
[Python] Debugging Debugging is an important thing to fix a problem of code. Debugger pdb pdb is a command-line tool to debug Python code. import pdb pdb.set_trace() ipdb ipdb is the same kind of tool. In addition, ipdb can debug IPython as well. But, this is not a built-in module. $ pip install ipdb import ipdb ipdb.set_trace() pudb pudb is a more useful debugger than pdb and ipdb. But, this is not a built-in mod.. 2021. 10. 27.
[Go] Testing Unit Testing Unit testing is a software testing method by which individual units of source code. This is a basic syntax for testing in Go. import "testing" func TestBlahBlah(t *testing.T) { // test statements } The test code needs to import the testing package. The test function takes a parameter as "t *testing.T". The test function's name has to start with Test. Let's make a simple program to t.. 2021. 10. 26.
[Python] logging Python has logging module. It helps us to log the code flow. Import logging module import logging logging.getLogger(__name__).addHandler(logging.NullHandler()) We can simply import the logging module and config it. Use logging module (with Stack Trace) import logging def divide_by_zero(): try: c = 3 / 0 except Exception as e: logging.error("Exception ", exc_info=True) divide_by_zero() # ERROR:ro.. 2021. 10. 25.