Skip to content

Instantly share code, notes, and snippets.

View djkeh's full-sized avatar
🏢
Working

Uno Kim djkeh

🏢
Working
View GitHub Profile
@djkeh
djkeh / kotlin-logging-style-guide.md
Last active October 20, 2023 02:48
kotlin-logging 사용법: logger 스타일 가이드

개요: kotling-logging 사용법

kotlin-logging에서 logger를 선언하는 방법은 2가지로 정리할 수 있다.

1. 표준안, 정석: static logger outside class

import io.github.oshai.kotlinlogging.KotlinLogging

private val logger = KotlinLogging.logger {} // 로거를 클래스 밖에 두는 방법
@djkeh
djkeh / .gitignore
Created August 16, 2022 01:38
Querydsl Configuration on Gradle - Spring Boot 2.7 + Querydsl 5.0.0 + Gradle 7.4.1
### Querydsl
/src/main/generated
@djkeh
djkeh / ThymeleafConfig.java
Last active January 3, 2024 07:27
Thymeleaf Decoupled Logic configuration for Spring Boot + Thymeleaf 3
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
@Configuration
public class ThymeleafConfig {
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver(
@djkeh
djkeh / AbstractSerializableParameterTest.java
Created September 11, 2020 09:24
Test case which shows a bug on AbstractSerializableParameter in io.swagger:swagger-models:1.5.20
package com.example.bootdemo;
import io.swagger.models.parameters.AbstractSerializableParameter;
import io.swagger.models.properties.BaseIntegerProperty;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
@djkeh
djkeh / DataSourceConfig.java
Last active July 9, 2020 03:34
Sample codes of reading user-custom yaml files as ConfigurationProperties of Spring Boot.
package com.your.project.config;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
@djkeh
djkeh / git-branches-by-commit-date.sh
Created February 20, 2020 04:05 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@djkeh
djkeh / tailc
Created November 28, 2019 04:12 — forked from liufuyang/tailc
Color output of linux tail command
#!/bin/bash
# save this file as tailc then
# run as: $ tailc logs/supplier-matching-worker.log Words_to_highlight
file=$1
if [[ -n "$2" ]]; then
color='
// {print "\033[37m" $0 "\033[39m"}
/(WARN|WARNING)/ {print "\033[1;33m" $0 "\033[0m"}
/(ERROR|CRIT)/ {print "\033[1;31m" $0 "\033[0m"}
@djkeh
djkeh / TestController.java
Created September 8, 2017 09:03
@RequestMapping 상속 문제 정리
package my.controllertest.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* 이 문제의 수동 테스트 결과는 "/path/home" 이다.<br>
* 1. 자식클래스의 "path"가 부모 클래스나 인터페이스를 override했기 때문.<br>
* 2. 자식클래스 "path"를 제거할 경우 답은 "/if/home" 이다.<br>
* 3. 자식 인터페이스 "if"를 제거할 경우 답은 "/superif/home"<br>
@djkeh
djkeh / BootApplication.java
Last active November 23, 2021 20:53 — forked from seanhinkley/BootApplication.java
Spring Boot 1.5.4.RELEASE + Thymeleaf 3.0.7.RELEASE (Gradle)
package com.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
@SpringBootApplication(exclude = ThymeleafAutoConfiguration.class)
public class BootApplication {
public static void main(String[] args) {
SpringApplication.run(AppSecurityApplication.class, args);
@djkeh
djkeh / BeanConfig.java
Last active April 30, 2020 02:40
프로토타입 빈 + InjectionPoint를 이용한 최신 스프링 Logger 주입 예제 코드
// 스프링 4.3부터 추가된 InjectionPoint를 이용한 Context-Aware Bean 생성 방법.
@Configuration
public class BeanConfig {
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
Logger logger(InjectionPoint injectionPoint) {
return LoggerFactory.getLogger(injectionPoint.getMethodParameter().getContainingClass());
}
}