기본 콘텐츠로 건너뛰기

글

Multiple pub/sub collection in meteor

iron Router를 잘 쓰고 있는데 쓰다 보니 이상한 점이 있다. 페이지별로 subscribe 하는 것까지는 좋지만 당연히 여러 개의 page에 대해 subscribe를 해야 하는데 waitOn 같은 곳에서 여러 개의 collection에 대해 subscribe를 하다 보니 N번 화면을 갱신하기도 하고 코드도 좀 번거롭다. 여러 개의 Collection에 대한 pub/sub을 한 번에 할 수 없을까 생각하고 있었는데 https://github.com/meteor/meteor/pull/716 최근 내용을 보니까 구현이 되어있다! 이것도 undocumented라고 해야 하나 싶다. 아무튼, 좋다. Posts, Replies 두 개의 Collection이 있다고 할 때 autopublish package를 meteor(혹은 mrt) remove autopublish하여 삭제하고 수동 가입을 구현한다면 /model/model.coffee @Posts = new Meteor.Collection "posts" @Replies = new Meteor.Collection "replies" /client/subscribe.coffee Meteor.subscribe 'posts-replies' /server/publish.coffee Meteor.publish 'posts', ->   [Posts.find(), Replies.find()] 이렇게 [ ] 배열 형태로 묶어만 주면 된다. 좋은 패치라고 생각한다. 적극적으로 활용하자.

iron-router에서 /#/(hashbang) 을 사용할때 주의점( ex. verify-email등)

iron-router 적응 중인데 역시 대세다. 최근 server-side도 반영되어 구 router package에서 안심하고 넘어와도 되겠다 싶었다. E-mail 인증( http://spectrumdig.blogspot.kr/2013/10/meteor-e-mail.html )을 구현해 놓았는데 이게 실제로 해보니까 iron-router 에선 제대로 되지 않는다. 찾아보니 Server 쪽에서 해당 URL이 들어올때 패치하는 방법이 있다. https://github.com/EventedMind/iron-router/issues/3#issuecomment-20917649 Server 아래 Route 관련 부분에 Accounts.urls.resetPassword = (token) ->   Meteor.absoluteUrl "reset-password/#{token}" Accounts.urls.verifyEmail = (token) ->   Meteor.absoluteUrl "verify-email/#{token}" Accounts.urls.enrollAccount = (token) ->   Meteor.absoluteUrl "enroll-account/#{token}" 이런 식으로 넣어주면 된다.

meteor에서 특정 조건에서 head를 조작하기

server/header.js 식으로 server에서만 작동하는 코드를 만들자. Fiber = Npm.require("fibers"); WebApp.connectHandlers.use(function(req, res, next) { if (req.url==='/connect') { res.writeHead(200, {'Content-Type': 'text/html'}); Fiber(function() { res.write('<html>') res.write('<head>'); res.write('<meta property="qc:admins" content="2311172222411526554572637573766534" />'); res.write('<head>'); res.write('<body></body>'); res.write('</html>') res.end(); }).run(); } else { next(); } }); 위 코드는 weiyun 인증의 경우인데 <meta property="qc:admins" ... 를 사이트에서 요구하는 경우이다. 이런 식으로 meta를 요구하는 경우가 종종 있는데 아마 구글 서비스 중에도 있을 듯. 사이트 도구? 아마 그럴 것이다. 저번에도 이야기 했지만 WebApp.connectHandlers 요거 좋은 놈이다. 서버쪽에서 특정 url로 들어왔을때 예외처리를 하고 싶다면 이걸 사용하면 된다. 예의 경우는 /connect 로 들어왔을 때만 예외처리를 하고 나머지는 그냥 next()로 넘겼다. ...

SoX Library 컴파일하기(for OS X)

./osxbuild 실행 오류 $ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" $ brew install automake 재시도 $ ./osxbuild configure.ac:21: installing './compile' configure.ac:10: installing './config.guess' configure.ac:10: installing './config.sub' configure.ac:12: installing './install-sh' configure.ac:12: installing './missing' libgsm/Makefile.am:35: error: Libtool library used but 'LIBTOOL' is undefined libgsm/Makefile.am:35:   The usual way to define 'LIBTOOL' is to add 'LT_INIT' libgsm/Makefile.am:35:   to 'configure.ac' and run 'aclocal' and 'autoconf' again. libgsm/Makefile.am:35:   If 'LT_INIT' is in 'configure.ac', make sure libgsm/Makefile.am:35:   its definition is in aclocal's search path. libgsm/Makefile.am: installing './depcomp' lpc10/Makefile.am:8: error: Libtool library used but 'LIBTOOL' is undefined ...

Genymotion 에서 Unroot/Root 상태 전환하기 위한 쉬운 방법.

Genymotion은 지옥 성능의 안드로이드 에뮬에 비해 확실히 쾌적하고 아름다운 툴이다. 최근 롬을 보면 기본 Su 설치 상태로 나오는데 일부 Root을 검사하는 앱에서 사용 제한이 걸리곤 한다. 멀티터치 같은 걸 시뮬하기 위해서 DroidMote를 사용한다던가 하는 용도를 봤을땐 Root가 필요하고 여러가지 이유로 개발환경에선 Root/Unroot를 다 쓸 수 있으면 좋다. Genymotion Configuration 아이콘을 찍고 Save 버튼 위 Always allow su access (bypass Superuser app)에 체크박스를 켜준다. Save 하면 아마 재부팅을 한다고 할 것이다. 재부팅하자. 요즘은 SuperSu 가 간단하니 SuperSu를 스토어에서 받자. 몇몇 가지를 묻는데 특별한 롬을 쓰느냐 물을 때 Normal 이랑 충돌이 있으니 기존 Su앱을 지우겠느냐에서 등등 상식적인 걸 체크하고 SuperSu를 다시 실행. 이제부턴 설정창에서 Su를 간편하게 껐다 켰다 할 수 있다.

meteor 에서 E-mail 인증하기

MAIL_URL은 gmail을 쓸 경우 다음과 같이 설정하면 된다. smtp:// 사용자계정 %40gmail.com: 계정암호 @smtp.gmail.com:465/ 혹은 google apps 계정은 경우 smtp:// 사용자계정 %40 구글Apps도메인 : 계정암호 @smtp.gmail.com:465/ ---- 가입자 확인 메일 발송엔 몇가지 문제가 있는데 1. Text로 메일을 보낸다. 2. Formatted 형식을 사용할 수 없다. 이건 내가 생각해봐도 좀 아니다 싶다. server 쪽에서 startup 할때 기존 Accounts.emailTemplate과 Accounts.sendVerificationEmail 등등이 제대로 작동하도록 바꿔치기 해주자. :: email.coffee Meteor.startup ->   # set Mail configuration   Email = Package.email.Email;   _.extend Accounts.emailTemplates,     from: "Gearlounge <no-reply@gearlounge.com>"     verifyEmail:       subject: (user)->         "#{"#{user.profile.displayName}님, "if (user.profile and user.profile.displayName)?}가입을 환영합니다."       html: (user, url)->         Handlebars.templates['verifyEmail'](           user: user.profile &...

Could not locate package.js 오류가 발생하면서 mrt/meteor 가 실행 안될때

/packages 디렉토리를 죄다 .gitignore로 등록해서 온 프로젝트가 있어서 지우고 다시 했더니 Could not locate package.js .. 오류가 발생했다. https://github.com/DiscoverMeteor/Microscope/issues/11 이 글을 참조. mrt uninstall --system 하고 다시 실행했더니 잘된다. 다행이네 다행이야.