Sunday, 9 October 2016

Node: Installation and Upgrade

Node is installed using nvm and nodejs packages are install using npm.

Initial Installation

1.  Install nvm
curl -o- | bash
2. Install node version 4
nvm install 4

Upgrade NVM and Node version

1. Upgrade nvm using
curl -o- | bash
creationix/nvm/v0.32.0/ | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10007  100 10007    0     0   5040      0  0:00:01  0:00:01 --:--:--  5038
=> nvm is already installed in /Users/Seet/.nvm, trying to update using git
=> Source string already in /Users/Seet/.bash_profile
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="/Users/Seet/.nvm"
[ -s "$NVM_DIR/" ] && . "$NVM_DIR/"  # This loads nvm

2. Upgrade to stable node js 5 version
nvm install 5
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v5.12.0 (npm v3.8.6)
3. Uninstall node js 4
nvm uninstall 4
4. Set nvm alias to avoid this error: "N/A: version "N/A" is not yet installed."
nvm alias default v5.12.0
5. Useful command for debugging
> nvm alias
default -> v5.12.0
node -> stable (-> v5.12.0) (default)
stable -> 5.12 (-> v5.12.0) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.6.0 (-> N/A)
> nvm debug
nvm --version: v0.32.0
$SHELL: /bin/bash
$HOME: /Users/Nebitrams
$NVM_DIR: '$HOME/.nvm'
nvm current: v5.12.0
which node: $NVM_DIR/versions/node/v5.12.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v5.12.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v5.12.0
npm root -g: $NVM_DIR/versions/node/v5.12.0/lib/node_modules

Upgrade NPM

1. Upgrade nvm using

Common Issue for Parse-server Upgrade

This is a common error during upgrade of parse-server.  After upgrade, the npm start may ends with error like this: "Cannot find module 'double-ended-queue'".

If you run npm list, you will see some missing modules such as the followings:
npm ERR! missing: double-ended-queue@^2.1.0-0, required by redis@2.8.0
npm ERR! missing: redis-commands@^1.2.0, required by redis@2.8.0
npm ERR! missing: redis-parser@^2.6.0, required by redis@2.8.0
 You can try to delete the package-lock.json and node_modules folder, following by re-install.

rm -rf package-lock.json node_modules/
npm i --no-optional
npm dedupe
npm up
Refer to for more information.

Friday, 7 October 2016

MongoDB : regular version upgrade

The local MongoDB instance was installed using brew.

Initial Installation

  1. Install Xcode command-line toolsxcode-select --install
  2. install home-brew

Upgrade locally installed mongodb

1. Upgrade brew by running
"brew update"
2. Upgrade mongodb by running
"brew upgrade mongodb"
==> Upgrading 1 outdated package, with result:
mongodb 3.2.10
==> Upgrading mongodb
==> Installing dependencies for mongodb: openssl
==> Installing mongodb dependency: openssl
==> Downloading
######################################################################## 100.0%
==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in

and run

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
==> Installing mongodb
==> Downloading
######################################################################## 100.0%
==> Pouring mongodb-3.2.10.el_capitan.bottle.tar.gz
==> Caveats
To have launchd start mongodb now and restart at login:
  brew services start mongodb
Or, if you don't want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺  /usr/local/Cellar/mongodb/3.2.10: 18 files, 245.2M

Upgrade mLab mongodb version

General steps for upgrade:
  1. Check the mLab upgrade guide.
  2. Test the application in staging environment
Once all test is completed, upgrade the mLab using Tool -> version.

Friday, 20 May 2016

ParseServer: managing mLab test environment


  1. You have completed the setup of a production mLab database.
  2. You have mongoLab client installed in your computer so that you can run these
    1. mongodump
    2. mongorestore


Copy from mLab production database to another mLab staging database.

mLab cloud backup vs local backup

The copy of production database to test database is achieved using backup and restore mechanism. mLab provides cloud based backup and restore functionality using the web based admin page.  However, each backup cost 50 cents.  Alternatively, you can achieve this free of charge by installing your own mongoLab client in your computer and perform backup to your local computer and then restore to another test database in mLab.

Copy mLab database from production to staging using local backup

You will first need to run a mongodump to backup your mLab production database to your local PC.  After that you run mongorestore to restore your local PC database backup to another mLab staging database.  

MongoDB provides two mechanisms for importing and exporting data. One way is via the mongoimport and mongoexport utilities. These allow you to import and export JSON and CSV representations of your data. The other way is with mongorestore and mongodump utilities which deal with binary dumps.

