问:
500 error in Jupyterhub
I configed the jupyterhub as the official site given,

```<code>c.JupyterHub.hub_ip = '0.0.0.0'
c.JupyterHub.hub_port = 8888
c.PAMAuthenticator.encoding = 'utf8'
c.LocalAuthenticator.create_system_users = True
c.Authenticator.admin_users = {'arvin'}
c.Spawner.cmd=['jupyterhub-singleuser']
c.JupyterHub.ssl_cert = '/mycert'
c.JupyterHub.ssl_key = '/mykey'
</code>```

and when I entered the users' page(logged in) and I get this:

```<code>500 : Internal Server Error
Failed to reach your server. Please try again later. Contact admin if the issue persists.
You can try restarting your server from the home page.
</code>```

Could anyone give me some solution?
I've tried some but they're seems not woking.

These are my logs.

```<code>arvin@arvin-Linux-PC:/etc/jupyter$ sudo jupyterhub -f jupyterhub_config.py
[sudo] password for arvin:
[I 2017-12-02 15:43:53.892 JupyterHub app:834] Loading cookie_secret from /etc/jupyter/jupyterhub_cookie_secret
[I 2017-12-02 15:43:53.921 JupyterHub app:983] Not using whitelist. Any authenticated user will be allowed.
[I 2017-12-02 15:43:53.934 JupyterHub app:1528] Hub API listening on http://*:8080/hub/
[W 2017-12-02 15:43:53.935 JupyterHub proxy:415]
    Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.
    Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.

[I 2017-12-02 15:43:53.935 JupyterHub proxy:458] Starting proxy @ https://0.0.0.0:8888/
15:43:54.044 - info: [ConfigProxy] Proxying https://0.0.0.0:8888 to (no default)
15:43:54.047 - info: [ConfigProxy] Proxy API at http://127.0.0.1:8001/api/routes
15:43:54.052 - error: [ConfigProxy] Uncaught Exception Error: listen EADDRINUSE 0.0.0.0:8888
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at Server._listen2 (net.js:1237:14)
    at listen (net.js:1273:10)
    at net.js:1382:9
    at nextTickCallbackWith3Args (node.js:452:9)
    at process._tickCallback (node.js:358:17)
    at Function.Module.runMain (module.js:444:11)
    at startup (node.js:136:18)
    at node.js:966:3
[W 2017-12-02 15:43:54.132 JupyterHub proxy:304] Adding missing default route
15:43:54.132 - info: [ConfigProxy] 200 GET /api/routes
[I 2017-12-02 15:43:54.132 JupyterHub proxy:370] Adding default route for Hub: / => http://*:8080
15:43:54.176 - info: [ConfigProxy] Adding route / -> http://*:8080
15:43:54.178 - info: [ConfigProxy] 201 POST /api/routes/
[I 2017-12-02 15:43:54.178 JupyterHub app:1581] JupyterHub is now running at https://0.0.0.0:8888/
[W 2017-12-02 15:44:05.453 JupyterHub base:202] Invalid or expired cookie token
[W 2017-12-02 15:44:05.455 JupyterHub base:202] Invalid or expired cookie token
[I 2017-12-02 15:44:05.455 JupyterHub log:122] 302 GET /hub/user/arvin/ → /hub/login?next=%2Fhub%2Fuser%2Farvin%2F (@192.168.1.106) 3.19ms
[I 2017-12-02 15:44:05.517 JupyterHub log:122] 200 GET /hub/login?next=%2Fhub%2Fuser%2Farvin%2F (@192.168.1.106) 33.93ms
[I 2017-12-02 15:44:11.466 JupyterHub base:346] User logged in: arvin
Last login: Sat Dec  2 15:42:25 CST 2017
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

12 packages can be updated.
9 updates are security updates.

[I 2017-12-02 15:44:11.766 JupyterHub spawner:978] Spawning jupyterhub-singleuser --port=41813 '--notebook-dir="~/"'
[W 2017-12-02 15:44:11.996 SingleUserNotebookApp configurable:168] Config option `open_browser` not recognized by `SingleUserNotebookApp`.  Did you mean `browser`?
[I 2017-12-02 15:44:12.337 SingleUserNotebookApp singleuser:365] Starting jupyterhub-singleuser server version 0.8.1
[I 2017-12-02 15:44:12.340 JupyterHub log:122] 200 GET /hub/api (@::1) 0.74ms
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] Serving notebooks from local directory: /home/arvin
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] 0 active kernels
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] The Jupyter Notebook is running at:
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] https://[all ip addresses on your system]:41813/user/arvin/
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1446] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 2017-12-02 15:44:12.444 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52568): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:13.393 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52636): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:14.074 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52688): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:16.292 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52838): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:16.326 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52844): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:21.332 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 53182): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:21.829 JupyterHub base:500] User arvin is slow to become responsive (timeout=10)
[I 2017-12-02 15:44:21.830 JupyterHub log:122] 302 POST /hub/login?next=%2Fhub%2Fuser%2Farvin%2F → /hub/user/arvin/ (@192.168.1.106) 10378.18ms
[W 2017-12-02 15:44:26.336 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 53520): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:31.340 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 53862): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[I 2017-12-02 15:44:31.910 JupyterHub base:722] Pending spawn for arvin didn't finish in 10.0 seconds
[I 2017-12-02 15:44:31.910 JupyterHub base:727] arvin is pending spawn
[I 2017-12-02 15:44:31.914 JupyterHub log:122] 200 GET /hub/user/arvin/ (arvin@192.168.1.106) 10012.39ms
[W 2017-12-02 15:44:36.344 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 54196): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:41.352 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 54530): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:43.471 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 54670): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:43.471 JupyterHub user:458] arvin's server never showed up at http://127.0.0.1:41813/user/arvin/ after 30 seconds. Giving up
[I 2017-12-02 15:44:43.472 SingleUserNotebookApp notebookapp:1382] Shutting down 0 kernels
[E 2017-12-02 15:44:43.901 JupyterHub gen:914] Exception in Future <tornado.concurrent.Future object at 0x7faef8a44908> after timeout
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/tornado/gen.py", line 910, in error_callback
        future.result()
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 445, in finish_user_spawn
        yield spawn_future
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 476, in spawn
        raise e
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 450, in spawn
        resp = yield server.wait_up(http=True, timeout=spawner.http_timeout)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 180, in wait_for_http_server
        timeout=timeout
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 135, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Server at http://127.0.0.1:41813/user/arvin/ didn't respond in 30 seconds

[E 2017-12-02 15:44:43.902 JupyterHub gen:914] Exception in Future <tornado.concurrent.Future object at 0x7faef8a44908> after timeout
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/tornado/gen.py", line 910, in error_callback
        future.result()
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 445, in finish_user_spawn
        yield spawn_future
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 476, in spawn
        raise e
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 450, in spawn
        resp = yield server.wait_up(http=True, timeout=spawner.http_timeout)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 180, in wait_for_http_server
        timeout=timeout
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 135, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Server at http://127.0.0.1:41813/user/arvin/ didn't respond in 30 seconds

[E 2017-12-02 15:44:43.903 JupyterHub web:1590] Uncaught exception GET /hub/user/arvin/ (192.168.1.106)
    HTTPServerRequest(protocol='http', host='192.168.1.119:8080', method='GET', uri='/hub/user/arvin/', version='HTTP/1.1', remote_ip='192.168.1.106', headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36', 'If-None-Match': '"5fdb62c9031609084027381f99480f6927c4813f"', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', 'Accept-Encoding': 'gzip, deflate', 'Cache-Control': 'max-age=0', 'Dnt': '1', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'Host': '192.168.1.119:8080', 'Referer': 'http://192.168.1.119:8080/hub/user/arvin/', 'Cookie': 'jupyter-hub-token="2|1:0|10:1512200651|17:jupyter-hub-token|44:ZTRmNGY0OGY0Y2RiNDYzZmJjNjc4YzlhZTA2NTFiYjI=|f6535cb1c54e41b6a43f4e438059b10feee0198ae1e77ec8d0fe90fe6a51c26d"', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1'})
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/tornado/web.py", line 1511, in _execute
        result = yield result
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 720, in get
        yield gen.with_timeout(timedelta(seconds=self.slow_spawn_timeout), spawner._spawn_future)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 445, in finish_user_spawn
        yield spawn_future
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 476, in spawn
        raise e
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 450, in spawn
        resp = yield server.wait_up(http=True, timeout=spawner.http_timeout)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 180, in wait_for_http_server
        timeout=timeout
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 135, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Server at http://127.0.0.1:41813/user/arvin/ didn't respond in 30 seconds

[E 2017-12-02 15:44:43.912 JupyterHub log:114] {
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
      "If-None-Match": "\"5fdb62c9031609084027381f99480f6927c4813f\"",
      "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
      "Accept-Encoding": "gzip, deflate",
      "Cache-Control": "max-age=0",
      "Dnt": "1",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
      "Host": "192.168.1.119:8080",
      "Referer": "http://192.168.1.119:8080/hub/user/arvin/",
      "Cookie": "jupyter-hub-token=\"2|1:0|10:1512200651|17:jupyter-hub-token|44:ZTRmNGY0OGY0Y2RiNDYzZmJjNjc4YzlhZTA2NTFiYjI=|f6535cb1c54e41b6a43f4e438059b10feee0198ae1e77ec8d0fe90fe6a51c26d\"",
      "Connection": "keep-alive",
      "Upgrade-Insecure-Requests": "1"
    }
[E 2017-12-02 15:44:43.912 JupyterHub log:122] 500 GET /hub/user/arvin/ (arvin@192.168.1.106) 6508.46ms
</code>```

I've noticed that there are some problem that the spawner may not be reached but I have really no idea about what to do even I've read the official docs.

答:
If you have a notebook in use before your hub installation and there exists a folder ~/.jupyter/. When you start the hub program and start the single-user notebook, it reads the configurations there and causes some problems so that the hub can never reach the single spawner till timesout.

I think this is a BUG which just conflicts with the notebook configuration ~/.jupyter.

As soon as you will move $HOME/.jupyter away, everything will work fine.

Title: 500 error in Jupyterhub

Body:
I configed the jupyterhub as the official site given,

c.JupyterHub.hub_ip = '0.0.0.0'
c.JupyterHub.hub_port = 8888
c.PAMAuthenticator.encoding = 'utf8'
c.LocalAuthenticator.create_system_users = True
c.Authenticator.admin_users = {'arvin'}
c.Spawner.cmd=['jupyterhub-singleuser']
c.JupyterHub.ssl_cert = '/mycert'
c.JupyterHub.ssl_key = '/mykey'

and when I entered the users' page(logged in) and I get this:

500 : Internal Server Error
Failed to reach your server. Please try again later. Contact admin if the issue persists.
You can try restarting your server from the home page.

Could anyone give me some solution?
I've tried some but they're seems not woking.

These are my logs.

arvin@arvin-Linux-PC:/etc/jupyter$ sudo jupyterhub -f jupyterhub_config.py
[sudo] password for arvin:
[I 2017-12-02 15:43:53.892 JupyterHub app:834] Loading cookie_secret from /etc/jupyter/jupyterhub_cookie_secret
[I 2017-12-02 15:43:53.921 JupyterHub app:983] Not using whitelist. Any authenticated user will be allowed.
[I 2017-12-02 15:43:53.934 JupyterHub app:1528] Hub API listening on http://*:8080/hub/
[W 2017-12-02 15:43:53.935 JupyterHub proxy:415]
    Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.
    Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.

[I 2017-12-02 15:43:53.935 JupyterHub proxy:458] Starting proxy @ https://0.0.0.0:8888/
15:43:54.044 - info: [ConfigProxy] Proxying https://0.0.0.0:8888 to (no default)
15:43:54.047 - info: [ConfigProxy] Proxy API at http://127.0.0.1:8001/api/routes
15:43:54.052 - error: [ConfigProxy] Uncaught Exception Error: listen EADDRINUSE 0.0.0.0:8888
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at Server._listen2 (net.js:1237:14)
    at listen (net.js:1273:10)
    at net.js:1382:9
    at nextTickCallbackWith3Args (node.js:452:9)
    at process._tickCallback (node.js:358:17)
    at Function.Module.runMain (module.js:444:11)
    at startup (node.js:136:18)
    at node.js:966:3
[W 2017-12-02 15:43:54.132 JupyterHub proxy:304] Adding missing default route
15:43:54.132 - info: [ConfigProxy] 200 GET /api/routes
[I 2017-12-02 15:43:54.132 JupyterHub proxy:370] Adding default route for Hub: / => http://*:8080
15:43:54.176 - info: [ConfigProxy] Adding route / -> http://*:8080
15:43:54.178 - info: [ConfigProxy] 201 POST /api/routes/
[I 2017-12-02 15:43:54.178 JupyterHub app:1581] JupyterHub is now running at https://0.0.0.0:8888/
[W 2017-12-02 15:44:05.453 JupyterHub base:202] Invalid or expired cookie token
[W 2017-12-02 15:44:05.455 JupyterHub base:202] Invalid or expired cookie token
[I 2017-12-02 15:44:05.455 JupyterHub log:122] 302 GET /hub/user/arvin/ → /hub/login?next=%2Fhub%2Fuser%2Farvin%2F (@192.168.1.106) 3.19ms
[I 2017-12-02 15:44:05.517 JupyterHub log:122] 200 GET /hub/login?next=%2Fhub%2Fuser%2Farvin%2F (@192.168.1.106) 33.93ms
[I 2017-12-02 15:44:11.466 JupyterHub base:346] User logged in: arvin
Last login: Sat Dec  2 15:42:25 CST 2017
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

12 packages can be updated.
9 updates are security updates.

[I 2017-12-02 15:44:11.766 JupyterHub spawner:978] Spawning jupyterhub-singleuser --port=41813 '--notebook-dir="~/"'
[W 2017-12-02 15:44:11.996 SingleUserNotebookApp configurable:168] Config option `open_browser` not recognized by `SingleUserNotebookApp`.  Did you mean `browser`?
[I 2017-12-02 15:44:12.337 SingleUserNotebookApp singleuser:365] Starting jupyterhub-singleuser server version 0.8.1
[I 2017-12-02 15:44:12.340 JupyterHub log:122] 200 GET /hub/api (@::1) 0.74ms
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] Serving notebooks from local directory: /home/arvin
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] 0 active kernels
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] The Jupyter Notebook is running at:
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1445] https://[all ip addresses on your system]:41813/user/arvin/
[I 2017-12-02 15:44:12.341 SingleUserNotebookApp notebookapp:1446] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 2017-12-02 15:44:12.444 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52568): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:13.393 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52636): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:14.074 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52688): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:16.292 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52838): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:16.326 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 52844): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:21.332 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 53182): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:21.829 JupyterHub base:500] User arvin is slow to become responsive (timeout=10)
[I 2017-12-02 15:44:21.830 JupyterHub log:122] 302 POST /hub/login?next=%2Fhub%2Fuser%2Farvin%2F → /hub/user/arvin/ (@192.168.1.106) 10378.18ms
[W 2017-12-02 15:44:26.336 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 53520): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:31.340 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 53862): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[I 2017-12-02 15:44:31.910 JupyterHub base:722] Pending spawn for arvin didn't finish in 10.0 seconds
[I 2017-12-02 15:44:31.910 JupyterHub base:727] arvin is pending spawn
[I 2017-12-02 15:44:31.914 JupyterHub log:122] 200 GET /hub/user/arvin/ (arvin@192.168.1.106) 10012.39ms
[W 2017-12-02 15:44:36.344 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 54196): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:41.352 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 54530): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:43.471 SingleUserNotebookApp iostream:1327] SSL Error on 8 ('127.0.0.1', 54670): [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:645)
[W 2017-12-02 15:44:43.471 JupyterHub user:458] arvin's server never showed up at http://127.0.0.1:41813/user/arvin/ after 30 seconds. Giving up
[I 2017-12-02 15:44:43.472 SingleUserNotebookApp notebookapp:1382] Shutting down 0 kernels
[E 2017-12-02 15:44:43.901 JupyterHub gen:914] Exception in Future <tornado.concurrent.Future object at 0x7faef8a44908> after timeout
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/tornado/gen.py", line 910, in error_callback
        future.result()
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 445, in finish_user_spawn
        yield spawn_future
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 476, in spawn
        raise e
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 450, in spawn
        resp = yield server.wait_up(http=True, timeout=spawner.http_timeout)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 180, in wait_for_http_server
        timeout=timeout
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 135, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Server at http://127.0.0.1:41813/user/arvin/ didn't respond in 30 seconds

[E 2017-12-02 15:44:43.902 JupyterHub gen:914] Exception in Future <tornado.concurrent.Future object at 0x7faef8a44908> after timeout
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/tornado/gen.py", line 910, in error_callback
        future.result()
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 445, in finish_user_spawn
        yield spawn_future
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 476, in spawn
        raise e
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 450, in spawn
        resp = yield server.wait_up(http=True, timeout=spawner.http_timeout)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 180, in wait_for_http_server
        timeout=timeout
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 135, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Server at http://127.0.0.1:41813/user/arvin/ didn't respond in 30 seconds

[E 2017-12-02 15:44:43.903 JupyterHub web:1590] Uncaught exception GET /hub/user/arvin/ (192.168.1.106)
    HTTPServerRequest(protocol='http', host='192.168.1.119:8080', method='GET', uri='/hub/user/arvin/', version='HTTP/1.1', remote_ip='192.168.1.106', headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36', 'If-None-Match': '"5fdb62c9031609084027381f99480f6927c4813f"', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', 'Accept-Encoding': 'gzip, deflate', 'Cache-Control': 'max-age=0', 'Dnt': '1', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'Host': '192.168.1.119:8080', 'Referer': 'http://192.168.1.119:8080/hub/user/arvin/', 'Cookie': 'jupyter-hub-token="2|1:0|10:1512200651|17:jupyter-hub-token|44:ZTRmNGY0OGY0Y2RiNDYzZmJjNjc4YzlhZTA2NTFiYjI=|f6535cb1c54e41b6a43f4e438059b10feee0198ae1e77ec8d0fe90fe6a51c26d"', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1'})
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/tornado/web.py", line 1511, in _execute
        result = yield result
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 720, in get
        yield gen.with_timeout(timedelta(seconds=self.slow_spawn_timeout), spawner._spawn_future)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/handlers/base.py", line 445, in finish_user_spawn
        yield spawn_future
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 476, in spawn
        raise e
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/user.py", line 450, in spawn
        resp = yield server.wait_up(http=True, timeout=spawner.http_timeout)
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 180, in wait_for_http_server
        timeout=timeout
      File "/usr/local/lib/python3.5/dist-packages/jupyterhub/utils.py", line 135, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Server at http://127.0.0.1:41813/user/arvin/ didn't respond in 30 seconds

[E 2017-12-02 15:44:43.912 JupyterHub log:114] {
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
      "If-None-Match": "\"5fdb62c9031609084027381f99480f6927c4813f\"",
      "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
      "Accept-Encoding": "gzip, deflate",
      "Cache-Control": "max-age=0",
      "Dnt": "1",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
      "Host": "192.168.1.119:8080",
      "Referer": "http://192.168.1.119:8080/hub/user/arvin/",
      "Cookie": "jupyter-hub-token=\"2|1:0|10:1512200651|17:jupyter-hub-token|44:ZTRmNGY0OGY0Y2RiNDYzZmJjNjc4YzlhZTA2NTFiYjI=|f6535cb1c54e41b6a43f4e438059b10feee0198ae1e77ec8d0fe90fe6a51c26d\"",
      "Connection": "keep-alive",
      "Upgrade-Insecure-Requests": "1"
    }
[E 2017-12-02 15:44:43.912 JupyterHub log:122] 500 GET /hub/user/arvin/ (arvin@192.168.1.106) 6508.46ms

I've noticed that there are some problem that the spawner may not be reached but I have really no idea about what to do even I've read the official docs.


来源: stackexchange

问:
Ignite cluster with mixed persistent/non-persistent cache nodes
In my Apache Ignite 2.3 cluster I want to run one node (probably two in the future for a backup) that has my replicated cache persistent on disk. I need to make sure this node is always up while other cache nodes don't have the persistent configuration and therefore access the cache only in memory. These non-persistent nodes can come and go frequently on demand as they are for computing but not for storing data.

When a non-persistent node is connected, what happens when the persistent node goes down? Ideally the cache should go away for the whole cluster but it doesn't. All nodes continue using the cache in memory it seems. But this means the new data will never be on disk and gone after cluster restart.
Is my configuration with mixed persistent/non-persistent nodes not common? How would I keep this type of cluster consistant?

Any background help appreciated.

答:
You can set node filter for you cache configuration and exclude compute nodes:

https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/CacheConfiguration.html#setNodeFilter(org.apache.ignite.lang.IgnitePredicate)

so the cache will be stored only on the particular set of nodes that you defined.

To distinct ignite instances, you can use user attributes in ignite configurations:
https://apacheignite.readme.io/docs/cluster#section-cluster-node-attributes

ContentLicense: CC BY-SA 3.0


问:
Filter results after date SQL Server
I need to filter my query to extract the results between 25th of the previous month and 25th of the current month. The SP receives a date as parameter, which I am using to extract the current month.I tried to make some casting but I can't figure how to deal with the January month when the last month has a different year(there must be a more efficient way also)</p>

```<code>@Date smalldatetime --received as parameter
select *
from mytable
where mytable.mydate between '25/'+cast(MONTH(@date)-1 as varchar(2))+'/'+cast(YEAR(@date) as varchar(4)) and '25/'+cast(MONTH(@date) as varchar(2))+'/'+cast(YEAR(@date) as varchar(4))
</code>```

答:
You don't need to do any casting. SQL Server's datetime functions are quite versatile. Try this:</p>

```<code>SELECT    *
FROM       mytable
WHERE    mytable.mydate BETWEEN DATEADD(DAY, 25, DATEADD(MONTH, DATEDIFF(MONTH, 0, @Date) - 1, 0)) AND DATEADD(DAY, 25, DATEADD(MONTH, DATEDIFF(MONTH, 0, @Date), 0))
</code>```

Title: Filter results after date SQL Server

Body:
I need to filter my query to extract the results between 25th of the previous month and 25th of the current month. The SP receives a date as parameter, which I am using to extract the current month.I tried to make some casting but I can't figure how to deal with the January month when the last month has a different year(there must be a more efficient way also)

@Date smalldatetime --received as parameter
select *
from mytable
where mytable.mydate between '25/'+cast(MONTH(@date)-1 as varchar(2))+'/'+cast(YEAR(@date) as varchar(4)) and '25/'+cast(MONTH(@date) as varchar(2))+'/'+cast(YEAR(@date) as varchar(4))

Body:
You don't need to do any casting. SQL Server's datetime functions are quite versatile. Try this:

SELECT    *
FROM       mytable
WHERE    mytable.mydate BETWEEN DATEADD(DAY, 25, DATEADD(MONTH, DATEDIFF(MONTH, 0, @Date) - 1, 0)) AND DATEADD(DAY, 25, DATEADD(MONTH, DATEDIFF(MONTH, 0, @Date), 0))


问:
Generating Multiple Typescript Files with NSwag
I've just started looking into using NSwag to auto-generate typescript clients for a WebAPI project.  I've naively started with this simple build step:

```<code>nswag webapi2swagger /assembly:bin\MyProject.WebAPI.dll /output:Swagger.json
nswag swagger2tsclient /input:Swagger.json /output:WebAPIs.ts
</code>```

This works great...  maybe too great.  I've now got a 17000 line typescript file full of clients for every endpoint in the API.

I know I could specify individual classes or controllers for nswag to generate, but I'd like it to be automatic for new controllers as we continue to build the system.  Ideally, I'd probably be best served with a set of typescript files where each file represented a single controller.

Does anyone know how I might use the command line tools to break up the output that way?

答: I don't think this is possible with the current CLI tools, so I wrote a small console application which uses reflection to gather controllers from the webapi assembly, then calls the WebApiToSwaggerGenerator and SwaggerToTypeScriptClientGenerator for each controller individually. </p>

Body:
I've just started looking into using NSwag to auto-generate typescript clients for a WebAPI project.  I've naively started with this simple build step:

nswag webapi2swagger /assembly:bin\MyProject.WebAPI.dll /output:Swagger.json
nswag swagger2tsclient /input:Swagger.json /output:WebAPIs.ts

This works great...  maybe too great.  I've now got a 17000 line typescript file full of clients for every endpoint in the API.

I know I could specify individual classes or controllers for nswag to generate, but I'd like it to be automatic for new controllers as we continue to build the system.  Ideally, I'd probably be best served with a set of typescript files where each file represented a single controller.

Does anyone know how I might use the command line tools to break up the output that way?


问:
Python: Removing a specific item that has a duplicate only knowing its index in a list
What I want this program to do is to delete all the 1's that are in the list that follow by index all the 2's.

This is the code:

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

I really put this program into the basics but the point is that I have only got the index of the 1 that follows the 2, tho when I do this the result is:

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

This means that it doesn't delete the 1 I want but just the first 1 it finds. Tho this is really a problem in a real program situation where the first 1 is an important value.

How can I fix it? Thanks

答:
Using list comprehension with enumerate(a) and index(2)

```<code>[j for i,j in enumerate(a) if not (i>a.index(2) and j==1)]
#[3, 1, 2]
</code>```

Body:
What I want this program to do is to delete all the 1's that are in the list that follow by index all the 2's.

This is the code:

a = [3, 1, 2, 1]
a.remove(a[3])
print(a)

I really put this program into the basics but the point is that I have only got the index of the 1 that follows the 2, tho when I do this the result is:

[3, 2, 1]

This means that it doesn't delete the 1 I want but just the first 1 it finds. Tho this is really a problem in a real program situation where the first 1 is an important value.

How can I fix it? Thanks

Body:
Using list comprehension with enumerate(a) and index(2)

[j for i,j in enumerate(a) if not (i>a.index(2) and j==1)]
#[3, 1, 2]


问:
How to move data from sale.order (order_line) to stock.picking(pack_operation_product_ids)
How does data from the field order_line (sale.order.line) to the field pack_operation_product_ids (stock move)?
I've made a custome field in each field..
so when a sale order on the approve data, which I made in move_line it participated also in the field are filled I made on pack_operation_product_ids.

i'm use odoo10

thx

答:
The values for creating procurement is returned from method _prepare_order_line_procurement in sale order line. If you need to pass your custom fields, you need to return your field values from this method.

example:

```<code>_inherit = 'sale.order.line'

@api.multi
def _prepare_order_line_procurement(self, group_id=False):
    vals = super(SaleOrderLine, self)._prepare_order_line_procurement(group_id=group_id)
    vals.update({
        'your_field_1': self.your_field_1_in_sale_order_line,
        'your_field_2': self.your_field_2_in_sale_order_line,
    })
    return vals
</code>```

Body:
The values for creating procurement is returned from method _prepare_order_line_procurement in sale order line. If you need to pass your custom fields, you need to return your field values from this method.

example:

_inherit = 'sale.order.line'

@api.multi
def _prepare_order_line_procurement(self, group_id=False):
    vals = super(SaleOrderLine, self)._prepare_order_line_procurement(group_id=group_id)
    vals.update({
        'your_field_1': self.your_field_1_in_sale_order_line,
        'your_field_2': self.your_field_2_in_sale_order_line,
    })
    return vals


问:
Add each value from each iterations from a for loop c#
I want to add each A value of each iteration together. In this loop it will go around ten times, so i will have 10 different A values. I want the total value of every A. I have solved it, but i feel like its must be an easier way to do it. So my question is, is there an easier way to do it?</p>

```<code>int a = 0;
int b = 0;
int c = 0;
int e = 0;
for (int i = 1; i <= 10; i++)
{
     a = i * i;
     c = a + b;
     c = e + c;
     e = c;
}
Console.WriteLine(c);
Console.Read();
</code>```

答:
You could use LINQ:

```<code>int a = Enumerable.Range(1, 10).Sum(i => i * i);
</code>```

Which is the same as:

```<code>int a = 0;
for (int i = 1; i <= 10; i++)
{
    a += i * i;
}
</code>```

By the way, if you want to calculate any power of i use Math.Pow:

```<code>int a = Enumerable.Range(1, 10).Sum(i => (int)Math.Pow(i, 2));
</code>```

Body:
I want to add each A value of each iteration together. In this loop it will go around ten times, so i will have 10 different A values. I want the total value of every A. I have solved it, but i feel like its must be an easier way to do it. So my question is, is there an easier way to do it?

int a = 0;
int b = 0;
int c = 0;
int e = 0;
for (int i = 1; i <= 10; i++)
{
     a = i * i;
     c = a + b;
     c = e + c;
     e = c;
}
Console.WriteLine(c);
Console.Read();

Body:
You could use LINQ:

int a = Enumerable.Range(1, 10).Sum(i => i * i);

Which is the same as:

int a = 0;
for (int i = 1; i <= 10; i++)
{
    a += i * i;
}

By the way, if you want to calculate any power of i use Math.Pow:

int a = Enumerable.Range(1, 10).Sum(i => (int)Math.Pow(i, 2));


问:
How to train a model to detect an event in a time line sequence of data
I have a time line of a users data and i want to train a model to detect events.

For example an event could be a gesture in a time line of accelerometer data.

or

time line of looking at the time (looking at a watch), (labeling nerves or calm).

What machine learning algorithm  will be appropriate for this problem?

Thanks

答:
There is no closed answer as to what is the best approach. Based on experience, my favourite approach to modelling series generally is LSTM nets. These work great with time events as long as you have enough data. You can either try to look for anomalies. For this you could use an LSTM that triggers when something 'unexpected' happens. Another option would be defining different states (e.g is.event = {0,1}) and train your LSTM as a normal classifier (check this question in Quora). You can use for example keras to implement this easily in python.

If data in not so abundant, you can also try other nice sequential models like HMM and HSMM. These are also supervised model that learn from sequential data. In the case of HSMM you also take into account the time each state has occur which depending on your data can be of use. As far as I know scikit-learn only supports HMM, however there is a HSMM library available here.

Finally, some remarks about processing your data. If you intend to do batch learning, any of the models here suggested should work fine. However, if you want to do on-line learning (meaning that you make prediction on the fly as data arrives), you will need to stick to LSTM or perhaps check this alternative if you decide to use any of the Bayesian Approach: paper on-line hsmm

Hope this helps!


问:
PushAsync runs without await
I'm using Navigation.PushAsync to navigate to a new page and when the work is done, it will call PopAsync to return to previous page. The problem is the first page needs to wait to the new page to pop and then continue some work. So I'm doing like this:

```<code>// source page:
DoWork();
await Navigation.PushAsync(new TargetPage());  <== this does not wait for the page!??
DoOtherWork();
</code>```

I observed that the DoOtherWork part runs immediately when the new page is shown, not until it is dismissed. But I'm using await here, so that means the later part should be a continuation upon the async task is finished, right? Why is it run without waiting for the Navigation task?

答:
```<code>await Navigation.PushAsync(new TargetPage());
</code>```

This code "await" until the "TargetPage" is visualized, then code continue with "OnOtherCode".

If you want to execute some code after TargetPage is closed, you should add this code after Navigation.PopAsync, or in "TargetPage's OnDisappearing" event.

Another solution can be: use a MessagingCenter.Send in "TargetPage's OnDisappearing" event and subscribe to the same message in the Calling Page

Title: PushAsync runs without await

Body:
I'm using Navigation.PushAsync to navigate to a new page and when the work is done, it will call PopAsync to return to previous page. The problem is the first page needs to wait to the new page to pop and then continue some work. So I'm doing like this:

// source page:
DoWork();
await Navigation.PushAsync(new TargetPage());  <== this does not wait for the page!??
DoOtherWork();

I observed that the DoOtherWork part runs immediately when the new page is shown, not until it is dismissed. But I'm using await here, so that means the later part should be a continuation upon the async task is finished, right? Why is it run without waiting for the Navigation task?

Body:
await Navigation.PushAsync(new TargetPage());

This code "await" until the "TargetPage" is visualized, then code continue with "OnOtherCode".

If you want to execute some code after TargetPage is closed, you should add this code after Navigation.PopAsync, or in "TargetPage's OnDisappearing" event.

Another solution can be: use a MessagingCenter.Send in "TargetPage's OnDisappearing" event and subscribe to the same message in the Calling Page


问:
How to set new value for the environment variable in VSTS
we have used the env:msg merge but it did take the default value in variables tab. We were unable to assign a value.Even though we see the value in the previous step

The code that assigns the value

```<code>$env:msgmerge = 'Git Merge to Master After Deployment Repo:' + "$(reponame)"
Write-Output $env:msgmerge
</code>```

Environment variables created with $env: are Process variables, so they're lost when the process exits and we can't access them from another process (PowerShell instance).

答:
Ahh this solved we need to use the vsts method</p>

```<code>$msgmerge = 'Git Merge to Master After Deployment Repo:' + "$(reponame)"
Write-Output $msgmerge

Write-Host ("##vso[task.setvariable variable=msgmerge;]$msgmerge")
</code>```

ContentLicense: CC BY-SA 4.0

Body:
we have used the env:msg merge but it did take the default value in variables tab. We were unable to assign a value.Even though we see the value in the previous step

The code that assigns the value

$env:msgmerge = 'Git Merge to Master After Deployment Repo:' + "$(reponame)"
Write-Output $env:msgmerge

Environment variables created with $env: are Process variables, so they're lost when the process exits and we can't access them from another process (PowerShell instance).

Body:
Ahh this solved we need to use the vsts method

$msgmerge = 'Git Merge to Master After Deployment Repo:' + "$(reponame)"
Write-Output $msgmerge

Write-Host ("##vso[task.setvariable variable=msgmerge;]$msgmerge")


问:
$state.go ui-routing function ignores custom parameters
I have created a 'go' back option that takes user back to the advSrch screen/state. I pass loadSearchQuery as true if going back.

```<code>  $scope.back = function() {
    $state.go('advSrch', { isDeleted: false, loadSearchQuery: true });
  };
</code>```

However my app always uses the default no matter what.

```<code>    }).state("advSrch",{url:"/advSrch",
    templateUrl: "app/search/advSearch.html",
    controller: "searchCtl",
    params: { isDeleted: null, loadSearchQuery: null },
    data: { authorizedRoles: ['USR']}
</code>```

When I console.log after going back loadSearchQuery is always null. Am I doing something wrong?

答:
Be sure you are trying to get loadSearchQuery from $stateParams.

```<code>angular.module('app').controller('searchCtl', ['$scope', '$state',   '$stateParams',
    function ($scope, $state, $stateParams) {

        // Log param
        console.log($stateParams.loadSearchQuery);

        // ...
    }
]);
</code>```

Edit: As jackthed states in answer, use of $stateParams is deprecated from ui-router version 1, and instead $transition$ could be used. For instance:

```<code>angular.module('app').controller('searchCtl', ['$scope', '$transition$',
    function ($scope, $transition$) {

        // Log param
        console.log($transition$.params().loadSearchQuery);

        // ...
    }
]);
</code>```

Body:
I have created a 'go' back option that takes user back to the advSrch screen/state. I pass loadSearchQuery as true if going back.

  $scope.back = function() {
    $state.go('advSrch', { isDeleted: false, loadSearchQuery: true });
  };

However my app always uses the default no matter what.

    }).state("advSrch",{url:"/advSrch",
    templateUrl: "app/search/advSearch.html",
    controller: "searchCtl",
    params: { isDeleted: null, loadSearchQuery: null },
    data: { authorizedRoles: ['USR']}

When I console.log after going back loadSearchQuery is always null. Am I doing something wrong?

Body:
Be sure you are trying to get loadSearchQuery from $stateParams.

angular.module('app').controller('searchCtl', ['$scope', '$state',   '$stateParams',
    function ($scope, $state, $stateParams) {

        // Log param
        console.log($stateParams.loadSearchQuery);

        // ...
    }
]);

Edit: As jackthed states in answer, use of $stateParams is deprecated from ui-router version 1, and instead $transition$ could be used. For instance:

angular.module('app').controller('searchCtl', ['$scope', '$transition$',
    function ($scope, $transition$) {

        // Log param
        console.log($transition$.params().loadSearchQuery);

        // ...
    }
]);


问:
How to make NSTableView transparent?
I want to make transparent NSTableView.

I am using WindowController class here.

I was trying this:

```<code>- (void)windowDidLoad
{
     [super windowDidLoad];
     [[self enclosingScrollView] setDrawsBackground: NO];
     [[self enclosingScrollView] setBorderType:NSNoBorder];

}

- (BOOL)isOpaque {

      return NO;
}
- (void)drawRect:(NSRect)drawRect
{
     [super drawRect: drawRect];
}
</code>```

But when i was writing this code i can't found enclosingScrollView in help window.

you can see here..

Any help?? Please remember me or correct me if i am doing something wrong.

Thank you.

答:
If your app needs to display a transparent table view, set the background color of the table view to be clear and set the enclosing scroll view to not draw its background. The following code snippet shows one way to display a transparent table:

Swift:

```<code>yourTableView.backgroundColor = NSColor.clear
yourTableView.enclosingScrollView?.drawsBackground = false
</code>```

Objective-C

```<code>[theTableView setBackgroundColor:[NSColor clearColor];
[[theTableView enclosingScrollView] setDrawsBackground:NO];
</code>```

Apple - Modifying a Table’s Visual Attributes

Title: How to make NSTableView transparent?

Body:
I want to make transparent NSTableView.

I am using WindowController class here.

I was trying this:

- (void)windowDidLoad
{
     [super windowDidLoad];
     [[self enclosingScrollView] setDrawsBackground: NO];
     [[self enclosingScrollView] setBorderType:NSNoBorder];

}

- (BOOL)isOpaque {

      return NO;
}
- (void)drawRect:(NSRect)drawRect
{
     [super drawRect: drawRect];
}

But when i was writing this code i can't found enclosingScrollView in help window.

you can see here..

Any help?? Please remember me or correct me if i am doing something wrong.

Thank you.

Body:
If your app needs to display a transparent table view, set the background color of the table view to be clear and set the enclosing scroll view to not draw its background. The following code snippet shows one way to display a transparent table:

Swift:

yourTableView.backgroundColor = NSColor.clear
yourTableView.enclosingScrollView?.drawsBackground = false

Objective-C

[theTableView setBackgroundColor:[NSColor clearColor];
[[theTableView enclosingScrollView] setDrawsBackground:NO];

Apple - Modifying a Table’s Visual Attributes


问:
Is ConfigurationManager.AppSettings available in .NET Core 2.0?
I've got a method that reads settings from my config file like this:

```<code>var value = ConfigurationManager.AppSettings[key];
</code>```

It compiles fine when targeting .NET Standard 2.0 only.

Now I need multiple targets, so I updated my project file with:

```<code><TargetFrameworks>netcoreapp2.0;net461;netstandard2.0</TargetFrameworks>
</code>```

But now, the compilation fails for netcoreapp2.0 with the following error message:

Error CS0103  The name 'ConfigurationManager' does not exist in the current context   (netcoreapp2.0)

Separately, I created a new .NET Core 2.0 console application (only targeting .NET Core 2.0 this time), but likewise there seems to be no ConfigurationManager under the namespace System.Configuration.

I'm quite confused because it's available under .NET Standard 2.0, so I would expect it to be available in .NET Core 2.0, as .NET Core 2.0 is .NET Standard 2.0 compliant.

What am I missing?

答:
Yes, ConfigurationManager.AppSettings is available in .NET Core 2.0 after referencing NuGet package System.Configuration.ConfigurationManager.

Credits goes to @JeroenMostert for giving me the solution.

Body:
I've got a method that reads settings from my config file like this:

var value = ConfigurationManager.AppSettings[key];

It compiles fine when targeting .NET Standard 2.0 only.

Now I need multiple targets, so I updated my project file with:

<TargetFrameworks>netcoreapp2.0;net461;netstandard2.0</TargetFrameworks>

But now, the compilation fails for netcoreapp2.0 with the following error message:

Error CS0103  The name 'ConfigurationManager' does not exist in the current context   (netcoreapp2.0)

Separately, I created a new .NET Core 2.0 console application (only targeting .NET Core 2.0 this time), but likewise there seems to be no ConfigurationManager under the namespace System.Configuration.

I'm quite confused because it's available under .NET Standard 2.0, so I would expect it to be available in .NET Core 2.0, as .NET Core 2.0 is .NET Standard 2.0 compliant.

What am I missing?


问:
Unable to assign python wand Image object

I'm trying to create high res jpegs from a pdf using wand. This question is a follow up to How to create high res JPEG with Wand.

I'm getting the error:

```<code>with ok.transform('2000x1000', '100%') as image:
AttributeError: __enter__
</code>```

Trying to step through the code:

```<code>Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
>>> im = ok.transform('2000x1000', '100%')
>>> im
>>> im
</code>```

you can see that I am unable to assign the transformed image to im. Why ?

答:
you can see that I am unable to assign the transformed image to im. Why ?

The method wand.image.Image.transform does not return an instance of wand.image.Image.

Also note. The MagickWand convenience method MagickTransformImage has been removed with IM-7. Use wand.image.Image.crop & wand.image.Image.resize directly.

with Image(filename=file_path, resolution=400) as image:
    image.crop(width=2000, height=1000)
```

Body:
I'm trying to create high res jpegs from a pdf using wand. This question is a follow up to How to create high res JPEG with Wand.

I'm getting the error:

with ok.transform('2000x1000', '100%') as image:
AttributeError: __enter__

Trying to step through the code:

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
>>> im = ok.transform('2000x1000', '100%')
>>> im
>>> im

you can see that I am unable to assign the transformed image to im. Why ?


问:
How to create listener for spring session destroyed events?
I have a code as below:

```<code>@Component
public class LogoutListener implements ApplicationListener<SessionDestroyedEvent>
{
  @Override
  public void onApplicationEvent(SessionDestroyedEvent event)
  {
    System.out.println("Application event happened");
    for (SecurityContext securityContext : event.getSecurityContexts())
    {
        System.out.println("session has ended");
    }
  }
}
</code>```

Since I am using a spring boot app.I cant use web.xml.Then how can I configure the listener.
This listener is looking for session destroyed events.

答: I think the answer here might be helpful. In it you'll find that, for applications without web.xml, you have to look at ServletContext.html#addListener</p>

Body:
I have a code as below:

@Component
public class LogoutListener implements ApplicationListener<SessionDestroyedEvent>
{
  @Override
  public void onApplicationEvent(SessionDestroyedEvent event)
  {
    System.out.println("Application event happened");
    for (SecurityContext securityContext : event.getSecurityContexts())
    {
        System.out.println("session has ended");
    }
  }
}

Since I am using a spring boot app.I cant use web.xml.Then how can I configure the listener.
This listener is looking for session destroyed events.


问:
Java, Reading two different types of variables from a file and using them as objects later
I working on a project that is based on reading a text from a file and putting it as objects in my code.

My file has the following elements:
(ignore the bullet points)

4

Christmas Party

20

Valentine

12

Easter

5

Halloween

8

The first line declares how many "parties" I have in my text file (its 4 btw)
Every party has two lines - the first line is the name and the second one is the number of places available.

So for example, Christmas Party has 20 places available

Here's my code for saving the information from the file as objects.

```<code>public class Parties
{
   static Scanner input = new Scanner(System.in);

  public static void main(String[] args) throws FileNotFoundException
  {

     Scanner inFile = new Scanner(new FileReader ("C:\\desktop\\file.txt"));

     int first = inFile.nextInt();
     inFile.nextLine();

    for(int i=0; i < first ; i++)
    {
        String str = inFile.nextLine();
        String[] e = str.split("\\n");

        String name = e[0];
        int tickets= Integer.parseInt(e[1]); //this is where it throw an error ArrayIndexOutOfBoundsException, i read about it and I still don't understand

        Party newParty = new Party(name, tickets);
        System.out.println(name+ " " + tickets);
    }
</code>```

This is my SingleParty Class:

```<code>public class SingleParty
{
    private String name;
    private int tickets;

    public Party(String newName, int newTickets)
    {
        newName = name;
        newTickets = tickets;

    }
</code>```

Can someone explain to me how could I approach this error?

Thank you

答:
str only contains the party name and splitting it won't work, as it won't have '\n' there.

It should be like this within the loop:

```<code>String name = inFile.nextLine();
int tickets = inFile.nextInt();

Party party = new Party(name, tickets);

// Print it here.

inFile().nextLine(); // for flushing
</code>```

Body:
I working on a project that is based on reading a text from a file and putting it as objects in my code.

My file has the following elements:
(ignore the bullet points)

4

Christmas Party

20

Valentine

12

Easter

5

Halloween

8

The first line declares how many "parties" I have in my text file (its 4 btw)
Every party has two lines - the first line is the name and the second one is the number of places available.

So for example, Christmas Party has 20 places available

Here's my code for saving the information from the file as objects.

public class Parties
{
   static Scanner input = new Scanner(System.in);

  public static void main(String[] args) throws FileNotFoundException
  {

     Scanner inFile = new Scanner(new FileReader ("C:\\desktop\\file.txt"));

     int first = inFile.nextInt();
     inFile.nextLine();

    for(int i=0; i < first ; i++)
    {
        String str = inFile.nextLine();
        String[] e = str.split("\\n");

        String name = e[0];
        int tickets= Integer.parseInt(e[1]); //this is where it throw an error ArrayIndexOutOfBoundsException, i read about it and I still don't understand

        Party newParty = new Party(name, tickets);
        System.out.println(name+ " " + tickets);
    }

This is my SingleParty Class:

public class SingleParty
{
    private String name;
    private int tickets;

    public Party(String newName, int newTickets)
    {
        newName = name;
        newTickets = tickets;

    }

Can someone explain to me how could I approach this error?

Thank you

Body:
str only contains the party name and splitting it won't work, as it won't have '\n' there.

It should be like this within the loop:

String name = inFile.nextLine();
int tickets = inFile.nextInt();

Party party = new Party(name, tickets);

// Print it here.

inFile().nextLine(); // for flushing


问:
Can DVD+R hold .iso files and boot up via to bios?
This seems like a stupid question, I know, but can I take a DVD+R and use that as a .iso image DVD and then boot a program from the bios with it? If not, what type of CD do I need?</p>

答:
Not quite sure what you mean by boot a program from bios with it?

Do you mean boot an ISO image as if it was a physical dvd?

It's tricky but can be done with Grub2 http://michael-prokop.at/blog/2009/05/25/boot-an-iso-via-grub2/

edit - sorry misunderstood.

If you just want to make a physical DVD from an iso image then just right click on the iso and select "burn image" in Windows7.  Or your DVD writing software probably has a burn ISO option.

Note this is different from copying an ISO onto a DVD - you need to burn it as an image so the format inside the iso is copied to the dvd as a whole

ContentLicense: CC BY-SA 2.5


问:
Form visible in Design View, but blank in Form View
My form is showing up in design, but not form view.  There are 700+ records.

In Design View -> Data, the Record Source is:

```<code>SELECT act.* FROM act;
</code>```

This query shows all records in Query view.

There are no filters, and Allow Form View is set to Yes.

What is causing my form not to show?

EDIT: I'm noticing that the form is extremely wide.  There isn't a width setting, but in Design view with window maximized I have to scroll way over to see the right edge.  Would this have anything to do with it?

答: On Design View of the Form click on "Details" which is just below the ruler and make sure that Visible is set to Yes on the Property Sheet.</p>

Body:
My form is showing up in design, but not form view.  There are 700+ records.

In Design View -> Data, the Record Source is:

SELECT act.* FROM act;

This query shows all records in Query view.

There are no filters, and Allow Form View is set to Yes.

What is causing my form not to show?

EDIT: I'm noticing that the form is extremely wide.  There isn't a width setting, but in Design view with window maximized I have to scroll way over to see the right edge.  Would this have anything to do with it?


问:
SOAPUI Groovy - Update XML request in another test case
I am having 2 test cases in my suite.
First test case contains 1 test step with xml request.
Second test case contains 1 test step with groovy script. I want to run the 1st test case from this groovy script a number of times. Every time I want to change the input XML. I am unable to update the input XML in TestCase 1.
I have the following the code for the groovy script:

```<code>import com.eviware.soapui.support.XmlHolder
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def tsuite = testRunner.testCase.testSuite
def acctInq_tstepName = tsuite.getTestCaseAt(1).getTestStepAt(0).getName()
def acctInq_requestHolder = tsuite.getTestCaseAt(1).testSteps[acctInq_tstepName].testRequest.getRequestContent()
def acctInq_req = groovyUtils.getXmlHolder("$acctInq_requestHolder")
acctInq_req["//soapenv:Envelope[1]/soapenv:Body[1]/v2:AcctInqRq[1]/ifx:DepAcctId[1]/ifx:AcctId[1]"] = "0009917812344"
acctInq_req.updateProperty()
</code>```

I also tried using

```<code>tstep.setPropertyValue("request",cStr(acctInq_req))
</code>```

In either case the XML is not getting updated. Please help.

答:
Try set node value like below and check if it fixed the issue:</p>

```<code>acctInq_req.setNodeValue("//*:ifx:AcctId[1]", "0009917812344")
</code>```

Body:
I am having 2 test cases in my suite.
First test case contains 1 test step with xml request.
Second test case contains 1 test step with groovy script. I want to run the 1st test case from this groovy script a number of times. Every time I want to change the input XML. I am unable to update the input XML in TestCase 1.
I have the following the code for the groovy script:

import com.eviware.soapui.support.XmlHolder
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def tsuite = testRunner.testCase.testSuite
def acctInq_tstepName = tsuite.getTestCaseAt(1).getTestStepAt(0).getName()
def acctInq_requestHolder = tsuite.getTestCaseAt(1).testSteps[acctInq_tstepName].testRequest.getRequestContent()
def acctInq_req = groovyUtils.getXmlHolder("$acctInq_requestHolder")
acctInq_req["//soapenv:Envelope[1]/soapenv:Body[1]/v2:AcctInqRq[1]/ifx:DepAcctId[1]/ifx:AcctId[1]"] = "0009917812344"
acctInq_req.updateProperty()

I also tried using

tstep.setPropertyValue("request",cStr(acctInq_req))

In either case the XML is not getting updated. Please help.

Body:
Try set node value like below and check if it fixed the issue:

acctInq_req.setNodeValue("//*:ifx:AcctId[1]", "0009917812344")


问:
pandas set boolean values for a column based on values of another column using regex match
I have a df that one column (acount_no) contains empty strings, space strings and repeated digits strings as its values. For these values, I want to create a new column (valid_account_no) and set False to their corresponding rows. Also if length of any account_no are <= 4, they will be set False to valid_account_no. the df looks like,

```<code> id    account_no    valid_account_no
 1                   False
 2     999999        False
 3     1234          False
 4     123456        True
</code>```

this my code,

```<code># sets boolean values of column valid account no when account no is spaced or repeated number
df['valid_account_no'] = df['account_no'].str.match(r"\b(\d)\1+\b| +")

# if length of any account nos are <= 4 or the account nos are empty
# set values of column valid account no to False
invalid_account_indices = df[(df['account_no'].str.len() <= 4) |
                             (df['account_no'] == '')].index
df.loc[invalid_account_indices, 'valid_account_no'] = False
</code>```

I am wondering if there a better way to achieve this, in a sense to make it more concise and efficient.

答:
Your approach itself if good, another work around is with simple boolean algebra i.e </p>

```<code>m1 = df['account_no'].str.match(r"\b(\d)\1+\b| +")
m2 = df['account_no'].str.len()<=4
m3 = df['account_no'] == ''
df['valid_account_no'] = (m1) | (m2 & m3)
</code>```

Body:
I have a df that one column (acount_no) contains empty strings, space strings and repeated digits strings as its values. For these values, I want to create a new column (valid_account_no) and set False to their corresponding rows. Also if length of any account_no are <= 4, they will be set False to valid_account_no. the df looks like,

 id    account_no    valid_account_no
 1                   False
 2     999999        False
 3     1234          False
 4     123456        True

this my code,

# sets boolean values of column valid account no when account no is spaced or repeated number
df['valid_account_no'] = df['account_no'].str.match(r"\b(\d)\1+\b| +")

# if length of any account nos are <= 4 or the account nos are empty
# set values of column valid account no to False
invalid_account_indices = df[(df['account_no'].str.len() <= 4) |
                             (df['account_no'] == '')].index
df.loc[invalid_account_indices, 'valid_account_no'] = False

I am wondering if there a better way to achieve this, in a sense to make it more concise and efficient.

Body:
Your approach itself if good, another work around is with simple boolean algebra i.e

m1 = df['account_no'].str.match(r"\b(\d)\1+\b| +")
m2 = df['account_no'].str.len()<=4
m3 = df['account_no'] == ''
df['valid_account_no'] = (m1) | (m2 & m3)


问:
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
I tried to restart my Apache server on CentOS 5.0 and got this message:

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Here is the /etc/hosts file:

```<code>127.0.0.1    server4-245    server4-245.com    localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6
</code>```

Here is the /etc/sysconfig/network file:

```<code>NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server4-245
</code>```

I also have this in the Apache httpd.conf file:

```<code>ServerName localhost
</code>```

However, I still get the first error message when I restart Apache.

答:
Make sure you're editing the right httpd.conf file, then the error about unreliable server's domain name should be gone (this is the most common mistake).

To locate your httpd.conf Apache configuration file, run:

```<code>apachectl -t -D DUMP_INCLUDES
</code>```

Then edit the file and uncomment or change ServerName line into:

```<code>ServerName localhost
</code>```

Then restart your apache by: sudo apachectl restart

Body:
I tried to restart my Apache server on CentOS 5.0 and got this message:

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Here is the /etc/hosts file:

127.0.0.1    server4-245    server4-245.com    localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6

Here is the /etc/sysconfig/network file:

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server4-245

I also have this in the Apache httpd.conf file:

ServerName localhost

However, I still get the first error message when I restart Apache.

Body:
Make sure you're editing the right httpd.conf file, then the error about unreliable server's domain name should be gone (this is the most common mistake).

To locate your httpd.conf Apache configuration file, run:

apachectl -t -D DUMP_INCLUDES

Then edit the file and uncomment or change ServerName line into:

ServerName localhost

Then restart your apache by: sudo apachectl restart


问:
In SQL Server, casting varchar to int converts the blank to 0, is there a way to avoid this?
```<code> sample0 <- paste("SELECT cast([Date] as Date) as Date values (NULL)
              ,[Major_Asset_Class] values (NULL)
              ,[Country] values (NULL)
              ,cast([CPI_Index] as float) as CPI_Index values (NULL)
              ,cast([GDP] as float) as GDP values (NULL)
              ,cast([",Local_Earning_Index,"] as float) as Local_Earning_Index values (NULL)
              ,cast([",Local_MARKET_CAP,"] as float) as Local_MARKET_CAP values (NULL)
              ,cast([",Local_NET_DVD,"] as float) as Local_NET_DVD values (NULL)
              ,cast([",Local_Price_Index,"] as float) as Local_Price_Index values (NULL)
              ,cast([",MSCI_Earning_Index,"] as float) as MSCI_Earning_Index values (NULL)
              ,cast([",MSCI_MARKET_CAP,"] as float) as MSCI_MARKET_CAP values (NULL)
              ,cast([",MSCI_NET_DVD,"] as float) as MSCI_NET_DVD values (NULL)
              ,cast([",MSCI_Price_Index,"] as float) as MSCI_Price_Index values (NULL)
              ,cast([",Volitility_Index,"] as FLOAT) as Volitility_Index values (NULL)
              ,cast([",Local_TtlGrs_Return,"] as float) as Local_TtlGrs_Return values (NULL)
              ,cast([",Local_TtlNet_Return,"] as float) as Local_TtlNet_Return into values (NULL)
              Last_Month_Data_1$
              FROM [Tableau].[dbo].[Last_Month_Data]",sep="")
</code>```

I don't want the blanks in each column to convert to 0s. How can i avoid that?

答:
Have a look at this post,
Put blank in sql server column with integer datatype

it shows how to replace the 0's with empty strings

Body:
 sample0 <- paste("SELECT cast([Date] as Date) as Date values (NULL)
              ,[Major_Asset_Class] values (NULL)
              ,[Country] values (NULL)
              ,cast([CPI_Index] as float) as CPI_Index values (NULL)
              ,cast([GDP] as float) as GDP values (NULL)
              ,cast([",Local_Earning_Index,"] as float) as Local_Earning_Index values (NULL)
              ,cast([",Local_MARKET_CAP,"] as float) as Local_MARKET_CAP values (NULL)
              ,cast([",Local_NET_DVD,"] as float) as Local_NET_DVD values (NULL)
              ,cast([",Local_Price_Index,"] as float) as Local_Price_Index values (NULL)
              ,cast([",MSCI_Earning_Index,"] as float) as MSCI_Earning_Index values (NULL)
              ,cast([",MSCI_MARKET_CAP,"] as float) as MSCI_MARKET_CAP values (NULL)
              ,cast([",MSCI_NET_DVD,"] as float) as MSCI_NET_DVD values (NULL)
              ,cast([",MSCI_Price_Index,"] as float) as MSCI_Price_Index values (NULL)
              ,cast([",Volitility_Index,"] as FLOAT) as Volitility_Index values (NULL)
              ,cast([",Local_TtlGrs_Return,"] as float) as Local_TtlGrs_Return values (NULL)
              ,cast([",Local_TtlNet_Return,"] as float) as Local_TtlNet_Return into values (NULL)
              Last_Month_Data_1$
              FROM [Tableau].[dbo].[Last_Month_Data]",sep="")

I don't want the blanks in each column to convert to 0s. How can i avoid that?


问:
Pace.js not working in IE 11
I have an angular-cli project. I have also added pace. I added it inside the header in index.html . It works correctly in chrome, but in IE-11 I get the following error:

```<code>ERROR TypeError: Invalid calling object
      stack: "TypeError: Invalid calling object
   at scheduleTask (http://localhost:4200/polyfills.bundle.js:8607:13)
   at ZoneDelegate.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6279:21)
   at DELEGATE_ZS.onScheduleTask (http://localhost:4200/polyfills.bundle.js:6169:13)
   at ZoneDelegate.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6273:17)
   at Zone.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6104:17)
   at Zone.prototype.scheduleMacroTask (http://localhost:4200/polyfills.bundle.js:6127:13)
   at Anonymous function (http://localhost:4200/polyfills.bundle.js:8637:17)
   at proto[name] (http://localhost:4200/polyfills.bundle.js:7142:17)
   at Anonymous function (http://localhost:4200/vendor.bundle.js:63666:13)
   at Observable.prototype._trySubscribe (http://localhost:4200/vendor.bundle.js:4172:13)",
      Symbol(observable)_h.fo48yw1o6i8: undefined,
      Symbol(rxSubscriber)_g.fo48yw1o6i8: undefined
</code>```

What am I doing wrong?

答:
There is a conflict between pace and the changes in zone.js v0.8.12 - see below for details.
To fix the issue I made sure to load pace.min.js after zone.min.js and the other IE polyfills and it worked like a charm.

https://github.com/HubSpot/pace/issues/399

```<code>In the newest version of zone.js (0.8.12) using pace with it causes all XMLHttpRequests to fail with the error message:

TypeError: Unable to get property 'apply' of undefined or null reference
Please see my issue for more information. If I get time I'll try and fix the issue inside pace itself but I've already spent the good part of 3-4 hours trying to debug this issue so we'll see..
</code>```

https://github.com/angular/zone.js/issues/816

```<code>After updating zone.js to the latest version (0.8.12) we started getting errors when loading an Angular page with angular/http calls in Internet Explorer 11 (works fine in Chrome). The request never initiates and there are a few errors in the console:

Unhandled Promise rejection: Unable to get property 'apply' of undefined or null reference ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Unable to get property 'apply' of undefined or null reference TypeError: Unable to get property 'apply' of undefined or null reference
at scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:142795:13)
at ZoneDelegate.prototype.scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140947:21)
at Zone.prototype.scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140772:17)
at Zone.prototype.scheduleMacroTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140795:13)
at Anonymous function (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:142824:17)
at proto[name] (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZ
After digging around a bit, it looks like a very new bit of code could be causing this, introduced in PR #800

The exact line of failure is below, where oriAddListener is undefined, causing the above error :

oriAddListener.apply(data.target, ['readystatechange', newListener]); // line 110
Rolling zone.js back to 0.8.11 which was before that PR fixes the issue and works as expected.
</code>```

Title: Pace.js not working in IE 11

Body:
I have an angular-cli project. I have also added pace. I added it inside the header in index.html . It works correctly in chrome, but in IE-11 I get the following error:

ERROR TypeError: Invalid calling object
      stack: "TypeError: Invalid calling object
   at scheduleTask (http://localhost:4200/polyfills.bundle.js:8607:13)
   at ZoneDelegate.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6279:21)
   at DELEGATE_ZS.onScheduleTask (http://localhost:4200/polyfills.bundle.js:6169:13)
   at ZoneDelegate.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6273:17)
   at Zone.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6104:17)
   at Zone.prototype.scheduleMacroTask (http://localhost:4200/polyfills.bundle.js:6127:13)
   at Anonymous function (http://localhost:4200/polyfills.bundle.js:8637:17)
   at proto[name] (http://localhost:4200/polyfills.bundle.js:7142:17)
   at Anonymous function (http://localhost:4200/vendor.bundle.js:63666:13)
   at Observable.prototype._trySubscribe (http://localhost:4200/vendor.bundle.js:4172:13)",
      Symbol(observable)_h.fo48yw1o6i8: undefined,
      Symbol(rxSubscriber)_g.fo48yw1o6i8: undefined

What am I doing wrong?

Body:
There is a conflict between pace and the changes in zone.js v0.8.12 - see below for details.
To fix the issue I made sure to load pace.min.js after zone.min.js and the other IE polyfills and it worked like a charm.

https://github.com/HubSpot/pace/issues/399

In the newest version of zone.js (0.8.12) using pace with it causes all XMLHttpRequests to fail with the error message:

TypeError: Unable to get property 'apply' of undefined or null reference
Please see my issue for more information. If I get time I'll try and fix the issue inside pace itself but I've already spent the good part of 3-4 hours trying to debug this issue so we'll see..

https://github.com/angular/zone.js/issues/816

After updating zone.js to the latest version (0.8.12) we started getting errors when loading an Angular page with angular/http calls in Internet Explorer 11 (works fine in Chrome). The request never initiates and there are a few errors in the console:

Unhandled Promise rejection: Unable to get property 'apply' of undefined or null reference ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Unable to get property 'apply' of undefined or null reference TypeError: Unable to get property 'apply' of undefined or null reference
at scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:142795:13)
at ZoneDelegate.prototype.scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140947:21)
at Zone.prototype.scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140772:17)
at Zone.prototype.scheduleMacroTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140795:13)
at Anonymous function (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:142824:17)
at proto[name] (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZ
After digging around a bit, it looks like a very new bit of code could be causing this, introduced in PR #800

The exact line of failure is below, where oriAddListener is undefined, causing the above error :

oriAddListener.apply(data.target, ['readystatechange', newListener]); // line 110
Rolling zone.js back to 0.8.11 which was before that PR fixes the issue and works as expected.


问:
aggregate by groups and report in sas
I've gotten the data I need and simply want to present it better, more like a pivot table in excel. The current code, that gives me the right value for freq is as follows:

```<code>proc means data = d sum;
vars mth age freq;
class mth age;
run;
</code>```

Variables "mth" and "age"are categories (7 groups each) and the goal was to get the sum of the variable "freq" for all of the intersections between "mth" and "age".  That was successful and the results are formatted as follows:

```<code>mth  age NObs Variable Sum
1     1   20  mth      20
              age      20
              freq     40
      2   30  mth      30
              age      30
              freq     65
...    ...       ...
7     1   25  mth      25
              age      25
              freq     48
</code>```

Again, the freq summation is correct with my code, i just want to display the results as follows:

```<code>  7  6  5  4  3  2  1
                         (<- column sum totals)
1                40  40  (<- intersection sums for freq)
2
...
7
</code>```

proc sql isnt playing nice and im not sure thats what to use anyways.  Thanks in advance for the help

答:
PROC MEANS isn't really the right tool: you want PROC TABULATE.

```<code>proc tabulate data=have;
  class mth age;
  var freq;
  tables mth,(all age)*freq*sum;
run;
</code>```

Something along those lines.  all gives you column totals, you could do the same thing before the , to get row totals.

Title: aggregate by groups and report in sas

Body:
I've gotten the data I need and simply want to present it better, more like a pivot table in excel. The current code, that gives me the right value for freq is as follows:

proc means data = d sum;
vars mth age freq;
class mth age;
run;

Variables "mth" and "age"are categories (7 groups each) and the goal was to get the sum of the variable "freq" for all of the intersections between "mth" and "age".  That was successful and the results are formatted as follows:

mth  age NObs Variable Sum
1     1   20  mth      20
              age      20
              freq     40
      2   30  mth      30
              age      30
              freq     65
...    ...       ...
7     1   25  mth      25
              age      25
              freq     48

Again, the freq summation is correct with my code, i just want to display the results as follows:

  7  6  5  4  3  2  1
                         (<- column sum totals)
1                40  40  (<- intersection sums for freq)
2
...
7

proc sql isnt playing nice and im not sure thats what to use anyways.  Thanks in advance for the help

Body:
PROC MEANS isn't really the right tool: you want PROC TABULATE.

proc tabulate data=have;
  class mth age;
  var freq;
  tables mth,(all age)*freq*sum;
run;

Something along those lines.  all gives you column totals, you could do the same thing before the , to get row totals.


问:
Simple question from a very no experienced programmer
Simple question: This is a method I created

```<code>public void move()
{
    double radians = direction * Math.PI / 180;
    //change the x location by the x vector of the speed
    X_Coordinate += (int)(speed * Math.Cos(radians));

    //change the y location by the y vectior of the speed
    Y_Coordinate -= (int)(speed * Math.Sin(radians));
}
</code>```

How do I take a value enter into a text box, use a button called move, to call this method and display the result?

答:
If you're using Visual Studio then...

Open the designer, and, from the toolbox, drag a TextBox and a Button onto the page (along with any other TextBox items you need, I'll assume you have them from now on.
Double click the button you just placed on the page. This creates an event handler, code within the scope of this block will execute when the button has been clicked.
Place the following code within the generated event handler code block, changing appropriately (e.g. TextBox names (You can change these using the Property Explorer within VS)):

```<code>var direction = 0;
if (int.TryParse(DirectionTextBox.Text, out direction))
{
    //further validate input here, as necessary

    Move(direction);
    XTextBox.Text = X_Coordinate.ToString();
    YTextBox.Text = Y_Coordinate.ToString();
}
else
{
    //handle invalid input, if not already done elsewhere.
}
</code>```

Presumably here X_Coordinate and Y_Coordinate are accessible variables. So, now, alter your move method to accept a parameter, like so:

```<code>public void Move(int direction)
{
    double radians = direction * Math.PI / 180;
    //change the x location by the x vector of the speed
    X_Coordinate += (int)(speed * Math.Cos(radians));

    //change the y location by the y vectior of the speed
    Y_Coordinate -= (int)(speed * Math.Sin(radians));
}
</code>```

Note that by this point I have no idea which of the elements of the Move method you wish to be variable input, but I'll keep thinking along the lines of this being an idea to can extend to as many elements as you like/need. Also note that there are many other ways to go about this - what I suggest is neat enough (given the information we have) and not too far altered from your initially posted code, hence, hopefully, easier for you to implement; but you could return a composite type from this method, and set visual outputs with the directly returned result to make things more concise.

Body:
Simple question: This is a method I created

public void move()
{
    double radians = direction * Math.PI / 180;
    //change the x location by the x vector of the speed
    X_Coordinate += (int)(speed * Math.Cos(radians));

    //change the y location by the y vectior of the speed
    Y_Coordinate -= (int)(speed * Math.Sin(radians));
}

How do I take a value enter into a text box, use a button called move, to call this method and display the result?

Body:
If you're using Visual Studio then...

Open the designer, and, from the toolbox, drag a TextBox and a Button onto the page (along with any other TextBox items you need, I'll assume you have them from now on.
Double click the button you just placed on the page. This creates an event handler, code within the scope of this block will execute when the button has been clicked.
Place the following code within the generated event handler code block, changing appropriately (e.g. TextBox names (You can change these using the Property Explorer within VS)):

var direction = 0;
if (int.TryParse(DirectionTextBox.Text, out direction))
{
    //further validate input here, as necessary

    Move(direction);
    XTextBox.Text = X_Coordinate.ToString();
    YTextBox.Text = Y_Coordinate.ToString();
}
else
{
    //handle invalid input, if not already done elsewhere.
}

Presumably here X_Coordinate and Y_Coordinate are accessible variables. So, now, alter your move method to accept a parameter, like so:

public void Move(int direction)
{
    double radians = direction * Math.PI / 180;
    //change the x location by the x vector of the speed
    X_Coordinate += (int)(speed * Math.Cos(radians));

    //change the y location by the y vectior of the speed
    Y_Coordinate -= (int)(speed * Math.Sin(radians));
}

Note that by this point I have no idea which of the elements of the Move method you wish to be variable input, but I'll keep thinking along the lines of this being an idea to can extend to as many elements as you like/need. Also note that there are many other ways to go about this - what I suggest is neat enough (given the information we have) and not too far altered from your initially posted code, hence, hopefully, easier for you to implement; but you could return a composite type from this method, and set visual outputs with the directly returned result to make things more concise.


问:
Googlebot 404 crawl errors after website changed
I had an old asp.net website (aspx) and have redesigned it with asp.net MVC using SSL.  Anyway, after I promoted the new site I saw a ton of errors which were being generated by bots looking for old pages; the errors were looking something like this: The controller for path '/blablabla/moreBlalbalba/page.aspx' was not found or does not implement IController. So, I updated my error handling to return a 301 response and redirect to the home page and added a sitemap.  The google 404 console errors went away for around a month, but now have a ton of 404 errors and they are all pointing to the old site structure.  As a side note, the new MVC/SSL site  has no 404 errors in the webmaster console, all the errors are on the non SSL site.  So, what is the best way to update the bots for the new site structure.

Thanks!

答:
I would suggest you to redirect all traffic from HTTP to HTTPS, using this example. This may solve your problem already.

And secondly create a sitemap for Google to check the relevant pages of the website, example here


问:
Why argument conversion is not considered when calling a templated function?
I have a template class and a friend operator* function

```<code>StereoSmp<TE> operator* (const StereoSmp<TE>& a, TE b)
</code>```

I use it with TE=float but I need to multiply a StereoSmp<float> * double
I think that should be possibile because it should converts double to float automatically and works but I get the error:

```<code>no match for ‘operator*’ (operand types are ‘StereoSmp<float>’ and
    ‘__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}’)
deduced conflicting types for parameter ‘TE’ (‘float’ and ‘double’)
</code>```

Why it doesn't convert double to float automatically? And what can I do to allow the automatic conversion between types?

答:
Don't make your friend a template.

```<code>template<class TE>
struct StereoSmp {
  friend StereoSmp operator* (const StereoSmp& a, TE b) {
    return multiply( a, b ); // implement here
  }
};
</code>```

this is a non-template friend to each type instance of the template StereoSmp.  It will consider conversions.

Template functions don't consider conversions, they simply do exact pattern matching.  Overload resolution is already insane enough in C++.

Body:
I have a template class and a friend operator* function

StereoSmp<TE> operator* (const StereoSmp<TE>& a, TE b)

I use it with TE=float but I need to multiply a StereoSmp<float> * double
I think that should be possibile because it should converts double to float automatically and works but I get the error:

no match for ‘operator*’ (operand types are ‘StereoSmp<float>’ and
    ‘__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}’)
deduced conflicting types for parameter ‘TE’ (‘float’ and ‘double’)

Why it doesn't convert double to float automatically? And what can I do to allow the automatic conversion between types?

Body:
Don't make your friend a template.

template<class TE>
struct StereoSmp {
  friend StereoSmp operator* (const StereoSmp& a, TE b) {
    return multiply( a, b ); // implement here
  }
};

this is a non-template friend to each type instance of the template StereoSmp.  It will consider conversions.

Template functions don't consider conversions, they simply do exact pattern matching.  Overload resolution is already insane enough in C++.