달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31


http://suite.tistory.com 2011.08 fs

아파치 버전 : 2.2.16

성능 이슈로 css , js 등 압축기능 설정 필요로 기존 아파치에 apxs 로 mod_deflate.so 생성하고
아파치를 시작할때  httpd.conf 아래 같은 오류 메시지  나오는 경우가 있어 해결해볼려고 구글링은 해보았지만
쉽게 답은 찾지 못했고

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$>./apache start
.....  mod_deflate.so: undefined symbol: inflateEnd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

기존 아파치라 httpd.conf 외 include 로 vhost 설정을 별도로 가지고 있어
별도의 vhost-httpd.conf 에

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LoadModule deflate_module     modules/mod_deflate.so  # 추가 httpd.conf 에서는 삭제  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
설정 적용 하여 해결함


 ~~~~~~~~~~~~~~~~ 압축 설정 적용 값   ~~~~~~~~~~~~~~~~~~~~
 <Location />
            AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript text/css application/javascript application/json
            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
            BrowserMatch \bMSIE\s6\.0 no-gzip
            SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
            SetEnvIfNoCase x-flash-version ^[0-9] no-gzip dont-vary
            Header append Vary User-Agent env=!dont-vary
        </Location>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

확인은 FireFox 에서 net 에서 확인하거나 FF에 구글에서 만든 page speed 설치해도 확인 쉽다.
(http://code.google.com/intl/ko-KR/speed/page-speed/docs/using_firefox.html)



* 참고로 정적 파일 css , js ,이미지등  브라우저 캐쉬 기간 설정 1주일
   -> js, css 수정시 적용 안될경우 대비로  배포시 fs.css?2011081314 임의의 파라미터 지정 필요성  
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 LoadModule expires_module    modules/mod_expires.so
        <IfModule mod_expires.c>
                ExpiresActive On

                ExpiresDefault "access plus 1 day"
                ExpiresByType image/gif "access plus 1 weeks"
                ExpiresByType image/png "access plus 1 weeks"
                ExpiresByType image/jpeg "access plus 1 weeks"
                ExpiresByType image/jpg "access plus 1 weeks"
                ExpiresByType text/css "access plus 1 weeks"
                ExpiresByType application/javascript "access plus 1 weeks"
                ExpiresByType application/x-shockwave-flash "access plus 1 weeks"
        </IfModule>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
적용여부는 브라우저 캐시 삭제후 page speed 플러그인으로 쉽게 확인 가능

 

:
Posted by mastar
2011. 6. 18. 18:17

[java] Pascal Triangle by array 용-ILE/LANG-JAVA(JSP)2011. 6. 18. 18:17


fs 2011.06

파스칼 삼각형 상위값 합이 자기 값인거!! 자바 배열로 출력

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/**
 * <pre>
  * FileName  : pascalTriangle.java
  * Package   :
  * Comment   :
  * </pre>
  *
  * @author   : http://suite.tistory.com/
  * @date     : 2011. 6. 18.
 */
public class pascalTriangle {

 public static void main(String[] args) {
  int HEIGHT = 100;
  final int CNUM = 1;
  long[][] dataArray = new long[HEIGHT][];
  for (int i = 0; i < HEIGHT; i++) {
   int cnt = 0;
   dataArray[i] = new long[i + 1];
   for (int j = 0; j < i + 1; j++) {
    if (cnt == 0 || i == j) {
     dataArray[i][cnt++] = CNUM;
     continue;
    } else {
     long val = dataArray[i - 1][j] + dataArray[i - 1][j - 1]; // 바로 상위 두개 값 합
     dataArray[i][cnt++] = val;

    }
   }
  }
  // print
  for (int k = 0; k < HEIGHT; k++) {
   for (int idx = 0; idx < dataArray[k].length; idx++) {
    System.out.print(dataArray[k][idx] + " ");
   }
   System.out.println();
  }
 }
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
결과

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
......
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

:
Posted by mastar

http://suite.tistory.com  2011.4

검색해도 해결이 잘안보이길래~ 모든 정답은 아닐수있음

오류 메시지 : --- Cause: org.apache.commons.dbcp.SQLNestedException: Borrow prepareStatement from pool failed

ibatis 로 sqlmap.xml 에서 update 문에 실제 테이블에 없는 필드 지정 과 문법 오류였음 ~.~
  



 

:
Posted by mastar

http://suite.tistory.com 2011-03

보통 리눅스에서는 vim이 파일 확장자가 php 경우 보통 php syntax 에 맞게 색을 구분에 보여주는데
확장를 다른걸로 바꾸면 걍 기본색 하나만 출력 될경우 좀 보기 어려워질때 아래 설정에 추가


보통 리눅스 : /usr/share/vim/vim**/filetype.vim
php 문서를 확장자로 nts로 할때  *.nts 추가

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Php3
au BufNewFile,BufRead *.php,*.php3 , *.nts             setf php


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

또는 vi에서 파일을 열고 에디터 모드에서

1. syntax on
2. setf php
  


:
Posted by mastar

http://suite.tistory.com 2011.2 fs

1.  상황  현재 프로세스도 없는데 메모리가 20% -> 80%가 된경우가 있다. 
   $> sar -r 실행 
   01시쯤부터 cache 메모리가 확 줄어들고 있음
 
  


해당 시간때에 파일 읽기 많은 프로세스가 실행되었된것으로 보임(로그 확인으로 특이한 프로세스가 수행중이었음)


$> free -k 결과  buffers 에 6G 정도있고 cached에는 1G 내외였음 시간이 흐르면서 cached는 계속 늘어나고있음
  
 
2.  확인 사항
$> ps -ef , ps aux , top 으로 모니터링 해도 메모리를 많이 잡고 있는 process 는 없음

$>cat /proc/meminfo 수행 결과 (slab 메모리가 다른 서버에 비해 많음) 
MemTotal:      8166480 kB
MemFree:         87520 kB
Buffers:        412972 kB
Cached:        1436408 kB
SwapCached:       5320 kB
Active:        2861672 kB
Inactive:       507492 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:      8166480 kB
LowFree:         87520 kB
SwapTotal:     4192956 kB
SwapFree:      4174184 kB
Dirty:             352 kB
Writeback:           0 kB
Mapped:        1551948 kB
Slab:          4674220 kB
CommitLimit:   8276196 kB
Committed_AS:  4289248 kB
PageTables:      12016 kB
VmallocTotal: 536870911 kB
VmallocUsed:    264492 kB
VmallocChunk: 536606199 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     2048 kB

-$> slabtop 실행 결과
 Active / Total Objects (% used)    : 7824739 / 8227380 (95.1%)
 Active / Total Slabs (% used)      : 1168335 / 1168343 (100.0%)
 Active / Total Caches (% used)     : 87 / 131 (66.4%)
 Active / Total Size (% used)       : -196427.88K / 35872.14K (-547.6%)
 Minimum / Average / Maximum Object : 0.02K / 0.00K / 128.00K

 OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
4805590 4507678  93%    0.72K 961118        5   3844472K ext2_inode_cache
2863088 2810478  98%    0.23K 178943       16    715772K dentry_cache

$>
cat /proc/slabinfo 실행 결과  inod cache를 많이 사용하는걸로 보임
...
ext2_inode_cache  4507680 4805590    736    5    1 : tunables   54   27    8 : slabdata 961118 961118      0
...
dentry_cache      2810526 2863088    240   16    1 : tunables  120   60    8 : slabdata 178943 178943      0

3. 조치 해본것
참조 구글링 :
http://linux-mm.org/Drop_Caches
To free pagecache:
#echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
-> 수행결과 메모리 다소 상승 됨 , 서버 문제없음

To free pagecache, dentries and inodes:
#echo 3 > /proc/sys/vm/drop_caches
-> 수행결과 서버 hang 발생했음 ~.~
  (https://bugzilla.redhat.com/show_bug.cgi?id=449381)

-> 결론적으로 운영중인 시스템에 drop_caches 조정은 위험해~~~
* 캐쉬를 단기간에 제거할려면 일정잡고 재부팅이 최선일수도 .... or vm.vfs_cache_pressure  설정값을 크게 변경

* 조치 안해도 계속두면 시스템이 알아서 cached쪽이 늘어남(vm.vfs_cache_pressure 설정에 따라 그런것 같음)

:
Posted by mastar


http://suite.tistory.com 2011.2 fs

<table><tr> <td> 리스트 화면을 동적 상 하 좌 우 변경하고 싶을때~~ 역시 검색 해도 잘안나와서 정리해봄
http://jquery.com/  Cross-browser 대단함~~~ 현재 제공해주는 최신 버전은 version 1.5임
 
<html>
<title>Jquery로 리스트 동적 변경 http://suite.tistory.com</title>
<head>
<script type="text/javascript" src="jquery-1.5.min.js"></script> 
</head>
<body>
<form method="get">
<table border=1>
  <tr id=MARK1>
    <td>
      <input type="checkbox" name="book_chk" value="checked_id1">
    </td>
    <td>제목1</td>
    <td>내용1</td> 
    <td>
      <input type="button" name="up1" value="up" onclick="moveUpItem('MARK1')">
      <input type="button" name="down1" value="down"  onclick="moveDownItem('MARK1')">
    </td>
  </tr>
  <tr id=MARK2>
    <td>
      <input type="checkbox" name="book_chk" value="checked_id2">
    </td>
    <td>제목2</td>
    <td>내용2</td> 
    <td>
      <input type="button" name="up2" value="up"  onclick="moveUpItem('MARK2')">
      <input type="button" name="down2" value="down"  onclick="moveDownItem('MARK2')">
    </td>
  </tr>
  <tr id=MARK3>
    <td>
      <input type="checkbox" name="book_chk" value="checked_id3">
    </td>
    <td>제목3</td>
    <td>내용3</td> 
    <td>
      <input type="button" name="up2" value="up"  onclick="moveUpItem('MARK3')">
      <input type="button" name="down2" value="down"  onclick="moveDownItem('MARK3')">
    </td>
  </tr>
  <tr id=MARK4>
    <td>
      <input type="checkbox" name="book_chk" value="checked_id4">
    </td>
    <td>제목4</td>
    <td>내용4</td> 
    <td>
      <input type="button" name="up2" value="up"  onclick="moveUpItem('MARK4')">
      <input type="button" name="down2" value="down"  onclick="moveDownItem('MARK4')">
    </td>
  </tr>
  <tr id=MARK5>
    <td>
      <input type="checkbox" name="book_chk" value="checked_id5">
    </td>
    <td>제목5</td>
    <td>내용5</td> 
    <td>
      <input type="button" name="up2" value="up"  onclick="moveUpItem('MARK5')">
      <input type="button" name="down2" value="down"  onclick="moveDownItem('MARK5')">
    </td>
  </tr>   
</table>
<script type="text/javascript">
       
function moveUpItem(currentMark) {    
 
  var idStr='#' + currentMark;
  var prevHtml=$(idStr).prev().html();

  if( prevHtml == null){
    alert("최상위 리스트입니다!");
    return;
  }
  var prevcurrentMark=$(idStr).prev().attr("id");
 
  var currcurrentMark=$(idStr).attr("id");
  var currHtml=$(idStr).html();
 
  //값 변경
  $(idStr).html(prevHtml);
  $(idStr).prev().html(currHtml);
 
  //id 값도 변경
  $(idStr).prev().attr("id","TEMP_TR");
  $(idStr).attr("id",prevcurrentMark);
  $("#TEMP_TR").attr("id",currcurrentMark);
 
}

function moveDownItem(currentMark) {    
 
  var idStr='#' + currentMark;
  var nextHtml=$(idStr).next().html();

  if( nextHtml == null){
    alert("최하위 리스트입니다!");
    return;
  }
  var nextcurrentMark=$(idStr).next().attr("id");
  var currcurrentMark=$(idStr).attr("id");
  var currHtml=$(idStr).html();
  $(idStr).next().html(currHtml);
 // $(idStr).next().attr("id",currcurrentMark);
 
  //값 변경
  $(idStr).html(nextHtml);
 
  //id 값도 변경
  $(idStr).next().attr("id","TEMP_TR");
  $(idStr).attr("id",nextcurrentMark);
  $("#TEMP_TR").attr("id",currcurrentMark);
 
}

</script>
<input type=submit name="test">  
</form>
</table>
</body>
</html> 

<수행 결과>






 

 

:
Posted by mastar

http://suite.tistory.com  fs 2011.2                                      

자바에서 리스트 객체의 멤버 값에 따라 정렬시

Collections.sort() 를 사용해보는데 한개 변수로 올림/내림 차순 정렬외
한개의 변수의 값이 같을때 2차로 정렬을 할려고하니 검색해도 잘안나와 적어봄~~

ex) 포인트가 높고 같을때는 최신날짜 순으로 할때

1. 객체 class

public class box {
 int point;
 int date;
 String title;
}

2.비교함수용 implements Comparator 클래스

import java.util.Comparator;

class comparator implements Comparator<box> {

 public int compare(box box1, box box2) {

  int ret = 0;
  if (box1.point < box2.point) {
   ret = 1;
  }
  if (box1.point == box2.point) {
   if (box1.date < box2.date) {
    ret = 1;
   }
  }
  return ret;
 }
//문자열이면 compareTo()를 활용하면 될것같음
}


3. main 클래스

import java.util.ArrayList;
import java.util.Collections;

public class test1 {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  ArrayList<box> al = new ArrayList();

  box b1 = new box();
  b1.point = 100;
  b1.date = 201012;
  b1.title = "제목1";
  al.add(b1);
  box b2 = new box();
  b2.point = 200;
  b2.date = 201101;
  b2.title = "제목2";
  al.add(b2);

  box b3 = new box();
  b3.point = 200;
  b3.date = 201102;
  b3.title = "제목3";
  al.add(b3);

  System.out.println("정렬전");
  for (int i = 0; i < al.size(); i++) {
   System.out.print(al.get(i).title);
   System.out.print("," + al.get(i).point);
   System.out.println("," + al.get(i).date);
  }

  Collections.sort(al, new comparator());

  System.out.println("\n정렬후\n");
  for (int i = 0; i < al.size(); i++) {
   System.out.print(al.get(i).title);
   System.out.print("," + al.get(i).point);
   System.out.println("," + al.get(i).date);
  }
 }
}


4. 실행결과
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
정렬전
제목1,100,201012
제목2,200,201101
제목3,200,201102

정렬후

제목3,200,201102
제목2,200,201101
제목1,100,201012
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

:
Posted by mastar

http://suite.tistory.com 2010 12

이클립스 톰켓 plugin 의 WEB-INF/lib 에서 jsp-api-2.0.jar 삭제 하고 톰켓 리스타트~

 Unable to read TLD "META-INF/c.tld" from JAR file "file:/c:/org.eclipse.wst.server.core/tmp9/wtpwebapps/WEB-INF/lib/standard-1.1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
org.apache.jasper.JasperException: Unable to read TLD "META-INF/c.tld" from JAR file "file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp9/wtpwebapps/WEB-INF/lib/standard-1.1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
 at org.apache.jasper.compiler.DefaultErrorHandler/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp9/wtpwebapps/WEB-INF/lib/standard-1.1.2.jar

 

:
Posted by mastar

2010-11 http://suite.tistory.com 

샘플소스중에  ApplicationFrame   상속 받아서 사용할때
super() 호출할때 java.awt.HeadlessException  오류 발생함

구글링에서 해결 관련 사항이 많이나오지만 해결은 안됨

- http://cewolf.sourceforge.net/new/faq/faq.html#Troubleshooting0

- Djava.awt.headless=true , 기타 x-window 기동~~
   DISPLAY~어쩌구~등

결론은 linux에서 ApplicationFrame 상속받지 않고 사용 하면된다. ~.~


http://www.java2s.com/Code/Java/Chart/Line-Chart.htm


 

:
Posted by mastar

http://suite.tistory.com fs 2010 03

도구 -> 개발자도구  비활성화 일때

레지스트리에서 변경하여 사용~~가능

IEDevTools > Disabled 값을 1 -> 0 으로 변경
자세한건 그림 참고~~~

사용자 삽입 이미지


 

:
Posted by mastar