constructor/destructor 가 있는 class 들을 union 으로 사용할 일이 없어서 몰랐는데 member 간 전환할 때 명시적으로 destructor 와 placement new 를 호출해주자.

#include <iostream>
#include <string>
#include <vector>
 
union S
{
    std::string str;
    std::vector<int> vec;
    ~S() {} // needs to know which member is active, only possible in union-like class 
};          // the whole union occupies max(sizeof(string), sizeof(vector<int>))
 
int main()
{
    S s = {"Hello, world"};
    // at this point, reading from s.vec is undefined behavior
    std::cout << "s.str = " << s.str << '\n';
    s.str.~basic_string();
    new (&s.vec) std::vector<int>;
    // now, s.vec is the active member of the union
    s.vec.push_back(10);
    std::cout << s.vec.size() << '\n';
    s.vec.~vector();
}

위 예제를 보면 std::string, std::vector<int> 형식의 member 를 가진 union type S 가 있다. S.str 사용 후 vec member 를 사용하려고 할 때 destructor (~basic_string()) 와 placement new(new (&s.vec) std::vector<int>) 를 명시적으로 호출해주는 것을 볼 수 있다. 위와 같이 명시적으로 호출해주지 않으면 해당 객체의 virtual table 이 이상해져서 access violation exception 이 발생할 수 있다.

참고 : https://en.cppreference.com/w/cpp/language/union

 

Union declaration - cppreference.com

A union is a special class type that can hold only one of its non-static data members at a time. The class specifier for a union declaration is similar to class or struct declaration: union attr class-head-name { member-specification } attr - (since C++11)

en.cppreference.com

 

728x90

업데이트되더니 UI 언어가 한국어로 바뀌어서 적응이 안된다. 설정에도 언어 바꾸는 건 없던데 난감했다. 검색해보니 설정 파일(%LOCALAPPDATA%\plastic4\client.conf) 을 수동으로 수정해줘야했다. 언어 설정을 찾아서 en 으로 바꾸고 다시 실행하면 UI 언어가 바뀌었다.

출처 : https://stackoverflow.com/questions/57779175/how-to-change-the-language-of-plastic-scm

 

how to change the language of plastic SCM?

I installed plastic SCM cloud edition in my pc, but for accident the language installed was Spanish, I'm looking in the preferences but I dint found and I tried uninstall and re install but always ...

stackoverflow.com

 

728x90
728x90

봇 테스트를 돌리다 보니 불필요한 데이터가 테이블에 쌓인다. 개발 서버 같은 경우 복구할 것도 아니라서 트랜잭션 로그 백업도 필요없다.

디스크 사용량을 줄이기 위해 일단 디비 복구모델을 단순모델로 바꾸자. 그리고 불필요한 봇 데이터들을 지우자. 하지만 테이블 지운다고 디비 파일 용량이 바로 줄어들지 않는다.

-- 로그 축소 작업
BACKUP LOG [Database] WITH TRUNCATE_ONLY
-- 로그 삭제
BACKUP LOG [Database] WITH NO_LOG
-- 파일 축소
DBCC SHRINKFILE (DB파일, 10)
DBCC SHRINKFILE (DB_LOG파일, 10)


출처: https://yongblog.tistory.com/72 [기억력이 나쁜 나에게 주는 페이지]

 

MSSQL MDF, LDF SHRINK 파일 용량 줄이기

일반적으로 MSSQL 은 데이터 파일 MDF / 로그 파일 ( 트랜잭션 ) LDF 로 나뉘어 집니다. ​ 간혹가다 LDF 파일의 용량이 너무 늘어나 디스크 용량을 다 사용하게되어 장애가 나는 상황이 발생합니다.

yongblog.tistory.com

 

728x90

https://www.microsoft.com/en-us/download/details.aspx?id=35460 

 

Download Microsoft Garage Mouse without Borders from Official Microsoft Download Center

