Posts

How to user firebase Orderby Wisely

Image
There are number of ways  firebase order by can be used.Ferfer the following example.  It can be user as a where clause  to select values based on child attribute.You dont need to select items within the for loop.  todoRef.orderByChild("title").equalTo("test 1").once('value').then(function(snapshot) {     snapshot.forEach(function(childSnapshot) {         var todoID=childSnapshot.key; }) }).. We can use it as fallow,,

Use node which-country

Image
I  need to take the users country based on the geo-codinates provided by the mobile application. whlile doing some reaserch in node which-country , I found that ituseful,but need to pass value wisely.  https://www.npmjs.com/package/which-country  var whichCountry = require('which-country'); // pass it as  [latitudes,logitudes] var userCountry = whichCountry([6.795019389999998,79.88569332999997]); console.log('test userCountry :'+userCountry);  //return null // pass it as [logitudes,latitudes] var userCountry = whichCountry([79.88569332999997,6.795019389999998]); console.log('test userCountry :'+userCountry);  //return LKA I test the application with the given code of me in the test packges given by them. https://github.com/vkurchatkin/which-country/blob/master/package.json AUS -22.000825,132.889122 BLR 52.337547,24.080529 CAN 57.255393,-106.712553 CYP 35.315045,33.681395 DZA 23.184085,7.117638 ITA 39.926747,9.017427 JPN 43.771243,142.764986

Stripe Testing With 1 Day Plan - Subscription Not Cancel Automatically

Image
We normally use Stripe one day plan to test the scenarios. However we found a unexpected behavior  with stripe when we are using stripe one day plan. We created a subscription with the test card " 4000000000000341 " which make the payment unsuccessful when try to charge. According to dunning rules subscription have to cancel after 2 attempts. " It's likely that the Subscription hasn't cancelled because it doesn't have enough time to cancel as you have a daily Subscription. You see when a new invoice is created for a Subscription, it resets the retry logic (basically setting the retries back to zero).  For a daily Subscription you can't have more than 1 retry as it wouldn't give the retry logic enough time to carry out the final condition (i.e cancel the Subscription).  "

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory Different

Image
 This is a common error I found when I upgrade from node 8.8 to node 10.1 within my mac osx seirra. > node build.js || nodejs build.js xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance node 10.1 is not a stable release and I had to backdate it with the stable version. In addition, to fix the issue I had to run few commands to identify the location of command line tools. https://stackoverflow.com/questions/18533761/find-out-the-path-location-to-command-line-tools-for-xcode?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa /usr/ bin / clang -- version Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin16.7.0 Thread model: po

Firebase Cloud Functions TypeError: Cannot read property 'val' of undefined

Image
I have started using fire-base functions some time back and it was in beta release. When I try to update the functions within the production with the different node packages of firebase functions, following error occurred. TypeError: Cannot read property 'val' of undefined at exports.<>.functions.database.ref.onWrite.event (/user_code/index.js:467:38) at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27) I have used number of  fire base functions  and all of them triggering based onWrite leads to the above error. After small search I found the following discussion , https://stackoverflow.com/questions/49746905/firebase-typeerror-cannot-read-property-val-of-undefined?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa I have moved  from     "firebase-functions": "^0.9.1", to  "firebase-functions": "^1.0.2", where there is a major cha

Mac OSX version 10.12 - There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping

Image
This is a common issue I have seen in Mac OSX when I try to use pip. eg:sudo pip install -t lib -r requirements.txt   Could not fetch URL https://pypi.python.org/simple/google-api-python-client/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping However the reason for the problem is pip version update  with relevant to underlying OSX infrastructure. You have to identify which version of pip is there within mac OS.  Run brew install python    Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into

Heroku Environmental Variables

Image
Heroku provide a nice solution for manage the variables within the cross environments. You can define the production variables within heroku and hide the details in .env files or keep the test data on .env files. eg: Using node js you can call these data as fallows. const stripe = require('stripe')(process.env.DATABASE_URI); With same code you can keep 2 values within  2 environments.