问:
Eclipse Paho Automatic Reconnect configure
As provided in documentation of java client's automaticReconnect feature:

Once the client has been disconnected, the client will attempt to
  connect with an increasing time interval. Starting at 1 second,
  doubling on each failed attempt up to 2 minutes.

But It raises some questions over client behavior:

After 2 minutes limit, Will client keep trying to connect indefinitely?
As I am not able to find any other parameter to control this iteration.

Is there any way available to configure this interval ?

答:
Look at the MqttAsyncClient.java source code (I have removed few lines below):

```<code>/**
 * Attempts to reconnect the client to the server.
 * If successful it will make sure that there are no further
 * reconnects scheduled. However if the connect fails, the delay will double
 * up to 128 seconds and will re-schedule the reconnect for after the delay.
 *
 * Any thrown exceptions are logged but not acted upon as it is assumed that
 * they are being thrown due to the server being offline and so reconnect
 * attempts will continue.
 */
private void attemptReconnect(){
    final String methodName = "attemptReconnect";
    //@Trace 500=Attempting to reconnect client: {0}
    log.fine(CLASS_NAME, methodName, "500", new Object[]{this.clientId});

    connect(this.connOpts, this.userContext,new IMqttActionListener() {

        public void onSuccess(IMqttToken asyncActionToken) {
            //@Trace 501=Automatic Reconnect Successful: {0}
            log.fine(CLASS_NAME, methodName, "501", new Object[]{asyncActionToken.getClient().getClientId()});
            comms.setRestingState(false);
            stopReconnectCycle();
        }

        public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
            //@Trace 502=Automatic Reconnect failed, rescheduling: {0}
            log.fine(CLASS_NAME, methodName, "502", new Object[]{asyncActionToken.getClient().getClientId()});
            if(reconnectDelay < 128000){
                reconnectDelay = reconnectDelay * 2;
            }
            rescheduleReconnectCycle(reconnectDelay);
        }
    });
}
</code>```

So the reconnect delay will be: 1, 2, 4, 8, 16, 32, 64, 128, 128, 128, 128, ...

Body:
Look at the MqttAsyncClient.java source code (I have removed few lines below):

/**
 * Attempts to reconnect the client to the server.
 * If successful it will make sure that there are no further
 * reconnects scheduled. However if the connect fails, the delay will double
 * up to 128 seconds and will re-schedule the reconnect for after the delay.
 *
 * Any thrown exceptions are logged but not acted upon as it is assumed that
 * they are being thrown due to the server being offline and so reconnect
 * attempts will continue.
 */
private void attemptReconnect(){
    final String methodName = "attemptReconnect";
    //@Trace 500=Attempting to reconnect client: {0}
    log.fine(CLASS_NAME, methodName, "500", new Object[]{this.clientId});

    connect(this.connOpts, this.userContext,new IMqttActionListener() {

        public void onSuccess(IMqttToken asyncActionToken) {
            //@Trace 501=Automatic Reconnect Successful: {0}
            log.fine(CLASS_NAME, methodName, "501", new Object[]{asyncActionToken.getClient().getClientId()});
            comms.setRestingState(false);
            stopReconnectCycle();
        }

        public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
            //@Trace 502=Automatic Reconnect failed, rescheduling: {0}
            log.fine(CLASS_NAME, methodName, "502", new Object[]{asyncActionToken.getClient().getClientId()});
            if(reconnectDelay < 128000){
                reconnectDelay = reconnectDelay * 2;
            }
            rescheduleReconnectCycle(reconnectDelay);
        }
    });
}

So the reconnect delay will be: 1, 2, 4, 8, 16, 32, 64, 128, 128, 128, 128, ...


来源: stackexchange

问:
Java ProcessBuilder Error When Space(s) In Path
So I spent half a day trying to get this to work with no positive result. I am using a Java ProcessBuilder to execute some .exe file with a couple of arguments, but the file-path contain space(s) and somehow I can't get it to work properly. I have checked a number of other SO posts and implemented solutions like surround code with escaped quotes and splitting it up in command and arguments etc. My code is below:

```<code>try {
    ProcessBuilder pBuilder = new ProcessBuilder(
        // Main Command.
        "C:\\namewith space\\database\\postgres_db\\bin\\pg_ctl.exe",
        // Command Parameters.
        "start",
        "-D C:\\namewith space\\database\\database",
        /*The quotes in the next argument are necessary, the -o stands for 'options' and everything between the quotes are the actual database parameters which to start the Database with.*/
        "-o \"-p 15000\"",
        "-l C:\\namewith space\\database\\postgres_db\\bin\\postgres_log.txt");

    File log = new File("\"C:\\folder\\log.txt\"");
    pBuilder.redirectErrorStream(true);
    pBuilder.redirectOutput(Redirect.appendTo(log));
    Process p = pBuilder.start();
    } catch (IOException ex) {
        System.out.println("Exception Occurred: " + ex);
    }
</code>```

I have tried so far:

Surrounding and not surrounding each/any of the paths in the above code with escaped quotes just in case that matters (something tells me it does...).

Using the Runtime.getRuntime().exec("full command with/without any/all escaped quotes"); method, but when searching on SO I found out everyone is saying you should use the ProcessBuilder instead.

Adding parts of the above code together in different ways in the ProcessBuiler's first command String, like "\"C:\\namewith space\\database\\postgres_db\\bin\\pg_ctl.exe\" start"

The files are 100% located at the given paths, I checked this by hand and by pasting the paths in the File Explorer over 10 times.

Splitting up the command into setting the working directory of the command to C:\namewith space\ and then adding the args without that part.

The error (via the System.out.println("Exception Occurred: " + ex); ) I keep getting is: java.io.IOException: Cannot run program "C:\namewith space\database\postgres_db\bin\pg_ctl.exe": The filename, directory name, or volume label syntax is incorrect.

Please let me know if you need any extra parts/code and I will do my best to provide it in detail.

答:
Try to break the problem down.

First just read the absolute path shown in the IOException into a File object and call the exists() method to check that the file really exists and the JVM has access to it.

If that didn't work, fix your path or the access permissions. If the file really exists and you can access it then create the ProcessBuilder without any parameters, just with absolute path to your exe.

You shouldn't get the IOException now. Then add the parameters one by one. If you find one that breaks the thing, then fix the parameter (maybe the double quotes are missing) and go onto the next until you finish.

ContentLicense: CC BY-SA 3.0

Body:
So I spent half a day trying to get this to work with no positive result. I am using a Java ProcessBuilder to execute some .exe file with a couple of arguments, but the file-path contain space(s) and somehow I can't get it to work properly. I have checked a number of other SO posts and implemented solutions like surround code with escaped quotes and splitting it up in command and arguments etc. My code is below:

try {
    ProcessBuilder pBuilder = new ProcessBuilder(
        // Main Command.
        "C:\\namewith space\\database\\postgres_db\\bin\\pg_ctl.exe",
        // Command Parameters.
        "start",
        "-D C:\\namewith space\\database\\database",
        /*The quotes in the next argument are necessary, the -o stands for 'options' and everything between the quotes are the actual database parameters which to start the Database with.*/
        "-o \"-p 15000\"",
        "-l C:\\namewith space\\database\\postgres_db\\bin\\postgres_log.txt");

    File log = new File("\"C:\\folder\\log.txt\"");
    pBuilder.redirectErrorStream(true);
    pBuilder.redirectOutput(Redirect.appendTo(log));
    Process p = pBuilder.start();
    } catch (IOException ex) {
        System.out.println("Exception Occurred: " + ex);
    }

I have tried so far:

Surrounding and not surrounding each/any of the paths in the above code with escaped quotes just in case that matters (something tells me it does...).

Using the Runtime.getRuntime().exec("full command with/without any/all escaped quotes"); method, but when searching on SO I found out everyone is saying you should use the ProcessBuilder instead.

Adding parts of the above code together in different ways in the ProcessBuiler's first command String, like "\"C:\\namewith space\\database\\postgres_db\\bin\\pg_ctl.exe\" start"

The files are 100% located at the given paths, I checked this by hand and by pasting the paths in the File Explorer over 10 times.

Splitting up the command into setting the working directory of the command to C:\namewith space\ and then adding the args without that part.

The error (via the System.out.println("Exception Occurred: " + ex); ) I keep getting is: java.io.IOException: Cannot run program "C:\namewith space\database\postgres_db\bin\pg_ctl.exe": The filename, directory name, or volume label syntax is incorrect.

Please let me know if you need any extra parts/code and I will do my best to provide it in detail.


问:
Flask python app crashes on heroku
I tried pushing my code directly to Heroku for hosting but I got so many errors. Now, what I did was host the code on Github, and then link the git repo with Heroku. Now, the Heroku app was created successfully but now it does not run as it crashes with an error code of H10 and status 503. My app.py code is;

```<code>from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return "Hello World"

if __name__ == '__main__':
    app.run(debug=True)
</code>```

From Heroku

```<code>Application Logs:

2017-06-07T04:06:26.163984+00:00 heroku[web.1]: State changed from starting
to crashed
2017-06-07T04:32:14.975648+00:00 heroku[web.1]: State changed from crashed
to starting
2017-06-07T04:32:25.466677+00:00 heroku[web.1]: Starting process with
command `gunicorn malicha:app --log-file=-`
2017-06-07T04:32:27.733743+00:00 heroku[web.1]: Process exited with status
127
2017-06-07T04:32:27.646433+00:00 app[web.1]: bash: gunicorn: command not
found
2017-06-07T04:32:27.750144+00:00 heroku[web.1]: State changed from starting
to crashed
2017-06-07T05:23:25.211376+00:00 heroku[web.1]: State changed from crashed
to starting
2017-06-07T05:23:36.977579+00:00 heroku[web.1]: Starting process with
command `gunicorn malicha:app --log-file=-`
2017-06-07T05:23:39.121911+00:00 app[web.1]: bash: gunicorn: command not
found
2017-06-07T05:23:39.208060+00:00 heroku[web.1]: State changed from starting
to crashed
2017-06-07T05:23:39.193064+00:00 heroku[web.1]: Process exited with status 207
</code>```

