2013년 3월 19일 화요일

자바스크립트 중복 제거 함수.

var a=[];
while(a.length <3) {
var n = Math.round(Math.random() * 20);
if (a.indexOf(n)==-1) a.push(n);
}

출처:http://stackoverflow.com/a/5740725

2013년 2월 23일 토요일

geopoint cannot be resolved to a type 해결책

1. 이클립스 프로젝트에서 오른쪽 클릭.

2. Properties -> Android 선택

3. Build Target 에서 Google API 를 선택한다.

 

번외로 dalvik.system.vmruntime cannot be resolved to a type 오류 발생시

플래폼 버젼을 내려준다. 2.2로 하니까 해결 됬음.

2013년 2월 4일 월요일

윈도우 톰캣 ROOT 네트워크 드라이브

윈도우에서 톰캣을 사용중에 있다.

서버 a 와 서버 b 가 있다.

서버 a에는 톰캣이 있고,  컨텐츠가 있다.

서버 b에는 톰캣이 있고, 컨텐츠가 없다.

서버b에서는 네트워크 드라이브를 통해서 서버 a의 컨텐츠를 가져 다 써야 한다.

서버a의 ROOT 위치는 webapps/ROOT, ROOT 드라이브를 공유했다.

네트워크 드라이브를 잡자.
net use X: \\tbittpcont1\root password /user:userid

server.xml 내용
      <Host name="localhost"  appBase=""            unpackWARs="true" autoDeploy="true">		<Context path="/" docBase="\\netbios\root" reloadable="true"/>        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"               prefix="localhost_access_log." suffix=".txt"               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>      </Host>

이게 중요한데, 네트워크 드라이브를 NETBIOS 로 지정 해 줘야 한다.

출처

ps. 진짜 해결 하고 나니 별거 아닌데, 장장 3일이나 걸쳐서 처리 했다.

2013년 2월 2일 토요일

SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-apr-443"]

SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-apr-443"]윈도우 톰캣 이관시 ssl keyfile 문제 발생.기존 서버윈도우 2008톰캣 버젼 : 7.0.14자바 버젼 : 1.6.0_25이관 서버윈도우 2008 R2 64bit톰캣 버젼 : 7.0.35자바 버젼 : 1.7.0_11처음에는 ssl key 파일이 64비트로 만들어 져서 그런건가 했더니, 아닌 것 같다.다음과 같이 server.xml 을 변경하여 해결.<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"SSLEnabled="true"               maxThreads="150" scheme="https" secure="true" keystoreFile="C:\keystore\.keystore"keystorePass="changeit"clientAuth="false" sslProtocol="TLS" />기존의 protocol "HTTP/1.1""org.apache.coyote.http11.Http11Protocol" 로 바꿔 줌.출처

2013년 2월 1일 금요일

asp.net 일정기간 지난 디렉토리 삭제.

CreationTime 이란 값으로 가져온 걸 뿌려 봤더니, 2013-01-31 오후 3:11:42 << 이런 형식으로 나온다.

이걸 어떻게 비교 하나 검색해보니 아래와 같이 비교 하더라.

출처:http://stackoverflow.com/questions/2222348/how-to-delete-files-older-than-3-months-old-in-a-directory-using-net

http://msdn.microsoft.com/ko-kr/library/system.io.directoryinfo.aspx
            //string dirName = "c:\\Temp";            string dirName = "c:\\tmp";            // C: 루트 디렉토리 정보를 가져옴            DirectoryInfo dInfo = new DirectoryInfo(dirName);            // 하위 FileInfo(파일정보) 배열을 받아옴            FileInfo[] fInfoSub = dInfo.GetFiles();            // 하위 DirectoryInfo(디렉토리정보) 배열을 받아옴            DirectoryInfo[] dInfoSub = dInfo.GetDirectories();            Response.Write(dInfo.FullName);            Response.Write("<br/>");            Response.Write(dInfo.CreationTime);            Response.Write("<br/>");            //if (dInfo.CreationTime < DateTime.Now.AddMonths(-3))            if (dInfo.CreationTime < DateTime.Now.AddMilliseconds(-1))            {                Response.Write("3개월이 지난 디렉토리입니다.");                dInfo.Delete(true); /true 값을 주면 하위 디렉토리,파일까지 삭제.            }            else            {                Response.Write("3개월이 지나지 않은 디렉토리입니다.");            }

 



            //2개월 이상 디렉토리 삭제            DirectoryInfo dirTemp = new DirectoryInfo(realORtestDir);            foreach(DirectoryInfo dirs in dirTemp.GetDirectories())            {                if (dirs.CreationTime < DateTime.Now.AddMonths(-2))                {                    //Response.Write("2개월이 지난 디렉토리입니다.");                    //Response.Write(dirs.FullName);                    dirs.Delete(true);                }            }

asp.net 네트워크 드라이브에 파일 쓰기

찾아 봤는 데, 여러가지 방법이 있지만 제일 쉽게 됬던 방법이다.

1. iis 관리자 -> IIS 영역 -> 인증 -> asp.net 가장 -> 작업(편집), 사용 -> 관련 아이디 패스워드 지정.

2. asp.net에서 경로 지정시 이런 형식으로 사용한다.
 saveDir = "\\\\192.168.0.1\\imgData\\" + today;

2013년 1월 29일 화요일

윈도우 telnet 자동 로그인

윈도우에서 telnet 자동 접속 후 명령어 실행하는 프로그램입니다.

확장자는 .vbs 로 합니다.

사용법

1. C:\oneIP.txt 파일을 만들고 한줄씩 접속할  아이피를 넣어준다.

2.아래 소스를 아무이름으로 .vbs 확장자로 만든다.

ex)telnet_auto.vbs

3. 실행한다.

ps. 접속 후 실행할 명령은 알아서 넣기.

set WshShell = WScript.CreateObject("WScript.Shell")Const ForReading = 1Const ForWriting = 2Const ForAppending = 8Const ipListFile = "C:\oneIP.txt"Set Shell = CreateObject("WScript.Shell")Set FSO = CreateObject("Scripting.FileSystemObject")If FSO.FileExists(ipListFile) Then	Set SwitchIP = FSO.opentextfile(ipListFile, ForReading, False)Else    Wscript.Echo "This file (" + ipListFile + ") does not exist."	Wscript.QuitEnd IfDim userIdDim userPwuserId = "yourid"userPw = "yourpass"WScript.Echo "Don't touch Anything!!"While Not SwitchIP.atEndOfStreamIP = SwitchIP.Readline()  WshShell.Run "cmd"  WScript.Sleep 100  WshShell.AppActivate "C:\Windows\system32\cmd.exe"  WScript.Sleep 100  rem telnet [address] [port]  WshShell.SendKeys "telnet " + IP + " 23{ENTER}"  WScript.Sleep 2000  rem [id]  WshShell.SendKeys userId + "{ENTER}"  WScript.Sleep 2000  rem [pwd]  WshShell.SendKeys userPw + "{ENTER}"  WScript.Sleep 1000  rem [command what you want]  WshShell.SendKeys "show ver{ENTER}"  WshShell.SendKeys "{ENTER}"  WScript.Sleep 2000  WshShell.SendKeys "exit{ENTER}"WendWScript.Sleep 2000WScript.Echo "Completed."