问:
tableview header in two rows
i'm italian, so sorry for my "ugly" english!

I'm working with a UITableview and my (dynamic) headers are too long!
So i want to split the headers in two rows... is it possible?

i've tried to uso "label.numberOfLines = 2" (or = 0) but it doesn't works!

this is the code:

```<code>- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
   UILabel *label = [[[UILabel alloc] init] autorelease];
    label.backgroundColor = [UIColor clearColor];

    NSString *header1 = [NSString stringWithFormat:@"Between %@ and %@ \n (33ª and 37ª week)", dateString1, dateString2];

    if (section == 0){
            label.text = header1;
            label.frame = CGRectMake(0, 6, 300, 30);
    } else
    //the others header

    label.numberOfLines = 2;

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
    [view autorelease];
    [view addSubview:label];

    return view;}
</code>```

thank you!!

答: label.numberOfLines = 2 will only show if the height of the label is enough to accommodate two lines. Also, the line height will depend on the font size. Make sure label is heigh enough to fit two lines of text at the given font size. Try making the font smaller or the label bigger. </p>

Title: tableview header in two rows

Body:
i'm italian, so sorry for my "ugly" english!

I'm working with a UITableview and my (dynamic) headers are too long!
So i want to split the headers in two rows... is it possible?

i've tried to uso "label.numberOfLines = 2" (or = 0) but it doesn't works!

this is the code:

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
   UILabel *label = [[[UILabel alloc] init] autorelease];
    label.backgroundColor = [UIColor clearColor];

    NSString *header1 = [NSString stringWithFormat:@"Between %@ and %@ \n (33ª and 37ª week)", dateString1, dateString2];

    if (section == 0){
            label.text = header1;
            label.frame = CGRectMake(0, 6, 300, 30);
    } else
    //the others header

    label.numberOfLines = 2;

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
    [view autorelease];
    [view addSubview:label];

    return view;}

thank you!!


来源: stackexchange

