build.gradle에서 npm run build 수행방법:


plugins {
id "com.moowork.node" version "1.2.0"
}
apply plugin: 'com.moowork.node'
task npmBuild(type: NpmTask) {
args = ['run-script','build']
}
build.dependsOn npmBuild



그리고, jar하면서 react.js의 결과파일을 static으로 넣는 방법은

 web-frontend 프로젝트를 별도로 만들고, (위의 build.gradle작업은 여기서 하고)


메인 spring-boot-webapp 프로젝트의 build.gradle에서   아래와 같이  의도적으로 build밑에껄 복사해준다.

jar {
//blabla
from {
configurations.compile.collect {it.isDirectory()? it: zipTree(it)}
}
into('static') {
from('../web-frontend/build')
}
}


Posted by yongary
,

Ajax axios, Redux

React.js 2018. 2. 25. 23:26


React에서 ajax기능을 사용할때는 axios HttpClient를 많이 사용한다.   REF



  axios.get('/user?id=velopert')

    .then( response => { console.log(response); } ) // SUCCESS
    .catch( response => { console.log(response); } ); // ERROR

axios.post('/msg', { user: 'velopert', message: 'hi' }) .then( response => { console.log(response) } ) .catch( response => { console.log(response) } ); //catch는 생략가능

//IE 호환문제 ? babe-polyfill로 해결? -> test해보자.

class 활용 예제. 

https://laracasts.com/discuss/channels/servers/get-data-out-from-axios-javascript



Redux 는 study중:    dispatcher방식으로 state관리  https://velopert.com/1225   




=================물론 jquery $.ajax도 사용할 수 있다 =================


 (POST앞에 있는것은 커서임)


출처:유투브



Posted by yongary
,

키보관 방법

블록체인 2018. 2. 18. 00:03

키나 IOTA seed를 암호화해서 보관하고 싶으면


파일을 알집으로 암호넣어서 zip을 한다음에


axcrypt.net에서 프로그램을 다운받아서 아주 긴 비번으로 로그인을 해서, 암호화를 하도록 한다.

256bit 알고리듬으라 안전하다.  



Posted by yongary
,

kubernetes

SDN,cloud,Puppet 2018. 2. 12. 19:19

Docker를 여러개의 host에서 쓴다던지 하는 경우로 인해,

서로 다른 Host내의 docker끼리 통신을 해야한다면(inter-host comm.)


Kubernetes를 사용하면 된다. 

Kubernetes에는 그 외에도 몇가지 기능이 있는데.. 


Posted by yongary
,

비트코인 지갑

블록체인 2018. 2. 1. 23:07

 REF

 비트코인 지갑 : 처음들으면 Bitcoin이 들어있는 것으로 착각들을 하지만, 실제로는 private키만 보관한다.

   종류는 인터넷에 연결된 Hot Wallet과  그렇지 않은 Cold Wallet이 있고 ,   HD(계층 결정적)Wallet도 참고삼아 보자.


  Hot Wallet - full node에는 full wallet,  SPV Node에는 SPV(Simple Payment Verification) wallet. 

                     전체 blockchain을 저장하지 않으면서 full node들의 메모리를 이용하는 가벼운 장점으로 인해, 모바일을 비롯해 많은 SPV wallet들이 발전중이다.


  Cold Wallet - 종이나 USB 혹은 특별히 제작된 Hardware와 같이 offline으로 private key를 저장하는 Wallet.




  HD Wallet - 24개 이하의 단어를 쓰면 private key를 생성해줘서 약간 외울수 있는 수준의 private key를 만들어 주는 지갑.

             brain Wallet도 비슷한 개념인거 같네요.   암튼 이것도 단어는 추측이 쉬워서 보안에 취약하다는 거...  

        정리하면) 단어를 이용해 pk를 만들거나 단어를 통해 pk를 암기하는 방식으로 pk를 안외워도 되는 방식이지만 보안에 썩 좋진 않음

        ==> 그래도  왠지 이게 끌리네요. 가성비가 좋을듯. 



 -------------  private key를 보관하지 않는 wallet --------  비트코인 지갑이라고 부를수 없을것 같구요

  Web Wallet- pk를 3자에게 맡긴 것으로, 거래소 등에 Wallet을 맡겼다고 보면 된다.  당근 위험!  

Posted by yongary
,

jQuery의 팝업 기능으로 간단히 이쁜 layer팝업을 만들수 있다.

 - 이걸 모를때는 bootstrap을 사용했었는데, jQuery가 더 편하다.

  (이쁘기는 bootstrap이 더 이쁠 것 같아요)



- 사용법도 간단하다.  REF


1. jquery관련 인클루드

  <script type="text/javascript" src="blabla/js/jquery.popup.min.js"></script>


2. html 팝업코딩

  <div id="popup" class="pop_style">

     blabla

  

3. jquery로 호출.

  뛰우기:  $('#popup').bPopup();


  close:   $('#popup').bPopup().close();

Posted by yongary
,

Excel upload

springBoot gradle 2018. 1. 23. 11:46

 poi 이용 : 한글 REF 

    영문: REF



1. maven dependency 추가.

<dependency>

<groupId>org.apache.poi</groupId>

<artifactId>poi</artifactId>

<version>3.15</version>

</dependency>

         <dependency>

            <groupId>org.apache.poi</groupId>

            <artifactId>poi-ooxml</artifactId>

            <version>3.15</version>

        </dependency>

<dependency>

            <groupId>org.apache.poi</groupId>

            <artifactId>poi-ooxml-schemas</artifactId>

            <version>3.15</version>

        </dependency>

        <dependency>

            <groupId>org.apache.poi</groupId>

            <artifactId>poi-contrib</artifactId>

            <version>3.6</version>

        </dependency>


2. JSP

function fnCheckUpload() {

var file = $("#excel").val();

if(file == "" || file == null){

alert("먼저 파일을 선택하세요.");

return false;

}

var fileFormat = file.split(".");

var fileType = fileFormat[1];

if(confirm("업로드 하시겠습니까?")){

$('#excelUpForm').attr('action','/uploadMoveinExcel.do');

var options = {

fail:function(data) {

        alert('저장 오류가 발행하였습니다.');

        $('#popup').bPopup().close();

        },

success:function(data){

alert(data + "건 업로드 완료");

$('#popup').bPopup().close();

},

type: "POST",

data : {"excelType" : fileType}

};

$('#excelUpForm').ajaxSubmit(options);

}

}

-----HTML--------

<form id="excelUpForm" method="post" action="" role="form" enctype="multipart/form-data">

                                    <input  id="excel" name="excel" class="file" type="file"  >


</form>



3. controller

  @ResponseBody

@RequestMapping(value="/uploadMoveinExcel.do")

public String uploadExcel( MultipartHttpServletRequest request, HttpSession session) {

List<ExcelVo> list = new ArrayList<>();

String excelType = request.getParameter("excelType");

log.info("uploadExcel.do + excelType:" + excelType);

if(excelType.equals("xls")){

list = moveinService.xlsExcelReader(request);

}else if(excelType.equals("xlsx")){

//IN_STUDY:  list = adminAccountsMngService.xlsxExcelReader(req);

}

int cnt = service.uploadList(list);

return String.valueOf(cnt);//success cnt : media처리의 경우, JSON포맷으로 잘 안변함(config필요), 따라서 간단히 숫자만 리턴.

}


4. service

  public List<MoveinExcelVo> xlsExcelReader(MultipartHttpServletRequest request) {

// 반환할 객체를 생성

List<MoveinExcelVo> list = new ArrayList<>();


MultipartFile file = request.getFile("excel");

HSSFWorkbook workbook = null;


try {

// HSSFWorkbook은 엑셀파일 전체 내용을 담고 있는 객체

workbook = new HSSFWorkbook(file.getInputStream());


// 0번째 sheet 반환

HSSFSheet curSheet = workbook.getSheetAt(0);  //workbook.getNumberOfSheets()

// row 탐색 for문

boolean isInTable = false;

for (int rowIndex = 0; rowIndex < curSheet.getPhysicalNumberOfRows(); rowIndex++) {

//헤더 Cell 찾기.

String firstCellValue = curSheet.getRow(rowIndex).getCell(0).getStringCellValue();

if ("구분".equals(firstCellValue.trim())) { //table헤더 발견.

isInTable = true;

continue; //헤더는 pass.  (다움줊부터 paring시작.)

}

if (isInTable) { //in Table 파싱 시작. ///////////////////////////////////////////

HSSFRow curRow = curSheet.getRow(rowIndex);

//필수 Cell들.

String cellStr = curRow.getCell(2).getStringCellValue(); //String 읽기

String cellDate =  StringUtil.toYYMMDD(curRow.getCell(5).getDateCellValue()); //날짜 읽기

String cellNum = curRow.getCell(7).getNumericCellValue() + ""; //산차.

  String cellLongNUm = StringUtil.toIntString(curRow.getCell(12).getNumericCellValue() ;   //엄청 긴 숫자 읽기

. . . . 

} catch (IOException e) {

e.printStackTrace();

}


// vo로 만들면서 db에 삽입코드는 생략.

return list;

}


public class StringUtil {


    private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

    public static String datePattern = "^\\d{4}[\\-](0[1-9]|1[012])[\\-](0[1-9]|[12][0-9]|3[01])$";

    public static boolean isDate(String str) {

    return Pattern.matches(datePattern, str);

    }

    //return YYYY-MM-DD String

    public static String toYYMMDD(Date date) {

    return formatter.format(date);

    }

    public static boolean isNumericOrFloat(String str) {

        if (str == null) {

            return false;

        }

        int sz = str.length();

        for (int i = 0; i < sz; i++) {

            if (Character.isDigit(str.charAt(i)) == false) {

            if (str.charAt(i) != '.')  //Added KY. '.'도 numeric으로 간주. float때문에.

            return false;

            }

        }

        return true;

    }

    

    //For Excel processing.

    // 엑셀에선 숫자를 항상 double로 읽기 때문에 int형태의 String으로 변환하면 유용.

    public static String toIntString(double doubleVal) {

    try {

    BigInteger k = new BigDecimal(doubleVal).toBigInteger();

    

    return String.valueOf(k);

   

    } catch (Exception e) {

    return null;

    }

    }

Posted by yongary
,

특수기능

ElasticSearch 2018. 1. 22. 21:38

template: 여러개의 template을 지정해 놓을 수 있음.

     -> 잘못 사용하면 여기에 계속 걸려서, insert가 안되는 경우도 있으니 조심필요.



join: 부모-child관계 지정.   (예:질문-답변)  REF

       RDB의 relation과 어느정도는 유사하게 사용이 가능하지만,

       one-to-many 관계에서만 사용하는 게 좋다. 

       (그리고, 한 index안에서만 사용한다 )


 -Relation: 부모와 자식관계 설정

 -Child 여러 개 설정 가능

- (손자)Child 밑에 Child를 둘 수 있음





_segment: segment내의 data까지 조회가 가능하다.





Posted by yongary
,

js 모듈화 코딩기법

jquery 2018. 1. 2. 09:14

http://www.nextree.co.kr/p4150/  

Posted by yongary
,

기본 Query예제

ElasticSearch 2017. 12. 31. 08:22


kibana필터 기본 문법:   REF - 루씬 문법임. . 

     title:(+return +"pink panther") : Field grouping - REF

  

timeliion 문법: REF



== 그 외 아래는 elastic 기본 Query예제이다. ====================================

 



  Index데이타넣기 + 자동생성 : REF


PUT /twitter
/doc/1 (1은 생략시 자동생성) { "user" : "kimchy", "post_date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch" }



Index 생성 및 Mapping 조정: REF

PUT twitter :생성 {} PUT twitter/_mapping/_doc { "properties": { "name": { "type": "text" } } } //type:keyword가 중요

데이타 타입: REF



문서하나 Delete:

    DELETE /twitter/_doc/1

   


 Delete Index:

 DELETE /twitter






  Match:  REF


GET entry/_search

{

  "query": {

    "term": {"play_name":"Hamlet"}

  }

}


GET entry


GET /_search { "query": { "match" : { "message" : "this is a test" } } }



Posted by yongary
,