카테고리 없음2009. 6. 9. 01:06

http://gavingrover.blogspot.com/2009/05/groovys-groovier-roadmap.html

그루비를 MS-DLR(Dynamic Language Runtime)에 구현하는 프로젝트다 있었다. 이쪽에 올라온 글을 보니.. 그루비의 키워드에 별칭을 쓸 수있게 한것 같다. (사실, 제목과는 달리, 저 포스트에서 언급한건 한글이아니고.. 중국글이었다..)

Name aliasing
Name aliasing is what got me interested in writing an alternative lexer/parser for the GrAST (Groovy AST) in the first place. I've long wanted to use Chinese characters as aliases for the English names and keywords in programs, to make the code shorter. I don't want to write this:
  content.tokenize().groupBy{ it }.
  collect{ ['key':it.key, 'value':it.value.size()] }.
  findAll{ it.value > 1 }.sort{ it.value }.reverse().
  each{ println "${it.key.padLeft( 12 )} : $it.value" }
when I can write this:
  物.割().组{它}.集{ ['钥':它.钥, '价':它.价.夵()] }.
  都{它.价>1}.分{它.价}.向().每{打"${它.钥.左(12)}: $它.价"}

 

이런 식이다. 어쩌면 JVM용 그루비에서도 조만간 이 기능을 볼수있지 않을까?

Posted by jintopark
카테고리 없음2009. 5. 28. 04:28

여기까지 오면...
우분투에 passenger, nginx, rails, ruby enterprise 까지 설치하게 된다. 최신 안정 설정인 것 같다.

sudo vi /etc/vim/vimrc
에서
맨 아래에



[code]
if &fileencodings !~? "utf-8"
set fileencodings^=utf-8
set fileencoding=utf-8
else
set fileencodings+=utf-8
endif

syntax enable

set ai
set sw=2
set ts=2

set scrolloff=3
set sidescrolloff=7
set sidescroll=1
[/code]

Posted by jintopark
카테고리 없음2009. 5. 28. 04:15

자바 설치

[code shell]sudo apt-get install sun-java5-bin sun-java5-jre sun-java5-jdk[/code]

그루비 설치

http://code.google.com/p/ant-deb-task/downloads/list (* 아직 1.6.2 용 deb는 올라오지 않았다.)

JDK를 설치하려면 /etc/apt/sources.list를 아래처럼

[code groovy]
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe

deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe

deb http://security.ubuntu.com/ubuntu hardy-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted universe

deb http://archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy multiverse

deb http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse [/code]

자바쪽은 쓸게 별로 없네...

Posted by jintopark
카테고리 없음2009. 5. 28. 03:54

앞으로는 Ubuntu 8.04 LTS를 쓰기로 했다. Debian 4 안녕~

기본 설정 과정을 간단하게 복사해두자.

유틸리티


  • echo "alias ll='ls -l'" >> ~/.bash_aliases
  • vi ~/.bashrc

.bashrc에서 .bash_aliases 로딩하는 문장의 코멘트 제거


사용자 추가

  • adduser yourloginname
  • visudo

yourloginname ALL=(ALL) ALL   

라고 입력

ssh 로그인 포트 수정

  • vi /etc/ssh/sshd_config

Port 22 를 Port 24 로 수정
(사실 내키는 번호로 수정)

iptables 방화벽 설치

  • vi /etc/iptables.up.rules

해서 아래 내용 입력

[code]
*filter

#  Allows all loopback (lo0) traffic
#  and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT

#  Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#  Allows all outbound traffic
#  You can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT

# Allows HTTP and HTTPS connections from anywhere
# (the normal ports for websites)
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
-A INPUT -p tcp --dport 3000 -j ACCEPT
-A INPUT -p tcp --dport 3001 -j ACCEPT
-A INPUT -p tcp --dport 3002 -j ACCEPT
-A INPUT -p tcp --dport 3003 -j ACCEPT

#  Allows SSH connections
# THE -dport 앞에서 SSH에 Port 에 적은 번호를 여기 적는다.
# 나는 24로 했다.
-A INPUT -p tcp -m state --state NEW --dport 24 -j ACCEPT

# Allow ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT

# log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

