Jan 28, 2014

[Solved] Error in npm install from a github url

Posted Jan 28, 2014
If you're like me who's used to executing "git clone [github url]" then you may encounter an unusual behavior when using "npm install [github url]" or specifying the git repository inside package.json.

Here's a sample error of using npm install [github path]:

E:\progs\workspace\tmp>npm install https://github.com/mannyvergel/oils-js.git
npm http GET https://github.com/mannyvergel/oils-js.git
npm http 200 https://github.com/mannyvergel/oils-js.git
npm ERR! not a package C:\Users\Manny\AppData\Local\Temp\npm-5216\1390883860006-
npm ERR! Error: ENOENT, open 'C:\Users\Manny\AppData\Local\Temp\npm-5216\1390883
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "E:\\progs\\nodejs0.10.7\\\\node.exe" "E:\\progs\\nodejs0.10.7\
\node_modules\\npm\\bin\\npm-cli.js" "install" "https://github.com/mannyvergel/o
npm ERR! cwd E:\progs\workspace\tmp
npm ERR! node -v v0.10.7
npm ERR! npm -v 1.2.21
npm ERR! path C:\Users\Manny\AppData\Local\Temp\npm-5216\1390883860006-0.9308887
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     E:\progs\workspace\tmp\npm-debug.log
npm ERR! not ok code 0

The solution is very simple, just prefix your github url with "git+" e.g.

Use the format in your package.json or npm install, e.g.
npm install git+https://github.com/mannyvergel/oils-js.git

Jan 25, 2014

[Solved] NodeUnit does not finish when connected to Mongo DB

Posted Jan 25, 2014
When running NodeUnit tests and your tests are connected to Mongo DB, the tests do not end and it just hangs there. The fix is to close the connection on NodeUnit's tearDown function.

Example below is using Mongoose' disconnect function to close the connection after NodeUnit tests are done:
var mongoose = require('mongoose');
exports.tearDown = function(ok){
        if(err) {

Jan 22, 2014

How to create and apply a patch from an SVN Commit

Posted Jan 22, 2014
In subversion, there are cases that you may want to apply the same commit to another folder. E.g. you have a similar branch of your source code and you have committed the changes in your main branch. For this case, rather than copying your codes manually, you can create a patch from your SVN commit and apply it to another directory using the ff:

Create a patch from your commit, get the difference between two svn commits. Usually it's just your [desired commit #] minus one:
svn diff -r [reference commit]:[desired commit] > [filename]
svn diff -r 9714:9715 > 9715.patch

Copy the patch file to the directory you want to apply it and go to that directory in the command line and type:
patch -p0 < [filename]
patch -p0 < 9715.patch 

Jan 15, 2014

[Solved] 403 Status Code on Twitter API

Posted Jan 15, 2014
As of January 14, I was surprised to see that my code that uses Twitter API to post tweets does not work anymore. Then I saw the announcement that they now require https for all connections, so my change is quite simple: