Skip to content

Instantly share code, notes, and snippets.

View stella6767's full-sized avatar
๐ŸŽฏ
Focusing

Kang Min Kyu stella6767

๐ŸŽฏ
Focusing
View GitHub Profile
@sombriks
sombriks / example.html
Created June 15, 2024 20:01
hx-dataset-include - keep your application state in the loop using this hacky, fast and simple extension.
<!--
Since the markup IS the application state, using data-* attributes to keep track of some specifics would be handy.
Luckily, HTMX is brutally easy to extend, so we can do that in no time!
-->
<article class="message task"
th:id="'task'+${task.id}"
th:data-task="${task.id}"
th:data-status="${task.status.id}"
th:hx-put="@{/task/{id}(id=${task.id})}"
hx-ext="hx-dataset-include"
@eywu
eywu / golang-templ-cli-on-mac.md
Last active March 15, 2025 03:53
Installing golang Templ CLI on Mac using Nix
@ihoneymon
ihoneymon / 20220627-spring-boot-application-configuration-data-desc.adoc
Last active March 29, 2023 08:27
์Šคํ”„๋ง ๋ถ€ํŠธ ๊ตฌ์„ฑํŒŒ์ผ ๋ฐ์ดํ„ฐ ์ ์žฌ ๊ฐ„๋‹จ์„ค๋ช…

์Šคํ”„๋ง ๋ถ€ํŠธ ๊ตฌ์„ฑ์†์„ฑ ์ด์šฉ(Spring Boot External Configuration)

์Šคํ”„๋ง ๋ถ€ํŠธ์—์„œ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ํ•„์š”ํ•œ ์†์„ฑ์„ "์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌ์„ฑํŒŒ์ผ" application.yml(ํ˜น์€ applicatoin.properties) ์— ์ž‘์„ฑํ•˜์—ฌ ํ™œ์šฉํ•ฉ๋‹ˆ๋‹ค.

Note

๋ฐ์ดํ„ฐ๊ตฌ์กฐ๋ฅผ ๊ณ„์ธตํ˜•์œผ๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์–ด์„œ ๊ฐœ์ธ์ ์œผ๋กœ .properties ํŒŒ์ผ ๋ณด๋‹ค๋Š” .yml(YAML) ํŒŒ์ผ ์ด์šฉ์„ ์„ ํ˜ธํ•ฉ๋‹ˆ๋‹ค.

[Flyway] Repeatable Migrations & Seed Data

๊ฐœ๋ฐœ ๋‹จ๊ณ„์—์„œ ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ ๋“ฑ ์‹œ๋“œ ๋ฐ์ดํ„ฐ๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ๋”๋Ÿฌ ์žˆ๋‹ค. ์ด ๋•Œ Flyway ์—์„œ ์ œ๊ณตํ•˜๋Š” Repeatable migration ์„ ํ™œ์šฉํ•ด ์‹œ๋“œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋ฉด ์–ด๋–ค ์ ์ด ํŽธํ•œ ์ง€ ๊ทธ๋ฆฌ๊ณ  ์œ ์˜ํ•  ์ ์€ ๋ฌด์—‡์ด ์žˆ๋Š” ์ง€ ์•Œ์•„๋ณด์ž.

Repeatable migrations have a description and a checksum, but no version. Instead of being run just once, they are (re-)applied every time their checksum changes.

Repeatable migration ์˜ ๊ฐ€์žฅ ํฐ ํŠน์ง•์€ checksum ๊ฐ’ (= ๋ณ€๊ฒฝ ์—ฌ๋ถ€ ์ฒดํฌํ•˜๋Š” ๊ฐ’) ์ด ๋ณ€๊ฒฝ๋œ ๊ฒฝ์šฐ ์—ฌ๋Ÿฌ ๋ฒˆ migration ์ด ์ ์šฉ๋œ๋‹ค๋Š” ์ ์ด๋‹ค. SQL-based migration ์—์„œ Repeatable migration ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” R__{description}.sql ์™€ ๊ฐ™์€ ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๋Š”๋ฐ, ์ด๋ฏธ migration ์ฒ˜๋ฆฌ๋œ ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜๋ฉด checksum ๊ฐ’์ด ๋ณ€๊ฒฝ ๋˜๋ฉด์„œ ํ•ด๋‹น ํŒŒ์ผ์˜ ๋‚ด์šฉ์ด ๋‹ค์‹œ migration ์ฒ˜๋ฆฌ ๋Œ€์ƒ์ด ๋œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

์œ„์™€ ๊ฐ™์€ ํŠน์ง•์œผ๋กœ ๋ณ„๋„์˜ ๋ฒ„์ „ ์ •๋ณด๋ฅผ ๋”ฐ๋กœ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๋Š”๋‹ค.

์‹œ๋“œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•  ๋•Œ Versioned migration ๋ณด๋‹ค Repeatable migration ์„ ์‚ฌ์šฉํ•˜๋ฉด ํŽธ๋ฆฌํ•œ ์ด์œ ๋„ ์œ„์—์„œ ์–ธ๊ธ‰ํ•œ ํŠน์ง•์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค. Versioned migration ์€ ๋ฒ„์ „, ์ฆ‰ ํŠน์ • ์‹œ์ ์˜ ์ƒํƒœ ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ  ๋”ฐ๋ผ์„œ ๋”ฑ ํ•œ ๋ฒˆ๋งŒ migration ์ฒ˜๋ฆฌ๊ฐ€ ๋œ๋‹ค. ๋”ฐ๋ผ์„œ ์‹œ๋“œ ๋ฐ์ดํ„ฐ๋ฅผ Versioned migration ์œผ๋กœ ๊ด€๋ฆฌํ•˜๋ฉด ์‹œ๋“œ ๋ฐ์ดํ„ฐ์˜ ์ถ”๊ฐ€ ๋ฐ ์‚ญ์ œ ์‹œ ๊ณ„์† ํ•ด์„œ ํŒŒ์ผ์„ ์ƒ์„ฑํ•ด์„œ ๋Œ€์‘ํ•ด์•ผ ํ•œ๋‹ค.

@rg3915
rg3915 / README.md
Created December 22, 2021 00:11
Alpine.js example
@gunlee01
gunlee01 / FiberTest.java
Created September 20, 2020 13:28
Project Loom, fiber(virtual thread) test generating stack trace.
package gunlee.demo.fiber;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
@novecentonove
novecentonove / alpineAxios.html
Created July 30, 2020 21:23
Alpine js / Axios Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<title>Alpine and axios</title>
</head>

Two approaches to handle error responses from Spring WebClient calls globally:

  • Exceptions with webclients are all wrapped in WebClientResponseException class. So we can handle that using Spring's ExceptionHandler annotation.

  • Using ExchangeFilterFunction while constructing the webclient bean.

With GitHub Actions, a workflow can publish artifacts, typically logs or binaries. As of early 2020, the life time of an artifact is hard-coded to 90 days (this may change in the future). After 90 days, an artifact is automatically deleted. But, in the meantime, artifacts for a repository may accumulate and generate mega-bytes or even giga-bytes of data files.

It is unclear if there is a size limit for the total accumulated size of artifacts for a public repository. But GitHub cannot reasonably let multi-giga-bytes of artifacts data accumulate without doing anything. So, if your workflows regularly produce large artifacts (such as "nightly build" procedures for instance), it is wise to cleanup and delete older artifacts without waiting for the 90 days limit.

Using the Web page for the "Actions" of a repository, it is possible to browse old workflow runs and manually delete artifacts. But the procedure is slow and tedious. It is fine to delete one selected artifact. It is not for a regular cleanup. We need

Singleton

  1. Roll-your-own lazy singleton

    public final class Single {
        private static Single INSTANCE;
        private Single() {}