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


Hello World를 Perl로 작성하기


1. 설치된 perl 위치 찾기

$ which perl
/usr/bin/perl


2. hello.pl 작성하기

#!/usr/bin/perl # 위치, Full Path # hello.pl # perl program name print "Hello World\n";

* #는 주석문 , ;(semi colon)는 명령문장의 끝


3. hello.pl 실행하기

$ ./hello.pl
Hello World
$ perl hello.pl
Hello World



* Perl은
Larry Wall이 만든 Practical Extraction and Report Language라는 언어로 문서 형태의 데이터로 부터 필요한 정보들을 추출(Extraction), 그 정보를 바탕으로 새로운 문서를 구성(Report)하는데 아주 잘 맞는 언어입니다.  http://www.perl.or.kr/perl_iyagi/intro



변수 $(일반변수) 


1. 작성하기
#!/usr/bin/perl
# hello.pl

$price=1000;
print "$price\n";

$price="1000" * 2;
print "$price\n";

print "Hello World\n";

$price="Very expensive.";
print "$price\n";

* 모든 숫자는 실수형( 정수형이 아니라)으로 저장 , 문자열로 재할당도 가능

2. 실행하기
$ ./hello.pl
1000
2000
Hello World
Very expensive.


블로그 이미지

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.

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


머신러닝, 게임 지표 분석 따라하기


머신러닝 피드백을 이용한 게임 지표 분석(https://goo.gl/6MQUbe)에서 참조한 Discovering Ketosis : how to effectively lose weight(https://github.com/arielf/weight-loss)를 따라 해 보기




"Ariel이 Github에 올린 머신러닝을 이용한 다이어트 방법은 얼마 전 해커 뉴스에 소개되면서 주목받았는데 발상의 전환이라 할 만 하다. 매번 식사를 하거나 운동을 할 때 칼로리를 신경쓰지 않고 그 날 자신이 한 행동 중 체중에 영향을 주었다고 생각하는 것들을 기록한다. 그리고 이렇게 일정량 쌓인 데이타를 일부 가공해 vowpal-wabbit에 쓸 수 있는 트레이닝셋을 만든 뒤 이를 이용해 훈련시킨 손실함수 계산으로 어떤 행동이 체중의 변화에 어떻게 기여하는지를 귀납적으로 추론한 것이다."


"개별 아이템의 가격이나 밸런스 조정에서 각 스킬의 수치 조정 부분은 사실상 이해 할 수 없는 블랙박스다"

"머신러닝을 이용하여 이 개별 수치 X를 조사하여 어떤 아이템이 매출의 증대에 도움이 되었고 어떤 것이 오히려 마이너스인지 분류하는 방법을 도입한다면 개별 수정사항이나 추가 아이템에 대한 객관적 평가가 가능해지고 매출이나 유저 만족도 평가를 더 개선하는 방향으로 이후 계획을 세우기 더 쉬워지지 않을까."



1. git clone하기


$ git clone https://github.com/arielf/weight-loss


- git clone해서 make 실행( 이에 대한 설명은 HOWTO.md를 참조 할 것 )



- make sc는 스코어에 관한 차트를 만들어 준다.

* 그래프는 위아래가 바뀌어서 나오네요.


- make시에 주의할 점은 ariel.csv를 계정명.csv로 변경해주면 됩니다.

    ( ariel.csv : vowpal-wabbit용 스크립트에 필요한 훈련용 데이터셋 )


* Vowpal Wabbit ( VW) project

is a fast out-of-core learning system sponsored by Microsoft Research and (previously) Yahoo! Research.




2. 게임 지표 분석 따라하기


1) 매출 엑셀 작성

* 동일하게 작성하고, date_iid_price_purchases_users.csv로 저장


2) perl 스크립터 작성

* 위의 코드는 convert.perl로 일단 저장


3) 변환 시키기


$ ./convert.perl date_iid_price_purchase_users.csv > data.csv

* data.csv는 위의 ariel.csv와 같이 계정명.csv로 변환해서 사용

* date_iid_price_purchases_users.csv는 샘플의 1일치보다 많게 작성할 것

* 위의 결과 화면은 화면상에 보이는 예제 엑셀만을 변환한 결과이며, 실제로 많은 데이타를
변환한다면, 좀 더 복잡한 결과가 나온다. 1줄의 길이가 터미널 전체가 될 수도 있다.


3. game-sales-item 데이타를 weight-loss에 적용하기


상위 data.csv에 2번째 column부분에 daily total sales를 추가 후에

$ cp data.csv vagrant.csv  // 계정명.csv
$ make
$ make sc

* 최종적으로 일자별로 총매출을 2번째 컬럼에 추가하면, ariel.csv와 유사 해 진다.

* 아래 data는 자세히 보이지 않지만, 의미적으로 이해하기에는 충분

* 결과 : Weight Gain ( Sales Gain ), Weight Loss ( Sales Loss )



