Thursday, May 29, 2014

Wednesday, May 28, 2014

SRM 521 DIV 1


 

MySolution 


public class MissingParentheses {
  
    int  missingNumber;
  
    public int countCorrections(String str){
        int leftCnt = 0;
        for(int i=0; i<str.length(); i++){
            if(str.charAt(i) == '('){
                leftCnt++;
            }else{
                if(leftCnt <=0){
                    missingNumber++;
                }else{
                    leftCnt--;
                }
            }
        }
        return leftCnt + missingNumber;
    }
}

 Problem Statement

     Given a string of parentheses, you must turn it into a well formed string by inserting as few parentheses as possible, at any position (you cannot delete or change any of the existing parentheses).
A well formed string of parentheses is defined by the following rules:
  • The empty string is well formed.
  • If s is a well formed string, (s) is a well formed string.
  • If s and t are well formed strings, their concatenation st is a well formed string.
As examples, "(()())", "" and "(())()" are well formed strings and "())(", "()(" and ")" are malformed strings. Given a String par of parentheses, return the minimum number of parentheses that need to be inserted to make it into a well formed string.

Definition

    
Class: MissingParentheses
Method: countCorrections
Parameters: String
Returns: int
Method signature: int countCorrections(String par)
(be sure your method is public)

Limits

    
Time limit (s): 2.000
Memory limit (MB): 64

Constraints

- par will contain between 1 and 50 characters, inclusive.
- Each character of par will be an opening or closing parenthesis, i.e., '(' or ')'.

Examples

0)
    
"(()(()"
Returns: 2
The string below is a possible well formed string you can get to by inserting the two closing parentheses marked.
(())(())
   ^   ^
1)
    
"()()(()"
Returns: 1
You can fix the string by inserting a single closing parenthesis at the end.
2)
    
"(())(()())"
Returns: 0
The input string is well formed, so no insertion is needed.
3)
    
"())(())((()))))()((())))()())())())()()()"
Returns: 7
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. 

Thursday, May 22, 2014

Using LazyLoad when you feel that you website is so so slow ~

Today I introduce Lazyload library that is made in javascript

basic pattern in html looks like below~

html
body
head
   script src='download.js'
   script src='hello.js'
 
/head
body
    div
    /div
/body
/html

if you call this webpage, you can see the fully loaded website after fully loading script and html tags,

that is html logic sequences, first script, second script, third script so on...
second script will be called after first script.

so if the website is huge or there are many script to be loaded.
people should wait more than they expected.


This Lazyload will make webpage fater than we think.

because we can controll to call scripts dynamically.

summary

1. dynamically loading script
2. script dependency
3. speed up when first website show

Monday, May 19, 2014

using ssh in mac OS

mac osx  ssh access


command)
    #ssh {userid}@{SERVER_IP}

방 알아볼때 유의사항 및 체크 사항

[부동산]
[ 집상태 체크 사항 ]
[  ] 근저당유무,건물종류
[  ] 집 위치 및 주변환경
[  ] 주차가능 여부        
[  ] 일조, 조망, 소음  체크 #남향#
[  ] 방상태 (크기.구조)
[  ] 화장실/욕실, 변기막힘  #물 세기, 녹묽#
[  ] 도배, 장판 , 천정(누수)상태
[  ] 방문, 창문 파손 여부, 방충망, 방범창 유무
[  ] 결로 , 습기 때문에 곰팡이 핀 곳은 없는지 체크
[  ] 개별난방여부, 보일러 작동이상 유무, 단열 상태
[  ] 가스, 전기상태
[  ] 수도-수압,온수,싱크대 배수
[  ] 관리비, 공과금 규모 체크
[  ] TV케이블,인터넷 전용선등 기타 시설 확인
[  ] 문고리, 열쇠 (새로하는게좋다.)

