2014년 12월 30일 화요일

[AnDrOiD] 화면 캡쳐 방지


setContentView(); 이전에 아래의 코드를 넣는다.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);


출처 : http://biig.tistory.com/54

2014년 12월 10일 수요일

[AnDrOiD] ADT 와 BlueStacks 연동



c:\> adb connect 127.0.0.1:5555
connected to 127.0.0.1:5555

unable to connected to 127.0.0.1:5555 이 나오는 경우 포트를 변경 한다.




2014년 11월 21일 금요일

[JaVaScRiPt] 태그 형식 제거

/**
 *  태그 형식 replace
 * */
function tagReplace(obj){
 if(obj.value.length > 0){
  var regex = /(<\s*[a-zA-Z]+\s*>|<\s*[a-zA-Z]+\s*|<\s*\/[a-zA-Z]+\s*>)/gi;
  obj.value = obj.value.replace(regex, '').trim();
 }
} // function tagReplace

2014년 9월 23일 화요일

[MySqL] Data Type

- 이미지 클릭시 원본 크기로 볼 수 있습니다. -

2014년 9월 19일 금요일

[MySqL] 국가이름을 반환 하는 function

경고 : DBA 가 아닌 사람이 어쩔수 없이 노가다(?)로 작성한 function 입니다. 그러므로 성능이나 다른 문제가 있을 수도 있습니다.

DELIMITER $$
DROP FUNCTION IF EXISTS FN_GetContryName $$
CREATE FUNCTION FN_GetContryName(country VARCHAR(5)) RETURNS VARCHAR(20)
 BEGIN
     DECLARE result VARCHAR(50);
  
  IF country = 'DEVEL' THEN SET result = '개발';
  -- ISO 3166-1 alpha-2, ISO 3166-1 alpha-3, ISO 3166-1 numeric 을 이용
  ELSEIF country = 'GH' OR country = 'GHA' OR country = '288' THEN SET result = '가나';
  ELSEIF country = 'GA' OR country = 'GAB' OR country = '266' THEN SET result = '가봉';
  ELSEIF country = 'GY' OR country = 'GUY' OR country = '328' THEN SET result = '가이아나';
  ELSEIF country = 'GM' OR country = 'GMB' OR country = '270' THEN SET result = '감비아';
  ELSEIF country = 'GG' OR country = 'GGY' OR country = '831' THEN SET result = '건지 섬';
  ELSEIF country = 'GP' OR country = 'GLP' OR country = '312' THEN SET result = '과들루프';
  ELSEIF country = 'GT' OR country = 'GTM' OR country = '320' THEN SET result = '과테말라';
  ELSEIF country = 'GU' OR country = 'GUM' OR country = '316' THEN SET result = '괌';
  ELSEIF country = 'GD' OR country = 'GRD' OR country = '308' THEN SET result = '그레나다';
  ELSEIF country = 'GR' OR country = 'GRC' OR country = '300' THEN SET result = '그리스';
  ELSEIF country = 'GL' OR country = 'GRL' OR country = '304' THEN SET result = '그린란드';
  ELSEIF country = 'GN' OR country = 'GIN' OR country = '324' THEN SET result = '기니';
  ELSEIF country = 'GW' OR country = 'GNB' OR country = '624' THEN SET result = '기니비사우';
  ELSEIF country = 'NA' OR country = 'NAM' OR country = '516' THEN SET result = '나미비아';
  ELSEIF country = 'NR' OR country = 'NRU' OR country = '520' THEN SET result = '나우루';
  ELSEIF country = 'NG' OR country = 'NGA' OR country = '566' THEN SET result = '나이지리아';
  ELSEIF country = 'AQ' OR country = 'ATA' OR country = '010' THEN SET result = '남극';
  ELSEIF country = 'SS' OR country = 'SSD' OR country = '728' THEN SET result = '남수단';
  ELSEIF country = 'ZA' OR country = 'ZAF' OR country = '710' THEN SET result = '남아프리카 공화국';
  ELSEIF country = 'NL' OR country = 'NLD' OR country = '528' THEN SET result = '네덜란드';
  ELSEIF country = 'AN' OR country = 'ANT' OR country = '530' THEN SET result = '네덜란드령 안틸레스';
  ELSEIF country = 'NP' OR country = 'NPL' OR country = '524' THEN SET result = '네팔';
  ELSEIF country = 'NO' OR country = 'NOR' OR country = '578' THEN SET result = '노르웨이';
  ELSEIF country = 'NF' OR country = 'NFK' OR country = '574' THEN SET result = '노퍽 섬';
  ELSEIF country = 'NC' OR country = 'NCL' OR country = '540' THEN SET result = '누벨칼레도니';
  ELSEIF country = 'NZ' OR country = 'NZL' OR country = '554' THEN SET result = '뉴질랜드';
  ELSEIF country = 'NU' OR country = 'NIU' OR country = '570' THEN SET result = '니우에';
  ELSEIF country = 'NE' OR country = 'NER' OR country = '562' THEN SET result = '니제르';
  ELSEIF country = 'NI' OR country = 'NIC' OR country = '558' THEN SET result = '니카라과';
  ELSEIF country = 'KR' OR country = 'KOR' OR country = '410' THEN SET result = '대한민국';
  ELSEIF country = 'DK' OR country = 'DNK' OR country = '208' THEN SET result = '덴마크';
  ELSEIF country = 'DM' OR country = 'DMA' OR country = '212' THEN SET result = '도미니카 연방';
  ELSEIF country = 'DO' OR country = 'DOM' OR country = '214' THEN SET result = '도미니카 공화국';
  ELSEIF country = 'DE' OR country = 'DEU' OR country = '276' THEN SET result = '독일';
  ELSEIF country = 'TL' OR country = 'TLS' OR country = '626' THEN SET result = '동티모르';
  ELSEIF country = 'LA' OR country = 'LAO' OR country = '418' THEN SET result = '라오스';
  ELSEIF country = 'LR' OR country = 'LBR' OR country = '430' THEN SET result = '라이베리아';
  ELSEIF country = 'LV' OR country = 'LVA' OR country = '428' THEN SET result = '라트비아';
  ELSEIF country = 'RU' OR country = 'RUS' OR country = '643' THEN SET result = '러시아';
  ELSEIF country = 'LB' OR country = 'LBN' OR country = '422' THEN SET result = '레바논';
  ELSEIF country = 'LS' OR country = 'LSO' OR country = '426' THEN SET result = '레소토';
  ELSEIF country = 'RE' OR country = 'REU' OR country = '638' THEN SET result = '레위니옹';
  ELSEIF country = 'RO' OR country = 'ROU' OR country = '642' THEN SET result = '루마니아';
  ELSEIF country = 'LU' OR country = 'LUX' OR country = '442' THEN SET result = '룩셈부르크';
  ELSEIF country = 'RW' OR country = 'RWA' OR country = '646' THEN SET result = '르완다';
  ELSEIF country = 'LY' OR country = 'LBY' OR country = '434' THEN SET result = '리비아';
  ELSEIF country = 'LT' OR country = 'LTU' OR country = '440' THEN SET result = '리투아니아';
  ELSEIF country = 'LI' OR country = 'LIE' OR country = '438' THEN SET result = '리히텐슈타인';
  ELSEIF country = 'MG' OR country = 'MDG' OR country = '450' THEN SET result = '마다가스카르';
  ELSEIF country = 'MQ' OR country = 'MTQ' OR country = '474' THEN SET result = '마르티니크';
  ELSEIF country = 'MH' OR country = 'MHL' OR country = '584' THEN SET result = '마셜 제도';
  ELSEIF country = 'YT' OR country = 'MYT' OR country = '175' THEN SET result = '마요트';
  ELSEIF country = 'MO' OR country = 'MAC' OR country = '446' THEN SET result = '마카오';
  ELSEIF country = 'MK' OR country = 'MKD' OR country = '807' THEN SET result = '마케도니아 공화국';
  ELSEIF country = 'MW' OR country = 'MWI' OR country = '454' THEN SET result = '말라위';
  ELSEIF country = 'MY' OR country = 'MYS' OR country = '458' THEN SET result = '말레이시아';
  ELSEIF country = 'ML' OR country = 'MLI' OR country = '466' THEN SET result = '말리';
  ELSEIF country = 'IM' OR country = 'IMN' OR country = '833' THEN SET result = '맨 섬';
  ELSEIF country = 'MX' OR country = 'MEX' OR country = '484' THEN SET result = '멕시코';
  ELSEIF country = 'MC' OR country = 'MCO' OR country = '492' THEN SET result = '모나코';
  ELSEIF country = 'MA' OR country = 'MAR' OR country = '504' THEN SET result = '모로코';
  ELSEIF country = 'MU' OR country = 'MUS' OR country = '480' THEN SET result = '모리셔스';
  ELSEIF country = 'MR' OR country = 'MRT' OR country = '478' THEN SET result = '모리타니';
  ELSEIF country = 'MZ' OR country = 'MOZ' OR country = '508' THEN SET result = '모잠비크';
  ELSEIF country = 'ME' OR country = 'MNE' OR country = '499' THEN SET result = '몬테네그로';
  ELSEIF country = 'MS' OR country = 'MSR' OR country = '500' THEN SET result = '몬트세랫';
  ELSEIF country = 'MD' OR country = 'MDA' OR country = '498' THEN SET result = '몰도바';
  ELSEIF country = 'MV' OR country = 'MDV' OR country = '462' THEN SET result = '몰디브';
  ELSEIF country = 'MT' OR country = 'MLT' OR country = '470' THEN SET result = '몰타';
  ELSEIF country = 'MN' OR country = 'MNG' OR country = '496' THEN SET result = '몽골';
  ELSEIF country = 'US' OR country = 'USA' OR country = '840' THEN SET result = '미국';
  ELSEIF country = 'UM' OR country = 'UMI' OR country = '581' THEN SET result = '미국령 군소 제도';
  ELSEIF country = 'VI' OR country = 'VIR' OR country = '850' THEN SET result = '미국령 버진아일랜드';
  ELSEIF country = 'MM' OR country = 'MMR' OR country = '104' THEN SET result = '미얀마';
  ELSEIF country = 'FM' OR country = 'FSM' OR country = '583' THEN SET result = '미크로네시아 연방';
  ELSEIF country = 'VU' OR country = 'VUT' OR country = '548' THEN SET result = '바누아투';
  ELSEIF country = 'BH' OR country = 'BHR' OR country = '048' THEN SET result = '바레인';
  ELSEIF country = 'BB' OR country = 'BRB' OR country = '052' THEN SET result = '바베이도스';
  ELSEIF country = 'VA' OR country = 'VAT' OR country = '336' THEN SET result = '바티칸 시국';
  ELSEIF country = 'BS' OR country = 'BHS' OR country = '044' THEN SET result = '바하마';
  ELSEIF country = 'BD' OR country = 'BGD' OR country = '050' THEN SET result = '방글라데시';
  ELSEIF country = 'BM' OR country = 'BMU' OR country = '060' THEN SET result = '버뮤다';
  ELSEIF country = 'BJ' OR country = 'BEN' OR country = '204' THEN SET result = '베냉';
  ELSEIF country = 'VE' OR country = 'VEN' OR country = '862' THEN SET result = '베네수엘라';
  ELSEIF country = 'VN' OR country = 'VNM' OR country = '704' THEN SET result = '베트남';
  ELSEIF country = 'BE' OR country = 'BEL' OR country = '056' THEN SET result = '벨기에';
  ELSEIF country = 'BY' OR country = 'BLR' OR country = '112' THEN SET result = '벨라루스';
  ELSEIF country = 'BZ' OR country = 'BLZ' OR country = '084' THEN SET result = '벨리즈';
  ELSEIF country = 'BA' OR country = 'BIH' OR country = '070' THEN SET result = '보스니아 헤르체고비나';
  ELSEIF country = 'BW' OR country = 'BWA' OR country = '072' THEN SET result = '보츠와나';
  ELSEIF country = 'BO' OR country = 'BOL' OR country = '068' THEN SET result = '볼리비아';
  ELSEIF country = 'BI' OR country = 'BDI' OR country = '108' THEN SET result = '부룬디';
  ELSEIF country = 'BF' OR country = 'BFA' OR country = '854' THEN SET result = '부르키나파소';
  ELSEIF country = 'BV' OR country = 'BVT' OR country = '074' THEN SET result = '부베 섬';
  ELSEIF country = 'BT' OR country = 'BTN' OR country = '064' THEN SET result = '부탄';
  ELSEIF country = 'MP' OR country = 'MNP' OR country = '580' THEN SET result = '북마리아나 제도';
  ELSEIF country = 'BG' OR country = 'BGR' OR country = '100' THEN SET result = '불가리아';
  ELSEIF country = 'BR' OR country = 'BRA' OR country = '076' THEN SET result = '브라질';
  ELSEIF country = 'BN' OR country = 'BRN' OR country = '096' THEN SET result = '브루나이';
  ELSEIF country = 'WS' OR country = 'WSM' OR country = '882' THEN SET result = '사모아';
  ELSEIF country = 'SA' OR country = 'SAU' OR country = '682' THEN SET result = '사우디아라비아';
  ELSEIF country = 'GS' OR country = 'SGS' OR country = '239' THEN SET result = '사우스조지아 사우스샌드위치 제도';
  ELSEIF country = 'SM' OR country = 'SMR' OR country = '674' THEN SET result = '산마리노';
  ELSEIF country = 'ST' OR country = 'STP' OR country = '678' THEN SET result = '상투메 프린시페';
  ELSEIF country = 'PM' OR country = 'SPM' OR country = '666' THEN SET result = '생피에르 미클롱';
  ELSEIF country = 'EH' OR country = 'ESH' OR country = '732' THEN SET result = '서사하라';
  ELSEIF country = 'SN' OR country = 'SEN' OR country = '686' THEN SET result = '세네갈';
  ELSEIF country = 'RS' OR country = 'SRB' OR country = '688' THEN SET result = '세르비아';
  ELSEIF country = 'SC' OR country = 'SYC' OR country = '690' THEN SET result = '세이셸';
  ELSEIF country = 'LC' OR country = 'LCA' OR country = '662' THEN SET result = '세인트루시아';
  ELSEIF country = 'VC' OR country = 'VCT' OR country = '670' THEN SET result = '세인트빈센트 그레나딘';
  ELSEIF country = 'KN' OR country = 'KNA' OR country = '659' THEN SET result = '세인트키츠 네비스';
  ELSEIF country = 'SH' OR country = 'SHN' OR country = '654' THEN SET result = '세인트헬레나';
  ELSEIF country = 'SO' OR country = 'SOM' OR country = '706' THEN SET result = '소말리아';
  ELSEIF country = 'SB' OR country = 'SLB' OR country = '090' THEN SET result = '솔로몬 제도';
  ELSEIF country = 'SD' OR country = 'SDN' OR country = '736' THEN SET result = '수단';
  ELSEIF country = 'SR' OR country = 'SUR' OR country = '740' THEN SET result = '수리남';
  ELSEIF country = 'LK' OR country = 'LKA' OR country = '144' THEN SET result = '스리랑카';
  ELSEIF country = 'SJ' OR country = 'SJM' OR country = '744' THEN SET result = '스발바르 얀마옌';
  ELSEIF country = 'SZ' OR country = 'SWZ' OR country = '748' THEN SET result = '스와질란드';
  ELSEIF country = 'SE' OR country = 'SWE' OR country = '752' THEN SET result = '스웨덴';
  ELSEIF country = 'CH' OR country = 'CHE' OR country = '756' THEN SET result = '스위스';
  ELSEIF country = 'ES' OR country = 'ESP' OR country = '724' THEN SET result = '스페인';
  ELSEIF country = 'SK' OR country = 'SVK' OR country = '703' THEN SET result = '슬로바키아';
  ELSEIF country = 'SI' OR country = 'SVN' OR country = '705' THEN SET result = '슬로베니아';
  ELSEIF country = 'SY' OR country = 'SYR' OR country = '760' THEN SET result = '시리아';
  ELSEIF country = 'SL' OR country = 'SLE' OR country = '694' THEN SET result = '시에라리온';
  ELSEIF country = 'SG' OR country = 'SGP' OR country = '702' THEN SET result = '싱가포르';
  ELSEIF country = 'AE' OR country = 'ARE' OR country = '784' THEN SET result = '아랍에미리트';
  ELSEIF country = 'AW' OR country = 'ABW' OR country = '533' THEN SET result = '아루바';
  ELSEIF country = 'AM' OR country = 'ARM' OR country = '051' THEN SET result = '아르메니아';
  ELSEIF country = 'AR' OR country = 'ARG' OR country = '032' THEN SET result = '아르헨티나';
  ELSEIF country = 'AS' OR country = 'ASM' OR country = '016' THEN SET result = '아메리칸사모아';
  ELSEIF country = 'IS' OR country = 'ISL' OR country = '352' THEN SET result = '아이슬란드';
  ELSEIF country = 'HT' OR country = 'HTI' OR country = '332' THEN SET result = '아이티';
  ELSEIF country = 'IE' OR country = 'IRL' OR country = '372' THEN SET result = '아일랜드';
  ELSEIF country = 'AZ' OR country = 'AZE' OR country = '031' THEN SET result = '아제르바이잔';
  ELSEIF country = 'AF' OR country = 'AFG' OR country = '004' THEN SET result = '아프가니스탄';
  ELSEIF country = 'AD' OR country = 'AND' OR country = '020' THEN SET result = '안도라';
  ELSEIF country = 'AL' OR country = 'ALB' OR country = '008' THEN SET result = '알바니아';
  ELSEIF country = 'DZ' OR country = 'DZA' OR country = '012' THEN SET result = '알제리';
  ELSEIF country = 'AO' OR country = 'AGO' OR country = '024' THEN SET result = '앙골라';
  ELSEIF country = 'AG' OR country = 'ATG' OR country = '028' THEN SET result = '앤티가 바부다';
  ELSEIF country = 'AI' OR country = 'AIA' OR country = '660' THEN SET result = '앵귈라';
  ELSEIF country = 'ER' OR country = 'ERI' OR country = '232' THEN SET result = '에리트레아';
  ELSEIF country = 'EE' OR country = 'EST' OR country = '233' THEN SET result = '에스토니아';
  ELSEIF country = 'EC' OR country = 'ECU' OR country = '218' THEN SET result = '에콰도르';
  ELSEIF country = 'ET' OR country = 'ETH' OR country = '231' THEN SET result = '에티오피아';
  ELSEIF country = 'SV' OR country = 'SLV' OR country = '222' THEN SET result = '엘살바도르';
  ELSEIF country = 'GB' OR country = 'GBR' OR country = '826' THEN SET result = '영국';
  ELSEIF country = 'VG' OR country = 'VGB' OR country = '092' THEN SET result = '영국령 버진아일랜드';
  ELSEIF country = 'IO' OR country = 'IOT' OR country = '086' THEN SET result = '영국령 인도양 지역';
  ELSEIF country = 'YE' OR country = 'YEM' OR country = '887' THEN SET result = '예멘';
  ELSEIF country = 'OM' OR country = 'OMN' OR country = '512' THEN SET result = '오만';
  ELSEIF country = 'AU' OR country = 'AUS' OR country = '036' THEN SET result = '오스트레일리아';
  ELSEIF country = 'AT' OR country = 'AUT' OR country = '040' THEN SET result = '오스트리아';
  ELSEIF country = 'HN' OR country = 'HND' OR country = '340' THEN SET result = '온두라스';
  ELSEIF country = 'AX' OR country = 'ALA' OR country = '248' THEN SET result = '올란드 제도';
  ELSEIF country = 'JO' OR country = 'JOR' OR country = '400' THEN SET result = '요르단';
  ELSEIF country = 'UG' OR country = 'UGA' OR country = '800' THEN SET result = '우간다';
  ELSEIF country = 'UY' OR country = 'URY' OR country = '858' THEN SET result = '우루과이';
  ELSEIF country = 'UZ' OR country = 'UZB' OR country = '860' THEN SET result = '우즈베키스탄';
  ELSEIF country = 'UA' OR country = 'UKR' OR country = '804' THEN SET result = '우크라이나';
  ELSEIF country = 'WF' OR country = 'WLF' OR country = '876' THEN SET result = '왈리스 퓌튀나';
  ELSEIF country = 'IQ' OR country = 'IRQ' OR country = '368' THEN SET result = '이라크';
  ELSEIF country = 'IR' OR country = 'IRN' OR country = '364' THEN SET result = '이란';
  ELSEIF country = 'IL' OR country = 'ISR' OR country = '376' THEN SET result = '이스라엘';
  ELSEIF country = 'EG' OR country = 'EGY' OR country = '818' THEN SET result = '이집트';
  ELSEIF country = 'IT' OR country = 'ITA' OR country = '380' THEN SET result = '이탈리아';
  ELSEIF country = 'ID' OR country = 'IDN' OR country = '360' THEN SET result = '인도네시아';
  ELSEIF country = 'IN' OR country = 'IND' OR country = '356' THEN SET result = '인도';
  ELSEIF country = 'JP' OR country = 'JPN' OR country = '392' THEN SET result = '일본';
  ELSEIF country = 'JM' OR country = 'JAM' OR country = '388' THEN SET result = '자메이카';
  ELSEIF country = 'ZM' OR country = 'ZMB' OR country = '894' THEN SET result = '잠비아';
  ELSEIF country = 'JE' OR country = 'JEY' OR country = '832' THEN SET result = '저지 섬';
  ELSEIF country = 'GQ' OR country = 'GNQ' OR country = '226' THEN SET result = '적도 기니';
  ELSEIF country = 'KP' OR country = 'PRK' OR country = '408' THEN SET result = '조선민주주의인민공화국';
  ELSEIF country = 'GE' OR country = 'GEO' OR country = '268' THEN SET result = '조지아';
  ELSEIF country = 'CF' OR country = 'CAF' OR country = '140' THEN SET result = '중앙아프리카 공화국';
  ELSEIF country = 'TW' OR country = 'TWN' OR country = '158' THEN SET result = '중화민국';
  ELSEIF country = 'CN' OR country = 'CHN' OR country = '156' THEN SET result = '중화인민공화국';
  ELSEIF country = 'DJ' OR country = 'DJI' OR country = '262' THEN SET result = '지부티';
  ELSEIF country = 'GI' OR country = 'GIB' OR country = '292' THEN SET result = '지브롤터';
  ELSEIF country = 'ZW' OR country = 'ZWE' OR country = '716' THEN SET result = '짐바브웨';
  ELSEIF country = 'TD' OR country = 'TCD' OR country = '148' THEN SET result = '차드';
  ELSEIF country = 'CZ' OR country = 'CZE' OR country = '203' THEN SET result = '체코';
  ELSEIF country = 'CL' OR country = 'CHL' OR country = '152' THEN SET result = '칠레';
  ELSEIF country = 'CM' OR country = 'CMR' OR country = '120' THEN SET result = '카메룬';
  ELSEIF country = 'CV' OR country = 'CPV' OR country = '132' THEN SET result = '카보베르데';
  ELSEIF country = 'KZ' OR country = 'KAZ' OR country = '398' THEN SET result = '카자흐스탄';
  ELSEIF country = 'QA' OR country = 'QAT' OR country = '634' THEN SET result = '카타르';
  ELSEIF country = 'KH' OR country = 'KHM' OR country = '116' THEN SET result = '캄보디아';
  ELSEIF country = 'CA' OR country = 'CAN' OR country = '124' THEN SET result = '캐나다';
  ELSEIF country = 'KE' OR country = 'KEN' OR country = '404' THEN SET result = '케냐';
  ELSEIF country = 'KY' OR country = 'CYM' OR country = '136' THEN SET result = '케이맨 제도';
  ELSEIF country = 'KM' OR country = 'COM' OR country = '174' THEN SET result = '코모로';
  ELSEIF country = 'CR' OR country = 'CRI' OR country = '188' THEN SET result = '코스타리카';
  ELSEIF country = 'CC' OR country = 'CCK' OR country = '166' THEN SET result = '코코스 제도';
  ELSEIF country = 'CI' OR country = 'CIV' OR country = '384' THEN SET result = '코트디부아르';
  ELSEIF country = 'CO' OR country = 'COL' OR country = '170' THEN SET result = '콜롬비아';
  ELSEIF country = 'CG' OR country = 'COG' OR country = '178' THEN SET result = '콩고 공화국';
  ELSEIF country = 'CD' OR country = 'COD' OR country = '180' THEN SET result = '콩고 민주 공화국';
  ELSEIF country = 'CU' OR country = 'CUB' OR country = '192' THEN SET result = '쿠바';
  ELSEIF country = 'KW' OR country = 'KWT' OR country = '414' THEN SET result = '쿠웨이트';
  ELSEIF country = 'CK' OR country = 'COK' OR country = '184' THEN SET result = '쿡 제도';
  ELSEIF country = 'HR' OR country = 'HRV' OR country = '191' THEN SET result = '크로아티아';
  ELSEIF country = 'CX' OR country = 'CXR' OR country = '162' THEN SET result = '크리스마스 섬';
  ELSEIF country = 'KG' OR country = 'KGZ' OR country = '417' THEN SET result = '키르기스스탄';
  ELSEIF country = 'KI' OR country = 'KIR' OR country = '296' THEN SET result = '키리바시';
  ELSEIF country = 'CY' OR country = 'CYP' OR country = '196' THEN SET result = '키프로스';
  ELSEIF country = 'TH' OR country = 'THA' OR country = '764' THEN SET result = '타이';
  ELSEIF country = 'TJ' OR country = 'TJK' OR country = '762' THEN SET result = '타지키스탄';
  ELSEIF country = 'TZ' OR country = 'TZA' OR country = '834' THEN SET result = '탄자니아';
  ELSEIF country = 'TC' OR country = 'TCA' OR country = '796' THEN SET result = '터크스 케이커스 제도';
  ELSEIF country = 'TR' OR country = 'TUR' OR country = '792' THEN SET result = '터키';
  ELSEIF country = 'TG' OR country = 'TGO' OR country = '768' THEN SET result = '토고';
  ELSEIF country = 'TK' OR country = 'TKL' OR country = '772' THEN SET result = '토켈라우';
  ELSEIF country = 'TO' OR country = 'TON' OR country = '776' THEN SET result = '통가';
  ELSEIF country = 'TM' OR country = 'TKM' OR country = '795' THEN SET result = '투르크메니스탄';
  ELSEIF country = 'TV' OR country = 'TUV' OR country = '798' THEN SET result = '투발루';
  ELSEIF country = 'TN' OR country = 'TUN' OR country = '788' THEN SET result = '튀니지';
  ELSEIF country = 'TT' OR country = 'TTO' OR country = '780' THEN SET result = '트리니다드 토바고';
  ELSEIF country = 'PA' OR country = 'PAN' OR country = '591' THEN SET result = '파나마';
  ELSEIF country = 'PY' OR country = 'PRY' OR country = '600' THEN SET result = '파라과이';
  ELSEIF country = 'PK' OR country = 'PAK' OR country = '586' THEN SET result = '파키스탄';
  ELSEIF country = 'PG' OR country = 'PNG' OR country = '598' THEN SET result = '파푸아 뉴기니';
  ELSEIF country = 'PW' OR country = 'PLW' OR country = '585' THEN SET result = '팔라우';
  ELSEIF country = 'PS' OR country = 'PSE' OR country = '275' THEN SET result = '팔레스타인';
  ELSEIF country = 'FO' OR country = 'FRO' OR country = '234' THEN SET result = '페로 제도';
  ELSEIF country = 'PE' OR country = 'PER' OR country = '604' THEN SET result = '페루';
  ELSEIF country = 'PT' OR country = 'PRT' OR country = '620' THEN SET result = '포르투갈';
  ELSEIF country = 'FK' OR country = 'FLK' OR country = '238' THEN SET result = '포클랜드 제도';
  ELSEIF country = 'PL' OR country = 'POL' OR country = '616' THEN SET result = '폴란드';
  ELSEIF country = 'PR' OR country = 'PRI' OR country = '630' THEN SET result = '푸에르토리코';
  ELSEIF country = 'FR' OR country = 'FRA' OR country = '250' THEN SET result = '프랑스';
  ELSEIF country = 'GF' OR country = 'GUF' OR country = '254' THEN SET result = '프랑스령 기아나';
  ELSEIF country = 'TF' OR country = 'ATF' OR country = '260' THEN SET result = '프랑스령 폴리네시아';
  ELSEIF country = 'FJ' OR country = 'FJI' OR country = '242' THEN SET result = '피지';
  ELSEIF country = 'FI' OR country = 'FIN' OR country = '246' THEN SET result = '핀란드';
  ELSEIF country = 'PH' OR country = 'PHL' OR country = '608' THEN SET result = '필리핀';
  ELSEIF country = 'PN' OR country = 'PCN' OR country = '612' THEN SET result = '핏케언 제도';
  ELSEIF country = 'HM' OR country = 'HMD' OR country = '334' THEN SET result = '허드 맥도널드 제도';
  ELSEIF country = 'HU' OR country = 'HUN' OR country = '348' THEN SET result = '헝가리';
  ELSEIF country = 'HK' OR country = 'HKG' OR country = '344' THEN SET result = '홍콩';
  ELSE SET result = '알 수 없음';
  END IF;
 
     RETURN result;

 END $$
DELIMITER ;

2014년 8월 19일 화요일

[AnDrOiD] ListView 스크롤이 버벅거릴때 ImageDownloader.java 를 사용


ListView 에 웹에서 받아오는 이미지를 넣게 되는 경우 스크롤시 느려 지는 경우가 발생 한다.
이 문제 해결을 위해서 누군가가 만들어 놓은 ImageDownloader를 이용해본 결과 버벅거림이 만족 스러울 만큼 부드러워 졌다.


getView 의 소스는 아래와 같다.


private final imgDownloader imageDownloader = new ImageDownloader(); // ① 여기

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  // TODO Auto-generated method stub
  
  if(convertView == null){
   convertView = inflater.inflate(R.layout.person_list, null);
   convertView.setTag(R.id.tvName, convertView.findViewById(R.id.tvName));
   convertView.setTag(R.id.tvAge, convertView.findViewById(R.id.tvAge));
   convertView.setTag(R.id.imgView, convertView.findViewById(R.id.imgView));
  }
  
  personInfo info = (personInfo) person.get(position);
  
  if(info != null){
   TextView tvName = (TextView)convertView.getTag(R.id.tvName);
   TextView tvAge = (TextView)convertView.getTag(R.id.tvAge);
   ImageView imgView = (ImageView)convertView.getTag(R.id.imgView);
   
   tvName.setText(info.getName());
   tvAge.setText(info.getAge());
   
   imgDownloader.download(info.getImage(),(ImageView)imgView); // ② 여기

  }
  return convertView;
 }

그리고 ImageDownloader.java 의 소스는 다음과 같다.

/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.exam01;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
import android.os.Handler;
import android.util.Log;
import android.widget.ImageView;

/**
 * This helper class download images from the Internet and binds those with the provided ImageView.
 *
 * It requires the INTERNET permission, which should be added to your application's manifest
 * file.

 *
 * A local cache of downloaded images is maintained internally to improve performance.
 */
public class ImageDownloader {
    private static final String LOG_TAG = "ImageDownloader";

    public enum Mode { NO_ASYNC_TASK, NO_DOWNLOADED_DRAWABLE, CORRECT }
    private Mode mode = Mode.NO_ASYNC_TASK;
    
    /**
     * Download the specified image from the Internet and binds it to the provided ImageView. The
     * binding is immediate if the image is found in the cache and will be done asynchronously
     * otherwise. A null bitmap will be associated to the ImageView if an error occurs.
     *
     * @param url The URL of the image to download.
     * @param imageView The ImageView to bind the downloaded image to.
     */
    public void download(String url, ImageView imageView) {
        resetPurgeTimer();
        Bitmap bitmap = getBitmapFromCache(url);

        if (bitmap == null) {
            forceDownload(url, imageView);
        } else {
            cancelPotentialDownload(url, imageView);
            imageView.setImageBitmap(bitmap);
        }
    }

    /*
     * Same as download but the image is always downloaded and the cache is not used.
     * Kept private at the moment as its interest is not clear.
       private void forceDownload(String url, ImageView view) {
          forceDownload(url, view, null);
       }
     */

    /**
     * Same as download but the image is always downloaded and the cache is not used.
     * Kept private at the moment as its interest is not clear.
     */
    private void forceDownload(String url, ImageView imageView) {
        // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
        if (url == null) {
            imageView.setImageDrawable(null);
            return;
        }

        if (cancelPotentialDownload(url, imageView)) {
            switch (mode) {
                case NO_ASYNC_TASK:
                    Bitmap bitmap = downloadBitmap(url);
                    addBitmapToCache(url, bitmap);
                    imageView.setImageBitmap(bitmap);
                    break;

                case NO_DOWNLOADED_DRAWABLE:
                    imageView.setMinimumHeight(156);
                    BitmapDownloaderTask task = new BitmapDownloaderTask(imageView);
                    task.execute(url);
                    break;

                case CORRECT:
                    task = new BitmapDownloaderTask(imageView);
                    DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
                    imageView.setImageDrawable(downloadedDrawable);
                    imageView.setMinimumHeight(156);
                    task.execute(url);
                    break;
            }
        }
    }

    /**
     * Returns true if the current download has been canceled or if there was no download in
     * progress on this image view.
     * Returns false if the download in progress deals with the same url. The download is not
     * stopped in that case.
     */
    private static boolean cancelPotentialDownload(String url, ImageView imageView) {
        BitmapDownloaderTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView);

        if (bitmapDownloaderTask != null) {
            String bitmapUrl = bitmapDownloaderTask.url;
            if ((bitmapUrl == null) || (!bitmapUrl.equals(url))) {
                bitmapDownloaderTask.cancel(true);
            } else {
                // The same URL is already being downloaded.
                return false;
            }
        }
        return true;
    }

    /**
     * @param imageView Any imageView
     * @return Retrieve the currently active download task (if any) associated with this imageView.
     * null if there is no such task.
     */
    private static BitmapDownloaderTask getBitmapDownloaderTask(ImageView imageView) {
        if (imageView != null) {
            Drawable drawable = imageView.getDrawable();
            if (drawable instanceof DownloadedDrawable) {
                DownloadedDrawable downloadedDrawable = (DownloadedDrawable)drawable;
                return downloadedDrawable.getBitmapDownloaderTask();
            }
        }
        return null;
    }

    Bitmap downloadBitmap(String url) {
        final int IO_BUFFER_SIZE = 4 * 1024;

        // AndroidHttpClient is not allowed to be used from the main thread
        final HttpClient client = (mode == Mode.NO_ASYNC_TASK) ? new DefaultHttpClient() :
            AndroidHttpClient.newInstance("Android");
        final HttpGet getRequest = new HttpGet(url);

        try {
            HttpResponse response = client.execute(getRequest);
            final int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode != HttpStatus.SC_OK) {
                Log.w("ImageDownloader", "Error " + statusCode +
                        " while retrieving bitmap from " + url);
                return null;
            }

            final HttpEntity entity = response.getEntity();
            if (entity != null) {
                InputStream inputStream = null;
                try {
                    inputStream = entity.getContent();
                    return BitmapFactory.decodeStream(new FlushedInputStream(inputStream));
                } finally {
                    if (inputStream != null) {
                        inputStream.close();
                    }
                    entity.consumeContent();
                }
            }
        } catch (IOException e) {
            getRequest.abort();
            Log.w(LOG_TAG, "I/O error while retrieving bitmap from " + url, e);
        } catch (IllegalStateException e) {
            getRequest.abort();
            Log.w(LOG_TAG, "Incorrect URL: " + url);
        } catch (Exception e) {
            getRequest.abort();
            Log.w(LOG_TAG, "Error while retrieving bitmap from " + url, e);
        } finally {
            if ((client instanceof AndroidHttpClient)) {
                ((AndroidHttpClient) client).close();
            }
        }
        return null;
    }
    
    /**
     * A patched InputSteam that tries harder to fully read the input stream.
     */
    static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        }

        @Override
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
                long bytesSkipped = in.skip(n-totalBytesSkipped);
                if (bytesSkipped == 0L) break;
                totalBytesSkipped += bytesSkipped;
            }
            return totalBytesSkipped;
        }
    }

    /**
     * The actual AsyncTask that will asynchronously download the image.
     */
    class BitmapDownloaderTask extends AsyncTask {
        private String url;
        private final WeakReference imageViewReference;

        public BitmapDownloaderTask(ImageView imageView) {
            imageViewReference = new WeakReference(imageView);
        }

        /**
         * Actual download method.
         */
        @Override
        protected Bitmap doInBackground(String... params) {
            url = params[0];
            return downloadBitmap(url);
        }

        /**
         * Once the image is downloaded, associates it to the imageView
         */
        @Override
        protected void onPostExecute(Bitmap bitmap) {
            if (isCancelled()) {
                bitmap = null;
            }

            addBitmapToCache(url, bitmap);

            if (imageViewReference != null) {
                ImageView imageView = imageViewReference.get();
                BitmapDownloaderTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView);
                // Change bitmap only if this process is still associated with it
                // Or if we don't use any bitmap to task association (NO_DOWNLOADED_DRAWABLE mode)
                if ((this == bitmapDownloaderTask) || (mode != Mode.CORRECT)) {
                    imageView.setImageBitmap(bitmap);
                }
            }
        }
    }


    /**
     * A fake Drawable that will be attached to the imageView while the download is in progress.
     *
     * Contains a reference to the actual download task, so that a download task can be stopped
     * if a new binding is required, and makes sure that only the last started download process can
     * bind its result, independently of the download finish order.

     */
    static class DownloadedDrawable extends ColorDrawable {
        private final WeakReference bitmapDownloaderTaskReference;

        public DownloadedDrawable(BitmapDownloaderTask bitmapDownloaderTask) {
            super(Color.BLACK);
            bitmapDownloaderTaskReference =
                new WeakReference(bitmapDownloaderTask);
        }

        public BitmapDownloaderTask getBitmapDownloaderTask() {
            return bitmapDownloaderTaskReference.get();
        }
    }

    public void setMode(Mode mode) {
        this.mode = mode;
        clearCache();
    }

    
    /*
     * Cache-related fields and methods.
     * 
     * We use a hard and a soft cache. A soft reference cache is too aggressively cleared by the
     * Garbage Collector.
     */
    
    private static final int HARD_CACHE_CAPACITY = 50;
    private static final int DELAY_BEFORE_PURGE = 10 * 1000; // in milliseconds

    // Hard cache, with a fixed maximum capacity and a life duration
    private final HashMap sHardBitmapCache =
        new LinkedHashMap(HARD_CACHE_CAPACITY / 2, 0.75f, true) {
        @Override
        protected boolean removeEldestEntry(LinkedHashMap.Entry eldest) {
            if (size() > HARD_CACHE_CAPACITY) {
                // Entries push-out of hard reference cache are transferred to soft reference cache
                sSoftBitmapCache.put(eldest.getKey(), new SoftReference(eldest.getValue()));
                return true;
            } else
                return false;
        }
    };

    // Soft cache for bitmaps kicked out of hard cache
    private final static ConcurrentHashMap> sSoftBitmapCache =
        new ConcurrentHashMap>(HARD_CACHE_CAPACITY / 2);

    private final Handler purgeHandler = new Handler();

    private final Runnable purger = new Runnable() {
        public void run() {
            clearCache();
        }
    };

    /**
     * Adds this bitmap to the cache.
     * @param bitmap The newly downloaded bitmap.
     */
    private void addBitmapToCache(String url, Bitmap bitmap) {
        if (bitmap != null) {
            synchronized (sHardBitmapCache) {
                sHardBitmapCache.put(url, bitmap);
            }
        }
    }

    /**
     * @param url The URL of the image that will be retrieved from the cache.
     * @return The cached bitmap or null if it was not found.
     */
    private Bitmap getBitmapFromCache(String url) {
        // First try the hard reference cache
        synchronized (sHardBitmapCache) {
            final Bitmap bitmap = sHardBitmapCache.get(url);
            if (bitmap != null) {
                // Bitmap found in hard cache
                // Move element to first position, so that it is removed last
                sHardBitmapCache.remove(url);
                sHardBitmapCache.put(url, bitmap);
                return bitmap;
            }
        }

        // Then try the soft reference cache
        SoftReference bitmapReference = sSoftBitmapCache.get(url);
        if (bitmapReference != null) {
            final Bitmap bitmap = bitmapReference.get();
            if (bitmap != null) {
                // Bitmap found in soft cache
                return bitmap;
            } else {
                // Soft reference has been Garbage Collected
                sSoftBitmapCache.remove(url);
            }
        }

        return null;
    }
 
    /**
     * Clears the image cache used internally to improve performance. Note that for memory
     * efficiency reasons, the cache will automatically be cleared after a certain inactivity delay.
     */
    public void clearCache() {
        sHardBitmapCache.clear();
        sSoftBitmapCache.clear();
    }

    /**
     * Allow a new delay before the automatic cache clear is done.
     */
    private void resetPurgeTimer() {
        purgeHandler.removeCallbacks(purger);
        purgeHandler.postDelayed(purger, DELAY_BEFORE_PURGE);
    }
}

[LiNuX] Debian 7 에 SAMBA 서버 구성



1. 패키지 설치

root@debian:~# apt-get install samba samba-common samba-common-bin


2. 삼바 데몬 정지

root@debian:~# /etc/init.d/samba status
[ ok ] nmbd is running.
[ ok ] smbd is running.
root@debian:~# /etc/init.d/samba stop
[ ok ] Stopping Samba daemons: nmbd smbd.


3. 삼바 디렉토리 생성

root@debian:~# mkdir -p /home/samba-shared
root@debian:~# chmod -R 777 /home/samba-shared/


4. 환경 설정 파일 수정

root@debian:~# vi /etc/samba/smb.conf

* 가장 아래  다음의 내용을 수정 하여 추가 한다.

[samba-shared]
comment = 공유 폴더
path = /home/samba-shared
read only = no
valid users = freecatz user1 user2
writable = yes
public = yes
create mask = 0777
directory mask = 0777


5. 삼바 서버 시작

root@debian:~# /etc/init.d/samba start
[ ok ] Starting Samba daemons: nmbd smbd.
root@debian:~# /etc/init.d/samba status
[ ok ] nmbd is running.
[ ok ] smbd is running.



6. 사용자 계정 추가


* 참고 : 우선 리눅스 시스템에 유저가 생성 되어 있어야 한다.
         시스템에 없는 계정을 등록 하려고 하는 경우 아래와 같은 에러 메세지가 나온다.

root@debian:~# smbpasswd -a tester
New SMB password:
Retype new SMB password:
Failed to add entry for user tester.

이러한 경우 useradd 명령어를 이용하여 사용자를 추가 하고 나서 smbpasswd 를 이용하여
삼바 계정을 생성 하도록 한다.


root@debian:~# smbpasswd -a freecatz
New SMB password:
Retype new SMB password:
Added user freecatz.

root@debian:~# smbpasswd -a user1
root@debian:~# smbpasswd -a user2
...


7. 공유디렉토리 접근 확인

\\192.168.0.10\samba-shared


8. 삼바 유저 확인

root@debian:~# pdbedit -w -L


9. 비밀번호 변경

root@debian:~# smbpasswd <계정>


10. 계정 삭제

root@debian:~# smbpasswd -x <계정>

2014년 8월 18일 월요일

[LiNuX] Debian 7 에 SVN 서버 구성



1. SVN 패키지 설치

root@debian:~# apt-get install subversion libapache2-svn apache2-mpm-worker


2. SVN 모듈 동작 확인

root@debian:~# a2enmod dav_svn
Considering dependency dav for dav_svn:
Module dav already enabled
Module dav_svn already enabled


3. SVN 디렉토리 생성 및 지정

root@debian:~# mkdir -p /home/svn/web
root@debian:~# svnadmin create /home/svn/web

root@debian:~# mkdir -p /home/svn/android
root@debian:~# svnadmin create /home/svn/android

* svnadmin 명령으로 디렉토리 생성이 안되는 경우 mkdir 명령을 사용하여 디렉토리를 만든 후 avnadmin 명령으로 디렉토리를 지정해 주도록 한다.



4. 디렉토리 권한 설정 

root@debian:~# chown www-data:www-data /home/svn/ -R


5. 환경설정 파일 수정

