블로그

  1. 블로그

블로그

글 수 39
  • Skin Info

ctags 는 프로그래밍 소스 코드의 태그들의 데이터베이스를 생성하는 유닉스 명령이다.


ctags를 이용하면 커널과 같은 거대 프로젝트를 분석하거나 다른 사람이 프로그래밍 소스로 프로그래밍 할 때 유용하게 사용할 수 있다.


1. ctags 설정 및 기본 사용법(debian 기준)


- 설치

sudo apt-get install ctags

분석하고자 하는 최상위 디렉토리로 이동후 


ctags --languages=python -R

위 명령어를 통해 태그 데이터베이스인 tags 파일을 생성한다.


- 홈 디렉토리의 .vimrc 파일을 열어 아래 내용을 추가 한다.


set tags=절대경로 or 상대경로

ex)

set tags=./tags

**** 자주 사용하는 단축키 또는 명령어 ***


:sts [tag] 

- [tag]가 정의된 위치를 나열하고 선택한 위치로 창을 수평 분할하여 새로 생성된 창에 표시한다.


:tj, ctrl+], 

-[tag]가 정의된 위치를 나열하고 선책한 위치로 점프. 현재 위치는 stack에 push된다.


ctrl+t     or     :po

- stack top에 저장된 위치를 pop 하고 그 위치로 점프


1. tinymce plugin 초기 설정

<script type="text/javascript" src="/common/tinymce_3_2_2_3/jscripts/tiny_mce/tiny_mce.js"> 
<script language="javascript">
 tinyMCE.init({
  //실제 textarea의 class명
  editor_selector : "editor_holder",  
  // General options
  mode : "textareas",
  theme : "advanced", 
  //skin : "o2k7",  
  language : "ko",
  plugins : "safari,noneditable,advimage,fullpage",
  theme_advanced_path : false,
  
  //IE에서 한글입력 문제 해결을 위해서
  forced_root_block : false, 
  //에디터 너비 높이 설정
  height : "330",
  width : "830",
  // Theme options
  /*
이건 각 버튼 영역이다 위의 그림을 보면 맨위에서부터 각각의 버튼 영역이 있다.
소스를 다운받으면 전체 버튼이 나오게 되는데
그중 간단히 쓸것만 아래처럼 변경한것임. 

샘플 그대로 사용해서 그중 자기가 필요한거를 넣거나 빼면된다.
 에디터상에 특정 아이콘을 이용해서 꾸미고싶다면 
아래 imagepop 을 참조해서 파일업로드해서 에디터에 넣는것을 추가했다.

  서버 특성상 각각의 파일업로드 처리 팝업을 만들었다고 가정하고 설명하겠다.  
('imagepop'은 기본에 없는 아이콘명)
  별도의 동영상이나 네이버 지도 API를 이용해서 넣거나 등등 이런경우 사용하면된다.
  */
 
  theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect",
  theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|"
+",bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor
,imagepop,cleanup,|,insertdate,inserttime,preview,|,forecolor,backcolor",
  theme_advanced_buttons3 : "",
  theme_advanced_buttons4 : "",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  theme_advanced_statusbar_location : "bottom",
  theme_advanced_resizing : false,

 
 
  // Example word content CSS (should be your site CSS) this one removes paragraph margins
  content_css : "/media/css/content.css",
 
  //에디터에 사용할 폰트 지정 
  theme_advanced_fonts : "굴림=굴림;굴림체=굴림체;궁서=궁서;궁서체=궁서체;돋움=돋움;돋움체=돋움체;바탕=바탕;바탕체=바탕체;Arial=Arial; Comic Sans MS='Comic Sans MS';Courier New='Courier New';Tahoma=Tahoma;Times New Roman='Times New Roman';Verdana=Verdana", 
 
  // Drop lists for link/image/media/template dialogs
  template_external_list_url : "lists/template_list.js",
  external_link_list_url : "lists/link_list.js",
  external_image_list_url : "lists/image_list.js",
  media_external_list_url : "lists/media_list.js",
 
  
  // Replace values for the template plugin
  template_replace_values : {
   username : "Some User",
   staffid : "991234"
  },


  /*
  에디터 파일업로드 이미지및 스크립트 설정 
  위에서 설명한 에디터 아이콘명 추가. 사용할 아이콘명 아이콘 이미지 경로 클릭시 호출된 함수를 작성한다.
  */
  setup : function(tinyMCE) {

        // Register youtube button
        tinyMCE.addButton('imagepop', {
           title : 'imagepop', 
           image : '/media/js/tiny_mce/themes/advanced/img/icons.gif',
           onclick : function() {
              cmdImgUploadPop();
           }
        });
  }  
    
 });

 //이미지 버튼 클릭시 팝업 실제 파일업로드를 구성하여 링크할 경로를 작성한다
( 아이콘클릭시 이 함수가 호출됨)
 function cmdImgUploadPop(){
  var win = window.open( "/board/board.do?cmd=editorImg",
        "editor_win",
        "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,"
          +"resizable=0,width=450,height=350,left=50,top=50"
   );
  win.focus();  
 }

// 파일업로드 완료후 opener.editorImgUploadComplete함수호출 되는 방식 
function editorImgUploadComplete(fileStr, dir){
  if( fileStr.length > 0 ){
   fileStr = fileStr.substring(0, fileStr.length-1);
   
   getObject("editorImgArrStr").value = fileStr;

   fileArray = fileStr.split("^");

   //3개가 한묶음
   var strImg = "";
   for( var i=0; i<fileArray.length; i+=3){
    strImg += "<br><img src='<%= slssConfig.getNoticeEditorUrl() %>" + dir + "/" + fileArray[i+2] + "' border=0><br><br>";
   }
   //var contents = tinyMCE.activeEditor.getContent(); 
   //tinyMCE.get('contents').getContent();
   var contents = tinyMCE.activeEditor.getDoc().body.innerHTML; 
   tinyMCE.activeEditor.setContent( contents + strImg );
  }
 }
</script>

실제 에디터가 사용될부분에 아래와 같이 작성한다.
<textarea class="editor_holder" name="contents" style='width: 830px; height: 330px;'></textarea> 

모든 에디터의 원리가 iframe으로 만들어지는 방식이기때문에 고질적인 문제가 iframe이 만들어지기전에
수정글을 넣을수가 없는 문제가 발생하기도한다. 그래서 그런경우에는 설정 안에 아래와 같이 넣어주면 된다.

setup : function(tinyMCE)  
    
    ed.onLoadContent.add(function(ed, o) {
        ed.focus();
        tinyMCE.activeEditor.setContent( 내용 );
    });


2. HTML에 HTML 형식 내용으로 출력 

<form action ="/admin/gbook/cn_update/" method="post" id="read_form" name="read_form"> {% csrf_token %}
     <input type="hidden" name="s_id" id="s_id" value=""> 
     <input type="button" id="up_button" name="up_button" value="수정" onclick="Read_Post({{cnlist.id}}, read_form);return false;" >
     <div class="table">
         <div class="tr">
             <div class="td">제목:{{cnlist.subject}}</div>
         </div>
         <div class="tr">
              <div class="td" id="context" >내용 1){{cnlist.context|safe}}</div>
         </div>
         <p> 
     </div>
 </form>
 <input type="button" name="bt1" onclick=" window.history.back()" value="취소">


보통 리눅스 시스템을 설치할 때 swap parition을 따로 생성한다.

메모리가 부족하면 swap disk를 메모리 대용으로 사용한다.

swap용량까지 부족해지면 시스템이 불안정해진다.

swap 장치를 만들 수 없으면 파일로 만들어 swap용량을 증설할 수 있다.

 

아래와 같이 하면 된다.

시나리오 : swap file을 512MB 만들어 swap 공간으로 사용한다. 

swap 파일을 저장할 디렉토리를 생성한다.
# mkdir /var/swap
디렉토리로 들어가 swap file을 만든다.
# cd /var/swap
# dd if=/dev/zero of=swap0.img bs=1M count=512
mkswap 명령으로 swap파일을 초기화한다.
# mkswap swap0.img
swap파일을 켠다.
# swapon /var/swap/swap0.img

이제 swap memory가 기존 swap 용량 + 512M 로 증가하였을 것이다.
부팅 시 swap file을 켜기 위해 다음과 같이 /etc/fstab 에 넣어 둔다.
# echo /var/swap/swap0.img swap swap defaults 0 0 >> /etc/fstab