问:
SSL certificate rejected trying to access GitHub over HTTPS behind firewall
I'm stuck behind a firewall, so I have to use HTTPS to access my GitHub repository. I'm using Cygwin 1.7.7 on Windows XP.

I've tried setting the remote to https://username@github.com/username/ExcelANT.git, but pushing prompts for a password, but it doesn't do anything once I've entered it.
https://username:<password>github.com/username/ExcelANT.git and cloning the empty repository from scratch, but each time it gives me the same error:

error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/username/ExcelANT.git/info/refs

Turning on GIT_CURL_VERBOSE=1 gives me

* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * successfully set certificate verify locations:
*   CAfile: none
CApath: /usr/ssl/certs
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Closing connection #0
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * successfully set certificate verify locations:
*   CAfile: none
CApath: /usr/ssl/certs
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Closing connection #0
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/username/ExcelANT.git/info/refs

```<code>fatal: HTTP request failed
</code>```

Is this a problem with my firewall, Cygwin or what?

I hadn't set the HTTP proxy in the Git configuration. However, it's an ISA server that needs NTLM authentication, not basic, so unless anyone knows how to force Git to use NTLM, I'm scuppered.

答:
Note that for me to get this working (RVM install on CentOS 5.6), I had to run the following:

export GIT_SSL_NO_VERIFY=true

and after that, the standard install procedure for curling the RVM installer into Bash worked a treat :)

Body:
I'm stuck behind a firewall, so I have to use HTTPS to access my GitHub repository. I'm using Cygwin 1.7.7 on Windows XP.

I've tried setting the remote to https://username@github.com/username/ExcelANT.git, but pushing prompts for a password, but it doesn't do anything once I've entered it.
https://username:<password>github.com/username/ExcelANT.git and cloning the empty repository from scratch, but each time it gives me the same error:

error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/username/ExcelANT.git/info/refs

Turning on GIT_CURL_VERBOSE=1 gives me

* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * successfully set certificate verify locations:
*   CAfile: none
CApath: /usr/ssl/certs
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Closing connection #0
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * successfully set certificate verify locations:
*   CAfile: none
CApath: /usr/ssl/certs
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Closing connection #0
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/username/ExcelANT.git/info/refs

fatal: HTTP request failed

Is this a problem with my firewall, Cygwin or what?

I hadn't set the HTTP proxy in the Git configuration. However, it's an ISA server that needs NTLM authentication, not basic, so unless anyone knows how to force Git to use NTLM, I'm scuppered.


来源: stackexchange

问:
Cors not allowed while using Axios
Hey I was working with fetch a normal fetch to request my API in my server, and It was working, but I found out that Axios is easier, so I tried to replace every fetch, but it looks like xhr doesn't work because of cors,

I already allowed cors when I was working with fetch, but for some reason cors is not allowed for xhr (Axios) requests

here is Axios defaults:

```<code>import axios from "axios"
import store from "@/store"
import { getLocalStorage } from "@/services/functions.services.js"

axios.defaults.baseURL = store.getters.getData("serverLink")
axios.defaults.withCredentials = true

axios.defaults.headers.common["Authorization"] = `Bearer ${getLocalStorage("access_token")} ${getLocalStorage("refresh_token")}`

</code>```

and here is how I use Axios:

```<code>function fetchF(link, body, method) {
    return new Promise(async (resolve, reject) => {
        axios[method.toLowerCase()](link, body)
            .then(rsp => {
                setLocalStorage("access_token", rsp.access_token);
                setLocalStorage("refresh_token", rsp.refresh_token);
                resolve(rsp);
            }).catch(error => {
                setLocalStorage("access_token", "");
                setLocalStorage("refresh_token", "");
                store.dispatch("changeData", {
                    option: "alertEl",
                    value: "Please log in, and try again",
                });
                return resolve({ isSuccess: false, err: "Please log in, and try again" });
            })
    });
}
</code>```

and here is how I enabled cors on the server-side:

```<code>app.use(cors({
    credentials: true,
}));

</code>```

here is the error:
error in the network page

答:
Just to clarify how to change the Access-Control-Allow-Origin to a specific domain (@Cypherjac)

here is how:

```<code>app.use(cors({
    origin: "http://localhost:8080",
    credentials: true,
}));

</code>```

ContentLicense: CC BY-SA 4.0

Title: Cors not allowed while using Axios

Body:
Hey I was working with fetch a normal fetch to request my API in my server, and It was working, but I found out that Axios is easier, so I tried to replace every fetch, but it looks like xhr doesn't work because of cors,

I already allowed cors when I was working with fetch, but for some reason cors is not allowed for xhr (Axios) requests

here is Axios defaults:

import axios from "axios"
import store from "@/store"
import { getLocalStorage } from "@/services/functions.services.js"

axios.defaults.baseURL = store.getters.getData("serverLink")
axios.defaults.withCredentials = true

axios.defaults.headers.common["Authorization"] = `Bearer ${getLocalStorage("access_token")} ${getLocalStorage("refresh_token")}`

and here is how I use Axios:

function fetchF(link, body, method) {
    return new Promise(async (resolve, reject) => {
        axios[method.toLowerCase()](link, body)
            .then(rsp => {
                setLocalStorage("access_token", rsp.access_token);
                setLocalStorage("refresh_token", rsp.refresh_token);
                resolve(rsp);
            }).catch(error => {
                setLocalStorage("access_token", "");
                setLocalStorage("refresh_token", "");
                store.dispatch("changeData", {
                    option: "alertEl",
                    value: "Please log in, and try again",
                });
                return resolve({ isSuccess: false, err: "Please log in, and try again" });
            })
    });
}

and here is how I enabled cors on the server-side:

app.use(cors({
    credentials: true,
}));

here is the error:
error in the network page

Body:
Just to clarify how to change the Access-Control-Allow-Origin to a specific domain (@Cypherjac)

here is how:

app.use(cors({
    origin: "http://localhost:8080",
    credentials: true,
}));


问:
Angular converting project to PWA, Dependencies error?
I am getting issues dynamically loading components using the following syntax:

```<code>this.dynamicContentPlacehold.clear();
const { AccountManagerComponent } = await import('./account-manager/account-manager.component')
const factory = this.componentFactoryResolver.resolveComponentFactory(AccountManagerComponent);
const componentRef = this.dynamicContentPlacehold.createComponent(factory);
componentRef.instance.user = this.user;
</code>```

I get the following console error.

```<code>ChunkLoadError: Loading chunk 592 failed.
</code>```

So I thought I would try what this link goes through, turning the app into a PWA

https://medium.com/fieldcircle/error-loading-chunk-xx-failed-with-angular-lazy-loaded-modules-6c5b1b6f8b8d

But when I run the command

```<code>ng add @angular/pwa --project user
</code>```

I get an error as shown

```<code>PS C:\Projects\user> ng add @angular/pwa --project user
ℹ Using package manager: npm
✔ Found compatible package version: @angular/pwa@latest.
✔ Package information loaded.

The package @angular/pwa will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
CREATE ngsw-config.json (631 bytes)
CREATE ClientApp/src/manifest.webmanifest (1332 bytes)
CREATE ClientApp/src/assets/icons/icon-128x128.png (1253 bytes)
CREATE ClientApp/src/assets/icons/icon-144x144.png (1394 bytes)
CREATE ClientApp/src/assets/icons/icon-152x152.png (1427 bytes)
CREATE ClientApp/src/assets/icons/icon-192x192.png (1790 bytes)
CREATE ClientApp/src/assets/icons/icon-384x384.png (3557 bytes)
CREATE ClientApp/src/assets/icons/icon-512x512.png (5008 bytes)
CREATE ClientApp/src/assets/icons/icon-72x72.png (792 bytes)
CREATE ClientApp/src/assets/icons/icon-96x96.png (958 bytes)
UPDATE angular.json (4222 bytes)
UPDATE package.json (2082 bytes)
UPDATE ClientApp/src/app/app.module.ts (4421 bytes)
UPDATE ClientApp/src/index.html (303 bytes)
⠧ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: user@0.0.0
npm ERR! Found: @angular/core@12.1.5
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"^12.1.3" from the root project
npm ERR!   peer @angular/core@"^12.0.0 || ^13.0.0-0" from @angular/cdk@12.2.0
npm ERR!   node_modules/@angular/cdk
npm ERR!     @angular/cdk@"^12.1.3" from the root project
npm ERR!   10 more (@angular/common, @angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/core@12.2.16
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"12.2.16" from @angular/service-worker@12.2.16
npm ERR!   node_modules/@angular/service-worker
npm ERR!     @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\me\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\me\AppData\Local\npm-cache\_logs\2022-02-07T10_57_36_373Z-debug.log
✖ Package install failed, see above.
The Schematic workflow failed. See above.
</code>```

These are my dependencies in the package.json file

```<code>"dependencies": {
    "@angular-devkit/build-angular": "~12.1.3",
    "@angular/animations": "^12.1.3",
    "@angular/cdk": "^12.1.3",
    "@angular/common": "^12.1.3",
    "@angular/compiler": "^12.1.3",
    "@angular/core": "^12.1.3",
    "@angular/forms": "^12.1.3",
    "@angular/platform-browser": "^12.1.3",
    "@angular/platform-browser-dynamic": "^12.1.3",
    "@angular/router": "^12.1.3",
    "@angular/service-worker": "^12.1.3",
    "@fortawesome/fontawesome-free": "^5.15.3",
    "@schematics/angular": "^12.1.3",
    "@sentry/browser": "^6.10.0",
    "del": "^6.0.0",
    "gulp": "^4.0.2",
    "ngx-cookie-service": "^12.0.0",
    "primeflex": "^2.0.0",
    "primeicons": "^4.1.0",
    "primeng": "^12.0.1",
    "raven-js": "^3.27.2",
    "rxjs": "^7.2.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
</code>```

How can I get this to work as I have no idea what the issue is, apart from confusing version conflicts for some reason?

I have also tried what Pankaj has said.

So I ran this with the version

```<code>ng add @angular/pwa@12.1.3
</code>```

but I still get this error

```<code>npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: user@0.0.0
npm ERR! Found: @angular/core@12.1.5
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"^12.1.3" from the root project
npm ERR!   peer @angular/core@"^12.0.0 || ^13.0.0-0" from @angular/cdk@12.2.0
npm ERR!   node_modules/@angular/cdk
npm ERR!     @angular/cdk@"^12.1.3" from the root project
npm ERR!   10 more (@angular/common, @angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/core@12.2.16
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"12.2.16" from @angular/service-worker@12.2.16
npm ERR!   node_modules/@angular/service-worker
npm ERR!     @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\me\AppData\Local\npm-cache\eresolve-report.txt for a full report.
</code>```

答:
The answer thus far was to remove this line and just use it directly from the import at the top.

```<code>const { AccountManagerComponent } = await import('./account-manager/account-manager.component')
</code>```

