星期二, 五月 23, 2006

JBOSS LOG4J 的控制.

conf/log4j.xml 里控制指定logger的开关

编写一个class,名字为: com.company.hrm.test.testLogger.

包含如下语句:

package com.company.hrm.test;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger;

public class testLogger
{
public testLogger()
{
}
public static void main(String[] args)
{
org.apache.log4j.BasicConfigurator.configure();
Logger log = org.apache.log4j.Logger.getLogger(testLogger.class.getName());
log.debug("来自testLogger的debug");
log.info("来自testLogger的info");
log.error("来自testLogger的error");
log.fatal("来自testLogger的fatal");
System.out.println("....................");

}
}

Log4j.xml:

<category name="com.company.hrm.test">
<priority value="FATAL"/>
</category>



priority 包含:ALL,DEBUG,INFO,WARN,FATAL,OFF 其中之一。

其中优先级别包含顺序为:ALL<DEBUG<INFO<WARN<FATAL<OFF
ALL的级别最低,如果想关闭某种类型的信息,需要把更高级的类型设置进去。

比如想关掉INFO级别的信息,只需要把priority的value设置为"OFF"或WARN,FATAL就可以了

星期二, 五月 16, 2006

MySQL Audit功能开启

在以下文件中加入如下行

/etc/my.cnf
[mysqld]
log_update=/var/log/mysql.update.log
log-long-format
set-variable = log=/var/log/mysql.log #一般完全SQL Plan记录

星期六, 五月 13, 2006

Mathematica Import输入Table数据文件

Mathematica Documentation: Import

Mathematica输入的数据文件,列必须用空格分开,空格的个数不限制。

如下:
001 28 12 15 21 19 01 999 03 11 08 01

data=Import["文件名","Table"]

星期五, 五月 12, 2006

MatheMatica 5 画图技巧之三:改变图形大小.

使用:ImageSize -> {620, 448} option来实现,如下:

ListPlot[fg, PlotStyle -> {PointSize[.02], RGBColor[
1, 0, 0]}, PlotJoined -> False, AxesOrigin -> {0, 0}, AxesLabel -> {"号码
", "频率"}, PlotLabel -> "2006年号码频率图", Frame ->
True, ImageSize -> {620, 448}];

星期二, 五月 09, 2006

lottery=
{{28,12,15,21,19,01},
{13,28,07,21,26,16},
{16,04,05,02,06,20},
{04,08,17,27,28,31},
{19,24,20,27,03,26},
{32,22,08,26,21,23},
{32,27,33,16,18,04},
{18,28,05,03,32,09},
{26,08,05,20,30,06},
{04,29,06,19,12,27},
{31,08,05,27,07,14},
{31,09,11,33,13,27},
{16,05,01,21,06,12},
{32,33,14,29,06,26},
{29,09,32,02,03,15},
{01,07,17,23,30,13},
{31,08,33,04,32,03},
{17,26,24,14,01,13},
{22,13,32,06,26,04},
{26,21,23,05,29,09},
{21,22,01,02,20,05},
{04,03,16,13,27,02},
{13,14,04,19,23,28},
{02,11,27,09,07,21},
{24,03,17,04,19,32},
{02,01,32,29,22,18},
{27,06,08,11,16,14},
{14,07,27,16,17,05},
{04,14,03,07,19,09},
{32,20,15,08,13,17},
{16,32,03,10,31,12},
{24,20,26,18,05,31},
{15,23,27,31,22,20},
{33,16,10,02,17,15},
{03,29,09,13,21,27},
{10,07,04,17,16,21},
{32,25,12,02,24,23}};

For[t = 1, t < Length[
lottery], t++; Show[ListPlot[lottery[[t]], PlotStyle -> {PointSize[.04], RGBColor[1, 0, 0] }]]]

星期一, 五月 08, 2006

Mathematica 5 画图之三,改变点的大小

Show[Graphics[{PointSize[.4],RGBColor[1,0,0],Point[{30,1}]},
Background\[Rule]GrayLevel[0.5]]]

Mathematica 5 绘图技巧二.

Plot[Sin[x], {x, 0, 2Pi},
PlotStyle -> {Thickness[0.02], Dashing[{0.03, 0.07}], RGBColor[1, 0, 0]}]

Mathematica 如何异步输出图象?

参数DisplayFunction(显示函数)
该参数决定图形的显示与否,当取值为Identity 时,图形不显示出来.
当取值为$DisplayFunction时恢复图形的显示.
1、 图形的组合显示函数Show

Plot的作用可以同时在同一坐标系的同一区间内作出不同函数的图像,但有时需要在同一坐标系的不同区间作出不同函数的图像,或者在同一坐标系作一个函数而要求函数的各个部分具有不同的形态(像分段函数),这个时候就需要使用Show函数.

实验13 在同一坐标系中作出y=ex和y=lnx的图像,并说明它们的图像关于直线y=x对称.
输入:
a=Plot[Exp[x],{x,-2,2},AspectRatio->Automatic,PlotStyle->RGBColor[0,1,0],
DisplayFunction->Identity]
b=Plot[Log[x],{x,0.3,3},AspectRatio->Automatic,PlotStyle->RGBColor[1,0,0],
DisplayFunction->Identity]
c=Plot[x,{x,-2,2},AspectRatio->Automatic,PlotStyle->Dashing[{0.09,0.04}],
DisplayFunction->Identity]
Show[a,b,c,DisplayFunction?$DisplayFunction]

如何设置Mathematica 5 的绘画参数?

Plot[Sin[x], {x, 0, 2Pi}, PlotStyle -> {RGBColor[1,
0, 0], Dashing[{0.03, 0.07}]}
]

星期日, 五月 07, 2006

巧用java来计算对数

巧用java来计算对数

毫无疑问,Java可以计算对数,然而在API中却有惊人的误差。但是如果运用了以下的方法,用Java处理数字所遇到的小麻烦就可以轻而易举的解决了。
  Sun的J2SE提供了一个单一的对数方法??double java.lang.Math.log(double),这很容易使用。请看如下代码:
  double x = Math.log(5);
  等价于下面的数学方程:
  x = ln 5
  或
  x = loge5
  其中e是内皮尔数或自然数。
  如果你想算底不同的对数又该如何做呢?很遗憾,我们还没有办法计算以10为底或以2为底的对数。但是它们却是在计算对数时用的最多的。要想解决这个问题,我们就要回想曾经在学校里学过的数学和对数方程:
  logx(y) =loge(x) / loge(y)
  这只需一段简单的Java程序来实现:
  package com.generationjava.math;
  public class Logarithm {
   static public double log(double value, double base) {
   return Math.log(value) / Math.log(base);
   }
  }
  计算100的以10为底的对数就变为非常简单了:
  double log = Logarithm.log(100, 10); // log is 2.0
  512的以2为底的对数是:
  double log = Logarithm.log(512, 2); // log is 9.0
  下面的两个简单的方法也都是很有用的:
  static public double log2(double value) {
   return log(value, 2.0);
   }
   static public double log10(double value) {
   return log(value, 10.0);
   }

星期二, 五月 02, 2006

Oscar Wilde 王?德 CSI said

http://www.brainyquote.com/quotes/quotes/o/oscarwilde117770.html

野心是失败者最后的庇护所
Ambition is the last refuge of the failure.

星期六, 四月 29, 2006

Fedora 5.0 有关NTFS及FAT文件系统的挂载

1、自己安装时,NTFS内核模块的版本判断及软件包的安装;

首先我们要安装NTFS的内核模块,一种是在线升级,另外一种是下载安装,当然也得与自己的内核相对应才行;

1..1 确立内核版本及下载说明;

[root@localhost beinan]# uname -p -r
2.6.15-1.2054_FC5 i686

如果您是下载内核的模块,应该看好内核版本,上面显示的是内核版本是2.6.15-1.2054_FC5 ,并且是i686的;

下载地址: http://www.linux-ntfs.org/content/view/157/83/

注意:在这页上有好多的版本,比如有smp的,这是多处理器的;有x86_64的,这是64位的CPU的,除非您用的是64位机器的,否则没有必要;

根据上面uname -p -r的输出,我下载了 kernel-module-ntfs-2.6.15-1.2054_FC5-2.1.26-0.rr.10.4.i686.rpm 软件包;


1..2 安装;

您可以点鼠标安装,也可以用命令安装

#rpm -ivh kernel-module-ntfs-*.rpm

星期四, 四月 27, 2006

Python打开文件,接受命令行

# -*- coding: UTF-8 -*-
import os
import sys
import traceback
if len(sys.argv)<2:
print "参数0",sys.argv[0]
print " 必须输入参数"
sys.exit(0)
try:
name =sys.argv[1]
if os.path.exists(name):
input = open(name,'r')
for line in input:
print line,
except Exception,e:
print traceback.print_exc()

星期三, 四月 26, 2006

Python 异常 处理小tips.

# -*- coding: UTF-8 -*-
import traceback
try:
print 1/0
except Exception,e:
print "异常",e
traceback.print_exc()

python 实现一个http client

import sys
import socket
Host="10.2.5.240"
Port=80
mysocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM);
mysocket.connect((Host,Port))
#mysocket.send("HTTP/1.1\n\r");
mysocket.send("GET /ehrm/ HTTP/1.1\n\rHost:10.2.5.34\n\r\n\r");
length=0;
while 1:
text = mysocket.recv(2048)
if not text:
break
print text
length=length+len(text)
print "读取了",length,"字节"
mysocket.close();

Python 函数注释的有趣功能

我们可以给一个函数加上功能说明。
允许用户在使用的时候,可以查看说明
语法: print 函数名.__doc__(注意是两个下画线连起来)
def test():
*** this is a test function
***

星期五, 四月 21, 2006

XP 命令行符号

Syntax : Redirection

   command  >  filename       Redirect command output to a file

command >> filename APPEND into a file

command < filename Type a text file and pass the text to command

commandA | commandB Pipe the output from commandA into commandB

command & command Perform the first command & then perform the second

command 2> filename Redirect any error message into a file

command 2> nul Redirect any error message to NUL

(command) 2> filename Redirect any CMD error into a file

command > fileA 2> fileB Redirect output and errors to separate files

command > file 2> nul Redirect output to a file and suppress any error

(command) > file 2> nul Redirect output to a file and suppress any CMD error

command > file 2>&1 Redirect output and errors to one file

command 2>&1 >filename This will fail!

XP 命令行超级工具

WMIC
Q.得到当前系统运行的所有进程。
WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid

or

WMIC /OUTPUT:C:\ProcessList.txt path win32_process get Caption,Processid,Commandline
或者 tasklist.exe /V得到详细信息。

如果想杀掉一个进程:taskkilll /PID #进程号# 或你知道程序的名字 taskkill /F /IM notepad.exe

星期二, 四月 04, 2006

如何用CSS来改变鼠标的光标形状?

手形 
十字 
文本光标 
等待 
默认 
问号 
左右箭头 
上下箭头 
系统自动给出效果

星期三, 三月 29, 2006

Linux终端输入汉字,保存出现错误.

只需要
1.export LANG=zh
或者
2.export LC_CTYPE=iso-8859-1