Friday, December 14, 2012

how to use Vi to view file in hex mode


":%!xxd" (minus quotes) will show file in hex mode
“:%!xxd -r“ will return to normal editing.

Monday, December 10, 2012

debug the java security policy

while run a java app with security manager,it just simply failed,we need more information.invoke app with following parameters:
java -Djava.security.manager -Djava.security.debug=access:failure
then we get following result:

About to get os.name property value
access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks)
access: access allowed (java.security.SecurityPermission getProperty.policy.expandProperties)
access: access allowed (java.security.SecurityPermission getProperty.policy.ignoreIdentityScope)
access: access allowed (java.security.SecurityPermission getProperty.policy.allowSystemProperty)
access: access allowed (java.util.PropertyPermission sun.security.policy.utf8 read)
access: access allowed (java.util.PropertyPermission sun.security.policy.numcaches read)
access: access allowed (java.util.PropertyPermission java.security.policy read)
access: access allowed (java.security.SecurityPermission getProperty.policy.url.1)
access: access allowed (java.util.PropertyPermission java.home read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\security\java.policy read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\security\java.policy read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\security\java.policy read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\security\java.policy read)
access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks)
access: access allowed (java.util.PropertyPermission java.ext.dirs read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\ext\* read)
access: access allowed (java.io.FilePermission C:\Windows\Sun\Java\lib\ext\* read)
access: access allowed (java.security.SecurityPermission getProperty.policy.url.2)
access: access allowed (java.util.PropertyPermission user.home read)
access: access allowed (java.io.FilePermission C:\Users\dwei\.java.policy read)
access: access allowed (java.io.FilePermission C:\Users\dwei\.java.policy read)
access: access allowed (java.io.FilePermission C:\Users\dwei\.java.policy read)
access: access allowed (java.security.SecurityPermission getProperty.policy.url.3)
access: access allowed (java.util.PropertyPermission java.home read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\security\examplepolicy read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\security\examplepolicy read)
access: access allowed (java.util.PropertyPermission java.protocol.handler.pkgs read)
access: access allowed (java.lang.reflect.ReflectPermission suppressAccessChecks)
access: access allowed (java.util.PropertyPermission java.util.logging.manager read)
access: access allowed (java.lang.RuntimePermission setContextClassLoader)
access: access allowed (java.lang.RuntimePermission shutdownHooks)
access: access allowed (java.util.logging.LoggingPermission control)
access: access allowed (java.util.PropertyPermission java.util.logging.config.class read)
access: access allowed (java.util.PropertyPermission java.util.logging.config.file read)
access: access allowed (java.util.PropertyPermission java.home read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\logging.properties read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\logging.properties read)
access: access allowed (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_30\jre\lib\logging.properties read)
access: access allowed (java.util.logging.LoggingPermission control)
access: access allowed (java.util.logging.LoggingPermission control)
access: access allowed (java.util.logging.LoggingPermission control)
access: access allowed (java.util.logging.LoggingPermission control)
access: access allowed (java.util.logging.LoggingPermission control)
access: access allowed (java.util.logging.LoggingPermission control)
access: access allowed (java.util.PropertyPermission http.maxRedirects read)
access: access allowed (java.util.PropertyPermission java.version read)
access: access allowed (java.util.PropertyPermission http.agent read)
access: access allowed (java.util.PropertyPermission http.auth.digest.validateProxy read)
access: access allowed (java.util.PropertyPermission http.auth.digest.validateServer read)
access: access allowed (java.util.PropertyPermission sun.net.http.errorstream.enableBuffering read)
access: access allowed (java.util.PropertyPermission sun.net.http.errorstream.timeout read)
access: access allowed (java.util.PropertyPermission sun.net.http.errorstream.bufferSize read)
access: access allowed (java.util.PropertyPermission sun.net.http.allowRestrictedHeaders read)
access: access allowed (java.util.PropertyPermission http.auth.serializeRequests read)
access: access allowed (java.util.PropertyPermission http.auth.ntlm.domain read)
access: access allowed (java.net.NetPermission getCookieHandler)
access: access allowed (java.net.NetPermission getResponseCache)
access: access allowed (java.util.PropertyPermission user.dir read)
access: access allowed (java.io.FilePermission C:\test read)
access: access allowed (java.security.SecurityPermission getProperty.policy.url.4)
access: access allowed (java.util.PropertyPermission java.security.auth.policy read)
access: access allowed (java.security.SecurityPermission getProperty.auth.policy.url.1)
access: access allowed (java.io.FilePermission C:\test read)
  The name of your operating system is: Windows 7