My requirements.txt

```<code>AppInst==2.1.5
Flask==0.12.2
Jinja2==2.9.6
MarkupSafe==1.0
Pillow==4.0.0
PyYAML==3.11
Pygments==2.1.3
Werkzeug==0.12.2
appdirs==1.4.3
apptools==4.4.0
argparse==1.4.0
attrs==15.2.0
backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.4.1
bleach==1.5.0
boto==2.40.0
certifi==2017.4.17
chardet==3.0.3
click==6.7
colorama==0.3.9
colorthief==0.2.1
configobj==5.0.6
configparser==3.5.0
cycler==0.10.0
decorator==4.0.9
dlib==19.4.0
docutils==0.13.1
ecdsa==0.13
encore==0.7.0
enstaller==4.8.12
entrypoints==0.2.2
enum34==1.1.6
envisage==4.6.0
esky==0.9.8
feedparser==5.2.1
flake8==3.3.0
futures==3.0.3
gnureadline==6.3.3
gunicorn==19.7.1
hatcher==0.10.4
html5lib==0.999
humanize==0.5.1
idna==2.5
imutils==0.4.3
ipykernel==4.5.2
ipython==4.0.0
ipython-genutils==0.1.0
ipywidgets==6.0.0
itsdangerous==0.24
jedi==0.10.2
jsonify==0.5
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.0.0
jupyter-console==5.1.0
jupyter-core==4.3.0
keyring==10.3.3
lxml==3.8.0
matplotlib==2.0.2
mccabe==0.6.1
memory-profiler==0.43
mistune==0.7.4
mpmath==0.19
nbconvert==5.2.1
nbformat==4.3.0
nose==1.3.7
notebook==4.4.1
numpy==1.12.1
okonomiyaki==0.16.10
olefile==0.44
opencv-python==3.2.0.7
packaging==16.8
pandas==0.20.2
pandocfilters==1.4.1
path.py==10.3.1
pathlib2==2.2.1
pbr==3.0.1
pep8==1.7.0
pexpect==4.2.1
pickleshare==0.7.4
pip==9.0.1
plotly==2.0.9
ply==3.10
prompt-toolkit==1.0.13
psutil==5.2.2
psycopg2==2.7.1
ptyprocess==0.5.1
pyasn1==0.2.3
pycodestyle==2.3.1
pycrypto==2.6.1
pyface==5.1.0
pyflakes==1.5.0
pyglet==1.1.4
pymongo==3.4.0
pyparsing==2.2.0
python-dateutil==2.6.0
pytz==2017.2
pyzmq==16.0.2
qtconsole==4.3.0
requests==2.17.3
rsa==3.4.2
scipy==0.19.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
stevedore==1.23.0
sympy==1.0
tabulate==0.7.7
terminado==0.6
testpath==0.3.1
tornado==4.5.1
traitlets==4.3.2
traits==4.6.0
traits-enaml==0.2.1
traitsui==5.1.0
tzlocal==1.4
urllib3==1.21.1
virtualenv==15.1.0
wcwidth==0.1.7
cmake==0.7.1
</code>```

     My Procfile

```<code>    web: gunicorn malicha:app --log-file=-
</code>```

     Build Log

the section of the build log after

-----> Found requirements.txt, installing dependencies using pip
DEPRECATION: --allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.
Collecting AppInst==2.1.5 (from -r requirements.txt (line 1))
  Downloading AppInst-2.1.5.tar.gz
Collecting Flask==0.12.2 (from -r requirements.txt (line 2))
  Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
Collecting Jinja2==2.9.6 (from -r requirements.txt (line 3))
  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB)
Collecting MarkupSafe==1.0 (from -r requirements.txt (line 4))
  Downloading MarkupSafe-1.0.tar.gz
Collecting Pillow==4.0.0 (from -r requirements.txt (line 5))
  Downloading Pillow-4.0.0-cp27-cp27m-manylinux1_x86_64.whl (5.6MB)
Collecting PyYAML==3.11 (from -r requirements.txt (line 6))
  Downloading PyYAML-3.11.zip (371kB)
Collecting Pygments==2.1.3 (from -r requirements.txt (line 7))
  Downloading Pygments-2.1.3-py2.py3-none-any.whl (755kB)
Collecting Werkzeug==0.12.2 (from -r requirements.txt (line 8))
  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
Requirement already satisfied: appdirs==1.4.3 in ./.heroku/vendor/lib/python2.7/site-packages (from -r requirements.txt (line 9))
Collecting apptools==4.4.0 (from -r requirements.txt (line 10))
  Downloading apptools-4.4.0.zip (490kB)
Collecting argparse==1.4.0 (from -r requirements.txt (line 11))
  Downloading argparse-1.4.0-py2.py3-none-any.whl
Collecting attrs==15.2.0 (from -r requirements.txt (line 12))
  Downloading attrs-15.2.0-py2.py3-none-any.whl
Collecting backports-abc==0.5 (from -r requirements.txt (line 13))
  Downloading backports_abc-0.5-py2.py3-none-any.whl
Collecting backports.shutil-get-terminal-size==1.0.0 (from -r requirements.txt (line 14))
  Downloading backports.shutil_get_terminal_size-1.0.0-py2.py3-none-any.whl
Collecting beautifulsoup4==4.4.1 (from -r requirements.txt (line 15))
  Downloading beautifulsoup4-4.4.1-py2-none-any.whl (81kB)
Collecting bleach==1.5.0 (from -r requirements.txt (line 16))
  Downloading bleach-1.5.0-py2.py3-none-any.whl
Collecting boto==2.40.0 (from -r requirements.txt (line 17))
  Downloading boto-2.40.0-py2.py3-none-any.whl (1.3MB)
Collecting certifi==2017.4.17 (from -r requirements.txt (line 18))
  Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB)
Collecting chardet==3.0.3 (from -r requirements.txt (line 19))
  Downloading chardet-3.0.3-py2.py3-none-any.whl (133kB)
Collecting click==6.7 (from -r requirements.txt (line 20))
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
Collecting colorama==0.3.9 (from -r requirements.txt (line 21))
  Downloading colorama-0.3.9-py2.py3-none-any.whl
Collecting colorthief==0.2.1 (from -r requirements.txt (line 22))
  Downloading colorthief-0.2.1-py2.py3-none-any.whl
Collecting configobj==5.0.6 (from -r requirements.txt (line 23))
  Downloading configobj-5.0.6.tar.gz
Collecting configparser==3.5.0 (from -r requirements.txt (line 24))
  Downloading configparser-3.5.0.tar.gz
Collecting cycler==0.10.0 (from -r requirements.txt (line 25))
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting decorator==4.0.9 (from -r requirements.txt (line 26))
  Downloading decorator-4.0.9-py2.py3-none-any.whl
Requirement already satisfied: dlib==19.4.0 in ./.heroku/vendor/lib/python2.7/site-packages (from -r requirements.txt (line 27))
Collecting docutils==0.13.1 (from -r requirements.txt (line 28))
  Downloading docutils-0.13.1-py2-none-any.whl (537kB)
Collecting ecdsa==0.13 (from -r requirements.txt (line 29))
  Downloading ecdsa-0.13-py2.py3-none-any.whl (86kB)
Collecting encore==0.7.0 (from -r requirements.txt (line 30))
  Downloading encore-0.7.0.tar.gz (122kB)
