Skip to content

Instantly share code, notes, and snippets.

View gksxodnd007's full-sized avatar

hubert gksxodnd007

View GitHub Profile
@gksxodnd007
gksxodnd007 / RedisSecurity.md
Last active April 14, 2018 16:18
Redis Security

Redis의 데이터 보호하기

Redis는 많은 곳에 적용 할 수 있는 훌륭한 IN-Memory NoSQL DB이다. 세션 관리를 위해 Redis를 많이 사용하는데 누군가에게 데이터를 탈취 당한다면 인증을 하지않은 사용자가 서버를 휘젓고 다닐 수 있다. 그렇기 때문에 Redis 인스턴스를 보호하는 것은 굉장히 중요하다.

다음과 같이 세 가지 방법으로 Redis 인스턴스들을 보호할 수 있다.

  • 비밀번호 설정하기
  • 커맨드 명령어 바꾸기
  • 네트워크 보안
@gksxodnd007
gksxodnd007 / Lambda.md
Last active April 18, 2018 04:12
java8 Lambda

람다식이란?

람다식(Lambda expression)은 간단히 말해서 메서드를 하나의 '식(expression)'으로 표현한 것이다. 메서드를 람다식으로 표현하면 메서드의 이름과 반환값이 없어지므로, 람다식을 '익명 함수(anonymous function)'이라고도 한다.

int[] arr = new int[5];
Arrays.setAll(arr, i -> (int)Math.random() * 5) + 1;
@gksxodnd007
gksxodnd007 / Stream.md
Last active July 15, 2020 02:50
Stream개념 소개

스트림이란?

JDK 8에서 추가된 Stream API에 대해서 알아보자.(파일 I/O에서 사용되는 스트림과는 다르다.)스트림은 데이터소스를 추상화하고, 데이터를 다루는데 자주 사용되는 메서들을 정의해 놓았다. 데이터소스를 추상화하였다는 것은, 데이터 소스가 무엇이든 같은 방식으로 다룰 수 있게 되었다는 것과 코드의 재사용성이 높아진다는 것을 의미한다. 먼저, 코드를 보면서 차이를 느껴보자.

//Stream 사용 전
String[] strArr = { "mash-up", "backend", "codingsquid" }
List<String> strList = Arrays.asList(strArr);

Arrays.sort(strArr);
Collections.sort(strList);
@gksxodnd007
gksxodnd007 / java-String.md
Last active June 3, 2018 14:43
String vs StringBuffer vs StringBuilder

이 글에서 각 클래스의 사용법을 설명하지는 않겠다. 각 클래스들의 특징과 성능적인 관점에서 비교해보고자 포스팅을 하는 것이기 때문이다.

비교

코드부터 보자.

final String value="abcde";

for (int i = 0; i &lt; 10; i ++) {
@gksxodnd007
gksxodnd007 / jpaConfig.md
Last active July 15, 2018 09:33
spring data jpa & hibernate bean config.md
    @Bean(destroyMethod = "close")
    public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        vendorAdapter.setGenerateDdl(true);
        vendorAdapter.setShowSql(true);

        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
        factory.setJpaVendorAdapter(vendorAdapter);
        factory.setPackagesToScan("org.codingsquid.isolation.entity");
@gksxodnd007
gksxodnd007 / gradle.md
Last active August 13, 2018 06:42
Gradle 기초

Gradle

Gradle Wrapper를 사용하는 목적

  • 이미 존재하는 프로젝트를 새로운 환경에 설치할때 별도의 설치나 설정과정없이 곧 바로 빌드할 수 있게 하기 위함(Java나 Gradle도 설치할 필요가 없음. 또한 로컬에 설치된 Gradle 또는 Java의 버전도 신경쓸 필요가 없음. 따라서 항상 Wrapper를 사용할 것을 권장.)

gradlew 파일

  • 유닉스용 실행 스크립트.
  • Gradle로 컴파일이나 빌드 등을 할때, 아래와 같이 하면 로컬에 설치된 gradle을 사용.
> gradle build
@gksxodnd007
gksxodnd007 / springBatchTerms.md
Created July 24, 2018 02:28
spring batch terms

Spring Batch Terms

Job

In Spring Batch, a Job is simply a container for Steps. It combines multiple steps that belong logically together in a flow and allows for configuration of properties global to all steps, such as restartability.

The job configuration contains

  • The simple name of the job
  • Definition and ordering of Steps
@gksxodnd007
gksxodnd007 / springBatchJobConfig.md
Created July 24, 2018 02:29
spring batch job config

Spring Batch Configuring Job

Restartability

if you want to restart the Job with new JobInstance. you have to setting option like below

<job id="footballJob" restartable="false">
    ...
@gksxodnd007
gksxodnd007 / springBatchStepConfig.md
Created July 24, 2018 02:30
spring batch step config

Configuring a Step

TaskletStep

Chunk-oriented processing is not the only way to process in a Step. What if a Step must consist as a simple stored procedure call? You could implement the call as an ItemReader and return null after the procedure finishes, but it is a bit unnatural since there would need to be a no-op ItemWriter. Spring Batch provides the TaskletStep for this scenario.

The Tasklet is a simple interface that has one method, execute, which will be a called repeatedly by the TaskletStep until it either returns RepeatStatus.FINISHED or throws an exception to signal a failure. Each call to the Tasklet is wrapped in a transaction. Tasklet implementors might call a stored procedure, a script, or a simple SQL update statement

  • example code
@gksxodnd007
gksxodnd007 / springboot-logback.md
Created August 12, 2018 04:21
스프링부트 Log back 설정

Spring boot logback 설정

  • classpath(resource디렉토리 밑)에 logback-spring.xml파일이 있으면 Boot가 설정파일을 읽어감.
  • logback-spring.xml파일이 없다면 .yml(.properties)파일의 설정을 보게됨.

설정시 특징

<appender name="privateLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <file>${LOG_PATH}/private.${port:-default}.log</file>