Docker file 내부에 아래와 같이 명시
# Change Apt-get URL
RUN cat /etc/apt/sources.list $i | sed -e "s/archive\.ubuntu\.com/ftp\.daumkakao\.com/g" > a.txt
RUN mv a.txt /etc/apt/sources.list
Docker file 내부에 아래와 같이 명시
# Change Apt-get URL
RUN cat /etc/apt/sources.list $i | sed -e "s/archive\.ubuntu\.com/ftp\.daumkakao\.com/g" > a.txt
RUN mv a.txt /etc/apt/sources.list
AWS 환경 아래에 ELB 뒷단에 apache가 80 포트로만 동작중일경우
ELB에 인증서를등록하고 80 과 443을 아파치의 80으로 포워딩 할경우
httpd.conf
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
모든 http 호출에 대해서 https 로 변경하는 설정.
RewriteCond %{HTTP:X-Forwarded-Proto} !https
> 설명
Apache에서 X-Forwarede-Proto 헤더 벨류의 값이 https가 아니면
aws ec2 상에서 timezone이 kst로 설정되어 있지 않다 ..
sudo vi /etc/profile
하단부에 아래 항목 추가
TZ=Asia/Seoul
export TZ
source /etc/profile
date
이후 Tomcat Restart
는 정상적인 시간이 설정됨을 확인할수 있다.
Tutorial Link : https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html#_storing_logs_with_elasticsearch
설치
테스트 환경 : Virtual Box - Ubuntu Server x64
1 CPU, 2GB RAM, 8GB HDD
https://www.elastic.co
Tar.gz 다운로드
elasticsearch-1.6.0
kibana-4.1.1-linux-x64
logstash-1.5.2
#. LogStash
설치 경로에서
bin/logstash -e 'input { stdin { } } output { stdout {} }'
위 명령어를 이용해서 Echo 로 동작 가능.
bin/logstash -e 'input { stdin { } } output { stdout { codec => rubydebug } }'
위 명령어를 이용하여
rubydebug라는 code형태로 출력가능..
EX :
good night moon
{
"message" => "good night moon",
"@version" => "1",
"@timestamp" => "2015-07-08T07:28:10.873Z",
"host" => "ubuntu"
}
N By N 배열의 숫자가 빙빙 돌아가며 찍히는 형태로 출력하는것..
점심시간에 잠깐 짬내서 날 코딩 ㄱㄱ...
1 16 15 14 13
2 17 24 23 12
3 18 25 22 11
4 19 20 21 10
5 6 7 8 9
위와 같은 형태로 출력되면 성공.......
아래는 코드 . 전문..
public class Snail {
public void run(int size) {
int[][] matrix = new int[size][size];
boolean xToRight = false;
boolean yToDown = true;
// first line (x 로 기록)
for (int x = 1; x <= size; x++) {
matrix[x - 1][0] = x;
}
int leftSize = size + 1;
int loopCount = 0;
int lastValue = size + 1;
int xPos = size;
int yPos = 1;
while (leftSize-- > 0) {
loopCount++;
// Y 방향 값
for (int innerLoop = 0; innerLoop < (size - loopCount); innerLoop++) {
if (yToDown)
yPos++;
else
yPos--;
matrix[xPos - 1][yPos - 1] = lastValue++;
}
yToDown = !yToDown;
// X 방향 값
for (int innerLoop = 0; innerLoop < (size - loopCount); innerLoop++) {
if (xToRight)
xPos++;
else
xPos--;
matrix[xPos - 1][yPos - 1] = lastValue++;
}
xToRight = !xToRight;
}
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
System.out.printf("%3d", matrix[i][j]);
}
System.out.println();
}
System.out.println();
}
public static void main(String[] args) {
Snail s = new Snail();
s.run(5);
}
}
초기 1렬을 그대로 출력하고
x축 끝에서 만날시 방향 전환
y축 끝에서 만날시 방향 전환
대충 이런 느낌으로 작성하였습니다.
머리가 굳어가는 느낌에 가끔 기름칠.
1 32 31 30 29 28 27 26 25
2 33 56 55 54 53 52 51 24
3 34 57 72 71 70 69 50 23
4 35 58 73 80 79 68 49 22
5 36 59 74 81 78 67 48 21
6 37 60 75 76 77 66 47 20
7 38 61 62 63 64 65 46 19
8 39 40 41 42 43 44 45 18
9 10 11 12 13 14 15 16 17
9에 대한 출력값...
조건
Url에서 특정 패턴을 추출해서 시스템 브라우저를 호출한다.
Webview에 WebViewClient 를 설정하고
webView.setWebViewClient(new TestWebViewClient());
해당 패턴이 포함되어 있을경우 시스템 브라우저를 호출한다.
private class TestWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.indexOf("___target=_blank") > -1){
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
context.startActivity(i);
return true;
}
return super.shouldOverrideUrlLoading(view, url);
}
}
Kitkat이전까지 이 방법으로 호출하였으나 문제는 킷캣 ( 4.4 kitkat ) 이상에서는 이 방법이 통하지 않습니다...
4.4부터 구글의 크롬엔진이 변경되어서 그렇다는 글을 검색을 통해서 확인하였고
여기저기 뒤져보다가 해결책을 발견...
webView에 웹 크롬 클라이언트를 설정..
webView.setWebChromeClient(new TestWebChromeClient());
새 창이 열리는 액션을 잡아서 해당 패턴일경우 새창에 띄워줍니다.
private class TestWebChromeClient extends WebChromeClient {
}
상기 두부분을 그대로 유지를 해둬야 4.4 이상에서도 동작하고 4.4 미만에서도 동작을 합니다.
사용중인 갤럭시 S3 의 개발자 도구가 환경설정에서 사라졌다..
숨김 처리가 되있는 ...
서두는 짧게.
홈화면 -> 메뉴버튼 -> 환경설정 -> 더보기
-> 디바이스 정보
-> 빌드번호를 터치터치터치... 연속으로 하다보면. 3 2 1 . 하고 떨어지면서 Toast가 노출된다...
개발자도구가 활성화 되었습니다.. 라는 문구가 나오고
Back 버튼...
더보기 메뉴 아래에 개발자 도구가 활성화 되어있다..
우야건 Success...
페이스북 생활코딩 그룹에 나온문제중 하나...
https://www.facebook.com/groups/codingeverybody/
"1원, 5원, 10원, 50원, 100원, 500원짜리가 각각 C1, C5, C10, C50, C100, C500개씩 있습니다. 가능한 적은 수의 동적으로 A원을 지불하려면, 몇 개의 동전이 있어야 할까요? 지불 방법은 적어도 1개는 존재한다고 가정합니다."
자바 개발자로서(?)
낼름 풀어보았다...
public static void main(String[] args) {
int val = 5323; // 입력값
int cv = 1000; // 500 -> 100 -> 50 으로 변할값.
int cx = 0, div = 0; // cx는 동전의 갯수 div는 2 : 5 스위치 값.
do {
div = (div == 2 ? 5 : 2); // 처음에 div 는 0이므로 div는 2가 되고
cv = cv / div; // cv는 500이된다.
cx += val / cv; // val / cv 는 정수값이므로, cx에 나누기의 몫이 들어가고
val = val % cv; // 나머지 값은 다음턴으로 넘긴다.
} while (cv != 1); // 1이 아니면 루프... do 아래 2번재 줄에서 cv 가 1이되어도 연산이 되므로 문제가 없다.
System.out.println(cx); // 대상 목적인 코인의 갯수만 출력 >.<.
}
상황 : Spring기반으로 짜여진 서버에서 한 클래스의 데이터를 모니터링 페이지에 띄우고자 합니다.
출력해야하는 클래스는 들고 있는 데이터의 가지수만 최소 5-7개에서 내부필드는 20-30개까지
하나하나 정성스레 포멧팅 해주면 되지만. 귀차니즘이 앞서서 어찌하면 이쁘게 String으로 뽑아낼수 있을까 하여
방법을 찾아보았습니다.
Q : 특정 클래스 A를 Json Format을 가지는 String Type로 출력하고자 합니다.
A.
- 구글에서 제공 하고 있는 GSON Library의 Pretty Format 메소드를 활용하여 출력.
GOOGLE GSON : http://code.google.com/p/google-gson/
#. Test Case
ObjClass.java |
import java.util.ArrayList; public class ObjClass { String name; int age; String address; ArrayList<String> newArr; } |
Main.java |
import java.util.ArrayList; import com.google.gson.Gson; import com.google.gson.GsonBuilder; public class Main { public static void main(String[] args){ ObjClass oc = new ObjClass(); oc.address = "123"; oc.age = 56; oc.name ="myname"; oc.newArr = new ArrayList<String>(); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String jsonOutput = gson.toJson(oc); System.out.println(jsonOutput); } } |
#.Output |
{ "name": "myname", "age": 56, "address": "123", "newArr": [] } |
필드의 값이 Null 일 경우에는 아에 출력에서 제외됩니다.
이어서 -
View 딴에 데이터를 전달해서 출력할 계획이기에
Javascript를 이용해서 Json Format에 Hightlight 해주는걸 찾아봐야겠습니다...
요즘 이클립스에서 이것저것 NodeJS 학습을 진행중인데
개발 경력 얼마나 되었다고 벌써부터 Code Assist 없으면 개발하기 힘들어집니다... (것보담 타이핑 하기 귀찮아 진다? ... 일이라면 하는데 -_- 공부라 생각하니 더 치기 싫어지는 이유는 뭘까 ..요? )
잡설은 여기까지 줄이겠습니다.
---------------
Eclipse에서 NodeJS를 이용하여 개발하는데 Code Assist 사용하기
준비
1. Eclipse
2. NodeJS
3. Git
시작
1.
Eclipse -> Menu -> Help -> Install New Software ->
http://download.eclipse.org/vjet/updates-nightly/
위 URL을 추가하여 플러그인을 설치합니다.
2. https://github.com/ebayopensource/vjet-typelib
#. 주의 사항?
Github에서 확인해보면 최종 Pushed 된 날짜가 2년전입니다.. (2011 04 ~ 2011 05 가 마지막 업데이트입니다 ( ..) )
Node나 JQuery의 경우 광속 Version Up을 하고 있는데 그 빠름을 따라가지 못하는 듯하여
최신 버전관련된 내용이 노출되지않거나 Deprecated된 내용이 정상적으로 노출될수 있으니 100% 신뢰는 금물입니다.
참조 : http://wiki.eclipse.org/VJET/Importing_VJET_JavaScript_Type_Libraries
Win7에서 Node 개발 환경을 구축하고 개발하다가 Custom Module의 추가가 요구되어 질때가 있다.
npm install 블라블라
명령어를 이용해서 설치하는 방법이 있지만.
설치를 해도 잡히지가 않고
NODE_HOME 환경변수를 등록해도 이클립스에서 모듈을 못불러온다...
추가로
www.nodejs.org 에서 Download를 이용해서 받으면
설치 경로 변경도 못한다.!!! ... (윈도우가 설치된 드라이브는 Win7기준으로 이래저래 제한사항이 몇 걸린다... )
그래서 발견한 해결책...
http://code.google.com/p/nodejs-win/
Node 설치경로 변경가능
기본 모듈 10여개 미리 설치됨
해당 결로의 루트에서 npm install 명령으로 추가 모듈 설치시 정상적으로
동작 :)
개발을 진행하다보면 Apache - Tomcat 구조로 서버 세팅을 완료하고
이미지를 캐싱한다는 이야기를 들었다..
어찌하나 직접 찾아보기로 해서 직접 아파치 설치를 해서 구현해 보았다..
Apache 설치
http://httpd.apache.org/download.cgi#apache24
Windows 기반으로 설치 진행
2.0.64버전을 설치아파치 설치 경로\Apache2\conf
httpd.conf : section 2
LoadModule expires_module modules/mod_expires.so |
위 라인 주석제거
httpd.conf Section2 에 아래 항목 추가
# # Apache Server Static Data Caching # <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/png "access plus 1 month" </IfModule> |
위 설정까지 적용한후 아파치 Restart를 수행한다.
Test용 이미지 등록
C:\Program Files (x86)\Apache Group\Apache2\htdocs\testProject\resources\images\k.png
Test용 Html 등록
C:\Program Files (x86)\Apache Group\Apache2\htdocs\testProject\a.html
a.html 의 내용은 Test이미지를 화면에 노출하는 단순 구조
이 테스트를 위해서 Fiddler를 사용해서 캐싱되는것을 확인하였다.
http://www.fiddler2.com/fiddler2/
아파치 뒤의 서블릿 컨테이너(톰캣)으로 전달되는것을 방지하기 위해
mod_proxy를 손봐야한다는 정보도 Get하였다.
참고 링크
http://ant103.egloos.com/198165
http://www.javajigi.net/pages/viewpage.action?pageId=287244298
http://system.neulwon.com/xe/?mid=linux_apache&page=2&document_srl=1518
안드로이드 에서 메시지 기반으로 이리저리 통통 기기 제어를 하려 하는데....
Permission Deny 상황이 자꾸 떨어진다.
뭘까 ...
http://www.android-permissions.org/permissionmap.html
오늘 (2012 10 09 ) 까지는 잘 접속되는데 나중에 될진 모르겠다..
중한 내용은 아래 내용... Broadcast Message 로 아래 내역은 허락되지 않는다. 시스템딴에서만 전송 가능하다는 이야기.. 다른 방법으로 메시지 날리는게 정답인듯?!?!?
android.app.action.ENTER_CAR_MODE, android.app.action.ENTER_DESK_MODE, android.app.action.EXIT_CAR_MODE, android.app.action.EXIT_DESK_MODE, android.backup.intent.CLEAR, android.backup.intent.INIT, android.backup.intent.RUN, android.bluetooth.adapter.action.DISCOVERY_FINISHED, android.bluetooth.adapter.action.DISCOVERY_STARTED, android.bluetooth.adapter.action.LOCAL_NAME_CHANGED, android.bluetooth.adapter.action.SCAN_MODE_CHANGED, android.bluetooth.adapter.action.STATE_CHANGED, android.bluetooth.device.action.ACL_CONNECTED, android.bluetooth.device.action.ACL_DISCONNECTED, android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED, android.bluetooth.device.action.BOND_STATE_CHANGED, android.bluetooth.device.action.CLASS_CHANGED, android.bluetooth.device.action.DISAPPEARED, android.bluetooth.device.action.FOUND, android.bluetooth.device.action.NAME_CHANGED, android.bluetooth.device.action.NAME_FAILED, android.bluetooth.device.action.PAIRING_CANCEL, android.bluetooth.device.action.PAIRING_REQUEST, android.intent.action.ACTION_MDN_STATE_CHANGED, android.intent.action.ACTION_POWER_CONNECTED, android.intent.action.ACTION_POWER_DISCONNECTED, android.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, android.intent.action.ACTION_SHUTDOWN, android.intent.action.ANY_DATA_STATE, android.intent.action.BATTERY_CHANGED, android.intent.action.BATTERY_LOW, android.intent.action.BATTERY_OKAY, android.intent.action.BOOT_COMPLETED, android.intent.action.CONFIGURATION_CHANGED, android.intent.action.DATA_CONNECTION_FAILED, android.intent.action.DEVICE_STORAGE_LOW, android.intent.action.DEVICE_STORAGE_OK, android.intent.action.DOCK_EVENT, android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED, android.intent.action.LOCALE_CHANGED, android.intent.action.NETWORK_SET_TIME, android.intent.action.NETWORK_SET_TIMEZONE, android.intent.action.NEW_OUTGOING_CALL, android.intent.action.PACKAGE_ADDED, android.intent.action.PACKAGE_CHANGED, android.intent.action.PACKAGE_DATA_CLEARED, android.intent.action.PACKAGE_INSTALL, android.intent.action.PACKAGE_REMOVED, android.intent.action.PACKAGE_REPLACED, android.intent.action.PACKAGE_RESTARTED, android.intent.action.RADIO_TECHNOLOGY, android.intent.action.REBOOT, android.intent.action.SCREEN_OFF, android.intent.action.SCREEN_ON, android.intent.action.SERVICE_STATE, android.intent.action.SIG_STR, android.intent.action.SIM_STATE_CHANGED, android.intent.action.TIMEZONE_CHANGED, android.intent.action.TIME_TICK, android.intent.action.UID_REMOVED, android.intent.action.USER_PRESENT, and android.provider.Telephony.SPN_STRINGS_UPDATED.
String strInputValue = "I Love You";
System.out.println("["+strInputValue+"]");
if(strInputValue.equals("TRUE"))
{
System.out.println("True");
}
String strInputValue = null;
System.out.println("["+strInputValue+"]");
if(strInputValue.equals("TRUE"))
{
System.out.println("True");
}
[null]
Exception in thread "main" java.lang.NullPointerException
at com.ncf.test.java.TestClass.main(TestClass.java:13)
String strInputValue = null;
System.out.println("["+strInputValue+"]");
if("TRUE".equals(strInputValue))
{
System.out.println("Pass");
}
$bin/mongod
$bin/mongod --dbpath ~/
MongoDB가 설치된 경로
MongoDB 구동
서비스 중인 포트로 접속해보면 1000을 더하면 진단 툴에 접속할수 있을을 알리는 메시지를 노출한다.
진단툴의 모습 주소는 localhost:28017이다.
변수를 할당한다거나. 수학 연산, 함수 생성등이 가능.