'분류 전체보기'에 해당되는 글 353건

  1. 2025.03.10 Select 에서 Selected Item을 해제
  2. 2024.07.04 DB에 접속 중인 목록 확인
  3. 2024.05.14 [Lucee CFHTTP] XML Request를 사용 할 때 주의해야 할 점.
  4. 2022.11.17 [MSSQL] 쿼리를 병렬 처리하게 하는 방법
  5. 2022.11.14 [Javascript] Trim()
  6. 2022.10.27 [Coldfusion] Header Override
  7. 2022.10.06 procedure/function/trigger 의 내용 찾기
  8. 2022.10.05 [Coldfusion] EncodeForHTML 이후 개행이 필요 할 때.
  9. 2021.11.02 [Javascript] HTML 로드시 반드시 실행되는 이벤트(pageshow, pagehide)
  10. 2021.07.09 [Coldfusion] Continue 사용 시 주의할 점.
2025. 3. 10. 12:42

Select 에서 Selected Item을 해제

select의 option을 숨겼다 보였다 하는 경우 숨길 때 selected option을 unselect 할 때 $().val("") 와 같은 걸 해도 다시 보이게 되면 브라우저에서 기존 상태를 읽어서 selected option이 그대로 나오는 경우가 있다.

이 경우는 아래와 같이 확실하게 selectd 를 false로 처리해야 함

 

$select.find("option:selected").prop("selected", false).trigger("change");

2024. 7. 4. 12:35

DB에 접속 중인 목록 확인

접속 정보 확인
exec sp_who2;

 

host 에 ip가 안나오는 경우 sp_who2에서 나온 SPID를 사용해서 아래와 같이 ip를 확인 할 수 있음.

SELECT client_net_address
FROM sys.dm_exec_connections
WHERE session_ID = @@SPID

2024. 5. 14. 07:35

[Lucee CFHTTP] XML Request를 사용 할 때 주의해야 할 점.

cfhttp(method='POST', charset='utf-8', url=apiUrl, result="response", clientcertpassword=qrCreds.ClientCertPassword, clientcert=qrCreds.ClientCertificate) {
    //cfhttpparam(type='header', name='Content-Type', value='text/xml'); //If you use type='xml' in lucee, you should not set the 'Content-Type' header.
    cfhttpparam(type='header', name='SOAPAction', value='http://services.escreen.com/RequestTicket');
    cfhttpparam(type='xml', value=trim(requestData));
}

 

위와 같이 Lucee 에서는 type="xml" 로 내용을 전달 하는 경우 "Content-Type: text/xml" 을 전달 하지 말아야 한다.

이유는 type="xml" 일 때 자동으로 "Content-Type: text/xml" 를 추가 하여 수신 측에서 Invalid header 로 처리될 수 있다.

 

꼭 "Content-Type: text/xml" 을 수동으로 전달 하고자 한다면 type="xml" 을 type="body"로 해야 한다.

2022. 11. 17. 13:56

[MSSQL] 쿼리를 병렬 처리하게 하는 방법

쿼리 옵티마이저가 알아서 하겠지만 강제로 병렬 처리 하게 하는 방법은 아래 와 같다.

 

2016 이상

1
2
3
4
5
6
SELECT *
FROM [Sales].[Orders] t
WHERE t.CustomerID >100
ORDER BY OrderID
OPTION(USE HINT('ENABLE_PARALLEL_PLAN_PREFERENCE'))
GO

 

이전 버전

1
2
3
4
5
6
SELECT *
FROM [Sales].[Orders] t
WHERE t.CustomerID >100
ORDER BY OrderID
OPTION(QUERYTRACEON 8649)
GO
2022. 11. 14. 12:58

[Javascript] Trim()

if (!String.prototype.trim) {
  String.prototype.trim = function () {
    return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  };
}
2022. 10. 27. 08:21

[Coldfusion] Header Override

header (CFHEADER) 를 사용 하면 header에 동일한 property가 존재해도 추가만 된다.

아래와 같이 사용하면 기존의 property 를 변경할 수 있다.

<cfscript>
    pc = getPageContext().getResponse();
    pc.setHeader("content-security-policy", "");
</cfscript>
2022. 10. 6. 10:58

procedure/function/trigger 의 내용 찾기

일반 적인 문자열

SELECT DISTINCT
       o.name AS Object_Name,
       o.type_desc
FROM sys.sql_modules m
       INNER JOIN
       sys.objects o
         ON m.object_id = o.object_id
WHERE m.definition Like '%totalRevenue%'

ESACPE 처리 해야 하는 문자열

SELECT DISTINCT
       o.name AS Object_Name,
       o.type_desc
FROM sys.sql_modules m
       INNER JOIN
       sys.objects o
         ON m.object_id = o.object_id
WHERE m.definition Like '%\[totalRevenue\]%' ESCAPE '\'
2022. 10. 5. 10:07

[Coldfusion] EncodeForHTML 이후 개행이 필요 할 때.

rereplace(EncodeForHTML("내용"), "&##xa;&##xd;|&##xd;&##xa;|&##xa;|&##xd;", "<br>", "all")
2021. 11. 2. 13:18

[Javascript] HTML 로드시 반드시 실행되는 이벤트(pageshow, pagehide)

history.back() 에서도 실행 됨 반대는 pagehide

https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event

https://www.w3schools.com/Jsref/event_onpageshow.asp

 

window.onpageshow = function (event) {
    if (event.persisted || (window.performance && window.performance.navigation.type == 2)) {
        console.log('BFCahe로부터 복원됨');
     } else {
        console.log('새로 열린 페이지');
     }
};

$(window).on("pageshow", function (event) {
    if (event.originalEvent.persisted || (window.performance && window.performance.navigation.type == 2)) {
        console.log('BFCahe로부터 복원됨');
     } else {
        console.log('새로 열린 페이지');
     }
});

2021. 7. 9. 10:12

[Coldfusion] Continue 사용 시 주의할 점.

<cfcontinue> 를 정상적이지 않은 곳에서 사용하게 되면 500 Internal Error 를 발생시키나.

<cfscript> 안에서 continue 를 잘못 사용하게 되면 그 뒤에 나오는 statement (cfscript 안의 statement만) 를 실행하지 않는 큰 문제가 생김.

 

예를 들어 아래 코드를 실행하게 되면 10 한번만 찍히게 됨.

<cfscript>

    a = 10;

    continue;

    a = 20;

    writeOutput(a);

    a = 30;

</script>

<cfoutput>#a#</cfoutput>

 

이건 아래와 같은 경우의 continue 이후의 뒤에 나오는 모든 statement를 건너 뜀(cfscript 안의 statement만)

그래서 cfscript 마지막에 있는 abort 도 실행되지 않음.

<cfscript>

    cfloop(query = sampleQuery) {

        if(sampleQuery.column eq 1) {

            continue;

        }

    }

    abort;

</script>

cfloop 에는 continue, break 를 사용할 수 없으니 반드시 아래와 같이 사용할 것.

<cfscript>

    for(var row in sampleQuery) {

        if(row.column eq 1) {

            continue;

        }

    }

    abort;

</script>