본문 바로가기

전체 글195

check the file is used by another process or not [windows] #include #include "windows.h" #include #include #include using namespace std; class File_locker { HANDLE file_handle; static const int MAX_TRIES = 10; static const int SLEEP_INTERVAL = 500; public: File_locker(std::string filename) { // you can use GetLastError() to determine why the open failed, // but this is a demo, not production code for (int i = 0; i < MAX_TRIES; ++i) { file_handle = ::Cre.. 2014. 3. 13.
sublime text2 auto indent, reindent , smart indent 굵직한 IDE들은 indent 재정렬을 다 지원한다. 그 이름을 auto indentsmart indentreindent 등으로 다르게 부르고 있긴 하지만.. sublime text2는 블럭 설정한후 Edit- LIne - reindent을 누르면 되는데 기본으로 단축키가 설정되어 있지 않다. 단축키는 개인이 설정 가능한데 Preference - Key binding User들어가면 keymap설정 파일이 뜬다 여기에 [ { "keys": ["Ctrl+i"], "command": "reindent"}] 이런식으로 설정하면 Ctrl+i 로 reindent가 가능하다. f12 등으로 해도 됨.. 2014. 3. 13.
MATLAB 에서 현재 IP 주소 얻기 1) 자바 명령어를 이용>> address = java.net.InetAddress.getLocalHost;>> IPaddress = char(address.getHostAddress); 2) 시스템 명령어를 이용[status,result]=system('ipconfig'); ipconfig를 실행시켰을 때 결과가 result에 들어가는데 string을 parsing해야한다. 2014. 3. 1.
MATLAB에서 socket 통신 MATLAB에서 C처럼 이벤트 방식의 고급소켓통신하기는 힘들다. 제공하는 tcpip 라이브러리도 매우 기초적인 수준이기 때문에 많은것을 기대 해선 안된다. 그래서 보통 기본만 하는 소켓통신을 하게 되는데 소켓통신라이브러리는 pnet이라는것을 다운 받아 사용하는것을 추천한다. http://www.mathworks.com/matlabcentral/fileexchange/345-tcpudpip-toolbox-2-0-6비동기방식의 서버 구현을 matlab에서 하기는 상당히 에로사항이 있는것 같다. 여기서는 Client 부분만 소개한다. 1) socket connectip = '127.0.0.1';port =9999; >> socket = pnet('tcpconnect',ip,port) 만들어진 socket id.. 2014. 2. 27.