Thursday, January 28, 2016

Mac 터미널 색상 변경

vi ~/.bash_profile

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'

추가:
중요한 것은 터미널의 설정에서 기본적으로 Pro 테마를 선택하고 '기본'으로 설정해야 한다는 것이다.
그러면 다음과 같이 반투명 검정 바탕에 아름다운 색깔이 나온다.

Tuesday, January 26, 2016

Javascript hex string to byte array

// Convert a hex string to a byte array
function hexToBytes(hex) {
    for (var bytes = [], c = 0; c < hex.length; c += 2)
    bytes.push(parseInt(hex.substr(c, 2), 16));
    return bytes;
}

// Convert a byte array to a hex string
function bytesToHex(bytes) {
    for (var hex = [], i = 0; i < bytes.length; i++) {
        hex.push((bytes[i] >>> 4).toString(16));
        hex.push((bytes[i] & 0xF).toString(16));
    }
    return hex.join("");
}

Sunday, January 10, 2016

Nginx 폴더를 node.js 연동

/etc/nginx/site-availables/default에 다음과 같이 추가

location /api/ {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://127.0.0.1:3000/;
    proxy_redirect off;
}

Wednesday, January 6, 2016