问:
Is there any way to lint a Python file to check for Numpy documentation style adherence?
I'm working on a project that requires Numpy documentation. In my Java days, I remember having linters that checked for Javadoc adherence in Eclipse/IDEA; is there an equivalent that checks for Numpy documentation style adherence?

I know about PEP257, but it doesn't seem to have any specific checks for Numpy documentation.

答:
Pylint seems to support that. Take a look at pylint.extensions.docparams.

To sum it up. You activate this checker of pylint by adding

```<code>load-plugins=pylint.extensions.docparams
</code>```

in the Master section of your .pylintrc.

This checker verifies that all function, method, and constructor
  docstrings include documentation of the

parameters and their types

return value and its type

exceptions raised

Actually pydocstyle (formerly pep257) recently added support for the numpy docstring convention. Although, it's not perfect I think it's the closest to what you want to achieve and it will probably improve in the near future.

```<code>pydocstyle --convention=numpy example.py
</code>```

Body:
Pylint seems to support that. Take a look at pylint.extensions.docparams.

To sum it up. You activate this checker of pylint by adding

load-plugins=pylint.extensions.docparams

in the Master section of your .pylintrc.

This checker verifies that all function, method, and constructor
  docstrings include documentation of the

parameters and their types

return value and its type

exceptions raised

Actually pydocstyle (formerly pep257) recently added support for the numpy docstring convention. Although, it's not perfect I think it's the closest to what you want to achieve and it will probably improve in the near future.

pydocstyle --convention=numpy example.py


来源: stackexchange

问:
Iterator referencing to nothing on 8th element PLF::Colony
I am having an interesting issue. For starters, I am currently developing a 2D geometry editor where the user is able to draw lines and arcs. In order to draw a line and arc, the user needs to select 2 nodes.

In an earlier question on the forum, I was wondering if there was anything available that will not invalidate pointers when elements are erased (or inserted) but is not an std::list (for various reasons that are scattered throughout stack overflow). A user recommended that I take a look at the plf::colony class. Which, in short, acts like std::list but has the speed of std::deque in many instances.

Anyways, I am implementing this class in my program to contain the nodes, lines, and arcs. I was able to successfully integrate the class and everything builds. However, I notice that there is a bug in my bug when I go to delete nodes.

I have narrowed down the issue to be this: If I create less then 10 nodes, my code is able to delete all of the nodes without an issue. However, if I select all of the 10 nodes, my program crashes. If I draw 20 nodes and select 10 of them for deletion, my program crashes. If I draw 15 nodes and select 5 of them, everything is good. If I draw 15 nodes and select 7 of them, everything is fine. If I draw 15 nodes and select 8, the program crashes. If I draw 50 nodes and select 8 for deletion, the program crashes. There is something about the 8th node that appears to crash the program.

Later, I stepped through the code (that I have posted below) and everything is fine until the iterator reaches the 8th item. There, the iterator points to nothing and crashes the program. The program crashes when it tries to erase the iterator from the colony.

I was wondering if anyone else using plf::colony ran into the same issue and what they did to fix the bug? Or is there something wrong with the way that I am setting up my code?

```<code>    for(int i = 1; i < 21; i++)
{
    _editor.addNode(0.25 * i, 0);
    _editor.getNodeList()->back()->setSelectState(true);
}

if(_editor.getNodeList()->size() > 0)
{
    plf::colony<node>::iterator stopIterator = _editor.getNodeList()->end();
    for(plf::colony<node>::iterator nodeIterator = _editor.getNodeList()->begin(); nodeIterator != _editor.getNodeList()->end(); ++nodeIterator)
    {
        if(nodeIterator->getIsSelectedState())
        {

            if(_editor.getNodeList()->size() <= 1 && _editor.getNodeList()->begin()->getIsSelectedState())
            {
                if(_editor.getNodeList()->size() == 1)
                    _editor.getNodeList()->clear();
                break;
            }

           _editor.getNodeList()->erase(nodeIterator);
        }
    }
}
</code>```

Edit:

Ok so this fix of from the code is unable to crash the program:

```<code>plf::colony<node>::iterator stopIterator = _editor.getNodeList()->end();
    for(plf::colony<node>::iterator nodeIterator = _editor.getNodeList()->begin(); nodeIterator != _editor.getNodeList()->end();)
    {
        if(nodeIterator->getIsSelectedState())
        {
            if(_editor.getLineList()->size() > 1)
            {
                /* Need to cycle through the entire line list and arc list in order to determine which arc/line the node is associated with and delete that arc/line by selecting i.
                 * The deletion of the arc/line occurs later in the code*/

                for(plf::colony<edgeLineShape>::iterator lineIterator = _editor.getLineList()->begin(); lineIterator != _editor.getLineList()->end(); ++lineIterator)
                {
                    if(*lineIterator->getFirstNode() == *nodeIterator || *lineIterator->getSecondNode() == *nodeIterator)
                    {
                        lineIterator->setSelectState(true);
                    }
                }
            }

            if(_editor.getArcList()->size() > 0)
            {
                for(plf::colony<arcShape>::iterator arcIterator = _editor.getArcList()->begin(); arcIterator != _editor.getArcList()->end(); ++arcIterator)
                {
                    if(*arcIterator->getFirstNode() == *nodeIterator || *arcIterator->getSecondNode() == *nodeIterator)
                    {
                        arcIterator->setSelectState(true);
                    }
                }
            }
           _editor.getNodeList()->erase(nodeIterator++);
        }
        else
            nodeIterator++;
    }
</code>```

答:
I'm not familiar with plf::colony, but the documentation states that elements are not invalidated with erase, with the exception of the erased element. You erase your nodeIterator and later you ++nodeIterator it.

My suggestion is trying to rewrite your loop so you can call the erase function with nodeIterator++.

ContentLicense: CC BY-SA 3.0

Body:
I am having an interesting issue. For starters, I am currently developing a 2D geometry editor where the user is able to draw lines and arcs. In order to draw a line and arc, the user needs to select 2 nodes.

In an earlier question on the forum, I was wondering if there was anything available that will not invalidate pointers when elements are erased (or inserted) but is not an std::list (for various reasons that are scattered throughout stack overflow). A user recommended that I take a look at the plf::colony class. Which, in short, acts like std::list but has the speed of std::deque in many instances.

Anyways, I am implementing this class in my program to contain the nodes, lines, and arcs. I was able to successfully integrate the class and everything builds. However, I notice that there is a bug in my bug when I go to delete nodes.

I have narrowed down the issue to be this: If I create less then 10 nodes, my code is able to delete all of the nodes without an issue. However, if I select all of the 10 nodes, my program crashes. If I draw 20 nodes and select 10 of them for deletion, my program crashes. If I draw 15 nodes and select 5 of them, everything is good. If I draw 15 nodes and select 7 of them, everything is fine. If I draw 15 nodes and select 8, the program crashes. If I draw 50 nodes and select 8 for deletion, the program crashes. There is something about the 8th node that appears to crash the program.

Later, I stepped through the code (that I have posted below) and everything is fine until the iterator reaches the 8th item. There, the iterator points to nothing and crashes the program. The program crashes when it tries to erase the iterator from the colony.

I was wondering if anyone else using plf::colony ran into the same issue and what they did to fix the bug? Or is there something wrong with the way that I am setting up my code?

    for(int i = 1; i < 21; i++)
{
    _editor.addNode(0.25 * i, 0);
    _editor.getNodeList()->back()->setSelectState(true);
}

if(_editor.getNodeList()->size() > 0)
{
    plf::colony<node>::iterator stopIterator = _editor.getNodeList()->end();
    for(plf::colony<node>::iterator nodeIterator = _editor.getNodeList()->begin(); nodeIterator != _editor.getNodeList()->end(); ++nodeIterator)
    {
        if(nodeIterator->getIsSelectedState())
        {

            if(_editor.getNodeList()->size() <= 1 && _editor.getNodeList()->begin()->getIsSelectedState())
            {
                if(_editor.getNodeList()->size() == 1)
                    _editor.getNodeList()->clear();
                break;
            }

           _editor.getNodeList()->erase(nodeIterator);
        }
    }
}

Edit:

Ok so this fix of from the code is unable to crash the program:

