Monthly Archives: December 2006

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 == … Continue reading

Posted in Computers and Internet | Leave a comment

All files in SD card are missing…

I was using a laptop sending a file of 5Mb to my phone via wirelessconnection. After sending, the phone popped up prompting if I wanted toreceive it, I chose yes. But then I don’t know where it was, so I … Continue reading

Posted in Uncategorized | Leave a comment

build boost 1.33.1 with VC80

Open "Visual Studio 2005 Command Prompt",change to boost directryset 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

Posted in Computers and Internet | Leave a comment

book review: Service Oriented Architecture A Planning and implementation Guide For Business and Technology

Service Oriented Architecture A Planning and implementation Guide For Business and TechnologyThis is not a book for Engieers, it is a book best for sales and people that talk more that do something. After a glance of it, I don’t … Continue reading

Posted in Books | Leave a comment

book review: XSLT Cookbook 2nd Edition

I want to have a turtorial on XSLT, but this book is not the right one. It provided a lot of small scripts, I think those little tips can be easily found in internet by google.

Posted in Books | Leave a comment

Lottery calculator

import randomimport structfor 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 ‘ … Continue reading

Posted in Computers and Internet | Leave a comment

Simple string operation in python

def 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 ‘, sget_ext(‘a.b’) # test the functionget_ext(‘a.b.c’)

Posted in Computers and Internet | Leave a comment

Dump constants defined by enum

I 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;

Posted in Computers and Internet | Leave a comment

failed to delete ReadOnly file on Windows via Python

The following does not work:win32api.SetFileAttributes( file2, win32con.FILE_ATTRIBUTE_NORMAL)win32api.DeleteFile(file2)#os.remove(file2)win32file.CopyFile( file1, file2, 0)I am in administrators’ group.The following errors occurred: (5, ‘CopyFile’, ‘Access is denied.’)

Posted in Uncategorized | Leave a comment

Oracle Drive and IE7

Our IT helpdesk claimed that Oracle Drive is not compatible with IE7.0, so I give up using it after having connection error. But Oracle Drive works well on my peer’s machine. I have another PC with IE6.0 installed, also can’t … Continue reading

Posted in Uncategorized | Leave a comment