About to get java.version property value
access: access allowed (java.util.PropertyPermission java.version read)
  The version of the JVM you are running is: 1.6.0_30
About to get user.home property value
access: access allowed (java.util.PropertyPermission user.home read)
  Your user home directory is: C:\Users\dwei
About to get java.home property value
access: access allowed (java.util.PropertyPermission java.home read)
  Your JRE installation directory is: C:\Program Files (x86)\Java\jdk1.6.0_30\jre

specify the policy file while run a applet

try out the java security guide,created the policy file,saved as a examplepolicy in local folder,the go to run the command line that invoke the applet view from sun.
appletviewer -J-Djava.security.policy=examplepolicy http://docs.oracle.com/javase/tutorial/security/tour1/examples/WriteFile.html

if we run the appletviewer from the folder that contains examplepolicy,the applet will be correctly run.oterwise the examplepolicy can not be find,so the applet will fail.

since the default jre\lib\security\java.security has a default item that load the policy from {user_home}\.java.policy,we can save newly created policy into that file,the invoke the applet anywhere,just make sure has the permission to write to that folder.

developers normally set up their JAVA_HOME to a JDK, so make sure change the java.security file in JDK\JRE\lib\security\java.security ,not the file under Program Files\Java\Jre\lib\security\java.security


locally fill a PDF form from FDF file

while open the insurance company online PDF documentation,it should automatically fill the claim form with logged in personal information.but it is downloading a file content call FDF, forms data format file which was used to fill the pdf.

open up the FDF file,found out that the file contains the url of the pdf file,I change that url to pdf file that downloaded previously from the same web site,vola, when double click th FDF file,the pdf was opened and automatically filled with information in FDF file.

take a look at the FDF file,we can also change the information in FDF to fill the PDF form.

Friday, November 23, 2012

Outlook Runtime Error -2147221233 The operation failed. An object cannot be found

This error comes out after my windows 7 get updated from microsoft, maybe some for outlook

in my VBA code ,I have following code to move a message to another folder.

 Msg.Move objNS.Folders(2).Folders("foldername")

is suddenly pop up the error messages,did some debug,find out that we need change to following code now

 Msg.Move objNS.Folders(1).Folders(13)

all index started with 1
objNS.Folders(1) is first folder in my outlook name space

objNS.Folders(1).Folders(13) is the 13th sub folder in previous folder,there is not method to get a sub folder by it's name,maybe a iteration will help to find the folder with specific name,but it is too heavy here,if we do not add new sub folder between first one and 13th,then we will be ok with previous code.




Wednesday, November 21, 2012

Installing the IDEA Module in GnuPG