Now it looks like this

```<code>import { AccountManagerComponent } from './account-manager/account-manager.component';

...

this.dynamicContentPlacehold.clear();
const factory = this.componentFactoryResolver.resolveComponentFactory(AccountManagerComponent);
const componentRef = this.dynamicContentPlacehold.createComponent(factory);
componentRef.instance.user = this.user;
</code>```

We then dont get the extra js file and dont have a problem. But would have been nice to figure out how to lazy load it, but I see that there is maybe routing lazy loading that we might be able to use.

I later tried a new project with no PWA and lazy loading of components that generate the extra .js files and it worked fine, so imagine there is some config mismatch as the problem project is older and has has all sorts done to it.

Body:
I am getting issues dynamically loading components using the following syntax:

this.dynamicContentPlacehold.clear();
const { AccountManagerComponent } = await import('./account-manager/account-manager.component')
const factory = this.componentFactoryResolver.resolveComponentFactory(AccountManagerComponent);
const componentRef = this.dynamicContentPlacehold.createComponent(factory);
componentRef.instance.user = this.user;

I get the following console error.

ChunkLoadError: Loading chunk 592 failed.

So I thought I would try what this link goes through, turning the app into a PWA

https://medium.com/fieldcircle/error-loading-chunk-xx-failed-with-angular-lazy-loaded-modules-6c5b1b6f8b8d

But when I run the command

ng add @angular/pwa --project user

I get an error as shown

PS C:\Projects\user> ng add @angular/pwa --project user
ℹ Using package manager: npm
✔ Found compatible package version: @angular/pwa@latest.
✔ Package information loaded.

The package @angular/pwa will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
CREATE ngsw-config.json (631 bytes)
CREATE ClientApp/src/manifest.webmanifest (1332 bytes)
CREATE ClientApp/src/assets/icons/icon-128x128.png (1253 bytes)
CREATE ClientApp/src/assets/icons/icon-144x144.png (1394 bytes)
CREATE ClientApp/src/assets/icons/icon-152x152.png (1427 bytes)
CREATE ClientApp/src/assets/icons/icon-192x192.png (1790 bytes)
CREATE ClientApp/src/assets/icons/icon-384x384.png (3557 bytes)
CREATE ClientApp/src/assets/icons/icon-512x512.png (5008 bytes)
CREATE ClientApp/src/assets/icons/icon-72x72.png (792 bytes)
CREATE ClientApp/src/assets/icons/icon-96x96.png (958 bytes)
UPDATE angular.json (4222 bytes)
UPDATE package.json (2082 bytes)
UPDATE ClientApp/src/app/app.module.ts (4421 bytes)
UPDATE ClientApp/src/index.html (303 bytes)
⠧ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: user@0.0.0
npm ERR! Found: @angular/core@12.1.5
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"^12.1.3" from the root project
npm ERR!   peer @angular/core@"^12.0.0 || ^13.0.0-0" from @angular/cdk@12.2.0
npm ERR!   node_modules/@angular/cdk
npm ERR!     @angular/cdk@"^12.1.3" from the root project
npm ERR!   10 more (@angular/common, @angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/core@12.2.16
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"12.2.16" from @angular/service-worker@12.2.16
npm ERR!   node_modules/@angular/service-worker
npm ERR!     @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\me\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\me\AppData\Local\npm-cache\_logs\2022-02-07T10_57_36_373Z-debug.log
✖ Package install failed, see above.
The Schematic workflow failed. See above.

These are my dependencies in the package.json file

"dependencies": {
    "@angular-devkit/build-angular": "~12.1.3",
    "@angular/animations": "^12.1.3",
    "@angular/cdk": "^12.1.3",
    "@angular/common": "^12.1.3",
    "@angular/compiler": "^12.1.3",
    "@angular/core": "^12.1.3",
    "@angular/forms": "^12.1.3",
    "@angular/platform-browser": "^12.1.3",
    "@angular/platform-browser-dynamic": "^12.1.3",
    "@angular/router": "^12.1.3",
    "@angular/service-worker": "^12.1.3",
    "@fortawesome/fontawesome-free": "^5.15.3",
    "@schematics/angular": "^12.1.3",
    "@sentry/browser": "^6.10.0",
    "del": "^6.0.0",
    "gulp": "^4.0.2",
    "ngx-cookie-service": "^12.0.0",
    "primeflex": "^2.0.0",
    "primeicons": "^4.1.0",
    "primeng": "^12.0.1",
    "raven-js": "^3.27.2",
    "rxjs": "^7.2.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },

How can I get this to work as I have no idea what the issue is, apart from confusing version conflicts for some reason?

I have also tried what Pankaj has said.

So I ran this with the version

ng add @angular/pwa@12.1.3

but I still get this error

npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: user@0.0.0
npm ERR! Found: @angular/core@12.1.5
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"^12.1.3" from the root project
npm ERR!   peer @angular/core@"^12.0.0 || ^13.0.0-0" from @angular/cdk@12.2.0
npm ERR!   node_modules/@angular/cdk
npm ERR!     @angular/cdk@"^12.1.3" from the root project
npm ERR!   10 more (@angular/common, @angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/core@12.2.16
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"12.2.16" from @angular/service-worker@12.2.16
npm ERR!   node_modules/@angular/service-worker
npm ERR!     @angular/service-worker@"^12.1.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\me\AppData\Local\npm-cache\eresolve-report.txt for a full report.

Body:
The answer thus far was to remove this line and just use it directly from the import at the top.

const { AccountManagerComponent } = await import('./account-manager/account-manager.component')

Now it looks like this

import { AccountManagerComponent } from './account-manager/account-manager.component';

...

this.dynamicContentPlacehold.clear();
const factory = this.componentFactoryResolver.resolveComponentFactory(AccountManagerComponent);
const componentRef = this.dynamicContentPlacehold.createComponent(factory);
componentRef.instance.user = this.user;

We then dont get the extra js file and dont have a problem. But would have been nice to figure out how to lazy load it, but I see that there is maybe routing lazy loading that we might be able to use.

I later tried a new project with no PWA and lazy loading of components that generate the extra .js files and it worked fine, so imagine there is some config mismatch as the problem project is older and has has all sorts done to it.


问:
jQuery Find and List all LI elements within a UL within a specific DIV
I have 3 Columns of ULs each a Dynamic UL container that can have anywhere from 0-9 LI containers (eventually more). All my LI elements have an attribute "rel" which I am trying to ultimately find that attribute and use it for something else on all LI elements within that parent DIV. I do eventually want to find more based on each but for not the very least the rel.. Any Ideas how I can achieve that with jQuery? Example:

```<code><ul id="column1">
   <li rel="1">Info</li>
   <li rel="2">Info</li>
   <li rel="3">Info</li>
</ul>
<ul id="column2">
   <li rel="4">Info</li>
   <li rel="5">Info</li>
   <li rel="6">Info</li>
</ul>
<ul id="column3">
   <li rel="7">Info</li>
   <li rel="8">Info</li>
   <li rel="9">Info</li>
</ul>
</code>```

these elements are all sortable as well. So when I get a list of them I want to also keep them in the order they were found from top to bottom of each column.

I have tried find(), parent(), and similar, maybe I am approaching it wrong. But its still worth mentioning to help come up with an idea

答:
Are you thinking about something like this?</p>

```<code>$('ul li').each(function(i)
{
   $(this).attr('rel'); // This is your rel value
});
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have 3 Columns of ULs each a Dynamic UL container that can have anywhere from 0-9 LI containers (eventually more). All my LI elements have an attribute "rel" which I am trying to ultimately find that attribute and use it for something else on all LI elements within that parent DIV. I do eventually want to find more based on each but for not the very least the rel.. Any Ideas how I can achieve that with jQuery? Example:

Info

Info

Info

Info

Info

Info

Info

Info

Info

these elements are all sortable as well. So when I get a list of them I want to also keep them in the order they were found from top to bottom of each column.

I have tried find(), parent(), and similar, maybe I am approaching it wrong. But its still worth mentioning to help come up with an idea

Body:
Are you thinking about something like this?

$('ul li').each(function(i)
{
   $(this).attr('rel'); // This is your rel value
});


问:
If I give Flink's RocksDB state backend enough memory, how does that differ from the heap-based state backend?
One obvious advantage of using the EmbeddedRocksDBStateBackend with Flink is that it can spill to disk when there isn't enough memory. But if I'm prepared to give it enough memory so that it never needs to use the disk, how is that different from using the HashMapStateBackend?

答:
These are the major differences:

The serialized format in which the RocksDB state backend maintains state has (much) less overhead (in general) than the binary object format used on the heap. So for a given amount of memory, RocksDB can hold more state.

The ser/de overhead in RocksDB means that that backend has significantly less throughput (on average).

The RocksDB backend maintains its state in off-heap memory, whereas state kept on the heap is subject to GC overhead and pauses. So RocksDB may have better worst-case latency. (Once Flink supports Java 17 and its modern garbage collectors, this factor may disappear.)

The RocksDB backend supports incremental checkpointing, which can significantly speed up both snapshots and restores (but see FLIP-151).

FWIW, some users choose to deploy with RocksDB configured to use a RAM disk as the local disk.


问:
Jmeter - Unable to move to next iteration when an ERROR occurs
I am using the following code in BeanShell postprocessor to stop the current iteration on an error and move to the next iteration. But in my case, I am handling the duration programmatically(infinite while loop and time functions) and not using the thread group loop/duration. So loop count is set to default one at thread group level.

My jmeter script would be -> 3 transaction + whilecontroller(10 transactions).

My error would occur at 5th transaction inside while loop. so i need to stop at that 5th transaction level and start the thread again.

ctx.setTestLogicalAction(org.apache.jmeter.threads.JMeterContext.TestLogicalAction.START_NEXT_ITERATION_OF_CURRENT_LOOP);

So in this case where am not using thread group loop count/duration and using the above code in a Beanshell Postprocessor, it is not moving to next iteration(like stop the current wihle loop run and start from initial). Am I missing something, could someone suggest?

答:
It won't, if the error occurs at 5th iteration - "your" code will proceed to 6th iteration without executing any Samplers which are below the Beanshell PostProcessor. According to interpretation of your description with my very limited level of English I believe you need to use START_NEXT_ITERATION_OF_THREAD action instead.

It's recommended to use JMeter's built-in test elements and avoid scripting where possible. Particular your case can be handled using If Controller and Flow Control Action Sampler combination

If you prefer or have to go for scripting - consider using the most performing language which is Groovy, it's recommended to use JSR223 Test Elements and Groovy language for scripting since JMeter 3.1


问:
How we can insert header and footer in google docs with google docs api using PHP code
I want to insert header and footer in my google docs with google docs api in PHP code. I am doing it like this-

```<code>$requests = new Google_Service_Docs_Request(array(
            'createHeader' => [
                'type' => 'TITLE',
                'sectionBreakLocation' => [
                    'index' => 0
            ],
        ],
    )),
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
    'requests' => $requests
));

$response = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
</code>```

but, i am getting this error-

```<code>PHP Fatal error:  Uncaught Google\Service\Exception: {
  "error": {
    "code": 400,
    "message": "Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\"",
    "errors": [
      {
        "message": "Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\"",
        "reason": "invalid"
      }
    ],
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "requests[5].create_header.type",
            "description": "Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\""
          }
        ]
      }
    ]
  }
}

