PHP에서 mail 함수로 메일 발송시 일부 업체에 메일 전송이 안될경우 


우선 메일로그를 확인하면,


Apr 14 00:26:58 phpserver sendmail[3162]: k3DFQw7q003160: to=<xxxxxx>, ctladdr=<nobody@localhost.localdomain> (99/99), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=121467, relay=mail.ziwoo.net. [123.456.678.012], dsn=5.6.0, stat=Data format error 

Apr 14 00:26:58 phpserver sendmail[3162]: k3DFQw7q003160: k3DFQw7q003162: DSN: Data format error 


일부 메일서비스에서 nobody@localhost.localdomain을 받는쪽에서 거부하는 경우가 발생합니다.


이 경우 /etc/mail/sendmail.cf 를 수정해서 해결할 수 있습니다.


##Dj$w.Foo.COM 부분을 주석 제거하고 Dj$ sample.com(사용자 서버 도메인)로 변경해 주시면 됩니다.




WRITTEN BY
라프르

,

웹 서비스 구성시 https 서버와 이미지 http서버간에 CORS문제 해결을 위한 Reverse proxy 구성입니다.


http://www.sample.com/data/images/ 


https://ssl.sample.com/


Apache에 mod_proxy 설치 후 conf 파일에서


LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_connect_module modules/mod_proxy_connect.so

LoadModule proxy_http_module modules/mod_proxy_http.so


ProxyPass /data/images http://www.sample.com/

ProxyPassReverse /data/images https://ssl.sample.com/


와 같이 설정해 주시면 됩니다.


WRITTEN BY
라프르

,

ionic2 logo에 대한 이미지 검색결과

ionic2에서 외부 API사용시 ionic serve에서 CORS(Cross-Origin Resource Sharing) 문제로 API 연동이 제대로 안된다.


이 문제를 해결하기 위해,


프로젝트 root에   ionic.config.json   파일을 열어서


{ "name": "ionic2-app-base", "app_id": "", "typescript": true, "v2": true, "proxies": [ { "path": "/api", "proxyUrl": "https://api.apiURL.com" } ] }


proxies 부분을 추가하고, 사용할 도메인을 proxyUrl에 세팅한 다음


getData() {
    return this.http.get('/api/api.php').map(res => res.json());
  }

실제 API연동 소스 부분에 다음과 같이 사용하면 CORS문제를 해결할 수 있다.


*** device에서 실행하거나 build할 경우 proxy가 적용 안되네요. 실제 build시에는 Full URI로 수정하고 하셔야됩니다.




WRITTEN BY
라프르

,

nodejs에 대한 이미지 검색결과


nodejs http basic smaple

1
2
3
4
5
6
7
var http = require('http');
 
http.createServer(function(request, response) {
  response.writeHead(200);
  response.write('Hello, Nodejs');
  response.end();
}).listen(8080);
cs



Read file Blocking code sample


1
2
3
4
var fs = require('fs');
 
var contents = fs.readFileSync('index.html');
console.log(contents);
cs



Read file Non-blocking code sample


1
2
3
fs.readFile('index.html',function(error,contents){
  console.log(contents);
});
cs



Read file in server


1
2
3
4
5
6
7
8
9
10
var http = require('http');
var fs = require('fs');
 
http.createServer(function(request, response) {
  response.writeHead(200,{
'Content-Type' : 'text/html'
});
  fs.readFile('index.html',function(error ,contents){
    response.write(contents);
    response.end();
  }); 
}).listen(8080);

cs



WRITTEN BY
라프르

,

성능향상 Tip

Javascript 2016. 8. 31. 16:08



Rendering process 


1. 브라우저는 CSSOM과 DOM트리를 결합해 렌더 트리를 생성

2. 화면에 출력할 Layout 계산

3. Paint (실제 화면에 픽셀을 그리는 단계)

4. 필요에 따라 reflow, repaint


reflow

기존 DOM노드의 width, height 변경시, 관련된 모든 노드의 수치를 다시 계산해서 render tree 재구성


repaint

reflow로 render tree가 재구성되면 render tree를 다시 그리는 작업

숫자와 상관없는 스타일 변경시에는 repaint만 실행됨


reflow, repaint는 부하가 높기때문에 신중히 사용



배열, 객체 생성시 성능향상 Tip


 

 빠름

 

 배열 생성

 var arr = [];

 var arr = new Array(); 

 배열 초기화 

 arr[i] = i; 

 arr.push(i);

 객체 생성

 var obj = {} 

 var obj = new Object(); 

 객체 초기화

 obj.a = 1; 

 obj["a"] = 1;

 문자열 생성

 var str = "test";

 var str = new String("test");


반복문 사용시 성능향상 Tip


반복문 사용시 for-in 은 순차적 탐색이 아닌, 반복 시점마다 객체의 모든 속성을 무작위 탐색하기 때문에 사용 지양


반복문 사용시 for 안에 array.length 사용하게 되면 반복시점마다 array.length 실행되기 때문에 사전에 변수에 담아서 사용


반복되는 객체사용시 별도의 변수에 담아서 사용



'Javascript' 카테고리의 다른 글

jQuery - form / ajax / json sample  (0) 2016.08.31
jQuery -event.stopPropagation / event.preventDefault  (0) 2016.08.31

WRITTEN BY
라프르

,


1. form data 전송 및 결과 json 받는 복합 sample


$('form').on('submit', function(event) {

    event.preventDefault();

    $.ajax('/book', {

      type: 'POST',

      data: $('form').serialize(),

      dataType: 'json',

      success: function(response) {

        var msg = $('<p></p>');

        msg.append(response.description);

        msg.append(response.price);

        msg.append(response.nights);

        msg.append(response.confirmation);

        

        $('.tour').html(msg).fadeIn();

      },

      contentType: 'application/json'

    });

  });



2. 단순 list data 조회용 sample


1) $.ajax 사용

$.ajax('/cities/deals', {

success: function(result) {

$.each(result,function(index, dealItem){

console.log(dealItem);        

});

}

});



2) $.getJSON 사용

$.getJSON('/cities/deals', function(result) {

$.each(result,function(index,dealItem){

var dealElement = $('.deal-' + index);

dealElement.find('.name').html(dealItem.name);

dealElement.find('.price').html(dealItem.price);

});    

});




'Javascript' 카테고리의 다른 글

성능향상 Tip  (0) 2016.08.31
jQuery -event.stopPropagation / event.preventDefault  (0) 2016.08.31

WRITTEN BY
라프르

,




event.stopPropagation()


이벤트 발생시 중첩된 상위 태그의 이벤트까지 발생하지 않고 현재 태그의 이벤트만 발생시키고 싶은 경우에 사용




event.preventDefault()


a태그에 #사용시 페이지 최상단으로 이동하는 효과를 사용하고 싶지 않을때 사용



Sample code


$('form').on('submit', function(event){

    event.preventDefault();

    $.ajax('/register',{

type:post,

data:$('form').serialize()

});

});

'Javascript' 카테고리의 다른 글

성능향상 Tip  (0) 2016.08.31
jQuery - form / ajax / json sample  (0) 2016.08.31

WRITTEN BY
라프르

,

기본 세팅

Python 2016. 8. 12. 17:03

파이썬 시작을 위한 기본 세팅


1. python 설치

https://www.python.org/ 2.7.x or 3.x 설치




2.path추가

컴퓨터 > 속성 > 고급 시스템 설정 > 환경변수 > 시스템변수 에서 "PATH" 항목에 아래 목록 추가

c:\python2.7

c:\python2.7\Scripts

c:\python2.7\Tools\Scripts


3. pip 설치

https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py


에서 get-pip.py 파일 다운로드 후


cmd 실행 후

python get-pip.py








WRITTEN BY
라프르

,