(THIS INFORMATION COMES FROM http://www.spywarewarrior.com)

The "official" Win32 builds of GnuPG do not include support for the IDEA algorithm, which is patented.* This can prove to be a problem when exchanging messages and files with PGP users (esp. PGP 2.6.x users) or importing old PGP keys. This web page explains how to install the IDEA module for GnuPG so that GnuPG can use the IDEA algorithm.
The IDEA module has been distributed as both a source code file (IDEA.C) and a compiled .DLL (IDEA.DLL). Unless you plan to compile the source code yourself, you want the IDEA.DLL, which is placed somewhere in the GnuPG installation directory and loaded with the load-extension option.
Please note that the IDEA module, its location within the GnuPG installation directory, and the method for loading that module with the load-extension option have changed over successive versions of GnuPG:
Please consult the appropriate directions for your version of GnuPG. All of the versions of the IDEA module discussed on this page are available for download from this site -- see the Downloadssection below.
* The IDEA is patented in many countries, including the U.S., and may be used for non-commercial
   purposes. For commercial uses you'll need to buy a license from MediaCrypt. For the "official"
   explanation of why the IDEA algorithm is not supported in GnuPG by default see HERE.

GnuPG 1.2.0 and later

There were big changes in GnuPG 1.2.0 with respect to the IDEA module. There's a new IDEA.DLL as well as a change from previous versions in the way the IDEA.DLL is loaded.

From the GnuPG 1.2.0 Announcement
* All modules are now linked statically; the --load-extension
  option is in general not useful anymore.  The only exception is
  to specify the deprecated IDEA cipher plugin.

* The IDEA plugin has changed.  Previous versions of the IDEA
  plugin will no longer work with GnuPG.  However, the current
  version of the plugin will work with earlier GnuPG versions.

Files

For "official" versions of GnuPG  (from gnupg.org), a new set of IDEA files is available from ftp.gnupg.dk (idea.c.gz & ideadll.zip):
FileSize (kb)Notes
idea.c13815/13727new source (gnupg.org)
idea.dll8192new Win32 DLL (gnupg.org)
The Nullify builds use Disastry's IDEA module (ideadll.zip), the same as previous Nullify builds:
FileSize (kb)Notes
idea.dll45056Disastry's IDEA module
See the Downloads section below for links to these files.

To Install

1. Place the IDEA.DLL in \LIB sub-dir of the GnuPG installation dir. 
2. Add the following line to the GPG.CONF file (in previous GnuPG
    versions it was in the OPTIONS file):
load-extension Lib\idea
    You can also specify a full path to the IDEA.DLL file:
load-extension C:\GnuPG\Lib\idea.dll
    This GPG.CONF file option line works for both the "official" and  
    Nullify
 GnuPG builds.

Friday, September 21, 2012

Web Service in Windows .Net

I followed a Shiv Pal Singh's post in CodeGuru that create a web service with .net in windows without a studio tools,here is the steps and content that recorded to help me remember.

1) install the IIS from windows 7,after installation the server is up,default page(actually is a html with one picture 

embedded with lot of links) can be see in browser.

2) add a default html in server's newly created virtual directory can also be see in browser,but the asmx web service file 

can not be see in browser because of the script handler is not properly registered in system

go to c:\windows\Microsoft.NET\Framework64\v.2.0.50727,run following command

ASPNET_REGIIS.exe -I 

remember this is 64 bit,not 32,running 32 in 64 will get a error

then stop and start the server:

net stop w3svc

net start w3svc

3) copy following content in to virtual directory,name is as FirstService.asmx, language is CS,not C


 <%@ WebService language="CS" class="FirstService" %>

  using System;
  using System.Web.Services;
  using System.Xml.Serialization;

  [WebService(Namespace="http://localhost/WebService/")]
  public class FirstService : WebService
  {
      [WebMethod]
      public int Add(int a, int b)
      {
          return a + b;
      }

      [WebMethod]
      public String SayHello()
      {
          return "Hello World";
      }
  }


we will get list of operations,use link can test the service,url http://localhost/WebService/FirstService.asmx?WSDL can 

return the wsdl file of the web service

now web service serverside is done

following step will test web service from local or another machine by web and standalone windows app

1) create following asp.net web page to test the web service,name it  as WebApp.aspx



<%@ Page Language="C#" %>
  <script runat="server">
  void runSrvice_Click(Object sender, EventArgs e)
  {
      FirstService mySvc = new FirstService();
      Label1.Text = mySvc.SayHello();
      Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text),
                    Int32.Parse(txtNum2.Text)).ToString();
  }
  </script>
  <html>
  <head>
  </head>
  <body>
  <form runat="server">
    <p>
        <em>First Number to Add </em>:
        <asp:TextBox id="txtNum1" runat="server"
             Width="43px">4</asp:TextBox>
    </p>
    <p>
        <em>Second Number To Add </em>:
        <asp:TextBox id="txtNum2" runat="server"
             Width="44px">5</asp:TextBox>
    </p>
    <p>
        <strong><u>Web Service Result -</u></strong>
    </p>
    <p>
        <em>Hello world Service</em> :
        <asp:Label id="Label1" runat="server"
             Font-Underline="True">Label</asp:Label>
    </p>
    <p>
        <em>Add Service</em> :
        & <asp:Label id="Label2" runat="server"
               Font-Underline="True">Label</asp:Label>
    </p>
    <p align="left">
        <asp:Button id="runSrvice" onclick="runSrvice_Click"
             runat="server" Text="Execute"></asp:Button>
    </p>
  </form>
  </body>

  </html>



This client is some code running from server to test web service,then display result in client page

2) standalone windows app,net point to a server that web service stay,we need use WSDL file from server to create a 

dll, link this dll with client code will make client test code connect with server and successfully test the operation


use following step to create DLL

WSDL http://localhost/WebService/FirstService.asmx?WSDL

this will download the server's WSDl file and create a agent file(C#) called FirstService.cs,use following command to 

compile the source code to a DLL,then put this dll in virtual dir\bin folder,IIS looking for this agent at run time.

csc /t:library FirstService.cs

create source code of the WinApp.cs


 using System;
 using System.IO;

 namespace SvcConsumer{
 class SvcEater
 {
        public static void Main(String[] args)
        {
                FirstService mySvc = new FirstService();
                Console.WriteLine("Calling Hello World Service: " + mySvc.SayHello());
                Console.WriteLine("Calling Add(2, 3) Service: " +
                mySvc.Add(2, 3).ToString());
        }
 }
}

using following to compile the client

csc /r:FirstService.dll WinApp.cs

exe file created,it will test our  web service created in previous steps








Friday, September 14, 2012

easy way to remember the parts of wsdl file

Tags:
definations: Root WSDL element
types: What data types will be transmitted
message:What messages will be transmitted
portType: what operations(functions) will be supported
binding: how will the message be transmitted on the wire? what SOAP-specific details are there.
service: Where is the service located?

Thursday, September 13, 2012

change the cygwin terminal prompt

the prompt controlled by variable PS1,so put following code to .bash_profile or .bashrc sould works


function prompt {
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
export PS1=" ${GREEN}\u${CYAN}@${BLUE}\h ${CYAN}\w${GRAY} $ "
}
prompt

see the sqlstatement been run in java code from ibatis

add following tag in log4j,all statement been run and their parameter,result column name and data will write into log file



       
       
     

Tuesday, September 11, 2012

ANT WINDOWS style path and POSIX style path in cygwin

while using ant in windows cygwin, we can not simplely pass a posix style path in ant script,because posix style path like "/cygdrive/c/test" or "/home/atc/" can not be recognized by ant,only recognized by cygwin shell.
so in order to use those posix style path in ant script, we need convert this string into a windows style path,then path to ant,utility cygpath will help to do this kind of converting.


<exec executable="cygpath" outputproperty="app.home.dir">
  <arg value="--windows"/>
  <arg value="/home/atc/chryslerds"/>
</exec>
<echo message="${app.home.dir}"/>

<exec executable="cygpath" outputproperty="ant.dir">
  <arg value="--windows"/>
  <arg value="/cygdrive/c/ant182"/>
</exec>

<echo message="${ant.dir}"/>

Thursday, August 2, 2012

VBA code that monitor inbox emails

this code will monitor outlook 2010 inbox email,if it come from specified people,then move email to specified    folder and if the email is come in weekend,then it will forward this email to another gmail account

---------------------------------------------------------------------------------------

Private WithEvents myOlItems  As Outlook.Items
Private kitty As Outlook.Folder

Private Sub Application_Startup()
    Dim olApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
      Set olApp = Outlook.Application
      Set objNS = olApp.GetNamespace("MAPI")
      Set myOlItems = objNS.GetDefaultFolder(olFolderInbox).Items
      'Set myOlItems = objNS.Folders("dwei@companyname.com").Folders("kitty").Items
      Set kitty = objNS.Folders(1).Folders("kitty")
     
End Sub

Private Sub myOlItems_ItemAdd(ByVal item As Object)

On Error GoTo ErrorHandler

  Dim Msg As Outlook.MailItem
  Dim myFwd As Outlook.MailItem
  Dim we As Boolean

  If TypeName(item) = "MailItem" Then
    Set Msg = item

    'MsgBox Msg.Subject
    'MsgBox Msg.Body
    If Msg.Sender = "Kitty Luo" Then
        we = Application.IsWeekendDay(Now)
        If (we) Then
            Set myFwd = Msg.Forward
            myFwd.Recipients.Add "test@gmail.com"
            myFwd.Send
        End If
       
        Msg.Move kitty
       
        Set myFwd = Nothing
    End If

  End If

ProgramExit:
  Exit Sub
ErrorHandler:
  MsgBox Err.Number & " - " & Err.Description
  Resume ProgramExit
End Sub

