Common npm permission issue

The problem: If you are using mac and install nodejs via pkg file downloaded from the official website, you are likely to encounter this error message when you try to install a npm module globally: npm ERR! Please try running this command again as root/Administrator. My solution DO NOT use sudo command to install the… Continue reading Common npm permission issue

Sublime Text 3: OS X Command Line

The problem Sublime Text 3 includes a command line tool, subl. However, it does not work out of the box after you install the editor in OS X Yosemite. My solution After the installation, create a symbolic link to Sublime Text using this command: ln -s /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl where ‘/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl’ is the location… Continue reading Sublime Text 3: OS X Command Line

Beer Recommendation Engine using PredictionIO

The Problem: We all love beers. And today, we face an unprecedented variety of options. We are overwhelmed by too many choices and couldn’t decide: What should I drink next? My Solution: In our Hack Reactor thesis project, I build a machine learning server using PredictionIO as a recommendation engine for beer. Boardly speaking, the… Continue reading Beer Recommendation Engine using PredictionIO

Angular.js factory: Handle $http asynchronously

The problem: When I was using $http service to get data from a remote API, my code below was not able to return data back to the controller. myApp.factory(‘myFactory’, function($http){ var data = { anArray:[] }; $http.get(‘/api’).success(function(data) { data.anArray.push(data); }); return data; }); This is because the return data is already executed before the $http… Continue reading Angular.js factory: Handle $http asynchronously

Setup proxy server with Express

The problem: I am working on a project using BreweryDB. I was trying to load some data from the API, but they don’t support jsonp. There is a CORS issue if I directly fetch data using Angular: XMLHttpRequest cannot load https://api.brewerydb.com/v2/. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:3000’ is therefore not… Continue reading Setup proxy server with Express

Angular UI bootstrap: Open first accordion with ng-repeat

The problem: I was using accordion directive in Angular UI Bootstrap 0.1.2. Reading the demo page, there is an example to show how to open the first-accordion-group by default: <accordion-group heading=”First Header” is-open=”true”> </accordion-group> This works fine for static content, but it fails to work with dynamic content using ng-repeat. In other words, it DOES… Continue reading Angular UI bootstrap: Open first accordion with ng-repeat