Nikon D80을 보내며~

life 2009. 9. 19. 00:47
중고로 구입해서 약 1년간 사진을 찍은 D80

사진을 별로 찍지 못한게 아쉽지만 다음에 카메라를 구입한다면 열심히 찍어야지~

다시 팔았으니 찍었던 사진들을 블로그에 기록해 놔야지~




:

Ms-sql에서 데이터베이스의 정보를 알 수 있는 정보 스키마 뷰(INFORMATION_SCHEMA)

database 2009. 9. 18. 10:54
Ms-sql에서 정보 스키마 뷰(INFORMATION_SCHEMA)라는 view가 있다.

view의 속성은 아래와 같이 있다.

CHECK_CONSTRAINTS

REFERENTIAL_CONSTRAINTS

COLUMN_DOMAIN_USAGE

ROUTINES

COLUMN_PRIVILEGES

ROUTINE_COLUMNS

COLUMNS

SCHEMATA

CONSTRAINT_COLUMN_USAGE

TABLE_CONSTRAINTS

CONSTRAINT_TABLE_USAGE

TABLE_PRIVILEGES

DOMAIN_CONSTRAINTS

TABLES

DOMAINS

VIEW_COLUMN_USAGE

KEY_COLUMN_USAGE

VIEW_TABLE_USAGE

PARAMETERS

VIEWS


데이터 베이스의 전체 테이블정보를 볼려면 select * from INFORMATION_SCHEMA.tables
테이블 갯수를 볼려면 select count(*) from INFORMATION_SCHEMA.tables

:

마우스로 드래그해서 선택한 텍스트 가져오기

script 2009. 9. 4. 15:23
어떤 사이트들에서는 페이지의 텍스트를 드래그해서 선택한 후 바로 검색을 할 수 있게 만든 기능들이 있다.
그래서 그 기능의 핵심인 선택한 텍스트를 가져오는 스크립트를 만들어 보았다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
            #console { width: 300px; height: 20px; border: 1px solid #ccc; }
        </style>
        <script type="text/javascript">
            function selectText() {
                var selectionText = "";
                if (document.getSelection) {
                    selectionText = document.getSelection();
                } else if (document.selection) {
                    selectionText = document.selection.createRange().text;
                }
                return selectionText;
            }
           
            document.onmouseup = function() {
                document.getElementById("console").innerHTML = selectText();
            }
        </script>
    </head>
    
    <body>
        <p>abcdefghijklmnopqrstuvwxyz</p>
        <p>마우스로 드래그해서 선택한 글 나오기</p>
        <div id="console"></div>
    </body>
</html>



데모


abcdefghijklmnopqrstuvwxyz

마우스로 드래그해서 선택한 글 나오기

:

이미지 파일첨부시 업로드 이미지 미리보기 (IE8, Firefox 3)

script 2009. 9. 3. 18:21
IE8에서 이미지 업로드시 기존의 돌아다니는 소스들은 이미지 미리보기 기능이 동작하지 않았다
IE8에서는 file의 경로(obj.value)를 가져오면 실제 클라이언트의 경로대신
보안상의 이유로 'fakepath'라는 경로를 반환한다.

그래서 플래시업로드를 이용하면 가능한 방법들이 많다. (ex. http://code.google.com/p/swfupload/)
그러나 플래시를 이용하지 않고 방법이 없을까 하고 구글링 중에 찾은 포스팅이 있었다.
소스를 보니 IE8에서는 브라우저 클립보드를 이용해서 클라이언트경로를 가져오는 것이다 !
근데 클립보드를 사용하려면 클립보드를 엑세스한다는 창이 뜬다.

그래서 좀 더 괜찮은 방법이 없나 생각해서 좀 바꿔보았다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title></title>
    <style type="text/css">
        .preView { width: 70px; height: 70px; text-align: center; border:1px solid silver; }
    </style>
    <script type="text/javascript">

        function fileUploadPreview(thisObj, preViewer) {
            if(!/(\.gif|\.jpg|\.jpeg|\.png)$/i.test(thisObj.value)) {
                alert("이미지 형식의 파일을 선택하십시오");
                return;
            }

            preViewer = (typeof(preViewer) == "object") ? preViewer : document.getElementById(preViewer);
            var ua = window.navigator.userAgent;

            if (ua.indexOf("MSIE") > -1) {
                var img_path = "";
                if (thisObj.value.indexOf("\\fakepath\\") < 0) {
                    img_path = thisObj.value;
                } else {
                    thisObj.select();
                    var selectionRange = document.selection.createRange();
                    img_path = selectionRange.text.toString();
                    thisObj.blur();
                }
                preViewer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fi" + "le://" + img_path + "', sizingMethod='scale')";
            } else {
                preViewer.innerHTML = "";
                var W = preViewer.offsetWidth;
                var H = preViewer.offsetHeight;
                var tmpImage = document.createElement("img");
                preViewer.appendChild(tmpImage);

                tmpImage.onerror = function () {
                    return preViewer.innerHTML = "";
                }

                tmpImage.onload = function () {
                    if (this.width > W) {
                        this.height = this.height / (this.width / W);
                        this.width = W;
                    }
                    if (this.height > H) {
                        this.width = this.width / (this.height / H);
                        this.height = H;
                    }
                }
                if (ua.indexOf("Firefox/3") > -1) {
                    var picData = thisObj.files.item(0).getAsDataURL();
                    tmpImage.src = picData;
                } else {
                    tmpImage.src = "file://" + thisObj.value;
                }
            }
        }

    </script>
</head>
<body>
    <input id="fileData" name="fileData" type="file" onchange="fileUploadPreview(this, 'preView')" />
    <div id="preView" class="preView" title="이미지미리보기"></div>
</body>
</html>

SyntaxHighlighter에서 doctype과 html태그를 빼버려서 그냥 box로 ;;

기존 소스에서  클립보드부분을 다르게 바꿨다.(약간은 내 맘대로 수정 : )
문제가 있다면 삭제 하겠습니다.(트랙백 날립니다~)

테스트 한 브라우저는 일단 IE8, IE7, IE6, Firefox 3.5.2 ! 끝 !


: