2008-09-25

debian BIOS CST 时间设置

debian BIOS CST 时间设置
    在多系统共存的机器里,一般BIOS时间都设置为当地时间(CST),但在debian下有时会遇到这样的问题:本地时间显示的居然是UTC时间,而国际标准时间却是CST时间。也就是说本地时间落后(或提前)8个小时。
每次关机,debian都会将UTC时间保存在BIOS里,这样在windows系统里,时间就落后8小时。

    解决办法:编辑/etc/default/rcS,修改UTC=yes为UTC=no。

Ubuntu配置Oracle-xe sqlplus

Ubuntu配置Oracle-xe sqlplus
1、设置ORACLE_HOME。
# ORACLE_HOME
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=XE

2、解决oracle以外的用户使用sqlplus连接服务器时的Linux Error: 13: Permission denied错误。

遇到 ORA-27121 错误
ORA-01034: ORACLE not available
ORA-27121: unable to determine size of shared memory segment
Linux Error: 13: Permission denied

主要是因为oracle安装程序没有给oracle这个可执行程序设置正确的setuid。这样设置一下:

$ cd $ORACLE_HOME/bin
$ chmod 6751 oracle

结果类似这样就行了。

$ ls -l $ORACLE_HOME/bin/oracle
-rwsr-s--x 1 oracle oinstall 23352783 Aug 14 2001 /home/oracle/app/oracle/product/8.1.6/bin/oracle

oracle 的函数大全

oracle 的函数大全

SQL中的单记录函数
1.ASCII
返回与指定的字符对应的十进制数;
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;

A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32


2.CHR
给出整数,返回对应的字符;
SQL> select chr(54740) zhao,chr(65) chr65 from dual;

ZH C
-- -
赵 A

3.CONCAT
连接两个字符串;
SQL> select concat('010-','88888888')||'转23' 高乾竞电话 from dual;

高乾竞电话
----------------
010-88888888转23

4.INITCAP
返回字符串并将字符串的第一个字母变为大写;
SQL> select initcap('smith') upp from dual;

UPP
-----
Smith


5.INSTR(C1,C2,I,J)
在一个字符串中搜索指定的字符,返回发现指定的字符的位置;
C1 被搜索的字符串
C2 希望搜索的字符串
I 搜索的开始位置,默认为1
J 出现的位置,默认为1
SQL> select instr('oracle traning','ra',1,2) instring from dual;

INSTRING
---------
9


6.LENGTH
返回字符串的长度;
SQL> select name,length(name),addr,length(addr),sal,length(to_char(sal)) from gao.nchar_tst;

NAME LENGTH(NAME) ADDR LENGTH(ADDR) SAL LENGTH(TO_CHAR(SAL))
------ ------------ ---------------- ------------ --------- --------------------
高乾竞 3 北京市海锭区 6 9999.99 7

7.LOWER
返回字符串,并将所有的字符小写
SQL> select lower('AaBbCcDd')AaBbCcDd from dual;

AABBCCDD
--------
aabbccdd


8.UPPER
返回字符串,并将所有的字符大写
SQL> select upper('AaBbCcDd') upper from dual;

UPPER
--------
AABBCCDD

9.RPAD和LPAD(粘贴字符)
RPAD 在列的右边粘贴字符
LPAD 在列的左边粘贴字符
SQL> select lpad(rpad('gao',10,'*'),17,'*')from dual;

