Monday, November 19, 2018

Git Tags - what, why, when and how

Git TAGS - What | Why | When | How
Today We will learn: -------------------------------
1. What are tags / releases
2. Why should i create TAGs
3. When to create TAGs
4. How to create TAGs in git

create | show | publish | delete

Step 1:
Checkout the branch where you want to create the tag
git checkout "branch name"
example : git checkout master
________________________________________________________


Step 2:
Create tag with some name
git tag "tag name"
example : git tag v1.0
git tag -a v1.0 -m "ver 1 of .." (to create annotated tags)
________________________________________________________

Step 3:
Display or Show tags
git tag
git show v1.0
git tag -l “v1.*”
________________________________________________________

Step 4:
Push tags to remote
git push origin v1.0
git push origin --tags
git push --tags (to push all tags at once)
________________________________________________________

Step 5:
Delete tags (if required only) to delete tags from local :
git tag -d v1.0
git tag --delete v1.0

to delete tags from remote :
git push origin -d v1.0
git push origin --delete v1.0
git push origin :v1.0
to delete multiple tags at once:
git tag -d v1.0 v1.1 (local)
git push origin -d v1.0 v1.1 (remote)


________________________________________________________

Checking out TAGS

 We cannot checkout tags in git
We can create a branch from a tag and checkout the branch
git checkout -b "branch name" "tag name" example :
git checkout -b ReleaseVer1 v1.0
 ________________________________________________________
Creating TAGS from past commits
git tag "tag name" "reference of commit"
example : git tag v1.2 5fcdb03




source

how to see git log and diff

source
How to see logs and diff in Git

git log --stat


  • git log --stat
to show all where file was changed.
how may lines are modified added or deletion like this.


 new_file.txt | 1 +
 1 file changed, 1 insertion(+)


  • git log -p
You will see like this.
    new added p

diff --git a/new_file.txt b/new_file.txt
index 8646659..b5f7bcb 100644
--- a/new_file.txt
+++ b/new_file.txt
@@ -1 +1,2 @@
 this is new file
+now added p word
\ No newline at end of file


Different between commit 

after change the file , where is changed to show this. you need to check differ.
  • git diff
 $ git diff
diff --git a/new_file.txt b/new_file.txt
index b5f7bcb..7f6d181 100644
--- a/new_file.txt
+++ b/new_file.txt
@@ -1,2 +1,4 @@
 this is new file
-now added p word
\ No newline at end of file
+now added p word
+changed
+another
\ No newline at end of file


Only changes file show

  • git diff --word-diff
$ git diff --word-diff

diff --git a/new_file.txt b/new_file.txt
index b5f7bcb..b11d6b6 100644
--- a/new_file.txt
+++ b/new_file.txt
@@ -1,2 +1,4 @@
this is new file
now {+new+}  added p word
{+changed+}
{+another+}

Fetch and Pull


when you work a branch with team you need checkout branch.
before work or push you need to pull first.

if anyone change their branch you must pull first and then push.

but if you fatch all branch to your repository, you can write 'git fetch origin master'

  • git pull origin master
  • git push origin master

  • git checkout -b dev
  • git checkout -b dev-amirul
  •  
  • git checkout dev
  •  
  • git branch
  • git push origin dev.


















Thursday, November 15, 2018

Host file added windows 10, 8

For Windows 10 and 8
  1. Press the Windows key.
  2. Type Notepad in the search field.
  3. In the search results, right-click Notepad and select Run as administrator.
  4. From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
  5. Make the necessary changes to the file.
  6. Click File > Save to save your changes.
For Windows 7 and Vista
  1. Click Start > All Programs > Accessories.
  2. Right-click Notepad and select Run as administrator.
  3. Click Continue on the Windows needs your permission UAC window.
  4. When Notepad opens, click File > Open.
  5. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
  6. Click Open.
  7. Make the necessary changes to the file.
  8. Click File > Save to save your changes.
For Windows NT, Windows 2000, and Windows XP
  1. Click Start > All Programs > Accessories > Notepad.
  2. Click File > Open.
  3. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
  4. Click Open.
  5. Make the necessary changes to the file.
  6. Click File > Save to save your changes.

Wednesday, November 14, 2018

laravel project from github setup step by step




1. Pull Laravel/php project from git provider.
 
 
 
2. Rename .env.example file to .env inside your project root and fill the database information. (windows wont let you do it, so you have to open your console cd your project root directory and run mv .env.example .env )
 
windows: copy .env.exmple to .env
 
3.  create database name and set .env file as your phpmyadmin setting.

4. Open the console and cd your project root directory

Run composer install or php composer.phar install
 
 
5. Run php artisan key:generate
6. Run php artisan migrate
7. Run php artisan db:seed to run seeders, if any.
8. Run php artisan serve

Tuesday, November 13, 2018

use back4app.com for parsing data from server very easy







Step 1 - Set up

At the beginning of each Parse activity, import the following:
1
2
3
4
5
6
7
8
9
10
11
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseUser;  


Step 2 - Sign Up

