노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Vaadin Appication 만들기


1. 준비물

- Eclipse ( www.eclipse.org )

- Vaadin Plugin for Eclipse ( Eclipse Market Place )


2. 프로젝트 생성

- New -> Vaadin -> Vaddin 7 Project with Maven 


- Select a Maven archetype 

    : Single-module Application Project(vaadin-archetype-application)


- Artiface Id : 필요에 따라 수정

- 생성된 소스 확인

@Theme("mytheme")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();
        
        final TextField name = new TextField();
        name.setCaption("Type your name here:");

        Button button = new Button("Click Me");
        button.addClickListener( e -> {
            layout.addComponent(new Label("Thanks " + name.getValue() 
                    + ", it works!"));
        });
        
        layout.addComponents(name, button);
        layout.setMargin(true);
        layout.setSpacing(true);
        
        setContent(layout);
    }

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}


3. Add to Tomcat 8.0


4. Run / Open

* 참조  -자료 동영상

https://youtu.be/o93ofXBIkf8 , Creating a Project from an Archetype


Hello World 만들기 

- init() 함수를 수정


1) Label 추가 하기

    @Override
    protected void init(VaadinRequest vaadinRequest) {
    	Label label = new Label("Hello World!");
    	setContent(label);
    }

2) Button 추가 하기

(1) button 생성

    @Override
    protected void init(VaadinRequest vaadinRequest) {
    	Button button = new Button("Greet");
    	setContent(button);
    }

(2) button addClickListener() 추가

@Override protected void init(VaadinRequest vaadinRequest) {         Button button = new Button("Greet");         button.addClickListener( e->Notification.show("Hello World!") );         setContent(button);

}

(3) text field 입력 받기 , VerticalLayout추가 하기

@Override protected void init(VaadinRequest vaadinRequest) { TextField textField = new TextField("Name");         Button button = new Button("Greet");         button.addClickListener( e->Notification.show("Hi! " + textField.getValue()) ); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addComponents(textField,button);         setContent(button); }


(4) verticalLayout.setMargin(true)


(5) verticalLayout.setSpacing(true)


(6) verticalLayout.setMargin(true), verticalLayout.setSpacing(true)


* 참조  -자료 동영상

https://youtu.be/9-qwPfpSHWc


Bandend 추가하기와 Grid안에 항목 나열하기


1. 사용될 소스 복사 하기

- CustomerStatus.java

- Customer.java

- CustomerService.java 


2. 소스 수정 하기


1) grid 추가 하기 ( 전체 Data 불러오기 )

    private CustomerService service = CustomerService.getInstance();  
    private Grid grid = new Grid();
	
    @Override
    protected void init(VaadinRequest vaadinRequest) {

    	
    	VerticalLayout verticalLayout = new VerticalLayout();
    	
    	
    	verticalLayout.addComponent( grid );
    	
    	List customers = service.findAll();
    	grid.setContainerDataSource( new BeanItemContainer<>(Customer.class, customers) );
    	
    	// kind of updating
    	updateList();
    	
    	verticalLayout.setMargin(true);		// around space
    	verticalLayout.setSpacing(true);	// inside layout space
    	
    	
    	setContent(verticalLayout);
    	
    }



2) 특정 column만 grid에 표현 오기

    private CustomerService service = CustomerService.getInstance();  
    private Grid grid = new Grid();
	
    @Override
    protected void init(VaadinRequest vaadinRequest) {

    	
    	VerticalLayout verticalLayout = new VerticalLayout();
    	
    	grid.setColumns("firstName","lastName","email"); // here you go
    	
    	verticalLayout.addComponent( grid );
    	
    	List customers = service.findAll();
    	grid.setContainerDataSource( new BeanItemContainer<>(Customer.class, customers) );
    	
    	// kind of updating
    	updateList();
    	
    	verticalLayout.setMargin(true);		// around space
    	verticalLayout.setSpacing(true);	// inside layout space
    	
    	
    	setContent(verticalLayout);
    	
    }

    private void updateList() {
    	List<Customer> customers = service.findAll();
    	grid.setContainerDataSource(new BeanItemContainer<>(Customer.class, customers));
    }


 

* 참조  -자료 동영상

https://youtu.be/0W0frepDKWI




블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.




XSS ( Cross Site Scripting ) 제거 하기


- 문자열을 아래와 같은 변환을 통해서, 불필요한 script를 제거 한다. ( 때로는 escape된 문자열를 변환후에 제거하는 과정도 필요하다. )


1. HTML Sanitizer Project




1) 다운로드


(1) owasp-java-html-sanitizer.jar



(2) Dependency jar


- guava : lib/guava-libraries/guava.jar
- JSR305 : lib/jsr305/jsr305.jar


2)  코드 작성

// prepackaged policies
String untrustedHTML="<script>alert()</script>";
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String safeHTML = policy.sanitize(untrustedHTML);


2. Jsoup


1) 다운로드 jsoup-1.10.2.jar


2) 코드작성

String unsafe =   "<p><a onclick="stealCookies()" href="http://example.com/">Link</a></p>";
String safe = Jsoup.clean(unsafe, Whitelist.basic());
// now: <p><a href="http://example.com/" rel="nofollow">Link</a></p>


* UnescapeHtml() - Class StringEscapeUtils - commons.apache.org

Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



Spring Boot와 Vaadin의 full stack 어플리케이션 ( JPA, PostgreSQL )


- Vaadin은 무멋인가?



1. 프로젝트 생성 ( start.spring.io , SPRING INITIALIZR )후에 zip 해제 하기


Maven Project , 1.4.4 ( 1.5.x는 에러가 발생 )

Dependencies 선택 : Web, Vaadin, JPA, PostgreSQL

Artifact : todolistvaading


2. 프로젝트 불러오기


Eclipse에서 Import -> Project from Folder or Archive

Project(우측 마우스) ->Run AS -> Maven clean, Maven Install 실행

Project(우측 마우스) -> Maven -> Update Project선택


3. 생성할 예제



4. UI 클래스 생성하기


package com.example;


import com.vaadin.annotation.Theme;

import com.vaadin.server.VaadinRequest;

import com.vaadin.spring.annotation.SpringUI;

import com.vaadin.ui.UI;


@SpringUI
@Theme("valo")
public class TodoUI extends UI {


private VerticalLayout layout;


    @Override
    protected void init(VaadinRequest vaadinRequest) {


// 화면 구성 하기

setupLayout();

addHeader();

addForm();

addTodoList();

addActionButton();

}

}


private void setupLayout(){
layout = new VerticalLayout();
    setContent(layout);
}

private void addHeader(){
Label header = new Label("TODO");

layout.addComponent(header);
}

private void addForm(){
HorizontalLayout formLayout = new HorizontalLayout();

TextField taskField = new TextField();

Button addButton = new Button("Add"); // 나중에 icon으로 변경


formLayout.addComponent(taskField, addButton);

layout.addComponent(formLayout);
}

private void addTodoList(){

//@Autowired TodoList todoList 추가
layout.addComponent(todoList);
}

@Component
public class TodoList extends VerticalLayout {

}

private void addActionButton() {

Button deleteButton = new Button("Delete completed");

layout.addComponent(deleteButton);

}



원문 : 동영상 강좌

https://www.youtube.com/watch?v=tnVKN25dIm8


-- 추가 꾸미기

private void setupLayout() {
...
layout.setSpacing(true);
layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
...
}

private void addHeader() {
...
header.addStyleName(ValoTheme.LABEL_H1);
header.setSizeUndefined();
...
}

private void addForm() {
...
formLayout.setSpacing(true);
formLayout.setWidth("80%");
}

private void addTodoList() {
...
todoList.setWidth("80%");
}
private void addActionButton() {
...
deleteButton.addClickListener(click->todoList.deleteCompleted());
}


Todo.java

TodoChangeListener.java

TodoLayout.java

TodoList.java

TodoRepository.java

TodoUI.java

TolistvaadinApplication.java



* Vaadin Login Example

https://examples.javacodegeeks.com/enterprise-java/vaadin/vaadin-login-example/




블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Maven을 윈도우10에 설치하기


Apache Maven은 소프트웨어 프로젝트 관리 툴이다. POM(project object model)의 개념 위에서, Maven은 project의 build와 보고서 만들기나 문서화를 정보의 중앙관리를 통해 관리할 수 있다.


1. 다운로드 하기 & unzip으로 풀어 놓기


http://maven.apache.org/download.cgi 에서 Binary zip archive를 받아서, 원하는 위치에 풀어 놓는다.



2.  고급 시스템 설정 -> 환경변수


1) 시스템 변수에 MAVEN_HOME을 추가하고 설치된 경로로 설정

2) 시스템 변수 Path에 %MAVEN_HOME%\bin을 추가 한다.


* Maven 설치 이전에 Java가 설치되어 있어야 하며, JAVA_HOME도 환경 변수에 등록이 되어 있어야 한다.


3. CMD를 통해서 정상 설치를 확인

> mvn -version

> mvn -help


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Jenkins 설치, 빌드설정,Port변경



젠킨스는 규모에 관계 없이 대단한 (자동) 빌드  를 만들어 준다.



선도적인 오픈 소스 자동화 서버인 젠킨스는 수백 가지의 플러그인을 모든 프로젝트의 빌드하는 것과 배포하는 것 및 자동화 하는 것을 하도록 제공한다.



젠킨스는 자바 Runtime 환경이 설치된 곳에서 독립적으로 실행되고 운영된다.


- 최소 Java 7, 권장 Java 8

- 512 MB RAM이상을 권장



1. 다운로드 ( https://jenkins.io/ )


- 9가지 종류에서 필요한 것을 선택




2. 실행

$ java -jar Jenkins.jar



3. 브라우저를 통한 연결


http://localhost:8080



* Windows 설치

- msi 실행



- 완료후 자동 접속 : 설치 폴더의 initialAdminPassword를 참조



plugin 설치 : Install suggested plugins 선택




- 설치 화면



- 관리자 계정 생성





- 설치 완료 메시지




* 접속 화



- 설치가 완료되면, Pipeline을 생성해야 한다.

Pipeline은 Code로써 Jenkinsfile로 쓰여진다.


Jenkinsfile (Declarative Pipeline)
pipeline {
    agent any 

    stages {
        stage('Build') { 
            steps { 
                sh 'make' 
            }
        }
        stage('Test'){
            steps {
                sh 'make check'
                junit 'reports/**/*.xml' 
            }
        }
        stage('Deploy') {
            steps {
                sh 'make publish'
            }
        }
    }
}

- Jenkins 글로벌 설정 : JDK(설치본 사용) , Ant(자동 설치 선택)






* 2부 Jenkins + SVN + Ant Build 구성하기

http://pseg.or.kr/pseg/index.php?mid=inforeview&document_srl=7617&listStyle=viewer


- 소스코드 관리 설정 ( Repository URL, Credentials ) -> 빌드 유발(Poll SCM) -> 빌드 (Ant)등을 설정 한다.

- #9 (빌드 순번)을 선택후에 해당 화면에서 Console Output를 선택하면, 자동 Build결과를 확인 할 수 있다. ( Default 위치는 c:\Jenkins\jobs\[Item이름]\builds\[빌드순번]\log 파일 )




* Jenkins port 변경


- 수정 파일 위치 : [설치폴더]\Jenkins.xml ( httpPort를 변경 )





- 서비스 재시작 : 제어판->관리도구->서비스->Jenkins


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


빅데이타 인사이트 과정 

빅데이터 연구원/서울대학교


선수 지식 - 기초통계, 마케팅 기초


세션 1: 데이터처리 개론과 Python 입문
- Python 기본 syntax / interpreter 사용법
- Program structures: functions, if-else, loops
세션 2: 데이터처리 개론과 Python 입문
- 기본 data types & sequences / file 사용
- library 개념과 사용 연습
세션 3: 빅데이터 분석을 위한 통계적 방법론
- 회귀분석, 로지스틱회귀분석
- Python 프로그램 이용 데이터 분석 실습
세션 4: 빅데이터 분석을 위한 통계적 방법론
- 의사결정나무, 군집분석
- Python 프로그램 이용 데이터 분석 실습
세션 5: 마케팅 애널리틱스 (Data-driven Marketing Analytics)
- 시장 수준 애널리틱스 / 애널리틱스 사례 실습 (가격 및 마케팅 활동 효과 분석)
세션 6: 마케팅 애널리틱스 (Data-driven Marketing Analytics)
- 고객 수준 애널리틱스 / 애널리틱스 사례 실습 (고객의 선택, 구매, 이탈 행동 분석)
세션 7: 비정형 데이터 분석을 통한 효율적인 의사결정
- Python 기초문법
- Python을 활용한 웹 크롤링
세션 8: 비정형 데이터 분석을 통한 효율적인 의사결정
- KoNLPy를 통한 텍스트 전처리
- 텍스트 데이터 시각화 및 분석하기
세션 9: 빅데이터 비즈니스 밸류 창출 프로세스
- 빅데이터 아키텍트의 기획
- 인사이트 도출을 위한 빅데이터 분석
세션 9: 빅데이터 비즈니스 밸류 창출 프로세스
- 분석 데이터를 활용한 비즈니스 가치 창출
빅데이터 활용 사례 특강: 빅데이터 세상의 초입: 알파고, 딥러닝, 주식
세션 10: 빅데이터 비즈니스 밸류 창출 프로세스
빅데이터 활용 사례 특강: 디지털 혁신 국가

* http://bigdata.snu.ac.kr/academy/info-insights.php


'Web Tech. > Python' 카테고리의 다른 글

Python 예제  (0) 2017.07.04
Python, Web 보안 (기초)  (0) 2017.07.04
vagrant up, Authentication failure. Retrying 발생시  (0) 2017.05.16
Eclipse(이클립스), Python Editor 설치  (0) 2016.11.16
Python/파이썬 설치  (0) 2016.11.16
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


60초안에 리눅스 성능 분석하기


리눅스 서버에 성능 문제로 접속을 한다면, 최초 1분안에 어떤 부분을 체크 하나요?

You login to a Linux server with a performance issue: what do you check in the first minute?


시스템 리소스 사용량의 정도와 실행중인 프로그램을 아래 10개의 명령어를 통해서 정보를 얻을 수  있다.

uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top


1. uptime

$ uptime
 23:51:26 up 21:31,  1 user,  load average: 30.02, 26.43, 19.02

This is a quick way to view the load averages, which indicate the number of tasks (processes) wanting to run.


2. dmesg | tail

$ dmesg | tail
[1880957.563150] perl invoked oom-killer: gfp_mask=0x280da, order=0, oom_score_adj=0
[...]
[1880957.563400] Out of memory: Kill process 18694 (perl) score 246 or sacrifice child
[1880957.563408] Killed process 18694 (perl) total-vm:1972392kB, anon-rss:1953348kB, file-rss:0kB
[2320864.954447] TCP: Possible SYN flooding on port 7001. Dropping request.  Check SNMP counters.

This views the last 10 system messages, if there are any.

3. vmstat 1

$ vmstat 1
procs ---------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
34  0    0 200889792  73708 591828    0    0     0     5    6   10 96  1  3  0  0
32  0    0 200889920  73708 591860    0    0     0   592 13284 4282 98  1  1  0  0
32  0    0 200890112  73708 591860    0    0     0     0 9501 2154 99  1  0  0  0
32  0    0 200889568  73712 591856    0    0     0    48 11900 2459 99  0  0  0  0
32  0    0 200890208  73712 591860    0    0     0     0 15898 4840 98  1  1  0  0
^C

Short for virtual memory stat, vmstat(8) is a commonly available tool (first created for BSD decades ago).

4. mpstat -P ALL 1

$ mpstat -P ALL 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015  _x86_64_ (32 CPU)

07:38:49 PM  CPU   %usr  %nice   %sys %iowait   %irq  %soft  %steal  %guest  %gnice  %idle
07:38:50 PM  all  98.47   0.00   0.75    0.00   0.00   0.00    0.00    0.00    0.00   0.78
07:38:50 PM    0  96.04   0.00   2.97    0.00   0.00   0.00    0.00    0.00    0.00   0.99
07:38:50 PM    1  97.00   0.00   1.00    0.00   0.00   0.00    0.00    0.00    0.00   2.00
07:38:50 PM    2  98.00   0.00   1.00    0.00   0.00   0.00    0.00    0.00    0.00   1.00
07:38:50 PM    3  96.97   0.00   0.00    0.00   0.00   0.00    0.00    0.00    0.00   3.03
[...]

This command prints CPU time breakdowns per CPU, which can be used to check for an imbalance.

5. pidstat 1

$ pidstat 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015    _x86_64_    (32 CPU)

07:41:02 PM   UID       PID    %usr %system  %guest    %CPU   CPU  Command
07:41:03 PM     0         9    0.00    0.94    0.00    0.94     1  rcuos/0
07:41:03 PM     0      4214    5.66    5.66    0.00   11.32    15  mesos-slave
07:41:03 PM     0      4354    0.94    0.94    0.00    1.89     8  java
07:41:03 PM     0      6521 1596.23    1.89    0.00 1598.11    27  java
07:41:03 PM     0      6564 1571.70    7.55    0.00 1579.25    28  java
07:41:03 PM 60004     60154    0.94    4.72    0.00    5.66     9  pidstat

07:41:03 PM   UID       PID    %usr %system  %guest    %CPU   CPU  Command
07:41:04 PM     0      4214    6.00    2.00    0.00    8.00    15  mesos-slave
07:41:04 PM     0      6521 1590.00    1.00    0.00 1591.00    27  java
07:41:04 PM     0      6564 1573.00   10.00    0.00 1583.00    28  java
07:41:04 PM   108      6718    1.00    0.00    0.00    1.00     0  snmp-pass
07:41:04 PM 60004     60154    1.00    4.00    0.00    5.00     9  pidstat
^C

Pidstat is a little like top’s per-process summary, but prints a rolling summary instead of clearing the screen.


6. iostat -xz 1

$ iostat -xz 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015  _x86_64_ (32 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          73.96    0.00    3.73    0.03    0.06   22.21

Device:   rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda        0.00     0.23    0.21    0.18     4.52     2.08    34.37     0.00    9.98   13.80    5.42   2.44   0.09
xvdb        0.01     0.00    1.02    8.94   127.97   598.53   145.79     0.00    0.43    1.78    0.28   0.25   0.25
xvdc        0.01     0.00    1.02    8.86   127.79   595.94   146.50     0.00    0.45    1.82    0.30   0.27   0.26
dm-0        0.00     0.00    0.69    2.32    10.47    31.69    28.01     0.01    3.23    0.71    3.98   0.13   0.04
dm-1        0.00     0.00    0.00    0.94     0.01     3.78     8.00     0.33  345.84    0.04  346.81   0.01   0.00
dm-2        0.00     0.00    0.09    0.07     1.35     0.36    22.50     0.00    2.55    0.23    5.62   1.78   0.03
[...]
^C

This is a great tool for understanding block devices (disks), both the workload applied and the resulting performance.

7. free -m

$ free -m
             total       used       free     shared    buffers     cached
Mem:        245998      24545     221453         83         59        541
-/+ buffers/cache:      23944     222053
Swap:            0          0          0

The right two columns show:

  • buffers: For the buffer cache, used for block device I/O.
  • cached: For the page cache, used by file systems.

8. sar -n DEV 1

$ sar -n DEV 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015     _x86_64_    (32 CPU)

12:16:48 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
12:16:49 AM      eth0  18763.00   5032.00  20686.42    478.30      0.00      0.00      0.00      0.00
12:16:49 AM        lo     14.00     14.00      1.36      1.36      0.00      0.00      0.00      0.00
12:16:49 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

12:16:49 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
12:16:50 AM      eth0  19763.00   5101.00  21999.10    482.56      0.00      0.00      0.00      0.00
12:16:50 AM        lo     20.00     20.00      3.25      3.25      0.00      0.00      0.00      0.00
12:16:50 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
^C
Use this tool to check network interface throughput: rxkB/s and txkB/s, as a measure of workload, and also to check if any limit has been reached.

9. sar -n TCP,ETCP 1

$ sar -n TCP,ETCP 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015    _x86_64_    (32 CPU)

12:17:19 AM  active/s passive/s    iseg/s    oseg/s
12:17:20 AM      1.00      0.00  10233.00  18846.00

12:17:19 AM  atmptf/s  estres/s retrans/s isegerr/s   orsts/s
12:17:20 AM      0.00      0.00      0.00      0.00      0.00

12:17:20 AM  active/s passive/s    iseg/s    oseg/s
12:17:21 AM      1.00      0.00   8359.00   6039.00

12:17:20 AM  atmptf/s  estres/s retrans/s isegerr/s   orsts/s
12:17:21 AM      0.00      0.00      0.00      0.00      0.00
^C
This is a summarized view of some key TCP metrics. These include:
  • active/s: Number of locally-initiated TCP connections per second (e.g., via connect()).
  • passive/s: Number of remotely-initiated TCP connections per second (e.g., via accept()).
  • retrans/s: Number of TCP retransmits per second.
 

10. top

$ top
top - 00:15:40 up 21:56,  1 user,  load average: 31.09, 29.87, 29.92
Tasks: 871 total,   1 running, 868 sleeping,   0 stopped,   2 zombie
%Cpu(s): 96.8 us,  0.4 sy,  0.0 ni,  2.7 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:  25190241+total, 24921688 used, 22698073+free,    60448 buffers
KiB Swap:        0 total,        0 used,        0 free.   554208 cached Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 20248 root      20   0  0.227t 0.012t  18748 S  3090  5.2  29812:58 java
  4213 root      20   0 2722544  64640  44232 S  23.5  0.0 233:35.37 mesos-slave
 66128 titancl+  20   0   24344   2332   1172 R   1.0  0.0   0:00.07 top
  5235 root      20   0 38.227g 547004  49996 S   0.7  0.2   2:02.74 java
  4299 root      20   0 20.015g 2.682g  16836 S   0.3  1.1  33:14.42 java
     1 root      20   0   33620   2920   1496 S   0.0  0.0   0:03.82 init
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd
     3 root      20   0       0      0      0 S   0.0  0.0   0:05.35 ksoftirqd/0
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
     6 root      20   0       0      0      0 S   0.0  0.0   0:06.94 kworker/u256:0
     8 root      20   0       0      0      0 S   0.0  0.0   2:38.05 rcu_sched

The top command includes many of the metrics we checked earlier. It can be handy to run it to see if anything looks wildly different from the earlier commands, which would indicate that load is variable.


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

 

톰캣 버전과 지원가능한 서블릿 버전 목록

Servlet

JSP Spec

Tomcat

Min. Java

3.0

2.2

7.0.x

1.6

2.5

2.1

6.0.x

1.5

2.4

2

5.5.x

1.4

2.3

1.2

4.1.x

1.3

2.2

1.1

3.3.x

1.1


http://help.eclipse.org/kepler/index.jsp


* Web application overview

The Web development environment provides the tools you need to develop Web applications as defined in the Sun Microsystems Java™ Servlet 2.3 Specification and the Sun Microsystems JSP 1.2 Specification. Web applications can be simple (consisting of only static Web pages) or they can be more advanced and include JavaServer Pages (JSP) files and Java servlets.

웹 개발 환경은 Sun Microsystems Java ™ Servlet 2.3 사양 및 Sun Microsystems JSP 1.2 사양에 정의 된대로 웹 응용 프로그램을 개발하는 데 필요한 도구를 제공 합니다. 웹 응용 프로그램은 단순한 웹 페이지 (정적 웹 페이지만으로 구성 될 수 있음) 또는 Java 웹 페이지 (JavaServer Pages) 파일 및 Java 서블릿을 포함하는 고급 기능을 제공 할 수 있습니다.


* Web projects

Web projects hold all of the Web resources that are created and used when developing your Web application. The first step to creating or importing a Web application is to create either a static or a dynamic Web project. Static Web projects are meant to contain only simple Web site resources, such as HTML files. Dynamic Web projects are used to structure Web applications that will use more complicated, dynamic Web technologies, such as JavaServer Pages files, and possibly data access resources.

웹 프로젝트는 웹 응용 프로그램을 개발할 때 만들어지고 사용되는 모든 웹 자원을 보유합니다. 웹 응용 프로그램을 만들거나 가져 오는 첫 번째 단계는 정적 또는 동적 웹 프로젝트를 만드는 것입니다. 정적 웹 프로젝트에는 HTML 파일과 같은 간단한 웹 사이트 리소스 만 포함됩니다. 동적 웹 프로젝트는 JavaServer Pages 파일 및 데이터 액세스 리소스와 같이보다 복잡하고 동적 인 웹 기술을 사용하는 웹 응용 프로그램을 구조화하는 데 사용됩니다.


* Dynamic Web projects and applications

There are two types of Web projects: dynamic and static. Dynamic web projects can contain dynamic Java EE resources such as servlets, JSP files, filters, and associated metadata, in addition to static resources such as images and HTML files. Static web projects only contains static resources. When you create Web projects, you can include cascading style sheets and JSP tag libraries (for dynamic Web projects), so that you can begin development with a richer set of project resources.

웹 프로젝트에는 동적 및 정적의 두 가지 유형이 있습니다. 동적 웹 프로젝트에는 이미지 및 HTML 파일과 같은 정적 리소스 이외에 서블릿, JSP 파일, 필터 및 관련 메타 데이터와 같은 동적 Java EE 리소스가 포함될 수 있습니다. 정적 웹 프로젝트에는 정적 리소스 만 포함됩니다. 웹 프로젝트를 생성 할 때 동적 웹 프로젝트를위한 CSS 스타일 라이브러리와 CSS 태그 라이브러리를 포함 할 수 있으므로 더 많은 프로젝트 리소스 세트로 개발을 시작할 수 있습니다.

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

Bootstrap 시작 하기


1. 학습 사이트 

http://www.w3schools.com/bootstrap/default.asp 

전체 항목을 배워야 하지만, 너무 많아서 어디서 부터 시작을 해야 할지 모를것 같다.

 


 
2. 동영상 학습  

https://www.youtube.com/watch?v=sTi_hcaBmsg  , 강좌 1. Bootstap Basic

 "웹학교"에서 YouTube를 통해서 w3school.com 사이트를 활용한 강의
사용되는 사이트가 2014년9월(3.2.2)이라 현재 버젼(3.3.5)과는 차이가 있지만 이해 가능


 
3. Bootstrap를 적용한 Theme 학습 - BS Theme "Company"


해당 테마를 하나씩 따라하면, 간단한 회사 홈페이지를 구현하게 되고, 이해가 쉬워진다.


사이트 : http://www.w3schools.com/bootstrap/bootstrap_theme_company.asp



* Bootstrap 사용시 포함할 부분



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.
Log4j 사용하기 ( in MVC controller )  

1. Log4j Library 프로젝트에 추가하기

1) Log4j-1.x.x.jar를 libray에 복사

2) Maven을 사용해서 자동 다운로드 ,  pom.xml
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>
2. log4j.properties구성
 # LOG4J configuration
log4j.rootLogger=INFO, console, file

# Console Logger
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%p] %d %c %x - %m%n

# File Logger
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/oes
log4j.appender.file.DatePattern='-'yyyy-MM-dd'.log'
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%p] %d %c %x - %m%n
  3. 호출(사용법)
// Controller
public class AAAController 
{
    private Logger logger = Logger.getLogger(AAAController.class);
    public loginAction()
    {
        logger.info( String.format("name[%s]",new Object[] {name} );
    }
}
출처 :  http://zjhzxhz.com/2014/06/integrate-spring-mvc-with-log4j/


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



Workingset를 Eclipse에 추가 하기


1. eclipse설정를 통해서

1) workspace
2) Open Perspective, Show View
3) Project Explorer부분에  Package Explorer를 추가 하기


참조 : http://sessionk.tistory.com/16



2. WorkingSet 추가하는 과정

0. Show View - Package Explorer


1) Package Explorer에서 Top Level Element를 Working Sets로 변경


2) Configure Working Sets로 추가 하기

참조 : http://whiteship.tistory.com/1441


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Java,  Ip Address 가져오기


- 다중 Network Interface를 갖고 있는 경우에 생기는  문제 


1. 일반적인 접근

  InetAddress ip;
  String hostname;
  String ipString ;
  
  ip = InetAddress.getLocalHost();
  hostname = ip.getHostName();
  ipString = ip.toString();

 System.out.println("is contain?  " + ipString.contains("192.168.") );


2. 다중 Network Interface 찾기

public class GetIpAddress {

    public static void main(String args[]) throws SocketException  {

    	System.out.println( "isSame = " + isSame("192.168.0.13") ); 
    	
    }

    static boolean isSame(String checkIp) throws SocketException {
    	
    	String interfaceIp=null;

    	// NetworkInterface.getNetoworkInterfaces()
        Enumeration nets = NetworkInterface.getNetworkInterfaces();
        
        for (NetworkInterface netint : Collections.list(nets)) {
            interfaceIp = displayInterfaceInformation(netint);
            if ( interfaceIp != null ) {
            	if( interfaceIp.contains(checkIp) )
            		return true;
            }
        }
        return false;
    }

    // NetworkInterface : getDisplayName(), getInetAddresses()
    static String displayInterfaceInformation(NetworkInterface netint) throws SocketException {

    	System.out.printf("Display name: %s \n", netint.getDisplayName());
    	//System.out.printf("Name: %s\n", netint.getName());

        Enumeration inetAddresses = netint.getInetAddresses();
        for (InetAddress inetAddress : Collections.list(inetAddresses)) {
        	
        	// only ipv4
        	if ( inetAddress instanceof Inet4Address ) {
        		System.out.printf("InetAddress: %s\n", inetAddress);
        		return inetAddress.toString();
        	}
        }
        return null;
     }

}


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


awk print



':'를 구분자로 첫번째 파일명을 출력

$ file * | grep HTML | grep -v jpg | awk -F: '{print $1}'



print문장에 명령어를 추가하고 shell로 저장

$ file * | grep HTML | grep -v jpg | awk -F: '{print "mv " $1 " " $1".old" }' > a.sh



참조 : http://www.commandlinefu.com/commands/view/1138/ps-ef-grep-process-grep-v-grep-awk-print-2-xargs-kill-9


$ ps -ef | grep PROCESS | grep -v grep | awk '{system "kill -9" $2}


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Upload Fake Image(가짜 이미지, 피싱스크립트) 의 검증


단순히 업로드 파일의 확장자로 구분되지 않는 phishing(피싱)파일을 제거하기 위해서 사용 가능


수천가지 다른 종류의 file type으로 부터 문자열,메타정보와 종류를 판별하는 프로젝트

https://tika.apache.org/ , a content analysis toolkit.

tika-app1.14.jar Library를 다운로드 ( https://tika.apache.org/download.html )


예제 소스

import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.tika.Tika; public class TestMain { public static void main(String[] args) throws Exception { //File f = new File("fakeTest.png"); // text/html //File f = new File("jpgTest.jpg"); // image/jpeg File f = new File("pngTest.png"); // image/png //File f = new File("gifTest.gif"); // image/gif System.out.println( f.toString()); System.out.println( f.getAbsolutePath() ); String allowFileExt = "image/jpg;image/jpeg;image/png;image/gif;"; if ( f.isFile() ) { Tika tika = new Tika(); try { String detectedType = tika.detect( new FileInputStream(f) ); System.out.println("Type : " + detectedType ); if (allowFileExt.indexOf(detectedType) == -1) { throw new Exception("Use only Type : JPG, JPEG, PNG, GIF"); } } catch (IOException e) { e.printStackTrace(); } } else { System.out.println("-not-" ); } } }




'Web Tech. > Spring Framework' 카테고리의 다른 글

Java,  Ip Address 가져오기  (0) 2017.02.07
awk print  (0) 2017.02.01
2개의 war 비교하기  (0) 2017.01.25
2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술  (0) 2017.01.24
HMAC SHA-256 이해  (0) 2017.01.24
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



2개의 war 비교하기




1. war 상태에서 비교 하기


$ diff 01.war 02.war
Binary files 01.war and 02.war differ



2. war 풀기 ( 특정 디렉토리로 이동해서 )


$ mkdir 01
$ cp 01.war 01
$ cd 01
$ jar xvf 01.war
 ▒▒▒▒▒▒: META-INF/MANIFEST.MF



3. Directory 비교하기


$ diff -r 01 02
* diff 결과

<는 a(file1)에만 있는 내용, >는 b(file2)에만 있는 내용을 의미




4. class를 decompile후에 Directory 비교 하기

하위 디렉토리의 class파일(-r **/*.class)을 원하는 디렉토리(-d .)에 확장자 .java( -s java)로 풀기
$ jad -d . -s java -r **/*.class 



* Ubuntu Java/Jar 설치하기

- 특정 버젼 설치하기
$ sudo apt-get install openjdk-7-jdk
- 가능 버젼 검색하기
$ apt-cache search jdk

http://stackoverflow.com/questions/14788345/how-to-install-jdk-on-ubuntu-linux



* Vim VI에서 ^M 지우기

:%s/^M$//g

* 주의! 그런데 위의 정규식에서 빨간색으로 된 ^M 이라는 문자열을 직접 글자 그대로 타이핑하면 안됩니다. 반드시 키보드의 Ctrl+V 키와 Ctrl+M 키를 눌러서 간접적으로 입력해야 합니다.


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,