The commands to dump, delete all tables/data and restore are as follows:
  1. mongodump -h <production-hostname> -d <production-database-name> -u <user> -p <password> -o <output directory>
  2. mongo <staging-hostname>/<staging-database-name> -u <user> -p <password> --eval "db.dropDatabase();"
  3. mongorestore -h <staging-hostname> -d <staging-database-name> -u <user> -p <password> <input db directory>

ParseServer: managing Heroku test environment


You have completed the setup of app in both
  1. local, i.e your own computer
  2. hosted on heroku, i.e this is the app that you deployed using "git push heroku master"
Refer to this heroku page for the details on creating staging, integration environments for the same application.  All the command below need to be ran in the heroku directory.  Heroku toolbelt is installed and you are logon using your heroku credential.


Setup a staging Heroku application.  A staging application is useful for testing new features in a production lookalike environment before releasing to production.

Checking your existing Git Remote

All applications on heroku are created with the default git remote as "heroku".  You can check the git remote using this command:
git remote -v
The command returns remotes as follows.  The heroku remote is the app that I deployed to the heroku.  The origin remote came from the git clone command when I clone from the parse-server-example git.
> origin (fetch)
> origin (push)
> heroku (fetch)
> heroku (push)

In this setup, I want to create elochallengestaging app from elochallenge app.  After the setup, I will have these 2 applications in Heroku.
  1. elochallenge
  2. elochallengestaging

Creating a Staging Environment

Run the following command to create a staging environment.
heroku fork --from elochallenge --to elochallengestaging
Add a new git remote using this command.
git remote add elochallengestaging
Run this again to confirm that remote is created successfully.
 git remote -v

Setting Configuration Variables

After the new environment is created.  You will need to set the configuration variables.  Run these command line.
  1. heroku config:set DATABASE_URI=xxx --remote  elochallengestaging
  2. heroku config:set MASTER_KEY=xxx --remote  elochallengestaging
  3. heroku config:set SERVER_URL=xxx --remote  elochallengestaging
You can also update the configuration variable using Heroku web admin page.

Publish Changes to Staging and Production Environment

When you are ready to test your code in staging, run the following command to push to staging.
git push elochallengestaging master
After testing in the staging environment is completed, you may push your changes to production.
git push heroku master

Pulling latest code from ParseServer github

The git remote that you checked out the source code via "git clone" will be updated with new releases.  Once you are ready to get the latest release, run one of the git pull command below from your local git folder.

  • git pull
  • git pull origin

If you see conflicts, check for the filename with conflict and use editor to resolve the merge conflict manually.  For example, this is a conflict in package.json
remote: Counting objects: 11, done.
remote: Total 11 (delta 6), reused 6 (delta 6), pack-reused 5Unpacking objects: 100% (11/11), done.
From   5eea333..084fa07  master     -> origin/master * [new branch]      parse-server-version -> origin/parse-server-versionAuto-merging package.json
CONFLICT (content): Merge conflict in package.json
Auto-merging index.jsAutomatic merge failed; fix conflicts and then commit the result.

After resolving conflicts, run the npm to get the latest.
  • npm outdated : to list the outdated modules. Sample output as follows.
Package       Current  Wanted  Latest  Locationexpress        4.13.4  4.13.4  4.14.0  express parse-server   2.2.10  2.2.14  2.2.14  parse-server
  • npm update : to get the latest modules to local computer
  • npm list : to list all the modules installed locally
Once you are ready, do a git add, git commit and deploy it to the staging environment by using git push command.
  • git push elochallengestaging master

Setting Git Defaults

You can set the git push defaults to the staging environment.  Run the following command to list all the git config.
git config -l
Run this to setup the push default to elochallengestaging.
git config push.default elochallengestaging
After setting up the default, you can push to the elochallengestaging by running this command.
git push

Friday, 24 October 2014

123 Dandelion - a fun way to learn odd, even numbers and times table

I designed this game for lower primary school children to learn odd numbers, even numbers and times table.
Click here to download from Apple AppStore
Choose a number series
The game starts with 5 numbers
More numbers at higher levels

Wednesday, 15 October 2014

123 Dandelion Terms of Use

Terms of Use

Thank you for choosing 123 Dandelion App! This is an agreement between you and App creator  that describes the terms of use for 123 Dandelion App and services.  You should review the entire agreement because all of the terms are important and together create this contract that applies to you.


Please note we do not provide warranties.

Limitation of Liability

Whilst every effort has been made in building this 123 Dandelion App, I am not to be held liable for any special, incidental, indirect or consequential damages or monetary losses of any kind arising out of or in connection with the use of the this App and information derived from this App.

This 123 Dandelion App is here purely as a service to you, please use it at your own risk. Do not use the App information for anything where loss of life, money, property, etc.

Privacy Policy

We collect personal and activity data, which may be linked.
We use technologies like cookies (small files stored on your browser), web beacons, or unique device identifiers to identify your computer or device so we can deliver a better experience. Our systems also log information like your browser, operating system and IP address.

We also may collect personally identifiable information that you provide to us, such as your name, address, phone number or email address. With your permission, we may also access other personal information on your device, such as your phone book, calendar or messages, in order to provide services to you. If authorized by you, we may also access profile and other information from services like Facebook.

Our systems may associate this personal information with your activities in the course of providing service to you (such as pages you view or things you click on or search for).

We do not knowingly contact or collect personal information from children under 4. If you believe we have inadvertently collected such information, please contact us so we can promptly obtain parental consent or remove the information.

We collect or share your location only with permission.
In serving you, we may use or store your precise geographic location, if you give us permission to do so. We do not use or share this data for any other purpose. Many devices will indicate through an icon when location services are operating. We only share this location information with others as approved by you.

You can request to see your personal data.
You can sign into your account to see any personally identifiable information we have stored, such as your name, email, address or phone number. You can also contact us by email to request to see this information.

We may keep data indefinitely.
We may keep data indefinitely.

We don't share your personal information with marketers.
We generally do not share personally identifiable information (such as name, address, email or phone) with other companies for marketing purposes.

No ad companies collect data through our service.
We do not allow advertising companies to collect data through our service for ad targeting.

You can ask privacy questions.
If you have any questions or concerns about our privacy policies, please contact us:

Vendors access data on our behalf.
In order to serve you, we may share your personal and anonymous information with other companies, including vendors and contractors. Their use of information is limited to these purposes, and subject to agreements that require them to keep the information confidential. Our vendors provide assurance that they take reasonable steps to safeguard the data they hold on our behalf, although data security cannot be guaranteed.

We take steps to protect personal information.
We take reasonable steps to secure your personally identifiable information against unauthorized access or disclosure. We encrypt transmission of data on pages where you provide payment information. However, no security or encryption method can be guaranteed to protect information from hackers or human error.

Information we collect may be stored or processed on computers located in any country where we do business.

Special situations may require disclosure of your data.
To operate the service, we also may make identifiable and anonymous information available to third parties in these limited circumstances: (1) with your express consent, (2) when we have a good faith belief it is required by law, (3) when we have a good faith belief it is necessary to protect our rights or property, or (4) to any successor or purchaser in a merger, acquisition, liquidation, dissolution or sale of assets. Your consent will not be required for disclosure in these cases, but we will attempt to notify you, to the extent permitted by law to do so.

You can review more privacy-related information.
This privacy policy was last updated on 15 October 2014. Our privacy policy may change from time to time. If we make any material changes to our policies, we will place a prominent notice on our website or application. If the change materially affects registered users, we will send a notice to you by email, push notification or text.

Thursday, 8 May 2014

Spelling 1942 Version 1.5.0 - a fun way to learn spelling

Spelling 1942, provides a fun way to learn spelling.  Every school gives out spelling list.  Your children can learn the school spelling list in this app and reinforce the learning by playing game this simple game.

The spelling lists are contributed by parents and teachers.  It is organised into Country, School, Level hierarchy.  School teachers are encouraged to submit their spelling list in MS Word file by email and I will make it available in this game.

A player can play the game in practise and challenge mode.  The practise mode is useful for the learning the words.  The challenge mode is designed to encourage children to aim for higher score and avoid making mistake.

In level 1 game play, player listen to pronunciation and shot the aeroplane which carry the pronounced word.  If the player is confident enough, he/she can shoot a helicopter and spell the pronounced word to get 10x the score.
Shoot helicopter and spell the word
to get 10x score

In level 2 game play, the game is more difficult because some "mutated" words will be appear as distractions.  For example, a word "spad" will appear instead of "sped" to test whether the player can pick up the right word.  If the player shoot the wrong word, he/she will get a penalty score.
Level 2 game play with "mutated" words

The game supports English, Chinese and Malay language.  It should be able to support any language in iPhone Siri.  Feel free to drop me a request on a new language if you are interested in.