How to remember Username and Password when pull or push Project with Git


Remember username and password when pull or push project 

In this tutorial I will share how to remember username and password when pull or push by working with git , also I will share how to avoid conflict lines  when developers are working at the same file in project.

To git remember username and password when pull or push

1) Go to your project folder
2) Right click in your project
3) Select Git Bash
4) Type: git config credential.helper store
5) Enter : your username and password

Then when pull or push git next time it will remember your username and password automatically.

Sometime developers are working at the same file ,one developer committed his/her task first ,and next developer do the same lines and the same file when pull it will conflict lines that required developer merge or resolved  that file or revert the previous file. To avoid conflict lines at the same file , here is step by step to avoid conflict line at the same file.

1) Commit your task (do not click button Push , just only commit )
2) Right click your project folder or your repository project
3) Stash Save
4) pull
5) stash pop
6) push

when push your project git will merge your code and line automatically.


Android Sample Project Part -1

Android Sample Project Part -1 


to create new sample android project and run it should have eclipse , genymotion for run and test it at local. And this is sample project demo.
Demo tax on Salary (android sample project)
1) step 1




2) step 2 - input currency (riels) to text box ,then show result pay tax.


Next tutorial we will create project step by step.

Android Sample Project Part -2

In this section we will create sample project step by step.

1) Create your project name in eclipse.
2)  In activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/lbltitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginTop="32dp"
   
        android:gravity="center_horizontal"
        android:text="@string/SalaryTax"
        android:textColor="#0101DF"
        android:textSize="35sp" />

    <TextView
        android:id="@+id/lblsalary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/lbltitle"
        android:layout_marginTop="37dp"
        android:text="@string/Salary"
        android:textColor="#0101DF"
        android:textSize="25sp" />

    <EditText
        android:id="@+id/txtsalary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/lblsalary"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/lblsalary"
        android:ems="10"
        android:textSize="15sp"
        android:inputType="number"
       android:width="200dp" >
        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/btncal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/CalculateTax"
        android:textColor="#0101DF"
        android:width="110dp" />

    <TextView
        android:id="@+id/lblnet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignLeft="@+id/lblsalary"
        android:layout_below="@+id/btncal"
        android:layout_marginTop="37dp"
        android:text="@string/NetSalary"
       android:textSize="20sp" />

    <TextView
        android:id="@+id/lbltax"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/lblnet"
        android:layout_below="@+id/lblnet"
        android:layout_marginTop="48dp"
        android:text="@string/Tax"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/txtsalary"
        android:layout_alignLeft="@+id/txtsalary"
        android:text="@string/introductionTaz" />

</RelativeLayout>







Android Sample Project Part - 3

Android Sample Project Part - 3


In  this section you will know more android sample project , and this part we will learn more about xml file.
In this part we will store variable name and values in String.xml file in android sample project .
To store variable and values in string.xml to ,go to android project 



<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">salary</string>
    <string name="action_settings">Settings</string>
     <string name="SalaryTax">Tax payment</string>
      <string name="Salary">Salary</string>
      <string name="CalculateTax">Calcualte</string>
     <string name="NetSalary">balance</string>
      <string name="Tax">Tax</string>
      <string name="introductionTaz">1$ = 4000 Riels</string>
    

</resources>

You saw some variable and values stores in string.xml file and ti was used activity_main.xml 
Example:1
android:text="@string/SalaryTax" ,also you can call to use it in MainActivity.java like this 
Example:2
Toast.makeText(MainActivity.this, getString(R.string.SalaryTax, comp, guesses), 
            Toast.LENGTH_LONG).show();

Android Sample Project Part - 4

Android Sample Project Part - 4

In this section you will know more about MainActivity.java and Concept in android sample project 
In this app you will know how to declare variable and some conditions in Salary Tax.

There are  some conditions that we will to do it in MainActivity.java


