Sunday, August 28, 2011

Ubuntu指令, 設定

開啟具root權限的視窗
sudo nautilus

執行32位元程式,需要安裝ia32-libs。執行adb的時候出現no such file or diretory,才發現64不能直接跑
apt-get install ia32-libs
會安裝lib32asound2, lib32bz2-1.0, lib32gccl, lib32gccl, lib32ncurse5, lib32ncursesw5, lib32stdc++6, lib32v41, lib32zl, libc6-i386

vi預設無法使用backspace
home/xxx/.vimrc or /etc/vim/vimr
加入
set nocompatible
set backspace=2

apt-get install vim-full

Monday, April 4, 2011

Xpath with prefix

XML file:

<ns:authenticateResponse xmlns:ns='http://webservices.surfbi.fcs.com'>
   <ns:return xmlns:ax27='http://exception.surfbi.fcs.com/xsd' xmlns:ax210='http://dto.surfbi.fcs.com/xsd' type='com.fcs.surfbi.dto.UserDTO'>
      <ax210:first_name>SurfBI</ax210:first_name>
    </ns:return>
</ns:authenticateResponse>



java程式碼, 在使用Xpath時要用xpath.setNamespaceContext()設定Namespace。

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true); 
DocumentBuilder builder = domFactory.newDocumentBuilder();
 
InputStream is = new ByteArrayInputStream(xmlInput.getBytes("UTF-8"));
Document doc = builder.parse(is);
            
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
xpath.setNamespaceContext(new FCSNamespaceContext());
 
String nil = xpath.evaluate("//ns:authenticateResponse/ns:return/@xsi:nil", doc);
XPathExpression expr = xpath.compile("//ns:authenticateResponse/ns:return/ax210:first_name");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;
 for (int i = 0; i < nodes.getLength(); i++) {
 
  String test = nodes.item(i).getTextContent();
 }



NamespaceContext

public class FCSNamespaceContext implements NamespaceContext{
    public String getNamespaceURI(String prefix)
    {
        if (prefix.equals("ns"))
            return "http://webservices.surfbi.fcs.com";
        else if (prefix.equals("ax210"))
            return "http://dto.surfbi.fcs.com/xsd";
        else if (prefix.equals("ax27"))
            return "http://exception.surfbi.fcs.com/xsd";
        else if (prefix.equals("xsi"))
            return "http://www.w3.org/2001/XMLSchema-instance";
        else
            return XMLConstants.NULL_NS_URI;
    }
    
    public String getPrefix(String namespace)
    {
        if (namespace.equals("http://webservices.surfbi.fcs.com"))
            return "ns";
        else if (namespace.equals("http://dto.surfbi.fcs.com/xsd"))
            return "ax210";
        else if (namespace.equals("http://exception.surfbi.fcs.com/xsd"))
            return "ax27";
        else if (namespace.equals("http://www.w3.org/2001/XMLSchema-instance"))
            return "xsi";
        else
            return null;
    }
 
    public Iterator getPrefixes(String namespace)
    {
        ArrayList list = new ArrayList();
        
        if ( namespace.equals( "http://webservices.surfbi.fcs.com")) {
          list.add( "ns");
        } else if ( namespace.equals( "http://dto.surfbi.fcs.com/xsd")) 
            list.add( "ax210");
        
      
        return list.iterator();
 
    }
}

Friday, March 11, 2011

美國找軟體開發工作

到美國幾個月了,景氣很差,整理一下工作種類。由於是到了美國才開始找工作,遇到的問題不少,首先是工作簽證,再過來是開始工作,該不該因工作搬家,總之問題很多。我把工作種類分成三種:
1. 知名大公司,例如MS, Google, IBM,….
    大公司的面試流程長,投履歷,電話面試幾次,在過來現場面試。現場面試會再細分不同的面試官,等等都通過,在過來還有簽證申請流程,等開始進辦公室上班,可能要花上幾個月時間。不過大公司資源多,錄取後,在簽證方面公司會請律師幫忙辦到完。之後也較容易幫忙申請綠卡。再來大公司求職者多,面試機會不容易取得,面試由於有好幾次,所以難度也較深,面試者較有時間談的深入。

2. 規模較小的公司。可能是剛起步但營收跟成長率都很好,也有可能真的就一家小公司。這方面需要多做功課才會知道公司狀況。規模小,面試流程也稍快,不過至少HR面試,工程師/部門經理面試,現場面試這些還是都有的。簽證這方面就要看公司,可能會有公司要錄取者赴簽證費用,也可能連申請都不幫忙申請,另外綠卡也不一定會有,錄取後要問一下HR。

3. 短期工作。市場上幾乎都是這種工作,如果不是有人幫忙推薦的話,直接到工作網站另如linkedin, careerbuilder等,幾乎都是短期工作,從2 個月到1年不等。有可能是在知名大公司上班,但大部分都是小公司。這種工作也幾乎都是透過人力仲介(recruiter, consulting, staff…名稱不一樣但是都是做一樣的事情),由仲介推薦候選者給公司選,有的公司可能直接現場面試,有的也是先電話面試,之後在現場面試。這種工作公司不可能發簽證,但是可以問仲介,仲介反而很容易幫忙申請簽證。原因是甚麼勒?  因為幫你申請簽證後,你就是仲介的員工,工作的公司會發薪水給仲介公司,仲介公司再發給你,當然仲介公司可以抽成,至於抽幾成就看仲介公司有沒有良心了…。有的黑心仲介會抽到4~5成。這還是你有在上班的情況,當你的短期工作結束,在找到下一個短期工作之間的期間,黑心仲介是不發薪水的。所以你有工作他就賺錢,你沒工作他也沒虧錢,所以仲介公司很高興給你簽證。

最近都在面試,也多少知道一些美國公司的狀況,希望再找工作的人,都能找到好工作

Asurion interview(write a code sample)

THe hiring procedure includes HR interview, Engineer interview, write three codes. I just descript 3 code questions and my answer below.

1. Write a function in JAVA, which input a int array and return a int. The result int  means one of the index of array. The index let the sum of left side equal with right side. The function can find a index. For example, intput a array{-1, 7, 3, 2,4} and result is 2. becasue array[2] = 3. The left side is –1+7 = 6. The right side is 2+4=6.

private int equi(int[] A){
   int left=0;
   int right = 0;
   int k=0;
   if(A.length ==1){
      return 0;
   }
 
   for(int i=1; i<A.length; i++){
       right += A[i]; 
    }
   for(int i=0; i< A.length; i++){
       if(left == right){
            return k;
       }
       left +=A[i];
       right = right-A[i+1];
       k=i+1;
     }
     return -1;
}



2. Write a function in JAVA. The function should find a gap in the binary array……

private int binary_gap(int n){
   Integer integer = new Integer(n);
   String binaryString= integer.toBinaryString(n);
   int length = binaryString.length();
   int gap=0;
   int gap_Max=0;
   for(int i=0; i<length; i++){
      if(binaryString.substring(i, i+1).equals("0")){   
         gap++;
      }else{
         if(gap>gap_Max){
            gap_Max = gap;
         }
         gap=0;
      }
   }
   return gap_Max;
}


3. write a function in Javascript. Input is a string. For example,
’asurion’
0 –> ’asurion’
1 –>’suriona’
2 –>’urionas’
3 –>’rionasu’
4 –>’ionasur’


function cyclic_automorphisms(ori) {
        var temp = ori;
        var automorphisms=0;
        for (i = 1; i < ori.length; i++) {
            temp = ori.substring(i, ori.length) + ori.substring(0, i);
            if (ori.match(temp) == ori) {
                automorphisms = i-1;
            }
        }
        return automorphisms;
 }

Friday, November 26, 2010

window7 使用者資料夾權限

進入使用者下的目錄如: Application Data, Local Settings等 會出現"無法存取,存取被拒",解決方法有二
第一種. 調整目錄的傭有者,預設是"system",調整為目前的使用者即可
資料夾上按右鍵,選"內容"->"安全性","進階"–>"擁有者"
第二種. 把everyone從目錄安全性內中刪除

Tuesday, May 25, 2010

subversion安裝使用

1. apache註冊為windows service
C:\Program Files\Apache Software Foundation\Apache2.2\bin>httpd.exe -k install

2. 分支
參考http://blog.yam.com/keithmin/article/8360958
http://blog.miniasp.com/category/Subversion.aspx

一般講到分支都會以trunk, tags, branches這三個名詞來解釋,但建立一個repository後,repository不會包含了trunk, tags, branches等三個虛擬目錄,之後在說一下怎麼建立,不過建起來後這三個目錄是包含在svn的DB中,在repository的file system中是看不到的。

httpd.conf的配置

   1: <Location /svn>


   2:     DAV svn


   3:     SVNParentPath "D:\projects"


   4: </Location>








專案區的配置



image















































先由專案區的trunk複製到repository的branches





Copy D:\test\trunk to http://localhost:8080/svn/project01/branches/kkk-branch


在TortoiseSVN中就是點選”branch/tag” 就會執行copy這個指令了,要注意的是branches這個虛擬目錄還未建立,這點我沒注意到,一直出現 '/svn/project01/!svn/bc/10/branches' path not found。可以用Copy D:\test\trunk to http://localhost:8080/svn/project01/branches 先建立了branches這個虛擬目錄,或是在Repository Browser中create director,在重新輸入Copy D:\test\trunk to http://localhost:8080/svn/project01/branches/kkk-branch,才建立好分支。




建立好分支後,再照著上面兩個參考網址,作就差不多。



選擇merge時,在tortoise中有三種type:

1. merge a range of revisions: 從trunk update至branch


2. reintegrate a branch: 把branch合併至trunk


    From URL: 填入branch的repository的位置


    working copy: 則是 trunk的工作區位置


3. merge two different trees:

Friday, May 21, 2010

windows 遠端連線

使用同一個帳號,不同電腦登入時會是兩個不一樣的環境,切換方法
1. run-> taskmgr –>“使用者” , 可以看到目前的使用者有哪些
    右鍵->連線,即可讓畫面切換過去

2. run->tsadmin, 可以看到目前的使用者有哪些
    右鍵->連線,即可讓畫面切換過去

不管是切換畫面或是強制登出都可以用這兩個指令