Signing up basically involves saving a new object of class ParseUser, shown as “User” in your app Dashboard, and setting at least two of its pre-defined attributes: username and password. In order to set these attributes, two specific methods of this class are used: ParseUser.setUsername() and ParseUser.setPassword().
The method used for saving the new user on the Dashboard is ParseUser.signUpInBackground(), which may come together with a callback function.
Note: Objects of this special class are not saved on the Dashboard with ParseObject.save() method.
To make SignUpActivity work, follow these steps:
  1. Import into your SignUpActivity, in addition to the dependencies imported in Step 1:
    1
    import com.parse.SignUpCallback;
    
  2. To implement user registration, simply use the following code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    ParseUser user = new ParseUser();
    // Set the user's username and password, which can be obtained by a forms
    user.setUsername(<Insert Username Here>);
    user.setPassword(<Insert User Password Here>);
    user.signUpInBackground(new SignUpCallback() {
        @Override
        public void done(ParseException e) {
            if (e == null) {
                alertDisplayer("Sucessful Sign Up!","Welcome" + <Insert Username Here> + "!");
            } else {
                ParseUser.logOut();
                Toast.makeText(SignUpActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
           }
        }
    });
    
    In the example project, this code is placed inside a SIGN UP button callback.
    Also, username and password are caught using Edit Texts.
  3. It’s interesting to add an additional method to display Alert Dialogs and make the process look more professional. The method below do this:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    private void alertDisplayer(String title,String message){
           AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this)
                   .setTitle(title)
                   .setMessage(message)
                   .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                       @Override
                       public void onClick(DialogInterface dialog, int which) {
                           dialog.cancel();
                           // don't forget to change the line below with the names of your Activities
                           Intent intent = new Intent(SignUpActivity.this, LogoutActivity.class);
                           intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                           startActivity(intent);
                       }
                   });
           AlertDialog ok = builder.create();
           ok.show();
       }
    

Step 3 - Log in

Logging in creates a Session object, which points to the User logged in. If login is successful, ParseUser.getCurrentUser() returns a User object, and a Session object is created in the Dashboard. Otherwise, if the target username does not exist, or the password is wrong, it returns null.
The method used to perform the login action is ParseUser.logInInBackground(), which requires as many arguments as the strings of username and password, and may call a callback function.
Note: After signing up, login is performed automatically.
To make LoginActivity work, follow these steps:
  1. Import into your LoginActivity, in addition to the dependencies imported in the Step 1:
    1
    import com.parse.LogInCallback;
    
  2. To implement user login function, simply use the code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    ParseUser.logInInBackground(<Insert Username Here>, <Insert User Password Here>, new LogInCallback() {
        @Override
        public void done(ParseUser parseUser, ParseException e) {
            if (parseUser != null) {
                alertDisplayer("Sucessful Login","Welcome back" + <Insert Username Here> + "!");
            } else {
                ParseUser.logOut();
                Toast.makeText(LoginActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    });
    
    In the example project, this code is placed inside a LOG IN button callback.
    Also, username and password are caught using Edit Texts.
    The method alertDisplayer is the same that you added in the SignUpActivity, don’t forget to change its Intent arguments though.

Step 4 - Log Out

Logging out deletes the active Session object for the logged User. The method used to perform log out is ParseUser.logOut().
To implement user log out, simply use the code below, in the LogoutActivity:
1
2
3
// logging out of Parse
ParseUser.logOut();
alertDisplayer("So, you're going...", "Ok...Bye-bye then");
In the example project, this code is placed inside a LOG OUT button callback.
The method alertDisplayer is the same that you added in the LoginActivity and SignUpActivity, don’t forget to change its Intent arguments though.

Step 5 - Test your app

  1. Run your app and create a couple of users, also try logging in again after registering them.
  2. Login at Back4App Website.
  3. Find your app and click on Dashboard > Core > Browser > User.
At this point, you should see your users as displayed below:
Note: Using the codes displayed above, every time you log in with a user, a Session is opened in your Dashboard, but when the user logs out that particular Session ends. Also, whenever an unsuccessful login or sign up attempt occurs, the Session opened in Parse Server Dashboard is deleted.

It’s done!

At this stage, you can log in, register or log out of your app using Parse Server core features through Back4App!


Login RegistrationSource

back4app CRUD operation

Adminca

Sunday, November 11, 2018

selectable button in android studio | click a button show hovor in android studio

Today I will discuss about android studio button selection. How we can use a hover effect in this button. .

here the code , you use this code snap to your drawer folder and give a name as you want.
then you use this as a background in your button which is stayed in layout section.



thanks , I will talk to you another topics later.

Friday, November 9, 2018

Espresso dependencies

/*Espresso testing */
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

Full code of dependency:CODE



Toast message check




Code END




Saturday, November 3, 2018

how to create custome Matcher in Espresso android studio

Create a class name  ErrorMatcher in androidTest folder.


public class ErrorMatcher {



@NonNull

public static Matcher withError(final Matcher stringMatcher) {

return new BoundedMatcher(TextView.class) {


@Override

public void describeTo(final Description description) {
description.appendText("error text: ");
stringMatcher.describeTo(description);
}


@Override

public boolean matchesSafely(final TextView textView) {
return stringMatcher.matches(textView.getError().toString());
}
};
}
}


# Maching logic is to match the subtext of the textview with only the error message.

#describeTo method only for debug.

# you can use this as your custom matcher in the test case as shown in below.

===================


@Test 

public void testLoginMandatory()
{
    onView(withId(R.id.email_sign_in_button)).perform(click());
    onView(ErrorMatcher.withError(Matchers.
            containsString("The field is required"))).check(matches(isDisplayed()));

}



Source