# Reject all other inbound - default deny
# unless explicitly allowed policy
-A INPUT -j REJECT
-A FORWARD -j REJECT

COMMIT
[/code]

  • vi /etc/network/interfaces
해서, 다음 참고로 수정
[code]
...
iface lo inet loopback
pre-up iptables-restore < /etc/iptables.up.rules
...
[/code]
그리고,
  • /etc/init.d/ssh reload

ssh 다시 접속해봐. (이번에는 yourloginname 으로..)

우분투 패키지 소스

  • sudo vi /etc/apt/sources.list
[code]
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted universe

deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe

deb http://security.ubuntu.com/ubuntu hardy-security main restricted universe
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted universe[/code]

서버 이름

  • sudo vi /etc/hosts # 127.0.1.1 hostname.domain.co.kr
  • sudo vi /etc/hostname # hostname.domain.co.kr
  • sudo /bin/hostname -F /etc/hostname

패키지들

  • sudo aptitude update
  • sudo locale-gen en_GB.UTF-8
  • sudo locale-gen ko_KR.UTF-8
  • sudo /usr/sbin/update-locale LANG=en_GB.UTF-8 (이건.. 안해도..)
  • sudo aptitude safe-upgrade
  • sudo aptitude full-upgrade
  • sudo aptitude install build-essential
  • sudo dpkg-reconfigure tzdata # Asia/Seoul로 만든다.
  • sudo apt-get install ntpdate
  • sudo ntpdate ntp.ubuntu.com # Update time
  • sudo apt-get install git-core
  • sudo apt-get install subversion

MYSQL

  • sudo apt-get install mysql-server mysql-client libmysqlclient15-dev
  • sudo vi /root/.gemrc
---
[code]
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
gem: --no-ri --no-rdoc

[/code]

루비 엔터프라이즈, nginx, passenger
[code]
sudo apt-get install zlib1g-dev libssl-dev libreadline5-dev
# http://www.rubyenterpriseedition.com/download.html#ubuntu 최신버전 확인
wget http://rubyforge.org/frs/download.php/57098/ruby-enterprise_1.8.6-20090520_i386.deb
sudo dpkg -i ruby-enterprise_1.8.6-20090520_i386.deb
sudo echo "PATH=/opt/ruby-enterprise/bin:$PATH" >> /etc/environment
su -
export PATH=/opt/ruby-enterprise/bin:$PATH
ruby -v
/opt/ruby-enterprise/bin/passenger-install-nginx-module # 1 선택, 한번더
/opt/ruby-enterprise/bin/passenger-install-nginx-module # 2를 선택.
/tmp/nginx-0.6.36 # 디렉토리 물으면 입력, prefix 는 그대로, extra는
--with-http_stub_status_module --with-http_ssl_module --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
vi /etc/init.d/nginx
[/code]

[code]
# Copyright (c) 2009 Jason Giedymin, http://AcronymLabs.com
#
# Permission is hereby granted, free of charge,
# to any person obtaining
# a copy of this software and .....
#---------------------------------------
. /lib/lsb/init-functions
#--------------------------------------
# Consts
#--------------------------------------
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx

PS="nginx"
PIDNAME="nginx" #Lets you do $PS-Master or $PS-Slave
PIDFILE=$PIDNAME.pid #pid file
PIDSPATH=/opt/nginx/logs
DESCRIPTION="Nginx Server..."

RUNAS=root #user to run as

SCRIPT_OK=0 #ala error codes
SCRIPT_ERROR=1 #ala error codes
TRUE=1 #boolean
FALSE=0 #boolean

lockfile=/var/lock/subsys/nginx
NGINX_CONF_FILE="/etc/nginx/nginx.conf"

#-----------------------
# Simple Tests
#-----------------------

#test if nginx is a file and executable
test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi

#set exit condition
#set -e

#-----------------------
# Functions
#-----------------------

setFilePerms(){

if [ -f $PIDSPATH/$PIDFILE ]; then
chmod -f 400 $PIDSPATH/$PIDFILE
fi
}

configtest() {
$DAEMON -t -c $NGINX_CONF_FILE
}

getPSCount() {
return `pgrep -f $PS | wc -l`
}

isRunning(){
pidof_daemon
PID=$?

if [ $PID -gt 0 ]; then
return 1
else
return 0
fi
}

status(){
isRunning
isAlive=$?

if [ "${isAlive}" -eq $TRUE ]; then
echo "$PIDNAME found running with processes: `pidof $PS`"
else
echo "$PIDNAME is NOT running."
fi


}

removePIDFile(){
if [ -f $PIDSPATH/PIDFILE ]; then
rm -f $PIDSPATH/$PIDFILE
fi
}

start() {
log_daemon_msg "Starting $DESCRIPTION"

isRunning
isAlive=$?

if [ "${isAlive}" -eq $TRUE ]; then
log_end_msg $SCRIPT_ERROR
else
start-stop-daemon --start --quiet --chuid $RUNAS --pidfile $PIDSPATH/$PIDFILE --exec $DAEMON
setFilePerms
log_end_msg $SCRIPT_OK
fi
}

stop() {
log_daemon_msg "Stopping $DESCRIPTION"

isRunning
isAlive=$?
if [ "${isAlive}" -eq $TRUE ]; then
start-stop-daemon --stop --quiet --pidfile $PIDSPATH/$PIDFILE

removePIDFile

log_end_msg $SCRIPT_OK
else
log_end_msg $SCRIPT_ERROR
fi
}

reload() {
configtest || return $?

log_daemon_msg "Reloading (via HUP) $DESCRIPTION"

isRunning
if [ $? -eq $TRUE ]; then
`killall -HUP $PS` #to be safe

log_end_msg $SCRIPT_OK
else
log_end_msg $SCRIPT_ERROR
fi
}

terminate() {
log_daemon_msg "Force terminating (via KILL) $DESCRIPTION"

PIDS=`pidof $PS` || true

[ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`

for i in $PIDS; do
if [ "$i" = "$PIDS2" ]; then
kill $i
removePIDFile
fi
done

log_end_msg $SCRIPT_OK

}

pidof_daemon() {
PIDS=`pidof $PS` || true

[ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`

for i in $PIDS; do
if [ "$i" = "$PIDS2" ]; then
return 1
fi
done
return 0
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop
start
;;
reload)
$1
;;
status)
status
;;
configtest)
$1
;;
terminate)
$1
;;
*)
FULLPATH=/etc/init.d/$PIDNAME
echo "Usage: $FULLPATH {start|stop|restart|force-reload|status|configtest|terminate}"
exit 1
;;
esac

exit 0
[/code]

nginx
  • chown root:root /etc/init.d/nginx
  • chmod +x /etc/init.d/nginx
  • vim /etc/nginx/nginx.conf

[code]
server {
    listen 80;
    # server_name www.mycook.com;
    root /home/deploy/testapp/public;
    passenger_enabled on;
}
[/code]