plf::colony<node>::iterator stopIterator = _editor.getNodeList()->end();
    for(plf::colony<node>::iterator nodeIterator = _editor.getNodeList()->begin(); nodeIterator != _editor.getNodeList()->end();)
    {
        if(nodeIterator->getIsSelectedState())
        {
            if(_editor.getLineList()->size() > 1)
            {
                /* Need to cycle through the entire line list and arc list in order to determine which arc/line the node is associated with and delete that arc/line by selecting i.
                 * The deletion of the arc/line occurs later in the code*/

                for(plf::colony<edgeLineShape>::iterator lineIterator = _editor.getLineList()->begin(); lineIterator != _editor.getLineList()->end(); ++lineIterator)
                {
                    if(*lineIterator->getFirstNode() == *nodeIterator || *lineIterator->getSecondNode() == *nodeIterator)
                    {
                        lineIterator->setSelectState(true);
                    }
                }
            }

            if(_editor.getArcList()->size() > 0)
            {
                for(plf::colony<arcShape>::iterator arcIterator = _editor.getArcList()->begin(); arcIterator != _editor.getArcList()->end(); ++arcIterator)
                {
                    if(*arcIterator->getFirstNode() == *nodeIterator || *arcIterator->getSecondNode() == *nodeIterator)
                    {
                        arcIterator->setSelectState(true);
                    }
                }
            }
           _editor.getNodeList()->erase(nodeIterator++);
        }
        else
            nodeIterator++;
    }


问:
What does the jsr keyword mean?
I'm looking at some Java code, and I've noticed the following:

```<code>if (!foo(bar, baz, qux)) {
    i = 0; jsr 433;
}
</code>```

javac chokes on it, saying it's not a statement and that a semicolon is expected after the keyword jsr.

I did some Googling, and I found some code containing the same thing, which leads me to believe it's there intentionally (even though they weren't able to get it to compile either). So what does jsr do? How does one get code containing it to compile?

答:
JSR stands for Java Specification Request.

There's probably a typo in that code and it should have been

```<code>if (!foo(bar, baz, qux)) {
    i = 0; //jsr 433;
}
</code>```

It seems to me that somebody did a non working checkin for some reason.

But, looking at that code, it looks awfully artificial, so it's probably decompiled code, as Andreas_D already stated.

Mini update: check the bottom comment:

```<code>/* Location:           C:\Users\Matteo\Downloads\FreeDownApplet.signed.jar
 * Qualified Name:     FreeDownApplet
 * JD-Core Version:    0.5.4
 */
</code>```

From this, I'd say somebody made a signed jar file that was obfuscated, and whoever posted that code decompiled it.

Update 2: Googling "JD core" yields http://java.decompiler.free.fr/ as the first result.

ContentLicense: CC BY-SA 2.5

Title: What does the jsr keyword mean?

Body:
I'm looking at some Java code, and I've noticed the following:

if (!foo(bar, baz, qux)) {
    i = 0; jsr 433;
}

javac chokes on it, saying it's not a statement and that a semicolon is expected after the keyword jsr.

I did some Googling, and I found some code containing the same thing, which leads me to believe it's there intentionally (even though they weren't able to get it to compile either). So what does jsr do? How does one get code containing it to compile?

Body:
JSR stands for Java Specification Request.

There's probably a typo in that code and it should have been

if (!foo(bar, baz, qux)) {
    i = 0; //jsr 433;
}

It seems to me that somebody did a non working checkin for some reason.

But, looking at that code, it looks awfully artificial, so it's probably decompiled code, as Andreas_D already stated.

Mini update: check the bottom comment:

/* Location:           C:\Users\Matteo\Downloads\FreeDownApplet.signed.jar
 * Qualified Name:     FreeDownApplet
 * JD-Core Version:    0.5.4
 */

From this, I'd say somebody made a signed jar file that was obfuscated, and whoever posted that code decompiled it.

Update 2: Googling "JD core" yields http://java.decompiler.free.fr/ as the first result.


问:
Write a Regex to find all words in a string which are enclosed by brackets
I want to match all the words in a string which have pattern like {{word}}

For Example:

This {{is}} a test {{String}}.
Should match {{is}} and {{String}}

I was using /{{(.*?)}}/g which gives correct result for above case but fails when I have string something like

This {{is{{is}}}} a test String

Output Should be: {{is{{is}}}} but it is returning {{is{{is}}

答:
One possible way is this.</p>

```<code>{{[\w{}]+}}
</code>```

Body:
One possible way is this.

{{[\w{}]+}}


问:
installing google-cloud using pip fails
Im trying to install the google-cloud python package, and I encounter the foloowing meesage whenn the installation fails:

```<code> pip install --upgrade google-cloud
    Collecting google-cloud
      Using cached google_cloud-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-dns<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_dns-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-monitoring<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_monitoring-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-error-reporting<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_error_reporting-0.23.2-py2.py3-none-any.whl
    Collecting google-cloud-bigquery<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_bigquery-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-bigtable<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_bigtable-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-runtimeconfig<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_runtimeconfig-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-pubsub<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_pubsub-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-datastore<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_datastore-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-core<0.24dev,>=0.23.1 (from google-cloud)
      Using cached google_cloud_core-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-resource-manager<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_resource_manager-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-vision<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_vision-0.23.3-py2.py3-none-any.whl
    Collecting google-cloud-translate<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_translate-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-logging<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_logging-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-language<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_language-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-speech<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_speech-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-spanner<0.24dev,>=0.23.1 (from google-cloud)
      Using cached google_cloud_spanner-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-storage<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_storage-0.23.1-py2.py3-none-any.whl
    Collecting gapic-google-cloud-error-reporting-v1beta1<0.16dev,>=0.15.0 (from google-cloud-error-reporting<0.24dev,>=0.23.0->google-cloud)
      Using cached gapic-google-cloud-error-reporting-v1beta1-0.15.3.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "<frozen importlib._bootstrap>", line 969, in _find_and_load
          File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
          File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\setuptools\__init__.py", line 11, in <module>
          File "<frozen importlib._bootstrap>", line 969, in _find_and_load
          File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
          File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\setuptools\extern\__init__.py", line 1, in <module>
          File "<frozen importlib._bootstrap>", line 969, in _find_and_load
          File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
          File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2927, in <module>
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2913, in _call_aside
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2952, in _initialize_master_working_set
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 956, in subscribe
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2952, in <lambda>
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2515, in activate
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2097, in declare_namespace
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2047, in _handle_ns
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2066, in _rebuild_mod_path
        AttributeError: '_NamespacePath' object has no attribute 'sort'

        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in C:\Users\OFIRAR~1\AppData\Local\Temp\pip-build-j5a_32a2\gapic-google-cloud-error-reporting-v1beta1\
</code>```

what could cause this? I installed other packages without problems.

答:
Since I cannot comment, I will answer it here.

I had this issue once. I fixed it by doing the following:

pip install --upgrade pip
pip install --upgrade setuptools

Some discussions relate this to an issue with Python 3*, and others with the version of pip.

If upgrading pip and setuptools does not work for you, try using Python 2.7*.

I have tested on my machine using Python 2.7.13 with pip v9.0.1.

Though this is a known issue, it has been discussed here and here

Title: installing google-cloud using pip fails

Body:
Im trying to install the google-cloud python package, and I encounter the foloowing meesage whenn the installation fails:

 pip install --upgrade google-cloud
    Collecting google-cloud
      Using cached google_cloud-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-dns<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_dns-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-monitoring<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_monitoring-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-error-reporting<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_error_reporting-0.23.2-py2.py3-none-any.whl
    Collecting google-cloud-bigquery<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_bigquery-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-bigtable<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_bigtable-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-runtimeconfig<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_runtimeconfig-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-pubsub<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_pubsub-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-datastore<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_datastore-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-core<0.24dev,>=0.23.1 (from google-cloud)
      Using cached google_cloud_core-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-resource-manager<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_resource_manager-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-vision<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_vision-0.23.3-py2.py3-none-any.whl
    Collecting google-cloud-translate<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_translate-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-logging<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_logging-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-language<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_language-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-speech<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_speech-0.23.0-py2.py3-none-any.whl
    Collecting google-cloud-spanner<0.24dev,>=0.23.1 (from google-cloud)
      Using cached google_cloud_spanner-0.23.1-py2.py3-none-any.whl
    Collecting google-cloud-storage<0.24dev,>=0.23.0 (from google-cloud)
      Using cached google_cloud_storage-0.23.1-py2.py3-none-any.whl
    Collecting gapic-google-cloud-error-reporting-v1beta1<0.16dev,>=0.15.0 (from google-cloud-error-reporting<0.24dev,>=0.23.0->google-cloud)
      Using cached gapic-google-cloud-error-reporting-v1beta1-0.15.3.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "<frozen importlib._bootstrap>", line 969, in _find_and_load
          File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
          File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\setuptools\__init__.py", line 11, in <module>
          File "<frozen importlib._bootstrap>", line 969, in _find_and_load
          File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
          File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\setuptools\extern\__init__.py", line 1, in <module>
          File "<frozen importlib._bootstrap>", line 969, in _find_and_load
          File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
          File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2927, in <module>
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2913, in _call_aside
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2952, in _initialize_master_working_set
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 956, in subscribe
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2952, in <lambda>
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2515, in activate
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2097, in declare_namespace
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2047, in _handle_ns
          File "c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg\pkg_resources\__init__.py", line 2066, in _rebuild_mod_path
        AttributeError: '_NamespacePath' object has no attribute 'sort'

        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in C:\Users\OFIRAR~1\AppData\Local\Temp\pip-build-j5a_32a2\gapic-google-cloud-error-reporting-v1beta1\

what could cause this? I installed other packages without problems.


问:
Default Routing with multiple parameters is loading component
Default rout is not loading Tab Component be default . it only works if I replace the below code

{
                path: 'tab/:id',
                component: TabComponent  tabs
            }// note:works with one parameter only
app.routing.ts

```<code>const appRoutes: Routes = [

    {
        path: '',
        component: NavMenuComponent, // nav component
        children: [
            {
                path: '',
                redirectTo: 'tab/' ,
                pathMatch: 'full'
            },
            {
                path: 'tab/:id/:title',
                component: TabComponent // tabs
            }
        ]
    },

];
</code>```

manu.copnent.html

```<code> <ul class="list-unstyled list" *ngFor='let tab of tabs'>
            <li><a [routerLink]="['/tab',tab.LinkTabID,tab.TabName]" class="anchorLink"><i class="icon-home scolor"></i><font color="white">{{tab.TabName}}</font></a></li>

        </ul>
</code>```

答:
You can't navigate to a non-existing route, and the route tab/ doesn't exist, only tab/1/foo (or whatever values you use for the parameters).

If you want to be able to navigate to tab/ you need to create such a route

```<code>const appRoutes: Routes = [

    {
        path: '',
        component: NavMenuComponent, // nav component
        children: [
            {
                path: '',
                redirectTo: '/tab' ,
                pathMatch: 'full'
            },
            {
                path: 'tab',
                component: TabComponent // tabs
            }
            {
                path: 'tab/:id/:title',
                component: TabComponent // tabs
            }
        ]
    },

];
</code>```

You should be aware that navigating from tabs/ to tabs/1/foo TabComponent is destroyed and recreated while navigating from
tabs/1/foo to tabs/2/bar TabComponent is reused.

Body:
Default rout is not loading Tab Component be default . it only works if I replace the below code

{
                path: 'tab/:id',
                component: TabComponent  tabs
            }// note:works with one parameter only
app.routing.ts

const appRoutes: Routes = [

    {
        path: '',
        component: NavMenuComponent, // nav component
        children: [
            {
                path: '',
                redirectTo: 'tab/' ,
                pathMatch: 'full'
            },
            {
                path: 'tab/:id/:title',
                component: TabComponent // tabs
            }
        ]
    },

];

manu.copnent.html

{{tab.TabName}}

Body:
You can't navigate to a non-existing route, and the route tab/ doesn't exist, only tab/1/foo (or whatever values you use for the parameters).

If you want to be able to navigate to tab/ you need to create such a route

const appRoutes: Routes = [

    {
        path: '',
        component: NavMenuComponent, // nav component
        children: [
            {
                path: '',
                redirectTo: '/tab' ,
                pathMatch: 'full'
            },
            {
                path: 'tab',
                component: TabComponent // tabs
            }
            {
                path: 'tab/:id/:title',
                component: TabComponent // tabs
            }
        ]
    },

];

You should be aware that navigating from tabs/ to tabs/1/foo TabComponent is destroyed and recreated while navigating from
tabs/1/foo to tabs/2/bar TabComponent is reused.


问:
XSL in script tags
I need to output XSL in between script tags to dynamically output values into JavaScript.

Here is the code, but I can't get it to work. I want to add the position() into the script so it outputs something like o.write("flash1"); and increments the number per each flash file embedded. Any help appreciated.

```<code><div>
  <xsl:attribute name="id">iframe-content<xsl:value-of select="position()"/></xsl:attribute>
  <div id="flash"></div><!--/flash-->
  <script type="text/javascript">
    // <![CDATA[
    var so = new SWFObject("swf/video2.swf", "showreel", "720", "484", "8", "#ffffff");
    so.addParam("quality", "high");
    so.addParam("allowScriptAccess", "always");
    so.addParam("wmode", "transparent");
    so.addVariable("videoURL", "http://www.masterseries.co.uk/public/TempFiles/Concrete1.flv");
    so.write("flash");
    // ]]>
  </script>
</div>
</code>```

答:
You were close (you just can't easily use CDATA the way you did):

```<code><!-- note that you don't need xsl:attribute here -->
<div id="iframe-content-{position()}">
  <div id="flash"></div><!--/flash-->
  <script type="text/javascript">
    var so = new SWFObject("swf/video2.swf", "showreel", "720", "484", "8", "#ffffff");
    so.addParam("quality", "high");
    so.addParam("allowScriptAccess", "always");
    so.addParam("wmode", "transparent");
    so.addVariable("videoURL", "http://www.masterseries.co.uk/public/TempFiles/Concrete1.flv");
    so.write("flash<xsl:value-of select='position()' />");
  </script>
</div>
</code>```

You can use

```<code><xsl:output cdata-section-elements="script"/>
</code>```

to create CDATA sections in the output. However, you must make sure the input script source is correctly XML-encoded, i.e. does not have bare <, &, > characters but their <, &, > equivalents.

Title: XSL in script tags

Body:
I need to output XSL in between script tags to dynamically output values into JavaScript.

Here is the code, but I can't get it to work. I want to add the position() into the script so it outputs something like o.write("flash1"); and increments the number per each flash file embedded. Any help appreciated.

  <xsl:attribute name="id">iframe-content<xsl:value-of select="position()"/></xsl:attribute>

Body:
You were close (you just can't easily use CDATA the way you did):

<!-- note that you don't need xsl:attribute here -->
<div id="iframe-content-{position()}">
  <div id="flash"></div><!--/flash-->
  <script type="text/javascript">
    var so = new SWFObject("swf/video2.swf", "showreel", "720", "484", "8", "#ffffff");
    so.addParam("quality", "high");
    so.addParam("allowScriptAccess", "always");
    so.addParam("wmode", "transparent");
    so.addVariable("videoURL", "http://www.masterseries.co.uk/public/TempFiles/Concrete1.flv");
    so.write("flash<xsl:value-of select='position()' />");
  </script>
</div>

You can use

<xsl:output cdata-section-elements="script"/>

to create CDATA sections in the output. However, you must make sure the input script source is correctly XML-encoded, i.e. does not have bare <, &, > characters but their &lt;, &amp;, &gt; equivalents.


问:
SQLAlchemy equivalent of Django ORM's relationship-spanning filter
This example is from the Django documentation.

Given the (Django) database model:

```<code>class Blog(models.Model):
    name = models.CharField(max_length=100)

class Entry(models.Model):
    blog = models.ForeignKey(Blog)
    headline = models.CharField(max_length=255)
    body_text = models.TextField()
</code>```

In Django I can use:

```<code>Entry.objects.filter(blog__name__exact='Beatles Blog')
</code>```

to get all Entry objects for blogs with the specified name.

Question: What is the equivalent SQLAlchemy statement, given the model definition below?

```<code>class Blog(Base):
    __tablename__ = "blog"
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(100))

class Entry(Base):
    __tablename__ = "entry"
    id = Column(Integer, primary_key=True)
    blogid = Column(Integer, ForeignKey(Blog.id))
    headline = Column(Unicode(255))
    body_text = Column(UnicodeText)

    blog = relationship(Blog, backref="entries")
</code>```

EDIT

I believe there are two ways to accomplish this:

```<code>>>> q = session.query
>>> print q(Entry).join(Blog).filter(Blog.name == u"One blog")
SELECT entry.id AS entry_id, entry.blogid AS entry_blogid, entry.headline AS entry_headline, entry.body_text AS entry_body_text
FROM entry JOIN blog ON blog.id = entry.blogid
WHERE blog.name = ?

>>> print q(Entry).filter(Entry.blog.has(Blog.name == u"One blog"))
SELECT entry.id AS entry_id, entry.blogid AS entry_blogid, entry.headline AS entry_headline, entry.body_text AS entry_body_text
FROM entry
WHERE EXISTS (SELECT 1
FROM blog
WHERE blog.id = entry.blogid AND blog.name = ?)

# ... and of course
>>> blog = q(Blog).filter(Blog.name == u"One blog")
>>> q(Entry).filter(Entry.blog == blog)
</code>```

A few more questions:

Are there other ways to accomplish this using SQLAlchemy than the ones above?

Would it not make sense if you could do session.query(Entry).filter(Entry.blog.name == u"One blog") in many-to-one relationships?

What SQL does Django's ORM produce in this case?

答:
Already late to the party, but i stumbled across this:

https://github.com/mitsuhiko/sqlalchemy-django-query/blob/master/sqlalchemy_django_query.py

This tries to build queries using the django notation.

From the docs: Post.query.filter_by(pub_date__year=2008)

Body:
This example is from the Django documentation.

Given the (Django) database model:

class Blog(models.Model):
    name = models.CharField(max_length=100)

class Entry(models.Model):
    blog = models.ForeignKey(Blog)
    headline = models.CharField(max_length=255)
    body_text = models.TextField()

In Django I can use:

Entry.objects.filter(blog__name__exact='Beatles Blog')

to get all Entry objects for blogs with the specified name.

Question: What is the equivalent SQLAlchemy statement, given the model definition below?

class Blog(Base):
    __tablename__ = "blog"
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(100))

class Entry(Base):
    __tablename__ = "entry"
    id = Column(Integer, primary_key=True)
    blogid = Column(Integer, ForeignKey(Blog.id))
    headline = Column(Unicode(255))
    body_text = Column(UnicodeText)

    blog = relationship(Blog, backref="entries")

EDIT

I believe there are two ways to accomplish this:

>>> q = session.query
>>> print q(Entry).join(Blog).filter(Blog.name == u"One blog")
SELECT entry.id AS entry_id, entry.blogid AS entry_blogid, entry.headline AS entry_headline, entry.body_text AS entry_body_text
FROM entry JOIN blog ON blog.id = entry.blogid
WHERE blog.name = ?

>>> print q(Entry).filter(Entry.blog.has(Blog.name == u"One blog"))
SELECT entry.id AS entry_id, entry.blogid AS entry_blogid, entry.headline AS entry_headline, entry.body_text AS entry_body_text
FROM entry
WHERE EXISTS (SELECT 1
FROM blog
WHERE blog.id = entry.blogid AND blog.name = ?)

# ... and of course
>>> blog = q(Blog).filter(Blog.name == u"One blog")
>>> q(Entry).filter(Entry.blog == blog)

A few more questions:

Are there other ways to accomplish this using SQLAlchemy than the ones above?

Would it not make sense if you could do session.query(Entry).filter(Entry.blog.name == u"One blog") in many-to-one relationships?

What SQL does Django's ORM produce in this case?


问:
Check if session key exists in Laravel 5.1?
I'm trying to check it a session key has already been set inside a controller. The documentation states that it is possible to check if an item exists in an array and that's it.

http://laravel.com/docs/5.1/session

答:
You can do this </p>

```<code>if(Session::has('your_key')){
        return $next($request);
    }
</code>```

Body:
You can do this

if(Session::has('your_key')){
        return $next($request);
    }


问:
Small JavaScript/jQuery mouseleave question
I got this small JavaScript using jQuery that slides down a ul when an image is clicked:

```<code>$(document).ready(function () {
$('img.menu_class').click(function() {
$('ul.the_menu').slideToggle('medium');
});

});
</code>```

I was wondering if I could modify it to recognize when the mouse leaves the ul/image and make it slide back instead of having the user click on the image again. If I use something else than click() it would (naturally) only apply to the image and won't recognize the ul as an object. Any suggestions?

答: you can use jquery mouseout()</p>

Body:
I got this small JavaScript using jQuery that slides down a ul when an image is clicked:

$(document).ready(function () {
$('img.menu_class').click(function() {
$('ul.the_menu').slideToggle('medium');
});

});

I was wondering if I could modify it to recognize when the mouse leaves the ul/image and make it slide back instead of having the user click on the image again. If I use something else than click() it would (naturally) only apply to the image and won't recognize the ul as an object. Any suggestions?

Body: you can use jquery mouseout()


问:
PHP Script does not seem to work
I run a script on my webspace which is used for an android application. Though, it does not seem to work. On some webspaces I get a blank site when I try reaching it, on others I receive a 500 Internal Server Error. Though this script should work properly because it used to do so.

It is supposed to get all information from a table and echo it after some INNER JOINs. I could not track the error even after some mysqli_error checks and some echos to check variables etc.

The variable $con does exist, the connection should work properly. I just removed it for stack overflow ^^.

```<code> <?php

$subId = 1;

$sql = "SELECT articles.a_id, sciences.science, articles.title, articles.content, login.username, articles.date, articles.viewed, articles.timestamp FROM articles
                INNER JOIN sciences ON articles.s_id = sciences.s_id
                INNER JOIN login ON articles.author = login.id
                WHERE articles.s_id = ".$subId."
                ORDER BY timestamp DESC";

if (!$res = mysqli_query($con,$sql)) {
    echo "FAIL";
    echo mysqli_error($con);
}
else {

$result = array();

while($row = mysqli_fetch_array($res)){
array_push($result,
array('a_id'=>$row[0],
'science'=>$row[1],
'title'=>$row[2],
'content'=>$row[3],
'author'=>$row[4],
'date'=>$row[5],
'viewed'=>$row[6],
'timestamp'=>$row[7]
));
}

echo json_encode(array("result"=>$result));
}
mysqli_close($con);

?>
</code>```

EDIT: I updated my code:

```<code>    <?php

$subId = 1;

$con = mysqli_connect("HOST", "USER", "PASSWORD", "DATABASE");

if (!$con)
{
echo "Cant't connect to MySQL.<br>";
echo "Debug: " . mysqli_connect_errno()
}

$sql = "SELECT articles.a_id, sciences.science, articles.title, articles.content, login.username, articles.date, articles.viewed, articles.timestamp FROM articles
INNER JOIN sciences ON articles.s_id = sciences.s_id
INNER JOIN login ON articles.author = login.id
WHERE articles.s_id = ".$subId."
ORDER BY timestamp DESC";

if (!$res = $con->query($sql))
{
    echo "FAIL";
}
else
{

    $result = array();

    while($row = $con->fetchArray($res))
    {
        array_push($result); //use the query to rename fields, if needed
    }

    echo json_encode(array("result"=>$result));
}

?>
</code>```

答:
I think part of the problem is that you're confusing mysql and mysqli functions.  You're using mysqli procedurally, i.e.: mysqli_fetch_array(), which doesn't exist.  You'll have to convert to mysql, or go with the mysqli functions like this:</p>

```<code>$subId = 1;

$con = mysqli_connect('host', 'user', 'pass', 'dbname');

if (!$con)
{
echo "Cant't connect to MySQL.<br>";
echo "Debug: " . mysqli_connect_errno()
}

$sql = "SELECT articles.a_id, sciences.science, articles.title, articles.content, login.username, articles.date, articles.viewed, articles.timestamp FROM articles
INNER JOIN sciences ON articles.s_id = sciences.s_id
INNER JOIN login ON articles.author = login.id
WHERE articles.s_id = ".$subId."
ORDER BY timestamp DESC";

if (!$res = $con->query($sql))
{
    echo "FAIL";
}
else
{

    $result = array();

    while($row = $con->fetchArray($res))
    {
        array_push($result); //use the query to rename fields, if needed
    }

    echo json_encode(array("result"=>$result));
}
</code>```

Title: PHP Script does not seem to work

Body:
I run a script on my webspace which is used for an android application. Though, it does not seem to work. On some webspaces I get a blank site when I try reaching it, on others I receive a 500 Internal Server Error. Though this script should work properly because it used to do so.

It is supposed to get all information from a table and echo it after some INNER JOINs. I could not track the error even after some mysqli_error checks and some echos to check variables etc.

The variable $con does exist, the connection should work properly. I just removed it for stack overflow ^^.

 <?php

$subId = 1;

$sql = "SELECT articles.a_id, sciences.science, articles.title, articles.content, login.username, articles.date, articles.viewed, articles.timestamp FROM articles
                INNER JOIN sciences ON articles.s_id = sciences.s_id
                INNER JOIN login ON articles.author = login.id
                WHERE articles.s_id = ".$subId."
                ORDER BY timestamp DESC";

if (!$res = mysqli_query($con,$sql)) {
    echo "FAIL";
    echo mysqli_error($con);
}
else {

$result = array();

while($row = mysqli_fetch_array($res)){
array_push($result,
array('a_id'=>$row[0],
'science'=>$row[1],
'title'=>$row[2],
'content'=>$row[3],
'author'=>$row[4],
'date'=>$row[5],
'viewed'=>$row[6],
'timestamp'=>$row[7]
));
}

echo json_encode(array("result"=>$result));
}
mysqli_close($con);

?>

EDIT: I updated my code:

    <?php

$subId = 1;

$con = mysqli_connect("HOST", "USER", "PASSWORD", "DATABASE");

if (!$con)
{
echo "Cant't connect to MySQL.
";
echo "Debug: " . mysqli_connect_errno()
}

$sql = "SELECT articles.a_id, sciences.science, articles.title, articles.content, login.username, articles.date, articles.viewed, articles.timestamp FROM articles
INNER JOIN sciences ON articles.s_id = sciences.s_id
INNER JOIN login ON articles.author = login.id
WHERE articles.s_id = ".$subId."
ORDER BY timestamp DESC";

if (!$res = $con->query($sql))
{
    echo "FAIL";
}
else
{

    $result = array();

    while($row = $con->fetchArray($res))
    {
        array_push($result); //use the query to rename fields, if needed
    }

    echo json_encode(array("result"=>$result));
}

?>

Body:
I think part of the problem is that you're confusing mysql and mysqli functions.  You're using mysqli procedurally, i.e.: mysqli_fetch_array(), which doesn't exist.  You'll have to convert to mysql, or go with the mysqli functions like this:

$subId = 1;

$con = mysqli_connect('host', 'user', 'pass', 'dbname');

if (!$con)
{
echo "Cant't connect to MySQL.<br>";
echo "Debug: " . mysqli_connect_errno()
}

$sql = "SELECT articles.a_id, sciences.science, articles.title, articles.content, login.username, articles.date, articles.viewed, articles.timestamp FROM articles
INNER JOIN sciences ON articles.s_id = sciences.s_id
INNER JOIN login ON articles.author = login.id
WHERE articles.s_id = ".$subId."
ORDER BY timestamp DESC";

if (!$res = $con->query($sql))
{
    echo "FAIL";
}
else
{

    $result = array();

    while($row = $con->fetchArray($res))
    {
        array_push($result); //use the query to rename fields, if needed
    }

    echo json_encode(array("result"=>$result));
}


问:
How to add multiple item to a ListView with each Button click
I found much on google but not able to get the answer.
I got How to add an item to a ListView with each Button click.
here we are learning to add single item..
thanks in advance</p>

答:
Any reason why you can't try the following? </p>

```<code>@Override
public void onClick(View v) {
    myDataArray.add(data1);
    myDataArray.add(data2);
    myAdapter.notifyDataSetChanged();
}
</code>```

Body:
Any reason why you can't try the following?

@Override
public void onClick(View v) {
    myDataArray.add(data1);
    myDataArray.add(data2);
    myAdapter.notifyDataSetChanged();
}


问:
Overlaying Pie Charts in ggplot2
I am making a pie chart to go along with a series of plots all made in ggplot2. The data I'm using have two categories broken in to a total of three subcategories. Basically, the data look like this:

```<code>    Category Category_Value Super_Category
    <fctr>   <dbl>          <dbl>
 1  A        0.03733874     1
 2  B        0.66732754     0
 3  C        0.29533372     1
</code>```

Here is the basic pie chart I have at the subcategory level:

And here is what I'd like to have (or something similar):

I had never made a pie chart in ggplot2 before, so here is my basic code to generate the top plot:

```<code>pie.chart <- ggplot(pie.data, aes(x = "", y = Category_Value, fill = Category, width = 1)) +
  geom_bar(width = 1, stat = "identity") +
  coord_polar("y", start = 0) +
  scale_fill_manual(values = c("#4DAF4A", "#377EB8", "#E41A1C")) +
  theme_bw() +
  theme(
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    panel.border = element_blank(),
    panel.grid   = element_blank(),
    axis.ticks   = element_blank()
  )
</code>```

Is this something that's doable? I messed around with making another plot grouped at the major category level and overlaying them without success.

答:
You could use annotate to get an approximation of your picture.

Firstly I've used your small subset of data

```<code>pie.data <- data.frame(
  Category = c("A", "B", "C"),
  Category_Value = c(0.03733874, 0.66732754, 0.29533372),
  Super_Category = c(1,0,1))
</code>```

Then I've appplied your code

```<code>pie.chart <- ggplot(pie.data, aes(x = "", y = Category_Value, fill = Category, width = 1)) +
  geom_bar(width = 1, stat = "identity") +
  coord_polar("y", start = 0) +
  scale_fill_manual(values = c("#4DAF4A", "#377EB8", "#E41A1C")) +
  theme_bw() +
  theme(
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    panel.border = element_blank(),
    panel.grid   = element_blank(),
    axis.ticks   = element_blank()
  )
</code>```

And Finnaly I drew line using

```<code>pie.chart + annotate("rect", xmin = 1.5, xmax = 1.9, ymin = 0,2, ymax = 0.30, alpha=0,colour = "black")
</code>```

And the output:

Note that because you have more data that my sample you will have to play with the settings values of ymin = 0,2, ymax = 0.30 in annotate in order your line will cover values that you want.

Title: Overlaying Pie Charts in ggplot2

Body:
I am making a pie chart to go along with a series of plots all made in ggplot2. The data I'm using have two categories broken in to a total of three subcategories. Basically, the data look like this:

    Category Category_Value Super_Category
    <fctr>   <dbl>          <dbl>
 1  A        0.03733874     1
 2  B        0.66732754     0
 3  C        0.29533372     1

Here is the basic pie chart I have at the subcategory level:

And here is what I'd like to have (or something similar):

I had never made a pie chart in ggplot2 before, so here is my basic code to generate the top plot:

pie.chart <- ggplot(pie.data, aes(x = "", y = Category_Value, fill = Category, width = 1)) +
  geom_bar(width = 1, stat = "identity") +
  coord_polar("y", start = 0) +
  scale_fill_manual(values = c("#4DAF4A", "#377EB8", "#E41A1C")) +
  theme_bw() +
  theme(
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    panel.border = element_blank(),
    panel.grid   = element_blank(),
    axis.ticks   = element_blank()
  )

Is this something that's doable? I messed around with making another plot grouped at the major category level and overlaying them without success.

Body:
You could use annotate to get an approximation of your picture.

Firstly I've used your small subset of data

pie.data <- data.frame(
  Category = c("A", "B", "C"),
  Category_Value = c(0.03733874, 0.66732754, 0.29533372),
  Super_Category = c(1,0,1))

Then I've appplied your code

pie.chart <- ggplot(pie.data, aes(x = "", y = Category_Value, fill = Category, width = 1)) +
  geom_bar(width = 1, stat = "identity") +
  coord_polar("y", start = 0) +
  scale_fill_manual(values = c("#4DAF4A", "#377EB8", "#E41A1C")) +
  theme_bw() +
  theme(
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    panel.border = element_blank(),
    panel.grid   = element_blank(),
    axis.ticks   = element_blank()
  )

And Finnaly I drew line using

pie.chart + annotate("rect", xmin = 1.5, xmax = 1.9, ymin = 0,2, ymax = 0.30, alpha=0,colour = "black")

And the output:

Note that because you have more data that my sample you will have to play with the settings values of ymin = 0,2, ymax = 0.30 in annotate in order your line will cover values that you want.


问:
No response from codeception
I am trying to run codeception against my Yii2 project. However, I can getting no response from the simplest command line invocations. The command just sits there, for hours, until I break it.

I have installed this codeception manually, using the official phar and placing it in my path. I also have a copy in my vendors directory. Both of them do no work.

```<code>#install
wget http://codeception.com/codecept.phar
cp codecept.phar /usr/local/bin/codecep

#any combination hangs
/usr/local/bin/codecep bootstrap
vendor/bin/codecept build
codecept run
codecept
</code>```

In am running PHP 5.5, and installed the latest version of codeception from the project web site.

Title: No response from codeception

Body:
I am trying to run codeception against my Yii2 project. However, I can getting no response from the simplest command line invocations. The command just sits there, for hours, until I break it.

I have installed this codeception manually, using the official phar and placing it in my path. I also have a copy in my vendors directory. Both of them do no work.

#install
wget http://codeception.com/codecept.phar
cp codecept.phar /usr/local/bin/codecep

#any combination hangs
/usr/local/bin/codecep bootstrap
vendor/bin/codecept build
codecept run
codecept

In am running PHP 5.5, and installed the latest version of codeception from the project web site.

Body: Try: www.pceuropa.net/blog/yii2-tests-codeception-configuration-first-test/


问:
define a function alias in VBA, possible?
I am using VBA behind MS Access
Say I have global methods foo1 and foo2 that gets the same arguments but do different things.
I know that in C++ I can assign a function an alias. Something like:
instead of:

```<code>If (term) then
   foo1 arg1, arg2, arg3
else
   foo2 arg1, arg2, arg3
End If
</code>```

I want to write:

```<code>Var new_func = Iff (term, foo1,foo2)
new_func arg1, arg2, arg3
</code>```

Can I do this on vba?

答:
No, unfortunately, that's not possible with VBA. Would be nice, but you'll just have to stick to your first syntax.

Update: So, I stand by my original assertion that the construct proposed in the question does not exist in VBA, but Alex K. and Remou have provided usable workarounds.

Body:
I am using VBA behind MS Access
Say I have global methods foo1 and foo2 that gets the same arguments but do different things.
I know that in C++ I can assign a function an alias. Something like:
instead of:

If (term) then
   foo1 arg1, arg2, arg3
else
   foo2 arg1, arg2, arg3
End If

I want to write:

Var new_func = Iff (term, foo1,foo2)
new_func arg1, arg2, arg3

Can I do this on vba?


问:
Adding rows to SQL query result
I have a custom query in my Java application that looks like that:

```<code>select
    to_char(search.timestamp,'Mon') as mon,
    COUNT(DISTINCT(search.ip_address))
from
    searches
WHERE
    searches.city = 1
group by 1;
</code>```

which should return all months that occur within the database, and number of distinct IP addresses within each month. However, at this point, some months do not have any entries, and they are missing in the SQL query result. How can I make sure that all of the months are displayed there, even if their count is 0?

Got it working with:

```<code>select
    to_char (gs.m,'Mon') as mon,
    count (distinct search.ip_address)
from
    generate_series (
          date_trunc('month', current_date - interval '11 month'),
          current_date,
          '1 month'
      ) gs (m)
    left join searches
    on date_trunc('month', search.timestamp) = gs.m AND search.city = 1
group by gs.m
order by gs.m;
</code>```

答:
```<code>select
    to_char (gs.m,'Mon') as mon,
    count (distinct(search.ip_address))
from
    searches
    right join
    generate_series (
        date_trunc('month', current_date - interval '1 year'),
        current_date,
        '1 month'
    ) gs (m) on date_trunc('month', search.timestamp) = gs.m
where searches.city = 1
group by gs.m
order by gs.m;
</code>```

Title: Adding rows to SQL query result

Body:
I have a custom query in my Java application that looks like that:

select
    to_char(search.timestamp,'Mon') as mon,
    COUNT(DISTINCT(search.ip_address))
from
    searches
WHERE
    searches.city = 1
group by 1;

which should return all months that occur within the database, and number of distinct IP addresses within each month. However, at this point, some months do not have any entries, and they are missing in the SQL query result. How can I make sure that all of the months are displayed there, even if their count is 0?

Got it working with:

select
    to_char (gs.m,'Mon') as mon,
    count (distinct search.ip_address)
from
    generate_series (
          date_trunc('month', current_date - interval '11 month'),
          current_date,
          '1 month'
      ) gs (m)
    left join searches
    on date_trunc('month', search.timestamp) = gs.m AND search.city = 1
group by gs.m
order by gs.m;


问:
use `SplitArrayField` instead of `SimpleArrayField` in ModelForm
I have model with ArrayField and I want use ModelForm. Django by default use SimpleArrayField but I need SplitArrayField. I get my data from json and I use form only for validation and I don't need input widgets. (I use client side rendering)

```<code>class Profile(models.Model):
  phone = ArrayField(CharField(max_length=20, validators=[some_validator]))

class ProfileForm(ModelForm):
  class Meta:
    model = Profile

form = ProfileForm(data={"phone":["555-5555","444-4444"]})
form.validate()
</code>```

How I can use SplitArrayField in ModelForm?

答:
I solve my problem with field_classes in Meta class:

```<code>class ProfileForm(ModelForm):

    class Meta:
        model = Profile
        field_classes = {
            'phone': SplitArrayField, # or any custom field
        }
</code>```

note:

SplitArrayField is not good enough for me so I create my own array form field

Body:
I have model with ArrayField and I want use ModelForm. Django by default use SimpleArrayField but I need SplitArrayField. I get my data from json and I use form only for validation and I don't need input widgets. (I use client side rendering)

class Profile(models.Model):
  phone = ArrayField(CharField(max_length=20, validators=[some_validator]))

class ProfileForm(ModelForm):
  class Meta:
    model = Profile

form = ProfileForm(data={"phone":["555-5555","444-4444"]})
form.validate()

How I can use SplitArrayField in ModelForm?

Body:
I solve my problem with field_classes in Meta class:

class ProfileForm(ModelForm):

    class Meta:
        model = Profile
        field_classes = {
            'phone': SplitArrayField, # or any custom field
        }

note:

SplitArrayField is not good enough for me so I create my own array form field


问:
Fatal error: Uncaught exception 'PDOException' thrown in C:\xampp\htdocs\register.php on line 19
I have received:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '5538ac14bb2ca7514f9f4d8826f3c45e'')' at line 1' in C:\xampp\htdocs\register.php:19 Stack trace: #0 C:\xampp\htdocs\register.php(19): PDO->exec('insert into use...') #1 {main} thrown in C:\xampp\htdocs\register.php on line 19.

How can this be solved, like what should be done?

```<code><?php
    session_start();

    // If the form has been submitted

    if (isset($_POST['submitted'])){

        // Create a database connection

        $db = new PDO("mysql:dbname=johnsoa7_db;host=localhost", "root", "");
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        // Get and sanitise the inputs, we don't need to do
        // this with the password as we hash it anyway

        $safe_forename = $db->quote($_POST['forename']);
        $safe_lastname = $db->quote($_POST['lastname']);
        $safe_email = $db->quote($_POST['email']);
        $hashed_password = $db->quote(md5($_POST['password']));

        // Insert the entry into the database

        $query = "insert into users values (default, $safe_forename, $safe_lastname, $safe_email, '$hashed_password')";

        $db->exec($query);

        // Get the ID

        $id = $db->lastInsertId();

        // Output success or the errors

        echo "Congratulations! You are now registered. Your ID is: $id";
    }
?>
</code>```

答:
You have an error in this line:

```<code>$query = "insert into users values (default, $safe_forename, $safe_lastname, $safe_email,'$hashed_password')";
</code>```

default should be quoted if it is string.

If it is a variable, you missed $.

Please see the comment by @ceejayoz:

As he said you don't need quoted around $hashed_password...

ContentLicense: CC BY-SA 4.0

Body:
I have received:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '5538ac14bb2ca7514f9f4d8826f3c45e'')' at line 1' in C:\xampp\htdocs\register.php:19 Stack trace: #0 C:\xampp\htdocs\register.php(19): PDO->exec('insert into use...') #1 {main} thrown in C:\xampp\htdocs\register.php on line 19.

How can this be solved, like what should be done?

<?php
    session_start();

    // If the form has been submitted

    if (isset($_POST['submitted'])){

        // Create a database connection

        $db = new PDO("mysql:dbname=johnsoa7_db;host=localhost", "root", "");
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        // Get and sanitise the inputs, we don't need to do
        // this with the password as we hash it anyway

        $safe_forename = $db->quote($_POST['forename']);
        $safe_lastname = $db->quote($_POST['lastname']);
        $safe_email = $db->quote($_POST['email']);
        $hashed_password = $db->quote(md5($_POST['password']));

        // Insert the entry into the database

        $query = "insert into users values (default, $safe_forename, $safe_lastname, $safe_email, '$hashed_password')";

        $db->exec($query);

        // Get the ID

        $id = $db->lastInsertId();

        // Output success or the errors

        echo "Congratulations! You are now registered. Your ID is: $id";
    }
?>

Body:
You have an error in this line:

$query = "insert into users values (default, $safe_forename, $safe_lastname, $safe_email,'$hashed_password')";

default should be quoted if it is string.

If it is a variable, you missed $.

Please see the comment by @ceejayoz:

As he said you don't need quoted around $hashed_password...


问:
IE7 Z-Index Layering Issues
I've isolated a little test case of IE7's z-index bug, but don't know how to fix it.
I have been playing with z-index all day long.

What is wrong with z-index in IE7?

Test CSS:

input {
    border: 1px solid #000;
}

div {
    border: 1px solid #00f;
}

ul {
    border: 1px solid #f00;
    background-color: #f00;
    list-style-type: none;
    margin: 0;
    padding-left: 0;
    z-index: 1000;
}

li {
    color: #fff;
    list-style-type: none;
    padding-left: 0;
    margin-left: 0;
}

span.envelope {
    position: relative;
}

span.envelope ul {
    position: absolute;
    top: 20px;
    left: 0;
    width: 150px;
}
```

<p>Test HTML:</p>

<pre class="lang-html prettyprint-override"><code><form>
  <label>Input #1:</label>
  <span id="envelope-1" class="envelope">
    <input name="my-input-1" id="my-input-1" />
      <ul>
        <li>item</li>
        <li>item</li>
        <li>item</li>
        <li>item</li>
      </ul>
  </span>
  <br><br>
  <label>Input #2:</label>
  <span id="envelope-2" class="envelope">
    <input name="my-input-2" id="my-input-2" />
  </span>
</form>
</code>```

答:
I found that I had to place a special z-index designation on div in a ie7 specific styelsheet:

div { z-index:10; }

For the z-index of unrelated divs, such as a nav, to show above the slider. I could not simply add a z-index to the slider div itself.

Title: IE7 Z-Index Layering Issues

Body:
I've isolated a little test case of IE7's z-index bug, but don't know how to fix it.
I have been playing with z-index all day long.

What is wrong with z-index in IE7?

Test CSS:

input {
    border: 1px solid #000;
}

div {
    border: 1px solid #00f;
}

ul {
    border: 1px solid #f00;
    background-color: #f00;
    list-style-type: none;
    margin: 0;
    padding-left: 0;
    z-index: 1000;
}

li {
    color: #fff;
    list-style-type: none;
    padding-left: 0;
    margin-left: 0;
}

span.envelope {
    position: relative;
}

span.envelope ul {
    position: absolute;
    top: 20px;
    left: 0;
    width: 150px;
}

Test HTML:

<form>
  Input #1:

    <input name="my-input-1" id="my-input-1" />

item

item

item

item

  Input #2:

    <input name="my-input-2" id="my-input-2" />

</form>


问:
Akka.net actor selections or references
What is more efficient in Akka.net, talking to actor selections or interacting with an IActorRef being passed in a message?</p>

答:
The best answer would be to benchmark it for your case, as this may depend on multiple conditions (like local/remote communication). When we're talking about communication within the same process, IActorRef should always be faster. In remote communication the difference may be smaller, but stil in favor of IActorRef.

That being said, it's important to get the difference between two:

When underlying actors stops (don't confuse stop with restart) its IActorRef is no longer valid. If it will be created some time later, your old IActorRef doesn't necessary have to point to it. This is one of the reasons, why you may Context.Watch(actorRef) to be notified when your actor dies.

Actor selection doesn't point directly to an actor's mailbox, therefore usually it's slower. The actual recipient's mailbox is resolved when you're trying to send a message through it. It doesn't suffer invalidation issues, but cannot be watched either. It also may point to more than one actor (using wildcards), so your message may be delivered to multiple actors somewhere in the actor hierarchy.

Title: Akka.net actor selections or references


问:
How to delete a single git repository clone, without the rm -rf sledgehammer?
It is not possible to remove a git repo simply with rm -r, because the .git directory contains lots of write-protected files. I have permission to delete these as I'm the owner, but it's not feasible to confirm them all one by one.

Now, it is possible to do it all in one command by adding the -f flag to rm, but that means I lose all protection against deleting stuff that's protected for good reason. Like, for instance, another git repository with local branches that I haven't pushed yet.

But it seems the only way, so I've found myself doing rm -rf quite a lot lately, but I always feel uneasy about it. Is there a better way to get rid of a single repo clone, that will not ask about thousands of individual files but will fail if I try to erase something but a single repo? Ideally, it should also check that the repo I'm trying to delete has some up-to-date remote, before actually deleting it.

I don't quite see what's unclear about this question... it is this:

How do I delete a repository with all contents, using commands that would not also nuke any other directory with write-protected files in it?

答:
You may create a little bash function in your .bashrc:

```<code>function rmgit() {
    # Recursively apply write permissions to files in the .git folder
    chmod -R +w "${1}/.git"
    # Remove the clone
    rm -r "${1}"
}
</code>```

Start a new shell and you should now being able to:

```<code>rmgit /path/to/clone
</code>```

Body:
You may create a little bash function in your .bashrc:

function rmgit() {
    # Recursively apply write permissions to files in the .git folder
    chmod -R +w "${1}/.git"
    # Remove the clone
    rm -r "${1}"
}

Start a new shell and you should now being able to:

rmgit /path/to/clone


问:
Ordering numbers but keeping 0's at the end of the tab
I want to order a column in e bidimensionnal array (ascending order) but keeping all the 0 at the end.
For exemple :

```<code>input = {5,2,1,0,4}
output = {1,2,4,5,0}
</code>```

I've done this method which orders the numbers (ascending) but i don't find how to keep the 0's at the end. (there can be multiple 0)

```<code>public static void orderCol(int[][] tab, int iCol){ // This will order numbers in the column i (ascending AND placing 0 at the end) (In case the user didnt already do it in the input file this will prevent further problems).
    int temp;
    for(int i=0; i< tab[0].length-1;i++){
        if(tab[iCol][i+1] < tab[iCol][i]){
            //swapping
            temp = tab[iCol][i];
            tab[iCol][i] = tab[iCol][i+1];
            tab[iCol][i+1] = temp;
            i=-1;
        }
    }
}
</code>```

Hope you can help, thanks in advance !

答:
you can first count how many 0's does your array have and create a new array with only the non-0s then sort the non-0s and append the 0's</p>

```<code>public int[] orderCol(int[][] tab, int iCol){ // This will order numbers in the column i (ascending AND placing 0 at the end) (In case the user didnt already do it in the input file this will prevent further problems).
    int index = 0;
    int[] newArray = new int[tab[0].length];
    for (int  x: tab[0]) { // iterates each element on tab[0]
        if (x != 0) newArray[index++] = x;
    }

// SORT YOUR newArray HERE using any sort algo

     while(index != tab[0].length) newArray[index++] = 0;
     return newArray;

}
</code>```

Body:
I want to order a column in e bidimensionnal array (ascending order) but keeping all the 0 at the end.
For exemple :

input = {5,2,1,0,4}
output = {1,2,4,5,0}

I've done this method which orders the numbers (ascending) but i don't find how to keep the 0's at the end. (there can be multiple 0)

public static void orderCol(int[][] tab, int iCol){ // This will order numbers in the column i (ascending AND placing 0 at the end) (In case the user didnt already do it in the input file this will prevent further problems).
    int temp;
    for(int i=0; i< tab[0].length-1;i++){
        if(tab[iCol][i+1] < tab[iCol][i]){
            //swapping
            temp = tab[iCol][i];
            tab[iCol][i] = tab[iCol][i+1];
            tab[iCol][i+1] = temp;
            i=-1;
        }
    }
}

Hope you can help, thanks in advance !

Body:
you can first count how many 0's does your array have and create a new array with only the non-0s then sort the non-0s and append the 0's

public int[] orderCol(int[][] tab, int iCol){ // This will order numbers in the column i (ascending AND placing 0 at the end) (In case the user didnt already do it in the input file this will prevent further problems).
    int index = 0;
    int[] newArray = new int[tab[0].length];
    for (int  x: tab[0]) { // iterates each element on tab[0]
        if (x != 0) newArray[index++] = x;
    }

// SORT YOUR newArray HERE using any sort algo

     while(index != tab[0].length) newArray[index++] = 0;
     return newArray;

}


问:
How to maintain image aspect ratio in modal using flexbox?
I have an image gallery in my modal, which is styled using flexbox. The problem is that some pictures which are too large horizontally flow over and make the flexbox stretch, so the item next to it is messed up, eventhough the flex weights are set in css.

```<code><div class="slideshow-container">
    <div class="mySlides fade" style="display: block;">
         <div class="numbertext">1 / 16</div>
              <img src="./img/normal/image.jpg" class="galimg" style="height: 331px;">
         <div class="text">Image description</div>
    </div>
    ....
</div>
</code>```

I want each image to maintain its aspect ratio. Some are landscape, some are portrait. So I thought I'd try the following:

```<code>var maxHeight = $('#modal-gallery').height()-39; // need 39px for the gallery navigation.
var maxWidth = $('#modal-gallery').width();
var ratio = maxHeight/maxWidth;
$('.galimg').each(function(i){
    if ($(this).height()/$(this).width() > ratio){
        $(this).width(maxWidth);
    } else {
        $(this).height(maxHeight);
    }
});
</code>```

CSS:

```<code>#modal-gallery { // this is the div surrounding the gallery
    flex: 6;
    display: flex;
    margin-right: auto;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.slideshow-container {
    display: flex;
    position: relative;
    margin: 0;
}
</code>```

I know the problem is probably somewhere in my JS, as I tried logging the width and height and often got 0. The html is generated dynamically through JS. I tried adding an onImgLoad function, but didn't get any result.

答:
There is no need to do a js thing. Just fix your css. Add some styles and HTML elements. The following is the most common way to show different size images in many websites (Please also expand the snippet to see how it behaves).

#modal-gallery { // this is the div surrounding the gallery
    flex: 6;
    display: flex;
    margin-right: auto;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.slideshow-container {
    display: flex;
    position: relative;
    margin: 0;
}
.mySlides{
    display:block
}
.slide-image{
  display:inline-block;
  width:220px;
  text-align:center;
  vertical-align:top;
  margin-bottom: 20px;
}
.img-container{
  display:block;
  width:200px;
}
.img-container .img{
    display:table-cell;
    vertical-align:middle;
    text-align:center;
}
.img-container img{
  max-height:200px;
  max-width:200px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="slideshow-container">
    <div class="mySlides fade">
        <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider1.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="http://i.imgur.com/RRUe0Mo.png" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://www.smashingmagazine.com/wp-content/uploads/2015/06/10-dithering-opt.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://www.smashingmagazine.com/wp-content/uploads/2015/06/10-dithering-opt.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider1.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
       <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="http://i.imgur.com/RRUe0Mo.png" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
    </div>

</div></code>```

Body:
I have an image gallery in my modal, which is styled using flexbox. The problem is that some pictures which are too large horizontally flow over and make the flexbox stretch, so the item next to it is messed up, eventhough the flex weights are set in css.

1 / 16

Image description

    ....

I want each image to maintain its aspect ratio. Some are landscape, some are portrait. So I thought I'd try the following:

var maxHeight = $('#modal-gallery').height()-39; // need 39px for the gallery navigation.
var maxWidth = $('#modal-gallery').width();
var ratio = maxHeight/maxWidth;
$('.galimg').each(function(i){
    if ($(this).height()/$(this).width() > ratio){
        $(this).width(maxWidth);
    } else {
        $(this).height(maxHeight);
    }
});

CSS:

#modal-gallery { // this is the div surrounding the gallery
    flex: 6;
    display: flex;
    margin-right: auto;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.slideshow-container {
    display: flex;
    position: relative;
    margin: 0;
}

I know the problem is probably somewhere in my JS, as I tried logging the width and height and often got 0. The html is generated dynamically through JS. I tried adding an onImgLoad function, but didn't get any result.

Body:
There is no need to do a js thing. Just fix your css. Add some styles and HTML elements. The following is the most common way to show different size images in many websites (Please also expand the snippet to see how it behaves).

#modal-gallery { // this is the div surrounding the gallery
    flex: 6;
    display: flex;
    margin-right: auto;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.slideshow-container {
    display: flex;
    position: relative;
    margin: 0;
}
.mySlides{
    display:block
}
.slide-image{
  display:inline-block;
  width:220px;
  text-align:center;
  vertical-align:top;
  margin-bottom: 20px;
}
.img-container{
  display:block;
  width:200px;
}
.img-container .img{
    display:table-cell;
    vertical-align:middle;
    text-align:center;
}
.img-container img{
  max-height:200px;
  max-width:200px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="slideshow-container">
    <div class="mySlides fade">
        <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider1.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="http://i.imgur.com/RRUe0Mo.png" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://www.smashingmagazine.com/wp-content/uploads/2015/06/10-dithering-opt.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://www.smashingmagazine.com/wp-content/uploads/2015/06/10-dithering-opt.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
      <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider1.jpg" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
       <div class="slide-image">
          <div class="numbertext">1 / 16</div>
          <div class="img-container">
            <div class="img">
              <img src="http://i.imgur.com/RRUe0Mo.png" class="galimg" />
            </div>
          </div>
          <div class="text">Image description</div>
      </div>
    </div>

</div>


问:
How to run binary file in Linux
I have a file called commanKT and want to run it in a Linux terminal. Can someone help by giving the command to run this file? I tried ./commonRT but I'm getting the error:

```<code>"bash: ./commonrt: cannot execute binary file"

[blackberry@BuildMc MainApp]$ ls -al commonKT
-rwxrwxr-x. 1 sijith sijith 10314053 Feb 27 16:49 commonKT
</code>```

答:
The only way that works for me (extracted from here):

```<code>chmod a+x name_of_file.bin
</code>```

Then run it by writing

```<code>./name_of_file.bin
</code>```

If you get a permission error you might have to launch your application with root privileges:

```<code> sudo ./name_of_file.bin
</code>```

Title: How to run binary file in Linux

Body:
I have a file called commanKT and want to run it in a Linux terminal. Can someone help by giving the command to run this file? I tried ./commonRT but I'm getting the error:

"bash: ./commonrt: cannot execute binary file"

[blackberry@BuildMc MainApp]$ ls -al commonKT
-rwxrwxr-x. 1 sijith sijith 10314053 Feb 27 16:49 commonKT

Body:
The only way that works for me (extracted from here):

chmod a+x name_of_file.bin

Then run it by writing

./name_of_file.bin

If you get a permission error you might have to launch your application with root privileges:

 sudo ./name_of_file.bin


答:
```<code>function createDateRangeArray($start, $end) {
// Modified by JJ Geewax

$range = array();

if (is_string($start) === true) $start = strtotime($start);
if (is_string($end) === true ) $end = strtotime($end);

if ($start > $end) return createDateRangeArray($end, $start);

do {
$range[] = date('Y-m-d', $start);
$start = strtotime("+ 1 day", $start);
}
while($start < $end);

return $range;
}
</code>```

Source: http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html

Title: PHP: Return all dates between two dates in an array

Body:
Expected Input:

getDatesFromRange( '2010-10-01', '2010-10-05' );

Expected Output:

Array( '2010-10-01', '2010-10-02', '2010-10-03', '2010-10-04', '2010-10-05' )

Body:
function createDateRangeArray($start, $end) {
// Modified by JJ Geewax

$range = array();

if (is_string($start) === true) $start = strtotime($start);
if (is_string($end) === true ) $end = strtotime($end);

if ($start > $end) return createDateRangeArray($end, $start);

do {
$range[] = date('Y-m-d', $start);
$start = strtotime("+ 1 day", $start);
}
while($start < $end);

return $range;
}

Source: http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html


问:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='eError']"}
I am trying to validate a login section with all valid and invalid inputs.

here is the code i have tried:

```<code>
    public void login_Valid_Invalid_Combinations() throws BiffException, IOException, InterruptedException
    {
      String FilePath = "D://credentials.xls";
      FileInputStream FIS = new FileInputStream(FilePath);
      Workbook WB = Workbook.getWorkbook(FIS);
      Sheet SH = WB.getSheet(0);
      for(int row =0; row<= SH.getRows()-1; row++)
      {
          String userNAME = SH.getCell(0, row).getContents();
          String passWORD = SH.getCell(1, row).getContents();
          System.out.println("USERMANE : "+userNAME + "  PASSWORD : "+passWORD);
          driver.get("LOGIN PAGE URL");
          driver.findElement(By.id("Email")).sendKeys(userNAME);
          driver.findElement(By.id("Password")).sendKeys(passWORD);
          driver.findElement(By.id("btnlogin")).click();
          System.out.println(driver.findElement(By.xpath("//*[@id='eError']")).getText());
          Thread.sleep(2000);
          String URL = driver.getCurrentUrl();
          System.out.println(URL);
          if (URL.equals("URL AFTER SUCCESFULL LOGIN"))
          {
              System.out.println("Login Successfull");
          }
          else
          {
              System.out.println("Login Failed");
          }
      }
      driver.close();
    }
```

I want to show the error message each time login failed, which is working fine. But when login is successful with valid inputs, it's showing:

"org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='eError']"}"

as the error message is not coming for successful login.

Can you please help me how to handle this.

答:
For such a case, i am not a fan of try/catch. You want to check if the element exists on the page and if it does print out the text it contains otherwise its a successful login,</p>

```<code>//Use findElements
List<WebElement> elements = driver.findElements(By.xpath("//*[@id='eError']"));
if(elements.size() > 0)
{
    System.out.println(elements.get(0).getText())
}
</code>```

Body:
I am trying to validate a login section with all valid and invalid inputs.

here is the code i have tried:

    public void login_Valid_Invalid_Combinations() throws BiffException, IOException, InterruptedException
    {
      String FilePath = "D://credentials.xls";
      FileInputStream FIS = new FileInputStream(FilePath);
      Workbook WB = Workbook.getWorkbook(FIS);
      Sheet SH = WB.getSheet(0);
      for(int row =0; row<= SH.getRows()-1; row++)
      {
          String userNAME = SH.getCell(0, row).getContents();
          String passWORD = SH.getCell(1, row).getContents();
          System.out.println("USERMANE : "+userNAME + "  PASSWORD : "+passWORD);
          driver.get("LOGIN PAGE URL");
          driver.findElement(By.id("Email")).sendKeys(userNAME);
          driver.findElement(By.id("Password")).sendKeys(passWORD);
          driver.findElement(By.id("btnlogin")).click();
          System.out.println(driver.findElement(By.xpath("//*[@id='eError']")).getText());
          Thread.sleep(2000);
          String URL = driver.getCurrentUrl();
          System.out.println(URL);
          if (URL.equals("URL AFTER SUCCESFULL LOGIN"))
          {
              System.out.println("Login Successfull");
          }
          else
          {
              System.out.println("Login Failed");
          }
      }
      driver.close();
    }

I want to show the error message each time login failed, which is working fine. But when login is successful with valid inputs, it's showing:

"org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='eError']"}"

as the error message is not coming for successful login.

Can you please help me how to handle this.

Body:
For such a case, i am not a fan of try/catch. You want to check if the element exists on the page and if it does print out the text it contains otherwise its a successful login,

//Use findElements
List<WebElement> elements = driver.findElements(By.xpath("//*[@id='eError']"));
if(elements.size() > 0)
{
    System.out.println(elements.get(0).getText())
}


问:
i am trying to clear a txt file in javascript
I have a text file that has some strings in it. I am trying to clear it to put something else in it. What is the right code?

I have tried File.Clear() but it keeps throwing errors.

答: Assuming you're using nodejs and not a browser (in a browser you have other means of persistence like localstorage, but not files), check this and remember, you use an in memory representation of the file, if you want an empty one you can create one anew, if you want to clear the contents on the disk you need to write an empty (or whatever content you need to write) on the disk.</p>