Sub MoveToFolder(folderName)

 mailboxNameString = "Inbox"

 Dim olApp As New Outlook.Application
 Dim olNameSpace As Outlook.NameSpace
 Dim olCurrExplorer As Outlook.Explorer
 Dim olCurrSelection As Outlook.Selection

 Dim olDestFolder As Outlook.MAPIFolder
 Dim olCurrMailItem As MailItem
 Dim m As Integer

 Set olNameSpace = olApp.GetNamespace("MAPI")
 Set olCurrExplorer = olApp.ActiveExplorer
 Set olCurrSelection = olCurrExplorer.Selection

 Set olDestFolder = olNameSpace.Folders(mailboxNameString).Folders(folderName)

 For m = 1 To olCurrSelection.Count
    Set olCurrMailItem = olCurrSelection.item(m)
    Debug.Print "[" & Date & " " & Time & "] moving #" & m & _
                ": folder = " & folderName & _
                "; subject = " & olCurrMailItem.Subject & "..."
    olCurrMailItem.Move olDestFolder
 Next m

End Sub

Function IsWeekendDay(MyDate As Variant) As Boolean
   
    Dim DayNum As Variant
    Dim IsWeekend As Boolean
   
    DayNum = Weekday(MyDate)
   
    Select Case DayNum
        'Case vbMonday, vbTuesday, vbWednesday, vbThursday, vbFriday
        Case vbSaturday, vbSunday
            IsWeekendDay = True
        Case Else
            IsWeekendDay = False
     End Select
End Function

send email on behave of your outlook account


                String to = "test@gmail.com";
String from = "dwei@companyname.com";
Properties properties = System.getProperties();

properties.setProperty("mail.transport.protocol","smtp");
properties.setProperty("mail.smtp.host", "mail.mpk.autc.com");
properties.setProperty("mail.smtp.auth", "true");

Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(properties, auth);
try{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(msg);
message.setText(msg);
Transport.send(message);
}catch (Exception e) {
e.printStackTrace();
}




class SMTPAuthenticator extends javax.mail.Authenticator {
        public PasswordAuthentication getPasswordAuthentication() {
           String username = "myOutlookUserName";
           String password = "myPassword";
           return new PasswordAuthentication(username, password);
        }
    }

schedule a job in java code

simple way to schedule a job running periodic


Timer timer = new Timer();
long delay = 10 * 60 * 1000; //10 minutes
timer.schedule(new Task(), 0, delay)



class Task extends TimerTask {

public void run() {
               //do the job
        }
}

send a HTTP Get request by Java


URL stageds2k7 = new URL("http://xxx.stg.yyy.com/ds2k7/services");
URLConnection sc = stageds2k7.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(sc.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
               content.append(inputLine);
// System.out.println(inputLine);
}
in.close();

how to pack a maven jar project with all dependencies and create a executable jar file

first, we need add following plugin into build tag


<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>fully.qualified.MainClass</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

then do following


mvn assembly:assembly
Note that this way is now deprecated. The preferred way is using:
mvn assembly:single

Monday, July 30, 2012

few SAP key words

1)A deferred cost is a cost that occurred in a transaction, but will not be expensed until a future accounting period.
2)A deferred credit could mean money received in advance of it being earned, such as deferred revenue, unearned revenue, or customer advances. A deferred credit could also result from complicated transactions where a credit amount arises, but the amount is not revenue.
3)Deferred revenue is not yet revenue. It is an amount that was received by a company in advance of earning it. The amount unearned (and therefore deferred) as of the date of the financial statements should be reported as a liability. The title of the liability account might be Unearned Revenues or Deferred Revenues.
4)A deferred expense is not yet an expense, even though it has already been paid. The deferred expense is reported on a company’s balance sheet until it becomes an expense in a future accounting period.

Monday, July 16, 2012

Friday, July 6, 2012

maven grail app failed on build

add this env parameter:  MAVEN_OPTS="-Xms256m -Xmx1024m -XX:MaxPermSize=256m"

Tuesday, July 3, 2012

CVS on Cygwin - ": no such repository"


when running cvs from cygwin get error says no such respository
after covert all cvs files format from dos to unix,command will be success.

$ find . \( -name Entries -o -name Root -o -name Repository \) -exec dos2unix {} \;

Tuesday, June 26, 2012

skip test while build maven project