LPAD(RPAD('GAO',1
-----------------
*******gao*******
不够字符则用*来填满


10.LTRIM和RTRIM
LTRIM 删除左边出现的字符串
RTRIM 删除右边出现的字符串
SQL> select ltrim(rtrim(' gao qian jing ',' '),' ') from dual;

LTRIM(RTRIM('
-------------
gao qian jing


11.SUBSTR(string,start,count)
取子字符串,从start开始,取count个
SQL> select substr('13088888888',3,8) from dual;

SUBSTR('
--------
08888888


12.REPLACE('string','s1','s2')
string 希望被替换的字符或变量
s1 被替换的字符串
s2 要替换的字符串
SQL> select replace('he love you','he','i') from dual;

REPLACE('H
----------
i love you


13.SOUNDEX
返回一个与给定的字符串读音相同的字符串
SQL> create table table1(xm varchar(8));
SQL> insert into table1 values('weather');
SQL> insert into table1 values('wether');
SQL> insert into table1 values('gao');

SQL> select xm from table1 where soundex(xm)=soundex('weather');

XM
--------
weather
wether


14.TRIM('s' from 'string')
LEADING 剪掉前面的字符
TRAILING 剪掉后面的字符
如果不指定,默认为空格符

15.ABS
返回指定值的绝对值
SQL> select abs(100),abs(-100) from dual;

ABS(100) ABS(-100)
--------- ---------
100 100


16.ACOS
给出反余弦的值
SQL> select acos(-1) from dual;

ACOS(-1)
---------
3.1415927


17.ASIN
给出反正弦的值
SQL> select asin(0.5) from dual;

ASIN(0.5)
---------
.52359878


18.ATAN
返回一个数字的反正切值
SQL> select atan(1) from dual;

ATAN(1)
---------
.78539816


19.CEIL
返回大于或等于给出数字的最小整数
SQL> select ceil(3.1415927) from dual;

CEIL(3.1415927)
---------------
4


20.COS
返回一个给定数字的余弦
SQL> select cos(-3.1415927) from dual;

COS(-3.1415927)
---------------
-1


21.COSH
返回一个数字反余弦值
SQL> select cosh(20) from dual;

COSH(20)
---------
242582598


22.EXP
返回一个数字e的n次方根
SQL> select exp(2),exp(1) from dual;

EXP(2) EXP(1)
--------- ---------
7.3890561 2.7182818


23.FLOOR
对给定的数字取整数
SQL> select floor(2345.67) from dual;

FLOOR(2345.67)
--------------
2345


24.LN
返回一个数字的对数值
SQL> select ln(1),ln(2),ln(2.7182818) from dual;

LN(1) LN(2) LN(2.7182818)
--------- --------- -------------
0 .69314718 .99999999


25.LOG(n1,n2)
返回一个以n1为底n2的对数
SQL> select log(2,1),log(2,4) from dual;

LOG(2,1) LOG(2,4)
--------- ---------
0 2


26.MOD(n1,n2)
返回一个n1除以n2的余数
SQL> select mod(10,3),mod(3,3),mod(2,3) from dual;

MOD(10,3) MOD(3,3) MOD(2,3)
--------- --------- ---------
1 0 2


27.POWER
返回n1的n2次方根
SQL> select power(2,10),power(3,3) from dual;

POWER(2,10) POWER(3,3)
----------- ----------
1024 27


28.ROUND和TRUNC
按照指定的精度进行舍入
SQL> select round(55.5),round(-55.4),trunc(55.5),trunc(-55.5) from dual;

ROUND(55.5) ROUND(-55.4) TRUNC(55.5) TRUNC(-55.5)
----------- ------------ ----------- ------------
56 -55 55 -55


29.SIGN
取数字n的符号,大于0返回1,小于0返回-1,等于0返回0
SQL> select sign(123),sign(-100),sign(0) from dual;

SIGN(123) SIGN(-100) SIGN(0)
--------- ---------- ---------
1 -1 0


30.SIN
返回一个数字的正弦值
SQL> select sin(1.57079) from dual;

SIN(1.57079)
------------
1


31.SIGH
返回双曲正弦的值
SQL> select sin(20),sinh(20) from dual;

SIN(20) SINH(20)
--------- ---------
.91294525 242582598


32.SQRT
返回数字n的根
SQL> select sqrt(64),sqrt(10) from dual;

SQRT(64) SQRT(10)
--------- ---------
8 3.1622777


33.TAN
返回数字的正切值
SQL> select tan(20),tan(10) from dual;

TAN(20) TAN(10)
--------- ---------
2.2371609 .64836083


34.TANH
返回数字n的双曲正切值
SQL> select tanh(20),tan(20) from dual;

TANH(20) TAN(20)
--------- ---------
1 2.2371609

35.TRUNC
按照指定的精度截取一个数
SQL> select trunc(124.1666,-2) trunc1,trunc(124.16666,2) from dual;

TRUNC1 TRUNC(124.16666,2)
--------- ------------------
100 124.16

36.ADD_MONTHS
增加或减去月份
SQL> select to_char(add_months(to_date('199912','yyyymm'),2),'yyyymm') from dual;

TO_CHA
------
200002
SQL> select to_char(add_months(to_date('199912','yyyymm'),-2),'yyyymm') from dual;

TO_CHA
------
199910


37.LAST_DAY
返回日期的最后一天
SQL> select to_char(sysdate,'yyyy.mm.dd'),to_char((sysdate)+1,'yyyy.mm.dd') from dual;

TO_CHAR(SY TO_CHAR((S
---------- ----------
2004.05.09 2004.05.10
SQL> select last_day(sysdate) from dual;

LAST_DAY(S
----------
31-5月 -04


38.MONTHS_BETWEEN(date2,date1)
给出date2-date1的月份
SQL> select months_between('19-12月-1999','19-3月-1999') mon_between from dual;

MON_BETWEEN
-----------
9
SQL>selectmonths_between(to_date('2000.05.20','yyyy.mm.dd'),to_date('2005.05.20','yyyy.mm.dd')) mon_betw from dual;

MON_BETW
---------
-60


39.NEW_TIME(date,'this','that')
给出在this时区=other时区的日期和时间
SQL> select to_char(sysdate,'yyyy.mm.dd hh24:mi:ss') bj_time,to_char(new_time
2 (sysdate,'PDT','GMT'),'yyyy.mm.dd hh24:mi:ss') los_angles from dual;

BJ_TIME LOS_ANGLES
------------------- -------------------
2004.05.09 11:05:32 2004.05.09 18:05:32


40.NEXT_DAY(date,'day')
给出日期date和星期x之后计算下一个星期的日期
SQL> select next_day('18-5月-2001','星期五') next_day from dual;

NEXT_DAY
----------
25-5月 -01

41.SYSDATE
用来得到系统的当前日期
SQL> select to_char(sysdate,'dd-mm-yyyy day') from dual;

TO_CHAR(SYSDATE,'
-----------------
09-05-2004 星期日
trunc(date,fmt)按照给出的要求将日期截断,如果fmt='mi'表示保留分,截断秒
SQL> select to_char(trunc(sysdate,'hh'),'yyyy.mm.dd hh24:mi:ss') hh,
2 to_char(trunc(sysdate,'mi'),'yyyy.mm.dd hh24:mi:ss') hhmm from dual;

HH HHMM
------------------- -------------------
2004.05.09 11:00:00 2004.05.09 11:17:00

42.CHARTOROWID
将字符数据类型转换为ROWID类型
SQL> select rowid,rowidtochar(rowid),ename from scott.emp;

ROWID ROWIDTOCHAR(ROWID) ENAME
------------------ ------------------ ----------
AAAAfKAACAAAAEqAAA AAAAfKAACAAAAEqAAA SMITH
AAAAfKAACAAAAEqAAB AAAAfKAACAAAAEqAAB ALLEN
AAAAfKAACAAAAEqAAC AAAAfKAACAAAAEqAAC WARD
AAAAfKAACAAAAEqAAD AAAAfKAACAAAAEqAAD JONES


43.CONVERT(c,dset,sset)
将源字符串 sset从一个语言字符集转换到另一个目的dset字符集
SQL> select convert('strutz','we8hp','f7dec') "conversion" from dual;

conver
------
strutz


44.HEXTORAW
将一个十六进制构成的字符串转换为二进制


45.RAWTOHEXT
将一个二进制构成的字符串转换为十六进制

46.ROWIDTOCHAR
将ROWID数据类型转换为字符类型

47.TO_CHAR(date,'format')
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2004/05/09 21:14:41

48.TO_DATE(string,'format')
将字符串转化为ORACLE中的一个日期


49.TO_MULTI_BYTE
将字符串中的单字节字符转化为多字节字符
SQL> select to_multi_byte('高') from dual;

TO
--



50.TO_NUMBER
将给出的字符转换为数字
SQL> select to_number('1999') year from dual;

YEAR
---------
1999


51.BFILENAME(dir,file)
指定一个外部二进制文件
SQL>insert into file_tb1 values(bfilename('lob_dir1','image1.gif'));


52.CONVERT('x','desc','source')
将x字段或变量的源source转换为desc
SQL> select sid,serial#,username,decode(command,
2 0,'none',
3 2,'insert',
4 3,
5 'select',
6 6,'update',
7 7,'delete',
8 8,'drop',
9 'other') cmd from v$session where type!='background';

SID SERIAL# USERNAME CMD
--------- --------- ------------------------------ ------
1 1 none
2 1 none
3 1 none
4 1 none
5 1 none
6 1 none
7 1275 none
8 1275 none
9 20 GAO select
10 40 GAO none


53.DUMP(s,fmt,start,length)
DUMP函数以fmt指定的内部数字格式返回一个VARCHAR2类型的值
SQL> col global_name for a30
SQL> col dump_string for a50
SQL> set lin 200
SQL> select global_name,dump(global_name,1017,8,5) dump_string from global_name;

GLOBAL_NAME DUMP_STRING
------------------------------ --------------------------------------------------
ORACLE.WORLD Typ=1 Len=12 CharacterSet=ZHS16GBK: W,O,R,L,D


54.EMPTY_BLOB()和EMPTY_CLOB()
这两个函数都是用来对大数据类型字段进行初始化操作的函数


55.GREATEST
返回一组表达式中的最大值,即比较字符的编码大小.
SQL> select greatest('AA','AB','AC') from dual;

GR
--
AC
SQL> select greatest('啊','安','天') from dual;

GR
--



56.LEAST
返回一组表达式中的最小值
SQL> select least('啊','安','天') from dual;

LE
--



57.UID
返回标识当前用户的唯一整数
SQL> show user
USER 为"GAO"
SQL> select username,user_id from dba_users where user_id=uid;

USERNAME USER_ID
------------------------------ ---------
GAO 25

58.USER
返回当前用户的名字
SQL> select user from dual;

USER
------------------------------
GAO


59.USEREVN
返回当前用户环境的信息,opt可以是:
ENTRYID,SESSIONID,TERMINAL,ISDBA,LABLE,LANGUAGE,CLIENT_INFO,LANG,VSIZE
ISDBA 查看当前用户是否是DBA如果是则返回true
SQL> select userenv('isdba') from dual;

USEREN
------
FALSE
SQL> select userenv('isdba') from dual;

USEREN
------
TRUE
SESSION
返回会话标志
SQL> select userenv('sessionid') from dual;

USERENV('SESSIONID')
--------------------
&n

Ubuntu安装oracle-xe-universal_10.2.0.1-1.0_i386

Ubuntu安装oracle-xe-universal_10.2.0.1-1.0_i386

安装:
1.库依赖
sudo apt-get install libaio

2.1源安装
添加源

##Oracle
deb http://oss.oracle.com/debian unstable main non-free

sudo apt-get install oracle-xe-client

2.2deb下载安装
http://www.oracle.com/technology/software/products/database/xe/htdocs/102xelinsoft.html

3.初始配置
安装直至出现一句You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
时,转换用户,输入su,跟住输入你的root密码,进入了root用户终端后,执行/etc/init.d/oracle-xe configure。
前两次默认回车,最后输入SYS和SYSTEM的密码。

4.Get Start
http://127.0.0.1:8080/apex
可以使用了

SQL操作全集


SQL操作全集

下列语句部分是Mssql语句,不可以在access中使用。

SQL分类: 
DDL—数据定义语言(CREATEALTERDROPDECLARE
DML—数据操纵语言(
SELECTDELETEUPDATEINSERT
DCL—数据控制语言(
GRANTREVOKECOMMITROLLBACK)

首先,简要介绍基础语句:
1、说明:创建数据库
CREATE DATABASE database-name 
2、说明:删除数据库
drop database dbname
3、说明:备份sql server
--- 创建 备份数据的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:mssql7backupMyNwind_1.dat'
--- 开始 备份
BACKUP DATABASE pubs TO testBack 
4、说明:创建新表
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
根据已有的表创建新表: 
A:
create table tab_new like tab_old (使用旧表创建新表)
B:
create table tab_new as select col1,col2… from tab_old definition only
5、说明:删除新表drop table tabname 
6、说明:增加一个列
Alter table tabname add column col type
注:列增加后将不能删除。DB2中列加上后数据类型也不能改变,唯一能改变的是增加varchar类型的长度。
7、说明:添加主键: Alter table tabname add primary key(col) 
说明:删除主键:
Alter table tabname drop primary key(col) 
8、说明:创建索引:create [unique] index idxname on tabname(col….) 
删除索引:
drop index idxname
注:索引是不可更改的,想更改必须删除重新建。
9、说明:创建视图:create view viewname as select statement 
删除视图:
drop view viewname
10、说明:几个简单的基本的sql语句
选择:
select * from table1 where 范围
插入:
insert into table1(field1,field2) values(value1,value2)
删除:
delete from table1 where 范围
更新:
update table1 set field1=value1 where 范围
查找:
select * from table1 where field1 like%value1%---like的语法很精妙,查资料!
排序:select * from table1 order by field1,field2 [desc]
总数:
select count * as totalcount from table1
求和:
select sum(field1) as sumvalue from table1
平均:
select avg(field1) as avgvalue from table1
最大:
select max(field1) as maxvalue from table1
最小:
select min(field1) as minvalue from table1
11、说明:几个高级查询运算词
A:
UNION 运算符 
UNION 运算符通过组合其他两个结果表(例如 TABLE1 和 TABLE2)并消去表中任何重复行而派生出一个结果表。当 ALLUNION 一起使用时(即 UNION ALL),不消除重复行。两种情况下,派生表的每一行不是来自 TABLE1 就是来自 TABLE2。 
B:
EXCEPT 运算符 
EXCEPT 运算符通过包括所有在 TABLE1 中但不在 TABLE2 中的行并消除所有重复行而派生出一个结果表。当 ALLEXCEPT 一起使用时 (EXCEPT ALL),不消除重复行。 
C:
INTERSECT 运算符
INTERSECT 运算符通过只包括 TABLE1 和 TABLE2 中都有的行并消除所有重复行而派生出一个结果表。当 ALLINTERSECT 一起使用时 (INTERSECT ALL),不消除重复行。 
注:使用运算词的几个查询结果行必须是一致的。 
12、说明:使用外连接 
A、
left outer join: 
左外连接(左连接):结果集几包括连接表的匹配行,也包括左连接表的所有行。 
SQL:
select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
B:
right outer join
右外连接(右连接):结果集既包括连接表的匹配连接行,也包括右连接表的所有行。 
C:
full outer join: 
全外连接:不仅包括符号连接表的匹配行,还包括两个连接表中的所有记录。

其次,大家来看一些不错的sql语句
1、说明:复制表(只复制结构,源表名:a 新表名:b) (Access可用)
法一:
select * into b from a where 1 <>1
法二:
select top 0 * into b from a

2、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用)
insert into b(a, b, c) select d,e,f from b;

3、说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用)
insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条件
例子:..
from b in '"&Server.MapPath(".")&"data.mdb" &"' where..

4、说明:子查询(表名1:a 表名2:b)
select a,b,c from a where a IN (select d from b ) 或者: select a,b,c from a where a IN (1,2,3)

5、说明:显示文章、提交人和最后回复时间
select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b

6、说明:外连接查询(表名1:a 表名2:b)
select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c

7、说明:在线视图查询(表名1:a )
select * from (SELECT a,b,c FROM a) T where t.a > 1;

8、说明:between的用法,between限制查询数据范围时包括了边界值,not between不包括
select * from table1 where time between time1 and time2
select a,b,c, from table1 where a not between 数值1 and 数值2

9、说明:in 的使用方法
select * from table1 where a [not] in (‘值1’,’值2’,’值4’,’值6’)

10、说明:两张关联表,删除主表中已经在副表中没有的信息 
delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )

11、说明:四表联查问题:
select * from a left inner join b on a.a=b.b right inner join c on a.a=c.c inner join d on a.a=d.d where .....

12、说明:日程安排提前五分钟提醒 
SQL:
select * from 日程安排 where datediff('minute',f开始时间,getdate())>5

13、说明:一条sql 语句搞定数据库分页
select top 10 b.* from (select top 20 主键字段,排序字段 from 表名 order by 排序字段 desc) a,表名 b where b.主键字段 = a.主键字段 order by a.排序字段

14、说明:前10条记录
select top 10 * form table1 where 范围

15、说明:选择在每一组b值相同的数据中对应的a最大的记录的所有信息(类似这样的用法可以用于论坛每月排行榜,每月热销产品分析,按科目成绩排名,等等.)
select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)

16、说明:包括所有在 TableA 中但不在 TableB和TableC 中的行并消除所有重复行而派生出一个结果表
(
select a from tableA ) except (select a from tableB) except (select a from tableC)

17、说明:随机取出10条数据
select top 10 * from tablename order by newid()

18、说明:随机选择记录
select newid()

19、说明:删除重复记录
Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)

20、说明:列出数据库里所有的表名
select name from sysobjects where type='U' 

21、说明:列出表里的所有的
select name from syscolumns where id=object_id('TableName')

22、说明:列示type、vender、pcs字段,以type字段排列,case可以方便地实现多重选择,类似select 中的case。
select type,sum(case vender when 'A' then pcs else 0 end),sum(case vender when 'C' then pcs else 0 end),sum(case vender when 'B' then pcs else 0 end) FROM tablename group by type
显示结果:
type vender pcs
电脑 A
1
电脑 A
1
光盘 B
2
光盘 A
2
手机 B
3
手机 C
3

23、说明:初始化表table1
TRUNCATE TABLE table1

24、说明:选择从10到15的记录
select top 5 * from (select top 15 * from table order by id asc) table_别名 order by id desc
  
随机选择数据库记录的方法(使用Randomize函数,通过SQL语句实现)
  对存储在数据库中的数据来说,随机数特性能给出上面的效果,但它们可能太慢了些。你不能要求ASP“找个随机数”然后打印出来。实际上常见的解决方案是建立如下所示的循环: 
Randomize 
RNumber
= Int(Rnd*499) +1 
 
While Not objRec.EOF 
If objRec("ID") = RNumber THEN 
... 这里是执行脚本 ... 
end if 
objRec.MoveNext 
Wend 
 
   这很容易理解。首先,你取出1到500范围之内的一个随机数(假设500就是数据库内记录的总数)。然后,你遍历每一记录来测试ID 的值、检查其是否匹配RNumber。满足条件的话就执行由THEN 关键字开始的那一块代码。假如你的RNumber 等于495,那么要循环一遍数据库花的时间可就长了。虽然500这个数字看起来大了些,但相比更为稳固的企业解决方案这还是个小型数据库了,后者通常在一 个数据库内就包含了成千上万条记录。这时候不就死定了? 
  采用SQL,你就可以很快地找出准确的记录并且打开一个只包含该记录的recordset,如下所示: 
Randomize 
RNumber
= Int(Rnd*499) + 1 
 
SQL
= "SELECT * FROM Customers WHERE ID = " & RNumber 
 
set objRec = ObjConn.Execute(SQL) 
Response.WriteRNumber
& " = " & objRec("ID") & " " & objRec("c_email") 
 
  不必写出RNumber 和ID,你只需要检查匹配情况即可。只要你对以上代码的工作满意,你自可按需操作“随机”记录。Recordset没有包含其他内容,因此你很快就能找到你需要的记录这样就大大降低了处理时间。 
再谈随机数 
  现在你下定决心要榨干Random 函数的最后一滴油,那么你可能会一次取出多条随机记录或者想采用一定随机范围内的记录。把上面的标准Random 示例扩展一下就可以用SQL应对上面两种情况了。 
  为了取出几条随机选择的记录并存放在同一recordset内,你可以存储三个随机数,然后查询数据库获得匹配这些数字的记录: 
SQL
= "SELECT * FROM Customers WHERE ID = " & RNumber & " OR ID = " & RNumber2 & " OR ID = " & RNumber3 
 
  假如你想选出10条记录(也许是每次页面装载时的10条链接的列表),你可以用BETWEEN 或者数学等式选出第一条记录和适当数量的递增记录。这一操作可以通过好几种方式来完成,但是
SELECT 语句只显示一种可能(这里的ID 是自动生成的号码): 
SQL
= "SELECT * FROM Customers WHERE ID BETWEEN " & RNumber & " AND " & RNumber & "+ 9

  注意:以上代码的执行目的不是检查数据库内是否有9条并发记录。

 
随机读取若干条记录,测试过
Access语法:
SELECT top 10 * From 表名 ORDER BY Rnd(id)
Sql server:
select top n * from 表名 order by newid()
mysqlelect
* From 表名 Order By rand() Limit n
Access左连接语法(最近开发要用左连接,Access帮助什么都没有,网上没有Access的SQL说明,只有自己测试, 现在记下以备后查)
语法elect table1.fd1,table1,fd2,table2.fd2
From table1 left join table2 on table1.fd1,table2.fd1 where ...
使用SQL语句 用...代替过长的字符串显示
语法:
SQL数据库:
select case when len(field)>10 then left(field,10)+'...' else field end as news_name,news_id from tablename
Access数据库:
SELECT iif(len(field)>2,left(field,2)+'...',field) FROM tablename; 
 
Conn.Execute说明
Execute方法
  该方法用于执行SQL语句。根据SQL语句执行后是否返回记录集,该方法的使用格式分为以下两种:
    
1.执行SQL查询语句时,将返回查询得到的记录集。用法为:
    
Set 对象变量名=连接对象.Execute("SQL 查询语言")
   Execute方法调用后,会自动创建记录集对象,并将查询结果存储在该记录对象中,通过Set方法,将记录集赋给指定的对象保存,以后对象变量就代表了该记录集对象。

    
2.执行SQL的操作性语言时,没有记录集的返回。此时用法为:
    连接对象.
Execute "SQL 操作性语句" [, RecordAffected][, Option]
      ·RecordAffected 为可选项,此出可放置一个变量,SQL语句执行后,所生效的记录数会自动保存到该变量中。通过访问该变量,就可知道SQL语句队多少条记录进行了操作。
      ·
Option 可选项,该参数的取值通常为adCMDText,它用于告诉ADO,应该将Execute方法之后的第一个字符解释为命令文本。通过指定该参数,可使执行更高效。

2008-09-23

牛人语录

牛人语录
1.    你让我滚,我滚了。你让我回来,对不起,滚远了
2.    流氓不可怕,就怕流氓有文化……
3.    走牛B的路,让傻B去说吧!
4.    开车无难事,只怕有新人!
6.    矿难在检讨中继续,楼价在控制中上升!
7.    XP不发威,你当我是DOS啊!
8.    英雄不问出路,流氓不看岁数!
9.    好好活着,因为我们会死很久!!!
10.  人又不聪明,还学人家秃顶!!
11.  没什么事不要找我,有事更不用找我
12.  宁和明白人打一架,不跟sb说句话
13.  再牛b的肖邦,也弹不出老子的悲伤!
14.  只要锄头舞的好,那有墙角挖不倒?
15.  连广告也信,读书读傻了吧!
16.  要在江湖混,最好是光棍!!
17.  不要和我比懒,我懒得和你比。
19.  早上长睡不起;晚上视睡如归!
21.  女为悦己者容男为悦己者穷!
22.  秃驴,敢跟贫道抢师太?
23.  犯贱是普遍真理,你我只是其中之一
24.  唯女人与英语难过也,唯老婆与工作难找也!
25.  赚别人的钱,让贫穷见鬼去吧。
26.  就算是believe 中间也藏了一个lie
27.  钱不是问题,问题是没钱!
30.  怀才就像怀孕,时间久了才能让人看出来。
31.  今天心情不好.我只有四句话想说.包括这句和前面的两句.我的话说完了
32.  人不能在一棵树上吊死,要在附近几棵树上多死几次试试
33.  走别人的路,让别人走投无路
34.  思想有多远,你就给我滚多远
35.  驴是的念来过倒
36.  上Google上百度一下。
37.  你以为我会眼睁睁地看着你去送死?我会闭上眼睛的。
38.  请你以后不要在我面前说英文了,OK?
39.  好久没有人把牛皮吹的这么清新脱俗了!
40.  一觉醒来,天都黑了。
41.  钱可以解决的问题都不是问题。
42.  不吃饱哪有力气减肥啊?
43.  问君能有几多愁,恰似一群太监上青楼
44.  钞票不是万能的,有时还需要信用卡。
45.  我允许你走进我的世界,但决不允许你在我的世界里走来走去。
46.  人怕出名猪怕壮,男怕没钱女怕胖。
47.  珍惜生活——上帝还让你活着,就肯定有他的安排。
48.  工作的最高境界就是看着别人上班,领着别人的工资。
49.  爱情就像便便,水一冲就再也回不来了~爱情就像便便,来了之后挡也挡不住~爱情就像便便,每次都一样又不太一样~爱情就像便便,有时努力了很久却只是个屁!
50、过去流氓在深山,现在流氓在公安

Borland C+GNU make编译、链接项目

Borland C+GNU make编译、链接项目
    Borland C 3.1的编译器举世无双,但其IDE在今天看来是丑陋之极。相信很多人都用Eclipse + CDT或者Vim等工具写代码,然后打开BCC建立工程,编译、链接程序。因此,笔者探索了利用脚本或make工具+bcc等命令完成对项目的编译、链接。
    为了更具有代表性,我建立了三个文件,main.c、fun.c和include/fun.h
main.c:
#include <stdio.h>
#include "fun.h"

int main(void)
{
        print();
        getchar();
        return 0;
}

fun.c:
#include <stdio.h>
#include "fun.h"

void print(void)
{
        printf("Hello, World!n");
}

fun.h:
void print(void);

    建立好文件后,首先使用最简单的方法--批处理脚本,建立run.bat文件。
run.bat
::Batch file, for Turbo C 2.0 and Borland C 3.1
set CC_HOME=D:/BORLANDC
set BIN=%CC_HOME%/BIN
set INCLUDE=%CC_HOME%/INCLUDE;./INCLUDE
set LIB=%CC_HOME%/LIB;./LIB

set PATH=%PATH%;%BIN%
set CC=%BIN%/bcc

set DIST=Release
set TARGET=pos.exe

set CFLAGS=-c -mm -O2 -G -I%INCLUDE% -n%DIST%
set LFLAGS=-mm -L%LIB% -n%DIST%

if not exist %DIST% mkdir %DIST%
%CC% %CFLAGS% *.c
%CC% -e%TARGET% %LFLAGS% %DIST%/*.obj

    运行,dist文件夹中就生成了执行文件test.exe,但是批处理文件自身功能有限,下面,我们尝试使用功能更强大的GNU make来描述项目依赖,编译、链接项目。
makefile
# GNU make makefile in windows and Dos, for Turbo C 2.0 and Borland C 3.1
# Confirm GNU make is in you PATH
SHELL=cmd.exe

CC_HOME=D:/BORLANDC
BIN=$(CC_HOME)/BIN
INCLUDES=$(CC_HOME)/INCLUDE;./INCLUDE
LIBS=$(CC_HOME)/LIB;./LIBS

export PATH=%PATH%;$(BIN)
CC=$(BIN)/bcc

DIST=Release
TARGET=pos.exe

CFLAGS=-c -mm -O2 -G -I$(INCLUDES) -n$(DIST)
LFLAGS=-mm -L$(LIBS) -n$(DIST)

all:link

link:compile
        $(CC) -e$(TARGET) $(LFLAGS) $(DIST)/*.obj
compile:setup
        $(CC) $(CFLAGS) *.c
setup:
        if not exist $(DIST) mkdir $(DIST)

clean:
        del /Q $(DIST)

    总结,linux下,vim+gcc+make为程序员提供了一个简单、实用而有效的项目编译、链接方案,对于Windows用户,编译器厂家都将自己的编译器封装起来,在某种程度上,把程序员绑定到IDE上了,程序员很难择自己喜欢、习惯的文本编辑工具。通用的编译脚本和GNU make脚本或许是Windows程序员的另外一种选择。


DOS、Windows下使用脚本、make工具编译程序

DOS、Windows下使用脚本、make工具编译程序

    在Linux下,程序员往往以Vi为编辑工具写代码,使用make和gcc在命令行下完成程序配置和编译;在DOS下,Turbo C与Borland C的编辑功能很弱,使用者往往只使用其编译器,但DOS的程序操作又显麻烦;在Windows下,新的IDE,如Eclipse+CDT拥有更加强大的功能和更亲和的页面,但是CDT却不提供对VC++编译器的支持,这个时候,我们就只能靠脚本来完成编译了。
    先来看脚本,Batch File文件,使用批处理,直接调用编译器来完成编译,对于简单的程序,这就够用了。
run.bat文件
# Batch file, for Turbo C 2.0 and Borland C 3.1
set CC_HOME=D:BORLANDC
set BIN=%CC_HOME%BIN
set INCLUDE=%CC_HOME%INCLUDE;.INCLUDE
set LIB=%CC_HOME%LIB;.LIB

set PATH=%PATH%;%BIN%
set CC=%BIN%bcc

set NAME=test
erase /Q %NAME%.exe
erase /Q %NAME%.obj
%CC% -e%NAME%.exe -mm -I%INCLUDE% -L%LIB% %NAME%.c
erase /Q %NAME%.obj
pause
    但是,这样的简单的程序对于真正的项目就力不从心了,这让我们想起了Linux下的makefile,不过现在FSF已经推出了windows下的make工具。
makefile文件
# GNU make makefile in windows, for Turbo C 2.0 and Borland C 3.1
# Confirm GNU make is in you PATH
SHELL=cmd.exe

CC_HOME=D:BORLANDC
BIN=$(CC_HOME)BIN
INCLUDE=$(CC_HOME)INCLUDE;.INCLUDE
LIB=$(CC_HOME)LIB;.LIB

export PATH=%PATH%;$(BIN)

CC=$(BIN)bcc
CFLAGS=-mm -I$(INCLUDE) -L$(LIB)
DIST=test

all:
    echo %PATH%
    $(CC) -e$(DIST) $(CFLAGS) $(DIST).c
    del /Q *.OBJ

clean:
    del /Q $(DIST).exe
    del /Q *.OBJ

2008-09-21

linux下常用的关机/重启命令

linux下常用的关机/重启命令

    在linux下一些常用的关机/重启命令有shutdown、halt、reboot、及init,它们都可以达到重启系统的目的,但每个命令的内部工作过程是不同的,通过本文的介绍,希望你可以更加灵活的运用各种关机命令。

1. shutdown
    shutdown 命令安全地将系统关机。 有些用户会使用直接断掉电源的方式来关闭linux,这是十分危险的。因为linux与windows不同,其后台运行着许多进程,所以强制关机可能会导 致进程的数据丢失﹐使系统处于不稳定的状态﹐甚至在有的系统中会损坏硬件设备。而在系统关机前使用shutdown命令﹐系统管理员会通知所有登录的用户 系统将要关闭。并且login指令会被冻结﹐即新的用户不能再登录。直接关机或者延迟一定的时间才关机都是可能的﹐还可能重启。这是由所有进程 〔process〕都会收到系统所送达的信号〔signal决定的。这让像vi之类的程序有时间储存目前正在编辑的文档﹐而像处理邮件〔mail〕和新闻 〔news〕的程序则可以正常地离开等等。
    shutdown执行它的工作是送信号〔signal〕给init程序﹐要求它改变 runlevel。Runlevel 0被用来停机〔halt〕﹐runlevel 6是用来重新激活〔reboot〕系统﹐而runlevel 1则是被用来让系统进入管理工作可以进行的状态﹔这是预设的﹐假定没有-h也没有-r参数给shutdown。要想了解在停机〔halt〕或者重新开机 〔reboot〕过程中做了哪些动作﹐你可以在这个文件/etc/inittab里看到这些runlevels相关的资料。
shutdown 参数说明:
   [-t] 在改变到其它runlevel之前﹐告诉init多久以后关机。
   [-r] 重启计算器。
   [-k] 并不真正关机﹐只是送警告信号给每位登录者〔login〕。
   [-h] 关机后关闭电源〔halt〕。
   [-n] 不用init﹐而是自己来关机。不鼓励使用这个选项﹐而且该选项所产生的后果往往不总是你所预期得到的。
   [-c] cancel current process取消目前正在执行的关机程序。所以这个选项当然没有时间参数﹐但是可以输入一个用来解释的讯息﹐而这信息将会送到每位使用者。
   [-f] 在重启计算器〔reboot〕时忽略fsck。
[-F] 在重启计算器〔reboot〕时强迫fsck。
   [-time] 设定关机〔shutdown〕前的时间。     
2.halt----最简单的关机命令
其实halt就是调用shutdown -h。halt执行时﹐杀死应用进程﹐执行sync系统调用﹐文件系统写操作完成后就会停止内核。
参数说明:
   [-n] 防止sync系统调用﹐它用在用fsck修补根分区之后﹐以阻止内核用老版本的超级块〔superblock〕覆盖修补过的超级块。
   [-w] 并不是真正的重启或关机﹐只是写wtmp〔/var/log/wtmp〕纪录。
   [-d] 不写wtmp纪录〔已包含在选项[-n]中〕。
   [-f] 没有调用shutdown而强制关机或重启。
   [-i] 关机〔或重启〕前﹐关掉所有的网络接口。
   [-p] 该选项为缺省选项。就是关机时调用poweroff。  
3.reboot
    reboot的工作过程差不多跟halt一样﹐不过它是引发主机重启﹐而halt是关机。它的参数与halt相差不多。
4.init
    init 是所有进程的祖先﹐它的进程号始终为1﹐所以发送TERM信号给init会终止所有的用户进程﹑守护进程等。shutdown 就是使用这种机制。init定义了8个运行级别(runlevel),init 0为关机﹐init 1为重启。关于init可以长篇大论﹐这里就不再叙述。另外还有telinit命令可以改变init的运行级别﹐比如﹐telinit -iS可使系统进入单用户模式﹐并且得不到使用shutdown时的信息和等待时间。

The Top 9½ In a Hacker’s Bookshelf

The Top 9½ In a Hacker’s Bookshelf

Every hacker should have a good solid dead tree library to draw ideas from and use as reference material. This list has a bit of everything - textbooks you will encounter at top tier computer science universities, books giving insight into the industry, and references you shouldn’t be caught without. It is a list of hackers’ classics.

Buy The Mythical Man MonthThe Mythical Man Month: Essays on Software Engineering - Anniversary Edition

by Fredrick P. Brooks

This is a classic on the human elements of software engineering first published in 1975. The technology has changed a lot in this time, but the human elements of software engineering have remained the same. It is a wealth of insight, often quoted, and very well known in the industry. “The Mythical Man Month” describes many commonly occurring problems in large and mid-scale development projects and breaks them down. Here are a two of the book’s important principles:

The Mythical Man-Month: Adding manpower to a late software project makes it later.

No silver bullet: There is not a single strategy, technique, or trick that can exponentially raise the productivity of programmers.

I recommend this book not only for programmers, but for anyone managing a software project. Project managers and programmers alike will appreciate Brooks’ clear, well-thought out points.

Buy The C Programming Language

The C Programming Language (2nd Edition)

by Brian W. Kernighan and Dennis M. Ritchie

Commonly referred to as just K&R, this is the canonical C reference book. It’s to the point without being too terse; its detailed enough for a beginner to understand without being bloated. K&R tells you exactly what you need. Nothing more, nothing less. At 274 pages this is one of the most compact languages references you will find. I dare a Java author to come up with something so sweetly concise.

This book is recommended for anyone learning C, and for anyone looking for a C reference book. K&R is a must read for anyone who is writing a language reference or technical literature.

If you have never programmed before, K&R might not be the best place to start out, but still doable if you are motivated. Beginners might also consider getting a copy of “The C Answer Book,” which gives detailed explanations of solutions to the K&R exercises.

Buy Structure and Interpretation of Computer Programs

Structure and Interpretation of Computer Programs (2nd Edition)

by Harold Abelson and Gerald Jay Sussman

SICP is used in entry level computer science classes at many top tier universities including the University of California - Berkeley and the Massachusetts Institute of Technology. It uses the Scheme language to introduce many powerful paradigms like recursion, lambda notation, abstraction, and interpreted languages.

I found this book incredibly dense when I first read it for an introductory CS class, and there was still much to learn from a reread several years later after I had a better grasp of the ideas presented here.

If you didn’t have the opportunity to use this book in the classroom, I would recommend picking it up to see what you missed, especially if you haven’t used any of the Lisp dialects extensively.

Buy Code Complete

Code Complete 2: A Practical Handbook of Software Construction

by Steve McConnell

“Code Complete 2″ is a highly regarded book about software construction, where McConnell defines construction as mainly programming and debugging, along with some elements of construction planning, detailed design, unit testing, integration, and integration testing.

The book’s focus is on writing better code. McConnell touches on a wide variety of topics including managing complexity, refactoring, coding style, and writing good comments.

This book is recommended for anyone who wants to write good solid code. It will save beginners time when learning good coding practices, and is a great refresher for programmers with years of experience who may find that over time they have developed habits that are holding them back.

Introduction to Algorithms

Introduction to Algorithms

by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein

This is another textbook. “Introduction to Algorithms,” is probably the most popular university-level text for algorithms classes. It also serves as an excellent reference book.

Even though practically speaking most programmers shouldn’t be writing their own implementation of, say, quicksort, in a production environment, algorithms knowledge is essential for understanding what kind of asymptotic performance you can expect from libraries and your own code.

“Introduction to Algorithms,” is recommended as a reference for any developer looking to brush up on their algorithm skills. It is also recommended if you are interested in topics like NP-Completeness , randomized algorithms, or Fast Fourier Transformation. Good math skills are essential if you want to grok all parts of this book.

Buy Design Patterns: Elements of Reusable Object-Oriented SoftwareDesign Patterns: Elements of Reusable Object-Oriented Software

by Erich Gamma, Richard Helm, Ralph Johnson, and John M. Vlissides

This is a catalog of different object-oriented design patterns. For each of the 23 patterns that are presented, the authors give an in-depth analysis including a motivating example for the pattern, common pitfalls and trade-offs, related patterns, and sample code in either C++ or Smalltalk. Some of the patterns covered are Singleton, Observer, Template Method, Iterator, and Proxy.

This book is a must read for intermediate or advanced developers working on object-oriented code. Coders that are new to object-oriented design would be best served by mastering the basics of an object-oriented language and digging in to non-trivial project before attempting to learn all of the patterns presented here, otherwise the patterns aren’t likely to “stick.”

Programming PearlsProgramming Pearls (2nd Edition)

by Jon Bentley

This is a great book for learning how to approach problems. Each of the 15 chapters presents a different task, such as sorting phone numbers, creating anagrams, or doing text searches. The problem is defined, and then Bentley walks through different solutions, providing a discussion and clear analysis of each solution, with a breakdown of programming principles at the end.

“Programming Pearls,” contains some very clever ideas, and would be of some use as an algorithm reference for a small class of problems, but the take away of the book is something much bigger and more general: how to approach and solve problems from the perspective of an engineer.

I recommend this book to anyone who enjoys working though programming brain teasers.

Buy Compilers: Principles, Techniques, and Tools Compilers: Principles, Techniques, and Tools

by Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman

“Compilers: Principles, Techniques, and Tools,” is commonly known simply as the “dragon book.” This is the standard textbook in a theoretical compilers class. It covers everything you would expect to find in a compilers text: language syntax, parsers, lexical analysis, grammars, intermediate code generation, runtime environments, optimization, etc. If you haven’t done a lot of work with these topics, be prepared to learn a whole slew of new termonolgy and concepts: deterministic finite automata, finite state automata, LR parsing, and more.

I particularily enjoyed parts of the dragon book that get down and dirty into the mathematical notation and theory - and this is large theme throughout the book. If you find regular expressions and state machines facinating you will really enjoy the book. On the other hand, if you are looking for a text that will introduce modern, practical compiler implementation details you may find the dragon book a bit lacking. In those respects the dragon book is starting to show its age (this version was copyrighted in 1986).


Unix Power Tools, Third Edition

by Shelley Powers, Jerry Peek, Tim O’Reilly, and Mike Loukides

This is one of the many great books from the O’Reilly collection. “Unix Power Tools,” weighs in at a hefty 1200 pages, and is full of descriptions of Unix command line tools, usage cases, and shell script syntax examples for all of the major shells.

“Unix Power Tools,” is a great reference book and is fairly well organized into self-contained chapters. If you find yourself reading this book from cover to cover you are an amazing specimen of geekdom.

Much of the information contained within this book can be found more quickly with a Google search, but sometimes its nice to have a dead tree reference as well.

This is one of the few books that is valuable for beginners and experts alike. Everyone from a complete Unix newbie to a seasoned Systems Administrator has something to gain from “Unix Power Tools.”

The Ultimate Hitchhiker's GuideThe Ultimate Hitchhiker’s Guide: Five Complete Novels and One Story

by Douglas Adams

Well this book isn’t technically about hacking, but your geek card is hereby revoked if you haven’t at least read this “increasingly inaccurately named,” Hitchhiker’s Trilogy. It contains all 5 books in the Trilogy: “The Hitchhiker’s Guide to the Galaxy,” “The Restaurant at the End of the Universe,” “Life, The Universe and Everything,” “So Long, and Thanks for All the Fish,” and “Mostly Harmless,” plus the short “Young Zaphod Plays it Safe.”

Be entertained. Discover the answer to life, the universe, and everything. Learn how to make a Pan Galactic Gargle Blaster. And most of all don’t panic!

This edition is bound in beautiful black leather and has a silk ribbon bookmark sewn into it. It’s like reading a very nice Bible, only more believable. (Mandatory disclaimer before any trolls find me: That was a joke.)

That’s it for my top 9½. What would you put in yours?

[Update: Have a look at the follow-up list, 5½ more books in a hacker’s bookshelf.]


ANSI C实现文件长度读取

ANSI C实现文件长度读取
#include <stdio.h>

long fsize(FILE *fp)
{
    long cur, size;
   
    cur = ftell(fp);
    fseek(fp, 0, SEEK_END);
    size = ftell(fp);
    fseek(fp, cur, SEEK_SET);
    return size;
}

int main(void)
{
    FILE *fp;
   
    fp = fopen("test.c","r");
    printf("size = %ldn", fsize(fp));
    fclose(fp);
   
    getchar();
    return 0;
}

Borland C和Turbo C的命令编译脚本

Borland C和Turbo C的命令编译脚本
本脚本只能编译单个文件,但可以包含多个头文件 。
set CC_HOME=D:BORLANDC
set BIN=%CC_HOME%BIN
set INCLUDE=%CC_HOME%INCLUDE;.INCLUDE
set LIB=%CC_HOME%LIB;.LIB

set PATH=%PATH%;%BIN%
set CC=%BIN%bcc

set NAME=test
erase /Q %NAME%.exe
erase /Q %NAME%.obj
%CC% -mm -e%NAME%.exe -I%INCLUDE% -L%LIB% %NAME%.c
erase /Q %NAME%.obj
pause

2008-09-20

5½ More Books In a Hacker’s Bookshelf


5½ More Books In a Hacker’s Bookshelf


This is a follow up to the list of recommended books for a hacker’s bookshelf that was posted a few months ago. Here are 5½ more essential books for a hacker’s bookshelf. This list is based on reader suggestions, and like the previous list of recommended programming books, it contains a nice mix of computer science texts, developer references, and books giving insight into the programming industry. This is another list of hackers’ classics.

The Pragmatic Programmer

The Pragmatic Programmer: From Journeyman to Master

by Andrew Hunt and David Thomas

The “Pragmatic Programmer” is a high level overview of a wide range of practical topics in software development. It covers just about every aspect of software development including working in teams, source control, writing bullet-proof code, thinking critically, remembering the big picture, the benefits of knowing your tools, effective communication…and the list goes on.

“The Pragmatic Programmer” is organized around a series of practical tips for becoming a better software developer. Many of the tips are immediately implementable, and each tip is explained in a logical way and supported by entertaining anecdotes and quotes. The book contains a handy tear-out card that lists all of the tips.

This book is recommended for anyone who wants to be a better coder. It is probably best suited to beginner and intermediate developers, but advanced developers may find it a fun and worthwhile read as well.

Also recommended by Florian Potschka and Jason.

The Art of Computer Programming, Volumes 1-3 Boxed Set by Donald E. Knuth

The Art of Computer Programming, Volumes 1-3 Boxed Set

by Donald E. Knuth

According to The New Hacker’s Dictionary, a safe answer when you don’t know something is always: “I think you can find that in Knuth.” The Art of Computer Programming (TAOCP) is a probably the definitive computer science text. This boxed set contains the first 3 volumes of a planned 7 volume set. Volume 4 is unfinished, and is currently being published as a set of smaller books called fascicles. The 3 volumes included here are: “Fundamental Algorithms,” “Seminumerical Algorithms,” and “Sorting and Searching.”

I’m a bit embarrassed to say that I haven’t read TAOCP - I’ve always found it a bit hard to justify spending $190 on a set of books, even if they are masterpieces. (Update: Amazon currently has the set marked down to $153.) I would recommend TAOCP to anyone who wants to fill in any gaps in their computer science knowledge, and who has a lot of pocket change laying around.

Also recommended by seb and Dennis Grooves.

The Art of UNIX Programming

The Art of UNIX Programming

by Eric S. Raymond

This book does a great job of explaining the old “hacker ethic” and explaining why *nix is the way it is. “The Art of UNIX Programming,” contains case studies and commentary from many of the big names in the *nix culture: Ken Thompson, Steve Johnson, Brian Kernighan, David Korn, and others.

This book really covers a lot of ground. The first part of the book is an introduction to the *nix history, culture, and philosophy. The main points brought up in the introduction are then well-illustrated by case studies. The book goes on to talk about the various tools that are available in the *nix ecosystem, and how to be a successful participant in the FOSS community.

This book is recommended for anyone who has an interest in operating systems history, the open source culture and philosophy, or just learning about different tools and techniques that will help in becoming a better coder.

Also recommended by jason and Tet.

The Little Schemer

The Little Schemer - 4th Edition

by Daniel P. Friedman and Matthias Felleisen

“The Little Schemer” (editions 1-3 were called the “Little Lisper”) uses a unique question and answer technique to create a dialog that really draws you into the book. It starts from first principles and gradually works up to more advanced topics like the halting problem and writing a Scheme interpreter.

Despite the title, this book isn’t really about Scheme; it covers only the basic features of the language, and doesn’t even introduce local variables. However, a more thorough treatment of Scheme is given in the next book in the serious, “The Seasoned Schemer.” What “The Little Schemer,” does do well is teach recursion and the art of “thinking in Lisp.” Recursion is a recurring theme that is continually expanded upon throughout the book.

This book is recommended for anyone looking for a mind-expanding treatment of recursion and the art of thinking like a lisper.

Also recommended by landon dyer.

Peopleware: Productive Projects and Teams by Tom DeMarco And Timothy Lister

Peopleware: Productive Projects and Teams (Second Edition)

by Tom DeMarco and Timothy Lister

“Peopleware” focuses on the sociological aspects of software development. The authors state that for the overwhelming majority of failed software projects, the failure was due to sociological, not technical, problems.

This book is very well regarded in the industry, and I think a large reason for that is the underlying theme of Peopleware: developers, when given the chance, will do the right thing. Furthering this idea, a manger’s job is not to make people work, but to give people the ability to work. This means (among other things) private offices with closing doors for developers, and coders who are given intellectual responsibility over their jobs. The points are backed up by statistical evidence and often humorous anecdotes.

This book is recommended for anyone who manages software development projects, or aspires to lead a team of developers. Buying one for management could just convince them to ditch the cubicle idea.

Also recommended by Florian Potschka.

Snow Crash

Snow Crash

by Neal Stephenson

“Snow Crash” is the obligatory science fiction book in the list. This book is one of the defining books in the cyberpunk genre, right along with Bruce Sterling’s work. “Snow Crash” is the story of Hiro Protagonist, last of the freelance hackers and the greatest sword fighter in the world, who delivers pizzas for a Mafia-controlled pizza franchise. He teams up with Y.T., a spunky young female skateboard courier in order to help his friend Da5id who was the victim of a computer virus with biological effects.

This book ties together ancient Sumerian myths, post-modern computer viruses, and biological hacking. The result is an almost matrix-esque hacker world view. For the most part, the book moves along very quickly from one surreal action sequence to another. My only complaint was that the section on Sumerian culture really bogged down the pace of the book.

“Snow Crash” is a must read for anyone who enjoys the cyberpunk genre and/or fast-paced, action-packed fiction.


Windows与Vmware下的Linux文件共享方式总结

Windows与Vmware下的Linux文件共享方式总结


Windows和Linux间有很多文件共享的方式,这里我总结了一下。假设你的Host计算机是Windows,Guest是Linux哈。

1.利用Samba

这是我用得最多的方式

2.在Linux下配置Apahce

在Linux下配置Apahce,然后在Windows下通过www方式把Linux下的文件下载下来。这种方式只能把Linux的文件传到Windows,不能把Windows的文件传到Linux.

3.在Linux下配置Ftp

用vsftp或者wu-ftp都可以,配置成上传权限的,然后Windows和Linux就可以相互共享文件了。

4.Windows下配置WWW服务

用IIS,Apache或者其它的都可以。如果你的Linux只有命令行的话,就用wget命令吧,可以很方便地下载文件。

5.Windows下配置Ftp

用serv-u比较简单

6.利用Windows的文件共享功能

比如说你的Windows的IP为192.168.0.1,共享了一个叫share的目录,那么就可以用下列命令

mount -t smbfs //192.168.0.1/share /mnt -o username=user%passwd

或者smbmount //192.168.0.1/share /mnt -o username=user%passwd(用这个命令要安samba哦)

7.用vmware tools工具

SharedFolders是Vmware4 的一个新功能,更加方便了在Host,Guest操作系统间共享文件。但是使用前

要安装vmware tools.

点击setting->vmware tools install
mount /dev/cdrom /mnt/cdrom

cd /mnt/cdrom

里面有一个vmware tools的tar包,解开执行vmware-tools-install.pl脚本,一路回车,一般没有问题。
点击Edit->Virtual Machine Settigns->Option->SharedFolders->Add,选定要共享的文件夹并给这个文件夹命名,下一步。选定“Enable
thisshare”, 确定以后,vmware会把这个文件夹自动mount到/mnt/hgfs目录下。

8.直接挂接物理硬盘或者硬盘分区

不过vmware也是支持直接mount Host机器的磁盘,方法是在虚机设置里新建磁盘,类型选“Usephysicaldisk(foradvanced users)”,再选定磁盘和分区就可以。但是这样的操作可能会引会文件系统的不一致,导致错误,不推荐使用。

9.用ISO文件

虚拟机里面的光驱可以有物理光驱和ISO文件两种,我们可以把我们的文件重点制件成ISO文件(用WinIso),然后在Linux中作为CDROM挂接。