본문 바로가기

프로그래밍

(357)
[번역] COM 자동 초기화 자동 클린업 http://blogs.msmvps.com/gdicanio/2010/12/28/com-automatic-initialization-and-cleanup-and-text-to-speech/ COM 자동 초기화와 자동 클린업 CComPtr 인스턴스를 사용하는 COM 코드가 다음과 같다고 하자. {HRESULT hr = CoInitialize(NULL);// 반환값 확인. CComPtr sp1;CComPtr sp2;// 인터페이스 포인터로 작업 CoUninitialize(); } 이 코드에는 미묘한 버그가 있다. 문제는 CoUninitialize 가 CComPtr 파괴자 전에 실행된다는 점이다. 옳바른 방법은 CoUninitialize 가 모든 COM 인터페이스 포인터가 (자신의 래핑된 CComPtr 파괴자에..
[SO번역] zlib: `deflate` 함수와 `compress` 함수의 차이점은 http://stackoverflow.com/questions/10166122/zlib-differences-between-the-deflate-and-compress-functions zlib: `deflate` 함수와 `compress` 함수의 차이점은zlib: Differences Between the `deflate` and `compress` Functions 질문 : zlib의 deflate() 과 compress() 함수의 차이점은 무엇인가요?온라인 샘플을 훑어봤는데, 어떤 것은 deflate 를 쓰고, 다른 것은 compress 를 쓰더군요.어떤 상황에서 어떤 것을 쓸지 어떻게 결정하나요? What are the differences between the deflate() and compr..
프로토타입 패턴은 왜 사용하는 건가? http://stackoverflow.com/questions/13887704/whats-the-point-of-the-prototype-design-pattern 질문 : 프로토타입 패턴은 왜 사용하는 건가?What's the point of the Prototype design pattern? http://stackoverflow.com/a/13888045/100093 프로토타입 패턴은 예를 들면 다음과 같은 잇점이 있다. - 객체 초기화 때의 (매우 비쌀 가능성이 있는) 오버헤드를 없애준다. - 같은 타입의 여러 객체가 거의 유사한 데이터를 가지고 있는 유스케이스를 최적화한다. 예를 들어, 프로그램이 네트워크로부터 거의 변하지 않는 데이터를 파싱하여 객체를 만든다고 하자. 객체를 만들 때마다 데이터..
CPP/STL const map 객체에 [key] 접근시 에러 #include #include #include int _tmain(int argc, _TCHAR* argv[]){std::map dict1({ { "AAA", { 1, 2, 0, 0 } },{ "B", { 2 } }});const std::map dict2({{ "abc", { 3, 3, 1, 0 } },{ "def", { 0 } }}); // okstd::vector v1 = dict1["AAA"]; // compile error!// ref : http://stackoverflow.com/questions/15614735/why-stdmapint-float-cant-use-operator-error-c2678// dict2 가 const 로 정의되어 있음.// [ 연산자는 자동으로 새로운 key, ..
electrons on sphere E denoted by (theta, phi). rho is fixed as R. E in cartesian coord is R ( sin(theta) cos(phi), sin(theta) sin(phi), cos(theta) ) F on E[i] is SUM_(k!=i) X(E[i]-E[k]) ----class X3: x, y, z def __init__(self, x, y, z): self.x, self.y, self.z = x, y, z def plus(self, Y): return X3(self.x + Y.x, self.y + Y.y, self.z + Y.z) ... ----class E : r = R th = 0 ph = 0 v = X3(0, 0, 0) def __init__(self, thet..
TORNADO too many file descriptors in select() 514515516517518519520521522523524525Traceback (most recent call last): File "D:\LiSeminar\dwyoon\www\login_persist\server.py", line 116, in main() File "D:\LiSeminar\dwyoon\www\login_persist\server.py", line 113, in main tornado.ioloop.IOLoop.current().start() File "C:\Python27\lib\site-packages\tornado\ioloop.py", line 858, in start event_pairs = self._impl.poll(poll_timeout) File "C:\Python27\..
IPv6 주소 뒤의 퍼센트 기호의 의미는? http://superuser.com/questions/99746/why-is-there-a-percent-sign-in-the-ipv6-address Q. (질문이 길어서 요점만 번역, 번역하지 않은질문 아래의 내용도 이해에 도움이 됨 읽어보세요.) ipv6 주소를 구하면 fe80::71a3:2b00:ddd3:753f%16 처럼 % 기호와 숫자가 붙어 나오기도 하고, 안 나오기도 하는데 이건 무엇인가? A1. % 기호 뒤의 숫자는 스코프 아이디 ( scope id ) 이다. IPv6 주소에는 3종류의 접근가능 스코프가 정의되어 있다. 1. 글로벌 접근 주소 (globally addressable). ISP 가 부여한 IPv6 주소로 퍼블릭 인터넷에서 사용할 수 있다. 2. 링크-로컬 (link-loca..
Teredo 터널 어댑터란? ISATAP 란? http://superuser.com/questions/22290/what-is-the-teredo-tunneling-pseudo-interface Q. 윈도우 7 얼티밋을 사용한다. ipconfig /all 을 하면 이더넷 어댑터 로컬 영역 연결 ( ethernet adapter local area connection ) 외에 터널 어댑터 Teredo Tunneling Pseudo-Interface ( tunnel adapter teredo tunneling pseudo-interface ) 도 나온다. 이것 뭔가? 뭣에 쓰는 건가? A1. Teredo 는 대부분 가정용 컴퓨터에서 사용하는 NAT 방화벽 뒤쪽에서 IPv6 네이티브 접속없이 원격 IPv6 리소스를 UDP 프로토콜을 통해 접근할 수 있도록..