2012年11月29日 星期四

Top Field


1.

VIRT: Total amount of virtual memory used by the process
RES: physical memory which the process has used 
S - Process status - Possible values:
  • R - Running
  • S - Sleeping (may be interrupted)



Reference:
Top_field

2012年11月28日 星期三

illumina rna-seq insert size discussion

1. illumina say insert using 200-500 bp insert. Reference: illumina office

2. Someone say the peak of 180~190bp and (means the inserts shall be 60~70bp, Pair-End). Reference: Seq_Answer

3. a simple clear answer: Reference Biostart

2012年11月27日 星期二

Human sequence reference

1. Current there a human project hg19 and mean the grch37

2. As I found in google the hg19 is equal the grch37,
    but the hg19 is develop in UCSC
    Reference: UCSC hg19, UCSC_hg19_Statistic

3. And grch37 is develop in the genome reference consortium
    Reference: GRCH37

4.  Ensembl is a European project, but the version I didn't clear
        *Ensembl_Human_Annotation Genbank
        *EnsemblJ_Human_Annotation_GTF
        *Ensembl_FTP_Download_include_FASTA

2012年11月26日 星期一

How to set Java memory size

1.  What is the heap function in java ?
Java heap is the heap size allocated to JVM applications which takes care of the new objects being created. If the objects being created exceed the heap size, it will throw an error saying memoryOutof Boun.


2. Problem:
How to set the java memory? to avoid the OutOfMemoryException.
and how much is fit?


3. Solution:
A.How to set java memory
Memory usage = Stack Size + Heap Size + Code Size
  
-Xmsinitial java heap size
-Xmxmaximum java heap size


-Xssset thread stack size




B. How much is fit on your application?
IBM technical report say about head size

Size your Java heap so that your application runs with a minimum heap usage of 40%, and a maximum heap usage of 70%.


Reference:
IBM heap size advice
How to set java memory and debug
Java Memory Talk
what_is_java_heap_size

2012年11月21日 星期三

Boost Error boost/thread/detail/thread.hpp:43: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'

1. Problem:
My boost version is boost_1_49_0, and System is Centos6.3
its build step is following and
it will auto create the library in the /usr/local/lib,
and the include files in /usr/local/include/boost:
  • su -
  • ./bootstrap.sh
  • ./b2
  • ./b2 link=static runtime-link=static stage install

But when I use this information to compile my project,
it is happen the following error
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:4926: undefined reference to `boost::thread::join()'
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:4927: undefined reference to `boost::thread::~thread()'
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:5003: undefined reference to `boost::thread::join()'
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:5004: undefined reference to `boost::thread::~thread()'


It seems like the thread error.



2. Solution:
I find the google and the key point is
add the
 -lboost_thread-mt
to my gcc,
and then it will pass the problem.



Reference:
Boost Error Undefined


2012年11月16日 星期五

Struts 1.3 redirect function in login page

1. Problem: 

In my application,
I have a login.jsp and
authorize page need the user to login through this login,
then he will get the content of authorize page.

A general method
in struts-config.xml  file
<action path="/login" type="struts.action.LoginAction" scope="session" name="loginForm">

            <forward name="login" path="/login" />   
            <forward name="success" path="/loginSuccessPage" />
</action>
<action path="/anyAuthorizePage" type="struts.action.AuthorizeAction" scope="request" >
            <forward name="login" path="/login" />
            <forward name="anyAuthorizePageSuccess" path="/anyAuthorizePageSuccessPage" />
 </action>


And long as you type following page, and assuming session is timeout
                     http://localhost/anyAuthorizePage
the action is AuthorizeAction and because not login,
user will receive the login.jsp.

But when the user login,
according to the login action,
user will receive the loginSuccessPage,
not user expected the anyAuthorizePageSucccessPage.



2. Solution:

My solution conception is
let client way provide redirect url to LoginAction, 
and LoginAction use this redirect url to perform the redirection page.

The key point in my solution is client way, therefore I don't handle any session  this in anyAuthorizeAction. I only focus on the client way and LoginAction.
Another reason why I solve in client way is me observe that the



3. Example:

The technique contains the javascript to get the browseURL, struts action of redirect attribute. The following simple step is following:

A. Adding the webbrowse url filed on login.jsp

 
<script type="text/javascript">

/*將 user browserID */
function loginOnload() {
    writeBrowseUrlToForms();
}


/* 寫入 browse URL 到欄位中 */
function writeBrowseUrlToForms() {
   
    // 取得所有表單的 form, 因為 tagname 會回傳 array 
    elementsForms = document.getElementsByTagName("form");
   
    // 進入個別 form 取得個別欄位
    for (var intCounter = 0; intCounter < elementsForms.length; intCounter++)
    {
           writeBrowseUrlToForm(elementsForms[intCounter]);
    }
}

/*單一 URL */
function writeBrowseUrlToForm(currentForm) {

     var elementsInputs;
     var browseurl = document.location.href;
    
     // 取得所有輸入欄位 input, 但只在意 formposition 與 endPosition 兩個欄位
     elementsInputs = currentForm.getElementsByTagName("input");

     for (var intCounter = 0; intCounter < elementsInputs.length; intCounter++)
     {
           var inputFieldName = elementsInputs[intCounter].name;
           var inputFieldValue = elementsInputs[intCounter].value;
          
           if (inputFieldName == "browseurl")
           {
              elementsInputs[intCounter].value = browseurl;
           }
     }

}

/* 加入 Layout Onload 到事件中*/
// Namespace of login content
var login;

if (!login) {
    login = {};
}

login.oldOnload = window.onload || function() {};
window.onload = function () {
    login.oldOnload();
    loginOnload();
};

</script>
<html:form action="/login" >

<%-- hidden the url redirect, and on submit send to user --%>
<table id="login_table" style="border-collapse: collapse">
      
    <tr>
    <td>User Name</td>
    <td><html:text name="loginForm" property="name" size="20" /></td>
    </tr>
    
    <tr>
    <td>Password</td>
    <td> <html:password name="loginForm" property="password" size="21" /></td>
    </tr>
    
        
    <%-- Hiden redirect page --%>
    <tr>
     <html:hidden property="browseurl" value=""/>
    </tr>
    
    <tr> <td colspan="2" align="right">    <html:submit value="login"/></td>
    </tr>
    
    
    
</table>

</html:form>



 B. And LoginAction adding sendRedirect() method in LoginAction

public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
 