* 16개월 간의 몸무게 변화 그래프

    - requires : R and ggplot2
    - script : date-weight.r  ( 10분만에 살펴보는 R 기초 문법, http://dev.epiloum.net/1546 )
    - data-set : weight.2015.csv





블로그 이미지

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.

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





2017년 1월 스타트업에서 구인(채용)시 원하는 개발관련 기술





개발 언어, DBMS/noSQL, Cloud등의 서비스 Flatform, Software등을 살펴 보면,




1th 그룹 : Java, NodeJS, Android, Python, JQuery, Amazon


2nd 그룹 : Redis, AWS, AngularJs, iOS, PostgreSQL, Nginx, Django , MongoDB




최신 기술의 동향일 수도 있지만, 이직 또는 구직을 위해서 학습을 해야 한다면, 참고 할 만 하다.





* 자료는 개발자 채용 정보 제공 사이트 rocketpunch.com의 


인기 채용 공고 40건 참조



* 채용시 사용된 keyword 리스트 추출




php
mysql
linux
android
git
kotlin
gcm/fcm
python
mssql
mongodb
amazon aws
ios
objective-c
swift
github
python
c++
django
python
postgresql
amazon aws
html5/css3/javascript
android
java
mysql
python
c++
c#
java
aws
cloud-server
dbms
node.js
postgresql
redis
nginx
react.js
hapi.js
amazon aws
restful-api
angularJS
jQuery
html5/css3/javascript
android
firebase
custom ui component
restful-api
asp.net
c#
html 
css
javascript
bootstrap
angularjs
node.js
php
mongodb
redis
프론트엔드 주요 기술
javascript
jquery
ajax
angularjs
wbesocket
html5/css3/javascript
android
ios
java
xcode
node.js
coffeescript
mysql
amazon ec2
amazon es3
android
ios
node.js
php
python
java
ios
php
mysql
apache
python
android
redis
node.js
jquery
msa
node.js
java
restful-api
linux
nosql
golang
redis
nginx
mysql
expressjs
c++
php
mysql
node.js
mongodb
android
ios
git
jira
c++
java
lucene
soir
elasticsearch
indexing
search-engine
web scraping(web crawling)
java
jsp
mysql
unity3d
cocos2d-x
c#
java
mahout-recommender
aws emr
text-mining
hadoop
elasticsearch
node.js
mongodb
nginx
redis
restful-api
amazon aws
java
python
node.js
jquery
java
python
android
ios
java
node.js
angularjs
mysql
android
java
php
jsp
jquery
mysql
html5/css3/javascript
jquery
java
python
django
html5/css3/javascript
node.js
android
mongodb
jquery
meteor
nginx
amazon aws
cordova
lamport
java
android
java
android studio
python
django
mariadb
rest API
docker
jenkins
django template engine 
cbv
javascript
html
css
angularjs
jquery
bootstrap
html/css/javascript
mysql
node.js
redis
amazon aws
php
jquery
mysql
java
python
node.js
amazon aws
codeigniter
nosql
elasticsearch
python
postgresql
redis
mongodb
flask
django
nginx
apache
sqlalchemy
oracle
python
angularjs
jquery
postgresql
nginx
redis
django
asana
slack


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

Upload Fake Image(가짜 이미지, 피싱스크립트) 의 검증  (0) 2017.01.31
2개의 war 비교하기  (0) 2017.01.25
HMAC SHA-256 이해  (0) 2017.01.24
Tomcat JDBC Connection Pool  (0) 2016.12.20
SVN 연결 해제, 재연결  (0) 2016.12.15
블로그 이미지

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.

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

SHA-256 해시(Hash) 이해

 

# SHA-256 Hash Calculator(계산기)를 통한 변환

 

# 해시(Hash)?

많은 용량의 데이타를 고정된 크기의 고유값으로 만드는 것이다. 데이타 값이 약간만 달려져도 해시에는 예측할 수 없는 큰 변화가 발행하며 전형 다른 값이 되며, 이를 일명 눈사태 효과라고 부른다.

 

# HMAC(해시 메시지 인증 코드)?

해시는 데이터의 수정 또는 변경은 검출 할 수 있으나, 거짓 행세는 찾을 수 없기 때문에

인증이 필요해 진다.

 

송신자와 수신자만이 공유하고 있는 Key와 Data(메시지)를 혼합해서 해시값을 만드는 것이다. 이를 HMAC(Hash-based Message Authentication Code)이라고 한다.

 

 

SHA-256 ?

Secure Hash Algorithm(SHA)-256약자의 조합으로 생성된 고유의 값이 256비트이다. ( 하지만, SHA-1은 1비트가 아니고, ver.1을 뜻한다. )

SHA-2기반으로 SHA-224, SHA-256,SHA-384, SHA-512가 만들어 졌다. ( 뒤에 숫자는 비트수를 의미한다. )

SHA-1(160비트)은 2008년에 보안에 심각한 결함이 발견

 

 

# 해쉬함수별 출력값(해쉬값) 길이 비교

Hash 함수

출력값 길이

16진수

md5

128 bits

32 bytes

ex) 8380482228e75045a7d14e063bde014b

sha-1

160 bits

40 bytes

ex) 764C46AE8BC50C4823E50F18DA45B9A21E8DD10B

sha-256

256 bits

64 bytes

ex) be178c0543eb17f5f3043021c9e5fcf30285e557a4fc309cce97ff9ca6182912


 

# 참조 :

http://sunphiz.me/wp/archives/1104?ckattempt=1

http://www.xorbin.com/tools/sha256-hash-calculator

https://www.jokecamp.com/blog/examples-of-creating-base64-hashes-using-hmac-sha256-in-different-languages/

 

 

# Message Digest 만들기

StringBuffer hexString = new StringBuffer();
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] hash = md.digest();

for (int i = 0; i < hash.length; i++) {
    if ((0xff & hash[i]) < 0x10) {
        hexString.append("0"
                + Integer.toHexString((0xFF & hash[i])));
    } else {
        hexString.append(Integer.toHexString(0xFF & hash[i]));
    }
}

 

출처 : https://stackoverflow.com/questions/5470219/get-md5-string-from-message-digest

블로그 이미지

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.

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

PostgreSQL CPU 과다 사용 ( high CPU Usage )




Postgres 프로세스중에서 CPU가 높은 PID를 찾고, 해당 PID를 통해서 Postgres ID를 찾아,

실행중인 query문장을 찾는다.






>Postgres(포스트 그레스) Backend ID(datid)를 System 프로세스 ID와 일치하는 정보는 아래 쿼리 결과를 통해서 실행된 query를 살펴 볼 수 있다.

SELECT pid, datname, usename, query FROM pg_stat_activity
where pid='';



> 실행 결과 예제 ( 구version )



http://dba.stackexchange.com/questions/44084/troubleshooting-high-cpu-usage-from-postgres-and-postmaster-services






* pg_stat_activity 속성

One row per server process, showing information related to the current activity of that process, such as state and current query. See pg_stat_activity for details.
ColumnTypeDescription
datidoidOID of the database this backend is connected to
datnamenameName of the database this backend is connected to
pidintegerProcess ID of this backend
usesysidoidOID of the user logged into this backend
usenamenameName of the user logged into this backend
application_nametextName of the application that is connected to this backend
client_addrinetIP address of the client connected to this backend. If this field is null, it indicates either that the client is connected via a Unix socket on the server machine or that this is an internal process such as autovacuum.
client_hostnametextHost name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for IP connections, and only when log_hostname is enabled.
client_portintegerTCP port number that the client is using for communication with this backend, or -1 if a Unix socket is used
backend_starttimestamp with time zoneTime when this process was started, i.e., when the client connected to the server
xact_starttimestamp with time zoneTime when this process' current transaction was started, or null if no transaction is active. If the current query is the first of its transaction, this column is equal to the query_start column.
query_starttimestamp with time zoneTime when the currently active query was started, or if state is not active, when the last query was started
state_changetimestamp with time zoneTime when the state was last changed
waitingbooleanTrue if this backend is currently waiting on a lock
statetextCurrent overall state of this backend. Possible values are:
  • active: The backend is executing a query.

  • idle: The backend is waiting for a new client command.

  • idle in transaction: The backend is in a transaction, but is not currently executing a query.

  • idle in transaction (aborted): This state is similar to idle in transaction, except one of the statements in the transaction caused an error.

  • fastpath function call: The backend is executing a fast-path function.

  • disabled: This state is reported if track_activities is disabled in this backend.

querytextText of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed.


블로그 이미지

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.

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



3. OctoberCMS , Creating Themes




1) 테마 만들기 ( myoctober.app:8000/backend , homestead설정 사용시 )



생성하기

- CMS -> Front-end theme -> 'Create a new blank theme'


속성 설정


- Name : Olympos

- Directory name : olympos

- Description : New starter theme

- Author : Ivan Doric

- Homepage : http://myoctober.app:8000






*테마 생성 위치 : themes/olympos/theme.yaml



활성화 - Activate Theme ( 신규 테마로 변경 )

: CMS->Front-end theme ->'Activate' Olympos





2) Layout 생성하기 : default.htm



메뉴 : CMS -> Layouts -> +Add : default.htm


위치 : themes/olympos/layouts/default.htm



* 기존 demo/layouts/default.htm를 copy하고, header/footer는 일단 삭제


* css : style.css 신규 생성

  <link href="{{ 'assets/css/style.css'|theme }}" rel="stylesheet">

      


* js : app.js는 신규 생성 ( jquery.js는 복사 )

        <script src="{{ [
            'assets/js/jquery.js', 'assets/js/app.js',
            ]|theme }}"></script>




3) Homepage 생성하기 : homepage.htm



메뉴 : CMS -> Layouts -> +Add : homepage.htm ( URL : / )


위치 : themes/olympos/pages/homepage.htm


Markup :

<h1>This is our homepage</h1>


4) 실행 결과

 






* 브라우저 View Source결과 ( script는 단일 파일로 변경되어, 요청 traffic을 감소 시킴 )

<!-- Scripts -->
<script src="http://myoctober.app:8000/combine/ffc6422ecc7902bad467abb69edcd8cb-1484897286"></script>

동영상 (영문 강좌)

     - watch-learn.com october-cms


블로그 이미지

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.October CMS , Basic Concepts ( 기본 개념 )




* Backend 접속 하기


URL : myoctober:8000/backend

ID/PW : admin/admin







1) 컨셉 1, Pages



- CMS -> Pages메뉴에서 '+Add'를 통해서 생성


- TITLE의 입력시

--입력값에 따라 URL 및 Filename을 자동 생성( 필요에 따라 변경 가능 )


-- [hostname:port]/URL로 접근 가능


-- 설정 항목 : Filename, Layout, Description, Markup(HTML)


- Markup내에서
-- Content 사용시:
 --- 사용 문법 : {% content "welcome.htm" %}
  --- 저장 위치 : themes/demo/content/welcome.html



-- Layout 선택 : default


     --- 저장 위치 :  themes/demo/layouts/default.htm


     --- Partial 사용시 : footer
         ---- 저장 위치 : themes/demo/partials/footer.htm
         ---- 사용 문법 : {% partial 'footer' %}



- Page의 물리적인 파일 구조와 저장 위치


    -- 위치 : themes/demo/pages/homepage.thm ( 기본 설치는 themes/demo에 위치 )


    -- 파일 : 속성 영역과 HTML Code영역으로 구분되어서 저장




예) 신규 Page : 'about'



- 설정 화면 : Layout(default)




- 결과 화면




2) 컨셉2, Plugin


- 설치 메뉴 

-- Settings -> SYSTEM -> Updates & Plugins -> Install Plugins


- blog plugin 설치후 사용하기 

-- 카테고리와 글을 추가

-- Categories -> New(새 카테고리) : New cat (Name ), new-cat ( Slug )

-- New post(새 포스트) -> (edit text) ->Save ( Manage, Published선택 )



- 목록 화면을 보여주기 위해서 페이지 추가

-- Pages -> +Add

--- blog라는 TITLE로 생성 (blog.htm)

-- Components -> BLOG를 선택하고 'Post List'를 'Markup' 영역으로 이동후 Save

--- blog.htm : {% component 'blogPosts' %}



-- 실행 화면 : myoctober:800/blog



- 내용 화면을 보여주기 위해서 페이지 추가

-- Pages -> +Add

--- blog-post라는 TITLE로 생성 (blog-post.htm, url : /blog/:slug )


-- Components -> BLOG를 선택하고 'Post'를 'Markup' 영역으로 이동후 Save

--- blog-post.htm : {% component 'blogPost' %}




-- 목록 페이지의 Post List 컴포넌트의 Links(Post page)에 연결


-- 실행 화면 ( 목록에서 선택시 )  : Layout(default) 미적용





* Backend 스크린샷

-Dashboard


-CMS

-- Pages, Partials, Layouts, Content, Assets, Components


-Media
-- Images, Video, Audio, Documents


-Setting
-- CMS : Front-end theme, Maintenance mode
-- SYSTEM : Updates & Plugins, Administrators, Customize back-end, Editor settings
-- MAIL : Mail Configuration, Mail templates
-- LOGS : Event log, Request log, Access log







관련 동영상 : Part2 Basic Concepts

http://watch-learn.com/series/making-websites-with-october-cms






사전 준비 : October CMS on Homestead 설치, http://printhelloworld.tistory.com/79

블로그 이미지

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.

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


OctoberCMS on Laravel(라라벨) Homestead



1) 소개


OctoberCMS는 무료이고, 오픈 소스이며, 자체 호스팅형의 CMS 플랫폼으로 Laravel PHP 프레임웍을 기초로 한다.


2번째 속성으로 Simple하고 모듈형 CMS는 개발자에 의해 확장되며, 정확하고 아름다운 UI를 갖고 있다.



Getting back to basics


 https://octobercms.com/blog/post/getting-back-to-basics


"많은 유명한 CMS들은 복잡하고 뒤얽혀진 시스템이 되었으며, 만약에 안을 들여다 보면 꽤 실망하게 될 것이다..."




