Jun 16, 2014

Format NSString to left pad zeroes in Objective C

Posted Jun 16, 2014
01, 02, 03, 04, 05..
int num = 1;
[NSString stringWithFormat:@"%02d", num];

001, 002, 003, 004, 005..
[NSString stringWithFormat:@"%03d", num];

0001, 0002, 0003, 0004, 0005..
[NSString stringWithFormat:@"%04d", num];

You get the pattern? Good!


May 12, 2014

Anywhere Pad, the Board Portal Software for iPads and Android Tablets

Posted May 12, 2014

Around a year ago, I wrote about Anywhere Pad, particularly about its new design. That blog entry was more of a test than anything else, but I thought of doing a follow-up post because a lot has happened since I published the first one.

Yes, I'm still affiliated with the product, but I can say with only a tiny hint of bias that Anywhere Pad has significantly improved from the first time I featured it here. 

Aside from the continuous enhancements we've been adding to refine Anywhere Pad's usability, we also made it more streamlined by aligning the Android version with the iOS version. Our goal is to give directors and administrators the same user experience whether they're using an iPad or Android tablet. It's not enough that Anywhere Pad works on Android and iOS. We want it to work just as well for either platform so whatever you choose, you get to enjoy all the benefits and conveniences offered by Anywhere Pad.

This move is in response to the fact that many organizations are now adopting a Bring Your Own Device (BYOD) policy. We realize the policy won't be effective unless people have the freedom to choose whatever device to use; but with most board portal vendors offering board portal solutions for iPad use only, administrators and directors have no choice but to switch to iOS tablets if they aren't already using one yet. Don't get me wrong – iPads are great gadgets. But there are a lot of folks who prefer to use Android devices (which are great gadgets, too) so it only makes sense that they get choice in the matter as well.

Thus, we made Anywhere Pad a viable Android board portal solution for enterprise use. With stringent security features such as AES-256 network encryption, AES-128 document encryption, 2048-bit SSL, ISO 27001 (AWS EC2), on-the-fly decryption, automatic purge for lost devices, audit logging, and fine-grained access control, Anywhere Pad can effectively safeguard confidential information from malicious attacks and unauthorized access, whether the threat is internal or external.

Aside from security, we also beefed up the real-paper feel directors have been looking for in a board portal solution. The freehand annotation feature allows users to write comments using their own hand or stylus, while the whiteboard lets them draw diagrams (and even doodles) and map out processes.

To learn more about Anywhere Pad and its capabilities, request for a demo or quote.


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-
0.930888706818223\tmp.tgz
npm ERR! Error: ENOENT, open 'C:\Users\Manny\AppData\Local\Temp\npm-5216\1390883
860006-0.930888706818223\package\package.json'
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
ils-js.git"
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
06818223\package\package.json
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.
git+https://github.com/mannyvergel/oils-js.git

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){
    mongoose.disconnect(function(err){
        if(err) {
            console.error(err);
            return;
        }
    });
    ok();
};



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]
e.g.
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]
e.g.
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:

From:
http://api.twitter.com/1.1/statuses/update.json

To:
https://api.twitter.com/1.1/statuses/update.json