출퇴근 시스템 업데이트로 수동으로 근무시간을 업데이트해야 했다. 출퇴근 시간이 생각이 안나서 PC 로그인 기록을 찾아봤다. 윈도우 + R 키를 눌러 실행 창에서 eventvwr.msc 를 입력해 이벤트 뷰어를 실행시켰다.

왼쪽 메뉴 트리에서 이벤트 뷰어(로컬) > Windows 로그 > 보안을 선택하자.

오른쪽 메뉴에서 현재 로그 필터링을 선택하고 이벤트 아이디에 4624(로그인), 4634(로그오프) 를 입력하자.

내역을 보면 계정 이름이 SYSTEM 이 제일 많이 보일텐데 무시하고 자신이 로그인한 계정을 찾으면 된다.

참고 : https://keefojifo.tistory.com/29

 

개인 PC 윈도우 로그인 기록 확인 방법

실행 (윈도우 + R) ----> eventvwr.msc (이벤트 뷰어) 를 입력 이벤트 뷰어(로컬) -->  Windows 로그 --> 보안 로그인 이벤트 ID 4624 로그오프 이벤트 ID 4634 필터를 사용하여 작업범주에 이벤트 ID를 넣고..

keefojifo.tistory.com

 

728x90

문자열 데이터에서 중복 문자열을 제거하고 싶을 때가 있다. 

Notepad++ 에서는 TextFX 라는 플러그인을 이용하면 된다. 안타깝게도 이 플러그인은 32bit 용만 제공된다.

플러그인 설치 후 재시작하면 TextFX 메뉴가 보인다. 먼저 TextFX > TextFX Tools > +Sort outputs only UNIQUE (at column) lines 를 체크한다. 적용할 문자열을 선택하고 위에 있는 Sort lines case sensitive (at column) 이나 Sort lines case insensitive (at column) 을 선택하면 중복이 제거된 정렬된 문자열을 획득할 수 있다.

EditPlus3 나 TextCrawler 를 이용해서 중복 문자열을 제거할 수 있다.

출처 : https://donghaerang.tistory.com/1552

 

텍스트의 중복 라인을 제거하는 3가지 방법

중복줄을 제거하는 방법을 설명드리겠습니다. 여기에서 소개해드릴 방법은 3가지로, 각각 EditPlus3, TextCrawler, Notepad++라는 프로그램을 이용한 방법입니다. EditPlus3를 이용하는 방법 1. EditPlus3를 실

donghaerang.tistory.com

 

728x90

복붙한 문자열 앞뒤에 있는 탭이나 스페이스로 이루어진 공백을 제거해야할 때가 있다. 

Notepad++ 에서는 편집 > 공백 기능(B) > 줄 시작/끝 공백 제거를 선택하면 된다.

중복된 줄바꿈의 경우에는 정규식을 이용해서 제거하면 된다. \r\n(\r\n)+ 을 \r\n 으로 변경하여 줄바꿈이 여러번 된 곳을 한번으로 제거하자.

728x90

 

long 형식의 경우 윈도우즈 Visual C++ 의 경우 32bit 로 처리되고 unix 에서는 64 bit 로 처리된다. max 가 다르니 cast 도 주의해야겠지만 이번에 겪은 문제는 long* 에 int * 주소를 넘기는 바람에 access violation 을 일으켰다.

참고 : https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models

 

64-bit computing - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search Computer architecture bit width "64-bit" redirects here. For 64-bit images in computer graphics, see Deep color. In computer architecture, 64-bit integers, memory addresses, or other d

en.wikipedia.org

http rest api 테스트로 많이 사용하는 curl 이라는 cli 로 더 유명하겠지만 libcurl 이라고 http client library 가 있다.

https://curl.se/

 

curl

command line tool and library for transferring data with URLs (since 1998) Time to donate to the curl project? Everything curl is a detailed and totally free book that explains basically everything there is to know about curl, libcurl and the associated pr

curl.se

curl_easy_getinfo api 에서 CURLINFO_RESPONSE_CODE 에 대해 long* 로 넘긴 주소에 결과값을 전달해 준다.

#include <curl/curl.h>
 
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
CURL *curl = curl_easy_init();
if(curl) {
  CURLcode res;
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  res = curl_easy_perform(curl);
  if(res == CURLE_OK) {
    long response_code;
    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
  }
  curl_easy_cleanup(curl);
}

 

 

출처 : https://curl.se/libcurl/c/curl_easy_getinfo.html

 

libcurl - curl_easy_getinfo()

curl_easy_getinfo - extract information from a curl handle Name curl_easy_getinfo - extract information from a curl handle Synopsis #include   CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... ); Description Request internal information from the c

curl.se

https://curl.se/libcurl/c/CURLINFO_RESPONSE_CODE.html

 

CURLINFO_RESPONSE_CODE

CURLINFO_RESPONSE_CODE explained Name CURLINFO_RESPONSE_CODE - get the last response code Synopsis #include   CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep); Description Pass a pointer to a long to receive the last received

curl.se

int responseCode = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);

vc++ 에서는 이 코드가 컴파일도 잘 되고 문제가 없었지만 linux 에서는 curl 호출 후 scope 나갈 때 std::string destructor 에서 터지는 이상한 문제가 발생했다.

case CURLINFO_RESPONSE_CODE:
    *param_longp = data->info.httpcode;
    break;

long* 에 int 형 데이터 주소를 넘기니 내부에서 int* 형 주소에 long 형식의 데이터를 write 하다가 int* 다음 영역의 데이터를 오염시켜서 발생하는 문제였다. 

불행히 curl_easy_getinfo 가 가변 변수 함수라 컴파일 타임에 잡아 낼 수 없었다.

예전엔 short, int 같은 형식을 선호했었는데 이제는 int8, int16, int32 와 같이 비트가 명시된 형식을 선호하게 되었다.

728x90

ssh 클라이언트로 putty 를 사용하고 있는데 사이트 목록 관리가 아쉽다.

Session 을 저장해서 사용할 수는 있지만 그룹화도 안되고 불편하다.

SuperPuTTY 홈페이지 : https://github.com/jimradford/superputty

 

GitHub - jimradford/superputty: The SuperPuTTY Window Manager for putty sessions

The SuperPuTTY Window Manager for putty sessions. Contribute to jimradford/superputty development by creating an account on GitHub.

github.com

다른 사람들은 SecureCRT 쓰는 것 같은데 유료라 라이센스 받는 것도 귀찮고 해서 무료로 찾다보니 SuperPuTTY 라는 것을 발견했다.

putty 를 사용하는 wrap 프로젝트라. PuTTY 경로를 설정해야 한다.

오른쪽에 목록을 저장할 수 있고 세션을 열면 탭으로 관리된다. 

창 레이아웃 설정이 살짝 아쉬운데 무료니깐...

728x90

한글 지원되는 코딩용 폰트가 거의 없다.

텍스트 편집기에서는 윈도우 기본 폰트인 맑은 고딕을 주로 사용했는데 가변폭이라서 별로다.

예전엔 굴림체를 주로 사용했는데 가독성이 좋지 않다.

 

검색해보니 D2 Coding 이 거의 유일한 한글 지원하는 코딩 폰트 같다. 나눔바른고딕 기반으로 코딩 가독성을 높였다고 한다.

난 사용하지 않지만 ligature 도 지원한다.

홈페이지 : https://github.com/naver/d2codingfont

 

GitHub - naver/d2codingfont: D2 Coding 글꼴

D2 Coding 글꼴. Contribute to naver/d2codingfont development by creating an account on GitHub.

github.com

 

728x90

회사에서 csv 형태로 된 로그나 기획 데이터를 볼 일이 많다. 

Notepad ++ 이나 Editplus 같은 텍스트 편집기로 볼 수도 있지만 rainbow csv 라는 확장툴을 알고 나서는 Visual Studio Code 를 애용하고 있다.

일단 칼럼별로 색상이 다르게 보여서 유용하다.

커맨드 팔레트를 열어서 Rainbow CSV: Align CSV columns 를 선택하면 칼럼들을 정렬시켜서 보여준다.

안타깝게도 가로 폭이 긴 CJK 문자가 들어갈 경우 정렬에 문제가 있다. :(

 

728x90

linux 에서 로그 볼 일이 많다보니 grep 사용이 잦다.

2022-03-19 1:21 | WARN  | warning 
2022-03-19 1:21 | WARN  | warning
2022-03-19 1:22 | FATAL | fatal
2022-03-19 1:23 | ERROR | error
2022-03-19 1:24 | INFO  | info
2022-03-19 1:25 | WARN  | warning
2022-03-19 1:22 | FATAL | no fatal
2022-03-19 1:23 | ERROR | no error

위와 같은 로그가 있을 때 WARN 문자열이 포함을 찾는 다음 아래와 같이 사용한다.

$ grep "WARN" log.txt
2022-03-19 1:21 | WARN  | warning
2022-03-19 1:25 | WARN  | warning

WARN 이 포함되지 않은 라인을 찾는 다면 아래와 같이 -v 옵션을 사용하면 된다.

$ grep -v "WARN" log.txt
2022-03-19 1:22 | FATAL | fatal
2022-03-19 1:23 | ERROR | error
2022-03-19 1:24 | INFO  | info
2022-03-19 1:22 | FATAL | no fatal
2022-03-19 1:23 | ERROR | no error

-v 는 invert match 라고 한다.

$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE.
Example: grep -i 'hello world' menu.h main.c

Pattern selection and interpretation:
  -E, --extended-regexp     PATTERN is an extended regular expression
  -F, --fixed-strings       PATTERN is a set of newline-separated strings
  -G, --basic-regexp        PATTERN is a basic regular expression (default)
  -P, --perl-regexp         PATTERN is a Perl regular expression
  -e, --regexp=PATTERN      use PATTERN for matching
  -f, --file=FILE           obtain PATTERN from FILE
  -i, --ignore-case         ignore case distinctions
  -w, --word-regexp         force PATTERN to match only whole words
  -x, --line-regexp         force PATTERN to match only whole lines
  -z, --null-data           a data line ends in 0 byte, not newline

Miscellaneous:
  -s, --no-messages         suppress error messages
  -v, --invert-match        select non-matching lines
  -V, --version             display version information and exit
      --help                display this help text and exit

Output control:
  -m, --max-count=NUM       stop after NUM selected lines
  -b, --byte-offset         print the byte offset with output lines
  -n, --line-number         print line number with output lines
      --line-buffered       flush output on every line
  -H, --with-filename       print file name with output lines
  -h, --no-filename         suppress the file name prefix on output
      --label=LABEL         use LABEL as the standard input file name prefix
  -o, --only-matching       show only the part of a line matching PATTERN
  -q, --quiet, --silent     suppress all normal output
      --binary-files=TYPE   assume that binary files are TYPE;
                            TYPE is 'binary', 'text', or 'without-match'
  -a, --text                equivalent to --binary-files=text
  -I                        equivalent to --binary-files=without-match
  -d, --directories=ACTION  how to handle directories;
                            ACTION is 'read', 'recurse', or 'skip'
  -D, --devices=ACTION      how to handle devices, FIFOs and sockets;
                            ACTION is 'read' or 'skip'
  -r, --recursive           like --directories=recurse
  -R, --dereference-recursive  likewise, but follow all symlinks
      --include=FILE_PATTERN  search only files that match FILE_PATTERN
      --exclude=FILE_PATTERN  skip files and directories matching FILE_PATTERN
      --exclude-from=FILE   skip files matching any file pattern from FILE
      --exclude-dir=PATTERN  directories that match PATTERN will be skipped.
  -L, --files-without-match  print only names of FILEs with no selected lines
  -l, --files-with-matches  print only names of FILEs with selected lines
  -c, --count               print only a count of selected lines per FILE
  -T, --initial-tab         make tabs line up (if needed)
  -Z, --null                print 0 byte after FILE name

Context control:
  -B, --before-context=NUM  print NUM lines of leading context
  -A, --after-context=NUM   print NUM lines of trailing context
  -C, --context=NUM         print NUM lines of output context
  -NUM                      same as --context=NUM
      --color[=WHEN],
      --colour[=WHEN]       use markers to highlight the matching strings;
                            WHEN is 'always', 'never', or 'auto'
  -U, --binary              do not strip CR characters at EOL (MSDOS/Windows)

When FILE is '-', read standard input.  With no FILE, read '.' if
recursive, '-' otherwise.  With fewer than two FILEs, assume -h.
Exit status is 0 if any line is selected, 1 otherwise;
if any error occurs and -q is not given, the exit status is 2.

Report bugs to: bug-grep@gnu.org
GNU grep home page: <http://www.gnu.org/software/grep/>
General help using GNU software: <http://www.gnu.org/gethelp/>

참고 : https://stackoverflow.com/questions/3548453/negative-matching-using-grep-match-lines-that-do-not-contain-foo

 

Negative matching using grep (match lines that do not contain foo)

I have been trying to work out the syntax for this command: grep ! error_log | find /home/foo/public_html/ -mmin -60 OR: grep '[^error_log]' | find /home/baumerf/public_html/ -mmin -60 I need ...

stackoverflow.com

 

728x90
exit

배치 스크립트 종료할 때 exit 로 종료하면 실행한 명령창도 같이 종료된다.

goto :eof

'goto :eof' 를 사용하면 실행한 스크립트만 종료된다.

참고 : https://www.lesstif.com/software-architect/batch-17105830.html

 

윈도 배치(Batch) 파일 프로그래밍 팁

ELSE 는 IF의 닫는 괄호와 같은 라인에 있어야 함.

www.lesstif.com

 

728x90
(1) 다른 프로그램이 같은 파일을 고치고 있는중일 수 있습니다.
    만약 그렇다면 같은 파일을 두 개의 프로그램에서 고치지 않도록
    조심하시기 바랍니다. 종료하세요. 계속하시려면 주의하세요.
(2) 이 파일을 고치다가 죽었었습니다.
    만약 그렇다면 ":recover" 혹은 "vim -r a.txt"
    을 사용하여 복구하십시오 (":help recovery" 참고).
    이미 복구하셨었다면 스왑파일 ".a.txt.swp"
    을(를) 지우셔야 이 메시지가 사라집니다.

스왑 파일 ".a.txt.swp"이 이미 존재합니다!
읽기 전용으로 열기([O]), 그냥 고치기((E)), 복구((R)), 끝내기((Q)), 버리기((A)):

오랜만에 linux 에서 작업하고 있다. ssh 접속해서 서버 로그를 vi 로 볼 일이 많다. 여러 사람이 같이 보다 보면 읽기 전용으로 열 것인지 물어보는 게 신경쓰인다.

$ vi --help
VIM - Vi IMproved 8.2 (2019 Dec 12, 빌드한 날짜 Jun  1 2020 06:42:35)

사용법: vim [인자] [파일 ..]       주어진 파일 고치기
   혹은: vim [인자] -               표준입력에서 텍스트 읽기
   혹은: vim [인자] -t tag          태그가 정의된 위치에서 파일 고치기
   혹은: vim [인자] -q [에러파일]   첫 번째 에러가 난 파일 고치기

인자:
   --                   이 뒤에는 파일 이름만
   -v                   Vi 모드 ("vi"와 같음)
   -e                   Ex 모드 ("ex"와 같음)
   -E                   향상된 Ex 모드
   -s                   조용한 (배치) 모드 ("ex"만)
   -d                   Diff 모드 ("vimdiff"와 같음)
   -y                   쉬운 모드 ("evim"과 같음, modeless)
   -R                   읽기 전용 모드 ("view"와 같음)
   -Z                   제한된 모드 ("rvim"과 같음)
   -m                   수정(파일 쓰기)이 허용되지 않음
   -M                   텍스트 수정이 허용되지 않음
   -b                   이진 상태
   -l                   리스프 상태
   -C                   Vi 호환: 'compatible'
   -N                   Vi와 호환되지 않음: 'nocompatible'
   -V[N][fname]         Be verbose [level N] [fname에 메시지 저장]
   -D                   디버깅 모드
   -n                   스왑 파일 없이 메모리만 사용
   -r                   스왑 파일 목록을 표시한 뒤 끝내기
   -r (파일 이름과 함께)        파손되었던 세션 복구
   -L                   -r과 같음
   -A                   Arabic 모드로 시작
   -H                   Hebrew 모드로 시작
   -T <terminal>        터미널 종류를 <terminal>로 설정
   --not-a-term         터미널에 입출력할 수 없다는 경고하지 않음
   --ttyfail            터미널에 입출력할 수 없는 경우 종료
   -u <vimrc>           .vimrc 대신 <vimrc>를 사용
   --noplugin           플러그인 스크립트를 불러들이지 않음
   -p[N]                N개의 탭 열기 (기본: 파일별로 하나)
   -o[N]                N개의 창 열기 (기본: 파일별로 하나)
   -O[N]                -o와 같지만 창을 수직으로 나누기
   +                    파일 마지막에서 시작
   +<lnum>              <lnum> 줄에서 시작
   --cmd <명령> vimrc 파일을 읽기 전에 <명령>을 실행
   -c <명령>            첫째 파일을 읽은 뒤 <명령>을 실행
   -S <세션>            첫째 파일을 읽은 뒤 <세션> 파일 불러 들이기
   -s <scriptin>        <scriptin> 파일에서 Normal 상태 명령 읽기
   -w <scriptout>       모든 입력된 명령을 <scriptout> 파일에 추가
   -W <scriptout>       모든 입력된 명령을 <scriptout> 파일에 저장
   -x                   암호화된 파일 고치기
   --startuptime <file> startup timing 메시지를 <file>에 저장
   -i <viminfo>         .viminfo 대신 <viminfo>를 사용
   --clean              'nocompatible', Vim defaults, no plugins, no viminfo
   -h 혹은 --help       도움말(이 메시지)을 출력한 뒤 끝내기
   --version            판 정보를 출력한 뒤 끝내기

$ vi -R <filename>

-R 옵션을 사용해서 읽기 전용 모드로 실행하면 위 메시지를 보지 않을 수 있다.

728x90

+ Recent posts