export CFLAGS=-m32
export LDFLAGS=-m32
Friday, November 11, 2011
Tuesday, November 1, 2011
three style add a event in query
fucntion(){....}
);
2) $().ready(
function(){...}
);
3)$(function(){...});
in query $(document) equals $()
Monday, October 31, 2011
diffence between JavaScript onload and jquery ready
but Jquery's $(document).ready() will be fired only when DOM is available for access,images may not be downloaded yet,so image's attributes like height may not available yet.
Thursday, October 27, 2011
Jquery's Chaining capability
Jquery selectors
Jquery factory function
Javascript top Object
navigator object represents the URL of the current window
Wednesday, October 26, 2011
logging with python
import logging
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('/var/tmp/myapp.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.WARNING)
logger.error('We have a problem')
logger.info('While this is just chatty')
only error was logged
2003-07-08 16:49:45,896 ERROR We have a problem
python debug with urllib2 or httplib
h=urllib2.HTTPHandler(debuglevel=1) into source code,we will see all debug information displayed
but that is not working with urllib2,with urllib2,we have to put
h=urllib2.HTTPHandler(debuglevel=1) in source code,and add h as a handler while build opener,then we see all debug information in console
Tuesday, October 25, 2011
curl simulate HTTP POST
wget simulate HTTP POST
python urllib2 module
1)Redirect will managed bu urllib2 Httpredirecthandler automatically,we don't need any code to handle it,one thing need to remember that 307 with POST is not support by urllib,need to change the library
2)session can also be managed by module automatically,the only thing we need to do is add urllib2.HTTPCookieProcessor() while build opener
3)we need create HTTPBasicAuthHandler with a HTTPPasswordMgrWithDefaultRealm that need add username and password
here is the sample code that can handle redirection,Basic Authentication,session management(cookie processor)
4) when we add password to passwordmanagement,we need give the url of the server,not the url we point to to fetch data
5)cmd is the data we send in http message body.
server = 'http://172.19.xxx.xxx/'
url = server + 'XmlConfig'
username='guest'
password ='xxxxxxxxxxxx'
cmd ='
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, server, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler,urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
response = urllib2.urlopen(url,cmd)
thepage = response.read()
print thepage
make vi and ls in cygwin have color
Adding color to VIM and CygwinThese are notes-to-self more than anything, but maybe you can use them. You can add colorized text to Vim by adding the following to .vimrc
in your $HOME directory:
" Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endi
If you don't have this file, you can create it using :mkv
. You can change your font-settings by editing them with Edit >> Select Font and then typing :set guifont
, followed by :mkv!
. I prefer Courier New, 9pt.
If you want colors for file listings (using ls
) in Cygwin, add the following to your .bashrc
file in your $HOME directory:
alias ls="ls -CF --color"
Friday, October 21, 2011
Vi command tip
Wednesday, October 19, 2011
colorful code in VI from SecureCRT
Tuesday, October 18, 2011
jquery selector
An ID: $('#some-id') gets the single element in the document that has the corresponding some-id ID.
A class: $('.some-class') gets all elements in the document that have a class of some-class.
following code will be explained,example from learning jquery
$('#selected-plays > li').addClass('horizontal');
the line used the child combinator(>) to add the horizontal class to all top-level items only,it says find each list item(li) that is a child (>) of an element within an ID of selected-plays(#selected-plays).
$('#selected-plays li:not(.horizontal)').addClass('sub-level');
get every list item(li) that is a descendant of an element with an ID of selected-plays(#selected-plays) and Does not have a class of horizontal(:not(.horizontal)).
$('a[@title]')
this is use XML Path Language (XPath),it says select all links that have a title attribute
$('div[ol]')
this is use XPath also,it says get all div elements that contain an ol element
$('a[@href^="mailto:"]').addClass('mailto');
this will look for all anchor elements(a) with href attribut([@href]) that begins(^)with mailto(^="mailto:")
$('a[@href$=".pdf"]').addClass('pdflink');
this will get all links with an href attribute that ends with .pdf,this is use a dollar sign($)
$('a[@href*="mysite.com"]').addClass('mysite');
this will get all links to other pages on mysite.com,this is use asterisk(*)
$('div.horizontal:eq(1)')
select second item from matched set of divs with a class of horizontal(this is custom selectors)
$('tr:odd').addClass('odd');
$('tr:even').addClass('even');
$('td:contains("Henry")').addClass('highlight');
another three useful custom selectors
config emacs
1) set a variable (setq var_name var_value),in list, true is "t",False is "nil"
evaluate your lisp code in emacs
1) open emacs
2)M-x(alt-X) emacs-lisp-mode
3) from menu Emacs-Lisp,choose interactive Expression evaluation,we will see a EList> prompt for you to input lisp code
EList>(setq test t)
t
EList>(setq test1 "test1")
test1
EList>
how to use cx_Oracle
cursor = cx_Oracle.Cursor(connection)
cursor.execute(query)
result= cursor.fetchall()
cursor.close()
connection.close()
for row in result:
print row
connection_string is username/password@tsnmame
or
connection = cx_Oracle.Connection(connection_string)
cur = connection.cursor()
cur.executemany("insert into net_eqam_info (sample_date, eqamip, rf_output, l2tp_session_id, cmts_name, eqam_name) values (trunc(sysdate),:1,:2,:3,:4,:5)",[{'1': '172.19.214.21', '2': '39000', '3': '1.1.1', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}, {'1': '172.19.214.21', '2': '39001', '3': '1.1.2', '4': 'eqam011.dupt', '5': 'cmts07.dupt'}])
connection.commit()
cur.close()
connection.close()
remember whe execute a batch query,first parameter is query with named parameter,second one is a list of dictionaries
three basic data structure in python
2)dictionary,dictionary is key:value list,created with {} and do not have a order,key must be unique
3)tuple,tuple is a instance list that can not be changed,created by (),and do have order,accessed by index
Pexpect is help interact with ssh
there is a tool call script expect that can help with this,but lack of database connection and data process(File read/write) and data structure
so I come up with a python and pexpect package,it was very neat to connect to ssh server interact with it and fetch the result,save it to a file,extract data I want,then save into database,here is the part of code for pexepect:
def readEqam(ip,userIndex):
print 'connecting to',ip
starttime = datetime.now()
logFile = file('eqam_'+ip+".txt",'w')
child=pexpect.spawn('ssh '+userNames[userIndex]+'@'+ip)
child.logfile=logFile
i=child.expect(["Are you sure you want to continue connecting","password:"])
print i
if i==0:
child.sendline('yes')
i=child.expect('password:')
child.sendline(passwords[userIndex])
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
child.sendline("show application m-cmts")
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
data = child.before
child.sendline("closeSession")
child=None
elif i==1:
child.sendline(passwords[userIndex])
i=child.expect('#>',60)
if i!=0:
child.kill(0)
return False
else:
child.sendline("show application m-cmts")
#print child.before
i=child.expect("#>",60)
if(i!=0):
child.kill(0)
return False
else:
#print "START",child.before,"END"
data = child.before
child.sendline("closeSession")
child.sendline("\r")
child = None
logFile.close()
print 'total time used:',(datetime.now()-starttime).seconds
return True,data
Compile the CX_Oracle
before use it we need setup the machine that use cx_Oracle
1)setup env variable call ORACLE_HOME,it should point to the path that Oracle database,standard client,or instant client(basic client,and SDK) installed
2)if still get error that can not import cx_Oracle from python,we need compile and install cx_Oracle in the machine it will be used
3)setup Oracle_Home as i said before,setup LD_LIBRARY_PATH to $ORALCE_PATH/lib folder
4) go to cx_Oracle folder,execute python setyp.py build,if it complains about one library can not be found,go to ORACLE_HOME(instant client),create a link for the library with the name gcc requested with the file has similar name but attach a version with the file.re-run build,if it success,then run python setup.py install,this one should be has a root privilege,otherwise will fail on copying file
5) when we connection to Oracle,we also need setup service name(tns name) in tnsnames.ora
we are good to go
Monday, October 17, 2011
Cable Modem tech
Friday, October 7, 2011
contract first webservice
otherwise,it will complain about there are no SOAP BODY EXTENSION for some data
Thursday, October 6, 2011
test PL/SQL SP code
open a new SQL windows,drag and drop the SP into this windows,I will create code for you to test,you just need change IN parameter's value,print the OUT value when call is done.
one thing is not very handy that It can not gracefully handle cursor,If I define a Cursor in my SP as a IN parameter,when I direct run the test,It says syntax wrong,I need change the cursor defintion same as it was define in my SP.
I still need addtional code to iterator my OUT cursor.
from SQLPLUS,it will be very handy than that.
simplely define a refcursor like this,and call sp,then print result.
note that all the code we out in sqlplus can also be put in sqldeveloper and get the same result.
SQL> var rc refcursor
SQL> exec WS_PKG.Get_CMTS_By_Facility('AJAX',10,:rc);
PL/SQL procedure successfully completed.
SQL> print rc
no rows selected
SQL>
if there are some data,it will print it out,good way to handle cursor here.
TOAD do not have a drag and drop option,It will be more convinient to run in TOAD.following those steps
1) browse to you packages(package),right click run package
2) from Menu View,select DBMS Output.
3) it will pop up a window,let you select specific SP,and ask for input parameters.REMEMBER,there is a tab beside Arguments in this popup dialog,called option,in there,we need click "Print OUT arguments/Return values to DBMS Output",make sure select third option "LOAD into grid from memory",then click OK,it will run test code and display return cursor value in grid.
This is tested in TOAD for Oracle FreeWare 10.6.0.42
thinking about JAX-WS with NetBeans
but,with a project I done long time ago,now I need to changes some of service's return data,say complex data type to include additional data.so I have edit my original wsdl file to include this change,and totoally delete current web service,create new web service based on my changed wsdl file,it override my original implementation with a empty one,I have manualy bring my previous implementation back and changed it to effect wsdl change.
looks like it will compile code to include all my changes in wsdl,when i build and deploy,it is successes,but it is not working.it says some class based on complex data type can not be find.
another step missed,it turns out that I need refresh my web service newly created to created another wsld file locally to pack inside war file(not my original edited wsdl file,they are same anyway),it was kindly asking for overriding my implementation and make a back up for you.so I did it,clean and build,deploy,test with soapUI,viola,it works.
so now in side my project,I have two wsdl files,I need to remember that which one is original one,I will need to edit it in future to change the service if the needs come.
one more thing to remember,logging,I using log4J for web service to logging
log file is look like this:
log4j.appender.logfile.File=${com.sun.aas.instanceRoot}/logs/DTTServices.log
that means web service will log to the file that reside in server's logs folder in Domain1,but If I run my unit test,I says it can not find file /logs/DTTServices.log
,since I am using linux,it is no possible to create a folder and file in root folder,so I need change that line like this
log4j.appender.logfile.File=logs/DTTServices.log
then I run the unit test,It will automatically create folder and log file for me.the logs folder will reside in root of the project,not in src, not in build either
that's all
Wednesday, October 5, 2011
add oracle jdbc driver to maven local repository
check out specified reversion source code from remote sub version server
Tuesday, October 4, 2011
Spring AOP execution PCD(Pointcut designator) execution expression
install and remove rpm in linux system
Spring PCD
Spring AOP pointcut declaration
Monday, October 3, 2011
Spring AOP concepts
Join point: a point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point always represents a method execution.
Advice: action taken by an aspect at a particular join point. Different types of advice include "around," "before" and "after" advice. (Advice types are discussed below.) Many AOP frameworks, including Spring, model an advice as an interceptor, maintaining a chain of interceptors around the join point.
Pointcut: a predicate that matches join points. Advice is associated with a pointcut expression and runs at any join point matched by the pointcut (for example, the execution of a method with a certain name). The concept of join points as matched by pointcut expressions is central to AOP, and Spring uses the AspectJ pointcut expression language by default.
Introduction: declaring additional methods or fields on behalf of a type. Spring AOP allows you to introduce new interfaces (and a corresponding implementation) to any advised object. For example, you could use an introduction to make a bean implement an IsModified interface, to simplify caching. (An introduction is known as an inter-type declaration in the AspectJ community.)
Target object: object being advised by one or more aspects. Also referred to as the advised object. Since Spring AOP is implemented using runtime proxies, this object will always be a proxied object.
AOP proxy: an object created by the AOP framework in order to implement the aspect contracts (advise method executions and so on). In the Spring Framework, an AOP proxy will be a JDK dynamic proxy or a CGLIB proxy.
Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.
Types of advice:
Before advice: Advice that executes before a join point, but which does not have the ability to prevent execution flow proceeding to the join point (unless it throws an exception).
After returning advice: Advice to be executed after a join point completes normally: for example, if a method returns without throwing an exception.
After throwing advice: Advice to be executed if a method exits by throwing an exception.
After (finally) advice: Advice to be executed regardless of the means by which a join point exits (normal or exceptional return).
Around advice: Advice that surrounds a join point such as a method invocation. This is the most powerful kind of advice. Around advice can perform custom behavior before and after the method invocation. It is also responsible for choosing whether to proceed to the join point or to shortcut the advised method execution by returning its own return value or throwing an exception.
fwe concept of ServiceMix(ESB)
BC-Binding Components
SE-Service Engines
SA-service assembly
SU-service unit
the components for ServiceMix comes two flavors
1) Binding Components provide additional transports to the container.
An example: the servicemix-http binding component allows to send messages into the ESB using HTTP
2) Service Engines add support for another type of business logic to the container.
An example: the servicemix-saxon service engine allows you to easily build applications that do XSL-T transformations
Thursday, September 29, 2011
about logging
you could just use log4J in your project,but if the component you dependent use others.so if you develop a component or framework,you better use apache common-logging(JCL),it provide a interface for logging,so it will enough for developing,but at run time,you need provide a implementation,such as SLF4J or log4j.
when we use third party component,such as spring framework,we want use log4J or slf4j,but,we need exclude JCL,and binding SLF4J with the log4J,so we can use log4J in our code,or if we do not binding slf4j with log4j,we can just use slf4J in our code.
here is the example that we can use slf4j or log4J in our code,but component we use is spring,commented part is using slf4J,we can put log configuration in one place,both spring and our code use same configuration and both logging correctly
package com.rogers;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Hello world!
*
*/
public class App {
//private static Logger log = LoggerFactory.getLogger(App.class);
private static Logger log = Logger.getLogger(App.class);
public static void main( String[] args )
{
log.info("hello,world---slf4j");
System.out.println( "Hello World!" );
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"application.xml"});
BO bo = ctx.getBean("bo",BO.class);
System.out.println("you name:"+bo.getName());
}
}
and here is the pom that config logging
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rogers</groupId>
<artifactId>springTest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>springTest</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Wednesday, September 28, 2011
tree traversal
for example,if I have tree like this
A
/ \
B C
the preorder way access order will be ABC
the inorder way access order will be BAC
the post Order way access order will be BCA
this algorithm will cursively apply to all node we meet
About few tags in HTML
1) The head must have, at
minimum, two children, a meta element defining the character set, and a title:
2) meta tag do not have a close tag,ex:
<meta http-equiv="content-type" content="text/html;charset=utf-8">
3) link tag in head also do not have a end tag ex:
<link type="text/css" rel="stylesheet" href="hello-world.css">
4) html5 doctype tag is like this
<!DOCTYPE HTML>
XHTML 1.0 Transitional: is like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and The DOCTYPE tells the browser how to render the document. Which DOCTYPE you use greatly affects
CSS styling and markup validation
Tuesday, September 27, 2011
pointer in c++
we assign int value to x as normal
int x;
x = 100;
but for pointer,we assign like this
y = &x; //that means y will contains x's address
if we print *y ,that means we print value of x,because * get object of that pointer point to.
here is a table that summarize all of those operators
expression | can be read as |
---|---|
*x | pointed by x |
&x | address of x |
x.y | member y of object x |
x->y | member y of object pointed by x |
(*x).y | member y of object pointed by x (equivalent to the previous one) |
x[0] | first object pointed by x |
x[1] | second object pointed by x |
x[n] | (n+1)th object pointed by x |
C++ in linux
here is a example and how to compile it
code:
#include <iostream>
using namespace std;
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area () {return (x*y);}
};
void CRectangle::set_values (int a, int b) {
x = a;
y = b;
}
int main () {
CRectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area();
return 0;
}
compile: g++ test1.cpp -o test1
run: /test1
Thursday, September 22, 2011
template method pattern
abstract class Game{
void init();
void play();
void printWinner();
void exit();
void playTheGame(){
init();
play();
printWinner();
exit();
}
}
class MonoGame extends Game(){
void init(){
System.out.println("init monoGame");
}
void play(){
System.out.println("playing monoGame");
}
void printWinner(){
System.out.println("print winner in monoGame");
}
void exit(){
System.out.println("exit monoGame");
}
}
//define other classes with new behaviors with override the abstract method
public static void main(String args[]){
Game g = new MonoGame();
g.playTheGame();
//other type of games
}
visitor pattern
interface Operation{
void op(){};
}
class AddOperation implements Operation{
void op(){
System.out.println("add operation");
}
}
class minusOperation implements Operation{
void op(){
System.out.println("minus");
}
}
//this can be used to get rid of the if or select case statements
public class Test{
public static void main(String args[]){
Operation o = new AddOperation();
o.op();
}
}
//here comes visitor pattern
interface Visitor(){
void visit(Operation o);
}
class ToAdd implements Visitor{
void visit(Operation o){
o.op();
}
}
class ToSubstract implements Visitor{
void visit(Operation o){
o.op();
}
}
public class MyTest{
public static void main(String[] args){
Operation op = new MinusOperation();
Visitor v = new ToSubstract();
v.visitor(op);
}
}
best example is Pizzas and delivery methods,for Pizza,we need to order it,all Pizza has this method,Delivery interface has a visit method that will pass Pizza and call Pizza's order method,so we add operations(different delivery method) to group of class( different Pizzas),we do not need to change Pizzas structure,becaus it is extracted to interface.
javascript closure definition
A closure is the local variables for a function - kept alive after the function has returned, or
A closure is a stack-frame which is not deallocated when the function returns. (as if a 'stack-frame' were malloc'ed instead of being on the stack!)
key points about difference betweeb interface and abstract class
1)Interfaces are just signatures and have no implementations (code in method bodies) where as abstract classes can have some implementations.
2)You can extend only one abstract class but you can extend (or implement) multiple interfaces
3)Interfaces define a contract or signature and have no behavior but abstract classes have behavior
Wednesday, September 21, 2011
how to count number os sessions
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class SessionCount implements HttpSessionListener{
private static int numberOfSessions;
/**
* @return the numberOfSessions
*/
public static int getNumberOfSessions() {
return numberOfSessions;
}
/**
* @param aNumberOfSessions the numberOfSessions to set
*/
public static void setNumberOfSessions(int aNumberOfSessions) {
numberOfSessions = aNumberOfSessions;
}
public void sessionCreated(HttpSessionEvent se) {
setNumberOfSessions(getNumberOfSessions() + 1);
}
public void sessionDestroyed(HttpSessionEvent se) {
setNumberOfSessions(getNumberOfSessions() - 1);
}
}
SQLDeveloper upcase allCode
the setting is in MEnu Tools|Preferences|Code Editor|Completion Insight|Change case as you type
this definitely should not be turn on as a default feature!!
Tuesday, September 20, 2011
easy way to find record in some table changed in specified date
Monday, September 19, 2011
add popup in icefaces visual pages
style="display: block; height: 48px; left: 1080px; top: 456px; position: absolute; width: 416px" title="DTT Dialog">
<f:facet name="header">
<ice:panelGrid cellpadding="0" cellspacing="0" columns="2" style="text-align: center;" width="100%">
<ice:outputText styleClass="PopupHeaderText" value="Device Activation and Topology Management"/>
<ice:commandButton actionListener="#{AMUChassis.closeButton_processAction}" alt="Close" id="yesNoPnlCloseBtn"
image="/resources/popupclose.gif" styleClass="PopupHeaderImage" title="Close Popup" type="button"/>
</ice:panelGrid>
</f:facet>
<f:facet name="body">
<ice:panelGroup styleClass="PopupBody">
<ice:outputText style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px; left: 416px; text-align: center;" value="Chassis #{AMUChassisSessionBean.originalChassisName} and all associated components will be deleted, continue ?"/>
<br/>
<br/>
<ice:commandButton actionListener="#{AMUChassis.yesButton_processAction}" id="yes"
style="position: relative; left: 120px; width: 80px" type="submit" value="Yes"/>
<ice:commandButton actionListener="#{AMUChassis.noButton_processAction}" id="no"
style="position: relative; left: 160px; width: 80px" type="submit" value="No"/>
</ice:panelGroup>
</f:facet>
</ice:panelPopup>
Friday, September 9, 2011
TreeMap vs HashMap vs HashTable
first TreeMap is sorted by key in nature,notice that if you put as key as negative number and it is save as String,then,it will mass up
you can put key as Long(negative),then it will work,HashMap is not sorted,but it will not keep the order that you put then in.
solution is to switch key and value,if they are both unique.
HashTable is older HashMap is new
HashTable is not allow null values.HashMap allows.
HashTable is synchnozed,HashMap is not.
Thursday, September 8, 2011
search a column references in whole database
execute this:
select table_name, column_name from all_tab_columns where column_name like 'FACILITY_SEQ'
it willlist all tables that reference to column "FACILITY_SEQ"
config jetty port from mvn command and pom
if we want change the port,we can start jetty like this mvn jetty:run -Djetty.port=9090
or add following code inside pom's maven-jetty-plugin configuration tag
<systemProperties>
<systemProperty>
<name>jetty.port</name>
<value>9090</value>
</systemProperty>
</systemProperties>
Wednesday, September 7, 2011
struts2 pass-through actions
filter all unread emails from gmail account
Friday, September 2, 2011
mvn site:site
Struts2 MVN practice
2) after project created,we can not clean,compile and package project because of folowing error,we need fix some reference in pom.xml
Reason: Resolving expression: '${project.version}': Detected the following recursive expression cycle: [] for project rogers:helloWorld at /home/dttdev1/struts2/helloWorld/pom.xml
3) add following line in properties tag,change struts2.Version to a real struts2 version like 2.2.3,
delet all spring dependencies,and test class and packages
<project.version>1.0.0.0</project.version>
4) after that,we can clean,compile,package and test it inside jetty by mvn jetty:run
5)create a newexamples.xml file in same folder as struts.xml reside.
6) newexamples.xml content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- - This file is included by the struts.xml file as an example - of how
to break up the configuration file into multiple files. -->
<struts>
<package name="newexamples" namespace="/mytest" extends="struts-default">
<action name="Name">
<result>/newexamples/namecollect.jsp</result>
</action>
<action name="HelloName" class="rogers.newexamples.TestAction">
<result name="SUCCESS">/newexamples/hello.jsp</result>
</action>
</package>
</struts>
7) include this xml file in struts.xml
<include file="newexamples.xml" />
8) create action class:
package rogers.newexamples;
public class TestAction {
private String name;
private String greeting;
public String execute() {
setGreeting("hello, " + getName());
return "SUCCESS";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGreeting() {
return greeting;
}
public void setGreeting(String greeting) {
this.greeting = greeting;
}
}
9) create two jsp file in newexamples folders(namecollect.jsp and hello.jsp
<s:form action="HelloName">
<s:textfield name="name" label="Your name" />
<s:submit />
</s:form>
<s:property value="greeting"/>
start jetty,then point to http://localhost:8080/tutorial/mytest/Name,it will display namecollect.jsp page,after give a name,click submit,it will redirect to a hello.jsp page with a greeting massage
thinking: 1)if we put newexamples.xml in different folder,even we include the xml file,but when we visit the namecollect page by action Name,it will complain that action name Name can not be find,not action mapped to name "Name".
we define action like this
<action name="Name">
<result>/newexamples/namecollect.jsp</result>
</action>
this means when we visit http://localhost:8080/tutorial/mytest/Name
it will show namecollect.jsp page
inside namecollect.jsp page we define
<s:form action="HelloName">
<s:textfield name="name" label="Your name" />
<s:submit />
</s:form>
that means when we give a name and click submit,textfield content will be send to mapped action HelloName(TestAction class)'s property name,then call it's execute method to setup property greeting.
from mapped action HelloName definition
<action name="HelloName" class="rogers.newexamples.TestAction">
<result name="SUCCESS">/newexamples/hello.jsp</result>
</action>
we know that when execute return "SUCCESS",it will carry the java bean's property greeting to page hello.jsp and render the hello.jsp to explorer.
last ,dont forget to add a extra line to in pom.xml for jetty configuration
<scanTarget>src/main/resources/newexamples.xml</scanTarget>
Maven command to create a new Project
Tuesday, August 30, 2011
struts2 mvn project auto completion in elcipse
the annotation is not auto complete,we need add struts2-codebehind-plugin-2.2.3.jar top build path,then
auto completion with annotation should work.the jar reside in strust2 lib folder.
or add following to project dependencies,otherwise will get a error when compile from command.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-codebehind-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
when add annotation to action class,we also need change pom.xml to compile code with source= 1.5,add following plugin in build tag
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
use mvn from terminal to deploy your mvn based struts2 application
I need test my newly created mvn based struts2 application,I don't want use jetty ot tomcat,because I already have a server startup,if I use gjetty/tomcat,I need to change the port,there might be some other port confict.search from internet get another mvn library to help run asadmin command to deploy my strut2 application from command line
here is the jar file need registered in pom and put correct parameter for it,then invoke "mvn exec:exec" then it will deploy you war file to existed start up server,this exec goal will call asadmin command to deploy war file.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>/home/dttdev1/glassfish-2.1.1-ml/bin/asadmin
</executable>
<arguments>
<argument>deploy</argument>
<argument>--user=admin</argument>
<argument>--passwordfile=/home/dttdev1/.asadminpass
</argument>
<argument>--host=nppdev.rogers.com</argument>
<argument>--port=4848</argument>
<argument>target/${artifactId}.${packaging}</argument>
</arguments>
</configuration>
</plugin>
and remember to put this inside build/plugins
Friday, August 26, 2011
use latest jetty server with mvn
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.21</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
we can change this to following to use latest jetty,like jetty 7
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>3</scanIntervalSeconds>
</configuration>
</plugin>
we can change code and resource,jetty will detect that,it point to webapp in src folder,not target folder,so no need to run package
System.out.println shortcut both for netbeans and eclispe
in eclipse type "syso",than Ctrl-space,it will add System.out.println("") too.
jsut for remind myself
Thursday, August 25, 2011
linux file search
find -name "ABC*"
search file based on file content
grep -rl "test" *
use jetty in eclipse for mvn struts2 web app
set up a exteranl tools for current project,location is ${maven_exec},work directory is ${project_loc},${project_loc} is for argument,put environment variable for MAVEN_OPTS as "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n" without start and end quotation mark.
this means jvm used by jetty will use port 4000 for remote debug
then in elcipse setup a debug configuration unser Remote Java application,connection type is Standard (Socket Attach),host is localhost ,port is 4000.
then start jetty,then run debug remote debugger will attach to jetty server,enable build automatically
we can use breakpoint variable watch,
code change will automatically compiled
but things like adding static variables, new domain classes will not work sice they need aware of while class loadup
see tomcat console like it was in windows
we need use "tail -f catalina.out" in log folder,then start,shutdown and deploy information will be displayed automatically in the console.
how to post XML in blogger
http://centricle.com/tools/html-entities/
Tuesday, August 23, 2011
read file from oracle PL/SQL
Monday, August 22, 2011
config tomcat to pint to application folder
for tomcat6 property debug should be removed
Tuesday, August 16, 2011
error while install Oracle Service bus
You do not have sufficient permissions to access the inventory '/home/tom1/oraInventory'. Installation cannot continue. Make sure that you have read/write permissions to the inventory directory and restart the installer.: Permission denied
the solution is create your own oraInventory in your home
1) create a folder in your home: mkdir oraInventory
2) craete a file in your home: touch oraInst.loc
3) add following content to the file
inventory_loc=/home/dttdev/oraInventory
inst_group=nppdev
then call installer like this
./runInstall -invPtrLoc /home/bpub/oraInst.loc
Tuesday, August 9, 2011
how to back up Large files
BACKUP
1)tar -cz mydir | split -d -b 1000m - myarchive.tgz.(include last dot)
2)md5sum myarchive.tgz.* > myarchive.md5
RESTORE
1)md5sum -c myarchive.md5
2)cat myarchive.tgz.* | tar -xz
6502: PL/SQL: numeric or value error
FOR i IN v_mac_tbl.FIRST .. v_mac_tbl.LAST LOOP
blar... with v_mac_tbl(i)
end loop
v_mac_tbl is a table of some sequence type
the table is fill by a fetch bulk collect into.
if the source cursor is empty,then the table is empty,so reference of v_mac_tbl(i) will throw SQLException,it sames like for loop will execute at least one time even table is empty.
the solution is use a if before For loop by checl v_mac_tbl.count >0.
Wednesday, July 27, 2011
one case for sqlexception with msg NO Data
Friday, July 8, 2011
what is BondingGroup in cmts
Bonding feature, which is the key feature of the Cisco Cable Wideband Solution, Release 1.0.
In the Cisco Cable Wideband Solution, Release 1.0, the DOCSIS 3.0 Downstream Channel Bonding
feature supports downstream wideband channels consisting of multiple bonded RF channels. The
solution provides wideband data services over existing hybrid fiber coax (HFC) networks. With
wideband data services, multiple RF channels are aggregated into a single logical wideband
channel (bonding group) that delivers higher bandwidth to the wideband cable modem than was
previously possible with DOCSIS 2.0 technology. This aggregation of RF channels is referred to as
“channel bonding.”
what is MacDomain in m-cmts linecard
registered on that MAC Domain. A cable modem is registered to only a single MAC Domain.
Thursday, July 7, 2011
code to call Store procedure and display result in SQLDeveloper
P_CHASSIS_SEQ NUMBER;
P_MODEL_SEQ NUMBER;
P_LC_CURSOR LINE_CARD_PKG.CURSOR_TYPE;
LC_CURSOR LINE_CARD_PKG.CURSOR_TYPE;
TYPE A IS RECORD(
SEQ NUMBER,
NAME VARCHAR2(128)
);
REC A;
BEGIN
P_CHASSIS_SEQ := 617;
P_MODEL_SEQ := 10;
P_LC_CURSOR := NULL;
LINE_CARD_PKG.GET_AVAILABLE_LC_BY_CHSEQ ( P_CHASSIS_SEQ => P_CHASSIS_SEQ,P_MODEL_SEQ => P_MODEL_SEQ,P_LC_CURSOR => P_LC_CURSOR) ;
LC_CURSOR := P_LC_CURSOR;
LOOP
FETCH P_LC_CURSOR INTO REC ;
EXIT WHEN P_LC_CURSOR%NOTFOUND;
dbms_output.put_line('sequence:'||REC.SEQ||'--'||'NAME:'||REC.NAME);
END LOOP ;
close P_LC_CURSOR ;
END;
another way call SP from TOAD
P_CHASSIS_SEQ NUMBER;
P_MODEL_SEQ NUMBER;
LC_CURSOR LINE_CARD_PKG.CURSOR_TYPE;
P_LC_CURSOR LINE_CARD_PKG.CURSOR_TYPE;
BEGIN
P_CHASSIS_SEQ := 338;
P_MODEL_SEQ := 15;
P_LC_CURSOR := NULL;
LC_CURSOR := NULL;
LINE_CARD_PKG.Get_Available_LC_By_ChSeq ( P_CHASSIS_SEQ, P_MODEL_SEQ, P_LC_CURSOR) ;
:LC_CURSOR :=P_LC_CURSOR;
END;
or use named parameters like this
DECLARE
P_CHASSIS_SEQ NUMBER;
P_MODEL_SEQ NUMBER;
P_LC_CURSOR LINE_CARD_PKG.CURSOR_TYPE;
LC_CURSOR LINE_CARD_PKG.CURSOR_TYPE;
BEGIN
P_CHASSIS_SEQ := 617;
P_MODEL_SEQ := 10;
P_LC_CURSOR := NULL;
LINE_CARD_PKG.Get_Available_LC_By_ChSeq ( P_CHASSIS_SEQ => P_CHASSIS_SEQ,
P_MODEL_SEQ => P_MODEL_SEQ,
P_LC_CURSOR => P_LC_CURSOR) ;
:LC_CURSOR :=P_LC_CURSOR;
END;
how to call a store procedure and display result in TOAD
exec schema.package.Get_Available_LC_By_ChSeq(338,15,:P_CURSOR)
228 and 15 is input parameter,P_CURSOR is output ref cursor
when click run TOAD will ask for output parameter type ,just choose cursor type.
then output parameter(cursor) will display in Data Grid tab of the TOAD.
Tuesday, July 5, 2011
sign "(+)" and "=>" in pl/sql
if (+) appears in right of "=",then it means right outer join
=> mean give specific parameter a value,ex
username=>'dojone'
log4j level
Log4J Levels |
Log4J Levels
Loggers may be assigned levels. The set of possible levels, that is DEBUG, INFO, WARN, ERROR and FATAL are defined in the org.apache.log4j.Level class.
If a given logger is not assigned a level, then it inherits one from its closest ancestor with an assigned level.
The root logger resides at the top of the logger hierarchy. It always exists and always has an assigned level.
The logger is the core component of the logging process. In log4j, there are 5 normal levels Levels of logger available (not including custom Levels), the following is borrowed from the log4j API (http://jakarta.apache.org/log4j/docs/api/index.html):
static Level DEBUG - The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
static Level INFO - The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
static Level WARN - The WARN level designates potentially harmful situations.
static Level ERROR - The ERROR level designates error events that might still allow the application to continue running.
static Level FATAL - The FATAL level designates very severe error events that will presumably lead the application to abort.
In addition, there are two special levels of logging available: (descriptions borrowed from the log4j API http://jakarta.apache.org/log4j/docs/api/index.html):
static Level ALL -The ALL Level has the lowest possible rank and is intended to turn on all logging.
static Level OFF - The OFF Level has the highest possible rank and is intended to turn off logging.
Thursday, June 23, 2011
Cable Network terms
L2VPN:layer 2 vpn
L3VPN:layer 3 vpn
SIP: session Initiation Protocol
IMS: IP Multimedia subsystem
PCMM:Packet Cable Multimedia
WiMAX: Worldwide interoperability for Microwave Access
PON:Passive Optical nework
HFC:Hybrid Fiber-Coax
MSO:multi system operator
I-CMTS:integrated Cable Modem Termination Sys
M-CMTS: Modular Cable Modem termination system
NSI:network side interface
PHY:Physical layer
ERMI:Edge resource management interface
CM: Cable modem
DOCSIS: Data over Cable Service Interface Specification
edge-eqam:edge quadrature amplitude modulation
SPA:shared port adapter
PRE4:performance routing engine 4
DTCC: DOCSIS Timing communication and Control
SIP:SPA Interface Processor
DTI:DOCSIS Timing Interface
PEM:Power Entry Module
RF:radio frequenct
US:up stream
DS:down stream
GE:gigabit ethernet
LC:line card
beautify sqlplus output
--var rc refcursor
--exec tmp_pkg.get_cmts_bychassis_cursor(14,:rc)
--print rc
here is the output:
CMTS_SEQ
----------
CMTS_NAME
--------------------------------------------------------------------------------
CHASSIS_SEQ
-----------
CHASSIS_NAME
--------------------------------------------------------------------------------
CMTS_TYPE_NAME
--------------------------------------------------------------------------------
MODEL
--------------------------------------------------------------------------------
14
CMTS_SEQ
----------
CMTS_NAME
--------------------------------------------------------------------------------
CHASSIS_SEQ
-----------
CHASSIS_NAME
--------------------------------------------------------------------------------
CMTS_TYPE_NAME
--------------------------------------------------------------------------------
MODEL
--------------------------------------------------------------------------------
cmts11.nmkt
CMTS_SEQ
----------
CMTS_NAME
--------------------------------------------------------------------------------
CHASSIS_SEQ
-----------
CHASSIS_NAME
--------------------------------------------------------------------------------
CMTS_TYPE_NAME
--------------------------------------------------------------------------------
MODEL
--------------------------------------------------------------------------------
14
CMTS_SEQ
----------
CMTS_NAME
--------------------------------------------------------------------------------
CHASSIS_SEQ
-----------
CHASSIS_NAME
--------------------------------------------------------------------------------
CMTS_TYPE_NAME
--------------------------------------------------------------------------------
MODEL
--------------------------------------------------------------------------------
cmts11.nmkt
CMTS_SEQ
----------
CMTS_NAME
--------------------------------------------------------------------------------
CHASSIS_SEQ
-----------
CHASSIS_NAME
--------------------------------------------------------------------------------
CMTS_TYPE_NAME
--------------------------------------------------------------------------------
MODEL
--------------------------------------------------------------------------------
i-cmts
CMTS_SEQ
----------
CMTS_NAME
--------------------------------------------------------------------------------
CHASSIS_SEQ
-----------
CHASSIS_NAME
--------------------------------------------------------------------------------
CMTS_TYPE_NAME
--------------------------------------------------------------------------------
MODEL
--------------------------------------------------------------------------------
ubr10012
CMTS_SEQ
----------
CMTS_NAME
--------------------------------------------------------------------------------
CHASSIS_SEQ
-----------
CHASSIS_NAME
--------------------------------------------------------------------------------
CMTS_TYPE_NAME
--------------------------------------------------------------------------------
MODEL
--------------------------------------------------------------------------------
we need make it tide and neat:
first format those columns that are too long
column CMTS_SEQ format 999
column CMTS_NAME format a12
...
then rerun the code and print cursor
we will get follwing output
SQL> print rc
CMTS_SEQ CMTS_NAME CHASSIS_SEQ CHASSIS_NAME CMTS_TYPE_NAME MODEL
-------- ------------ ----------- ------------ ------------ ------------
14 cmts11.nmkt 14 cmts11.nmkt i-cmts ubr10012
cheers!
call storeprocedure from sqlplus
exec tmp_pkg.get_cmts_by_chasses_corsor(14,:rc)
print rc
note:there are not semicolon(;) at end os statement
14 is input parameter,rc is output parameter as a cursor
rlwrap help sqlplus to use up arrow key
./configure
make
make install(maybe need sudo)
then run sqlplus like this:
rlwrap sqlplus user/pw@tnsname
connect to Oracle Db by sqlplus in linux
2) add or changes a entry like this
ORCLDBDTT =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ip address )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = STGSPDB)
)
)
note: ORCLDBDTT is a name call tns name,STGSPDB is a service ID
3)save the file connect to db by this:
sqlplus user/password@ORCLDBDTT
Thursday, June 16, 2011
JSF2 and javascript
<h:outputScript library="js" name="common.js" />
this will create
<script type="text/javascript"
src="/JavaServerFaces/faces/javax.faces.resource/common.js?ln=js"
></script>
common.js file should be reside in resources/js folder
this is from MKYong's blog
Wednesday, June 15, 2011
include local javascript file in ee6 web app for jsp pages
<script type="text/javascript" src="http://localhost:8080/JavaEE6Webinar/faces/javax.faces.resource/javascript.js"></script>
xhtml file include js files in ee6
< h:outputScript name="javascript.js" target="head"> < /h:outputScript>
javascript.js should be inside resources folder,this will be load by javax.faces.resource
when load css file,it should go like this
< h:outputStylesheet name="css/jsfcrud.css"/>
jsfcrud.css file be inside resource/css folder
this piece of code can be put anywhere that use target to put script tag in head or body.
Monday, June 13, 2011
install XML Tool in netbean 7
Friday, June 3, 2011
linux file find method
find -name 'mypage.htm'
In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.
find / -name 'mypage.htm'
In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root.
find -name 'file*'
In the above example the system would search for any file beginning with file in the current directory and any subdirectory.
find -name '*' -size +1000k
In the above example the system would search for any file that is larger then 1000k.
find . -size +500000 -print
Next, similar to the above example, just formatted differently this command would find anything above 500MB.
---------------------------------------------------------------------------------------------
SEARCH FILE CONTAIN STRING
Task: Search all subdirectories recursively
You can search for a text string all files under each directory, recursively with -roption:
$ grep -r "redeem reward" /home/tom
Task: Only print filenames
By default, grep command prints the matching lines You can pass -H option to print the filename for each match.
$ grep -H -r “redeem reward” /home/tom
Monday, May 30, 2011
redhat sound card problems
when I get online to watch video,some of them have very low voice volume,event in visualized windows 7,especially the video recorded(not confirmed) from mac.I find following way can fix it
1) in console,run gstreamer-properties
2) in pop windows,changed Default output plugin from AutoDetect to ALSA(advanced Linux sound architecture).
Monday, May 16, 2011
CSS
1)p {color:red;text-align:center;} --- select(html element) and style
2)#para1
{
text-align:center;
color:red;
} --- is select and style
3).center {text-align:center;} ---class select and style
4)p.center {text-align:center;} --- html element's class select and style
how to use external style sheet: inside html "head" element put "link" element
Wednesday, April 6, 2011
add Jax-rpc web service plugin in netbeans 6.9.1
Monday, April 4, 2011
Friday, April 1, 2011
netbeans 6.5.1 open with one windows only
2)delete all file from user's home\.netbeans\6.5\config\Windows2Local\Components
3) restart netbeans
enable comet in glassfish
delete expired certificate from glassfish
2) keytool -delete -v -alias verisignserverca -keystore ./domains/domain1/config/cacerts.jks