精灵五笔改造now时间格式

精灵五笔改造now时间格式,在码表中查找now,然后添加下面的命令,并勾选新添加的在系统词汇之前

$ddcmd(<date.yyyy>-<date.mm>-<date.dd> <time.h>:<time.mm>,<time.h>:<time.mm>)

点击保存,然后输入 now,即可出现下面格式的日期时间
2014-08-22 16:08

PHP使用stripslashes会把HTML代码直接显示出来

PHP使用stripslashes会把HTML代码直接显示出来,而不是HTML代码的表现。

可以用htmlspecialchars_decode来让HTML表现出来。

有些时候必须要使用stripslashes,比如开启了magic_quotes_gpc,如果一个字符串中有引号之类的,PHP会自动给在单引号前加上双斜杠。这时,在使用的这个字符串的时候,就要用stripslashes()去掉,然后再用htmlspecialchars_decode来让HTML代码表现出来。

shit!

高版本的PHP中,magic_quotes_gpc这个特性已经移除了,我在PHP5.5和PHP5.5以上就没有发现这个问题。

php5.2开启pdo的PHP.ini配置

php5.2开启pdo,需要同时打开下面两个扩展

extension=php_pdo.dll
extension=php_pdo_mysql.dll

也就是说extension=php_pdo.dll是必须的,然后再打开对应的数据库的PDO扩展。

PS. 查看了下自己服务器上的PHP5.6,只需要开启extension=php_pdo_mysql.dll就行了,已经没有php_pdo.dll这个扩展了。PHP5.5估计也是这样的,其它版本未知。

VC跨进程实现自动托放

VC跨进程实现自动托放

//这个版本在64位系统上会造成目标进程闪退。
void test()
{
	char szFile[] = "d:\\jinkexy.mse";
	HWND hWnd = ::FindWindowA("3DSMAX", NULL);
	if (hWnd == NULL) return;

	DWORD dwBufSize = sizeof(DROPFILES) + sizeof(szFile) + 1;
	BYTE *pBuf = NULL;
	LPSTR pszRemote = NULL;
	HANDLE hProcess = NULL;
	__try {
		pBuf = new BYTE[dwBufSize];
		if (pBuf == NULL) __leave;
		memset(pBuf, 0, dwBufSize);
		DROPFILES *pDrop = (DROPFILES *)pBuf;
		pDrop->pFiles = sizeof(DROPFILES);
		strcpy((char *)(pBuf + sizeof(DROPFILES)), szFile);
		DWORD dwProcessId;
		GetWindowThreadProcessId(hWnd, &dwProcessId);
		hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, dwProcessId);
		if (hProcess == NULL) __leave;
		pszRemote = (LPSTR)VirtualAllocEx(hProcess, NULL, dwBufSize, MEM_COMMIT, PAGE_READWRITE);
		if (pszRemote == NULL) __leave;
		if (WriteProcessMemory(hProcess, pszRemote, pBuf, dwBufSize, 0))
			::SendMessage(hWnd, WM_DROPFILES, (WPARAM)pszRemote, NULL);
	}
	__finally {
		if (pBuf != NULL) delete[]pBuf;
		if (pszRemote != NULL) VirtualFreeEx(hProcess, pszRemote, dwBufSize, MEM_FREE);
		if (hProcess != NULL) CloseHandle(hProcess);
	}
}



//这个版本可以正常使用,和操作系统位数无关
/**
* Dia is running, so we simulate a drag & drop event.
* Uses __argv & __argc for list of files to drop.
*/
int CWork::DragAndDropDia(HWND hWnd)
{
	if (hWnd == NULL)
	{
		//char szFile[] = MSE_FILE;
		hWnd = ::FindWindowA("3DSMAX", NULL);
		if (hWnd == NULL)
		{
			AfxMessageBox(_TEXT("请先打开3dsmax窗口"));
			return -1;
		}
		}

		char szFile[MAX_PATH];
		GetModuleFileNameA(NULL, szFile, MAX_PATH);
		PathRemoveFileSpecA(szFile);
		strcat_s(szFile, MAX_PATH, "\\maxscript.mse");

		// int iNumFiles = (gUseRegVal) ? __argc - 1 : __argc - 2;
		int iNumFiles = 1;
		int iCurBytePos = sizeof(DROPFILES);
		LPDROPFILES pDropFiles;
		HGLOBAL hGlobal;
		int i;

		/* May use more memory than is needed... oh well. */
		hGlobal = GlobalAlloc(GHND | GMEM_SHARE,
		sizeof(DROPFILES) +
		(_MAX_PATH * iNumFiles) + 1);

		/* memory failure? */
		if (hGlobal == NULL)
		return -1;

		/* lock the memory */
		pDropFiles = (LPDROPFILES)GlobalLock(hGlobal);

		/* set offset where the file list begins */
		pDropFiles->pFiles = sizeof(DROPFILES);

		/* no wide chars and drop point is in client coordinates */
		pDropFiles->fWide = FALSE;
		pDropFiles->pt.x = pDropFiles->pt.y = 100;
		pDropFiles->fNC = FALSE;

		//for (i = (gUseRegVal) ? 1 : 2; i < __argc; ++i)
		//{
		// strcpy(((LPSTR)(pDropFiles)+iCurBytePos), __argv[i]);
		// /**
		// * Move the current position beyond the file name copied.
		// * +1 for NULL terminator
		// */
		// iCurBytePos += strlen(__argv[i]) + 1;
		//}
		strcpy(((LPSTR)(pDropFiles)+iCurBytePos), szFile);
		iCurBytePos += strlen(szFile) + 1;


		((LPSTR)(pDropFiles))[iCurBytePos] = 0;
		GlobalUnlock(hGlobal);

		/* Force dia to the foreground */
		SetForegroundWindow(hWnd);

	/* restore only if minimized */
	if (IsIconic(hWnd))
	{
		ShowWindow(hWnd, SW_RESTORE);
	}

	//AfxMessageBox(L"准备发送消息");

	/* send the file list */
	::PostMessage(hWnd, WM_DROPFILES, (WPARAM)hGlobal, 0);


	//::GlobalFree(hGlobal);
	return 0;
}

asp.net在cs文件向aspx输出html的时候避免html编码

asp.net在cs文件向aspx输出html的时候避免html编码

可以使用HtmlString代替string. 如下函数:

public HtmlString CheckCurrentNav(string nav)
{
	nav = nav.ToLower();
	string currentPageName = Path.GetFileName(Request.Path).ToString();
	if (nav == currentPageName)
	{
		return new HtmlString("class='active_nav'");
	}
	else
	{
		return new HtmlString("");
	}
}

让VC编译出来的程序不依赖于运行时DLL

让VC编译出来的程序不依赖于msvcr80.dll/msvcr90.dll/msvcr100.dll等文件

正常情况下,当我们用VC编译出一个Console/Win32类型项目的exe程序时(这里暂不考虑MFC程序),会依赖于msvcrxx.dll文件(xx为不同VC对应的版本号,VC2005为80,VC2008为90,VC2010为100),发布程序的时候,就需要把对应的dll也copy过去,比较不方便。

通过以下的方法,可以让exe不依赖于这些dll(不过生成的exe会大很多)

以VC2010英文版为例,切换到Solution Explorer视图,在项目上右击,选择Properties,Configuration选项选中Release,依次点击Configuration Properties->C/C++->Code Generation->Runtime Library,选择/MT即可。以Release方式重新Build项目,在Release文件夹下即可生成不依赖于msvcr100.dll的exe文件。

下面简单说明Runtime Library四个选项的含义:

(D表示Dll,而d表示debug版本)

MT(Multi-threaded):多线程版本

MTd(Multi-threaded debug):多线程调试版本

MD(Multi-threaded Dll):多线程Dll版本

MDd(Multi-threaded Dll debug):多线程调试Dll版本

MYSQL开启远程访问权限

MYSQL开启远程访问权限,编辑my.cnf,把bind-address一行注释掉,如下图:

在my.cnf中,把上图的这个注释掉 ( find / -name my.cnf )

然后重启Mysql

再执行下面的语句

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
FLUSH PRIVILEGES;

去掉远程访问权限:

mysql -u root -p123456

use mysql;
delete from user where host='%';
select host, user from user;
FLUSH PRIVILEGES;

//给用户授权,所有权限
GRANT ALL ON *.* TO 'pig'@'%';

对于Mysql5.7, 要注释掉my.cnf里面默认的两行代码