</code>```

Please help me out with this, That how we can insert texts in header and footer in google docs using PHP.

答:
In your script, how about the following modification?

Create header:

I thought that the reason of the error message of Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\"" is due to 'type' => 'TITLE',. But when I saw your script, $requests is required to be an array. So how about the following modification?

From:

```<code>$requests = new Google_Service_Docs_Request(array(
            'createHeader' => [
                'type' => 'TITLE',
                'sectionBreakLocation' => [
                    'index' => 0
            ],
        ],
    )),
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
    'requests' => $requests
));
</code>```

To:

```<code>$requests = new Google_Service_Docs_Request(array(
    'createHeader' => [
        'type' => 'DEFAULT',
        'sectionBreakLocation' => [
            'index' => 0
        ],
    ],
));

$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
    'requests' => array($requests)
));
</code>```

Create footer:

In this case, please replace createHeader to createFooter in the above $requests.

Note:

As additional information, when you want to use the first page header and footer, you can use the following request.

```<code>  $requests = new Google_Service_Docs_Request(array(
      'updateDocumentStyle' => [
          'documentStyle' => [
              'useFirstPageHeaderFooter' => true,
          ],
          'fields' => 'useFirstPageHeaderFooter',
      ],
  ));
</code>```

References:

CreateHeaderRequest

CreateFooterRequest

Body:
I want to insert header and footer in my google docs with google docs api in PHP code. I am doing it like this-

$requests = new Google_Service_Docs_Request(array(
            'createHeader' => [
                'type' => 'TITLE',
                'sectionBreakLocation' => [
                    'index' => 0
            ],
        ],
    )),
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
    'requests' => $requests
));

$response = $service->documents->batchUpdate($documentId, $batchUpdateRequest);

but, i am getting this error-

PHP Fatal error:  Uncaught Google\Service\Exception: {
  "error": {
    "code": 400,
    "message": "Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\"",
    "errors": [
      {
        "message": "Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\"",
        "reason": "invalid"
      }
    ],
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "requests[5].create_header.type",
            "description": "Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\""
          }
        ]
      }
    ]
  }
}

Please help me out with this, That how we can insert texts in header and footer in google docs using PHP.

Body:
In your script, how about the following modification?

Create header:

I thought that the reason of the error message of Invalid value at 'requests[5].create_header.type' (type.googleapis.com/google.apps.docs.v1.HeaderFooterType), \"TITLE\"" is due to 'type' => 'TITLE',. But when I saw your script, $requests is required to be an array. So how about the following modification?

From:

$requests = new Google_Service_Docs_Request(array(
            'createHeader' => [
                'type' => 'TITLE',
                'sectionBreakLocation' => [
                    'index' => 0
            ],
        ],
    )),
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
    'requests' => $requests
));

To:

$requests = new Google_Service_Docs_Request(array(
    'createHeader' => [
        'type' => 'DEFAULT',
        'sectionBreakLocation' => [
            'index' => 0
        ],
    ],
));

$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
    'requests' => array($requests)
));

Create footer:

In this case, please replace createHeader to createFooter in the above $requests.

Note:

As additional information, when you want to use the first page header and footer, you can use the following request.

  $requests = new Google_Service_Docs_Request(array(
      'updateDocumentStyle' => [
          'documentStyle' => [
              'useFirstPageHeaderFooter' => true,
          ],
          'fields' => 'useFirstPageHeaderFooter',
      ],
  ));

References:

CreateHeaderRequest

CreateFooterRequest


问:
WebRTC Relay Server / Broadcast multiple clients
I've got WebRTC peer to peer working but when I want to broadcast a single camera to multiple clients obviously peer to peer isn't suitable.

I've found solutions like

http://lynckia.com
and

http://www.medooze.com/products/mcu/webrtc-support.aspx

But the first I can't get setup (and it seems to have cross browser issues)
the second just feels like we're hitting a nail with a nuclear missile.

All I need is a relay, I don't need to decode / recode streams.

I just need

The Broadcaster to connect to the server (peer to peer)

The clients to connect to the server (peer to peer)

The server to relay the stream from the broadcaster to the clients.

Is there any software out there that offers this solution that I've missed? is there an alternative working and scalable alternative?

Thanks

答:
If you just want to broadcast from a peer to a set of peers, if they don't care about the latency, the best solution is to covert WebRTC to live streaming, without transcoding just muxing:

```<code>Peer(Publisher) ---WebRTC--> Server --RTMP/HLS/DASH--> Peers/Players
</code>```

If this works good for you, SRS is able to covert WebRTC to live streaming.

Because live streaming allows you to use CDN or TCP to deliver the streams, and the latency is about 3~5s, so this solution is only available when Peers/Players never need to communicate to the Peer(Publisher).

If you want all those peers to talk to each other, it's very complex and need a WebRTC SFU cluster to do this, there will be a huge number of streams. For example, if allows 100 peers to talk to each other, there will be 100x100 = 10k streams.

It's too complicated, so I don't think there is good open-source solution right now(at 2022.02).

Body:
If you just want to broadcast from a peer to a set of peers, if they don't care about the latency, the best solution is to covert WebRTC to live streaming, without transcoding just muxing:

Peer(Publisher) ---WebRTC--> Server --RTMP/HLS/DASH--> Peers/Players

If this works good for you, SRS is able to covert WebRTC to live streaming.

Because live streaming allows you to use CDN or TCP to deliver the streams, and the latency is about 3~5s, so this solution is only available when Peers/Players never need to communicate to the Peer(Publisher).

If you want all those peers to talk to each other, it's very complex and need a WebRTC SFU cluster to do this, there will be a huge number of streams. For example, if allows 100 peers to talk to each other, there will be 100x100 = 10k streams.

It's too complicated, so I don't think there is good open-source solution right now(at 2022.02).


问:
MySqlConversionException when accessing DateTime field from DataReader
I have a C# application over MySql, using MySQL Connector; I'm trying to make a
DataReader request, the query executes fine, however, when trying to access a DateTime field, i'm getting MySqlConversionException {"Unable to convert MySQL date/time value to System.DateTime"}

this is the prototype

```<code>if (dr != null && !dr.Read()) return;

sesion.Id = Convert.ToInt32(dr["id"]);
sesion.Usuario = Convert.ToInt32(dr["usuario"]);
sesion.Estado = Convert.ToByte(dr["estado"]);
// doesn't work
sesion.FchCreacion = Convert.ToDateTime(dr["fch_creacion"]);
</code>```

Any suggestions?
Thanks in advance

答: It could also be a DBNull value.</p>

OwnerDisplayName: Jhonny D. Cano -Leftware-

ContentLicense: CC BY-SA 2.5

Body:
I have a C# application over MySql, using MySQL Connector; I'm trying to make a
DataReader request, the query executes fine, however, when trying to access a DateTime field, i'm getting MySqlConversionException {"Unable to convert MySQL date/time value to System.DateTime"}

this is the prototype

if (dr != null && !dr.Read()) return;

sesion.Id = Convert.ToInt32(dr["id"]);
sesion.Usuario = Convert.ToInt32(dr["usuario"]);
sesion.Estado = Convert.ToByte(dr["estado"]);
// doesn't work
sesion.FchCreacion = Convert.ToDateTime(dr["fch_creacion"]);

Any suggestions?
Thanks in advance

Body: It could also be a DBNull value.

OwnerDisplayName: Joel Coehoorn


问:
How to create new core in Solr 5?
Currently we are using Apache Solr 4.10.3 OR Heliosearch Distribution for Solr [HDS] as a search engine to index our data.

Now after that, I got the news about Apache Solr 5.0.0 release in last month. I'd successfully installed Apache Solr 5.0.0 version and now its running properly on 8983 port (means only running solr but unable to create core). In that UI, I'm unable to find the example core as well as schema or config files under it. So, I started creating new core as we create in old versions but unable to create one. Following is the error, I'm getting it:

Error CREATEing SolrCore 'testcore1': Unable to create core [testcore1] Caused by: Could not find configName for collection testcore1 found:null

Note: I also seen Cloud tab on (ie. http://localhost:8983/solr/) left side of Solr UI and also don't know how it works? Meaning I don't know the location of the schema.xml, solrconfig.xml files due to lack of example folder (Collection1) and how to update those files?

Is there any useful document or solution available to solve this error?

答: copy conf from solr/example/conf to solr/server/solr/.

Title: How to create new core in Solr 5?


问:
How can I delete files over (n) days old but leave (n) files regardless of age?
I wrote the following in PHP but I was wondering if there is an elegant way to do this in a Linux shell script? Basically delete files over (n) days old, but leave the (n) newest files regardless of age.

```<code>    PHP

    foreach (glob("backup/*.db") as $file) {
        $a[$file]=date("Y-m-d",filemtime($file));
    }
    $i=0;
    arsort($a);
    foreach($a as $file=>$date) {
        if ($i++>=10) {
            if ($date<=date("Y-m-d",strtotime("-10 days"))) {
                unlink($file);
                xmessage("PURGED: $file");
            }
        }
    }
</code>```

My idea was to delete with "find -mtime +(n) exec rm" but only pipe in the files that are NOT in "head -n +(n)"? But "head -n" does not seem to do what I thought it would. Thanks.

```<code>SHELL SCRIPT

find -mtime +10 | ls -t *.DB.tar.gz | head -n -10
</code>```

答:
If you have a version of find that cannot use -printf (f.ex. busybox), you can use this:

```<code>find ${FOLDER} -type f -exec stat -c "%y %-25n" {} \; |
sort -n |
head -n -$(MIN_FILES_TO_KEEP) |
cut -d ' ' -f3- |
xargs -r -I FILE find FILE -mtime +$(MIN_DAYS_TO_KEEP) |
xargs -n1 rm
</code>```

I had to refactor the command to use in docker-compose and this was the result. It is not the most elegant or efficient solution though.

Body:
I wrote the following in PHP but I was wondering if there is an elegant way to do this in a Linux shell script? Basically delete files over (n) days old, but leave the (n) newest files regardless of age.

    PHP

    foreach (glob("backup/*.db") as $file) {
        $a[$file]=date("Y-m-d",filemtime($file));
    }
    $i=0;
    arsort($a);
    foreach($a as $file=>$date) {
        if ($i++>=10) {
            if ($date<=date("Y-m-d",strtotime("-10 days"))) {
                unlink($file);
                xmessage("PURGED: $file");
            }
        }
    }

My idea was to delete with "find -mtime +(n) exec rm" but only pipe in the files that are NOT in "head -n +(n)"? But "head -n" does not seem to do what I thought it would. Thanks.

SHELL SCRIPT

find -mtime +10 | ls -t *.DB.tar.gz | head -n -10

Body:
If you have a version of find that cannot use -printf (f.ex. busybox), you can use this:

find ${FOLDER} -type f -exec stat -c "%y %-25n" {} \; |
sort -n |
head -n -$(MIN_FILES_TO_KEEP) |
cut -d ' ' -f3- |
xargs -r -I FILE find FILE -mtime +$(MIN_DAYS_TO_KEEP) |
xargs -n1 rm

I had to refactor the command to use in docker-compose and this was the result. It is not the most elegant or efficient solution though.


问:
i want to align my elements so that they start in the same place (vertically)
I try to do some CSS and I have 4 items on a line.
I would like to align my 2 "sous-jacent de référence" but I don't know how can I do it.
I tried to use position: relative but it didn't work

there is my code:

body {
  background-color: rgb(0, 0, 0);
  text-align: center;
}

.title {
  color: white;
  border: 2px solid black;
  margin: 2%;
  padding-bottom: 2%;
}

.left {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left2 {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left3 {
  color: white;
  font-size: 20px;
  padding-top: 2%;
  position: absolute;
}

.right {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.right2 {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>

<head>

</head>

<body>

  <div class="title">
    <h2>Formulaire</h2>

  </div>

  <div class="left">
    typologie du produit
  </div>
  <div class="left2">
    <input type="text" id="typologie" name="typologie" required minlength="2" maxlength="50" size="10"> </div>
  <div class="right">
    Sous-jacent de référence
  </div>
  <div class="left2">
    <input type="text" id="Sous-jacent" name="Sous-jacent" required minlength="2" maxlength="50" size="10"> </div>

  <div class="left">
    Nom du produit

  </div>
  <div class="left2">
    <input type="text" id="typologie" name="typologi2" required minlength="2" maxlength="50" size="10"> </div>

  <div class="right">
    Sous-jacent de référence
  </div>
  <div class="left2">
    <input type="text" id="Sous-jacent" name="Sous-jacent2" required minlength="2" maxlength="50" size="10"> </div>

</body>

</html></code>```

I want to say to my algorithm: "my 3 and div begins at x%"

I tried a lot of things (it works when I use float: right but it's quite confusing)

Thanks for your help!

答:
You can try using flex to align your items in your layout.
Create wrappers to each cell (title and input) you have and wrap all cells to one parent wrapper.
In this case you can control each cell separately and create flexible grid you want.

Moreover, you can simplify your cells, please check first two rows of Code Snippet.
Is it works for you?

body {
  background-color: rgb(0, 0, 0);
  text-align: center;
}

.title {
  color: white;
  border: 2px solid black;
  margin: 2%;
  padding-bottom: 2%;
}

.wrapper {
  display: flex;
  flex-wrap: wrap;
  color: white;
  column-gap: 1rem;
  row-gap: 1rem;
}

.cell {
  display: flex;
  width: calc(50% - .5rem);
  column-gap: 1rem;
}

/* old code */

/*.left {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left2 {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left3 {
  color: white;
  font-size: 20px;
  padding-top: 2%;
  position: absolute;
}

.right {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.right2 {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}*/```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>

<head>

</head>

<body>

  <div class="title">
    <h2>Formulaire</h2>
  </div>

  <div class="wrapper">
    <div class="cell">
      <div class="text">
        typologie du produit
      </div>
      <input type="text" id="typologie" name="typologie" required minlength="2" maxlength="50" size="10">
    </div>

    <div class="cell">
      <div class="text">
        Sous-jacent de référence
      </div>
      <input type="text" id="Sous-jacent" name="Sous-jacent" required minlength="2" maxlength="50" size="10">
    </div>

    <div class="cell">
      <div class="left">
        typologie du produit
      </div>
      <div class="left2">
        <input type="text" id="typologie" name="typologie" required minlength="2" maxlength="50" size="10"> </div>

    </div>

    <div class="cell">
      <div class="right">
        Sous-jacent de référence
      </div>
      <div class="left2">
        <input type="text" id="Sous-jacent" name="Sous-jacent" required minlength="2" maxlength="50" size="10"> </div>
    </div>

    <div class="cell">
      <div class="left">
        Nom du produit

      </div>
      <div class="left2">
        <input type="text" id="typologie" name="typologi2" required minlength="2" maxlength="50" size="10"> </div>
    </div>

    <div class="cell">
      <div class="right">
        Sous-jacent de référence
      </div>
      <div class="left2">
        <input type="text" id="Sous-jacent" name="Sous-jacent2" required minlength="2" maxlength="50" size="10"> </div>

    </div>
  </div>

</body>

</html></code>```

Body:
I try to do some CSS and I have 4 items on a line.
I would like to align my 2 "sous-jacent de référence" but I don't know how can I do it.
I tried to use position: relative but it didn't work

there is my code:

body {
  background-color: rgb(0, 0, 0);
  text-align: center;
}

.title {
  color: white;
  border: 2px solid black;
  margin: 2%;
  padding-bottom: 2%;
}

.left {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left2 {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left3 {
  color: white;
  font-size: 20px;
  padding-top: 2%;
  position: absolute;
}

.right {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.right2 {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

<!DOCTYPE html>

Formulaire

    typologie du produit

    <input type="text" id="typologie" name="typologie" required minlength="2" maxlength="50" size="10">

    Sous-jacent de référence

    <input type="text" id="Sous-jacent" name="Sous-jacent" required minlength="2" maxlength="50" size="10">

    Nom du produit

    <input type="text" id="typologie" name="typologi2" required minlength="2" maxlength="50" size="10">

    Sous-jacent de référence

    <input type="text" id="Sous-jacent" name="Sous-jacent2" required minlength="2" maxlength="50" size="10">

I want to say to my algorithm: "my 3 and div begins at x%"

I tried a lot of things (it works when I use float: right but it's quite confusing)

Thanks for your help!

Body:
You can try using flex to align your items in your layout.
Create wrappers to each cell (title and input) you have and wrap all cells to one parent wrapper.
In this case you can control each cell separately and create flexible grid you want.

Moreover, you can simplify your cells, please check first two rows of Code Snippet.
Is it works for you?

body {
  background-color: rgb(0, 0, 0);
  text-align: center;
}

.title {
  color: white;
  border: 2px solid black;
  margin: 2%;
  padding-bottom: 2%;
}

.wrapper {
  display: flex;
  flex-wrap: wrap;
  color: white;
  column-gap: 1rem;
  row-gap: 1rem;
}

.cell {
  display: flex;
  width: calc(50% - .5rem);
  column-gap: 1rem;
}

/* old code */

/*.left {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left2 {
  padding-left: 2%;
  float: left;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.left3 {
  color: white;
  font-size: 20px;
  padding-top: 2%;
  position: absolute;
}

.right {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}

.right2 {
  float: left;
  padding-left: 30%;
  color: white;
  font-size: 20px;
  padding-top: 2%;
}*/

<!DOCTYPE html>
<html>

<head>

</head>

<body>

  <div class="title">
    <h2>Formulaire</h2>
  </div>

  <div class="wrapper">
    <div class="cell">
      <div class="text">
        typologie du produit
      </div>
      <input type="text" id="typologie" name="typologie" required minlength="2" maxlength="50" size="10">
    </div>

    <div class="cell">
      <div class="text">
        Sous-jacent de référence
      </div>
      <input type="text" id="Sous-jacent" name="Sous-jacent" required minlength="2" maxlength="50" size="10">
    </div>

    <div class="cell">
      <div class="left">
        typologie du produit
      </div>
      <div class="left2">
        <input type="text" id="typologie" name="typologie" required minlength="2" maxlength="50" size="10"> </div>

    </div>

    <div class="cell">
      <div class="right">
        Sous-jacent de référence
      </div>
      <div class="left2">
        <input type="text" id="Sous-jacent" name="Sous-jacent" required minlength="2" maxlength="50" size="10"> </div>
    </div>

    <div class="cell">
      <div class="left">
        Nom du produit

      </div>
      <div class="left2">
        <input type="text" id="typologie" name="typologi2" required minlength="2" maxlength="50" size="10"> </div>
    </div>

    <div class="cell">
      <div class="right">
        Sous-jacent de référence
      </div>
      <div class="left2">
        <input type="text" id="Sous-jacent" name="Sous-jacent2" required minlength="2" maxlength="50" size="10"> </div>

    </div>
  </div>

</body>

</html>


问:
How to convey the jwt id token received from the Oauth flow to the mobile app?
The consumer of the app server (stateless rest api) is a mobile app invoking the app server endpoints via SSL.

I want to pass the jwt id token (received from the oauth/openidconnect flow) to the mobile app so that the mobile app can pass the jwt id token in the header of subsequent endpoint requests.

I have the following options:

Server side session - jwt id token is stored on the server (file system or db) and the session id is sent to mobile app via cookie. Subsequent endpoint invocations check token from session.

Client side session - signed cookie containing the jwt token is sent to the mobile app.  Subsequent endpoint invocations check the token from cookie.

Token based - jwt token is sent as repsome body. Subsequent endpoint invocations pass the token in header.

Each of above technique allows the app server endpoint to know who the caller is (by reading the jwt token).

Which is the secure way amongst the above options for the app server to convey the token to the mobile app?

答:
The standard option is for the mobile app to receive tokens using the AppAuth pattern, according to this RFC8252 section. As you are discovering, if an API does the OAuth flow, the app cannot easily ask the API for tokens, since there is no credential that can be sent in this request (cookies cannot be issued to mobile views).

To see how this looks, see these resources:

Curity iOS AppAuth Example

Curity Android AppAuth Example

React Native AppAuth


问:
How do we determine if a website uses an API or not?
How do we determine if a website uses an API or not? For ex. If I want to scrap a data from particular website to create a Database, should I check that whether that website allows me to scrap data or does that website allow API? How can I check it?</p>

答:
The website owner's wishes should be put in a file called robots.txt. If you use a scraping framework like scrapy, reading and respecting this file is typically built into the framework. If not, you must parse and respect this file manually, which can be some work. Alternatively, read it manually, if you're just scraping a handful of sites.

As an example, check out [https://stackoverflow.com/robots.txt](stackoverflow's robots.txt file).


问:
Format like KSQL long timestamp in ABAP?
How to create an KSQL Timestamp in ABAP ?

ISO Extended is not enough.

"timestamp":"2022-02-07T08:35:02,4595190",

I need this ..

"timestamp": "2021-03-23T14:00:04.893888792Z",

Who has an idea ?

答:
Use TIMESTAMPL data type. "2021-03-23T14:00:04.893888792Z" is just external presentation. It's 20210323140004.893888792 inside

Example:

```<code>DATA lv_now TYPE timestampl.

GET TIME STAMP FIELD lv_now.

DATA(lv_str) = /ui2/cl_json=>serialize(
    data             = lv_now
*    compress         = compress
*    name             = name
*    pretty_name      = pretty_name
*    type_descr       = type_descr
*    assoc_arrays     = assoc_arrays
    ts_as_iso8601    = abap_true
*    expand_includes  = expand_includes
*    assoc_arrays_opt = assoc_arrays_opt
*    numc_as_string   = numc_as_string
*    name_mappings    = name_mappings
).

WRITE lv_str.
</code>```

Body:
Use TIMESTAMPL data type. "2021-03-23T14:00:04.893888792Z" is just external presentation. It's 20210323140004.893888792 inside

Example:

DATA lv_now TYPE timestampl.

GET TIME STAMP FIELD lv_now.

DATA(lv_str) = /ui2/cl_json=>serialize(
    data             = lv_now
*    compress         = compress
*    name             = name
*    pretty_name      = pretty_name
*    type_descr       = type_descr
*    assoc_arrays     = assoc_arrays
    ts_as_iso8601    = abap_true
*    expand_includes  = expand_includes
*    assoc_arrays_opt = assoc_arrays_opt
*    numc_as_string   = numc_as_string
*    name_mappings    = name_mappings
).

WRITE lv_str.


问:
Fixtures causing problems when migrating
One of my apps has an initial_data.json file in /fixtures, which works great when using vanilla django to specify some initial data. However, when migrating using South, when it steps through 'Loading initial data for ' I get an IntegrityError, because duplicate data already exists. This makes sense, because my migration didn't empty the table, so the initial data from previous calls to syncdb is already there.

How can I either 1) tell South to not load initial data while migrating, or 2) modify initial_data.json or other django files so that duplicate data errors are handled gracefully, instead of crashing the migrate process in south?

答: migrate using the --no-initial-data option</p>


问:
How can I make Microsoft GRAPH token acquisition faster?
I am currently implementing an SSO-OBO flow for my addin. In this flow, I basically request for a bootstrap token from the Azure Identity platform using the Office.Auth.getAccessToken() API. And then exchange that for a Microsoft GRAPH token using  the auth-code flow. And it works correctly.

This entire process of getting the Bootstrap token, and exchanging it for a Microsoft GRAPH token takes around 2.52 seconds. (Average time over 10 trials.)

I have 2 questions related to this :

Is 2.52 seconds normal for this type of transaction?

If it is not normal, are there any documents or techniques that can help me increase the speed of this 'exchange'?

Please note that I used a free account AWS-Lambda/API Gateway for the tests I executed. I am not so sure if that affects latency. Also the test was done using a 50mbps connection.

Thank you all in advance.

答:
I have similar numbers (a bit faster though, ~800ms. Probably it's related to the azure datacenter location vs your app location). The bandwidth does not matter, as the amount of data transferred is tiny, but ping does (I'd at least make sure that your AWS app and Azure datacenter you are making request to, are located in the same country / part of the world)

You can cache the token (in the local storage, for example) and use the cached copy until it expires. The expiration time is written in the token itself ("exp" field, you can look at the contents of the token using the https://jwt.io for example). Or you could use some library that would do caching for you.


问:
I'm not getting the expected outputs in this powershell script
i made this script in powershell, but i'm not doing something correctly (I'm trying to learn self-taught uwu)

This is the script in question.

```<code>function Get-DesiredProcess {
    $DesiredProcess=Read-Host "Welcome to de advanced task manager! Choose an action to do: 1. WUP (WindowsUpdate) 2. MDP (ProxyModification)"
    Switch ($DesiredProcess)
    {
        WUP {$ChosenProcess=Install-WUpdate}
        MDP {$ChosenProcess=Set-Proxy}
        }
    If ($DesiredProcess -eq $null) {
    Write-Error "You must specify an action!"
    return Get-DesiredProcess
    }
    Else {
    Set-Variable -Name "DesiredProcess" -Value "ChosenProcess"
    }
}

Get-DesiredProcess
Write-Output $DesiredProcess
Write-Output $ChosenProcess
</code>```

The 2 last "Write-Output" are just for testing if it did registry the variables correctly or not (spoiler, it didn't)

When the Read-Host have not been answered, it should output "You specify an action!" but does nothing:

```<code>Welcome to de advanced task manager! Choose an action to do: 1. WUP (WindowsUpdate) 2. MDP (ProxyModification):

PS C:\Users\user1\Documents\scriptsfiles>
</code>```

And when a choice is made, it should keep the variable with this part:

```<code>Set-Variable -Name "DesiredProcess" -Value "ChosenProcess"
</code>```

Instead of that it executes directly the choosen process...

Thanks in advance!

答:
What I understand after reading your description, you need to declare all of the variables as global otherwise you need to access those variables inside of the function. A function variable can not be accessible from outside of the function. As per my understanding from your description, your code will be like this:</p>
```<code>function Get-DesiredProcess
{

$DesiredProcess=Read-Host "Welcome to de advanced task manager! Choose an action to do: 1. WUP (WindowsUpdate) 2. MDP (ProxyModification)"

  switch ($DesiredProcess)
  {
      1 {$ChosenProcess="Install-WUpdate"}
      2 {$ChosenProcess="Set-Proxy"}
  }

  If ($DesiredProcess -eq [string]::empty)
  {
     Write-Error "You must specify an action!"

     Get-DesiredProcess
  }

  Else
  {
    Set-Variable -Name "DesiredProcessName" -Value "$ChosenProcess"
    Write-host "You chose this: "$DesiredProcessName
  }

}

Get-DesiredProcess
</code>```

Body:
i made this script in powershell, but i'm not doing something correctly (I'm trying to learn self-taught uwu)

This is the script in question.

function Get-DesiredProcess {
    $DesiredProcess=Read-Host "Welcome to de advanced task manager! Choose an action to do: 1. WUP (WindowsUpdate) 2. MDP (ProxyModification)"
    Switch ($DesiredProcess)
    {
        WUP {$ChosenProcess=Install-WUpdate}
        MDP {$ChosenProcess=Set-Proxy}
        }
    If ($DesiredProcess -eq $null) {
    Write-Error "You must specify an action!"
    return Get-DesiredProcess
    }
    Else {
    Set-Variable -Name "DesiredProcess" -Value "ChosenProcess"
    }
}

Get-DesiredProcess
Write-Output $DesiredProcess
Write-Output $ChosenProcess

The 2 last "Write-Output" are just for testing if it did registry the variables correctly or not (spoiler, it didn't)

When the Read-Host have not been answered, it should output "You specify an action!" but does nothing:

Welcome to de advanced task manager! Choose an action to do: 1. WUP (WindowsUpdate) 2. MDP (ProxyModification):

PS C:\Users\user1\Documents\scriptsfiles>

And when a choice is made, it should keep the variable with this part:

Set-Variable -Name "DesiredProcess" -Value "ChosenProcess"

Instead of that it executes directly the choosen process...

Thanks in advance!

Body:
What I understand after reading your description, you need to declare all of the variables as global otherwise you need to access those variables inside of the function. A function variable can not be accessible from outside of the function. As per my understanding from your description, your code will be like this:

function Get-DesiredProcess
{

$DesiredProcess=Read-Host "Welcome to de advanced task manager! Choose an action to do: 1. WUP (WindowsUpdate) 2. MDP (ProxyModification)"

  switch ($DesiredProcess)
  {
      1 {$ChosenProcess="Install-WUpdate"}
      2 {$ChosenProcess="Set-Proxy"}
  }

  If ($DesiredProcess -eq [string]::empty)
  {
     Write-Error "You must specify an action!"

     Get-DesiredProcess
  }

  Else
  {
    Set-Variable -Name "DesiredProcessName" -Value "$ChosenProcess"
    Write-host "You chose this: "$DesiredProcessName
  }

}

Get-DesiredProcess


问:
How to solve this error Undefined index: password in on line
Undefined index: password in on line

: Cannot modify header information - headers already sent by (output started at /storage/ssd4/628/18415628/public_html/Kunj/admin/index.php:8) in on line

: Cannot modify header information - headers already sent by (output started at /storage/ssd4/628/18415628/public_html/Kunj/admin/index.php:8) in on line

Not Access!

This error comes from this code

```<code><?php
session_start();
require_once('functions.php');
require_once('dbconnection.php');
require_once('includes/init.php');
$password = $_SESSION['password'];
$admin_data = get_admin($conn, $password);
if ($password != $admin_data['password']) {
    header('location: login.php');
</code>```

答:
Change this line

```<code>$password = $_SESSION['password'];
</code>```

to

```<code>if(isset($_SESSION['password'])){
  $password = $_SESSION['password'];
}else{
  $password = '';
}
</code>```

Body:
Undefined index: password in on line

: Cannot modify header information - headers already sent by (output started at /storage/ssd4/628/18415628/public_html/Kunj/admin/index.php:8) in on line

: Cannot modify header information - headers already sent by (output started at /storage/ssd4/628/18415628/public_html/Kunj/admin/index.php:8) in on line

Not Access!

This error comes from this code

<?php
session_start();
require_once('functions.php');
require_once('dbconnection.php');
require_once('includes/init.php');
$password = $_SESSION['password'];
$admin_data = get_admin($conn, $password);
if ($password != $admin_data['password']) {
    header('location: login.php');

Body:
Change this line

$password = $_SESSION['password'];

to

if(isset($_SESSION['password'])){
  $password = $_SESSION['password'];
}else{
  $password = '';
}


问:
How to parse string in bash by position of starting and ending substring
For such a log file like this

```<code>xyz003 2021-12-20T15:08:44+01:00 <local0,debug> my_service: 15:08:44.015 DEBUG ABCDEFGHIJKLMNOPQRSTUVWXYZ MyClass  - Incoming message from service blahblah, headers:{...} payload:(aaa=111, bbb=22222, ccc=333, ddd=44444444444)...
</code>```

I need to parse some things e.g. ccc, I need to have the value of it but the value may have variable length and be in variable position in log. So I need to find ccc= and return the whole substring to ,.

I'm not very good in bash scripting. I found only cut command or ${string:position:length} whatever it's called. But I don't know how to tell - give me everything from position of ccc= to position of first , after that.

Is there a way to do it?

答:
You don't need to deal with positions to answer your question at all:

```<code>in='xyz003 2021-12-20T15:08:44+01:00 <local0,debug> my_service: 15:08:44.015 DEBUG ABCDEFGHIJKLMNOPQRSTUVWXYZ MyClass  - Incoming message from service blahblah, headers:{...} payload:(aaa=111, bbb=22222, ccc=333, ddd=44444444444)...'
ccc=${in##*ccc=}  # assign everything after the last "ccc=" to ccc
ccc=${ccc%%,*}    # remove everything after the last , in $ccc
echo "ccc=$ccc"   # ...and you have your output.
</code>```

...or, with regular expressions:

```<code>if [[ $in =~ ccc=([^,]+), ]]; then
  echo "Found ccc: ${BASH_REMATCH[1]}"
fi
</code>```

Body:
For such a log file like this

xyz003 2021-12-20T15:08:44+01:00 <local0,debug> my_service: 15:08:44.015 DEBUG ABCDEFGHIJKLMNOPQRSTUVWXYZ MyClass  - Incoming message from service blahblah, headers:{...} payload:(aaa=111, bbb=22222, ccc=333, ddd=44444444444)...

I need to parse some things e.g. ccc, I need to have the value of it but the value may have variable length and be in variable position in log. So I need to find ccc= and return the whole substring to ,.

I'm not very good in bash scripting. I found only cut command or ${string:position:length} whatever it's called. But I don't know how to tell - give me everything from position of ccc= to position of first , after that.

Is there a way to do it?

Body:
You don't need to deal with positions to answer your question at all:

in='xyz003 2021-12-20T15:08:44+01:00 <local0,debug> my_service: 15:08:44.015 DEBUG ABCDEFGHIJKLMNOPQRSTUVWXYZ MyClass  - Incoming message from service blahblah, headers:{...} payload:(aaa=111, bbb=22222, ccc=333, ddd=44444444444)...'
ccc=${in##*ccc=}  # assign everything after the last "ccc=" to ccc
ccc=${ccc%%,*}    # remove everything after the last , in $ccc
echo "ccc=$ccc"   # ...and you have your output.

...or, with regular expressions:

if [[ $in =~ ccc=([^,]+), ]]; then
  echo "Found ccc: ${BASH_REMATCH[1]}"
fi


问:
Flutter Visual Studio - develop for Windows
There is a warning when I use flutter doctor :
Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components

What does it mean ? i didnt find the installation component !

答:
It's basically saying that if you want to develop your flutter app for windows
you will need to install Visual Studio 2022 and while installing Visual Studio 2022 you will need to download this: Desktop development with C++

Also you have to install the third link in this: https://visualstudio.microsoft.com/downloads/

You could also get Desktop development with C++ tool after installing visual studio and then navigating to tool -> Get tools and features -> Desktop development with C++


问:
Access the Bundle from navDeepLinkBuilder.setArguments(bundle)
There is a Service that at some point creates a Notification that always leads to the same Fragment. The Service wants to send the Fragment some Key-Value Data. In an Intent I would put those as Extras. The PendingIntent doesn't have a putExtras method, but the NavDeepLinkBuilder has a setArguments method that takes a Bundle.

val pendingIntent = NavDeepLinkBuilder(applicationContext)
            .setComponentName(MainActivity::class.java)
            .setGraph(R.navigation.nav_main)
            .setArguments(myExtras)
            .setDestination(R.id.destinationFragment)
            .createPendingIntent()

val builder = NotificationCompat.Builder(this, CHANNEL_ID)
            .setPriority(NotificationCompat.PRIORITY_MAX)
            .setContentText("some text")
            .setContentTitle("some text")
            .setContentIntent(pendingIntent)

startForeground(NOTIFICATION, builder.build())
```
<p>Can the bundle that was fed into setArguments be accessed later from the destination Fragment? I tried it in the following way, but it just returns me the default value:</p>
<pre class="lang-kotlin prettyprint-override"><code>activity?.intent?.extras?.let {
    val myExtra = extras.getInt(KEY, DEFAULT_VALUE)
    Timber.e("got the Value $myExtra")
}
</code>```

答:
Yes, you can access your bundle from your destination fragment. Check this out</p>
```<code>//your fragment
override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
): View {
    super.onCreateView(inflater, container, savedInstanceState)

    if (arguments != null) {
        if (requireArguments().containsKey(YOUR_KEY)) {
            //logic
        }
    }
}
</code>```

Body:
There is a Service that at some point creates a Notification that always leads to the same Fragment. The Service wants to send the Fragment some Key-Value Data. In an Intent I would put those as Extras. The PendingIntent doesn't have a putExtras method, but the NavDeepLinkBuilder has a setArguments method that takes a Bundle.

val pendingIntent = NavDeepLinkBuilder(applicationContext)
            .setComponentName(MainActivity::class.java)
            .setGraph(R.navigation.nav_main)
            .setArguments(myExtras)
            .setDestination(R.id.destinationFragment)
            .createPendingIntent()

val builder = NotificationCompat.Builder(this, CHANNEL_ID)
            .setPriority(NotificationCompat.PRIORITY_MAX)
            .setContentText("some text")
            .setContentTitle("some text")
            .setContentIntent(pendingIntent)

startForeground(NOTIFICATION, builder.build())

Can the bundle that was fed into setArguments be accessed later from the destination Fragment? I tried it in the following way, but it just returns me the default value:

activity?.intent?.extras?.let {
    val myExtra = extras.getInt(KEY, DEFAULT_VALUE)
    Timber.e("got the Value $myExtra")
}

Body:
Yes, you can access your bundle from your destination fragment. Check this out

//your fragment
override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
): View {
    super.onCreateView(inflater, container, savedInstanceState)

    if (arguments != null) {
        if (requireArguments().containsKey(YOUR_KEY)) {
            //logic
        }
    }
}


问:
Speeding up complex Android View Inflation
I have a relatively big XML layout (38 kB, 600 lines) with hierarchy like:

```<code><ScrollView>
 <LinearLayout>
  <TabHost>
   <LinearLayout>
    <FrameLayout> //tab widget
     <LinearLayout> //tab content
      <LinearLayout> //section
       <TextView> //section name
       <LinearLayout orientation="horizontal"> //item 1 box
        <TextView> //item 1 title
        <Spinner> //item 1 picker
       </LinearLayout>
       <LinearLayout> //item 2 box
        <TextView> //item 2 title
        <Spinner> //item 2 picker
       </LinearLayout>
       ...  //18 other items
      </LinearLayout>
      ... //4 other sections with 15 items each
</>
</code>```

It is a data entry form that has to have that many items and the best I can do now is to do to wrap setContentView and loading of data to the spinners in an AsyncTask with a "Loading..." dialog.

Does extensive using of themes also slow down the view inflation? The view inflater wouldn't need to look in loaded theme.xml, but if I were to inline the theme into the layout xml, it would also increase the size of the XML considerably, thus slow down the parser.

Is there something I could do to simplify the layout that would make it load at least twice as fast?
I'm thinking that I might try to get rid of the horizontal LinearLayouts, and build the "section" with TableLayout.

答:
The only thing I can think to do would be to break your views into a couple different parts and inflate each view whenever the user gets to that part.  Not sure if that helps at all but good luck.

Also might help to look at that portion of the code in traceview

Body:
I have a relatively big XML layout (38 kB, 600 lines) with hierarchy like:

<ScrollView>
 <LinearLayout>
  <TabHost>
   <LinearLayout>
    <FrameLayout> //tab widget
     <LinearLayout> //tab content
      <LinearLayout> //section
       <TextView> //section name
       <LinearLayout orientation="horizontal"> //item 1 box
        <TextView> //item 1 title
        <Spinner> //item 1 picker
       </LinearLayout>
       <LinearLayout> //item 2 box
        <TextView> //item 2 title
        <Spinner> //item 2 picker
       </LinearLayout>
       ...  //18 other items
      </LinearLayout>
      ... //4 other sections with 15 items each
</>

It is a data entry form that has to have that many items and the best I can do now is to do to wrap setContentView and loading of data to the spinners in an AsyncTask with a "Loading..." dialog.

Does extensive using of themes also slow down the view inflation? The view inflater wouldn't need to look in loaded theme.xml, but if I were to inline the theme into the layout xml, it would also increase the size of the XML considerably, thus slow down the parser.

Is there something I could do to simplify the layout that would make it load at least twice as fast?
I'm thinking that I might try to get rid of the horizontal LinearLayouts, and build the "section" with TableLayout.


问:
Count number of GCP log entries during a specified time
Is it possible to count number of occurrences of a specific log message over a specific period of time from GCP Stackdriver logging? To answer the question "How many times did this event occur during this time period." Basically I would like the integral of the curve in the chart below.

It doesn't have to be a moving window, this time it's more of a one-time-task. A count-aggregator or similar on the advanced log query would also work if that would be available.

The query looks like this:

```<code>(resource.type="container"
logName="projects/xyz-142842/logs/drs"
"Publish Message for updated entity"
) AND (timestamp>="2018-04-25T06:20:53Z" timestamp<="2018-04-26T06:20:53Z")
</code>```

My log based metric for the graph above looks like this:

My Dashboard is setup like this:

答:
With PacketAI, you can send logs of arbitrary formats, including from GCP.  then the logs dashboard will automatically parse and group into patterns as shown in this video.  https://streamable.com/n50kr8

Counts and trends of different log patterns are also displayed

Disclaimer: I work for PacketAI

Body:
Is it possible to count number of occurrences of a specific log message over a specific period of time from GCP Stackdriver logging? To answer the question "How many times did this event occur during this time period." Basically I would like the integral of the curve in the chart below.

It doesn't have to be a moving window, this time it's more of a one-time-task. A count-aggregator or similar on the advanced log query would also work if that would be available.

The query looks like this:

(resource.type="container"
logName="projects/xyz-142842/logs/drs"
"Publish Message for updated entity"
) AND (timestamp>="2018-04-25T06:20:53Z" timestamp<="2018-04-26T06:20:53Z")

My log based metric for the graph above looks like this:

My Dashboard is setup like this:


问:
how to show null when use iferror excel
is there anyone know how to show null when use iferror in excel?
i use multiple in iferror, but it shows 0, not show zero space or null;

screenshot is like this :

i want the result is like this,

答:
I suppose if you need to use the =IFERROR formula, you could rely on the div#0 error by multiplying and dividing by itself:

```<code>=IFERROR(E5*F5*F5/F5," ")
</code>```

This will give an error if F5 is 0.

Title: how to show null when use iferror excel

Body:
I suppose if you need to use the =IFERROR formula, you could rely on the div#0 error by multiplying and dividing by itself:

=IFERROR(E5*F5*F5/F5," ")

This will give an error if F5 is 0.


问:
SQL group by on query and subquery
I have a few tables grouped together:
Divisions > Sessions > Registrations > Registration Week Days

Each Division has several sessions, each session has several registrations, and each registration has weekday options (either M-F, MWF, T/Th).

I have this query:

SELECT d.Name, r.Weekdays, COUNT(r.weekdays) from divisions d
left join sessions s on s.DivisionID = d.ID
left join registrations r on r.SessionID = s.ID
order by r.Weekdays
```
<p>This query contains all the info I need but I'm trying to group by in such a way to get weekday option count for each division, kind of like this:</p>
```Div | Weekday Option| Count
Div1| M-F           | 4
Div1| MWF           | 5
Div1| T/Th          | 3
Div2| M-F           | 7
```

This shouldn't be too tough for SQL adepts, but my group by statements keep leaving out information I need and I'm not quite sure how to get the format above.  Any suggestions would be great and I'm sure there are several right answers!

答:
Did you try in to group "d.Name, r.Weekdays" columns?

Code is here:

```<code>SELECT d.Name, r.Weekdays, COUNT(r.weekdays)
FROM divisions d
    left join sessions s on s.DivisionID = d.ID
    left join registrations r on r.SessionID = s.ID
group by d.Name, r.Weekdays
order by r.Weekdays
</code>```

Title: SQL group by on query and subquery

Body:
I have a few tables grouped together:
Divisions > Sessions > Registrations > Registration Week Days

Each Division has several sessions, each session has several registrations, and each registration has weekday options (either M-F, MWF, T/Th).

I have this query:

SELECT d.Name, r.Weekdays, COUNT(r.weekdays) from divisions d
left join sessions s on s.DivisionID = d.ID
left join registrations r on r.SessionID = s.ID
order by r.Weekdays

This query contains all the info I need but I'm trying to group by in such a way to get weekday option count for each division, kind of like this:

Div | Weekday Option| Count
Div1| M-F           | 4
Div1| MWF           | 5
Div1| T/Th          | 3
Div2| M-F           | 7

This shouldn't be too tough for SQL adepts, but my group by statements keep leaving out information I need and I'm not quite sure how to get the format above.  Any suggestions would be great and I'm sure there are several right answers!

Body:
Did you try in to group "d.Name, r.Weekdays" columns?

Code is here:

SELECT d.Name, r.Weekdays, COUNT(r.weekdays)
FROM divisions d
    left join sessions s on s.DivisionID = d.ID
    left join registrations r on r.SessionID = s.ID
group by d.Name, r.Weekdays
order by r.Weekdays


问:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
I am a newbie to Hyperledger Fabric and I am trying to install Samples, Binaries and Docker Images. I used this command line:

curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s

But I got this error:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

My machine is Ubuntu 18.04 and I've already made sure the version of curl in my machine is the newest. I've already googled this error and tried what I can, but it still don't work well. Hope you guys can give me some suggestions. Thanks a lot!

答: /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"</p>


问:
Can I COUNTIF across multiple columns in an array formula?
Seems simple to me..

I want to do something along the lines of =Countif(A2:X , "Yes")

I would wrap this in an arrayformula with a simple IF(A2:A = "" ,"" .....

I want it to bring back the number of "Yes" per row

So if row 2 has 12 yes' then bring back 12, row 3 has 7 so 7 etc

This has worked to an extent but brings back the count across the entire range rather than split by row

答:
Though it is a bit tedious, couldn't you do this:</p>
```<code>=COUNTIF(A2:A, "Yes") + COUNTIF(B2:B, "Yes") + COUNTIF(C2:C, "Yes") + COUNTIF(D2:D, "Yes") + COUNTIF(E2:E, "Yes") + COUNTIF(F2:F, "Yes") + COUNTIF(G2:G, "Yes") + COUNTIF(H2:H, "Yes") + COUNTIF(I2:I, "Yes") + COUNTIF(J2:J, "Yes") + COUNTIF(K2:K, "Yes") + COUNTIF(L2:L, "Yes") + COUNTIF(M2:M, "Yes") + COUNTIF(N2:N, "Yes") + COUNTIF(O2:O, "Yes") + COUNTIF(P2:P, "Yes") + COUNTIF(Q2:Q, "Yes") + COUNTIF(R2:R, "Yes") + COUNTIF(S2:S, "Yes") + COUNTIF(T2:T, "Yes") + COUNTIF(U2:U, "Yes") + COUNTIF(V2:V, "Yes") + COUNTIF(W2:W, "Yes") + COUNTIF(X2:X, "Yes")
</code>```

Body:
Though it is a bit tedious, couldn't you do this:

=COUNTIF(A2:A, "Yes") + COUNTIF(B2:B, "Yes") + COUNTIF(C2:C, "Yes") + COUNTIF(D2:D, "Yes") + COUNTIF(E2:E, "Yes") + COUNTIF(F2:F, "Yes") + COUNTIF(G2:G, "Yes") + COUNTIF(H2:H, "Yes") + COUNTIF(I2:I, "Yes") + COUNTIF(J2:J, "Yes") + COUNTIF(K2:K, "Yes") + COUNTIF(L2:L, "Yes") + COUNTIF(M2:M, "Yes") + COUNTIF(N2:N, "Yes") + COUNTIF(O2:O, "Yes") + COUNTIF(P2:P, "Yes") + COUNTIF(Q2:Q, "Yes") + COUNTIF(R2:R, "Yes") + COUNTIF(S2:S, "Yes") + COUNTIF(T2:T, "Yes") + COUNTIF(U2:U, "Yes") + COUNTIF(V2:V, "Yes") + COUNTIF(W2:W, "Yes") + COUNTIF(X2:X, "Yes")


问:
Error upon compilation while using jax.jit
Pardon me I'm still a noob with the inner workings of Jax and trying to find my way around it. I have this code which works well without the jit. But when I try to jit it, it throws an error. I initially used an if else statement within the code which also did not work and had to rewrite the code this way without an if else statement. How do I get around this?. MWE is below.</p>
```<code>
import jax
import jax.numpy as jnp
jax.config.update("jax_enable_x64", True)

num_rows = 5
num_cols = 20
smf = jnp.array([jnp.inf, 0.1, 0.1, 0.1, 0.1])
par_init = jnp.array([1.0,2.0,3.0,4.0,5.0])
lb = jnp.array([0.1, 0.1, 0.1, 0.1, 0.1])
ub = jnp.array([10.0, 10.0, 10.0, 10.0, 10.0])
par = jnp.broadcast_to(par_init[:,None],(num_rows,num_cols))

kvals = jnp.where(jnp.isinf(smf), 1, num_cols)
kvals = jnp.insert(kvals, 0, 0)
kvals = jnp.cumsum(kvals)

par0_col = jnp.zeros(num_rows*num_cols - (num_cols-1) * jnp.sum(jnp.isinf(smf)))
lb_col = jnp.zeros(num_rows*num_cols - (num_cols-1) * jnp.sum(jnp.isinf(smf)))
ub_col = jnp.zeros(num_rows*num_cols- (num_cols-1) * jnp.sum(jnp.isinf(smf)))

for i in range(num_rows):
    par0_col = par0_col.at[kvals[i]:kvals[i+1]].set(par[i, :kvals[i+1]-kvals[i]])
    lb_col = lb_col.at[kvals[i]:kvals[i+1]].set(lb[i])
    ub_col = ub_col.at[kvals[i]:kvals[i+1]].set(ub[i])

par_log = jnp.log10((par0_col - lb_col) / (1 - par0_col / ub_col))

@jax.jit
def compute(p):
    arr_1 = jnp.zeros(shape = (num_rows, num_cols))
    arr_2 = jnp.zeros(shape = (num_rows, num_cols))
    for i in range(num_rows):

        arr_1 = arr_1.at[i, :].set((par_log[kvals[i]:kvals[i+1]]))
        arr_2 = arr_2.at[i, :].set(10**par_log[kvals[i]:kvals[i+1]])

    return arr_1

arr = compute(par_log)
print(arr)

# WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
# Traceback (most recent call last):
#   File "test_7.py", line 47, in <module>
#     arr = compute(par_log)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/traceback_util.py", line 162, in reraise_with_filtered_traceback
#     return fun(*args, **kwargs)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/api.py", line 424, in cache_miss
#     out_flat = xla.xla_call(
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 1661, in bind
#     return call_bind(self, fun, *args, **params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 1652, in call_bind
#     outs = primitive.process(top_trace, fun, tracers, params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 1664, in process
#     return trace.process_call(self, fun, tracers, params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 633, in process_call
#     return primitive.impl(f, *tracers, **params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/dispatch.py", line 128, in _xla_call_impl
#     compiled_fun = _xla_callable(fun, device, backend, name, donated_invars,
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/linear_util.py", line 263, in memoized_fun
#     ans = call(fun, *args)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/dispatch.py", line 155, in _xla_callable_uncached
#     return lower_xla_callable(fun, device, backend, name, donated_invars,
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/profiler.py", line 206, in wrapper
#     return func(*args, **kwargs)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/dispatch.py", line 169, in lower_xla_callable
#     jaxpr, out_avals, consts = pe.trace_to_jaxpr_final(
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/profiler.py", line 206, in wrapper
#     return func(*args, **kwargs)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/interpreters/partial_eval.py", line 1566, in trace_to_jaxpr_final
#     jaxpr, out_avals, consts = trace_to_subjaxpr_dynamic(fun, main, in_avals)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/interpreters/partial_eval.py", line 1543, in trace_to_subjaxpr_dynamic
#     ans = fun.call_wrapped(*in_tracers)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/linear_util.py", line 166, in call_wrapped
#     ans = self.f(*args, **dict(self.params, **kwargs))
#   File "test_7.py", line 42, in compute
#     arr_1 = arr_1.at[i, :].set((par_log[kvals[i]:kvals[i+1]]))
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/numpy/lax_numpy.py", line 5704, in _rewriting_take
#     return _gather(arr, treedef, static_idx, dynamic_idx, indices_are_sorted,
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/numpy/lax_numpy.py", line 5713, in _gather
#     indexer = _index_to_gather(shape(arr), idx)  # shared with _scatter_update
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/numpy/lax_numpy.py", line 5956, in _index_to_gather
#     raise IndexError(msg)
# jax._src.traceback_util.UnfilteredStackTrace: IndexError: Array slice indices must have static start/stop/step to be used with NumPy indexing syntax. Found slice(Traced<ShapedArray(int64[], weak_type=True)>with<DynamicJaxprTrace(level=0/1)>, Traced<ShapedArray(int64[], weak_type=True)>with<DynamicJaxprTrace(level=0/1)>, None). To index a statically sized array at a dynamic position, try lax.dynamic_slice/dynamic_update_slice (JAX does not support dynamically sized arrays within JIT compiled functions).

# The stack trace below excludes JAX-internal frames.
# The preceding is the original exception that occurred, unmodified.

# --------------------

# The above exception was the direct cause of the following exception:

</code>```

答:
The issue is that indexing in JAX must be done with static values, and within JIT kvals[i] is not a static value (because it is computed from a JAX array).

One easy way to fix this in your case is to make kvals a non-jax array; for example when you define it, do this;

kvals = list(jnp.cumsum(kvals))
```

This works here because kvals is created outside the jit expression. In general, if your indices are also created inside a JIT expression, you can compute slices dynamically with lax.dynamic_slice, which does support dynamic start indices.

For more background on static vs. traced values, a useful read is How To Think In JAX.

Body:
Pardon me I'm still a noob with the inner workings of Jax and trying to find my way around it. I have this code which works well without the jit. But when I try to jit it, it throws an error. I initially used an if else statement within the code which also did not work and had to rewrite the code this way without an if else statement. How do I get around this?. MWE is below.

import jax
import jax.numpy as jnp
jax.config.update("jax_enable_x64", True)

num_rows = 5
num_cols = 20
smf = jnp.array([jnp.inf, 0.1, 0.1, 0.1, 0.1])
par_init = jnp.array([1.0,2.0,3.0,4.0,5.0])
lb = jnp.array([0.1, 0.1, 0.1, 0.1, 0.1])
ub = jnp.array([10.0, 10.0, 10.0, 10.0, 10.0])
par = jnp.broadcast_to(par_init[:,None],(num_rows,num_cols))

kvals = jnp.where(jnp.isinf(smf), 1, num_cols)
kvals = jnp.insert(kvals, 0, 0)
kvals = jnp.cumsum(kvals)

par0_col = jnp.zeros(num_rows*num_cols - (num_cols-1) * jnp.sum(jnp.isinf(smf)))
lb_col = jnp.zeros(num_rows*num_cols - (num_cols-1) * jnp.sum(jnp.isinf(smf)))
ub_col = jnp.zeros(num_rows*num_cols- (num_cols-1) * jnp.sum(jnp.isinf(smf)))

for i in range(num_rows):
    par0_col = par0_col.at[kvals[i]:kvals[i+1]].set(par[i, :kvals[i+1]-kvals[i]])
    lb_col = lb_col.at[kvals[i]:kvals[i+1]].set(lb[i])
    ub_col = ub_col.at[kvals[i]:kvals[i+1]].set(ub[i])

par_log = jnp.log10((par0_col - lb_col) / (1 - par0_col / ub_col))

@jax.jit
def compute(p):
    arr_1 = jnp.zeros(shape = (num_rows, num_cols))
    arr_2 = jnp.zeros(shape = (num_rows, num_cols))
    for i in range(num_rows):

        arr_1 = arr_1.at[i, :].set((par_log[kvals[i]:kvals[i+1]]))
        arr_2 = arr_2.at[i, :].set(10**par_log[kvals[i]:kvals[i+1]])

    return arr_1

arr = compute(par_log)
print(arr)

# WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
# Traceback (most recent call last):
#   File "test_7.py", line 47, in <module>
#     arr = compute(par_log)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/traceback_util.py", line 162, in reraise_with_filtered_traceback
#     return fun(*args, **kwargs)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/api.py", line 424, in cache_miss
#     out_flat = xla.xla_call(
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 1661, in bind
#     return call_bind(self, fun, *args, **params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 1652, in call_bind
#     outs = primitive.process(top_trace, fun, tracers, params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 1664, in process
#     return trace.process_call(self, fun, tracers, params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/core.py", line 633, in process_call
#     return primitive.impl(f, *tracers, **params)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/dispatch.py", line 128, in _xla_call_impl
#     compiled_fun = _xla_callable(fun, device, backend, name, donated_invars,
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/linear_util.py", line 263, in memoized_fun
#     ans = call(fun, *args)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/dispatch.py", line 155, in _xla_callable_uncached
#     return lower_xla_callable(fun, device, backend, name, donated_invars,
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/profiler.py", line 206, in wrapper
#     return func(*args, **kwargs)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/dispatch.py", line 169, in lower_xla_callable
#     jaxpr, out_avals, consts = pe.trace_to_jaxpr_final(
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/profiler.py", line 206, in wrapper
#     return func(*args, **kwargs)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/interpreters/partial_eval.py", line 1566, in trace_to_jaxpr_final
#     jaxpr, out_avals, consts = trace_to_subjaxpr_dynamic(fun, main, in_avals)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/interpreters/partial_eval.py", line 1543, in trace_to_subjaxpr_dynamic
#     ans = fun.call_wrapped(*in_tracers)
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/linear_util.py", line 166, in call_wrapped
#     ans = self.f(*args, **dict(self.params, **kwargs))
#   File "test_7.py", line 42, in compute
#     arr_1 = arr_1.at[i, :].set((par_log[kvals[i]:kvals[i+1]]))
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/numpy/lax_numpy.py", line 5704, in _rewriting_take
#     return _gather(arr, treedef, static_idx, dynamic_idx, indices_are_sorted,
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/numpy/lax_numpy.py", line 5713, in _gather
#     indexer = _index_to_gather(shape(arr), idx)  # shared with _scatter_update
#   File "/home/richinex/anaconda3/envs/numerical/lib/python3.8/site-packages/jax/_src/numpy/lax_numpy.py", line 5956, in _index_to_gather
#     raise IndexError(msg)
# jax._src.traceback_util.UnfilteredStackTrace: IndexError: Array slice indices must have static start/stop/step to be used with NumPy indexing syntax. Found slice(Traced<ShapedArray(int64[], weak_type=True)>with<DynamicJaxprTrace(level=0/1)>, Traced<ShapedArray(int64[], weak_type=True)>with<DynamicJaxprTrace(level=0/1)>, None). To index a statically sized array at a dynamic position, try lax.dynamic_slice/dynamic_update_slice (JAX does not support dynamically sized arrays within JIT compiled functions).

# The stack trace below excludes JAX-internal frames.
# The preceding is the original exception that occurred, unmodified.

# --------------------

# The above exception was the direct cause of the following exception:

Body:
The issue is that indexing in JAX must be done with static values, and within JIT kvals[i] is not a static value (because it is computed from a JAX array).

One easy way to fix this in your case is to make kvals a non-jax array; for example when you define it, do this;

kvals = list(jnp.cumsum(kvals))

This works here because kvals is created outside the jit expression. In general, if your indices are also created inside a JIT expression, you can compute slices dynamically with lax.dynamic_slice, which does support dynamic start indices.

For more background on static vs. traced values, a useful read is How To Think In JAX.


问:
Python interpretor returns error for FASTAPI - **extra: Any,
I'm having trouble executing fastapi under WSL.
I'm using:

WSL2

Ubuntu 16.04.7 LTS

Python 3.5.2 (using Visual Studio Code interpretor)

fastapi - 0.73.0

uvicorn - 0.8.6

I'm getting an error when I execute the uvicorn command -

**extra: Any,

see attached image.

I'm stuck on this for a while so any ideas would be strongly appreciated.

I tried updating python interpretor to newer version (3.9) but for some reason I did not succeed - see pls the second attached screenshot.

答:
FastAPI requires python 3.6 and won't work with Python 3.5 as you've found out.

The ubuntu version you're using does not have a new enough Python version by default. You can either install a more recent Python version in Windows, upgrade your Ubuntu version or use the deadsnakes ppa to get access to newer versions of Python on older Ubuntu versions (or the other way around if you need old Python versions on more recent versions of Ubuntu).


问:
Using matplotlib to draw a path given cartesian coordinates
I'm new to matplotlib and numpy and am trying to plot some array data to something like this:

but it currently looks like this:

My code is extremely basic but basically the image above is what I'd like to be able to do. I'm not too concerned yet with drawing gridlines but  the plot should be proportional. I've looked at some examples on the mathplotlib website but can't find something similar enough.
I wonder if pyplot is not the correct procedure or if my array is not formatted correctly?

```<code>import numpy as np
from matplotlib import pyplot as plt

data = [(2, 2), (3, 2), (4, 1), (4, 0), (3, 0), (3, 1), (4, 2),
        (4, 3), (4, 4), (3, 3), (3, 4), (2, 4), (2, 3), (1, 4),
        (0, 4), (0, 3), (1, 3), (0, 2), (1, 2), (0, 1), (0, 0),
        (1, 0), (1, 1), (2, 0), (2, 1)]

data = np.asarray(data)
print(data)
plt.ylim(0, 4)
plt.xlim(0, 4)
plt.axis([0, 4, 0, 4])
plt.plot(data)
plt.show()
</code>```

答:
Try

```<code>plt.plot(*data.transpose())
</code>```

instead of

```<code>plt.plot(data)
</code>```

The plt.plot function takes 2 arrays, one with all the x-values and one with all the y-values. You cannot pass it a mixture of x and y values. The transpose method will reorder the values so that all x values are together and all y values are togheter and the star * operator will unpack those arrays into tow separate function arguments.

Body:
I'm new to matplotlib and numpy and am trying to plot some array data to something like this:

but it currently looks like this:

My code is extremely basic but basically the image above is what I'd like to be able to do. I'm not too concerned yet with drawing gridlines but  the plot should be proportional. I've looked at some examples on the mathplotlib website but can't find something similar enough.
I wonder if pyplot is not the correct procedure or if my array is not formatted correctly?

import numpy as np
from matplotlib import pyplot as plt

data = [(2, 2), (3, 2), (4, 1), (4, 0), (3, 0), (3, 1), (4, 2),
        (4, 3), (4, 4), (3, 3), (3, 4), (2, 4), (2, 3), (1, 4),
        (0, 4), (0, 3), (1, 3), (0, 2), (1, 2), (0, 1), (0, 0),
        (1, 0), (1, 1), (2, 0), (2, 1)]

data = np.asarray(data)
print(data)
plt.ylim(0, 4)
plt.xlim(0, 4)
plt.axis([0, 4, 0, 4])
plt.plot(data)
plt.show()

Body:
Try

plt.plot(*data.transpose())

instead of

plt.plot(data)

The plt.plot function takes 2 arrays, one with all the x-values and one with all the y-values. You cannot pass it a mixture of x and y values. The transpose method will reorder the values so that all x values are together and all y values are togheter and the star * operator will unpack those arrays into tow separate function arguments.


问:
Regex to replace IP address
75.122.1.23

I need to replace the third number with 2 so it looks like 75.122.2.23

What regex can match the third section?

答:
```<code>int replacementNumber = 2;
ip = ip.replaceAll("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "$1.$2."+replacementNumber+".$4");
</code>```

Commented form:

```<code>/^                 # match beginning
    (
        \d{1,3}    # one address segment
        \.         # separation dot
        \d{1,3})   # second address segment
    \.             # separation dot
    \d{1,3}        # address segment to be replaced
    \.             # separation dot
    (\d{1,3})      # last address segment
$/x                # match end, ignore comments
</code>```

Title: Regex to replace IP address

Body:
int replacementNumber = 2;
ip = ip.replaceAll("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "$1.$2."+replacementNumber+".$4");

Commented form:

/^                 # match beginning
    (
        \d{1,3}    # one address segment
        \.         # separation dot
        \d{1,3})   # second address segment
    \.             # separation dot
    \d{1,3}        # address segment to be replaced
    \.             # separation dot
    (\d{1,3})      # last address segment
$/x                # match end, ignore comments