본문 바로가기

CodeGate

PHP에서 문자열 추출 방법 (정규식 사용하지 않음) function extractStringsBetweenAnB( $html, $startChar, $endChar ) { $c1 = substr_count($html, $startChar); $c2 = substr_count($html, $endChar); if( $c1 extractStringBetweenAnB( $html, $startChar, $endChar ); $html = str_replace($startChar.$result[$i].$endChar,"",$html); } ret.. 더보기
특정 디렉토리 모니터링하기 특정 디렉토리.. 여기선 C드라이브를 모니터링 하도록 만들었다. import sys import time import logging from watchdog.observers import Observer from watchdog.events import LoggingEventHandler if __name__ == "__main__": logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') event_handler = LoggingEventHandler() observer = Observer() observer.schedule(event_handler, "C:\\", rec.. 더보기
1MB 짜리 파일 10만개 for i in `seq 1 100000`; do dd if=/dev/zero of=./small$i bs=1024 count=1000 done 더보기
10MB 짜리 파일 1만개 for i in `seq 1 10000`; do dd if=/dev/zero of=./file$i bs=1024 count=10000 done 더보기
포트모니터링 쉘 스크립트 while :; doecho "9901, 9902 port monitoring"netstat -an | grep 9901 | grep -v grep | wc -lnetstat -an | grep 9901 | grep -v grep | grep EST | wc -l netstat -an | grep 9902 | grep -v grep | wc -lnetstat -an | grep 9902 | grep -v grep | grep EST | wc -l sleep 3done 위 스크립트를 실행하면 3초에 한번씩 9901 포트와 9902 포트에 연결된 수를 보여준다. 만약 EST로 필터링한 것과 전체의 차이가 많이 나면 뭔가 문제가 있다는 것이니, 해당 서버의 로그를 확인하는게 좋을 것입니다. 더보기
특정 디렉토리에 있는 파일 삭제 또는 보기 (윈도우) for %f in (C:\Temp\*.txt) do type %f 이렇게 하면 Temp 밑에 있는 text 파일의 내용을 볼 수 있다. 만약 삭제를 하고 싶다면 type 대신에 del 명령어를 사용하면된다. 더보기
Node JS file upload 여기서 퍼온 글입니다. : http://firejune.com/1716 요즘 OpenStack Object Storage(Swift)를 가지고 놀고있습니다. Swift는 아마존(Amazon)의 S3 서비스와 유사한 오픈소스화 된 오브젝트 스토리지 서비스이며 최근 주목받는 클라우드 솔루션입니다. 두드러진 특징은 ReSTful API를 제공한다는 것입니다. 그래서 웹서버를 통하지 않고 클라이언트(예를 들면 웹브라우저 또는 모바일 애플리케이션)에서 직접 접근하여 관리할 수 있는 인터페이스를 제공합니다. Authentication(인증)과 Container/Object로 이루어진 간단한 계층 구조를 가지며 동일한 URI에 GET, POST, PUT, DELETE 등의 HTTP 메서드를 이용하여 행동을 구분하고,.. 더보기
Node JS 개발환경 구축하기 With Eclipse Install New Software 에서 아래 URL 추가하면 됩니다. http://chromedevtools.googlecode.com/svn/update/dev/ 여기선 자바 디버깅하는 것처럼 하면 안됩니다. 더보기
Resetting the Host Machine's File Descriptors First, check the current system limit for file descriptors:cat /proc/sys/fs/file-maxIf the setting is lower than 64000, edit the /etc/sysctl.conf file, and reset the fs.file-max parameter:fs.file-max = 64000Then increase the maximum number of open files on the system by editing the /etc/security/limits.confconfiguration file. Add the following entry:* - nofile 8192Edit the /etc/pam.d/system-auth.. 더보기
ajax cross domain 해결 원리 ajax로 호출할때 외부 URL을 호출하면 보안 문제 때문에 작동되지 않는다. 이때 간단한 해결 방법이다. 아래처럼 외부 URL을 호출 한 후 sample.asp 에서 javascript 문법에 맞춰 데이터를 넘겨주면 된다. 핵심은 script src="" 에 외부 URL을 넣어도 동작한다는 것이다. 더보기