2012년 2월 29일 수요일

다음 클라우드

http://ubuntu.or.kr/viewtopic.php?p=90771

 $ mkdir tmp
 $ dpkg-deb -x daumcloud_1.0.0.86.deb tmp
 $ dpkg-deb --control daumcloud_1.0.0.86.deb tmp/DEBIAN
 $ sed -i "s/i386/all/" tmp/DEBIAN/control
 $ dpkg -b tmp daumcloud_1.0.0.86_64.deb

리눅스 명령어


  • 부트 프로세스 관리 : update-rc.d
  • tar.bz2 압축 풀기 : tar -jxvf 파일명
  • 파일 내용 검색
    • find로 파일 내용을 검색하고 싶으면 아래와 같이 하면 된다.
    • find /path -name "*.php" | xargs grep pattern

    • 예를 들면 아래와 같이 하면 된다.
    •  
    • $ find ./ -name "*.php" | xargs grep "lang->cmd_modify = '수정'"
    • ./common/lang/ko.lang.php:    $lang->cmd_modify = '수정';

    • $ find ./ -name "*.php" | xargs grep "수정"
    • ./common/lang/ko.lang.php:    $lang->cmd_modify = '수정';

    • ko.lang.php 파일에 "수정"이라는 단어가 포함 되어 있다.
    • 출처 : http://blog.naver.com/tranger/100108769285

    • .svn 삭제
    • find . -type d -name .svn -depth -exec rm -rf {} \;
    • 출처 : http://linsoo.tistory.com/2186?srchid=BR1http%3A%2F%2Flinsoo.tistory.com%2F2186

  • 패키지 설치 : sudo dpkg -i *deb



  • kill all :  kill -9 `ps -ef | grep oraxpo | grep -v grep | awk '{print $2}'`

emacs init


(setq inferior-lisp-program "/usr/bin/sbcl")
(add-to-list 'load-path "/home/jaejin/.emacs.d/slime/")
(add-to-list 'load-path "/home/jaejin/.emacs.d")
(require 'slime)

(slime-setup)

(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)

;; python flymake
  (when (load "flymake" t)
         (defun flymake-pyflakes-init ()
           (let* ((temp-file (flymake-init-create-temp-buffer-copy
                              'flymake-create-temp-inplace))
              (local-file (file-relative-name
                           temp-file
                           (file-name-directory buffer-file-name))))
             (list "pyflakes" (list local-file))))

         (add-to-list 'flymake-allowed-file-name-masks
                  '("\\.py\\'" flymake-pyflakes-init)))

(add-hook 'find-file-hook 'flymake-find-file-hook)

;;
(load "erlang_appwiz" t nil)

(require 'erlang-start)
(require 'erlang-eunit)
(require 'erlang-flymake)

(setq auto-mode-alist (cons '("\\.erl$" . erlang-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.hrl$" . erlang-mode) auto-mode-alist))

;; 반투명하게 하기
(defun set-frame-alpha (arg &optional active)
  (interactive "nEnter alpha value (1-100): \np")
  (let* ((elt (assoc 'alpha default-frame-alist))
         (old (frame-parameter nil 'alpha))
         (new (cond ((atom old)     `(,arg ,arg))
                    ((eql 1 active) `(,arg ,(cadr old)))
                    (t              `(,(car old) ,arg)))))
    (if elt (setcdr elt new) (push `(alpha ,@new) default-frame-alist))
    (set-frame-parameter nil 'alpha new)))
(global-set-key (kbd "C-c t") 'set-frame-alpha)

;; This is needed for Distel setup
(let ((distel-dir "/home/jaejin/.emacs.d/distel/elisp"))
  (unless (member distel-dir load-path)
    ;; Add distel-dir to the end of load-path
    (setq load-path (append load-path (list distel-dir)))))

(require 'distel)
(distel-setup)

2012년 2월 24일 금요일

리눅스 사전

설치방법
apt-get install python-setuptools
easy_install pip
pip install beautifulsoup
apt-get install python-gtk2 ; apt-get install python-glade2

아래에 있는 Dict.py 내용으로 Dict.py 파일을 만든다.
같은 폴더에 Main.glade 내용으로 Main.glade 파일을 만든다.


  • 기능
    • 기본적인 단어검색
    • 다음 dic 을 이용해서 만들어서 인터넷 연결시 사용해야 함
    • 검색결과 우분투 notification 에서 나옴
    • 어플을 뛰어 놓은 상태에서 텍스트 복사시에 자동으로 검색함.
  • 필요한 lib
    • glade
    • pygtk
    • BeautifulSoup

Dict.py
#-*- coding: utf-8 -*-
# coding: utf-8
# author : spyrogira256@gmail.com

import pygtk
pygtk.require("2.0")



import gtk, gobject
import gtk.glade
import sys

import pynotify

import httplib
#import urllib2
from BeautifulSoup import BeautifulSoup

# even in Python this is globally nasty <img src="http://developer.ubuntu.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"> , do something nicer in your own code
capabilities = {'actions':             False,
        'body':                False,
        'body-hyperlinks':     False,
        'body-images':         False,
        'body-markup':         False,
        'icon-multi':          False,
        'icon-static':         False,
        'sound':               False,
        'image/svg+xml':       False,
        'private-synchronous': False,
        'append':              False,
        'private-icon-only':   False}


ENTER_KEY = 65293
DAUM_DIC = "small.dic.daum.net"
DAUM_QUERY = "/search.do?q="

MEANS= [{'title':"영어사전",'search_class': "txt_means_KUEK"},
        {'title':"영영사전",'search_class': "txt_means_WOEE"},
        {'title': "국어사전", 'search_class' : "txt_means_KOKK"},
        {'title':"일어사전", 'search_class' : "txt_means_KUKJ"},
        {'title' : "중국어사전", 'search_class' : "txt_means_KOKC"}] 
# ENG_MEAN = "txt_means_KUEK"  # 영어사전 
# EE_MEAN = "txt_means_WOEE" # 영영사전 
# KOR_MEAN = "txt_means_KOKK" # 국어사전 
# JP_MEAN = "txt_means_KUKJ" # 일어 
# CH_MEAN = "txt_means_KOKC" # 중국어 


class ClipboardInfo:
    pass

class DictHTMLParse :
    
    def parse(self, html_doc):
        soup = BeautifulSoup(html_doc)
        result = ""
        for mean in MEANS :
            fetchData= soup.fetch('div',{'class' : mean['search_class']})
            if len(fetchData) > 0 :
                result += mean['title'] + "\r\n"
                result += fetchData[0].contents[0] + "\r\n\r\n"
        
        return result

class Dict:

    # signal handler called when the clipboard returns text data
    def clipboard_text_received(self, clipboard, text, data):
        if not text or text == '':
            return

        if self.cbi.text !=text and len(text) > 0 :
            print "cbi text %s " % text
            self.txt_entry.set_text(text)
            self.cbi.text = text
            self.daum_search(text)

        return

     # get the clipboard text
    def fetch_clipboard_info(self):
        self.clipboard.request_text(self.clipboard_text_received)
        return True


    def __init__(self):
        file = "Main.glade"
        self.builder = gtk.Builder()
        self.builder.add_from_file(file)
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("MainWindow")
        self.txt_entry = self.builder.get_object("txt_entry")
        self.txtview = self.builder.get_object("txtview")
        self.cbi = ClipboardInfo()
        self.cbi.text= ""

        dic = {"search_callback" : self.search_callback, 
               "on_exit_click": self.on_exit_click ,
               "txt_key_press": self.txt_key_press
               }
        self.builder.connect_signals(di설치방법
apt-get install pip
apt-get install glade
pip install beautifulsoup

아래에 있는 Dict.py 내용으로 Dict.py 파일을 만든다.
같은 폴더에 Main.glade 내용으로 Main.glade 파일을 만든다. c)

        # 클립보드 초기화 
        self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
        self.clipboard.set_text("",-1)
        self.clipboard.clear()

        # 백그라운드 쓰레드 1.5 초 간격으로 클립보드 확인 
        gobject.timeout_add(1500, self.fetch_clipboard_info)

        self.window.show()
        
    def on_exit_click(self,widget,data=None):
        gtk.main_quit()
    
    def search_callback(self,widget, data=None):
        self.daum_search(self.txt_entry.get_text())

    def txt_key_press(self,widget, event):
        if event.keyval == ENTER_KEY :
            self.daum_search(self.txt_entry.get_text())
            print self.txt_entry.get_text()

               
    def daum_search(self, search_text=None):
        conn = httplib.HTTPConnection(DAUM_DIC)
        conn.request("GET",DAUM_QUERY+search_text)
        res = conn.getresponse()
        parser = DictHTMLParse()

        textBuffer = gtk.TextBuffer()
        text = parser.parse(res.read())
        textBuffer.set_text(text)

        self.txtview.set_buffer(textBuffer)
        notify = Notify()
        notify.show(text)
        
class Notify :
    def initCaps(self):
        caps = pynotify.get_server_caps()
        if caps is None:
            print "Failed to receive server caps."
            sys.exit(1)
        
        for cap in caps:
            capabilities[cap] = True
 
    def printCaps(self):
        info = pynotify.get_server_info()
        print "Name:          " + info["name"]
        print "Vendor:        " + info["vendor"]
        print "Version:       " + info["version"]
        print "Spec. Version: " + info["spec-version"]
 
        caps = pynotify.get_server_caps()
        if caps is None:
            print "Failed to receive server caps."
            sys.exit (1)
 
            print "Supported capabilities/hints:"
        if capabilities['actions']:
            print "\tactions"
        if capabilities['body']:
            print "\tbody"
        if capabilities['body-hyperlinks']:
            print "\tbody-hyperlinks"
        if capabilities['body-images']:
            print "\tbody-images"
        if capabilities['body-markup']:
            print "\tbody-markup"
        if capabilities['icon-multi']:
            print "\ticon-multi"
        if capabilities['icon-static']:
            print "\ticon-static"
        if capabilities['sound']:
            print "\tsound"
        if capabilities['image/svg+xml']:
            print "\timage/svg+xml"
        if capabilities['private-synchronous']:
            print "\tprivate-synchronous"
        if capabilities['append']:
            print "\tappend"
        if capabilities['private-icon-only']:
            print "\tprivate-icon-only"
 
        print "Notes:"
        if info["name"] == "notify-osd":
            print "\tx- and y-coordinates hints are ignored"
            print "\texpire-timeout is ignored"
            print "\tbody-markup is accepted but filtered"
        else:
            print "\tnone"
 
    def __init__(self):
           
        if not pynotify.init("icon-summary-body"):
            sys.exit(1)
 
       # call this so we can savely use capabilities dictionary later

        self.initCaps()
 
       # show what's supported
        self.printCaps()
 
        # try the icon-summary-body case
        
    def show(self,text) :
        n = pynotify.Notification (text)
        n.show()


if __name__ == "__main__" :
    dict = Dict()
    gtk.main()


Main.glade


<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <!-- interface-requires gtk+ 3.0 -->
  <object class="GtkWindow" id="MainWindow">
    <property name="can_focus">False</property>
    <property name="has_resize_grip">False</property>
    <signal name="delete-event" handler="on_exit_click" swapped="no"/>
    <child>
      <object class="GtkVBox" id="vbox1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkHBox" id="hbox1">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <object class="GtkEntry" id="txt_entry">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="invisible_char">•</property>
                <property name="shadow_type">none</property>
                <signal name="key-press-event" handler="txt_key_press" swapped="no"/>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="b_search">
                <property name="label" translatable="yes">찾기</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_action_appearance">False</property>
                <signal name="clicked" handler="search_callback" object="txt_entry" swapped="no"/>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="b_close">
                <property name="label" translatable="yes">닫기</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_action_appearance">False</property>
                <signal name="clicked" handler="on_exit_click" swapped="no"/>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">2</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkScrolledWindow" id="scrolledwindow1">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="shadow_type">in</property>
            <child>
              <object class="GtkTextView" id="txtview">
                <property name="width_request">300</property>
                <property name="height_request">300</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="vscroll_policy">natural</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>



  1. tray로 넣기
  2. 강세 추가
  3. 발음듣기 추가
  4. screenlet로 추가하기

2012년 2월 21일 화요일

db create


drop table tcdt_fbs;
create table tcdt_fbs
(
fbs_seq number,
hgrnk_seq number,
pjt_cd varchar(30),
fbs_cd varchar(10),
fbs_nm varchar(100),
fbs_expln varchar(1000),
stln_seqc number,
mdfc_id varchar(15),
mdfc_dttm date,
rgst_id varchar(15),
rgst_dttm date,
primary key(fbs_seq)
);

drop index ix_tcdt_fbs_01;
create index ix_tcdt_fbs_01
on tcdt_fbs(stln_seqc asc);

drop SEQUENCE tcdt_fbs_seq;
CREATE SEQUENCE tcdt_fbs_seq
START WITH 1
INCREMENT BY 1
MINVALUE 0 NOMAXVALUE;

2012년 2월 20일 월요일

erlang에서 파일 읽기


  • 라인별로 읽기

    1> {ok, S} = file:open("data1.dat", read).
    {ok,<0.43.0>}
    2> io:get_line(S, '').
    "{person, \"joe\", \"armstrong\",\n"
    3> io:get_line(S, '').
    "\t[{occupation, programmer},\n"
    4> io:get_line(S, '').
    "\t {favoriteLanguage, erlang}]}.\n"
    5> io:get_line(S, '').
    "\n"
    6> io:get_line(S, '').
    "{cat, {name, \"zorro\"},\n"
    7> io:get_line(S, '').
    "
    {owner, \"joe\"}}.\n"
    8> io:get_line(S, '').
    eof
    9> file:close(S).

    •  

    2012년 2월 15일 수요일

    git로 riak 설치방법

    기준 우분투 11.04
    설치전 필요한 파일
    Erlang R14B03 이상 버젼

    소스 받기
    git clone https://github.com/basho/riak.git

    설치하기
    cd riak
    make all

    Node 생성하기
    make devrel

    Node 실행하기
    cd dev/dev1/bin
    riak start

    제대로 실행 됐는지 확인 방법
    ps -ef | grep beam


    Node 죽이기
    cd dev/dev1/bin
    riak stop


    Node clustering
    cd dev/dev2/bin
    riak start
    riak-admin join dev1@127.0.0.1