2015의 게시물 표시

MongoDB Replication 설정

# 참고 https://docs.mongodb.org/manual/reference/configuration-options/#replication-options # 설정해야 되는 것 - /etc/mongod.conf replSet=rep oplogSize=2048 $ mongo $ rs.initiate()

Underscore.js로 Object에 특정 Key 존재여부 체크하기

최근 회사 프로젝트를 진행하면서 Object의 특정 Key가 존재하는지 체크할 일이 생겼는데 여러가지 방법을 시도해보았으나 제일 좋은것은 Underscore.js의 has 메서드인 것 같다. 아래는 Underscore.js의 document의 has 메서드 부분이다. has _.has(object, key) Does the object contain the given key? Identical to  object.hasOwnProperty(key) , but uses a safe reference to the  hasOwnProperty  function, in case it's been  overridden accidentally . _.has({a: 1, b: 2, c: 3}, "b"); => true 여기서처럼 Object에 특정 Key가 존재하는지 체크할 때는 _.has 를 이용하는 것이 깔끔한 것 같다. 추가로 Object의 hasOwnProperty 메서드를 사용해도 되지 않냐고 생각할 수도 있지만 overridden accidentally 링크에서 설명하는 것처럼 prototype의 키 값이 충돌하는 경우 문제가 될 수 있기 때문에 _.has 를 사용하는 것이 더 나은 선택으로 보인다.

MyFolio 서비스 런칭

MyFolio 서비스 런칭 myfolio.me 웹 기반 포트폴리오 제작 서비스 Coding 없이 텍스트 입력, 파일 업로드만으로 포트폴리오 제작 가능 플랫폼 클라이언트 : HTML, Javascript (jQuery, …) 서버 : NodeJS (Express JS) DB : MariaDB ​

OpenWeatherMap API 이용해서 날씨 데이터 가져오기

OpenWeatherMap API 도시별 날씨 데이터 가져오기 OpenWeatherMap Query Example http://api.openweathermap.org/data/2.5/find?APPID=SAMPLE_API_KEY&q=Seoul,kr&units=metric APPID: API Key q: 도시명,국가코드 units: 표시 타입(metric: 섭씨) request 모듈로 날씨 데이터 가져오기 var WEATHER_API_URL = "http://api.openweathermap.org/data/2.5/find"; var WEATHER_QUERY_UNITS = "metric"; var APP_ID = "DEMO_API_KEY"; Weather.getWeatherData = function(city, countryCode, callback) { var query = { APPID: APP_ID, units: WEATHER_QUERY_UNITS, q: city + "," + countryCode } var options = { method: 'GET', url: WEATHER_API_URL, qs: query }; var weatherData; logger.info("GET query: ", query); request(options, function(err, res, body) { var parsedBody = JSON.parse(body); if(!parsedBody) { return callback(err, null); } // weatherData 가공해서 필요한 형태로 만들어줌 weatherData = self.makeWeatherData(serviceType, par