Important! Selecting a language below will dynamically change the complete page content to that language. Download Mouse without Borders (http://aka.ms/mm) is a product that makes you the captain of your computer fleet by allowing you to control up to four

www.microsoft.com

마소에서 제공하는 소프트웨어 kvm 이다.

다운 받아서 설치하고 간단한 설정만 하면 된다.

실행 후 호스트가 될 컴퓨터에서 NO 를 선택하면 접근 코드가 나온다.

접속할 컴퓨터에서 프로그램 실행 후 접근 코드와 컴퓨터 이름을 입력하고 연결(LINK) 버튼을 누르면 된다.

연결이 완료되면 연결된 장비로 키보드/마우스가 넘어가서 사용할 수 있다.

전에 사용하던 Input Director 가 UI 도 제대로 안 보이고 해서 넘어갈까 했는데 

화면 이동시에 물결 효과 때문에 못 넘어가겠다. 

https://www.inputdirector.com/downloads.html

 

Input Director - Software KVM to Control Multiple Computers

 

www.inputdirector.com

아직까지는 Input Director 승

728x90

aws s3 에 대응하는 azure 서비스는 blob storage 인 것 같다.

https://azure.microsoft.com/en-us/features/storage-explorer/#overview

 

Azure Storage Explorer – cloud storage management | Microsoft Azure

Easily manage your Azure storage accounts in the cloud, from Windows, macOS, or Linux, using Azure Storage Explorer.

azure.microsoft.com

GUI 를 통해 접근하고 싶으면 Azure Storage Explorer 를 이용하면 된다.

https://docs.microsoft.com/ko-kr/cli/azure/install-azure-cli-windows?tabs=azure-cli 

 

Windows용 Azure CLI 설치

Windows에서 Azure CLI를 설치하려면 Windows 명령 프롬프트(CMD)를 통해 CLI에 대한 액세스 권한을 제공하는 MSI 설치 관리자 또는 Powershell을 사용해야 합니다.

docs.microsoft.com

배치 스크립트 작업을 위해서는 azure cli 가 필요하다.

https://docs.microsoft.com/ko-kr/cli/azure/storage/blob?view=azure-cli-latest

 

az storage blob

--> az storage blob 이 페이지가 도움이 되었나요? 구조화 되지 않은 데이터 (blob)의 개체 저장소를 관리 합니다. 명령에 대해 다음과 같은 인증 매개 변수 중 하나를 지정 하십시오.--auth-모드,--계정-

docs.microsoft.com

blob storage cli 는 "az storage blob" 으로 시작한다.

az storage blob <command> --account-name <account name> --account-key <account key>
SET AZURE_STORAGE_ACCOUNT=<account name>
SET AZURE_STORAGE_KEY=<account key>

접근법이 다양하게 있지만 <account name> 과 <account key> 를 발급받은 경우에는 cli 에 --acount-name 과 --account-key 를 붙이거나 환경변수로 설정하는 방법이 있다.

az storage blob list -c <container name> --query "[*].name"

컨테이너 내에 목록을 가져올 때는 list 명령어를 사용한다. 결과값이 json 형태로 return 되는데 --query <JMESPATH>를 이용해 원하는 결과값으로 필터링할 수 있다.

az storage blob download -c <container name> -f <local file name> -n <remote file name>
az storage blob download-batch -d <download path> -s <container name> --pattern <pattern>

하나만 가져올 때는 download 여러개 가져올 때는 download-batch 명령어를 사용한다. 컨테이너 명령인자가 download 는 '-c', download-batch 는 '-s' 로 다르다.

az storage blob upload -c <container name> -f <file name> -n "<remote file name>"
az storage blob upload-batch -d <container name> -s <source path> --destination-path <destination path>

단일 파일 업로드는 upload, 여러 파일 업로드는 upload-batch 명령어를 사용한다. upload-batch 사용시 --destination-path 를 지정하지 않으면 root 에 업로드 된다.

az storage blob delete -c <container name> -n <file name>
az storage blob delete-batch -s <container name> --pattern <pattern string>

단일 파일 삭제는 delete, 다중 파일 삭제는 delete-batch 명령어를 사용합니다.

728x90

코드 수정을 하다보면 여러 부분에 동시에 같은 문자열을 입력하고 싶을 때가 있다. 커서를 옮겨가며 붙여넣기를 할 수도 있지만 Visual Studio 는 다중 커서(Multi Caret) 를 지원한다.

에디터에서 Ctrl + Alt + 클릭을 하면 해당 위치에 커서가 추가된다.

여러 곳을 선택한 상태에서 문자열을 입력하면 같은 문자열이 입력된다. copy constructor 나 assignment operator 만들 때 같은 변수명을 입력해야하는 경우가 있는데 'this->' 같은 문자열 입력할 때 편하다.

참고 : Improving your productivity in the Visual Studio Editor

 

Improving your productivity in the Visual Studio Editor

Over the last few updates to Visual Studio 2017, we’ve been hard at work adding new features to boost your productivity while you’re writing code. Many of these are the result of your direct feedback coming from the UserVoice requests, Developer Commun

devblogs.microsoft.com

 

728x90

윈도우즈 배치 파일에서 오늘 날짜, 시간을 가져오려면 %date%, %time% 환경 변수를 사용하면 된다.

>echo %date%
2021-10-06
>echo %time%
14:22:52.76

설치된 윈도우즈의 로케일에 따라 결과 문자열이 다를 수 있다.

Azure 에 설치된 윈도우즈 서버에서 실행했을 때 다음과 같은 결과가 나왔다.

>echo %date%
Tue 10/05/2021

원하는 형식의 문자열을 얻으려면 powershell 로 DateTime api 를 이용하면 된다.

>powershell -Command [DateTime]::Now.ToString(\"yyyyMMdd_hhmmss\")
20211006_022824

>for /f "delims=" %a in ('powershell -Command [DateTime]::Now.ToString(\"yyyyMMdd_hhmmss\"^)') do @echo DateTime is: %a
DateTime is: 20211006_022911

utc 시간이나 어제 날짜 같은 문자열을 만들 때도 편리하다.

>for /f "delims=" %a in ('powershell -Command [DateTime]::UtcNow.ToString(\"yyyyMMdd_hhmmss\"^)') do @echo utc DateTime is: %a
utc DateTime is: 20211006_053039

>for /f "delims=" %a in ('powershell -Command [DateTime]::Now.AddDays(-1^).ToString(\"yyyyMMdd_hhmmss\"^)') do @echo yesterday is: %a
yesterday is: 20211005_023148

참고 : https://serverfault.com/questions/384718/how-to-create-a-yesterday-date-in-a-batch

 

How to create a yesterday date in a batch

copy \\server01\E$\LogFiles\IVR\bcR\??120428.* \\LBC\workgroup\cs\ftp\Team\bcR\ copy \\server02\E$\LogFiles\IVR\bcR\??120428.* \\LBC\workgroup\cs\ftp\Team\bcR\ copy \\server03\E$\LogFiles\IVR\bcR\??

serverfault.com

microsoft - 표준 날짜 및 시간 서식 문자열

 

표준 날짜 및 시간 서식 문자열

표준 날짜 및 시간 서식 문자열을 사용하여 .NET에서 날짜 및 시간 값의 텍스트 표현을 정의하는 방법을 알아봅니다.

docs.microsoft.com

 

728x90

윈도우에서 파일 복사할 때 xcopy 를 썼었는데 이제는 더 옵션이 많은 robocopy 를 사용하고 있다.

A svn 에서 B svn 으로 폴더를 동기화하고 싶을 때 /mir 과 /xd 옵션을 사용하고 있다.

/mir Mirrors a directory tree (equivalent to /e plus /purge). Using this option with the /e option and a destination directory, overwrites the destination directory security settings.
/xd <directory>[ ...] Excludes directories that match the specified names and paths.
robocopy svn_A svn_B /mir /xd .svn

참고 :

서버구축이야기!! - Windows(윈도우)에서 ROBOCOPY를 이용한 파일 백업, 일치화 하기

 

Windows(윈도우)에서 ROBOCOPY를 이용한 파일 백업, 일치화 하기

Windows(윈도우)에서 ROBOCOPY를 이용한 파일 백업, 일치화 하기 이번시간에는 Windows를 이용하시는분들을 위해 간편하게 파일을 백업, 일치화, 복사하는 도구를 알아보도록 하겠습니다 리눅스를 이

server-talk.tistory.com

Microsoft - robocopy

 

robocopy

Reference article for the robocopy command, which copies file data from one location to another.

docs.microsoft.com

 

728x90

svn checkout 이나 commit 하려고 할 때 SSL Certificate 관련된 오류가 발생할 때가 있다.

svn: E170013: Commit failed (details follow):
svn: E170013: Unable to connect to a repository at URL 'https://xxx.yyy.zzz.ddd/svn/trunk'
svn: E230001: Server SSL certificate verification failed: certificate issued for a different hostname

내부, 외부 ip 가 있고 내부에는 hostname 으로 접근 가능하게 설정했는데 외부에서 public ip 로 접근하려고 해서 발생했었다.

Error validating server certificate for 'https://xxx.yyy.zzz.ddd:ppp':
 - The certificate is not issued by a trusted authority. Use the
 fingerprint to validate the certificate manually!
 - The certificate hostname does not match.
 Certificate information:
 - Hostname: 
hostname.domain
 - Valid: from Jul 19 07:18:37 2021 GMT until Jul 17 07:18:37 2031 GMT
 - Issuer: 
hostname.domain
 - Fingerprint: FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF
 (R)eject, accept (t)emporarily or accept (p)ermanently?

interative mode 에서는 입력창에 p 를 입력해 accept 하면 되는데 jenkins 와 같은 자동화 툴에서는 문제가 된다.

이럴 때 svn cli option 중에 --trust-server-cert-failures 를 사용하면 된다. 

--non-interactive : do no interactive prompting (default is to prompt
only if standard input is a terminal device)
--trust-server-cert : deprecated; same as --trust-server-cert-failures=unknown-ca
--trust-server-cert-failures ARG : with --non-interactive, accept SSL server certificates with failures; ARG is comma-separated list of 'unknown-ca' (Unknown Authority), 'cn-mismatch' (Hostname mismatch), 'expired' (Expired certificate), 'not-yet-valid' (Not yet valid certificate) and 'other' (all other not separately classified certificate errors).

예전엔 --trust-server-cert 옵션만 있었는데 다양한 certificate 오류를 처리하기 위해 svn 1.9 에 --trust-server-cert-failures 가 추가되었다. 체크인이나 체크아웃 시에 --non-interactive 옵션과 함께 --trust-server-cert-failures 옵션을 추가해서 실행하면 된다.

svn ci . --non-interactive --trust-server-cert-failure="unknown-ca,cn-mismatch,expired,not-yet-valid,other"

참고 : https://stackoverflow.com/questions/5165516/server-certificate-verification-failed

 

Server certificate verification failed

When I execute svn in command line: command: svn commit path -m "Uploaded By User" --username username --password password --non-interactive --trust-server-cert --quiet 2>&1 This res...

stackoverflow.com

 

728x90

+ Recent posts