Friday, November 11, 2011

Tuesday, November 1, 2011

three style add a event in query

1) $(document).ready(
fucntion(){....}
);
2) $().ready(
function(){...}
);
3)$(function(){...});

in query $(document) equals $()

Monday, October 31, 2011

diffence between JavaScript onload and jquery ready

Javascript have a method called window.onload(),it will be fired when all document(DOM,file,image) downloaded completely
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

with jquery's chaining capability,we can get multiple sets of elements and do multiple thing with them
$('td:contains("Henry")') //get every cell containing "Henry"
.parent() //get its parent
.find('td:eq(1)') //find inside the parent the 2nd cell
.addClass(highlight') //add the "highlight" class to that cell
.end() //revert back to the parent of the cell containing "Henry"
.find('td:eq(2)') //find inside the parent the 3rd cell
.addClass('highlight'); //add the "highlight" class to that cell

Jquery selectors

$('#selected-plays > li').addClass('horizontal');
means find each list item (li) that is a child (>) of an element with an ID of
selected-plays (#selected-plays).
$('#selected-plays li:not(.horizontal)').addClass('sub-level');
we are getting every list item (li) that:
1. Is a descendant of an element with an ID of selected-plays
(#selected-plays), and
2. Does not have a class of horizontal (:not(.horizontal)).

jquery also use XPath selectors,like
$('a[@title]') means select all links that has a title attribut
$()'div[ol]') means get all div elements that contain an ol element
$('a[@href^="mailto:"]') means get all anchor elements(a) with an href attributes([@href]) that begin with mailto(^="mailto:")
$('a[@href$=".pdf"]') means get all links with a href attribute that ends with .pdf
$('a[@href*="mysite.com"]') means get all internal linkes,

Jquery's custom selectors
$('div.horizontal:eq(1)') means select the second item from a matched set of divs with a class of horizontal
$('tr:odd')
$('tr:even')
$('td:contains("henry")')

Jquery factory function

the $() function remove the need to do a for loop to acces a group of lelement since whatever we put nside the parenthese will be looped through automatically end store as a jQuery objec,we cn put just about anything inside the parenthese of the $(),here are few examples
A tag name: $('p') gets all paragraphs in the document.
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.

In jQuery, the dollar sign $ is simply shorthand for jQuery

Javascript top Object

window object is the top one.it will be created after user open a browser,or we can create sub windows from current window.we can also refer to its properties(property and method),
like we can call following method:
var subwindow = window.open("define.html","def","height=200,width=300")
subwindow.close()
window.alert("the is a javascript alert dialog")
if(window.confirm("Are you sure you want to start over?")
{
location.href="index.html"
}

the word window could be ommited.
var answer = prompt("What is your name?","");
if (answer)
{
alert("Hello, " + answer + "!");
}

window.addEventListener(’load’, functionName, false);
window.attachEvent(’onload’, functionName);

navigator object represents the URL of the current window

Wednesday, October 26, 2011

logging with python

logging within python is pretty easy

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

with httplib,as see in dive into python if we put line
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

in windows I use following command
curl http://172.19.xx.xxx/XmlConfig -u guest:password -d@cmd.txt -basic -v -L -c c.txt
-u for username and password
-d@ read HTTP message body from cmd.txt file
-basic: BASIC Authentication
-v: verbose output
-L : auto follow redirect
-c:save and load cookie from c.txt,and auto manage session by cookie

in linux:
curl http://172.19.xxx.xxx/XmlConfig -u guest:password -d '' -basic -v -L -c c.txt

this one I put the HTTP message body in command like directly


when curl output it will print curl message started with star(*), the data been send with by curl "<",data received with "<".

wget simulate HTTP POST

wget --http-user=guest --http-passwd=I$%##$@%H http://172.19.208.6/XMlConfig -d -S --post-file cmd.txt

-d: debug
-S:print server response
cmd.txt : HTTP message body send to server

python urllib2 module

play with python urllib2 module,try to make a HTTP POST with a http url,with 307 Redirection and Cookie management,Basic Authentication.here is what I learn
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 .bashrcfile in your $HOME directory:

alias ls="ls -CF --color"

Friday, October 21, 2011

how to find a directory of specific library

import urllib2

print urllib2.__file__

Vi command tip

ctrl-Z go back to the shell,use fg return to vi
direct jump into a line :100
use :sh create a new shell,exit this shell will return back to vi
use -R open file read only
:set number will dislay line number,set nonumber close line number display

Wednesday, October 19, 2011

colorful code in VI from SecureCRT

go to Options menu,choose session options,select Emulation under Termainl,change Terminal from T100 to Xtern,check "ANSI Color" and "Use color scheme",click OK,and relogin,then when use VI or emacs,it will color your code

Tuesday, October 18, 2011

jquery selector

A tag name: $('p') gets all paragraphs in the document.
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

emacs configuration done by a file called .emac in home directory,it will explain by Lisp language

1) set a variable (setq var_name var_value),in list, true is "t",False is "nil"

evaluate your lisp code in emacs

while all configuration for emcs is reside in .emacs file,we need temporarily test those configurations before permanently put into .emacs file
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

connection = cx_Oracle.Connection(connection_string)
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

1)list,list is the sequence of data,created with [],and has order,can be accessed by index
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

I have a 400-500 ssh server that I need connect to by ssh,since those server are not real OS server,they are eqipment,they are response very slowly,even for the login,I tried jsch,it can not handle the server's delay,my command was inserted into the server's prompt information,and not been accepted and executed.
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

cx_Oracle is python library that help us connect to Oracle database run qery to retrieve data or update data in database
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

Cable Modem is type of netwoek bridge and medem that provides bi-directionary communication var radio frequency channel on a HFC and RFoG infrastructure
HFC stand for Hybrid fibre-coaxial( chinese is 混合光缆同轴)
RFoG stands for Radio Frequency over Glass,in which the coax partion of HFC network replaced by a single-fiber,passive optical architecture(PON)



Friday, October 7, 2011

contract first webservice

while coding on existing wsdl file,after I add my customized DataType,messages and operations(In Port Types),then add Soap bindings(add these operations into Binding),we need add more stuff under operation from Binding,we need add soap operation under operation and add soap body under in and out parameter,add soap:fault under FAULT.
otherwise,it will complain about there are no SOAP BODY EXTENSION for some data

Thursday, October 6, 2011

test PL/SQL SP code

SQLDeveloper has a very good GUI,that can let you test the SP you developed
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

for webservice developing in netbeans,it is very nice that netbeans have very good wsdl editor,you can add complex data type,you can add messages,you can add Port Type,Bindings and Services,it is very handy.
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

mvn install:install-file -DgroupId=com.oracle -DartifactId=oracle -Dversion=11.2.0.4.0 -Dpackaging=jar -Dfile=/home/dttdev1/libs/ojdbc5.jar

config-make-install package in linux

./configure
./make
./make installgit

check out specified reversion source code from remote sub version server

svn checkout -r 614 https://src.springframework.org/svn/spring-samples/configuration-basic configuration-basic
614 is the reversion
https://src.springframework.org/svn/spring-samples/configuration-basic is the url
configuration-basic is target folder

Tuesday, October 4, 2011

Spring AOP execution PCD(Pointcut designator) execution expression

mostly,we use execution,here is the execution expression format

execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern) throws-pattern?)

pay attention to the space after question mark,and only ret-type-pattern is mandatory,after name-pattern,there is not space between name-pattern and bracket
for example:@Pointcut("execution(* transfer(..))")
means: start is for return type pattern,start means any type
transfer is for name-pattern,it means any method named transfer
two dots .. is parameter pattern,it means any number of parameter with any type
if we change it to (*),it mean one parameter with any type
(*,String) means two parameter with first one can be any type,second one must be String

install and remove rpm in linux system

install rpm -iv VirtualBox-4.1-4.1.4_74291_rhel5-1.x86_64.rpm
find rpm -qa |grep -i VirtualBox
remove rpm -e VirtualBox-4.1-4.1.0_BETA3_72886_rhel5-1.x86_64

Spring PCD

Spring AOP supports the following AspectJ pointcut designators (PCD) for use in pointcut expressions:

execution - for matching method execution join points, this is the primary pointcut designator you will use when working with Spring AOP

within - limits matching to join points within certain types (simply the execution of a method declared within a matching type when using Spring AOP)

this - limits matching to join points (the execution of methods when using Spring AOP) where the bean reference (Spring AOP proxy) is an instance of the given type

target - limits matching to join points (the execution of methods when using Spring AOP) where the target object (application object being proxied) is an instance of the given type

args - limits matching to join points (the execution of methods when using Spring AOP) where the arguments are instances of the given types