[※ 전세집 계약전 확인사항]
1) 등기부등본 확인 - 근저당이 설정된매물은아닌가?? + 주택용도 정상 등록된 건물?  ## 등기부 등본 확인 ###
2) 등기부상 소유자와 계약자(계좌주인)가 일치하나? - (토지 와 건물) 소유자확인  #### 물건의 소유주와 계약을 해야한다 ####
  - 등기부등본상 계약자가 동일인물인지, 집주소가 서류와 같은지 확인  ## 신분증 대조 ##
3) 뉴타운개발단지인가?? (향후지역개발변경등)
4) 잔금처리후 전입신고, 확정일자
1) 관리비와 세금(수도,가스,전기)처리는 ?
2) 유지보수처리는 시설물(수도,가스,보일러등)  ?
3) 계약서내 계약금,잔금의금액,지급일정과 임대차 기간명시.
4) 계약서에 시설(수도가스보일러등)관리책임에 대한 부분 기재.
5) 전세계약서 기타 세부사항 확인 ,  2년간?
6) 중개업자에게 중개물확인설명서요구(집의상태,소재지등의정보)
7) 중개 수수료는?

[※ 계약잔금처리 전. ]
 (1) 집상태 재확인
 (2) 등기부등본 재확인 - 변동사항 / 등기부상 소유자, 계약자(계좌주인) 확인 필!

[※ 계약잔금처리 후 ]
(1) 영수증 확인        
(2) 입주,전입신고 및 확정일자(or전세권)받기 (동사무소나 구청, 등기소)
(3) 등기부등본 재 확인
[대항력 : -전입신고 유지 , -확정일자 있는 계약서 보관 , -실제거주 유지]

※ [토지,건물에대한 확인 공부서류]
등기부등본(건물,토지), 토지대장, 가옥대장, 건축물관리대장, 도시계획확인원, 토지이용계획확인원 ,지적도

Sunday, May 11, 2014

Trello

I use This Website to communicate with my project Team.

this UI is very simple and the way to use is very easy so I like it.

Android clearly exit source

영어로 설명하려고 하다 보니깐 너무 어려워서 한글로 설명을 해야겠다.

내 현상 :
난 웹뷰를 사용하는 Application을 사용했는데 web에서 Browser의 accept-lanuguage의 값을 받아서 셋팅을 한다. 한국어 모드에서 어플리케이션을 종료하고 영어 모드로 변경하고 다시 어플을 실행했을때 웹뷰에서 예전의 값을 그대로 가지고 있는 현상이 발생되었다.
그 말은 즉, 어플리케이션이 정상적으로 완전 종료가 되지 않아서 프로세스가 완전 재실행되지 않고 웹뷰의 헤더값이 예전과 유지되는 현상이 있었다.

인터넷에서 찾아보니깐 어플리케이션을 종료하는 방법에는 여러가지가 있더라.
1. finish();

2. restartPackage

3. killBackgroundProcessor

4. killProcessor

5. System.exit(0)

마지막으로 아래와 같은 방법

테스트 결과 아래처럼 하는 방법이 제일 안전하고, 그리고 Webview의 내용이 정상적으로 재설정되었다.
아래 참조 링크 걸었는데 거기에 자세한 내용이 나온다.


final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
//stop running service inside current process. 
List<RunningServiceInfo> serviceList = am.getRunningServices(100);
for(RunningServiceInfo service : serviceList){
    if( service.pid == Process.myPid()){
        Intent stop = new Intent();
        stop.setComponent(service.service);
        stopService(stop);
    }
}
//move current task to background.
Intent launchHome = new Intent(Intent.ACTION_MAIN);
launchHome.addCategory(Intent.CATEGORY_DEFAULT); launchHome.addCategory(Intent.CATEGORY_HOME);
startActivity(launchHome);
//post delay runnable(waiting for home application launching) 
new Handler().postDelayed(new Runnable(){
    @Override public void run() {
        am.killBackgroundProcesses(getPackageName());
    }
}, 3000);




참조 :
http://blog.naver.com/PostView.nhn?blogId=huewu&logNo=110120532880