root@debian:~# vi /etc/apache2/mods-enabled/dav_svn.conf
<Location /svn/web>
   DAV svn
   SVNPath /home/svn/web
 
   AuthType Basic
   AuthName "Web Project Repository"
   AuthUserFile /etc/apache2/dav_svn.passwd
   Require valid-user
</Location>

<Location /svn/android>
   DAV svn
   SVNPath /home/svn/android
 
   AuthType Basic
   AuthName "Android Project Repository"
   AuthUserFile /etc/apache2/dav_svn.passwd
   Require valid-user
</Location>


6. SVN 사용자 계정 생성(최초 사용자 생성시 c 옵션을 적용)

root@debian:~# htpasswd -mc /etc/apache2/dav_svn.passwd <계정명>
root@debian:~# htpasswd -m /etc/apache2/dav_svn.passwd <계정명>


6-1. SVN 사용자 계정 삭제

root@debian:~# htpasswd -D /etc/apache2/dav_svn.passwd <계정명>


6-2. 비밀번호 변경 

root@debian:~# htpasswd /etc/apache2/dav_svn.passwd <계정명>

7. 아파치 서버 재시작

# /etc/init.d/apache2 restart


8. 브라우저를 이용하여 확인

http://192.168.0.10/svn/web
http://192.168.0.10/svn/android




2014년 8월 8일 금요일

[EtC] Play 2.2.4 Framework 개발 환경 구성


*참고 : play 명령 대신 activator 명령어를 사용 하시기 바랍니다.
          이 문서를 작성할 당시에는 play 명령어를 사용하여 작성 되었으나,
          activator 명령어가 play명령과 거의 동일한 옵션으로 실행 가능 합니다.



1. 플레이 프레임워크 다운로드

http://www.playframework.com/download 에서 다운로드 받아 적당한 디렉토리에 압축을 푼다. 이 문서에서는 play-2.2.4.zip 를 내려 받았다. 다른 버젼도 크게 다른 부분은 없을듯.


참고 : 플레이 프레임워크를 사용 하기 위해서는 jdk 가 설치 되어 있어야 한다.
          이 문서에서는 jdk 설치 와 환경 설정등은 다루지 않는다.


2. 압축 해제




적당한 디렉토리에 압축을 해제 한다.


3. play 명령어 사용을 위한 환경 변수 설정



어느 위치에서든 play.bat 명령어를 사용할 수 있도록 PATH 전역 변수에 등록 시켜 둔다.


4. play 명령어 실행 확인



위의 그림과 같이 play 명령을 실행해 본다. 명령이 실행 되지 않는다면, PATH 설정에 잘못된 부분이 있는지 확인 하도록 한다.


5. 프레임워크 구성 요소 내려 받기

프레임워크의 압축을 해제한 디렉토리로 이동 하여 위의 그림과 같이 builld.bat clean 을 실행 한다. 시간이 조금 오래 걸리니 기다리도록 한다. 

이 문서에서는 플레이 프레임워크를 D:\devel\play-2.2.4 에 압축 해제 하였으며, D:\devel\play-2.2.4\framework\ 로 이동 하여 명령어를 실행 하였다.


build.bat publish-local 명령을 실행 하도록 한다. 이 과정도 오래 걸리니 기다리도록 한다.


6. 테스트용 프로젝트 생성



프로젝트를 생성할 디렉토리로 이동 하여 위의 그림과 같이 play 명령어를 사용하여 프로젝트를 생성 한다.

d:\devel\workspace\play> play new helloworld

중간에 어떤 언어를 이용 할 것인지 묻는데, 프로젝트를 구성 하고자 하는 언어를 선택 후 엔터키를 입력 한다.


명령어를 실행 하고 나서 해당 디렉토리로 이동 하여 보면, 위의 그림과 같이 파일과 디렉토리가 자동으로 생성 되어 있을 것이다.



7. 생성된 프로젝트의 실행 및 확인

생성된 프로젝트 디렉토리로 이동 하여 play 명령을 사용 하면, play 명령 콘솔로 진입 하게 된다. 위의 그림과 같이 play 명령 콘솔로 진입 후, run 명령을 사용하여 프로젝트를 실행 시키도록 한다.

참고 : 처음에 프로젝트 디렉토리에서 play 명령을 사용하게 되면 어느 정도 시간이 걸리니 기다리도록 한다.



play 명령 콘솔에서 run 명령어 사용후, 위의 그림과 같이 "Server Started" 라는 메세지가 나오면 실행이 완료된 상태로, 브라우저를 통해서 확인 할 수 있다.
종료는 Ctrl + D 키를 누르면 play 명령 콘솔로 나올 수 있다.



위의 그림과 같이 브라우저에서 http://localhost:9000 의 주소로 접근하여 확인 할 수 있다.



8. 개발 하기 위한 Eclipse 환경 설정

생성한 프로젝트의 디렉토리로 이동 하여, 위의 그림과 같이 play eclipse 명령을 실행 한다. 조금 오래 걸릴수도 있으니 기다리도록 한다. 

이 과정에서는 이클립스에서 프로젝트를 import 할 수 있도록 프로젝트 디렉토리에 파일을 생성해 주는 단계. 명령이 완료 되면, 이제 이클리스를 실행 하도록 한다.


Project Explorer 윈도우 에서 마우스 오른쪽 버튼, 나타나는 메뉴에서 Import -> Import 를 선택 한다.



나타나는 팝업창에서 "EXisting Projects into Workspace" 를 선택 후 Next 버튼 클릭.



생성한 프로젝트의 디렉토리를 선택 후 "Finish" 버튼을 클릭 한다.



일단, 프로젝트의 import 는 되었으나 스칼라 언어의 자동완성이나 색상 표시를 해결 해야 한다.





9. 이클립스에 스칼라 언어 플러그인 설치




http://download.scala-ide.org/sdk/helium/e38/scala210/stable/site

플레이 프레임워크 2.4.4 에서는  스칼라 2.10 버젼대를 사용하고 있다. 



위의 그림과 같이 두개의 항목을 선택 후, "Next" 버튼을 클릭 한다.



"Next"  버튼을 클릭 하여 다음 단계로 진행 한다.



라이선스에 동의 선택 후, "Finish" 버튼을 클릭 하여 다음 단계로 진행 한다.



설치 하는 동안 잠시 기다리도록 한다.



이클립스를 다시 시작 한다.



스칼라 플러그인 업데이트를 감지 하였다고 한다. 필요한 경우 업데이트를 받도록 한다.



코드에 색상이 들어가 있다. 스칼라 코드를 살펴 보았으나, 아직은 이해 불가...


이후, 시간이 나면 다시 계속 작성할 예정...