manywaypark's Blog
개발, 검색, 함수

problem:

rebar(엄밀히 말하면 rebar2)에서 rebar3로 업그레이드를 진행중인데, sqerl에서 아래와 같은 오류가 났다.

===> Compiling project

===> Compiling path/to/file.erl failed

path/to/file.erl:none: error in parse transform 'sqerl_gobot': {function_clause,

                                         [{lists,map,

                                           [#Fun<sqerl_gobot.1.114344583>,

                                            undefined],

                                           [{file,lists.erl},{line,1237}]},

                                          {sqerl_gobot,who_types_the_untyped,

                                           1,

                                           [{file,

                                             /path/to/project/_build/default/lib/sqerl/src/sqerl_gobot.erl},

                                            {line,81}]},

                                          {sqerl_gobot,parse_transform,2,

                                           [{file,

                                             /path/to/project/_build/default/lib/sqerl/src/sqerl_gobot.erl},

                                            {line,51}]},

                                          {compile,

                                           '-foldl_transform/2-anonymous-2-',

                                           2,

                                           [{file,compile.erl},{line,932}]},

                                          {compile,foldl_transform,2,

                                           [{file,compile.erl},{line,934}]},

                                          {compile,

                                           '-internal_comp/4-anonymous-1-',2,

                                           [{file,compile.erl},{line,295}]},

                                          {compile,fold_comp,3,

                                           [{file,compile.erl},{line,321}]},

                                          {compile,internal_comp,4,

                                           [{file,compile.erl},

                                            {line,305}]}]}


root cause:

사실 제법 많은 시간을 헤맸는데, 원본 파일이 컴파일 되지 않는 것이었다. 아래 라인을 소스 파일에서 제거하고 돌려보면 컴파일 에러(include 파일을 찾지 못함)가 났다.

-compile({parse_transform, sqerl_gobot}).

rebar2와 rebar3(정확히는 rebar3의 release)의 디렉토리 구조가 달라서 아예 컴파일이 안되는 것이 었다. 

AST구성후 parse transform후에 컴파일을 진행하게 되므로 상기 에러와 같은 이상한 에러가 나온다. 

직접적인 원인은 include가 되지 않아 정상적인 AST가 생성되지 않았는데 그 AST를 조작질(parse trasform)하려니깐 문제가 생긴 것인데... 에러 메시지만으로 알아보기 힘들었다.


solution:

include path 정확히 설정해 준다. release의 root에 rebar.config 파일이 있다면 아래처럼 설정한다 (사실 이거말고 다른 방법도 몇개 존재한다).

{erl_opts, [debug_info

           ,{parse_transform, lager_transform}

           ,{i, "apps/project"}]}.

요점은 parser transform을 요하는 소스 파일이라해도 적용전의 형태에서 컴파일은 되어야만 한다는 것. 

parser transform 관련해서 문제 생기면 transform을 disable하고 컴파일 테스트해보는 것을 추천하고 싶다.


happy hackin'



함수이름 마지막에 마침표를 찍어야 anonymous function(일반적으로 변수에 저장된) 함수를 invoke할 수 있는 것은 좀 이상하다.

Joe 아저씨도 의문을 표시한 적이 있구나.

https://groups.google.com/forum/#!topic/elixir-lang-core/Zop_x5K85XE

namespace를 분리하든가 scoping을 활용하든가 하면 좀더 깔끔한 방법이 있을 듯도 한데...


happy hackin'

대량의 동시 접속 처리하기 위한 설정들 모음

ref: http://emqtt.io/docs/v2/tune.html


결론을 먼저 말하자면 lc_monetary 설정(/etc/posgresql/.../postgresql.conf 파일)이 다를 때 생기는 문제다.

pg_dump를 한 postgresql의 설정으로 맞추어 주면 해결 된다.


내 경우의 원인은,

  1. box A에서 ubuntu 설치 후 기본 locale을 ko_KR.UTF8로 설정한 후에 postgresql server를 설치 (postgresql도 전부 ko_kR) .
  2. box B에서 ubuntu 설치 시 기본 locale을 en_US.UTF8로 설정하면서 postgresql server를 우분투 설치할 때 같이 설치(postgresql도 전부 en_US) .
  3. box A에서 pg_dump한 파일을 box B에서 pg_restore시도


KRW money type을 못 알아보겠다는 건 당연해보인다.


ref: https://www.postgresql.org/message-id/jv8i51$mb8$1@dough.gmane.org


happy hackin'


ps. system 수준에서 locale이 없다면 locale -a로 확인하고 locale-gen, update-locale을 해준다.

설치:

현재 우분투 14.04에서 기본 최신 gcc인 4.8을 쓰고 있는데 4.9를 쓸 일이 생겼다.

소스에서 빌드해서 써도 되지만 시간이 좀 걸리므로, PPA를 활용해서 설치한다.

⟫ sudo su -

# apt-get install build-essential

# add-apt-repository ppa:ubuntu-toolchain-r/test

# apt-get update

# apt-get install gcc-4.9 g++-4.9 cpp-4.9


설정:

기본 toolchain을 간단히 변경하기 위해 update-alternatives를 썼다.

참고 링크의 여러 방법을 참고해서 제일 간단한 방법을 하나 만들어보았다.

요지는 gcc가 변경될 때 g++, cpp도 함께 변경되게 만든 것이다.

 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 --slave /usr/bin/cpp cpp-bin /usr/bin/cpp-4.9

 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 --slave /usr/bin/cpp cpp-bin /usr/bin/cpp-4.8

cpp 대신 cpp-bin을 쓴 이유는 cpp는 우분투 시스템에서 기본적으로 생성되는 것이라 변경할 경우 스크립트가 깨질 수 있다고 두번째 참고 링크에 나옴.


확인:

제대로 변경되는지 확인해보자

⟫ sudo update-alternatives --set gcc /usr/bin/gcc-4.8          

update-alternatives: using /usr/bin/gcc-4.8 to provide /usr/bin/gcc (gcc) in manual mode

⟫ gcc --version

gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

......

4 ⟫ g++ --version

g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

......

⟫ cpp --version

cpp (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

......

⟫ sudo update-alternatives --set gcc /usr/bin/gcc-4.9

update-alternatives: using /usr/bin/gcc-4.9 to provide /usr/bin/gcc (gcc) in manual mode

⟫ gcc --version

gcc (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3

......

⟫ g++ --version

g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3

......

⟫ cpp --version

cpp (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3

......


refs:

http://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu

http://stackoverflow.com/questions/7832892/how-to-change-the-default-gcc-compiler-in-ubuntu/9103299


happy hackin'


Load Average? IO wait?

tips & tricks/Linux/Unix 2016. 7. 27. 13:50 by manywaypark

Load Average:

CPU Load에 관한 알기쉬운 설명:

http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages

http://www.howtogeek.com/194642/understanding-the-load-average-on-linux-and-other-unix-like-systems/

요약하자면, 

CPU Load 값은 코어당 1이 full인데  70%이하 정도로 유지 하는 것이 적당하다는 말인데, 

예를 들어 코어가 4개일 경우 full load는 4.0이고, 적절한 값은 2.8 이다.


IO wait:

http://bencane.com/2012/08/06/troubleshooting-high-io-wait-in-linux/

요약하자면, top, iostat, iotop, lsof (-p PID), pvdisplay 등의 유틸리티를 써서 IO 유발자(?)를 찾아내는데, 아래 명령으로 process state가 'D'인 놈을 찾아서 lsof -p PID를 통해 확인한다음 조치를 취하자는 말.

# find process w/ 'D' state (in every 5 sec, 10 times)

for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; done


happy hackin'

[maven] source jar, javadoc 다운로드

java 2016. 7. 13. 11:49 by manywaypark

maven을 쓰면 기본적으로는 pom.xml 파일의 dependency에 지정된 artifact들의 binary jar만 받아오는데, 소스나 javadoc이 보고싶은 경우가 있다.

아래처럼 해주면 source jar, javadoc을 받아온다.


mvn dependency:sources

mvn dependency:resolve -Dclassifier=javadoc


ref: http://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository


happy hackin'

R을 이용해서 sound 분석하기

함수형 언어/R 2016. 7. 11. 13:42 by manywaypark

R을 이용해서 sound 분석하기 참고자료.


  • http://www.r-bloggers.com/intro-to-sound-analysis-with-r/
  • https://cran.r-project.org/web/packages/seewave/vignettes/seewave_analysis.pdf

happy hackin'


[macport] port select --set

tips & tricks/Mac 2016. 7. 6. 10:49 by manywaypark

macport를 쓰다보면 같은 package이지만 여러 버전이 있는 경우가 있다.

postgresql의 예를 들자면 아래와같이 하면 9.4버전으로 설정을 맞추어준다.

sudo port select --set postgresql postgresql94

설정을 맞춘다는 것의 의미는 각종 파일 및 링크(eg, /opt/local/bin/pg_config 등)를 업데이트해주는 것을 말한다.


ref: http://stackoverflow.com/questions/7832296/usage-of-postgresql-select-on-macports


happy hackin'


PS. packagename_select 패키지를 설치해야되는 듯. postgresql은 postgresql_select

remmina는 다 좋은데 윈도우 키 누른 상태가 지속되는 경우가 있다.

해결법은 간단하다. 윈도우 키를 빠르게 두 번 연속으로 누르면 된다.


ref: http://askubuntu.com/questions/390869/disable-super-winkey-key-in-remmina


happy hackin'

1 ··· 3 4 5 6 7 8 9 ··· 31 
분류 전체보기 (306)
잡담 (20)
함수형 언어 (65)
emacs (16)
java (18)
tips & tricks (154)
사랑 (1)
가사 (0)
독서 (4)
mobile (6)
비함수형 언어 (2)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

04-27 12:12