星期一, 五月 10, 2010

Re: Lisp注释语句.

Lisp 注释规则二:

缩进规则:
    函数调用形式参数对齐
    宏和特殊形式针对最后一个左括号缩进两格
    ;;;; 文件级别注释
    ;;; 段落级别注释
    ;;  函数内部代码注释
    ;   函数内部代码单行注释,放在代码后面



2010/5/7 William Wang <javacave@gmail.com>
在阅读 Practical Common Lisp书的时候,突然想到LISP的注释符号应该是如何写呢?
google了下。
http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/com_mechanics.html

单句注释;分号表示 ;;;header
块注释 #|
 Notes:zh
  #

另外一种非常规的注释,是在代码中用“ ”来表示,比如下列代码

	(defun mumble_fcn ( arg1 arg2  ) 
"This function takes two arbitrary arguments and returns some
arbitrarily random result. NOTE: both arguments should be non-nil."
(do-random-thing (do-random-thing arg1 ) arg2 ))




星期五, 五月 07, 2010

SAP NetWeaver Composition Environment 7.2 Trial Version 安装 步骤 Create secure store 出现错误

SAP NetWeaver Composition Environment 7.2 Trial Version
首先下载了jdk 1.6.0_07之上的版本,我下载的是 1.6.0_20版本,并且下载了jce 6的文件,很小只有8K.
安装到步骤时候出现错误:
createsecurestore.JPG
安装 :18/29的时候,Create secure store
 
根据提示打开错误日志:
C:\Program Files\sapinst_instdir\NW72_DEV_ADA\SERVER\SecureStoreCreate.log
发现如下提示:

FATAL: Main class "com.sap.security.core.server.secstorefs.SecStoreFS" cannot be started:
  FATAL: java.lang.ExceptionInInitializerError
    at javax.crypto.Cipher.getInstance(DashoA13*..)
    at javax.crypto.Cipher.getInstance(DashoA13*..)
    at iaik.security.provider.IAIK.a(Unknown Source)
    at iaik.security.provider.IAIK.addAsJDK14Provider(Unknown Source)
    at iaik.security.provider.IAIK.addAsJDK14Provider(Unknown Source)
    at com.sap.security.core.server.secstorefs.Crypt.<clinit>(Crypt.java:85)
    at com.sap.security.core.server.secstorefs.SecStoreFS.setSID(SecStoreFS.java:177)
    at com.sap.security.core.server.secstorefs.SecStoreFS.handleCreate(SecStoreFS.java:838)
    at com.sap.security.core.server.secstorefs.SecStoreFS.main(SecStoreFS.java:1308)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:161)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
    at javax.crypto.SunJCE_b.<clinit>(DashoA13*..)
    ... 14 more
Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
    at javax.crypto.SunJCE_b.i(DashoA13*..)
    at javax.crypto.SunJCE_b.g(DashoA13*..)
    at javax.crypto.SunJCE_b$1.run(DashoA13*..)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 15 more

  FATAL: com.sap.engine.offline.OfflineToolStart will abort now with exitcode 2

Solution:
copy
C:\Program Files\Java\jre6\lib\security 下所有文件到sap临时安装JVM目录下,
如果有提示是否需要覆盖,不要覆盖SAP原来的文件。
to
C:\Program Files\sapinst_instdir\NW72_DEV_ADA\SERVER\sapjvm\sapjvm_6\jre\lib\security


Lisp注释语句.

在阅读 Practical Common Lisp书的时候,突然想到LISP的注释符号应该是如何写呢?
google了下。
http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/com_mechanics.html

单句注释;分号表示 ;;;header
块注释 #|
 Notes:zh
  #

另外一种非常规的注释,是在代码中用“ ”来表示,比如下列代码

	(defun mumble_fcn ( arg1 arg2  ) 
"This function takes two arbitrary arguments and returns some
arbitrarily random result. NOTE: both arguments should be non-nil."
(do-random-thing (do-random-thing arg1 ) arg2 ))



星期二, 四月 20, 2010

数据库Auto time stamp字段

MYSQL 5.x支持:通过字段申明:
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);

MSSQL:支持:
版本戳 timestamp 字段类型。

星期一, 四月 19, 2010

SAP相关 第一帖

2010.4.20日。

今天装好了Net Weaver 7.1 SR1
和 笔记本上ECC 6.0 EH4 FOR MSSQL 2005 WINDOW 7

准备全力投入SAP 了

星期二, 一月 26, 2010

jsp code too large for try statement

必杀技:
在JAVA_OPTS里加入以下变量:

1.java -Dcom.sun.tools.javac.main.largebranch=true

java lib\tools.jar 包内

注意,如果装有多个版本的JDK,需要通过设置JAVA_HOME来指明使用的JDK的路径
只是在path中加入是不够的。

星期三, 一月 06, 2010

Linux文件名包含特殊字符无法使用通配符:Argument list too long

Linux文件名包含特殊字符比如-,括弧()等等,grep "xxx" filename

会出现:Argument list too long错误

简单解决办法,同find 一起使用

find . -exec grep -l "搜索字符" "{}" \;

列出包含 “搜索字符”的文件名

星期二, 十二月 15, 2009

IE getElementById display

Could not get the display property. Invalid argument

使用obj.style.display='none'
出现错误:
Could not get the display property. Invalid argument

function hider() {
var label, control;

if(document.getElementById && (label = document.getElementById('hidden1'))
&& (control = document.getElementById('hidden2'))
&& label.style && control.style)
{
label.style.display = control.style.display
= ('none' == label.style.display) ? '' : 'none';
}

星期二, 十二月 01, 2009

clear window update store directory

clear window update store directory

%systemdrive%\windows\SoftwareDistribution

clear

星期五, 十一月 20, 2009

wxwidgets convet wxString to C Style char

wxString 提供的 c_str,fn_str,char_str等都source code encoding相关

如果想转换成功,必须注意编译的encoding选择。

比如如果打开了unicode的编译选择,wxWidgets想从一个wxString得到一个 c Style的char *
最安全的方法为:
wxString asc=wxString("this is 汉字");
char *=asc.mb_str(wxConvUTF8);

curl 如何在mingw下使用


首先从http://curl.haxx.se/下载最新的源代码包。
比如 curl-7.19.7.tar.gz
1.然后将其展开到一个目录下,将来将要引用这里面的内容,include和lib
2.进入lib目录下:运行 mingw32-make -f Makefile.m32 编译生成所有的库.libcur.a及libcurl.dll等
3.进入/curl/docs/examples/ 编译个测试程序:
gcc -DCURL_STATICLIB -I ../../include -L ../../lib simple.c -o simple -lcurl -lws2_32 -lwinmm

运行simple.exe,能够正常运行。
CodeBlocks 里如何使用libcurl 实现static link(静态连接,避免运行使用libcurl.dll)

在codeblocks里可以在项目属性build options link setting 里加入 libcur.a的包,以及定义编译使用静态链接的属性
CURL_STATICLIB或者在使用的代码里加入:

#define CURL_STATICLIB

codeblock配置如图:


注意:如果编译的时候出现符号错误:
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_initA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_search_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_dnA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_values_lenA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_value_free_len'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_unbind_s'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_msgfree'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ber_free'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'

这是需要连接mingw32的 ldap32 .这个需要在项目的build option link lib 里加入:
D:\MinGW\lib\libwldap32.a,顺序要注意.

libwldap32.a必须在libcurl.a的后面

星期一, 十一月 16, 2009

Windows rundll32 utility

Any program using the Windows file association mechanism can be started with the rundll32 utility.

用一个编辑器,打开一个默认后缀的文件:

RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL c:\temp\a.txt

ere a list of what is available
rundll32 shell32,Control_RunDLL                     Run The Control Panel
rundll32 shell32,Control_RunDLL X Start applet X of Control Panel
("X" = any CPL filename)
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,4 Regional setting, Date tab

rundll32 shell32,OpenAs_RunDLL \dir\filename.txt Open The 'Open With...' Window
rundll32 shell32,ShellAboutA Info-Box Open 'About Window Window'
rundll32 shell32,Control_RunDLL desk.cpl Open Display Properties
rundll32 user,cascadechildwindows Cascade All Windows
rundll32 user,tilechildwindows Minimize All Child-Windows
rundll32 user,repaintscreen Refresh Desktop
rundll32 keyboard,disable Lock The Keyboard
rundll32 mouse,disable Disable Mouse
rundll32 user,swapmousebutton Swap Mouse Buttons
rundll32 user,setcursorpos Set Cursor Position To (0,0)
rundll32 user,wnetconnectdialog Show 'Map Network Drive' Window
rundll32 user,wnetdisconnectdialog Show 'Disconnect Network Disk' Window
rundll32 user,disableoemlayer Display The BSOD (blue screen of death)Window
rundll32 diskcopy,DiskCopyRunDll Show Copy Disk Window
rundll32 rnaui.dll,RnaWizard Run 'Internet Connection Wizard'
rundll32 shell32,SHFormatDrive Run 'Format Disk (A)' Window
rundll32 shell32,SHExitWindowsEx -1 Cold Restart Of Windows Explorer
rundll32 shell32,SHExitWindowsEx 1 Shut Down Computer
rundll32 shell32,SHExitWindowsEx 0 Logoff Current User
rundll32 shell32,SHExitWindowsEx 2 Windows9x Quick Reboot
rundll32 krnl386.exe,exitkernel Force Windows 9x To Exit (no confirmation)
rundll32 rnaui.dll,RnaDial "MyConnect" Run 'Net Connection' Dialog
rundll32 msprint2.dll,RUNDLL_PrintTestPage Choose & Print Test Page Of Current Printer
rundll32 user,setcaretblinktime Set New Cursor Rate Speed
rundll32 user, setdoubleclicktime Set New DblClick Speed (Rate)
rundll32 sysdm.cpl,InstallDevice_Rundll Hardware installation wizard
rundll32 user,MessageBeep Default beep sound
rundll32 user32.dll,MessageBeep Default beep sound (XP)
rundll32 shell32.dll,Control_RunDLL appwiz.cpl Add/remove programs
rundll32 shell32.dll,Control_RunDLL timedate.cpl,,0 Date/time settings
rundll32 shell32.dll,Control_RunDLL odbccp32.cpl ODBC settings

rundll32.exe url.dll,FileProtocolHandler http:\\www.rgagnon.com
rundll32.exe url.dll,FileProtocolHandler c:\mypdf.pdf
Open the associated application
rundll32 amovie.ocx,RunDll /play /close c:\mymovie.mpg
Play multimedia (movie or sound)

Rundll32.exe powrprof.dll,SetSuspendState Sleep Put the computer in Sleep mode


Privacy (IE)
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 Internet temporary files
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 Cookies
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 1 History
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 Forms Data
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 Passwords
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 Delete everything

星期二, 十一月 03, 2009

mysql get table index SQL command

1.show index from tablename
2.select * from information_schema.statistics where table_name='tableName' ;

星期一, 十一月 02, 2009

Mysql 性能分析


EXPLAIN
SELECT * FROM table IGNORE INDEX (indexname) WHERE

星期三, 十月 28, 2009

网络地址类型一览

URL: http://publib.boulder.ibm.com/infocenter/zvm/v5r4/topic/com.ibm.zvm.v54.kijl0/hcsk7b3014.htm

The type of a IPv6 address is identified by the high-order bits of the address, as follows:

Table 2. Types of IPv6 Addresses
Address type Binary prefix IPv6 notation
Unspecified 00 . . . 0 (128 bits) ::/128
Loopback 00 . . . 1 (128 bits) ::1/128
Multicast 11111111 FF00::/8
Link-local unicast 1111111010 FE80::/10
Site-local unicast 1111111011 FEC0::/10
Global unicast (everything else)

Three categories of IP addresses are supported in IPv6:

Unicast
An identifier for a single interface. A packet sent to a unicast address is delivered to the interface identified by that address. It can be link-local scope, site-local scope, or global scope.
Multicast
An identifier for a group of interfaces (typically belonging to different nodes). A packet sent to a multicast address is delivered to all interfaces identified by that address.
Anycast
An identifier for a group of interfaces (typically belonging to different nodes). A packet sent to an anycast address is delivered to the closest member of a group, according to the routing protocols' measure of distance.

Anycast addresses are taken from the unicast address spaces (of any scope) and are not syntactically distinguishable from unicast addresses. Anycast is described as a cross between unicast and multicast. Like multicast, multiple nodes may be listening on an anycast address. Like unicast, a packet sent to an anycast address will be delivered to one (and only one) of those nodes. The exact node to which it is delivered is based on the IP routing tables in the network.

There are no broadcast addresses in IPv6. Multicast addresses have superseded this function.

Unicast IPv6 Addresses

IPv6 unicast addresses can be aggregated with prefixes of arbitrary bit-length similar to IPv4 addresses under Classless Interdomain Routing (CIDR).

A unicast address has the following format:

Figure 8. Unicast Address Format
n bits 128-n bits
network prefix interface ID

There are several types of unicast addresses in IPv6: global unicast, site-local unicast, and link-local unicast. There are also some special-purpose subtypes of global unicast, such as IPv6 addresses with embedded IPv4 addresses. Additional address types or subtypes can be defined in the future.

Global Unicast Addresses

The general format for IPv6 global unicast addresses is:

Figure 9. Global Unicast Address Format
n bits m bits 128-n-m bits
global routing prefix subnet ID interface ID

The global routing prefix is a (typically hierarchically-structured) value assigned to a site (a cluster of subnets/links). The subnet ID is an identifier of a link within the site. The interface ID is used to identify an interface on a link; interface IDs are required to be unique within a subnet prefix.

All global unicast addresses other than those that start with B'000' have a 64-bit interface ID field (that is, n + m = 64). Global unicast addresses that start with B'000' have no such constraint on the size or structure of the interface ID field.

Examples of global unicast addresses that start with B'000' are IPv6 address with embedded IPv4 addresses. These include IPv4-mapped IPv6 addresses and IPv4-compatible IPv6 addresses.

Local Use Address

There are two types of local-use unicast addresses defined: link-local and site-local. The link-local address is for use on a single link and the site-local address is for use in a single site.

Link-local Addresses

Link-local addresses have the following format:

Figure 10. Link-local address format
10 bits 54 bits 64 bits
1111111010 0 interface ID

A link-local address is required on each physical interface. Link-local addresses are designed to be used for addressing on a single link for purposes such as automatic address configuration, neighbor discovery, or in the absence of routers. It also may be used to communicate with other nodes on the same link. A link-local address is automatically assigned.

Routers will not forward any packets with link-local source or destination addresses to other links.

Site-local Addresses

Site-local addresses have the following format:

Figure 12. Site-local address format
10 bits 38 bits 16 bits 64 bits
1111111011 0 subnet ID interface ID

Site-local addresses are designed to be used for addressing inside of a site without the need for a global prefix. A site-local address cannot be reached from another site. A site-local address is not automatically assigned to a node. It must be assigned using automatic or manual configuration.

Routers will not forward any packets with site-local source or destination addresses outside of the site.

Loopback Address

The unicast address 0:0:0:0:0:0:0:1 is called the loopback address. It cannot be assigned to any physical interface. It may be thought of as a link-local unicast address assigned to a virtual interface (typically called the loopback interface) that allows local applications to send messages to each other.

The loopback address cannot be used as the source address in IPv6 packets that are sent outside of a node. An IPv6 packet with a destination address of loopback cannot be sent outside of a node and be forwarded by an IPv6 router. A packet received on an interface with destination address of loopback will be dropped.

Unspecified Address

The address 0:0:0:0:0:0:0:0 is called the unspecified address. It will not be assigned to any node. It indicates the absence of an address. One example of its use is in the Source Address field of any IPv6 packets sent by an initializing host before it has learned its own address.

The unspecified address cannot be used as the destination address of IPv6 packets or in IPv6 routing headers. An IPv6 packet with a source address of unspecified cannot be forwarded by an IPv6 router.

IPv4-mapped IPv6 Addresses

These addresses hold an embedded global IPv4 address. They are used to represent the addresses of IPv4 nodes as IPv6 addresses to applications that are enabled for IPv6 and are using AF_INET6 sockets. This allows IPv6 enabled applications always to deal with IP addresses in IPv6 format regardless of whether the TCP/IP communications are occurring over IPv4 or IPv6 networks. The dual-mode TCP/IP stack performs the transformation of the IPv4-mapped addresses to and from native IPv4 format. IPv4-mapped addresses have the following format:

Figure 14. IPv4-mapped IPv6 address
80 bits 16 32 bits
0000...0000 FFFF IPv4 address

Examples:

  • In IPv6-IPv4 decimal form:
    ::FFFF:129.144.52.38
  • In IPv6-compressed form
    ::FFFF:8190:3426
IPv4-compatible IPv6 Addresses

These addresses hold an embedded global IPv4 address. They are used dynamically to tunnel IPv6 packets over IPv4 networks. IPv6 nodes that use this technique are assigned special IPv6 unicast addresses which hold an IPv4 address in the low-order 32-bits. IPv4-compatible IPv6 addresses have the following format:

Figure 15. IPv4-compatible IPv6 address
80 bits 16 32 bits
0000...0000 0000 IPv4 address

Examples:

  • In IPv6-IPv4 decimal form
    ::129.144.52.38
  • In IPv6-compressed form
    ::8190:3426
Multicast IPv6 Addresses

An IPv6 multicast address is an identifier for a group of interfaces (typically on different nodes). It is identified with a prefix of 11111111 or FF in hexadecimal notation. It provides a way of sending packets to multiple destinations. An interface may belong to any number of multicast groups.

Multicast address format

Binary 11111111 at the start of the address identifies the address as being a multicast address. Multicast addresses have the following format:

Figure 16. Multicast address format
8 4 4 112 bits
11111111 flags scope group ID
Figure 17. Flags in multicast address
 ---------------
| 0 | 0 | 0 | T |

---------------
  • The 3 high-order flags are reserved, and must be initialized to 0.
  • T = 0 indicates a permanently-assigned (well-known) multicast address, assigned by the Internet Assigned Number Authority (IANA).
  • T = 1 indicates a non-permanently assigned (transient) multicast address.

Scope is a 4-bit multicast scope value used to limit the scope of the multicast group. Group ID identifies the multicast group, either permanent or transient, within the given scope.

Multicast scope

The scope field indicates the scope of the IPv6 internetwork for which the multicast traffic is intended. The size of this field is 4 bits. In addition to information provided by multicast routing protocols, routers use multicast scope to determine whether multicast traffic can be forwarded. For multicast addresses there are 14 possible scopes (some are still unassigned), ranging from interface-local to global (including both link-local and site-local).

The following table lists the defined values for the scope field:

Table 3. Multicast scope field values
Value Scope
0 Reserved
1 Interface-local scope (same node)
2 Link-local scope (same link)
3 Subnet-local scope
4 Admin-local scope
5 Site-local scope (same site)
8 Organization-local scope
E Global scope
F Reserved
All other scope field values are currently undefined.

For example, traffic with the multicast address of FF02::2 has a link-local scope. An IPv6 router never forwards this type of traffic beyond the local link.

Interface-local
The interface-local scope spans a single interface only. A multicast address of interface-local scope is useful only for loopback delivery of multicasts within a node, for example, as a form of interprocess communication within a computer. Unlike the unicast loopback address, interface-local multicast addresses may be joined on any interface.
Link-local
Link-local addresses are used by nodes when communicating with neighboring nodes on the same link. The scope of the link-local address is the local link.
Subnet-local
Subnet-local scope is given a different and larger value than link-local to enable possible support for subnets that span multiple links.
Admin-local
Admin-local scope is the smallest scope that must be administratively configured, that is, not automatically derived from physical connectivity or other, non-multicast-related configuration.
Site-local
The scope of a site-local address is the site or organization internetwork. Addresses must remain within their scope. A router must not forward packets outside of its scope.
Organization-local
This scope is intended to span multiple sites belonging to a single organization.
Global
Global scope is used for uniquely identifying interfaces anywhere in the Internet.
Multicast groups

Group ID identifies the multicast group, either permanent or transient, within the given scope. The size of this field is 112 bits. Permanently assigned groups can use the group ID with any scope value and still refer to the same group. Transient assigned groups can use the group ID in different scopes to refer to different groups. Multicast addresses from FF01:: through FF0F:: are reserved, well-known addresses. Use of these group IDs for any other scope values, with the T flag equal to 0, is not allowed.

All-nodes multicast groups

These groups identify all IPv6 nodes within a given scope. Defined groups include:

  • Interface-local all-nodes group (FF01::1)
  • Link-local all-nodes group (FF02::1)
All-routers multicast groups

These groups identify all IPv6 routers within a given scope. Defined groups include:

  • Interface-local all-routers group (FF01::2)
  • Link-local all-routers group (FF02::2)
  • Site-local all-routers group (FF05::2)
Solicited-node multicast group

For each unicast address which is assigned to an interface, the associated solicited-node multicast group is joined on that interface. The solicited-node multicast address facilitates the efficient querying of network nodes during address resolution.

Anycast IPv6 Addresses

An IPv6 anycast address is an identifier for a set of interfaces (typically belonging to different nodes). A packet sent to an anycast address is delivered to one of the interfaces identified by that address (the nearest interface), according to the routing protocols' measure of distance. It uses the same formats as a unicast address, so one cannot differentiate between a unicast and an anycast address simply by examining the address. Instead, anycast addresses are defined administratively.

For more information about IPv6 addressing, see RFC 3513, Internet Protocol Version 6 (IPv6) Addressing Architecture.

Java中如何得到网卡的IP地址而不是127.0.0.1

tip:最后发现,如果是web程序可以通过,javax.servlet.http .HttpServletRequest里的:getServerName()可以用来得到外部IP,很奇怪。getLocalAddr().getHostAddress()的结果不同.


String ipaddress="";
java.util.Enumeration interfaces = java.net.NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements())
{
java.net.NetworkInterface card = (java.net.NetworkInterface) interfaces.nextElement();
java.util.Enumeration addresses = card.getInetAddresses();
if (addresses == null)
continue;

while (addresses.hasMoreElements())
{
java.net.InetAddress address = (java.net.InetAddress) addresses.nextElement();
if(!address.isLoopbackAddress())//skip 127.0.0.1 address
{
if(address.isSiteLocalAddress())//yes,it,not NIC link address
{
ipaddress=address.getHostAddress();
break;
}
}
}
}

星期日, 十月 25, 2009

wxButton 如何捕获Enter回车事件

动态事件connect 需要使用wxEVT_COMMAND_BUTTON_CLICKED事件,而不是wxEVT_KEY_DOWN

wxButton *toclip = new wxButton(books,ID_BUTTON_TO_CLIP, wxT("复制剪贴板"), wxPoint(x,y));
toclip ->Connect(wxEVT_COMMAND_BUTTON_CLICKED ,wxCommandEventHandler(GlobalEvtHandler::OnPagingHandler));

星期三, 十月 21, 2009

get jboss tomcat http server config port and SSL etc

通过MBean jmx的方式来发现系统配置是个比较好的program思路
发现Mbean的几个方法如下:
那个可以工作要看不同的jboss 版本。第一个一般是可以的

1.MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
2.MBeanServer server = org.jboss.mx.util.MBeanServerLocator.locateJBoss();

InitialContext ctx = new InitialContext(table); // From table

MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/HttpAdaptor");

System.out.println("Version = "
+ (String)server.getAttribute(new ObjectName("jboss.system:type=Server"), new String("Version")));


JBOSS 允许SSL及配置的数字签名文件
早server.xml或tomcat config.xml文件中加入两个属性
keystoreFile="${user.home}/.keystore" keystorePass="changeit"

然后到.keystore指定的目录下运行如下命令:

%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA

跟随提示,密码同keystorePass属性指定的保持一致就可以了

all is ok.



星期三, 十月 14, 2009

wxWidgets 连续打开两个Dialog造成exception的原因

使用wxwidgets打开wxDialog出现一个奇怪的问题.

代码如下:
原因:
Destroy();造成了异常。
只需要最后一次打开Dialog的时候,调用Destroy()就可以了。
不知道为什么,很奇怪。

最后发现:这样解决了一场问题,但是,引用程序不会退出了,挂死了!!!!

经过再次的研究,在每次点ok按钮 退出Dialog的时候,要调用:EndModal(wxID_OK);
奇怪之极。要加入
dlg.EndModal(wxID_OK);
dlg2.EndModal(wxID_OK);



void test()
{
wxDialog dlg;
dlg.Create(NULL, wxNewId(), _T("Step 1"),
wxDefaultPosition, wxSize(500,300));
wxPanel* bgpanel=new wxPanel(&dlg, wxID_ANY, wxDefaultPosition, wxSize(dlg.GetSize().GetWidth(),dlg.GetSize().GetHeight()), wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("Step 1"));
wxButton* ok = new wxButton(bgpanel,wxID_OK,_("ok"),wxPoint(bgpanel->GetSize().GetWidth()/2-50,bgpanel->GetSize().GetHeight()-60));

dlg.ShowModal();
dlg.Destroy();

wxDialog dlg2;
dlg2.Create(NULL, wxNewId(), _T("Step 2"),
wxDefaultPosition, wxSize(500,300));
wxPanel* bgpane2=new wxPanel(&dlg2, wxID_ANY, wxDefaultPosition, wxSize(dlg2.GetSize().GetWidth(),dlg2.GetSize().GetHeight()), wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("step 1"));
wxButton* ok2 = new wxButton(bgpane2,wxID_OK,_("ok"),wxPoint(bgpane2->GetSize().GetWidth()/2-50,bgpane2->GetSize().GetHeight()-60));

dlg2.ShowModal();
dlg2.Destroy();
}

星期四, 九月 03, 2009

wxDateTime时间格式

strftime(3)

Name

strftime - format date and time

Synopsis

#include <time.h>
size_t strftime(char *s, size_t max, const char *format, const struct tm
*tm);
The strftime() function formats the broken-down time tm according to the format specification format and places the result in the character array s of size max.

Ordinary characters placed in the format string are copied to s without conversion. Conversion specifications are introduced by a '%' character, and terminated by a conversion specifier character, and are replaced in s as follows:

%a
The abbreviated weekday name according to the current locale.
%A
The full weekday name according to the current locale.
%b
The abbreviated month name according to the current locale.
%B
The full month name according to the current locale.
%c
The preferred date and time representation for the current locale.
%C
The century number (year/100) as a 2-digit integer. (SU)
%d
The day of the month as a decimal number (range 01 to 31).
%D
Equivalent to %m/%d/%y. (Yecch -- for Americans only. Americans should note that in other countries %d/%m/%y is rather common. This means that in international context this format is ambiguous and should not be used.) (SU)
%e
Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space. (SU)
%E
Modifier: use alternative format, see below. (SU)
%F
Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
%G
The ISO 8601 year with century as a decimal number. The 4-digit year corresponding to the ISO week number (see %V). This has the same format and value as %y, except that if the ISO week number belongs to the previous or next year, that year is used instead. (TZ)
%g
Like %G, but without century, i.e., with a 2-digit year (00-99). (TZ)
%h
Equivalent to %b. (SU)
%H
The hour as a decimal number using a 24-hour clock (range 00 to 23).
%I
The hour as a decimal number using a 12-hour clock (range 01 to 12).
%j
The day of the year as a decimal number (range 001 to 366).
%k
The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) (TZ)
%l
The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) (TZ)
%m
The month as a decimal number (range 01 to 12).
%M
The minute as a decimal number (range 00 to 59).
%n
A newline character. (SU)
%O
Modifier: use alternative format, see below. (SU)
%p
Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as 'pm' and midnight as 'am'.
%P
Like %p but in lowercase: 'am' or 'pm' or a corresponding string for the current locale. (GNU)
%r
The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to '%I:%M:%S %p'. (SU)
%R
The time in 24-hour notation (%H:%M). (SU) For a version including the seconds, see %T below.
%s
The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. (TZ)
%S
The second as a decimal number (range 00 to 60). (The range is up to 60 to allow for occasional leap seconds.)
%t
A tab character. (SU)
%T
The time in 24-hour notation (%H:%M:%S). (SU)
%u
The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. (SU)
%U
The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
%V
The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. (SU)
%w
The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
%W
The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
%x
The preferred date representation for the current locale without the time.
%X
The preferred time representation for the current locale without the date.
%y
The year as a decimal number without a century (range 00 to 99).
%Y
The year as a decimal number including the century.
%z
The time-zone as hour offset from GMT. Required to emit RFC 822-conformant dates (using "%a, %d %b %Y %H:%M:%S %z"). (GNU)
%Z
The time zone or name or abbreviation.
%+
The date and time in date(1) format. (TZ) (Not supported in glibc2.)
%%
A literal '%' character.

