Monday, November 10, 2014

delete from middle of the file to beginning of the file

vggx
To delete from the current position to the beginning of the file.

Friday, September 5, 2014

special count in a text file

here is the search need to be done in beginning of the file
grep -a "^D" NCFPAY.TXT

here is the seatch need to be done at end of line

grep -a "TEXT$" NCFPAY.TXT

count the empty line

grep -a "^$" NCFPAY.TXT

there is more from http://www.thegeekstuff.com/2011/01/regular-expressions-in-grep-command/


Thursday, August 28, 2014

Monday, August 25, 2014

Friday, August 22, 2014

the errors sign in eclipse confuse developers

some time,we saw the class and method we reference in eclipse,but the eclipse still shows a error sign in that class or method.
the problem is the order of class path.
try to move the java generated code up to top,make sure it is before the class that reference them.
error sign should go away.

Tuesday, August 19, 2014

database lock check

when doing a database lock check of oracle database, we need check following sys tables.

v$active_session_history as a
v$sql as s

join by sql_id
a.user_id <> 0 will exclude SYS user.
a.sample_time to check the data and time.
a.blocking_session is not null


Wednesday, July 30, 2014

Install JDK from command line

jdk-8u11-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature" INSTALLDIR=D:\Java8\jdk1.8.0_11

Tuesday, July 22, 2014

Quartz job run time overlapped solutioon

normally when we schedule a job,we expected that when job started when at second scheduled time,the first run before this run is not finished,two process will have some time overlapped,this could cause data in db not consistent.

the solution is make job stateful, next run will wait for first run to finished.

public xxxxxJob extends QuartzJobBean implements ApplicationContextAware,StatefulJob{
}

interface StateFulJob is the key here.

Friday, June 20, 2014

Adding CBC radio into foobar2000

open foobar2000,from menu file --> add Location.
put following into the address:
http://playerservices.streamtheworld.com/pls/CBC_R1_TOR_H.pls

Tuesday, June 17, 2014

JBOSS WEB ACCESS LOG CONFIG

in Jboss server folder /deploy/jbossweb.sar,file server.xml

find tag valve with following attributes

classname="org.apache.catalina.valves.AccessLogValve"
directory="${jboss.server.log.dir}"
filedateformat="yyyy-MM-dd"
pattern="%{rl_client_ip}i %h %l %u %t "%r" %s %b %D"
prefix="${jboss.server.name}_access."
resolvehosts="false"
suffix=".log" valve

