问:
How can I start my MainActivity after Facebook Login to Android app?
I am trying to integrate Facebook login to my app through Firebase. When the user clicks on "Continue with Facebook" button, I see a blue progress bar and then the text on the button changes to "logout". I intent to open another Activity when the Login succeeds. I have used startActivity() method for that. However, nothing happens. Please help!

Below is the extract of onCreate() method of my Login Activity

```<code>     callbackManager = CallbackManager.Factory.create();
    // Register your callback
    LoginManager.getInstance().registerCallback(callbackManager,
            // If the login attempt is successful, then call onSuccess and pass the LoginResult
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {

                    // The HomeScreen.class should load, it is not happening.
                    startActivity(new Intent(getApplicationContext() ,HomeScreen.class));
                    // I get this Log on my screen, which is proof that this loop is executed
                    Log.w("TAG", "User ID: " +
                            loginResult.getAccessToken().getUserId() + "\n" +
                            "Auth Token: " + loginResult.getAccessToken().getToken());
                }
                // If the user cancels the login, then call onCancel
                @Override
                public void onCancel() {
                    Toast.makeText(getApplicationContext(),
                            "Canceled login through Facebook",Toast.LENGTH_LONG).show();
                }
                // If an error occurs, then call onError
                @Override
                public void onError(FacebookException exception) {
                    Toast.makeText(getApplicationContext(),
                            " Facebook Login failed!",Toast.LENGTH_LONG).show();
                    Log.w("FB failed", exception);
                }
            });
</code>```

I am allowing for Google login also through Firebase, for this I have written the onActivityResult method. It is this -

```<code>    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);

        } else {
            // Handle failed signin here
           Toast.makeText(getApplicationContext(),
                   "Google Sign In Failed, Please try with Facebook or Email!", Toast.LENGTH_LONG).show();
        }
    }
    callbackManager.onActivityResult(requestCode, resultCode, data);

}
</code>```

答:
try this :</p>

```<code> public void onSuccess(LoginResult loginResult) {

            Intent intent = new Intent(loginActivity.this,HomeScreen.class);
            startActivity(intent);

            }
</code>```

Body:
I am trying to integrate Facebook login to my app through Firebase. When the user clicks on "Continue with Facebook" button, I see a blue progress bar and then the text on the button changes to "logout". I intent to open another Activity when the Login succeeds. I have used startActivity() method for that. However, nothing happens. Please help!

Below is the extract of onCreate() method of my Login Activity

     callbackManager = CallbackManager.Factory.create();
    // Register your callback
    LoginManager.getInstance().registerCallback(callbackManager,
            // If the login attempt is successful, then call onSuccess and pass the LoginResult
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {

                    // The HomeScreen.class should load, it is not happening.
                    startActivity(new Intent(getApplicationContext() ,HomeScreen.class));
                    // I get this Log on my screen, which is proof that this loop is executed
                    Log.w("TAG", "User ID: " +
                            loginResult.getAccessToken().getUserId() + "\n" +
                            "Auth Token: " + loginResult.getAccessToken().getToken());
                }
                // If the user cancels the login, then call onCancel
                @Override
                public void onCancel() {
                    Toast.makeText(getApplicationContext(),
                            "Canceled login through Facebook",Toast.LENGTH_LONG).show();
                }
                // If an error occurs, then call onError
                @Override
                public void onError(FacebookException exception) {
                    Toast.makeText(getApplicationContext(),
                            " Facebook Login failed!",Toast.LENGTH_LONG).show();
                    Log.w("FB failed", exception);
                }
            });

I am allowing for Google login also through Firebase, for this I have written the onActivityResult method. It is this -

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);

        } else {
            // Handle failed signin here
           Toast.makeText(getApplicationContext(),
                   "Google Sign In Failed, Please try with Facebook or Email!", Toast.LENGTH_LONG).show();
        }
    }
    callbackManager.onActivityResult(requestCode, resultCode, data);

}

Body:
try this :

 public void onSuccess(LoginResult loginResult) {

            Intent intent = new Intent(loginActivity.this,HomeScreen.class);
            startActivity(intent);

            }


来源: stackexchange

问:
Having issues with if, else statements python
I am learning python and was doing an exercise for myself and I get a few problems.

If I type "yes" will that return invalid answer since it's looking for "Yes"?

Also, I feel like I am doing something wrong with my if statement even if I type "Yes" Correctly I still get "Invalid Answer" Printed.

Any thoughts on how I can improve?

```<code>attribute = {
    "G": "Greatest",
    "O": "Of",
    "A": "All",
    "T": "Time"
    }

answer = str(raw_input("Will You Make Me Food?:"))

for answer in range(2):
    if answer == "Yes":
        print attribute
    elif answer == "No":
        print "Your the Worst"
    else:
        print "Invalid Answer"
</code>```

答:
When dealing with user input. It's always a best to strip out extra white space. And when doing string comparisons to always bring things to lower or upper case. So start with

```<code>answer = raw_input("Will You Make Me Food?:").strip().lower()
</code>```

Then

```<code>if answer == "yes":
    print attribute
elif answer == "no":
    print "Your the Worst"
else:
    print "Invalid Answer"
</code>```

having done that, examine your for loop. You are executing the above code twice. for answer in range(2): but you are gathering input only once. Did yoyu perhaps mean

```<code>for answer in range(2):
    answer = raw_input("Will You Make Me Food?:").strip().lower()

    if answer == "yes":
        print attribute
    elif answer == "no":
        print "Your the Worst"
    else:
        print "Invalid Answer"
</code>```

Addendum:
Regarding your problem about printing attribute in order. This is a dictionary, so it will not be saved in the same order that you define it. For that you can use tuples instead

```<code>attribute = [(    "G", "Greatest"),("O": "Of"), ... )
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am learning python and was doing an exercise for myself and I get a few problems.

If I type "yes" will that return invalid answer since it's looking for "Yes"?

Also, I feel like I am doing something wrong with my if statement even if I type "Yes" Correctly I still get "Invalid Answer" Printed.

Any thoughts on how I can improve?

attribute = {
    "G": "Greatest",
    "O": "Of",
    "A": "All",
    "T": "Time"
    }

answer = str(raw_input("Will You Make Me Food?:"))

for answer in range(2):
    if answer == "Yes":
        print attribute
    elif answer == "No":
        print "Your the Worst"
    else:
        print "Invalid Answer"

Body:
When dealing with user input. It's always a best to strip out extra white space. And when doing string comparisons to always bring things to lower or upper case. So start with

answer = raw_input("Will You Make Me Food?:").strip().lower()

Then

if answer == "yes":
    print attribute
elif answer == "no":
    print "Your the Worst"
else:
    print "Invalid Answer"

having done that, examine your for loop. You are executing the above code twice. for answer in range(2): but you are gathering input only once. Did yoyu perhaps mean

for answer in range(2):
    answer = raw_input("Will You Make Me Food?:").strip().lower()

    if answer == "yes":
        print attribute
    elif answer == "no":
        print "Your the Worst"
    else:
        print "Invalid Answer"

Addendum:
Regarding your problem about printing attribute in order. This is a dictionary, so it will not be saved in the same order that you define it. For that you can use tuples instead

attribute = [(    "G", "Greatest"),("O": "Of"), ... )


问:
What is the relationship between PyTorch and Torch?
There are two PyTorch repositories :

https://github.com/hughperkins/pytorch

https://github.com/pytorch/pytorch

The first clearly requires Torch and lua and is a wrapper, but the second doesn't make any reference to the Torch project except with its name.

How is it related to the Lua Torch?

答:
Here a short comparison on pytorch and torch.

Torch:

A Tensor library like numpy, unlike numpy it has strong GPU support.

Lua is a wrapper for Torch (Yes! you need to have a good understanding of Lua), and for that you will need LuaRocks package manager.

PyTorch:

No need for the LuaRocks package manager, no need to write code in Lua. And because we are using Python, we can develop Deep Learning models with utmost flexibility. We can also exploit major Python packages likes scipy, numpy, matplotlib and Cython with PyTorch's own autograd.

There is a detailed discussion on this on pytorch forum. Adding to that both PyTorch and Torch use THNN. Torch provides lua wrappers to the THNN library while Pytorch provides Python wrappers for the same.

PyTorch's recurrent nets, weight sharing and memory usage with the flexibility of interfacing with C, and the current speed of Torch.

For more insights, have a look at this discussion session here.

ContentLicense: CC BY-SA 4.0


问:
Find Textbox control
In my application i have 50 textboxes i want find all the textbox control using the code and i want to perform a color change in the textbox after doing certain validations. How can i acheive that? i used the following code but it doesnt work properly

```<code>foreach (Control cntrl in Page.Controls)
    {
        if (cntrl is TextBox)
        {
            //Do the operation
        }
    }
</code>```

<%@ Page Language="C#" MasterPageFile="~/HomePageMaster.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="Default" Title="Sample Page" %>

答:
```<code>protected void setColor(Control Ctl)
{
    foreach (Control cntrl in Ctl.Controls)
    {
         if (cntrl.GetType().Name == "TextBox")
         {
              //Do Code
         }
         setColor(Control cntrl);
    }
}
</code>```

You can then call this with setColor(Page)

ContentLicense: CC BY-SA 2.5

Title: Find Textbox control

Body:
In my application i have 50 textboxes i want find all the textbox control using the code and i want to perform a color change in the textbox after doing certain validations. How can i acheive that? i used the following code but it doesnt work properly

foreach (Control cntrl in Page.Controls)
    {
        if (cntrl is TextBox)
        {
            //Do the operation
        }
    }

<%@ Page Language="C#" MasterPageFile="~/HomePageMaster.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="Default" Title="Sample Page" %>

Body:
protected void setColor(Control Ctl)
{
    foreach (Control cntrl in Ctl.Controls)
    {
         if (cntrl.GetType().Name == "TextBox")
         {
              //Do Code
         }
         setColor(Control cntrl);
    }
}

You can then call this with setColor(Page)


问:
How to find elements in array that contain a given substring?
I have 3 strings, I would like to get only the equal strings of them, something like this:

```<code>$Var1 = "Sant";
$Array[] = "Hello Santa Claus";   // Name_1
$Array[] = "Santa Claus";         // Name_2
</code>```

I would like to get both of them because they match "Sant".

With my code I only get Name_2

```<code>$len = strlen($Var1);
foreach($Array as $name)
{
   if (  stristr($Var1, substr($name, 0, $len)))
   {
     echo $name;
   }
}
</code>```

I understand why I only get Name_2, but I don't know how to solve this situation.

答:
You should do it like this. You can use stristr but you have to flip arguments because you are passing wrong arguments. First argument should be haystack and second should be needle.

Try this code snippet here

```<code>ini_set('display_errors', 1);

$Var1 = "Sant";
$Array[] = "Hello Santa Claus";   // Name_1
$Array[] = "Santa Claus";         // Name_2

foreach ($Array as $name)
{
    if (stristr($name,$Var1)!==false)
    {
        echo $name;
        echo PHP_EOL;
    }
}
</code>```

Body:
I have 3 strings, I would like to get only the equal strings of them, something like this:

$Var1 = "Sant";
$Array[] = "Hello Santa Claus";   // Name_1
$Array[] = "Santa Claus";         // Name_2

I would like to get both of them because they match "Sant".

With my code I only get Name_2

$len = strlen($Var1);
foreach($Array as $name)
{
   if (  stristr($Var1, substr($name, 0, $len)))
   {
     echo $name;
   }
}

I understand why I only get Name_2, but I don't know how to solve this situation.

Body:
You should do it like this. You can use stristr but you have to flip arguments because you are passing wrong arguments. First argument should be haystack and second should be needle.

Try this code snippet here

ini_set('display_errors', 1);

$Var1 = "Sant";
$Array[] = "Hello Santa Claus";   // Name_1
$Array[] = "Santa Claus";         // Name_2

foreach ($Array as $name)
{
    if (stristr($name,$Var1)!==false)
    {
        echo $name;
        echo PHP_EOL;
    }
}


问:
Left outer join with 3 tables and subquery
sorry for the late response.

For a key in table A, there may be 2 or more records present in tables B and C. That is, one another column in these tables will have a date value which would be making the keys unique. So I want to extract the record that has maximum date value. And that's why I am using the max function. I know that the subquery which I have coded should not be included in the ON clause and it would do the filtering before the join statement. So eventually I want to know how to mention the max clause in the query.

Example:
Table A
Key - AAAAA

Table B:
Record 1
Key - AAAAA
Date - 2017-10-01

Record 2
Key - AAAAA
Date - 2017-10-05

I want the only the record AAAAA/2017-10-05 to be selected from the table B

Basically records from table A where A.c3 = 'Y' should be extracted first (assume it gives 500 records)
Then join these 500 records with tables B and C (left outer, to have all the matching records and the non-matching records should have nulls in the columns from the tables B and C)
In tables B and C, if more than 1 record present with different dates, the maximum date field should be extracted.

Hence final output should contain 500 records.

答:
Just do it?</p>

```<code>SELECT A.A1, A.A2, B.B1, B.B2, C.C1, C.C2
FROM TABLE1 A
LEFT OUTER JOIN TABLE2 B
ON A.A1 = B.B1
LEFT OUTER JOIN TABLE3 C
ON A.A1 = C.C1
WHERE A.C3 = 'Y' and (B.B1 is null or C.B1 is null)
</code>```

Body:
Just do it?

SELECT A.A1, A.A2, B.B1, B.B2, C.C1, C.C2
FROM TABLE1 A
LEFT OUTER JOIN TABLE2 B
ON A.A1 = B.B1
LEFT OUTER JOIN TABLE3 C
ON A.A1 = C.C1
WHERE A.C3 = 'Y' and (B.B1 is null or C.B1 is null)


问:
How to display a toast message by clicking on a homescreen widget in android studio?
please tell me what i'm doing wrong

```<code>NewAppWidget.java class

package com.example.kinjolnath.alert;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;

/**
 * Implementation of App Widget functionality.
 */

public class NewAppWidget extends AppWidgetProvider {
    private static final String TAG = NewAppWidget.class.getSimpleName();

void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {
    Log.d(TAG, "Inside updateAppWidget");
    Log.i(TAG, "Inside updateAppWidget");
    Log.e(TAG, "Inside updateAppWidget");

//        Toast.makeText(context,
//                "Should appear at widget click", Toast.LENGTH_SHORT).show();

    // Construct the RemoteViews object
    Intent intent = new Intent(context, MapsActivity.class);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            intent,PendingIntent.FLAG_UPDATE_CURRENT);

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);

    views.setOnClickPendingIntent(R.id.imageButton, pendingIntent);
    Intent sendingIntent = new Intent(context, SendingService.class);
    sendingIntent.setAction(SendingService.ACTION_SEND_MESSAGE);
    PendingIntent sendingPendingIntent = PendingIntent.getService(context, 0, sendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    views.setOnClickPendingIntent(R.id.imageButton, sendingPendingIntent);
    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // There may be multiple widgets active, so update all of them
    Log.d(TAG, "Inside onUpdate");
    Log.i(TAG, "Inside onUpdate");
    Log.e(TAG, "Inside onUpdate");
    SendingService.startActionSendMessage(context);
    for (int appWidgetId : appWidgetIds) {
        updateAppWidget(context, appWidgetManager, appWidgetId);
    }
}

@Override
public void onEnabled(Context context) {
    // Enter relevant functionality for when the first widget is created
    Log.d(TAG, "Inside onEnabled");
    Log.i(TAG, "Inside onEnabled");
    Log.e(TAG, "Inside onEnabled");
}

@Override
public void onDisabled(Context context) {
    // Enter relevant functionality for when the last widget is disabled
    Log.d(TAG, "Inside onDisabled");
    Log.i(TAG, "Inside onDisabled");
    Log.e(TAG, "Inside onDisabled");
    }
}
</code>```

SendingService.java class

```<code>package com.example.kinjolnath.alert;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.Toast;

/**
 * Created by kinjolnath on 01-06-2017.
 */

public class SendingService extends IntentService{
    private static final String TAG = NewAppWidget.class.getSimpleName();
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
 * @param name Used to name the worker thread, important only for debugging.
 */
public static final String ACTION_SEND_MESSAGE = "com.example.MapsActivity.action.send_message";

public SendingService(String name) {
    super(name);
}

public static void startActionSendMessage(Context context){
    Intent intent = new Intent(context, SendingService.class);
    intent.setAction(ACTION_SEND_MESSAGE);
    context.startService(intent);
    Log.d(TAG, "Inside startActionSendMessage");
    Log.i(TAG, "Inside startActionSendMessage");
    Log.e(TAG, "Inside startActionSendMessage");
}

@Override
protected void onHandleIntent(@Nullable Intent intent) {
    if (intent != null){
        final String action = intent.getAction();
        Log.d(TAG, action + "inside onHandleIntent");
        if(ACTION_SEND_MESSAGE.equals(action)){
            handleActionSend();
        }
    }
}
//handleActionSend method:
private void handleActionSend() {
    Toast.makeText(this, "Message sent", Toast.LENGTH_SHORT).show();
    Log.d(TAG, "Inside handleActionSend");
    Log.i(TAG, "Inside handleActionSend");
    Log.e(TAG, "Inside handleActionSend");
    }
}
</code>```

I followed a tutorial from Udacity and ended up at this stage but it still doesn't work
I am new to android development so any help would be appreciated.

答:
You can not show Toast on Clicking of WidGet because the widget extends AppWidgetProvider so that class not able to call current Context

If you want to show Toast when create widget or select widget is possible by using bellow code:

```<code>Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(context,"hiii dhruv", Toast.LENGTH_LONG).show();
            }
        });
</code>```

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

How to user above code in your widget class

```<code>@Override
    public void onUpdate(final Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        super.onUpdate(context, appWidgetManager, appWidgetIds);
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(context,"hiii dhruv", Toast.LENGTH_LONG).show();
            }
        });

    }
</code>```

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

or

```<code> @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);
        Toast.makeText(context, "hiiiiiiiiiiii", Toast.LENGTH_SHORT).show();
    }
</code>```

Body:
please tell me what i'm doing wrong

NewAppWidget.java class

package com.example.kinjolnath.alert;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;

/**
 * Implementation of App Widget functionality.
 */

public class NewAppWidget extends AppWidgetProvider {
    private static final String TAG = NewAppWidget.class.getSimpleName();

void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {
    Log.d(TAG, "Inside updateAppWidget");
    Log.i(TAG, "Inside updateAppWidget");
    Log.e(TAG, "Inside updateAppWidget");

//        Toast.makeText(context,
//                "Should appear at widget click", Toast.LENGTH_SHORT).show();

    // Construct the RemoteViews object
    Intent intent = new Intent(context, MapsActivity.class);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            intent,PendingIntent.FLAG_UPDATE_CURRENT);

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);

    views.setOnClickPendingIntent(R.id.imageButton, pendingIntent);
    Intent sendingIntent = new Intent(context, SendingService.class);
    sendingIntent.setAction(SendingService.ACTION_SEND_MESSAGE);
    PendingIntent sendingPendingIntent = PendingIntent.getService(context, 0, sendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    views.setOnClickPendingIntent(R.id.imageButton, sendingPendingIntent);
    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // There may be multiple widgets active, so update all of them
    Log.d(TAG, "Inside onUpdate");
    Log.i(TAG, "Inside onUpdate");
    Log.e(TAG, "Inside onUpdate");
    SendingService.startActionSendMessage(context);
    for (int appWidgetId : appWidgetIds) {
        updateAppWidget(context, appWidgetManager, appWidgetId);
    }
}

@Override
public void onEnabled(Context context) {
    // Enter relevant functionality for when the first widget is created
    Log.d(TAG, "Inside onEnabled");
    Log.i(TAG, "Inside onEnabled");
    Log.e(TAG, "Inside onEnabled");
}

@Override
public void onDisabled(Context context) {
    // Enter relevant functionality for when the last widget is disabled
    Log.d(TAG, "Inside onDisabled");
    Log.i(TAG, "Inside onDisabled");
    Log.e(TAG, "Inside onDisabled");
    }
}

SendingService.java class

package com.example.kinjolnath.alert;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.Toast;

/**
 * Created by kinjolnath on 01-06-2017.
 */

public class SendingService extends IntentService{
    private static final String TAG = NewAppWidget.class.getSimpleName();
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
 * @param name Used to name the worker thread, important only for debugging.
 */
public static final String ACTION_SEND_MESSAGE = "com.example.MapsActivity.action.send_message";

public SendingService(String name) {
    super(name);
}

public static void startActionSendMessage(Context context){
    Intent intent = new Intent(context, SendingService.class);
    intent.setAction(ACTION_SEND_MESSAGE);
    context.startService(intent);
    Log.d(TAG, "Inside startActionSendMessage");
    Log.i(TAG, "Inside startActionSendMessage");
    Log.e(TAG, "Inside startActionSendMessage");
}

@Override
protected void onHandleIntent(@Nullable Intent intent) {
    if (intent != null){
        final String action = intent.getAction();
        Log.d(TAG, action + "inside onHandleIntent");
        if(ACTION_SEND_MESSAGE.equals(action)){
            handleActionSend();
        }
    }
}
//handleActionSend method:
private void handleActionSend() {
    Toast.makeText(this, "Message sent", Toast.LENGTH_SHORT).show();
    Log.d(TAG, "Inside handleActionSend");
    Log.i(TAG, "Inside handleActionSend");
    Log.e(TAG, "Inside handleActionSend");
    }
}

I followed a tutorial from Udacity and ended up at this stage but it still doesn't work
I am new to android development so any help would be appreciated.

Body:
You can not show Toast on Clicking of WidGet because the widget extends AppWidgetProvider so that class not able to call current Context

If you want to show Toast when create widget or select widget is possible by using bellow code:

Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(context,"hiii dhruv", Toast.LENGTH_LONG).show();
            }
        });

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

How to user above code in your widget class

@Override
    public void onUpdate(final Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        super.onUpdate(context, appWidgetManager, appWidgetIds);
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(context,"hiii dhruv", Toast.LENGTH_LONG).show();
            }
        });

    }

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

or

 @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);
        Toast.makeText(context, "hiiiiiiiiiiii", Toast.LENGTH_SHORT).show();
    }


问:
Informatica & Git: Version Control
I'm relatively new to Informatica but from what I've been told it seems like Informatica doesn't play nice with third party version control systems like Git because of Informatica's proprietary XML file structure. Unfortunately the default Informatica VCS is not an option for me due to my requirements. Is there a way that I can version control my file system by supporting classic Git operations on other files of mine (e.g. shell scripts), but only allow complete overrides on Informatica XML files?</p>

答:
Except the way Lasse mentioned to use .gitattributes, You can also specify the merge stratgeies for certain files (xml files).

Assume you want to preserve the version not to replaced during merge, you can set as below:

In .gitattribute, add the content filename merge=ours.

Define ours merge strategy by git config --global merge.ours.driver true.

Now when you do a merge, git will keep the filename as current version.

More details, you can refer last part (Merge Strategies) in this article.

Title: Informatica & Git: Version Control


问:
Link within label in Swift
I would like to do that in my app :

The label is like : username comment

I don't know how to add the "button" within the label; I found this library but I'm not sure it will work? https://github.com/optonaut/ActiveLabel.swift

Maybe use it by creating a regex for the first word? What do you think?

答:
Use Active-Label https://github.com/optonaut/ActiveLabel.swift
Make a UILabel named label

```<code> let customType = ActiveType.custom(pattern: "\\sjohncena\\b")
 label.enabledTypes.append(customType3)
 label.handleCustomTap(for: customType) { self.alert("Custom type", message: $0) }

 func alert(_ title: String, message: String) {
        let vc = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
        vc.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
        present(vc, animated: true, completion: nil)
    }
</code>```

where johncena is string which is clickable.
see https://github.com/optonaut/ActiveLabel.swift/blob/master/ActiveLabelDemo/ViewController.swift

Title: Link within label in Swift

Body:
Use Active-Label https://github.com/optonaut/ActiveLabel.swift
Make a UILabel named label

 let customType = ActiveType.custom(pattern: "\\sjohncena\\b")
 label.enabledTypes.append(customType3)
 label.handleCustomTap(for: customType) { self.alert("Custom type", message: $0) }

 func alert(_ title: String, message: String) {
        let vc = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
        vc.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
        present(vc, animated: true, completion: nil)
    }

where johncena is string which is clickable.
see https://github.com/optonaut/ActiveLabel.swift/blob/master/ActiveLabelDemo/ViewController.swift


问:
Access .laccdb file not clean until last user logs out
I have an Access data base (.accdb) on the local network server that is used by multiple users, via the local network OR by using Remote Desktop via VPN to a terminal services computer connected to the www and the local network.

three issues:

1: The .laccdb file contains the users (local and remote) even after they log out until the file is deleted when the last user logs out.  Access doesn't seem to clean up after itself regardless of the mode of connection.  Are there any options, settings or anything I can add to the db to cleanup the .laccdb file?

The remote users are not listed by login id or computername or username in the .laccdb file, just by terminal-services-computer-name and "Admin".
I'd like to know which remote user(s) are actively logged in.

Rarely, the last user logs out but the .laccdb file is not deleted.  Restarting that user's computer seems to be the easiest fix but it can take some time to get that done.  Meanwhile there are some database operations that can't be done without exclusive access.

答:
This is normal behavior of the .laccdb file.

It contains the machine names of those connected to the database in the form "Machine Name Admin" and it's only adding connected machines to the list, not deleting. Therefore if you have 50 users connected at some stage but only one remains active, the .laccdb file will still list 50 machine names. You cannot change that.

You cannot also change the machine name to the user login id. If you want that, you'll have to handle it manually through VBA.

As for the file not getting deleted as soon as the last user exits, this seems to be a network issue.


问:
Unknown column 'submittedby' in 'field list'
I am pretty new to PHP and MySQL and I just can't figure this one out. I
have searched all around the forum but haven't found an answer I can make sense of.

I get the following error: Unknown column 'submittedby' in 'field list', the problem is with this line of the code -

```<code>$update="update users set enrol_Date='".$enrol_Date."', username='".$username."', firstname='".$firstname."', lastname='".$lastname."', identificationCard='".$identificationCard."', email='".$email."',contact='".$contact."', submittedby='".$submittedby."' where id='".$id."'";
</code>```

The whole code is:

```<code><?php
  require('db.php');
  include("auth.php");
  $id=$_REQUEST['id'];
  $query = "SELECT * from users where id='".$id."'";
  $result = mysqli_query($con, $query) or die ( mysqli_error());
  $row = mysqli_fetch_assoc($result);
?>

<?php
  $status = "";
  if(isset($_POST['new']) && $_POST['new']==1)
  {
    $id=$_REQUEST['id'];
    $enrol_Date = date("Y-m-d H:i:s");
    $username =$_REQUEST['username'];
    $firstname =$_REQUEST['firstname'];
    $lastname =$_REQUEST['lastname'];
    $identificationCard =$_REQUEST['identificationCard'];
    $email =$_REQUEST['email'];
    $contact =$_REQUEST['contact'];
    $submittedby = $_SESSION["username"];
    $update="update users set enrol_Date='".$enrol_Date."', username='".$username."', firstname='".$firstname."', lastname='".$lastname."', identificationCard='".$identificationCard."', email='".$email."',contact='".$contact."', submittedby='".$submittedby."' where id='".$id."'";
    mysqli_query($con, $update) or die(mysqli_error($con));
    $status = "Profile Updated Successfully. </br></br>
    <a href='view.php'>View Updated Record</a>";
    echo '<p style="color:#FF0000;">'.$status.'</p>';
  }else {
?>
</code>```

Here is my form code:

```<code><form name="form" method="post" action="">
  <input type="hidden" name="new" value="1" />
  <input name="id" type="hidden" value="<?php echo $row['id'];?>" />
  <label for="username"> Username : </label>
  <p><input type="text" name="username" placeholder="Username"
  required value="<?php echo $row['username'];?>" /></p>
  <label for="firstname"> Firstname : </label>
  <p><input type="text" name="firstname" placeholder="Firstname"
  required value="<?php echo $row['firstname'];?>" /></p>
  <label for="lastname"> Lastname : </label>
  <p><input type="text" name="lastname" placeholder="Lastname"
  required value="<?php echo $row['lastname'];?>" /></p>
  <label for="i/cno"> I/C No : </label>
  <p><input type="text" name="identificationCard" placeholder="I/C"
  required value="<?php echo $row['identificationCard'];?>" /></p>
  <label for="email"> Email : </label>
  <p><input type="text" name="email" placeholder="Email"
  required value="<?php echo $row['email'];?>" /></p>
  <label for="contact"> Contact : </label>
  <p><input type="text" name="contact" placeholder="Contact"
  required value="<?php echo $row['contact'];?>" /></p>
  <p><input name="submit" type="submit" value="Submit" /></p>
</form>
</code>```

Thanks.

答: check "submittedby" field exist in your users table or not

Body:
I am pretty new to PHP and MySQL and I just can't figure this one out. I
have searched all around the forum but haven't found an answer I can make sense of.

I get the following error: Unknown column 'submittedby' in 'field list', the problem is with this line of the code -

$update="update users set enrol_Date='".$enrol_Date."', username='".$username."', firstname='".$firstname."', lastname='".$lastname."', identificationCard='".$identificationCard."', email='".$email."',contact='".$contact."', submittedby='".$submittedby."' where id='".$id."'";

The whole code is:

<?php
  require('db.php');
  include("auth.php");
  $id=$_REQUEST['id'];
  $query = "SELECT * from users where id='".$id."'";
  $result = mysqli_query($con, $query) or die ( mysqli_error());
  $row = mysqli_fetch_assoc($result);
?>

<?php
  $status = "";
  if(isset($_POST['new']) && $_POST['new']==1)
  {
    $id=$_REQUEST['id'];
    $enrol_Date = date("Y-m-d H:i:s");
    $username =$_REQUEST['username'];
    $firstname =$_REQUEST['firstname'];
    $lastname =$_REQUEST['lastname'];
    $identificationCard =$_REQUEST['identificationCard'];
    $email =$_REQUEST['email'];
    $contact =$_REQUEST['contact'];
    $submittedby = $_SESSION["username"];
    $update="update users set enrol_Date='".$enrol_Date."', username='".$username."', firstname='".$firstname."', lastname='".$lastname."', identificationCard='".$identificationCard."', email='".$email."',contact='".$contact."', submittedby='".$submittedby."' where id='".$id."'";
    mysqli_query($con, $update) or die(mysqli_error($con));
    $status = "Profile Updated Successfully.

    View Updated Record";
    echo '
'.$status.'
';
  }else {
?>

Here is my form code:

<form name="form" method="post" action="">
  <input type="hidden" name="new" value="1" />
  <input name="id" type="hidden" value="<?php echo $row['id'];?>" />
   Username :

<input type="text" name="username" placeholder="Username"
  required value="<?php echo $row['username'];?>" />

   Firstname :

<input type="text" name="firstname" placeholder="Firstname"
  required value="<?php echo $row['firstname'];?>" />

   Lastname :

<input type="text" name="lastname" placeholder="Lastname"
  required value="<?php echo $row['lastname'];?>" />

   I/C No :

<input type="text" name="identificationCard" placeholder="I/C"
  required value="<?php echo $row['identificationCard'];?>" />

   Email :

<input type="text" name="email" placeholder="Email"
  required value="<?php echo $row['email'];?>" />

   Contact :

<input type="text" name="contact" placeholder="Contact"
  required value="<?php echo $row['contact'];?>" />

<input name="submit" type="submit" value="Submit" />

</form>

Thanks.


问:
How do I mount a remote Linux folder in Windows through SSH?
I'm a blind student currently in a system admin/shell programming class. Although ssh works fine for executing commands like ls, pwd, etc editors do not work well with my screen reader and an ssh session. I was wondering if it is possible to mount a Linux folder over ssh so it appears as a windows drive? This way I could edit any files I needed to with accessible software and not have to constantly use SCP to send files back and fourth.</p>

答: Apparently the free NetDrive software from Novell can access SFTP file servers.</p>

OwnerDisplayName: Jared

LastEditorDisplayName: Michael Haren

OwnerDisplayName: Alnitak


问:
TensorFlow: use tensor as list argument in graph
I would like to use a tf.Tensor as an argument of type (python) list for another operation in a TensorFlow graph.
In other words, I would like to use a Tensor as dynamic list argument for another operation. Is this possible?

Executable example:

```<code>import tensorflow as tf
import numpy as np

graph = tf.Graph()
var1 = np.random.randn(2, 3)
var2 = np.random.randn(2, 3, 4)

with graph.as_default():
    def getRange(myTensor):
        myRank = tf.rank(myTensor)
        return tf.range(tf.constant(1), tf.squeeze(myRank))

    def getMoments(myTensor):
        myMoments = tf.nn.moments(myTensor, axes=getRange(myTensor))
        return myMoments
    var1tf = tf.Variable(var1)
    var2tf = tf.Variable(var2)
    var1moments = getMoments(var1tf)
    var2moments = getMoments(var2tf)
    rangeVar1 = getRange(var1tf)
    rangeVar2 = getRange(var2tf)
    init = tf.global_variables_initializer()

with tf.Session(graph=graph) as sess:
    sess.run([init])
    print(sess.run([rangeVar1])) # outputs [1], ok
    print(sess.run([rangeVar2])) # outputs [1, 2], ok
    print(sess.run([var1moments]))
    print(sess.run([var2moments]))
</code>```

This throws:

```<code>raise TypeError("'Tensor' object is not iterable.")
</code>```

答:
I found a solution using get_shape():</p>

```<code>def getMoments(myTensor):
    myRank = len(myTensor.get_shape().as_list())
    print('rank via shape:', myRank)
    myMoments = tf.nn.moments(myTensor, axes=list(range(1, myRank)))
    return myMoments
</code>```

Body:
I would like to use a tf.Tensor as an argument of type (python) list for another operation in a TensorFlow graph.
In other words, I would like to use a Tensor as dynamic list argument for another operation. Is this possible?

Executable example:

import tensorflow as tf
import numpy as np

graph = tf.Graph()
var1 = np.random.randn(2, 3)
var2 = np.random.randn(2, 3, 4)

with graph.as_default():
    def getRange(myTensor):
        myRank = tf.rank(myTensor)
        return tf.range(tf.constant(1), tf.squeeze(myRank))

    def getMoments(myTensor):
        myMoments = tf.nn.moments(myTensor, axes=getRange(myTensor))
        return myMoments
    var1tf = tf.Variable(var1)
    var2tf = tf.Variable(var2)
    var1moments = getMoments(var1tf)
    var2moments = getMoments(var2tf)
    rangeVar1 = getRange(var1tf)
    rangeVar2 = getRange(var2tf)
    init = tf.global_variables_initializer()

with tf.Session(graph=graph) as sess:
    sess.run([init])
    print(sess.run([rangeVar1])) # outputs [1], ok
    print(sess.run([rangeVar2])) # outputs [1, 2], ok
    print(sess.run([var1moments]))
    print(sess.run([var2moments]))

This throws:

raise TypeError("'Tensor' object is not iterable.")

Body:
I found a solution using get_shape():

def getMoments(myTensor):
    myRank = len(myTensor.get_shape().as_list())
    print('rank via shape:', myRank)
    myMoments = tf.nn.moments(myTensor, axes=list(range(1, myRank)))
    return myMoments


问:
Position animated icons and remove overlapping using CSS
I am trying to position the icons to the right and the tags to the center.
My website is using BootStrap and Font-Awesome. Below is the HTML:

```<code><div class="row">
  <div class="col-lg-12" style="text-align: center">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>
    <span> </span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>
    <span> </span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>
    <span> </span>
    <i class="fa fa-heart faa-pulse animated" style="float:right;"></i>
    <i class="fa fa-star faa-pulse animated" style="float:right;"></i>
    <i class="fa fa-smile-o faa-pulse animated" style="float:right;"></i>
  </div>
</div>
<div class="row">
  <div class="col-lg-12">
    <h1 class="post-header" style="text-align: center">This is the header</h1>
  </div>
</div>
</code>```

CSS:

```<code>@keyframes pulse {
  0% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }

  50% {
    -webkit-transform: scale(0.8);
    -ms-transform: scale(0.8);
    transform: scale(0.8);
  }

  100% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }
}

.faa-pulse.animated,
.faa-pulse.animated-hover:hover,
.faa-parent.animated-hover:hover > .faa-pulse {
  -webkit-animation: pulse 2s linear infinite !important;
  animation: pulse 2s linear infinite !important;
  font-size:1.8em;
}
.fa-heart {
    color: red !important;
}
.fa-star {
    color: gold !important;
}
.fa-smile-o {
  color: deeppink !important;
}
</code>```

The problem is my icons are overlapping with each other during animation and the tags are not aligned to the center. Also,there is very little space between the icons. How can I solve this problem?

Here is the demo

答:
Try this:

Re-formated HTML:

```<code><div class="row">
  <div class="col-lg-12 text-center">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>

    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>

    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>
    <span class="animated-icons">
    <i class="fa fa-heart faa-pulse animated"></i>
    <i class="fa fa-star faa-pulse animated" ></i>
    <i class="fa fa-smile-o faa-pulse animated" ></i>
    </span>

  </div>
</div>
</code>```

CSS:

```<code>.animated-icons {
  position: absolute;
  right: 15px;
}
</code>```

Body:
I am trying to position the icons to the right and the tags to the center.
My website is using BootStrap and Font-Awesome. Below is the HTML:

      Health

      Fitness

      Safety

This is the header

CSS:

@keyframes pulse {
  0% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }

  50% {
    -webkit-transform: scale(0.8);
    -ms-transform: scale(0.8);
    transform: scale(0.8);
  }

  100% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }
}

.faa-pulse.animated,
.faa-pulse.animated-hover:hover,
.faa-parent.animated-hover:hover > .faa-pulse {
  -webkit-animation: pulse 2s linear infinite !important;
  animation: pulse 2s linear infinite !important;
  font-size:1.8em;
}
.fa-heart {
    color: red !important;
}
.fa-star {
    color: gold !important;
}
.fa-smile-o {
  color: deeppink !important;
}

The problem is my icons are overlapping with each other during animation and the tags are not aligned to the center. Also,there is very little space between the icons. How can I solve this problem?

Here is the demo

Body:
Try this:

Re-formated HTML:

<div class="row">
  <div class="col-lg-12 text-center">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>

    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>

    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>
    <span class="animated-icons">
    <i class="fa fa-heart faa-pulse animated"></i>
    <i class="fa fa-star faa-pulse animated" ></i>
    <i class="fa fa-smile-o faa-pulse animated" ></i>
    </span>

  </div>
</div>

CSS:

.animated-icons {
  position: absolute;
  right: 15px;
}


问:
Retrieving variables from a text file through a hashmap
I am creating a school program for a project in which I a writing words and translations to a file, (separated by a character). I have read that I can read them via a hash map into an array. I was just wondering if someone could point me in the right direction as how to do this.

If anyone has a better idea of how to store and retrieve the words I would love to learn. The reason I am writing to a file is so the user can store as many words as they want.

Thank-you so much :D

答:
You can try something like this</p>

```<code>    File f = new File("/Desktop/Codes/Text.txt");
    // enter your file location
    HashMap<String, String[]> hs = new HashMap<String, String[]>();
    // throw exception in main method
    Scanner sc = new Scanner(f);
    String s="";
    while(sc.hasNext()){
       s = sc.next();
       // create a method to search translation
       String []trans = searchTrans(s);
       hs.put(s, trans);

    }
</code>```

Body:
You can try something like this

    File f = new File("/Desktop/Codes/Text.txt");
    // enter your file location
    HashMap<String, String[]> hs = new HashMap<String, String[]>();
    // throw exception in main method
    Scanner sc = new Scanner(f);
    String s="";
    while(sc.hasNext()){
       s = sc.next();
       // create a method to search translation
       String []trans = searchTrans(s);
       hs.put(s, trans);

    }


问:
Android Studio Expression Evaluation during debugging
I am new to Android Studio and was trying to get my hands on.

My question is: how can I see the value of any expression which needs to be evaulated?

For instance, in the code below, how can I see the value of Message.getText()?

```<code>    if (Message.getText() == null){
        Message.setError("Invalid Message");flag=true;
    }
</code>```

I have been using Eclipse with PyDev and there I had the option to evaluate any expression while debugging by using the print statement.

I was just wondering if there is any equivalent functionality in Android studio

答: You can just use "evaluate expression" button while debugging.

Body:
I am new to Android Studio and was trying to get my hands on.

My question is: how can I see the value of any expression which needs to be evaulated?

For instance, in the code below, how can I see the value of Message.getText()?

    if (Message.getText() == null){
        Message.setError("Invalid Message");flag=true;
    }

I have been using Eclipse with PyDev and there I had the option to evaluate any expression while debugging by using the print statement.

I was just wondering if there is any equivalent functionality in Android studio


问:
How to hide timezone option in kendo scheduler event creation in angularjs
When i unchecked 'All Day Event' option in 'Kendo' scheduler event, its giving timezone option. How can i  hide that timezone option?     </p>

<p>-</p>

答: The timezone options are implemented in a separate kendo.timezones.min.js file. If you remove it from your page declaration you will not have the timezone option and the default "Etc/UTC" timezone will be used.</p>

Body:
When i unchecked 'All Day Event' option in 'Kendo' scheduler event, its giving timezone option. How can i  hide that timezone option?

-


问:
How to make div appear on button click using Javascript
I'm trying to make a div appear on button click which I've not succeeded from the below code.Please let me know if I've done any thing wrong in the code.

function showDiv() {
  document.getElementById('sign-in').style.display = "block";
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>Login

<div id="sign-in" class="login" style="display: none;">
  <form>
    <div class="row">
      <div class="col-md-3">
        <div class="form-group inline-form">
          <input type="email" class="form-control" id="email" Placeholder="email">
        </div>
      </div>
      <div class="col-md-3">
        <div class="form-group inline-form">
          <input type="password" class="form-control" id="pwd">
        </div>
      </div>
      <div class="col-md-3">
        <div class="checkbox">
          <label><input type="checkbox"> Remember me</label>
        </div>
      </div>
      <div class="col-md-3">
        <button type="submit" class="btn btn-default ">Submit</button>
      </div>
    </div>
  </form>
</div></code>```

答:
Can I strongly, strongly suggest that you use jQuery to do this - it makes this task trivial on all browsers.  To do this with jQuery, perform the following steps.

Include the jQuery script library in your web page .

Add an id property to your button Login.

Add the following Javascript to your page:

```<code><script>
    $(function() {
        $("#loginButton").click(function() {
            $("#sign-in").show();
        });
    });
</script>
</code>```

Body:
I'm trying to make a div appear on button click which I've not succeeded from the below code.Please let me know if I've done any thing wrong in the code.

function showDiv() {
  document.getElementById('sign-in').style.display = "block";
}

Login

  <form>

          <input type="email" class="form-control" id="email" Placeholder="email">

          <input type="password" class="form-control" id="pwd">

          <input type="checkbox"> Remember me

        <button type="submit" class="btn btn-default ">Submit</button>

  </form>

Body:
Can I strongly, strongly suggest that you use jQuery to do this - it makes this task trivial on all browsers.  To do this with jQuery, perform the following steps.

Include the jQuery script library in your web page <script
  src="https://code.jquery.com/jquery-3.2.1.min.js"
  integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  crossorigin="anonymous"></script>.

Add an id property to your button <a class="btn btn-default log-bar" href="#" id="loginButton" role="button" onclick = "showDiv()" >Login</a>.

Add the following Javascript to your page:

<script>
    $(function() {
        $("#loginButton").click(function() {
            $("#sign-in").show();
        });
    });
</script>