if (verifyUser(username, password)) {
           
          ....
       
            // 如果需要重導入功能
            ActionRedirect redirect = null;
            if ( (redirect = sendRedirect(request, loginForm.getBrowseurl(), mapping)) != null) {
                return redirect;
            }else {
                return mapping.findForward("success");
            }
        } 

}

}


    protected ActionRedirect sendRedirect(HttpServletRequest req, String needLoginPageURL, ActionMapping mapping) {
        ActionRedirect redirect = null;
       
        if (req == null || needLoginPageURL == null || needLoginPageURL.equals("")) {
            return redirect;
        }
        logger.info(needLoginPageURL);
       
        // 比對是否相同 host not by hack
         if (equalsHost(getThisFormUrl(req), needLoginPageURL)) {
           
             String contextPath = getContextPath(needLoginPageURL);
           
             if (contextPath != null) {
               
                 // 手動加入想要 login 內容
                 if (contextPath.contains("/authorizePage.do")) {
                     redirect = new ActionRedirect(mapping.findForward("
authorizePage"));
                 }
               
             } // end if path
         }
        return redirect;
    }



/** 需要 URL 網址 */
    protected String getThisFormUrl(HttpServletRequest req) {
        String reqUrl = req.getRequestURL().toString();
        String queryString = req.getQueryString();  
        if (queryString != null) {
            reqUrl += "?"+queryString;
        }
        return reqUrl;
    }



C. LoginForm.class add the browseurl

public class LoginForm extends ActionForm{
    private static final long serialVersionUID = 1L;
    private String name;
    private String password;
    private String browseurl;        // 如果需要從新導入可以使用
   
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getBrowseurl() {
        return browseurl;
    }
    public void setBrowseurl(String browseurl) {
        this.browseurl = browseurl;
    }
     
}

D. Setting the struts.xml Action
<action path="/login" type="struts.action.LoginAction" scope="session" name="loginForm">
            <forward name="login" path="/login" />   
            <forward name="success" path="/successLogin" />           
           <forward name="authorizePage" path="/authorizePaget.do" redirect="true" />
</action>



Reference
Struts_Action_Redirct
GET_Browse_URL
web_GET_URL

2012年11月13日 星期二

JSP or Struts simply show error page and exception inforamtion

1. Problem
In develop the web application by struts or jsp,
it has the requirement to show the error message,
but use the struts default exception handler method is complex to show data,
because it involve the bean, action setting for exception type.

I study the inline error page show and share it.


2. Solution
I use simple jsp handle object,
pageContext.exception and
pageContext.errorData


3. Example

Notice: if you use struts,
don't write the <global-exceptions> tag,
we will transfer the exception to the tomcat handle

A. in web.xml write
=============================================
<error-page>
        <error-code>404</error-code>
        <location>/error.jsp</location>
</error-page>
 
<error-page>
     <exception-type>java.lang.Throwable</exception-type>
      <location>/error.jsp</location>
</error-page>
=============================================



B. error.jsp
=============================================

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isErrorPage="true" %>
<html>
<head>
<title>Error Page</title>

 <style type="text/css">
h2{background:darkblue;color:white}
h3{background:darkblue;color:white}
.style1 {
    color: #66CCFF;
    font-size: x-large;
    font-weight: bold;
}
</style>


</head>
<body>
<span class="style1">Oops...</span><br>
<div>
A system error has occured. <br>
If the
problem persists, please report this information to the System Administrator.
</div>

<br/>
[<a href="./index.jsp">GoGack to index</a>]
[<a href="javascript:showDetails()">Show details</a> ]
[<a href="javascript:hideDetails()">Hide details</a> ]
<br/>


<table id="showDetailsLinkDiv" style="{display:none}"   cellspacing="0" width="100%" border="1">
 
    <tr valign="top">
        <td width="40%"><b>Error:</b></td>
        <td>${pageContext.exception}</td>
    </tr>
 
    <tr valign="top">
        <td><b>URI:</b></td>
        <td>${pageContext.errorData.requestURI}</td>
    </tr>
 
    <tr valign="top">
        <td><b>Status code:</b></td>
        <td>${pageContext.errorData.statusCode}</td>
    </tr>
 
    <tr valign="top">
    <td><b>Stack trace:</b></td>
    <td>
        <c:forEach var="trace"
                 items="${pageContext.exception.stackTrace}">
        <p>${trace}</p>
    </c:forEach>
    </td>
    </tr>

</table>

<script language="javascript">
   function showDetails() {
     document.getElementById("showDetailsLinkDiv").style.display = "inline";
   }
   function hideDetails() {
     document.getElementById("showDetailsLinkDiv").style.display = "none";
   }
</script>
</body>
</html>


=============================================


Reference:
http://geekexplains.blogspot.tw/2008/06/errorexception-handling-in-jsp-using.html

2012年11月12日 星期一

Eclipse problem: import ClassName cannot be resolved.

1. Problem:
  When I write a java web project a long times, and use the subversion case,
  It appear the import ClassName cannot be resolved. problem

2. Solution:
    I don't know the real reason. But I solve it by
    choose the project item of menu -> Clean function


Reference:
Many other solution
May be the reason

Javascript search string

1. Problem:
   There are kind of search string function in javascript. At first
   we can attract by  search() method, but when we use it to search dot "."  
   information such as judge the upload file is ".jpeg" suffix,  it will return 0.


2. Why:
   Because argument of search()  is regular expression, I avoid it and use
   indexOf() method replace it. And it will work correct


3. Example:
strA = "myPic.jpeg"
strA.search(".");
result: 0
strA.indexOf(".");
result: 5



Reference:
Like problem
string method

2012年11月8日 星期四

Eclispe change webapp name

Motivation. There are some step you can change your web app in eclispe

Step:
 1. open project
 2. click the mouse right button and choose the properties in the finally button
 3. choose  web project setting
 4. type the new in context root
 5. stop the server and remove the old project
 6. because the eclipse will change the web.xml file, and add the tag in   web.xml, so 1. you can copy old web.xml to this.  2. or delete this tag 


Encourage problem but can solve by my step especially the step 6 is important:
a. problem {java.lang.IllegalArgumentException: Can't convert}
b. 404 not find new appname


Eclipse store your  web application position:
/home/${yourname}/workspace2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps


Reference:
How to change eclipse webapp name?
How to fix the error of java.lang.IllegalArgumentException: Can't convert






2012年11月6日 星期二

Get DIV Height

1 Problem:
   Sometimes you should make the layout in html using the css,
   and first should get the height from two div,
   the often use js code offsetHeight property,
   but it can't the real the height??


2. Reason:
    Because the offsetHeight didn't contain the margin height
     [offsetHeight property useage]
  Returns the height of the visible area for an object, in pixels. The value   contains the height with the padding, scrollBar, and the border, but does not include the margin.


3. solution:
    add the maring, but you should reference how to get margin top value

/* Get the div offsetHeight value*/
function getDivHeight(divIdName) {
    var div = document.getElementById(divIdName);
    var divHeight = 0;
   
    if (div){
        divHeight =  div.offsetHeight;
    }
     
    return divHeight;
}

/* I didn't know now to get the css top margin */
function getMainTopMarginHeight() {
    return 70;  /* Fix the content values*/
}


var mainBlockHeightTopMargin =  getDivHeight("main") +  getMainTopMarginHeight();


Reference





2012年11月4日 星期日

GNOME panel restart in centos

GNOME panel restart
1. problem:
sometimes you will unfortunately to close the gnome panel, may be it disappear or delete by you

2. solution:
a. remove the setting files
mv ~/.gnome2 /tmp
mv ~/.gconf /tmp /tmp
b. restart the pc
reboot

Iimage align text bottom

1. Problem: when you bind the text and image, the image can effect the line-height such that the image bottom is high the text bottom.

2. solution: setting the imge css property
 img { vertical-align: middle; }

Refereence:
http://stackoverflow.com/questions/5021676/vertical-align-img-and-text-within-li

Get rid of iframe boarder

1. problem: Although the iframe is not support in future, but some time you can see it. And in IE the iframe will have the border in white color,
you can eliminate it by

2. solution::
frameborder="0"

Multiple method on onload

1. Problem:
we can do something in window.load position such as arrange the layout,
but there are only one method in this window.onload function.


2. Solution
we can store the previous onload method,
and build a new anomyous function which put the old_onload_method,
adding the new load_method.

var oldOnload = window.onload || function () {};
window.onload = function ()
{
    oldOnload();
    // Do Something...
}

Reference:
http://www.jaceju.net/blog/archives/160/

CSS span width

CSS span width

1. problem:
span didn't support the width property in span, or inine tag

2. solution:

span {
  background-color:#ffcc00;
  display:-moz-inline-box;
  display:inline-block;
  width:150px;
}



refrence:
http://www.blabla.cn/css_kb/html_span_width_kb.html

CSS table align

1.  This is a simple solution, but in IE didn't work, you can see the reference for
more technique.

2. Solution::
  .center {
    margin-left:auto; 
    margin-right:auto;
  }


Reference:
http://www.granneman.com/webdev/coding/css/centertables/

2012年11月1日 星期四

Unicode and 全形字元 在 html

1. What is Unicode HTML ?
when you type the other nature characte, you can use unicode in html


2. How to use ?
you type a set of &#AABB;  in this AABB is the unice code number, and &#; is the encolse around the char.


3. Example
,  is the , symbol

Reference: