问:
Group objects by one of its params with javascript
Basically I would want to transform this

```<code>[
  { key: 0, name: 'Some name' },
  { key: 0, name: 'Some name' },
  { key: 1, name: 'Some name' },
  { key: 1, name: 'Some name' },
]
</code>```

To this where every object with the key of  0 would go into the first array and every object with the key of 1 would go into the second array.

```<code>[
  [
    { key: 0, name: 'Some name' },
    { key: 0, name: 'Some name' },
  ],
  [
    { key: 1, name: 'Some name' },
    { key: 1, name: 'Some name' },
  ],
];
</code>```

Would really not mind using lodash for this but couldn't find the correct array method.

答:
This is how I'd solve it with reduce:

const firstArray = [
  { key: 0, name: 'Some name' },
  { key: 0, name: 'Some name' },
  { key: 1, name: 'Some name' },
  { key: 1, name: 'Some name' },
]

const secondArray = firstArray.reduce((acc, elem) => {
  acc[elem.key] = [...(acc[elem.key] || []), elem];
  return acc
}, [])

console.log(secondArray)```

Body:
Basically I would want to transform this

[
  { key: 0, name: 'Some name' },
  { key: 0, name: 'Some name' },
  { key: 1, name: 'Some name' },
  { key: 1, name: 'Some name' },
]

To this where every object with the key of  0 would go into the first array and every object with the key of 1 would go into the second array.

[
  [
    { key: 0, name: 'Some name' },
    { key: 0, name: 'Some name' },
  ],
  [
    { key: 1, name: 'Some name' },
    { key: 1, name: 'Some name' },
  ],
];

Would really not mind using lodash for this but couldn't find the correct array method.


来源: stackexchange

问:
Text exceeding maximum height and width of the container
desktop:

mobile devices:

Hello I have a problem my text is passing my maximum height
I would like my container to follow the height and that my text has maximum width of my container my text

code:

```<code><div className="App">
  <div class="wrapper">
    <div className="text">
      <div class="card-info">
        <div class="card-about">
          <a class="card-tag tag-news">NEWS</a>
          <div class="card-time">6/11/2018</div>
        </div>
      </div>
      <h3 className="textxd">dasssssssssssssssss</h3>
      <p className="textxd">
        aaaaaaaaaaaaa dasuhdasudhu dasuhduashu aaaaaaaaaaaaa dasuhdasudhu
        dasuhduashu aaaaaaaaaaaaa da aaaaaaaaaaaaa dasuhdasudhu dasuhduashu
        aaaaaaaaaaaaa dasuhdasudhu dasuhduashu aaaaaaaaaaaaa dasuhdasudhu
        dasuhduashu aaaaaaaaaaaaa dasuhdasudhu dasuhduashusuhdasudhu
        dasuhduashu aaaaaaaaaaaaa dasuhdasudhu dasuhduashu
      </p>
    </div>
  </div>
</div>
</code>```

css:

```<code>.App {
  padding: 20px;
  font-family: sans-serif;
  text-align: center;
  background: red;
  height: 40vh;
}

.wrapper {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 30vh;
  max-height: 30vh;
  border-radius: 10px;
  cursor: pointer;
  background:blue;

}
.textxd {
  margin-top: 10px;
  margin-bottom: 5px;
}
.text {
  height: 100%;
  max-height: 30vh;
  padding: 0.15rem 1.25rem;
  color: white;
  transition: all 0.3s ease-in;
  ${({ isHover }) =>
    isHover &&
    `
  color:black;
  transition: all 0.3s ease-in;
   `}
}
.card-about {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
}
.card-tag {
  width: 60px;
  max-width: 100px;
  padding: 0.2rem 0.5rem;
  font-size: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: #ffab00;
  color: #fff;
}
.card-info {
  position: relative;
}
</code>```

I do not know how I could solve this I would need to leave my container and responsive text that my container follows the height of the text or that the text has a maximum height

答:
Just set height auto on mobile devices like this

```<code>@media only screen and (max-width: 600px) {
 .wrapper {
  height: auto;
  max-height: auto;
 }
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
desktop:

mobile devices:

Hello I have a problem my text is passing my maximum height
I would like my container to follow the height and that my text has maximum width of my container my text

code:

          NEWS

6/11/2018

dasssssssssssssssss

        aaaaaaaaaaaaa dasuhdasudhu dasuhduashu aaaaaaaaaaaaa dasuhdasudhu
        dasuhduashu aaaaaaaaaaaaa da aaaaaaaaaaaaa dasuhdasudhu dasuhduashu
        aaaaaaaaaaaaa dasuhdasudhu dasuhduashu aaaaaaaaaaaaa dasuhdasudhu
        dasuhduashu aaaaaaaaaaaaa dasuhdasudhu dasuhduashusuhdasudhu
        dasuhduashu aaaaaaaaaaaaa dasuhdasudhu dasuhduashu

css:

.App {
  padding: 20px;
  font-family: sans-serif;
  text-align: center;
  background: red;
  height: 40vh;
}

.wrapper {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 30vh;
  max-height: 30vh;
  border-radius: 10px;
  cursor: pointer;
  background:blue;

}
.textxd {
  margin-top: 10px;
  margin-bottom: 5px;
}
.text {
  height: 100%;
  max-height: 30vh;
  padding: 0.15rem 1.25rem;
  color: white;
  transition: all 0.3s ease-in;
  ${({ isHover }) =>
    isHover &&
    `
  color:black;
  transition: all 0.3s ease-in;
   `}
}
.card-about {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
}
.card-tag {
  width: 60px;
  max-width: 100px;
  padding: 0.2rem 0.5rem;
  font-size: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: #ffab00;
  color: #fff;
}
.card-info {
  position: relative;
}

I do not know how I could solve this I would need to leave my container and responsive text that my container follows the height of the text or that the text has a maximum height

Body:
Just set height auto on mobile devices like this

@media only screen and (max-width: 600px) {
 .wrapper {
  height: auto;
  max-height: auto;
 }
}


问:
restful service attempt gives build error that i am unable to decipher
I'm following the spring.io tutorial on building a restful service. (https://spring.io/guides/gs/rest-service/).
I run the application with gradlew bootRun.

```<code>  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.4.RELEASE)

2020-02-14 13:21:59.768  INFO 9504 --- [           main] c.e.restservice.RestServiceApplication   : Starting RestServiceApplication on DESKTOP-6L8BU2S with PID 9504 (C:\Users\Gebruiker\IdeaProjects\rest-service\build\classes\java\main started by Gebruiker in C:\Users\Gebruiker\IdeaProjects\rest-service)
2020-02-14 13:21:59.770  INFO 9504 --- [           main] c.e.restservice.RestServiceApplication   : No active profile set, falling back to default profiles: default
2020-02-14 13:22:00.630  INFO 9504 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-02-14 13:22:00.641  INFO 9504 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-02-14 13:22:00.642  INFO 9504 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-02-14 13:22:00.723  INFO 9504 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-02-14 13:22:00.723  INFO 9504 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 888 ms
2020-02-14 13:22:00.904  INFO 9504 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-14 13:22:01.024  INFO 9504 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-02-14 13:22:01.029  INFO 9504 --- [           main] c.e.restservice.RestServiceApplication   : Started RestServiceApplication in 1.57 seconds (JVM running for 1.943)
2020-02-14 13:23:10.145  INFO 9504 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-02-14 13:23:10.145  INFO 9504 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-02-14 13:23:10.153  INFO 9504 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 8 ms
<=========----> 75% EXECUTING [9m 1s]                                                                                > :bootRun
</code>```

This gives me a Whitelabel Error Page, my intelliJ IDEA gives me an error when building the application, but I don't know what to do about this error because it gives little information:

build error

答:
Looks like it might version incompatibility between Gradle and IntelliJ.

Try updating IntelliJ to latest version.

Body:
I'm following the spring.io tutorial on building a restful service. (https://spring.io/guides/gs/rest-service/).
I run the application with gradlew bootRun.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.4.RELEASE)

2020-02-14 13:21:59.768  INFO 9504 --- [           main] c.e.restservice.RestServiceApplication   : Starting RestServiceApplication on DESKTOP-6L8BU2S with PID 9504 (C:\Users\Gebruiker\IdeaProjects\rest-service\build\classes\java\main started by Gebruiker in C:\Users\Gebruiker\IdeaProjects\rest-service)
2020-02-14 13:21:59.770  INFO 9504 --- [           main] c.e.restservice.RestServiceApplication   : No active profile set, falling back to default profiles: default
2020-02-14 13:22:00.630  INFO 9504 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-02-14 13:22:00.641  INFO 9504 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-02-14 13:22:00.642  INFO 9504 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-02-14 13:22:00.723  INFO 9504 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-02-14 13:22:00.723  INFO 9504 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 888 ms
2020-02-14 13:22:00.904  INFO 9504 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-14 13:22:01.024  INFO 9504 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-02-14 13:22:01.029  INFO 9504 --- [           main] c.e.restservice.RestServiceApplication   : Started RestServiceApplication in 1.57 seconds (JVM running for 1.943)
2020-02-14 13:23:10.145  INFO 9504 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-02-14 13:23:10.145  INFO 9504 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-02-14 13:23:10.153  INFO 9504 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 8 ms
<=========----> 75% EXECUTING [9m 1s]                                                                                > :bootRun

This gives me a Whitelabel Error Page, my intelliJ IDEA gives me an error when building the application, but I don't know what to do about this error because it gives little information:

build error


问:
Hide custom cursor when mouseover on iframe
I am struggling trying to find out how to hide my custom cursor when it's over an iframe.

I designed a custom cursor but it works fine in all the web sections. However, when it goes over he Vimeo iframe, the mouse stay at the edge of the iframe and shows the default web browser cursor.

I think the easiest way, would be hide the custom cursor whenever I make mouseover on the iframe.

Trying to figure out by using CSS (applying display:none when is the custom cursor is over the iframe) and js but none worked out.

Here the code in codepen: https://codepen.io/felixgonzalo/pen/vYOLrVJ

This is the code:
JS

```<code>let mouseCursor = document.querySelector(".cursor");
let Links = document.querySelectorAll("a");
let logo = document.querySelector(".logo-error");

window.addEventListener('mousemove', cursor);

function cursor(e){

    mouseCursor.style.top = e.pageY + "px";
    mouseCursor.style.left = e.pageX + "px";
}

Links.forEach(link =>{

    if ( link !== logo ){

        link.addEventListener("mouseleave", () => {

            mouseCursor.classList.remove("link-grow");
        });

        link.addEventListener("mouseover", () => {

            mouseCursor.classList.add("link-grow");
        });
    }

});
</code>```

CSS

```<code>body{
    cursor: none;

}

.cursor{
    width: 2rem;
    height: 2rem;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    transition-property: background, transform;
    transform-origin: 100% 100%;
    z-index: 20000;
    pointer-events: none;
}

.link-grow{
    transform: scale(1.2);
    background: white;
    mix-blend-mode: difference;

}

a:-webkit-any-link {
    cursor: none;
}

.logo-error:hover .cursor{
    display: none !important;
}

@media (max-width: 768px){
  .cursor {
    display: none;

  }
}
</code>```

答:
Basically, you need 3 things here:

Get the iframe element

var iframe = document.querySelector("iframe");```
</div>
</div>
</p>

<ol start="2">
<li>Add <code>mouseover</code> event handler</li>
</ol>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>iframe.addEventListener("mouseover", function() {
  mouseCursor.style.display = 'none';
})</code>```

Add mouseleave event handler

iframe.addEventListener("mouseleave", function() {
  mouseCursor.style.display = 'block';
})```

Now, your custom cursor will be hidden whenever you hover over the iframe, and it will become visible again once you move the mouse away from your iframe.

PLEASE NOTE: Be aware that I am using querySelector which returns the FIRST selector only, so in case you have many iFrames, it will only apply the code on the first one. To avoid this, you either use querySelectorAll or getElementsByTagName, loop over the returned array, and inject the event.

Body:
I am struggling trying to find out how to hide my custom cursor when it's over an iframe.

I designed a custom cursor but it works fine in all the web sections. However, when it goes over he Vimeo iframe, the mouse stay at the edge of the iframe and shows the default web browser cursor.

I think the easiest way, would be hide the custom cursor whenever I make mouseover on the iframe.

Trying to figure out by using CSS (applying display:none when is the custom cursor is over the iframe) and js but none worked out.

Here the code in codepen: https://codepen.io/felixgonzalo/pen/vYOLrVJ

This is the code:
JS

let mouseCursor = document.querySelector(".cursor");
let Links = document.querySelectorAll("a");
let logo = document.querySelector(".logo-error");

window.addEventListener('mousemove', cursor);

function cursor(e){

    mouseCursor.style.top = e.pageY + "px";
    mouseCursor.style.left = e.pageX + "px";
}

Links.forEach(link =>{

    if ( link !== logo ){

        link.addEventListener("mouseleave", () => {

            mouseCursor.classList.remove("link-grow");
        });

        link.addEventListener("mouseover", () => {

            mouseCursor.classList.add("link-grow");
        });
    }

});

CSS

body{
    cursor: none;

}

.cursor{
    width: 2rem;
    height: 2rem;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    transition-property: background, transform;
    transform-origin: 100% 100%;
    z-index: 20000;
    pointer-events: none;
}

.link-grow{
    transform: scale(1.2);
    background: white;
    mix-blend-mode: difference;

}

a:-webkit-any-link {
    cursor: none;
}

.logo-error:hover .cursor{
    display: none !important;
}

@media (max-width: 768px){
  .cursor {
    display: none;

  }
}

Body:
Basically, you need 3 things here:

Get the iframe element

var iframe = document.querySelector("iframe");

Add mouseover event handler

iframe.addEventListener("mouseover", function() {
  mouseCursor.style.display = 'none';
})

Add mouseleave event handler

iframe.addEventListener("mouseleave", function() {
  mouseCursor.style.display = 'block';
})

Now, your custom cursor will be hidden whenever you hover over the iframe, and it will become visible again once you move the mouse away from your iframe.

PLEASE NOTE: Be aware that I am using querySelector which returns the FIRST selector only, so in case you have many iFrames, it will only apply the code on the first one. To avoid this, you either use querySelectorAll or getElementsByTagName, loop over the returned array, and inject the event.


问:
gcloud sql instances patch fails with invalid data error
When trying to add high availability on an existing Cloud SQL instance using:

gcloud sql instances patch $INSTANCE --project $PROJECT --availability-type regional

the process fails with this message

The following message will be used for the patch API method.
{"project": "$PROJECT", "name": "$INSTANCE", "settings": {"availabilityType": "REGIONAL", "databaseFlags": [{"name": "sql_mode", "value": "TRADITIONAL"}, {"name": "default_time_zone", "value": "+01:00"}]}}
ERROR: (gcloud.sql.instances.patch) HTTPError 400: The incoming request contained invalid data.

It also fails using the web interface.
Gcloud version Google Cloud SDK [280.0.0]
This is the output of the log (not much help that I can see):

```<code>2020-02-14 11:01:34,476 DEBUG    root            Loaded Command Group: [u'gcloud', u'sql', u'instances']
2020-02-14 11:01:34,510 DEBUG    root            Loaded Command Group: [u'gcloud', u'sql', u'instances', u'patch']
2020-02-14 11:01:34,517 DEBUG    root            Running [gcloud.sql.instances.patch] with arguments: [--availability-type: "regional", --project: "$PROJECT", INSTANCE: "$INSTANCE"]
2020-02-14 11:01:35,388 INFO     ___FILE_ONLY___ The following message will be used for the patch API method.

2020-02-14 11:01:35,398 INFO     ___FILE_ONLY___ {"project": "$PROJECT", "name": "$INSTANCE", "settings": {"availabilityType": "REGIONAL", "databaseFlags": [{"name": "sql_mode", "value": "TRADITIONAL"}, {"name": "default_time_zone", "value": "+01:00"}]}}

2020-02-14 11:01:35,865 DEBUG    root            (gcloud.sql.instances.patch) HTTPError 400: The incoming request contained invalid data.
Traceback (most recent call last):
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 981, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 807, in Run
    resources = command_instance.Run(args)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\surface\sql\instances\patch.py", line 306, in Run
    return RunBasePatchCommand(args, self.ReleaseTrack())
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\surface\sql\instances\patch.py", line 278, in RunBasePatchCommand
    instance=instance_ref.instance))
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\third_party\apis\sql\v1beta4\sql_v1beta4_client.py", line 697, in Patch
    config, request, global_params=global_params)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\third_party\apitools\base\py\base_api.py", line 731, in _RunMethod
    return self.ProcessHttpResponse(method_config, http_response, request)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\third_party\apitools\base\py\base_api.py", line 737, in ProcessHttpResponse
    self.__ProcessHttpResponse(method_config, http_response, request))
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\third_party\apitools\base\py\base_api.py", line 604, in __ProcessHttpResponse
    http_response, method_config=method_config, request=request)
HttpBadRequestError: HttpError accessing <https://sqladmin.googleapis.com/sql/v1beta4/projects/$PROJECT/instances/$INSTANCE?alt=json>: response: <{'status': '400', 'content-length': '269', 'x-xss-protection': '0', 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer', 'server': 'ESF', '-content-encoding': 'gzip', 'cache-control': 'private', 'date': 'Fri, 14 Feb 2020 10:01:35 GMT', 'x-frame-options': 'SAMEORIGIN', 'alt-svc': 'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000', 'content-type': 'application/json; charset=UTF-8'}>, content <{
  "error": {
    "code": 400,
    "message": "The incoming request contained invalid data.",
    "errors": [
      {
        "message": "The incoming request contained invalid data.",
        "domain": "global",
        "reason": "invalidRequest"
      }
    ]
  }
}
>
2020-02-14 11:01:35,868 ERROR    root            (gcloud.sql.instances.patch) HTTPError 400: The incoming request contained invalid data.
2020-02-14 11:01:35,898 DEBUG    root            Metrics reporting process started...
</code>```

Edit:

When using the gcloud cli command:

gcloud patch with 3 input parameters

Both $PROJECT and $INSTANCE do exist since I can gcloud sql databases list --instance $INSTANCE --project $PROJECT and it works fine.

availability-type=regional it's documented so should work

I'm not constructing the request manually, I'm using gcloud CLI

When using the console.cloud.google.com web interface:

Main menu -> SQL -> select instance -> Enable High Availability.
It's a button, no parameters added by myself.

Both return the same error "The incoming request contained invalid data."
Can't see how I may be doing it wrong.

答:
Please check your data in the incoming request.

I used the Method: instances.patch and it worked as expected for me.

project
instance-name

request body:

```<code>

  "settings": {
    "availabilityType": "REGIONAL",
    "databaseFlags": [
      {
        "name": "sql_mode",
        "value": "TRADITIONAL"
      },
      {
        "name": "default_time_zone",
        "value": "+01:00"
      }
    ]
  }
}
</code>```

Curl command:

```<code>  'https://sqladmin.googleapis.com/sql/v1beta4/projects/your-project/instances/your_instancet?key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"settings":{"availabilityType":"REGIONAL","databaseFlags":[{"name":"sql_mode","value":"TRADITIONAL"},{"name":"default_time_zone","value":"+01:00"}]}}' \
  --compressed```
```

<p>Response 200:</p>

```{
  "kind": "sql#operation",
  "targetLink": "https://content-sqladmin.googleapis.com/sql/v1beta4/projects/your-project/instances/your-instance",
  "status": "PENDING",
  "user": "@cloud.com",
  "insertTime": "2020-02-14T12:35:37.615Z",
  "operationType": "UPDATE",
  "name": "3f55c1be-97b5-4d37-8d1f-15cb61b4c6cc",
  "targetId": "your-instance",
  "selfLink": "https://content-sqladmin.googleapis.com/sql/v1beta4/projects/wave25-vladoi/operations/3f55c1be-97b5-4d37-8d1f-15cb61b4c6cc",
  "targetProject": "your-project"
}
```

Body:
When trying to add high availability on an existing Cloud SQL instance using:

gcloud sql instances patch $INSTANCE --project $PROJECT --availability-type regional

the process fails with this message

The following message will be used for the patch API method.
{"project": "$PROJECT", "name": "$INSTANCE", "settings": {"availabilityType": "REGIONAL", "databaseFlags": [{"name": "sql_mode", "value": "TRADITIONAL"}, {"name": "default_time_zone", "value": "+01:00"}]}}
ERROR: (gcloud.sql.instances.patch) HTTPError 400: The incoming request contained invalid data.

It also fails using the web interface.
Gcloud version Google Cloud SDK [280.0.0]
This is the output of the log (not much help that I can see):

2020-02-14 11:01:34,476 DEBUG    root            Loaded Command Group: [u'gcloud', u'sql', u'instances']
2020-02-14 11:01:34,510 DEBUG    root            Loaded Command Group: [u'gcloud', u'sql', u'instances', u'patch']
2020-02-14 11:01:34,517 DEBUG    root            Running [gcloud.sql.instances.patch] with arguments: [--availability-type: "regional", --project: "$PROJECT", INSTANCE: "$INSTANCE"]
2020-02-14 11:01:35,388 INFO     ___FILE_ONLY___ The following message will be used for the patch API method.

2020-02-14 11:01:35,398 INFO     ___FILE_ONLY___ {"project": "$PROJECT", "name": "$INSTANCE", "settings": {"availabilityType": "REGIONAL", "databaseFlags": [{"name": "sql_mode", "value": "TRADITIONAL"}, {"name": "default_time_zone", "value": "+01:00"}]}}

2020-02-14 11:01:35,865 DEBUG    root            (gcloud.sql.instances.patch) HTTPError 400: The incoming request contained invalid data.
Traceback (most recent call last):
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 981, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 807, in Run
    resources = command_instance.Run(args)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\surface\sql\instances\patch.py", line 306, in Run
    return RunBasePatchCommand(args, self.ReleaseTrack())
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\surface\sql\instances\patch.py", line 278, in RunBasePatchCommand
    instance=instance_ref.instance))
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\third_party\apis\sql\v1beta4\sql_v1beta4_client.py", line 697, in Patch
    config, request, global_params=global_params)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\third_party\apitools\base\py\base_api.py", line 731, in _RunMethod
    return self.ProcessHttpResponse(method_config, http_response, request)
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\third_party\apitools\base\py\base_api.py", line 737, in ProcessHttpResponse
    self.__ProcessHttpResponse(method_config, http_response, request))
  File "C:\Users\udAL\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\third_party\apitools\base\py\base_api.py", line 604, in __ProcessHttpResponse
    http_response, method_config=method_config, request=request)
HttpBadRequestError: HttpError accessing <https://sqladmin.googleapis.com/sql/v1beta4/projects/$PROJECT/instances/$INSTANCE?alt=json>: response: <{'status': '400', 'content-length': '269', 'x-xss-protection': '0', 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer', 'server': 'ESF', '-content-encoding': 'gzip', 'cache-control': 'private', 'date': 'Fri, 14 Feb 2020 10:01:35 GMT', 'x-frame-options': 'SAMEORIGIN', 'alt-svc': 'quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000', 'content-type': 'application/json; charset=UTF-8'}>, content <{
  "error": {
    "code": 400,
    "message": "The incoming request contained invalid data.",
    "errors": [
      {
        "message": "The incoming request contained invalid data.",
        "domain": "global",
        "reason": "invalidRequest"
      }
    ]
  }
}
>
2020-02-14 11:01:35,868 ERROR    root            (gcloud.sql.instances.patch) HTTPError 400: The incoming request contained invalid data.
2020-02-14 11:01:35,898 DEBUG    root            Metrics reporting process started...

Edit:

When using the gcloud cli command:

gcloud patch with 3 input parameters

Both $PROJECT and $INSTANCE do exist since I can gcloud sql databases list --instance $INSTANCE --project $PROJECT and it works fine.

availability-type=regional it's documented so should work

I'm not constructing the request manually, I'm using gcloud CLI

When using the console.cloud.google.com web interface:

Main menu -> SQL -> select instance -> Enable High Availability.
It's a button, no parameters added by myself.

Both return the same error "The incoming request contained invalid data."
Can't see how I may be doing it wrong.

Body:
Please check your data in the incoming request.

I used the Method: instances.patch and it worked as expected for me.

project
instance-name

request body:

  "settings": {
    "availabilityType": "REGIONAL",
    "databaseFlags": [
      {
        "name": "sql_mode",
        "value": "TRADITIONAL"
      },
      {
        "name": "default_time_zone",
        "value": "+01:00"
      }
    ]
  }
}

Curl command:

  'https://sqladmin.googleapis.com/sql/v1beta4/projects/your-project/instances/your_instancet?key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"settings":{"availabilityType":"REGIONAL","databaseFlags":[{"name":"sql_mode","value":"TRADITIONAL"},{"name":"default_time_zone","value":"+01:00"}]}}' \
  --compressed```

Response 200:

{
  "kind": "sql#operation",
  "targetLink": "https://content-sqladmin.googleapis.com/sql/v1beta4/projects/your-project/instances/your-instance",
  "status": "PENDING",
  "user": "@cloud.com",
  "insertTime": "2020-02-14T12:35:37.615Z",
  "operationType": "UPDATE",
  "name": "3f55c1be-97b5-4d37-8d1f-15cb61b4c6cc",
  "targetId": "your-instance",
  "selfLink": "https://content-sqladmin.googleapis.com/sql/v1beta4/projects/wave25-vladoi/operations/3f55c1be-97b5-4d37-8d1f-15cb61b4c6cc",
  "targetProject": "your-project"
}


答:
Remove the first leadmanager, like this:</p>

```<code>web: gunicorn leadmanager.wsgi --log-file -
</code>```

Title: ModuleNotFoundError: No module named 'App Name' when using Django and Gunicorn on a heroku server

Body:
What I am trying to do here is setup a sample django app in heroku server. When running the app with gunicorn I get this error

This is what's in the log.

2020-02-14T12:11:30.549141+00:00 heroku[web.1]: State changed from crashed to starting
2020-02-14T12:11:41.607618+00:00 heroku[web.1]: Starting process with command `gunicorn leadmanager.wsgi --log-file -`
2020-02-14T12:11:44.346394+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-02-14T12:11:44.347348+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [4] [INFO] Listening at: http://0.0.0.0:54007 (4)
2020-02-14T12:11:44.347349+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [4] [INFO] Using worker: sync
2020-02-14T12:11:44.351554+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [10] [INFO] Booting worker with pid: 10
2020-02-14T12:11:44.359278+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [11] [INFO] Booting worker with pid: 11
2020-02-14T12:11:45.104994+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-14T12:11:44.664943+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [11] [ERROR] Exception in worker process
2020-02-14T12:11:44.664951+00:00 app[web.1]: Traceback (most recent call last):
2020-02-14T12:11:44.664953+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-02-14T12:11:44.664953+00:00 app[web.1]: worker.init_process()
2020-02-14T12:11:44.664954+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-02-14T12:11:44.664954+00:00 app[web.1]: self.load_wsgi()
2020-02-14T12:11:44.664955+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-02-14T12:11:44.664955+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-02-14T12:11:44.664955+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-02-14T12:11:44.664956+00:00 app[web.1]: self.callable = self.load()
2020-02-14T12:11:44.664956+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-02-14T12:11:44.664957+00:00 app[web.1]: return self.load_wsgiapp()
2020-02-14T12:11:44.664957+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-02-14T12:11:44.664957+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-02-14T12:11:44.664958+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
2020-02-14T12:11:44.664959+00:00 app[web.1]: mod = importlib.import_module(module)
2020-02-14T12:11:44.664959+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2020-02-14T12:11:44.664961+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-02-14T12:11:44.664961+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2020-02-14T12:11:44.664962+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2020-02-14T12:11:44.664962+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
2020-02-14T12:11:44.664962+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
2020-02-14T12:11:44.664963+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 728, in exec_module
2020-02-14T12:11:44.664963+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-02-14T12:11:44.664964+00:00 app[web.1]: File "/app/leadmanager/wsgi.py", line 16, in <module>
2020-02-14T12:11:44.664964+00:00 app[web.1]: application = get_wsgi_application()
2020-02-14T12:11:44.664964+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2020-02-14T12:11:44.664965+00:00 app[web.1]: django.setup(set_prefix=False)
2020-02-14T12:11:44.664965+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
2020-02-14T12:11:44.664966+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2020-02-14T12:11:44.664966+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
2020-02-14T12:11:44.664966+00:00 app[web.1]: app_config = AppConfig.create(entry)
2020-02-14T12:11:44.664967+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
2020-02-14T12:11:44.664967+00:00 app[web.1]: module = import_module(entry)
2020-02-14T12:11:44.664967+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2020-02-14T12:11:44.664968+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-02-14T12:11:44.664968+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2020-02-14T12:11:44.664969+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2020-02-14T12:11:44.664969+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
2020-02-14T12:11:44.664970+00:00 app[web.1]: ModuleNotFoundError: No module named 'leads'

In the settings.py I am including the apps like this

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'whitenoise.runserver_nostatic',
    'rest_framework',
    'leads',
    'frontend',
    'knox',
    'accounts'
]

I will attach an image of my folder structure

this is working fine in my localhost but when ran on the heroku server with gunicorn results in this "Module not found error"

Sorry I am new to django and was not able to find a solution for this issue

Body:
Remove the first leadmanager, like this:

web: gunicorn leadmanager.wsgi --log-file -


问:
How to ignore specific charactor and new line using regex
I am trying to validate a csv file using Apache-NiFi.

My CSV file has some defects.

```<code>id,name,address
1,sachith,{"Lane":"ABC.RTG.EED","No":"12"}
2,nalaka,{"Lane":"DEF",
"No":"23"}
3,muha,{"Lane":"GRF.FFF","No":"%$&%*^%"}
</code>```

Here in second row,its been divided into two lines and third row has some special characters.

I want to ignore both the lines. For that I use \{("\w+":"\w+",)*[^%&*@]*\}, but this is not capturing row split error and new line.

I also used \{("\w+":"\w+",)*[^%&*@]*\}$, but it doesnt even get the right answer.

Body:
I am trying to validate a csv file using Apache-NiFi.

My CSV file has some defects.

id,name,address
1,sachith,{"Lane":"ABC.RTG.EED","No":"12"}
2,nalaka,{"Lane":"DEF",
"No":"23"}
3,muha,{"Lane":"GRF.FFF","No":"%$&%*^%"}

Here in second row,its been divided into two lines and third row has some special characters.

I want to ignore both the lines. For that I use \{("\w+":"\w+",)*[^%&*@]*\}, but this is not capturing row split error and new line.

I also used \{("\w+":"\w+",)*[^%&*@]*\}$, but it doesnt even get the right answer.

Body: This is you might looking for: ^[0-9]+,[a-z]+,\{("\w+":"[\w\.]+","\w+":"[a-zA-Z0-9]+")\}$


问:
if statement never returns true in scala when comparing strings
I'm reading text from a text file in Scala. I'm having difficulties with if statements.

```<code>for (line <- Source.fromFile(filename).getLines) {
    if (line.length>7) {
        println("b1  >" + line(7)+ "<    " + line(0).getType)
        if(line(7)=="#") {
            println("hashtag")
        }
    }
}
</code>```

below is 2 lines from my text file. the first line has 4 spaces followed by many hashtags. the second line is 4 spaces followed by 1 hashtag (the 4 spaces keep getting deleted by stack overflow)

```<code>##################################################################################################################################################
#
</code>```

below is the output i recieve

```<code>//| b1  >#<    12
//| b1  > <    12
</code>```

Question 1) why is getType returning 12? This is the strangest data type I've ever heard of.

Question 2) (possibly answered by Q1) why does the if(line(7)=="#") statement never returns true?

答:
To answer your questions in reverse order:

Question 2. Because line is a String, line(7) is a Char which is never equal to a String. You want to compare it with '#' instead.

Question 1. Because of the above, this calls Char.getType method which

Returns a value indicating a character's general category.

(not that you can find it from Scala's own documentation). You probably wanted getClass instead.

Body:
I'm reading text from a text file in Scala. I'm having difficulties with if statements.

for (line <- Source.fromFile(filename).getLines) {
    if (line.length>7) {
        println("b1  >" + line(7)+ "<    " + line(0).getType)
        if(line(7)=="#") {
            println("hashtag")
        }
    }
}

below is 2 lines from my text file. the first line has 4 spaces followed by many hashtags. the second line is 4 spaces followed by 1 hashtag (the 4 spaces keep getting deleted by stack overflow)

##################################################################################################################################################
#

below is the output i recieve

//| b1  >#<    12
//| b1  > <    12

Question 1) why is getType returning 12? This is the strangest data type I've ever heard of.

Question 2) (possibly answered by Q1) why does the if(line(7)=="#") statement never returns true?


问:
Volley error response bytes does not convert from bytes to string
```<code>CustomStringRequest customStringRequest = new CustomStringRequest(requestMethod.ordinal(), serverUrl,
            result -> {
                Log.d(TAG, "headers: " + result.headers);
                Log.d(TAG, "response: " + result.response);
                createTaskItem(result);
            },
            error -> {
                Log.d(TAG, "error: " + error);
            })
</code>```

error is in JSON string, I tried to get error like this:

```<code>new String(error.networkResponse.data, "utf-8");
new String(error.networkResponse.data);
</code>```

none of the above method works, i always get empty string, don't know why :(

as you can see bytes in picture, the error response is actually this:

```<code>   {
  "error": [
    "Wrong Credentials!"
  ],
  "email_exists": false
}
</code>```

I am using:

```<code>implementation 'com.android.volley:volley:1.1.1'
</code>```

答:
You can convert your response to json object using GSON ,

```<code> val customPojo = CustomPojo()

 val gson = Gson()
 gson.toJson(myPojo)
</code>```

CustomPojo should be your response model class.

Body:
CustomStringRequest customStringRequest = new CustomStringRequest(requestMethod.ordinal(), serverUrl,
            result -> {
                Log.d(TAG, "headers: " + result.headers);
                Log.d(TAG, "response: " + result.response);
                createTaskItem(result);
            },
            error -> {
                Log.d(TAG, "error: " + error);
            })

error is in JSON string, I tried to get error like this:

new String(error.networkResponse.data, "utf-8");
new String(error.networkResponse.data);

none of the above method works, i always get empty string, don't know why :(

as you can see bytes in picture, the error response is actually this:

   {
  "error": [
    "Wrong Credentials!"
  ],
  "email_exists": false
}

I am using:

implementation 'com.android.volley:volley:1.1.1'

Body:
You can convert your response to json object using GSON ,

 val customPojo = CustomPojo()

 val gson = Gson()
 gson.toJson(myPojo)

CustomPojo should be your response model class.


问:
How can I learn a multitouch screen's communication protocol and write a C# application for it?
I have got a monitor with multitouch overlay on top of it. It works fine with Windows 7 but I want to write a multitouch application in C# for Windows XP which doesn't support touch feature out of the box. There is no documentation whatsoever and I emailed the manufacturer but never got a reply.

However the device works with Google Earth, which doesn't natively support multitouch, on Windows XP. So I think it generates many types of messages together i.e. WM_TOUCH for Windows 7, one for Google Earth COM API, and probably its own messages either in UDP or Windows message form. How can I trap all communications and learn the protocol?

答: I've recently been developing on the Windows 7 platform for multitouch. I'm using UniTuio -- see http://xtuio.com You can look at my question I had to get it working. I'm also using a bridge for Windows 7 called Touch2TUIO, it seems to work quite well. If you need to make the mouse inactive see my question here: using windows 7 with unituio</p>

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
How to connect to KDB server using PyQ and Python?
I am using Python 2.7 and I have installed PyQ, with q (x64 version) set up correctly, under Debian 10.

The question is how to connect to a KDB server (I have the credentials (IP, port, user and password))?

答:
Start a pyq session, switch to the q interpreter then use hopen

```<code>Using the q interpreter in PyQ:
>>> q()
q)h:hopen `:localhost:1234 // `:host:port:user:pass
q)h"2+2"
q)4
</code>```

Edit - Further example from within Python and Creating A Pandas.DataFrame:

```<code>I have the following table defined on my q server process:

q)tbl:([]col1:`a`b`c;col2:til 3)
q)tbl
col1 col2
---------
a    0
b    1
c    2

Then from my client PyQ interpreter:

from pyq import q
import numpy as np # Numpy is needed as a middle man for interpreting kdb objects to python.
import pandas as pd
import datetime # if your kdb table has dates and times

q("h:hopen `:localhost:1234")
tbl2 = q("h\"tbl\"") # need to escape the quotes around tbl
tblNP = np.array(tbl2)
df = pd.DataFrame(tblNP)
df
  col1  col2
0    a     0
1    b     1
2    c     2
</code>```

Using qPython:

```<code>from qpython import qconnection
import pandas as pd

if __name__ == '__main__':
    # create connection object
    q = qconnection.QConnection(host='localhost', port=1234, pandas=True)
    # initialize connection
    q.open()

    # simple query execution via: QConnection.sendSync
    df = q.sendSync('tbl')
    # close connection
    q.close()
</code>```

See qSQL for how to select specific data from your tables. Tables in kdb can be very large and may be unwise to select the entire thing. e.q.

```<code>PyQ:
tbl2 = q("h\"select from trades where date = 2020.02.14\"")
qPython:
df = q.sendSync('select from trades where date = 2020.02.14')
</code>```

Are you planning on doing any data processing client side in q? If only looking to get data from the kdb server for use with python, qPython may be a better option.

Body:
Start a pyq session, switch to the q interpreter then use hopen

Using the q interpreter in PyQ:
>>> q()
q)h:hopen `:localhost:1234 // `:host:port:user:pass
q)h"2+2"
q)4

Edit - Further example from within Python and Creating A Pandas.DataFrame:

I have the following table defined on my q server process:

q)tbl:([]col1:`a`b`c;col2:til 3)
q)tbl
col1 col2
---------
a    0
b    1
c    2

Then from my client PyQ interpreter:

from pyq import q
import numpy as np # Numpy is needed as a middle man for interpreting kdb objects to python.
import pandas as pd
import datetime # if your kdb table has dates and times

q("h:hopen `:localhost:1234")
tbl2 = q("h\"tbl\"") # need to escape the quotes around tbl
tblNP = np.array(tbl2)
df = pd.DataFrame(tblNP)
df
  col1  col2
0    a     0
1    b     1
2    c     2

Using qPython:

from qpython import qconnection
import pandas as pd

if __name__ == '__main__':
    # create connection object
    q = qconnection.QConnection(host='localhost', port=1234, pandas=True)
    # initialize connection
    q.open()

    # simple query execution via: QConnection.sendSync
    df = q.sendSync('tbl')
    # close connection
    q.close()

See qSQL for how to select specific data from your tables. Tables in kdb can be very large and may be unwise to select the entire thing. e.q.

PyQ:
tbl2 = q("h\"select from trades where date = 2020.02.14\"")
qPython:
df = q.sendSync('select from trades where date = 2020.02.14')

Are you planning on doing any data processing client side in q? If only looking to get data from the kdb server for use with python, qPython may be a better option.


问:
Cant run scm-server 2
I've downloaded scm-server 2 from Jenkins to run on my dedicated source code server. Unfortunately it won't start for some reason. It works on my desktop computer so probably there is just a package missing.

Using Ubuntu 18.04 with apache2 and jetty9 packages installed, which might be relevant.

Any ideas?

```<code>~/scm-server/bin$ ./scm-server
2019-09-16 10:33:58.689:INFO::main: Logging initialized @478ms to org.eclipse.jetty.util.log.StdErrLog
2019-09-16 10:33:59.595:INFO:oejs.Server:main: jetty-9.4.14.v20181114; built: 2018-11-14T21:20:31.478Z; git: c4550056e785fb5665914545889f21dc136ad9e6; jvm 12.0.2+10
2019-09-16 10:34:02.442:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /scm, did not find org.eclipse.jetty.jsp.JettyJspServlet
2019-09-16 10:34:02.514:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2019-09-16 10:34:02.516:INFO:oejs.session:main: No SessionScavenger set, using defaults
2019-09-16 10:34:02.525:INFO:oejs.session:main: node0 Scavenging every 600000ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventor (file:/home/klarre/scm-server/work/scm/webapp/WEB-INF/lib/classloader-leak-prevention-core-2.7.0.jar) to method java.lang.ClassLoader.isAncestor(java.lang.ClassLoader)
WARNING: Please consider reporting this to the maintainers of se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-09-16 10:34:04.105 [main] [          ] INFO  sonia.scm.lifecycle.BootstrapContextFilter - register for restart events
2019-09-16 10:34:04.125 [main] [          ] INFO  sonia.scm.event.LegmanScmEventBus - create new event bus ScmEventBus-1
2019-09-16 10:34:04.319:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@4dc8caa7{SCM-Manager 2.0.0-SNAPSHOT,/scm,file:///home/klarre/scm-server/work/scm/webapp/,UNAVAILABLE}{/home/klarre/scm-server/var/webapp/scm-webapp.war}
java.util.ServiceConfigurationError: sonia.scm.event.ScmEventBus: Provider sonia.scm.event.LegmanScmEventBus could not be instantiated
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:583)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:805)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:723)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
    at sonia.scm.util.ServiceUtil.getService(ServiceUtil.java:99)
    at sonia.scm.event.ScmEventBus.getInstance(ScmEventBus.java:89)
    at sonia.scm.lifecycle.BootstrapContextFilter.initializeContext(BootstrapContextFilter.java:75)
    at sonia.scm.lifecycle.BootstrapContextFilter.init(BootstrapContextFilter.java:68)
    at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)
    at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:744)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:368)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:852)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:415)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:382)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at sonia.scm.server.ScmServer.init(ScmServer.java:139)
    at sonia.scm.server.ScmServer.run(ScmServer.java:100)
    at sonia.scm.server.ScmServerDaemon.main(ScmServerDaemon.java:62)
Caused by:
java.util.ServiceConfigurationError: com.github.legman.HandlerFindingStrategy: service type not accessible to unnamed module @2c78d320
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:590)
    at java.base/java.util.ServiceLoader.checkCaller(ServiceLoader.java:570)
    at java.base/java.util.ServiceLoader.<init>(ServiceLoader.java:505)
    at java.base/java.util.ServiceLoader.load(ServiceLoader.java:1647)
    at com.github.legman.internal.ServiceLocator.locate(ServiceLocator.java:67)
    at com.github.legman.internal.ServiceLocator.locate(ServiceLocator.java:92)
    at com.github.legman.EventBus.<init>(EventBus.java:152)
    at sonia.scm.event.LegmanScmEventBus.create(LegmanScmEventBus.java:79)
    at sonia.scm.event.LegmanScmEventBus.<init>(LegmanScmEventBus.java:73)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:781)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:723)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
    at sonia.scm.util.ServiceUtil.getService(ServiceUtil.java:99)
    at sonia.scm.event.ScmEventBus.getInstance(ScmEventBus.java:89)
    at sonia.scm.lifecycle.BootstrapContextFilter.initializeContext(BootstrapContextFilter.java:75)
    at sonia.scm.lifecycle.BootstrapContextFilter.init(BootstrapContextFilter.java:68)
    at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)
    at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:744)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:368)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:852)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:415)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:382)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at sonia.scm.server.ScmServer.init(ScmServer.java:139)
    at sonia.scm.server.ScmServer.run(ScmServer.java:100)
    at sonia.scm.server.ScmServerDaemon.main(ScmServerDaemon.java:62)
2019-09-16 10:34:04.377:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2019-09-16 10:34:04.382:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@53d102a2{/,[file:///home/klarre/scm-server/var/webapp/docroot/],AVAILABLE}
2019-09-16 10:34:04.459:INFO:oejs.AbstractConnector:main: Started ServerConnector@18c49a9f{HTTP/1.1,[http/1.1]}{0.0.0.0:8088}
2019-09-16 10:34:04.460:INFO:oejs.Server:main: Started @6303ms
</code>```

答:
Took some time, but from version 2.0.0-rc4 on, SCM-Manager is compatible with Java 9 and above.

Here you can find out how to get the version: https://www.scm-manager.org/uncategorized/scm-manager-2-0-0-rc4/

Title: Cant run scm-server 2

Body:
I've downloaded scm-server 2 from Jenkins to run on my dedicated source code server. Unfortunately it won't start for some reason. It works on my desktop computer so probably there is just a package missing.

Using Ubuntu 18.04 with apache2 and jetty9 packages installed, which might be relevant.

Any ideas?

~/scm-server/bin$ ./scm-server
2019-09-16 10:33:58.689:INFO::main: Logging initialized @478ms to org.eclipse.jetty.util.log.StdErrLog
2019-09-16 10:33:59.595:INFO:oejs.Server:main: jetty-9.4.14.v20181114; built: 2018-11-14T21:20:31.478Z; git: c4550056e785fb5665914545889f21dc136ad9e6; jvm 12.0.2+10
2019-09-16 10:34:02.442:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /scm, did not find org.eclipse.jetty.jsp.JettyJspServlet
2019-09-16 10:34:02.514:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2019-09-16 10:34:02.516:INFO:oejs.session:main: No SessionScavenger set, using defaults
2019-09-16 10:34:02.525:INFO:oejs.session:main: node0 Scavenging every 600000ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventor (file:/home/klarre/scm-server/work/scm/webapp/WEB-INF/lib/classloader-leak-prevention-core-2.7.0.jar) to method java.lang.ClassLoader.isAncestor(java.lang.ClassLoader)
WARNING: Please consider reporting this to the maintainers of se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-09-16 10:34:04.105 [main] [          ] INFO  sonia.scm.lifecycle.BootstrapContextFilter - register for restart events
2019-09-16 10:34:04.125 [main] [          ] INFO  sonia.scm.event.LegmanScmEventBus - create new event bus ScmEventBus-1
2019-09-16 10:34:04.319:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@4dc8caa7{SCM-Manager 2.0.0-SNAPSHOT,/scm,file:///home/klarre/scm-server/work/scm/webapp/,UNAVAILABLE}{/home/klarre/scm-server/var/webapp/scm-webapp.war}
java.util.ServiceConfigurationError: sonia.scm.event.ScmEventBus: Provider sonia.scm.event.LegmanScmEventBus could not be instantiated
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:583)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:805)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:723)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
    at sonia.scm.util.ServiceUtil.getService(ServiceUtil.java:99)
    at sonia.scm.event.ScmEventBus.getInstance(ScmEventBus.java:89)
    at sonia.scm.lifecycle.BootstrapContextFilter.initializeContext(BootstrapContextFilter.java:75)
    at sonia.scm.lifecycle.BootstrapContextFilter.init(BootstrapContextFilter.java:68)
    at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)
    at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:744)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:368)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:852)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:415)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:382)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at sonia.scm.server.ScmServer.init(ScmServer.java:139)
    at sonia.scm.server.ScmServer.run(ScmServer.java:100)
    at sonia.scm.server.ScmServerDaemon.main(ScmServerDaemon.java:62)
Caused by:
java.util.ServiceConfigurationError: com.github.legman.HandlerFindingStrategy: service type not accessible to unnamed module @2c78d320
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:590)
    at java.base/java.util.ServiceLoader.checkCaller(ServiceLoader.java:570)
    at java.base/java.util.ServiceLoader.<init>(ServiceLoader.java:505)
    at java.base/java.util.ServiceLoader.load(ServiceLoader.java:1647)
    at com.github.legman.internal.ServiceLocator.locate(ServiceLocator.java:67)
    at com.github.legman.internal.ServiceLocator.locate(ServiceLocator.java:92)
    at com.github.legman.EventBus.<init>(EventBus.java:152)
    at sonia.scm.event.LegmanScmEventBus.create(LegmanScmEventBus.java:79)
    at sonia.scm.event.LegmanScmEventBus.<init>(LegmanScmEventBus.java:73)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:781)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:723)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
    at sonia.scm.util.ServiceUtil.getService(ServiceUtil.java:99)
    at sonia.scm.event.ScmEventBus.getInstance(ScmEventBus.java:89)
    at sonia.scm.lifecycle.BootstrapContextFilter.initializeContext(BootstrapContextFilter.java:75)
    at sonia.scm.lifecycle.BootstrapContextFilter.init(BootstrapContextFilter.java:68)
    at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)
    at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:744)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:368)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:852)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:415)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:382)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at sonia.scm.server.ScmServer.init(ScmServer.java:139)
    at sonia.scm.server.ScmServer.run(ScmServer.java:100)
    at sonia.scm.server.ScmServerDaemon.main(ScmServerDaemon.java:62)
2019-09-16 10:34:04.377:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2019-09-16 10:34:04.382:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@53d102a2{/,[file:///home/klarre/scm-server/var/webapp/docroot/],AVAILABLE}
2019-09-16 10:34:04.459:INFO:oejs.AbstractConnector:main: Started ServerConnector@18c49a9f{HTTP/1.1,[http/1.1]}{0.0.0.0:8088}
2019-09-16 10:34:04.460:INFO:oejs.Server:main: Started @6303ms


问:
Find question text block in image with Python Opencv
How can I select question blocks in a jpg file with questions in Python code? The codes below select texts. I want to select question blocks with their choices.

```<code>import cv2

image = cv2.imread('test2.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (9,9), 0)
thresh = cv2.adaptiveThreshold(blur,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV,11,30)

kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (9,9))
dilate = cv2.dilate(thresh, kernel, iterations=4)

cnts = cv2.findContours(dilate, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts\[0\] if len(cnts) == 2 else cnts\[1\]

ROI_number = 0
for c in cnts:
    area = cv2.contourArea(c)
    if area > 10000:
        x,y,w,h = cv2.boundingRect(c)
        cv2.rectangle(image, (x, y), (x + w, y + h), (36,255,12), 3)
        ROI = image\[y:y+h, x:x+w\]
        cv2.imwrite('ROI_{}.png'.format(ROI_number), ROI)
        ROI_number += 1

cv2.imshow('thresh', thresh)
cv2.imshow('dilate', dilate)
cv2.imshow('image', image)
cv2.waitKey()
</code>```

Desired result:

I drew the rectangles in the picture with the mouse. There are no rectangles in the original picture.

The original file is here:

答:
There can be better solutions but here is my approach:

Make erosion operation to image to be able to visible of paragraphs as just one contour.

Eliminate the middle line by doing it white.

Make erosion again after eliminating middle line.

Then your paragraphs will seem as one contour. Apply minAreaRect.

Draw rectangles to source image.

Note: I coded in C++ because my environment based on C++ and I am not familiar with Python but it should be simple to convert.

Here is the code and result images:

```<code>#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <vector>

using namespace std;
using namespace cv;

int main( int argc, char** argv )
{
    Mat img = imread("/ur/source/image/orijinal.jpg",CV_LOAD_IMAGE_GRAYSCALE);

    resize(img,img,Size(img.cols/4,img.rows/4));

    Mat org = img.clone();
    Mat element = getStructuringElement( MORPH_ELLIPSE,
                                         Size( 2*10 + 1, 2*10+1 ),
                                         Point( 5, 5 ) );

    Mat dst;
    erode( img, dst, element );

    for(int i=0;i<dst.rows;i++)
    {
        for(int j=0;j<dst.cols;j++)
        {
           if(dst.at<uchar>(Point(j,i))<252 && dst.at<uchar>(Point(j,i)) > 50 )
               dst.at<uchar>(Point(j,i)) = 255;
        }
    }

    Mat element2 = getStructuringElement( MORPH_ELLIPSE,
                                         Size( 2*10 + 1, 2*10+1 ),
                                         Point( 5, 5 ) );

    Mat dst2,threshold_output;
    erode( dst, dst2, element2);

        vector<vector<Point> > contours;
        vector<Vec4i> hierarchy;

        /// Detect edges using Threshold
        threshold( dst2, threshold_output, 100, 255, THRESH_BINARY );
        /// Find contours
        findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

        /// Find the rotated rectangles for each contour
        vector<RotatedRect> minRect( contours.size() );

        for( int i = 0; i < contours.size(); i++ )
            minRect[i] = minAreaRect( Mat(contours[i]) );

        /// Draw contours + rotated rects
        Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );
        Mat result_zero = Mat::zeros( threshold_output.size(), CV_8UC3 );

        for( int i = 0; i< contours.size(); i++ )
        {
            Scalar color(0,255,255);
            // detect contours
            drawContours( drawing, contours, i, color, 1, 8, vector<Vec4i>(), 0, Point() );

            Point2f rect_points[4]; minRect[i].points( rect_points );
            for( int j = 0; j < 4; j++ )
            {
                line( img, rect_points[j], rect_points[(j+1)%4], color, 1, 8 );
            }
        }

    imshow("Source",org);

    imshow("Output1",dst);

    imshow("Output2",dst2);

    imshow("Output3",img);

    waitKey(0);

    return 0;
}
</code>```

Source:

First erosion:

Eliminate middle line and erosion again:

After minAreaRect draw rectangles to source image:

Body:
How can I select question blocks in a jpg file with questions in Python code? The codes below select texts. I want to select question blocks with their choices.

import cv2

image = cv2.imread('test2.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (9,9), 0)
thresh = cv2.adaptiveThreshold(blur,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV,11,30)

kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (9,9))
dilate = cv2.dilate(thresh, kernel, iterations=4)

cnts = cv2.findContours(dilate, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts\[0\] if len(cnts) == 2 else cnts\[1\]

ROI_number = 0
for c in cnts:
    area = cv2.contourArea(c)
    if area > 10000:
        x,y,w,h = cv2.boundingRect(c)
        cv2.rectangle(image, (x, y), (x + w, y + h), (36,255,12), 3)
        ROI = image\[y:y+h, x:x+w\]
        cv2.imwrite('ROI_{}.png'.format(ROI_number), ROI)
        ROI_number += 1

cv2.imshow('thresh', thresh)
cv2.imshow('dilate', dilate)
cv2.imshow('image', image)
cv2.waitKey()

Desired result:

I drew the rectangles in the picture with the mouse. There are no rectangles in the original picture.

The original file is here:

Body:
There can be better solutions but here is my approach:

Make erosion operation to image to be able to visible of paragraphs as just one contour.

Eliminate the middle line by doing it white.

Make erosion again after eliminating middle line.

Then your paragraphs will seem as one contour. Apply minAreaRect.

Draw rectangles to source image.

Note: I coded in C++ because my environment based on C++ and I am not familiar with Python but it should be simple to convert.

Here is the code and result images:

#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <vector>

using namespace std;
using namespace cv;

int main( int argc, char** argv )
{
    Mat img = imread("/ur/source/image/orijinal.jpg",CV_LOAD_IMAGE_GRAYSCALE);

    resize(img,img,Size(img.cols/4,img.rows/4));

    Mat org = img.clone();
    Mat element = getStructuringElement( MORPH_ELLIPSE,
                                         Size( 2*10 + 1, 2*10+1 ),
                                         Point( 5, 5 ) );

    Mat dst;
    erode( img, dst, element );

    for(int i=0;i<dst.rows;i++)
    {
        for(int j=0;j<dst.cols;j++)
        {
           if(dst.at<uchar>(Point(j,i))<252 && dst.at<uchar>(Point(j,i)) > 50 )
               dst.at<uchar>(Point(j,i)) = 255;
        }
    }

    Mat element2 = getStructuringElement( MORPH_ELLIPSE,
                                         Size( 2*10 + 1, 2*10+1 ),
                                         Point( 5, 5 ) );

    Mat dst2,threshold_output;
    erode( dst, dst2, element2);

        vector<vector<Point> > contours;
        vector<Vec4i> hierarchy;

        /// Detect edges using Threshold
        threshold( dst2, threshold_output, 100, 255, THRESH_BINARY );
        /// Find contours
        findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

        /// Find the rotated rectangles for each contour
        vector<RotatedRect> minRect( contours.size() );

        for( int i = 0; i < contours.size(); i++ )
            minRect[i] = minAreaRect( Mat(contours[i]) );

        /// Draw contours + rotated rects
        Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );
        Mat result_zero = Mat::zeros( threshold_output.size(), CV_8UC3 );

        for( int i = 0; i< contours.size(); i++ )
        {
            Scalar color(0,255,255);
            // detect contours
            drawContours( drawing, contours, i, color, 1, 8, vector<Vec4i>(), 0, Point() );

            Point2f rect_points[4]; minRect[i].points( rect_points );
            for( int j = 0; j < 4; j++ )
            {
                line( img, rect_points[j], rect_points[(j+1)%4], color, 1, 8 );
            }
        }

    imshow("Source",org);

    imshow("Output1",dst);

    imshow("Output2",dst2);

    imshow("Output3",img);

    waitKey(0);

    return 0;
}

Source:

First erosion:

Eliminate middle line and erosion again:

After minAreaRect draw rectangles to source image:


问:
is there SQL injection?
I have this kind of code with statement query, could you help me is there SQL injection or it is a secure code?

```<code><%

  String aUser = request.getParameter("user");
  Conn aPlug = null;
  Statement aStatement = null;
  ResultSet aResultSet = null;

    aPlug = Conn.getPlug("fetchAssetId");
    aStatement = Conn.getConnection().createStatement();
    aResultSet = aStatement.executeQuery("select pass, file_name from users where user_id = owner and user_name = '" + aUser + "'");

    %>
</code>```

thank you

答:
Yes, this code is vulnerable.

Injection happens when you allow user provided values directly into your query. Here's the user provided value:

String aUser = request.getParameter("user");

It's coming from a GET parameter, i.e. ?user='; DROP TABLE..

And here's the bit where it's used in your query:

user_name = '" + aUser + "'

You should instead use a PreparedStatement, as described quite nicely on bobby-tables.

Title: is there SQL injection?

Body:
I have this kind of code with statement query, could you help me is there SQL injection or it is a secure code?

<%

  String aUser = request.getParameter("user");
  Conn aPlug = null;
  Statement aStatement = null;
  ResultSet aResultSet = null;

    aPlug = Conn.getPlug("fetchAssetId");
    aStatement = Conn.getConnection().createStatement();
    aResultSet = aStatement.executeQuery("select pass, file_name from users where user_id = owner and user_name = '" + aUser + "'");

    %>

thank you


问:
How to install mod_mono on Debian 10
I want to run ASP.NET MVC application in Debian 10 with Apache.
I have installed latest mono from mono Debian 10 repository using apt.

Trying to install mod_modo using

```<code>apt install libapache2-mod-mono
</code>```

throws error

```<code>> Reading package lists... Done Building dependency tree Reading state
> information... Done Some packages could not be installed. This may
> mean that you have requested an impossible situation or if you are
> using the unstable distribution that some required packages have not
> yet been created or been moved out of Incoming. The following
> information may help to resolve the situation:
>
> The following packages have unmet dependencies:  libapache2-mod-mono :
> Depends: mono-apache-server (< 4.6) but 4.7.1-0xamarin2+debian10b1 is
> to be installed or
>  mono-apache-server4 (< 4.6) but 4.7.1-0xamarin2+debian10b1 is to be installed or
> mono-apache-server2 (< 4.6) but it is not installable
> E: Unable to correct problems, you have held broken
> packages.
</code>```

How to install mod_mono on Debian 10 ?

/etc/apache2/mods-available  contans mod_mono.
Maybe it is sufficient to enable it in apache to get it work ?

/etc/sources.list contains:

```<code>deb http://ftp.debian.org/debian buster main contrib non-free
deb http://ftp.debian.org/debian buster-updates main contrib non-free
deb http://security.debian.org buster/updates main contrib non-free
</code>```

/etc/apt/sources.list.d  contains two files:

mono-official-stable-list:

```<code>deb https://download.mono-project.com/repo/debian stable-buster main
</code>```

and pgdg.list:

```<code>deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main
#deb-src http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main
</code>```

Update

I tried commands from GAD3R answer.

```<code>apt install libapache2-mod-mono
</code>```

still fails. Error message is a bit different:

```<code>Hit:1 http://security.debian.org buster/updates InRelease
Hit:2 http://ftp.debian.org/debian buster InRelease
Hit:3 http://ftp.debian.org/debian buster-updates InRelease
Hit:4 http://apt.postgresql.org/pub/repos/apt buster-pgdg InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
7 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libapache2-mod-mono : Depends: mono-apache-server (< 4.4) but 4.7.1-0xamarin2+debian10b1 is to be installed or
                                mono-apache-server4 (< 4.4) but 4.7.1-0xamarin2+debian10b1 is to be installed
E: Unable to correct problems, you have held broken packages.
</code>```

答:
Install libapache2-mod-mono from the official debian repository.

```<code>sudo rm /etc/apt/sources.list.d/mono-official-stable.list
</code>```

Then run :

```<code>sudo apt update
sudo apt purge mono.
sudo apt autoremove
sudo apt install libapache2-mod-mono
</code>```

please file a bug report to mono dev team on github.

Title: How to install mod_mono on Debian 10

Body:
I want to run ASP.NET MVC application in Debian 10 with Apache.
I have installed latest mono from mono Debian 10 repository using apt.

Trying to install mod_modo using

apt install libapache2-mod-mono

throws error

> Reading package lists... Done Building dependency tree Reading state
> information... Done Some packages could not be installed. This may
> mean that you have requested an impossible situation or if you are
> using the unstable distribution that some required packages have not
> yet been created or been moved out of Incoming. The following
> information may help to resolve the situation:
>
> The following packages have unmet dependencies:  libapache2-mod-mono :
> Depends: mono-apache-server (< 4.6) but 4.7.1-0xamarin2+debian10b1 is
> to be installed or
>  mono-apache-server4 (< 4.6) but 4.7.1-0xamarin2+debian10b1 is to be installed or
> mono-apache-server2 (< 4.6) but it is not installable
> E: Unable to correct problems, you have held broken
> packages.

How to install mod_mono on Debian 10 ?

/etc/apache2/mods-available  contans mod_mono.
Maybe it is sufficient to enable it in apache to get it work ?

/etc/sources.list contains:

deb http://ftp.debian.org/debian buster main contrib non-free
deb http://ftp.debian.org/debian buster-updates main contrib non-free
deb http://security.debian.org buster/updates main contrib non-free

/etc/apt/sources.list.d  contains two files:

mono-official-stable-list:

deb https://download.mono-project.com/repo/debian stable-buster main

and pgdg.list:

deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main
#deb-src http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main

Update

I tried commands from GAD3R answer.

apt install libapache2-mod-mono

still fails. Error message is a bit different:

Hit:1 http://security.debian.org buster/updates InRelease
Hit:2 http://ftp.debian.org/debian buster InRelease
Hit:3 http://ftp.debian.org/debian buster-updates InRelease
Hit:4 http://apt.postgresql.org/pub/repos/apt buster-pgdg InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
7 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libapache2-mod-mono : Depends: mono-apache-server (< 4.4) but 4.7.1-0xamarin2+debian10b1 is to be installed or
                                mono-apache-server4 (< 4.4) but 4.7.1-0xamarin2+debian10b1 is to be installed
E: Unable to correct problems, you have held broken packages.

Body:
Install libapache2-mod-mono from the official debian repository.

sudo rm /etc/apt/sources.list.d/mono-official-stable.list

Then run :

sudo apt update
sudo apt purge mono.
sudo apt autoremove
sudo apt install libapache2-mod-mono

please file a bug report to mono dev team on github.


问:
Glassfish admin console slow loading
Today I stopped/started my GlassfishV3 instance and now I cannot access the addmin console located at http://servername:4848/. The screen says:  "The admin console is loading..." This is going on forever now.

I have tried as follows:

I have tried adding the following entry to my domain.xml located at /glassfishv3/glassfish/domains/domain1/config as suggested in another Stack Overflow Q&A but after restarting the server still no luck.

<java-options>-Dcom.sun.enterprise.tools.admingui.NO_NETWORK=true</java-options>

I have also installed glassfishv3 on my local machine and cannot recreate the problem.I can go to http://localhost:4848 without any problem.

I have also looked at the server.log and jvm.log files located under the /glassfishv3/glassfish/domains/domain1/logs and nothing there that shed some light.

Any help would be very much appreciated

答:
I don't know if you are referencing this answer, but there is a second step described (disabling update module).

Two more ideas:

Check if the NO_NETWORK=true option really works (there should be no ads in GF admin console)

Watch the server.log (glassfish-install-dir/glassfis/domains/domain1/logs) during startup and look for the last log entry before the delay occurs. This could be a hint for the source of the delay.

Title: Glassfish admin console slow loading


问:
How to merge columns in temporary table while inserting data from a SubQuery in SQL?
I have a temp table #TestData as below where data is inserted using sub-query

```<code>Id      Amount         Ccy    Description
2012    2373350.000    INR    test1
2012    2321030.000    INR    test12
2014    2350.000       INR    test4
2014    30.000         USD    test5
2014    130.000        USD    test6
</code>```

code updated : using stuff and group by to concatenate strings hoever getting error invalid object Tmpta

```<code>      INSERT  INTO #TestData

       -- SELECT  Tmpta.Id,Tmpta.Amount,Tmpta.Ccy,tmpta.Description
     SELECT  Tmpta.Id ,
                    STUFF(( SELECT  ',' + CAST(B.[Amount] AS VARCHAR(20))
                            FROM    Tmpta B
                            WHERE   B.id = Tmpta.id
                            ORDER BY B.[Amount]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Amount ,
                    STUFF(( SELECT  ',' + B.[cur]
                            FROM    Tmpta B
                            WHERE   B.id = Tmpta.id
                            ORDER BY B.[cur]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Ccy ,
                    STUFF(( SELECT  ',' + B.[Description]
                            FROM    Tmpta B
                            WHERE   B.id = Tmpta.id
                            ORDER BY B.[Description]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Description
         FROM    ( SELECT SubQuery
                  ) Tmpta

         WHERE   tmpta.Id in (2012,2014)
         group by Tmpta.id
</code>```

I want to merge data as below :

```<code>Id      Amount                         Ccy          Description
2012    2373350.000,2321030.000        INR,INR      test1,test12
2014    2350.000,30.000,130.000        INR,USD,USD  test4,test5,test6
</code>```

any idea how we can achieve this?

Please help.
Thanks!

答:
if you want to use subquery then you can to put that data into the temp table and use that table in the query except using a subquery

DROP TABLE #Tmpta

SELECT ID,Amount,cur,Description
INTO #Tmpta
from data A

SELECT  #Tmpta.Id ,
                    STUFF(( SELECT  ',' + CAST(B.[Amount] AS VARCHAR(20))
                            FROM    #Tmpta B
                            WHERE   B.id = #Tmpta.id
                            ORDER BY B.[Amount]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Amount ,
                    STUFF(( SELECT  ',' + B.[cur]
                            FROM    #Tmpta B
                            WHERE   B.id = #Tmpta.id
                            ORDER BY B.[cur]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Ccy ,
                    STUFF(( SELECT  ',' + B.[Description]
                            FROM    #Tmpta B
                            WHERE   B.id = #Tmpta.id
                            ORDER BY B.[Description]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Description
         FROM    #Tmpta

```<code>     WHERE   #Tmpta.Id in (2012,2014)
     group by #Tmpta.id
</code>```

Body:
I have a temp table #TestData as below where data is inserted using sub-query

Id      Amount         Ccy    Description
2012    2373350.000    INR    test1
2012    2321030.000    INR    test12
2014    2350.000       INR    test4
2014    30.000         USD    test5
2014    130.000        USD    test6

code updated : using stuff and group by to concatenate strings hoever getting error invalid object Tmpta

      INSERT  INTO #TestData

       -- SELECT  Tmpta.Id,Tmpta.Amount,Tmpta.Ccy,tmpta.Description
     SELECT  Tmpta.Id ,
                    STUFF(( SELECT  ',' + CAST(B.[Amount] AS VARCHAR(20))
                            FROM    Tmpta B
                            WHERE   B.id = Tmpta.id
                            ORDER BY B.[Amount]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Amount ,
                    STUFF(( SELECT  ',' + B.[cur]
                            FROM    Tmpta B
                            WHERE   B.id = Tmpta.id
                            ORDER BY B.[cur]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Ccy ,
                    STUFF(( SELECT  ',' + B.[Description]
                            FROM    Tmpta B
                            WHERE   B.id = Tmpta.id
                            ORDER BY B.[Description]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Description
         FROM    ( SELECT SubQuery
                  ) Tmpta

         WHERE   tmpta.Id in (2012,2014)
         group by Tmpta.id

I want to merge data as below :

Id      Amount                         Ccy          Description
2012    2373350.000,2321030.000        INR,INR      test1,test12
2014    2350.000,30.000,130.000        INR,USD,USD  test4,test5,test6

any idea how we can achieve this?

Please help.
Thanks!

Body:
if you want to use subquery then you can to put that data into the temp table and use that table in the query except using a subquery

DROP TABLE #Tmpta

SELECT ID,Amount,cur,Description
INTO #Tmpta
from data A

SELECT  #Tmpta.Id ,
                    STUFF(( SELECT  ',' + CAST(B.[Amount] AS VARCHAR(20))
                            FROM    #Tmpta B
                            WHERE   B.id = #Tmpta.id
                            ORDER BY B.[Amount]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Amount ,
                    STUFF(( SELECT  ',' + B.[cur]
                            FROM    #Tmpta B
                            WHERE   B.id = #Tmpta.id
                            ORDER BY B.[cur]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Ccy ,
                    STUFF(( SELECT  ',' + B.[Description]
                            FROM    #Tmpta B
                            WHERE   B.id = #Tmpta.id
                            ORDER BY B.[Description]
                          FOR
                            XML PATH('')
                          ), 1, 1, '') AS Description
         FROM    #Tmpta

     WHERE   #Tmpta.Id in (2012,2014)
     group by #Tmpta.id


问:
javascript When I try to use a array ,it shows undefined
When I use the second array,it shows undefined,but I can use the first array.

```<code>this.$axios.get("/classes/")
  .then(response => {
    this.tableData = response.data;
    for (var i = 0; i < response.data.length; i++) {
      this.cName.push(response.data[i].className);
    }
    for (var ii = 0; ii < response.data.length; ii++) {
      this.$axios.get("/classStudent/?className=" + this.cName[ii])
        .then(response => {
          this.cPeoplecount.push(String(response.data.length));
        })
    }
  })
</code>```

the first array is cName,the second array is cPeoplecount.

答:
i guess all your code is inside a function then this should be a async function to do asynchronous using await on every axios request, as below:

```<code>async myFunction () {
  ...
  for (var ii = 0; ii < response.data.length; ii++) {
      await this.$axios.get() ...
  }
  ...
}
</code>```

Body:
When I use the second array,it shows undefined,but I can use the first array.

this.$axios.get("/classes/")
  .then(response => {
    this.tableData = response.data;
    for (var i = 0; i < response.data.length; i++) {
      this.cName.push(response.data[i].className);
    }
    for (var ii = 0; ii < response.data.length; ii++) {
      this.$axios.get("/classStudent/?className=" + this.cName[ii])
        .then(response => {
          this.cPeoplecount.push(String(response.data.length));
        })
    }
  })

the first array is cName,the second array is cPeoplecount.

Body:
i guess all your code is inside a function then this should be a async function to do asynchronous using await on every axios request, as below:

async myFunction () {
  ...
  for (var ii = 0; ii < response.data.length; ii++) {
      await this.$axios.get() ...
  }
  ...
}


问:
Add pages to PDF using FPDF if pagecount is not divisible by 4
Im trying to print some fpdf generated PDFs but if the page total is odd or not divisible by 4 then printing to a booklet is causing me some issues

eg total pages = 73 printing to a booklet on A3 paper needs 4 pages per A3 sheet

If i use this script

```<code>$pageCount = 73;
if ($pageCount % 4 != 0) {
$newpagecount = $pageCount += 4 - ($pageCount % 4);
}

while ($pageCount < $newpagecount) {
    $pageCount++;
//add page here and keep looping until it gets to the divisble by 4 number
}
</code>```

I get 76 which is correct and divisible by 4 what i need it to do is add a blank page to my source document until i get to the new divisible by 4 pageCount?

Any suggestions?
Thanks!

答:
In your while loop simply add a call to the AddPage method to create new pages as needed.

```<code>while ($pageCount < $newpagecount) {
    $pageCount++;
    $yourpdf->AddPage(); //add page here and keep looping until it gets to the divisble by 4 number
}
</code>```

Body:
Im trying to print some fpdf generated PDFs but if the page total is odd or not divisible by 4 then printing to a booklet is causing me some issues

eg total pages = 73 printing to a booklet on A3 paper needs 4 pages per A3 sheet

If i use this script

$pageCount = 73;
if ($pageCount % 4 != 0) {
$newpagecount = $pageCount += 4 - ($pageCount % 4);
}

while ($pageCount < $newpagecount) {
    $pageCount++;
//add page here and keep looping until it gets to the divisble by 4 number
}

I get 76 which is correct and divisible by 4 what i need it to do is add a blank page to my source document until i get to the new divisible by 4 pageCount?

Any suggestions?
Thanks!

Body:
In your while loop simply add a call to the AddPage method to create new pages as needed.

while ($pageCount < $newpagecount) {
    $pageCount++;
    $yourpdf->AddPage(); //add page here and keep looping until it gets to the divisble by 4 number
}