티스토리 툴바


Hacker's Daily Conversation Practice

Q: How would you like to pay for this?
A: with the credit card / in cash 
What is the total? They come $29.50.
I don't seem to have it on me.

I would like to report my credit card lost.
 
I'm feeling very ill now.
Please give me some first aid.
First aid: 응급처치
Some first aid: 구급약

used to do와 be used to sth
used to do: ~하는 것에 익숙했었다.(끝난 과거)
be used to sth: ~에 익숙하다.(현재)
I used to smoke, but I gave up a couple of years ago.
We are used to the noise from the traffic now.
I'm used to getting up early.  (NO "I'm used to get up early")
You'll soon get used to his sense of humour.
"didn't use to" in AM, "used not to" in BR

think / believe / feel / reckon / be under the impression / be of the opinion(FORM)
think: usually MY thought
believe: usually OTHER's thought, or my SUBJECTIVE thought about TRUTH, BELIEF, PROBABILITY...
Do you think they'll come?
Police believe that the man may be armed.
We felt we were unlucky to lose.
USAGE
to firmly think / believe / feel / be under the impression / be of the opinion
to mistakenly think / believe / feel / be under the impression
to sincerely think / believe / feel / hold
to strongly feel / be of the opinion

I'd like a flight to Seoul, please.
For economy class, we can quote you a price of $850.
quote
REPEAT EXACT WORD
quote sb on sth
quote sth from sb/sth
He quoted a passage from the minister's speech.
Don't quote me on that.
GIVE PRICE
They quoted us 800 pounds for the installing a shower unit.

How often are your flight to Seoul?
Would you like an aisle or window seat?
How many seats are available for the Friday flight?
I would like to check out now.
Would it be possible to get an itemized bill? 

leave 떠나다
leave sth ~에서 떠나다
leave sb ~에게서 떠나다
leave sth ~을 미루다, ~을 두고 오다, ~을 (결과로) 남기다 ~을 그대로 두다
be left 남다
저작자 표시
Posted by 배트
This code is based on Apache common library.
If you are able to use the library, I recommend it. :-)

private boolean contentEquals(File file1, File file2) throws IOException {

    boolean file1Exists = file1.exists();

    if (file1Exists != file2.exists()) {

        return false;

    }


    if (!file1Exists) {

        // two not existing files are equal

        return true;

    }


    if (file1.isDirectory() || file2.isDirectory()) {

        // don't want to compare directory contents

        throw new IOException("Can't compare directories, only files");

    }


    if (file1.length() != file2.length()) {

        // lengths differ, cannot be equal

        return false;

    }


    if (file1.getCanonicalFile().equals(file2.getCanonicalFile())) {

        // same file

        return true;

    }


    FileInputStream fileStream1 = new FileInputStream(file1);

    FileInputStream fileStream2 = new FileInputStream(file2);


    BufferedInputStream bufferedStream1 = new BufferedInputStream(fileStream1);

    BufferedInputStream bufferedStream2 = new BufferedInputStream(fileStream2);


    int ch = bufferedStream1.read();

    while (-1 != ch) {

        int ch2 = bufferedStream2.read();

        if (ch != ch2) {

            return false;

        }

        ch = bufferedStream1.read();

    }


    int ch2 = bufferedStream2.read();


    bufferedStream1.close();

    bufferedStream2.close();


    return (ch2 == -1);

}



저작자 표시
Posted by 배트
조금 재미있긴 했는데 업무 시간에 너무 딴짓 했네.

<html>

<head> 


<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=euc-kr"> 


<title>Layer Test</title>


<script language="JavaScript"> 


var newArticleDivId = "write_article_layer";

var newArticleUrl = "http://www.naver.com/";

var minimumMargine = 50;

var maximumWidth = 800;


/*

 * openLayeredDialog

 * 레이어에 떠 있는 iFrame을 웹 페이지에 표시한다.

 */

function openLayeredDialog() {

    // 배경이 되는 반투명 레이어를 생성한다.

    var div1 = document.createElement("DIV");

    div1.id = newArticleUrl;

    div1.onclick = function () {closeLayeredDialog(false);};

    div1.style.position = "absolute";

    div1.style.height = "100%";

    div1.style.width = "100%";

    div1.style.top = "0";

    div1.style.left = "0";

    div1.style.background = "#000000";

    div1.style.opacity = "0.6";

    div1.style.filter = "alpha(opacity=60)";

    

    // iFrame을 담는 레이어를 생성한다.

    var div2 = document.createElement("DIV");

    div2.id = newArticleDivId + "_inner";

    div2.style.position = "absolute";

    div2.style.background = "#ffffff";

    

    // iFrame을 생성한다.

    var iframe1 = document.createElement("IFRAME");

    iframe1.src = newArticleUrl;

    iframe1.frameborder = "0";

    iframe1.style.height = "100%";

    iframe1.style.width = "100%";

    

    // 앞서 생성한 Element들을 웹 페이지에 추가한다.

    div2.appendChild(iframe1);

    document.body.appendChild(div1);

    document.body.appendChild(div2);

    

    // 레이어의 크기를 조정한다.

    adjustmentLayeredDialog();

    

    // 웹브라우저의 크기를 조절할 때 발생하는 이벤트의 핸들러를 등록한다.

    window.onresize = function(event) {adjustmentLayeredDialog();};

}


/*

 * closeLayeredDialog

 * 레이어를 제거한다.

 * 인자 normalClose가 true라면 Confirm 대화 창을 표시한다.

 * 인자 normalClose가 false라면 Confirm 대화 창을 표시하지 않는다.

 */

function closeLayeredDialog(normalClose) {

    // Confirm 대화 창을 표시한다.

    if (!normalClose) {

        willClose = confirm("이 페이지에서 나가면 작성하던 내용들은 저장되지 않습니다.\n정말 나가겠습니까?");

    } else {

        willClose = true;

    }

    

    // 레이어를 제거한다.

    if (willClose) {

        var child_background = document.getElementById(newArticleDivId);

        var child_inner = document.getElementById(newArticleDivId + "_inner");

        

        if (child_background) {

            document.body.removeChild(child_background);

        }

        if (child_inner) {

            document.body.removeChild(child_inner);

        }

        

        // 레이어를 제거하며 웹브라우저의 크기를 조절할 때 발생하는 이벤트의 핸들러도 제거한다.

        window.onresize = null;

    }

}


/*

 * adjustmentLayeredDialog

 * 레이어를 크기와 위치를 조정한다.

 */

function adjustmentLayeredDialog() {

    var child_inner = document.getElementById(newArticleDivId + "_inner");

    if (child_inner) {

        var clientHeight = document.body.clientHeight;

        var clientWidth = document.body.clientWidth;

        var top = minimumMargine;
        var left = 0;

       

        var height = clientHeight - minimumMargine * 2;

        var width = clientWidth - minimumMargine * 2;

        

        if (width > maximumWidth) {

            width = maximumWidth;

        }

            

        left = (clientWidth - width) / 2;

    

        child_inner.style.height = height;

        child_inner.style.width = width;

        child_inner.style.top = top;

        child_inner.style.left = left;

    }

}


</script> 


</head> 


<body>


<a href="javascript:openLayeredDialog();">레이어 보이기</a>


</body>

</html>

 
저작자 표시
Posted by 배트
성능은 보장 못해도 완전 심플하다 ㅋㅋㅋ

출처: Simple Implementation of Wildcard (*) Text Matching using Java
http://www.adarshr.com/papers/wildcard

/**
 * Performs a wildcard matching for the text and pattern 
 * provided.
 * 
 * @param text the text to be tested for matches.
 * 
 * @param pattern the pattern to be matched for.
 * This can contain the wildcard character '*' (asterisk).
 * 
 * @return <tt>true</tt> if a match is found, <tt>false</tt> 
 * otherwise.
 */

public static boolean wildCardMatch(String text, String pattern)
{
    // Create the cards by splitting using a RegEx. If more speed 
    // is desired, a simpler character based splitting can be done.
    String [] cards = pattern.split("\\*");

    // Iterate over the cards.
    for (String card : cards)
    {
        int idx = text.indexOf(card);
        
        // Card not detected in the text.
        if(idx == -1)
        {
            return false;
        }
        
        // Move ahead, towards the right of the text.
        text = text.substring(idx + card.length());
    }
    
    return true;
}

저작자 표시
Posted by 배트
// this code is just sample. not function form.
// just a reference!

const unsigned char pKey[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

const unsigned char pIn[] = {0,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc,0xd,0xe,0xf};
unsigned char pCipher[16] = {0,};
unsigned char pPlain[16] = {0,};

{
    /**
    * AES ECB Encryption
    *
    * @param pKey 128bit key
    * @param pIn 128bit plain input
    * @param pCipher (output) 128bit cipher output
    * @return true/false
    */
    AES_KEY stKey;
    memset(&stKey, 0, sizeof(AES_KEY));
    if(AES_set_encrypt_key(pKey, 128, &stKey)<0)
        return false;
    AES_ecb_encrypt(pIn, pCipher, &stKey, AES_ENCRYPT);
    //return true;
}

{
    /**
    * AES ECB Decryption
    *
    * @param pKey 128bit key
    * @param pCipher 128bit cipher input
    * @param pPlain (output) 128bit plain output
    * @return true/false
    */
    AES_KEY stKey;
    memset(&stKey, 0, sizeof(AES_KEY));
    if(AES_set_decrypt_key(pKey, 128, &stKey)<0)
        return false;
    AES_ecb_encrypt(pCipher, pPlain, &stKey, AES_DECRYPT);
    //return true;
}
저작자 표시
Posted by 배트
TAG OpenSSL
public static void printCurrentStackTrace() {
    try {
        StackTraceElement[] cause = Thread.currentThread().getStackTrace();
        if(cause==null || cause.length==0)
            return;

        // 1st stack is skipped
        for( int i=0 ; i<cause.length ; i++ ) {
            if(i==1)
                continue;
            System.err.println(cause[i].toString());
        }
    } catch(SecurityException e) {
        e.printStackTrace();
        return;
    }
}

public static void printErrorAndStackTrace(String err) {
    System.err.println(err);
    
    try {
        StackTraceElement[] cause = Thread.currentThread().getStackTrace();
        if(cause==null || cause.length==0)
            return;

        // 1st stack is skipped
        for( int i=0 ; i<cause.length ; i++ ) {
            if(i==1)
                continue;
            System.err.println(cause[i].toString());
        }
    } catch(SecurityException e) {
        e.printStackTrace();
        return;
    }
}
저작자 표시
Posted by 배트

Rules of JAVA Exception

by Junseok Oh

 

1.     간단한 기능을 하는 메소드는 굳이 예외를 발생시키지 않고, C와 유사하게 boolean 형 또는 에러코드를 의미하는 int 형을 반환한다. (하지만 에러코드를 정의하는 게 비효율적일 수 있다.)

2.     boolean/int 반환 메소드에서 Exception이 발생 시, error stack을 출력하고 해당 Exception에 해당하는 적절한 값을 리턴한다. (C 스타일)

3.     Exception은 메소드의 기능과 문맥에 맞는 다른 Exception으로 변환/추상화한다.
발생한 Exception에 해당하는 기능이 메소드에 암시되어 있다면, 그대로 bypass한다.

4.     제작하는 메소드가 다른 메소드의 기능을 얇게 추상화한다면, 모든 Exception bypass하게 throws Exception으로 정의할 수 있다.
boolean
을 반환할지, bypass 할 지는 메소드의 기능이 critical한지 trivial한지에 따라 달라진다. 발생할 수 있는 Exception의 종류를 기준으로 삼지 않는다.

5.     파일 입출력을 암시하는 메소드 안에서 발생하는 IOException bypass한다.
하지만 메소드의 문맥에 따라 IOException을 다른 Exception으로 변환한다.

6.     Exception을 던지는 경우, 되도록 Java에 정의되어 있는 표준 Exception을 사용한다.

7.     비록 귀찮더라도 너무 많은 코드를 try문으로 감싸는 것은 지양한다.
비록 귀찮더라도 구체적인 하위 Exception catch한다.

8.     되도록 Exception에 구체적인 에러 메시지를 포함시킨다.

9.     catch 블록에서 할 수 있는 작업은 복구/트레이스/ Exception 발생/종료뿐이다. 그냥 지나치는 것은 지양한다.
finally
블록에서 할 수 있는 작업은 try/catch 블록에서의 작업에 대한 공통 마무리이다. finally 블록에서 메소드를 종료하는 것은 지양한다.
(try/catch
블록에 return이 있다면, finally 블록 코드를 실행 후에 메소드를 종료하기 때문.)

10.   (임시) 부모/자식 예외를 모두 catch하는 블록이 연속되는 경우, 반드시 자식 예외에 해당하는 catch 블록이 앞에 위치해야 한다.


will be continuously updated...
저작자 표시
Posted by 배트
귀찮귀찮

GT-P1000 (GSM)
GT-P1010 (Wi-Fi Model)
SHW-M180W (Wi-Fi Model, Korea only)
SHW-M180S (SKT)
SHW-M180K (KTF)
SHW-M180L (LGU+)
SCH-I800 (Verizon, US Cellular)
SPH-P100 (Sprint)
SGH-I987 (AT&T)
SGH-T849 (T-Mobile)
SC-01C (NTT DoCoMo)
저작자 표시
Posted by 배트
1. 꼴에 Enterprise는 잘 안깔린다. Professional이 잘 깔리는 듯.
2. 되도록 가상 드라이브는 사용하지 말고, ISO를 임시경로에 풀어서 설치하자.
3. Setup.exe를 이용해서 설치하려면 SETUPSIZ.INI에서 vmpath를 Oracle의 java.exe로 바꿔주자.
4. 구성요소 선택할 때 OLE object viewer를 제거하고 설치하자.
5. 아래 커맨드가 가장 무난히 설치된다.

D:\vs6pro\SETUP\acmsetup.exe /t VS98PRO.STF /s D:\vs6pro /n "NAME /o "COMPANY" /k "0000000000"


저작자 표시
Posted by 배트
문장에도 호흡이 있다. 그 단위만큼은 한 호흡에 읽어야 쉽게 이해된다.
연상력이 부족하다. 퇴근하고 늦은 밤에 하는 공부는 힘들다.

The top executives agreed to negotiate with the union.
They are having a team meeting today.
To meet the president was a privilege.
A rushed decision should be avoided under any circumstances.
The financial health of the company is in a doubt.
The prospect of increased revenue awaits us next year.
The new structure that is going up at Williams and 3rd will accommodate hundreds of commercial enterprises.
It is understood that Mr. Gann will resign fairly soon.
There remain significant challenges to the fledgling company as it tries to gain a foothold in a highly competitive market.
The value of the dollar rose against Japanese yen after skirmishes in the Middle East died down.
Salaried employees received a ten percent increase in wages as an incentive to increase production.
저작자 표시
Posted by 배트
TAG TOEIC