问:
Sending Email in SSIS Package on Azure Server
I’m a developer in a company in Turkey. We use Microsoft SQL Server Management Studio 2016, Microsoft Visual Studio Professional 2015. In additional, our database is on Azure.
Also there are some privacy policies which are not allow me to setup plug-in to app or setup new application without permission.

Here is my problem. I need to develop a package in SSIS which sends an email. Because of Azure, as I googled SMTP server is not working. After my search,  I ahve found a solution and it’s senGrid.
However I tried to use it in a SSIS package, I couldn’t success. (The resason is that I’m new on SSIS and Azure) My team lead is pushing me about my task which has to send an email in SSIS package.

I need help about this subject but community of Microsoft doesn’t have enough knowhow. (I coudn’t find any solution to my issue.)

Could you help me? I can accept any kind of advice.

答:
If you are using Azure SQL Database (not the SQL Server in the Azure VM), SSIS is not supported. And there is no plan to include SSIS in SQL Azure. We can get more info from Azure feedback.

If we want to use this feature, we can create the Azure VM SQL server. We need to create a new Integration Services project and send mail task and deploy it to SQL server.

We also could use Azure Webjob to send the mail. Please refer to another SO thread.


来源: stackexchange

问:
TypeError: stream is undefined
Can't add a database connection to my small react app, i tried a bunch of npm modules: sqlite, sqlite3, realm. All fall back with type error:

```<code>TypeError: stream is undefined
</code>```

i do absolutely nothing, just added a require statement in my component case that error:

```<code>import db from 'sqlite';
</code>```

or:

```<code>var sqlite = require('sqlite3').verbose();
</code>```

The last trace string:

```<code>(function (process){
module.exports = function (blocking) {
  [process.stdout, process.stderr].forEach(function (stream) {
    if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
      stream._handle.setBlocking(blocking)
    }
  })
}
</code>```

and real fails on building, with Error: Cannot find module 'AccessibilityInfo'

答: Your last trace points to the content of set-blocking npm module. Usually it is used by npmlog. It requires process.stderr and process.stdout to be present. In your case they aren't. If you are running the app in Electron that might be the case.

ContentLicense: CC BY-SA 3.0

Title: TypeError: stream is undefined

Body:
Can't add a database connection to my small react app, i tried a bunch of npm modules: sqlite, sqlite3, realm. All fall back with type error:

TypeError: stream is undefined

i do absolutely nothing, just added a require statement in my component case that error:

import db from 'sqlite';

or:

var sqlite = require('sqlite3').verbose();

The last trace string:

(function (process){
module.exports = function (blocking) {
  [process.stdout, process.stderr].forEach(function (stream) {
    if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
      stream._handle.setBlocking(blocking)
    }
  })
}

and real fails on building, with Error: Cannot find module 'AccessibilityInfo'


问:
Detect log file rotation (while watching log file for modification)
I use the following code to track ssh log-ins:

```<code>def follow(thefile):
  thefile.seek(0,2)
  while True:
    line = thefile.readline()
    if not line:
      time.sleep(0.1)
      continue
    yield line

if __name__ == '__main__':
  logfile = open('/var/log/auth.log', 'r')
  loglines = follow(logfile)
  for line in loglines:
    print 'do something here'
</code>```

I've noticed that this script suddenly stops working after a couple of days. I don't get any error, it doesn't terminate, it just stops working, as if readline() would never return.

So I executed a echo 'test' >> auth.log.1 and this indeed ends up getting processed by the script, because sometime ago auth.log got renamed to auth.log.1

How can I track when such a log rotation happens and adjust accordingly?

答:
you can have a look at the inode, of the file.

```<code>import os
inode = os.stat('/var/log/auth.log').st_ino
</code>```

When the inode changes, the file has been rotated.

ContentLicense: CC BY-SA 4.0

Body:
I use the following code to track ssh log-ins:

def follow(thefile):
  thefile.seek(0,2)
  while True:
    line = thefile.readline()
    if not line:
      time.sleep(0.1)
      continue
    yield line

if __name__ == '__main__':
  logfile = open('/var/log/auth.log', 'r')
  loglines = follow(logfile)
  for line in loglines:
    print 'do something here'

I've noticed that this script suddenly stops working after a couple of days. I don't get any error, it doesn't terminate, it just stops working, as if readline() would never return.

So I executed a echo 'test' >> auth.log.1 and this indeed ends up getting processed by the script, because sometime ago auth.log got renamed to auth.log.1

How can I track when such a log rotation happens and adjust accordingly?

Body:
you can have a look at the inode, of the file.

import os
inode = os.stat('/var/log/auth.log').st_ino

When the inode changes, the file has been rotated.


问:
How to sort categories by totals in Lotus Notes View
Basically, I wanted to sort in descending order a view by the total number of users subscribed in a document (using column totals). They are categorized by the title of the document.

Example

Document A category has 15 total subscriptions.

Document B category has 20 total subscriptions

Document C category has 4 total subscriptions

In the view they would organize in such a way it would look like this

```<code>>(Title)   |        Totals     |        User
B          |        20         |
           |                   |        Gerard
           |                   |        ....(more users)
A          |        15         |
           |                   |        Michael
           |                   |        ....(more users)
C          |        4          |
           |                   |        John
           |                   |        ....(more users)
                   --------
                   39
</code>```

I tried ticking sort > descending in the Totals column properties but it doesn't work. Is there a workaround for this?

答:
You can scan the view (loop over looking for 'iscategory' or jumping to each category using 'getnextcategory') using a viewnavigator and capture the categorised totals from the category 'entries' - if you save these values into a 'reporting doc' you can create a view of these reports and sort the reports on the total field(s) you saved. Run the process on demand or scheduled with an agent.

Its a bit 'round-about' but depending on your app (db size, performance required, etc, can work ok.

Body:
Basically, I wanted to sort in descending order a view by the total number of users subscribed in a document (using column totals). They are categorized by the title of the document.

Example

Document A category has 15 total subscriptions.

Document B category has 20 total subscriptions

Document C category has 4 total subscriptions

In the view they would organize in such a way it would look like this

>(Title)   |        Totals     |        User
B          |        20         |
           |                   |        Gerard
           |                   |        ....(more users)
A          |        15         |
           |                   |        Michael
           |                   |        ....(more users)
C          |        4          |
           |                   |        John
           |                   |        ....(more users)
                   --------
                   39

I tried ticking sort > descending in the Totals column properties but it doesn't work. Is there a workaround for this?


问:
How to use AWK regExp to print multiple substring pattern in a excel format in different column
I have a log file which contains millions line like this:

```<code>$ cat file.log
10.0.7.92 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&size=320x280&ak=AY1234&output=vast&version=1.1&sleepAfter=&requester=John&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1
10.0.6.91 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&output=vast&version=1.1&sleepAfter=&requester=John&size=320x280&ak=AY1234&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1
</code>```

I want print output of every line like this in excel with different columns:

```<code>inwapads    AY1234  john    320x280
</code>```

How to do that use awk or do I need to use another method.

答:
If your desired Input looks like the file data:

```<code>$ cat file.log
10.0.7.92 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&size=320x280&ak=AY1234&output=vast&version=1.1&sleepAfter=&requester=John&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1
10.0.6.91 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&output=vast&version=1.1&sleepAfter=&requester=John&size=320x280&ak=AY1234&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1
</code>```

Then you can simply use awk working on column $7 with some gensub( /regex/, substitution, n, column), awk's general substitution tool

```<code>$ awk '{
    item=gensub( /(^.*\/)(.*\/)(.*)(\/)(\?.*$)/ , "\\3" , 1, $7 )
    ak=gensub( /(^.*ak\=)([A-Z]*[0-9]*)(\&)(.*$)/ , "\\2" , 1, $7)
    req=gensub( /(^.*requester\=)([A-Za-z]*)(\&)(.*$)/ , "\\2", 1, $7)
    s=gensub( /(^.*size\=)([0-9]*x[0-9]*)(\&.*$)/, "\\2", 1,  $7)
    print item, ak, req, s
}' file.log
</code>```

Output:

```<code>inwapads AY1234 John 320x280
inwapads AY1234 John 320x280
</code>```

Body:
I have a log file which contains millions line like this:

$ cat file.log
10.0.7.92 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&size=320x280&ak=AY1234&output=vast&version=1.1&sleepAfter=&requester=John&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1
10.0.6.91 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&output=vast&version=1.1&sleepAfter=&requester=John&size=320x280&ak=AY1234&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1

I want print output of every line like this in excel with different columns:

inwapads    AY1234  john    320x280

How to do that use awk or do I need to use another method.

Body:
If your desired Input looks like the file data:

$ cat file.log
10.0.7.92 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&size=320x280&ak=AY1234&output=vast&version=1.1&sleepAfter=&requester=John&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1
10.0.6.91 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&output=vast&version=1.1&sleepAfter=&requester=John&size=320x280&ak=AY1234&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1

Then you can simply use awk working on column $7 with some gensub( /regex/, substitution, n, column), awk's general substitution tool

$ awk '{
    item=gensub( /(^.*\/)(.*\/)(.*)(\/)(\?.*$)/ , "\\3" , 1, $7 )
    ak=gensub( /(^.*ak\=)([A-Z]*[0-9]*)(\&)(.*$)/ , "\\2" , 1, $7)
    req=gensub( /(^.*requester\=)([A-Za-z]*)(\&)(.*$)/ , "\\2", 1, $7)
    s=gensub( /(^.*size\=)([0-9]*x[0-9]*)(\&.*$)/, "\\2", 1,  $7)
    print item, ak, req, s
}' file.log

Output:

inwapads AY1234 John 320x280
inwapads AY1234 John 320x280


问:
Is it better to generate csv in the view or in the model?
I want to create a rails application that download all the employees with their companies.

Model: company(has_many employees)

I have the following choices.

define #to_csv that export employee to csv with the format in Employee Model, loop employees, and call from template.

loop the employees, and generate the csv with the format in the template.

From the viewpoint of code design, which is better?

====added===
I'm doing it like this.

Controller:

```<code>def hoge
  employees = Employee.all
  respond_to do |format|
    format.csv do
      send_data render_to_string('hoge'), filename: "hoge.csv", type: 'text/csv;chartset=utf-8'
    end
  end
end
</code>```

Template: views/employees/hoge.csv.ruby

```<code>require 'csv'
CSV.generate do |csv|
  # ...
  # generate csv
end
</code>```

答:
Model is best.

There is one more option using datatable plugin, using which you can add buttons above table to export data in csv, excel, pdf, etc.

Check link: https://datatables.net/extensions/buttons/examples/initialisation/export.html

Body:
I want to create a rails application that download all the employees with their companies.

Model: company(has_many employees)

I have the following choices.

define #to_csv that export employee to csv with the format in Employee Model, loop employees, and call from template.

loop the employees, and generate the csv with the format in the template.

From the viewpoint of code design, which is better?

====added===
I'm doing it like this.

Controller:

def hoge
  employees = Employee.all
  respond_to do |format|
    format.csv do
      send_data render_to_string('hoge'), filename: "hoge.csv", type: 'text/csv;chartset=utf-8'
    end
  end
end

Template: views/employees/hoge.csv.ruby

require 'csv'
CSV.generate do |csv|
  # ...
  # generate csv
end


问:
How to speed collection "contains" execution plan?
If I make analogy to Oracle database : they have the notion of "index" and "hint" to speed the execution of a query. So I want to make the analogy to Java : is it possible to make the execution of the "contains" method of a collection to be quick ?

答:
is it possible to make the execution of the "contains" method of a collection to be quick ?

Yes, use a collection with a faster contains method.

e.g.

```<code>HashSet -> O(1)
SortedSet -> O(ln N)
List -> O(N)
</code>```

The big-O time complexity indicates how the worst case time for an operation as the size of the collection grows. Lower time complexity is faster for modest to large collections.

Note: this only tells you how the collection scales. If the collection is very small like 1 or 2, then a List might be the fastest.

The Big-O notation is well explained What is a plain English explanation of "Big O" notation?

Body:
is it possible to make the execution of the "contains" method of a collection to be quick ?

Yes, use a collection with a faster contains method.

e.g.

HashSet -> O(1)
SortedSet -> O(ln N)
List -> O(N)

The big-O time complexity indicates how the worst case time for an operation as the size of the collection grows. Lower time complexity is faster for modest to large collections.

Note: this only tells you how the collection scales. If the collection is very small like 1 or 2, then a List might be the fastest.

The Big-O notation is well explained What is a plain English explanation of "Big O" notation?


问:
Adding noise to image for deep learning, yes or no?
I've been thinking that adding noise to an image can prevent overfitting and also "increase" the dataset by adding variations to it. I'm only trying to add some random 1s to images that has shape (256,256,3) which uses uint8 to represent its color. I don't think that can affect the visualization at all (I showed both images with matplotlib and they seems almost the same) and has only ~0.01 mean difference in the sum of their values.

But it doesn't look to have its advances. After training for a long time it's still not as good as the one doesn't use noises.

Has anyone tried to use noise for image classification tasks like this? Is it eventually better?

答:
I wouldn't go to add noise to your data. Some papers employ input deformations during training to increase robutness and convergence speed of models. However, these deformations are statistically inefficient (not just on image but any kind of data).
You can read Intriguing properties of Neural Networks from Szegedy et al. for more details (and refer to references 9 & 13 for papers that uses deformations).

If you want to avoid overfitting, you might be interested to read about regularization instead.


问:
How to emit new structure
```<code>var instanceType = typeof(T);
LocalBuilder instanceBuilder = il.DeclareLocal(instanceType);// T
if (instanceType.IsValueType)
{
    il.Emit(OpCodes.Ldloca, instanceBuilder);
    il.Emit(OpCodes.Initobj, instanceBuilder);
    il.Emit(OpCodes.Stloc_S, instanceBuilder);
}
else
{
    il.Emit(OpCodes.Newobj, instanceType.GetConstructor(Type.EmptyTypes));
    il.Emit(OpCodes.Stloc_S, instanceBuilder);
}

il.Emit(OpCodes.Ldstr, "Test");
il.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { TypeUtil._StringType }));

il.Emit(OpCodes.Ldloc, instanceBuilder);
il.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { TypeUtil._ObjectType }));
</code>```

Can anybody tell me how to emit new structure creation through it default constructor?

答:
All you need is ldloca (or ldflda / ldsflda) and initobj. There is nothing to store (the stloc_s is unnecessary). The second parameter to initobj is the type token, not the address:

```<code>using System;
using System.Reflection.Emit;

static class Program
{
    static void Main()
    {

        var method = new DynamicMethod("create", typeof(Foo), new[] { typeof(int) });
        var il = method.GetILGenerator();
        var local = il.DeclareLocal(typeof(Foo));

        // initialize the local (essentially: the default ctor)
        il.Emit(OpCodes.Ldloca_S, local);
        il.Emit(OpCodes.Initobj, typeof(Foo));

        // assign the parameter value to the property
        il.Emit(OpCodes.Ldloca_S, local);
        il.Emit(OpCodes.Ldarg_0);
        il.Emit(OpCodes.Call,
            typeof(Foo).GetProperty(nameof(Foo.Id)).GetSetMethod());

        // load, box, and call CWL
        il.Emit(OpCodes.Ldloc_S, local);
        il.Emit(OpCodes.Box, typeof(Foo));
        il.Emit(OpCodes.Call, typeof(Console).GetMethod(
            nameof(Console.WriteLine), new[] { typeof(object) }));

        // return the value of the
        il.Emit(OpCodes.Ldloc_S, local);
        il.Emit(OpCodes.Ret);

        // call the emitted method
        var del = (Func<int, Foo>)method.CreateDelegate(typeof(Func<int, Foo>));
        var foo = del(42);
    }

}
public struct Foo
{
    public int Id { get; set; } // not usually a good idea, note
    public override string ToString() => Id.ToString();
}
</code>```

Title: How to emit new structure

Body:
var instanceType = typeof(T);
LocalBuilder instanceBuilder = il.DeclareLocal(instanceType);// T
if (instanceType.IsValueType)
{
    il.Emit(OpCodes.Ldloca, instanceBuilder);
    il.Emit(OpCodes.Initobj, instanceBuilder);
    il.Emit(OpCodes.Stloc_S, instanceBuilder);
}
else
{
    il.Emit(OpCodes.Newobj, instanceType.GetConstructor(Type.EmptyTypes));
    il.Emit(OpCodes.Stloc_S, instanceBuilder);
}

il.Emit(OpCodes.Ldstr, "Test");
il.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { TypeUtil._StringType }));

il.Emit(OpCodes.Ldloc, instanceBuilder);
il.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { TypeUtil._ObjectType }));

Can anybody tell me how to emit new structure creation through it default constructor?

Body:
All you need is ldloca (or ldflda / ldsflda) and initobj. There is nothing to store (the stloc_s is unnecessary). The second parameter to initobj is the type token, not the address:

using System;
using System.Reflection.Emit;

static class Program
{
    static void Main()
    {

        var method = new DynamicMethod("create", typeof(Foo), new[] { typeof(int) });
        var il = method.GetILGenerator();
        var local = il.DeclareLocal(typeof(Foo));

        // initialize the local (essentially: the default ctor)
        il.Emit(OpCodes.Ldloca_S, local);
        il.Emit(OpCodes.Initobj, typeof(Foo));

        // assign the parameter value to the property
        il.Emit(OpCodes.Ldloca_S, local);
        il.Emit(OpCodes.Ldarg_0);
        il.Emit(OpCodes.Call,
            typeof(Foo).GetProperty(nameof(Foo.Id)).GetSetMethod());

        // load, box, and call CWL
        il.Emit(OpCodes.Ldloc_S, local);
        il.Emit(OpCodes.Box, typeof(Foo));
        il.Emit(OpCodes.Call, typeof(Console).GetMethod(
            nameof(Console.WriteLine), new[] { typeof(object) }));

        // return the value of the
        il.Emit(OpCodes.Ldloc_S, local);
        il.Emit(OpCodes.Ret);

        // call the emitted method
        var del = (Func<int, Foo>)method.CreateDelegate(typeof(Func<int, Foo>));
        var foo = del(42);
    }

}
public struct Foo
{
    public int Id { get; set; } // not usually a good idea, note
    public override string ToString() => Id.ToString();
}


问:
Error while using Github library in Java in Android Studio
I want to create a Speaker Recognition Android app using android studio.

I came accross https://github.com/amaurycrickx/recognito Library in java.
But I am having difficulty in implementing it in Android.

First, I saved the recognito folder by copying it in libs folder (creating it manually) in my main directory of my android app.

Then, in settings.gradle file -- include ':recognito'

```<code>build.gradle app file --     compile project(':recognito')
</code>```

After sync. getting the error -

```<code>Error:Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :recognito.
</code>```

I researched, Gradle error: configuration declares dependency which is not declared It says that since build.gradle file doesn`t exists for the Recognito project. But how will it? Cos it contains only java files.

Please help ..

Build.gradle

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.urvi.android.abc"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile project(':recognito')

}
</code>```

settings.gradle

```<code>include ':app'
include ':recognito'
</code>```

and the folder Recognito I copied has https://github.com/amaurycrickx/recognito/tree/master/recognito files. I did not copy from the initial path

答: It seems that this library has not been made to be used for Android app but Java application. It uses parts of the Java API not available for Android (like  javax.sound.sampled.*). Plus I'd not recommend to use any library not being updated in the last 3 years.</p>

Body:
I want to create a Speaker Recognition Android app using android studio.

I came accross https://github.com/amaurycrickx/recognito Library in java.
But I am having difficulty in implementing it in Android.

First, I saved the recognito folder by copying it in libs folder (creating it manually) in my main directory of my android app.

Then, in settings.gradle file -- include ':recognito'

build.gradle app file --     compile project(':recognito')

After sync. getting the error -

Error:Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :recognito.

I researched, Gradle error: configuration declares dependency which is not declared It says that since build.gradle file doesn`t exists for the Recognito project. But how will it? Cos it contains only java files.

Please help ..

Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.urvi.android.abc"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile project(':recognito')

}

settings.gradle

include ':app'
include ':recognito'

and the folder Recognito I copied has https://github.com/amaurycrickx/recognito/tree/master/recognito files. I did not copy from the initial path


问:
How can I remove spaces in view?
I use laravel 5.3

My case is like this :

My code in view :

```<code><div class="alert alert-warning" role="alert">
    "
    @if(isset($country))
        {{ $country }}
    @endif
    @if(isset($city))
        @if(isset($country))
            -
        @endif
        {{ $city }}
    @endif
    "
