Friday, April 25, 2008

C++ 里 #include " " 与 #incluce< > 的区别

搜索的范围不同

#include " " 用于用户自定义头文件,编译器会在先在用户当前目录开始搜索,找不到的话编译器到编译工具规定的目录中寻找该头文件。例如#include"smtp.h" 也可以在子目录里,例如#include"mylib/smtp.h"

#include< > 用于格式来引用标准库的头文件,编译器会自动在编译器设置的目录里搜索。例如#include

C++ error C2664:解决方法(转)

error C2664: 'void ATL::CStringT::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [4]' to 'const wch



CString s;

s.Format("%2d", num1);

but it generates the following error message when compiling:

d:\my documents\visual studio 2005\projects\pt24\pt24\expression.cpp(74) : error C2664: 'void ATL::CStringT::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [4]' to 'const wchar_t *'

with

[

BaseType=wchar_t,

StringTraits=StrTraitMFC_DLL

]

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast



Your project is UNICODE enabled so CString format expects an UNICODE string instead of an ASCII one. You need to use the _T macro to create an UNICODE string:

str.Format(_T("%2d"), 42);

You can also change you project settings to use ASCII if you wish. Go to Project properties, Configuration Properties, General and you'll find an option named "Character Set". Change it to "Use Multi-Byte Character Set".

Thursday, April 24, 2008

program 中的 SQL 语句写法

程序中的代码:


string insertQuery;

insertQuery="INSERT INTO TABLE_NAME VALUES(" + appNo + ", '"+work_county+"', '"+ssn+ "', TO_DATE('"+birth_date +"','DDMMYYYY'), '"+gender +"', '"+last_name+"','"+first_name+"', '"+middle_name + "' , 'A')";



生成的SQL 语句:

INSERT INTO TABLE_NAME VALUES( 001,'China','0000000','TO_DATE('01051983','DDMMYY'),
'MALE','AUSTIN','XU','','A');


需要注意的是:
1.INT 类型的不需要用 ' ' 括写来,只有STRING 或者 CHAR 类型的才需要。
2.程序代码中所有东西都是用 + 号连接起来,为的是成为一个完整的字符串,+ 号 两连肯定都要用" " , 代码是STRING, VARIABLE +号. 但还要VARIABLE 的类型决定要不要用' 号

Tuesday, April 15, 2008

Got job offer today!

今天终于收到JOB OFFER了,本来上周二就跟BOSS 定了,可今天才收到OFFER LETTER。所以一直没跟家人和朋友说。今天总算好了。公司还不错,薪水也还不错。我在MSN的Fighter for a better life 后加了 A small step forward。前进了一小步。 最近家里老不顺,股票低吧,打麻将也老输钱,我说的是我爸妈,我也输其实,干脆不打了。

嗯,要以后更积极的面对人生了,用我爸的话说,要好好给人家干。 用BOSS 的话说,I know you won't let me down. So I won't let everyone down.

Monday, April 7, 2008

数据库NULL值的处理

1.MSSQL: ISNULL()

语法

ISNULL ( check_expression , replacement_value ) AS Item1

参数

check_expression

将被检查是否为 NULL的表达式。check_expression 可以是任何类型的。

replacement_value

在 check_expression 为 NULL时将返回的表达式。replacement_value 必须与 check_expresssion 具有相同的类型。

返回类型

返回与 check_expression 相同的类型。

注释

如果 check_expression 不为 NULL,那么返回该表达式的值;否则返回 replacement_value。

2.Oracle: NVL()

语法

NVL(eExpression1, eExpression2)

参数

eExpression1, eExpression2

如果 eExpression1 的计算结果为 null 值,则 NVL() 返回 eExpression2。如果 eExpression1 的计算结果不是 null 值,则返回 eExpression1。eExpression1 和 eExpression2 可以是任意一种数据类型。如果 eExpression1 与 eExpression2 的结果皆为 null 值,则 NVL( ) 返回 NULL

返回值类型

字符型、日期型、日期时间型、数值型、货币型、逻辑型或 null 值

说明

在不支持 null 值或 null 值无关紧要的情况下,可以使用 NVL( ) 来移去计算或操作中的 null 值。

3.Mysql: IFNULL()

语法

IFNULL(expr1,expr2)

参数

expr1,expr2

假如expr1不是NULL,IFNULL()返回expr1,否则它返回expr2。IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境。

Monday, March 10, 2008

Making your own arff file( Weka Data Mining)

sample:
%Comments
%
%

@RELATION name
%@relation


%@attribute

