Lewphee.com is about to support HTML5 roundly.
Tue, 04 Oct 2011 01:29:03 +0800
Be aware of that HTML5 is the trend in next web technology, this site (lewphee.com) is about to support HTML5 roundly in the next 2 weeks. 

There are also some new UIs and other features will be released.

Waiting 4 ur comments about these changes.

More »
Manage Multiple Projects In Subversion
Sat, 09 Jul 2011 04:41:02 +0800
Normally there are not only one project on our Subversion server, but, if you manage multiple projects with single repository, these projects will share the revision id in one.
The solution is create a directory with start folder but create multiple repository, like following:
svnserve -i -r /data/svn/repos1

Then, create the projects,
svnadmin create /data/svn/repos1/prj1
svnadmin create /data/svn/repos1/prj2
svnadmin create /data/svn/repos1/prj3
svnadmin create /data/svn/repos1/prj4

use this solution,that u must use the absolute path in your svn client:
svn import prj1src svn://192.168.2.25/prj1

More »
删除多余的备份
Sat, 19 Sep 2009 01:38:55 +0800

当初的server-backup.pl不太完善,因为不会自动删除已经备份的文件,所以日积月累会很多多余的文件。现在改进一下。

#now, we delete the file created at 7 days ago.
($sec,$min,$hour,$mday,$mon,$year,
          $wday,$yday,$isdst) = localtime(time()-7*24*60*60);
$bto = sprintf("/data/backup/%4d%02d%02d.tar.gz", $year+1900, $mon+1, $mday);
system("rm -f ".$bto);
system("echo \"".localtime(time)." delete $bto OK.\" >> /data/log/backup.log");

这样,就会删除7天以前的备份档了。

More »
使用批处理转换FLV
Sat, 02 May 2009 02:11:56 +0800

经常有一些电影,要转换成FLV,以在MP4查看(或者其它原因,如大小),所以,写了个脚本进行转换。

前提有mencoder,这在mplayer的官网有下载。

配置好mencoder,使得在CMD方式下可以转换。

再使用以下BAT处理文件进行批量转换。

SET OPS=-of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=200:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:dia=-1:cmp=6:vb_strategy=1 -vf scale=320:240 -ofps 12 -srate 22050
FOR %%i IN (*.rmvb *.avi) do (mencoder %%i -o %%i.flv %OPS%)

OPS变量是mencoder的转换参数。详情参考mencoder的说明即可

More »
提高 Linux 上 socket 性能
Fri, 10 Apr 2009 16:39:03 +0800
来自于IBM developerWorks的文章,转来这里做个记录 http://www.ibm.com/developerworks/cn/linux/l-hisock.html
More »
Makefile Need an operator错误
Thu, 09 Apr 2009 16:12:47 +0800
Makefile里用了vpath,引起了这个错误。这个问题有待解决。
More »
禁掉百度MP3
Wed, 25 Mar 2009 01:54:21 +0800

百度MP3够无耻的,泛滥引用MP3,搞得流量大增。所以写了个小脚本,用脚本来生成播放器,好让百度蜘蛛再也找不着我的MP3~~哼哼

用法:

<script type="text/javascript">
<!--//

//第一参数为文件目录,第二参数为文件名,第三参数为文件类型
var p200903250135 = new MultimediaClass("/uploads/music/misc/", "dgdt", 0);

//输出播放器
p200903250135.flushPlayer();
//-->
</script>

点此下载

More »
Install DBD::mysql on windows
Tue, 24 Feb 2009 04:59:15 +0800

我的PERL是ActivePerl 5.10的,所以使用ppm就可以安装mysql接口。但是,要加入以下地址的repository

http://cpan.uwinnipeg.ca/PPMPackages/10xx/package.xml

More »
让Subversion自动加上ID等Tags
Mon, 19 Jan 2009 02:20:17 +0800

  从CVS中转过来的时候,Subversion的Id等Tag不能自动加上。有点不太适应,不过,我们可以稍微配置一下,让Subversion自动加上。

  在CVS,只要文档中存在$Id: filename.c Exp $这样的串,CVS都会改写并加上修改日期和修改人的串:$Id: filename.c, v 1.1 2006/11/09 13:58:50 rory Exp $

  在Subversion里,也是这样的。不过要配置一下(客户端)。

在你的Subversion配置文件里(~/.subversion/config,WIN下是C:\Documents and Settings\~\Application Data\Subversion\config),找到[auto-props],添加*.c= svn:keywords=Id Reversion Date,这样成了:

[auto-props]

#...

#....

*.c= svn:keywords=Id Reversion Date

*.h= svn:keywords=Id Reversion Date

 

还有,还要启用auto-props:

[miscellany]
enable-auto-props = yes

经过以上配置,以后的文件中,只要存在$Id$这样的字符,都会替换成Subversion的版本串说明了。

另,关于UTF8的文件(如一些XML文件之类的),不能正确加上,上次在SVN的网站上看到相关说明,不过我一时找不出来,稍后再提这个问题吧。

More »
创建WINDOWS服务程序
Sat, 13 Dec 2008 17:11:38 +0800
1.安装和删除服务
首先向服务控制管理器安装服务:

int install_service() { SC_HANDLE sc, sv; SERVICE_DESCRIPTION scsc; char str[MAX_PATH];
GetModuleFileName(NULL, str, MAX_PATH); scsc.lpDescription = "Service test"; sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (sc == NULL) { printf("Install service error."); return 0; }
strcat(str, " -runserver");
sv = CreateService(sc, "TestSrv", "Test service", SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,SERVICE_ERROR_IGNORE, str, NULL, NULL, NULL, NULL, NULL);
if (sv != NULL){ ChangeServiceConfig2(sv, SERVICE_CONFIG_DESCRIPTION, &scsc); CloseServiceHandle(sv); }else{ CloseServiceHandle(sc); }
printf("Service Installed"); return 0; }


删除服务为以下程序:

int delete_service()
{
SC_HANDLE sc, sv;
SERVICE_STATUS ss;
sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (sc == NULL) {
printf("OpenSCManage error.");
return 0;
}
sv = OpenService(sc, "TestSrv", SERVICE_ALL_ACCESS);
if (sv != NULL) {
QueryServiceStatus(sv, &ss);
if(ss.dwCurrentState != SERVICE_STOPPED)
ControlService(sv, SERVICE_CONTROL_STOP, &ss);
DeleteService(sv);
CloseServiceHandle(sv);
}
CloseServiceHandle(sc);
printf("Service Deleted");
return 0;
}


2.服务主线程程序和服务控制程序:

void WINAPI TestServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
SERVICE_STATUS_HANDLE hStatus;
SERVICE_STATUS ServiceStatus;
hStatus = RegisterServiceCtrlHandler("TestSrv",
(LPHANDLER_FUNCTION)ControlHandle);
if (hStatus == (SERVICE_STATUS_HANDLE)0) return;
ServiceStatus.dwServiceType = SERVICE_WIN32;
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
ServiceStatus.dwControlsAccepted= SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_SHUTDOWN;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
SetServiceStatus(hStatus, &ServiceStatus);
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus(hStatus, &ServiceStatus);
/*开始*/
begin_session();
}

void ControlHandle(DWORD dwControl)
{
switch (dwControl) {
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus (hStatus, &ServiceStatus);
break;
}
}


3.从程序入口启动服务

int startup_service()
{
SERVICE_TABLE_ENTRY ServiceTable[2];
ServiceTable[0].lpServiceName = "TestSrv";
ServiceTable[0].lpServiceProc =
(LPSERVICE_MAIN_FUNCTION)TestServiceMain;
ServiceTable[1].lpServiceName = NULL;
ServiceTable[1].lpServiceProc = NULL;
// 启动服务的控制分派机线程
StartServiceCtrlDispatcher(ServiceTable);
return 0;
}
More »
WINDOWS 下获取本机 DNS
Sat, 13 Dec 2008 17:06:49 +0800
以下是我用于提取本机DNS的代码,使用WIN32 API GetNetworkParams函数。
另,获取DNS的方法也有读取REGEDIT的方法。

int get_dns_servers(char* hostlist, int hsize)
{
FIXED_INFO *fi;
unsigned long s;
DWORD ret;

memset(hostlist, 0, sizeof(char)*hsize);

s = sizeof(fi);
fi= (FIXED_INFO*)malloc(sizeof(char)*s);
memset(fi, 0, sizeof(char)*s);

ret = GetNetworkParams(fi, &s);
if( ret == ERROR_BUFFER_OVERFLOW )
{
free(fi);
fi= (FIXED_INFO*)malloc(sizeof(char)*s);
}

ret = GetNetworkParams(fi, &s);
sprintf(hostlist, "%s,%s", fi->DnsServerList.IpAddress.String, (fi->DnsServerList.Next)->IpAddress.String);

free(fi);

return 0;
}
More »
全屏模式的开发
Sat, 13 Dec 2008 16:57:07 +0800
近日,在使用SDK开发全屏程序时,遇到一些奇怪的问题。

一般我们要全屏时,首先要获取屏幕最大像素,使用GetSystemMetrics可以达到目的。

int iX, iY;


iX = GetSystemMetrics(SM_CXSCREEN);
iY = GetSystemMetrics(SM_CYSCREEN);


获取当前窗口位置。其实这一步骤只是获取一个有效WINDOWPLACEMENT结构以后填充。

WINDOWPLACEMENT		wpc;


GetWindowPlacement(hWnd, &wpc);


再次,我们要设置窗口的属性不要包含WS_CAPTION和WS_THICKFRAME风格。

SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE)

& ~(WS_CAPTION|WS_THICKFRAME));


重算客户区并设置窗口新Placement:
AdjustWindowRectEx(&rc, GetWindowLong(hWnd, GWL_STYLE),

FALSE, GetWindowLong(hWnd, GWL_EXSTYLE));

wpc.rcNormalPosition = rc;
wpc.showCmd = SW_SHOWNORMAL;
SetWindowPlacement(hWnd, &wpc);


这样,全屏就完成了。当然恢复一般窗口模式就不用多说了吧,反操作就成。
有些资料说要处理WM_GETMINMAXINFO消息,这要看个人需要,你不处理也OK,处理更好。
More »
Tags
Recent Post
Recent Comments
Links
Copyright Notes
You can reship all of these articles without permission but MUST mark the original link in your post. Please contact with me() if u have advice or other arrangements.
Copyright©2007-2011 lewphee.com All rights reserved.