Some conversion specifications can be modified by preceding the conversion specifier character by the E or O modifier to indicate that an alternative format should be used. If the alternative format or specification does not exist for the current locale, the behaviour will be as if the unmodified conversion specification were used. (SU) The Single Unix Specification mentions %Ec, %EC, %Ex, %EX, %Ey, %EY, %Od, %Oe, %OH, %OI, %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, %Oy, where the effect of the O modifier is to use alternative numeric symbols (say, roman numerals), and that of the E modifier is to use a locale-dependent alternative representation.

The broken-down time structure tm is defined in <time.h>. See also ctime(3).

Return Value

The strftime() function returns the number of characters placed in the array s, not including the terminating null byte, provided the string, including the terminating null byte, fits. Otherwise, it returns 0, and the contents of the array is undefined. (Thus at least since libc 4.4.4; very old versions of libc, such as libc 4.4.1, would return max if the array was too small.)

Note that the return value 0 does not necessarily indicate an error; for example, in many locales %p yields an empty string.

Environment

The environment variables TZ and LC_TIME are used.

Conforming to

SVr4, C89, C99. There are strict inclusions between the set of conversions given in ANSI C (unmarked), those given in the Single Unix Specification (marked SU), those given in Olson's timezone package (marked TZ), and those given in glibc (marked GNU), except that %+ is not supported in glibc2. On the other hand glibc2 has several more extensions. POSIX.1 only refers to ANSI C; POSIX.2 describes under date(1) several extensions that could apply to strftime() as well. The %F conversion is in C99 and POSIX.1-2001.