@target - limits matching to join points (the execution of methods when using Spring AOP) where the class of the executing object has an annotation of the given type

@args - limits matching to join points (the execution of methods when using Spring AOP) where the runtime type of the actual arguments passed have annotations of the given type(s)

@within - limits matching to join points within types that have the given annotation (the execution of methods declared in types with the given annotation when using Spring AOP)

@annotation - limits matching to join points where the subject of the join point (method being executed in Spring AOP) has the given annotation

Spring AOP pointcut declaration

A pointcut declaration has two parts:
a signature comprising a name and any parameters, and a pointcut expression that determines exactly which method executions we are interested in.
In the @AspectJ annotation-style of AOP, a pointcut signature is provided by a regular method definition, and the pointcut expression is indicated using the @Pointcut annotation (the method serving as the pointcut signature must have a void return type).

Monday, October 3, 2011

Spring AOP concepts

Aspect: a modularization of a concern that cuts across multiple classes. Transaction management is a good example of a crosscutting concern in enterprise Java applications. In Spring AOP, aspects are implemented using regular classes (the schema-based approach) or regular classes annotated with the @Aspect annotation (the @AspectJ style).

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)

JBI-- Java Business Integration
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

execute a java class that has main method in maven

mvn exec:java -Dexec.mainClass="com.rogers.App"

about logging

speaking about logging,most people just choose one to use,JUL,Log4J,or SLF4J,but there are some complicated situation that could cause problems
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

there are three type of tree traversals
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

few rules that 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++

in C or C++,when we declare a variable like int x;we define normal variable with type int,but when we declare like int* y,or int *y,that means we declare a int pointer
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



expressioncan be read as
*xpointed by x
&xaddress of x
x.ymember y of object x
x->ymember y of object pointed by x
(*x).ymember 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

did not try c++ in linux for a long time,

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

template pattern provide abstract definition of methods in a class and,redefine it's behavior later on the fly and without change its structures,at same time it will keep overall execute step sequence.

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

visitor pattern is used to add extra operations for group of class with out change their structures

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

this is simple question and be asked almost all interviewing,the most importance thing is to mention the key points
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

following code will help to count number of session in a web application

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

SQLDeveloper aways upcase my code while I developing pl/SQL store procedure
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

SELECT A.BONDING_GROUP_SEQ,TO_TIMESTAMP(TO_CHAR(A.MODIFY_DATE,'DD-MM-RRRR HH24:MI:SS'),'DD-MM-RRRR HH24:MI:SS') FROM DTT_BONDING_GROUP a where trunc(A.MODIFY_DATE) = '19-SEP-11'

Monday, September 19, 2011

add popup in icefaces visual pages

<ice:panelPopup autoCentre="true" draggable="true" id="deletePanelPopup" modal="true" rendered="#{AMUChassisSessionBean.yesNoRendered}"
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

while using TreeMap and HashMap,find out that they are different
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

if we looking for all reference to a specific column in whole database,we can
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

maven-jetty-plugin run container at default port 8080.
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

in struts2 if we define a action like this

<action name="Name">
<result>/chapterOne/NameCollector.jsp</result>
</action>

that means we just need to display the jsp page from this action,because the tag did not specify any java class for this action,so there is not java class related to this action.

filter all unread emails from gmail account

use "is:unread in:inbox" in search field to filter all unread email to display.
for hotmail, there is a button called unread in top

Friday, September 2, 2011

mvn site:site

this will create a report about the project include a left menu for About,dependencies,issue track etc,it also create surefire report.

Struts2 MVN practice

1) use MVN archetype:generate to create struts blank project number,choose number 198,give a artifactId and GroupId,choose the struts2 version and package and other parameters

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

invoke mvn archetype:generate will promote a list of project type and Groupid and ArchetypeID to create new project

Tuesday, August 30, 2011

struts2 mvn project auto completion in elcipse

after I import my maven created struts2 project,when I try to add a Action,
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

while use netbean 6.5 for iceface based application with glassfish2
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

when we run jetty:run,mvn will add following plugin in your pom file

<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 Netbeans type "sout" with tab,it will add System.out.println("").
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

search file based on filename
find -name "ABC*"
search file based on file content

grep -rl "test" *

use jetty in eclipse for mvn struts2 web app

by use remote debug,we can use jetty as a web server and change code from eclipse,change will be effect immediately after save,we don't need to restart jetty,here is the step

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

tomcat in windows has a console display message after it was started,but in linux,it doesn't

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

use following website to decode xml file,then copy and paste in blogger

http://centricle.com/tools/html-entities/

Tuesday, August 23, 2011

read file from oracle PL/SQL

oracle provide a pckage UTF_FILE to read/write file from db server's directory

Monday, August 22, 2011

config tomcat to pint to application folder

change server.xml file to include following tag and content inside host tag

<Context path="/cims" docBase="C:/workspace/cimsreport/web" debug="0"
reloadable="true" crossContext="true">
</Context>


for tomcat6 property debug should be removed

Tuesday, August 16, 2011

error while install Oracle Service bus

while install Oracle Service Bus in linux,get following error
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

the content is reference from http://www.electronic-equipments.co.uk/tutorial/linux/backup_large_files.html
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

in PL/SQL if we iterate a table and use follwing syntax
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

while writing PLSQL in store procedure ,if we use select column_name into variable where bla,bla statement,if it returned resultset is empty, then it will throw sqlexception with error massage says that "no data",best solution is that check existence of the records before use select into.

Friday, July 8, 2011

call function from sqlplus

select LINE_CARD_PKG.GET_NEW_LINE_CARD_SEQ() from DUAL;

what is BondingGroup in cmts

Cisco IOS Release 12.3(21)BC and 12.3(21a)BC3 support the DOCSIS 3.0 Downstream Channel
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

A MAC domain is responsible for all MAC Management Messages to the set of cable modems that are
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

DECLARE
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

DECLARE
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

if I have store procedure located in a package,I want call it in toad for some test,I can do it like this

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 (+) apears in left of "=",then it means left outer join
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

DTV:digital TV
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

when runing following code in sql plus,we get a very messay output because of column data type and it's width;
--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!

limited resultset in oracle sql statement

select * form dtt_cmts where rownum <20;

call storeprocedure from sqlplus

var rc refcursor
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

download rlwrap
./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

1) find tnsnames.ora
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

TNS stand for

TNS stands for Transparent Network Substrate

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

include following code in head or body

<script type="text/javascript" src="http://localhost:8080/JavaEE6Webinar/faces/javax.faces.resource/javascript.js"></script>

YUI library loading code creation url

http://developer.yahoo.com/yui/articles/hosting/

xhtml file include js files in ee6

inside h:head include following tags
< 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

get update plugin from here:http://deadlock.netbeans.org/hudson/job/xml/lastSuccessfulBuild/artifact/build/updates/updates.xml

Friday, June 3, 2011

linux file find method

SEARCH FILE HAS SPECIAL NAME AND SIZE ETC
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

I have Dell T5500 with Redhat installed,it have a tiny problem with it sound card.
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

CSS syntax:
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

search a file in svn

svn log --verbose --username user --password password |grep test.txt

search a file in linux based on file name

find -name 'filename.txt'

add Jax-rpc web service plugin in netbeans 6.9.1

Version: NetBeans 6.9.1 Tools -> Plugins Click "Settings" tab and "add" button Provide a name (ex. Hudson) and the URL above in the original post (http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/nbms/updates.xml.gz) Close the dialog box Click on Reload Catalog and click the "Available Plugins" tab Find your JAX-RPC plugin goodness in the list, select its checkbox, and click "Install"

Monday, April 4, 2011

if we make glassfish display his log information like tomcat do,just need start glassfish like this: asadmin -start-domain --verbose

Friday, April 1, 2011

netbeans 6.5.1 open with one windows only

1) kill netbeans
2)delete all file from user's home\.netbeans\6.5\config\Windows2Local\Components
3) restart netbeans

enable comet in glassfish

asadmin set server.http-service.http-listener.http-listener-1.property.cometSupport=true

delete expired certificate from glassfish

1) ./bin/asadmin change-master-password --savemasterpassword=true --domaindir=./domains/
2) keytool -delete -v -alias verisignserverca -keystore ./domains/domain1/config/cacerts.jks

Wednesday, January 19, 2011

python remarkable express:
swap value
>>> a,b = b,a

python 3.o will delete long type ,only int exist