1)


  [...]
  
    
      
        org.apache.maven.plugins
        maven-surefire-plugin
        2.12
        
          true
        
      
    
  
  [...]

2)
mvn install -DskipTests
3)mvn install -Dmaven.test.skip=true

Monday, June 25, 2012

java - Maven Modules + Building a Single Specific Module

-pl, --projects
        Build specified reactor projects instead of all projects
-am, --also-make
        If project list is specified, also build projects required by the list
So just cd into the parent P directory and run:

mvn install -pl B -am
And this will build B and the modules required by B."

Monday, June 18, 2012

Ways that JMS Messages can be consumed


  • Synchronously. A subscriber or a receiver explicitly fetches the message from the destination by calling the receivemethod. The receive method can block until a message arrives or can time out if a message does not arrive within a specified time limit.
  • Asynchronously. A client can register a message listener with a consumer. A message listener is similar to an event listener. Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener'sonMessage method, which acts on the contents of the message.

Best AXIS 1.3 web service tutorial on internet

http://www.digizol.org/2008/07/web-service-axis-tutorial-client-server.html

Tuesday, June 12, 2012

JBOSS 4.3 web server binding to hostname and ip not localhost

started jboss like this: run.sh -b 10.20.22.4

cron expression


A cron specification allows the complex declaration of job scheduling which is tied to the system clock and calendar. Here is the full specification copied verbatim fromhttp://www.opensymphony.com/quartz/api/org/quartz/CronTrigger.html:
For those unfamiliar with "cron", this means being able to create a firing schedule such as: "At 8:00am every Monday through Friday" or "At 1:30am every last Friday of the month".
A "Cron-Expression" is a string comprised of 6 or 7 fields separated by white space. The 6 mandatory and 1 optional fields are as follows:
Field NameAllowed ValuesAllowed Special Characters
Seconds0-59, - * /
Minutes0-59, - * /
Hours0-23, - * /
Day-of-month1-31, - * ? / L W C
Month1-12 or JAN-DEC, - * /
Day-of-Week1-7 or SUN-SAT, - * ? / L C #
Year (Optional)empty, 1970-2099, - * /
The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.
The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".
The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.
The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.
The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".
The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month.
The 'C' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "calendar". This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "5C" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after sunday".
The legal characters and the names of months and days of the week are not case sensitive.

Examples

ExpressionMeaning
"0 0 12 * * ?"Fire at 12pm (noon) every day
"0 15 10 ? * *"Fire at 10:15am every day
"0 15 10 * * ?"Fire at 10:15am every day
"0 15 10 * * ? *"Fire at 10:15am every day
"0 15 10 * * ? 2005"Fire at 10:15am every day during the year 2005
"0 * 14 * * ?"Fire every minute starting at 2pm and ending at 2:59pm, every day
"0 0/5 14 * * ?"Fire every five minutes starting at 2pm and ending at 2:55pm, every day
"0 0/5 14,18 * * ?"Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day
"0 0-5 14 * * ?"Fire every minute starting at 2pm and ending at 2:05pm, every day
"0 10,44 14 ? 3 WED"Fire at 2:10pm and at 2:44pm every Wednesday in the month of March
"0 15 10 ? * MON-FRI"Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
"0 15 10 15 * ?"Fire at 10:15am on the 15th day of every month
"0 15 10 L * ?"Fire at 10:15am on the last day of every month
"0 15 10 ? * 6L"Fire at 10:15am on the last Friday of every month
"0 15 10 ? * 6L 2002-2005"Fire at 10:15am on every last friday of every month during the years 2002, 2003, 2004 and 2005
"0 15 10 ? * 6#3"Fire at 10:15am on the third Friday of every month
Pay attention to the effects of '?' and '*' in the day-of-week and day-of-month fields!
NOTES:
  • Support for the features described for the 'C' character is not complete.
  • Support for specifying both a day-of-week and a day-of-month value is not complete (you'll need to use the '?' character in on of these fields).
  • Be careful when setting fire times between midnight and 1:00 AM - "daylight savings" can cause a skip or a repeat depending on whether the time moves back or jumps forward.

Friday, May 25, 2012

maven-antrun-plugin is maven plugin that let you run ant target in pom


Maven AntRun Plugin

This plugin provides the ability to run Ant tasks from within Maven. You can even embed your Ant scripts in the POM!
It is not the intention of this plugin to provide a means of polluting the POM, so it's encouraged to move all your Ant tasks to a build.xml file and just call it from the POM using Ant's  task.
One of the main purposes of this plugin is to facilitate the migration from Ant based projects to Maven. Some projects may not currently be able to migrate because they depend on custom build functionality that Maven doesn't provide by default.

mvn plugin get outofmemory while instructing the compiled classes


while run maven plugin cobertura's target to instruct the class,get outofmemory error
solution
add following property in pom will solve the problem


...

...



    256M



AXIOM


The Apache Axiom™ library provides an XML Infoset compliant object model implementation which supports on-demand building of the object tree. It supports a novel "pull-through" model which allows one to turn off the tree building and directly access the underlying pull event stream using the StAX API. It also has built in support for XML Optimized Packaging (XOP) and MTOM, the combination of which allows XML to carry binary data efficiently and in a transparent manner. The combination of these is an easy to use API with a very high performant architecture!
Developed as part of Apache Axis2, Apache Axiom is the core of Apache Axis2. However, it is a pure standalone XML Infoset model with novel features and can be used independently of Apache Axis2.

Thursday, May 24, 2012

maven dependency scope


Dependency scope is used to limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.
There are 6 scopes available:
  • compile
    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
  • provided
    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
  • runtime
    This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
  • test
    This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
  • system
    This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
  • import (only available in Maven 2.0.9 or later)
    This scope is only used on a dependency of type pom in the  section. It indicates that the specified POM should be replaced with the dependencies in that POM's  section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

Perl language variable types

in perl, there are three data types
1)scalar
  my $animal ="camel";
  my $amswer = 42;
2) arrays
  my @animals =("camel","llama","owl");
  my @numbers = (23,42,69);
  my @mixed = ("camel",42,123.56);
3)hashes
   my %fruit_color = ("apple","red","banana","yellow");
   my %fruit_color =(apple=>"red",banana =>"yellow",);

Thursday, May 17, 2012

Maven project build problems

Having one maven project that build jar file need few minutes,each time when we need run the job from a ant script,we made change,then using maven build jar file,then using ant script pass job name as a parameter,then run the job.
this process is not efficiency because any small change need a rebuild jar file.
solution:
change ant script running target's classpath to include project/target/classes fold as a pathelement's path attribute,set project in eclipse build automatically,then make changes,eclipse will automatically build project(compile source code,copy resource into target/classes folder),we don't need to run maven job to compile and package jar file,run ant script directly, that will save amount of time.

looks like when we change java code,auto build is fast,but when we change a resource,builds are little slow.

Monday, April 30, 2012

start and shutdown jboss 4.3 EAP

start jboss AS is simplely involke a bat file or sh file,but shutdown need provide a user name and it's password save in server's props\jmx-console-users.properties file,like this

shutdown.sh -S -u admin -p admin

Friday, April 27, 2012

SAP DOCTYPE means


The document type is used for the following functions in General Ledger Accounting (FI-GL), Accounts Receivable (FI-AR), and Accounts Payable (FI-AP) components:
  • Differentiating the business transactions to be posted
All vendor invoices, for example, are posted using the same document type.
  • Controlling document storage
This is the main function of the document type. You must specify a number range for every document type. The original documents from a number range are stored together.
  • Posting invoices with the vendor net procedure
The document type determines whether or not the net procedure is used when posting a vendor invoice. With the vendor net procedure for posting, the system automatically subtracts cash discount from the corresponding offsetting entries when the document is posted.The document type is entered in the document header and applies to the whole document.
Document types are defined at client level. The standard system already contains document types which you can use or change.

search in cvs commited comments

worked for a while,just forget one of the change i made lost somewhere,need to find it out,
so nee to earch based on cvs commits comments,following command satisfy the request
cvs log -S -N 
it will list all comment,use a search tool,ot grep or give a -d parameter to limit the result

Thursday, April 26, 2012

JCO Connection Error while SAP server IP changes

while using SAP server's Name for JCO connection,suddenly got following errors


SAP_CMINIT3 : rc=20 > Connect to SAP gateway failed
Connect_PM  GWHOST=vmsapqa03, GWSERV=sapgw00, SYSNR=00