In SUSv2, the %S specified allowed a range of 00 to 61, to allow for the theoretical possibility of a minute that included a double leap second (there never has been such a minute).

Glibc Notes

Glibc provides some extensions for conversion specifications. (These extensions are not specified in POSIX.1-2001, but a few other systems provide similar features.) Between the % character and the conversion specifier character, an optional flag and field width may be specified. (These precede the E or O modifiers, if present.)

The following flag characters are permitted:

_
(underscore) Pad a numeric result string with spaces.
-
(dash) Do not pad a numeric result string.
  • Pad a numeric result string with zeros even if the conversion specifier character uses space-padding by default.
^
Convert alphabetic characters in result string to upper case.
#
Swap the case of the result string. (This flag only works with certain conversion specifier characters, and of these, it is only really useful with %Z).

An optional decimal width specifier may follow the (possibly absent) flag. If the natural size of the field is smaller than this width, then the result string is padded (on the left) to the specified width.

Bugs

Some buggy versions of gcc complain about the use of %c: warning: '%c' yields only last 2 digits of year in some locales. Of course programmers are encouraged to use %c, it gives the preferred date and time representation. One meets all kinds of strange obfuscations to circumvent this gcc problem. A relatively clean one is to add an intermediate function
size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) {
return strftime(s, max, fmt, tm);

}

Example

The program below can be used to experiment with strftime().
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
char outstr[200];
time_t t;
struct tm *tmp;
t = time(NULL);
tmp = localtime(&t);
if (tmp == NULL) {
perror("localtime");
exit(EXIT_FAILURE);
}
if (strftime(outstr, sizeof(outstr), argv[1], tmp) == 0) {
fprintf(stderr, "strftime returned 0");
exit(EXIT_FAILURE);
}
printf("Result string is \"%s\"\n", outstr);
exit(EXIT_SUCCESS);
} /* main */
Some examples of the result string produced by the glibc implementation of strftime() are as follows:
$ ./a.out "%m"
Result string is "11"
$ ./a.out "%5m"
Result string is "00011"
$ ./a.out "%_5m"
Result string is " 11"

See Also

date(1), time(2), ctime(3), setlocale(3), sprintf(3), strptime(3)