| Onega's profileOnegaBlogListsNetwork | Help |
|
|
May 19 no best mail clientWindows Live Mail can't receive message body behind proxy, only subject is received. Thunderbird 2.0.14 can't receive gmail behind proxy, it failed to access news.microsoft.com too with/without proxy. November 12 Got BSOD yesterdayI was copying files from a compressed folder to c:\ using Windows XP SP2 explorer, it reported to take about 87 minutes, but it seems stopped at copying a file so I want to cancel the operation. The "Cancel" button was used but the copying process is still hanging for a while( 3 minutes?), I tried to call "Task manager" but "Ctrl+Alt+Del" does not work. So I shutdown the power and next time Windows start up with Blue Screen Error forever. Even Windows Setup program refuse to continue due to MBR error. March 27 Link errorI am building a big workspace and faced link error problem. After two hours research, I noticed that size of one file is 0, which is output file of an idl. I deleted all the idl output files and rebuild the idl file, then the workspaces built successfully. March 25 Firefox 3.0Installed the alpha version firefox 3.0, no new features found (I am lazy to read its release notes), but what I can tell is that its speed is super fast!
http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/firefox-3.0a3pre.en-US.win32.installer.exe
I am behind a proxy and I can't sign in hotmail/google via some proxy, this problem also fixed by firefox 3.0. March 08 cdt-4.0.0-M5-win32.x86.zipIt is so called a new major release. But the refactoring feature is still very limited -- can only "rename", and the speed is very slow. I created a test project of a simple source file (less than 10 lines), while it took about 2 seconds to "rename". March 03 Implement reliable transfer over UDPI am thinking of implementing parameterized TCP protocol over UDP. That is, allow program to configure any parameters they want in order to optimize the network usage. Before I put into action, some work went into my eyes: http://udt.sourceforge.net/ UDT: UDP-based Data Transfer Protocol http://www.codeproject.com/internet/udt.asp A UDP-based Reliable Data Transfer Library February 27 include path and lib path set in VC++ IDE was override by environment variablesI set include path and lib path of boost path in VC++ IDE, but the build script reset INCLUDE and LIB environment variables before launching the build command. This confused us for a while -- the damn perl script. Need to add .\ to include pathI want to override some header file(root\somewhere\a.h) in another directory, so I created a header file (root\aaa\proj\a.h) in the project directory, a source file (root\aaa\b.cpp) of this project referred this header file, it reports link error -- some method in a.h was not found. This error was fixed by adding ".\" to include path of the project. February 07 Speed of string concatenationI saw a lot of place use CString +=, but I thought this is an inefficient way, so I did the following test: int length = 1024 * 16; { ProfileTimer timer("CString test"); CString szText; for(int i=0; i<length; i++) { szText += "a"; } } { ProfileTimer timer("std::string test"); std::string szText; for(int i=0; i<length; i++) { szText += "a"; } } { ProfileTimer timer("std::stringstream test"); std::stringstream ss; for(int i=0; i<length; i++) { ss << "a"; } std::string szText = ss.str(); szText.c_str(); } Build with VC++ 6.0 // Debug configuration // [3316] CString test costs 0.102501 seconds, CPU cycle:204489240 // [3316] std::string test costs 0.0237083 seconds, CPU cycle:47293355 // [3316] std::stringstream test costs 0.00570771 seconds, CPU cycle:11383169 // Release configuration // [388] CString test costs 0.0586345 seconds, CPU cycle:116974315 // [388] std::string test costs 0.00277884 seconds, CPU cycle:5540249 // [388] std::stringstream test costs 0.00197818 seconds, CPU cycle:3943002 January 17 bookmark on network programmingACE_WIN32_Proactor sample Greate post on Reactor and Proactor patterns Comparing Two High-Performance I/O Design Patterns Url: http://www.artima.com/articles/io_design_patterns.html TProactor (ACE compatible Proactor) - add-on to ACE class-libraries, which allows using of ACE Proactor pattern on POSIX platforms January 02 Embedding python in VC2005// Embedding python in C++ program. // VC2005, boost 1.33.1, Python 2.5 // Reference: // http://wiki.python.org/moin/boost.python/EmbeddingPython #include "stdafx.h" #define _WIN32_WINNT 0x0500 #include <Windows.h> #include <iostream> #include <sstream> #include <boost/python.hpp> #include <boost/python/converter/registry.hpp> #pragma comment(lib,"boost_python-vc80-mt-1_33_1.lib") using namespace boost::python; void Dump(LPCSTR s) { OutputDebugStringA(s); if( IsDebuggerPresent()) { OutputDebugStringA("\n"); } std::cout<<s<<std::endl; } void Dump(std::stringstream& ss) { Dump(ss.str().c_str()); } class CppBaseClass { public: virtual void setString(LPCSTR d) { std::stringstream ss; ss<< __FUNCTION__<<"('"<<d<<"')"; Dump(ss); } void NonVirtualMethod(int d) { std::stringstream ss; ss<< __FUNCTION__<<"('"<<d<<"')"; Dump(ss); } }; class CppClass :public CppBaseClass { public: void setString(LPCSTR s) { std::stringstream ss; ss<< __FUNCTION__<<"('"<<s<<"')"; Dump(ss); } int getNum() { return m_data; } void setNum(int n) { m_data = n; } CppClass():m_data(0) { InterlockedIncrement(&m_instance_count); std::stringstream ss; ss<< __FUNCTION__ << "[" <<reinterpret_cast<int>(this) <<"] in thread "<<GetCurrentThreadId(); Dump(ss); } CppClass(int n):m_data(n) { InterlockedIncrement(&m_instance_count); std::stringstream ss; ss<< __FUNCTION__ << "[" <<reinterpret_cast<int>(this) <<"] in thread "<<GetCurrentThreadId(); Dump(ss); } ~CppClass() { InterlockedDecrement(&m_instance_count); std::stringstream ss; ss<< __FUNCTION__ << "["<< reinterpret_cast<int>(this) <<"] in thread "<<GetCurrentThreadId(); Dump(ss); } static void Check() { std::stringstream ss; ss<< "Instance count:"<<m_instance_count; Dump(ss); } private: int m_data; static long m_instance_count; }; long CppClass::m_instance_count; int main( int argc, char ** argv ) { Py_Initialize(); try { CppClass cpp; boost::python::converter::registry::query(type_id<int>()); object main_module(( handle<>(borrowed(PyImport_AddModule("__main__"))))); object main_namespace = main_module.attr("__dict__"); main_namespace["CppClass"] = class_<CppClass>("CppClass") .def(init<int>()) .def("NonVirtualMethod", &CppBaseClass::NonVirtualMethod) .def("setString", &CppClass::setString) .def("setStringBase", &CppBaseClass::setString) .def("getNum",&CppClass::getNum) .def("setNum", &CppClass::setNum); main_namespace["cpp"] = ptr(&cpp); handle<> ignored(( PyRun_String( "print 'Hello, World'\n" "cpp = CppClass()\n" "cpp.NonVirtualMethod(111)\n" "cpp.setString('pass string test')\n" "cpp.setStringBase('pass string to base class')\n" "cpp.setNum(1234)\n" "print cpp.getNum()\n" "cpp = CppClass(4)\n" "cpp = None\n", Py_file_input, main_namespace.ptr(), main_namespace.ptr() ) )); } catch( error_already_set ) { PyErr_Print(); } Py_Finalize();// http://www.boost.org/libs/python/todo.html#pyfinalize-safety CppClass::Check(); } _________________________________________________________________ Get the Live.com Holiday Page for recipes, gift-giving ideas, and more. www.live.com/?addtemplate=holiday December 26 Allocate consecutive sectors for large file#include <stdio.h> #include <tchar.h> #include <windows.h> #include <iostream> int CreateFileOfSize(LPCTSTR filename, __int64 len) { HANDLE hfile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,// FILE_ATTRIBUTE_SPARSE_FILE flag will not allocate disk space 0); if(!hfile) { return GetLastError(); } LARGE_INTEGER li; li.QuadPart = len; if( 0 == SetFilePointerEx(hfile, li, 0, FILE_BEGIN) ) { CloseHandle(hfile); return GetLastError(); } if(!SetEndOfFile(hfile) ) { CloseHandle(hfile); return GetLastError(); } CloseHandle(hfile); return ERROR_SUCCESS; } int _tmain(int argc, _TCHAR* argv[]) { // tested on Windows XP NTFS drive // verified with diskview.exe (http://www.microsoft.com/technet/sysinternals/FileAndDisk/DiskView.mspx) int ret = CreateFileOfSize(_T("c:\\test_1g.tmp"), 1024*1024*1024); std::cout<<"Error code:" << ret<<std::endl; return 0; } View Athletes' Collections with Live Search. See it! December 24 build boost 1.33.1 with VC80Open "Visual Studio 2005 Command Prompt", change to boost directry set PYTHON_VERSION="2.5" set PYTHON_ROOT="c:\python25" set PYTHON_LIB_PATH="c:\python25\libs" E:\opensource\boost\boost_1_33_1>bjam "-sTOOLS=vc-8_0" install December 21 Lottery calculatorimport random import struct for i in range(0, 5): ndict={} #empty dict while len(ndict) < 6: n = random.randint(1, 33) ndict[n] = n keys = ndict.keys() keys.sort() #for k, v in ndict.iteritems(): red_nums = ' ' for k in keys: print ' ', k #print 'len of dict is ', len(ndict) n = random.randint(1,16) print 'black number is ', n Simple string operation in pythondef get_ext(s): # get extension part of file name dot_pos = s.rfind('.') if dot_pos<> -1: print 'dot position is ', dot_pos, ' input is ', s s = s[0:dot_pos] print 'output is ', s get_ext('a.b') # test the function get_ext('a.b.c') December 11 Dump constants defined by enumI have a long list of constants (all are prefixed with EID_) defined in enum and I want to dump them in user friendly name, so I did a regex replace in Notepad++. Find what: (EID_[_A-Z0-9]*), Replace with: case \1: MY_TRACE("PushEvent(\1)"); break; September 28 Corba problem solvedSolved a runtime problem on corba client today. I have a code snippet that works in one project but failed in another project. After painful investigation and try-and-error investigation, the solution seems to be linking addtional two libraries with the failure project. September 15 Performance factsHere are performance facts of data persistence I collected for evaluation of some project. Write about 20,000 fixed sized structures (10 fields) to file, CFile cost 0.02 seconds, file size: 900KB MSXSML cost 3.95 seconds, file size: 5MB Xerces cost 1.01 seconds, file size: 5MB XML via ofstream cost 1.95 seconds, file size: 5MB XML via stringstream cost 10.73 seconds, file size 5MB. IE consumed 407,816KB memory loading the xml file. get base64 encoding string for int array via managed c++array<int>^ p = gcnew array<int>(2); for(int i=0; i< p->Length; i++) p[i] = 0x41414141; array<Byte>^ source_data = gcnew array<Byte>(p->Length * 4); System::Buffer::BlockCopy(p, 0, source_data, 0, source_data->Length); String^ bas64string = Convert::ToBase64String( source_data,0,source_data->Length); Console::WriteLine(bas64string);
|
|
|