Monthly salary (Riels)Rate
0 - 800,0000%
800,001 - 1,250,0005%
1,250,001 - 8,500,00010%
8,500,001 - 12,500,00015%
12,500,001 - upwards20%
public class MainActivity extends Activity {
public Button CalculateTax;
public EditText Salary;
public TextView NetSalary;
public TextView Tax;

public double salarys, netsalary,tax = 0;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
                //call method 
addOnclickListener();
}
private void addOnclickListener() {
// TODO Auto-generated method stub
CalculateTax = (Button)findViewById(R.id.btncal);
Salary = (EditText)findViewById(R.id.txtsalary);
NetSalary = (TextView)findViewById(R.id.lblnet);
Tax = (TextView)findViewById(R.id.lbltax);

CalculateTax.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if(Salary.getText().toString().equals("")){
Toast.makeText(getApplicationContext(), "Please Fill in the salary", Toast.LENGTH_LONG).show();
}
else
{
salarys = Double.valueOf(Salary.getText().toString());
if(salarys>=0 && salarys<=800000){
netsalary salarys ;
tax = 0;
}else if(salarys >= 800001 && salarys <= 1250000){
tax = (salarys *0.05)-40000;
netsalary salarys -((salarys *0.05) - 40000);
}else if(salarys >=1250001 && salarys <= 8500000){
tax = (salarys *0.1)-102500;
netsalary  salarys  - ((salarys  *0.1 ) - 102500);
}else if(salarys >= 8500001 && salarys <= 12500000){
tax = (salarys *0.15)-527500;
netsalary  salarys - ((salarys *0.15)-527500);
}else {
tax = (salarys *0.2)-1152500;
DecimalFormat df = new DecimalFormat("00.00");
                   String myre = df.format(tax);
netsalary  salarys - ((salarys *0.2)-1152500);
DecimalFormat dfo = new DecimalFormat("00.00");
                   String myreo = dfo.format(netsalary  );
}
}
String finaltax = String.valueOf(tax);
Tax.setText(" Pay tax = "+finaltax);
NetSalary.setText("Your Balance = "+ String.valueOf(netsalary  ));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

Android Concept Sample Project

Android Concept Sampe Project 

In this tutorial you will know android project concept and this project name is tax on salary..
Some Countries get from citizen who is working in company or NGO and tax will automatically to government monthly . so this this tutorial we will create new android sample project it s name tax on Salary


Example: Cambodia (Tax on Salary)

Monthly salary (Riels)Rate
0 - 800,0000%
800,001 - 1,250,0005%
1,250,001 - 8,500,00010%
8,500,001 - 12,500,00015%
12,500,001 - upwards20%


Next tutorial we will create this sample android project.

Comparator Date - Java

In this tutorial you will know how to compare Date  in java .
In this section we will do step by step
1. Comparator Date in Java
2. Comparator by using method after(), before() and equal()

public boolean after(Date date);
public boolean  before(Date date)
public boolean equal(Object o);

See Example1;

import java.util.Date;

public class Details {
       public static void main(String[] args) {
Date today = new Date();
Date myDate = new Date(today.getYear(),today.getMonth()-1,today.getDay());
getCompareDate(today, myDate);
}
public static void getCompareDate(Date today, Date myDate){
System.out.println("method Comparator > My Date is : "+myDate);  
    System.out.println("method Comparator Today Date is : "+today);
    if (today.compareTo(myDate)<0){
        System.out.println(" method Comparator Today Date is Lesser than my Date");
    }
    else if (today.compareTo(myDate)>0){
        System.out.println(" method Comparator Today Date is Greater than my date");
    }  
    else{
        System.out.println("Both Dates are equal");
    }

}

//result:
method Comparator > My Date is : Mon Feb 01 00:00:00 ICT 2016
method Comparator Today Date is : Mon Mar 14 23:52:02 ICT 2016
 method Comparator Today Date is Greater than my date


Example2: method after(), before(), equal();

import java.util.Date;

public class Details {
public static void main(String[] args) {
Date today = new Date();
Date myDate = new Date(today.getYear(),today.getMonth()-1,today.getDay());
getDateComapreBeforeAndAfter(today, myDate);
}

private static void getDateComapreBeforeAndAfter(Date today, Date myDate){
//After() or before() or equal() method want to know today > myDate ? and it return boolean true or false
System.out.println("Date method compare Before : "+today.before(myDate));
System.out.println("Date method compare After : "+today.after(myDate));
System.out.println("Date method compare equal : "+today.equals(myDate));
}
}

result :

Date method compare Before : false
Date method compare After : true
Date method compare equal : false





Kategori

Kategori