pattern is explained as following:

  • %a - Remote IP address
  • %A - Local IP address
  • %b - Bytes sent, excluding HTTP headers, or '-' if no bytes were sent
  • %B - Bytes sent, excluding HTTP headers
  • %h - Remote host name
  • %H - Request protocol
  • %l - Remote logical username from identd (always returns '-')
  • %m - Request method
  • %p - Local port
  • %q - Query string (prepended with a '?' if it exists, otherwise an empty string
  • %r - First line of the request
  • %s - HTTP status code of the response
  • %S - User session ID
  • %t - Date and time, in Common Log Format format
  • %u - Remote user that was authenticated
  • %U - Requested URL path
  • %v - Local server name
  • %D - Time taken to process the request, in millis
  • %T - Time taken to process the request, in seconds
  • %I - current Request thread name (can compare later with stacktraces)
In addition, the caller can specify one of the following aliases for commonly utilized patterns:
  • common - %h %l %u %t "%r" %s %b
  • combined - %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"
There is also support to write information from the cookie, incoming header, the Session or something else in the ServletRequest.
It is modeled after the apache syntax:
  • %{xxx}i for incoming headers
  • %{xxx}o for outgoing response headers
  • %{xxx}c for a specific cookie
  • %{xxx}r xxx is an attribute in the ServletRequest
  • %{xxx}s xxx is an attribute in the HttpSession

Tuesday, May 20, 2014

java mail failed with connection denied from ,ail server



add following parameter to JVM globle or put it in maven batch file



-Djava.net.preferIPv4Stack=true

check the possibilities that plugun could be upgrade

mvn versions:plugin-updates-report 

Tuesday, May 13, 2014

Android app for java developer

http://pan.baidu.com/s/1kqHMa

Friday, April 4, 2014

delete block of content in VIM

capital V mark the start of block,move cursor to end of block, delete block with x or d,
if you want delete to end if file,use capital G move cursor to end of file,the x or d delete

hang linux terminal

ctrl+s will hang linux terminal,and ctrl+Q will resume it.

three important signals in linux

The 3 most important "kill" signals on the Linux/UNIX command line

Most Linux or UNIX users know that there is a kill(1) command to stop processes, but what are the options, what do they mean?
These options are called signals, which can be expressed in either numbers or words. Some known once are "-1" or "-HUP". Also well known is "-9" (aka "-KILL")
  • -1 or -HUP - This argument makes kill send the "Hang Up" signal to processes. This probably originates from the modem/dial-in era. Processes have to be programmed to actually listen to this process and do something with it. Most daemons are programmed to re-read their configuration when they receive such a signal. Anyway; this is very likely the safest kill signal there is, it should not obstruct anything.
  • -2 or -SIGINT - This is the same as starting some program and pressing CTRL+C during execution. Most programs will stop, you could lose data.
  • -9 or -KILL - The kernel will let go of the process without informing the process of it. An unclean kill like this could result in data loss. This is the "hardest", "roughest" and most unsafe kill signal available, and should only be used to stop something that seems unstoppable.
  • -15 or -TERM - Tell the process to stop whatever it's doing, and end itself. When you don't specify any signal, this signal is used. It should be fairly safe to perform, but better start with a "-1" or "-HUP".

Thursday, April 3, 2014

perl private variables

Private Variables in a Subroutine:

By default, all variables in Perl are global variables which means they can be accessed from anywhere in the program. But you can create private variables called lexical variables at any time with the my operator.
The my operator confines a variable to a particular region of code in which it can be used and accessed. Outside that region, this variable can not be used or accessed. This region is called its scope. A lexical scope is usually a block of code with a set of braces around it, such as those defining the body of the subroutine or those marking the code blocks of if, while, for, foreach, and eval statements.
Following is an example showing you how to define a single or multiple private variables using my operator:
sub somefunc {
   my $variable; # $variable is invisible outside somefunc()
   my ($another, @an_array, %a_hash); # declaring many variables at once
}

pass parameter into perl sub fucntion

Passing Arguments to a Subroutine:

You can pass various arguments to a subroutine like you do in any other programming language and they can be acessed inside the function using the special array @_. Thus the first argument to the function is in $_[0], the second is in $_[1], and so on.
You can pass arrays and hashes as arguments like any scalar but passing more than one array or hash normally causes them to lose their separate identities. So we will use references ( explained in the next chapter ) to pass any array or hash.

perl language variables

We have learnt that Perl has following three basic data types:
  • Scalars
  • Arrays
  • Hashes
Accordingly we are going to use three types of variables in Perl. A scalar variable will precede by a dollar sign ($) and it can store either a number, a string, or a reference. A array variable will precede by sign @ and it will store ordered lists of scalars. Finally Hash variable will precede by sign % and will be used to store sets of key/value pairs.
Perl maintains every variable type in a separate namespace. So you can, without fear of conflict, use the same name for a scalar variable, an array, or a hash. This means that $foo and @foo are two different variables.


perl test console

perl -d -e 1
last one is number "1", not letter "l".

find current shell

ps -p $$

Wednesday, April 2, 2014

delete more line from vim

upper V,then upper G go to end of file,then x,it will delete filr content
or rm file,then touch to create a new empty file.

grep binary or hex search

grep -P "\x1A" file_name

for VIM  use /\%x1A or /\%x1a, "\%1A" is search pattern

Wednesday, March 5, 2014

Monday, March 3, 2014

JCO trace

SAP JCo offers two different ways to write trace files.
    1. Set the two options -Djco.trace_level= -Djco.trace_path= when you start the JVM.
    2. Call the methods JCO.setTracePath(String directory_of_trace_files) and JCO.setTraceLevel(int trace_level) in your Java program.

In both cases files of signature JCO*.trc are created in the defined directory directory_of_trace_file. The quantity of log information can be adjusted with the trace level. The additional logging that is switched on for certain trace levels is described below. For error diagnostic the trace level 5 is recommended.
  • 0: no trace files are written
  • 1: logging of the SAP JCo Java API is switched on
  • 3: logging of the SAP JCo JNI API is switched on
  • 5: important information for error diagnostic is switched on