Collecting enstaller==4.8.12 (from -r requirements.txt (line 31))
  Downloading enstaller-4.8.12.tar.gz (905kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 146, in <module>
        write_version_py()
      File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 88, in write_version_py
        raise ImportError("Unable to import git_revision. Try removing "
    ImportError: Unable to import git_revision. Try removing enstaller/_version.py and the build directory before building.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PRtgXg/enstaller/
-----> Creating environment variables.
-----> Buildpack installed.
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 176.8M
-----> Launching...
       Released v26
       https://malicha.herokuapp.com/ deployed to Heroku```
</div>
</div>
</p>

<h1>   error while building</h1>

```on inspecting the build log, I discovered an error while building :  Downloading enstaller-4.8.12.tar.gz (905kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 146, in <module>
    write_version_py()
  File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 88, in write_version_py
    raise ImportError("Unable to import git_revision. Try removing "
ImportError: Unable to import git_revision. Try removing enstaller/_version.py and the build directory before building.

----------------------------------------
```

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PRtgXg/enstaller/

答:
I solved the problem by simply editing my Procfile from </p>

```<code>web: gunicorn app:app --log-file=-
</code>```

<p>to </p>

```<code>web: gunicorn src.app:app --log-file=-
</code>```

Title: Flask python app crashes on heroku

Body:
I tried pushing my code directly to Heroku for hosting but I got so many errors. Now, what I did was host the code on Github, and then link the git repo with Heroku. Now, the Heroku app was created successfully but now it does not run as it crashes with an error code of H10 and status 503. My app.py code is;

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return "Hello World"

if __name__ == '__main__':
    app.run(debug=True)

From Heroku

Application Logs:

2017-06-07T04:06:26.163984+00:00 heroku[web.1]: State changed from starting
to crashed
2017-06-07T04:32:14.975648+00:00 heroku[web.1]: State changed from crashed
to starting
2017-06-07T04:32:25.466677+00:00 heroku[web.1]: Starting process with
command `gunicorn malicha:app --log-file=-`
2017-06-07T04:32:27.733743+00:00 heroku[web.1]: Process exited with status
127
2017-06-07T04:32:27.646433+00:00 app[web.1]: bash: gunicorn: command not
found
2017-06-07T04:32:27.750144+00:00 heroku[web.1]: State changed from starting
to crashed
2017-06-07T05:23:25.211376+00:00 heroku[web.1]: State changed from crashed
to starting
2017-06-07T05:23:36.977579+00:00 heroku[web.1]: Starting process with
command `gunicorn malicha:app --log-file=-`
2017-06-07T05:23:39.121911+00:00 app[web.1]: bash: gunicorn: command not
found
2017-06-07T05:23:39.208060+00:00 heroku[web.1]: State changed from starting
to crashed
2017-06-07T05:23:39.193064+00:00 heroku[web.1]: Process exited with status 207

My requirements.txt

AppInst==2.1.5
Flask==0.12.2
Jinja2==2.9.6
MarkupSafe==1.0
Pillow==4.0.0
PyYAML==3.11
Pygments==2.1.3
Werkzeug==0.12.2
appdirs==1.4.3
apptools==4.4.0
argparse==1.4.0
attrs==15.2.0
backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.4.1
bleach==1.5.0
boto==2.40.0
certifi==2017.4.17
chardet==3.0.3
click==6.7
colorama==0.3.9
colorthief==0.2.1
configobj==5.0.6
configparser==3.5.0
cycler==0.10.0
decorator==4.0.9
dlib==19.4.0
docutils==0.13.1
ecdsa==0.13
encore==0.7.0
enstaller==4.8.12
entrypoints==0.2.2
enum34==1.1.6
envisage==4.6.0
esky==0.9.8
feedparser==5.2.1
flake8==3.3.0
futures==3.0.3
gnureadline==6.3.3
gunicorn==19.7.1
hatcher==0.10.4
html5lib==0.999
humanize==0.5.1
idna==2.5
imutils==0.4.3
ipykernel==4.5.2
ipython==4.0.0
ipython-genutils==0.1.0
ipywidgets==6.0.0
itsdangerous==0.24
jedi==0.10.2
jsonify==0.5
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.0.0
jupyter-console==5.1.0
jupyter-core==4.3.0
keyring==10.3.3
lxml==3.8.0
matplotlib==2.0.2
mccabe==0.6.1
memory-profiler==0.43
mistune==0.7.4
mpmath==0.19
nbconvert==5.2.1
nbformat==4.3.0
nose==1.3.7
notebook==4.4.1
numpy==1.12.1
okonomiyaki==0.16.10
olefile==0.44
opencv-python==3.2.0.7
packaging==16.8
pandas==0.20.2
pandocfilters==1.4.1
path.py==10.3.1
pathlib2==2.2.1
pbr==3.0.1
pep8==1.7.0
pexpect==4.2.1
pickleshare==0.7.4
pip==9.0.1
plotly==2.0.9
ply==3.10
prompt-toolkit==1.0.13
psutil==5.2.2
psycopg2==2.7.1
ptyprocess==0.5.1
pyasn1==0.2.3
pycodestyle==2.3.1
pycrypto==2.6.1
pyface==5.1.0
pyflakes==1.5.0
pyglet==1.1.4
pymongo==3.4.0
pyparsing==2.2.0
python-dateutil==2.6.0
pytz==2017.2
pyzmq==16.0.2
qtconsole==4.3.0
requests==2.17.3
rsa==3.4.2
scipy==0.19.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
stevedore==1.23.0
sympy==1.0
tabulate==0.7.7
terminado==0.6
testpath==0.3.1
tornado==4.5.1
traitlets==4.3.2
traits==4.6.0
traits-enaml==0.2.1
traitsui==5.1.0
tzlocal==1.4
urllib3==1.21.1
virtualenv==15.1.0
wcwidth==0.1.7
cmake==0.7.1

     My Procfile

    web: gunicorn malicha:app --log-file=-

     Build Log

the section of the build log after

-----> Found requirements.txt, installing dependencies using pip
DEPRECATION: --allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.
Collecting AppInst==2.1.5 (from -r requirements.txt (line 1))
  Downloading AppInst-2.1.5.tar.gz
Collecting Flask==0.12.2 (from -r requirements.txt (line 2))
  Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
Collecting Jinja2==2.9.6 (from -r requirements.txt (line 3))
  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB)
Collecting MarkupSafe==1.0 (from -r requirements.txt (line 4))
  Downloading MarkupSafe-1.0.tar.gz
Collecting Pillow==4.0.0 (from -r requirements.txt (line 5))
  Downloading Pillow-4.0.0-cp27-cp27m-manylinux1_x86_64.whl (5.6MB)
Collecting PyYAML==3.11 (from -r requirements.txt (line 6))
  Downloading PyYAML-3.11.zip (371kB)
Collecting Pygments==2.1.3 (from -r requirements.txt (line 7))
  Downloading Pygments-2.1.3-py2.py3-none-any.whl (755kB)
Collecting Werkzeug==0.12.2 (from -r requirements.txt (line 8))
  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
Requirement already satisfied: appdirs==1.4.3 in ./.heroku/vendor/lib/python2.7/site-packages (from -r requirements.txt (line 9))
Collecting apptools==4.4.0 (from -r requirements.txt (line 10))
  Downloading apptools-4.4.0.zip (490kB)
Collecting argparse==1.4.0 (from -r requirements.txt (line 11))
  Downloading argparse-1.4.0-py2.py3-none-any.whl
Collecting attrs==15.2.0 (from -r requirements.txt (line 12))
  Downloading attrs-15.2.0-py2.py3-none-any.whl
Collecting backports-abc==0.5 (from -r requirements.txt (line 13))
  Downloading backports_abc-0.5-py2.py3-none-any.whl
Collecting backports.shutil-get-terminal-size==1.0.0 (from -r requirements.txt (line 14))
  Downloading backports.shutil_get_terminal_size-1.0.0-py2.py3-none-any.whl
Collecting beautifulsoup4==4.4.1 (from -r requirements.txt (line 15))
  Downloading beautifulsoup4-4.4.1-py2-none-any.whl (81kB)
Collecting bleach==1.5.0 (from -r requirements.txt (line 16))
  Downloading bleach-1.5.0-py2.py3-none-any.whl
Collecting boto==2.40.0 (from -r requirements.txt (line 17))
  Downloading boto-2.40.0-py2.py3-none-any.whl (1.3MB)
Collecting certifi==2017.4.17 (from -r requirements.txt (line 18))
  Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB)
Collecting chardet==3.0.3 (from -r requirements.txt (line 19))
  Downloading chardet-3.0.3-py2.py3-none-any.whl (133kB)
Collecting click==6.7 (from -r requirements.txt (line 20))
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
Collecting colorama==0.3.9 (from -r requirements.txt (line 21))
  Downloading colorama-0.3.9-py2.py3-none-any.whl
Collecting colorthief==0.2.1 (from -r requirements.txt (line 22))
  Downloading colorthief-0.2.1-py2.py3-none-any.whl
Collecting configobj==5.0.6 (from -r requirements.txt (line 23))
  Downloading configobj-5.0.6.tar.gz
Collecting configparser==3.5.0 (from -r requirements.txt (line 24))
  Downloading configparser-3.5.0.tar.gz
Collecting cycler==0.10.0 (from -r requirements.txt (line 25))
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting decorator==4.0.9 (from -r requirements.txt (line 26))
  Downloading decorator-4.0.9-py2.py3-none-any.whl
Requirement already satisfied: dlib==19.4.0 in ./.heroku/vendor/lib/python2.7/site-packages (from -r requirements.txt (line 27))
Collecting docutils==0.13.1 (from -r requirements.txt (line 28))
  Downloading docutils-0.13.1-py2-none-any.whl (537kB)
Collecting ecdsa==0.13 (from -r requirements.txt (line 29))
  Downloading ecdsa-0.13-py2.py3-none-any.whl (86kB)
Collecting encore==0.7.0 (from -r requirements.txt (line 30))
  Downloading encore-0.7.0.tar.gz (122kB)
Collecting enstaller==4.8.12 (from -r requirements.txt (line 31))
  Downloading enstaller-4.8.12.tar.gz (905kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 146, in <module>
        write_version_py()
      File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 88, in write_version_py
        raise ImportError("Unable to import git_revision. Try removing "
    ImportError: Unable to import git_revision. Try removing enstaller/_version.py and the build directory before building.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PRtgXg/enstaller/
-----> Creating environment variables.
-----> Buildpack installed.
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 176.8M
-----> Launching...
       Released v26
       https://malicha.herokuapp.com/ deployed to Heroku

   error while building

on inspecting the build log, I discovered an error while building :  Downloading enstaller-4.8.12.tar.gz (905kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 146, in <module>
    write_version_py()
  File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 88, in write_version_py
    raise ImportError("Unable to import git_revision. Try removing "
ImportError: Unable to import git_revision. Try removing enstaller/_version.py and the build directory before building.

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PRtgXg/enstaller/

Body:
I solved the problem by simply editing my Procfile from

web: gunicorn app:app --log-file=-

to

web: gunicorn src.app:app --log-file=-


问:
Multi line regex expression
I have the following file, and I'm trying to use /\|\".*\"\|/gm match multi line..end here, but the regex finds nothing using sed -e ':a;N;$!ba;s/\|\".*\"\|/abcxyz/gm' t >  t.2, I can't find out what's wrong with it.

```<code>    |2012-10-12 13:41:08.067|2012-10-12 13:45:03.282|f||"multi line star t herer erj
jdkajdkfj
   end here"|2017
</code>```

答:
To quote from the GNU sed manual:

The 'M' modifier to regular-expression matching is a GNU 'sed'
       extension which directs GNU 'sed' to match the regular expression
       in 'multi-line' mode.  The modifier causes '^' and '$' to match
       respectively (in addition to the normal behavior) the empty string
       after a newline, and the empty string before a newline.  There are
       special character sequences ('`' and '\'') which always match the
       beginning or the end of the buffer.  In addition, the period
       character does not match a new-line character in multi-line mode.

(emphasis added)

You need to add \n to match the (possibly multiple?) newlines explicitly, or else do it a different way. I'd suggest using [^\"] in place of .*, unless you know there's only one quoted field per record in the file.

Title: Multi line regex expression

Body:
I have the following file, and I'm trying to use /\|\".*\"\|/gm match multi line..end here, but the regex finds nothing using sed -e ':a;N;$!ba;s/\|\".*\"\|/abcxyz/gm' t >  t.2, I can't find out what's wrong with it.

    |2012-10-12 13:41:08.067|2012-10-12 13:45:03.282|f||"multi line star t herer erj
jdkajdkfj
   end here"|2017


问:
Implementing an integer merge sort in C#
Recently got a bubble sort algorithm functioning, and decided I would try a merge sort algorithm, I'm trying to write it from scratch as a personal challenge, I feel as though my logic is fundamentally flawed in it however, Not knowing where else to turn for advice, I welcome any input. I feel like C# doesn't like my declaration of sub-arrays, they do seem to be an improper solution also</p>

```<code>public static void MergeSort(int[] A) // WIP
    {
        if (A.Length % 2 == 0 )     //Checks if input array is even
        {
            int[] B;                //Declares sub array
            int[] C;                //Declares sub array
            for (int x = 0; x < A.Length ; x++)     //Performs an action for every item item in the array
            {
                if (x < A.Length / 2)               //selects the first half of the input array and assigns it to sub-Array B
                {
                    B[x] = A[x];
                }
                if(x > A.Length / 2)                //Selects the second half of the input array and assigns it to sub-Array C
                {
                    C[x] = A[x];

                }
            }

        }
</code>```

答:
You are getting errors because you are trying to use an unassigned variable (arrays B and C). If you need to understand how arrays work go here.
If you initialize int[B] = new int[A.Length / 2]; then your code will compile without errors.

Your code should look like this, just in order to work, I did not refactor anything, just did the minimum to make it work:

```<code> public static void MergeSort(int[] A) // WIP
        {
            if (A.Length % 2 == 0)     //Checks if input array is even
            {
                int[] B = new int[A.Length / 2];                //Declares sub array
                int[] C = new int[A.Length / 2];                //Declares sub array
                for (int x = 0; x < A.Length; x++)     //Performs an action for every item item in the array
                {
                    if (x < A.Length / 2)               //selects the first half of the input array and assigns it to sub-Array B
                    {
                        B[x] = A[x];
                    }
                    if (x > A.Length / 2)                //Selects the second half of the input array and assigns it to sub-Array C
                    {
                        C[x] = A[x];

                    }
                }

            }
        }
</code>```

Body:
Recently got a bubble sort algorithm functioning, and decided I would try a merge sort algorithm, I'm trying to write it from scratch as a personal challenge, I feel as though my logic is fundamentally flawed in it however, Not knowing where else to turn for advice, I welcome any input. I feel like C# doesn't like my declaration of sub-arrays, they do seem to be an improper solution also

public static void MergeSort(int[] A) // WIP
    {
        if (A.Length % 2 == 0 )     //Checks if input array is even
        {
            int[] B;                //Declares sub array
            int[] C;                //Declares sub array
            for (int x = 0; x < A.Length ; x++)     //Performs an action for every item item in the array
            {
                if (x  A.Length / 2)                //Selects the second half of the input array and assigns it to sub-Array C
                {
                    C[x] = A[x];

                }
            }

        }

Body:
You are getting errors because you are trying to use an unassigned variable (arrays B and C). If you need to understand how arrays work go here.
If you initialize int[B] = new int[A.Length / 2]; then your code will compile without errors.

Your code should look like this, just in order to work, I did not refactor anything, just did the minimum to make it work:

 public static void MergeSort(int[] A) // WIP
        {
            if (A.Length % 2 == 0)     //Checks if input array is even
            {
                int[] B = new int[A.Length / 2];                //Declares sub array
                int[] C = new int[A.Length / 2];                //Declares sub array
                for (int x = 0; x < A.Length; x++)     //Performs an action for every item item in the array
                {
                    if (x < A.Length / 2)               //selects the first half of the input array and assigns it to sub-Array B
                    {
                        B[x] = A[x];
                    }
                    if (x > A.Length / 2)                //Selects the second half of the input array and assigns it to sub-Array C
                    {
                        C[x] = A[x];

                    }
                }

            }
        }


问:
How can I make the bot code independent of the channel,( I want a single bot code for facebook at work and DirectLine)
My aim is to use a single bot code to run the bot at two different channels DirectLine and Facebook@work. I am going to cite an example of issues that I face when I am using facebook channel and directLine channel. The issues I have are the following:

The links or urls though supported through mark down in DirectLine are not supported in facebook, I have to make a seperate hero card.
Even if i use an url through hero card in facebook, the skype link cant be connected, bcos the link "sip:***@xxx.com", is changed to xxx alone.
I cannot get the name of the user from the "From.Name".

So what is the best possible way to resolve this? Should I simply write functions for each channels??Is that the only option.
What I want in the end is a bot code that is independent of the channel that is used for chatting

答: Use a simple switch-case for the Activity.Channel in the messagesController, then format the Activity.Text that is giving you troubles for each channel</p>


问:
LWP::Curl installation trying to connect to internet

My team is trying to install the LWP::Curl module on
an AIX server and is facing an issue.

We are using Perl v5.8.8 and are trying to install LWP::Curl v0.14.

We have successfully installed Curl v7.40 on our AIX server.

During installation of LWP::Curl it seems that the Curl.pm package is trying to connect to internet and is unable to do so. Our AIX server is not connected to internet.

Is this connection necessary?

Can we bypass this connection and still install the module?

I have posted excerpts from the log

*** Your host cannot resolve the domain name 'cpan.org', which
    probably means the Internet connections are unavailable.
==> Should we try to install the required module(s) anyway? [n] y
```

<p>if we  select ‘Y’  search the dependencies on internet ('cpan.org' )</p>

<pre class="lang-none prettyprint-override"><code>*** Installing Test::Exception...
CPAN: Storable loaded ok
Going to read /home/root/.cpan/Metadata
Warning: Found only 0 objects in /home/root/.cpan/Metadata
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
LWP failed with code[500] message[LWP::Protocol::MyFTP: Bad hostname 'ftp.perl.org']
Fetching with Net::FTP:
  ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
Issuing "/usr/bin/ftp -n"
ftp : Unknown host ftp.perl.org
Not connected.
Local directory now /home/root/.cpan/sources/authors
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz.
</code>```

答:
Our AIX server is not connected to internet.

I would have thought it was obvious that cpan cannot work without a connection to the internet. Surely you don't think all the sources of all the CPAN modules are stored on your system?

But if you want to install random Perl modules on an isolated system then you will have to do exactly that. I suggest you take a look at CPAN::Mini. If you install it on a machine that is connected to the internet and use it to build a mirroe then you can copy the mirror over to your offline system and use that to install modules

An alternative would be to download the .tar.gz package files of the modules manually (for instance from LWP-Curl-0.14) copy them over to your AIX system and install from there using the process described in perlmodinstall

But note that doing things this way removes much of the convenience of cpan, in particular you must establish any missing dependencies (perhaps using the CPAN Dependencies site) and download and install those in the same way. You will also have to be much more careful about keeping modules up to date, as all of that must be done manually too

Body:
My team is trying to install the LWP::Curl module on
an AIX server and is facing an issue.

We are using Perl v5.8.8 and are trying to install LWP::Curl v0.14.

We have successfully installed Curl v7.40 on our AIX server.

During installation of LWP::Curl it seems that the Curl.pm package is trying to connect to internet and is unable to do so. Our AIX server is not connected to internet.

Is this connection necessary?

Can we bypass this connection and still install the module?

I have posted excerpts from the log

*** Your host cannot resolve the domain name 'cpan.org', which
    probably means the Internet connections are unavailable.
==> Should we try to install the required module(s) anyway? [n] y

if we  select ‘Y’  search the dependencies on internet ('cpan.org' )

*** Installing Test::Exception...
CPAN: Storable loaded ok
Going to read /home/root/.cpan/Metadata
Warning: Found only 0 objects in /home/root/.cpan/Metadata
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
LWP failed with code[500] message[LWP::Protocol::MyFTP: Bad hostname 'ftp.perl.org']
Fetching with Net::FTP:
  ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
Issuing "/usr/bin/ftp -n"
ftp : Unknown host ftp.perl.org
Not connected.
Local directory now /home/root/.cpan/sources/authors
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz.


问:
HAProxy + WebSocket Disconnection
I am using HAProxy to send requests, on a subdomain, to a node.js app.

I am unable to get WebSockets to work. So far I have only been able to get the client to establish a WebSocket connection but then there is a disconnection which follows very soon after.

I am on ubuntu. I have been using various versions of socket.io and node-websocket-server. The client is either the latest versions of Safari or Chrome. HAProxy version is 1.4.8

Here is my HAProxy.cfg

```<code>global
    maxconn 4096
    pidfile /var/run/haproxy.pid
    daemon

defaults
    mode http

    maxconn 2000

    option http-server-close
    option http-pretend-keepalive

    contimeout      5000
    clitimeout      50000
    srvtimeout      50000

frontend HTTP_PROXY
    bind *:80

    timeout client  86400000

    #default server
    default_backend NGINX_SERVERS

    #node server
    acl host_node_sockettest hdr_beg(host) -i mysubdomain.mydomain

use_backend NODE_SOCKETTEST_SERVERS if host_node_sockettest

backend NGINX_SERVERS
server THIS_NGINX_SERVER 127.0.0.1:8081

backend NODE_SOCKETTEST_SERVERS
timeout queue   5000
timeout server  86400000

server THIS_NODE_SERVER localhost:8180 maxconn 200 check
</code>```

I've trawled the web and mailing list but can not get any of the suggested solutions to work.

(p.s. this could be for serverfault, but there are other HAProxy question on S.O, so I have chosen to post here)

答:
Try using Socket.io instead of node-websockets-server, it's an abstraction layer with fallbacks to many different methods of instant communication between browser and server.

Whilst it's true WebSockets violate HTTP 1.0, they do not violate HTTP 1.1, so you should be able to proxy them with any server capable of proxying HTTP 1.1

Title: HAProxy + WebSocket Disconnection

Body:
I am using HAProxy to send requests, on a subdomain, to a node.js app.

I am unable to get WebSockets to work. So far I have only been able to get the client to establish a WebSocket connection but then there is a disconnection which follows very soon after.

I am on ubuntu. I have been using various versions of socket.io and node-websocket-server. The client is either the latest versions of Safari or Chrome. HAProxy version is 1.4.8

Here is my HAProxy.cfg

global
    maxconn 4096
    pidfile /var/run/haproxy.pid
    daemon

defaults
    mode http

    maxconn 2000

    option http-server-close
    option http-pretend-keepalive

    contimeout      5000
    clitimeout      50000
    srvtimeout      50000

frontend HTTP_PROXY
    bind *:80

    timeout client  86400000

    #default server
    default_backend NGINX_SERVERS

    #node server
    acl host_node_sockettest hdr_beg(host) -i mysubdomain.mydomain

use_backend NODE_SOCKETTEST_SERVERS if host_node_sockettest

backend NGINX_SERVERS
server THIS_NGINX_SERVER 127.0.0.1:8081

backend NODE_SOCKETTEST_SERVERS
timeout queue   5000
timeout server  86400000

server THIS_NODE_SERVER localhost:8180 maxconn 200 check

I've trawled the web and mailing list but can not get any of the suggested solutions to work.

(p.s. this could be for serverfault, but there are other HAProxy question on S.O, so I have chosen to post here)

ContentLicense: CC BY-SA 2.5


问:
ng-model not changing on Controller
In my application I have a div where the content depends on the value of a radio. The value is initialised in my controller when I click on a button and it is supposed to reset when I click on him again. My problem is that after the value is initialised I can change it using the radio but It won't change when I call the function.

My html code:

```<code><div>
    <div ng-if="pageType=='select'">
        <label><input type="radio" ng-model="pageType" value="valueA">Value A</label>
        <label><input type="radio" ng-model="pageType" value="valueB">Value B</label>
    </div>
    <div ng-if="pageType=='valueA'">
        <div ng-controller="valueAController">
            <div ng-include="'views/valueA.html'"></div>
        </div>
    </div>
    <div ng-if="pageType=='valueB'">
        <div ng-controller="valueBController">
            <div ng-include="'views/value.html'"></div>
        </div>
    </div>
</div>
</code>```

My Controller js

```<code>$scope.resetValue= function () {
    $scope.pageType= "select";
}
</code>```

Any idea of what is generating this error or maybe a workaround for it?

答:
The ngIf is creating an isolate scope, so it now has its own version of pageType. If you nest pageType another level on the $scope object it should work.

```<code><div>
    <div ng-if="pageType=='select'">
        <label><input type="radio" ng-model="magicDot.pageType" value="valueA">Value A</label>
        <label><input type="radio" ng-model="magicDot.pageType" value="valueB">Value B</label>
    </div>
    <div ng-if="magicDot.pageType=='valueA'">
        <div ng-controller="valueAController">
            <div ng-include="'views/valueA.html'"></div>
        </div>
    </div>
    <div ng-if="magicDot.pageType=='valueB'">
        <div ng-controller="valueBController">
            <div ng-include="'views/value.html'"></div>
        </div>
    </div>
</div>
</code>```

In your controller

```<code>$scope.resetValue= function () {
    $scope.magicDot = {
      pageType: "select"
    };
}
</code>```

Title: ng-model not changing on Controller

Body:
In my application I have a div where the content depends on the value of a radio. The value is initialised in my controller when I click on a button and it is supposed to reset when I click on him again. My problem is that after the value is initialised I can change it using the radio but It won't change when I call the function.

My html code:

        <input type="radio" ng-model="pageType" value="valueA">Value A
        <input type="radio" ng-model="pageType" value="valueB">Value B

My Controller js

$scope.resetValue= function () {
    $scope.pageType= "select";
}

Any idea of what is generating this error or maybe a workaround for it?

Body:
The ngIf is creating an isolate scope, so it now has its own version of pageType. If you nest pageType another level on the $scope object it should work.

<div>
    <div ng-if="pageType=='select'">
        <label><input type="radio" ng-model="magicDot.pageType" value="valueA">Value A</label>
        <label><input type="radio" ng-model="magicDot.pageType" value="valueB">Value B</label>
    </div>
    <div ng-if="magicDot.pageType=='valueA'">
        <div ng-controller="valueAController">
            <div ng-include="'views/valueA.html'"></div>
        </div>
    </div>
    <div ng-if="magicDot.pageType=='valueB'">
        <div ng-controller="valueBController">
            <div ng-include="'views/value.html'"></div>
        </div>
    </div>
</div>

In your controller

$scope.resetValue= function () {
    $scope.magicDot = {
      pageType: "select"
    };
}


问:
Cannot read JSON in pandas
I have a nested JSON. I want it to be read in pandas in order to explore it, but I got errors. When to use read_json method, I got: "Trailing data". It is valid JSON. How to read it in pd? (Tried differently, but did not work). It looks like this:

```<code>{
"contributors": null,
"coordinates": null,
"created_at": "Fri May 26 08:54:00 +0000 2017",
"entities": {
    "hashtags": [],
    "media": [
        {
            "display_url": "pic.twitter.com/Pm28ORTePl",
            "expanded_url": "",
            "id": 868027417121751040,
            "id_str": "868027417121751040",
            "indices": [
                94,
                117
            ],
            "media_url": "",
            "sizes": {
                "large": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "medium": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "small": {
                    "h": 355,
                    "resize": "fit",
                    "w": 680
                },
                "thumb": {
                    "h": 150,
                    "resize": "crop",
                    "w": 150
                }
            },
            "type": "photo",
            "url": ""
        }
    ],
    "symbols": [],
    "urls": [
        {
            "display_url": "",
            "expanded_url": "",
            "indices": [
                70,
                93
            ],
            "url": ""
        }
    ],
    "user_mentions": []
},
"extended_entities": {
    "media": [
        {
            "display_url": "pic.twitter.com/Pm28ORTePl",
            "expanded_url": "1",
            "id": 868027417121751040,
            "id_str": "868027417121751040",
            "indices": [
                94,
                117
            ],
            "media_url": "",
            "media_url_https": "",
            "sizes": {
                "large": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "medium": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "small": {
                    "h": 355,
                    "resize": "fit",
                    "w": 680
                },
                "thumb": {
                    "h": 150,
                    "resize": "crop",
                    "w": 150
                }
            },
            "type": "photo",
            "url": ""
        }
    ]
},
"favorite_count": 1,
"favorited": false,
"geo": null,
"id": 868027425757724672,
"id_str": "868027425757724672",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "ru",
"place": null,
"possibly_sensitive": false,
"retweet_count": 0,
"retweeted": false,
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"text": "\u041f\u0440\u043e\u043f\u0430\u0432\u0448\u0430\u044f \u0432 \u041a\u043e\u043a\u0448\u0435\u0442\u0430\u0443 \u0448\u043a\u043e\u043b\u044c\u043d\u0438\u0446\u0430 \u0436\u0438\u043b\u0430 \u0432 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u043c \u0434\u043e\u043c\u0435 \u0438 \u0431\u0440\u043e\u0434\u044f\u0436\u043d\u0438\u0447\u0430\u043b\u0430\n",
"truncated": false,
"user": {
    "contributors_enabled": false,
    "created_at": "Wed May 18 11:59:50 +0000 2011",
    "default_profile": true,
    "default_profile_image": false,
    "description": "\u041a\u0430\u0437\u0430\u0445\u0441\u0442\u0430\u043d\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043f\u043e\u0440\u0442\u0430\u043b",
    "entities": {
        "description": {
            "urls": []
        },
        "url": {
            "urls": [
                {
                    "display_url": "",
                    "expanded_url": "",
                    "indices": [
                        0,
                        22
                    ],
                    "url": ""
                }
            ]
        }
    },
    "favourites_count": 87,
    "follow_request_sent": false,
    "followers_count": 17989,
    "following": true,
    "friends_count": 98,
    "geo_enabled": true,
    "has_extended_profile": false,
    "id": 300811189,
    "id_str": "300811189",
    "is_translation_enabled": false,
    "is_translator": false,
    "lang": "ru",
    "listed_count": 86,
    "location": "\u0410\u043b\u043c\u0430\u0442\u044b",
    "name": "",
    "notifications": false,
    "profile_background_color": "C0DEED",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/300811189/1489117916",
    "profile_image_url": "http://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg",
    "profile_link_color": "1DA1F2",
    "profile_sidebar_border_color": "C0DEED",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "protected": false,
    "screen_name": "",
    "statuses_count": 53011,
    "time_zone": "Quito",
    "translator_type": "none",
    "url": "",
    "utc_offset": -18000,
    "verified": false
}
</code>```

}

答:
Sorry, but your JSON is actually not valid, despite your saying it is.

This line:
"media_url": "": "",

Should probably be:
"media_url": "",

At which point, when I added the final bracket } that was outside of your code block, validated as properly formed JSON.

Title: Cannot read JSON in pandas

Body:
I have a nested JSON. I want it to be read in pandas in order to explore it, but I got errors. When to use read_json method, I got: "Trailing data". It is valid JSON. How to read it in pd? (Tried differently, but did not work). It looks like this:

{
"contributors": null,
"coordinates": null,
"created_at": "Fri May 26 08:54:00 +0000 2017",
"entities": {
    "hashtags": [],
    "media": [
        {
            "display_url": "pic.twitter.com/Pm28ORTePl",
            "expanded_url": "",
            "id": 868027417121751040,
            "id_str": "868027417121751040",
            "indices": [
                94,
                117
            ],
            "media_url": "",
            "sizes": {
                "large": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "medium": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "small": {
                    "h": 355,
                    "resize": "fit",
                    "w": 680
                },
                "thumb": {
                    "h": 150,
                    "resize": "crop",
                    "w": 150
                }
            },
            "type": "photo",
            "url": ""
        }
    ],
    "symbols": [],
    "urls": [
        {
            "display_url": "",
            "expanded_url": "",
            "indices": [
                70,
                93
            ],
            "url": ""
        }
    ],
    "user_mentions": []
},
"extended_entities": {
    "media": [
        {
            "display_url": "pic.twitter.com/Pm28ORTePl",
            "expanded_url": "1",
            "id": 868027417121751040,
            "id_str": "868027417121751040",
            "indices": [
                94,
                117
            ],
            "media_url": "",
            "media_url_https": "",
            "sizes": {
                "large": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "medium": {
                    "h": 404,
                    "resize": "fit",
                    "w": 773
                },
                "small": {
                    "h": 355,
                    "resize": "fit",
                    "w": 680
                },
                "thumb": {
                    "h": 150,
                    "resize": "crop",
                    "w": 150
                }
            },
            "type": "photo",
            "url": ""
        }
    ]
},
"favorite_count": 1,
"favorited": false,
"geo": null,
"id": 868027425757724672,
"id_str": "868027425757724672",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "ru",
"place": null,
"possibly_sensitive": false,
"retweet_count": 0,
"retweeted": false,
"source": "Twitter Web Client",
"text": "\u041f\u0440\u043e\u043f\u0430\u0432\u0448\u0430\u044f \u0432 \u041a\u043e\u043a\u0448\u0435\u0442\u0430\u0443 \u0448\u043a\u043e\u043b\u044c\u043d\u0438\u0446\u0430 \u0436\u0438\u043b\u0430 \u0432 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u043c \u0434\u043e\u043c\u0435 \u0438 \u0431\u0440\u043e\u0434\u044f\u0436\u043d\u0438\u0447\u0430\u043b\u0430\n",
"truncated": false,
"user": {
    "contributors_enabled": false,
    "created_at": "Wed May 18 11:59:50 +0000 2011",
    "default_profile": true,
    "default_profile_image": false,
    "description": "\u041a\u0430\u0437\u0430\u0445\u0441\u0442\u0430\u043d\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043f\u043e\u0440\u0442\u0430\u043b",
    "entities": {
        "description": {
            "urls": []
        },
        "url": {
            "urls": [
                {
                    "display_url": "",
                    "expanded_url": "",
                    "indices": [
                        0,
                        22
                    ],
                    "url": ""
                }
            ]
        }
    },
    "favourites_count": 87,
    "follow_request_sent": false,
    "followers_count": 17989,
    "following": true,
    "friends_count": 98,
    "geo_enabled": true,
    "has_extended_profile": false,
    "id": 300811189,
    "id_str": "300811189",
    "is_translation_enabled": false,
    "is_translator": false,
    "lang": "ru",
    "listed_count": 86,
    "location": "\u0410\u043b\u043c\u0430\u0442\u044b",
    "name": "",
    "notifications": false,
    "profile_background_color": "C0DEED",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/300811189/1489117916",
    "profile_image_url": "http://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg",
    "profile_link_color": "1DA1F2",
    "profile_sidebar_border_color": "C0DEED",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "protected": false,
    "screen_name": "",
    "statuses_count": 53011,
    "time_zone": "Quito",
    "translator_type": "none",
    "url": "",
    "utc_offset": -18000,
    "verified": false
}

}


问:
I am getting an error that "Post 404 [conversation update]" in microsoft bot ? how to resolve that?
POST 404 [conversationUpdate]
I am getting the error only when I have used web API, else working properly.</p>

答: I have faced the same issue. I resolved it by using http://localhost:3979/api/messages instead of http://127.0.0.1:3979/api/messages</p>


问:
Issue with overlapping text at column at report having predefined number of columns
I'm trying to display data column wise in jasper report to achieve the same i have created jasper report with A4 size and change the page property to 3 column vertically so it shows data vertically in 3 column.

The issue is if i have the one record then it shows correct data but if i have multiple data then it prints data on exiting data which i do not want is there any way we can force jasper to show data in parallel to each other in vertical manner instead of printing it on top of each other.

Below is the sample table which i have used for testing purpose with insert statements.

```<code> create table jasper_demo(
  no         number(2,0),
  name       varchar2(14),
  loc        varchar2(13)
 )

 insert into jasper_demo values(10, 'ACCOUNTING', 'NEW YORK');

 insert into jasper_demo values(20, 'INFLATION', 'LONDON');

 insert into jasper_demo values(30, 'GAMMA-RAYS', 'CHINA');

 insert into jasper_demo values(40, 'HEXA-RAYS', 'JAPAN');
</code>```

Query to retrieve data from db(oracle 11g)

```<code>SELECT
b.no,b.name,b.loc
FROM
(SELECT LEVEL  as lvl from dual CONNECT BY LEVEL <= 24)
 a
full outer JOIN
(  SELECT    rownum  as lvl,
      no,
      name,
      loc
     from jasper_demo
  )   b ON a.lvl = b.lvl
order by a.lvl
</code>```

Source of jasper:

```<code><?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_1" columnCount="3" pageWidth="595" pageHeight="842" columnWidth="185" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c58759d6-4d76-455f-89bd-1a9b204e0bc8">
    <queryString>
        <![CDATA[SELECT
    b.no,b.name,b.loc
FROM
    (SELECT LEVEL  as lvl from dual CONNECT BY LEVEL <= 24)
     a
full outer JOIN
    (  SELECT    rownum  as lvl,
      no,
      name,
      loc
     from jasper_demo
      )   b ON a.lvl = b.lvl
   order by a.lvl]]>
    </queryString>
    <field name="NO" class="java.math.BigDecimal"/>
    <field name="NAME" class="java.lang.String"/>
    <field name="LOC" class="java.lang.String"/>
    <group name="NO">
        <groupExpression><![CDATA[$F{NO}]]></groupExpression>
    </group>
    <group name="NAME">
        <groupExpression><![CDATA[$F{NAME}]]></groupExpression>
    </group>
    <group name="LOC">
        <groupExpression><![CDATA[$F{LOC}]]></groupExpression>
    </group>
    <detail>
        <band height="128" splitType="Stretch">
            <textField>
                <reportElement x="0" y="10" width="100" height="30" uuid="f8ac39df-75ca-44e6-aca6-eef38ff74f73">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NO}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="45" width="100" height="30" uuid="44c44cc6-c7d4-44c5-8907-af98439b2fc6">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement key="" x="0" y="80" width="100" height="30" uuid="8186d204-5448-49d5-893d-6a953f21cdf8">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="202" y="9" width="100" height="30" uuid="6fc3b438-b12d-4f43-b4b3-c040806f2ac1">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NO}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="202" y="44" width="100" height="30" uuid="31af60e9-505b-438d-9eb3-4fc8d2c9bf4c">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="202" y="79" width="100" height="30" uuid="48ffb03f-b785-42b6-b2b7-4fe087d3550e">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>
</code>```

Problem i'm facing:

答:
The design of the report is wrong.

The right "column" with three textFields are out of region of your column.

You have set this properties for report:

columnCount="3"

pageWidth="595"

columnWidth="185"

and the width the x-position of textFields from second (right) column is greater than 185.

The fix is very simple. You should set sizes and positions for textFields that all elements will be at column.

The sample of good design

Template

All elements are at region of report's column.

```<code><?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Report with 3 columns" columnCount="3" pageWidth="595" pageHeight="842" columnWidth="185" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c58759d6-4d76-455f-89bd-1a9b204e0bc8">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="users.csv"/>
    <field name="category" class="java.lang.String"/>
    <field name="user" class="java.lang.String"/>
    <field name="status" class="java.lang.String"/>
    <detail>
        <band height="128" splitType="Stretch">
            <textField>
                <reportElement x="0" y="10" width="90" height="30" uuid="f8ac39df-75ca-44e6-aca6-eef38ff74f73">
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{category}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="45" width="90" height="30" uuid="44c44cc6-c7d4-44c5-8907-af98439b2fc6">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{user}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement key="" x="0" y="80" width="90" height="30" uuid="8186d204-5448-49d5-893d-6a953f21cdf8">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="90" y="10" width="90" height="30" uuid="6fc3b438-b12d-4f43-b4b3-c040806f2ac1">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{category}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="90" y="45" width="90" height="30" uuid="31af60e9-505b-438d-9eb3-4fc8d2c9bf4c">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{user}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="90" y="80" width="90" height="30" uuid="48ffb03f-b785-42b6-b2b7-4fe087d3550e">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>
</code>```

The design at Jaspersoft Studio looks like:

Datasource

I've used simple csv datasource:

```<code>category,user,status
1,user1,WORK
1,user1,HOLIDAY
1,user2,SICK
2,user1,WORK
2,user2,WORK
2,user2,HOLIDAY
2,user3,HOLIDAY
2,user4,SICK
3,user1,HOLIDAY
3,user3,HOLIDAY
3,user5,HOLIDAY
4,user1,WORK
4,user1,HOLIDAY
4,user2,SICK
4,user2,WORK
4,user2,SICK
4,user3,HOLIDAY
4,user4,HOLIDAY
4,user5,HOLIDAY
</code>```

Output result

The output result is 3 columns per row (one column with two textFields) - 6 columns of textFields per pseudo row.

The overlapping effect is gone.

Body:
I'm trying to display data column wise in jasper report to achieve the same i have created jasper report with A4 size and change the page property to 3 column vertically so it shows data vertically in 3 column.

The issue is if i have the one record then it shows correct data but if i have multiple data then it prints data on exiting data which i do not want is there any way we can force jasper to show data in parallel to each other in vertical manner instead of printing it on top of each other.

Below is the sample table which i have used for testing purpose with insert statements.

 create table jasper_demo(
  no         number(2,0),
  name       varchar2(14),
  loc        varchar2(13)
 )

 insert into jasper_demo values(10, 'ACCOUNTING', 'NEW YORK');

 insert into jasper_demo values(20, 'INFLATION', 'LONDON');

 insert into jasper_demo values(30, 'GAMMA-RAYS', 'CHINA');

 insert into jasper_demo values(40, 'HEXA-RAYS', 'JAPAN');

Query to retrieve data from db(oracle 11g)

SELECT
b.no,b.name,b.loc
FROM
(SELECT LEVEL  as lvl from dual CONNECT BY LEVEL <= 24)
 a
full outer JOIN
(  SELECT    rownum  as lvl,
      no,
      name,
      loc
     from jasper_demo
  )   b ON a.lvl = b.lvl
order by a.lvl

Source of jasper:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_1" columnCount="3" pageWidth="595" pageHeight="842" columnWidth="185" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c58759d6-4d76-455f-89bd-1a9b204e0bc8">
    <queryString>
        <![CDATA[SELECT
    b.no,b.name,b.loc
FROM
    (SELECT LEVEL  as lvl from dual CONNECT BY LEVEL <= 24)
     a
full outer JOIN
    (  SELECT    rownum  as lvl,
      no,
      name,
      loc
     from jasper_demo
      )   b ON a.lvl = b.lvl
   order by a.lvl]]>
    </queryString>
    <field name="NO" class="java.math.BigDecimal"/>
    <field name="NAME" class="java.lang.String"/>
    <field name="LOC" class="java.lang.String"/>
    <group name="NO">
        <groupExpression><![CDATA[$F{NO}]]></groupExpression>
    </group>
    <group name="NAME">
        <groupExpression><![CDATA[$F{NAME}]]></groupExpression>
    </group>
    <group name="LOC">
        <groupExpression><![CDATA[$F{LOC}]]></groupExpression>
    </group>
    <detail>
        <band height="128" splitType="Stretch">
            <textField>
                <reportElement x="0" y="10" width="100" height="30" uuid="f8ac39df-75ca-44e6-aca6-eef38ff74f73">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NO}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="45" width="100" height="30" uuid="44c44cc6-c7d4-44c5-8907-af98439b2fc6">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement key="" x="0" y="80" width="100" height="30" uuid="8186d204-5448-49d5-893d-6a953f21cdf8">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="202" y="9" width="100" height="30" uuid="6fc3b438-b12d-4f43-b4b3-c040806f2ac1">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NO}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="202" y="44" width="100" height="30" uuid="31af60e9-505b-438d-9eb3-4fc8d2c9bf4c">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="202" y="79" width="100" height="30" uuid="48ffb03f-b785-42b6-b2b7-4fe087d3550e">
                    <printWhenExpression><![CDATA[$F{NO}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

Problem i'm facing:

Body:
The design of the report is wrong.

The right "column" with three textFields are out of region of your column.

You have set this properties for report:

columnCount="3"

pageWidth="595"

columnWidth="185"

and the width the x-position of textFields from second (right) column is greater than 185.

The fix is very simple. You should set sizes and positions for textFields that all elements will be at column.

The sample of good design

Template

All elements are at region of report's column.

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Report with 3 columns" columnCount="3" pageWidth="595" pageHeight="842" columnWidth="185" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c58759d6-4d76-455f-89bd-1a9b204e0bc8">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="users.csv"/>
    <field name="category" class="java.lang.String"/>
    <field name="user" class="java.lang.String"/>
    <field name="status" class="java.lang.String"/>
    <detail>
        <band height="128" splitType="Stretch">
            <textField>
                <reportElement x="0" y="10" width="90" height="30" uuid="f8ac39df-75ca-44e6-aca6-eef38ff74f73">
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{category}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="45" width="90" height="30" uuid="44c44cc6-c7d4-44c5-8907-af98439b2fc6">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{user}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement key="" x="0" y="80" width="90" height="30" uuid="8186d204-5448-49d5-893d-6a953f21cdf8">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="90" y="10" width="90" height="30" uuid="6fc3b438-b12d-4f43-b4b3-c040806f2ac1">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{category}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="90" y="45" width="90" height="30" uuid="31af60e9-505b-438d-9eb3-4fc8d2c9bf4c">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{user}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="90" y="80" width="90" height="30" uuid="48ffb03f-b785-42b6-b2b7-4fe087d3550e">
                    <printWhenExpression><![CDATA[$F{category}!=null]]></printWhenExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

The design at Jaspersoft Studio looks like:

Datasource

I've used simple csv datasource:

category,user,status
1,user1,WORK
1,user1,HOLIDAY
1,user2,SICK
2,user1,WORK
2,user2,WORK
2,user2,HOLIDAY
2,user3,HOLIDAY
2,user4,SICK
3,user1,HOLIDAY
3,user3,HOLIDAY
3,user5,HOLIDAY
4,user1,WORK
4,user1,HOLIDAY
4,user2,SICK
4,user2,WORK
4,user2,SICK
4,user3,HOLIDAY
4,user4,HOLIDAY
4,user5,HOLIDAY

Output result

The output result is 3 columns per row (one column with two textFields) - 6 columns of textFields per pseudo row.

The overlapping effect is gone.


问:
How to calculate total width of text including the left and right bearing
I am trying to calculate the total width of a span in HTML including both the left and right bearings of the first and last characters. I have already tried Javascript's offsetWidth and jQuery's width & outerWidth functions, but neither of them return the correct value I am seeking. Here is an example of what I mean. Running in Firefox the calculated width is 135px, while measuring with the Web Developer plug-in gives an actual width of 141px.

Edit

Here is what I've tried, and here are the values it gives me:
offsetWidth = 135
jQuery.width() = 135
jQuery.outerWidth() = 135

None of them are calculating the 6px overhang on the 'f' (which would make the width 141).

答:
Actually, I think the problem is the font itself. I changed the jsfiddle to font-family: monospace, and it was all contained within the grey box (and calculated correctly, as a result). Even leaving it as the original font, but changing the sample to "aaa" or "mmmm" worked great. It's just the "f" glyph in that font that's blowing it for you.

Unfortunately, I don't know of a DOM attribute that accounts for that. Not sure that's much of an answer, but I don't have access to comment on the question and thought these findings might help point you in the right direction...


问:
Passing data from components in Angular 2
My objective is when the user clicks a message displayed on /messages, it redirects them to /message with the messages displayed information. Please direct me in the right direction if I'm doing something wrong.

This is my error:

```<code>Unhandled Promise rejection: Template parse errors:
Can't bind to 'messages' since it isn't a known property of 'message'. ("ge-header">{{user.name}}</h2>
  <ul class="list-group" style="list-style-type: none;">
    <message [ERROR ->][messages]="message"></message>
    Inbox: <ul class="list-group" style="list-style-type: none;">
   "): MessagesComponent@3:13
'message' is not a known element:
1. If 'message' is an Angular component, then verify that it is part of this module.
2. If 'message' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("class="page-header">{{user.name}}</h2>
  <ul class="list-group" style="list-style-type: none;">
    [ERROR ->]<message [messages]="message"></message>
    Inbox: <ul class="list-group" style="list-style-type: no"): MessagesComponent@3:4 ; Zone: <root> ; Task: Promise.then ; Value:
</code>```

Messages Component:

```<code>import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../services/auth.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-messages',
  templateUrl: './messages.component.html',
  styleUrls: ['./messages.component.css']
})
export class MessagesComponent implements OnInit {
  messages: Object;
  username: String;
  user: Object;
  messageID: String;
  public UserList: Object;
  public RecpList: Object;

  constructor(private authService: AuthService,
    private router: Router
    ) { }

  ngOnInit() {
    this.authService.getProfile().subscribe(profile => {
      this.user = profile.user;
      this.username = profile.user.username;
    },
    err => {
      console.log(err);
      return false;
    });

    this.authService.getMessages(this.username).subscribe(list => {
        this.UserList = list.UserList;
        this.RecpList = list.RecpList;
    },
    err => {
      console.log(err);
      return false;
    });
  }

  onMessageClick(messageID){
    this.authService.getMessage(this.user, messageID).subscribe(list => {
      console.log(list);
      this.router.navigate(['/message', ]);
    });

  }
}
</code>```

Messages html:

```<code><div *ngIf="user">
  <h2 class="page-header">{{user.name}}</h2>
  <ul class="list-group" style="list-style-type: none;">
    <message [messages]="message"></message>
    Inbox: <ul class="list-group" style="list-style-type: none;">
      <li *ngFor="let message of RecpList" (click)="onMessageClick(message.messageID)" class="list-group" style="text-align: center;"><strong>{{message.createdBy}}</strong> {{message.subject}} <strong>{{message.dateCreated}}</strong></li>
    </ul>
    Sent: <ul class="list-group" style="list-style-type: none;">
      <li *ngFor="let message of UserList" (click)="onMessageClick(message.messageID)" class="list-group" style="text-align: center;"><strong>{{message.recipients}}</strong> {{message.subject}} <strong>{{message.dateCreated}}</strong></li>
    </ul>
  <li class="list-group"><a [routerLink] = "['/newmessage']">New Message</a></li>
  </ul>
</div>
</code>```

Message Component:

```<code>import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../services/auth.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-message',
  templateUrl: './message.component.html',
  styleUrls: ['./message.component.css'],
  inputs: ['messages']
})
export class MessageComponent implements OnInit {
messages: Object;
user: Object;
createdBy: String;
recipients: String;
subject: String;
message: String;
previousMessage: String;
nextMessage: String;

  constructor(private authService: AuthService,
    private router: Router) { }

  ngOnInit() {
    this.authService.getProfile().subscribe(profile => {
      this.user = profile.user;
    },
    err => {
      console.log(err);
      return false;
    });
  }

}
</code>```

Message html:

```<code><p>{{messages.subject}}</p>
</code>```

This is my component structure

答:
So it looks like a couple of things:

You need to include the id or message in here this.router.navigate(['/message', ]); which is looks like you may have missed adding it in there

You need to specify the path in your router like this { path: 'message/:id', component: MessageComponent }

You can retrieve what is passed in by getting it from the params using something like this:

this.message = this.route.params.subscribe(params => {
   this.id = params['id'];
});

Body:
My objective is when the user clicks a message displayed on /messages, it redirects them to /message with the messages displayed information. Please direct me in the right direction if I'm doing something wrong.

This is my error:

Unhandled Promise rejection: Template parse errors:
Can't bind to 'messages' since it isn't a known property of 'message'. ("ge-header">{{user.name}}

    <message [ERROR ->][messages]="message"></message>
    Inbox:

   "): MessagesComponent@3:13
'message' is not a known element:
1. If 'message' is an Angular component, then verify that it is part of this module.
2. If 'message' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("class="page-header">{{user.name}}

    [ERROR ->]<message [messages]="message"></message>
    Inbox: <ul class="list-group" style="list-style-type: no"): MessagesComponent@3:4 ; Zone: <root> ; Task: Promise.then ; Value:

Messages Component:

import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../services/auth.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-messages',
  templateUrl: './messages.component.html',
  styleUrls: ['./messages.component.css']
})
export class MessagesComponent implements OnInit {
  messages: Object;
  username: String;
  user: Object;
  messageID: String;
  public UserList: Object;
  public RecpList: Object;

  constructor(private authService: AuthService,
    private router: Router
    ) { }

  ngOnInit() {
    this.authService.getProfile().subscribe(profile => {
      this.user = profile.user;
      this.username = profile.user.username;
    },
    err => {
      console.log(err);
      return false;
    });

    this.authService.getMessages(this.username).subscribe(list => {
        this.UserList = list.UserList;
        this.RecpList = list.RecpList;
    },
    err => {
      console.log(err);
      return false;
    });
  }

  onMessageClick(messageID){
    this.authService.getMessage(this.user, messageID).subscribe(list => {
      console.log(list);
      this.router.navigate(['/message', ]);
    });

  }
}

Messages html:

{{user.name}}

    <message [messages]="message"></message>
    Inbox:

{{message.createdBy}} {{message.subject}} {{message.dateCreated}}

    Sent:

{{message.recipients}} {{message.subject}} {{message.dateCreated}}

New Message

Message Component:

import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../services/auth.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-message',
  templateUrl: './message.component.html',
  styleUrls: ['./message.component.css'],
  inputs: ['messages']
})
export class MessageComponent implements OnInit {
messages: Object;
user: Object;
createdBy: String;
recipients: String;
subject: String;
message: String;
previousMessage: String;
nextMessage: String;

  constructor(private authService: AuthService,
    private router: Router) { }

  ngOnInit() {
    this.authService.getProfile().subscribe(profile => {
      this.user = profile.user;
    },
    err => {
      console.log(err);
      return false;
    });
  }

}

Message html:

{{messages.subject}}

This is my component structure


问:
Check if name is valid with Proper case and Max one space
I searched for all regex exp but didn't find any matching my needs.

Regular expression to allow spaces between words

Regular expression to allow alphanumeric, max one space etc

Regex, every non-alphanumeric character except white space or colon

In none of the above did I get a solution:

I need to check that the name is valid if

=> First letter every word should be caps

=> Rest all letters of each word should be small

=> Name should have only alpha char A-Z and a-z

=> First word Length should be min 3

=> Name should not have more than one space between words

Ex :

sujay       => false

Sujay       => true

Sujay u     => false

Sujay U     => true

Sujay U n   => false

Sujay U N   => true

SuJay U     => false

Sujay UN    => false

Sujay Uls   => true

Sujay9      => false

Su          => false

Su U        => false

Sujay U N   => true

Sujay Uls Nat=> true

|*| Check function used :

```<code>static boolean chkNamVldFnc(String namVar)
{
    String namRegExpVar = "[A-Z][A-Za-z ]{2,}";

    Pattern pVar = Pattern.compile(namRegExpVar);
    Matcher mVar = pVar.matcher(namVar);
    return mVar.matches();
}
</code>```

|*| Try 1 :

```<code>String namRegExpVar = "[A-Z][A-Za-z ]{2,}";
</code>```

|*| Try 2 :

```<code>String namRegExpVar = "[A-Z][a-z]{2,}+//s[A-Z][a-z]{2,}";
</code>```

|*| Try 3 :

```<code>String NamRegExpVar = "[A-Z][a-z]{2,}||[A-Z][a-z]{2,}+//s[A-Z][a-z]";
</code>```

Kindly help me with Proper Regular Exp :

I also want to know why we should start Reg Exp with ^ and end with $

答:
Try:

```<code>^[A-Z][a-z]{2,}(?: [A-Z][a-z]*)*$
</code>```

First name must start with letter A-Z, followed by at least 2 letters a-z

Optionally, there can be names following the first name, seperated by a space and beginning with letter A-Z, and followed by optional letters a-z

ContentLicense: CC BY-SA 4.0

Body:
I searched for all regex exp but didn't find any matching my needs.

Regular expression to allow spaces between words

Regular expression to allow alphanumeric, max one space etc

Regex, every non-alphanumeric character except white space or colon

In none of the above did I get a solution:

I need to check that the name is valid if

=> First letter every word should be caps

=> Rest all letters of each word should be small

=> Name should have only alpha char A-Z and a-z

=> First word Length should be min 3

=> Name should not have more than one space between words

Ex :

sujay       => false

Sujay       => true

Sujay u     => false

Sujay U     => true

Sujay U n   => false

Sujay U N   => true

SuJay U     => false

Sujay UN    => false

Sujay Uls   => true

Sujay9      => false

Su          => false

Su U        => false

Sujay U N   => true

Sujay Uls Nat=> true

|*| Check function used :

static boolean chkNamVldFnc(String namVar)
{
    String namRegExpVar = "[A-Z][A-Za-z ]{2,}";

    Pattern pVar = Pattern.compile(namRegExpVar);
    Matcher mVar = pVar.matcher(namVar);
    return mVar.matches();
}

|*| Try 1 :

String namRegExpVar = "[A-Z][A-Za-z ]{2,}";

|*| Try 2 :

String namRegExpVar = "[A-Z][a-z]{2,}+//s[A-Z][a-z]{2,}";

|*| Try 3 :

String NamRegExpVar = "[A-Z][a-z]{2,}||[A-Z][a-z]{2,}+//s[A-Z][a-z]";

Kindly help me with Proper Regular Exp :

I also want to know why we should start Reg Exp with ^ and end with $

Body:
Try:

^[A-Z][a-z]{2,}(?: [A-Z][a-z]*)*$

