Posts

Schedule Task on Google Cloud (Firebase)

Image
Major difficulty I faced as a backend-developer using stripe is the automated tasks running in the back-end based on time.For an example a batch process run in night or a small intended delay within a user process. The use of javascript based delay functions cannot accept in enterprise level applications, due to high unreliability within them. For example, all the delay functions might removed within sever restart. During the search of solid solution, I found the google cloud cron jobs,  which overcome the issue without going out of google platform. Thanks for the reference: https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html Start with prerequisites: Ensure these are available locally. git Python 2.7 Python pip Google Cloud SDK Clone the repository to a desired folder git clone https : //github.com/firebase/functions-cron Move to functions - cron folder from the command line enable gclould tool to use your project.   gcloud

Git merge specific files to master

Image
 It is a common requirement for every developer to maintain a dev code and production seperately . Sometimes we have to merge specific files to master from dev specially when it come to bug fixing of a released module. This article describe how to achieve this impossible task in nutshell. Thanks jasonrudolph for the guide git checkout source_branch <paths>... I' m using bitbucket and if I need to merge only  kanchana branch new_product file to the master Frist you have to checkout to master Then checkout the file with the branch name (kanchana ) git checkout kanchana src/products/new_product   After that you can proceed with git commit and push as usual   

ZTE MF 667 Remove Card Lock

Image
DC Unlock is the Most populer application .But its not free. Sonic provide good chance .You can User following URL. http://ineedohelp.blogspot.com/2012/04/internet-dongle-unlock.html Fallow the interaction as it indicates .There is a major difference only on identify device .You need to select ZTE and enable DC Unlock to detect Dongle by clieck on Search. I used  this with Windows 10.

Firebase database.ServerValue.TIMESTAMP get current time

Firebase Server Time STAMP can only retive the value when it comminted to firebase database var currentTimeStamp=firebase.database.ServerValue.TIMESTAMP; value for this will be set when datbase operation like set ,push or update occures . In order to get the value you need to write code like below.   ref.child(test).child(time-stamp').set(firebaseAdmin.database.ServerValue.TIMESTAMP).then(function() {                           ref.child(test).once('value').then(function(Snapshot) {                                                          var currentTimeStamp= Snapshot.val()['time-stamp']; }); });

Firsby for Unit test Firebase REST API

Firebase required to iniciate in order to run test cases. Firsby is a api testing fromwork ,which can work with jasmine.  npm install jasmine-node -g Install frisby.js http://frisbyjs.com/ Create spec file witih spec folder Import depeldancy var request = require("request"); var server = require("./../src/test.js");   // server file var frisby = require('frisby'); Header value for every request frisby.globalSetup({ request: { headers: {'AccessToken':process.env.test_token}. // taken from the .env } }); Dependent Request frisby.create(' Login')   .post(process.env.npm_config_host+'/api/login',{.  //take the host when running test command         "profile-type": "test",         "mess-token":"" }) .after(function(err, res, body) {   frisby.create('Dome')     .post(process.env.npm_config_host+'/api/user',{           "profile-type": &qu

Uplaod to Firebase Storage from Node Express REST

Image
I need to upload user profile picture from mobile device trogh rest API to Firebase storage .Finally I go the follwing articale wich really guide me .  https://mzmuse.com/blog/how-to-upload-to-firebase-storage-in-node In order to upload the file from Express REST I used connect-busboy and fs node modules . Route file   router.post('/api/user-pic/profile-type/:type', ProfilePicController.setProfile); Controller File    exports.setProfile = function(req, res, next) {                     var fstream;                     req.pipe(req.busboy);                     req.busboy.on('file', function (fieldname, file, filename) {                                           console.log("Uploading: " + filename);                         fstream = fs.createWriteStream(__dirname + '/files/' + filename);                               file.pipe(fstream);                         const filePath = __dirname + '/files/' + filename;  

Node Express REST API Document while coding

I have used apidoc in my  Node Express REST Project . It works like charm and cpable to handle document versioning. APIDOC Inline Documentation for RESTful web APIs http://apidocjs.com/#param-api-description 1.npm install apidoc - g 2. /** * @api {get} /tasks/:id Find a task * @apiGroup Tasks * @apiDescription User login + register user if user login for the frist time. * @apiParam {id} id Task id * @apiSuccess {Number} id Task id * @apiSuccess {String} title Task title * @apiSuccess {Boolean} done Task is done? * @apiSuccess {Date} updated_at Update's date * @apiSuccess {Date} created_at Register's date * @apiSuccessExample {json} Success * HTTP/1.1 200 OK * { * "id": 1, * "title": "Study", * "done": false * "updated_at": "2016-02-10T15:46:51.778Z", * "created_at": "2016-02-10T15:46:51.778Z" * } * @apiErrorExample {json} Task not f