'분류 전체보기'에 해당되는 글 1582건

  1. 2022.03.16 [Java] Read Properties File.
  2. 2022.03.15 [Gradle] build.gradle 에서 maven insecure protocol 설정
  3. 2022.03.14 [Shell] Bash String Replacement.
  4. 2022.03.14 [Python] pip upgrade.
  5. 2022.02.15 [Elasticsearch] Arirang classpath 미등록 시.
  6. 2022.02.10 [Elastic] Elastic Contributor Program - 2022, 2021
  7. 2022.01.28 [Elasticsearch] Exists Query...
  8. 2022.01.28 [Elasticsearch] Aggs - Cardinality, Derivative, Cumulative...
  9. 2022.01.24 [Python] pyenv install from local tar.xz 설치 하기.
  10. 2022.01.24 [Gradle] configurations 를 이용한 log4j dependency 반영

[Java] Read Properties File.

ITWeb/개발일반 2022. 3. 16. 15:19

일반 Java Application 프로젝트에서 resources 폴더 아래 application.properties 같은 정보를 가져와야 할 때가 있습니다.

아래 처럼 사용 하시면 됩니다.

 

application.properties)

host=localhost
port=8888

 

MainApplication.java)

public void readProperties() {
    Properties prop = new Properties();
    
    try ( InputStream stream = MainApplication.class.getClassLoader().getResourceAsStream("application"
    +".properties")) {
    	prop.load(Stream);
    } catch (Exception e) {
    }
    
    try {
    	Resource resource = new ClassPathResource("application.properties");
        prop.load(resource.getInputStream());
    } catch (Exception e) {
    }
    
    System.out.println( prop.getProperty("host") );
    System.out.println( prop.getProperty("port") );
}

 

:

[Gradle] build.gradle 에서 maven insecure protocol 설정

ITWeb/개발일반 2022. 3. 15. 12:39

maven. uri 설정 시 https 가 아닌 http 를 사용 할 경우 gradle 7.x 에서는 아래 설정을 추가해 주면 됩니다.

 

repositories {
	mavenCentral()
    
    maven {
    	url = uri("http://nexus.xxxxx.com/repository/snapshots")
        allowInsecureProtocol = true
    }
    
    maven {
    	url = uri("http://nexus.xxxxx.com/repository/public")
        allowInsecureProtocol = true
    }
}

 

:

[Shell] Bash String Replacement.

ITWeb/개발일반 2022. 3. 14. 12:14

docker-compose.yml 내 .env 를 이용한 활용이 안되는 경우 아래 처럼 그냥 string replacement 를 통해서 처리 할 수도 있습니다.

bash 에서  array, loop, replacement 에 대한 예제로 작성해 둡니다.

 

SERVICE_NAME='{{SERVICE_NAME}}=escs'
VERSION='{{VERSION}}=8.0.0'
CONTAINER_NAME='{{CONTAINER_NAME}}=escs-c'

DOCKER_VAR=( $SERVICE_NAME $VERSION $CONTAINER_NAME )

for var in "${DOCKER_VAR[@]}"; do
    kvs=($(echo $var | tr "=" "\n"))
    # linux
    sed -i "s/${kvs[0]}/${kvs[1]}/g" docker-compose.yml
    # osx
    sed -i '' "s/${kvs[0]}/${kvs[1]}/g" docker-compose.yml
done

 

:

[Python] pip upgrade.

ITWeb/개발일반 2022. 3. 14. 12:06

 

pip install 하다 보면 pip upgrade 를 하라는 메시지를 접할 때가 있습니다.

제공 하는 메시지는 'pip install --upgrade pip' 인데 이대로 실행 했을 경우 잘 안될 때는 아래와 같이 user 옵션을 주고 실행해 보시면 됩니다.

 

$ pip install --user --upgrade pip

 

:

[Elasticsearch] Arirang classpath 미등록 시.

Elastic/Elasticsearch 2022. 2. 15. 10:11

arirang plugin 을 사용 하면서 사전 데이터에 대한 classpath 설정은 했는데 config/dictionary path 생성을 하지 않았을 경우 reload api 가 동작 하지 않는다고 합니다.

 

이럴 경우 config/dictionary path 생성 하고 사전 데이터 배포 후 node 를 재시작 해주셔야 하는 번거로움이 있으니 초기 설치 시 꼭 사전 데이터에 대한 배포 후 실행을 해주시면 좋을 것 같습니다.

 

혹시 같은 실수 반복 할 수도 있어서 기록합니다.

:

[Elastic] Elastic Contributor Program - 2022, 2021

Elastic 2022. 2. 10. 13:03

2022년에는 방식이 변경 된다고 해서 활동을 거의 하지 않았는데 다행히 Bronze 를 주셨네요. ^^

참여 하고 싶으신 분들은 아래 링크 통해서 하시면 됩니다.

 

https://contributor-program.app.elstc.co/

Elastic Bronze Contributor 2022

 

Elastic Bronze Contributor 2021

:

[Elasticsearch] Exists Query...

Elastic/Elasticsearch 2022. 1. 28. 11:44

공식 문서)

Exists query | Elasticsearch Guide [7.16] | Elastic

 

exists query 는 field 자체가 아래 이유등으로 인해 생성 되자 않는 문서를 찾습니다.

즉, 

- null 또는 empty array (빈문자열 "" 은 해당 되지 않습니다.)

- index: false

- ignore_above 설정 값을 넘었을 때

- ignore_malformed 설정에 걸렸을 때

 

검색 엔진 특성상 null, empty string 에 대해서는 전처리를 통해서 명확히 제거 하거나 목적에 맞게 변형 하는 것이 좋습니다.

 

검색엔진을 이용해서 field:"" 또는 field: " " 과 같은 질의를 작성 하는 것은 좋지 않습니다.

 

:

[Elasticsearch] Aggs - Cardinality, Derivative, Cumulative...

Elastic/Elasticsearch 2022. 1. 28. 11:37

공식 문서)

Cardinality aggregation | Elasticsearch Guide [7.16] | Elastic

Derivative aggregation | Elasticsearch Guide [7.16] | Elastic

Cumulative cardinality aggregation | Elasticsearch Guide [7.16] | Elastic

 

현재 값과 직전 값에 대한 차이를 구합니다.

공식 문서에 자세한 내용들이 나와 있으니 보시면 좋습니다.

 

제가 사용 했던 예제는 공식 문서에 있는 거 활용 했습니다.

 

DAU 를 cardinality aggs 로 구하고 

Daily DAU 에 대한 누적 카운트를 cumulative_cardinality aggs 로 구하고 (여기서 buckets_path 는 cardinality aggs) 

Daily DAU 에 대한 변화를 derivative aggs 로 구했습니다. (여기서 buckets_path 는 cumulative_cardinality aggs)

 

아래는 공식 문서 예제 올려 둔 내용입니다.

GET /user_hits/_search
{
  "size": 0,
  "aggs": {
    "users_per_day": {
      "date_histogram": {
        "field": "timestamp",
        "calendar_interval": "day"
      },
      "aggs": {
        "distinct_users": {
          "cardinality": {
            "field": "user_id"
          }
        },
        "total_new_users": {
          "cumulative_cardinality": {
            "buckets_path": "distinct_users" 
          }
        }
      }
    }
  }
}

 

:

[Python] pyenv install from local tar.xz 설치 하기.

ITWeb/개발일반 2022. 1. 24. 12:12

맥북 기준으로 작성 합니다.

 

$HOME/.pyenv/cache

위 경로에 설치 하고자 하는 python tar.xz 파일을 다운로드 받아서 넣어 두고 진행을 하면 됩니다.

 

$ wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tar.xz 

$ mv ~/Downloads/Python-3.9.9.tar.xz ~/.pyenv/cache/

$ pyenv install 3.9.9

 

이와 같이 하면 설치가 가능 합니다.

사내 보안 정책으로 설치가 안될 경우 활용 하면 됩니다.

 

:

[Gradle] configurations 를 이용한 log4j dependency 반영

ITWeb/개발일반 2022. 1. 24. 11:40

최근에 발생한 log4j 보안 이슈로 인해서 patch 작업이 필요 했었는데요.

build.gradle 에서 configurations 를 이용해서 쉽게 적용 할 수 있는 방법인데 기억하기 위해 이것도 기록해 봅니다.

 

관련 보안 내용은 아래 링크 참고 하시면 됩니다.

Log4j – Apache Log4j Security Vulnerabilities

 

Log4j – Apache Log4j Security Vulnerabilities

<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apa

logging.apache.org

build.gradle)

configuration {
  all {
  	resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    	if ( details.requested.group == 'org.apache.logging.log4j' ) {
        	details.useVersion '2.17.1'
        }
    }
  }
  
  compileOnly {
    extendsFrom annotationProccessor
  }
}

 

: