Pages

12/23/2013

Create eclipse project by sbt

sbt만으로도 작업하면 좋겠지만 그래도 오랬동안 사용한 eclipse를 버릴 수는 없다..콜록
sbt는 sbteclipse plugin만 추가하면 eclipse프로젝트를 쉽게 생성 할 수 있다.
https://github.com/typesafehub/sbteclipse
사용방법부터 source까지 친절하게 나와있다.
sbteclipse를 한번 사용해보자. (우선 sbt 0.13 버전이 필요하다..난 이미 설치되어있다^^콜록)

$mkdir testSbtEclipse
$cd testSbtEclipse
$vi build.sbt

name := "testSbtEclipse"

version := "1.0"

scalaVersion := "2.10.3"

setting 사이에 꼭 Enter로 띄워주도록 하자..^^

build.sbt가 만들어졌으면 sbt를 실행해보자.
$sbt
[info] Set current project to testSbtEclipse (in build file:/Users/sil-010/Documents/scala-works/workspace/testSbtEclipse/)
> exit
$ll
drwxr-xr-x  5 sil-010  staff  170 12 23 12:30 .
drwxr-xr-x  8 sil-010  staff  272 12 23 11:56 ..
-rw-r--r--  1 sil-010  staff   70 12 23 12:28 build.sbt
drwxr-xr-x  3 sil-010  staff  102 12 23 12:23 project
drwxr-xr-x  3 sil-010  staff  102 12 23 12:30 target
프로젝트 폴더가 생성된것을 확인 할 수 있다.
이제 sbteclipse플러그인을 추가해보자.
global로 추가하려면 ~/.sbt/0.13/plugins/ 폴더
아니면 현제 프로젝트 폴더안의 project폴더안에 plugins.sbt 파일을 생성하고 sbteclipse를 추가한다.
$vi ~/Documents/scala-works/workspace/testSbtEclipse/project/plugins.sbt

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")

eclipse 명령어로 eclipse 프로젝트를 생성한다.
$sbt eclipse
[info] Loading project definition from /Users/sil-010/Documents/scala-works/workspace/testSbtEclipse/project
[info] Updating {file:/Users/sil-010/Documents/scala-works/workspace/testSbtEclipse/project/}testsbteclipse-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to testSbtEclipse (in build file:/Users/sil-010/Documents/scala-works/workspace/testSbtEclipse/)
[info] About to create Eclipse project files for your project(s).
[info] Updating {file:/Users/sil-010/Documents/scala-works/workspace/testSbtEclipse/}testsbteclipse...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Successfully created Eclipse project files for project(s):
[info] testSbtEclipse
$ll
drwxr-xr-x  8 sil-010  staff  272 12 23 12:43 .
drwxr-xr-x  8 sil-010  staff  272 12 23 11:56 ..
-rw-r--r--  1 sil-010  staff  589 12 23 12:43 .classpath
-rw-r--r--  1 sil-010  staff  368 12 23 12:43 .project
-rw-r--r--  1 sil-010  staff   70 12 23 12:28 build.sbt
drwxr-xr-x  5 sil-010  staff  170 12 23 12:43 project
drwxr-xr-x  4 sil-010  staff  136 12 23 12:43 src
drwxr-xr-x  5 sil-010  staff  170 12 23 12:43 target
많이 보던 익숙한 폴더 구조를 확인 할 수있다. 끄읕^^

12/08/2013

Install the ensime & sublime-ensime (Sublime text 3)

다음은 scala개발을 더 원할하게 도와줄 ensime을 설치 하겠다. 그리고 sublime-ensime플러그인까지 설치하겠다. 드디어 eclipse와 작별하는건가.. 콜록.. ㅎ

우선 sbt에 ensime-sbt-cmd plugin을 설치하자.

mkdir ~/.sbt/0.13/plugins
echo "addSbtPlugin(\"org.ensime\" % \"ensime-sbt-cmd\" % \"0.1.2\")" >> ~/.sbt/0.13/plugins/plugins.sbt
플러그인 설치 끝.
다음은 전에 만들었던 project혹은 새로운 프로젝트 폴더로 가서 ensime config file을 생성한다.
$sbt
[info] Loading global plugins from /Users/jknyou/.sbt/0.13/plugins
[info] Updating {file:/Users/jknyou/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading http://repo1.maven.org/maven2/org/ensime/ensime-sbt-cmd_2.10_0.13/0.1.2/ensime-sbt-cmd-0.1.2.jar ...
[info]  [SUCCESSFUL ] org.ensime#ensime-sbt-cmd;0.1.2!ensime-sbt-cmd.jar (1412ms)
[info] Done updating.
[info] Set current project to testsbt (in build file:/Users/jknyou/workspace/scalaworks/testSbt/)
> ensime generate
[info] Gathering project information...
[info] Processing project: ProjectRef(file:/Users/jknyou/workspace/scalaworks/testSbt/,testsbt)...
[info]  Reading setting: name...
[info]  Reading setting: organization...
[info]  Reading setting: version...
[info]  Reading setting: scalaVersion...
[info]  Reading setting: moduleName...
[info]  Evaluating task: projectDependencies...
[info]  Evaluating task: unmanagedClasspath...
[info]  Evaluating task: managedClasspath...
[info]  Evaluating task: internalDependencyClasspath...
[info]  Evaluating task: unmanagedClasspath...
[info]  Evaluating task: managedClasspath...
[info]  Evaluating task: internalDependencyClasspath...
[info]  Evaluating task: exportedProducts...
[info]  Evaluating task: unmanagedClasspath...
[info]  Evaluating task: managedClasspath...
[info]  Evaluating task: internalDependencyClasspath...
[info]  Evaluating task: exportedProducts...
[info]  Reading setting: sourceDirectories...
[info]  Reading setting: sourceDirectories...
[info]  Reading setting: classDirectory...
[info]  Reading setting: classDirectory...
[info]  Reading setting: ensimeConfig...
[info] Wrote configuration to .ensime
성공!
다음은 sublime의 package Controller를 사용하여 sublime-ensime 를 설치하자.
Preferences > Package Control > Install Package > Ensime
설치가 완료되면 Ensime server를 패키지에 설치한다. sublime pageckage 확인은
sublime console에서 sublime.packages_path() 명령어로 알 수 있다.
scala버전에 맞게 Ensime을 다운 받는다. Download
Sublime pacakge폴더에 디렉토리를 생성한다.
Ensime/server (ex:/Users/jknyou/Library/Application Support/Sublime Text 3/Packages/Ensime/server) 다운 받은 ensime을 Ensime/server 디렉토리에 압축을 푼다.
drwxr-xr-x   7 jknyou  staff   238 12  8 13:20 .
drwxr-xr-x   4 jknyou  staff   136 12  8 13:20 ..
-rw-r--r--@  1 jknyou  staff   251  2 27  2013 LICENSE
-rw-r--r--@  1 jknyou  staff  3889  2 27  2013 README.md
drwxr-xr-x@  4 jknyou  staff   136  2 27  2013 bin
drwxr-xr-x@ 22 jknyou  staff   748  2 27  2013 elisp
drwxr-xr-x@ 17 jknyou  staff   578  2 27  2013 lib
jknyouui-MacBook-Air:server jknyou$ pwd
/Users/jknyou/Library/Application Support/Sublime Text 3/Packages/Ensime/server
restart Sublime Text
마우스 우클릭, Ensime > Maintenance > start
에러를 표시해주는 똑똑한 scala editer가 된것을 확인 할 수 있다.
언제나 친절한 Documentation ^^
https://github.com/sublimescala/sublime-ensime
https://www.dropbox.com/sh/ryd981hq08swyqr/V9o9rDvxkS/ENSIME%20Releases

Install SBT

sbt는 Simple Build Tool의 약자다. project 셋팅, 빌드등을 수행해주는 역할을 한다. 요즘 스칼라를 사용해보려고 하고있다. Intelli-j나 eclipse를 사용하면 되지만 왠지...sublime으로 하고 싶은 충동이 들었다... 스칼라 스크립트로 실행해도 되지만...프로그래머는 귀찮은 작업을 싫어해야한다..ㅋㅋ 그래서 sbt를 설치 하게 되었다..콜록

sbt는 설치하는 법은 어려가지가 있다. sbt setup doc 에서 확일해 볼수 있듯이 macports, brew등을 이용해 인스톨 할 수 있다.(난 언제나 맥 위주로...콜록) 하지만 난 언제나 download해서 설치하는 것을 좋아한다..콜록

다운 받자. download sbt-0.13.0
압축을 풀쟈.

tar -zxvf ./sbt.tgz
필요한 launch만 가져온다. 경로는 클래스 패스로 잡을 경로또는 잡혀있는 경로로 한다. 런처를 실행 시킬 스크립트를 만든다.
cp bin/sbt-launch.jar ~/bin
cd ~/bin
touch sbt
vi sbt
SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"
java $SBT_OPTS -jar `dirname $0`/sbt-launch.jar "$@"
끝! documentation에 있는것 처럼 헬로우 월드를 찍어보자!! ㅋㅋㅋㅋ
mkdir hello
cd hello
echo 'object Hi { def main(args: Array[String]) = println("Hi!") }' > hw.scala
sbt run
잘된다...콜록 폴더 구조 및 설명도 자세히 나와있다. Documanetation 만세....콜록

10/03/2013

Django(python) - url controller

url을 작성해보자. urls.py에 정의하면되는데 친절하게 example까지 나와있다.

from django.conf.urls import patterns, include, url
from basic_board import views

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'django_board.views.home', name='home'),
    # url(r'^django_board/', include('django_board.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
    url(r'^$', views.home),
    url(r'^boards/', views.getAllList),
    url(r'^test/', views.test),
)
다음은 컨트롤러를 작성하자. testapp폴더에 views.py를 수정하자.
# -*- coding: utf-8 -*-
from django.shortcuts import render_to_response
from django.core import serializers

from django.http import HttpResponse

from django.views.decorators.csrf import csrf_exempt

from django.utils import timezone
from django.utils import simplejson

from testapp.models import Board


def home(req):
 return render_to_response('index.html')

def test(req):
 return render_to_response('test.html')

@csrf_exempt
def getAllList(req):
 if req.method == 'POST':
  pass

 boardList = Board.objects.order_by('-id')
 print req.method
 return HttpResponse(serializers.serialize('json', boardList), content_type="application/json") 
source 자세한건 천천히 업데이트해야겟다..콜록

Django(python) - settings.py, db, model

django 프로젝트만드는것에 이어서 app을 만들어보자.
장고는 한프로젝트에 여러개의 app을 생성 할 수 있다. 반대로 하나의 앱을 여러개의 프로젝트에 적용 할 수도 있다. app을 생성하자. manage.py가 있는 폴더에서

python manage.py startapp testapp
app을 생성했다.
testapp폴더가 생성되고 그안에 파이썬 파일들이 생성된다. 파일의 용도에 대해 알아보자.
models.py - 우리가 사용할 도메인 모델을 정의할때 쓴다.
tests.py - 이름 그대로로 test할때 사용한다.
views.py - spring에서 컨트롤러라고 생각하면 될 것 같다.
settings.py 를 수정하자.
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'testBoard',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': 'root',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '3306',                      # Set to empty string for default.
    }
}
database를 mysql을 사용했다. mysql을 사용하려면 MySQLdb 모듈이 필요하다. 다른 DB도 마찬가로 모듈이 필요하다. sqlite같이 필요없는 것도 있지만 대부분 필요하다. 필요한 모듈을 설치한다. 시간도 맞게 바꿔주고 app을 등록하자.
TIME_ZONE = 'Asia/Seoul'

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'testapp',
)
이외에 정적파일 url, 디렉토리등을 자신에게 맞게 설정한다. 설정이 끝나면 table을 생성할 수있다.
python manage.py syncdb
models.py에 모델을 정의하면 테이블이 생성된다. django는 orm을 제공하고있어서 별다른 모듈이 필요없다. 모델을 정의해보자. model은 models.Model을 상속해서 생성한다. 보통의 orm모델 생성 방식과 비슷하다..너무 내생각인가 콜록.. ㅎㅎ
from django.db import models

class Board(models.Model):
 title = models.CharField(max_length=50, blank=True)
 content = models.CharField(max_length=250, blank=True)
 writer = models.CharField(max_length=50, blank=True)
 created_date = models.DateField(null=True, blank=True)
table을 생성하기전에 쿼리를 먼저 확인 할 수 있다.
python manage.py sqlall testapp
syncdb를 다시 실행하면 table이 생성된다.

Django(python) install and startproject

Django 장고라고 읽는다. d는 묵음...콜록
이름이 멋지다...맘에 듬. https://www.djangoproject.com/
웹 사이트에서 보면 알 수 있듯이 django는 python으로만든 web framework다. framework라는 단어만 들으면 마음이 편안해진다. 이 프레임워크가 날 도와줄 거니까...하하..

우선 장고를 설치하자!! 물론 python은 설치 되어 있어야한다.
https://www.djangoproject.com/download/
다운로드 페이지에서 설치 방법까지 나와있다.친절하다. 다운받고 압축을 푼다.

cd Django-1.5.4
sudo python setup.py install
설치후 확인
django-admin.py
usage가 나온다. 설치 끝

startproject 로 프로젝트를 만들어 보자.

django-admin.py startproject testProject
프로젝트가 생성되었다.

폴더 구조를 한번 보자.

./manage.py 이름 그대로다. 장고 프로젝트를 매니지해준다. 프로젝트안에서 새로운 앱을 생성하거나 서버를 돌리는등 모든 관리를 한다.
./testProject/settings.py 장고 앱의 설정 파일 (spring에서 root-context.xml 이라고 생각하면 될 것 같다.)
./testProject/url.py 앱의 url (spring에서 requestMapping 같은 느낌?콜록)
./testProject/wsgi.py 서버 관련 설정 파일

난 사실 java개발자다....python을 좋아하지만 ㅋㅋㅋ
서버를 한번 돌려보자.
python manage.py runserver
포트를 변경해서 돌릴 수도 있다.
python manage.py runserver 8081
이상~ django로 프로젝트를 만들었다. 나머지는 나중에 해야한다...나가봐야한다...난 잘나가니까..콜록

9/27/2013

install redis on centos

cache...저도 참 좋아하는데요...콜록 ㅋㅋㅋ 사실 redis는 cache가 아니다...DB다. 난 근데 cache로 사용한다. redis는 in memory db로 memcache와 자주 비교된다.cache와 비슷한 속도를 가졌으면서 더 많은 기능을 제공한다. 캐시와는 다르게 disk에 저장 할 수도 있고 문자열, Set, Sorted Set, Hash, List등의 다양한 Data Type을 지원한다. 이미 많은 프로젝트에서 크게 기여 하고 있는 검증된!!! 환상적 오픈소스이다..콜록

그래서 오늘은 위대한 redis를 위해 redis설치를 적어 놓겠다!!!ㅎㅎ OS는 내가 좋아하는 centos^^

일단 다운받고 설치 하자. http://redis.io/
redis사이트에서 받을 수 있고 친절한 documentation도 볼 수 있다.

cd /usr/local/src
wget http://download.redis.io/releases/redis-2.6.16.tar.gz
tar xzf redis-2.6.16.tar.gz
mv redis-2.6.16/ redis
cd redis
make
바로 사용하면 된다.....설치도 쉽다...콜록
src/redis-server
클라이언트로 접속하여 테스트해 볼 수 있다.
src/redis-cli
ping
센스있다...핑퐁ㅋㅋㅋㅋㅋ 편하게 사용하기 위해 서비스에 등록하자.
mkdir /etc/redis
cp redis.conf /etc/redis
vi /etc/redis/redis.conf
필요한 설정들을 수정한다. daemonize yes loglevel notice logfile /var/log/redis.log dir /var/lib/redis
친절한 분이 스크립트를 만들어 놓으셧다. 냉큼 받아서 경로만 수정하자
wget https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
vi redis-server
redis="/usr/local/src/redis/src/redis-server"

mv redis-server /etc/init.d
chmod 755 /etc/init.d/redis-server
chkconfig --add redis-server
chkconfig --level 345 redis-server on

vi /etc/sysctl.conf
vm.overcommit_memory = 1

sysctl vm.overcommit_memory=1
service redis-server start
끝~ 이제 입맛에 맛게 사용하면된다. jedis를 쓰든뭘하든 ㅎㅎ

9/25/2013

python-Rest call(urllib)

프로그래밍을 하다보면 rest call을 해야 할때가 종종 있다....별로없나?;;콜록 ㅎ python은 rest call도 상당히 편하다~ 다른 언어들도 편하지만....음 파이썬도 편하다^^ 정말 짧은 코드로 rest call을 효과적으로 할 수 있다.

언제나 그렇듯 필요한 라이브러리는 항상 훌륭한 분들이 만들어 놓으셨다^^ urllib를 사용하면 쉽게 rest call을 처리 할 수 있다.
http://docs.python.org/2/library/urllib.html document도 참 친절하다^^

모듈을 인스톨하거나 다운 받을 필요없다 바로 사용 할 수 있다. 우와~

# lib import
import json, urllib2, urllib

# target url
BASE_URL = 'http://apis.daum.net/local/geo/addr2coord'

# 사용할 api key
apikeys = [
 'DAUM_LOCAL_DEMO_APIKEY'
]

# 파라미터들
params = {
 'apikey' : apikeys[count%4],
 'q' : '성남시 분당구 율동 300-2',
 'output' : 'json'
}
# urlencode 후 rest call
req = urllib2.urlopen(BASE_URL, urllib.urlencode(params)).read()

# json data
jsonData = json.loads(req)

끝 너무 간단하다~^^ 간단해도 쓸려고 하면 기억 나지않는다..콜록... 끝

9/22/2013

python Scrapy (crawling)

crawling.....말이 크롤링이지 그냥 웹페이지를 긁어오기다 콜록.. ㅋㅋ 나는 python을 좋아한다. 훌륭한 개발자분들이 편리한 모듈, 프레임워크등을 많이 만들어 놓으셨다. 감사합니다^^

Crawling 하는 방법은 엄청 많다. 그중에서 나는 Scrapy를 사용했다...스크랩파이? 콜록 ㅋㅋ 사용법은 매우 간단하다. Scrapy Tutorial 튜토리얼도 매우 친절하게 나와있다.

당연히....python이 필요하다 ㅋㅋㅋ 2.6 또는 2.7버전이 필요하다. 3.0은 안해 봣지만 안됄지 쉽다..콜록 ㅋㅋ pip 나 easy_install을 이용하여 편하게 이지 인스톨한다..콜록

easy_install Scrapy
pip install Scrapy
설치가 끝낫다....필요한 디펜던시들은 알아서 처리해준다...편하다 콜록...ㅋㅋ

scrapy 프로젝트를 생성한다.

scrapy startproject tutorial
scrapy.cfg: 프로젝트의 설정 파일 tutorial/: 프로젝트 폴더 tutorial/items.py: 사용할 item, 뽑아낼 데이터가 들어 갈 것이다. tutorial/pipelines.py: 뽑아낸 데이터로 뭔가 처리할때 쓴다. 뭔가..ㅎ tutorial/settings.py: 프로젝트 설정 파일 tutorial/spiders/: 정보를 모아줄 거미들...ㅋㅋ동작할 크롤러들이다.

item.py에 사용할 item을 추가한다.

from scrapy.item import Item, Field
class HealthItem(Item):
 name = Field()
 phone = Field()
 address = Field()
 home_page = Field()
spiders폴더에 정보를 모아 줄 거미를 추가한다..ㅎㅎ
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector

from vwell.items import HealthItem

class HealthSpider(BaseSpider):
    # spider 이름 유니크해야한다.
    name = "health"
    allowed_domains = ["cdc.go.kr"]
    # 크롤링할 url
    start_urls = [
     "https://nip.cdc.go.kr/nip/manage.do?service=getMedicalCenterList&ARTICLECNT=100&CURPAGE=1&SIDCOD=1100000000&SelFlag=HC"
    ]
    
    # 데이터 파싱
    def parse(self, response):
  hxs = HtmlXPathSelector(response)
  healths = hxs.select('//*[@id="contents"]/div[@class="conbox sch"]/div[@class="tableA"]/table/tbody/tr')
  items = []
  count = 0

  for health in healths:
   item = HealthItem()
   item['name'] = health.select('//td')[count*4].select('text()').extract()[0]
   item['phone'] = health.select('//td')[count*4+1].select('ul/li')[0].select('text()').extract()
   item['phone'].append(health.select('//td')[count*4+1].select('ul/li')[1].select('text()').extract()[0])
   item['address'] = health.select('//td')[count*4+2].select('text()').extract()[0]
   item['home_page'] = health.select('//td')[count*4+3].select('a/@href').extract()[0]
   count += 1
   items.append(item)

  return items
HtmlXPathSelector의 select를 이용해 html을 파싱한다. 사용법은 금방 적응 할 정도로 간단하다. tag이름과 / 로 태그를 선택할 수있다.
hxs.select('//ul/li')
@를 이용하여 태그의 properties에 접근할 수있다.
hxs.select('//*[@id="contents"]/div[@class="conbox sch"]/div[@class="tableA"]/table/tbody/tr')
text()로 value값을 가져 올 수 있다. extract()를 할때 List로 반환 된다는데 주의하자.
hxs.select('//ul/li/text()').extract()
scrapy.cfg 파일있는 폴더로가서 실행해보자.
scrapy crawl health -o items.json -t json
크롤링한 결과는 items.json 파일에 저장되어있을 것이다.

크롤링한 데이터로 다른 처리를 추가하고 싶다면 pipeline을 이용하면된다. pipelines.py파일에 처리할 클래스를 추가하고 settings.py등록해주면 끝이다. 간단하다. 나는 유니코드가 보기 싫어서 스트링으로 저장하는 pipeline을 추가햇다.

class JsonWriterPipeline(object):

 def __init__(self):
  self.file = open('healthList.json', 'w')

 def process_item(self, item, spider):
  newItem = {}
  newItem['name'] = item['name'].encode('utf-8')
  newItem['phone'] = item['phone']
  newItem['address'] = item['address'].encode('utf-8')
  newItem['home_page'] = item['home_page'].encode('utf-8')

  line =  '{ "name" : "%s", "phone" : ["%s", "%s"], "address" : "%s", "home_page" : "%s" },' %(newItem['name'], newItem['phone'][0].encode('utf-8'), newItem['phone'][1].encode('utf-8'), newItem['address'], newItem['home_page']) + '\n'
  self.file.write(line)
  return item
settings.py에 등록해준다.
ITEM_PIPELINES = [
    'vwell.pipelines.JsonWriterPipeline'
]
다시 실행한다. 끝~ 웹페이지 크롤링....쉽다...콜록^^
source : https://github.com/semicolok/python-scrapy

9/05/2013

install mariaDb(centos)

난 공짜를 좋아한다...그래서 mariaDb를 좋아한다....(그래서 자꼬 머리가 빠지나?..콜록) mariaDb는 mysql이랑 완전 똑같다. 너므 비슷하다~ 더 빠르다는데...그건 잘 모르겟다..난 둔하다 ㅠㅠ ㅋㅋㅋ

설치하는 방법은 매우 간단하다~ 근데 외우지는 못한다.;;;ㅎㅎ 그래서 정리해 놓는다.

yum으로 인스톨 할테다. repo파일을 추가하자.

 vi /etc/yum.repos.d/MariaDB.repo
붙여넣긔!
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5.32/centos6-amd64/
# 버전이나 os는 알맞게 변경
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum update 하고 인스톨 실행!!
yum update
yum install MariaDB-server MariaDB-client
service mysql start
끝...너무 성의없나? 간간히 수정해야지 ㅎㅎ 콜록!

install nginx(Centos)

nginx 설정이 apache보다 쉽고(개인적으로...콜록) 성능도 더 좋은(잘 느끼진 못하지만^^;) nginx설치 방법을 정리해보겠다. mac을 좋아하지만 개발할때 많이 사용하는 centos를 기준으로 정리해보겠다.

설치방법은 간단하다. 우선 다운 받고 압축을 푼다.

wget http://nginx.org/download/nginx-1.5.4.tar.gz
tar -xzvf nginx-1.5.4.tar.gz
압축 풀고 make / make install 하면 끝난다. make 하기전에 gcc, make 등 필요한 것들을 먼저 install 한다.
yum install gcc gcc-c++ make autoconf wget libxml2-devel perl perl-devel perl-ExtUtils-*  pcre-devel openssl-devel zlib library cpan
난 yum을 좋아한다...콜록 prefix와 module을 설정하고 make/make install
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-mail_ssl_module --with-http_mp4_module --with-mail
make
make install
다음은 실행 파일을 만들어 준다. 그래야 편하다...
vi /etc/init.d/nginx
붙여넣긔!!!
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
 
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
$nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
퍼미션 변경하고 실행하고 정지
chmod +x /etc/init.d/nginx
service nginx start
service nginx stop
이상!!! 콜록....

9/04/2013

Sublime Text Keyboard shortcuts - OS X

오늘은 사용할려고 하면 생각안나는 단축키를 정리해 보겠다.
Edit 툴마다 다 비슷하지만 조금씩 다른 단축키 쓸때마다 헷갈린다.
나만 그런가?^^ 콜록
먼저 내가 가장 많이 쓰는 Sublime text 단축키를 먼저 정리해 보겠다.
sublime text는 친절하게 shortcuts을 정리한 문서를 제공한다.
sublime text keyboard shortcuts
다쓰는건 무리고....자주 쓰는 것만 정리해야겠다. 너무 많다...콜록

시작!! start!!

cmd + x : Delete line
cmd + z : undo
cmd + Shift + z : redo
cmd + y : redo
Ctrl + k : 라인의 현 커서 위치 이후로 삭제
cmd + ENTER : Insert line after
cmd + Shift + ENTER : Insert line before
cmd + Shift + d : Duplicate line(s)
Ctrl + cmd + UP/DOWN : Move line/selection up, down
cmd + ] : 들여쓰기
cmd + [ : 내어쓰기
cmd + / : 주석처리/주석해제
cmd + Shift + v : Paste and indent correctly
cmd + l : Select line - Repeat to select next lines
Ctrl + Shift + UP/DOWN : 세로영역 수정
cmd + f : Find
cmd + Alt + f : Replace
cmd + t, cmd + p : 파일명으로 탭 찾기
cmd + Shift + f : 특정 폴더나 파일에서 내용 검색
Ctrl + g : 입력한 라인으로 이동
cmd + i : 현재 단어 찾기
cmd + Shift + g : 현재 단어 모두 찾아서 선택
Ctrl + Shift + m : 괄호 안의 내용을 모두 선택
cmd + option + LEFT/RIGHT : 탭 이동
Ctrl + m : 여는 괄호/ 닫는 괄호로 이동
cmd + Shift + t : Open last closed tab
cmd + = : font size 크게
cmd + - : font size 작게
cmd + Shift + p : open prompt
Ctrl + ` : open sublime console
cmd + Alt + 1,2,3,4 : 세로분할 수
cmd + Alt + 5 : 그리드 보기
Ctrl + 1,2,3,4 : 세로분할 창 선택
Ctrl + Shift + 1,2,3,4 : 탭을 세로분할창으로 이동
cmd + K, cmd + U : Transform to Uppercase
cmd + K, cmd + L : Transform to Lowercase
이상 sublime text 단축키 끝.^^ 콜록.

9/03/2013

Mac OS X localhost name modification

간단한 설정 부터 올려보자. 콜록
개발을 하다 보면 localhost 명을 변경해야 할때도 있다.
그리고 변경하면 수월한 작업이 가능하다.
mac을 사용하기 때문에 mac에서 하는 방법만 기억해 놓아야지 ㅎㅎ
그리고 윈도우 설정은 너무 쉽다...도 쉽지만;;;
내 기억이 맞다면
windows는 system32 > drive > etc > host
파일일것이다.

맥은
sudo vi /private/etc/hosts
dscacheutil -flushcache

위 코드와 같이 파일을 수정하고 캐쉬를 날려주면 되겠다.
나중엔 이쁘게써야지^^
영어로 써야지...콜록 ㅋㅋㅋ

9/02/2013

Blog start

어떻게 사용하는 거지? 콜록.... 처음 블로그를 해보는 초보로서....난감하다. 글이 올라가긴 하는건가...기침이 난다...콜록 반말해도 되나?^^ 아무도 안보니 상관없겟다. ㅋㅋㅋ