</div>
</code>```

The result like this :

" England - London "

I want the result like this :

"England - London"

How can I do it?

答:
This wouldn't be the best method, but you could try setting the string to a variable and try the below code. Please verify whether the variable isn't containing spaces in your controller and send the trimmed variables to the view </p>

```<code><div class="alert alert-warning" role="alert">
    {{--*/ $finalString = ""; /*--}}
    @if(isset($country))
        {{--*/ $finalstring .= $country; /*--}}
    @endif
    @if(isset($city))
        @if(isset($country))
            {{--*/ $finalString .= ' - '; /*--}}
        @endif
        {{--*/ $finalString .= $city; /*--}}
    @endif
    "{{ $finalString }}"
</div>
</code>```

Title: How can I remove spaces in view?

Body:
I use laravel 5.3

My case is like this :

My code in view :

    "
    @if(isset($country))
        {{ $country }}
    @endif
    @if(isset($city))
        @if(isset($country))
            -
        @endif
        {{ $city }}
    @endif
    "

The result like this :

" England - London "

I want the result like this :

"England - London"

How can I do it?

Body:
This wouldn't be the best method, but you could try setting the string to a variable and try the below code. Please verify whether the variable isn't containing spaces in your controller and send the trimmed variables to the view

<div class="alert alert-warning" role="alert">
    {{--*/ $finalString = ""; /*--}}
    @if(isset($country))
        {{--*/ $finalstring .= $country; /*--}}
    @endif
    @if(isset($city))
        @if(isset($country))
            {{--*/ $finalString .= ' - '; /*--}}
        @endif
        {{--*/ $finalString .= $city; /*--}}
    @endif
    "{{ $finalString }}"
</div>


问:
Edge Browser HTML file Upload not working
Edge Browser HTML file Upload not working if file name having space

Basic Code:

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fileupload_get

Run this URL and check in Edge Browser.

If any fix available to this issue. It will be great to share.

答: seems that it was a bug of edge (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8282613/). As i see it is fixed on the latest version, so maybe you have to install this version.</p>


问:
Problems Building Application as Release in Visual Studio 2008 - C++
I'm having a little trouble building my application as Release in Visual Studio 2008.  It builds fine without any errors or warning as Debug.  The application is primarily Win32 with a little MFC and ATL mixed in here and there.  Most of the projects in the solution generate a LIB and DLL.

This is one of the errors I am getting:

fatal error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

My application is a multithreaded DLL, so the /MD needs to stay.  The only Windows includes are these:

```<code>#include "stdafx.h"
#include "afx.h"
#include "WMIQuery.h"
#include "SerialPort.h"
</code>```

The other error is this:

fatal error C1083: Cannot open include file: 'WMIQuery.h': No such file or directory

This one really doesn't make sense to me because, the environment has no problem finding this file building for Debug.

Does anyone know how to fix this?  If any additional information is needed, just say so, and I'll post.  Thanks.

答: Double-check your environment variables.  I believe it uses separate values for debugging and releasing.</p>

ContentLicense: CC BY-SA 2.5

Body:
I'm having a little trouble building my application as Release in Visual Studio 2008.  It builds fine without any errors or warning as Debug.  The application is primarily Win32 with a little MFC and ATL mixed in here and there.  Most of the projects in the solution generate a LIB and DLL.

This is one of the errors I am getting:

fatal error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

My application is a multithreaded DLL, so the /MD needs to stay.  The only Windows includes are these:

#include "stdafx.h"
#include "afx.h"
#include "WMIQuery.h"
#include "SerialPort.h"

The other error is this:

fatal error C1083: Cannot open include file: 'WMIQuery.h': No such file or directory

This one really doesn't make sense to me because, the environment has no problem finding this file building for Debug.

Does anyone know how to fix this?  If any additional information is needed, just say so, and I'll post.  Thanks.


问:
Yet another "No Persistence provider for EntityManager named X"
I'm converting an old eclipse IVY Project to maven. In the old project it used eclipselink, and I'd like it to use hibernate.

I've created a couple of projects using Hibernate, so I used my persistence.XML from those, and changed the parts that needed to be changed.

Though I'm experiencing a problem; It can't find my persistence provider.
In my pom, I've tried using the hibernate-core dependency, and the hibernate-persistence-provider - none worked.

As for now, my pom is as follows:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>test.dk</groupId>
<artifactId>test-test</artifactId>
<packaging>war</packaging>
<version>4.1</version>
<name>test</name>

<prerequisites>
    <maven>3</maven>
</prerequisites>

<properties>
    <vaadin.version>7.7.8</vaadin.version>
    <vaadin.plugin.version>7.7.8</vaadin.plugin.version>
    <jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <!-- If there are no local customisations, this can also be "fetch" or "cdn" -->
    <vaadin.widgetset.mode>local</vaadin.widgetset.mode>
</properties>

<repositories>
    <repository>
        <id>vaadin-addons</id>
        <url>http://maven.vaadin.com/vaadin-addons</url>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
    </dependency>

    <dependency>
        <groupId>com.vaadin.addon</groupId>
        <artifactId>vaadin-charts-model</artifactId>
        <version>3.2.0</version>
    </dependency>

    <dependency>
        <groupId>com.vaadin.addon</groupId>
        <artifactId>vaadin-charts</artifactId>
        <version>3.2.0</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-bridge</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-gvt</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>batik-anim</artifactId>
        <version>1.8</version>
    </dependency>

    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.7</version>
    </dependency>

    <dependency>
        <groupId>org.vaadin.addon</groupId>
        <artifactId>confirmdialog</artifactId>
        <version>3.1.1</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-util</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-svggen</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-svg-dom</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
        <version>${vaadin.version}</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-dom</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.1.Final</version>
    </dependency>

    <dependency>
        <groupId>org.snmp4j</groupId>
        <artifactId>snmp4j</artifactId>
        <version>2.5.0</version>
    </dependency>

    <dependency>
        <groupId>ch.ethz.ganymed</groupId>
        <artifactId>ganymed-ssh2</artifactId>
        <version>262</version>
    </dependency>

</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <!-- Exclude an unnecessary file generated by the GWT compiler. -->
                <packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${vaadin.plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>update-theme</goal>
                        <goal>update-widgetset</goal>
                        <goal>compile</goal>
                        <goal>compile-theme</goal>
                        <!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
                        <goal>compile-theme</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.0.0</version>
            <!-- Clean up also any pre-compiled themes -->
            <configuration>
                <filesets>
                    <fileset>
                        <directory>src/main/webapp/VAADIN/themes</directory>
                        <includes>
                            <include>**/styles.css</include>
                            <include>**/styles.scss.cache</include>
                        </includes>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

        <!-- The Jetty plugin allows us to easily test the development build by
            running jetty:run on the command line. -->
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.plugin.version}</version>
            <configuration>
                <scanIntervalSeconds>2</scanIntervalSeconds>
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <!-- Vaadin pre-release repositories -->
        <id>vaadin-prerelease</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>

        <repositories>
            <repository>
                <id>vaadin-prereleases</id>
                <url>http://maven.vaadin.com/vaadin-prereleases</url>
            </repository>

            <repository>
                <id>vaadin-addons</id>
                <url>http://maven.vaadin.com/vaadin-addons</url>
            </repository>

            <repository>
                <id>vaadin-snapshots</id>
                <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>vaadin-prereleases</id>
                <url>http://maven.vaadin.com/vaadin-prereleases</url>
            </pluginRepository>
            <pluginRepository>
                <id>vaadin-snapshots</id>
                <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>
</code>```

And my persistence.XML

```<code><persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
         version="2.1">
<persistence-unit name="Test" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/stabilitydb2?useSSL=false"/>
        <property name="javax.persistence.jdbc.user" value="root"/>
        <property name="javax.persistence.jdbc.password" value="PASSWORD_ON_STACKOVERFLOW"/>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.show_sql" value="false"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
        <property name="hibernate.hbm2ddl.auto" value="validate"/>

        <!-- Configuring Connection Pool -->
        <property name="hibernate.c3p0.min_size" value="5"/>
        <property name="hibernate.c3p0.max_size" value="20"/>
        <property name="hibernate.c3p0.timeout" value="500"/>
        <property name="hibernate.c3p0.max_statements" value="50"/>
        <property name="hibernate.c3p0.idle_test_period" value="2000"/>
    </properties>
</persistence-unit>
</code>```

And I have ensured the persistence.XML is located in the resources

Though I keep getting the error

```<code>Jun 07, 2017 9:58:52 AM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE: javax.persistence.PersistenceException: No Persistence provider for EntityManager named Test
</code>```

And the code for creating the entitymanager (I know it's not threadsafe - sry.)

```<code>public class FactoryMaker {

    /**
     * The entity manager factory.
     */
    private static EntityManagerFactory entityManagerFactory;

    /**
     * Gets the factory - singleton
     *
     * @return the factory
     */
    public static EntityManagerFactory getFactory() {
        if (entityManagerFactory == null)
            entityManagerFactory = Persistence.createEntityManagerFactory("Test");

        return entityManagerFactory;
    }

}
</code>```

This is working in all other projects. What is going on? I have tried deleting my repo, and reimporting. No dice.

Really hope somebody can help me.

Best regards.

答:
Well this is akward.

The problem was the mysql-connector...

```<code><!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>
</code>```

was missing.

Body:
I'm converting an old eclipse IVY Project to maven. In the old project it used eclipselink, and I'd like it to use hibernate.

I've created a couple of projects using Hibernate, so I used my persistence.XML from those, and changed the parts that needed to be changed.

Though I'm experiencing a problem; It can't find my persistence provider.
In my pom, I've tried using the hibernate-core dependency, and the hibernate-persistence-provider - none worked.

As for now, my pom is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>test.dk</groupId>
<artifactId>test-test</artifactId>
<packaging>war</packaging>
<version>4.1</version>
<name>test</name>

<prerequisites>
    <maven>3</maven>
</prerequisites>

<properties>
    <vaadin.version>7.7.8</vaadin.version>
    <vaadin.plugin.version>7.7.8</vaadin.plugin.version>
    <jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <vaadin.widgetset.mode>local</vaadin.widgetset.mode>
</properties>

<repositories>
    <repository>
        <id>vaadin-addons</id>
        <url>http://maven.vaadin.com/vaadin-addons</url>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
    </dependency>

    <dependency>
        <groupId>com.vaadin.addon</groupId>
        <artifactId>vaadin-charts-model</artifactId>
        <version>3.2.0</version>
    </dependency>

    <dependency>
        <groupId>com.vaadin.addon</groupId>
        <artifactId>vaadin-charts</artifactId>
        <version>3.2.0</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-bridge</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-gvt</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>batik-anim</artifactId>
        <version>1.8</version>
    </dependency>

    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.7</version>
    </dependency>

    <dependency>
        <groupId>org.vaadin.addon</groupId>
        <artifactId>confirmdialog</artifactId>
        <version>3.1.1</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-util</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-svggen</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-svg-dom</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
        <version>${vaadin.version}</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-dom</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.1.Final</version>
    </dependency>

    <dependency>
        <groupId>org.snmp4j</groupId>
        <artifactId>snmp4j</artifactId>
        <version>2.5.0</version>
    </dependency>

    <dependency>
        <groupId>ch.ethz.ganymed</groupId>
        <artifactId>ganymed-ssh2</artifactId>
        <version>262</version>
    </dependency>

</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>

                <packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${vaadin.plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>update-theme</goal>
                        <goal>update-widgetset</goal>
                        <goal>compile</goal>
                        <goal>compile-theme</goal>

                        <goal>compile-theme</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.0.0</version>

            <configuration>
                <filesets>
                    <fileset>
                        <directory>src/main/webapp/VAADIN/themes</directory>
                        <includes>
                            <include>**/styles.css</include>
                            <include>**/styles.scss.cache</include>
                        </includes>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.plugin.version}</version>
            <configuration>
                <scanIntervalSeconds>2</scanIntervalSeconds>
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>

        <id>vaadin-prerelease</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>

        <repositories>
            <repository>
                <id>vaadin-prereleases</id>
                <url>http://maven.vaadin.com/vaadin-prereleases</url>
            </repository>

            <repository>
                <id>vaadin-addons</id>
                <url>http://maven.vaadin.com/vaadin-addons</url>
            </repository>

            <repository>
                <id>vaadin-snapshots</id>
                <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>vaadin-prereleases</id>
                <url>http://maven.vaadin.com/vaadin-prereleases</url>
            </pluginRepository>
            <pluginRepository>
                <id>vaadin-snapshots</id>
                <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>

And my persistence.XML

<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
         version="2.1">
<persistence-unit name="Test" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/stabilitydb2?useSSL=false"/>
        <property name="javax.persistence.jdbc.user" value="root"/>
        <property name="javax.persistence.jdbc.password" value="PASSWORD_ON_STACKOVERFLOW"/>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.show_sql" value="false"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
        <property name="hibernate.hbm2ddl.auto" value="validate"/>

        <property name="hibernate.c3p0.min_size" value="5"/>
        <property name="hibernate.c3p0.max_size" value="20"/>
        <property name="hibernate.c3p0.timeout" value="500"/>
        <property name="hibernate.c3p0.max_statements" value="50"/>
        <property name="hibernate.c3p0.idle_test_period" value="2000"/>
    </properties>
</persistence-unit>

And I have ensured the persistence.XML is located in the resources

Though I keep getting the error

Jun 07, 2017 9:58:52 AM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE: javax.persistence.PersistenceException: No Persistence provider for EntityManager named Test

And the code for creating the entitymanager (I know it's not threadsafe - sry.)

public class FactoryMaker {

    /**
     * The entity manager factory.
     */
    private static EntityManagerFactory entityManagerFactory;

    /**
     * Gets the factory - singleton
     *
     * @return the factory
     */
    public static EntityManagerFactory getFactory() {
        if (entityManagerFactory == null)
            entityManagerFactory = Persistence.createEntityManagerFactory("Test");

        return entityManagerFactory;
    }

}

This is working in all other projects. What is going on? I have tried deleting my repo, and reimporting. No dice.

Really hope somebody can help me.

Best regards.

Body:
Well this is akward.

The problem was the mysql-connector...

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

was missing.


问:
HTML prevent line break (between two table tags)
I have following code:

```<code><table>
    <tr>
        <td>Table 1</td>
    </tr>
</table>

<table>
    <tr>
        <td>Table 2</td>
    </tr>
</table>
</code>```

Very unfortunately, a line break is inserted between these two tables. I have tried putting them both in a single span and setting the whitespace to nowrap, but at no avail. Please, could you tell me how I can simply put these elements in a single row, without setting the float attribute in CSS and without surrounding each table with a  {table} 	 and then putting this in a table row.

Thanks a lot in advance. I have asked Google, but it just wouldn't say anything ^^ StackOverflow remained silent so far, too

答:
        Table 1

        Table 2

```
</div>
</div>
</p>

```<title>Page Title</title>

        Table 1

        Table 2

```

Body:
I have following code:

        Table 1

        Table 2

Very unfortunately, a line break is inserted between these two tables. I have tried putting them both in a single span and setting the whitespace to nowrap, but at no avail. Please, could you tell me how I can simply put these elements in a single row, without setting the float attribute in CSS and without surrounding each table with a  {table} 	 and then putting this in a table row.

Thanks a lot in advance. I have asked Google, but it just wouldn't say anything ^^ StackOverflow remained silent so far, too

Body:
<html>
<head>
</head>
<body>

<table style="display:inline">
    <tr>
        <td>Table 1</td>
    </tr>
</table>

<table style="display:inline">
    <tr>
        <td>Table 2</td>
    </tr>
</table>

</body>
</html>

<title>Page Title</title>
</head>
<body>

<table style="display:inline">
    <tr>
        <td>Table 1</td>
    </tr>
</table>

<table style="display:inline">
    <tr>
        <td>Table 2</td>
    </tr>
</table>

</body>
</html>


问:
javaScript issue about "this"
I'm trying to build a game demon, and run into a problem when I'm trying to add a clickEventHanlder to a button, the code goes here:

```<code>function GameConstructor(){
    this.start = startGame;
    this.count = 5;
    ...
    function startGame(){
        if(this.count > 5){ //here goes the problem, this don't point to the game object when I click the button
            ...
        }
}
...
var game = new GameConstructor(); //game object has a method called start
$("#someBtn").click(game.start); //in the method start this now point to the button so this.count is undefined.
</code>```

I know I can define a global variable count = 5 to solve this, but I just wonder if there is a way to fix in my original way? Thanks.

答:
this always point to the current function context in Javascript. Means the lowest function just out of the 'this'. So, you can do like;</p>

```<code>function GameConstructor(){
    var self= this;
    this.start = startGame;
    this.count = 5;
    ...
    function startGame(){
        if(self.count > 5){ //here goes the problem, this don't point to the game object when I click the button
            ...
        }
}
...
var game = new GameConstructor(); //game object has a method called start
$("#someBtn").click(game.start); //in the method start this now point to the button so this.count is undefined.
</code>```

Title: javaScript issue about "this"

Body:
I'm trying to build a game demon, and run into a problem when I'm trying to add a clickEventHanlder to a button, the code goes here:

function GameConstructor(){
    this.start = startGame;
    this.count = 5;
    ...
    function startGame(){
        if(this.count > 5){ //here goes the problem, this don't point to the game object when I click the button
            ...
        }
}
...
var game = new GameConstructor(); //game object has a method called start
$("#someBtn").click(game.start); //in the method start this now point to the button so this.count is undefined.

I know I can define a global variable count = 5 to solve this, but I just wonder if there is a way to fix in my original way? Thanks.

Body:
this always point to the current function context in Javascript. Means the lowest function just out of the 'this'. So, you can do like;

function GameConstructor(){
    var self= this;
    this.start = startGame;
    this.count = 5;
    ...
    function startGame(){
        if(self.count > 5){ //here goes the problem, this don't point to the game object when I click the button
            ...
        }
}
...
var game = new GameConstructor(); //game object has a method called start
$("#someBtn").click(game.start); //in the method start this now point to the button so this.count is undefined.


答:
I'm not a complete JavaScript wizard, but my guess is that the this inside your nested function is referring to that nested function, not the outer instance.

Many people opt to create a self variable instead, to be a bit more explicit about this scope stuff.  Maybe try this:

```<code>function GameConstructor(){
    var self = this;    // <-- here, then reference self subsequently
    self.start = startGame;
    self.count = 5;
    ...
    function startGame(){
        if(self.count > 5){ //here goes the problem, this don't point to the game object when I click the button
            ...
        }
}
</code>```

Title: javaScript issue about "this"

Body:
I'm not a complete JavaScript wizard, but my guess is that the this inside your nested function is referring to that nested function, not the outer instance.

Many people opt to create a self variable instead, to be a bit more explicit about this scope stuff.  Maybe try this:

function GameConstructor(){
    var self = this;    // <-- here, then reference self subsequently
    self.start = startGame;
    self.count = 5;
    ...
    function startGame(){
        if(self.count > 5){ //here goes the problem, this don't point to the game object when I click the button
            ...
        }
}


问:
Separate log file for custom processor
NiFi 1.2.0

Need to create a separate log file, say, customprocessor.log besides the app.log file created by NiFi.

I went through some interesting, existing threads like this, however, I am unable to figure out how to make it working in the code.

Following is the existing logback.xml :

```<code><?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
    <contextListener>
        <resetJUL>true</resetJUL>
    </contextListener>
    <appender name="APP_FILE">
        <file>/var/log/nifi/nifi-app.log</file>
        <rollingPolicy>
            <!--
                               For daily rollover, use 'app_%d.log'.
              For hourly rollover, use 'app_%d{yyyy-MM-dd_HH}.log'.
              To GZIP rolled files, replace '.log' with '.log.gz'.
              To ZIP rolled files, replace '.log' with '.log.zip'.
            -->
            <fileNamePattern>/var/log/nifi/archive/nifi-app_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy>
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <!-- keep 30 log files worth of history -->
            <maxHistory>3</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
     <immediateFlush>true</immediateFlush>
    </appender>
    <appender name="USER_FILE">
        <file>/var/log/nifi/nifi-user.log</file>
        <rollingPolicy>
            <!--
                               For daily rollover, use 'user_%d.log'.
              For hourly rollover, use 'user_%d{yyyy-MM-dd_HH}.log'.
              To GZIP rolled files, replace '.log' with '.log.gz'.
              To ZIP rolled files, replace '.log' with '.log.zip'.
            -->
            <fileNamePattern>/var/log/nifi/archive/nifi-user_%d.log</fileNamePattern>
            <!-- keep 30 log files worth of history -->
            <maxHistory>3</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>
    <appender name="BOOTSTRAP_FILE">
        <file>/var/log/nifi/nifi-bootstrap.log</file>
        <rollingPolicy>
            <!--
              For daily rollover, use 'user_%d.log'.
              For hourly rollover, use 'user_%d{yyyy-MM-dd_HH}.log'.
              To GZIP rolled files, replace '.log' with '.log.gz'.
              To ZIP rolled files, replace '.log' with '.log.zip'.
            -->
            <fileNamePattern>/var/log/nifi/archive/nifi-bootstrap_%d.log</fileNamePattern>
            <!-- keep 5 log files worth of history -->
            <maxHistory>5</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>
    <appender name="CONSOLE">
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>
    <!-- valid logging levels: TRACE, DEBUG, INFO, WARN, ERROR -->
    <logger name="org.apache.nifi" level="INFO"/>
    <logger name="org.apache.nifi.processors" level="WARN"/>
    <logger name="org.apache.nifi.processors.standard.LogAttribute" level="INFO"/>
    <logger name="org.apache.nifi.controller.repository.StandardProcessSession" level="WARN" />
    <logger name="org.apache.zookeeper.ClientCnxn" level="ERROR" />
    <logger name="org.apache.zookeeper.server.NIOServerCnxn" level="ERROR" />
    <logger name="org.apache.zookeeper.server.NIOServerCnxnFactory" level="ERROR" />
    <logger name="org.apache.zookeeper.server.quorum" level="ERROR" />
    <logger name="org.apache.zookeeper.ZooKeeper" level="ERROR" />
    <logger name="org.apache.zookeeper.server.PrepRequestProcessor" level="ERROR" />
    <logger name="org.apache.calcite.runtime.CalciteException" level="OFF" />
    <logger name="org.apache.curator.framework.recipes.leader.LeaderSelector" level="OFF" />
    <logger name="org.apache.curator.ConnectionState" level="OFF" />
    <!-- Logger for managing logging statements for nifi clusters. -->
    <logger name="org.apache.nifi.cluster" level="INFO"/>
    <!-- Logger for logging HTTP requests received by the web server. -->
    <logger name="org.apache.nifi.server.JettyServer" level="INFO"/>
    <!-- Logger for managing logging statements for jetty -->
    <logger name="org.eclipse.jetty" level="INFO"/>
    <!-- Suppress non-error messages due to excessive logging by class or library -->
    <logger name="com.sun.jersey.spi.container.servlet.WebComponent" level="ERROR"/>
    <logger name="com.sun.jersey.spi.spring" level="ERROR"/>
    <logger name="org.springframework" level="ERROR"/>
    <!-- Suppress non-error messages due to known warning about redundant path annotation (NIFI-574) -->
    <logger name="com.sun.jersey.spi.inject.Errors" level="ERROR"/>
    <!--
        Logger for capturing user events. We do not want to propagate these
        log events to the root logger. These messages are only sent to the
        user-log appender.
    -->
    <logger name="org.apache.nifi.web.security" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.web.api.config" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.authorization" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.cluster.authorization" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.web.filter.RequestLogger" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <!--
        Logger for capturing Bootstrap logs and NiFi's standard error and standard out.
    -->
    <logger name="org.apache.nifi.bootstrap" level="INFO" additivity="false">
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>
    <logger name="org.apache.nifi.bootstrap.Command" level="INFO" additivity="false">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>
    <!-- Everything written to NiFi's Standard Out will be logged with the logger org.apache.nifi.StdOut at INFO level -->
    <logger name="org.apache.nifi.StdOut" level="INFO" additivity="false">
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>
    <!-- Everything written to NiFi's Standard Error will be logged with the logger org.apache.nifi.StdErr at ERROR level -->
    <logger name="org.apache.nifi.StdErr" level="ERROR" additivity="false">
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>
    <root level="DEBUG">
        <appender-ref ref="APP_FILE"/>
    </root>
</configuration>
</code>```

Now, I can add a new appender for the custom log file :

```<code><!-- Start : Separate log file for custom processor -->
<appender name="CUSTOM_FILE">
        <file>/var/log/nifi/custom-processor.log</file>
        <rollingPolicy>
            <!--
                               For daily rollover, use 'app_%d.log'.
              For hourly rollover, use 'app_%d{yyyy-MM-dd_HH}.log'.
              To GZIP rolled files, replace '.log' with '.log.gz'.
              To ZIP rolled files, replace '.log' with '.log.zip'.
            -->
            <fileNamePattern>/var/log/nifi/archive/custom-processor_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy>
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <!-- keep 30 log files worth of history -->
            <maxHistory>3</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
     <immediateFlush>true</immediateFlush>
    </appender>
<!-- End : Separate log file for custom processor -->

<!-- Start : Separate log file for custom processor -->
    <logger name="com.nifi.CustomLog" level="DEBUG" additivity="false">
        <appender-ref ref="CUSTOM_FILE" />
    </logger>
    <!-- End : Separate log file for custom processor -->
</code>```

I have the following questions :

Are the entries that I am adding correct

In the code, I use the following snippet to get the root logger,
however, I didn't find a method/constructor to get my custom logger
in the code, how shall I do that ?

import org.apache.nifi.logging.ComponentLog;..final ComponentLog logger = getLogger();logger.debug("...");

答:
I have custom processor with class name: org.apache.nifi.processors.groovyx.ExecuteGroovyScript

To get logger i'm using this.getLogger()

In this case adding the following configuration to conf/logback.xml will create a separate file logs/x.log where only logs from my processor will appear.

<appender name="X_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${org.apache.nifi.bootstrap.config.log.dir}/x.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${org.apache.nifi.bootstrap.config.log.dir}/x_%d.log</fileNamePattern>
        <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
    </encoder>
</appender>
<logger name="org.apache.nifi.processors.groovyx.ExecuteGroovyScript" level="INFO" >
    <appender-ref ref="X_FILE"/>
</logger>
```

<p>Note that in the logger definition there should be your processor's class name</p>

<p>You can also define the package name (or parent package name) as a logger name to cover several processors located in this package:</p>

<pre class="lang-xml prettyprint-override"><code><logger name="org.apache.nifi.processors.groovyx" level="INFO" >
    <appender-ref ref="X_FILE"/>
</logger>
</code>```

in this case all classes of org.apache.nifi.processors.groovyx package
and all sub-packages will be logged into X_FILE logger.

Title: Separate log file for custom processor

Body:
NiFi 1.2.0

Need to create a separate log file, say, customprocessor.log besides the app.log file created by NiFi.

I went through some interesting, existing threads like this, however, I am unable to figure out how to make it working in the code.

Following is the existing logback.xml :

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
    <contextListener>
        <resetJUL>true</resetJUL>
    </contextListener>
    <appender name="APP_FILE">
        <file>/var/log/nifi/nifi-app.log</file>
        <rollingPolicy>

            <fileNamePattern>/var/log/nifi/archive/nifi-app_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy>
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>

            <maxHistory>3</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
     <immediateFlush>true</immediateFlush>
    </appender>
    <appender name="USER_FILE">
        <file>/var/log/nifi/nifi-user.log</file>
        <rollingPolicy>

            <fileNamePattern>/var/log/nifi/archive/nifi-user_%d.log</fileNamePattern>

            <maxHistory>3</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>
    <appender name="BOOTSTRAP_FILE">
        <file>/var/log/nifi/nifi-bootstrap.log</file>
        <rollingPolicy>

            <fileNamePattern>/var/log/nifi/archive/nifi-bootstrap_%d.log</fileNamePattern>

            <maxHistory>5</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>
    <appender name="CONSOLE">
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="org.apache.nifi" level="INFO"/>
    <logger name="org.apache.nifi.processors" level="WARN"/>
    <logger name="org.apache.nifi.processors.standard.LogAttribute" level="INFO"/>
    <logger name="org.apache.nifi.controller.repository.StandardProcessSession" level="WARN" />
    <logger name="org.apache.zookeeper.ClientCnxn" level="ERROR" />
    <logger name="org.apache.zookeeper.server.NIOServerCnxn" level="ERROR" />
    <logger name="org.apache.zookeeper.server.NIOServerCnxnFactory" level="ERROR" />
    <logger name="org.apache.zookeeper.server.quorum" level="ERROR" />
    <logger name="org.apache.zookeeper.ZooKeeper" level="ERROR" />
    <logger name="org.apache.zookeeper.server.PrepRequestProcessor" level="ERROR" />
    <logger name="org.apache.calcite.runtime.CalciteException" level="OFF" />
    <logger name="org.apache.curator.framework.recipes.leader.LeaderSelector" level="OFF" />
    <logger name="org.apache.curator.ConnectionState" level="OFF" />

    <logger name="org.apache.nifi.cluster" level="INFO"/>

    <logger name="org.apache.nifi.server.JettyServer" level="INFO"/>

    <logger name="org.eclipse.jetty" level="INFO"/>

    <logger name="com.sun.jersey.spi.container.servlet.WebComponent" level="ERROR"/>
    <logger name="com.sun.jersey.spi.spring" level="ERROR"/>
    <logger name="org.springframework" level="ERROR"/>

    <logger name="com.sun.jersey.spi.inject.Errors" level="ERROR"/>

    <logger name="org.apache.nifi.web.security" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.web.api.config" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.authorization" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.cluster.authorization" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>
    <logger name="org.apache.nifi.web.filter.RequestLogger" level="INFO" additivity="false">
        <appender-ref ref="USER_FILE"/>
    </logger>

    <logger name="org.apache.nifi.bootstrap" level="INFO" additivity="false">
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>
    <logger name="org.apache.nifi.bootstrap.Command" level="INFO" additivity="false">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>

    <logger name="org.apache.nifi.StdOut" level="INFO" additivity="false">
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>

    <logger name="org.apache.nifi.StdErr" level="ERROR" additivity="false">
        <appender-ref ref="BOOTSTRAP_FILE" />
    </logger>
    <root level="DEBUG">
        <appender-ref ref="APP_FILE"/>
    </root>
</configuration>

Now, I can add a new appender for the custom log file :

<appender name="CUSTOM_FILE">
        <file>/var/log/nifi/custom-processor.log</file>
        <rollingPolicy>

            <fileNamePattern>/var/log/nifi/archive/custom-processor_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy>
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>

            <maxHistory>3</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
     <immediateFlush>true</immediateFlush>
    </appender>

    <logger name="com.nifi.CustomLog" level="DEBUG" additivity="false">
        <appender-ref ref="CUSTOM_FILE" />
    </logger>

I have the following questions :

Are the entries that I am adding correct

In the code, I use the following snippet to get the root logger,
however, I didn't find a method/constructor to get my custom logger
in the code, how shall I do that ?

import org.apache.nifi.logging.ComponentLog;..final ComponentLog logger = getLogger();logger.debug("...");

Body:
I have custom processor with class name: org.apache.nifi.processors.groovyx.ExecuteGroovyScript

To get logger i'm using this.getLogger()

In this case adding the following configuration to conf/logback.xml will create a separate file logs/x.log where only logs from my processor will appear.

<appender name="X_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${org.apache.nifi.bootstrap.config.log.dir}/x.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${org.apache.nifi.bootstrap.config.log.dir}/x_%d.log</fileNamePattern>
        <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
    </encoder>
</appender>
<logger name="org.apache.nifi.processors.groovyx.ExecuteGroovyScript" level="INFO" >
    <appender-ref ref="X_FILE"/>
</logger>

Note that in the logger definition there should be your processor's class name

You can also define the package name (or parent package name) as a logger name to cover several processors located in this package:

<logger name="org.apache.nifi.processors.groovyx" level="INFO" >
    <appender-ref ref="X_FILE"/>
</logger>

in this case all classes of org.apache.nifi.processors.groovyx package
and all sub-packages will be logged into X_FILE logger.


问:
fill cells with formula 'MATCH', where the lookup_value increments but lookup_array stays
For example, in this case:

```<code>1| A     |    B   |     C  |
2|MyData | Lookup | Result |
3|Apple  | Grape  |   4    |
4|Banana | Cherry |   3    |
5|Cherry | Cat    |  #N/A  |
6|Grape  | Dog    |  #N/A  |
7|Mango  | ...    | ...    |
8|       | ...    | ...    |
</code>```

I know the formula for cell C3 is =MATCH(B3,A3:A7,0).
Then for C4, it's =MATCH(B4,A3:A7,0).

The issue is, I can't find a way to copy it down. Excel tries to increment the range offset (i.e. change A3:A7 to A5:A9) and I can't find a way to stop this.

Obviously I don't want to fill the formula cell-by-cell, so is it possible to let Excel fill it for me, while incrementing lookup_value without incrementing lookup_array?

答: You can add $ =MATCH(B3,$A$3:$A$7,0).

Body:
For example, in this case:

1| A     |    B   |     C  |
2|MyData | Lookup | Result |
3|Apple  | Grape  |   4    |
4|Banana | Cherry |   3    |
5|Cherry | Cat    |  #N/A  |
6|Grape  | Dog    |  #N/A  |
7|Mango  | ...    | ...    |
8|       | ...    | ...    |

I know the formula for cell C3 is =MATCH(B3,A3:A7,0).
Then for C4, it's =MATCH(B4,A3:A7,0).

The issue is, I can't find a way to copy it down. Excel tries to increment the range offset (i.e. change A3:A7 to A5:A9) and I can't find a way to stop this.

Obviously I don't want to fill the formula cell-by-cell, so is it possible to let Excel fill it for me, while incrementing lookup_value without incrementing lookup_array?

Body: You can add $ =MATCH(B3,$A$3:$A$7,0).


问:
How to get difference between two dates in Year/Month/Week/Day?
How to get difference between two dates in Year/Month/Week/Day in an efficient way?

eg. difference between two dates is 1 Year, 2 Months, 3 Weeks, 4 Days.

Difference represents count of year(s), month(s), week(s) and day(s) between two dates.

答:
I have below solution which works correctly for me(After doing some Test cases).
Extra Test cases are acceptable.</p>

```<code>public class DateDiffernce
{
    private int m_nDays = -1;
    private int m_nWeek;
    private int m_nMonth = -1;
    private int m_nYear;

    public int Days
    {
        get
        {
            return m_nDays;
        }
    }

    public int Weeks
    {
        get
        {
            return m_nWeek;
        }
    }

    public int Months
    {
        get
        {
            return m_nMonth;
        }
    }

    public int Years
    {
        get
        {
            return m_nYear;
        }
    }

    public void GetDifferenceBetwwenTwoDate(DateTime objDateTimeFromDate, DateTime objDateTimeToDate)
    {
        if (objDateTimeFromDate.Date > objDateTimeToDate.Date)
        {
            DateTime objDateTimeTemp = objDateTimeFromDate;
            objDateTimeFromDate = objDateTimeToDate;
            objDateTimeToDate = objDateTimeTemp;
        }

        if (objDateTimeFromDate == objDateTimeToDate)
        {
            //textBoxDifferenceDays.Text = " Same dates";
            //textBoxAllDifference.Text = " Same dates";
            return;
        }

        // If From Date's Day is bigger than borrow days from previous month
        // & then subtract.
        if (objDateTimeFromDate.Day > objDateTimeToDate.Day)
        {
            objDateTimeToDate = objDateTimeToDate.AddMonths(-1);
            int nMonthDays = DateTime.DaysInMonth(objDateTimeToDate.Year, objDateTimeToDate.Month);
            m_nDays = objDateTimeToDate.Day + nMonthDays - objDateTimeFromDate.Day;

        }

        // If From Date's Month is bigger than borrow 12 Month
        // & then subtract.
        if (objDateTimeFromDate.Month > objDateTimeToDate.Month)
        {
            objDateTimeToDate = objDateTimeToDate.AddYears(-1);
            m_nMonth = objDateTimeToDate.Month + 12 - objDateTimeFromDate.Month;

        }

       //Below are best cases - simple subtraction
        if (m_nDays == -1)
        {
            m_nDays = objDateTimeToDate.Day - objDateTimeFromDate.Day;
        }

        if (m_nMonth == -1)
        {
            m_nMonth = objDateTimeToDate.Month - objDateTimeFromDate.Month;
        }

        m_nYear = objDateTimeToDate.Year - objDateTimeFromDate.Year;
        m_nWeek = m_nDays / 7;
        m_nDays = m_nDays % 7;
    }
}
</code>```

Body:
I have below solution which works correctly for me(After doing some Test cases).
Extra Test cases are acceptable.

public class DateDiffernce
{
    private int m_nDays = -1;
    private int m_nWeek;
    private int m_nMonth = -1;
    private int m_nYear;

    public int Days
    {
        get
        {
            return m_nDays;
        }
    }

    public int Weeks
    {
        get
        {
            return m_nWeek;
        }
    }

    public int Months
    {
        get
        {
            return m_nMonth;
        }
    }

    public int Years
    {
        get
        {
            return m_nYear;
        }
    }

    public void GetDifferenceBetwwenTwoDate(DateTime objDateTimeFromDate, DateTime objDateTimeToDate)
    {
        if (objDateTimeFromDate.Date > objDateTimeToDate.Date)
        {
            DateTime objDateTimeTemp = objDateTimeFromDate;
            objDateTimeFromDate = objDateTimeToDate;
            objDateTimeToDate = objDateTimeTemp;
        }

        if (objDateTimeFromDate == objDateTimeToDate)
        {
            //textBoxDifferenceDays.Text = " Same dates";
            //textBoxAllDifference.Text = " Same dates";
            return;
        }

        // If From Date's Day is bigger than borrow days from previous month
        // & then subtract.
        if (objDateTimeFromDate.Day > objDateTimeToDate.Day)
        {
            objDateTimeToDate = objDateTimeToDate.AddMonths(-1);
            int nMonthDays = DateTime.DaysInMonth(objDateTimeToDate.Year, objDateTimeToDate.Month);
            m_nDays = objDateTimeToDate.Day + nMonthDays - objDateTimeFromDate.Day;

        }

        // If From Date's Month is bigger than borrow 12 Month
        // & then subtract.
        if (objDateTimeFromDate.Month > objDateTimeToDate.Month)
        {
            objDateTimeToDate = objDateTimeToDate.AddYears(-1);
            m_nMonth = objDateTimeToDate.Month + 12 - objDateTimeFromDate.Month;

        }

       //Below are best cases - simple subtraction
        if (m_nDays == -1)
        {
            m_nDays = objDateTimeToDate.Day - objDateTimeFromDate.Day;
        }

        if (m_nMonth == -1)
        {
            m_nMonth = objDateTimeToDate.Month - objDateTimeFromDate.Month;
        }

        m_nYear = objDateTimeToDate.Year - objDateTimeFromDate.Year;
        m_nWeek = m_nDays / 7;
        m_nDays = m_nDays % 7;
    }
}


问:
SQL Server Error After Web Deploy of App to Separate Web Server
I'm getting the following error once I move the app off onto its own Windows 2012 R2 IIS web server that is on Prem. The SQL 2014 DB server is in Azure. Firewall is disabled.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Further:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist.

My connection strings DO NOT specify any local SQL Express DB:

```<code> <connectionStrings>
    <remove name ="NewUserToolContext"/>
    <remove name ="DefaultConnection"/>
    <add name="NewUserToolContext" connectionString="Data Source=SQLDBSERVERNAME;Initial Catalog=NewUserTool;Integrated Security=False;User Id = USERID;password = PASSWORD" providerName="System.Data.SqlClient" />
    <add name="DefaultConnection" connectionString="Data Source=SQLDBSERVERNAME;Initial Catalog=NewUserTool;Integrated Security=False;User Id = USERID;password = PASSWORD" providerName="System.Data.SqlClient" />
  </connectionStrings>
</code>```

My partial _Layout view has some code that checks role membership before displaying specific menu items. After doing a lot of searches on this I found old posts from 2012 and one post from way back in 2013 regarding some kind of membership initializer. The post was incredibly vague and confusing and didn't seem relevant. It also didn't explain anything about what to do, especially not for MVC 6 Entity Framework in 2017. I tried, I couldn't find anything they were talking about. I started learning ASP.NET last year with MVC 6.

答:
Firstly, have you enable 1433 port in the firewall of your VM? If no, you could turn on this port using following steps.

On the Start menu, click Run, type WF.msc, and then click OK.

In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane (upper right corner).

In the Rule Type dialog box, select Port, and then click Next.

In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the Database Engine, by default SQL Server uses 1433. Please input 1433 and Click Next until finish the steps.

Secondly, you also need to enable 1433 port in Network Security Group which related to your VM. Steps below are for your reference.

Find the Network Security Group name which related to your VM in Netowrk interfaces panel.

Open this NSG, click [Add] button in the Inbound security rules panel

Add a rule as following.

After that, you could access the database hosted in VM.

Edit 2017/6/13

Firstly, I suggest you write the connection string to a log file before using it on your server. You will find whether the right connection string is used to connect your server. Maybe the connection string is override by other configurations.

In addition, is your web server hosted on Azure VM or local machine?

Please also try to enable 32-bit applications in your app pool advanced setting.

Some other things you could try.

Please check whether you have configured Dynamic IP Security or ipSecurity in your web.config. It will block any IP addresses based on your configuration.

Have you tried removing all the original files at your test server when deploying your release?

Body:
I'm getting the following error once I move the app off onto its own Windows 2012 R2 IIS web server that is on Prem. The SQL 2014 DB server is in Azure. Firewall is disabled.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Further:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist.

My connection strings DO NOT specify any local SQL Express DB:

 <connectionStrings>
    <remove name ="NewUserToolContext"/>
    <remove name ="DefaultConnection"/>
    <add name="NewUserToolContext" connectionString="Data Source=SQLDBSERVERNAME;Initial Catalog=NewUserTool;Integrated Security=False;User Id = USERID;password = PASSWORD" providerName="System.Data.SqlClient" />
    <add name="DefaultConnection" connectionString="Data Source=SQLDBSERVERNAME;Initial Catalog=NewUserTool;Integrated Security=False;User Id = USERID;password = PASSWORD" providerName="System.Data.SqlClient" />
  </connectionStrings>

My partial _Layout view has some code that checks role membership before displaying specific menu items. After doing a lot of searches on this I found old posts from 2012 and one post from way back in 2013 regarding some kind of membership initializer. The post was incredibly vague and confusing and didn't seem relevant. It also didn't explain anything about what to do, especially not for MVC 6 Entity Framework in 2017. I tried, I couldn't find anything they were talking about. I started learning ASP.NET last year with MVC 6.


问:
Amazon API Gateway authorization AWS_IAM
What does it means AWS_IAM as Authorization model in Amazon API Gateway?

If I test the Lambda inside the AWS console it works and prints "Hello World", but if I use the endpoint URL and open it inside another browser's tab it say {"message":"Missing Authentication Token"} how can I get this authentication token?

答:
Create a new IAM user

Go to AWS IAM and create a new user with programmatic access for accessing your API Gateway. Then attach a policy with enough permissions (AmazonAPIGatewayInvokeFullAccess) to the user/group to be able to access your API Gateway endpoint. Once you get through all the steps, you will be presented with a key/secret for your new user.

Make an API request with AWS Signature using Postman

Now, to simplify things, install Postman and then use the Authorization tab in your request page, to select AWS Signature:

Fill in AccessKey / SecretKey for your new user, AWS Region in which you operate (e.g., us-west-1) and click the Update Request button.
At that point Postman will fill in the necessary Headers for your request and you can make authorized requests to your API Gateway.


问:
Passing data from Objective-C Viewcontroller to Swift ViewController
I'm trying to pass data from an objective-c ViewController to a Swift ViewController and I'm getting this error in my Objective-C controller:

Property 'type' not found on object of type 'UIViewController'

My Objective-C code:

```<code>UIViewController *mainController = [self.storyboard instantiateViewControllerWithIdentifier:@"IdentitySelfieViewController"];
mainController.type = "passport";
[self.navigationController pushViewController:mainController animated:YES];
</code>```

Import into the Bridging-header file:

```<code>#import "PassportViewController.h"
</code>```

And created the corresponding String into my Swift View Controller

```<code>let type = ""
</code>```

Thank you for any help

答:
The Solution to your problem is like that :

First in your Swift Controller add the @Objc before the class keyword like that :

```<code>@objc class ViewController: UIViewController
</code>```

and that in that controller create a variable like that :

```<code>public var myValue:String  = ""
</code>```

After this in your Objective-C ViewController you need to import this and keep in mind this is very important.

```<code>#import "TargetName-Swift.h"
</code>```

TargetName should be replaced by your target name. After this you can easily call the variables of that Swift Controller like that:

```<code>ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"];
vc.myValue = @"Hello";
</code>```

Body:
I'm trying to pass data from an objective-c ViewController to a Swift ViewController and I'm getting this error in my Objective-C controller:

Property 'type' not found on object of type 'UIViewController'

My Objective-C code:

UIViewController *mainController = [self.storyboard instantiateViewControllerWithIdentifier:@"IdentitySelfieViewController"];
mainController.type = "passport";
[self.navigationController pushViewController:mainController animated:YES];

Import into the Bridging-header file:

#import "PassportViewController.h"

And created the corresponding String into my Swift View Controller

let type = ""

Thank you for any help

Body:
The Solution to your problem is like that :

First in your Swift Controller add the @Objc before the class keyword like that :

@objc class ViewController: UIViewController

and that in that controller create a variable like that :

public var myValue:String  = ""

After this in your Objective-C ViewController you need to import this and keep in mind this is very important.

#import "TargetName-Swift.h"

TargetName should be replaced by your target name. After this you can easily call the variables of that Swift Controller like that:

ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"];
vc.myValue = @"Hello";


问:
Swift Dictionary access value through subscript throws Error
Accessing a Swift Dictionary value through subscript syntax is gives error Ambiguous reference to member 'subscript'

Here is the code

```<code>class Model {

    struct Keys {
        static let type :String = "type" //RowType
        static let details :String = "details"
    }

    var type :RowType = .None
    var details :[Detail] = []

    init(with dictionary:Dictionary<String, Any>) {

        if let type = dictionary[Keys.type] as? String {
            self.type = self.rowTypeFromString(type: type)
        }

        if let detailsObj = dictionary[Keys.details] as? Array { //Error : Ambiguous reference to member 'subscript'

       }
    }

}
</code>```

if i remove the type casting as? Array at the end of optional-binding it compiles fine

I am expecting the value of details key to be an Array, I know that i can use [String,Any] instead of Dictionary<Key, Value>, What is causing the issue ?

答:
Issue is solved by explicitly specifying the Type of objects the array contains, In my case it was Array<[String:Any]>

```<code>if let detailsObj = dictionary[Keys.details] as? Array<[String:Any]> { //we should also specify what type is present inside Array

}
</code>```

Credits: @Hamish, @Dávid Pásztor

Thanks!

Body:
Accessing a Swift Dictionary value through subscript syntax is gives error Ambiguous reference to member 'subscript'

Here is the code

class Model {

    struct Keys {
        static let type :String = "type" //RowType
        static let details :String = "details"
    }

    var type :RowType = .None
    var details :[Detail] = []

    init(with dictionary:Dictionary<String, Any>) {

        if let type = dictionary[Keys.type] as? String {
            self.type = self.rowTypeFromString(type: type)
        }

        if let detailsObj = dictionary[Keys.details] as? Array { //Error : Ambiguous reference to member 'subscript'

       }
    }

}

if i remove the type casting as? Array at the end of optional-binding it compiles fine

I am expecting the value of details key to be an Array, I know that i can use [String,Any] instead of Dictionary<Key, Value>, What is causing the issue ?

Body:
Issue is solved by explicitly specifying the Type of objects the array contains, In my case it was Array<[String:Any]>

if let detailsObj = dictionary[Keys.details] as? Array<[String:Any]> { //we should also specify what type is present inside Array

}

Credits: @Hamish, @Dávid Pásztor

Thanks!