问:
Azure: Publishing a web application removed my webjob on same app service
I have a Azure solution (provider web to my SharePoint app, but that shouldn't matter). I have created one app service where I publish my web application and I also have a web job which I want to have on same app service

I Deploy this web job separately by uploading the zip-file (or ps1-file) in the web job-part of my app service. Se image below

BUT: If I redeploy my web application (from Visual Studio) the web job is removed!

The best thing would be to include the web job in the deployment of the deployment of the web application, but in any case I just dont want it to be removed when I deploy the web application.

Any good solutions/suggestions?

答: If you look under the Settings tab on the Publish to Azure dialog in Visual Studio, there is a checkbox labeled "Remove Additional Files at Destination". Make sure this is unchecked. If it is checked, all additional files that are not in your Visual Studio solution will be removed. </p>

ContentLicense: CC BY-SA 3.0


问:
MySQL: Counting number of staff
I'm very new to programming in sql and I'm having an issue with a question.

I have to find the department with the largest number of staff, and I'm not at all sure how to do it.

The tables i can use are

I think the end result would have the columns, Department_no and Max(Count(Department_no)) but I'm not sure how I'd get this? Or is there a simpler way that I'm just not seeing?

EDIT So far I have

SELECT Department_no, Count(Department_no)
 FROM ManagerOrBoss
 GROUP BY Department_no;

But I ideally want to find the maximum of the count, but SQL keeps giving a 'Invalid use of group function error'.

答:
You can use count with group by clause in your query as shown below</p>

```<code> select Department_no, count(Staff_id) from ManagerOrBoss
 group by department_no
 order by count(staff_id) limit 1
</code>```

Title: MySQL: Counting number of staff

Body:
You can use count with group by clause in your query as shown below

 select Department_no, count(Staff_id) from ManagerOrBoss
 group by department_no
 order by count(staff_id) limit 1


问:
Issue with namespaces in XSLT Translation
*I found out that the issue seems to be because of the line

xmlns="http://sample.com/task/1.0"

There was no namespace assigned and when I added one (ns1) things seemed to translate the way I wanted to. My revised question would be "Why was not having a namespace assigned there a problem, and if I were to want to change that in many files, how would I do that?"

I am new to XSLT but am trying to take an XML document and turn it into RDF. My approach was to just start with a simple translation to pull out some XML terms in plain text to start off. I took an XML file, stripped it of namespaces, and was able to get things to display properly.

In this iteration, I added the namespaces back to the XML file, but kept them from being referenced in tags. I also added them to the XSL file. When I run the translation, I only get the text that I wrote before the values. However, when I change the xsl:template match to be anything beyond "/*", I get the values but not the text. Here is the code

XML:

```<code><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<getCollectiveTaskResponse xmlns="http://sample.com/task/1.0" xmlns:ns2="http://sample.com/commonElements/1.0" xmlns:ns3="http://sample.com/individualTask/1.0" xmlns:ns4="http://sample.com/collectiveTask/1.0" xmlns:ns5="http://sample.com/xsd/handle" xmlns:ns6="http://sample.com/appinfo/1">
<collectiveTask>
    <generalInformation>
        <number>13</number>
        <title>Quarterback</title>
        <name>Dan Marino</name>
    </generalInformation>    </collectiveTask>
</code>```

And here is the XSL:

```<code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://sample.com/task/1.0"     xmlns:ns2="http://sample.com/commonElements/1.0"     xmlns:ns3="http://sample.com/individualTask/1.0" xmlns:ns4="http://sample.com/collectiveTask/1.0" xmlns:ns5="http://sample.com/xsd/handle" xmlns:ns6="http://sample.com/appinfo/1">
<xsl:template match="/getCollectiveTaskResponse">

Number:<xsl:value-of select="collectiveTask/generalInformation/number"/>
Title:<xsl:value-of select="collectiveTask/generalInformation/title"/>
Name:<xsl:value-of select="collectiveTask/generalInformation/name"/>

</xsl:template>

</xsl:stylesheet>
</code>```

答:
If you are using an XSLT 2 or 3 processor then to make your template

```<code><xsl:template match="/getCollectiveTaskResponse">

Number:<xsl:value-of select="collectiveTask/generalInformation/number"/>
Title:<xsl:value-of select="collectiveTask/generalInformation/title"/>
Name:<xsl:value-of select="collectiveTask/generalInformation/name"/>

</xsl:template>
</code>```

work you need to put xpath-default-namespace="http://sample.com/task/1.0" on your xsl:stylesheet element.

Body:
*I found out that the issue seems to be because of the line

xmlns="http://sample.com/task/1.0"

There was no namespace assigned and when I added one (ns1) things seemed to translate the way I wanted to. My revised question would be "Why was not having a namespace assigned there a problem, and if I were to want to change that in many files, how would I do that?"

I am new to XSLT but am trying to take an XML document and turn it into RDF. My approach was to just start with a simple translation to pull out some XML terms in plain text to start off. I took an XML file, stripped it of namespaces, and was able to get things to display properly.

In this iteration, I added the namespaces back to the XML file, but kept them from being referenced in tags. I also added them to the XSL file. When I run the translation, I only get the text that I wrote before the values. However, when I change the xsl:template match to be anything beyond "/*", I get the values but not the text. Here is the code

XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<getCollectiveTaskResponse xmlns="http://sample.com/task/1.0" xmlns:ns2="http://sample.com/commonElements/1.0" xmlns:ns3="http://sample.com/individualTask/1.0" xmlns:ns4="http://sample.com/collectiveTask/1.0" xmlns:ns5="http://sample.com/xsd/handle" xmlns:ns6="http://sample.com/appinfo/1">
<collectiveTask>
    <generalInformation>
        <number>13</number>
        <title>Quarterback</title>
        <name>Dan Marino</name>
    </generalInformation>    </collectiveTask>

And here is the XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://sample.com/task/1.0"     xmlns:ns2="http://sample.com/commonElements/1.0"     xmlns:ns3="http://sample.com/individualTask/1.0" xmlns:ns4="http://sample.com/collectiveTask/1.0" xmlns:ns5="http://sample.com/xsd/handle" xmlns:ns6="http://sample.com/appinfo/1">
<xsl:template match="/getCollectiveTaskResponse">

Number:<xsl:value-of select="collectiveTask/generalInformation/number"/>
Title:<xsl:value-of select="collectiveTask/generalInformation/title"/>
Name:<xsl:value-of select="collectiveTask/generalInformation/name"/>

</xsl:template>

</xsl:stylesheet>

Body:
If you are using an XSLT 2 or 3 processor then to make your template

<xsl:template match="/getCollectiveTaskResponse">

Number:<xsl:value-of select="collectiveTask/generalInformation/number"/>
Title:<xsl:value-of select="collectiveTask/generalInformation/title"/>
Name:<xsl:value-of select="collectiveTask/generalInformation/name"/>

</xsl:template>

work you need to put xpath-default-namespace="http://sample.com/task/1.0" on your xsl:stylesheet element.


问:
constexpr expression and variable lifetime, an example where g++ and clang disagree
Consider the simple C++11 code:

```<code>template<int N>
struct Foo {};

template <int N>
constexpr int size(const Foo<N>&) { return N; }

template <int N>
void use_size(const Foo<N>& foo) { constexpr int n = size(foo); }

int main()
{
    Foo<5> foo;

    constexpr int x = size(foo);  // works with gcc and clang
                                  // _but_
    use_size(foo);                // the same statement in the use_size()
                                  // function _only_ works for gcc
}
</code>```

I can successfuly compile it with g++ -std=c++11 foo.cpp

however if I use clang++, clang++ -std=c++11 foo.cpp I get

```<code>foo.cpp:15:28: error: constexpr variable 'n' must be initialized by a constant expression
void use_size(const Foo<N>& foo) { constexpr int n = size(foo); }
                                                     ~~~~~^~~~
foo.cpp:23:5: note: in instantiation of function template specialization 'use_size<5>' requested here
    use_size(foo);                // the same statement in the use_size()
    ^
1 error generated.
</code>```

(nb: compiler versions. I have checked the previous statement with g++ version 5.3.1 and 7.2.1 and with clang++ version 3.6.2 and 5.0.0)

My question: which of g++ or clang is right? What is the problem?

答:
I was expecting Clang to be wrong in this case. It should evaluate your function call as being a constant expression, simply because you use only the template parameter, and not the object itself. Since you don't use the object in your constexpr function, there should be nothing prohibit compile time evaluation.

However, there's a rule in the standard that says object that began their lifetime preceding the constant expression such as a reference is not useable as constexpr.

There is a simple fix in that case. I think it didn't like the reference:

```<code>template <int N> // pass by value, clang is happy
void use_size(Foo<N> foo) { constexpr int n = size(foo); }
</code>```

Here's a live example

Alternatively, you can also copy your foo object and use that local object:

```<code>template <int N>
void use_size(const Foo<N>& foo) {
    auto f = foo;
    constexpr int n = size(f);
}
</code>```

Live example

Body:
Consider the simple C++11 code:

template<int N>
struct Foo {};

template <int N>
constexpr int size(const Foo<N>&) { return N; }

template <int N>
void use_size(const Foo<N>& foo) { constexpr int n = size(foo); }

int main()
{
    Foo<5> foo;

    constexpr int x = size(foo);  // works with gcc and clang
                                  // _but_
    use_size(foo);                // the same statement in the use_size()
                                  // function _only_ works for gcc
}

I can successfuly compile it with g++ -std=c++11 foo.cpp

however if I use clang++, clang++ -std=c++11 foo.cpp I get

foo.cpp:15:28: error: constexpr variable 'n' must be initialized by a constant expression
void use_size(const Foo<N>& foo) { constexpr int n = size(foo); }
                                                     ~~~~~^~~~
foo.cpp:23:5: note: in instantiation of function template specialization 'use_size<5>' requested here
    use_size(foo);                // the same statement in the use_size()
    ^
1 error generated.

(nb: compiler versions. I have checked the previous statement with g++ version 5.3.1 and 7.2.1 and with clang++ version 3.6.2 and 5.0.0)

My question: which of g++ or clang is right? What is the problem?

Body:
I was expecting Clang to be wrong in this case. It should evaluate your function call as being a constant expression, simply because you use only the template parameter, and not the object itself. Since you don't use the object in your constexpr function, there should be nothing prohibit compile time evaluation.

However, there's a rule in the standard that says object that began their lifetime preceding the constant expression such as a reference is not useable as constexpr.

There is a simple fix in that case. I think it didn't like the reference:

template <int N> // pass by value, clang is happy
void use_size(Foo<N> foo) { constexpr int n = size(foo); }

Here's a live example

Alternatively, you can also copy your foo object and use that local object:

template <int N>
void use_size(const Foo<N>& foo) {
    auto f = foo;
    constexpr int n = size(f);
}

Live example


问:
Cross-Process Mutex Read/Write Locking
I'm trying to make inter-process communication in C/C++ on Windows environment.

I am creating a shared memory page file and two processes get the handle to that file. It's like this:

Process1: Initialize shared memory area. Wait for Process2 to fill it.

Process2: Get handle to shared memory area. Put stuff in it.

I am creating a named mutex in process1 as well. Now process1 acquires the ownership of the mutex soon after creating it (using WaitSingleObject). Obviously, there is nothing in the memory area so I need to release the mutex. Now I need to wait until the memory is filled instead of trying to acquire the mutex again.

I was thinking of conditional variables. Process2 signals the condition variable once it fills in the memory area and process1 will acquire the information immediately.

However, as per MS Documentation on Condition Variables, they are not shared across processes which is clear from their initialization as they are not named.

Furthermore, the shared memory area can hold up to one element at any given moment which means process2 cannot refill after filling it unless process1 extracts its information.

From the given description it's clear that condition variables are the best for this purpose (or Monitors). So is there a way around this?

答: I have used events for this before.  Use 2 named auto reset events.  1 data ready event and one buffer ready event.  Writer waits for buffer ready, writes data and sets the data ready event.  Reader waits for data ready event, reads memory and sets the buffer ready event.  If done properly you should not need the mutex.</p>

Title: Cross-Process Mutex Read/Write Locking


问:
Python Multiplication list
why won't it return the answer? </p>

```<code>    x=[1,2,3]
    y=[2,4,6]
    xy  = []
    def mult_list(xy):
        for i in range(0, len(x)):
        xy.append(x[i]*y[i])
        return xy
</code>```

答:
```<code>x=[1,2,3]
y=[2,4,6]
res=[i*j for i,j in zip(x,y)]
</code>```

What I have done here is used zip function.The zip() function take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples.

example:

```<code>numberList = [1, 2, 3]
strList = ['one', 'two', 'three']

# No iterables are passed
result = zip()

# Converting itertor to list
resultList = list(result)
print(resultList)

# Two iterables are passed
result = zip(numberList, strList)

# Converting itertor to set
resultSet = set(result)
print(resultSet)
</code>```

output:
[]
{(2, 'two'), (3, 'three'), (1, 'one')}

Title: Python Multiplication list

Body:
why won't it return the answer?

    x=[1,2,3]
    y=[2,4,6]
    xy  = []
    def mult_list(xy):
        for i in range(0, len(x)):
        xy.append(x[i]*y[i])
        return xy

Body:
x=[1,2,3]
y=[2,4,6]
res=[i*j for i,j in zip(x,y)]

What I have done here is used zip function.The zip() function take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples.

example:

numberList = [1, 2, 3]
strList = ['one', 'two', 'three']

# No iterables are passed
result = zip()

# Converting itertor to list
resultList = list(result)
print(resultList)

# Two iterables are passed
result = zip(numberList, strList)

# Converting itertor to set
resultSet = set(result)
print(resultSet)

output:
[]
{(2, 'two'), (3, 'three'), (1, 'one')}


问:
CloudFoundry/Springboot app using Liberty for Java on Bluemix all of a sudden crashes when starting, no changes in code for months
I have a javascript/html/css application being served with Springboot on Bluemix.  Running the app locally works just fine, and the code has not been changed in a couple months.  When I attempt to push the app using the CF CLI, I get the following error:

```<code>   2017-11-13T12:18:29.89-0600 [CELL/0] OUT Successfully destroyed container
   2017-11-13T12:19:33.32-0600 [CELL/0] OUT Creating container
   2017-11-13T12:19:37.70-0600 [CELL/0] OUT Successfully created container
   2017-11-13T12:19:55.79-0600 [CELL/0] OUT Starting health monitoring of container
   2017-11-13T12:19:59.83-0600 [APP/PROC/WEB/0] OUT 18:19:59.812 [main] INFO app.Application -  App Started
   2017-11-13T12:20:03.49-0600 [APP/PROC/WEB/0] OUT 2017-11-13 18:20:03,485 INFO  [main] app : app.Application : Starting Application on  with PID 13 (/home/vcap/app/BOOT-INF/classes started by vcap in /home/vcap/app)
   2017-11-13T12:20:03.49-0600 [APP/PROC/WEB/0] OUT 2017-11-13 18:20:03,487 INFO  [main] app : app.Application : No active profile set, falling back to default profiles: default
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR J9Generic_Signal_Number=00000004 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR RCX=0000000000000536 RDX=0000000000000000 R8=000000000000000C R9=00000000FFFFFFF9
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR RIP=00007F82CB50AADF GS=0000 FS=0000 RSP=00007F82CC39F460
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm12 4207fffffff8016a (f: 4294443264.000000, d: 1.288490e+10)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm13 3c57c00000000000 (f: 0.000000, d: 5.149960e-18)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Module=/home/vcap/app/.java/jre/lib/amd64/compressedrefs/libj9vm29.so
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR CPU=amd64 (4 logical CPUs) (0x7daa33000 RAM)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4E869F [libj9vm29.so+0xeb69f])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4DED50 [libj9vm29.so+0xe1d50])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Java_java_lang_ClassLoader_defineClassImpl+0xa4 (0x00007F82C0D69134 [libjclse7b_29.so+0x11134])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Unhandled exception
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Type=Segmentation error vmState=0x00000000
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Handler1=00007F82CB481AA0 Handler2=00007F82CAD8BE00 InaccessibleAddress=0000000000000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR EFlags=0000000000010246 CS=0033 RBP=00007F82CC39F9B0 ERR=0000000000000004
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR TRAPNO=000000000000000E OLDMASK=0000000000000000 CR2=0000000000000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm6 1610000ab3f109b8 (f: 3018918400.000000, d: 2.041302e-202)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm11 3c4cd58858eb8000 (f: 1491828736.000000, d: 3.126201e-18)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm15 4028f40b5ed97f00 (f: 1591312128.000000, d: 1.247665e+01)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4DDEDA [libj9vm29.so+0xe0eda])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR R14=0000000000000000 R15=0000000000000000
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm0 00ff000000000000 (f: 0.000000, d: 7.063274e-304)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm2 6a003e74696e693c (f: 1768843520.000000, d: 3.978864e+202)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm7 b8d41014f309b3f1 (f: 4077499392.000000, d: -6.037435e-35)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm10 3fe0000000000000 (f: 0.000000, d: 5.000000e-01)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR ----------- Stack Backtrace -----------
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4E6C85 [libj9vm29.so+0xe9c85])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR ---------------------------------------
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR R10=0000000000000522 R11=00007F82CC39FA0C R12=0000000000000000 R13=00007F82CBB9F520
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm3 105953dd10130610 (f: 269682176.000000, d: 6.525551e-230)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm4 d91013075953130a (f: 1498616576.000000, d: -1.037698e+121)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm5 5953cc0913045953 (f: 319052128.000000, d: 2.044833e+122)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm8 0000000000000000 (f: 0.000000, d: 0.000000e+00)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm9 09b3fe01b8042e01 (f: 3087281664.000000, d: 6.348990e-262)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Module_base_address=00007F82CB3FD000
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Target=2_90_20170901_363591 (Linux 4.4.0-75-generic)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB50AADF [libj9vm29.so+0x10dadf])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB502134 [libj9vm29.so+0x105134])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4E7E64 [libj9vm29.so+0xeae64])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82C0D74DD9 [libjclse7b_29.so+0x1cdd9])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR RDI=00007F82CC39F9B0 RSI=0000000000000000 RAX=0000000000000001 RBX=0000000000000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm1 0000ffffffffffff (f: 4294967296.000000, d: 1.390671e-309)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm14 bc5b599f227becbb (f: 578546880.000000, d: -5.930604e-18)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82B053920E [<unknown>+0x0])
   2017-11-13T12:20:03.89-0600 [APP/PROC/WEB/0] OUT Exit status 255
   2017-11-13T12:20:03.92-0600 [CELL/0] OUT Exit status 0
   2017-11-13T12:20:03.94-0600 [CELL/0] OUT Destroying container
   2017-11-13T12:20:03.94-0600 [CELL/0] OUT Stopping instance 5a3e2441-bbd9-402c-5748-fd68
   2017-11-13T12:20:03.96-0600 [API/0] OUT Process has crashed with type: "web"
   2017-11-13T12:20:03.97-0600 [API/0] OUT App instance exited with guid f7a4a8ff-ebbc-49cf-96eb-37895fb88edd payload: {"instance"=>"5a3e2441-bbd9-402c-5748-fd68", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 255", "crash_count"=>4, "crash_timestamp"=>1510597203938616258, "version"=>"7ebb8072-9edc-40e3-a749-ce83273fb0d3"}
</code>```

I have other apps using the liberty for java buildpack on Bluemix that are doing fine, but this app specifically has started crashing with no changes to the environment or code, and the errors are not too helpful.  I've tried increasing memory and using several different buildpacks (IBM's websphere libery as well as cloud foundry's) to no avail Any advice would be appreciated.

答: Have you tried increasing the memory for the apps and try the liberty buildpack?</p>

Body:
I have a javascript/html/css application being served with Springboot on Bluemix.  Running the app locally works just fine, and the code has not been changed in a couple months.  When I attempt to push the app using the CF CLI, I get the following error:

   2017-11-13T12:18:29.89-0600 [CELL/0] OUT Successfully destroyed container
   2017-11-13T12:19:33.32-0600 [CELL/0] OUT Creating container
   2017-11-13T12:19:37.70-0600 [CELL/0] OUT Successfully created container
   2017-11-13T12:19:55.79-0600 [CELL/0] OUT Starting health monitoring of container
   2017-11-13T12:19:59.83-0600 [APP/PROC/WEB/0] OUT 18:19:59.812 [main] INFO app.Application -  App Started
   2017-11-13T12:20:03.49-0600 [APP/PROC/WEB/0] OUT 2017-11-13 18:20:03,485 INFO  [main] app : app.Application : Starting Application on  with PID 13 (/home/vcap/app/BOOT-INF/classes started by vcap in /home/vcap/app)
   2017-11-13T12:20:03.49-0600 [APP/PROC/WEB/0] OUT 2017-11-13 18:20:03,487 INFO  [main] app : app.Application : No active profile set, falling back to default profiles: default
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR J9Generic_Signal_Number=00000004 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR RCX=0000000000000536 RDX=0000000000000000 R8=000000000000000C R9=00000000FFFFFFF9
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR RIP=00007F82CB50AADF GS=0000 FS=0000 RSP=00007F82CC39F460
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm12 4207fffffff8016a (f: 4294443264.000000, d: 1.288490e+10)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm13 3c57c00000000000 (f: 0.000000, d: 5.149960e-18)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Module=/home/vcap/app/.java/jre/lib/amd64/compressedrefs/libj9vm29.so
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR CPU=amd64 (4 logical CPUs) (0x7daa33000 RAM)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4E869F [libj9vm29.so+0xeb69f])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4DED50 [libj9vm29.so+0xe1d50])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Java_java_lang_ClassLoader_defineClassImpl+0xa4 (0x00007F82C0D69134 [libjclse7b_29.so+0x11134])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Unhandled exception
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Type=Segmentation error vmState=0x00000000
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Handler1=00007F82CB481AA0 Handler2=00007F82CAD8BE00 InaccessibleAddress=0000000000000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR EFlags=0000000000010246 CS=0033 RBP=00007F82CC39F9B0 ERR=0000000000000004
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR TRAPNO=000000000000000E OLDMASK=0000000000000000 CR2=0000000000000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm6 1610000ab3f109b8 (f: 3018918400.000000, d: 2.041302e-202)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm11 3c4cd58858eb8000 (f: 1491828736.000000, d: 3.126201e-18)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm15 4028f40b5ed97f00 (f: 1591312128.000000, d: 1.247665e+01)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4DDEDA [libj9vm29.so+0xe0eda])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR R14=0000000000000000 R15=0000000000000000
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm0 00ff000000000000 (f: 0.000000, d: 7.063274e-304)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm2 6a003e74696e693c (f: 1768843520.000000, d: 3.978864e+202)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm7 b8d41014f309b3f1 (f: 4077499392.000000, d: -6.037435e-35)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm10 3fe0000000000000 (f: 0.000000, d: 5.000000e-01)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR ----------- Stack Backtrace -----------
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4E6C85 [libj9vm29.so+0xe9c85])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR ---------------------------------------
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR R10=0000000000000522 R11=00007F82CC39FA0C R12=0000000000000000 R13=00007F82CBB9F520
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm3 105953dd10130610 (f: 269682176.000000, d: 6.525551e-230)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm4 d91013075953130a (f: 1498616576.000000, d: -1.037698e+121)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm5 5953cc0913045953 (f: 319052128.000000, d: 2.044833e+122)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm8 0000000000000000 (f: 0.000000, d: 0.000000e+00)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm9 09b3fe01b8042e01 (f: 3087281664.000000, d: 6.348990e-262)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Module_base_address=00007F82CB3FD000
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR Target=2_90_20170901_363591 (Linux 4.4.0-75-generic)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB50AADF [libj9vm29.so+0x10dadf])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB502134 [libj9vm29.so+0x105134])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82CB4E7E64 [libj9vm29.so+0xeae64])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82C0D74DD9 [libjclse7b_29.so+0x1cdd9])
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR RDI=00007F82CC39F9B0 RSI=0000000000000000 RAX=0000000000000001 RBX=0000000000000001
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm1 0000ffffffffffff (f: 4294967296.000000, d: 1.390671e-309)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR xmm14 bc5b599f227becbb (f: 578546880.000000, d: -5.930604e-18)
   2017-11-13T12:20:03.79-0600 [APP/PROC/WEB/0] ERR (0x00007F82B053920E [<unknown>+0x0])
   2017-11-13T12:20:03.89-0600 [APP/PROC/WEB/0] OUT Exit status 255
   2017-11-13T12:20:03.92-0600 [CELL/0] OUT Exit status 0
   2017-11-13T12:20:03.94-0600 [CELL/0] OUT Destroying container
   2017-11-13T12:20:03.94-0600 [CELL/0] OUT Stopping instance 5a3e2441-bbd9-402c-5748-fd68
   2017-11-13T12:20:03.96-0600 [API/0] OUT Process has crashed with type: "web"
   2017-11-13T12:20:03.97-0600 [API/0] OUT App instance exited with guid f7a4a8ff-ebbc-49cf-96eb-37895fb88edd payload: {"instance"=>"5a3e2441-bbd9-402c-5748-fd68", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 255", "crash_count"=>4, "crash_timestamp"=>1510597203938616258, "version"=>"7ebb8072-9edc-40e3-a749-ce83273fb0d3"}

I have other apps using the liberty for java buildpack on Bluemix that are doing fine, but this app specifically has started crashing with no changes to the environment or code, and the errors are not too helpful.  I've tried increasing memory and using several different buildpacks (IBM's websphere libery as well as cloud foundry's) to no avail Any advice would be appreciated.


问:
Doubletap and slide/drag finger to zoom in/out
If anyone came across the google maps app for iOS there is a great feature to zoom in/out with one finger:
Doubletap on the uiscrollview and then immediately slide finger up or down to zoom in/out.
Does anyone know how this is achieved? Did google post any snippet of that?</p>

答:
Use a UIPanGestureRecognizer to track the up/down drag.
To ensure it only gets triggered on a double-tap, give it a delegate that does the following:

```<code>func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
    if gestureRecognizer == yourZoomRecognizer {
        return touch.tapCount == 2
    } else {
        return true
    }
}
</code>```

Now handle the messages coming from the gesture-recogniser. You can derive a zoom scale like so:

```<code>let zoomFactor: CGFloat = 1.01        //Each point of pan zooms in or out by this much
var zoomScale: CGFloat = 1            //Dummy variable for example purposes.

@IBAction func handleZoomGesture(sender: UIPanGestureRecognizer) {
    if sender.state == .began {
        //Set initial translation to reflect the current zoomScale
        let logZoom = log(zoomScale) / log(zoomFactor)
        sender.setTranslation(CGPoint(x: 0, y: logZoom), in: sender.view)
    } else if sender.state == .changed {
        let logZoom = sender.translation(in: sender.view).y
        zoomScale = pow(zoomFactor, logZoom)
    }
}
</code>```

This doesn't show actually setting the zoomScale on a scrollview, which is a bunch of extra code - you'll want to get the pan gesture's location and center the zoom around that. You'll also want to clamp the zoomScale, and maybe handle the zoom ending too.

Body:
Use a UIPanGestureRecognizer to track the up/down drag.
To ensure it only gets triggered on a double-tap, give it a delegate that does the following:

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
    if gestureRecognizer == yourZoomRecognizer {
        return touch.tapCount == 2
    } else {
        return true
    }
}

Now handle the messages coming from the gesture-recogniser. You can derive a zoom scale like so:

let zoomFactor: CGFloat = 1.01        //Each point of pan zooms in or out by this much
var zoomScale: CGFloat = 1            //Dummy variable for example purposes.

@IBAction func handleZoomGesture(sender: UIPanGestureRecognizer) {
    if sender.state == .began {
        //Set initial translation to reflect the current zoomScale
        let logZoom = log(zoomScale) / log(zoomFactor)
        sender.setTranslation(CGPoint(x: 0, y: logZoom), in: sender.view)
    } else if sender.state == .changed {
        let logZoom = sender.translation(in: sender.view).y
        zoomScale = pow(zoomFactor, logZoom)
    }
}

This doesn't show actually setting the zoomScale on a scrollview, which is a bunch of extra code - you'll want to get the pan gesture's location and center the zoom around that. You'll also want to clamp the zoomScale, and maybe handle the zoom ending too.


问:
#1111 - Invalid use of group function
I am using the following query in an attempt to get  total number(sum) of slides retrieving the max number from each project, however I am receiving the following error (#1111 - Invalid use of group function). Here's the query:

```<code>SELECT COALESCE(project,'Total') as Project, SUM(MAX(slides)) as Slides
FROM projects_tbl
WHERE date BETWEEN '2010-01-01' AND '2010-12-31'
GROUP BY Project with ROLLUP
</code>```

If I remove the SUM(), then the it works, however, I do not get an accurate total for all of the projects/slides.

Thanks in advance for any and all replies.

答:
```<code>SELECT  COALESCE(project,'Total') as Project, SUM(maxslides) AS slides
FROM    (
        SELECT  project, MAX(slides) as maxslides
        FROM    projects_tbl
        WHERE   date BETWEEN '2010-01-01' AND '2010-12-31'
        GROUP BY
                project
        ) q
GROUP BY
        project WITH ROLLUP
</code>```

ContentLicense: CC BY-SA 2.5

Title: #1111 - Invalid use of group function

Body:
I am using the following query in an attempt to get  total number(sum) of slides retrieving the max number from each project, however I am receiving the following error (#1111 - Invalid use of group function). Here's the query:

SELECT COALESCE(project,'Total') as Project, SUM(MAX(slides)) as Slides
FROM projects_tbl
WHERE date BETWEEN '2010-01-01' AND '2010-12-31'
GROUP BY Project with ROLLUP

If I remove the SUM(), then the it works, however, I do not get an accurate total for all of the projects/slides.

Thanks in advance for any and all replies.


问:
How can I remove rows from a postgres table that all have the same value in a column, if any of those rows contains a certain value in another column?
I have a table that looks like this:

```<code>Teacher   | Class | Number of students
Ms. Smith | 101   | 101
Mr. Frank | 300   | 20
Mr. Frank | 401   | 0
Mr. Smith | 102   | 20
Ms. Date  | 300   | 0
Mr. First | 100   | 10
</code>```

I want to query and get back a table that has removed any teacher (all of their rows) who has a class of zero students, so the result I'm looking for is:

```<code>Teacher   | Class | Number of students
Ms. Smith | 101   | 101
Mr. Smith | 102   | 20
Mr. First | 100   | 10
</code>```

Any idea how I can do this? I am stumped.

答:
Use not exists:

```<code>select *
from teachers t
where not exists (
    select 1
    from teachers
    where number_of_students = 0 and teacher = t.teacher)

  teacher  | class | number_of_students
-----------+-------+--------------------
 Ms. Smith |   101 |                101
 Mr. Smith |   102 |                 20
 Mr. First |   100 |                 10
(3 rows)
</code>```

Body:
I have a table that looks like this:

Teacher   | Class | Number of students
Ms. Smith | 101   | 101
Mr. Frank | 300   | 20
Mr. Frank | 401   | 0
Mr. Smith | 102   | 20
Ms. Date  | 300   | 0
Mr. First | 100   | 10

I want to query and get back a table that has removed any teacher (all of their rows) who has a class of zero students, so the result I'm looking for is:

Teacher   | Class | Number of students
Ms. Smith | 101   | 101
Mr. Smith | 102   | 20
Mr. First | 100   | 10

Any idea how I can do this? I am stumped.

Body:
Use not exists:

select *
from teachers t
where not exists (
    select 1
    from teachers
    where number_of_students = 0 and teacher = t.teacher)

  teacher  | class | number_of_students
-----------+-------+--------------------
 Ms. Smith |   101 |                101
 Mr. Smith |   102 |                 20
 Mr. First |   100 |                 10
(3 rows)


问:
PHP protect directory from direct URL access
I have an ADMIN script.

```<code>admin/index.php
</code>```

All activity is done through this index.php file.
 Users are logging in before gaining access to the program functionality.
$_SESSION['user_authenticated'] is created and set to true.

```<code>admin/template/..
</code>```

This folder contains images, css, javascript files.
They are used only within this ADMIN. (in the backend only)

The question:

I need all the content from admin/template/.. directory to be protected against direct access.
It should be available only to authenticated users.

I guess there has to be a .htaccess redirecting requests to check_session_auth_variable.php, which looks if $_SESSION['user_authenticated'] is true or false and redirects to requested file or throws a 404 error?

I know that the best option would be to place the directory outside of the web root, but in my case I need to keep the directory structure as is, without modification.

答:
I usually use this</p>

```<code>$redi_ext = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$php_verify = strpos($redi_ext, ".php");
if($php_verify !== false){ header('location: PAGE_NOT_FOUND_URL'); }
</code>```

Body:
I have an ADMIN script.

admin/index.php

All activity is done through this index.php file.
 Users are logging in before gaining access to the program functionality.
$_SESSION['user_authenticated'] is created and set to true.

admin/template/..

This folder contains images, css, javascript files.
They are used only within this ADMIN. (in the backend only)

The question:

I need all the content from admin/template/.. directory to be protected against direct access.
It should be available only to authenticated users.

I guess there has to be a .htaccess redirecting requests to check_session_auth_variable.php, which looks if $_SESSION['user_authenticated'] is true or false and redirects to requested file or throws a 404 error?

I know that the best option would be to place the directory outside of the web root, but in my case I need to keep the directory structure as is, without modification.

Body:
I usually use this

$redi_ext = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$php_verify = strpos($redi_ext, ".php");
if($php_verify !== false){ header('location: PAGE_NOT_FOUND_URL'); }


问:
Klipfolio (Podio integration) is missing values
Using API I have exported data from my Podio app into Klipfolio but somehow not all data is being exported. When trying to show all values from a field, only some of them are shown.

I have tried to find the root of the problem by contacting Klipfolios support but have gotten the following answer

"The data in the datasource is all of the data being returned by the service you are connected to via the API, if there is a discrepancy in what you are seeing in the service portal and the datasource then you will need to contact that service to determine the issue as it is not something that Klipfolio is restricting "

As an example of the problem I have included two screenshots.

A screenshot of the Podio app export called "Personale"

.

In column R (highlighted in red) the values for the "Stilling" field is seen. There is a total of 155 values.

A screenshot from Klipfolio with the values from the "Stilling" field put into a table:
.

As seen there is only 80 items and when I scroll down some of them is not even from the "Stilling" field, but from the one of the other fields.

Somehow not all values are being exported into the Klipfolio data source (JSON format). Can anyone tell me how I can solve the problem, or do I need to provide more information?

答:
As Pavlo mentioned, you will need to filter based on a JSON record name and not the indices of the JSON record as not all field arrays will be in the same position for each item. The following JSON expressions should return all the value records for where the label of the field is "Stilling"</p>

```<code>@/items/fields[label='Stilling']/values/value/text
</code>```

Body:
As Pavlo mentioned, you will need to filter based on a JSON record name and not the indices of the JSON record as not all field arrays will be in the same position for each item. The following JSON expressions should return all the value records for where the label of the field is "Stilling"

@/items/fields[label='Stilling']/values/value/text


答:
Make sure your indentation is correct. return xy should be outside of the loop.

It is preferable not to have xy a global list. Instead, define it inside the function. If it is global you will get funny results if mul_list is called more than once.

```<code>def mult_list(list_a, list_b):
    xy  = []
    for i in range(0, len(list_a)):
        xy.append(list_a[i] * list_b[i])
    return xy

x = [1, 2, 3]
y = [2, 4, 6]

print(mult_list(x, y))
#  [2, 8, 18]
</code>```

But it is considered not pythonic to use range in order to index into a list. Instead you can use zip:

```<code>def mult_list(list_a, list_b):
    xy  = []
    for num_a, num_b in zip(list_a, list_b):
        xy.append(num_a * num_b)
    return xy

x = [1, 2, 3]
y = [2, 4, 6]

print(mult_list(x, y))
#  [2, 8, 18]
</code>```

Title: Python Multiplication list

Body:
Make sure your indentation is correct. return xy should be outside of the loop.

It is preferable not to have xy a global list. Instead, define it inside the function. If it is global you will get funny results if mul_list is called more than once.

def mult_list(list_a, list_b):
    xy  = []
    for i in range(0, len(list_a)):
        xy.append(list_a[i] * list_b[i])
    return xy

x = [1, 2, 3]
y = [2, 4, 6]

print(mult_list(x, y))
#  [2, 8, 18]

But it is considered not pythonic to use range in order to index into a list. Instead you can use zip:

def mult_list(list_a, list_b):
    xy  = []
    for num_a, num_b in zip(list_a, list_b):
        xy.append(num_a * num_b)
    return xy

x = [1, 2, 3]
y = [2, 4, 6]

print(mult_list(x, y))
#  [2, 8, 18]


问:
Theming order by taxonomy term
I have a view that gets all the nodes from a certain type and shows them on a page; every node is categorized by a taxonomy term.
I created a custom .template file to theme the view using the row style, but what I really would like to do is order all the nodes under a category, for example:

category 1

node 1

node 7

node 15

category 2

node 2

node 6

How do I do this?

答:
Please note steps describe below are for D6:

Create u r view using drupal views module

Select the appropriate fields,

under filter field, Select the taxonomy , and select appropriate taxonomy term

Select the appropriate fields (which you will like to display).

change the output style to table or whatever you prefer

and there you have it

Hope it helps.

Title: Theming order by taxonomy term


问:
Cannot Bind Event Handler to Button
I creating a utility program in Python using wxPython, but I'm unable to bind a method to the button.

The interesting thing is, I've binded another button(self.add_employee_to_list) exactly the same way, but that one works.

```<code>class MyDialog(wx.Frame):

    def __init__(self, parent, title):
        self.no_resize = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
        wx.Frame.__init__(self, parent, title=title, size=(500, 450),style = self.no_resize)

        self.panel = wx.Panel(self, size=(250, 270))

        self.add_employee_to_list = wx.Button(self.panel, label="Add Employee", pos=(250,50), size=(115,25))
        self.add_employee_to_list.Bind(wx.EVT_BUTTON, self.add_employee_to_box)

        #Button that produces error on binding
        self.remove_employee_from_list = wx.Button(self.panel, label="Remove Employee",pos= (250,80), size=(115,25))
        self.remove_employee_from_list.Bind(wx.EVT_BUTTON, self.remove_employee_from_list)

    def remove_employee_from_list(self, event):
        pass

app = wx.App(False)
frame = MyDialog(None, "Crystal Rose")
app.MainLoop()
</code>```

I get the following error:

```<code>Traceback (most recent call last):   File "C:/Users/SR/PycharmProjects/CrystalRose/CrystalRoseGUI.py", line 59, in <module>
    frame = MyDialog(None, "Crystal Rose")   File "C:/Users/SR/PycharmProjects/CrystalRose/CrystalRoseGUI.py", line 22, in __init__
    self.remove_employee_from_list.Bind(wx.EVT_BUTTON, self.remove_employee_from_list)   File "C:\Program Files (x86)\Python36-32\lib\site-packages\wx\core.py", line 1339, in
_EvtHandler_Bind
    assert callable(handler) or handler is None AssertionError
</code>```

答:
You're declaring remove_employee_from_list as a method and also setting it as a button in __init__. The button and the method that fires aren't the same thing and need different names. Try this:

```<code>import wx

class MyDialog(wx.Frame):

    def __init__(self, parent, title):
        self.no_resize = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
        wx.Frame.__init__(self, parent, title=title, size=(500, 450),style = self.no_resize)

        self.panel = wx.Panel(self, size=(250, 270))

        self.add_employee_to_list = wx.Button(self.panel, label="Add Employee", pos=(250,50), size=(115,25))
        self.add_employee_to_list.Bind(wx.EVT_BUTTON, self.add_employee_to_box)

        #Button that produces error on binding
        self.remove_employee_from_list = wx.Button(self.panel, label="Remove Employee",pos= (250,80), size=(115,25))
        self.remove_employee_from_list.Bind(wx.EVT_BUTTON, self.remove_employee_from_box)

    def remove_employee_from_box(self, event):
        pass

    def add_employee_to_box(self, event):
        pass

app = wx.App(False)
frame = MyDialog(None, "Crystal Rose")
frame.Show()
app.MainLoop()
</code>```

Title: Cannot Bind Event Handler to Button

Body:
I creating a utility program in Python using wxPython, but I'm unable to bind a method to the button.

The interesting thing is, I've binded another button(self.add_employee_to_list) exactly the same way, but that one works.

class MyDialog(wx.Frame):

    def __init__(self, parent, title):
        self.no_resize = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
        wx.Frame.__init__(self, parent, title=title, size=(500, 450),style = self.no_resize)

        self.panel = wx.Panel(self, size=(250, 270))

        self.add_employee_to_list = wx.Button(self.panel, label="Add Employee", pos=(250,50), size=(115,25))
        self.add_employee_to_list.Bind(wx.EVT_BUTTON, self.add_employee_to_box)

        #Button that produces error on binding
        self.remove_employee_from_list = wx.Button(self.panel, label="Remove Employee",pos= (250,80), size=(115,25))
        self.remove_employee_from_list.Bind(wx.EVT_BUTTON, self.remove_employee_from_list)

    def remove_employee_from_list(self, event):
        pass

app = wx.App(False)
frame = MyDialog(None, "Crystal Rose")
app.MainLoop()

I get the following error:

Traceback (most recent call last):   File "C:/Users/SR/PycharmProjects/CrystalRose/CrystalRoseGUI.py", line 59, in <module>
    frame = MyDialog(None, "Crystal Rose")   File "C:/Users/SR/PycharmProjects/CrystalRose/CrystalRoseGUI.py", line 22, in __init__
    self.remove_employee_from_list.Bind(wx.EVT_BUTTON, self.remove_employee_from_list)   File "C:\Program Files (x86)\Python36-32\lib\site-packages\wx\core.py", line 1339, in
_EvtHandler_Bind
    assert callable(handler) or handler is None AssertionError

Body:
You're declaring remove_employee_from_list as a method and also setting it as a button in __init__. The button and the method that fires aren't the same thing and need different names. Try this:

import wx

class MyDialog(wx.Frame):

    def __init__(self, parent, title):
        self.no_resize = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
        wx.Frame.__init__(self, parent, title=title, size=(500, 450),style = self.no_resize)

        self.panel = wx.Panel(self, size=(250, 270))

        self.add_employee_to_list = wx.Button(self.panel, label="Add Employee", pos=(250,50), size=(115,25))
        self.add_employee_to_list.Bind(wx.EVT_BUTTON, self.add_employee_to_box)

        #Button that produces error on binding
        self.remove_employee_from_list = wx.Button(self.panel, label="Remove Employee",pos= (250,80), size=(115,25))
        self.remove_employee_from_list.Bind(wx.EVT_BUTTON, self.remove_employee_from_box)

    def remove_employee_from_box(self, event):
        pass

    def add_employee_to_box(self, event):
        pass

app = wx.App(False)
frame = MyDialog(None, "Crystal Rose")
frame.Show()
app.MainLoop()


问:
bootstrap datepicker not selecting date in post variable

Code for datepicker.

```<code>    <form action="xyz.php" method="post">
            <div class="form-group">
            <label class="col-md-2 control-label" for="textarea"> From Date</label>
                <div class="col-md-2">
                    <div class="bfh-datepicker" >
                        <input id="dateFrom" type="text" name="dateFrom"  class="datepicker">
                   </div>

                </div>
          <button type="submit" name="create" class="btn btn-primary">
        </div>
    </form>
</code>```

Code for fetching value in php

```<code>       if(isset($_POST['create'])){
          echo $fromDate=$_POST['dateFrom'];

            }
</code>```

I want date in my post variable. but its giving me error "Notice: Undefined index: dateFrom in line....."

答:
you will need to get the value:

```<code>$('#dateForm').val()
</code>```

or

```<code>$('#dateForm').date('date')
</code>```

and see the way you can pass this value to the BE.

Body:
Code for datepicker.

    <form action="xyz.php" method="post">

             From Date

                        <input id="dateFrom" type="text" name="dateFrom"  class="datepicker">

          <button type="submit" name="create" class="btn btn-primary">

    </form>

Code for fetching value in php

       if(isset($_POST['create'])){
          echo $fromDate=$_POST['dateFrom'];

            }

I want date in my post variable. but its giving me error "Notice: Undefined index: dateFrom in line....."

Body:
you will need to get the value:

$('#dateForm').val()

or

$('#dateForm').date('date')

and see the way you can pass this value to the BE.


问:
How do I do base64 encoding on iOS?
I'd like to do base64 encoding and decoding, but I could not find any support from the iPhone SDK. How can I do base64 encoding and decoding with or without a library?

OwnerDisplayName: BlueDolphin

ContentLicense: CC BY-SA 4.0

Title: How do I do base64 encoding on iOS?

Body:
A really, really fast implementation which was ported (and modified/improved) from the PHP Core library into native Objective-C code is available in the QSStrings Class from the QSUtilities Library.  I did a quick benchmark: a 5.3MB image (JPEG) file took < 50ms to encode, and about 140ms to decode.

The code for the entire library (including the Base64 Methods) are available on GitHub.

Or alternatively, if you want the code to just the Base64 methods themselves, I've posted it here:

First, you need the mapping tables:

static const char _base64EncodingTable[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const short _base64DecodingTable[256] = {
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -2, -1, -1, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 62, -2, -2, -2, 63,
    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -2, -2, -2, -2, -2, -2,
    -2,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -2, -2, -2, -2, -2,
    -2, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
    -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
};

To Encode:

+ (NSString *)encodeBase64WithString:(NSString *)strData {
    return [QSStrings encodeBase64WithData:[strData dataUsingEncoding:NSUTF8StringEncoding]];
}

+ (NSString *)encodeBase64WithData:(NSData *)objData {
    const unsigned char * objRawData = [objData bytes];
    char * objPointer;
    char * strResult;

    // Get the Raw Data length and ensure we actually have data
    int intLength = [objData length];
    if (intLength == 0) return nil;

    // Setup the String-based Result placeholder and pointer within that placeholder
    strResult = (char *)calloc((((intLength + 2) / 3) * 4) + 1, sizeof(char));
    objPointer = strResult;

    // Iterate through everything
    while (intLength > 2) { // keep going until we have less than 24 bits
        *objPointer++ = _base64EncodingTable[objRawData[0] >> 2];
        *objPointer++ = _base64EncodingTable[((objRawData[0] & 0x03) << 4) + (objRawData[1] >> 4)];
        *objPointer++ = _base64EncodingTable[((objRawData[1] & 0x0f) << 2) + (objRawData[2] >> 6)];
        *objPointer++ = _base64EncodingTable[objRawData[2] & 0x3f];

        // we just handled 3 octets (24 bits) of data
        objRawData += 3;
        intLength -= 3;
    }

    // now deal with the tail end of things
    if (intLength != 0) {
        *objPointer++ = _base64EncodingTable[objRawData[0] >> 2];
        if (intLength > 1) {
            *objPointer++ = _base64EncodingTable[((objRawData[0] & 0x03) << 4) + (objRawData[1] >> 4)];
            *objPointer++ = _base64EncodingTable[(objRawData[1] & 0x0f) << 2];
            *objPointer++ = '=';
        } else {
            *objPointer++ = _base64EncodingTable[(objRawData[0] & 0x03) << 4];
            *objPointer++ = '=';
            *objPointer++ = '=';
        }
    }

    // Terminate the string-based result
    *objPointer = '\0';

    // Create result NSString object
    NSString *base64String = [NSString stringWithCString:strResult encoding:NSASCIIStringEncoding];

    // Free memory
    free(strResult);

    return base64String;
}

To Decode:

+ (NSData *)decodeBase64WithString:(NSString *)strBase64 {
    const char *objPointer = [strBase64 cStringUsingEncoding:NSASCIIStringEncoding];
    size_t intLength = strlen(objPointer);
    int intCurrent;
    int i = 0, j = 0, k;

    unsigned char *objResult = calloc(intLength, sizeof(unsigned char));

    // Run through the whole string, converting as we go
    while ( ((intCurrent = *objPointer++) != '\0') && (intLength-- > 0) ) {
        if (intCurrent == '=') {
            if (*objPointer != '=' && ((i % 4) == 1)) {// || (intLength > 0)) {
                // the padding character is invalid at this point -- so this entire string is invalid
                free(objResult);
                return nil;
            }
            continue;
        }

        intCurrent = _base64DecodingTable[intCurrent];
        if (intCurrent == -1) {
            // we're at a whitespace -- simply skip over
            continue;
        } else if (intCurrent == -2) {
            // we're at an invalid character
            free(objResult);
            return nil;
        }

        switch (i % 4) {
            case 0:
                objResult[j] = intCurrent << 2;
                break;

            case 1:
                objResult[j++] |= intCurrent >> 4;
                objResult[j] = (intCurrent & 0x0f) << 4;
                break;

            case 2:
                objResult[j++] |= intCurrent >>2;
                objResult[j] = (intCurrent & 0x03) << 6;
                break;

            case 3:
                objResult[j++] |= intCurrent;
                break;
        }
        i++;
    }

    // mop things up if we ended on a boundary
    k = j;
    if (intCurrent == '=') {
        switch (i % 4) {
            case 1:
                // Invalid state
                free(objResult);
                return nil;

            case 2:
                k++;
                // flow through
            case 3:
                objResult[k] = 0;
        }
    }

    // Cleanup and setup the return NSData
    NSData * objData = [[[NSData alloc] initWithBytes:objResult length:j] autorelease];
    free(objResult);
    return objData;
}


问:
Error in source() unexpected numeric constant
when I write an R script in a test.R file

```<code>nb <- 22

paste("Etudions le nombre: ",nb)
paste("Le logarithme népérien de ce nombre est: ", log(nb))
paste("La racine carrée de ce nombre est: ", sqrt(nb))
paste("Le cosinus de ce nombre est: ", cos(nb))
paste("Si on ajoute 3 au nombre ", nb, " on obtient: ", nb + 3)

q("ask")
</code>```

I executed using :

```<code>source("/Users/shous/Desktop/Master2.0/LanguageR/test.R")
</code>```

error  message :

```<code>Error in source("/Users/shous/Desktop/Master2.0/LanguageR/test.R") :
/Users/shous/Desktop/Master2.0/LanguageR/test.R:1:9: unexpected numeric constant
1: nbÂ <-Â 22
</code>```

答:
unexpected numeric constant 1: nbÂ <-Â 22

This is R telling you that it found the line

```<code>nbÂ <-Â 22
</code>```

and that isn't valid syntax. You can duplicate this simply on the command line with something like a = a 22, which also isn't valid syntax. You need to correct that line of code - I don't know what you want it to be, perhaps there is a missing line break, or perhaps it should be Â + 22 or Â[22], etc...

The line that produces the error does not occur in the code you show, perhaps you should make sure you are running the right file.

Body:
when I write an R script in a test.R file

nb <- 22

paste("Etudions le nombre: ",nb)
paste("Le logarithme népérien de ce nombre est: ", log(nb))
paste("La racine carrée de ce nombre est: ", sqrt(nb))
paste("Le cosinus de ce nombre est: ", cos(nb))
paste("Si on ajoute 3 au nombre ", nb, " on obtient: ", nb + 3)

q("ask")

I executed using :

source("/Users/shous/Desktop/Master2.0/LanguageR/test.R")

error  message :

Error in source("/Users/shous/Desktop/Master2.0/LanguageR/test.R") :
/Users/shous/Desktop/Master2.0/LanguageR/test.R:1:9: unexpected numeric constant
1: nbÂ <-Â 22

Body:
unexpected numeric constant 1: nbÂ <-Â 22

This is R telling you that it found the line

nbÂ <-Â 22

and that isn't valid syntax. You can duplicate this simply on the command line with something like a = a 22, which also isn't valid syntax. You need to correct that line of code - I don't know what you want it to be, perhaps there is a missing line break, or perhaps it should be Â + 22 or Â[22], etc...

The line that produces the error does not occur in the code you show, perhaps you should make sure you are running the right file.


问:
testing my REPOSITORY layer with DBUnit/Junit, should I manually build scheme or automate it? what's the advantages?
I am thinking on how to design my unit-tests for my java based-repositories and encountering design problems:
Lets assume I have a Consumer table with data related to my consumer:
{ ID, Name, Phone }
And my ConsumerRepository extends BaseRepository which extends JPA repo and supports findByPhone, findByName, findAll queries and save option.

I'm using H2 in-memo DB and DBUnit for those tests, all configured and running and was thinking about this:

When launching data to my in-memory DB, should I be configuring the data with the ConsumerTestData.xml (DBUnit) and manually adding the Consumer data for each test for e.g:

```<code><dataset>
<CONSUMER CONSUMER_ID="1" FIRST_NAME="Elvis" LAST_NAME="Presley" PHONE="+972123456789" EMAIL="elvis@isep.com" CREATION_DATE="2017-08-29"/>
<CONSUMER CONSUMER_ID="2" FIRST_NAME="Bob" LAST_NAME="Dylan" PHONE="+972123456780" EMAIL="bob@isep.com" CREATION_DATE="2017-08-29"/>
<CONSUMER CONSUMER_ID="3" FIRST_NAME="Lady" LAST_NAME="Gaga" PHONE="+972123456781" EMAIL="gaga@isep.com" CREATION_DATE="2017-08-29"/>
</dataset>
</code>```

or should I automate it? for e.g:

```<code>@Test
public void findByPhone(){
    ConsumerEntity consumerEntity = ConsumerUtil.createRandomConsumer();
    ConsumerEntity savedConsumerEntity = consumerRepository.save(consumerEntity);
    assertThat(consumerRepository.findByPhone(savedConsumerEntity.getPhone()).isEqualTo(savedConsumerEntity.getPhone());
}
</code>```

While my createRandomConsumer generates random data.

Pros:
I think automating would be much more generic and handy as if ConsumerEntity might change or any code changes next - i will not have to change my .xml file and just be able to add things to the TestEntity function.
Cons:
Creating new objects and saving to in-memo DB might be more difficult if contains any constraints in the DB scheme.

Should I use DBUnit at all? if automating it - why should I use DBUnit? is it better just to use JUnit (Rolling back the data after each test and just adding the data I need for the test automatically as in the example above?)

If chose to use DBUnit for this - and manually added - what are the advantages of such thing? why is it better than using simple JUnit with Spring?

Thanks!

答:
You seem to be asking 2 questions: whether to use DBUnit and whether to use randomization.

As for DBUnit

It adds extra steps and extra maintenance costs. If you already have code to save entities (via XxxRepository), then there is no reason to introduce yet additional tool.

This is true not only for DBUnit but for any tool that duplicates existing persistence logic.

Instead you can just create an object instance, fill all the fields and save with the repository. This makes refactoring much easier.

As for test randomization

I think your test looks very good. With randomization you can cover more cases with less tests, find tricky cases that you couldn't think of yourself, isolate your tests easily (e.g. generate unique username instead of keeping track of them somewhere), etc.

As per cons: good randomziation (and good tests in general) require a good command of OOP, so not everyone can easily use it when the project grows big. Also tests start failing from time to time because they are written in haste and not every possibility is considered. To catch such cases you should run the tests locally many times (which sometimes people forget). Good news: IntelliJ can repeat tests N times for JUnit (for TestNG there is an annotation).

In general you should think more when you write randomized tests. But if written properly they provide better coverage and lower maintenance overhead. If you're interested in different randomization techniques, check this out.

Body:
I am thinking on how to design my unit-tests for my java based-repositories and encountering design problems:
Lets assume I have a Consumer table with data related to my consumer:
{ ID, Name, Phone }
And my ConsumerRepository extends BaseRepository which extends JPA repo and supports findByPhone, findByName, findAll queries and save option.

I'm using H2 in-memo DB and DBUnit for those tests, all configured and running and was thinking about this:

When launching data to my in-memory DB, should I be configuring the data with the ConsumerTestData.xml (DBUnit) and manually adding the Consumer data for each test for e.g:

<dataset>
<CONSUMER CONSUMER_ID="1" FIRST_NAME="Elvis" LAST_NAME="Presley" PHONE="+972123456789" EMAIL="elvis@isep.com" CREATION_DATE="2017-08-29"/>
<CONSUMER CONSUMER_ID="2" FIRST_NAME="Bob" LAST_NAME="Dylan" PHONE="+972123456780" EMAIL="bob@isep.com" CREATION_DATE="2017-08-29"/>
<CONSUMER CONSUMER_ID="3" FIRST_NAME="Lady" LAST_NAME="Gaga" PHONE="+972123456781" EMAIL="gaga@isep.com" CREATION_DATE="2017-08-29"/>
</dataset>

or should I automate it? for e.g:

@Test
public void findByPhone(){
    ConsumerEntity consumerEntity = ConsumerUtil.createRandomConsumer();
    ConsumerEntity savedConsumerEntity = consumerRepository.save(consumerEntity);
    assertThat(consumerRepository.findByPhone(savedConsumerEntity.getPhone()).isEqualTo(savedConsumerEntity.getPhone());
}

While my createRandomConsumer generates random data.

Pros:
I think automating would be much more generic and handy as if ConsumerEntity might change or any code changes next - i will not have to change my .xml file and just be able to add things to the TestEntity function.
Cons:
Creating new objects and saving to in-memo DB might be more difficult if contains any constraints in the DB scheme.

Should I use DBUnit at all? if automating it - why should I use DBUnit? is it better just to use JUnit (Rolling back the data after each test and just adding the data I need for the test automatically as in the example above?)

If chose to use DBUnit for this - and manually added - what are the advantages of such thing? why is it better than using simple JUnit with Spring?

Thanks!


问:
Vaadin grid: binding to dynamic filter variable when using dom-repeat
I am using the vaadin data grid and the dom-repeat template, in order to create a grid with dynamic columns. I am also using a filter in the grid's footer.

I need placeholder text within that filter's input text field, so I have to set up the input tag. The part that is a problem is the value. In the Vaadin grid's documentation, this is a statically-named variable equal to the column name, prepended with _filter and then appended with the value of the text field (::input).

If I were to hard-code it as _inputHost::input it would bind to the dynamically-generated property for the "host" column, but only for this column. It also causes the sorting to break.

In the example below, I've used _filterXXXXXXX::input. What should I be using instead?

HTML:

```<code><template>
   <vaadin-grid id="grid" data-provider="[[dataProvider]]" size= "[[size]]">
      <template is="dom-repeat" items="[[columns]]" as="column">
        <vaadin-grid-column>
          <template class="header">[[column]]</template>
          <template>[[get(column, item)]]</template>
          <template class="footer">
            <vaadin-grid-filter aria-label="[[column]]" path="[[column]]" value="[[_filterColumn]]">
              <input placeholder="[[column]]" slot="filter" value="{{_filterXXXXXXX::input}}" focus-target>
            </vaadin-grid-filter>
          </template>
        </vaadin-grid-column>
      </template>
   </vaadin-grid>
</template>
</code>```

JS:

```<code>this.dataProvider = function(params, callback)
{
    var items = [];
    items.push ({ID:100, host:"foo.com", rank:5});
    items.push ({ID:101, host:"bar.com", rank:8});
    items.push ({ID:102, host:"meh.com", rank:15});
    this.size = items.length;
    callback(items);
}
this.columns = [];
this.columns.push ("ID", "host");
</code>```

答:
Firstly I never used vaadin-grid before sorry if I'm wrong.

I think _filterXXXXXXX can be any variable but if you use plain string, the variable will attach to host so you should use another variable instead. I think one of simplest way is use item variable (column in your case) such as item.filter.

So your code should be

```<code><vaadin-grid-filter aria-label="[[column]]" path="[[column]]" value="[[column.filter]]">
  <input placeholder="[[column]]" slot="filter" value="{{column.filter::input}}" focus-target>
</vaadin-grid-filter>
</code>```

Of course I didn't test it sorry for that.

Body:
I am using the vaadin data grid and the dom-repeat template, in order to create a grid with dynamic columns. I am also using a filter in the grid's footer.

I need placeholder text within that filter's input text field, so I have to set up the input tag. The part that is a problem is the value. In the Vaadin grid's documentation, this is a statically-named variable equal to the column name, prepended with _filter and then appended with the value of the text field (::input).

If I were to hard-code it as _inputHost::input it would bind to the dynamically-generated property for the "host" column, but only for this column. It also causes the sorting to break.

In the example below, I've used _filterXXXXXXX::input. What should I be using instead?

HTML:

<template>
   <vaadin-grid id="grid" data-provider="[[dataProvider]]" size= "[[size]]">
      <template is="dom-repeat" items="[[columns]]" as="column">
        <vaadin-grid-column>
          <template class="header">[[column]]</template>
          <template>[[get(column, item)]]</template>
          <template class="footer">
            <vaadin-grid-filter aria-label="[[column]]" path="[[column]]" value="[[_filterColumn]]">
              <input placeholder="[[column]]" slot="filter" value="{{_filterXXXXXXX::input}}" focus-target>
            </vaadin-grid-filter>
          </template>
        </vaadin-grid-column>
      </template>
   </vaadin-grid>
</template>

JS:

this.dataProvider = function(params, callback)
{
    var items = [];
    items.push ({ID:100, host:"foo.com", rank:5});
    items.push ({ID:101, host:"bar.com", rank:8});
    items.push ({ID:102, host:"meh.com", rank:15});
    this.size = items.length;
    callback(items);
}
this.columns = [];
this.columns.push ("ID", "host");

Body:
Firstly I never used vaadin-grid before sorry if I'm wrong.

I think _filterXXXXXXX can be any variable but if you use plain string, the variable will attach to host so you should use another variable instead. I think one of simplest way is use item variable (column in your case) such as item.filter.

So your code should be

<vaadin-grid-filter aria-label="[[column]]" path="[[column]]" value="[[column.filter]]">
  <input placeholder="[[column]]" slot="filter" value="{{column.filter::input}}" focus-target>
</vaadin-grid-filter>

Of course I didn't test it sorry for that.


问:
A potentially dangerous Request.Path value was detected from the client (?)
Environment:

IIS 8.5

.NET Framework Version: 4.6.2 (using WebForms)

Windows Server 2012 R2

Problem:

The following exception is being reported:

```<code>BASE EXCEPTION: System.Web.HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (?).
   at System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
   at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)

BASE EXCEPTION HRESUT: -2147467259

EXCEPTION: System.Web.HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (?).
   at System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
   at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)
</code>```

Other information shown in our logs:

```<code>PATH_INFO
/cities/index.aspx?locid=4163
----
QUERY_STRING
----
REMOTE_ADDR
66.249.65.204
----
REMOTE_HOST
66.249.65.204
----
REQUEST_METHOD
GET
----
SCRIPT_NAME
/cities/index.aspx?locid=4163
----
URL
/cities/index.aspx?locid=4163
----
HTTP_FROM
googlebot(at)googlebot.com
----
HTTP_USER_AGENT
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
</code>```

What I do not understand is if I cut and paste the path in my browser, the page is rendered just fine and without error.

Questions:

Why does googlebot, when crawling the page produce this error, yet no error is generated when I enter the path in a browser?  (I do find it odd that the error log shows no value for the query string, even though it is present).

Why is the "?" character considered potentially dangerous?

Any advice would be appreciated as I am trying to understand how this particular "error" is being raised when the path is in fact valid.

Thanks in advance.

答:
The same happens if you (or a pentester) access URL's ala https://domain.tld/<foobar and https://domain.tld/</.

Even with custom error pages enabled, this will return an error page rendered by IIS, and if you are logging errors in Application_Error you might find your logs full of noise from scanners/bots/etc.

I found that a rather simple workaround for this is to handle HttpException exceptions in Application_Error in Global.asax.cs. This way you don't need to tweak with requestValidationMode.

Create the following pages in the root of your application:

400.html - for IIS

400.aspx - for ASP.NET

404.html - for IIS

404.aspx - for ASP.NET

500.html - for IIS

500.aspx - for ASP.NET

The .html files have content ala this:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>400 Bad request</title>
</head>
<body>
    <h1>400 Bad request</h1>
</body>
</html>
</code>```

The .aspx files have content ala this:

```<code><%@ Page Language="C#" %>
<%
    Response.StatusCode = 400;
    Server.Transfer("~/400.html");
%>
</code>```

Ensure that you set the appropriate response status code within the .aspx files.

Configure ASP.NET's custom errors as below:

```<code><customErrors mode="RemoteOnly" redirectMode="ResponseRewrite" defaultRedirect="~/500.aspx">
  <error statusCode="400" redirect="~/400.aspx"/>
  <error statusCode="404" redirect="~/404.aspx"/>
  <error statusCode="500" redirect="~/500.aspx"/>
</customErrors>
</code>```

Configure IIS's custom errors as below:

```<code><httpErrors errorMode="DetailedLocalOnly">
 <remove statusCode="400"/>
 <error statusCode="400" path="400.html" responseMode="File"/>
 <remove statusCode="404"/>
 <error statusCode="404" path="404.html" responseMode="File"/>
 <remove statusCode="500"/>
 <error statusCode="500" path="500.html" responseMode="File"/>
</httpErrors>
</code>```

Adjust Global.asax.cs accordingly:

```<code>protected void Application_Error(object sender, EventArgs e)
{
    var lastError = Server.GetLastError();
    Server.ClearError();

    if (lastError.GetType() == typeof(HttpException))
    {
        Response.StatusCode = 400;
        Server.Transfer("400.html");
    }
    else
    {
        Response.StatusCode = 500;
        Server.Transfer("500.html");

        // logging
    }
}
</code>```

See http://benfoster.io/blog/aspnet-mvc-custom-error-pages for the full story on how to setup custom error pages and https://msdn.microsoft.com/en-us/library/bb397417.aspx for more on error handlers.

Body:
Environment:

IIS 8.5

.NET Framework Version: 4.6.2 (using WebForms)

Windows Server 2012 R2

Problem:

The following exception is being reported:

BASE EXCEPTION: System.Web.HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (?).
   at System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
   at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)

BASE EXCEPTION HRESUT: -2147467259

EXCEPTION: System.Web.HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (?).
   at System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
   at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)

Other information shown in our logs:

PATH_INFO
/cities/index.aspx?locid=4163
----
QUERY_STRING
----
REMOTE_ADDR
66.249.65.204
----
REMOTE_HOST
66.249.65.204
----
REQUEST_METHOD
GET
----
SCRIPT_NAME
/cities/index.aspx?locid=4163
----
URL
/cities/index.aspx?locid=4163
----
HTTP_FROM
googlebot(at)googlebot.com
----
HTTP_USER_AGENT
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

What I do not understand is if I cut and paste the path in my browser, the page is rendered just fine and without error.

Questions:

Why does googlebot, when crawling the page produce this error, yet no error is generated when I enter the path in a browser?  (I do find it odd that the error log shows no value for the query string, even though it is present).

Why is the "?" character considered potentially dangerous?

Any advice would be appreciated as I am trying to understand how this particular "error" is being raised when the path is in fact valid.

Thanks in advance.

Body:
The same happens if you (or a pentester) access URL's ala https://domain.tld/<foobar and https://domain.tld/</.

Even with custom error pages enabled, this will return an error page rendered by IIS, and if you are logging errors in Application_Error you might find your logs full of noise from scanners/bots/etc.

I found that a rather simple workaround for this is to handle HttpException exceptions in Application_Error in Global.asax.cs. This way you don't need to tweak with requestValidationMode.

Create the following pages in the root of your application:

400.html - for IIS

400.aspx - for ASP.NET

404.html - for IIS

404.aspx - for ASP.NET

500.html - for IIS

500.aspx - for ASP.NET

The .html files have content ala this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>400 Bad request</title>
</head>
<body>
    <h1>400 Bad request</h1>
</body>
</html>

The .aspx files have content ala this:

<%@ Page Language="C#" %>
<%
    Response.StatusCode = 400;
    Server.Transfer("~/400.html");
%>

Ensure that you set the appropriate response status code within the .aspx files.

Configure ASP.NET's custom errors as below:

<customErrors mode="RemoteOnly" redirectMode="ResponseRewrite" defaultRedirect="~/500.aspx">
  <error statusCode="400" redirect="~/400.aspx"/>
  <error statusCode="404" redirect="~/404.aspx"/>
  <error statusCode="500" redirect="~/500.aspx"/>
</customErrors>

Configure IIS's custom errors as below:

<httpErrors errorMode="DetailedLocalOnly">
 <remove statusCode="400"/>
 <error statusCode="400" path="400.html" responseMode="File"/>
 <remove statusCode="404"/>
 <error statusCode="404" path="404.html" responseMode="File"/>
 <remove statusCode="500"/>
 <error statusCode="500" path="500.html" responseMode="File"/>
</httpErrors>

Adjust Global.asax.cs accordingly:

protected void Application_Error(object sender, EventArgs e)
{
    var lastError = Server.GetLastError();
    Server.ClearError();

    if (lastError.GetType() == typeof(HttpException))
    {
        Response.StatusCode = 400;
        Server.Transfer("400.html");
    }
    else
    {
        Response.StatusCode = 500;
        Server.Transfer("500.html");

        // logging
    }
}

See http://benfoster.io/blog/aspnet-mvc-custom-error-pages for the full story on how to setup custom error pages and https://msdn.microsoft.com/en-us/library/bb397417.aspx for more on error handlers.


问:
Merge multiple variables in R
I have a dataset such that the same variable is contained in difference columns for each subject. I want to merge them to the same columns.

E.g.:, I have this dataframe, and there are three DVs, but they are in different columns (A,B,C) for different subjects.

```<code>data.frame(ID = c(1,2,3), DV1_A=c(1,NA,NA), DV1_B= c(NA,4,NA), DV1_C = c(NA,NA,5), DV2_A=c(3,NA,NA), DV2_B=c(NA,3,NA), DV2_C=c(NA,NA,5), FACT = c("A","B","C"))
</code>```

How can I merge them to just two columns? so the result is:

```<code>data.frame(ID = c(1,2,3), DV1_A=c(1,NA,NA), DV1_B= c(NA,4,NA), DV1_C = c(NA,NA,5), DV2_A=c(3,NA,NA), DV2_B=c(NA,3,NA), DV2_C=c(NA,NA,5), FACT = c("A","B","C"), DV_1 = c(1,4,5), DV_2 = c(3,3,5))
</code>```

答:
You can use coalesce from dplyr:

```<code>library(dplyr)

df %>%
  mutate(DV_1 = coalesce(DV1_A, DV1_B, DV1_C),
         DV_2 = coalesce(DV2_A, DV2_B, DV2_C))
</code>```

If you have a lot of DV columns to combine, you might not want to type all the column names. In this case, you can first grep the column names for each DV, parse each name to symbols with rlang::syms, then splice (!!!) the symbols in coalesce (Advice from @hadley):

```<code>library(rlang)
var_quo1 = syms(grep("DV1", names(df), value = TRUE))
var_quo2 = syms(grep("DV2", names(df), value = TRUE))

df %>%
  mutate(DV_1 = coalesce(!!! var_quo1),
         DV_2 = coalesce(!!! var_quo2))
</code>```

If instead, you have a ton of DV's, you might not even want to type all the coalesce lines, in this case, you can create a function that outputs one DV column given an input number and lapply + bind_col all of them together:

```<code>DV_combine = function(num_DVs){

  DV_name = sym(paste0("DV", num_DVs))
  DV_syms = syms(grep(paste0("DV", num_DVs), names(df), value = TRUE))

  df %>%
    transmute(!!DV_name := coalesce(!!! DV_syms))
}

bind_cols(df, lapply(1:2, DV_combine))
</code>```

Result:

```<code>  ID DV1_A DV1_B DV1_C DV2_A DV2_B DV2_C FACT DV_1 DV_2
1  1     1    NA    NA     3    NA    NA    A    1    3
2  2    NA     4    NA    NA     3    NA    B    4    3
3  3    NA    NA     5    NA    NA     5    C    5    5
</code>```

Note:

This method will work for both numeric and character class columns, but not factor's. One should first convert the factor columns to character before using this method.

Data:

```<code>df = structure(list(ID = c(1, 2, 3), DV1_A = c(1, NA, NA), DV1_B = c(NA,
4, NA), DV1_C = c(NA, NA, 5), DV2_A = c(3, NA, NA), DV2_B = c(NA,
3, NA), DV2_C = c(NA, NA, 5), FACT = structure(1:3, .Label = c("A",
"B", "C"), class = "factor")), .Names = c("ID", "DV1_A", "DV1_B",
"DV1_C", "DV2_A", "DV2_B", "DV2_C", "FACT"), row.names = c(NA,
-3L), class = "data.frame")
</code>```

Title: Merge multiple variables in R

Body:
I have a dataset such that the same variable is contained in difference columns for each subject. I want to merge them to the same columns.

E.g.:, I have this dataframe, and there are three DVs, but they are in different columns (A,B,C) for different subjects.

data.frame(ID = c(1,2,3), DV1_A=c(1,NA,NA), DV1_B= c(NA,4,NA), DV1_C = c(NA,NA,5), DV2_A=c(3,NA,NA), DV2_B=c(NA,3,NA), DV2_C=c(NA,NA,5), FACT = c("A","B","C"))

How can I merge them to just two columns? so the result is:

data.frame(ID = c(1,2,3), DV1_A=c(1,NA,NA), DV1_B= c(NA,4,NA), DV1_C = c(NA,NA,5), DV2_A=c(3,NA,NA), DV2_B=c(NA,3,NA), DV2_C=c(NA,NA,5), FACT = c("A","B","C"), DV_1 = c(1,4,5), DV_2 = c(3,3,5))

Body:
You can use coalesce from dplyr:

library(dplyr)

df %>%
  mutate(DV_1 = coalesce(DV1_A, DV1_B, DV1_C),
         DV_2 = coalesce(DV2_A, DV2_B, DV2_C))

If you have a lot of DV columns to combine, you might not want to type all the column names. In this case, you can first grep the column names for each DV, parse each name to symbols with rlang::syms, then splice (!!!) the symbols in coalesce (Advice from @hadley):

library(rlang)
var_quo1 = syms(grep("DV1", names(df), value = TRUE))
var_quo2 = syms(grep("DV2", names(df), value = TRUE))

df %>%
  mutate(DV_1 = coalesce(!!! var_quo1),
         DV_2 = coalesce(!!! var_quo2))

If instead, you have a ton of DV's, you might not even want to type all the coalesce lines, in this case, you can create a function that outputs one DV column given an input number and lapply + bind_col all of them together:

DV_combine = function(num_DVs){

  DV_name = sym(paste0("DV", num_DVs))
  DV_syms = syms(grep(paste0("DV", num_DVs), names(df), value = TRUE))

  df %>%
    transmute(!!DV_name := coalesce(!!! DV_syms))
}

bind_cols(df, lapply(1:2, DV_combine))

Result:

  ID DV1_A DV1_B DV1_C DV2_A DV2_B DV2_C FACT DV_1 DV_2
1  1     1    NA    NA     3    NA    NA    A    1    3
2  2    NA     4    NA    NA     3    NA    B    4    3
3  3    NA    NA     5    NA    NA     5    C    5    5

Note:

This method will work for both numeric and character class columns, but not factor's. One should first convert the factor columns to character before using this method.

Data:

df = structure(list(ID = c(1, 2, 3), DV1_A = c(1, NA, NA), DV1_B = c(NA,
4, NA), DV1_C = c(NA, NA, 5), DV2_A = c(3, NA, NA), DV2_B = c(NA,
3, NA), DV2_C = c(NA, NA, 5), FACT = structure(1:3, .Label = c("A",
"B", "C"), class = "factor")), .Names = c("ID", "DV1_A", "DV1_B",
"DV1_C", "DV2_A", "DV2_B", "DV2_C", "FACT"), row.names = c(NA,
-3L), class = "data.frame")


问:
PROC SQL with merge with two where statement and in a single dataset
```<code>data a;
set b1(where=(PARAMCD='ABC') rename=(aval=abc) in=a) b1(where=(PARAMCD='CDE') rename=(aval=cde));
by usubjid  AVISITN;
if a;
PARAMCD="ASD";

AVAL=mean(abc,cde);
run;
</code>```

I have a single dataset in SAS where several paramcd i need to filter two paramcd and avg of those value. I need to create a proc sql syntax to have merge issue to be solved.

答:
Looks like you just want to join a table with itself.  Try something like this.

```<code>proc sql ;
create table a as
  select a.usubjid
       , a.avisitn
       , a.aval as abc
       , b.aval as cde
       , mean(a.aval,b.aval) as aval
  from b1 a
  left join b1 b
  on a.usubjid = b.usubjid
  and a.avisitn = b.avisitn
  and a.paramcd='ABC'
  and b.paramcd='CDE'
;
quit;
</code>```

Or you could use sub-queries to replicate the where= dataset option.

```<code>create table a as
  select a.usubjid
       , a.avisitn
       , a.aval as abc
       , b.aval as cde
       , mean(a.aval,b.aval) as aval
  from (select * from b1 where paramcd='ABC') a
  left join (select * from b1 where paramcd='CDE') b
  on a.usubjid = b.usubjid
  and a.avisitn = b.avisitn
;
</code>```

Body:
data a;
set b1(where=(PARAMCD='ABC') rename=(aval=abc) in=a) b1(where=(PARAMCD='CDE') rename=(aval=cde));
by usubjid  AVISITN;
if a;
PARAMCD="ASD";

AVAL=mean(abc,cde);
run;

I have a single dataset in SAS where several paramcd i need to filter two paramcd and avg of those value. I need to create a proc sql syntax to have merge issue to be solved.

Body:
Looks like you just want to join a table with itself.  Try something like this.

proc sql ;
create table a as
  select a.usubjid
       , a.avisitn
       , a.aval as abc
       , b.aval as cde
       , mean(a.aval,b.aval) as aval
  from b1 a
  left join b1 b
  on a.usubjid = b.usubjid
  and a.avisitn = b.avisitn
  and a.paramcd='ABC'
  and b.paramcd='CDE'
;
quit;

Or you could use sub-queries to replicate the where= dataset option.

create table a as
  select a.usubjid
       , a.avisitn
       , a.aval as abc
       , b.aval as cde
       , mean(a.aval,b.aval) as aval
  from (select * from b1 where paramcd='ABC') a
  left join (select * from b1 where paramcd='CDE') b
  on a.usubjid = b.usubjid
  and a.avisitn = b.avisitn
;


问:
Sort a numpy array of numpy arrays by lengths of the internal arrays
If I have a numpy array with each element being another numpy array of varying lengths (not an ndarray because of this), how can I sort the outer array by descending lengths of the inner array?

For example:

```<code>a = np.array([np.array([1]), np.array([1, 2, 3]), np.array([1, 2])])
</code>```

would be sorted as:

```<code>[[1, 2, 3], [1, 2], [1]]
</code>```

答:
For array of arrays as output -

```<code>a[np.argsort([len(i) for i in a])[::-1]]
</code>```

Sample run -

```<code>In [329]: a
Out[329]: array([array([1]), array([1, 2, 3]), array([1, 2])], dtype=object)

In [330]: a[np.argsort([len(i) for i in a])[::-1]]
Out[330]: array([array([1, 2, 3]), array([1, 2]), array([1])], dtype=object)

# If you need a list of lists as output
In [341]: [i.tolist() for i in _]
Out[341]: [[1, 2, 3], [1, 2], [1]]
</code>```

Body:
If I have a numpy array with each element being another numpy array of varying lengths (not an ndarray because of this), how can I sort the outer array by descending lengths of the inner array?

For example:

a = np.array([np.array([1]), np.array([1, 2, 3]), np.array([1, 2])])

would be sorted as:

[[1, 2, 3], [1, 2], [1]]

Body:
For array of arrays as output -

a[np.argsort([len(i) for i in a])[::-1]]

Sample run -

In [329]: a
Out[329]: array([array([1]), array([1, 2, 3]), array([1, 2])], dtype=object)

In [330]: a[np.argsort([len(i) for i in a])[::-1]]
Out[330]: array([array([1, 2, 3]), array([1, 2]), array([1])], dtype=object)

# If you need a list of lists as output
In [341]: [i.tolist() for i in _]
Out[341]: [[1, 2, 3], [1, 2], [1]]


问:
How to resolve composer package circular dependency of external package?
See Github issue, where this question originated.

My package is phpdocumentor/reflection-docblock, it's not a dependency.

I'm trying to update phpdocumentor/reflection-docblock to newer phpunit/phpunit dependency, that started to use the package I update.

There is new circular dependency:

(this) phpdocumentor/reflection-docblock package requires phpunit/phpunit

phpunit/phpunit requires phpspec/prophecy (since phpunit/phpunit 4.5)

phpspec/prophecy requires this phpdocumentor/reflection-docblock (this) package

In abstraction:

A needs B

B needs C (new one!)

C needs A

Before - works

```<code>{
    "require-dev": {
        "phpunit/phpunit": "4.4"
    }
}
</code>```

After - broken

```<code>{
    "require-dev": {
        "phpunit/phpunit": "4.5"
    }
}
</code>```

When I run:

```<code>composer update
</code>```

Composer conflict output:

```<code>Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phpdocumentor/reflection-docblock dev-phpunit -> satisfiable by phpdocumentor/reflection-docblock[dev-phpunit].
    - phpspec/prophecy v1.3.1 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5].
    - phpunit/phpunit 4.5.0 requires phpspec/prophecy ~1.3.1 -> satisfiable by phpspec/prophecy[v1.3.1].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.0, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.1, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.2, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.3, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.4, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.5, dev-phpunit].
    - Installation request for phpunit/phpunit 4.5 -> satisfiable by phpunit/phpunit[4.5.0].
</code>```

I've tried:

minimum-stability: dev

aliases "phpunit/phpunit": "4.5 as 4.4"

Any ideas how to approach this?

答:
Add

```<code>"extra": {
    "branch-alias": {
        "dev-master": "4.x-dev"
    }
}
</code>```

to composer.json of phpdocumentor/reflection-docblock.

This will allow you to use current master as version 4.x which satisfies requirements

Downside is. You will have to update this section when moving on with versions.

Body:
See Github issue, where this question originated.

My package is phpdocumentor/reflection-docblock, it's not a dependency.

I'm trying to update phpdocumentor/reflection-docblock to newer phpunit/phpunit dependency, that started to use the package I update.

There is new circular dependency:

(this) phpdocumentor/reflection-docblock package requires phpunit/phpunit

phpunit/phpunit requires phpspec/prophecy (since phpunit/phpunit 4.5)

phpspec/prophecy requires this phpdocumentor/reflection-docblock (this) package

In abstraction:

A needs B

B needs C (new one!)

C needs A

Before - works

{
    "require-dev": {
        "phpunit/phpunit": "4.4"
    }
}

After - broken

{
    "require-dev": {
        "phpunit/phpunit": "4.5"
    }
}

When I run:

composer update

Composer conflict output:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phpdocumentor/reflection-docblock dev-phpunit -> satisfiable by phpdocumentor/reflection-docblock[dev-phpunit].
    - phpspec/prophecy v1.3.1 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5].
    - phpunit/phpunit 4.5.0 requires phpspec/prophecy ~1.3.1 -> satisfiable by phpspec/prophecy[v1.3.1].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.0, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.1, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.2, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.3, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.4, dev-phpunit].
    - Can only install one of: phpdocumentor/reflection-docblock[2.0.5, dev-phpunit].
    - Installation request for phpunit/phpunit 4.5 -> satisfiable by phpunit/phpunit[4.5.0].

I've tried:

minimum-stability: dev

aliases "phpunit/phpunit": "4.5 as 4.4"

Any ideas how to approach this?

Body:
Add

"extra": {
    "branch-alias": {
        "dev-master": "4.x-dev"
    }
}

to composer.json of phpdocumentor/reflection-docblock.

This will allow you to use current master as version 4.x which satisfies requirements

Downside is. You will have to update this section when moving on with versions.


问:
Installation error with RDCOMClient in RSTUDIO
I´m trying to install the RDCOMClient package in rstudio in order to use the R2PPT package to create power point presentations.

I search and the instruction to install RDCOMClient package is:

install.packages("RDCOMClient", repos = "http://www.omegahat.org/R")

The problem is that the reposotory webpage is not available anymore.

does anyone know how to install the RDCOMClient or use R2PPT without RDCOMClient package?

答:
I also could install it from CRAN with R 3.4 but with a computer stuck with R 3.3.1 I had error:

```<code>package ‘RDCOMClient’ is not available (for R version 3.3.1)
</code>```

It's undocumented on CRAN so I tried OmegaHat and got

```<code>package ‘RDCOMClient’ was built before R 3.0.0: please re-install it
</code>```

Then I followed @g-grothendieck 's link in this post this post's comments and found a version I could install manually :

http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.3/

You can find every version there.

Body:
I also could install it from CRAN with R 3.4 but with a computer stuck with R 3.3.1 I had error:

package ‘RDCOMClient’ is not available (for R version 3.3.1)

It's undocumented on CRAN so I tried OmegaHat and got

package ‘RDCOMClient’ was built before R 3.0.0: please re-install it

Then I followed @g-grothendieck 's link in this post this post's comments and found a version I could install manually :

http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.3/

You can find every version there.