설치

sudo apt update && sudo apt upgrade

sudo apt install openjdk-19-jdk openjdk-19-jre

 

환경변수설정

readlink -f $(which java)  	#readlink -f 는 심볼릭 링크와 연결된 절대경로 보기

vim /etc/profile 			#root계정의 환경변수 설정

#or

vim ~/.profile				#접속계정의 환경변수 설정

 

아래 2줄을 맨 마지막에 추가

export JAVA_HOME=/usr/lib/jvm/java-19-openjdk-amd64		#경로는 자바 설치 경로로 readlink 명령어 결과
export PATH=${PATH}:${JAVA_HOME}/bin

 

적용시키기

source /etc/profile

# or

source ~/.profile

Azure Template을 이용해 바로 MS Azure에 배포가 가능하다!

 

 

https://github.com/azure/azure-quickstart-templates

 

Azure/azure-quickstart-templates

Azure Quickstart Templates. Contribute to Azure/azure-quickstart-templates development by creating an account on GitHub.

github.com

 

+유료 템플릿도 있다하니 유심히 보자!

From Array to List


1
2
Integer[] numArray = {1,2,3,4,5};
List<Integer> numList = Arrays.asList(numArray);        
cs


From List to Array


1
2
3
4
5
6
List<Integer> numList = new ArrayList<Integer>();
numList.add(1);
numList.add(2);
numList.add(3);
numList.add(4);
numArray = numList.toArray(new Integer[numList.size()]);
cs

추가


From Array to ArrayList


1
2
Integer[] numArray = {1,2,3,4,5};
ArrayList<Integer> numList = new ArrayList<Integer>(Arrays.asList(numArray));
cs


1
2
int[] numArray = {1,2,3,4,5};
ArrayList<Integer> numList = new ArrayList<Integer>(Arrays.stream(numArray).boxed().collect(Collectors.toList()));
cs


1
2
3
//String -> ArrayList<Character>
String s = "test";
ArrayList<Character> ss = new ArrayList<Character>(s.chars().mapToObj(x -> (char)x).collect(Collectors.toList()));
cs


매번 깃허브 페이지에 들어가 Repo 만드는 것조차 귀찮은 분들을 위한 글입니다.


명령어 하나로 깃헙 레포지토리 생성과 commit 및 push를 한번에 처리하는 방법입니다.



터미널을 키신 후 bin 아래에 스크립트를 작성합니다.

1
vi /usr/local/bin/git-build
cs


아래와 같이 작성해주세요.

세부 내용은 각자에 맞게 바꿔주시면 됩니다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash 
# Set your GitHub username and email 
# 레포지토리 이름을 설정하는 부분입니다.
# 여기서는 명령어를 실행한 디렉토리 이름을 레포지토리 이름으로 씁니다.
# 만약 규칙을 원하신다면 편의에 맞게 바꾸시면 될 것 같아요.
repo_name=$1
dir_name=`basename $(pwd)`
if [ "$repo_name" = "" ]; then
  repo_name=$dir_name
fi
# 깃헙 계정 정보를 넣어주세요.
export GITHUB_USERNAME="깃허브유저이름" 
export GITHUB_EMAIL="깃허브이메일" 
git config --global user.name "${GITHUB_USERNAME}" 
git config --global user.email "${GITHUB_EMAIL}" 
git config --global credential.helper cache 
git config --global credential.helper 'cache --timeout=3600' 
echo "MAKE REPO IN GITHUB"
curl -"${GITHUB_USERNAME}" https://api.github.com/user/repos -"{\"name\":\"$repo_name\"}"
echo "[Info] Creating Local Git Repository ...."
git init
git add . 
# 디폴트로 'Init'이 커밋 메세지로 들어가게 했어요.
# 이 부분 또한 편의에 맞게 바꿔 주시면 됩니다!
git commit -"Init"
git remote add origin https://github.com/${GITHUB_USERNAME}/$repo_name.git
echo "[Info] Pushing local repository master branch to Github origin/master branch..."
git push -u origin master
cs



마지막으로 해당 스크립트를 실행가능하게 해줍니다.


1
chmod +x /usr/local/bin/git-build
cs



이제 프로젝트 루트 폴더 안에서 git build 명령어 하나로 깃헙에 repo 생성부터 커밋, 푸시까지 바로 됩니다!


1
git build
cs





아래의 글을 참조해서 만들었습니다.

https://rorlab.org/rblogs/239

https://developer.github.com/v3/repos/#create




'CODING > ETC' 카테고리의 다른 글

Azure Template  (0) 2019.04.24
빅데이터에 대한 좋은 개념 글  (0) 2019.01.24
프로세스 및 쓰레드에 대한 좋은 설명 글  (0) 2019.01.21
.gitignore 수정 후 재적용  (0) 2018.11.13
GIT 파일 추적 끄기  (0) 2018.09.26

https://www.samsungsds.com/global/ko/support/insights/1196824_2284.html

https://mooneegee.blogspot.com/2015/01/



https://m.blog.naver.com/itperson/220821884483

'CODING > ETC' 카테고리의 다른 글

Azure Template  (0) 2019.04.24
터미널에서 깃허브 Repo 만들고 커밋 및 푸시하기  (0) 2019.03.02
빅데이터에 대한 좋은 개념 글  (0) 2019.01.24
.gitignore 수정 후 재적용  (0) 2018.11.13
GIT 파일 추적 끄기  (0) 2018.09.26

장고에서 로그 찍는 방법에 대한 설명을 적어봅니다.



장고는 python의 Logging 모듈을 그대로 사용합니다.


Logging 모듈 문서는 아래의 링크에서 확인하실 수 있어요.


https://docs.python.org/3.6/library/logging.html?highlight=logging#module-logging




파이썬 Logging 모듈은 총 4가지로 구성됩니다.


Logger, Handler, Formatter, Filter


자세한 설명은 python 다큐멘테이션과 아래의 장고 다큐멘테이션에서 확인 할 수 있습니다!


https://docs.djangoproject.com/en/2.1/topics/logging/



저는 간단히 복붙할 수 있는 코드만 나열하고 어떤 의미인지만 설명할게요.



우선 날짜별, 시간별로 로그파일을 저장할때는 handler 모듈 중에서 TimedRotatingFileHandler를 이용합니다.



아래와 같이 장고 프로젝트 디렉토리 안의 settings.py에 아래와 같은 코드를 입력하면 지정한 경로에 차근차근 로그 파일이 저장되게 됩니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# projectDir/settings.py
 
# 우선 저장될 로그의 기본 이름과 위치를 지정합니다.
LOG_FILE = 'custom/path/to/save/log/myLog.log'
 
 
# 만약 settings.py가 위치한 디렉토리 기준으로 로그를 저장하고 싶다면 아래와 같이 코드를 입력하면 됩니다.
# import os
# LOG_FILE = os.path.join(os.path.dirname(__file__), '../log', 'myLog.log')
# 저는 settings.py 가 위치한 디렉토리의 상위에 log 라는 폴더를 만들어서 그곳에 파일을 저장했으며, 위의 코드는 그것을 의미합니다.
# 만약 자신만의 위치에 지정하고 싶다면 아래와 같은 코드를 입력하면 됩니다.
 
 
LOGGING = { 
    'version'1
    'disable_existing_loggers': False, 
    'formatters': {
        'myFormatt': {
            'format''[{levelname}] [{asctime}] [{process:d}] [{thread:d}]: {message}',
        },
    },
    'handlers': { 
        'file': { 
            'level''DEBUG'
            'class''logging.handlers.TimedRotatingFileHandler'
            'filename': LOG_FILE, # 위에 선언한 파일 이름
            'when'"midnight"# 매 자정마다
            'formatter''myFormatt'
            'backupCount':5
            }, 
        }, 
        'loggers': {
            'myLog': { 
                'handlers': ['file'], 
                'level''DEBUG'
            }, 
        }
    }
 
cs



현재 날짜에 해당하는 로그는 위에서 지정한 기본 파일 이름으로 저장되며, 하루가 지난 로그 들은 찍힌 날짜가 파일명 뒤에 붙어서 아래와 같은 형태로 저장되게 됩니다.



1
2
3
4
5
6
log/
├── myLog.log
├── myLog.log.2018-11-11
├── myLog.log.2018-11-12
├── myLog.log.2018-11-13
└── myLog.log.2018-11-14
cs



이 외에도 분단위로 시간단위로 특정 기간 단위로 저장할 수 있습니다. 또한, 필터를 이용해 원하는 내용만 필터링 한다거나, 원하는 포멧을 만들어서 특정 데이터를 얻는 등의 다양한 로그를 찍을 수 있습니다.

이에 해당하는 내용은 위에 언급한 다큐멘테이션 링크에서 확인할 수 있습니다~!

MySQL에서 sql 쿼리 파일을 불러오거나 실행하는 명령어입니다.



In MySQL Command Line

1
source path/to/file.sql
cs



In Linus Shell

1
mysql -u userId -p dbName < path/to/file.sql
cs


'CODING > MYSQL' 카테고리의 다른 글

2017_10_10_MySQL_기본_명령어(쿼리문)  (0) 2017.10.10

+ Recent posts