问:
Visual Studio. Code changes don't do anything
Any changes I make to my code aren't doing anything. I've even tried putting lines in that I know will crash my program, and nothing. It just keep running the old version. It's even loading old versions of files I've edited and saved.

There a 3 projects in my solution. 2 are pure C#. 1 is a WinForms application.

答:
Had issue with saving code changes on VS2017 (mac) Version 7.3 Preview (7.3 build 740)

Only way to get file changes to save was to do File > Save All

Doing File>Save would act like the file saved. But, when I opened the file again and no changes were saved.


来源: stackexchange

问:
text on the right of the pic, js
I have a div and inside that div i have a pic and a text. Right now text goes at the bottom of the pic and if the text is large then we cannot see the whole text , what i want is pic on the left side and text on the right side of the pic and everything should fit inside the broder, please have a look at the pic for more info , any help will be highly appreciated.

答:
Float the image to left. In your css:</p>

```<code>img{float: left;}
</code>```

ContentLicense: CC BY-SA 3.0

Title: text on the right of the pic, js

Body:
Float the image to left. In your css:

img{float: left;}


问:
ASP.NET (C#) event to happen before printing
I have a web form in ASP.Net with C# code behind. It's a simple thing, and I'm pretty new so I'm kind of stuck.

In the source code of the web form I have a button called "print" that looks like this:

```<code><asp:Button ID="btnPrint" runat="server" onclientclick="window.print();" Text="Print" />
</code>```

No problem. In the code behind I have this:

```<code> protected void btnPrint_Click(object sender, EventArgs e)
{
    //get current Date/Time
    string dateTime = DateTime.Now.ToLongDateString() + ", at " + DateTime.Now.ToShortTimeString();

    //set it to labelDate
    lblDate.Text = "Requested on " + dateTime;

}
</code>```

So the problem is that when I hit the print button, the form prints before the code executes and stamps the label (lblDate.Text).

Soooo... my noob question is how to get that date/time stamp to process before the form prints?

Thanks for your advice.

Mark

答:
Try something like this:</p>

```<code>protected void btnPrint_Click(object sender, EventArgs e)
{
    //get current Date/Time
    string dateTime = DateTime.Now.ToLongDateString() + ", at " + DateTime.Now.ToShortTimeString();

    //set it to labelDate
    lblDate.Text = "Requested on " + dateTime;

 ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "window.print();", true);

}
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I have a web form in ASP.Net with C# code behind. It's a simple thing, and I'm pretty new so I'm kind of stuck.

In the source code of the web form I have a button called "print" that looks like this:

<asp:Button ID="btnPrint" runat="server" onclientclick="window.print();" Text="Print" />

No problem. In the code behind I have this:

 protected void btnPrint_Click(object sender, EventArgs e)
{
    //get current Date/Time
    string dateTime = DateTime.Now.ToLongDateString() + ", at " + DateTime.Now.ToShortTimeString();

    //set it to labelDate
    lblDate.Text = "Requested on " + dateTime;

}

So the problem is that when I hit the print button, the form prints before the code executes and stamps the label (lblDate.Text).

Soooo... my noob question is how to get that date/time stamp to process before the form prints?

Thanks for your advice.

Mark

Body:
Try something like this:

protected void btnPrint_Click(object sender, EventArgs e)
{
    //get current Date/Time
    string dateTime = DateTime.Now.ToLongDateString() + ", at " + DateTime.Now.ToShortTimeString();

    //set it to labelDate
    lblDate.Text = "Requested on " + dateTime;

 ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "window.print();", true);

}


问:
Make Https call using HttpClient
I have been using HttpClient for making WebApi calls using C#. Seems neat & fast way compared to WebClient. However I am stuck up while making Https calls.

How can I make below code to make Https calls?

```<code>HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://foobar.com/");
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/xml"));

var task = httpClient.PostAsXmlAsync<DeviceRequest>(
                "api/SaveData", request);
</code>```

EDIT 1:
The code above works fine for making http calls. But when I change the scheme to https it does not work. Here is the error obtained:

The underlying connection was closed: Could not establish trust
  relationship for the SSL/TLS secure channel.

EDIT 2:
Changing the scheme to https is: step one.

How do I supply certificate & public / private key along with C#
  request.

答:
When connect to https I got this error too, I add this line before HttpClient httpClient = new HttpClient(); and connect successfully:

```<code>ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
</code>```

I know it from This Answer and Another Similar Anwser and the comment mentions:

This is a hack useful in development so putting a #if DEBUG #endif statement around it is the least you should do to make this safer and stop this ending up in production

Besides, I didn't try the method in Another Answer that use new X509Certificate() or new X509Certificate2() to make a Certificate, I'm  not sure simply create by new() will work or not.

EDIT:  Some References:

Create a Self-Signed Server Certificate in IIS 7

Import and Export SSL Certificates in IIS 7

Convert .pfx to .cer

Best practices for using ServerCertificateValidationCallback

I find value of Thumbprint is equal to x509certificate.GetCertHashString():

Retrieve the Thumbprint of a Certificate

ContentLicense: CC BY-SA 4.0

Title: Make Https call using HttpClient

Body:
I have been using HttpClient for making WebApi calls using C#. Seems neat & fast way compared to WebClient. However I am stuck up while making Https calls.

How can I make below code to make Https calls?

HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://foobar.com/");
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/xml"));

var task = httpClient.PostAsXmlAsync<DeviceRequest>(
                "api/SaveData", request);

EDIT 1:
The code above works fine for making http calls. But when I change the scheme to https it does not work. Here is the error obtained:

The underlying connection was closed: Could not establish trust
  relationship for the SSL/TLS secure channel.

EDIT 2:
Changing the scheme to https is: step one.

How do I supply certificate & public / private key along with C#
  request.

Body:
When connect to https I got this error too, I add this line before HttpClient httpClient = new HttpClient(); and connect successfully:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

I know it from This Answer and Another Similar Anwser and the comment mentions:

This is a hack useful in development so putting a #if DEBUG #endif statement around it is the least you should do to make this safer and stop this ending up in production

Besides, I didn't try the method in Another Answer that use new X509Certificate() or new X509Certificate2() to make a Certificate, I'm  not sure simply create by new() will work or not.

EDIT:  Some References:

Create a Self-Signed Server Certificate in IIS 7

Import and Export SSL Certificates in IIS 7

Convert .pfx to .cer

Best practices for using ServerCertificateValidationCallback

I find value of Thumbprint is equal to x509certificate.GetCertHashString():

Retrieve the Thumbprint of a Certificate


问:
Create dataframe of too long integers
I am trying to create dataframe which should contain very long integer. My code is as follows:

```<code>import pandas as pd

data = [123456789123456789123456789123456789123456789,
123456789123456789123456789123456789123456789]
cols = ['Col1', 'Col2']
df = pd.DataFrame(data, columns=cols)
print(df)
</code>```

But I am getting the following error:

```<code>Traceback (most recent call last):
File "/home/watson/Desktop/test.py", line 5, in <module>
    df = pd.DataFrame(data, columns=cols)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 330, in __init__
    copy=copy)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 463, in _init_ndarray
    values = _prep_ndarray(values, copy=copy)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 5578, in _prep_ndarray
    values = convert(values)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 5567, in convert
    return maybe_convert_platform(v)
File "/usr/local/lib/python2.7/dist-
packages/pandas/core/dtypes/cast.py", line 47, in
maybe_convert_platform
    values = lib.maybe_convert_objects(values)
File "pandas/_libs/src/inference.pyx", line 1165, in
pandas._libs.lib.maybe_convert_objects (pandas/_libs/lib.c:58498)
    OverflowError: long int too large to convert
</code>```

答:
You can avoid the error by setting dtype=object. In addition, you have a typo in your example and are passing the wrong shape data given that you are specifying two columns. The following line works:

```<code>df = pd.DataFrame([data], columns=cols, dtype=object)
</code>```

Note: I wrapped your data in a list to make it the correct dimensions. If I don't do that, it gives the OverflowError, even though it should really give a ValueError about the shape of the passed values.

```<code>In [1]: df = pd.DataFrame([data], columns=cols, dtype=object)

In [2]: df
Out[2]:
                                            Col1  \
0  123456789123456789123456789123456789123456789

                                            Col2
0  123456789123456789123456789123456789123456789
</code>```

Title: Create dataframe of too long integers

Body:
I am trying to create dataframe which should contain very long integer. My code is as follows:

import pandas as pd

data = [123456789123456789123456789123456789123456789,
123456789123456789123456789123456789123456789]
cols = ['Col1', 'Col2']
df = pd.DataFrame(data, columns=cols)
print(df)

But I am getting the following error:

Traceback (most recent call last):
File "/home/watson/Desktop/test.py", line 5, in <module>
    df = pd.DataFrame(data, columns=cols)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 330, in __init__
    copy=copy)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 463, in _init_ndarray
    values = _prep_ndarray(values, copy=copy)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 5578, in _prep_ndarray
    values = convert(values)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 5567, in convert
    return maybe_convert_platform(v)
File "/usr/local/lib/python2.7/dist-
packages/pandas/core/dtypes/cast.py", line 47, in
maybe_convert_platform
    values = lib.maybe_convert_objects(values)
File "pandas/_libs/src/inference.pyx", line 1165, in
pandas._libs.lib.maybe_convert_objects (pandas/_libs/lib.c:58498)
    OverflowError: long int too large to convert

Body:
You can avoid the error by setting dtype=object. In addition, you have a typo in your example and are passing the wrong shape data given that you are specifying two columns. The following line works:

df = pd.DataFrame([data], columns=cols, dtype=object)

Note: I wrapped your data in a list to make it the correct dimensions. If I don't do that, it gives the OverflowError, even though it should really give a ValueError about the shape of the passed values.

In [1]: df = pd.DataFrame([data], columns=cols, dtype=object)

In [2]: df
Out[2]:
                                            Col1  \
0  123456789123456789123456789123456789123456789

                                            Col2
0  123456789123456789123456789123456789123456789


问:
power bi create dataset using gateway in c#
Has anyone tried this?
The API as defined here:
https://msdn.microsoft.com/en-us/library/mt203562.aspx
is vague. It suggests the following structure for SSAS on premise:

```<code>{
   "name":"SalesMarketing",
   "defaultMode":"AsOnPrem",
   "tables": [],
   "datasources":[
      {
         "name":"SalesMarketing",
         "connectionString":"Data Source=asazure://westcentralus.asazure.windows.net/mypowerbi;Initial Catalog=SalesMarketing;Cube=Model"
      }
   ]
}
</code>```

On premise SSAS connections must be done through a Gateway and a datasource. I have gateway and datasource working with a Power Bi Report. However, I cannot create a dataset from c# using their example.
I always get (400) Bad Request. This is typical error for just about anything on the PBI service. There are no clues as to what the error is. I tried to capture the calls to the the service using the "Get Data" button on powerbi.com but the queries did not make sense and did not match API.
Any ideas on what the structure should contain for a gateway datasource?

答:
After a lot of trial and error I solved it:

```<code>string dataset = $@"{{
    ""name"":""{dataSetName}"",
    ""defaultMode"":""AsOnPrem"",
    ""tables"": [],
    ""datasources"":[
        {{
        ""name"":""{dataSourceName}"",
        ""connectionString"":""Provider=MSOLAP.5;Data Source={server};Initial Catalog={ssasTabularModelName};Cube=Model;""
        }} ]
}}
</code>```

The key is in the connection string format.

Body:
Has anyone tried this?
The API as defined here:
https://msdn.microsoft.com/en-us/library/mt203562.aspx
is vague. It suggests the following structure for SSAS on premise:

{
   "name":"SalesMarketing",
   "defaultMode":"AsOnPrem",
   "tables": [],
   "datasources":[
      {
         "name":"SalesMarketing",
         "connectionString":"Data Source=asazure://westcentralus.asazure.windows.net/mypowerbi;Initial Catalog=SalesMarketing;Cube=Model"
      }
   ]
}

On premise SSAS connections must be done through a Gateway and a datasource. I have gateway and datasource working with a Power Bi Report. However, I cannot create a dataset from c# using their example.
I always get (400) Bad Request. This is typical error for just about anything on the PBI service. There are no clues as to what the error is. I tried to capture the calls to the the service using the "Get Data" button on powerbi.com but the queries did not make sense and did not match API.
Any ideas on what the structure should contain for a gateway datasource?

Body:
After a lot of trial and error I solved it:

string dataset = $@"{{
    ""name"":""{dataSetName}"",
    ""defaultMode"":""AsOnPrem"",
    ""tables"": [],
    ""datasources"":[
        {{
        ""name"":""{dataSourceName}"",
        ""connectionString"":""Provider=MSOLAP.5;Data Source={server};Initial Catalog={ssasTabularModelName};Cube=Model;""
        }} ]
}}

The key is in the connection string format.


问:
Issue while loading/serving tensorflow model in java using estimators
I used the census data and created a wide and deep model using the estimators api in tensorflow. While loading the model in Java, there seems to be an error which doesn't let the model to be loaded. Exception looks like

```<code>Exception in thread "main" org.tensorflow.TensorFlowException: Op type not
registered 'SparseFeatureCross' in binary running on gmalhotra-mba-2.local.
Make sure the Op and Kernel are registered in the binary running in this
process.
at org.tensorflow.SavedModelBundle.load(Native Method)
at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:39)
at deeplearning.DeepLearningTest.main(DeepLearningTest.java:32)
</code>```

Please find the python code below used for saving the model:
https://gist.github.com/gaganmalhotra/cd6a5898b9caf9005a05c8831a9b9153

Java code used is as follows:

```<code>    public static void main(String[] args) {
          try (SavedModelBundle b = SavedModelBundle.load("/Users/gagandeep.malhotra/Documents/SampleTF_projects/temporaryModel/1510624417/", "serve")) {

    Session sess = b.session();

                //Create the input sensor
                  float[][] mat=new float[1][1];
                  mat[0]=new float[]{0.5f};

                // create tensors specific to inputs ....

                Tensor<?> x = (Tensor<?>) Tensor.create(mat);

                //run the model
                float[][] y = sess.runner()
                        .feed("input", x)
                        .fetch("output")
                        .run()
                        .get(0)
                        .copyTo(new float[1][1]);

               //print the result
                System.out.println(y[0][0]);
}
</code>```

PS : Tensorflow version used: 1.3

答:
When you use operations in the tf.contrib module, they are not considered to be experimental, thus are not part of the stable TensorFlow API and aren't included in other language distributions.

However, in TensorFlow 1.4 and above you can explicitly load the shared library in Java using TensorFlow.loadLibrary().

To do that, first you need to find the location of the shared library that contains the implementation of the tf.contrib operation you're interested in. In this case it seems like it's tf.contrib.layers, so you'd do something like this:

```<code>python -c "import tensorflow; print(tensorflow.contrib.layers.__path__)"
</code>```

Which would print something like:

```<code>['/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers']
</code>```

Then you'd find all the shared libraries in that path using something like:

```<code>find /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers -name "*.so"
</code>```

Which would be something like:

```<code>/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/ops/_sparse_feature_cross_op.so
</code>```

Alright, now you have that library, you can load it in Java using:

```<code>public static void main(String[] args) {
    TensorFlow.loadLibrary("/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/ops/_sparse_feature_cross_op.so");

    // And now load the model etc.
}
</code>```

Caveats:

If you want to run on a different machine, you'd want to package the .so file above with your program and adjust the call to TensorFlow.loadLibrary() appropriately.

Make sure you're using the same TensorFlow version for Python and Java (1.4)

Hope that helps.

Body:
I used the census data and created a wide and deep model using the estimators api in tensorflow. While loading the model in Java, there seems to be an error which doesn't let the model to be loaded. Exception looks like

Exception in thread "main" org.tensorflow.TensorFlowException: Op type not
registered 'SparseFeatureCross' in binary running on gmalhotra-mba-2.local.
Make sure the Op and Kernel are registered in the binary running in this
process.
at org.tensorflow.SavedModelBundle.load(Native Method)
at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:39)
at deeplearning.DeepLearningTest.main(DeepLearningTest.java:32)

Please find the python code below used for saving the model:
https://gist.github.com/gaganmalhotra/cd6a5898b9caf9005a05c8831a9b9153

Java code used is as follows:

    public static void main(String[] args) {
          try (SavedModelBundle b = SavedModelBundle.load("/Users/gagandeep.malhotra/Documents/SampleTF_projects/temporaryModel/1510624417/", "serve")) {

    Session sess = b.session();

                //Create the input sensor
                  float[][] mat=new float[1][1];
                  mat[0]=new float[]{0.5f};

                // create tensors specific to inputs ....

                Tensor<?> x = (Tensor<?>) Tensor.create(mat);

                //run the model
                float[][] y = sess.runner()
                        .feed("input", x)
                        .fetch("output")
                        .run()
                        .get(0)
                        .copyTo(new float[1][1]);

               //print the result
                System.out.println(y[0][0]);
}

PS : Tensorflow version used: 1.3

Body:
When you use operations in the tf.contrib module, they are not considered to be experimental, thus are not part of the stable TensorFlow API and aren't included in other language distributions.

However, in TensorFlow 1.4 and above you can explicitly load the shared library in Java using TensorFlow.loadLibrary().

To do that, first you need to find the location of the shared library that contains the implementation of the tf.contrib operation you're interested in. In this case it seems like it's tf.contrib.layers, so you'd do something like this:

python -c "import tensorflow; print(tensorflow.contrib.layers.__path__)"

Which would print something like:

['/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers']

Then you'd find all the shared libraries in that path using something like:

find /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers -name "*.so"

Which would be something like:

/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/ops/_sparse_feature_cross_op.so

Alright, now you have that library, you can load it in Java using:

public static void main(String[] args) {
    TensorFlow.loadLibrary("/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/ops/_sparse_feature_cross_op.so");

    // And now load the model etc.
}

Caveats:

If you want to run on a different machine, you'd want to package the .so file above with your program and adjust the call to TensorFlow.loadLibrary() appropriately.

Make sure you're using the same TensorFlow version for Python and Java (1.4)

Hope that helps.


问:
Room Persistence Library: Weird Error during migration
I am scratching my head with this error. I couldn't find any answer so far. I have old database which I am migrating to Persistence Room library. However whenever I do migration, I am getting following error,

```<code>java.lang.IllegalStateException: Migration didn't properly handle.
</code>```

Code I am using is as follows:

```<code>@Entity(tableName = ROUTE_TABLE)
public class RouteData {

    static final String ROUTE_TABLE = "name";

    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id")
    private int id;
    @ColumnInfo(name = "col1")
    private String col1;
    //Other columns with exactly same as 'col1' just different names
    //Getters and Setters
}
</code>```

For migration,

```<code>Room.databaseBuilder(context.getApplicationContext(), MyData.class, DATABASE_NAME)
            .addMigrations(MIGRATION_LATEST)
            .fallbackToDestructiveMigration()
            .build();

private static final Migration MIGRATION_LATEST = new Migration(9, 10) {
    @Override
    public void migrate(SupportSQLiteDatabase db) {
        //Log.i("Tag" , "Migration Started");
        //Migration logic
        //Log.i("Tag" , "Migration Ended");
    }
};
</code>```

When I run program. I get "Migration Ended" log in my LogCat but when I am trying access database again, it is giving me following error.

```<code> Caused by: java.lang.IllegalStateException: Migration didn't properly handle xxx.
                                                                              Expected:
                                                                             TableInfo{name='name', columns={col1=Column{name='col1', type='TEXT', notNull=false, primaryKeyPosition=0}, ....}, foreignKeys=[]}
                                                                              Found:
                                                                             TableInfo{name='name', columns={col1=Column{name='col1', type='INTEGER', notNull=false, primaryKeyPosition=0}, ....}, foreignKeys=[]}
</code>```

I have no idea where where this "INTEGER" is coming. I tried uninstalling, invalidating cache and any other closely related solution. Any idea what is going on? It works perfectly fine if you freshly install app. Error is coming up only after migration. According to my log cat, all migration steps seems to be completed but it is still showing migration not handled properly.

答:
Thank you all for trying to help me, however I have finally found the answer after days of frustrating debugging. In my app manifest auto backup was on,

android:allowBackup="true"

So while trying out various databases, google was actually backing up my any newly created databases and their structure and restoring them automatically when I was reinstalling app. Hence I was getting this wired error. Once I switch of auto backup android:allowBackup="false" and reinstall app, I can test migration properly.

My suggestion for all developers in future encountering such problem, SWITCH OFF auto backup while development. You can switch it on once you have tested your migration.

Body:
I am scratching my head with this error. I couldn't find any answer so far. I have old database which I am migrating to Persistence Room library. However whenever I do migration, I am getting following error,

java.lang.IllegalStateException: Migration didn't properly handle.

Code I am using is as follows:

@Entity(tableName = ROUTE_TABLE)
public class RouteData {

    static final String ROUTE_TABLE = "name";

    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id")
    private int id;
    @ColumnInfo(name = "col1")
    private String col1;
    //Other columns with exactly same as 'col1' just different names
    //Getters and Setters
}

For migration,

Room.databaseBuilder(context.getApplicationContext(), MyData.class, DATABASE_NAME)
            .addMigrations(MIGRATION_LATEST)
            .fallbackToDestructiveMigration()
            .build();

private static final Migration MIGRATION_LATEST = new Migration(9, 10) {
    @Override
    public void migrate(SupportSQLiteDatabase db) {
        //Log.i("Tag" , "Migration Started");
        //Migration logic
        //Log.i("Tag" , "Migration Ended");
    }
};

When I run program. I get "Migration Ended" log in my LogCat but when I am trying access database again, it is giving me following error.

 Caused by: java.lang.IllegalStateException: Migration didn't properly handle xxx.
                                                                              Expected:
                                                                             TableInfo{name='name', columns={col1=Column{name='col1', type='TEXT', notNull=false, primaryKeyPosition=0}, ....}, foreignKeys=[]}
                                                                              Found:
                                                                             TableInfo{name='name', columns={col1=Column{name='col1', type='INTEGER', notNull=false, primaryKeyPosition=0}, ....}, foreignKeys=[]}

I have no idea where where this "INTEGER" is coming. I tried uninstalling, invalidating cache and any other closely related solution. Any idea what is going on? It works perfectly fine if you freshly install app. Error is coming up only after migration. According to my log cat, all migration steps seems to be completed but it is still showing migration not handled properly.


问:
TFS 2010 Branching Error on Label TF10169
I can't create a branch in TFS; when I try to branch the code in $/MainCode to $/BranchCode, using a label as the source, I get this error:

TF10169: Unsupported pending change attempted on team project folder $/BranchCode.  Use the Project Creation Wizard in Team Explorer to create a project or the Team Project deletion tool to delete one.

Why would I need to create or delete a project?  Both $/MainCode and $/BranchCode exist.......  I don't get this.

Thanks.

答:
I might be completely wrong here, but isn't it the case that the things immediately below $/ are Team Projects, rather than branches? So you would have

```<code>$
    SuperFoo
        Main
        vNext
    AmazingBar
        Main
        vNext
        vNextNext
</code>```

and you would branch (say) $/SuperFoo/Main to $/SuperFoo/MyNewBranch ?

I can't right now find decent docs on Team Projects, and my experience is only with TFS 2005, but that's how I've always understood the hierarchy.

Body:
I might be completely wrong here, but isn't it the case that the things immediately below $/ are Team Projects, rather than branches? So you would have

$
    SuperFoo
        Main
        vNext
    AmazingBar
        Main
        vNext
        vNextNext

and you would branch (say) $/SuperFoo/Main to $/SuperFoo/MyNewBranch ?

I can't right now find decent docs on Team Projects, and my experience is only with TFS 2005, but that's how I've always understood the hierarchy.


问:
Android Device long-press causing an underlying link to fire when an overlay div is closed
I have a fixed overlay div with a high z-index showing a gallery of images. There is a close button in the top right corner which closes the overlay gallery.

Unfortunately, the website has a fixed top bar header with a facebook social icon using an anchor tag and font-awesome icon. The facebook link is positioned EXACTLY underneath the gallery close button. Closing the overlay gallery on an android device causes the underlying facebook anchor link to fire as well, taking the user to facebook. Evidently, two clicks are being registered, one for the overlay close anchor and another for the facebook icon link.

The problem doesn't seem to occur on iPhone devices. On one of the phones I tested, the gallery closes without causing the facebook link to fire.

At the present, I'm resorting to nasty hacks like setting the facebook link href to javascript:void(0) when the gallery is opened, and then correcting the link when the gallery is closed using a javascript timer delay. It prevents the facebook link from firing, but the facebook anchor tag is still getting a click/hover which causes the hover effect to fire, thus causing the css :hover styling to apply.

Is there any easy solution to this problem or a better way?

答:
I "solved" the issue by creating a transparent overlay div on top of the facebook icon when the gallery is opened, and then removed it 300ms after the gallery was closed.

:/


问:
3D Plotting with (or without) mesh in MATLAB
I have a function G(a,b) that takes two inputs and returns a number. The function itself involves using ode45 and eigenvalues of some matrix depending on the values of a and b.  I want to look at a 3D plot (ideally a 2D heat plot of G vs a and b, but I know MATLAB can twist axes and stuff).

I have tried 2 approaches. The first is the nested for loops

```<code>i=1
j=1
for a = 0:1:40 ;
   for b = 0:.1:10 ;
      Value(i,j) = G(a,b);
      B(j)=b;
      j=j+1 ;
    end
    A(i) = a;
    i=i+1 ;
end
</code>```

Why I do not like this:  I end up with three vectors/arrays: A B and G.  Since G is 2D, I cannot just do surf(A,B,G).  So my next thought was mesh:

```<code>a = 0:1:40;
b = 0:.1:10;
[A,B] = meshgrid(a,b);
Value = G(A,B);
</code>```

Now my error is understandably that my function wants numbers a,b not arrays.

So I am kind of stuck as to how to best approach this and any suggestions would be greatly appreciated!

答:
Two solutions come to my mind. First, implement G function using . operators. For example, if there is any a*b, change it to a.*b, or a/b change it to a./b.

Second, if your function can be implemented in a symbolic format, you can plot your function using ezmesh in a simple format.

In sum, the solution to your question depends on implementation of G function.

Body:
I have a function G(a,b) that takes two inputs and returns a number. The function itself involves using ode45 and eigenvalues of some matrix depending on the values of a and b.  I want to look at a 3D plot (ideally a 2D heat plot of G vs a and b, but I know MATLAB can twist axes and stuff).

I have tried 2 approaches. The first is the nested for loops

i=1
j=1
for a = 0:1:40 ;
   for b = 0:.1:10 ;
      Value(i,j) = G(a,b);
      B(j)=b;
      j=j+1 ;
    end
    A(i) = a;
    i=i+1 ;
end

Why I do not like this:  I end up with three vectors/arrays: A B and G.  Since G is 2D, I cannot just do surf(A,B,G).  So my next thought was mesh:

a = 0:1:40;
b = 0:.1:10;
[A,B] = meshgrid(a,b);
Value = G(A,B);

Now my error is understandably that my function wants numbers a,b not arrays.

So I am kind of stuck as to how to best approach this and any suggestions would be greatly appreciated!


问:
CGAffineTransform an UIView with UIPanGestureRecognizer
I have view A, add sub on self view. And i want when i draw panGestureRegonizer on view A, view A will move follow draw.

And while moving view A will scale. View A will scale to smaller when view move to top/left/bottom/right of sreen and scale to larger when view move to center of screen.

I have try many solution, but i can not make it.

Please suggest help me?

答:
Logic: You have coordinate system(CS) with center, x and y. When the user uses pan gesture, he/she generates sequence of points in the CS. So our task is to measure the distance between the center of the CS and users' points. When we have the furthest distance, we can calculate scale factor for our scaling view.

```<code>var center: CGPoint! //center of the CS
let maxSize: CGSize = CGSize.init(width: 100, height: 100) // maximum size of our scaling view
var maxLengthToCenter: CGFloat! //maximum distance from the center of the CS to the furthest point in the CS

private func prepareForScaling() {
    self.center = self.view.center //we set the center of our CS to equal the center of the VC's view
    let frame = self.view.frame
    //the furthest distance in the CS is the diagonal, and we calculate it using pythagoras theorem
    self.maxLengthToCenter = (frame.width*frame.width + frame.height*frame.height).squareRoot()
}
</code>```

Then we need to call our setup functional to have our data ready for scaling functionality - we can do this in viewDidLoad:

```<code>override func viewDidLoad() {
    super.viewDidLoad()
    self.prepareForScaling()
}
</code>```

Then we need a helper function to calculates the scaled size of our view, for user's pan gesture current position on the screen.

```<code>private func scaledSize(for location: CGPoint) -> CGSize {
    //calculate location x,y differences from the center
    let xDifference = location.x - self.center.x
    let yDifference = location.y - self.center.y

    //calculate the scale factor - note that this factor will be between 0.0(center) and 0.5(diagonal - furthest point)
    //It is due our measurement - from center to view's edge. Consider multiplying this factor with your custom constant.
    let scaleFactor = (xDifference*xDifference + yDifference*yDifference).squareRoot()/maxLengthToCenter
    //create scaled size with maxSize and current scale factor
    let scaledSize = CGSize.init(width: maxSize.width*(1-scaleFactor), height: maxSize.height*(1-scaleFactor))

    return scaledSize
}
</code>```

And finally, we need to modify our pan gesture action to change the size of A:

```<code>@IBAction func panGestureAction(_ sender: UIPanGestureRecognizer) {
    UIView.animateKeyframes(withDuration: 0.1, delay: 0, options: UIViewKeyframeAnimationOptions.calculationModeLinear, animations: {

        let location = sender.location(in: sender.view?.superview)

        sender.view?.frame = CGRect.init(origin: CGPoint.init(x: 0, y: 0), size: self.scaledSize(for: location))

        sender.view?.center = location
    })
}
</code>```

Body:
Logic: You have coordinate system(CS) with center, x and y. When the user uses pan gesture, he/she generates sequence of points in the CS. So our task is to measure the distance between the center of the CS and users' points. When we have the furthest distance, we can calculate scale factor for our scaling view.

var center: CGPoint! //center of the CS
let maxSize: CGSize = CGSize.init(width: 100, height: 100) // maximum size of our scaling view
var maxLengthToCenter: CGFloat! //maximum distance from the center of the CS to the furthest point in the CS

private func prepareForScaling() {
    self.center = self.view.center //we set the center of our CS to equal the center of the VC's view
    let frame = self.view.frame
    //the furthest distance in the CS is the diagonal, and we calculate it using pythagoras theorem
    self.maxLengthToCenter = (frame.width*frame.width + frame.height*frame.height).squareRoot()
}

Then we need to call our setup functional to have our data ready for scaling functionality - we can do this in viewDidLoad:

override func viewDidLoad() {
    super.viewDidLoad()
    self.prepareForScaling()
}

Then we need a helper function to calculates the scaled size of our view, for user's pan gesture current position on the screen.

private func scaledSize(for location: CGPoint) -> CGSize {
    //calculate location x,y differences from the center
    let xDifference = location.x - self.center.x
    let yDifference = location.y - self.center.y

    //calculate the scale factor - note that this factor will be between 0.0(center) and 0.5(diagonal - furthest point)
    //It is due our measurement - from center to view's edge. Consider multiplying this factor with your custom constant.
    let scaleFactor = (xDifference*xDifference + yDifference*yDifference).squareRoot()/maxLengthToCenter
    //create scaled size with maxSize and current scale factor
    let scaledSize = CGSize.init(width: maxSize.width*(1-scaleFactor), height: maxSize.height*(1-scaleFactor))

    return scaledSize
}

And finally, we need to modify our pan gesture action to change the size of A:

@IBAction func panGestureAction(_ sender: UIPanGestureRecognizer) {
    UIView.animateKeyframes(withDuration: 0.1, delay: 0, options: UIViewKeyframeAnimationOptions.calculationModeLinear, animations: {

        let location = sender.location(in: sender.view?.superview)

        sender.view?.frame = CGRect.init(origin: CGPoint.init(x: 0, y: 0), size: self.scaledSize(for: location))

        sender.view?.center = location
    })
}


问:
Add
 in between  and  using Jquery/Javascript
How do I dynamically add a
 tag after  and another  tag in HTML?

so my before code looks like this:

```<code><span>Some Text</span><span>Another text</span>
</code>```

I want to look like this:

```<code><span>Some Text</span><br><span>Another text</span>
</code>```

There are a few span tags inside a
 container, so is there a way to append all the span tags inside that div container so that all span tags have br tag one after another?

Note that  tag is produced and appended by a library, so there is no way i can change to a
 tag or something else that has breakline.

答:
Get all the span except the last since you don't need to place br tag after the last span and then append br tag after the element using after() method.

// with pure css selector
$('.con > span:not(:last-of-type)').after('
')

// or using jQuery :last
// $('.con span:not(:last)').after('
')```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="con">
  <span>Some Text</span><span>Another text</span>
  <span>Some Text</span><span>Another text</span>
</div></code>```

Reference :

:not

:last

:last-of-type

after

Child Selector (“parent > child”)

UPDATE : With pure CSS you can use clear property.

span {
 float:left;
 clear:both;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="con">
  <span>Some Text</span><span>Another text</span>
  <span>Some Text</span><span>Another text</span>
</div></code>```

Title: Add <br> in between </span> and <span> using Jquery/Javascript

Body:
How do I dynamically add a
 tag after  and another  tag in HTML?

so my before code looks like this:

Some TextAnother text

I want to look like this:

Some Text
Another text

There are a few span tags inside a
 container, so is there a way to append all the span tags inside that div container so that all span tags have br tag one after another?

Note that  tag is produced and appended by a library, so there is no way i can change to a
 tag or something else that has breakline.

Body:
Get all the span except the last since you don't need to place br tag after the last span and then append br tag after the element using after() method.

// with pure css selector
$('.con > span:not(:last-of-type)').after('<br/>')

// or using jQuery :last
// $('.con span:not(:last)').after('<br/>')

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="con">
  <span>Some Text</span><span>Another text</span>
  <span>Some Text</span><span>Another text</span>
</div>

Reference :

:not

:last

:last-of-type

after

Child Selector (“parent > child”)

UPDATE : With pure CSS you can use clear property.

span {
 float:left;
 clear:both;
}

<div class="con">
  <span>Some Text</span><span>Another text</span>
  <span>Some Text</span><span>Another text</span>
</div>


问:
JS: Posting form directly
If on document.ready, I want my form to auto post itself, is this possible?

So when the document has loaded, then it posts itself and takes to the action="" (in this case is ?upload=true).

I heard about $.post() jquery, but this is just for posting in the background?

答:
Yes, $.post() in jQuery is for POST requests with AJAX.

If you want a form to submit on the document ready event, just invoke the submit itself!

```<code>$(document).ready( function()
{
  $('form').submit()
});
</code>```

Title: JS: Posting form directly

Body:
Yes, $.post() in jQuery is for POST requests with AJAX.

If you want a form to submit on the document ready event, just invoke the submit itself!

$(document).ready( function()
{
  $('form').submit()
});


答:
You can use insertAfter method to add the html tag

$('span').each(function(i, v) {
  $('
').insertAfter($(this))

})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>Some Text</span><span>Another text</span></code>```

Body:
You can use insertAfter method to add the html tag

$('span').each(function(i, v) {
  $('<br/>').insertAfter($(this))

})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>Some Text</span><span>Another text</span>


问:
ExtJS changing the value of a combobox item on the fly
So im working with ExtJS 3.3, I have a combo box which im filling with values, some of the values need to be indented in the list when its expanded, so I have used   this works great when the combo is expanded, but once i select an item, the   actually shows in the combobox when its collapsed.

For instance; when its expanded, my values show as

```<code>        this is my indented value
</code>```

and this is exactly what i want, but when collapsed, the value shows as

```<code>    this is my indented value
</code>```

Is there any way i can trim the spaces from the front of the value on the fly so in the expanded view it shows with the indents, but collapsed it just shows the value and nothing else?

I have found a select listener, but thats all i can find.

答:
I would do it the other way around, as this is easier and more logical: The indentation shouldn't be part of the value in the first place. I would modify the combo's template:

```<code>tpl: '<tpl for="."><div class="x-combo-list-item"><tpl if="indent">    </tpl>{text}</div></tpl>',
</code>```

and add a boolean to the store items:

```<code>fields: [{
    name:'indent',
    type:'boolean'
</code>```

which, if set to true, will indent the value corresponding to the store record.

If you want different indents, you can try to use a template function to generate your indent based on a number. The following sample only works in recent versions of ExtJS, YMMV:

```<code>tpl: new Ext.XTemplate(
    '<tpl for="."><div class="x-combo-list-item">{[ this.getIndent(values.indent) ]}{text}</div></tpl>',
    {
        getIndent: function(indent) {
            var s = "";
            for(var i=0;i<indent; i++) s= s+" ";
            return s;
        }
    }
),
store:{
    inlineData:[{
        text: 'A',
        indent:2
    },{
        text: 'B',
        indent: 4
    }],
}
</code>```

Body:
So im working with ExtJS 3.3, I have a combo box which im filling with values, some of the values need to be indented in the list when its expanded, so I have used   this works great when the combo is expanded, but once i select an item, the   actually shows in the combobox when its collapsed.

For instance; when its expanded, my values show as

        this is my indented value

and this is exactly what i want, but when collapsed, the value shows as

    this is my indented value

Is there any way i can trim the spaces from the front of the value on the fly so in the expanded view it shows with the indents, but collapsed it just shows the value and nothing else?

I have found a select listener, but thats all i can find.

Body:
I would do it the other way around, as this is easier and more logical: The indentation shouldn't be part of the value in the first place. I would modify the combo's template:

tpl: '<tpl for="."><div class="x-combo-list-item"><tpl if="indent">&nbsp;&nbsp;&nbsp;&nbsp;</tpl>{text}</div></tpl>',

and add a boolean to the store items:

fields: [{
    name:'indent',
    type:'boolean'

which, if set to true, will indent the value corresponding to the store record.

If you want different indents, you can try to use a template function to generate your indent based on a number. The following sample only works in recent versions of ExtJS, YMMV:

tpl: new Ext.XTemplate(
    '<tpl for="."><div class="x-combo-list-item">{[ this.getIndent(values.indent) ]}{text}</div></tpl>',
    {
        getIndent: function(indent) {
            var s = "";
            for(var i=0;i<indent; i++) s= s+"&nbsp;";
            return s;
        }
    }
),
store:{
    inlineData:[{
        text: 'A',
        indent:2
    },{
        text: 'B',
        indent: 4
    }],
}


问:
Are BouncyCastle's AES engines hardware accelerated?
I wonder if anyone knows if BouncyCastle's AES engines support hardware acceleration, e.g., make use of AES-NI. My understanding is that some "native code" need to be invoked in order to be accelerated, but I couldn't find any.

Are BC's AES engines completely software implementations? If so, that's not so good given that many modern MCUs/CPUs provide AES modules - correct? A similar question was asked about 5 years ago, but the situation was somewhat different as hardware acceleration was not prevalent.

答:
According to Bouncy Castle it is not supported and will not be supported:
https://github.com/bcgit/bc-java/issues/221</p>


问:
Cross Domain access to USPS API
I am trying to make a CORS request to USPS website with jquery, I have gotten it to work on my work pc, with internet explorer only for some reason. and I get a CORS error on the newer version of IE and also Firefox and Chrome.

In a question I wasn't allowed to comment on due to not having a rep, they suggested sending it to a server first then making the request instead of from the browser, Can somebody explain this to me? How can I host a server with javascript, I simply need to use this API to get tracking information and this stupid CORS restriction is a pain in my rear every time I try to do something like this.

Please help.

```<code>  function sendTrackingRequest(x) {
        var requestURL = "http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML="
        var request = new XMLHttpRequest();
        request.open( "GET", requestURL + trackNumberToBeTracked, true);
        // various sanitizations should be employed on the backend when dealing with user input
        request.responseType = "text/xml";
        request.setRequestHeader( "Content-Type", "xml" );
        request.addEventListener( "readystatechange", function() {
            if ( request.readyState == 4 ) {
                if ( request.status == 200 ) {
                    // process response
                    var trackingStatus = request.response
                    showResult(trackingStatus);
                    console.log(trackNumberToBeTracked);
                } else {
                    alert("error")
                }
            }
        }, false );
        request.send();
    }
});
</code>```

答:
Okay everyone.

Please bear with me I have made a huge beginner mistake and figured out what was wrong with Slakes help.

So in my code, I had a function with a similar name which was a .response not defined. I got this error after I listened to the first helper who said a contenttype was not necesarry for a Get request which he was right after further research.

After i removed all the bad functions which i was testing, I finally got my response to work. here is my code

```<code>$(document).ready(function() {
$('#trackButton').click(function() {
    var enteredNumber = $('#trackingNumbers').value;
    var trackNumberToBeTracked = '<TrackRequest USERID="648FOOTL0638">    <TrackID ID="9405510200839104436417"></TrackID></TrackRequest>'
    sendTrackingRequest();

    function sendTrackingRequest(x) {
        var requestURL = "http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML="
        var request = new XMLHttpRequest();
        request.open( "GET", requestURL + trackNumberToBeTracked, true);
        // various sanitizations should be employed on the backend when dealing with user input
        request.addEventListener( "readystatechange", function() {
            if ( request.readyState == 4 ) {
                if ( request.status == 200 ) {
                    // process response
                    var trackingStatus = request.response
                    alert(trackingStatus);
                    console.log(trackNumberToBeTracked);
                } else {
                    alert("error")
                }
            }
        }, false );
        request.send();
    }
});
</code>```

Here is the code that was below it, giving me the error after I took out set header type (which solved my CORS issue as POST requests are not allowed on the api)

```<code>function showResult(request) {
    var xmlDoc = request.response.documentElement;
    removeWhitespace(xmlDoc);
    var outputResult = $("#BodyRows");
    var rowData = xmlDoc.$("#Employee");

    addTableRowsFromXmlDoc(rowData,outputResult);
};
</code>```

});

Title: Cross Domain access to USPS API

Body:
I am trying to make a CORS request to USPS website with jquery, I have gotten it to work on my work pc, with internet explorer only for some reason. and I get a CORS error on the newer version of IE and also Firefox and Chrome.

In a question I wasn't allowed to comment on due to not having a rep, they suggested sending it to a server first then making the request instead of from the browser, Can somebody explain this to me? How can I host a server with javascript, I simply need to use this API to get tracking information and this stupid CORS restriction is a pain in my rear every time I try to do something like this.

Please help.

  function sendTrackingRequest(x) {
        var requestURL = "http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML="
        var request = new XMLHttpRequest();
        request.open( "GET", requestURL + trackNumberToBeTracked, true);
        // various sanitizations should be employed on the backend when dealing with user input
        request.responseType = "text/xml";
        request.setRequestHeader( "Content-Type", "xml" );
        request.addEventListener( "readystatechange", function() {
            if ( request.readyState == 4 ) {
                if ( request.status == 200 ) {
                    // process response
                    var trackingStatus = request.response
                    showResult(trackingStatus);
                    console.log(trackNumberToBeTracked);
                } else {
                    alert("error")
                }
            }
        }, false );
        request.send();
    }
});

Body:
Okay everyone.

Please bear with me I have made a huge beginner mistake and figured out what was wrong with Slakes help.

So in my code, I had a function with a similar name which was a .response not defined. I got this error after I listened to the first helper who said a contenttype was not necesarry for a Get request which he was right after further research.

After i removed all the bad functions which i was testing, I finally got my response to work. here is my code

$(document).ready(function() {
$('#trackButton').click(function() {
    var enteredNumber = $('#trackingNumbers').value;
    var trackNumberToBeTracked = '<TrackRequest USERID="648FOOTL0638">    <TrackID ID="9405510200839104436417"></TrackID></TrackRequest>'
    sendTrackingRequest();

    function sendTrackingRequest(x) {
        var requestURL = "http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML="
        var request = new XMLHttpRequest();
        request.open( "GET", requestURL + trackNumberToBeTracked, true);
        // various sanitizations should be employed on the backend when dealing with user input
        request.addEventListener( "readystatechange", function() {
            if ( request.readyState == 4 ) {
                if ( request.status == 200 ) {
                    // process response
                    var trackingStatus = request.response
                    alert(trackingStatus);
                    console.log(trackNumberToBeTracked);
                } else {
                    alert("error")
                }
            }
        }, false );
        request.send();
    }
});

Here is the code that was below it, giving me the error after I took out set header type (which solved my CORS issue as POST requests are not allowed on the api)

function showResult(request) {
    var xmlDoc = request.response.documentElement;
    removeWhitespace(xmlDoc);
    var outputResult = $("#BodyRows");
    var rowData = xmlDoc.$("#Employee");

    addTableRowsFromXmlDoc(rowData,outputResult);
};

});


问:
Not able to post the select option value in express js
I wanted to make a signup page.In my user model schema , I have a security question and answer field for the users to input.The security questions are in the select html tag for the users to choose.My user schema model looks like this-

```<code>   var mongoose = require('mongoose');
   // declare schema object.
   var Schema = mongoose.Schema;

   var userSchema = new Schema({

          userName          : {type:String,default:'',required:true},
          firstName             : {type:String,default:''},
          lastName              : {type:String,default:''},
          email             : {type:String,default:''},
          mobileNumber          : {type:Number,default:''},
          password          : {type:String},
          securityQusetion  : {type:String},
          securityAnswer        : {type:String}

          });

          mongoose.model('User',userSchema);
</code>```

I'm using jade templating engine.On the mongodb database I get all the other data except security question.My jade view file and the signup route is here
 jsfiddle

答:
This could only be a minor thing but I noticed that in the following line:

```<code>securityQusetion  : {type:String}
</code>```

"Security Question" was spelled incorrectly. Perhaps the typo is causing errors in Jade file.

Body:
I wanted to make a signup page.In my user model schema , I have a security question and answer field for the users to input.The security questions are in the select html tag for the users to choose.My user schema model looks like this-

   var mongoose = require('mongoose');
   // declare schema object.
   var Schema = mongoose.Schema;

   var userSchema = new Schema({

          userName          : {type:String,default:'',required:true},
          firstName             : {type:String,default:''},
          lastName              : {type:String,default:''},
          email             : {type:String,default:''},
          mobileNumber          : {type:Number,default:''},
          password          : {type:String},
          securityQusetion  : {type:String},
          securityAnswer        : {type:String}

          });

          mongoose.model('User',userSchema);

I'm using jade templating engine.On the mongodb database I get all the other data except security question.My jade view file and the signup route is here
 jsfiddle

Body:
This could only be a minor thing but I noticed that in the following line:

securityQusetion  : {type:String}

"Security Question" was spelled incorrectly. Perhaps the typo is causing errors in Jade file.


问:
How to combine nodes by alternating data structures? - Java
I am given two data structures of Nodes, and I am supposed to combine them into one single Node with alternating data structures. The data structures may or may not be of equal lengths.

I have already attempted this problem and I have checked over my code, but it still isn't correct. I have written other methods that I use in this one particular method, so I will post the code for those too. I came up with my method by looking at examples of how the data organization for this particular problem works.

Get the head of the Node list:

```<code>public static <E> Node<E> getHead(Node<E> current) {
    Node<E> head = null;
    while (current != null) {
        head = current;
        current = current.previous;
    }
    return head;
}
</code>```

Get the number of Nodes in the data structure:

```<code>public static <E> int countNodes(Node<E> current) {
    int count = 0;
    while (current != null) {
        count++;
        current = current.next;
    }
    return count;
}
</code>```

Note that I have tested these two methods (getHead and countNodes) and they have proven to be correct. I have posted them to see if they are missing something.

The Node class itself was written by my instructor and has been tested to be correctly written

```<code>public static class Node<E> {
    public Node<E> next;
    public Node<E> previous;
    public E data;

    public Node(E d) {
        data = d;
    }

    public String toString() {
        if (next == null)
            return "";
        return data + ", " + next.toString();
    }

    public boolean equals(Object o) {
        Node<E> node = (Node<E>) o;
        if (node == null)
            return false;
        Node<E> current = this;
        while (current != null && node != null) {
            if (!current.data.equals(node.data)) {
                return false;
            }
            current = current.next;
            node = node.next;
        }
        return current == null && node == null;
    }
}
</code>```

Finally, the method that I am having problems with: (Updated with edits)

```<code>public static <E> Node<E> combineNodes(Node<E> current, Node<E> current2) {
    Node<E> newNode = null;
    int currentSize = countNodes(current);
    int current2Size = countNodes(current2);
    int size = Math.max(currentSize, current2Size);

    for (int i = 0; i < size; i++) {
        if (i <= currentSize - 1) {
            Node<E> node = new Node<E>(current.data);
            newNode.next = node;
            node.previous = newNode;
            newNode = newNode.next;
            current = current.next;
        }
        if (i <= current2Size - 1) {
            Node<E> node = new Node<E>(current2.data);
            newNode.next = node;
            node.previous = newNode;
            newNode = newNode.next;
            current2 = current2.next;
        }
    }

    return getHead(newNode);
}
</code>```

Again, I have looked through the code and I feel like it should work. Is there anything that I am missing or doing wrong?

Edit

I should have included the test case that I was given. My instructor is using the JUnit test case library for the assignment. This is the test case that I have to pass:

```<code>@Test
public void combineNodesTest1() {
    LinkedData.Node<String> node = makeStructure(10); // Makes a data structure of Nodes from "Fred 0" to "Fred 9"
    LinkedData.Node<String> node2 = makeStructure(10);
    LinkedData.Node<String> ret = new LinkedData.Node<String>("Fred 0");
    ret.next = new LinkedData.Node<String>("Fred 0");
    LinkedData.Node<String> r = ret.next;
        for(int i = 1; i<10;i++) {
        r.next = new LinkedData.Node<String>("Fred "+i);
        r = r.next;
        r.next = new LinkedData.Node<String>("Fred "+i);
        r = r.next;
    }
    LinkedData.Node<String> answer = LinkedData.combineNodes(node, node2); // Method that I wrote
    assertEquals(ret, answer);
}
</code>```

The makeStructure() method is correctly written.

Edit 2

I have updated the code to actually link the nodes together, but it is still wrong. I'd like to know what I'm doing wrong now.

Thanks,
Steward

答:
From my perspective, you don't change any of pointers (next, previous) in your combineNodes method. You only traverse the structure. What is missing in the first if is

```<code>newNode = current;
newNode.next = current2;
current = current.next;
</code>```

and then the following in the second if

```<code>newNode = current2;
newNode.next = current;
current2 = current2.next;
</code>```

Body:
I am given two data structures of Nodes, and I am supposed to combine them into one single Node with alternating data structures. The data structures may or may not be of equal lengths.

I have already attempted this problem and I have checked over my code, but it still isn't correct. I have written other methods that I use in this one particular method, so I will post the code for those too. I came up with my method by looking at examples of how the data organization for this particular problem works.

Get the head of the Node list:

public static <E> Node<E> getHead(Node<E> current) {
    Node<E> head = null;
    while (current != null) {
        head = current;
        current = current.previous;
    }
    return head;
}

Get the number of Nodes in the data structure:

public static <E> int countNodes(Node<E> current) {
    int count = 0;
    while (current != null) {
        count++;
        current = current.next;
    }
    return count;
}

Note that I have tested these two methods (getHead and countNodes) and they have proven to be correct. I have posted them to see if they are missing something.

The Node class itself was written by my instructor and has been tested to be correctly written

public static class Node<E> {
    public Node<E> next;
    public Node<E> previous;
    public E data;

    public Node(E d) {
        data = d;
    }

    public String toString() {
        if (next == null)
            return "";
        return data + ", " + next.toString();
    }

    public boolean equals(Object o) {
        Node<E> node = (Node<E>) o;
        if (node == null)
            return false;
        Node<E> current = this;
        while (current != null && node != null) {
            if (!current.data.equals(node.data)) {
                return false;
            }
            current = current.next;
            node = node.next;
        }
        return current == null && node == null;
    }
}

Finally, the method that I am having problems with: (Updated with edits)

public static <E> Node<E> combineNodes(Node<E> current, Node<E> current2) {
    Node<E> newNode = null;
    int currentSize = countNodes(current);
    int current2Size = countNodes(current2);
    int size = Math.max(currentSize, current2Size);

    for (int i = 0; i < size; i++) {
        if (i <= currentSize - 1) {
            Node<E> node = new Node<E>(current.data);
            newNode.next = node;
            node.previous = newNode;
            newNode = newNode.next;
            current = current.next;
        }
        if (i <= current2Size - 1) {
            Node<E> node = new Node<E>(current2.data);
            newNode.next = node;
            node.previous = newNode;
            newNode = newNode.next;
            current2 = current2.next;
        }
    }

    return getHead(newNode);
}

Again, I have looked through the code and I feel like it should work. Is there anything that I am missing or doing wrong?

Edit

I should have included the test case that I was given. My instructor is using the JUnit test case library for the assignment. This is the test case that I have to pass:

@Test
public void combineNodesTest1() {
    LinkedData.Node<String> node = makeStructure(10); // Makes a data structure of Nodes from "Fred 0" to "Fred 9"
    LinkedData.Node<String> node2 = makeStructure(10);
    LinkedData.Node<String> ret = new LinkedData.Node<String>("Fred 0");
    ret.next = new LinkedData.Node<String>("Fred 0");
    LinkedData.Node<String> r = ret.next;
        for(int i = 1; i<10;i++) {
        r.next = new LinkedData.Node<String>("Fred "+i);
        r = r.next;
        r.next = new LinkedData.Node<String>("Fred "+i);
        r = r.next;
    }
    LinkedData.Node<String> answer = LinkedData.combineNodes(node, node2); // Method that I wrote
    assertEquals(ret, answer);
}

The makeStructure() method is correctly written.

Edit 2

I have updated the code to actually link the nodes together, but it is still wrong. I'd like to know what I'm doing wrong now.

Thanks,
Steward

Body:
From my perspective, you don't change any of pointers (next, previous) in your combineNodes method. You only traverse the structure. What is missing in the first if is

newNode = current;
newNode.next = current2;
current = current.next;

and then the following in the second if

newNode = current2;
newNode.next = current;
current2 = current2.next;


答:
You want something like this:

```<code>$(function() {
  $('#myformid').submit();
});
</code>```

See the documentation for jQuery's submit().

And see this working demo: http://jsfiddle.net/8hg8s/

Title: JS: Posting form directly

Body:
If on document.ready, I want my form to auto post itself, is this possible?

So when the document has loaded, then it posts itself and takes to the action="" (in this case is ?upload=true).

I heard about $.post() jquery, but this is just for posting in the background?

Body:
You want something like this:

$(function() {
  $('#myformid').submit();
});

See the documentation for jQuery's submit().

And see this working demo: http://jsfiddle.net/8hg8s/


问:
How do I center a row of images?
English major here; I know practically nothing about coding, so please use VERY BASIC language. I need to know for my book publishing class website. I'm trying to align rows of images for our "Team Members" page. How do I do that? Below is the first row of images. Right now, they're shifted to the left.

 Publishers

 Mike
Course Director

 Mackenzie
Publisher

 Liz
Associate Publisher

 Mia
Publishing Assistant

```

答:
Modify your code as follows.</p>

```<code><!-- First Set -->
    <h3> Publishers </h3>
    <div class="box alt">
        <div class="row 50% uniform" style="left: 50%;position: absolute;> <!-- % changes space between pictures -->
            <div class="2u"><span class="image fit"><img src="images/headshots/mike.JPG" alt="" /><p> Mike<br>Course Director</p></span></div>
            <div class="2u"><span class="image fit"><img src="images/headshots/mackenzie.JPG" alt="" /><p> Mackenzie<br>Publisher</p></span></div>
            <div class="2u"><span class="image fit"><img src="images/headshots/liz.JPG" alt="" /><p> Liz<br>Associate Publisher</p></span></div>
            <div class="2u"><span class="image fit"><img src="images/headshots/mia.JPG" alt="" /><p> Mia<br>Publishing Assistant</p></span></div>
        </div>
    </div>
</code>```

Title: How do I center a row of images?

Body:
Modify your code as follows.

<!-- First Set -->
    <h3> Publishers </h3>
    <div class="box alt">
        <div class="row 50% uniform" style="left: 50%;position: absolute;> <!-- % changes space between pictures -->
            <div class="2u"><span class="image fit"><img src="images/headshots/mike.JPG" alt="" /><p> Mike<br>Course Director</p></span></div>
            <div class="2u"><span class="image fit"><img src="images/headshots/mackenzie.JPG" alt="" /><p> Mackenzie<br>Publisher</p></span></div>
            <div class="2u"><span class="image fit"><img src="images/headshots/liz.JPG" alt="" /><p> Liz<br>Associate Publisher</p></span></div>
            <div class="2u"><span class="image fit"><img src="images/headshots/mia.JPG" alt="" /><p> Mia<br>Publishing Assistant</p></span></div>
        </div>
    </div>


问:
VisJs - Get number of edges of a specific node
I want to find the number of edges which are connected to a specific node in visjs/javascript.

To illustrate my needs I have made up this example:

```<code><html>
<head>
    <title>Get number of edges of a specific node</title>
    <script type="text/javascript" src="/home/altug/Downloads/BTAGViewer/libs/visjs/vis.min.js"></script>
</head>
<body>
    <div id="mynetwork"></div>
    <script type="text/javascript">
      // create an array with nodes
      var nodes = new vis.DataSet([
        {id: "A", label: 'label A'},
        {id: "B", label: 'label B'},
        {id: "C", label: 'label C'},
        {id: "D", label: 'label D'},
        {id: "E", label: 'label E'}
      ]);

      // create an array with edges
      var edges = new vis.DataSet([
        {from: "A", to: "C"},
        {from: "A", to: "B"},
        {from: "B", to: "D"},
        {from: "B", to: "E"}
      ]);

      // create a network
      var container = document.getElementById('mynetwork');
      var data = {
        nodes: nodes,
        edges: edges
      };
      var options = {};
      var network = new vis.Network(container, data, options);

      var some_id = "B";
      var some_node = nodes.get(some_id);
      console.dir(some_node);

      console.log(/*magically retrieve the number of edges for node "B" ---> 3 (for this graph)*/);
    </script>
</body>
</code>```

I know I could iterate over the edges and count the occurences of the specific node id, like for example:

```<code>for(var i = 0; i < edges.get().length; i++){
    ...
}
</code>```

But isn't there another possibility using vis.js built-in capabilities?

答:
Other suggested approaches iterate over all the edges in the network, looking only at the edges DataSet. But the network DataSet itself offers a getConnectedEdges() function, returning an array of edge ids when a nodeId is specified. So to get your count, it's just

```<code>network.getConnectedEdges(nodeId).length
</code>```

where nodeId is the id of the node you are interested in.

It looks like internally, nodes and edges are accessed directly by [nodeId],  without having to do an iteration, so that access time in functions like getConnectedEdges(nodeId) should be roughly constant, rather than linear in the numbers of edges.

That should make a huge difference in large networks.

Body:
I want to find the number of edges which are connected to a specific node in visjs/javascript.

To illustrate my needs I have made up this example:

    <title>Get number of edges of a specific node</title>

I know I could iterate over the edges and count the occurences of the specific node id, like for example:

for(var i = 0; i < edges.get().length; i++){
    ...
}

But isn't there another possibility using vis.js built-in capabilities?

Body:
Other suggested approaches iterate over all the edges in the network, looking only at the edges DataSet. But the network DataSet itself offers a getConnectedEdges() function, returning an array of edge ids when a nodeId is specified. So to get your count, it's just

network.getConnectedEdges(nodeId).length

where nodeId is the id of the node you are interested in.

It looks like internally, nodes and edges are accessed directly by [nodeId],  without having to do an iteration, so that access time in functions like getConnectedEdges(nodeId) should be roughly constant, rather than linear in the numbers of edges.

That should make a huge difference in large networks.


问:
text on the right of the pic, js
I have a div and inside that div i have a pic and a text. Right now text goes at the bottom of the pic and if the text is large then we cannot see the whole text , what i want is pic on the left side and text on the right side of the pic and everything should fit inside the broder, please have a look at the pic for more info , any help will be highly appreciated.

答:
set float: left for the image may be what you need

https://jsfiddle.net/1kvykb18/

Title: text on the right of the pic, js


问:
Monitoring Apache Tomcat applications in production environment
How do you ensure that your applications in production are up and running?
How do you alert your team of developers if something goes wrong?

I'm asking this because I'm writing a bash script to check for this issue, I'd like to know if there is a smarter or more complete way to achieve this.
The idea behind is this command: wget -q -O - APPLICATION_URL_HERE | grep 'ERROR 404, I still have to check all kinds of HTTP errors, but you can get the point of what I mean.
If an application is recognized to not be running a mail is sent to the list of the team it belongs to.

All my applications are running on Apache Tomcat.

答:
It depends on how detailed on what you sight is doing that you want to be.  There are a number of companies that offer products and services that will monitor web applications to make sure they are fully running, and if not, explain where the error is and what it is doing.  I think Empirix has one with their web testing suite, but it has been a while since I have used it, so they may have removed it then. There are lots of others too.  The ones I have seen that do this are really automated tests that go through the site and report any errors found.

If you are really serious (as in wanting to spend money to make sure your sites are up), I would do a search on Gartner around web site availability.  I am almost positive they are going to have a magic quadrant around this topic, and it will give you a good place to start.

I would say what you are doing isn't bad, you're just reinventing the wheel a little, and it probably won't be a thorough as the companies that focus on it.  That being said, yours is definitely the cheaper alternative, and it may accomplish what you need.

OwnerDisplayName: Montecristo

LastEditorDisplayName: Patrick Cuff

OwnerDisplayName: Kevin


问:
How to check whether input value is integer or float?
How to check whether input value is integer or float?

Suppose 312/100=3.12
Here i need check whether 3.12 is a float value or integer value, i.e., without any decimal place value.

答:
Do this to distinguish that.

If for example your number is 3.1214 and stored in num but you don't know kind of num:

```<code>num = 3.1214
// cast num to int
int x = (int)num;
if(x == num)
{
  // num is a integer
}
else
  // num is float
}
</code>```

In this example we see that num is not integer.

Body:
Do this to distinguish that.

If for example your number is 3.1214 and stored in num but you don't know kind of num:

num = 3.1214
// cast num to int
int x = (int)num;
if(x == num)
{
  // num is a integer
}
else
  // num is float
}

In this example we see that num is not integer.


答:
For designing and DOM styling issue, you have to choose CSS tag. There I tried to do this by seeing your image try this code instead. For float your image you can only use float: left or you can try this code.

```<code>HTML :

<div class="post-container">
    <h3 class="post-title">Post title</h3>
    <div class="post-thumb"><img src="your image url"/></div>
    <div class="post-content">
        <p>this is a test this is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a test </p></div>
</div>

CSS:

.post-container {
    margin: 20px 20px 0 0;
    border: 1px solid #333;
    overflow: auto
}
.post-thumb {
    float: left
}
.post-thumb img {
    display: block
    height : 200px;width:200px;
}
.post-content {
    margin-left: 210px
}
.post-title {
    font-weight: bold;
    font-size: 200%;
    padding: 9px;
    background: #ccc
}
</code>```

Title: text on the right of the pic, js

Body: I have a div and inside that div i have a pic and a text. Right now text goes at the bottom of the pic and if the text is large then we cannot see the whole text , what i want is pic on the left side and text on the right side of the pic and everything should fit inside the broder, please have a look at the pic for more info , any help will be highly appreciated.

Body:
For designing and DOM styling issue, you have to choose CSS tag. There I tried to do this by seeing your image try this code instead. For float your image you can only use float: left or you can try this code.

HTML :

<div class="post-container">
    <h3 class="post-title">Post title</h3>
    <div class="post-thumb"><img src="your image url"/></div>
    <div class="post-content">
        <p>this is a test this is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a test </p></div>
</div>

CSS:

.post-container {
    margin: 20px 20px 0 0;
    border: 1px solid #333;
    overflow: auto
}
.post-thumb {
    float: left
}
.post-thumb img {
    display: block
    height : 200px;width:200px;
}
.post-content {
    margin-left: 210px
}
.post-title {
    font-weight: bold;
    font-size: 200%;
    padding: 9px;
    background: #ccc
}


问:
How do I override a method in a subclass in Java?
First off, I need to override the method:

public boolean recordBid(int bidPrice, String sellerID)

so it manages the recording of a bid.

To begin with, if the bidPrice is greater than the buyNowprice then this bidPrice should reset to the buyNowPrice. After the bid price has been reset (if required) the method should invoke the superclass version of the recordBid() method, passing along the bid price and seller ID as parameters, and trap the result that it returns (ie. store it in a variable), so that it can be checked to determine if the bid price has been recorded successfully.

Im a little confused on how I need to trap the result and also not sure if Im doing it the right way here?.

My original recordBid() method:

```<code>public boolean recordBid(int bidPrice, String bidderID)
{
  if (saleEnded == true)
  {
     return false;
  }

  else if (bidPrice <= this.highestBid)
  {
     return false;
  }

  else
  {
     this.highestBid = bidPrice;
     this.bidderID = bidderID;
     return true;
  }
}
</code>```

My subclass, where I need to overwrite recordBid()

```<code>public class BuyItNowSale extends ItemSale {

//instance variables
private double buyNowPrice;
private boolean acceptingNearestOffer;

public BuyItNowSale(String itemNumber, String itemDescription, String itemCondition,
        String sellerID, boolean acceptingNearestOffer) {

super(itemNumber, itemDescription, itemCondition, sellerID);

    this.acceptingNearestOffer = false;

//overidden recordBid() method

public boolean recordBid(int bidPrice, String bidderID)  {

    if(bidPrice > buyNowPrice) {

        bidPrice = 0;
        super.recordBid(bidPrice, sellerID);

    }

}
</code>```

答:
With your requirement

if the bidPrice is greater than the buyNowprice then this bidPrice should reset to the buyNowPrice

Your method should be:

```<code>@Override
public boolean recordBid(int bidPrice, String bidderID)  {
    if(bidPrice > buyNowPrice) {
        bidPrice = (int) buyNowPrice;
    }
    return super.recordBid(bidPrice, sellerID);
}
</code>```

Body:
First off, I need to override the method:

public boolean recordBid(int bidPrice, String sellerID)

so it manages the recording of a bid.

To begin with, if the bidPrice is greater than the buyNowprice then this bidPrice should reset to the buyNowPrice. After the bid price has been reset (if required) the method should invoke the superclass version of the recordBid() method, passing along the bid price and seller ID as parameters, and trap the result that it returns (ie. store it in a variable), so that it can be checked to determine if the bid price has been recorded successfully.

Im a little confused on how I need to trap the result and also not sure if Im doing it the right way here?.

My original recordBid() method:

public boolean recordBid(int bidPrice, String bidderID)
{
  if (saleEnded == true)
  {
     return false;
  }

  else if (bidPrice <= this.highestBid)
  {
     return false;
  }

  else
  {
     this.highestBid = bidPrice;
     this.bidderID = bidderID;
     return true;
  }
}

My subclass, where I need to overwrite recordBid()

public class BuyItNowSale extends ItemSale {

//instance variables
private double buyNowPrice;
private boolean acceptingNearestOffer;

public BuyItNowSale(String itemNumber, String itemDescription, String itemCondition,
        String sellerID, boolean acceptingNearestOffer) {

super(itemNumber, itemDescription, itemCondition, sellerID);

    this.acceptingNearestOffer = false;

//overidden recordBid() method

public boolean recordBid(int bidPrice, String bidderID)  {

    if(bidPrice > buyNowPrice) {

        bidPrice = 0;
        super.recordBid(bidPrice, sellerID);

    }

}

Body:
With your requirement

if the bidPrice is greater than the buyNowprice then this bidPrice should reset to the buyNowPrice

Your method should be:

@Override
public boolean recordBid(int bidPrice, String bidderID)  {
    if(bidPrice > buyNowPrice) {
        bidPrice = (int) buyNowPrice;
    }
    return super.recordBid(bidPrice, sellerID);
}


问:
Connecting to Mysql using Jhipster
I have generated an spring boot + angular application . imported entities with jdl. working properly with h2 . I am newbie and want to use mysql.I have configured datasource in application-dev.yml with following code.

```<code>datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:mysql://localhost:3306/blogdb?useUnicode=true&characterEncoding=utf8&useSSL=false
    username: name
    password:pass
h2:
    console:
        enabled: false
     hikari:
            data-source-properties:
                cachePrepStmts: true
                prepStmtCacheSize: 250
                prepStmtCacheSqlLimit: 2048
                useServerPrepStmts: true
    jpa:
        database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
    show-sql: true
</code>```

2) I have updated my pom configuration from h2 to mysql with following code.

```<code><plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
            <configuration>
                <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
                <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
                <driver>com.mysql.jdbc.Driver</driver>
                <url>jdbc:mysql://localhost:3306/blogdb</url>
                <defaultSchemaName>blogdb</defaultSchemaName>
                <username>name</username>
                <password>**</password>
                <referenceUrl>hibernate:spring:pt.farol.destfinder.domain?dialect=org.hibernate.dialect.MySQLInnoDBDialect&hibernate.ejb.naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy</referenceUrl>
                <verbose>true</verbose>
                <logging>debug</logging>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.javassist</groupId>
                    <artifactId>javassist</artifactId>
                    <version>${javassist.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.liquibase.ext</groupId>
                    <artifactId>liquibase-hibernate5</artifactId>
                    <version>${liquibase-hibernate5.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                    <version>${project.parent.version}</version>
                </dependency>
                <dependency>
                    <groupId>javax.validation</groupId>
                    <artifactId>validation-api</artifactId>
                    <version>${validation-api.version}</version>
                </dependency>
            </dependencies>
        </plugin>
</code>```

PROBLEM when i run my project i am getting following error .

```<code>    The Class-Path manifest attribute in C:\..\..\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar referenced one or more files that do not exist: C:\..\.\.m2\repository\org\liquibase\liquibase-core\3.5.3\lib\snakeyaml-1.13.jar
22:58:49.740 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
22:58:49.751 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
22:58:49.751 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/G:/Java%20Projects/target/classes/]
22:58:52.636 [restartedMain] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/G:/Java%20Projects/target/classes/]
</code>```

Edit
git repository link

yo-rc.json file

```<code>{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.beam"
    },
    "jhipsterVersion": "4.10.2",
    "baseName": "beam",
    "packageName": "com.beam",
    "packageFolder": "com/beam",
    "serverPort": "8080",
    "authenticationType": "session",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "rememberMeKey": "801a22f60c33f866035c634e04c3b5b096fdedc6",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}
</code>```

答:
Normally in application-dev.yml spacing is considered so in password to be

yours,
datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:mysql://localhost:3306/blogdb?useUnicode=true&characterEncoding=utf8&useSSL=false
    username: name
    password:pass
what to be done is,

datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:mysql://localhost:3306/blogdb?useUnicode=true&characterEncoding=utf8&useSSL=false
    username: name
    password: pass

just check it out

Title: Connecting to Mysql using Jhipster

Body:
I have generated an spring boot + angular application . imported entities with jdl. working properly with h2 . I am newbie and want to use mysql.I have configured datasource in application-dev.yml with following code.

datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:mysql://localhost:3306/blogdb?useUnicode=true&characterEncoding=utf8&useSSL=false
    username: name
    password:pass
h2:
    console:
        enabled: false
     hikari:
            data-source-properties:
                cachePrepStmts: true
                prepStmtCacheSize: 250
                prepStmtCacheSqlLimit: 2048
                useServerPrepStmts: true
    jpa:
        database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
    show-sql: true

2) I have updated my pom configuration from h2 to mysql with following code.

<plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
            <configuration>
                <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
                <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
                <driver>com.mysql.jdbc.Driver</driver>
                <url>jdbc:mysql://localhost:3306/blogdb</url>
                <defaultSchemaName>blogdb</defaultSchemaName>
                <username>name</username>
                <password>**</password>
                <referenceUrl>hibernate:spring:pt.farol.destfinder.domain?dialect=org.hibernate.dialect.MySQLInnoDBDialect&hibernate.ejb.naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy</referenceUrl>
                <verbose>true</verbose>
                <logging>debug</logging>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.javassist</groupId>
                    <artifactId>javassist</artifactId>
                    <version>${javassist.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.liquibase.ext</groupId>
                    <artifactId>liquibase-hibernate5</artifactId>
                    <version>${liquibase-hibernate5.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                    <version>${project.parent.version}</version>
                </dependency>
                <dependency>
                    <groupId>javax.validation</groupId>
                    <artifactId>validation-api</artifactId>
                    <version>${validation-api.version}</version>
                </dependency>
            </dependencies>
        </plugin>

PROBLEM when i run my project i am getting following error .

    The Class-Path manifest attribute in C:\..\..\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar referenced one or more files that do not exist: C:\..\.\.m2\repository\org\liquibase\liquibase-core\3.5.3\lib\snakeyaml-1.13.jar
22:58:49.740 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
22:58:49.751 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
22:58:49.751 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/G:/Java%20Projects/target/classes/]
22:58:52.636 [restartedMain] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/G:/Java%20Projects/target/classes/]

Edit
git repository link

yo-rc.json file

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.beam"
    },
    "jhipsterVersion": "4.10.2",
    "baseName": "beam",
    "packageName": "com.beam",
    "packageFolder": "com/beam",
    "serverPort": "8080",
    "authenticationType": "session",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "rememberMeKey": "801a22f60c33f866035c634e04c3b5b096fdedc6",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}


问:
Sublime Text requires restart on settings changes to take effect
My Sublime Text 3 ( but also applies to ST2 as I experienced the same issue before I switched to ST3 ) requires restart for any settings changes to take effect. This happens on a Mac Mini in the office but not on my Macbook Pro ( which is pretty much the same setup ).

I do sync settings over Dropbox by symlinking Application Support/Sublime Text 3 folder to Dropbox. However, I can recall it happening even before I did that.

Any ideas how to make it apply settings changes immediately?

答:
In Mac:

"Cmd + Shift + P"

Enter: "Install Packages"

Enter: "Restart"

Now, you should see the "Restart" option under "File" in me main menu.


问:
Why does SerializeJSON return an int with .0?
The following code:

```<code><cfscript>
struct = StructNew();
struct.x = 1;
struct.y = 2;
</cfscript>

<cfoutput>#SerializeJSON(struct)#</cfoutput>
</code>```

Results in the following output:

```<code>{"Y":2.0,"X":1.0}
</code>```

So my question is why does the .0 get added? and is there some way to remove it?

答:
Adding a trailing .0 to numbers was a known "feature" in the way serializeJson was implemented  in release 8. It is fixed/changed in CF 9.01 on my home XP machine your code returns</p>

```<code>{"Y":"2","X":"1"}
</code>```

Body:
The following code:

<cfscript>
struct = StructNew();
struct.x = 1;
struct.y = 2;
</cfscript>

<cfoutput>#SerializeJSON(struct)#</cfoutput>

Results in the following output:

{"Y":2.0,"X":1.0}

So my question is why does the .0 get added? and is there some way to remove it?

Body:
Adding a trailing .0 to numbers was a known "feature" in the way serializeJson was implemented  in release 8. It is fixed/changed in CF 9.01 on my home XP machine your code returns

{"Y":"2","X":"1"}


问:
ionic running issue in windows
i am Getting below error while i am running the same....pls help</p>

```<code>E:\App_testing\MyFirstApp>ionic serve
{ Error
    at new Exception (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\lib\errors.js:8:23)
    at new FatalException (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\lib\errors.js:17:9)
    at Config.<anonymous> (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\lib\config.js:61:35)
    at Generator.throw (<anonymous>)
    at rejected (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\tslib\tslib.js:101:69)
    at <anonymous> name: 'Exception', exitCode: 1, fatal: true }
</code>```

答:
This is related to config.json file, delete the config.json file from location  </p>

```<code>C:\Users\<UserName>\.ionic\config.json
</code>```

Title: ionic running issue in windows

Body:
i am Getting below error while i am running the same....pls help

E:\App_testing\MyFirstApp>ionic serve
{ Error
    at new Exception (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\lib\errors.js:8:23)
    at new FatalException (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\lib\errors.js:17:9)
    at Config.<anonymous> (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\lib\config.js:61:35)
    at Generator.throw (<anonymous>)
    at rejected (C:\Users\test\AppData\Roaming\npm\node_modules\ionic\node_modules\tslib\tslib.js:101:69)
    at <anonymous> name: 'Exception', exitCode: 1, fatal: true }

Body:
This is related to config.json file, delete the config.json file from location

C:\Users\<UserName>\.ionic\config.json


问:
How can I call scalar functions in a table view based on conditions?
I have a sample view defined as;

```<code> CREATE view [ab].[udv_SUMMARY] as
select
  txt.[Timestamp],
 txt.[Site],
   txt.[Name],
  txt.[Variance]
 from [ab].Text_Table txt
</code>```

I have 3 user defined functions( [udf_BJ_CT],[udf_BJ_MD],[udf_BJ_NY]

I need to change Variance value based on the output of all those 3 functions.

How can I call these 3 functions in the view based on the Site parameter?
Note: My functions take parameters as timestamp and Site.

答:
You can use CASE WHEN here.

```<code>CREATE view [ab].[udv_SUMMARY] as
select
    txt.[Timestamp],
    txt.[Site],
    txt.[Name],
    txt.[Variance],
    (CASE   WHEN txt.[Site] = {CONDITION 1} THEN dbo.[udf_BJ_CT](txt.[Timestamp],txt.[Site])
            WHEN txt.[Site] = {CONDITION 2} THEN dbo.[udf_BJ_MD](txt.[Timestamp],txt.[Site])
            WHEN txt.[Site] = {CONDITION 3} THEN dbo.[udf_BJ_NY](txt.[Timestamp],txt.[Site])
            ELSE dbo.[Def_Fxn](...)
    END)
 from [ab].Text_Table txt
</code>```

You have to replace your actual condition with {CONDITION 1},{CONDITION 2} and {CONDITION 3}

Body:
I have a sample view defined as;

 CREATE view [ab].[udv_SUMMARY] as
select
  txt.[Timestamp],
 txt.[Site],
   txt.[Name],
  txt.[Variance]
 from [ab].Text_Table txt

I have 3 user defined functions( [udf_BJ_CT],[udf_BJ_MD],[udf_BJ_NY]

I need to change Variance value based on the output of all those 3 functions.

How can I call these 3 functions in the view based on the Site parameter?
Note: My functions take parameters as timestamp and Site.

Body:
You can use CASE WHEN here.

CREATE view [ab].[udv_SUMMARY] as
select
    txt.[Timestamp],
    txt.[Site],
    txt.[Name],
    txt.[Variance],
    (CASE   WHEN txt.[Site] = {CONDITION 1} THEN dbo.[udf_BJ_CT](txt.[Timestamp],txt.[Site])
            WHEN txt.[Site] = {CONDITION 2} THEN dbo.[udf_BJ_MD](txt.[Timestamp],txt.[Site])
            WHEN txt.[Site] = {CONDITION 3} THEN dbo.[udf_BJ_NY](txt.[Timestamp],txt.[Site])
            ELSE dbo.[Def_Fxn](...)
    END)
 from [ab].Text_Table txt

You have to replace your actual condition with {CONDITION 1},{CONDITION 2} and {CONDITION 3}