Basic Git commands

Check if Git has already been installed, Git is usually preinstalled on Mac and Linux.

git --version

Type the following command and then press enter: Tell Git who you are First, you need to tell Git who you are:

git config –global user.email “you@example.com”
git config –global user.name “Your Name”

Some basic Git operations
When we worked on GitHub, the basic work cycle like the fork,  edit, commit, pull request,  merge. The same cycle, with a few differences, is what we will work through on the command line.

Getting the current branch

$ git status
# On branch master
nothing to commit (working directory clean)

Merge code from remote branch called dev to local user alex

git checkout dev
git pull
git checkout alex
git merge dev

Merge code from local alex to remote branch

git checkout dev
git merge alex
git push
git checkout alex

git branch commands’ various options. -a shows all local and remote branches, while -r shows only remote branches.

Show all local and remote branch

$git branch -a

Show all remote branch

$ git branch -r
$ git branch -v -r

There’s also another way to do figure out what branches are on your remote by actually using the remotely related commands, git remote and git ls-remote. The former displays plenty of information about the remote in general and how it relates to your own repository, while the latter simply lists all references to branches and tags that it knows about.

$ git remote show origin
$ git ls-remote --heads origin

Conflict Merge error
While merging file from master to local alex branch, sometime we may cause conflict merge error. We can solve the conflicted merge error in the number of ways. If we want to merge conflict file to remote master file then we can use git command.

git checkout master hitest.php

Or

git add .
git stash

Reset last committed or undo: The 1st command will Undo local and second will force delete from remote

git reset --hard HEAD^1
git push -f

Check Last two week commits

   git log --since=2.weeks

Firebase – Introduction

Firebase is the product of Google. To create new Firebase projects, you need a Google account. Firebase projects can be created and managed using the Firebase console (https://firebase.google.com/console/). Firebase provides different SDKs for mobile and web apps to interact with its database. Ionic apps should use the web SDK (https://firebase. google.com/docs/web/setup).

Note: Ionic apps should use the web SDK (https://firebase. google.com/docs/web/setup).

Why Firebase?

Firebase has made the life of developers easier as they don’t have to spend time building backend server to build simple APIs. We can easily do all CRUD operations with minimum effort and with Web socket supports it’s super fast in syncing data. Also, Firebase offers offline sync, user authentication, and features or securing the data with sets of rules.

Firebase provides user authentication for multiple platforms: Custom – for integrating with existing authentication systems

  • E-mail – register and authenticate users by e-mail and password.
  • Anonymous – for guest accounts without any personal information required
  • Facebook
  • Google
  • Twitter
  • GitHub

Firebase provides many options such as Analytics, Authentication, Database, Storage, Hosting, Notification and many other options. All Firebase database data is stored as JSON objects and no relational tables exist.

 

Database Structure

Firebase has a unique database structure that is different from other databases. Each Firebase database is stored as a tree-like JSON object. This tree structure is very flexible for all kinds of data. You can organize the app’s data in a way suits most for your app. For an e-commerce app, its database can be organized as below

{
	"products": {
		"00001": {
			"name": "iPhone 6s plus",
			"price": 613.50
		},
		"00002": {
			"name": "LG Nexus 5",
			"price": 187.99
		}
	},
	"customers": {
		"00001": {
			"firstName": "Alex",
			"lastName": "Cheng",
			"email": "alex@example.com"
		}
	},
	"orders": {
		"00001": {
			"customer": "00001",
			"items": {
				"00001": true,
				"00002": true
			},
			"shippingCost": 5.00
		}
	}
}

The property products is a map of product id to its properties. The property customers is a map of customer id to its properties. The property orders is a map of order id to its properties.

Each data value in the database has a unique path to identify it. If you think of the whole JSON object as a file directory, then the path describes how to navigate from the root to a data value. For example, the path of the price of the product with id 00001 is /products/00001/price. The path /orders represent all orders. The path is used when reading or writing data, as well as configuring security rules.

 

Adding Firebase database to Ionic

We have to create new project and Google will display three platform option as Android, ISO, and the web. The Ionic is web based so we have to choose to add Firebase to the web app. Add Firebase to your web app shows a dialog with code ready to be copied into the HTML file.

Google Place id

  addPlaces(places) {
    places.forEach((place) => {
      this.db.object('/locations/' + place.place_id).valueChanges().subscribe(data => {
        place.reviewsAvg = data && data['reviewsAvg'] || 0;
        place.reviewsCount = data && data['reviewsCount'] || 0;
      });
      this.places.push(place);
    });
  }

 

    this.locationRef = db.object('/locations/' + navParams.data.place_id);
    this.location = this.locationRef.valueChanges().subscribe(data => {
      this.reviewsAvg = data && data.reviewsAvg || 0;
      this.reviewsCount = data && data.reviewsCount || 0;
    });
    thi

 

 profileRef = {} as ProfileRef;  

this.db.object('/profiles/' + this.navParams.get('userId')).valueChanges().subscribe(data => {
      console.log("profile data : ", data);
      this.profileRef = <ProfileRef> data;
      
    },
    err => console.log("error in retrieving user from profile : "+err),
    () => console.log("user profile key retrieve successful"));

 

Taking review From single user 

this.reviews = db.list('/reviews', ref => 
  
 ref.orderByChild('uid').equalTo(navParams.data.userId)).valueChanges();