@ATTRIBUTE AAA NUMERIC
@ATTRIBUTE "BBB" REAL
@ATTRIBUTE CCC NUMERIC
@ATTRIBUTE DDD NUMERIC
@ATTRIBUTE class { type1, type2, type3 }


@DATA
2, 3.20, 4, 5, type1
1, 2.13, 3, 4, type3

you need to make sure that
  • nothing is case sensitive
  • the header section is prefaced by @RELATION
  • each attribute is indicated by @ATTRIBUTE, attribute's name should be one word
  • the data section is prefaced by @DATA
  • the data is comma separated or use spaces, with the class as the last attribute
  • everything should be separated spaces except, no tab is allowed. Or you will get a error when you import the arff file
  • lines that begin with a% are comments.

Sunday, March 9, 2008

常用句总结

Much appreciated. We'll be sure to give that a try.

Wednesday, March 5, 2008

PHOTOSHOP 格式存储问题

当参数不对的时候,另存时PHOTOSHOP将不显示JPEG等格式,这时要将模式改为 RGB颜色,8位/通道。

Thursday, February 28, 2008

javascript 中 radio button 的判断

HTML 页面;

<(form method="post" action="https://××××××××" name="application">
<(input value="M" name="gender" type="radio">Male
<(input value="F" name="gender" type="radio">Female

<(input name="submit" value="Submit" onclick="return validator(application)"type="submit")>

JAVASCRIPT 中
function validator(theForm)
{
if (!theForm.gender[0].checked &&!theForm.gender[1].checked)
{ alert("Select your gender, please!");theForm.gender[0].focus();return false; }


最主要的radio button 是采用数组形式存储的。

Tuesday, February 26, 2008

Oracle date problem

init文件中: NLS_DATE_FORMAT设定为YYYY-MM-DD
在client端也可以,修改注册表或者环境变量就可以|

name:NLS_DATE_FORMAT
values:yyyy-mm-dd
本文来自:http://www.87717.com

客 户 端 的 显 示 依 据 客 户 端 NLS_DATE_FORMAT 环 境 变 量 的 设 置 值 , 如 果 没 有 设 置其 值 , 则 系 统 按 server 端 的 设 定 来 显 示 。 所 以 你 要 在 客 户 端 设 定 需 要 的 格 式 , 也可 以 在 session 中 临 时 设 定 。
alter session set nls_date_format='YYYY"-"MM"-"DD';

windows下,在注册表中 HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE下增加一字符串:NLS_DATE_FORMAT,把其值设成:YYYY-MM-DD
2、Unix下,在用户的.profile文件中增加以下内容:
NLS_DATE_FORMAT=YYYY-MM-DD
export NLS_DATE_FORMAT

如果你是NT,修改注册表:NLS_DATE_FORMAT变成你自己喜欢的格式
加上:HKEY_local_machine\software\oracle\homex\,加字符串上键名:NLS_DATE_FORMAT,键值:yyyy-mm-dd hh24:mi:ss
如果是UNIX,在.profile中将上面的参数set并export

如果你不想做上面的工作,你还可以在SQL_PATH的目录下定义login.sql,在里面写上一句:
alter session set nls_date_format='你喜欢的格式';

Sunday, February 17, 2008

Spyware.Cyberlog-X removal

1.下载杀毒软件SMITFRAUDFIX (由S!Ri编写)
位置:http://siri.urz.free.fr/Fix/SmitfraudFix.zip

2。安装该软件到电脑。
3。运行程序文件 SMITFRAUDFIX.CMB
根据提示选择: 1-SEARCH (搜索),然后回车
这时,会有一段文字出现,为搜索到的已经被感染的文件清单.该资料自动保存到C:\RAPPORT.TXT

注意,运行该程序时,有可能被你现有的杀毒软件检测为"非法程序",请忽略.

4.请关机重启,到"安全模式".
5.运行程序文件 SMITFRAUDFIX.CMB
根据提示选择: 2-CLEAN (清除),然后回车
这时,电脑进行清楚已被感染的文件和程序.

6.病毒被清除完毕,又有提问"Do you want to clean the registry?" (需要清理注册吗?)
回答"是",即打Y,然后回车

7.全部完成后,重启电脑.烦人的病毒提示没有了.
说明病毒SPYWARE CYBERBLOG-X已经被彻底清除.

Thursday, February 14, 2008

ASP Including Files

普通方法


include parent file 方法
"ASP出错解决方法
http://support.microsoft.com/?id=332117
href="/XXX/XXX/XXX/XXX/index.asp">XXXX "(正确)
href="index.asp">XXXX "(错误)
对于include parent directory 的 link 文件,其中的href 应该为除HOMEPAGE 的全部DIRECTORY,否则会自动加上其所在目录的directory name.

Wednesday, February 6, 2008

JAVA中indexOf 和 lastIndexOf 的使用


int indexOf(char ch)
int lastIndexOf(char ch)
int indexOf(char ch, int startIndex)
int lastIndexOf(char ch, int endIndex)
int indexOf(String str)
int lastIndexOf(String str)

int indexOf(String str, int startIndex)
int lastIndexOf(String str, int endIndex)

Wednesday, January 16, 2008

解决Access错误 Selected collating sequence not supported by the operating system

这种问题都是由于生成的Access 文件是在支持中文的系统创建的然后用在英文的服务器上造成的。

微软的技术解释请参见
http://support.microsoft.com/kb/141306/EN-US/
解决方法:
1)打开我的 Microsoft Access ,Open 任意一个文件,然后点"tools",选中 Options,再选 General 项。注意在右下方有 New Database Sort Order下拉框,选中 General。然后关掉该文件。(注意,Options只有在有文件打开的状况下才能使用)
2)然后"File" --> "New..." 创建一个空白数据文件,然后"file" --> "Get External Data" -- "Import",打开我的老数据库文件将所有的 tables 全部传到新文件来,然后保存新文件。我要做这步是因为我的论坛里已经有许多的数据在里面,我不愿从头再来。如果你在新建论坛,或新建系统时遇到此类问题,大可新建 table,或用 SQL query 写入初始数据。
3)保存此新文件,然后上传到服务器。

Windows快捷键大全(转)

快捷键
单独按Windows:显示或隐藏 “开始”功能表
  Windows+BREAK:显示“系统属性” 对话框
  Windows+D:显示桌面
  Windows+M:最小化所有窗口
  Windows+Shift+M:还原最小化的窗口
  Windows+E:开启“资源管理器”
  Windows+F:查找文件或文件夹
  Windows+CTRL+ F:查找电脑
  Windows+F1:显示 Windows “帮助”
  Windows+R:开启“运行” 对话框
  Windows+U:开启 “公用程序管理器”
  Windows+L:切换使用者(Windows XP新功能)

Ctrl快捷键
Ctrl+S 保存
Ctrl+W 关闭程序
Ctrl+N 新建
Ctrl+O 打开
Ctrl+Z 撤销
Ctrl+F 查找
Ctrl+X 剪切
Ctrl+C 复制
Ctrl+V 粘贴
Ctrl+A 全选
Ctrl+[ 缩小文字
Ctrl+] 放大文字
Ctrl+B 粗体
Ctrl+I 斜体
Ctrl+U 下划线
Ctrl+Shift 输入法切换
Ctrl+空格 中英文切换
Ctrl+回车 QQ号中发送信息
Ctrl+Home 光标快速移到文件头
Ctrl+End 光标快速移到文件尾
Ctrl+Esc 显示开始菜单
Ctrl+Shift+< 快速缩小文字
Ctrl+Shift+> 快速放大文字
Ctrl+F5 在IE中强行刷新
Ctrl+拖动文件 复制文件
Ctrl+Backspace 启动\关闭输入法
拖动文件时按住Ctrl+Shift 创建快捷方式

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
Alt快捷键


Alt+F4 关闭当前程序
Alt+空格+C 关闭窗口
Alt+空格+N 最小化当前窗口
Alt+空格+R 恢复最小化窗口
Alt+空格+X 最大化当前窗口
Alt+空格+M 移动窗口
Alt+空格+S 改变窗口大小
Alt+Tab 两个程序交换
Alt+255 QQ号中输入无名人
Alt+F 打开文件菜单
Alt+V 打开视图菜单
Alt+E 打开编辑菜单
Alt+I 打开插入菜单
Alt+O 打开格式菜单
Alt+T 打开工具菜单
Alt+A 打开表格菜单
Alt+W 打开窗口菜单
Alt+H 打开帮助菜单
Alt+回车 查看文件属性
Alt+双击文件 查看文件属性
Alt+X 关闭C语言
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

Shift快捷键

Shift+空格 半\全角切换
Shift+右击 右菜单打开方式
Shift+F10 选中文件的右菜单
Shift+多级文件 全部关闭
Shift+Del 直接删除文件
Shift+^ 处在中文标点符号半角在智能ABC中省曰号
Shift+\ 处在中文标点符号半角在智能ABC中顿号


★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

快捷键


常规键盘快捷键

Ctrl + C 复制。
Ctrl + X 剪切。
Ctrl + V 粘贴。
Ctrl + Z 撤消。
Delete 删除。
Shift + Delete 永久删除所选项,而不将它放到“回收站”中。
拖动某一项时按 CTRL 复制所选项。
拖动某一项时按 CTRL + SHIFT 创建所选项目的快捷键。
F2 重新命名所选项目。
CTRL + 向右键 将插入点移动到下一个单词的起始处。
CTRL + 向左键 将插入点移动到前一个单词的起始处。
CTRL + 向下键 将插入点移动到下一段落的起始处。
CTRL + 向上键 将插入点移动到前一段落的起始处。
CTRL + SHIFT + 任何箭头键 突出显示一块文本。
SHIFT + 任何箭头键 在窗口或桌面上选择多项,或者选中文档中的文本。
Ctrl + A 选中全部内容。
F3 搜索文件或文件夹。
Alt + Enter 查看所选项目的属性。
Alt + F4 关闭当前项目或者退出当前程序。
ALT + Enter 显示所选对象的属性。
Alt + 空格键 为当前窗口打开快捷菜单。
Ctrl + F4 在允许同时打开多个文档的程序中关闭当前文档。
Alt + Tab 在打开的项目之间切换。
Alt + Esc 以项目打开的顺序循环切换。
F6 在窗口或桌面上循环切换屏幕元素。
F4 显示“我的电脑”和“Windows 资源管理器”中的“地址”栏列表。
Shift + F10 显示所选项的快捷菜单。
Alt + 空格键 显示当前窗口的“系统”菜单。
Ctrl + Esc 显示“开始”菜单。
ALT + 菜单名中带下划线的字母 显示相应的菜单。
在打开的菜单上显示的命令名称中带有下划线的字母 执行相应的命令。
F10 激活当前程序中的菜单条。
右箭头键 打开右边的下一菜单或者打开子菜单。
左箭头键 打开左边的下一菜单或者关闭子菜单。
F5 刷新当前窗口。
BackSpace 在“我的电脑”或“Windows 资源管理器”中查看上一层文件夹。
Esc 取消当前任务。
将光盘插入到 CD-ROM 驱动器时按 SHIFT 键 阻止光盘自动播放。
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
对话框快捷键

Ctrl + Tab 在选项卡之间向前移动。
Ctrl + Shift +Tab 在选项卡之间向后移动。
Tab 在选项之间向前移动。
Shift + Tab 在选项之间向后移动。
ALT + 带下划线的字母 执行相应的命令或选中相应的选项。
Enter 执行活选项动或按钮所对应的命令。
空格键 如果活选项动是复选框,则选中或清除该复选框。
箭头键 活选项动是一组选项按钮时,请选中某个按钮。
F1 显示帮助。
F4 显示当前列表中的项目。
BackSpace 如果在“另存为”或“打开”对话框中选中了某个文件夹,则打开上一级文件夹。
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
自然键盘快捷键

在“Microsoft 自然键盘”或包含 Windows 徽标键() 和“应用程序”键() 的其他兼容键盘中,您可以使用以下快捷键。

请按 目的
显示或隐藏“开始”菜单。
win+ BREAK 显示“系统属性”对话框。
+ D 显示桌面。
+ M 最小化所有窗口。
+ Shift + M 还原最小化的窗口。
+ E 打开“我的电脑”。
+ F 搜索文件或文件夹。
CTRL+ + F 搜索计算机。
+ F1 显示 Windows 帮助。
+ L 如果连接到网络域,则锁定您的计算机,或者如果没有连接到网络域,则切换用户。
+ R 打开“运行”对话框。
显示所选项的快捷菜单。
+ U 打开“工具管理器”。

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
辅助键盘快捷键

请按 目的
右侧 SHIFT 键八秒钟 切换“筛选键”的开和关。
左边的 ALT + 左边的 SHIFT + PRINT SCREEN 切换“高对比度”的开和关。
左边的 ALT + 左边的 SHIFT + NUM LOCK 切换“鼠标键”的开和关。
Shift 键五次 切换“粘滞键”的开和关。
Num Lock 键五秒钟 切换“切换键”的开和关。
+ U 打开“工具管理器”。
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
“Windows 资源管理器”键盘快捷键

请按 目的
END 显示当前窗口的底端。
主页 显示当前窗口的顶端。
NUM LOCK + 数字键盘的星号 (*) 显示所选文件夹的所有子文件夹。
NUM LOCK + 数字键盘的加号 (+) 显示所选文件夹的内容。
NUM LOCK + 数字键盘的减号 (-) 折叠所选的文件夹。
左箭头键 当前所选项
处于展开状态时折叠该项,或选定其父文件夹。
右箭头键 当前所选项处于折叠状态时展开该项,或选定第一个子文件夹

IE的快捷键
Ctrl+A 选择全部网页
Ctrl+B或Ctrl+I 快速打开收藏夹,整理收藏夹
Ctrl+C 复制当前网页内容
Ctrl+D 将当前页添加到收藏夹
Ctrl+E或Ctrl+F3 搜索有键入内容的网页
Ctrl+F 在当前页中查找
Ctrl+H 查看历史记录
Ctrl+L 键入网址进入你想去的网页
Ctrl+N 以当前页打开,它可以快速打开新的网页窗口
Ctrl+P 打印所选的文字
Ctrl+R或F5 刷新当前页
Ctrl+S 保存当前页
Ctrl+W 快速关闭当前窗口
ALT+←/→ 前返/后退一页
ALT+D 光标快速移入地址栏
F4 打开地址栏
F11 切换到全屏幕或常规窗口

Thursday, November 15, 2007

Buffer Overflow Problem(转)

Buffer Overflow Problem: Consider the following code:
Harry Hochheiser, hhochheiser@towson.edu 
// buffer overflow demo
#include <>
using namespace std;

int main() {
int importantData = 1;
int buffer[10];

cout << "importantData = " << importantData << endl;
cout << "buffer overflow " << endl;v

for (int i = 0; i < ??; i++)
buffer[i] = 7;
cout << "importantData = " << importantData << endl;
return 0;
}
  1. Type in the above program. What value should replace the ?? Compile and Run with this value.
  2. Replace the ?? with 20 this time. What happens? Why?

The following security checklist is a tool used to find potential security vulnerabilities in your programs. Read the checklist, apply it (as best you can) to the problem given above, and answer these questions:

  1. Describe the buffer overflow problem.
  2. Give three real life examples of buffer overflow attacks (research on the web, and indicate your sources).
  3. What can result from a buffer overflow?
  4. List three ways you could potentially overflow a buffer in your program.
  5. How could you prevent a buffer overflow from occurring in your program?

Some of the elements in the checklist may refer to material that we have not seen this semester. If so, please disregard them.

Please submit the program with appropriate marking (in color or alternate font) and your answers to these questions

Security checklist
Vulnerability Buffer Overflow
Description A buffer overflow occurs when data is written beyond the boundaries of a fixed length buffer overwriting adjacent memory locations which may include other buffers, variables and program flow data.
Risk Writing outside the bounds of a block of allocated memory can corrupt data, crash the program, or cause the execution of malicious code.WARNING: over 80% of security problems result from buffer overflows!
Real World Exaple The earliest known exploitation of a buffer overflow was the Morris worm in 1988. In 2001, the Code Red wormexploited a buffer overflow in Microsoft's Internet Information Services and in 2003 the SQLSlammer worm compromised machines running Microsoft SQL Server 2000.
Task: Check your code YesNoUnsure
1. Check each array assignment that could result in an overflow (indices >= ARR_SIZE ) EX: arr[ARR_SIZE] = 0;
2.Check loop boundaries >= ARR_SIZE EX: for (i = 0; i <= ARR_SIZE; i++) array[i] = x;//off-by-one!
3. Check all indices that are input. EX: cin >> i; array[i] = x;
4. Are all string functions within range? (hint: do not use: gets, strcpy, sprintf)
5.Are arrays close to pointers? (Hint: remember the return address of a function is a pointer)
Shaded area indicated this is a high security risk!

Monday, November 12, 2007

生活用品英语(不定期更新)

被子 quilt [kwilt] 
手巾架towel holder

Sunday, November 11, 2007

Eclipse 中正确显示中文字符

Window->Preferences->General->Workspace ->Text file encodeing
change Default(Cp1252) to UTF-8

Thursday, November 8, 2007

KartRider (跑跑卡丁车)Nexon 连喷方法


上右
上右 + shift
左上
右 + shift (快)
左上 ( 喷)
右 + shift (快)
左上 ( 喷)

上+ ctrl

KartRider (跑跑卡丁车)Nexon 快捷键

人物表情:
CTRL+1笑  lol CTRL+2怕怕
CTRL+3哭 CTRL+4怒 >।< CTRL+5打招呼 CTRL+6喜欢 CTRL+7- -! CTRL+8睡觉


CTRL:道具
R:复位键
←↑↓→/WASD:上下左右
ESC:计时赛
F4:截图
F5:准备/开始
F7,F8:游戏音乐 开/关
F11:窗口/全屏



按ctrl+e 可以直接跑计时赛

按ctrl+r 可以直接进入回放

按alt+F4 关闭游戏

按shift+F4 穿水,穿香蕉,穿人

按alt+F6 卡自爆,穿人,穿水,穿香