LOCATION    CPIC (TCP/IP) on local host
ERROR       partner 'vmsapqa03:3300' not reached
TIME        Wed Apr 25 09:41:03 2012
RELEASE     720
COMPONENT   NI (network interface)
VERSION     40
RC          -10
MODULE      nixxi.cpp
LINE        3286
DETAIL      NiPConnect2: 10.21.66.56:3300
SYSTEM CALL connect
ERRNO       10060
ERRNO TEXT  WSAETIMEDOUT: Connection timed out
COUNTER     1

it is not related to any code, it is the IP address been tied with the host name changed by network administrator,solution is using full name for the machine.,like vmsapqa03.groupname.com.

Monday, April 2, 2012

analyze the code to calculate key

004010B4 XOR EBX,EBX
004010B6 XOR ESI,ESI
004010B8 CMP DWORD PTR DS:[402173],13
004010BF JL SHORT ReverseM.004010F7
004010C1 MOV AL,BYTE PTR DS:[EBX+40211A]
004010C7 CMP AL,0
004010C9 JE SHORT ReverseM.004010D3
004010CB CMP AL,46
004010CD JNZ SHORT ReverseM.004010D0
004010CF INC ESI
004010D0 INC EBX
004010D1 JMP SHORT ReverseM.004010C1
004010D3 CMP ESI,7
004010D6 JL SHORT ReverseM.004010F7
004010D8 JMP ReverseM.00401205

Wednesday, February 29, 2012

Netbean Maven project include WS client code

Maven project in netbeans that include some webserivce client code reference to generated java code,but those code is not in classpath,so it cause error in IDE,but command clean package is OK.
put following code in pom.xml build-plugins

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-ws-source</id>
<phase>gernated-source</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/java-gen</source>
</sources>
</configuration>
</execution>
</executions>
<configuration>
</configuration>
</plugin>

Tuesday, February 28, 2012

access other user's table from sqldeveloper

while using sqldeveloper,we can only see the table belongs to the user logged in,
if you want access other user's table,you can use following method

1) right click the connection,then schema browser,so so can see other user's table
2)clik on "other users" below the connection,then user,then tables you want access

Wednesday, February 15, 2012

python code that crumble data for test

following code that read big data(fixed length) file,and scruble the specified columns data to create new data to test.

from random import randint

fa = open ('a.bbb','r')
fb = open ('b.txt','w')
i = 0
for line in fa:
i= i + 1
if(i!=1):
s = list(line)
if(len(s)>500 and s[300]!=' ' and s[300]!= ''):
print s[300] + s[301]
delta = str(int(s[300]+s[301]) + i/5000 + 1)
if (len(delta)>2):
delta = str(randint(10, 99))
x = list(delta)
if (len(delta)<2):
s[300]='0'
s[301]=x[0]
else:
s[300]=x[0]
s[301]=x[1]
print ' ---> ' + s[300] + s[301]
fb.write("".join(s))
else:
fb.write(line)
fa.close()
fb.close()

Python code that find the wrong data in huge data file

following code go though big data file find the line that data startwith letter "T"

fa = open ('a.bbb','r')
i = 0
for line in fa:
i= i + 1
if line.startswith('T'):
print i;
fa.close()

python code that separate 150000 records into 15 small files

fa = open ('b150000.txt','r')
n = 1
fb = open ('b-1.txt','w')
i = 0
for line in fa:
# 1 to 10000 for first 10001 to 20000 for second
if((i/10000 +1)!=n):
n=i/10000 + 1
fb.close()
fb = open('b-'+str(n)+'.txt','w')
fb.write(line)
i = i + 1
fa.close()
fb.close()

comments in ibatis sqlmap files

if you want put some comments in ibatis sqlmap file,you can not just like you did in sql -- two dash with comment.
you have to put all comments line this /*multiline comments */

Java 7 Diamond operator

List<String> strList = new ArrayList<>();
List<Map<String, List<String>> strList = new ArrayList<>();

Java 7 String switch

public class Test{
public static void main(String[] args){
System.out.println(monthNameToDays("March",2012));
}
public static int monthNameToDays(String s, int year) {
switch(s) {
case "April": case "June":
case "September": case "November":
return 30;
case "January": case "March":
case "May": case "July":
case "August": case "December":
return 31;
case "February":
return 28;
default:
return 0;
}
}
}