2) OctoberCMS 설치 (신규, 추가)


vagrant를 실행하고, October project를  설치한다. ( 신규 프로젝트 생성 )

 
    > vagrant up
    > vagrant ssh
    > cd Code
    
    >
    > composer create-project october/october myoctober dev-master -vvv
    >
myoctober :  선호하는 폴더명/Domain명으로 대체


*비슷한 설명 : https://octobercms.com/docs/console/commands#console-install-composer




3) hosts파일에 등록하기 ( 접근용 Domain )

  192.168.10.10    myoctober.app


4) .homestead/Homestead.yaml 수정하기

   sites:
        - map : myoctober.app   
          to : /home/vagrant/Code/myoctober
    databases:
        - myoctober


5) vagrant 재시작

 
    > vagrant reload --provision
    > vagrant ssh
    > cd Code

* Oracle VM Virtual Box가 무반응시에 Oracle VM Virtual Box관리자 화면에서 시작/종료를 반복후에 위의 reload명령어를 수행한다.



* vagrant reload --provision 옵션 설명 : https://www.vagrantup.com/docs/cli/reload.html



6) 설치 결과를 확인하는 접속





* 단일 장비에서는 설정을 console명령으로 직접 변경 가능하다,

   DB 선택, DB 계정, Domain명등을 설정할 수 있다


    > php artisan October:install



아래는 backend 접속을 위한 수동 설정을 다룬다.


6) DB 설정


MySQL(33060), Postgres(54320)을 사용하며, username과 password는 homestead/secret이다.



7) /config/database.php를 수정

    'default' => 'pgsql', // 'mysql'

from

        'pgsql' => [
            'driver'   => 'pgsql',
            'host'     => 'localhost',
            'port'     => '',
            'database' => 'database',
            'username' => 'root',
            'password' => '',
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => 'public',
        ],


to

 
        'pgsql' => [
            'driver'   => 'pgsql',
            'host'     => env('DB_HOST'),
            'port'     => env('DB_PORT'),
            'database' => env('DB_DATABASE'),
            'username' => env('DB_USERNAME'),
            'password' => env('DB_PASSWORD'),
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => env('DB_SCHEMA'),
        ],

.env 파일 만들기 ( 위치 : project root )

DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=myoctober
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_SCHEMA=public


데이타베이스 migrate (터미널상에서)

> cd myoctober > php artisan october:up


octoberCMS의 backend접속 하기

> http://myoctober.app:8000/backend
> admin/admin





원문 : https://renatio.com/blog/install-octobercms-laravel-homestead

블로그 이미지

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.

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



Laravel(라라벨) 5.3,

Layouts, CSS & JS Part 1




Layout를 사용해서 파일이나 페이지에 포함되도록 끼워 넣는 방법과 JS파일을 연결하는 방법을 정리한다.



1. 기본 Layout 폴더와 페이지를 만들기


위치 : reources\views\layout\layouts.blade.php


    
<!DOCTYPE HTML>
<html>
<head>
  <title>
    @yield('title') Page
  </title>
</head>
<body>
    @yield('content')
</body>
@stack('scripts')
{!! Html::script('js/hello.js') !!}
</html>

1.1 public/js/hello.js

    
alert('Hello World!!');



2. laravelcollective/html 설치하기

    
> composer require laravelcollective/html


2.1 laravelcollective/html 등록하기


위치 : config/app.php

    
    'providers' => [ Collective\Html\HtmlServiceProvider::class, ],

    'aliases' => [ 'Form' => Collective\Html\FormFacade::class,
                        'Html' => Collective\Html\HtmlFacade::class, ],


3. View 페이지 ( Blade Template PHP ) 작성 하기


위치 : resources/views/pages/hello.blade.php

    
    @extends('layout.layouts')
    @section('title','Hello World')

    @section('content')
        My name is Henrio !!!
    @endsection

    @push('scripts')
        {!! Html::script('js/hello2.js') !!}
    @endpush

2.1 public/js/hello2.js

    
alert('Hello, Hello, It's ME.');


동영상 강좌  : https://www.youtube.com/watch?v=Xza0wUFJC3M&index=3&list=PL-4_JsMSrLiqrzQ36KwYVn4uCjYLiAd_C






Laravel(라라벨) 5.3 ,

Layouts, CSS & JS Part 2



1. download Bootstrap


 copy folder to /public with name of 'bootstrap'




2. include css to layouts.blade.php

	<head>
		{!! Html::style('bootstrap/css/bootstrap.min.css')!!}
	</head>


3. add form code to hello.blade.php

	@section('content')
	    <div class="container">

		<div class="row">
		    <h4>Hello World! Henrio</h4>
		    <hr/>
		</div>

		<div class="row">

		    <div class="container">

			{!! Form::open( ['url' => '', 'method' => 'POST',
			    'class' => 'form-horizontal'] ) !!}
			{!! Form::token() !!}

			<div class="row">
			    <div class="col-sm-2 center-block">
				{!! Form::label('text','Insert Your Text Here!',
				    ['class' => 'control-label pull-right']) !!}
			    </div>
			    <div class="col-sm-4 center-block">
				{!! Form::text('text','',
				    ['class' => 'form-control pull-left']) !!}
			    </div>
			    <div class="col-sm-6 center-block">

			    </div>
			</div> <!-- class row -->

			<div class="row">
			     
			</div> <!-- class row -->

			<div class="row">
			    <div class="col-sm-6 center-block">
				{!! Form::submit('Submit The Input',
				    ['id' =>'btn-stmt','class' => 'btn btn-info pull-right']) !!}
			    </div>
			    <div class="col-sm-6 center-block">

			    </div>
			</div> <!-- class row -->

			{!! Form::close() !!}

		    </div> <!-- class container  -->

		</div> <!-- class row -->

	    </div> <!-- class container -->
	@endsection


4. create styles.css under css folder

	
	#btn-sbmt {
	    position:relative;
	    margin-top:50px;
	}



5. add styles.css to layouts.blade.php

	<head>
		{!! Html::style(css/styles.css')!!}
	</head>



동영상 강좌 https://www.youtube.com/watch?v=PS-Yr8CRI1o&index=4&list=PL-4_JsMSrLiqrzQ36KwYVn4uCjYLiAd_C





Laravel(라라벨) 5.3,

Forms And Working With Models



1. Create Controller & Model , MySQL Table

	
> php artisan make:controller TextController
> php artisan make:model Posts
> create table (
		id int not null auto_increment primary key,
		posts text,
	)


2. Modify Code for model at app/Posts.php

class Posts extends Model
{
    //
    public $timestamps = false;

    protected $table = "posts";
    protected $primaryKey = "ID";
    protected $casts = ["ID" => "INT"];

}	


3. Modify Code for controller at app/Http/Controllers/TextController.php

public function submitted(Request $request) {
        $text = $request->get('text');
        echo $text;	
}


4. Add router to routes/web.php

Route::post('submitted','TextController@submitted');	


5. Add post url at resource/views/pages/hello.blade.php

	
                {!! Form::open( ['url' => '/submitted', 'method' => 'POST',
                    'class' => 'form-horizontal'] ) !!}
                {!! Form::token() !!}


Test access and check the result  : http://[hosturl]:8000/hello




6. Modify code to save at app/Http/Controllers/TextController.php

        $text = $request->get('text');
        //echo $text;
        $posts = new Posts();
        $posts->Posts = $text;
        // save
        $posts->save();	





동영상 강좌 https://www.youtube.com/watch?v=OgbUlgSwl-o&index=5&list=PL-4_JsMSrLiqrzQ36KwYVn4uCjYLiAd_C



관련된 이전 글 : Laravel 5.3 , Routes & Controllers for MVC ( Model View Controller )


- Controller 와 View 수정을 위한 위치등을 참조...


http://printhelloworld.tistory.com/admin/entry/post/?id=76


블로그 이미지

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.

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


Laravel(라라벨) 5.3,

Routes & Controllers for MVC



-- vagrant를 통해서 homestead를 설치한 환경에서 작성




1. Route 파일 위치 확인하기


routes/ 폴더 아래에 api.php , console.php, web.php가 존재한다.




사용할 파일은 web.php 이다.


* 해당 파일의 내용을 확인하는 방법은 http://[호스트명]:8000/으로 접속하면 결과를 볼 수 있다. welcome.blade.php는 resource/views/welcome.blade.php에 위치 한다.



2. HelloController 생성하기


HelloWorld>php -v
HelloWorld>php artisan make:controller HelloController


3. View ( Blade Template ) 생성하기


resources/views/아래에 pages 폴더를 만들고, 그 아래에 hello.blade.php파일을 생성한다.



4. HelloController에 function을 추가하기



*  http://[호스트명]:8000/hello으로 접속하면 Error가 발생하는 것을 볼 수 있다.



5. Web Route 파일에 분기 로직을 추가 하기



*  http://[호스트명]:8000/hello으로 접속하면 Empty화면을 볼 수 있다.



6. View ( View Blade Template ) 수정 하기




*  http://[호스트명]:8000/hello으로 접속하면 정상적인 결과를 볼 수 있다.




참조 동영상


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



Laravel 5.3 Tutorial Series  ( 최종 Update : 2016. Nov. 5 )


https://www.youtube.com/playlist?list=PL-4_JsMSrLiqrzQ36KwYVn4uCjYLiAd_C

블로그 이미지

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.

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


Tomcat JDBC Connection Pool의 

일반 속성 ( Common Attributes )을 사용 하기




JDBC 연결하고 사용중(서비스중)에 갑자기 발생하는 단절 현상과 같이 Query시에 발생하는 PSQLException 중에서 에러 메시지 종류가 1. ERROR : could not establish connection,2. Detail : could not connect to server 인 경우에 testOnBorrow, validationQuery를 사용하면, 연결 단절시에 대한 조치를 할 수 있다. 




설정하는 옵션에 대한 설명은 아래 표를 참고 한다.

Attribute Description
defaultAutoCommit

(boolean) The default auto-commit state of connections created by this pool. If not set, default is JDBC driver default (If not set then the setAutoCommit method will not be called.)

testOnBorrow

(boolean) The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. NOTE - for a true value to have any effect, the validationQuery or validatorClassName parameter must be set to a non-null string. In order to have a more efficient validation, see validationInterval. Default value is false

validationQuery

(String) The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query does not have to return any data, it just can't throw a SQLException. The default value is null. Example values are SELECT 1(mysql), select 1 from dual(oracle), SELECT 1(MS Sql Server)

validationQueryTimeout

(int) The timeout in seconds before a connection validation queries fail. This works by calling java.sql.Statement.setQueryTimeout(seconds) on the statement that executes the validationQuery. The pool itself doesn't timeout the query, it is still up to the JDBC driver to enforce query timeouts. A value less than or equal to zero will disable this feature. The default value is -1.

validatorClassName

(String) The name of a class which implements the org.apache.tomcat.jdbc.pool.Validator interface and provides a no-arg constructor (may be implicit). If specified, the class will be used to create a Validator instance which is then used instead of any validation query to validate connections. The default value is null. An example value iscom.mycompany.project.SimpleValidator.

참조 원문 : https://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html



for high-concurrency (높은 동시성)


Validating Connections

데이타베이스 풀링은 문제점을 갖고 있고, 이는 연결된 풀들이 끊어질 수(신선하지 않은) 있다.

<Resource type="javax.sql.DataSource"
            name="jdbc/TestDB"
            factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/mysql"
            username="mysql_user"
            password="mypassword123"
            testOnBorrow="true"
            validationQuery="SELECT 1"
            />

Validation Queries는 몇가지 단점도 있다.


1. 자주 사용하면, 시스템의 성능을 저하시킨다.

2. 멀리 떨어져 있는 상태에서 호출하면, 결과는 실패일 수있다

 

http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency



자바에서 사용하는 경우를 예로 들면 아래와 같다.

Code Example - Plain Java

import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;

  import org.apache.tomcat.jdbc.pool.DataSource;
  import org.apache.tomcat.jdbc.pool.PoolProperties;

  public class SimplePOJOExample {

      public static void main(String[] args) throws Exception {
          PoolProperties p = new PoolProperties();
          p.setUrl("jdbc:mysql://localhost:3306/mysql");
          p.setDriverClassName("com.mysql.jdbc.Driver");
          p.setUsername("root");
          p.setPassword("password");
          p.setJmxEnabled(true);
          p.setTestWhileIdle(false);
          p.setTestOnBorrow(true);
          p.setValidationQuery("SELECT 1");
          p.setTestOnReturn(false);
          p.setValidationInterval(30000);
          p.setTimeBetweenEvictionRunsMillis(30000);
          p.setMaxActive(100);
          p.setInitialSize(10);
          p.setMaxWait(10000);
          p.setRemoveAbandonedTimeout(60);
          p.setMinEvictableIdleTimeMillis(30000);
          p.setMinIdle(10);
          p.setLogAbandoned(true);
          p.setRemoveAbandoned(true);
          p.setJdbcInterceptors(
            "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"+
            "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
          DataSource datasource = new DataSource();
          datasource.setPoolProperties(p);

          Connection con = null;
          try {
            con = datasource.getConnection();
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("select * from user");
            int cnt = 1;
            while (rs.next()) {
                System.out.println((cnt++)+". Host:" +rs.getString("Host")+
                  " User:"+rs.getString("User")+" Password:"+rs.getString("Password"));
            }
            rs.close();
            st.close();
          } finally {
            if (con!=null) try {con.close();}catch (Exception ignore) {}
          }
      }

  }



블로그 이미지

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.

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


Laravel(라라벨) Homestead 사용하기




Laravel은 로컬 개발환경을 포함해서 PHP 개발 경험 전체를 즐겁도록 하기 위한 노력을 많이 한다고 설명하며,  그것은 Homestead다.



(먼저 필요한 것 중에서) Vagrant는 쉽고 우아한 방법으로 가상머신 관리와 공급을 제공한다. ( 가상화 인스턴스인 Virtual Machine을 관리하는 소프트웨어 이다. )


Oracle Virtual BoxVagrant를 설치 해야 한다. 

여러 Provider를 지원하기는 하지만, 기본 Provider는 VirtualBox이다. 


=> Vagrant 설치후 확인 : vagrant -v


http://rangken.github.io/blog/2015/vagrant-1/ ( Vagrant 기본 설정 및 명령어 )




Laravel Homestead는 공식 지원이며, 미리 설치된 Vagrant box이며, 로컬 머신에 PHP, HHVM, web server 또는 어떤 다른 소프트웨어의 설치가 필요없는 개발 환경을 제공한다.


=> 다양한 box들 : https://atlas.hashicorp.com/boxes/search



0. 설치 환경


- window 10
- virtual box 4.3.12 ( 5.0.x ~ 5.1.x 는 설치시 에러 )



1. 설치 및 셋업



1) HomeStead Vagrant Box 설치 


    -- Vagrant Box는 일종의 스냅샷 이미지 ( OS와 프로그램이 미리 설치되어 있는 이미지)

    -- Ubuntu 16.04.01 (homestead 4.4.0) ,PHP 7.1, HHVM, Nginx

    -- MySQL, Postgres, NodeJs, Redis, Memcached, Beanstalkd, Blackfire Profiler

> vargrant box add laravel/homestead



=> C:\Users\[계정명]\.vagrant.d\boxes\laravel-VAGRANTSLASH-homestead\0.4.0\virtualbox 에 가상 디스크가 생긴다.



2) Homestead 프로젝트 설치


--> git bash를 사용할 수 있는 환경을 구성후에 사용 할 것



   

(1) 홈 디렉토리에서 저장소 clone

> cd ~
> git clone https://github.com/laravel/homestead.git Homestead



   

(2) Homestead 디렉토리에서 git bash실행

> cd ~/Homestead
> bash init.sh

   => 홈 디렉토리밑에 .homestead/Homestead.yaml설정파일 생성


   또는 > laravel new example 와 같이 어플리케이션을 직접 생성



   

(3) Homestead.yaml 설정


    - cpu 개수는 적당히 늘려주기

    - 로컬 Window 공유 디렉토리 생성 하기 ( ~/Code )

    - sites변경시에는 갱신  : >vagrant reload --provision

---
ip: "192.168.10.10"    # homestead VM이 사용할 주소
memory: 2048
cpus: 2
provider: virtualbox   # Virtual Machine Provider

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa     # SSH로그인에 사용할 private key

folders:
    - map: ~/Code    # 로컬 디렉토리 경로
      to: /home/vagrant/Code    # VM의 디렉토리 경로

sites:
    - map: homestead.app  # 도메인 이름
      to: /home/vagrant/Code/Laravel/public   # 웹서버의 Document Root

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

    - project 생성 : ~Code > composer create-project   laravel/laravel --no-dev --prefer-dist -vvv laravel


(4) Host 파일 설정하기

  -- 웹페이지 접속을 위한 도메인 등록

# %WINDIR%\System32\drivers\etc\hosts
192.168.10.10    homestead.app


   

(5) Vagrant Box 실행

    -- boot the VM & 자동으로 공유폴더와 Nginx 사이트를 구성한다.

C:\Users\[계정명]\Homestead\
C:\Users\[계정명]\Homestead\vagrant up
C:\Users\[계정명]\Homestead\

=> 이때  /.ssh/id_rsa가 Not Found일때 : > ~/.ssh/ssh-keygen 실행


$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/[계정명]/.ssh/id_rsa): /c/Users/[계정명]/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again:


=> 동시에 C:\Users\[계정명]\VirtualBox VMs에 폴더가 Homestead-xx 생긴다.


=> Console ,  userid/password : vagrant/vagrant


=> destroy시 : > vagrant destroy --force


=> SSH auth에서 에러 발생시, 아래 config.ssh.forward_agent = true를 Vagrantfile내에 추가



(6) Vagrant ssh 실행


C:\Users\[계정명]\Homestead\
C:\Users\[계정명]\Homestead\vagrant ssh
C:\Users\[계정명]\Homestead\

=> 접속 실패시 


1) config.ssh.forward_agent = true를 Vagrantfile내에 추가

Vagrant.configure("2") do |config| config.ssh.private_key_path = "~/.ssh/id_rsa" config.ssh.forward_agent = true end

2) id_rsa.pub 복사


~/.ssh/id_rsa.pub@guest 파일 내용을 ~/.ssh/authorized_key@host에 추가


 참조 : http://stackoverflow.com/questions/22922891/vagrant-ssh-authentication-failure



=> 추가로 다중 프로젝트(Laravel 어플리케이션) 생성하기

> vagrant ssh
> cd Code
> laravel new example

#수정하기 
#./homestead/Homestead.yaml

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public

    - map: example.app
      to: /home/vagrant/Code/example/public

databases:
    - homestead
    - example




==> 원문 : 


https://laravel.com/docs/5.1/homestead



Homestead environment ( Port Forward , 충돌시 변경되므로 부팅 로그를 확인) :

    • SSH: 2222 → Forwards To 22
    • HTTP: 8000 → Forwards To 80
    • HTTPS: 44300 → Forwards To 443
    • MySQL: 33060 → Forwards To 3306
    • Postgres: 54320 → Forwards To 5432



==> 참고:


https://goo.gl/lRnC8k ( vagrant로 node 개발 환경 구성 하기 )


http://mobicon.tistory.com/322 ( vagrant 개발 환경 구축 및 애플리케이션 공유하기 )

--> Node.js + MongoDB 개발환경


http://l5.appkr.kr/lessons/02-install-homestead-windows.html 

( Homestead 설치 (on Windows) )

--> SSH 설정, MySQL 접속(id/pw: homestead/secret)


http://m.blog.naver.com/two4zero/220602350718 ( laravel - Homestead 설치 )


http://k-story.tistory.com/333 (VirtualBox에서 xshell 연동하기.)

--> Virtual Box 네트워크 어댑터, 포트 포워딩 설정 ( 호스트 IP, 게스트 IP )


http://stackoverflow.com/questions/29450404/is-there-a-default-password-to-connect-to-vagrant-when-using-homestead-ssh-for ( 연결에 사용되는 default password )

--> vagrant@127.0.0.1's password:


* 기타 설치 에러 A:



Q : VBoxManage.exe hostonlyif create에러가 발생 할때

C:\Program Files\Oracle\VirtualBox\>VBoxManage.exe hostonlyif create
0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Code E_FAIL (0x80004005) - Unspecified error
 (extended info not available)
VBoxManage.exe: error: Context: "int __cdecl handleCreate(struct HandlerArg *,int,int *)" 
at line 66 of file VBoxManageHostonly.cpp

Answer 1 : kaspersky 언인스톨, NDIS6 브릿지 드라이버 설청

Hi,
I found a solution preventing you to uninstall Kaspersky.
You have to install manually the VirtualBox Network drivers. You can found those drivers here :
C:\Program Files\Oracle\VirtualBox\drivers\network
There is two folders, go inside both of them and right click install on the *.inf files.
Now the installation of hosts only virtual networks adapters should be nice but don't boot up. You have to manually install a new service on your "VirtualBox Host-Only Network" adapter.
go to the network adapters list
right click on this network adapter choose "Properties"
click on the "Install..." button and add a service
choose The Manufacturer "Oracle Corporation" and the network service named "VirtualBox NDIS6 Bridged Networking driver".
Validate all the windows, and all should be OK. 

Answer 2 : 네트웍 설정 ( Virtual Box )을 아래와 같이 수정


https://www.virtualbox.org/ticket/14040






* ssh-config 확인하는 방법


> vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "/Users/MYUSER/.vagrant.d/insecure_private_key"
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes



* 기타 설치 에러 B:


Q : Warning: Authentication failure. Retrying...이 지속적으로 발생할때


==> default: Forwarding ports...
default: 80 => 8080 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...

실제 해결된 방법은 config.ssh.forward_agent = true를 Vagrantfile내에 추가하면 되었다.



Answer 1 : NAT -> Advanced 설정


http://stackoverflow.com/questions/40968297/laravel-homestead-hangs-at-ssh-auth-method-private-key-on-mac



Answer 2  : config.vm.boot_timeout = 600 을 추가하기


http://es.stackoverflow.com/questions/36242/error-config-vm-boot-timeout-en-vagrant-up-para-homestead



-- config.vm.boot_timeout = 600 ( Vagrantfile내에 추가 )

    config.vm.boot_timeout = 600 

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON.parse(File.read(homesteadJsonPath))
    end



Answer 3  : private key를  host 등록하기  


https://github.com/mitchellh/vagrant/issues/5186


0. vagrant ssh-config를 통해 IdentifyFile위치 확인 insecure_private.key.pub 내용 복사

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/admin/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes

1. vagrant up중에 default: Warning: Authentication failure. Retrying...반복시에 중단

2. vagrant ssh접속 시도, passsword를 입력요청시에 vagrant를 입력
3. insecure_private.key.pub를 복사해서 ~/.ssh/authorized_keys에 추가 4. vagrant halt후에 vagrant up --provision으로 재시작

<예제>

    
    config.ssh.private_key_path = File.expand_path('~/.ssh/id_rsa')
    config.vm.boot_timeout = 600 

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON.parse(File.read(homesteadJsonPath))
    end


vagrant 실행 화면 ( 정상적인 상황 )
    
$ vagrant reload --provision
==> homestead-7: Attempting graceful shutdown of VM...
    homestead-7: Guest communication could not be established! This is usually because
    homestead-7: SSH is not running, the authentication information was changed,
    homestead-7: or some other networking issue. Vagrant will force halt, if
    homestead-7: capable.
==> homestead-7: Forcing shutdown of VM...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
    homestead-7: Adapter 1: nat
    homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
    homestead-7: 80 (guest) => 8000 (host) (adapter 1)
    homestead-7: 443 (guest) => 44300 (host) (adapter 1)
    homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
    homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
    homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
    homestead-7: SSH address: 127.0.0.1:2222
    homestead-7: SSH username: vagrant
    homestead-7: SSH auth method: private key
    homestead-7: Warning: Authentication failure. Retrying...
    homestead-7: Warning: Authentication failure. Retrying...
    homestead-7: Warning: Authentication failure. Retrying...
    homestead-7: Warning: Authentication failure. Retrying...
	....
    homestead-7: Warning: Authentication failure. Retrying...
    homestead-7: Warning: Authentication failure. Retrying...
    homestead-7: Warning: Authentication failure. Retrying...
==> homestead-7: Machine booted and ready!
==> homestead-7: Checking for guest additions in VM...
    homestead-7: The guest additions on this VM do not match the installed version of
    homestead-7: VirtualBox! In most cases this is fine, but in rare cases it can
    homestead-7: prevent things such as shared folders from working properly. If you see
    homestead-7: shared folder errors, please make sure the guest additions within the
    homestead-7: virtual machine match the version of VirtualBox you have installed on
    homestead-7: your host and reload your VM.
    homestead-7:
    homestead-7: Guest Additions Version: 5.1.10
    homestead-7: VirtualBox Version: 4.3
==> homestead-7: Setting hostname...
==> homestead-7: Configuring and enabling network interfaces...
==> homestead-7: Mounting shared folders...
    homestead-7: /vagrant => C:/Users/admin/Homestead
    homestead-7: /home/vagrant/Code => C:/Users/admin/Code
==> homestead-7: Running provisioner: file...
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: C:/Users/admin/AppData/Local/Temp/vagrant-shell20170103-6508-1tmfveg.sh
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating Site: homestead.app
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating Site: example.app
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Restarting Nginx
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating MySQL Database: homestead
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating Postgres Database: homestead
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating MySQL Database: example
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Creating Postgres Database: example
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Clear Variables
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: script: Update Composer
==> homestead-7: Updating to version 1.3.0 (stable channel).
==> homestead-7:     Downloading: Connecting...                                               Downloadi         ng: 100%
==> homestead-7: Use composer self-update --rollback to return to version 1.2.3
==> homestead-7: Running provisioner: shell...
    homestead-7: Running: C:/Users/admin/AppData/Local/Temp/vagrant-shell20170103-6508-inqc9i.sh


블로그 이미지

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.

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

OnTimer - SetTimer


작업1) 메시지를 등록한다.


WM_TIMER->OnTimer을 추가하면

void SetTimerTestDlg::OnTimer(UINT_PTR nIDEvent)
{
    CDialog::OnTimer(nIDEvent);
}

가 자동으로 생성이 된다.. 



작업 2) 그리고 두개의 함수를 만들어 준다.

void SetTimerTestDlg::OnStartTimer()
{

    //1은 ID, 1000는 시간(ms)
    SetTimer(1, 30*1000, 0);  // 30초에 한번 실행
}

void SetTimerTestDlg::OnStopTimer()
{

    // 타이머 종료 
    KillTimer(1);
}


*  추가 설명

// OnStartTimer()은 타이머 시작 이고
// OnStopTimer()은 타이머 중지 이다.

void SetTimerTestDlg::OnTimer(UINT_PTR nIDEvent)
{

    printf(" timer called \n");
    CDialog::OnTimer(nIDEvent);
}


라고 실행할 명령어( 테스트로 printf)를 입력하고 OnStartTimer를 실행하면
1초에 한 번씩 프린트를 실행하게 된다.

타이머 종료할때는 OnStopTimer()를 실행하면된다.


블로그 이미지

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.

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

C# Packet Class

바이트 버퍼링 전송 수신 send receive

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;

namespace LClient
{
    public partial class Packet
    {
        NetworkStream _stream;
        BinaryWriter _writer;

        byte[] _buffer;
        byte[] _data;

        public void setStream( NetworkStream stream )
        {
            _stream = stream;
            _writer = new BinaryWriter(_stream);
        }

        public void read()
        {
            byte[] blen = new byte[4];
            int read = _stream.Read(blen, 0, blen.Length);
            int ilen = BitConverter.ToInt32(blen,0);
            
            _data = new byte[ilen];
            _stream.Read(_data, 0, ilen);

        }
        public int readInt()
        {
            //보관
            byte[] t = new byte[_data.Length];
            Array.Copy(_data, 0, t, 0, _data.Length);

            byte[] idata = new byte[4];
            Array.Copy(_data, 0, idata, 0, idata.Length);

            _data = new byte[t.Length - idata.Length];
            Array.Copy(t, idata.Length, _data, 0, _data.Length);

            return BitConverter.ToInt32(idata, 0);
        }

        public String readUTF8()
        {
            //보관
            byte[] t = new byte[_data.Length];
            Array.Copy(_data, 0, t, 0, _data.Length);

            byte[] sl = new byte[2];
            Array.Copy(_data, 0, sl, 0, sl.Length );
            short slen = BitConverter.ToInt16(sl,0);

            byte[] sd = new byte[slen];
            Array.Copy(_data, 0, sd, 0, sd.Length);

            if ( t.Length < sl.Length+slen )
            {
                return null;
            }
            else 
            {
                _data = new byte[t.Length - (sl.Length + sd.Length)];

                Array.Copy(t,(sl.Length+sd.Length),
                            _data,0, _data.Length);

                return Encoding.UTF8.GetString(sd);
            }

        }

        public void WriteInt( int num )
        {
            if (_buffer == null)
            {
                _buffer = BitConverter.GetBytes(num);
            }
            else
            {

                byte[] b = BitConverter.GetBytes(num);

                byte[] t = new byte[_buffer.Length];
                Array.Copy(_buffer, 0, t, 0, _buffer.Length);

                _buffer = new byte[t.Length + b.Length];

                Array.Copy(t, 0, _buffer, 0, t.Length);
                Array.Copy(b, 0, _buffer, t.Length, b.Length);
            }

        }

        public void WriteUTF( String str )
        {
            if (_buffer == null)
            {
                byte[] b = Encoding.UTF8.GetBytes(str);
                byte[] a = BitConverter.GetBytes((short)b.Length);

                _buffer = new byte[a.Length + b.Length];

                Array.Copy(a, 0, _buffer, 0, a.Length);
                Array.Copy(b, 0, _buffer, a.Length, b.Length);
            }
            else
            {
                byte[] t = new byte[_buffer.Length];
                Array.Copy(_buffer, 0, t, 0, _buffer.Length);
                byte[] b = Encoding.UTF8.GetBytes(str);
                byte[] a = BitConverter.GetBytes((short)b.Length);

                _buffer = new byte[t.Length + a.Length + b.Length];

                Array.Copy(t, 0, _buffer, 0, t.Length);
                Array.Copy(a, 0, _buffer, t.Length, a.Length);
                Array.Copy(b, 0, _buffer, t.Length + a.Length, b.Length);

            }
                
        }

        public void Flush()
        {
            // size
            _writer.Write(_buffer.Length);

            // data
            _stream.Write(_buffer, 0, _buffer.Length);

            _stream.Flush();
        }

        public int getLength()
        {
            return _buffer.Length;
        }
        public byte[] getData()
        {
            return _data;
        }
    }
}


'Application, App > VC++' 카테고리의 다른 글

OnTimer - SetTimer  (0) 2016.12.15
Stack with std::list  (0) 2016.12.15
Effective C++ 목차  (0) 2016.12.15
IO Completion Port 작성하기 ( 2010.10.06 )  (0) 2016.12.15
블로그 이미지

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.

,