/etc/init.d/nginx start
  • /etc/init.d/nginx status
  • /etc/init.d/nginx stop
  • /usr/sbin/update-rc.d -f nginx defaults
  • 루비 패키지

  • aptitude install libmysql-ruby1.8
  • apt-get install libmagick9-dev
  • gem install rmagick
  • apt-get install libxml2 libxslt1-dev #노코기리 때문에...
  • gem install nokogiri
  • 마지막으로..
    • sudo /etc/init.d/nginx restart

    참고

    http://articles.slicehost.com/ubuntu-hardy
    http://github.com/jnstq/rails-nginx-passenger-ubuntu/tree/master
    Posted by jintopark
    카테고리 없음2009. 5. 15. 15:21
    4월 말경에 이런 포스트가 올라왔었다. 그루비만 설치해도 GSP에서 include 기능을 사용할 수 있게 해준다는 패치였다. 이 패치는1.6.2 부터 정식 버전에 포함되었다.

    얼마나 기다린 기능이었는지 모른다. 사실 내가 만들고 싶은 패치였지만, 실무에 바쁘다는 핑계로 시도도 하지 못하고 있었다. 이 정도면 굳이 Grails를 안쓰고 GROOVY + GSP 조합만으로도 코딩에 충분하다.

    이제 신규 프로젝트나, 완전 개편 프로젝트는 루비온레일즈로 하고 기존 서블릿 사이트의 업그레이드는 GROOVY+GSP로 하면 된다!!!
    Posted by jintopark
    카테고리 없음2009. 4. 28. 17:14
    조금 늦게 올립니다. (http://jinto.pe.kr/1112 와 함께 올립니다.)


    프로그래밍 그루비 - 10점
    기욤 라포르쥬 외 지음
    박제권 옮김/인사이트
    번역한 책은 Groovy in Action. 이 책이 나온 것은 2006년이었다. 나는 PDF로 나온 베타 버전을 사서 읽었었는데, 덕분에 그때 진행하던 프로젝트에 재미있게 적용했었다. 그때, 이런 책은 번역판 안나오나, 하는 생각을 했었다. 좋은 기술인데 국내에는 알려지지 않는게 안타까웠다.

    일년 뒤 겨울이었다. 이런 저런 사정이 생겨서, 더 이상은 회사에 출퇴근하는 생활을 하지 않겠다, 는 결심을 하고 이것 저것 손대고 있었는데, 루비온레일즈라는 것을 만져보니 너무 재미있었다. 양재동 "DAUM"사무실에서 루비 사용자 모임 세미나를 한다길래 한번 나가봤다. 그때 우연히도 김석준님께서 옆자리에 앉으셨었다. 통성명하고 몇마디 나누었는데, 알고보니 이분이 "레일스 애자일 프로그래밍"을 번역하신 분이었다.

    며칠 뒤, 다시 김석준님과 만나는 "우연"이 있었는데, 이때는 광화문 근처, 조계사 뒤쪽의 스타벅스였다. 그후로는 가끔씩 만나면서 이런 저런 이야기를 나누었고, 어쩌다 그루비에 대한 내 생각을 석준님께 이야기하기도 했었다. 한번 시작된 우연은 계속이어졌다. 김석준님이 번역서를 냈던 "인사이트"에서는 이미 Groovy in Action의 국내 판권을 가지고 있었고, 기존에 번역을 진행하던 역자가 사정이 있어서 번역을 중단한 상태였던 것. 태국으로 여행을 다녀온 이후로는, 나도 사회에 대해, 뭔가 기여좀 하면서 살고 싶다는, 그런 생각도 있었고, 전부터 번역이란걸 해보고 싶다는 욕심도 있었다.
    인사이트 측의 간단한 테스트 번역을 거친 후 2008년 1월에 "번역출판계약서"란 것을 작성하고 번역을 시작했다. 계약서에 따르면 내가 "갑" 이었다. 대기업을 다녀본 적이 없는 나는, 태어나서 처음으로 "갑"쪽에 사인을 해봤다.

    처음에는 번역 한페이지에, 빨간색 교정 메모가 두페이지는 될 정도였다. 회사에서 보려고 기사 하나를 번역하는 것과, 번역서를 만드는 일은 완전히 다른 작업이었다. 토요일이나 일요일, 또는 밤에 주로 번역을 했고, 시작한지 일년이 지난 지난 달에야 서점에 깔리게 되었다.


    책을 받아보니, 나도 이제 역자가 되었구나라는 기쁨, 처음부터 다시 번역하고 싶을 정도의 민망함. 그리고 다른 책으로 다시 도전해보고 싶다는 욕심. 같은 것들이 느껴진다.

    어쩌면 인사이트 최대의 실패작이 될지도 모르.. 지만 자바진영의 동적언어들 중에서도 그루비는 활발하게 발전하는 언어이고 확산 가능성도 높은 언어다.(고 생각한다.)

    (* 아래 사진: 아무래도 화면에 PDF를 띄워놓는 것 보다는, 출력을 해서 눈으로보고, 손으로 써가며 번역하는 편이 훨씬 편했다. 어느날 밤인가, 어릴 때 본 영화속의 모짜르트 흉내를 내보았다. 번역자란 것이 생각만큼 재미있는 직업은 아니었지만, 즐기자고 마음먹으면, 나름 견딜만 했다.)


    Posted by jintopark
    카테고리 없음2009. 4. 28. 17:02
    한번 당한 적이 있는 문제였는데도 독자의 질문에 제대로 답하지 못했었다. "Shinnara" 님의 블로그에 "def" 의 헷갈리는 부분에 대해 글이 올라왔다. def 는 어떤 경우에는 꼭 필요하고, 어떤 경우에는 생략할 수 있다.

    http://naratalk.com/302 을 읽어보시라.
    Posted by jintopark
    카테고리 없음2009. 4. 11. 13:44
    구글 앱 엔진에서 자바를 쓸 수 있다는 소식을 전했었다. 이 기능은 현재로써는 10000 명에게만 맛보기로 허용된다고 하는데, 일찍신청한 덕분에 써볼 수 있었다. (구글 앱엔진 계정은 요즘은 핸드폰으로 인증을 한단다. 구글 앱엔진 한국 개발자 토론 그룹의 김기움님이 작성한 글을 참고하자.)

    앱엔진 계정이 있다면 튜토리얼을 보고 따라하면 어플리케이션이 올라간다. 지금까지 올린 것들 모두 테스트뿐이다. ㅜㅜ

    파이선 테스트 어플리케이션 : http://stage.appspot.com
    자바 테스트 어플리케이션 : http://dailypick.appspot.com


    ----- 09.04.12 1 AM 에 추가 -----
    간단한 절차를 적어두면

    1. JDK 다운로드 (JAVA 5또는 JAVA 6 모두 가능, 구글 앱엔진에서는 6를 씀)
    2. ANT 다운로드
    3. 앱엔진 자바 SDK 다운로드
    4. SDK 압축을 풀고
    demos\new_project_template\src\WEB-INF\appengine-web.xml 파일을 열어서
    어플리케이션 아이디를 수정
    <application>new-project-template</application>
    <application>자신이 생성한 어플리케이션 아이디로</application>

    5. 도스창을 열고 demos\new_project_template 로 이동

    C:\...\demos\new_project_template>ant
    .... 실행 결과 표시
    C:\...\demos\new_project_template>..\..\bin\appcfg.cmd update www
    ... 실행결과 표시
    

    이제 서버에 접속해서 확인해보면 된다.

    ---------------------------
    P.S. 원래는 자바를 쓸 수 있게 해달라고 요청하면, 메일로 승인되었다는 답장이 온다는데, 나는 안왔다.. ... 하지만 자바 어플리케이션을 올려보니.. 올라간다.. 이게 뭐지?
    Posted by jintopark
    카테고리 없음2009. 4. 8. 18:06

    기욤 아저씨의 블로그에 "구글 앱 엔진에서 그루비를 써보아요!"라는 글이 올라왔다. 처음 든 생각은, 이거, 며칠 늦은 만우절 농담이네. 헌데, 설마.. 하며 링크들을 살포시 눌러보니...

    구글 블로그 : "앱 엔진에서 자바를 쓸 수 있다." : 어, 진짜?

    스프링쪽에도 글이 올라와있다. : "write your Google App Engine applications in Groovy!"  (이 쪽에는 간단한 튜토리얼도 있네?)

    오옷!, 엔제인가 앱엔진에서 그루비 쓰게 해달라고 전세계 찌질이 그루비빠들이 구글에 졸라댈 때 나도 함께 졸랐었는데, 그때 졸라대면서도 속으로는 '설마 안될꺼야,' 라고 생각했었다. 우짜둥둥 경사로다. ^^


    ----

    P.S. 사실 JVM을 열어준거니까, JRuby, Scala, Jython도 모두 쓸 수 있다. ^^

    Posted by jintopark
    카테고리 없음2009. 4. 6. 03:20
    그루비의 XMLBuilder를 이용하는 간단한 그루비 클래스를 만들고, 이를 자바 클래스쪽에서 사용하는 방법을 시연하는 (한글로된) 글이 있다.

    이동국님의 블로그 : http://blog.openframework.or.kr/77

    이동국님의 블로그에는
    1. HTTPClient를 쉽게 만들게 해주는 HttpBuilder소개도 올라와 있다. http://blog.openframework.or.kr/87

    2. JDBC 사용 코드를 이용해서 자바보다 그루비가 얼마나 간결한지 보여주는 예제도 있다.
    http://blog.openframework.or.kr/76

    Posted by jintopark

     

     
    «이전  1 2 3 4 5  다음»