
2007年7月26日
摘要: 做為程序員,從感性角度講評一下7年里我使用過的9款機械鍵盤,確實更有特色,這種特殊的觸聽體驗非常美妙!
閱讀全文
posted @
2021-03-30 15:45 我愛佳娃 閱讀(399) |
評論 (0) |
編輯 收藏
搬了個家,想通過A410點播imac上下載的電影,通過系統自帶共享samba怎么都不成功。
想到是13年買的A410,應該升級一下,可官網都沒了,最后搜索到這個16年的最新固件:
https://drivers.softpedia.com/get/DVD-BluRay-Media-Players/Cloud-Media/Cloud-Media-Popcorn-Hour-A-410-Media-Player-Firmware-050816061625POP425802.shtml通過USB順利更新了一把。
再查看mac可以開nfs,方法如下:
sudo vi /etc/exports
加入:
/ -sec=sys
/Users /Users/popeye /Users/popeye/movies -ro -mapall=popeye:staff -alldirs
檢查配置:
sudo nfsd checkexports
重啟:
sudo nfsd restart
這里要注意movies目錄是我重新建立的755權限,不要用系統原來的目錄,不然總是訪問不了。
再到A410里網絡瀏覽里就能找到了。
posted @
2020-01-19 21:43 我愛佳娃 閱讀(704) |
評論 (0) |
編輯 收藏
http://mathias-kettner.de/checkmk_livestatus.html下載并解壓最新的包:
check_mk-1.2.1i3.tar.gz
再解壓其中的到livestatus目錄:
livestatus.tar.gz
進入:livestatus/src
再:make clean livestatus.o
會發現一堆錯誤,根據編譯NDO的選項:
ndoutils-1.4b7/src:
make clean ndomod-3x.o
gcc -fno-common -g -O2 -DHAVE_CONFIG_H -D BUILD_NAGIOS_3X -o ndomod-3x.o ndomod.c io.o utils.o -bundle -flat_namespace -undefined suppress -lz
在最后的編譯選項里添上:
-flat_namespace -undefined suppress -lz
就可以編譯出:
livestatus.o
--------------------------
livecheck編不過,報找不到n_short:
ip_icmp.h:92: error: expected specifier-qualifier-list before ‘n_short’
vi ./check_icmp.c
把這個調整到INCLUDE序列的最后即可:
#include "/usr/include/netinet/ip_icmp.h"
posted @
2012-12-21 07:00 我愛佳娃 閱讀(1557) |
評論 (0) |
編輯 收藏
摘要:
場景
想要用到的場景:用戶訪問WEB服務,WEB訪問非WEB服務1,服務1又再訪問2、3,合并計算后,把數據返回給WEB及前端用戶。想讓訪問鏈上的所有服務都能得到認證和鑒權,認為本次請求確實是來自用戶的。所以想到用CAS,讓用戶在一點登錄,所有服務都到此處認證和鑒權。
閱讀全文
posted @
2012-12-01 10:43 我愛佳娃 閱讀(9805) |
評論 (3) |
編輯 收藏
This tutorial will walk you through how to configure SSL (https://localhost:8443 access) on Tomcat in 5 minutes.

For this tutorial you will need:
- Java SDK (used version 6 for this tutorial)
- Tomcat (used version 7 for this tutorial)
The set up consists in 3 basic steps:
- Create a keystore file using Java
- Configure Tomcat to use the keystore
- Test it
- (Bonus ) Configure your app to work with SSL (access through https://localhost:8443/yourApp)
1 – Creating a Keystore file using Java
Fisrt, open the terminal on your computer and type:
Windows:
cd %JAVA_HOME%/bin
Linux or Mac OS:
cd $JAVA_HOME/bin
The $JAVA_HOME on Mac is located on “/System/Library/Frameworks/JavaVM.framework/Versions/{your java version}/Home/”
You will change the current directory to the directory Java is installed on your computer. Inside the Java Home directory, cd to the bin folder. Inside the bin folder there is a file named keytool. This guy is responsible for generating the keystore file for us.
Next, type on the terminal:
keytool -genkey -alias tomcat -keyalg RSA
When you type the command above, it will ask you some questions. First, it will ask you to create a password (My password is “password“):
loiane:bin loiane$ keytool -genkey -alias tomcat -keyalg RSA Enter keystore password: password Re-enter new password: password What is your first and last name? [Unknown]: Loiane Groner What is the name of your organizational unit? [Unknown]: home What is the name of your organization? [Unknown]: home What is the name of your City or Locality? [Unknown]: Sao Paulo What is the name of your State or Province? [Unknown]: SP What is the two-letter country code for this unit? [Unknown]: BR Is CN=Loiane Groner, OU=home, O=home, L=Sao Paulo, ST=SP, C=BR correct? [no]: yes Enter key password for (RETURN if same as keystore password): password Re-enter new password: password
It will create a .keystore file on your user home directory. On Windows, it will be on: C:\Documents and Settings\[username]; on Mac it will be on /Users/[username] and on Linux will be on /home/[username].
2 – Configuring Tomcat for using the keystore file – SSL config
Open your Tomcat installation directory and open the conf folder. Inside this folder, you will find the server.xml file. Open it.
Find the following declaration:
<!-- <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> -->
Uncomment it and modify it to look like the following:
Connector SSLEnabled="true" acceptCount="100" clientAuth="false" disableUploadTimeout="true" enableLookups="false" maxThreads="25" port="8443" keystoreFile="/Users/loiane/.keystore" keystorePass="password" protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https" secure="true" sslProtocol="TLS" />
Note we add the keystoreFile, keystorePass and changed the protocol declarations.
3 – Let’s test it!
Start tomcat service and try to access https://localhost:8443. You will see Tomcat’s local home page.
Note if you try to access the default 8080 port it will be working too: http://localhost:8080
4 – BONUS - Configuring your app to work with SSL (access through https://localhost:8443/yourApp)
To force your web application to work with SSL, you simply need to add the following code to your web.xml file (before web-app tag ends):
<security-constraint> <web-resource-collection> <web-resource-name>securedapp</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>
The url pattern is set to /* so any page/resource from your application is secure (it can be only accessed with https). The transport-guarantee tag is set to CONFIDENTIAL to make sure your app will work on SSL.
If you want to turn off the SSL, you don’t need to delete the code above from web.xml, simply changeCONFIDENTIAL to NONE.
Reference: http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html (this tutorial is a little confusing, that is why I decided to write another one my own).
Happy Coding!
posted @
2012-11-12 23:17 我愛佳娃 閱讀(3180) |
評論 (0) |
編輯 收藏
EXTJS和D3都很強大,不解釋了,把D3繪的圖直接放到一個EXT的TAB里,直接上圖上代碼:

代碼中的D3例子來自:
https://github.com/mbostock/d3/wiki/Force-Layout
可用于繪制拓撲結構圖.
Ext.define('EB.view.content.SingleView', {
extend : 'Ext.panel.Panel',
alias : 'widget.singleview',
layout : 'fit',
title : 'single view',
initComponent : function() {
this.callParent(arguments);
},
onRender : function() {
var me = this;
me.doc = Ext.getDoc();
me.callParent(arguments);
me.drawMap();
},
drawMap : function() {
var width = 960, height = 500
var target = d3.select("#" + this.id+"-body");
var svg = target.append("svg").attr("width", width).attr("height",
height);
var force = d3.layout.force().gravity(.05).distance(100).charge(-100)
.size([width, height]);
// get from: https://github.com/mbostock/d3/wiki/Force-Layout
// example: force-directed images and labels
d3.json("graph.json", function(json) {
force.nodes(json.nodes).links(json.links).start();
var link = svg.selectAll(".link").data(json.links).enter()
.append("line").attr("class", "link");
var node = svg.selectAll(".node").data(json.nodes).enter()
.append("g").attr("class", "node").call(force.drag);
node.append("image").attr("xlink:href",
"https://github.com/favicon.ico").attr("x", -8).attr("y",
-8).attr("width", 16).attr("height", 16);
node.append("text").attr("dx", 12).attr("dy", ".35em").text(
function(d) {
return d.name
});
force.on("tick", function() {
link.attr("x1", function(d) {
return d.source.x;
}).attr("y1", function(d) {
return d.source.y;
}).attr("x2", function(d) {
return d.target.x;
}).attr("y2", function(d) {
return d.target.y;
});
node.attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")";
});
});
});
}
});
posted @
2012-09-27 07:38 我愛佳娃 閱讀(4476) |
評論 (0) |
編輯 收藏
到這里下載最新PKG:
http://www.mysql.com/downloads/
下來后先裝:mysql-5.5.27-osx10.6-x86_64.pkg
它是裝到/usr/local/mysql,到此目錄運行下:
./scripts/mysql_install_db --user mysql
通過這個啟動:
./bin/mysqld_safe
排錯:
看下上面的LOG提示.
Can't find file: './mysql/host.frm' :一般是沒權限,把DATA目錄刪除,再用上面命令建一次
unknow option:把/etc/my.cnf刪除掉,里面有新版本不認識的上一版本遺留配置
說mysql.sock找不到,這個版本是在/tmp/目錄下哦!
再把剩下兩個包裝了,就可以通過配置面板啟動了:
MySQL.prefPane
MySQLStartupItem.pkg
下次升級可能要給下/usr/local/mysql/data目錄的權限
posted @
2012-08-05 16:43 我愛佳娃 閱讀(2641) |
評論 (0) |
編輯 收藏
摘要: 非常淺顯易懂的PERL編碼說明.
一目了然PERL編碼,注意是轉的
閱讀全文
posted @
2011-10-09 08:04 我愛佳娃 閱讀(3222) |
評論 (0) |
編輯 收藏
下面以MAC為例,如果是LINUX需要把DYLD發為LD
把下面代碼加到代碼開頭,它就可以自啟動了,不需要再EXPORT或者-I
BEGIN {
#需要加到LOADPATH的路徑
my $need = '/usr/local/nagios/pkg/ebase/';
push @INC, $need;
if ( $^O !~ /MSWin32/ ) {
my $ld = $ENV{DYLD_LIBRARY_PATH};
if ( !$ld ) {
$ENV{DYLD_LIBRARY_PATH} = $need;
}
elsif ( $ld !~ m#(^|:)\Q$need\E(:|$)# ) {
$ENV{DYLD_LIBRARY_PATH} .= ':' . $need;
}
else {
$need = "";
}
if ($need) {
exec 'env', $^X, $0, @ARGV;
}
}
}
@import url(http://www.tkk7.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
posted @
2011-10-03 21:37 我愛佳娃 閱讀(1766) |
評論 (0) |
編輯 收藏
限制用戶在自己目錄下載文件:
建立nagiosdnld
指向軟鏈接:/usr/local/nagios/dnld -> /Users/nagiosdnld/dnld
編輯/etc/sshd_config
Match User nagiosdnld
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
ChrootDirectory /Users/nagiosdnld
重啟下服務:
launchctl stop org.openbsd.ssh-agent
launchctl start org.openbsd.ssh-agent
@import url(http://www.tkk7.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
posted @
2011-10-03 03:15 我愛佳娃 閱讀(1809) |
評論 (0) |
編輯 收藏
摘要: iostat 輸出解析
1. /proc/partitions
對于kernel 2.4, iostat 的數據的主要來源是 /proc/partitions,而對于kernel 2.6, 數據主要來自/proc/diskstats或者/sys/block/[block-device-name]/stat。
先看看 /proc/partitions 中有些什么。
# cat /proc/partitions
major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq
閱讀全文
posted @
2011-09-17 11:37 我愛佳娃 閱讀(1646) |
評論 (0) |
編輯 收藏
@import url(http://www.tkk7.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://www.tkk7.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
編譯:
修改Makefile.PL:
$archname="universal64-macosx";
去除生成的makefile中所有-arch i386 -Werror
make all
最后把所有可執行文件拷到同一目錄,再用
export DYLD_LIBRARY_PATH=/tmp/test
即可直接運行:
eb:tmp$ ls ./test/
Sigar.bundle cpu_info.pl
Sigar.pm libsigar-universal64-macosx.dylib
eb:tmp popeyecai$ perl -I./test ./test/cpu_info.pl
2 total CPUs..
Vendor........Intel
Model.........Macmini4,1
Mhz...........2660
Cache size....3072
Vendor........Intel
Model.........Macmini4,1
Mhz...........2660
Cache size....3072
posted @
2011-09-10 10:45 我愛佳娃 閱讀(852) |
評論 (0) |
編輯 收藏
摘要: Stl 刪除元素注意事項 STL中的容器按存儲方式分為兩類,一類是按以數組形式存儲的容器(如:vector 、deque);另一類是以不連續的節點形式存儲的容器(如:list、set、map)。在使用erase方法來刪除元素時,需要注意一些問題。 在使用 list、set 或 m...
閱讀全文
posted @
2011-07-18 17:02 我愛佳娃 閱讀(1486) |
評論 (0) |
編輯 收藏
目的:
限制用戶在特定目錄(不能看到上級或者根目錄)
只能執行scp或者sftp拷貝特別目錄下的文件
不能SSH登陸,其它命令不能執行
機制:
SSH登陸成功后,scponly會接管SHELL,并CHROOT到特別目錄,讓用戶“以為”這個目錄就是根目錄
它只會響應SFTP和SCP命令
只影響配置SHELL為SCPONLY的用戶,其它用戶不受影響
MAC下安裝:
LINUX下安裝SCPONLY非常簡單,不多說,特說下MAC的
GOOGLE一下scponly,下載解壓后編譯安裝:
./configure --enable-chrooted-binary --enable-rsync-compat --enable-scp-compat --enable-sftp-logging-compat --with-sftp-server=/usr/libexec/sftp-server
make clean all
sudo make install
會安裝好:/usr/local/sbin/scponlyc
用workgroup manager建立下載用戶,比方說是dnld,并配置其login shell到上述路徑
因為CHROOT后執行的命令都以用戶目錄/Users/dnld做為根目錄,所以要把scponly用到的scp和sftp-server兩個可執行文件和信賴庫拷到其下。以ROOT用戶登錄,且CD至/Users/dnld,執行以下腳本就會把這件事做好:
perl ./printlib.pl /usr/bin/scp
perl ./printlib.pl /usr/libexec/sftp-server
我寫的腳本源碼,自動搜索信賴關系,并在當前目錄建立目錄結構:
#!/bin/perl
%result=();
$result{$ARGV[0]}=1;
sub addlib{
@a = `otool -L \"$_[0]\"`;
#print @a;
for $i (@a){
if ($i =~/\s*([a-z|A-Z|\.|0-9|\/|\+|\-]*)\s*/){
#print "$1\n";
$result{$1}=1;
}
}
}
$before = 1;
$after = 0;
while ($before != $after){
$before = scalar keys %result;
for $i (keys %result){
addlib($i);
}
$after = scalar keys %result;
print "before $before, after $after\n";
}
for $i (keys %result){
#print "$i\n";
if ($i =~ /(.*)\/([~\/]*)/){
system ("mkdir -p \.$1");
system ("cp $i \.$1/");
}
}
調試:
加大LOG級別:
cat 7 /usr/local/scponly/etc/scponly/debuglevel
從其它機器或者本機用dnld用戶來拷貝文件,看登陸LOG:
tail -f /var/log/*
dstruss類似strace來看進程在做什么
直接到SCPONLY里加LOG,這個最直接了。
posted @
2011-07-13 02:25 我愛佳娃 閱讀(787) |
評論 (0) |
編輯 收藏
brew install openssl安裝完SSL庫后,
Update the configure file for Mac OS X compatibility
- vim ./configure
- on line 6673 change the text to read
- if test -f “$dir/libssl.dylib”; then
這個是用BREW裝的SSL,貌似MAC下是64位的,這個還用不了:
./configure --enable-command-args --with-ssl-inc=/usr/local/Cellar/openssl/0.9.8r/include --with-ssl-lib=/usr/local/Cellar/openssl/0.9.8r/lib
只能用MAC自帶的成功了:
./configure --enable-command-args --with-ssl-inc=/Developer/SDKs/MacOSX10.6.sdk/usr/inclue/openssl --with-ssl-lib=/Developer/SDKs/MacOSX10.6.sdk/usr/lib
posted @
2011-06-03 21:29 我愛佳娃 閱讀(390) |
評論 (0) |
編輯 收藏
創建如下文件和內容:/etc/yum.repos.d/dag.repo
運行:yum install rrdtool
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
posted @
2011-02-03 21:38 我愛佳娃 閱讀(1615) |
評論 (2) |
編輯 收藏
要SSH和系統兩邊都配置對才行,其實也很簡單:
用命令:
dpkg-reconfigure locales
進去后只選擇zh_CN.UTF-8,并設置成默認字符集。
再到/root/.bashrc里加上:
export LC_ALL=zh_CN.UTF-8
SSH客戶端使用UTF-8字符集,如SECURECRT就在SESSION
OPTIONS->APPERANCE->CHARACTER ENCODING里選擇UTF-8
posted @
2010-05-08 09:58 我愛佳娃 閱讀(1463) |
評論 (0) |
編輯 收藏
一、設置YUM源
cd /etc/yum.repos.d/
wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
mv CentOS-Base.repo.5 CentOS-Base.repo
因為默認的配置文件中服務器地址用的版本號是變量$releasever,所以需要將其替換為實際的版本號,否則是無法連接到服務器的,當前CentOS
最新版是5.3,所以我們修改CentOS-Base.repo
vi CentOS-Base.repo
在vi編輯器中進行全文件替換
:%s/$releasever/5.3/
二、安裝
1:安裝apache
yum install httpd httpd-devel
2:安裝mysql
yum install mysql mysql-server mysql-devel
3:安裝php
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
4:啟動apache
測試php
建立以下文件/var/www/html/test.php
編輯其內容
// test.php
<?php
phpinfo();
?>
5:測試
在瀏覽器中輸入:http://IP/test.php
看是否顯示PHP的信息
6:設置開機啟動
chkconfig httpd on
posted @
2010-04-20 09:56 我愛佳娃 閱讀(2246) |
評論 (0) |
編輯 收藏
安裝SAMBA后,配置下面SHARE:
[popeye]
path = /
valid users = root
read only = no
public = yes
writable = yes
發現可以瀏覽目錄,但不可寫,查了下是SELINUX在作怪,把它禁用即可:
先實時停止它:
setenforce 0
改配置:
vi /etc/sysconfig/selinux
修改成:
SELINUX=disabled
posted @
2010-04-07 14:36 我愛佳娃 閱讀(2303) |
評論 (0) |
編輯 收藏
摘要: 經過一段時間知識積累后,你可能想在自己的網站建立一個WIKI。WIKI有專用的格式和標記,習慣了用M$的WORD,在它們之間轉換會相當痛苦。
這里介紹了從各種格式文檔向WIKI轉化的辦法:點這里。
閱讀全文
posted @
2010-03-27 12:15 我愛佳娃 閱讀(5211) |
評論 (2) |
編輯 收藏
摘要: 講了SED的用法,特別是換行c\命令,以及多行替換。
閱讀全文
posted @
2009-09-01 10:12 我愛佳娃 閱讀(3972) |
評論 (1) |
編輯 收藏
這里有個帖子論證HIBERNATE在批量插入時性能下降,以及一些解決方式。
其核心在于批量插入時,積攢一定量后就寫庫,并清除SESSION里的第一級緩存,以免后續插入操作受緩存查找而影響效率:
if ( j % batchNum2 == 0 ) {//執行物理批量插入
session.flush();
session.clear();
}
基于JPA的事務操作,SESSION不可見,此時,需要直接調用EntityManager的flush和clear。
但EntityManager也是被封裝入JpaDaoSupport,實際的EntityManager對象也不容易取得。
此時可以用其JpaTemplate成員的execute方法來實現這兩個操作:
getJpaTemplate().execute(new JpaCallback() {
public Object doInJpa(EntityManager em) throws PersistenceException {
em.flush();
em.clear();
return null;
}
}, true);
在我這里測試結果:
沒有定期調用以上方法時,插入50個記錄要2秒,并且隨著記錄增多,時間越來越長。
每插入50個調用以上方法后,插入50個記錄小于300毫秒,且不隨記錄個數線性增長。
posted @
2009-07-16 21:20 我愛佳娃 閱讀(6713) |
評論 (0) |
編輯 收藏
Linux 運行的時候,是如何管理共享庫(*.so)的?在 Linux 下面,共享庫的尋找和加載是由 /lib/ld.so 實現的。 ld.so 在標準路經(/lib, /usr/lib) 中尋找應用程序用到的共享庫。
但是,如果需要用到的共享庫在非標準路經,ld.so 怎么找到它呢?
目前,Linux 通用的做法是將非標準路經加入 /etc/ld.so.conf,然后運行 ldconfig 生成 /etc/ld.so.cache。 ld.so 加載共享庫的時候,會從 ld.so.cache 查找。
傳統上, Linux 的先輩 Unix 還有一個環境變量 -
LD_LIBRARY_PATH 來處理非標準路經的共享庫。ld.so 加載共享庫的時候,也會查找這個變量所設置的路經。但是,有不少聲音主張要避免使用
LD_LIBRARY_PATH 變量,尤其是作為全局變量。這些聲音是:
*
LD_LIBRARY_PATH is not the answer -
http://prefetch.net/articles/linkers.badldlibrary.html
* Why
LD_LIBRARY_PATH is bad -
http://xahlee.org/UnixResource_dir/_/ldpath.html
*
LD_LIBRARY_PATH - just say no -
http://blogs.sun.com/rie/date/20040710
解決這一問題的另一方法是在編譯的時候通過 -R<path> 選項指定 run-time path。
posted @
2009-06-11 09:52 我愛佳娃 閱讀(834) |
評論 (0) |
編輯 收藏
摘要: 今天搞了一天,JAVA調用一個PERL程序,得不得就退不出,千試萬試,LOG精細到逐行,知道在哪停住了,但打死不知道為什么。
后來吃個飯都放棄了,居然又找到答案,要沒看到它,那真以為里面有鬼了。
閱讀全文
posted @
2009-05-15 21:04 我愛佳娃 閱讀(14244) |
評論 (4) |
編輯 收藏
如需要,設置PROXY:
export http_proxy=http://127.0.0.1:3128
啟動,然后設置MIRROR,直接安裝:
perl -MCPAN -e shell
cpan> o conf urllist set http://www.perl87.cn/CPAN/
cpan> install JSON
posted @
2009-05-12 16:31 我愛佳娃 閱讀(1197) |
評論 (0) |
編輯 收藏
方法1:采用String的split,驗證代碼如下:
import java.util.Arrays;
public class TestSplit {
public static void main(String[] args) {
String orignString = new String("5,8,7,4,3,9,1");
String[] testString = orignString.split(",");
int[] test = { 0, 0, 0, 0, 0, 0, 0 };
//String to int
for (int i = 0; i < testString.length; i++) {
test[i] = Integer.parseInt(testString[i]);
}
//sort
Arrays.sort(test);
//asc sort
for (int j = 0; j < test.length; j++) {
System.out.println(test[j]);
}
System.out.println("next ");
// desc
for (int i = (test.length - 1); i >= 0; i--) {
System.out.println(test[i]);
}
}
}
方法2:采用StringTokenizer
import java.util.Arrays;
import java.util.StringTokenizer;
public class SplitStringTest {
public static void main(String[] args) {
String s = new String("5,8,7,4,3,9,1");
int length = s.length();
//split s with ","
StringTokenizer commaToker = new StringTokenizer(s, ",");
String[] result = new String[commaToker.countTokens()];
int k = 0;
while (commaToker.hasMoreTokens()) {
result[k] = commaToker.nextToken();
k++;
}
int[] a = new int[result.length];
for (int i = 0; i < result.length; i++) {
a[i] = Integer.parseInt(result[i]);
}
//sort
Arrays.sort(a);
//asc sort
for (int j = 0; j < result.length; j++) {
System.out.println(a[j]);
}
}
}
posted @
2009-04-24 13:07 我愛佳娃 閱讀(490) |
評論 (0) |
編輯 收藏
摘要: mysqldump 是采用SQL級別的備份機制,它將數據表導成 SQL 腳本文件,在不同的 MySQL 版本之間升級時相對比較合適,這也是最常用的備份方法。
閱讀全文
posted @
2009-03-29 17:02 我愛佳娃 閱讀(2526) |
評論 (0) |
編輯 收藏
摘要: 在EXT里如果定義類和擴展類
閱讀全文
posted @
2009-03-03 15:57 我愛佳娃 閱讀(1077) |
評論 (1) |
編輯 收藏
update user set password = password ('xxxx') where user = "root";
grant all privileges on *.* to root@'%' identified by 'xxxx';
其它參數的例子:
grant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by '123';
給來自10.163.225.87的用戶joe分配可對數據庫vtdc的employee表進行select,insert,update,delete,create,drop等操作的權限,并設定口令為123。
要重啟一次MYSQL才能使本地用戶密碼生效:
/usr/local/mysql/support-files/mysql.server restart
posted @
2009-02-12 14:31 我愛佳娃 閱讀(1656) |
評論 (0) |
編輯 收藏
由于EXTJS是用XMLHTTP來LOAD的,所以在本地會看到一直LOADING的畫面。應該把它放到一個WEB服務器上,以HTTPD為例:
編輯文件:
/etc/httpd/conf.d/extjs.conf
內容如下:
Alias /extjs "/point/to/real/dir/ext/"
<Directory "/point/to/real/dir/ext/">
Options Indexes
AllowOverride AuthConfig Options
Order allow,deny
Allow from all
</Directory>
重啟httpd:
service httpd restart
這樣訪問http://hostip/extjs/docs/index.html就能在本地看EXTJS的文檔了。
注,經下面同學回復,有不用架設服務器的辦法,我搜了一下,供大家參考,本人未嘗試:
http://www.tkk7.com/mengyuan760/archive/2008/04/21/194510.html
posted @
2009-02-05 11:52 我愛佳娃 閱讀(2446) |
評論 (2) |
編輯 收藏
繼這篇動物機搭建起來后:
自己DIY了一個低功耗基于ADSL的JAVA J2EE服務器
又有新功能加入:
摘要: 以前家里動物機長開著只是下載電影,公司封了淘寶和MSN,現在又可以用它從公司上網了。
可以使用如下模式上網:
APP <=> HTTP TUNNEL <=> SERVER
HTTP TUNNEL有一個客戶端,它可以起一個SOCKS本地代理來接收APP數據,然后打包發送到運行在家里的HTTP TUNNEL服務端,由這個服務端程序通過ADSL出到公網即可。
閱讀全文
posted @
2008-12-03 17:55 我愛佳娃 閱讀(1823) |
評論 (0) |
編輯 收藏
摘要: 摘要:
本文從介紹基礎概念入手,探討了在C/C++中對日期和時間操作所用到的數據結構和函數,并對計時、時間的獲取、時間的計算和顯示格式等方面進行了闡述。本文還通過大量的實例向你展示了time.h頭文件中聲明的各種函數和數據結構的詳細使用方法。
關鍵字:UTC(世界標準時間),Calendar Time(日歷時間),epoch(時間點),clock tick(時鐘計時單元)
閱讀全文
posted @
2008-11-28 09:57 我愛佳娃 閱讀(15636) |
評論 (0) |
編輯 收藏
摘要: 當ManyToMany或者ManyToOne定義時,JoinTable中referencedColumnName指向的是非主鍵(non PK columns),將 報ClassCastException。這里有個簡單解決辦法。
閱讀全文
posted @
2008-10-27 17:30 我愛佳娃 閱讀(4017) |
評論 (1) |
編輯 收藏
摘要: RRD插入值的計算方式
閱讀全文
posted @
2008-09-17 21:15 我愛佳娃 閱讀(766) |
評論 (0) |
編輯 收藏
摘要: linux通過ntlm上網/vmware的image管理/yum更新系統
閱讀全文
posted @
2008-09-08 09:57 我愛佳娃 閱讀(1601) |
評論 (0) |
編輯 收藏
Ways to include code/library from another file (eval, do, require
and use)
1) do $file is like eval `cat $file`, except the former:
1.1: searches @INC.
1.2: bequeaths an *unrelated* lexical scope on the eval'ed code.
2) require $file is like do $file, except the former:
2.1: checks for redundant loading, slipping already loaded files.
2.2: raises an exception on failure to find, compile, or execute $file.
3) require Module is like require "Module.pm", except the former:
3.1: translates each "::" into your system's directory separator.
3.2: primes the parser to disambiguate class Module as an indirect object.
4) use Module is like require Module, except the former:
4.1: loads the module at compile time, not run-time.
4.2: imports symbols and semantics from that package to the current one.
eval除了可以形成動態CODE外,還可以做異常捕捉:
eval {
...
};
if ($@) {
errorHandler($@);
}
$@在無異常時是NULL,否則是異常原因
posted @
2008-08-12 10:42 我愛佳娃 閱讀(446) |
評論 (0) |
編輯 收藏
摘要: PERL開源打包程序PAR和PP(類似于商業程序的perl2exe/perlapp)
閱讀全文
posted @
2008-08-11 21:13 我愛佳娃 閱讀(599) |
評論 (0) |
編輯 收藏
摘要: 在多至上萬臺主機的系統中,集中定義配置,然后自動應用到所有主機。
閱讀全文
posted @
2008-07-28 11:12 我愛佳娃 閱讀(562) |
評論 (0) |
編輯 收藏
如下圖所示位置設置不掃描迅雷網絡通信即可:

posted @
2008-06-28 08:11 我愛佳娃 閱讀(3048) |
評論 (6) |
編輯 收藏
摘要: 相信很多人都有過這樣的經驗,改一個東西可能就幾分鐘,但找到在哪改、會影響到什么地方,卻要花半小時。有了這個工具,讓我們在非常大的項目里,在文件和代碼的海洋里能馬上找到所要關注的部分。有的人說,我有CTRL+SHIFT+T,可是你能記住幾年前一個項目里的類名嗎?而查閱文字描述的任務卻要容易得多。
Mylyn的項目領隊這樣說道:這個新名字是向“髓磷脂”物質致敬,該物質通過使神經元更有效的傳導電流來促進你的思考。我們已經聽到使用者聲稱,Mylyn工具將他們的效率提高到了他們覺得正在以思考的速度編碼的地步。減少阻礙我們生產力的UI摩擦就是Mylyn項目全部的內容。
此文是我之Mylyn初體驗,不搞大而全,而只把我覺得這個工具最爽、最KILLER的功能介紹出來。
閱讀全文
posted @
2008-06-15 13:02 我愛佳娃 閱讀(45464) |
評論 (7) |
編輯 收藏
摘要: # Select location bar: Ctrl/Cmd+L or Alt+D
# Select search bar: Ctrl/Cmd+K
閱讀全文
posted @
2008-06-02 12:56 我愛佳娃 閱讀(1979) |
評論 (0) |
編輯 收藏
摘要: ECLIPSE的快捷鍵非常多,如果只挑3個,我就選擇它們:
1
Alt + /
自動完成
2
Ctrl + O
Quick Outline:函數列表,可以定制這個窗口
3
Ctrl+K (加SHIFT是向上)
向下查找選中的字符串
閱讀全文
posted @
2008-06-01 16:31 我愛佳娃 閱讀(1476) |
評論 (0) |
編輯 收藏
摘要: FF是深受廣大程序員喜愛,不是因為它的快,而是因為FIREBUG1.2版本(點這里)這個宇宙無敵插件,調試JS程序變成了一片小蛋糕。
最后,要說一下FF的幾個小技巧
閱讀全文
posted @
2008-05-30 13:43 我愛佳娃 閱讀(3873) |
評論 (2) |
編輯 收藏
摘要: ASSERT是在調試與測試環境,讓程序員和測試者及時發現運行時錯誤的極簡極佳之方法。
它的語法因為簡單所以美麗。
有的文章攻擊ASSERT(點這里),是混淆了其使用目的的結果。
閱讀全文
posted @
2008-05-30 11:54 我愛佳娃 閱讀(2082) |
評論 (3) |
編輯 收藏
命令行:
C:\Program Files\Rational\ClearCase\bin>clearfsimport -recurse -nsetevent d:\temp\cli D:\prj\pcrf\PCFFACN\web\
SNAPVIEW時,要把需加入的文件放到一臨時目錄,不能直接在SNAPVIEW對應的目錄加入。
另外,要把需要加入的目錄先行加入到CC,如上面的cli目錄
posted @
2008-05-26 18:10 我愛佳娃 閱讀(555) |
評論 (0) |
編輯 收藏
摘要: 回調函數是相當有用,它的意義不僅可以讓調用者控制調用函數的執行,還可以有效的將“算法”與“數據”分離,將涉及數據的部分放入回調接口(inner class)中,算法就會相對獨立。下面是一個示例。
閱讀全文
posted @
2008-05-16 19:19 我愛佳娃 閱讀(2644) |
評論 (3) |
編輯 收藏
摘要: 平時編程中經常遇到將多項內容放入字串,然后再一一解析出來的情況,常常是這樣的字串操作不勝其煩。
我們可以使用JSON這一標準格式來組織內容到字符串,然后現成的類庫來進行解析,準確而清晰。
閱讀全文
posted @
2008-05-10 12:15 我愛佳娃 閱讀(7110) |
評論 (4) |
編輯 收藏
摘要: 描述在WEB瀏覽器端的代碼架構,主要講得是有哪些功能點,JS代碼結構如何劃分。
閱讀全文
posted @
2008-03-09 16:52 我愛佳娃 閱讀(1609) |
評論 (0) |
編輯 收藏
摘要: 當我們寫好SERVICE層的MANAGER方法后,就已經完成業務邏輯,可以用DWR從BROWSER直接調用,不必要再寫一個“緩沖層”,這樣的好處是避免了今后對SERVICE層的多處同時改動。
閱讀全文
posted @
2008-03-03 20:59 我愛佳娃 閱讀(4774) |
評論 (1) |
編輯 收藏
摘要: 有時候,在SPRING中兩個類互相含有對方的聲明,一般情況這是不允許并且極可能是有錯誤的。
但有時候這正是我們想要的,考慮這種情況:
閱讀全文
posted @
2008-02-24 10:13 我愛佳娃 閱讀(38415) |
評論 (11) |
編輯 收藏
摘要: ACTIVEPERL在LINUX下的安裝以及PERL2EXE的使用
閱讀全文
posted @
2008-02-20 12:40 我愛佳娃 閱讀(3127) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2008-02-03 15:06 我愛佳娃 閱讀(531) |
評論 (0) |
編輯 收藏
摘要: JPA標準+HIBERNATE實現+SPINRG揉和
搭建MAVEN2的內網服務器:設置一個目錄在WEB服務上可以訪問
MYSQL可以被外部機器連接
cannot connect to VM錯誤
閱讀全文
posted @
2008-01-28 23:08 我愛佳娃 閱讀(6417) |
評論 (1) |
編輯 收藏
摘要: “編程的核心是數據結構,而不是算法”,“編程的本質是控制復雜度”,“過早的優化是萬惡之源”,“寧花機器一分,不花程序員一秒”。這些UNIX的設計哲學,非常值得體味。
閱讀全文
posted @
2007-12-05 17:52 我愛佳娃 閱讀(3996) |
評論 (12) |
編輯 收藏
摘要: 用PERL編寫SOAP服務是相當方便的,但是如果用其它語言來訪問它,卻不容易,下面介紹一種不需要WSDL描述就能訪問它的方法。
閱讀全文
posted @
2007-12-05 12:00 我愛佳娃 閱讀(3096) |
評論 (0) |
編輯 收藏
摘要: 設計不在乎一開始就非常完備,并且考慮到所有情況和變化;設計的精髓在于當某種變化來臨時,能夠重新審視,甚至是調整全部的設計,讓它能夠兼容之后的“同種類”變化,從而使今后再有這樣的變化時,帶來最少量改動。為此目的,哪怕是推翻重來也在所不惜......
閱讀全文
posted @
2007-12-02 17:35 我愛佳娃 閱讀(2239) |
評論 (9) |
編輯 收藏
摘要: 事情開始想的簡單,可開始做發現沒那么容易。本文描述配置LINGO+SPRING+ACTIVEMQ的曲折過程,希望看過的人不要再犯相同錯誤。
閱讀全文
posted @
2007-11-24 15:29 我愛佳娃 閱讀(4037) |
評論 (0) |
編輯 收藏
摘要: 目前網絡上大多是PHP或者ASP的空間,如果自己想搭建一個基于JAVA的WEB服務器或者自己調試J2EE的服務都不方便。另一方面,大家現在基本上家里都是包月的ADSL,它的上行帶寬有512K,足夠搭建一個自己WEB服務器了。不妨參考下我最近DIY的一臺功耗不足40W的動物機:BT,電驢,路由器,防火墻,WEB服務器,SUBVERSION代碼服務器,APACHE,MYSQL一個都不少!全部配下來RMB1100。
閱讀全文
posted @
2007-11-19 21:47 我愛佳娃 閱讀(4203) |
評論 (8) |
編輯 收藏
(轉)
設我們有一臺計算機,有兩塊網卡,eth0連外網,ip為1.2.3.4;eth1連內網,ip為192.168.0.1.現在需要把發往地址1.2.3.4的81端口的ip包轉發到ip地址192.168.0.2的8180端口,設置如下:
1. iptables -t nat -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 81 -j DNAT --to-destination192.168.0.2:8180
2. iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -d 192.168.0.2 -p tcp -m tcp --dport 8180 -j SNAT --to-source 192.168.0.1
真實的傳輸過程如下所示:
假設某客戶機的ip地址為6.7.8.9,它使用本機的1080端口連接1.2.3.4的81端口,發出的ip包源地址為6.7.8.9,源端口為1080,目的地址為1.2.3.4,目的端口為81.
主機1.2.3.4接收到這個包后,根據nat表的第一條規則,將該ip包的目的地址更該為192.168.0.2,目的端口更該為8180,同時在連接跟蹤表中創建一個條目,(可從/proc/net/ip_conntrack文件中看到),然后發送到路由模塊,通過查路由表,確定該ip包應發送到eth1接口.在向eth1接口發送該ip包之前,根據nat表的第二條規則,如果該ip包來自同一子網,則將該ip包的源地址更該為192.168.0.1,同時更新該連接跟蹤表中的相應條目,然后送到eth1接口發出.
此時連接跟蹤表中有一項:
連接進入: src=6.7.8.9 dst=1.2.3.4 sport=1080 dport=81
連接返回: src=192.168.0.2 dst=6.7.8.9 sport=8180 dport=1080
是否使用: use=1
而從192.168.0.2發回的ip包,源端口為8180,目的地址為6.7.8.9,目的端口為1080,主機1.2.3.4的TCP/IP棧接收到該ip包后,由核心查找連接跟蹤表中的連接返回欄目中是否有同樣源和目的地址和端口的匹配項,找到后,根據條目中的記錄將ip包的源地址由192.168.0.2更該為1.2.3.4, 源端口由8180更該為81,保持目的端口號1080不變.這樣服務器的返回包就可以正確的返回發起連接的客戶機,通訊就這樣開始.
還有一點, 在filter表中還應該允許從eth0連接192.168.0.2地址的8180端口:
iptables -A INPUT -d 192.168.0.2 -p tcp -m tcp --dport 8180 -i eth0 -j ACCEPT
posted @
2007-11-18 18:54 我愛佳娃 閱讀(7449) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2007-11-18 12:20 我愛佳娃 閱讀(1205) |
評論 (0) |
編輯 收藏
摘要:
閱讀全文
posted @
2007-11-18 12:19 我愛佳娃 閱讀(2939) |
評論 (1) |
編輯 收藏
udev是devfs的替代品,可以動態管理/dev下的設備,主要作用是根據硬件的信息(match條件),將它建立到分配(assign語句)到/dev相應的名字下。
這篇文章相當不錯,易懂:
http://www.reactivated.net/writing_udev_rules.html
posted @
2007-11-14 14:45 我愛佳娃 閱讀(914) |
評論 (0) |
編輯 收藏
摘要: 網上材料大多比較復雜,本文是簡潔明了的快餐式文章。分安裝部分和使用部分。
安裝部分對SUBVERSION做為SSL訪問方式配置做了詳細說明,使用部分對實際使用時最常用的模式做了說明。
閱讀全文
posted @
2007-11-13 13:04 我愛佳娃 閱讀(1879) |
評論 (0) |
編輯 收藏
<bean id="nodeSvcImpl" class="com.exchangebit.nms.magic.NodeSvcImpl">
<property name="notifyClient" ref="notifyClient"/>
</bean>
<jaxws:endpoint
id="nodeSvc"
implementor="#nodeSvcImpl"
address="/NodeSvc">
</jaxws:endpoint>
posted @
2007-11-01 17:38 我愛佳娃 閱讀(4994) |
評論 (0) |
編輯 收藏
摘要: Reverse Ajax主要是在BS架構中,從服務器端向多個瀏覽器主動推數據的一種技術。應用范圍廣泛。
本文就DWR使用中,代碼組織、聲明做了說明。并解決了在非DWR線程中,WebContextFactory.get()返回空的問題。
閱讀全文
posted @
2007-11-01 17:35 我愛佳娃 閱讀(5226) |
評論 (3) |
編輯 收藏
今天在WINDOWS下用SOCKET時發現如下錯誤:(LINUX下正常)
Your vendor has not defined Fcntl macro F_GETFL, used at :/Perl/site/lib/IO/Multiplex.pm line 932.
只需要替換Multiplex.pm line 932處函數nonblock:
sub nonblock
{
my $fh = shift;
my $flags = fcntl($fh, F_GETFL, 0)
or die "fcntl F_GETFL: $!\n"
fcntl($fh, F_SETFL, $flags | O_NONBLOCK)
or die "fcntl F_SETFL $!\n"
}
替換為:
use constant WIN32 => $^O =~ /win32/i;
sub nonblock {
my $sock = shift;
if (WIN32) {
my $set_it = "1"
ioctl( $sock, 0x80000000 | (4 << 16) | (ord('f') << 8) | 126, $set_it) || return 0;
} else {
fcntl($sock, F_SETFL, fcntl($sock, F_GETFL, 0) | O_NONBLOCK) || return 0;
}
}
即可。
posted @
2007-10-31 20:40 我愛佳娃 閱讀(1185) |
評論 (0) |
編輯 收藏
摘要: SOAP中不支持HashMap,但可以通過定義XmlAdapter適配器將數組轉換成HashMap的方式來支持。本文通過完整例子來說明。
有了轉換器這個工具,我們可以在SOAP的JAXB綁定里支持各種JAVA的COLLECTION類型,以及自定義類型,打破了SOAP原始支持類型的限制。
閱讀全文
posted @
2007-10-29 16:41 我愛佳娃 閱讀(7226) |
評論 (5) |
編輯 收藏
我一個JSP頁面,在IE6下死活分隔條沒有響應,在FF下沒問題,左找右找,才發現是開頭的一句:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ">
把我害慘了!
posted @
2007-10-26 22:16 我愛佳娃 閱讀(891) |
評論 (0) |
編輯 收藏
在Eclipse的Software Updates/Find and Install…中點New Remote Site…填入:
http://download.macromedia.com/pub/labs/jseclipse/autoinstall/
安裝JSEclipse完成后。
如果你用EXT庫的話,再把完整的庫,點這里
拷貝到這里,注意user_library需要自己創建,另外,是不要帶解壓目錄,而是所有的XML文件直接拷入:
E:\myeclipse\workspace\.metadata\.plugins\com.interaktonline.jseclipse\user_library
posted @
2007-09-13 21:14 我愛佳娃 閱讀(11339) |
評論 (6) |
編輯 收藏
摘要: 之前文章提到過用MAVEN2啟動JETTY,這里介紹一種直接從ECLIPSE中啟動的辦法。
適用于6.1.3以上,包括6.1.5的JETTY。
它主要是利用了JDK的代碼自動更換性能(code hot replace),可以不用重啟JETTY就調試、更換資源文件。注意:一定是DEBUG方式運行才有這項功能。
所以應該說這篇文章的方法更好:
在Run->Debug中,N...
閱讀全文
posted @
2007-09-13 21:04 我愛佳娃 閱讀(19656) |
評論 (8) |
編輯 收藏
摘要: 本文說明了 Linux 系統的配置文件,在多用戶、多任務環境中,配置文件控制用戶權限、系統應用程序、守護進程、服務和其它管理任務。這些任務包括管理用戶帳號、分配磁盤配額、管理電子郵件和新聞組,以及配置內核參數。本文還根據配置文件的使用和其所影響的服務的情況對目前 Red Hat Linux 系統中的配置文件進行了分類。
閱讀全文
posted @
2007-09-10 18:24 我愛佳娃 閱讀(441) |
評論 (0) |
編輯 收藏

posted @
2007-09-10 17:54 我愛佳娃 閱讀(509) |
評論 (0) |
編輯 收藏
今天被SWFObject困擾一天,發現:
- SWFObject通過本地HTML用不成功,必須通過WEB在線方式取。
- 直接用ADOBE的OBJECT標簽都可以。但是如果一旦加入EXT-YUI的使用,在IE下不行,FF可以。所以還是用SWFObject穩妥些。
- 就算是在線取,如果在嵌套IE的瀏覽工具里(如TT)也會不成功,FF沒有問題。
- 用SWFObject時還要注意,如果要訪問FLASH的函數,輸出完FLASH后,并不能馬上取得指針使用,而要在其它函數中使用,比如:通過某個按鈕事件激發。
也就是,把這部分放在初始化中:
var so = new SWFObject(format_path ("swf/hehe.swf"), "mytopo", "800", "600", "8", "#FFFFFFFF");
so.write("flashcontent");
this._topo = thisMovie("mytopo");
使用的語句放在另一處:
_topo.setBK(format_path ("images/pic3.jpg"));
歸根結底,FLASH函數調用的調試,目前實驗成功的:一是要用SWF,二是要在線調試。
posted @
2007-09-08 22:02 我愛佳娃 閱讀(890) |
評論 (0) |
編輯 收藏
在
上一篇文章中的問題,今天又再試了下,居然解決了,看來把遇到問題放一放是有好處的。
第一,是要用對CXF的庫,在一行代碼未變的情況下,只要使用最新的庫。看來在最新庫里解決了數組問題:
2.1-incubator-SNAPSHOT
就沒問題,如果是用:
2.0-incubator
就會出現上篇文章的情況。我使用MAVEN2,就寫成:
<!--for cxf-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.1-incubator-SNAPSHOT</version>
<!-- version>2.0-incubator</version-->
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.1-incubator-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-aegis</artifactId>
<version>2.1-incubator-SNAPSHOT</version>
</dependency>
第二,對SOAP::Lite的改變,SOAP::Lite不支持doc/literal,但通過閱讀
"NET-based Web Service Using the SOAP::Lite Perl Library".
我的上篇文章有鏈接,我寫的PERL程序在某些情況下依然不行。
這次再加了兩處改動后就可以了:(注意:CXF里不要使用aegisDatabinding,用默認的即可)
my $soap = SOAP::Lite
-> uri('http://magic.nms.exchangebit.com/')
-> on_action( sub{ join '/', 'http://www.alfredbr.com', $_[1] })
-> proxy('http://127.0.0.1:8080/ebnms/NotifyService')
->autotype(0);
其中的autotype(0)非常重要。另外一處改動是,程序中的根變量名改成"arg0",即與WSDL中定義一致。
實驗發現,帶不帶attr中的xmlns都可以。完整代碼如下:
use SOAP::Lite ( +trace => all, maptype => {} );

my $soap = SOAP::Lite
-> uri('http://magic.nms.exchangebit.com/')
-> on_action( sub{ join '/', 'http://www.alfredbr.com', $_[1] })
-> proxy('http://127.0.0.1:8080/ebnms/NotifyService')
->autotype(0);

#$soap->sendAlarmString ("good");

#$soap->sendAlarm (SOAP::Data->name(arg0=>{devName=>"hehe", devIp=>"ip1"}));

{# call send alarm
my @params = (
# $header,
SOAP::Data->name(arg0 => goodhehe)
);
my $method = SOAP::Data->name('ns1:sendAlarmString')
->attr({"xmlns:ns1" => 'http://magic.nms.exchangebit.com/'});
my $result = $soap->call($method => @params);
print "\nsend string alarm result:\n";
if ($result->fault)
{
print $result->faultstring;
}
else
{
print $result->result;
}
print "\nn";
}

{# call send dev alarm
my @params = (SOAP::Data->name(arg0=>{devName=>"hehe", devIp=>"ip1"}));
my $method = SOAP::Data->name('sendAlarm');
# ->attr({"xmlns:ns1" => 'http://magic.nms.exchangebit.com/'});
my $result = $soap->call($method => @params);
print "\nsend string alarm result:\n";
if ($result->fault)
{
print $result->faultstring;
}
else
{
print $result->result;
}
print "\n\n";
}

{# call send arr alarm
my @params = (
SOAP::Data->name(arg0 => [
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe1", devIp=>"ip1"},
{devName=>"hehe2", devIp=>"ip2"}])
);
my $method = SOAP::Data->name('sendAlarmArr');
my $result = $soap->call($method => @params);
print "\nsend string alarm result:\n";
if ($result->fault)
{
print $result->faultstring;
}
else
{
my @a = @{$result->result->{item}};
foreach $i (@a) {
print "ele: $i->{devName}, $i->{devIp}\n";
}
}
print "\n\n";
}
posted @
2007-08-23 14:13 我愛佳娃 閱讀(1437) |
評論 (1) |
編輯 收藏
摘要: 最近需要一個能根據請求數變化的線程池,JAVA有這樣的東西,可是C++下好像一般只是固定大小的線程池。所以就基于ACE寫了個,只做了初步測試。
主要思想是:1. 重載ACE_Task,這相當于是個固定線程池,用一個信號量(ACE_Thread_Semaphore)來記數空閑線程數。2. 初始化時根據用戶的輸入,確定最少線程數minnum和最大線程數maxnum,當多個請求到來,并且無空閑線程(信...
閱讀全文
posted @
2007-08-14 17:56 我愛佳娃 閱讀(6082) |
評論 (4) |
編輯 收藏
編譯指南:
http://support.hyperic.com/confluence/display/DOCSHQ30/Build+Instructions
直接按照這個走,設置一些變量:
JBOSS_HOME=C:\Program Files\server-3.1.0\hq-engine
JAVA_HOME = %SDKS_HOME%\jdk1.5.0_04
JAVA_OPTS = "-ea"
ANT_HOME = %TOOLS_HOME%\apache-ant-1.6.5
ANT_OPTS = -Xmx256M -XX:MaxPermSize=128m
發現SERVER起不來,后來不用自己下載的JBOSS,而是直接下載個可以直接解壓的HQ安裝包,然后把JBOSS_HOME改到安裝目錄(如上)。然后再運行ant deploy就安過去了。
AGENT沒有發現問題,編譯出來的直接運行就好了,在build/agent目錄下。
posted @
2007-08-12 15:59 我愛佳娃 閱讀(493) |
評論 (0) |
編輯 收藏
摘要: 最近因為用HYPERIC產品,裝了一下Postgres數據庫,下面簡說下在WINDOWS下安裝的情況。
下載那個直接解壓版,解壓
在"$PG"目錄下創建一個rootpass.txt文件,內容為數據庫的超級用戶密碼??梢蕴顐€“p”,方便后面登陸。準備工作到此結束,下面的步驟以管理員身份執行。
移動DLL文件[8.1.5及以上版本不需要這一步驟]:
cd...
閱讀全文
posted @
2007-08-12 15:56 我愛佳娃 閱讀(5771) |
評論 (0) |
編輯 收藏
最近想用PERL通過SOAP與JAVA通信,想到了XFIRE,現在叫CXF提供的服務。但總是差一點成功。
第一步,
由于用了SPRING,所以最先看了這篇文章:
Writing a service with Spring 服務是建成功了,PERL和JAVA是可以正常通信了,詳見
上篇文章可是CXF自己的CLIENT生成代碼卻訪問“自定義結構數組”的函數不成功:
public List<DeviceValue> sendAlarmArr (List<DeviceValue> arr);
第二步,
左試右試不成功,甚至去試了Axis2,但那個生成的WSDL把上面的結構變成AnyType,估計不對。
又回來,看了
Aegis綁定,我還找到將它用到SPRING里的方法:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<bean id="serviceClass" class="com.exchangebit.nms.magic.NotifyServiceImpl"/>
<bean id="aegisDatabinding" class="org.apache.cxf.aegis.databinding.AegisDatabinding"/>
<bean id="serviceFactory" class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="dataBinding" ref="aegisDatabinding"/>
</bean>
<bean id="serverBeanFactory" class="org.apache.cxf.frontend.ServerFactoryBean" init-method="create">
<property name="address" value="/NotifyService"/>
<property name="bindingId" value="http://schemas.xmlsoap.org/soap/"/>
<property name="serviceBean" ref="serviceClass"/>
<property name="serviceFactory" ref="serviceFactory"/>
</bean>

<jaxws:endpoint
id="notifyService"
implementor="com.exchangebit.nms.magic.NotifyServiceImpl"
address="/NotifyService">
<!--jaxws:serviceFactory>
<ref bean="serviceFactory"/>
</jaxws:serviceFactory-->
</jaxws:endpoint>
</beans>


其實,跟前一種JAX-WS的方式轉換非常簡單,把其中的注釋去掉就是Aegis綁定,注釋掉就是JAX-WS。
客戶端沒有在SPRING里試成功,但寫代碼也相當簡單,Aegis真好:
getBean ("notifyClient");
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(NotifyService.class);
factory.setAddress("http://127.0.0.1:8080/ebnms/NotifyService");
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
NotifyService client = (NotifyService) factory.create();
DoTest (client);
這次,到是CXF的SERVER和CLIENT都可以正常通信了。但我不說也知道啦,PERL又出問題了!
第三步,
又進一步搜,才知道Document, Literal, RPC, Encoding對SOAP消息的影響,
這篇文章(
中文的)相當好!
大義是RPC/Encoding將方法名稱放入了operation節中,并且消息里含有類型信息,不方便檢驗。
而Document/Literal通過增加WSDL復雜度,將方法名、參數類型全部放入了types一節,方便了處理。
而SOAP::Lite只支持RPC/Encoding的方式,但也有辦法讓它形成Doc/Lit的消息:
點這里。
但,這種方法只支持JAX-WS的服務,Aegis的PERL就會出錯了。
所以,不管用哪種要么JAVA的CLIENT和SERVER通信有問題,不然就是把PERL拒之門外。我懷疑是不是CXF的JAX-WS的數組處理有問題,不然Aegis為何不出錯?另外,Aegis對PERL的消息不夠寬容,本已是Doc/Lit格式,只是帶有TYPE信息也會出錯。
不知如何解,先記在此,以后回過頭來再研究了。
posted @
2007-08-07 21:39 我愛佳娃 閱讀(2920) |
評論 (1) |
編輯 收藏
摘要: SOAP::Lite的Lite是說其好用,其實它的實現并不“輕量”,功能也非常強大,所以我們要用好它。
在調用服務時,有時遇到有復雜結構或者數組時,還是有點小麻煩,下面以調用以下三個函數為例分別寫出SOAP::Lite如何組合它們的參數,其它情況也應該能迎刃而解。
public class DeviceValue {
&nbs...
閱讀全文
posted @
2007-08-03 22:37 我愛佳娃 閱讀(2878) |
評論 (0) |
編輯 收藏
一般bat只能運行一個程序,有時需要在電腦啟動或者自己有多個程序要啟動時,編輯一個bat實現一組程序的啟動。可以使用start語句。
它不支持帶空格的目錄名,可以先CD到程序目錄,再start,舉例如下:
cd "C:\Program Files\Tor\"
start tor.exe
cd "C:\Program Files\Privoxy\"
start privoxy.exe
cd "C:\Program Files\Mozilla Firefox\"
start firefox.exe
posted @
2007-07-29 10:36 我愛佳娃 閱讀(4541) |
評論 (0) |
編輯 收藏
以下文字摘自:JOIN, JOIN2, HQL, Fetch
Join用法:
主要有Inner Join 及 Outer Join:
最常用的(默認是Inner):
Select <要選擇的字段> From <主要資料表>
<Join 方式> <次要資料表> [On <Join 規則>]
Inner Join 的主要精神就是 exclusive , 叫它做排他性吧! 就是講 Join 規則不相符的資料就會被排除掉, 譬如講在 Product 中有一項產品的供貨商代碼 (SupplierId), 沒有出現在 Suppliers 資料表中, 那么這筆記錄便會被排除掉
Outer Join:
Select <要查詢的字段> From <Left 資料表>
<Left | Right> [Outer] Join <Right 資料表> On <Join 規則>
語法中的 Outer 是可以省略的, 例如你可以用 Left Join 或是 Right Join, 在本質上, Outer Join 是 inclusive, 叫它做包容性吧! 不同于 Inner Join 的排他性, 因此在 Left Outer Join 的查詢結果會包含所有 Left 資料表的資料, 顛倒過來講, Right Outer Join 的查詢就會包含所有 Right 資料表的資料
另外,還有全外聯:
FULL JOIN 或 FULL OUTER JOIN
完整外部聯接返回左表和右表中的所有行。當某行在另一個表中沒有匹配行時,則另一個表的選擇列表列包含空值。如果表之間有匹配行,則整個結果集行包含基表的數據值。
以及,
交叉聯接
交叉聯接返回左表中的所有行,左表中的每一行與右表中的所有行組合。交叉聯接也稱作笛卡爾積。
沒有 WHERE 子句的交叉聯接將產生聯接所涉及的表的笛卡爾積。第一個表的行數乘以第二個表的行數等于笛卡爾積結果集的大小。也就是說在沒有 WHERE 子句的情況下,若表 A 有 3 行記錄,表 B 有 6 行記錄 : :
SELECT A.*,B.* FROM 表A CROSS JOIN 表B
那以上語句會返回 18 行記錄。
Fetch:
在我們查詢Parent對象的時候,默認只有Parent的內容,并不包含childs的信息,如果在Parent.hbm.xml里設置lazy="false"的話才同時取出關聯的所有childs內容.
問題是我既想要hibernate默認的性能又想要臨時的靈活性該怎么辦? 這就是fetch的功能。我們可以把fetch與lazy="true"的關系類比為事務當中的編程式事務與聲明式事務,不太準確,但是大概是這個意思。
總值,fetch就是在代碼這一層給你一個主動抓取得機會.
Parent parent = (Parent)hibernateTemplate.execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q = session.createQuery(
"from Parent as parent "+
" left outer join fetch parent.childs " +
" where parent.id = :id"
);
q.setParameter("id",new Long(15));
return (Parent)q.uniqueResult();
}
});
Assert.assertTrue(parent.getChilds().size() > 0);
你可以在lazy="true"的情況下把fetch去掉,就會報異常. 當然,如果lazy="false"就不需要fetch了
HQL一些特色方法:
in and between may be used as follows:
from DomesticCat cat where cat.name between 'A' and 'B'
from DomesticCat cat where cat.name in ( 'Foo', 'Bar', 'Baz' )
and the negated forms may be written
from DomesticCat cat where cat.name not between 'A' and 'B'
from DomesticCat cat where cat.name not in ( 'Foo', 'Bar', 'Baz' )
Likewise, is null and is not null may be used to test for null values.
Booleans may be easily used in expressions by declaring HQL query substitutions in Hibernate configuration:
<property name="hibernate.query.substitutions">true 1, false 0</property>
This will replace the keywords true and false with the literals 1 and 0 in the translated SQL from this HQL:
from Cat cat where cat.alive = true
You may test the size of a collection with the special property size, or the special size() function.
from Cat cat where cat.kittens.size > 0
from Cat cat where size(cat.kittens) > 0
For indexed collections, you may refer to the minimum and maximum indices using minindex and maxindex functions. Similarly, you may refer to the minimum and maximum elements of a collection of basic type using the minelement and maxelement functions.
from Calendar cal where maxelement(cal.holidays) > current_date
from Order order where maxindex(order.items) > 100
from Order order where minelement(order.items) > 10000
The SQL functions any, some, all, exists, in are supported when passed the element or index set of a collection (elements and indices functions) or the result of a subquery (see below).
select mother from Cat as mother, Cat as kit
where kit in elements(foo.kittens)
select p from NameList list, Person p
where p.name = some elements(list.names)
from Cat cat where exists elements(cat.kittens)
from Player p where 3 > all elements(p.scores)
from Show show where 'fizard' in indices(show.acts)
Note that these constructs - size, elements, indices, minindex, maxindex, minelement, maxelement - may only be used in the where clause in Hibernate3.
Elements of indexed collections (arrays, lists, maps) may be referred to by index (in a where clause only):
from Order order where order.items[0].id = 1234
select person from Person person, Calendar calendar
where calendar.holidays['national day'] = person.birthDay
and person.nationality.calendar = calendar
select item from Item item, Order order
where order.items[ order.deliveredItemIndices[0] ] = item and order.id = 11
select item from Item item, Order order
where order.items[ maxindex(order.items) ] = item and order.id = 11
The expression inside [] may even be an arithmetic expression.
select item from Item item, Order order
where order.items[ size(order.items) - 1 ] = item
HQL also provides the built-in index() function, for elements of a one-to-many association or collection of values.
select item, index(item) from Order order
join order.items item
where index(item) < 5
Scalar SQL functions supported by the underlying database may be used
from DomesticCat cat where upper(cat.name) like 'FRI%'
posted @
2007-07-26 16:44 我愛佳娃 閱讀(33589) |
評論 (1) |
編輯 收藏