问:
junit no webapplication context found: no ContextLoad Listener registered?
I am trying to write test cases for my structs application in which some of configurations in springs based xml files.
i moved all my applicationContext files into src/test/resources class path but when i run my test class(RunAs-> Junit Test), it throws below error </p>

```<code>java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:90)
    at com.cisco.attrui.test.BundleSearchActionTest.getPidBTSplitPctSearchTest(BundleSearchActionTest.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
    at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
</code>```

答:
If the files are in src/test/resources, you can add the @ContextConfiguration annotation to your test class to fetch as many files as required by providing them in an array follows:

```<code>@ContextConfiguration(locations = {"classpath:one-file.xml","classpath:another-file.xml", "classpath:and-another-file.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
</code>```

Body:
I am trying to write test cases for my structs application in which some of configurations in springs based xml files.
i moved all my applicationContext files into src/test/resources class path but when i run my test class(RunAs-> Junit Test), it throws below error

java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:90)
    at com.cisco.attrui.test.BundleSearchActionTest.getPidBTSplitPctSearchTest(BundleSearchActionTest.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
    at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Body:
If the files are in src/test/resources, you can add the @ContextConfiguration annotation to your test class to fetch as many files as required by providing them in an array follows:

@ContextConfiguration(locations = {"classpath:one-file.xml","classpath:another-file.xml", "classpath:and-another-file.xml"})
@RunWith(SpringJUnit4ClassRunner.class)


来源: stackexchange

问:
Python 3 , Unable to convert datetime stamp to datetime object, TypeError: an integer is required (got type str)
Im trying to process timeseries data in CSV and count the number of time epochs, for this example epoch = 1000 millisecs

Here is the python code:

```<code>import csv
  import os
  import datetime

    eeg_record = []
    path  = "C:\\Users\\ary\\Desktop\\nuerosky blink tests\\backup\\process_from_backup\\blink_50px\\task_blink40000radious50px_duration_40000.csv"
    """read CSV file"""
    def get_dirs(path_):
        if os.access(path_,os.F_OK and os.R_OK):
            f = open(path_)
            row_counter = 0
            for row in csv.reader(f):
                ##print(row)
                ##skip the header
                 if row_counter == 0:
                     row_counter = row_counter + 1
                     continue
                 else:
                     eeg_record.append(row)
            f.close()

    """get the number of epochs based on a epoch size in milliseconds"""
    def get_number_of_epochs(epoch_size_in_milliseconds):
            initial_datetime = datetime.datetime(2000,1,1,0,0,0,0)
            current_datetime = datetime.datetime(2000,1,1,0,0,0,0)
            epoch_counter = 0
            row_counter = 0
            epoch = datetime.timedelta(milliseconds=epoch_size_in_milliseconds)
            for row in eeg_record:
                if row_counter == 0:
                    row_counter =  row_counter + 1
                    initial_datetime = str_to_datetime_(row[1])
                else:
                    current_datetime = str_to_datetime_(row[1])
                    if  initial_datetime - current_datetime >= epoch:
                        initial_datetime = current_datetime
                        epoch_counter = epoch_counter + 1
            print("counter: ",epoch_counter)

""" covert datetime of this format 2017-10-13 19:22:50:525 to datetime object"""
def  str_to_datetime_(datetime_str):
     return datetime.datetime(datetime_str,'%Y-%m-%d %H:%M:%S:%f')
</code>```

Im running this via Spyder IDE and using Python 3.6.2

My input:

```<code> get_number_of_epochs(1000)
</code>```

Example of the data:

```<code>Time_Stamp_In_Milli_Secs,Time_Stamp_Formatted,Raw,A,B,C,D,Class_Stimulia
1.50795E+12,2017-10-13 19:22:13:249,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:249,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:253,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:253,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:266,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:266,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:266,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:268,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:268,53,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:280,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:280,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:280,54,-1,0,0,-1,NO_STIMULIA
</code>```

The error:

```<code>  File "<ipython-input-235-fac5a2a567a4>", line 33, in get_number_of_epochs
    initial_datetime = str_to_datetime_(row[1])

  File "<ipython-input-235-fac5a2a567a4>", line 45, in str_to_datetime_
    return datetime.datetime(datetime_str,'%Y-%m-%d %H:%M:%S:%f')

TypeError: an integer is required (got type str)
</code>```

How can I fix this error using the current APIs in my code?

答:
I think what you are looking for is

```<code>datetime.datetime.strptime(datetime_str, '%Y-%m-%d %H:%M:%S:%f')
</code>```

The standard datetime constructor looks like

```<code>datetime.datetime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, tzinfo: datetime.tzinfo)
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Im trying to process timeseries data in CSV and count the number of time epochs, for this example epoch = 1000 millisecs

Here is the python code:

import csv
  import os
  import datetime

    eeg_record = []
    path  = "C:\\Users\\ary\\Desktop\\nuerosky blink tests\\backup\\process_from_backup\\blink_50px\\task_blink40000radious50px_duration_40000.csv"
    """read CSV file"""
    def get_dirs(path_):
        if os.access(path_,os.F_OK and os.R_OK):
            f = open(path_)
            row_counter = 0
            for row in csv.reader(f):
                ##print(row)
                ##skip the header
                 if row_counter == 0:
                     row_counter = row_counter + 1
                     continue
                 else:
                     eeg_record.append(row)
            f.close()

    """get the number of epochs based on a epoch size in milliseconds"""
    def get_number_of_epochs(epoch_size_in_milliseconds):
            initial_datetime = datetime.datetime(2000,1,1,0,0,0,0)
            current_datetime = datetime.datetime(2000,1,1,0,0,0,0)
            epoch_counter = 0
            row_counter = 0
            epoch = datetime.timedelta(milliseconds=epoch_size_in_milliseconds)
            for row in eeg_record:
                if row_counter == 0:
                    row_counter =  row_counter + 1
                    initial_datetime = str_to_datetime_(row[1])
                else:
                    current_datetime = str_to_datetime_(row[1])
                    if  initial_datetime - current_datetime >= epoch:
                        initial_datetime = current_datetime
                        epoch_counter = epoch_counter + 1
            print("counter: ",epoch_counter)

""" covert datetime of this format 2017-10-13 19:22:50:525 to datetime object"""
def  str_to_datetime_(datetime_str):
     return datetime.datetime(datetime_str,'%Y-%m-%d %H:%M:%S:%f')

Im running this via Spyder IDE and using Python 3.6.2

My input:

 get_number_of_epochs(1000)

Example of the data:

Time_Stamp_In_Milli_Secs,Time_Stamp_Formatted,Raw,A,B,C,D,Class_Stimulia
1.50795E+12,2017-10-13 19:22:13:249,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:249,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:250,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:251,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:252,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:253,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:253,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:266,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:266,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:266,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,55,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:267,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:268,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:268,53,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:280,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:280,54,-1,0,0,-1,NO_STIMULIA
1.50795E+12,2017-10-13 19:22:13:280,54,-1,0,0,-1,NO_STIMULIA

The error:

  File "<ipython-input-235-fac5a2a567a4>", line 33, in get_number_of_epochs
    initial_datetime = str_to_datetime_(row[1])

  File "<ipython-input-235-fac5a2a567a4>", line 45, in str_to_datetime_
    return datetime.datetime(datetime_str,'%Y-%m-%d %H:%M:%S:%f')

TypeError: an integer is required (got type str)

How can I fix this error using the current APIs in my code?

Body:
I think what you are looking for is

datetime.datetime.strptime(datetime_str, '%Y-%m-%d %H:%M:%S:%f')

The standard datetime constructor looks like

datetime.datetime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, tzinfo: datetime.tzinfo)

ContentLicense: CC BY-SA 3.0


问:
Basic Objective-C array 'for' loop assistance
So heres my hangup, I create an array, pass buttons into it and use a for loop in an attempt to place each button on the view. I know they will be in the same position because they both go through the same CGRectMake. However i cannot seem to place anything on the screen with this code, although it doesn't return any errors it still has me stumped as to why.

Anyone got any suggestions? Thanks!

```<code>- (void)practiceMethod{

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Practice Method has begun" message:@"Alert" delegate: self cancelButtonTitle:@"Close" otherButtonTitles: nil];
 //[alert show];
 [alert release];

 float i=0;

 CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];

 UIImage *buttonGraphic = [UIImage imageNamed:@"1.png"];

 UIButton *buttonOne = [[UIButton alloc] initWithFrame:applicationFrame];
 UIButton *buttonTwo = [[UIButton alloc] initWithFrame:applicationFrame];

 buttonArray = [[NSArray alloc] initWithObjects:buttonOne, buttonTwo,nil];

 for (i = 0; i > [buttonArray count]; i++) {

  UIButton *tempElement = [buttonArray objectAtIndex:i];

  tempElement.frame = CGRectMake(140, 230, 50, 50);

  [tempElement setBackgroundImage:buttonGraphic forState:UIControlStateNormal];

  [self addSubview:tempElement];
 }
}
</code>```

答:
Replace:

```<code>for (i = 0; i > [buttonArray count]; i++) {
   UIButton *tempElement = [buttonArray objectAtIndex:i];
   ...

}
</code>```

With the array looping shortcut syntax:

```<code>for (UIButton *tempElement in buttonArray) {
    ...

}
</code>```

It's also better to use buttonWithType: with UIButton:

```<code>UIButton *buttonOne = [UIButton buttonWithType: UIButtonTypeCustom];
buttonOne.frame = applicationFrame;
</code>```

ContentLicense: CC BY-SA 2.5

Body:
So heres my hangup, I create an array, pass buttons into it and use a for loop in an attempt to place each button on the view. I know they will be in the same position because they both go through the same CGRectMake. However i cannot seem to place anything on the screen with this code, although it doesn't return any errors it still has me stumped as to why.

Anyone got any suggestions? Thanks!

- (void)practiceMethod{

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Practice Method has begun" message:@"Alert" delegate: self cancelButtonTitle:@"Close" otherButtonTitles: nil];
 //[alert show];
 [alert release];

 float i=0;

 CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];

 UIImage *buttonGraphic = [UIImage imageNamed:@"1.png"];

 UIButton *buttonOne = [[UIButton alloc] initWithFrame:applicationFrame];
 UIButton *buttonTwo = [[UIButton alloc] initWithFrame:applicationFrame];

 buttonArray = [[NSArray alloc] initWithObjects:buttonOne, buttonTwo,nil];

 for (i = 0; i > [buttonArray count]; i++) {

  UIButton *tempElement = [buttonArray objectAtIndex:i];

  tempElement.frame = CGRectMake(140, 230, 50, 50);

  [tempElement setBackgroundImage:buttonGraphic forState:UIControlStateNormal];

  [self addSubview:tempElement];
 }
}

Body:
Replace:

for (i = 0; i > [buttonArray count]; i++) {
   UIButton *tempElement = [buttonArray objectAtIndex:i];
   ...

}

With the array looping shortcut syntax:

for (UIButton *tempElement in buttonArray) {
    ...

}

It's also better to use buttonWithType: with UIButton:

UIButton *buttonOne = [UIButton buttonWithType: UIButtonTypeCustom];
buttonOne.frame = applicationFrame;


答:
Do the following and see:

change your str_to_datetime_ function to the following

```<code>def  str_to_datetime_(datetime_str):
    return datetime.datetime.strptime(datetime_str, '%Y-%m-%d %H:%M:%S:%f')
</code>```

Title: Python 3 , Unable to convert datetime stamp to datetime object, TypeError: an integer is required (got type str)

Body:
Do the following and see:

change your str_to_datetime_ function to the following

def  str_to_datetime_(datetime_str):
    return datetime.datetime.strptime(datetime_str, '%Y-%m-%d %H:%M:%S:%f')


问:
Date comparison validation in angular
I have 2 dates:  1.start and 2.end
format is like this.

```<code>12/4/2017               console.log(startDate);
12/20/2017              console.log(endDate);
</code>```

I am writing a validation to check if the end date is bigger than start date throw error,but it is not working.
this is what i have tried:

```<code>var startDate = new Date(this.formB['startDateVal']).toLocaleDateString();
var endDate=new Date(this.formB['dueDateVal']).toLocaleDateString();
</code>```

this is my condition:

```<code>if(endDate<startDate){
      this.bucketMsgClass='fielderror';
      this.bucketSuccessMsg = 'End Date is must lower than Start Date.';
 }
</code>```

where am i doing wrong.?

答:
Going through this link that explains comparing dates in javascript would probably help you understand the problem and solve it.

Compare two dates with JavaScript

Title: Date comparison validation in angular

Body:
I have 2 dates:  1.start and 2.end
format is like this.

12/4/2017               console.log(startDate);
12/20/2017              console.log(endDate);

I am writing a validation to check if the end date is bigger than start date throw error,but it is not working.
this is what i have tried:

var startDate = new Date(this.formB['startDateVal']).toLocaleDateString();
var endDate=new Date(this.formB['dueDateVal']).toLocaleDateString();

this is my condition:

if(endDate<startDate){
      this.bucketMsgClass='fielderror';
      this.bucketSuccessMsg = 'End Date is must lower than Start Date.';
 }

where am i doing wrong.?


问:
Not able to access StaticResource in Xamarin Forms from app.xaml
I am not able to access static resources that created in app.xaml.
its my app.xaml code

```<code><Application.Resources>
    <ResourceDictionary>
      <Color x:Key="AppDefaultColor">#07bab7</Color>
      <Color x:Key="PageDefaultColor">#f0f0f0</Color>
    </ResourceDictionary>
  </Application.Resources>
</code>```

when i try to use this in my page as static resource it gives error.
its my page code which i used to access static resource from app.xaml

```<code><Label Text="Test"  TextColor="{StaticResource AppDefaultColor}"  />
</code>```

答:
Please Check that your app.xaml.cs class call InitializeComponent() method. In the App constructor which is required when creating the App.xaml and associated code behind.

Please look into picture

Body:
I am not able to access static resources that created in app.xaml.
its my app.xaml code

<Application.Resources>
    <ResourceDictionary>
      <Color x:Key="AppDefaultColor">#07bab7</Color>
      <Color x:Key="PageDefaultColor">#f0f0f0</Color>
    </ResourceDictionary>
  </Application.Resources>

when i try to use this in my page as static resource it gives error.
its my page code which i used to access static resource from app.xaml


问:
CSS: hide
 on hover
I would like that menu with class "bbb" occurs only when user hover on link in class "aaa" (as a drop-down menu...)

I use css and I created some code:

```<code>.aaa:hover .bbb {
  opacity: 1;
}

.bbb {
  opacity: 0;
}
</code>```

But it doesn't work as intended. Can you help mi to get where i am wrong? I tried also do i with display:none & display:block instead of opacity.

Modification: resolution below doesn't work because i have other css metods. Pasted it:

.footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  text-align: center;
  font: inherit;
  font-size: 10px;
  color: white;
}

a, a:hover, a:active, a:visited {
  color: white;
}

.buttons {
  position: absolute;
  text-align: center;
}

.set:not(:last-child) {
  border-bottom: 1px dotted #aaa;
}

html, body, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  z-index: 1;
}

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
}

ol, ul {
  list-style: none;
}

blockquote, q {
  quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Default Styles
--------------------------------------------------------------------*/

body {
  background: url('img/denim.png');
  font-family: 'Droid Sans', sans-serif;;
}

.clearfix {
  clear: both;
}

.wrap {
  width: 940px;
  margin: 4em auto;
}

nav {
  background: -webkit-gradient(linear, center top, center bottom, from(#fff), to(#ccc));
  background-image: linear-gradient(#fff, #ccc);
  border-radius: 6px;
  box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.4);
  padding: 0 10px;
  position: relative;
}

.menu li {
  float: left;
  position: relative;
}

.menu li a {
  color: #444;
  display: block;
  font-size: 14px;
  line-height: 20px;
  padding: 6px 12px;
  margin: 8px 8px;
  vertical-align: middle;
  text-decoration: none;
}

.menu li a:hover {
  background: -webkit-gradient(linear, center top, center bottom, from(#ededed), to(#fff));
  background-image: linear-gradient(#ededed, #fff);
  border-radius: 12px;
  box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
  color: #222;
}

/* Dropdown styles */

.menu ul {
  position: absolute;
  left: -9999px;
  list-style: none;
  opacity: 0;
  transition: opacity 1s ease;
}

.menu ul li {
  float: none;
}

.menu ul a {
  white-space: nowrap;
}

/* Displays the dropdown on hover and moves back into position */
.menu li:hover ul {
  background: rgba(255,255,255,0.7);
  border-radius: 0 0 6px 6px;
  box-shadow: inset 0px 2px 4px rgba(0,0,0,0.4);
  left: 5px;
  opacity: 1;
}

.aaa:hover .bbb {
  display: block;
}

.bbb {
  display: none;
}

/* Persistant Hover State */

.menu li:hover a {
  background: -webkit-gradient(linear, center top, center bottom, from(#ccc), to(#ededed));
  background-image: linear-gradient(#ccc, #ededed);
  border-radius: 12px;
  box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
  color: #222;
}

.menu li:hover ul a {
  background: none;
  border-radius: 0;
  box-shadow: none;
}

.menu li:hover ul li a:hover {
  background: -webkit-gradient(linear, center top, center bottom, from(#eee), to(#fff));
  background-image: linear-gradient(#ededed, #fff);
  border-radius: 12px;
  box-shadow: inset 0px 0px 4px 2px rgba(0,0,0,0.3);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrap">
  <nav>
    <ul class="menu">
      <li><span class="iconic home"></span> Home</li>
      <li><span class="iconic magnifying-glass"></span> newIB
        <ul>
          <li>111</li>
          <li>222</li>
          <li>333</li>
          <li>444</li>
          <li class="aaa">555
            <ul class="bbb">
              <li>test</li>
              <li>test</li>
              <li>test</li>
              <li>test</li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </nav>
</div></code>```

答:
You have to nest the ul with the .bbb li inside the .aaa li:

.bbb {
  opacity: 0;
}

.aaa:hover .bbb {
  opacity: 1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav>
  <ul class="menu">
    <li><span class="iconic home"></span> Home</li>
    <li><span class="iconic magnifying-glass"></span> newIB
      <ul>
        <li>111</li>
        <li>222</li>
        <li>333</li>
        <li>444</li>
        <li class="aaa">555
          <ul>
            <li class="bbb">test</li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>
</nav></code>```

Title: CSS: hide <ul> on hover

Body:
I would like that menu with class "bbb" occurs only when user hover on link in class "aaa" (as a drop-down menu...)

I use css and I created some code:

.aaa:hover .bbb {
  opacity: 1;
}

.bbb {
  opacity: 0;
}

But it doesn't work as intended. Can you help mi to get where i am wrong? I tried also do i with display:none & display:block instead of opacity.

Modification: resolution below doesn't work because i have other css metods. Pasted it:

.footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  text-align: center;
  font: inherit;
  font-size: 10px;
  color: white;
}

a, a:hover, a:active, a:visited {
  color: white;
}

.buttons {
  position: absolute;
  text-align: center;
}

.set:not(:last-child) {
  border-bottom: 1px dotted #aaa;
}

html, body, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  z-index: 1;
}

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
}

ol, ul {
  list-style: none;
}

blockquote, q {
  quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Default Styles
--------------------------------------------------------------------*/

body {
  background: url('img/denim.png');
  font-family: 'Droid Sans', sans-serif;;
}

.clearfix {
  clear: both;
}

.wrap {
  width: 940px;
  margin: 4em auto;
}

nav {
  background: -webkit-gradient(linear, center top, center bottom, from(#fff), to(#ccc));
  background-image: linear-gradient(#fff, #ccc);
  border-radius: 6px;
  box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.4);
  padding: 0 10px;
  position: relative;
}

.menu li {
  float: left;
  position: relative;
}

.menu li a {
  color: #444;
  display: block;
  font-size: 14px;
  line-height: 20px;
  padding: 6px 12px;
  margin: 8px 8px;
  vertical-align: middle;
  text-decoration: none;
}

.menu li a:hover {
  background: -webkit-gradient(linear, center top, center bottom, from(#ededed), to(#fff));
  background-image: linear-gradient(#ededed, #fff);
  border-radius: 12px;
  box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
  color: #222;
}

/* Dropdown styles */

.menu ul {
  position: absolute;
  left: -9999px;
  list-style: none;
  opacity: 0;
  transition: opacity 1s ease;
}

.menu ul li {
  float: none;
}

.menu ul a {
  white-space: nowrap;
}

/* Displays the dropdown on hover and moves back into position */
.menu li:hover ul {
  background: rgba(255,255,255,0.7);
  border-radius: 0 0 6px 6px;
  box-shadow: inset 0px 2px 4px rgba(0,0,0,0.4);
  left: 5px;
  opacity: 1;
}

.aaa:hover .bbb {
  display: block;
}

.bbb {
  display: none;
}

/* Persistant Hover State */

.menu li:hover a {
  background: -webkit-gradient(linear, center top, center bottom, from(#ccc), to(#ededed));
  background-image: linear-gradient(#ccc, #ededed);
  border-radius: 12px;
  box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
  color: #222;
}

.menu li:hover ul a {
  background: none;
  border-radius: 0;
  box-shadow: none;
}

.menu li:hover ul li a:hover {
  background: -webkit-gradient(linear, center top, center bottom, from(#eee), to(#fff));
  background-image: linear-gradient(#ededed, #fff);
  border-radius: 12px;
  box-shadow: inset 0px 0px 4px 2px rgba(0,0,0,0.3);
}

 Home

 newIB

111

222

333

444

555

test

test

test

test

Body:
You have to nest the ul with the .bbb li inside the .aaa li:

.bbb {
  opacity: 0;
}

.aaa:hover .bbb {
  opacity: 1;
}

<nav>
  <ul class="menu">
    <li><a href="#"><span class="iconic home"></span> Home</a></li>
    <li><a href="https://system.aliorbank.pl/sign-in"><span class="iconic magnifying-glass"></span> newIB</a>
      <ul>
        <li><a href="#">111</a></li>
        <li><a href="#">222</a></li>
        <li><a href="#">333</a></li>
        <li><a href="#">444</a></li>
        <li class="aaa"><a href="www.example.pl">555</a>
          <ul>
            <li class="bbb"><a href ="https://www.example.pl">test</a></li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>
</nav>


问:
PHP | Codeigniter Redirect | Cannot modify header information
I have a problem when i try to use redirect() function from CodeIgniter.

The error is (when i try to call addMed() function)

```<code>A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /a_directory/CabUser.php:46)
Filename: helpers/url_helper.php
Line Number: 561
Backtrace:
File: /a_directory/CabUser.php>
Line: 48
Function: redirect
File: /a_directory/index.php
Line: 315
Function: require_once
</code>```

My File "CabUser.php"

```<code><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class CabUser extends CI_Controller {

  function __construct() {
    parent::__construct();
    $this->load->database();
  }

  public function index() {
    if ($this->session->has_userdata('for_login')) {
        $userPrivelegies = $this->session->userdata['for_login']['privelegies'];
        if($userPrivelegies) {
            redirect('CabMed', 'refresh');
        }
        else {
            $this->load->model('Cab_model');
              $this->Cab_model->getUserData();
        }
    }
    else {
        redirect('login');
    }
  }

  function logout() {
    if ($this->session->has_userdata('for_login')) {
      $this->session->sess_destroy('for_login');
    }
    redirect('home', 'refresh');
  }

  function addMed() {
    $data['numePrenumeMedic'] = $this->input->post('medic');
    $username = $this->session->userdata['for_login']['username'];
    $this->db->where('username', $username);
    $query = $this->db->get('Users');
    $ID = $query->row()->ID;

    $this->db->where('ID', $ID);
    $this->db->update('UserData', $data);

    echo "<script>
            alert('Succes!!!');
          </script>";

    redirect('CabUser', 'refresh'); //here's the problem
  }

  function upload() {
    if ($this->input->post('update')) {
      $data['numePrenume'] = $this->input->post('name');
      $data['numePrenume'] = $this->input->post('name');
      $data['facebook'] = $this->input->post('facebook');
      $data['ok'] = $this->input->post('ok');
      $data['instagram'] = $this->input->post('instagram');
      $data['datanasterii'] = $this->input->post('year') . '-' . $this->input->post('month') .'-' . $this->input->post('day');
      $data['telefon'] = $this->input->post('telefon');
      $data['adresa'] = $this->input->post('address');
      $data['sex'] = $this->input->post('sex');

      $sess = $this->session->userdata('for_login', 'username');

      $this->db->where('username',$sess['username']);
      $query = $this->db->get('Users');

      $ID = $query->row()->ID;

      $this->db->where('ID', $ID);
      $this->db->update('Users', $data);

      $this->db->where('ID', $ID);
      $this->db->set('numePrenumePacient', $data['numePrenume']);
      $this->db->update('Pacienti');

      echo "<script>
            alert('Succes!!!');
          </script>";
      redirect('CabUser', 'refresh');
    }
    else {
      echo "<script>
            alert('Error to update. \n Try later please...);
          </script>";
      redirect('CabUser', 'refresh');
    }

  }

}
?>
</code>```

答:
Your solution is,

Remove echo "";
code from everywhere where you are using redirect() function. Because redirect function uses header function of php and before any header, you should not echo or send anything to browser.

And that is what the error says.

Body:
I have a problem when i try to use redirect() function from CodeIgniter.

The error is (when i try to call addMed() function)

A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /a_directory/CabUser.php:46)
Filename: helpers/url_helper.php
Line Number: 561
Backtrace:
File: /a_directory/CabUser.php>
Line: 48
Function: redirect
File: /a_directory/index.php
Line: 315
Function: require_once

My File "CabUser.php"

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class CabUser extends CI_Controller {

  function __construct() {
    parent::__construct();
    $this->load->database();
  }

  public function index() {
    if ($this->session->has_userdata('for_login')) {
        $userPrivelegies = $this->session->userdata['for_login']['privelegies'];
        if($userPrivelegies) {
            redirect('CabMed', 'refresh');
        }
        else {
            $this->load->model('Cab_model');
              $this->Cab_model->getUserData();
        }
    }
    else {
        redirect('login');
    }
  }

  function logout() {
    if ($this->session->has_userdata('for_login')) {
      $this->session->sess_destroy('for_login');
    }
    redirect('home', 'refresh');
  }

  function addMed() {
    $data['numePrenumeMedic'] = $this->input->post('medic');
    $username = $this->session->userdata['for_login']['username'];
    $this->db->where('username', $username);
    $query = $this->db->get('Users');
    $ID = $query->row()->ID;

    $this->db->where('ID', $ID);
    $this->db->update('UserData', $data);

    echo "";

    redirect('CabUser', 'refresh'); //here's the problem
  }

  function upload() {
    if ($this->input->post('update')) {
      $data['numePrenume'] = $this->input->post('name');
      $data['numePrenume'] = $this->input->post('name');
      $data['facebook'] = $this->input->post('facebook');
      $data['ok'] = $this->input->post('ok');
      $data['instagram'] = $this->input->post('instagram');
      $data['datanasterii'] = $this->input->post('year') . '-' . $this->input->post('month') .'-' . $this->input->post('day');
      $data['telefon'] = $this->input->post('telefon');
      $data['adresa'] = $this->input->post('address');
      $data['sex'] = $this->input->post('sex');

      $sess = $this->session->userdata('for_login', 'username');

      $this->db->where('username',$sess['username']);
      $query = $this->db->get('Users');

      $ID = $query->row()->ID;

      $this->db->where('ID', $ID);
      $this->db->update('Users', $data);

      $this->db->where('ID', $ID);
      $this->db->set('numePrenumePacient', $data['numePrenume']);
      $this->db->update('Pacienti');

      echo "";
      redirect('CabUser', 'refresh');
    }
    else {
      echo "";
      redirect('CabUser', 'refresh');
    }

  }

}
?>

Body:
Your solution is,

Remove echo "<script>
            alert('Succes!!!');
          </script>";
code from everywhere where you are using redirect() function. Because redirect function uses header function of php and before any header, you should not echo or send anything to browser.

And that is what the error says.


问:
Type-signature vs. function equation in Haskell
I'm new to Haskell and to functional programming.  I'm reading through Real World Haskell, and I've realized I'm confused by a few examples.

Specifically this is in Chapter 9, in the section "A Domain specific language for predicates", the examples which have the w x y z parameters.

I've boiled it down to this:

Why does this code compile?

```<code>f :: Int -> (Int -> Int)
f x y = x+y

main = do
  let q = f 4 5
  putStr  (show (q))
</code>```

According to the type signature, f is clearly accepting 1 parameter and returning a function.
However, it seems I can write the function equation so it will accept two parameters and return an int.
Why is this possible?  Does this mean the type signature is ignored?

Is this currying?  Is this some kind of closure?
If I understand this http://www.haskell.org/haskellwiki/Currying correctly, then it seems to be somewhat in reverse to currying as defined there - my f function is taking multiple arguments instead of a single one!

Also, can anyone answering please provide a link to some sort of Haskell documentation where this ability is stated (if possible at all).

EDIT:

After thinking about this for some time, what you two seem to be implying is that:

1) This syntax is syntactic sugar, f will always have a single parameter, no matter how many parameters are written in the equation

2) Upon application of f, the function body will (always?) be transformed into a stub (in effect, the returned function), where x is fixed to the parameter given (4), and y is a parameter.

3) Then this new function is applied to 5 which replaces y, and then the + function is evaluated.

What I was really interested in was, where exactly does it say something like "in the function equation, if you write more than one parameter, it's really syntactic sugar, and the following actually happens..." as I wrote above.
Or is that so obvious to everyone except me?

Edit II:

The real eye-opener answer was in @luqui comment below, unfortunately I don't think I can mark a comment as an answer.

It is the fact that
f x y = ...
is actually syntactic sugar for:
f = \x -> \y -> ...

And for me, everything else everyone below said follows from this.

I found a sort of source for this in the Gentle Introduction to Haskell, here: http://haskell.cs.yale.edu/tutorial/functions.html in section 3.1, called Lambda Abstractions.

In fact, the equations:

inc x                  = x+1
    add x y                = x+y

are really shorthand for:

inc                    = \x   -> x+1
    add                    = \x y -> x+y

While it doesn't use the phrase "syntactic sugar", it uses the more, uh, mathematically oriented word "shorthand", but as a programmer I read this as "sugar" :-)

答:
It's not really syntax sugar, it's just how function application works in Haskell.

Consider:

```<code>f :: Int -> Int -> Int -> Int
f x y z = x + y + z

g = f 4
h = g 4 5

f 4 4 5 -- 13
g 4 5   -- 13
g 6     -- 13
</code>```

You can play with this in ghci to confirm. g is a partial application of function f - its type is g :: Int -> Int -> Int.

You can also write:

```<code>((f 4) 4) 5  -- 13
</code>```

In this case (f 4) returns a partially applied function that takes two additional arguments, ((f 4) 4) returns a partially applied function that takes one argument, and the whole expression reduces to 13.

Body:
I'm new to Haskell and to functional programming.  I'm reading through Real World Haskell, and I've realized I'm confused by a few examples.

Specifically this is in Chapter 9, in the section "A Domain specific language for predicates", the examples which have the w x y z parameters.

I've boiled it down to this:

Why does this code compile?

f :: Int -> (Int -> Int)
f x y = x+y

main = do
  let q = f 4 5
  putStr  (show (q))

According to the type signature, f is clearly accepting 1 parameter and returning a function.
However, it seems I can write the function equation so it will accept two parameters and return an int.
Why is this possible?  Does this mean the type signature is ignored?

Is this currying?  Is this some kind of closure?
If I understand this http://www.haskell.org/haskellwiki/Currying correctly, then it seems to be somewhat in reverse to currying as defined there - my f function is taking multiple arguments instead of a single one!

Also, can anyone answering please provide a link to some sort of Haskell documentation where this ability is stated (if possible at all).

EDIT:

After thinking about this for some time, what you two seem to be implying is that:

1) This syntax is syntactic sugar, f will always have a single parameter, no matter how many parameters are written in the equation

2) Upon application of f, the function body will (always?) be transformed into a stub (in effect, the returned function), where x is fixed to the parameter given (4), and y is a parameter.

3) Then this new function is applied to 5 which replaces y, and then the + function is evaluated.

What I was really interested in was, where exactly does it say something like "in the function equation, if you write more than one parameter, it's really syntactic sugar, and the following actually happens..." as I wrote above.
Or is that so obvious to everyone except me?

Edit II:

The real eye-opener answer was in @luqui comment below, unfortunately I don't think I can mark a comment as an answer.

It is the fact that
f x y = ...
is actually syntactic sugar for:
f = \x -> \y -> ...

And for me, everything else everyone below said follows from this.

I found a sort of source for this in the Gentle Introduction to Haskell, here: http://haskell.cs.yale.edu/tutorial/functions.html in section 3.1, called Lambda Abstractions.

In fact, the equations:

inc x                  = x+1
    add x y                = x+y

are really shorthand for:

inc                    = \x   -> x+1
    add                    = \x y -> x+y

While it doesn't use the phrase "syntactic sugar", it uses the more, uh, mathematically oriented word "shorthand", but as a programmer I read this as "sugar" :-)

Body:
It's not really syntax sugar, it's just how function application works in Haskell.

Consider:

f :: Int -> Int -> Int -> Int
f x y z = x + y + z

g = f 4
h = g 4 5

f 4 4 5 -- 13
g 4 5   -- 13
g 6     -- 13

You can play with this in ghci to confirm. g is a partial application of function f - its type is g :: Int -> Int -> Int.

You can also write:

((f 4) 4) 5  -- 13

In this case (f 4) returns a partially applied function that takes two additional arguments, ((f 4) 4) returns a partially applied function that takes one argument, and the whole expression reduces to 13.


问:
invalid input syntax for type numeric: ""
```<code>SELECT Concat(npi.first_name, ' ', npi.middle_name, ' ', npi.last_name) AS othername, npi.nhif_persons_identity_serial,
  CASE WHEN npi.person_identity_number IS NULL THEN '' WHEN Trim(npi.person_identity_number) = '' THEN ''
    ELSE npi.contact_email END, npi.biometric_member_number, npi.birth_certificate_number, npi.national_id_number, CASE
    WHEN npi.national_passport_number IS NULL THEN '' WHEN Trim(npi.national_passport_number) = '' THEN ''
    ELSE npi.national_passport_number END, CASE WHEN npi.national_pin_number IS NULL THEN ''
    WHEN Trim(npi.national_pin_number) = '' THEN '' ELSE npi.national_pin_number END, CASE
    WHEN npi.contact_email IS NULL THEN '' WHEN Trim(npi.contact_email) = '' THEN '' ELSE npi.contact_email END, CASE
    WHEN npi.address_district IS NULL THEN '' WHEN Trim(npi.address_district) = '' THEN '' ELSE npi.address_district
  END, CASE WHEN npi.address_location IS NULL THEN '' WHEN Trim(npi.address_location) = '' THEN ''
    ELSE npi.address_location END, CASE WHEN npi.address_county IS NULL THEN ''
    WHEN Trim(npi.address_county) = '' THEN '' ELSE npi.address_county END, CASE WHEN npi.work_code IS NULL THEN ''
    WHEN Trim(npi.work_code) = '' THEN '' ELSE npi.work_code END, CASE WHEN npi.address_physical IS NULL THEN ''
    WHEN Trim(npi.address_physical) = '' THEN '' ELSE npi.address_physical
  END
  , npi.date_of_birth  , npi.date_registered, npi.date_added,CASE WHEN npi.gender IS NULL THEN ''
    WHEN Trim(npi.gender) = '' THEN '' ELSE npi.gender
  END
  , npi.first_name, npi.middle_name, npi.last_name,

   CASE WHEN npi.marital_status IS NULL THEN ''
    WHEN Trim(npi.marital_status) = '' THEN '' ELSE npi.marital_status
  END
  ,CASE WHEN npi.contact_address IS NULL THEN ''
    WHEN Trim(npi.contact_address) = '' THEN '' ELSE npi.contact_address
  END
  ,CASE WHEN npi.contact_telephone IS NULL THEN ''
    WHEN Trim(npi.contact_telephone) = '' THEN '' ELSE npi.contact_telephone
  END
  ,CASE WHEN npi.contact_mobile IS NULL THEN ''
    WHEN Trim(npi.contact_mobile) = '' THEN '' ELSE npi.contact_mobile
  END
  ,CASE WHEN npi.mobile_contact_detail IS NULL THEN ''
    WHEN Trim(npi.mobile_contact_detail) = '' THEN '' ELSE npi.mobile_contact_detail
  END
  ,CASE WHEN npi.temp_member_number IS NULL THEN ''
     ELSE npi.temp_member_number
  END
  ,CASE WHEN npi.national_nhif_number IS NULL THEN ''
    WHEN Trim(npi.national_nhif_number) = '' THEN '' ELSE npi.national_nhif_number
  END
  ,CASE WHEN nbci.facial_full_image IS NULL THEN ''
    WHEN Trim(nbci.facial_full_image) = '' THEN '' ELSE nbci.facial_full_image
  END
  ,CASE WHEN nbci.facial_scaled_image IS NULL THEN ''
    WHEN Trim(nbci.facial_scaled_image) = '' THEN '' ELSE nbci.facial_scaled_image
  END

FROM nhif_persons_identities npi
  INNER JOIN nhif_biometric_cards nbc ON npi.nhif_persons_identity_serial = nbc.nhif_persons_identity_serial
  INNER JOIN nhif_biometric_card_images nbci ON nbci.nhif_biometric_card_serial = nbc.nhif_biometric_card_serial
WHERE npi.nhif_persons_identity_serial = 293182
</code>```

Am selecting data from database and if the column doesn't contain any value it output "blank" , Though am running into the error below when i execute the query i have tried to search but the answers i have got doesn't work.
It seems its the error with numeric.

```<code>ERROR:  invalid input syntax for type numeric: ""
LINE 35:   ,CASE WHEN npi.temp_member_number IS NULL THEN ''
                                                          ^

********** Error **********

ERROR: invalid input syntax for type numeric: ""
SQL state: 22P02
Character: 2318
</code>```

答:
I suppose you try to get text, not integer, so you would see euther some number like 1234 or empty string ``, not zero, to do that cast numeric to text, eg:

ELSE npi.temp_member_number::text

then you get the wanter result...

(apply to all not text fields, where you expect empty string if NULL)

Body:
SELECT Concat(npi.first_name, ' ', npi.middle_name, ' ', npi.last_name) AS othername, npi.nhif_persons_identity_serial,
  CASE WHEN npi.person_identity_number IS NULL THEN '' WHEN Trim(npi.person_identity_number) = '' THEN ''
    ELSE npi.contact_email END, npi.biometric_member_number, npi.birth_certificate_number, npi.national_id_number, CASE
    WHEN npi.national_passport_number IS NULL THEN '' WHEN Trim(npi.national_passport_number) = '' THEN ''
    ELSE npi.national_passport_number END, CASE WHEN npi.national_pin_number IS NULL THEN ''
    WHEN Trim(npi.national_pin_number) = '' THEN '' ELSE npi.national_pin_number END, CASE
    WHEN npi.contact_email IS NULL THEN '' WHEN Trim(npi.contact_email) = '' THEN '' ELSE npi.contact_email END, CASE
    WHEN npi.address_district IS NULL THEN '' WHEN Trim(npi.address_district) = '' THEN '' ELSE npi.address_district
  END, CASE WHEN npi.address_location IS NULL THEN '' WHEN Trim(npi.address_location) = '' THEN ''
    ELSE npi.address_location END, CASE WHEN npi.address_county IS NULL THEN ''
    WHEN Trim(npi.address_county) = '' THEN '' ELSE npi.address_county END, CASE WHEN npi.work_code IS NULL THEN ''
    WHEN Trim(npi.work_code) = '' THEN '' ELSE npi.work_code END, CASE WHEN npi.address_physical IS NULL THEN ''
    WHEN Trim(npi.address_physical) = '' THEN '' ELSE npi.address_physical
  END
  , npi.date_of_birth  , npi.date_registered, npi.date_added,CASE WHEN npi.gender IS NULL THEN ''
    WHEN Trim(npi.gender) = '' THEN '' ELSE npi.gender
  END
  , npi.first_name, npi.middle_name, npi.last_name,

   CASE WHEN npi.marital_status IS NULL THEN ''
    WHEN Trim(npi.marital_status) = '' THEN '' ELSE npi.marital_status
  END
  ,CASE WHEN npi.contact_address IS NULL THEN ''
    WHEN Trim(npi.contact_address) = '' THEN '' ELSE npi.contact_address
  END
  ,CASE WHEN npi.contact_telephone IS NULL THEN ''
    WHEN Trim(npi.contact_telephone) = '' THEN '' ELSE npi.contact_telephone
  END
  ,CASE WHEN npi.contact_mobile IS NULL THEN ''
    WHEN Trim(npi.contact_mobile) = '' THEN '' ELSE npi.contact_mobile
  END
  ,CASE WHEN npi.mobile_contact_detail IS NULL THEN ''
    WHEN Trim(npi.mobile_contact_detail) = '' THEN '' ELSE npi.mobile_contact_detail
  END
  ,CASE WHEN npi.temp_member_number IS NULL THEN ''
     ELSE npi.temp_member_number
  END
  ,CASE WHEN npi.national_nhif_number IS NULL THEN ''
    WHEN Trim(npi.national_nhif_number) = '' THEN '' ELSE npi.national_nhif_number
  END
  ,CASE WHEN nbci.facial_full_image IS NULL THEN ''
    WHEN Trim(nbci.facial_full_image) = '' THEN '' ELSE nbci.facial_full_image
  END
  ,CASE WHEN nbci.facial_scaled_image IS NULL THEN ''
    WHEN Trim(nbci.facial_scaled_image) = '' THEN '' ELSE nbci.facial_scaled_image
  END

FROM nhif_persons_identities npi
  INNER JOIN nhif_biometric_cards nbc ON npi.nhif_persons_identity_serial = nbc.nhif_persons_identity_serial
  INNER JOIN nhif_biometric_card_images nbci ON nbci.nhif_biometric_card_serial = nbc.nhif_biometric_card_serial
WHERE npi.nhif_persons_identity_serial = 293182

Am selecting data from database and if the column doesn't contain any value it output "blank" , Though am running into the error below when i execute the query i have tried to search but the answers i have got doesn't work.
It seems its the error with numeric.

ERROR:  invalid input syntax for type numeric: ""
LINE 35:   ,CASE WHEN npi.temp_member_number IS NULL THEN ''
                                                          ^

********** Error **********

ERROR: invalid input syntax for type numeric: ""
SQL state: 22P02
Character: 2318


问:
Detect Android soft navigation bar height in Ionic 2

In my Ionic 2 application, I have a grid component with items, that scrolls vertically.

The problem is that in Android devices with soft navigation bar (included in the screen) The scrolling stops before the entire content has revealed (see the bottom of the screen).

Example screenshot of an Android Nexus 5 (with soft bottom navigation bar):

Example screenshot of an iPhone 7 (without soft bottom navigation bar):

My question is: How can I detect the soft navigation bar's height (if existent) so that I can add it to the grid's bottom padding?

答:
Try to use Cordova Fullscreen Plugin or add the below settings in your config file,</p>

```<code><preference name="Fullscreen" value="true" />
</code>```

Body:
Try to use Cordova Fullscreen Plugin or add the below settings in your config file,

<preference name="Fullscreen" value="true" />


问:
we are doing pan OCR, using tesseract but is not able to detect the details like name and pan number
We are cropping the pan card image by increasing the height by 20px for every iteration and then we are passing that image to tesseract to do ocr but we are getting noise with output.if you have better solution on Image processing or
another libraries like cv2 then please help us.

```<code>import pytesseract
from PIL import Image, ImageEnhance, ImageFilter

im = Image.open("image/testpan.jpg")
width = im.size[0]
height = im.size[1]
print('width,height-->',width,height)

yy='img'
zz='.jpg'

x=0
for j in range(x,height):
    img2 = im.crop((0, x, width/2,x+70))
    img2.save(yy+str(j)+zz)

    img = Image.open(yy+str(j)+zz)
    # img = img.convert("L")
    img.save(yy + str(j) + zz)
    text = pytesseract.image_to_string(Image.open(yy+str(j)+zz))
    print('IIIII',j, text)

    x=x+20
    j=x
    if j>height:
        break
</code>```

答:
Does this ok?

convert to gray

threshold

findContours

boundingRect

Body:
We are cropping the pan card image by increasing the height by 20px for every iteration and then we are passing that image to tesseract to do ocr but we are getting noise with output.if you have better solution on Image processing or
another libraries like cv2 then please help us.

import pytesseract
from PIL import Image, ImageEnhance, ImageFilter

im = Image.open("image/testpan.jpg")
width = im.size[0]
height = im.size[1]
print('width,height-->',width,height)

yy='img'
zz='.jpg'

x=0
for j in range(x,height):
    img2 = im.crop((0, x, width/2,x+70))
    img2.save(yy+str(j)+zz)

    img = Image.open(yy+str(j)+zz)
    # img = img.convert("L")
    img.save(yy + str(j) + zz)
    text = pytesseract.image_to_string(Image.open(yy+str(j)+zz))
    print('IIIII',j, text)

    x=x+20
    j=x
    if j>height:
        break


问:
Use python + Selenium to login,but can't find div
```<code># _*_coding:utf-8_*_
from selenium import webdriver

driver=webdriver.Chrome()
url="https://login.alibaba.com"
driver.get(url)
driver.implicitly_wait(3)
print(driver.page_source)
driver.quit()
</code>```

i want to login by selenium, but can't find the login id "fm-login-id"

答:
To be able to handle elements inside authentication form, you need to switch to iframe:

```<code>driver=webdriver.Chrome()
url="https://login.alibaba.com"
driver.get(url)
deiver.switch_to.frame("alibaba-login-box")
driver.find_element_by_id("fm-login-id").send_keys("my email")
driver.find_element_by_id("fm-login-password").send_keys("my password")
</code>```

Body:
# _*_coding:utf-8_*_
from selenium import webdriver

driver=webdriver.Chrome()
url="https://login.alibaba.com"
driver.get(url)
driver.implicitly_wait(3)
print(driver.page_source)
driver.quit()

i want to login by selenium, but can't find the login id "fm-login-id"

Body:
To be able to handle elements inside authentication form, you need to switch to iframe:

driver=webdriver.Chrome()
url="https://login.alibaba.com"
driver.get(url)
deiver.switch_to.frame("alibaba-login-box")
driver.find_element_by_id("fm-login-id").send_keys("my email")
driver.find_element_by_id("fm-login-password").send_keys("my password")


问:
How to draw rounded raised and sunken edges of control?
I need a way to draw rounded raised and sunken corner edges on a custom control.  Currently, I am using ControlPaint.DrawBorder3D, but of course the corners are squared off and looks terrible. How can this be done?  Also, this project is not allowed to use any PInvoke calls.</p>

答:
you have to draw it manually via a series of arcs and lines.  the easiest way is to add them to a Path and use Graphics.DrawPath(...)

check out this post in the MSDN forums


问:
Savon/Ruby - Unable to add ':info' to specific XML tag
I am currently trying to run a Soap Call in Ruby. Using Savon client, I am not getting the response I want. This is the XML I want to create:

```<code>    <soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:sch="http://test.com/requests/test-manager/schema">
       <soapenv:Header/>
       <soapenv:Body>
         <sch:createTestDateRequest>
            <sch:testMethod>DD</sch:testMethod>
             <sch:testPeriodNumber>999</sch:testPeriodNumber>
             <sch:testDateTime>2017-12-14 00:00:00</sch:testDateTime>
             <sch:name>Automated test</sch:name>
           </sch:createTestDateRequest>
       </soapenv:Body>
    </soapenv:Envelope>
</code>```

And I've written the following code to create that Soap Call:

```<code>   require 'savon'
   $soap_client_testmgr = Savon.client(
        wsdl: 'http://test.com/test-manager-ws/TestManagerSoapService?wsdl',
        namespace: 'http://test.com/requests/test-manager/schema',
        env_namespace: :soapenv,
        namespace_identifier: :sch,
        pretty_print_xml: true,
        log: true,
        log_level: :debug)

    $soap_client_testmgr.call(:create_test_date, message: {
            :testMethod => 'DD',
            :testPeriodNumber => $test_period,
            :testDateTime => (Date.today+7).strftime('%Y-%m-%d') + ' 00:00:00',
            :name => 'Automated test'})
</code>```

But the XML that is generated is the following, missing the :sch before every individual name tag. This should be taken from the WSDL, correct? I've looked into namespace identifiers, but I have yet to find a fitting solution.

```<code>    <soapenv:Body>
        <sch:createTestDateRequest>
          <testMethod>DD</testMethod>
          <testPeriodNumber>999</testPeriodNumber>
          <testDateTime>2017-12-14 00:00:00</testDateTime>
          <name>Automated test</name>
        </sch:createTestDateRequest>
      </soapenv:Body>
    </soapenv:Envelope>
</code>```

What could solve this? I just need to add the sch: before the name tag.

Thanks!

答:
Fixed it by using string interpolation:</p>

```<code>    $soap_client_testmgr.call(:create_test_date, message: {
        :"sch:testMethod" => 'DD',
        :"sch:testPeriodNumber" => $test_period,
        :"sch:testDateTime" => (Date.today+7).strftime('%Y-%m-%d') + ' 00:00:00',
        :"sch:name" => 'Automated test'})
</code>```

Body:
I am currently trying to run a Soap Call in Ruby. Using Savon client, I am not getting the response I want. This is the XML I want to create:

    <soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:sch="http://test.com/requests/test-manager/schema">
       <soapenv:Header/>
       <soapenv:Body>
         <sch:createTestDateRequest>
            <sch:testMethod>DD</sch:testMethod>
             <sch:testPeriodNumber>999</sch:testPeriodNumber>
             <sch:testDateTime>2017-12-14 00:00:00</sch:testDateTime>
             <sch:name>Automated test</sch:name>
           </sch:createTestDateRequest>
       </soapenv:Body>
    </soapenv:Envelope>

And I've written the following code to create that Soap Call:

   require 'savon'
   $soap_client_testmgr = Savon.client(
        wsdl: 'http://test.com/test-manager-ws/TestManagerSoapService?wsdl',
        namespace: 'http://test.com/requests/test-manager/schema',
        env_namespace: :soapenv,
        namespace_identifier: :sch,
        pretty_print_xml: true,
        log: true,
        log_level: :debug)

    $soap_client_testmgr.call(:create_test_date, message: {
            :testMethod => 'DD',
            :testPeriodNumber => $test_period,
            :testDateTime => (Date.today+7).strftime('%Y-%m-%d') + ' 00:00:00',
            :name => 'Automated test'})

But the XML that is generated is the following, missing the :sch before every individual name tag. This should be taken from the WSDL, correct? I've looked into namespace identifiers, but I have yet to find a fitting solution.

    <soapenv:Body>
        <sch:createTestDateRequest>
          <testMethod>DD</testMethod>
          <testPeriodNumber>999</testPeriodNumber>
          <testDateTime>2017-12-14 00:00:00</testDateTime>
          <name>Automated test</name>
        </sch:createTestDateRequest>
      </soapenv:Body>
    </soapenv:Envelope>

What could solve this? I just need to add the sch: before the name tag.

Thanks!

Body:
Fixed it by using string interpolation:

    $soap_client_testmgr.call(:create_test_date, message: {
        :"sch:testMethod" => 'DD',
        :"sch:testPeriodNumber" => $test_period,
        :"sch:testDateTime" => (Date.today+7).strftime('%Y-%m-%d') + ' 00:00:00',
        :"sch:name" => 'Automated test'})


问:
cmd Pinging a specific port and ip
I'm trying to make a simple script on cmd (bat file) to check if couple of remote servers are up and up running

i wanted to ping a specific ip and port.

when i got %ERRORLEVEL% = 1 i knew there was a problem
and when i got %ERRORLEVEL% = 0 the server was ok

after some fooling around with ping command i saw that you can't ping a specific port...

then i tried using telnet on my script and telnet dosent return any value (to what i could find) if there is a successful Session or not

if anyone got any other way to check if couple servers are running  for a script i would appreciate the help.
Thanks

答:
first you should install telnet client
then press window+r and type cmd
command prompt open after that put a command telnet remoteIP port</p>

Title: cmd Pinging a specific port and ip


问:
Deploy Spring Boot jar on Azure App Service
I'm having trouble getting a Spring Boot API to work on an Azure app service. I've followed the Microsoft guide on https://learn.microsoft.com/en-us/java/azure/spring-framework/deploy-spring-boot-java-web-app-on-azure but having no luck so far.

The application does start (I can see the app boot up in the log file) but http requests to the app service url always end in a timeout.

I've read that Azure app services only pick up embedded tomcat servers that run on port 80 or 8080, but had no luck with that as well.

The app is deployed in the www root and an appropriate web.config is deployed as well.

I've tried running the App Service with and without an application server (Tomcat and Jetty, that is not needed because the server is embedded in the application), but both approaches failed.

Am I missing some other configuration part? Or could this be related to the type of plan I'm using on azure? Maybe some issue with the resource?

Any pointers?

Thx,

Bert

答:
Combining the steps in the official tutorials and your actual situation, I provide the following check points:

Point 1: Please use mvn package to bulid the JAR package in the directory under which the pom.xml file is located.

]

Point 2: Please make sure that the jar package name configured in web.config is the same as the uploaded jar package name.

web.config

```<code><?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\<your project name>"">
    </httpPlatform>
  </system.webServer>
</configuration>
</code>```

Point 3: Please use FTP to publish jar files and web.config to D:\home\site\wwwroot\ directory on KUDU.

Point 4: Please make sure ApplicationSettings matches your project such as jdk version,tomcat version.

If you want to deploy a war file, you need to configure the ApplicationSettings of your app service on Azure portal, then upload the war file into the path D:\home\site\wwwroot\webapps.

In addition, you could check the log files on KUDU : https://<your project name>.scm.azurewebsites.net/DebugConsole.

As references, please refer to the documents and threads below.

1.Configure web apps in Azure App Service

2.Create a Java web app in Azure App Service

3.Deploying Springboot to Azure App Service.

Hope it helps you.

Body:
Combining the steps in the official tutorials and your actual situation, I provide the following check points:

Point 1: Please use mvn package to bulid the JAR package in the directory under which the pom.xml file is located.

]

Point 2: Please make sure that the jar package name configured in web.config is the same as the uploaded jar package name.

web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\<your project name>&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

Point 3: Please use FTP to publish jar files and web.config to D:\home\site\wwwroot\ directory on KUDU.

Point 4: Please make sure ApplicationSettings matches your project such as jdk version,tomcat version.

If you want to deploy a war file, you need to configure the ApplicationSettings of your app service on Azure portal, then upload the war file into the path D:\home\site\wwwroot\webapps.

In addition, you could check the log files on KUDU : https://<your project name>.scm.azurewebsites.net/DebugConsole.

As references, please refer to the documents and threads below.

1.Configure web apps in Azure App Service

2.Create a Java web app in Azure App Service

3.Deploying Springboot to Azure App Service.

Hope it helps you.


问:
Adjust EditText icon away from the left border
I created an EditText with a drawable image. The problem is that the image is very close to the border of the EditText, is there a way to adjust it?

Note: Im using an svg file for the image

Image: In the image you can see the shoulder of the person is almost touching the left border

Code:

```<code>        <EditText

            android:id="@+id/sampleName"
            android:drawableStart="@drawable/sampleImage"
            android:drawablePadding="10dp"
            android:layout_height="wrap_content"
            android:maxLines="1"
            android:layout_width="match_parent"
            android:background="@color/white"

            android:layout_marginLeft="5dp"
            />
</code>```

答:
Try this</p>

```<code><EditText
     android:id="@+id/sampleName"
     android:drawableStart="@drawable/sampleImage"
     android:drawablePadding="10dp"
     android:layout_height="wrap_content"
     android:maxLines="1"
     android:layout_width="match_parent"
     android:background="@color/white"
     android:padding="15dp"
     android:layout_marginLeft="5dp"
     />
</code>```

Body:
I created an EditText with a drawable image. The problem is that the image is very close to the border of the EditText, is there a way to adjust it?

Note: Im using an svg file for the image

Image: In the image you can see the shoulder of the person is almost touching the left border

Code:

        <EditText

            android:id="@+id/sampleName"
            android:drawableStart="@drawable/sampleImage"
            android:drawablePadding="10dp"
            android:layout_height="wrap_content"
            android:maxLines="1"
            android:layout_width="match_parent"
            android:background="@color/white"

            android:layout_marginLeft="5dp"
            />

Body:
Try this

<EditText
     android:id="@+id/sampleName"
     android:drawableStart="@drawable/sampleImage"
     android:drawablePadding="10dp"
     android:layout_height="wrap_content"
     android:maxLines="1"
     android:layout_width="match_parent"
     android:background="@color/white"
     android:padding="15dp"
     android:layout_marginLeft="5dp"
     />


问:
C# code runs quick on IIS, but slow on Mono - how to improve it?
I have an ASP.NET application that is working well on my Windows development machine. The server is Linux running Mono though, and once uploaded the same code is running 4 or 5 times slower there than it does on the Windows box (taking 25 seconds vs 5 seconds for one task for instance).

Is this performance a known problem with Mono ? And is there anything I can do about it ? The code is mostly text processing, string replaces, regexes and the like, if that makes any difference. I've profiled and debugged my code using VS locally, but I don't know if it's possible to do remote debugging on the server with Mono, or what I need to do next to fix it really.

答:
Install Mono, preferably on a Linux system similar to your server. Profile your code on Mono and see where the bottlenecks are.

I have a Mono app running on a Linux server that follows Apache log files. I developed it on Windows and when testing it on Linux, I found it to be something like 8-10 times slower on Mono 2.4 vs. .NET 3.5. Most of its time is spent in Regex.Match and string functions. I was able to double the overall speed of the program in Mono just by specifying StringComparison.Ordinal in 4 calls to string.EndsWith(). If ordinal string comparisons are what you want, that might give you a speed boost.

Even with StringComparison.Ordinal, string.StartsWith() was still slow. I got a 25% increase in overall program speed by writing my own version of string.StartsWith().

So if ordinal comparisons are what your app needs to do, try specifying StringComparison.Ordinal or writing your own string functions.


问:
Kubernetes: Ingress doesn't have IP address
I setup a 3 nodes K8S cluster locally with virtualbox. When I try out the ingress, it doesn't setup the IP address:

```<code>2017-11-11 17:00:49.015691 I | proto: duplicate proto type registered:
google.protobuf.Any
2017-11-11 17:00:49.016061 I | proto: duplicate proto type registered: google.protobuf.Duration
2017-11-11 17:00:49.016112 I | proto: duplicate proto type registered: google.protobuf.Timestamp
NAME            HOSTS                     ADDRESS   PORTS     AGE
whale-ingress   a.whale.hey,b.whale.hey             80        9m
</code>```

Ingress:

```<code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: whale-ingress
spec:
  rules:
  - host: a.whale.hey
    http:
      paths:
      - path: /
        backend:
          serviceName: whale-svc-a
          servicePort: 80
  - host: b.whale.hey
    http:
      paths:
      - path: /
        backend:
          serviceName: whale-svc-b
          servicePort: 80
</code>```

Did I set something wrong?

答:
An Ingress is an object that only provides a configuration, not an active component (such as a Pod or a Service).
As coreypobrien said, you need to deploy an Ingress controller, which will read the ingresses you deployed in your cluster and change its configuration accordingly.

At this page you can find the documentation of the official kubernetes ingress controller, based on nginx https://github.com/kubernetes/ingress-nginx/blob/master/README.md

Another option is the traefik ingress controller: https://docs.traefik.io/user-guide/kubernetes/

Body:
I setup a 3 nodes K8S cluster locally with virtualbox. When I try out the ingress, it doesn't setup the IP address:

2017-11-11 17:00:49.015691 I | proto: duplicate proto type registered:
google.protobuf.Any
2017-11-11 17:00:49.016061 I | proto: duplicate proto type registered: google.protobuf.Duration
2017-11-11 17:00:49.016112 I | proto: duplicate proto type registered: google.protobuf.Timestamp
NAME            HOSTS                     ADDRESS   PORTS     AGE
whale-ingress   a.whale.hey,b.whale.hey             80        9m

Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: whale-ingress
spec:
  rules:
  - host: a.whale.hey
    http:
      paths:
      - path: /
        backend:
          serviceName: whale-svc-a
          servicePort: 80
  - host: b.whale.hey
    http:
      paths:
      - path: /
        backend:
          serviceName: whale-svc-b
          servicePort: 80

Did I set something wrong?


问:
How best to do a JavaScript array with non-consecutive indexes?
I'm writing a Google Chrome extension, in JavaScript, and I want to use an array to store a bunch of objects, but I want the indexes to be specific non-consecutive ID numbers.

(This is because I need to be able to efficiently look up the values later, using an ID number that comes from another source outside my control.)

For example:

```<code>var myObjects = [] ;

myObjects[471] = {foo: "bar"} ;

myObjects[3119] = {hello: "goodbye"}
</code>```

When I do console.log(myObjects), in the console I see the entire array printed out, with all the thousands of 'missing' indexes showing undefined.

My question is: does this matter? Is this wasting any memory?

And even if it's not wasting memory, surely whenever I loop over the array, it wastes CPU if I have to manually skip over every missing value?

I tried using an object instead of an array, but it seems you can't use numbers as object keys. I'm hoping there's a better way to achieve this?

答:
It would be implementation dependent, but I don't think you need to worry about wasted memory for the "in between" indices. The developer tools don't represent how the data is necessarily stored.

Regarding iterating over them, yes, you would be iterating over everything in between when using a for loop.

If the sequential order isn't important, then definitely use a plain Object instead of an Array. And yes, you can use numeric names for the properties.

```<code>var myObjects = {} ;

myObjects["471"] = {foo: "bar"} ;

myObjects["3119"] = {hello: "goodbye"};
</code>```

Here I used Strings for the names since you said you were having trouble with the numbers. They ultimately end up represented as strings when you loop anyway.

Now you'll use a for-in statement to iterate over the set, and you'll only get the properties you've defined.

EDIT:

With regard to console.log() displaying indices that shouldn't be there, here's an example of how easy it is to trick the developer tools into thinking you have an Array.

```<code>var someObj = {};

someObj.length = 11;
someObj.splice = function(){};

someObj[10] = 'val';

console.log(someObj);
</code>```

Clearly this is an Object, but Firebug and the Chrome dev tools will display it as an Array with 11 members.

```<code>[undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, "val"]
</code>```

So you can see that the console doesn't necessarily reflect how/what data is actually stored.

Body:
I'm writing a Google Chrome extension, in JavaScript, and I want to use an array to store a bunch of objects, but I want the indexes to be specific non-consecutive ID numbers.

(This is because I need to be able to efficiently look up the values later, using an ID number that comes from another source outside my control.)

For example:

var myObjects = [] ;

myObjects[471] = {foo: "bar"} ;

myObjects[3119] = {hello: "goodbye"}

When I do console.log(myObjects), in the console I see the entire array printed out, with all the thousands of 'missing' indexes showing undefined.

My question is: does this matter? Is this wasting any memory?

And even if it's not wasting memory, surely whenever I loop over the array, it wastes CPU if I have to manually skip over every missing value?

I tried using an object instead of an array, but it seems you can't use numbers as object keys. I'm hoping there's a better way to achieve this?

Body:
It would be implementation dependent, but I don't think you need to worry about wasted memory for the "in between" indices. The developer tools don't represent how the data is necessarily stored.

Regarding iterating over them, yes, you would be iterating over everything in between when using a for loop.

If the sequential order isn't important, then definitely use a plain Object instead of an Array. And yes, you can use numeric names for the properties.

var myObjects = {} ;

myObjects["471"] = {foo: "bar"} ;

myObjects["3119"] = {hello: "goodbye"};

Here I used Strings for the names since you said you were having trouble with the numbers. They ultimately end up represented as strings when you loop anyway.

Now you'll use a for-in statement to iterate over the set, and you'll only get the properties you've defined.

EDIT:

With regard to console.log() displaying indices that shouldn't be there, here's an example of how easy it is to trick the developer tools into thinking you have an Array.

var someObj = {};

someObj.length = 11;
someObj.splice = function(){};

someObj[10] = 'val';

console.log(someObj);

Clearly this is an Object, but Firebug and the Chrome dev tools will display it as an Array with 11 members.

[undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, "val"]

So you can see that the console doesn't necessarily reflect how/what data is actually stored.


问:
How do i get the text from a xml.dom.minidom Dom Element?
How do I get the text value of the title element?
Is this even possible with a Dom Element?
Will I have to parse out the text by hand?</p>

```<code>#-*-coding:utf8;-*-
#qpy:3
#qpy:console

import re
import urllib.request
from xml.dom import minidom

def download(url):
    with urllib.request.urlopen(url) as res:
        return res.read().decode('latin-1')

class RSSFeed(object):
    def __init__(self, url):
        self.url = url
        self.raw_xml = download(url)
        self.dom = minidom.parseString(self.raw_xml)
        self.links = self.dom.getElementsByTagName('link')

    def entries(self):
        ret = {}
        for element in self.dom.getElementsByTagName('entry'):
            title = element.getElementsByTagName('title')[0]
            print(title.toprettyxml())

    def __str__(self):
        return self.dom.toprettyxml()

feed_url = 'https://rickys-python-notes.blogspot.com/atom.xml?redirect=false&start-index=1&max-results=500'
feed = RSSFeed(feed_url)
dom = feed.dom
print(feedHow totries())
</code>```

答:
```<code>#-*-coding:utf8;-*-
#qpy:3
#qpy:console

import urllib.request
from xml.dom import minidom

def parse_feed(url):
    with urllib.request.urlopen(url) as res:
        dom = minidom.parseString(res.read().decode('latin-1'))
    for element in dom.getElementsByTagName('entry'):
        title = element.getElementsByTagName('title')[0].firstChild.nodeValue
        link = element.getElementsByTagName('link')[0].getAttribute('href')
        author = element.getElementsByTagName('name')[0].firstChild.nodeValue
        article = element.getElementsByTagName('content')[0].firstChild.nodeValue
        yield type('Entry', (object,), dict(title=title, link=link, author=author, article=article))

feed_url = 'https://rickys-python-notes.blogspot.com/atom.xml?redirect=false&start-index=1&max-results=500'

for entry in parse_feed(feed_url):
    print(entry.title, entry.link)
</code>```

Body:
How do I get the text value of the title element?
Is this even possible with a Dom Element?
Will I have to parse out the text by hand?

#-*-coding:utf8;-*-
#qpy:3
#qpy:console

import re
import urllib.request
from xml.dom import minidom

def download(url):
    with urllib.request.urlopen(url) as res:
        return res.read().decode('latin-1')

class RSSFeed(object):
    def __init__(self, url):
        self.url = url
        self.raw_xml = download(url)
        self.dom = minidom.parseString(self.raw_xml)
        self.links = self.dom.getElementsByTagName('link')

    def entries(self):
        ret = {}
        for element in self.dom.getElementsByTagName('entry'):
            title = element.getElementsByTagName('title')[0]
            print(title.toprettyxml())

    def __str__(self):
        return self.dom.toprettyxml()

feed_url = 'https://rickys-python-notes.blogspot.com/atom.xml?redirect=false&start-index=1&max-results=500'
feed = RSSFeed(feed_url)
dom = feed.dom
print(feedHow totries())


问:
Properly Format a datetime-local form input via echo from MYSQL Table
I'm attempting to echo the value of arrivalDateTimeDest into a form so that the user can edit this value. I've attempted to accomplish this a few ways, however, the value that's echo's always equals mm/dd/yyyy --:-- --. What am I doing wrong? My attempts are listed below.

```<code><input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date_format($row['arrivalDateTimeDest'],'Y/m/d H:i:s')?>">

<input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date('Y/m/d H:i:s', $row['arrivalDateTimeDest'])?>">

<input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date('c', $row['arrivalDateTimeDest'])?>">
</code>```

In light of the recent answers to this post, I've pinpointed the issue, however I cannot yet solve it. When input type = text, I have no issue echoing the value, however, I cannot do this when the input type is set to datetime-local.

答:
Use strotitime before you change the format of date. Check below :</p>

```<code><?php $date = "2011-12-05 10:13 AM";?>
<input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date('Y-m-d\TH:i', strtotime($date)); ?>">
</code>```

Body:
I'm attempting to echo the value of arrivalDateTimeDest into a form so that the user can edit this value. I've attempted to accomplish this a few ways, however, the value that's echo's always equals mm/dd/yyyy --:-- --. What am I doing wrong? My attempts are listed below.

<input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date_format($row['arrivalDateTimeDest'],'Y/m/d H:i:s')?>">

<input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date('Y/m/d H:i:s', $row['arrivalDateTimeDest'])?>">

<input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date('c', $row['arrivalDateTimeDest'])?>">

In light of the recent answers to this post, I've pinpointed the issue, however I cannot yet solve it. When input type = text, I have no issue echoing the value, however, I cannot do this when the input type is set to datetime-local.

Body:
Use strotitime before you change the format of date. Check below :

<?php $date = "2011-12-05 10:13 AM";?>
<input type='datetime-local' id="arrivalDateTimeDest" name='arrivalDateTimeDest' value="<?php echo date('Y-m-d\TH:i', strtotime($date)); ?>">


问:
How to navigate within a View Group
Within HTML you can navigate internally within a page using:

```<code><a href="#someElement">Go To Element</a>
</code>```

What is the equivalent in an Android App?

I have an Activity with a lot of text and headlines separating the text pieces. I want the user to be able to click somewhere and thereby navigate to a specific headline, so they don't have to scroll too much themselves.

How can I achieve this?

答:
Use

```<code>view.clearFocus();
 view.requestFocus();
</code>```

like an example if you are using EdiText and id is mEditText than you have to use mEditText.clearFocus();
 mEditText.requestFocus();

Title: How to navigate within a View Group

Body:
Within HTML you can navigate internally within a page using:

Go To Element

What is the equivalent in an Android App?

I have an Activity with a lot of text and headlines separating the text pieces. I want the user to be able to click somewhere and thereby navigate to a specific headline, so they don't have to scroll too much themselves.

How can I achieve this?

Body:
Use

view.clearFocus();
 view.requestFocus();

like an example if you are using EdiText and id is mEditText than you have to use mEditText.clearFocus();
 mEditText.requestFocus();


问:
Typical ref counting for a handler pipeline
Trying to upgrade to Netty 4.1.17.Final, I'm facing a ref counting issue for the following pipeline.

The first handler is framing the raw input from ByteBuf: waiting there are at least the minimal amount of readableBytes to consume a frame, putting all the frames that can be read from this raw input in the output (in/out List parameter). The frames are derived buffers, using readSlice.

The second handler is parsing each frame as an application specific class (not ref counted).

As far as I understand, only the second handler should call release().

Unfortunately, it raises IllegalReferenceCountException: refCnt: 0 for some cases (when the buffer is recycled) in the first, when trying to readIntLE.

It's unclear to me whether in such handler pipeline/chain, the first one should retain the buffer, or not use derived buffer, ...

Edit #1: Contrary to what I understand from the documentation, readRetainedSlice doesn't really "behaves similarly to readSlice(...).retain()" in such case, as the buffer returned by readRetainedSlice has a refCnt different from the parent one.

Edit #2: Filtering the leak detection details with leakDetection.acquireAndReleaseOnly=false, it seems the issue is on the outbound side.

```<code>23:20:55.586 ERROR [s.n.u.ResourceLeakDetector] :: LEAK: ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records:
#1:
    io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88)
    io.netty.util.ReferenceCountUtil.safeRelease(ReferenceCountUtil.java:113)
    io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:256)
    io.netty.channel.embedded.EmbeddedChannel.doWrite(EmbeddedChannel.java:724)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901)
    io.netty.channel.embedded.EmbeddedChannel$EmbeddedUnsafe$1.flush(EmbeddedChannel.java:820)
    io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1321)
        ...
    io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:92)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:89)
    NettyEmbedder$.withChannel(NettyEmbedder.scala:95)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:89)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:50)
        ...
#2:
    io.netty.buffer.AdvancedLeakAwareByteBuf.retain(AdvancedLeakAwareByteBuf.java:36)
    io.netty.util.ReferenceCountUtil.retain(ReferenceCountUtil.java:40)
    io.netty.channel.embedded.EmbeddedChannel.doWrite(EmbeddedChannel.java:722)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901)
    io.netty.channel.embedded.EmbeddedChannel$EmbeddedUnsafe$1.flush(EmbeddedChannel.java:820)
    io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1321)
        ...
    io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1041)
    io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:92)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:89)
    NettyEmbedder$.withChannel(NettyEmbedder.scala:95)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:89)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:50)
#3:
    Hint: 'DefaultChannelPipeline$HeadContext#0' will handle the message from this point.
    io.netty.channel.DefaultChannelPipeline.touch(DefaultChannelPipeline.java:116)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:810)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
    io.netty.channel.ChannelOutboundHandlerAdapter.write(ChannelOutboundHandlerAdapter.java:104)
    NettyEmbedder$$anon$1.write(NettyEmbedder.scala:88)
        ...
    io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:304)
    reactivemongo.core.protocol.MongoHandler.write(MongoHandler.scala:91)
        ...
Created at:
    Hint: 'NettyEmbedder$$anon$1#0' will handle the message from this point.
    io.netty.channel.DefaultChannelPipeline.touch(DefaultChannelPipeline.java:116)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:810)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
    io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113)
    io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
    io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
    io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:304)
    reactivemongo.core.protocol.MongoHandler.write(MongoHandler.scala:91)
        ...
    io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:92)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:89)
    NettyEmbedder$.withChannel(NettyEmbedder.scala:95)
        ...
</code>```

答:
So I looked at your code and there is a buffer leak:

https://github.com/cchantep/ReactiveMongo/blob/49bde9b63a95b2d20f9ae44ae41104a5bf3f154c/driver/src/main/scala/core/protocol/protocol.scala#L241

This calls frame.readBytes(readableBytes) which will return a new allocated ByteBuf that you just drop on the floor without calling release(). While calling release() here should fix this leak I would suggest just calling frame.skipBytes(readableBytes) which will also discard it but without the allocation and memory copy.

Hopefully this should fix it.

Please note my Scala skills are a bit rusty so maybe I missed something :)

Body:
Trying to upgrade to Netty 4.1.17.Final, I'm facing a ref counting issue for the following pipeline.

The first handler is framing the raw input from ByteBuf: waiting there are at least the minimal amount of readableBytes to consume a frame, putting all the frames that can be read from this raw input in the output (in/out List parameter). The frames are derived buffers, using readSlice.

The second handler is parsing each frame as an application specific class (not ref counted).

As far as I understand, only the second handler should call release().

Unfortunately, it raises IllegalReferenceCountException: refCnt: 0 for some cases (when the buffer is recycled) in the first, when trying to readIntLE.

It's unclear to me whether in such handler pipeline/chain, the first one should retain the buffer, or not use derived buffer, ...

Edit #1: Contrary to what I understand from the documentation, readRetainedSlice doesn't really "behaves similarly to readSlice(...).retain()" in such case, as the buffer returned by readRetainedSlice has a refCnt different from the parent one.

Edit #2: Filtering the leak detection details with leakDetection.acquireAndReleaseOnly=false, it seems the issue is on the outbound side.

23:20:55.586 ERROR [s.n.u.ResourceLeakDetector] :: LEAK: ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records:
#1:
    io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88)
    io.netty.util.ReferenceCountUtil.safeRelease(ReferenceCountUtil.java:113)
    io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:256)
    io.netty.channel.embedded.EmbeddedChannel.doWrite(EmbeddedChannel.java:724)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901)
    io.netty.channel.embedded.EmbeddedChannel$EmbeddedUnsafe$1.flush(EmbeddedChannel.java:820)
    io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1321)
        ...
    io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:92)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:89)
    NettyEmbedder$.withChannel(NettyEmbedder.scala:95)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:89)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:50)
        ...
#2:
    io.netty.buffer.AdvancedLeakAwareByteBuf.retain(AdvancedLeakAwareByteBuf.java:36)
    io.netty.util.ReferenceCountUtil.retain(ReferenceCountUtil.java:40)
    io.netty.channel.embedded.EmbeddedChannel.doWrite(EmbeddedChannel.java:722)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934)
    io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901)
    io.netty.channel.embedded.EmbeddedChannel$EmbeddedUnsafe$1.flush(EmbeddedChannel.java:820)
    io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1321)
        ...
    io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1041)
    io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:92)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:89)
    NettyEmbedder$.withChannel(NettyEmbedder.scala:95)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:89)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4.apply(ChannelFactorySpec.scala:50)
#3:
    Hint: 'DefaultChannelPipeline$HeadContext#0' will handle the message from this point.
    io.netty.channel.DefaultChannelPipeline.touch(DefaultChannelPipeline.java:116)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:810)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
    io.netty.channel.ChannelOutboundHandlerAdapter.write(ChannelOutboundHandlerAdapter.java:104)
    NettyEmbedder$$anon$1.write(NettyEmbedder.scala:88)
        ...
    io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:304)
    reactivemongo.core.protocol.MongoHandler.write(MongoHandler.scala:91)
        ...
Created at:
    Hint: 'NettyEmbedder$$anon$1#0' will handle the message from this point.
    io.netty.channel.DefaultChannelPipeline.touch(DefaultChannelPipeline.java:116)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:810)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
    io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113)
    io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
    io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816)
    io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
    io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:304)
    reactivemongo.core.protocol.MongoHandler.write(MongoHandler.scala:91)
        ...
    io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:92)
    ChannelFactorySpec$$anonfun$3$$anonfun$apply$4$$anonfun$apply$6.apply(ChannelFactorySpec.scala:89)
    NettyEmbedder$.withChannel(NettyEmbedder.scala:95)
        ...