First name must start with letter A-Z, followed by at least 2 letters a-z

Optionally, there can be names following the first name, seperated by a space and beginning with letter A-Z, and followed by optional letters a-z


问:
C++ all prime numbers function not working
So i am really new at programming, i was messing around and decided to try coding a Prime generator. The idea is the user inputs the maximum number the computer should check for a prime, and it outputs a text file with all the primes till there.
So i've written this piece of code.

```<code>#include <iostream>
#include <string>
#include <Windows.h>
#include <fstream>

using namespace std;
int isPrime(int num) {
    for (int a = 1; a <= num/2; a++)
        if (num % a == 0)
            return 0;
    return 1;
}

int main() {
    ofstream out_data("primes.txt");
    std::string name;
    int quantity;
    int maximum = 1000000;
    std::cout << "What is your name ?\n";
    getline(std::cin, name);
    std::cout << "What is the biggest number you want to get as a prime " << name << "? Please note that the maximum is " << maximum <<" \n";
    std::cin >> quantity;
    if (quantity <= maximum) {
        for (int b = 1; b < quantity; b++) {
            if (isPrime(b) == 1) {
                std::cout << b << "\n";
                out_data << b << "\n";
            }
        }
        std::cout << "The computer has finished calculating primes. Please check your folder for a .txt file.";
        Sleep(60000);
    }
    if (quantity > maximum) {
        std::cout << "Oh, i'm sorry. The computer can not calculate till " << quantity << ".";
        Sleep(15000);
    }
    return 0;
}
</code>```

The file and the console shows just the number 1. I spent some time trying to find out what's wrong with the code and got nowhere. In my mind the for loop would repeat itself and the if statement until b

答: You should start your loop in isPrime from 2 instead of 1. Every integer equals 0 mod 1.

Body:
So i am really new at programming, i was messing around and decided to try coding a Prime generator. The idea is the user inputs the maximum number the computer should check for a prime, and it outputs a text file with all the primes till there.
So i've written this piece of code.

#include <iostream>
#include <string>
#include <Windows.h>
#include <fstream>

using namespace std;
int isPrime(int num) {
    for (int a = 1; a <= num/2; a++)
        if (num % a == 0)
            return 0;
    return 1;
}

int main() {
    ofstream out_data("primes.txt");
    std::string name;
    int quantity;
    int maximum = 1000000;
    std::cout << "What is your name ?\n";
    getline(std::cin, name);
    std::cout << "What is the biggest number you want to get as a prime " << name << "? Please note that the maximum is " << maximum <<" \n";
    std::cin >> quantity;
    if (quantity <= maximum) {
        for (int b = 1; b < quantity; b++) {
            if (isPrime(b) == 1) {
                std::cout << b << "\n";
                out_data << b << "\n";
            }
        }
        std::cout << "The computer has finished calculating primes. Please check your folder for a .txt file.";
        Sleep(60000);
    }
    if (quantity > maximum) {
        std::cout << "Oh, i'm sorry. The computer can not calculate till " << quantity << ".";
        Sleep(15000);
    }
    return 0;
}

The file and the console shows just the number 1. I spent some time trying to find out what's wrong with the code and got nowhere. In my mind the for loop would repeat itself and the if statement until b