问:
Google Analytics 4 API - runReport() give empty result : "source" Dimension not working
I'm working with the new Google Analytics API (GA4) on a PHP script.
My API requests were working well since yesterday, one of the runReport() query suddenly start returning empty result :

```<code>        $globalTrendData = $client->runReport([
        'property' => 'properties/' . $property_id,
        'dateRanges' => [
            new DateRange([
                'start_date' => '20daysAgo',
                'end_date' => 'yesterday',
            ]),
        ],
        'dimensions' => [
            new Dimension(['name' => 'pagePath',]),
            new Dimension(['name' => 'pageTitle',]),
            new Dimension(['name' => 'city',]),
            new Dimension(['name' => 'source',]),
            new Dimension(['name' => 'date',])
        ],
        'metrics' => [
            new Metric(['name' => 'screenPageViews',]),
            new Metric(['name' => 'userEngagementDuration',]),
            new Metric(['name' => 'activeUsers',]),

        ]
    ]);
</code>```

Why this query stopped working ? Is Google making some change on the API ?

答:
Few days ago, Google started using new names for dimensions and metrics...
Remplacing some used by the old Universal Analytics API.

A migration documentation just appeared here : https://developers.google.com/analytics/devguides/migration/api/reporting-ua-to-ga4-dims-mets

So for my problem, I had to change :

```<code> new Dimension(['name' => 'source',]),
</code>```

By :

```<code>new Dimension(['name' => 'sessionSource',]),
</code>```

As "sessionSource" is the new official GA4 name to get source dimension. Solved the problem and got the correct return.

Hope it can help some people wondering why suddenly Analytics calls don't work, check metrics and dimensions names on the link above !

Body:
I'm working with the new Google Analytics API (GA4) on a PHP script.
My API requests were working well since yesterday, one of the runReport() query suddenly start returning empty result :

        $globalTrendData = $client->runReport([
        'property' => 'properties/' . $property_id,
        'dateRanges' => [
            new DateRange([
                'start_date' => '20daysAgo',
                'end_date' => 'yesterday',
            ]),
        ],
        'dimensions' => [
            new Dimension(['name' => 'pagePath',]),
            new Dimension(['name' => 'pageTitle',]),
            new Dimension(['name' => 'city',]),
            new Dimension(['name' => 'source',]),
            new Dimension(['name' => 'date',])
        ],
        'metrics' => [
            new Metric(['name' => 'screenPageViews',]),
            new Metric(['name' => 'userEngagementDuration',]),
            new Metric(['name' => 'activeUsers',]),

        ]
    ]);

Why this query stopped working ? Is Google making some change on the API ?

Body:
Few days ago, Google started using new names for dimensions and metrics...
Remplacing some used by the old Universal Analytics API.

A migration documentation just appeared here : https://developers.google.com/analytics/devguides/migration/api/reporting-ua-to-ga4-dims-mets

So for my problem, I had to change :

 new Dimension(['name' => 'source',]),

By :

new Dimension(['name' => 'sessionSource',]),

As "sessionSource" is the new official GA4 name to get source dimension. Solved the problem and got the correct return.

Hope it can help some people wondering why suddenly Analytics calls don't work, check metrics and dimensions names on the link above !


来源: stackexchange

问:
Antd button loading spin centering
Hello everyone I am using antd in my React app and have encountered a spinner problem. I would like the spinner to spin inside the element (in the center), and not stretch it, but just appear and disappear. Please help!

```<code>      <Button
        **loading**
        type="primary"
        onClick={handleClick}
      >
        Click me
      </Button>
</code>```

[standart spinner behavior][1]
[1]: https://i.stack.imgur.com/R62gE.gif

答: you want like this? the loading just center and Loading remained

ContentLicense: CC BY-SA 4.0

Title: Antd button loading spin centering

Body:
Hello everyone I am using antd in my React app and have encountered a spinner problem. I would like the spinner to spin inside the element (in the center), and not stretch it, but just appear and disappear. Please help!

      <Button
        **loading**
        type="primary"
        onClick={handleClick}
      >
        Click me
      </Button>

[standart spinner behavior][1]
[1]: https://i.stack.imgur.com/R62gE.gif


问:
Can I restrict access to Cloud Storage only to instances running on cloud run?
We have a few front and back end services running on Cloud Run. In Cloud Storage we store things such as files and images.

What I want to achieve is accessing the images from my front-end Cloud Run instances and only from my front-end Cloud Run instances. The images by default should, if accessed from other services, throw a 401.

Do you have any suggestions? For now we are not able to figure out a way of doing so.

答:
If the page are generated by your frontend service, you can restrict the access to the file to only the Cloud Run frontend service.

For that, you have to deploy your service with a custom service account.

Then, go to your bucket and remove all the permissions on it, and add only the Cloud Run custom service account the permissions to access the bucket. Use uniform access control on your bucket.

Like that, only the frontend service account will be allowed to access to the bucket.


问:
Tortoise SVN can't sync two branches. Why?
I've been using TortoiseSVN for a good while now and we have come to like it quite much. But I was asked to use another repository as well and sync rep1's single branch with rep2. Yet when I write to branch tag as a first test it says:

```<code>Error: Source and dest appear not to be in the same repository (src:   ...
dst..)
</code>```

I was a little surprised. So what if they are in different repositories? Is there no way to sync a single branch in 2 repositories aside from complete branch import?

答:
Well, what i hoped that tortoise svn could have done was that i could use SVNBridge to update local rep from rep1(std SVN) and update a single branch in rep2(Bridged to TFS) from the local rep. It seems tortoise svn cannot do so.

what i did was, first grab everything(branches, tags, etc) and create a local image of rep1. Then i opened the project from eclipse and imported the project in my local rep (updated from rep1). I disconnected the project from team menu. Then clicked Share Project and pointed to my TFS server. The eclipse version was now connected directly to TFS. Everytime people commit something to the regular SVN (rep1) i would update the local rep then in eclipse in team menu, click detect local changes and check in those changes to the TFS. This was i have some semblance of history in TFS as well as full history in SVN.

If you guys have a more sensible solution please do share:)

Thanks,

ContentLicense: CC BY-SA 3.0

Body:
I've been using TortoiseSVN for a good while now and we have come to like it quite much. But I was asked to use another repository as well and sync rep1's single branch with rep2. Yet when I write to branch tag as a first test it says:

Error: Source and dest appear not to be in the same repository (src:   ...
dst..)

I was a little surprised. So what if they are in different repositories? Is there no way to sync a single branch in 2 repositories aside from complete branch import?


问:
Can I have an Express middleware that runs after the router but before the route handler?
I want a generic middleware that can take the "req.route.path" value (e.g. "/foo/:id" and not the actual URL value "/foo/123") and return it on a HTTP response header called "X-ROUTE-NAME". The idea is for this route value to be recorded and logged by separate logging/metrics infrastructure and allow "group by" on the route name for other analysis purposes later.

Here's my first attempt:

```<code>app.use(function(req, res, next) {
  const {path} = req.route;
  console.log("The path was:", path);
  res.setHeader("X-ROUTE-NAME", req.route.path);
  next();
});
</code>```

It doesn't work because if you put it BEFORE you register routes, it doesn't have any value in req.route.path yet. But if you register it AFTER the routes, you get an exception when you try to set the header if a handler has already sent content on the req.

So yah, the tricky part is figuring out how to snatch the "req.route.path" value AFTER it's set by the router (and saving it to the response as a header), but BEFORE a handler picks it up (since the handler can send content if it wants to and then you wont be able to set headers anymore).

Any ideas?

答:
Use something like this :

router.use(routerModule) to route to the router module in main file.

And use router.get('/path', yourroute, actualCodeToBeExecuted) in the router module.

In this way, your yourroute be called after the router but before the actual functional route.

Hope this works!

Body:
I want a generic middleware that can take the "req.route.path" value (e.g. "/foo/:id" and not the actual URL value "/foo/123") and return it on a HTTP response header called "X-ROUTE-NAME". The idea is for this route value to be recorded and logged by separate logging/metrics infrastructure and allow "group by" on the route name for other analysis purposes later.

Here's my first attempt:

app.use(function(req, res, next) {
  const {path} = req.route;
  console.log("The path was:", path);
  res.setHeader("X-ROUTE-NAME", req.route.path);
  next();
});

It doesn't work because if you put it BEFORE you register routes, it doesn't have any value in req.route.path yet. But if you register it AFTER the routes, you get an exception when you try to set the header if a handler has already sent content on the req.

So yah, the tricky part is figuring out how to snatch the "req.route.path" value AFTER it's set by the router (and saving it to the response as a header), but BEFORE a handler picks it up (since the handler can send content if it wants to and then you wont be able to set headers anymore).

Any ideas?


问:
Global Model not found
When I try running the tutorial notebook Kats205: https://github.com/facebookresearch/Kats/blob/main/tutorials/kats_205_globalmodel.ipynb
In the first cell itself
from kats.models.globalmodel
I get the ModuleNotFoundError: No module named 'kats.models.globalmodel' error.
Has there been some refactoring and the tutorials are not
updated? Can someone help me with the correct usage example for Global Model?

Here are screenshots from the Colab session:

答:
The package I get from pip does not have globalmodel. However, when I install from Git repo it works.

Installation command:

!pip install -qq git+https://github.com/facebookresearch/Kats.git#egg=Kats

Title: Global Model not found


问:
nodemon not applying changes automatically to the app
When I save changes to the app nodemon says 'restarting due to changes'.
But when I refresh my localhost it does not apply the changes.
Everytime I have to run nodemon app.js to see the changes in my app. Why is it happening so?

Below is the app.js code:

```<code>const express = require('express')

// create express app
const app = express();

//register view engine
app.set('view engine','ejs');

//listen for requests
app.listen(3000);

app.use((req,res)=>{

    console.log('new request made');
    console.log('Host:',req.hostname);
    console.log('Path:',req.path);
    console.log('Method:',req.method);

});
//multiple get request handlers for diff webpages
app.get('/',(req,res)=>{

    const blogs = [
        {title: 'Yoshi finds eggs', snippet: 'Lorem ipsum dolor sit amet consectetur'},
        {title: 'Mario finds stars', snippet: 'Lorem ipsum dolor sit amet consectetur'},
        {title: 'How to defeat bowser', snippet: 'Lorem ipsum dolor sit amet consectetur'},
      ];

    res.render('index',{title:'Home',blogs:blogs});  //the path for html webpage is always relative unless provided absolute. the root dir name of the path should be specified.
});

app.get('/about',(req,res)=>{
    res.render('about',{title:'About'});

});

app.get('/blogs/create',(req,res)=>{
    res.render('create',{title:'Create blog'});
});

app.get('/featured',(req,res)=>{

    res.send('<p>Featured page</p>');
});

//redirects
app.get('/about-us',(req,res)=>{
    res.redirect('/about');          //express send this response to the browser and automatically set status code to 301.
});

//setup 404 page(this functionality always at last beacuse this displays 404 page when any of the above urls is not found)
app.use((req,res) => {
    res.status(404).render('404',{title:'Error 404'});
});

</code>```

package.json code:

```<code>{
  "dependencies": {
    "ejs": "^3.1.6",
    "express": "^4.17.2"
  }
}

</code>```

Versions:
nodemon 2.0.15,
node v16.13.2,
npm 8.1.2

答:
Restarting server is one thing, refreshing browser is another thing. For server watching I use nodemon. Nodemon can see when changes occur in any types of files. But nodemon cannot refresh browser page. For this We may use two additional packages - connect-livereload,livereload.

```<code>npm install connect-livereload livereload
</code>```

Below example:

Folder & File structure :

app.js

```<code>const path = require("path");
const livereload = require("livereload");
const connectLivereload = require("connect-livereload");
const express = require("express");
const port = 3000;

const liveReloadServer = livereload.createServer();
liveReloadServer.watch(path.join(__dirname, "views"));

liveReloadServer.server.once("connection", () => {
  setTimeout(() => {
    liveReloadServer.refresh("/");
  }, 50);
});

const app = express();
app.use(connectLivereload());

app.set("view engine", "ejs");

app.get("/", (req, res) => {
  res.render("index");
});

app.get("/about", (req, res) => {
  res.render("about", { title: "About" });
});

//listen for requests
app.listen(port, () => {
  console.log(`Server is  listening at http://localhost:${port}`);
});
</code>```

index.ejs

```<code><!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>ejs & express</title>
  </head>
  <body>
    <main>
      <div>
        <h1>This is great and it works perfectly!</h1>
        <p>Welcome to using EJS with nodemon and livereload</p>
      </div>
    </main>
  </body>
</html>
</code>```

about.ejs

```<code><!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>ejs & express</title>
  </head>
  <body>
    <main>
      <div>
        <h1>This is great and it works perfectly!</h1>
        <p>Welcome to About Page !</p>
      </div>
    </main>
  </body>
</html>
</code>```

package.json

```<code>{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "nodemon app.js -e ejs",
    "watch": "nodemon --ext ejs",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "connect-livereload": "^0.6.1",
    "ejs": "^3.1.6",
    "express": "^4.17.2",
    "livereload": "^0.9.3"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}
</code>```

npm run watch

We run app.js with command npm run watch

Now it works like a charm !

Output :

Body:
When I save changes to the app nodemon says 'restarting due to changes'.
But when I refresh my localhost it does not apply the changes.
Everytime I have to run nodemon app.js to see the changes in my app. Why is it happening so?

Below is the app.js code:

const express = require('express')

// create express app
const app = express();

//register view engine
app.set('view engine','ejs');

//listen for requests
app.listen(3000);

app.use((req,res)=>{

    console.log('new request made');
    console.log('Host:',req.hostname);
    console.log('Path:',req.path);
    console.log('Method:',req.method);

});
//multiple get request handlers for diff webpages
app.get('/',(req,res)=>{

    const blogs = [
        {title: 'Yoshi finds eggs', snippet: 'Lorem ipsum dolor sit amet consectetur'},
        {title: 'Mario finds stars', snippet: 'Lorem ipsum dolor sit amet consectetur'},
        {title: 'How to defeat bowser', snippet: 'Lorem ipsum dolor sit amet consectetur'},
      ];

    res.render('index',{title:'Home',blogs:blogs});  //the path for html webpage is always relative unless provided absolute. the root dir name of the path should be specified.
});

app.get('/about',(req,res)=>{
    res.render('about',{title:'About'});

});

app.get('/blogs/create',(req,res)=>{
    res.render('create',{title:'Create blog'});
});

app.get('/featured',(req,res)=>{

    res.send('
Featured page
');
});

//redirects
app.get('/about-us',(req,res)=>{
    res.redirect('/about');          //express send this response to the browser and automatically set status code to 301.
});

//setup 404 page(this functionality always at last beacuse this displays 404 page when any of the above urls is not found)
app.use((req,res) => {
    res.status(404).render('404',{title:'Error 404'});
});

package.json code:

{
  "dependencies": {
    "ejs": "^3.1.6",
    "express": "^4.17.2"
  }
}

Versions:
nodemon 2.0.15,
node v16.13.2,
npm 8.1.2

Body:
Restarting server is one thing, refreshing browser is another thing. For server watching I use nodemon. Nodemon can see when changes occur in any types of files. But nodemon cannot refresh browser page. For this We may use two additional packages - connect-livereload,livereload.

npm install connect-livereload livereload

Below example:

Folder & File structure :

app.js

const path = require("path");
const livereload = require("livereload");
const connectLivereload = require("connect-livereload");
const express = require("express");
const port = 3000;

const liveReloadServer = livereload.createServer();
liveReloadServer.watch(path.join(__dirname, "views"));

liveReloadServer.server.once("connection", () => {
  setTimeout(() => {
    liveReloadServer.refresh("/");
  }, 50);
});

const app = express();
app.use(connectLivereload());

app.set("view engine", "ejs");

app.get("/", (req, res) => {
  res.render("index");
});

app.get("/about", (req, res) => {
  res.render("about", { title: "About" });
});

//listen for requests
app.listen(port, () => {
  console.log(`Server is  listening at http://localhost:${port}`);
});

index.ejs

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>ejs & express</title>
  </head>
  <body>
    <main>
      <div>
        <h1>This is great and it works perfectly!</h1>
        <p>Welcome to using EJS with nodemon and livereload</p>
      </div>
    </main>
  </body>
</html>

about.ejs

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>ejs & express</title>
  </head>
  <body>
    <main>
      <div>
        <h1>This is great and it works perfectly!</h1>
        <p>Welcome to About Page !</p>
      </div>
    </main>
  </body>
</html>

package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "nodemon app.js -e ejs",
    "watch": "nodemon --ext ejs",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "connect-livereload": "^0.6.1",
    "ejs": "^3.1.6",
    "express": "^4.17.2",
    "livereload": "^0.9.3"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

npm run watch

We run app.js with command npm run watch

Now it works like a charm !

Output :


问:
Im trying something with IF in Batch but is not working as im expecting
I need to do an script that looks for some text in a file and also look for a file itself in a %userprofile% path, and it works fine but when i tried to unify it so that instead of outputing 2 confirming messages only output 1, something is not going as expected, this is the code:

```<code>hostname > hstnm.txt
SET /p hstnm=<hstnm.txt
SET pccer=.filextension1
SET pcsip=.filextension2
SET fullhost=%hstnm%%pccer%
SET fullsip=%hstnm%%pcsip%
SET fullroute=%userprofile%\thepath\%fullhost%
SET siproute=%userprofile%\thepath\%fullsip%

FINDSTR /m "<Protocol>TLS</Protocol>" "%siproute%"
IF %errorlevel%==0 (
 SET siptest="true"
) ELSE (
 SET siptest="false"
)

IF EXIST "%fullroute%" (
 SET certest="true"
) ELSE (
 SET certest="false"
)

IF %siptest%=="true" & %certest%=="true" (
ECHO message if everything good
) ELSE (
ECHO message if something bad
)
pause
</code>```

The FINDSTR and the IF EXIST are working properly (if u swap SET for an ECHO it does display a message). The problem arrives at the part of using the %certest% and the %siproute%, it is doing nothing, just outputs this (if i quit the @echo off)

```<code>...
C:\path>IF EXIST "C:\Users\Administrador\Appdata\Roaming\Interactive Intelligence\PureCloud Softphone\certificates\sip\GSSES0401107C.grupogss.corp.cer" (SET certest="true" )  ELSE (SET certest="false" )
No se esperaba & en este momento.
C:\path>IF "true"=="true" & "true"=="true" (
C:\path>
</code>```

Help me please! thanks in advance.

答:
The line in question has a '&' character which I assume you are trying to use as a boolean AND operator - 'IF' in CMD does not have an AND operator.  The CMD command chain mechanism does and that's where the probably confusion arises.  I typically nest IFs in cases like this:

```<code>IF %siptest%=="true" (
    IF %certest%=="true" (...
</code>```

The '&' operator " simply chains a number of command together on one line:

```<code>dir & cd \ & dir & del myfile.txt
</code>```

All the above command will be executed, one after the other.

On the other hand, the '&&' operator works a bit more like an AND operator in that it executes the next command in the chain only if ERRORLEVEL of the previous command is "0" (no error).

```<code>del myfile.txt && echo Done! && cd c:\
</code>```

The echo command will only be executed if del command returns a 0 as its ERRORLEVEL.  The cd command is dependent on the results all of the previous commands, meaning it only takes one failed command to break the chain.

I am personally also careful how I use variables and always enclose them:

```<code>IF "%MYVAR%"=="0" (...
</code>```

I do that because in the end you are not comparing a variable to something, but rather it is a simple string comparison; CMD variables are replaced with the content of what they represent before any actions on them.  When that replacement happens can be adjusted to a certain degree, but in the end it is always a string comparison.  That means that if the variable doesn't have any content (it happens) and you use that to compare, without some kind of enclosure, then your script will fail and exit, due to the resulting IF being malformed.

https://ss64.com/nt/if.html

https://ss64.com/nt/syntax-conditional.html

Body:
I need to do an script that looks for some text in a file and also look for a file itself in a %userprofile% path, and it works fine but when i tried to unify it so that instead of outputing 2 confirming messages only output 1, something is not going as expected, this is the code:

hostname > hstnm.txt
SET /p hstnm=<hstnm.txt
SET pccer=.filextension1
SET pcsip=.filextension2
SET fullhost=%hstnm%%pccer%
SET fullsip=%hstnm%%pcsip%
SET fullroute=%userprofile%\thepath\%fullhost%
SET siproute=%userprofile%\thepath\%fullsip%

FINDSTR /m "<Protocol>TLS</Protocol>" "%siproute%"
IF %errorlevel%==0 (
 SET siptest="true"
) ELSE (
 SET siptest="false"
)

IF EXIST "%fullroute%" (
 SET certest="true"
) ELSE (
 SET certest="false"
)

IF %siptest%=="true" & %certest%=="true" (
ECHO message if everything good
) ELSE (
ECHO message if something bad
)
pause

The FINDSTR and the IF EXIST are working properly (if u swap SET for an ECHO it does display a message). The problem arrives at the part of using the %certest% and the %siproute%, it is doing nothing, just outputs this (if i quit the @echo off)

...
C:\path>IF EXIST "C:\Users\Administrador\Appdata\Roaming\Interactive Intelligence\PureCloud Softphone\certificates\sip\GSSES0401107C.grupogss.corp.cer" (SET certest="true" )  ELSE (SET certest="false" )
No se esperaba & en este momento.
C:\path>IF "true"=="true" & "true"=="true" (
C:\path>

Help me please! thanks in advance.

Body:
The line in question has a '&' character which I assume you are trying to use as a boolean AND operator - 'IF' in CMD does not have an AND operator.  The CMD command chain mechanism does and that's where the probably confusion arises.  I typically nest IFs in cases like this:

IF %siptest%=="true" (
    IF %certest%=="true" (...

The '&' operator " simply chains a number of command together on one line:

dir & cd \ & dir & del myfile.txt

All the above command will be executed, one after the other.

On the other hand, the '&&' operator works a bit more like an AND operator in that it executes the next command in the chain only if ERRORLEVEL of the previous command is "0" (no error).

del myfile.txt && echo Done! && cd c:\

The echo command will only be executed if del command returns a 0 as its ERRORLEVEL.  The cd command is dependent on the results all of the previous commands, meaning it only takes one failed command to break the chain.

I am personally also careful how I use variables and always enclose them:

IF "%MYVAR%"=="0" (...

I do that because in the end you are not comparing a variable to something, but rather it is a simple string comparison; CMD variables are replaced with the content of what they represent before any actions on them.  When that replacement happens can be adjusted to a certain degree, but in the end it is always a string comparison.  That means that if the variable doesn't have any content (it happens) and you use that to compare, without some kind of enclosure, then your script will fail and exit, due to the resulting IF being malformed.

https://ss64.com/nt/if.html

https://ss64.com/nt/syntax-conditional.html


问:
Interaction.author isn't defined but I already defined "interaction"
Code::

```<code>fs.writeFile("./logs.txt", `Hug command executed by ${interaction.author}`, function(err) {
            if(err) {
                return console.log(err)
            }
            console.log("The file has been saved!");
        });
</code>```

logs.txt:
Logs.txt file

Console:
Command prompt

Yes I did define interaction when making the slash command "async execute(interaction){
rest of code
}"

答:
So my IRL friend came online and helped me, he told me instead of going to each command and putting the same code there he told me to go to index.js and put this code

```<code>client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    var member = interaction.user.tag

    const command = client.commands.get(interaction.commandName);

    if (!command) return;

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }

    fs.appendFile("logs.txt", `${interaction.commandName} command executed by ${member}\n`, function(err) {
        if(err) {
            return console.log(err)
        }
        console.log("The file has been saved!");
    });
});
</code>```

Body:
Code::

fs.writeFile("./logs.txt", `Hug command executed by ${interaction.author}`, function(err) {
            if(err) {
                return console.log(err)
            }
            console.log("The file has been saved!");
        });

logs.txt:
Logs.txt file

Console:
Command prompt

Yes I did define interaction when making the slash command "async execute(interaction){
rest of code
}"

Body:
So my IRL friend came online and helped me, he told me instead of going to each command and putting the same code there he told me to go to index.js and put this code

client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    var member = interaction.user.tag

    const command = client.commands.get(interaction.commandName);

    if (!command) return;

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }

    fs.appendFile("logs.txt", `${interaction.commandName} command executed by ${member}\n`, function(err) {
        if(err) {
            return console.log(err)
        }
        console.log("The file has been saved!");
    });
});


问:
Search for string in several spreadsheets (without macros)
Suppose I have several rows of data across different spreadsheets in the same workbook and I want to display (in a separate spreadsheet) only the rows which contain a specific string. How would I do that?</p>

答:
Without macros this gets a little clumsy, but one way to do it is with linking and filtering.

In your separate workbook, copy all the rows from the several worksheets that might be of interest and make sure that they are linked to the source workbook or worksheets. (If you are doing all of this from within the same workbook, you don't have to worry about the external linking.)

Then apply filtering to all of these rows, and set up your filter to look for the specific string that you need.


问:
How to add CSS to change colour on hover
I am trying to create a button with text inside. I want it so that when you hover over the box, the color of the box changes to white, and the colour of the text changes to blue.

How can I add css to make my text and box change colors on hover?

Edited: I got the html snippet for that from another part of the website template I am editing. It is basically a box that does exactly what I have outline above. I then placed it inside the list tag of the menu html, hoping that it will just transfer the functionality but it didn't work. So I tried to add the [hover:] but it still isn't working.

I know I am doing something wrong but I don't know enough to know what it is.

Code snippet is for html:

                                Upload resources

答:
Use :hover pseudo selector

```<code>element{
    color: white;
    background: blue;
}

element:hover{
    color: blue;
    background: white;
}
</code>```

You can check these at Click Here

Body:
Use :hover pseudo selector

element{
    color: white;
    background: blue;
}

element:hover{
    color: blue;
    background: white;
}

You can check these at Click Here


问:
Extracting dates that satisfied multiple conditions using NCO/CDO or bash
I have a netcdf file containing vorticity (per sec) and winds (m/s). I want to print the dates of gridpoints that satisfy the following conditions:

1). Vorticity > 1x10^-5 per sec and winds >= 5 m/s at a gridpoint.

2). The average of vorticity and winds at the "four" (North, West, East, South) surrounding the gridpoint found in (1) should also be > 1x10^-5 and 5m/s, respectively.

I am able to just filter the gridpoints that satisfied (1), using ncap:

```<code>ncap2 -v -O -s 'where(vort > 1e-5 && winds >= 5) vort=vort; elsewhere vort=vort.get_miss();' input_test.nc output_test.nc
</code>```

How do I get the dates? Also how can I implement the second condition.

Here's the screenshot of the header of the netcdf file.

I'll appreciate any help on this.

答:
This may be achieved by combining "cdo" and "nco".

The average value of the surrounding 4 grids needed for the second condition can be calculated by combining the shiftxy and ensmean operators of "cdo".

```<code>cdo selname,vr,wspd input_test.nc vars.nc
cdo -expr,'vr_mean=vr; wspd_mean=wspd' \
      -ensmean \
        -shiftx,1  vars.nc \
        -shiftx,-1 vars.nc \
        -shifty,1  vars.nc \
        -shifty,-1 vars.nc \
    vars_mean.nc
</code>```

You can then use merge operator of "cdo" to combine the variables needed to check conditions 1) and 2) into a single NetCDF file, and use ncap2 to check the conditions as you have tried.

In the example command below, the "for" loop of "ncap2" is used to scan the time. If there is at least one grid that satisfies both conditions 1) and 2) at each time, the information for that time will be displayed.

```<code>cdo merge vars.nc vars_mean.nc vars_test.nc
ncap2 -s '*flag = (vr > 1e-5 && wspd >= 5) && (vr > 1e-5 && wspd >= 5); *nt=$time.size; for(*i=0;i<nt;i++) { if ( max(flag(i,:,:))==1 ) { print(time(i)); } }' vars_test.nc
</code>```

Body:
I have a netcdf file containing vorticity (per sec) and winds (m/s). I want to print the dates of gridpoints that satisfy the following conditions:

1). Vorticity > 1x10^-5 per sec and winds >= 5 m/s at a gridpoint.

2). The average of vorticity and winds at the "four" (North, West, East, South) surrounding the gridpoint found in (1) should also be > 1x10^-5 and 5m/s, respectively.

I am able to just filter the gridpoints that satisfied (1), using ncap:

ncap2 -v -O -s 'where(vort > 1e-5 && winds >= 5) vort=vort; elsewhere vort=vort.get_miss();' input_test.nc output_test.nc

How do I get the dates? Also how can I implement the second condition.

Here's the screenshot of the header of the netcdf file.

I'll appreciate any help on this.

Body:
This may be achieved by combining "cdo" and "nco".

The average value of the surrounding 4 grids needed for the second condition can be calculated by combining the shiftxy and ensmean operators of "cdo".

cdo selname,vr,wspd input_test.nc vars.nc
cdo -expr,'vr_mean=vr; wspd_mean=wspd' \
      -ensmean \
        -shiftx,1  vars.nc \
        -shiftx,-1 vars.nc \
        -shifty,1  vars.nc \
        -shifty,-1 vars.nc \
    vars_mean.nc

You can then use merge operator of "cdo" to combine the variables needed to check conditions 1) and 2) into a single NetCDF file, and use ncap2 to check the conditions as you have tried.

In the example command below, the "for" loop of "ncap2" is used to scan the time. If there is at least one grid that satisfies both conditions 1) and 2) at each time, the information for that time will be displayed.

cdo merge vars.nc vars_mean.nc vars_test.nc
ncap2 -s '*flag = (vr > 1e-5 && wspd >= 5) && (vr > 1e-5 && wspd >= 5); *nt=$time.size; for(*i=0;i<nt;i++) { if ( max(flag(i,:,:))==1 ) { print(time(i)); } }' vars_test.nc


问:
The date command appears to convert timezones the wrong way?
I'm working on a script where I need to convert the current time, in UTC to something else:

```<code>fmt="%Y-%m-%d %H:%M:%S"
tzone=America/Detroit
nowinutc=$(TZ=UTC date +"$fmt");echo $nowinutc
nowintz=$(date -d "TZ=\"$tzone\" $nowinutc" +"$fmt");echo $nowintz
yestintz=$(date -d "$nowintz - 1 day" +"$fmt");echo $yestintz
</code>```

I know America/Detroit is 5 hours behind UTC, so 08:00:00 should become 03:00:00, but:

```<code>$ fmt="%Y-%m-%d %H:%M:%S"
$ tzone=America/Detroit
$ nowinutc=$(TZ=UTC date +"$fmt");echo $nowinutc
2022-02-11 08:49:51
$ nowintz=$(date -d "TZ=\"$tzone\" $nowinutc" +"$fmt");echo $nowintz
2022-02-11 13:49:51
$ yestintz=$(date -d "$nowintz - 1 day" +"$fmt");echo $yestintz
2022-02-12 14:49:51
</code>```

It's probably not the date command that gets it wrong, but what am I doing wrong here? It looks like everything works the opposite way of expected. Not only does the timezone conversion add 5 hours, but subtracting 1 day adds 25 hours - what is going on here?

答:
so 08:00:00 should become 03:00:00

Then the input is in UTC and you are in Detroit.

```<code>TZ=America/Detroit date -d "08:00:00 UTC" +%H:%M:%S
TZ=America/Detroit date -d "TZ=\"UTC\" 08:00:00" +%H:%M:%S
TZ=America/Detroit date -d "08:00:00+00:00" +%H:%M:%S
</code>```

From man date examples:

```<code>   Show the time on the west coast of the US (use tzselect(1) to find TZ)

          $ TZ='America/Los_Angeles' date

   Show the local time for 9AM next Friday on the west coast of the US

          $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'
</code>```

Body:
I'm working on a script where I need to convert the current time, in UTC to something else:

fmt="%Y-%m-%d %H:%M:%S"
tzone=America/Detroit
nowinutc=$(TZ=UTC date +"$fmt");echo $nowinutc
nowintz=$(date -d "TZ=\"$tzone\" $nowinutc" +"$fmt");echo $nowintz
yestintz=$(date -d "$nowintz - 1 day" +"$fmt");echo $yestintz

I know America/Detroit is 5 hours behind UTC, so 08:00:00 should become 03:00:00, but:

$ fmt="%Y-%m-%d %H:%M:%S"
$ tzone=America/Detroit
$ nowinutc=$(TZ=UTC date +"$fmt");echo $nowinutc
2022-02-11 08:49:51
$ nowintz=$(date -d "TZ=\"$tzone\" $nowinutc" +"$fmt");echo $nowintz
2022-02-11 13:49:51
$ yestintz=$(date -d "$nowintz - 1 day" +"$fmt");echo $yestintz
2022-02-12 14:49:51

It's probably not the date command that gets it wrong, but what am I doing wrong here? It looks like everything works the opposite way of expected. Not only does the timezone conversion add 5 hours, but subtracting 1 day adds 25 hours - what is going on here?

Body:
so 08:00:00 should become 03:00:00

Then the input is in UTC and you are in Detroit.

TZ=America/Detroit date -d "08:00:00 UTC" +%H:%M:%S
TZ=America/Detroit date -d "TZ=\"UTC\" 08:00:00" +%H:%M:%S
TZ=America/Detroit date -d "08:00:00+00:00" +%H:%M:%S

From man date examples:

   Show the time on the west coast of the US (use tzselect(1) to find TZ)

          $ TZ='America/Los_Angeles' date

   Show the local time for 9AM next Friday on the west coast of the US

          $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'


问:
FFMPEG metadata not work with segment format
I'm trying to add rotation metadata to the video recorded from RTSP stream. All works fine until I try to run recording with segment format. My command looks like this:

```<code>ffmpeg -rtsp_transport tcp -stimeout 1000000 -i "<RTSP>" -vcodec copy -map_metadata 0 -metadata:s:v rotate=270 -an -dn -y -segment_time 60 -strftime 1 -reset_timestamps 1 -t 25 -f segment /home/short.mp4

</code>```

I can see in logs that rotate should be written to the metadata as displaymatrix: rotation of -90.00 degrees

```<code>ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --disable-stripping --enable-pic --enable-shared --enable-pthreads --cross-prefix=aarch64-poky-linux- --ld='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cc='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cxx='aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --arch=aarch64 --target-os=linux --enable-cross-compile --extra-cflags=' -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0=/usr/src/debug/ffmpeg/4.2.2-r0 -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot= -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot-native= -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --extra-ldflags='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now' --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot --libdir=/usr/lib --shlibdir=/usr/lib --datadir=/usr/share/ffmpeg --disable-mipsdsp --disable-mipsdspr2 --cpu=generic --pkg-config=pkg-config --disable-static --enable-alsa --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-bzlib --disable-libfdk-aac --enable-gpl --disable-libgsm --disable-indev=jack --disable-libvorbis --enable-lzma --disable-libmfx --disable-libmp3lame --disable-openssl --enable-postproc --disable-sdl2 --disable-libspeex --enable-swresample --enable-swscale --enable-libtheora --disable-vaapi --disable-vdpau --disable-libvpx --enable-libx264 --disable-libx265 --enable-libxcb --enable-outdev=xv --enable-zlib
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, rtsp, from 'rtsp://admin:dupa.666@192.168.77.122:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream':
  Metadata:
    title           : RTSP Session
  Duration: N/A, start: 0.200000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 5 fps, 5 tbr, 90k tbn, 180k tbc
Output #0, segment, to '/home/short.mp4':
  Metadata:
    title           : RTSP Session
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, q=2-31, 5 fps, 5 tbr, 90k tbn, 90k tbc
    Side data:
      displaymatrix: rotation of -90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[segment @ 0x5594be0340] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[segment @ 0x5594be0340] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
frame=   67 fps=8.6 q=-1.0 Lsize=N/A time=00:00:13.00 bitrate=N/A speed=1.67x
</code>```

Unfortunately, there is no metadata in out video

```<code>$ ffmpeg -i short.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --disable-stripping --enable-pic --enable-shared --enable-pthreads --cross-prefix=aarch64-poky-linux- --ld='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cc='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cxx='aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --arch=aarch64 --target-os=linux --enable-cross-compile --extra-cflags=' -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0=/usr/src/debug/ffmpeg/4.2.2-r0 -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot= -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot-native= -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --extra-ldflags='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now' --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot --libdir=/usr/lib --shlibdir=/usr/lib --datadir=/usr/share/ffmpeg --disable-mipsdsp --disable-mipsdspr2 --cpu=generic --pkg-config=pkg-config --disable-static --enable-alsa --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-bzlib --disable-libfdk-aac --enable-gpl --disable-libgsm --disable-indev=jack --disable-libvorbis --enable-lzma --disable-libmfx --disable-libmp3lame --disable-openssl --enable-postproc --disable-sdl2 --disable-libspeex --enable-swresample --enable-swscale --enable-libtheora --disable-vaapi --disable-vdpau --disable-libvpx --enable-libx264 --disable-libx265 --enable-libxcb --enable-outdev=xv --enable-zlib
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'short.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : RTSP Session
    encoder         : Lavf58.29.100
  Duration: 00:00:13.00, start: 0.000000, bitrate: 1024 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080, 1023 kb/s, 5.15 fps, 5 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandler
At least one output file must be specified
</code>```

Any idea how to record RTSP using both segment and metadata? I really prefer using metadata for rotation, as I plan to save more information in metadata in the future.

答:
I found out it has been resolved in

https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=a74428921f8bfb33cbe0340bfd810b6945e432d2#patch1

and it works fine in ffmpeg 5.0. You can also apply this patch to 4.4.

Body:
I'm trying to add rotation metadata to the video recorded from RTSP stream. All works fine until I try to run recording with segment format. My command looks like this:

ffmpeg -rtsp_transport tcp -stimeout 1000000 -i "<RTSP>" -vcodec copy -map_metadata 0 -metadata:s:v rotate=270 -an -dn -y -segment_time 60 -strftime 1 -reset_timestamps 1 -t 25 -f segment /home/short.mp4

I can see in logs that rotate should be written to the metadata as displaymatrix: rotation of -90.00 degrees

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --disable-stripping --enable-pic --enable-shared --enable-pthreads --cross-prefix=aarch64-poky-linux- --ld='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cc='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cxx='aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --arch=aarch64 --target-os=linux --enable-cross-compile --extra-cflags=' -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0=/usr/src/debug/ffmpeg/4.2.2-r0 -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot= -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot-native= -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --extra-ldflags='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now' --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot --libdir=/usr/lib --shlibdir=/usr/lib --datadir=/usr/share/ffmpeg --disable-mipsdsp --disable-mipsdspr2 --cpu=generic --pkg-config=pkg-config --disable-static --enable-alsa --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-bzlib --disable-libfdk-aac --enable-gpl --disable-libgsm --disable-indev=jack --disable-libvorbis --enable-lzma --disable-libmfx --disable-libmp3lame --disable-openssl --enable-postproc --disable-sdl2 --disable-libspeex --enable-swresample --enable-swscale --enable-libtheora --disable-vaapi --disable-vdpau --disable-libvpx --enable-libx264 --disable-libx265 --enable-libxcb --enable-outdev=xv --enable-zlib
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, rtsp, from 'rtsp://admin:dupa.666@192.168.77.122:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream':
  Metadata:
    title           : RTSP Session
  Duration: N/A, start: 0.200000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 5 fps, 5 tbr, 90k tbn, 180k tbc
Output #0, segment, to '/home/short.mp4':
  Metadata:
    title           : RTSP Session
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, q=2-31, 5 fps, 5 tbr, 90k tbn, 90k tbc
    Side data:
      displaymatrix: rotation of -90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[segment @ 0x5594be0340] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[segment @ 0x5594be0340] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
frame=   67 fps=8.6 q=-1.0 Lsize=N/A time=00:00:13.00 bitrate=N/A speed=1.67x

Unfortunately, there is no metadata in out video

$ ffmpeg -i short.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --disable-stripping --enable-pic --enable-shared --enable-pthreads --cross-prefix=aarch64-poky-linux- --ld='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cc='aarch64-poky-linux-gcc -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --cxx='aarch64-poky-linux-g++ -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --arch=aarch64 --target-os=linux --enable-cross-compile --extra-cflags=' -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0=/usr/src/debug/ffmpeg/4.2.2-r0 -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot= -fdebug-prefix-map=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot-native= -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot' --extra-ldflags='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now' --sysroot=/home/ubuntu/przemoch/safeway-by-sternkraft/build/tmp/work/aarch64-poky-linux/ffmpeg/4.2.2-r0/recipe-sysroot --libdir=/usr/lib --shlibdir=/usr/lib --datadir=/usr/share/ffmpeg --disable-mipsdsp --disable-mipsdspr2 --cpu=generic --pkg-config=pkg-config --disable-static --enable-alsa --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-bzlib --disable-libfdk-aac --enable-gpl --disable-libgsm --disable-indev=jack --disable-libvorbis --enable-lzma --disable-libmfx --disable-libmp3lame --disable-openssl --enable-postproc --disable-sdl2 --disable-libspeex --enable-swresample --enable-swscale --enable-libtheora --disable-vaapi --disable-vdpau --disable-libvpx --enable-libx264 --disable-libx265 --enable-libxcb --enable-outdev=xv --enable-zlib
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'short.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : RTSP Session
    encoder         : Lavf58.29.100
  Duration: 00:00:13.00, start: 0.000000, bitrate: 1024 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080, 1023 kb/s, 5.15 fps, 5 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandler
At least one output file must be specified

Any idea how to record RTSP using both segment and metadata? I really prefer using metadata for rotation, as I plan to save more information in metadata in the future.


问:
K8s deployment Minio How to access the Console?
How do I access the Minio console?

minio.yaml

apiVersion: v1
kind: Service
metadata:
  name: minio
  labels:
    app: minio
spec:
  clusterIP: None
  ports:
    - port: 9000
      name: minio
  selector:
    app: minio
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: minio
spec:
  serviceName: minio
  replicas: 4
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      terminationGracePeriodSeconds: 20
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                    - minio
              topologyKey: kubernetes.io/hostname
      containers:
      - name: minio
        env:
        - name: MINIO_ACCESS_KEY
          value: "hengshi"
        - name: MINIO_SECRET_KEY
          value: "hengshi202020"
        image: minio/minio:RELEASE.2018-08-02T23-11-36Z
        args:
        - server
        - http://minio-0.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        - http://minio-1.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        - http://minio-2.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        - http://minio-3.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        ports:
        - containerPort: 9000
        - containerPort: 9001
        volumeMounts:
        - name: minio-data
          mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: minio-data
    spec:
      accessModes:
      - ReadWriteMany
      resources:
        requests:
          storage: 300M
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
spec:
  type: NodePort
  ports:
    - name: server-port
      port: 9000
      targetPort: 9000
      protocol: TCP
      nodePort: 30009
    - name: console-port
      port: 9001
      targetPort: 9001
      protocol: TCP
      nodePort: 30010
  selector:
    app: minio
```

curl http://NodeIP:30010 is failed

I tried container --args --console-address ":9001"  or  env  MINIO_BROWSER   still not accessible

One more question, what is the latest image startup parameter for Minio? There seems to be something wrong with my args

enter image description here

答:
You can specify --console-address :9001 in your deployment.yaml file as below in args: section .

```<code>args:
  - server
  - --console-address
  - :9001
  - /data
</code>```

Same way your Service and Ingress needs to point to 9001 port now with the latest Minio.

```<code>ports:
    - protocol: TCP
      port: 9001
</code>```

Body:
How do I access the Minio console?

minio.yaml

apiVersion: v1
kind: Service
metadata:
  name: minio
  labels:
    app: minio
spec:
  clusterIP: None
  ports:
    - port: 9000
      name: minio
  selector:
    app: minio
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: minio
spec:
  serviceName: minio
  replicas: 4
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      terminationGracePeriodSeconds: 20
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                    - minio
              topologyKey: kubernetes.io/hostname
      containers:
      - name: minio
        env:
        - name: MINIO_ACCESS_KEY
          value: "hengshi"
        - name: MINIO_SECRET_KEY
          value: "hengshi202020"
        image: minio/minio:RELEASE.2018-08-02T23-11-36Z
        args:
        - server
        - http://minio-0.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        - http://minio-1.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        - http://minio-2.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        - http://minio-3.minio-internal.cts-cernerdevtools-minio.svc.cluster.local/data/
        ports:
        - containerPort: 9000
        - containerPort: 9001
        volumeMounts:
        - name: minio-data
          mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: minio-data
    spec:
      accessModes:
      - ReadWriteMany
      resources:
        requests:
          storage: 300M
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
spec:
  type: NodePort
  ports:
    - name: server-port
      port: 9000
      targetPort: 9000
      protocol: TCP
      nodePort: 30009
    - name: console-port
      port: 9001
      targetPort: 9001
      protocol: TCP
      nodePort: 30010
  selector:
    app: minio

curl http://NodeIP:30010 is failed

I tried container --args --console-address ":9001"  or  env  MINIO_BROWSER   still not accessible

One more question, what is the latest image startup parameter for Minio? There seems to be something wrong with my args

enter image description here

Body:
You can specify --console-address :9001 in your deployment.yaml file as below in args: section .

args:
  - server
  - --console-address
  - :9001
  - /data

Same way your Service and Ingress needs to point to 9001 port now with the latest Minio.

ports:
    - protocol: TCP
      port: 9001


问:
react-router-dom v6 useRoutes
Uncaught Error: Objects are not valid as a React child (found: object with keys {$$typeof, _payload, _init}). If you meant to render a collection of children, use an array instead.

index.tsx:

```<code>import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

import 'assets/styles/base.css'

ReactDOM.render(<App />, document.getElementById('root'))

</code>```

App.tsx:

```<code>import React, { memo, Suspense } from 'react'
import { HashRouter, useRoutes, Navigate } from 'react-router-dom'
import { renderRoutes } from 'react-router-config'
const Discover = React.lazy(() => import('views/discover'))
const NotFound = React.lazy(() => import('views/not-found'))

const Router = memo(() => {
  const element = useRoutes([
    {
      path: '/',
      element: Navigate({
        to: '/discover',
        replace: true
      })
    },
    {
      path: '/discover',
      element: Discover
    },
    {
      path: '*',
      element: NotFound
    }
  ])
  return element
})

const App = memo(() => {
  return (
    <HashRouter>
      <header>header</header>
      <Suspense fallback={<div>loading</div>}>
        <Router></Router>
      </Suspense>
      <footer>footer</footer>
    </HashRouter>
  )
})

export default App

</code>```

github:https://github.com/ashuicoder/react-music-ts

答:
Based on the documentation : https://reactrouter.com/docs/en/v6/hooks/use-routes

You should put component instance in the 'element' properties:

```<code>const element = useRoutes([
  {
    path: '/',
    element: <Navigate to='/discover' replace={true} />
  },
  {
    path: '/discover',
    element: <Discover />
  },
  {
    path: '*',
    element: <NotFound />
  }
])
</code>```

Title: react-router-dom v6 useRoutes

Body:
Uncaught Error: Objects are not valid as a React child (found: object with keys {$$typeof, _payload, _init}). If you meant to render a collection of children, use an array instead.

index.tsx:

import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

import 'assets/styles/base.css'

ReactDOM.render(<App />, document.getElementById('root'))

App.tsx:

import React, { memo, Suspense } from 'react'
import { HashRouter, useRoutes, Navigate } from 'react-router-dom'
import { renderRoutes } from 'react-router-config'
const Discover = React.lazy(() => import('views/discover'))
const NotFound = React.lazy(() => import('views/not-found'))

const Router = memo(() => {
  const element = useRoutes([
    {
      path: '/',
      element: Navigate({
        to: '/discover',
        replace: true
      })
    },
    {
      path: '/discover',
      element: Discover
    },
    {
      path: '*',
      element: NotFound
    }
  ])
  return element
})

const App = memo(() => {
  return (
    <HashRouter>
      header
      <Suspense fallback={
loading
}>
        <Router></Router>
      </Suspense>
      footer
    </HashRouter>
  )
})

export default App

github:https://github.com/ashuicoder/react-music-ts

Body:
Based on the documentation : https://reactrouter.com/docs/en/v6/hooks/use-routes

You should put component instance in the 'element' properties:

const element = useRoutes([
  {
    path: '/',
    element: <Navigate to='/discover' replace={true} />
  },
  {
    path: '/discover',
    element: <Discover />
  },
  {
    path: '*',
    element: <NotFound />
  }
])


问:
Gnome-terminal - How to Copy selection to clipboard automatically?
I want to make gnome-terminal behave in such a way that when the
end user selects a region on the terminal (with a mouse or mouse
key), it gets automatically copied into the clipboard. Is it
possible at all?  If so, how?</p>

答:
I've been searching for a long time a way to emulate Putty's behavior in the default Ubuntu terminal:

left-click to select text and copies it into the clipboard

right-click to paste the content of the clipboard

The only solution I found, which works perfectly, is to patch the Gnome terminal (as you already guessed it).

ContentLicense: CC BY-SA 2.5


问:
Missing argument for parameter 'from' in call. Insert 'from: <#Decoder#>'
I am trying to create a new instance of a codable struct

```<code>@State private var parcel = Parcel()
</code>```

but I'm getting this error:

Missing argument for parameter 'from' in call
Insert 'from: <#Decoder#>'

```<code>struct Parcel: Codable {
    var created_at: String
    var height: Double
    var id: String
    var length: Double
    var mode: String?
    var object: String
    var predefined_package: String?
    var updated_at: String?
    var weight: Double
    var width: Double
}
</code>```

答: By default, structs create an initialiser behind the scenes for every non-optional property that you declare. So by simply creating an instance of the struct you need to include all non-optional values it requires. If you don’t want to add the values when you initialise it, change them to vars and make them optional (add ? to the end).</p>

Body:
I am trying to create a new instance of a codable struct

@State private var parcel = Parcel()

but I'm getting this error:

Missing argument for parameter 'from' in call
Insert 'from: <#Decoder#>'

struct Parcel: Codable {
    var created_at: String
    var height: Double
    var id: String
    var length: Double
    var mode: String?
    var object: String
    var predefined_package: String?
    var updated_at: String?
    var weight: Double
    var width: Double
}


问:
mvn clean install compilation failure for JUnit 5
I am running Junit 5 tests in 2 projects. In one project same set up is workign fine and tests are runwithout issue.

In the other project I am consistently getting below compilation error. The dependencies are added in PoM file and when run from eclipse, tests run without error. Just mvn clean install fails. I have looked at various posts for similar error but it did not solve my issue. Any leads will be really helpful. same pom file in other projects works perfectly fine.

```<code>Error:
     Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project junit5-sampletests: Compilation failure: Compilation failure:
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass2.java:[3,29]     package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestBaseClass.java:[3,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestBaseClass.java:[4,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass1.java:[3,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass3.java:[3,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass2.java:[7,10] cannot find symbol
</code>```

Contents of my pom file:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>demo</groupId>
    <artifactId>junit5-sampletests</artifactId>
    <version>1.0.1</version>
    <packaging>jar</packaging>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>

                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                </dependencies>
                <configuration>

                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <additionalClasspathElements>
                        <additionalClasspathElement>src/test/java/</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <outputDirectory>${basedir}/target/site/surefire-report.html</outputDirectory>
                </configuration>

            </plugin>
        </plugins>
    </reporting>
    <repositories>
        <repository>
            <id>maven-repository</id>
            <url>file:///${project.basedir}/maven-repository</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite</artifactId>
            <scope>test</scope>
            <version>1.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-api</artifactId>
            <version>1.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>```
</div>
</div>
</p>
<p>Structure in Eclipse:</p>
<p>The test are very simple as of now as I am tryign to create and prorotype junit5 framwrok. One of teh test file is:</p>
```package demoTest;
```
<p>import org.junit.jupiter.api.Test;</p>
<p>/**</p>
<ul>
<li>@author ayesha</li>
<li></li>
</ul>
<p>*/
public class TestDemoClass3 extends TestBaseClass {</p>
```@Test
public void test5() throws Exception {
    System.out.println("Test 1 from DemoClass 3 "  +Thread.currentThread().getName());
}

@Test

public void test6() throws Exception {
    System.out.println("Test 2 from DemoClass 3 " + Thread.currentThread().getName());

}
```

}

答: src tag was added to the pom file. Removing this , worked well.</p>

Body:
I am running Junit 5 tests in 2 projects. In one project same set up is workign fine and tests are runwithout issue.

In the other project I am consistently getting below compilation error. The dependencies are added in PoM file and when run from eclipse, tests run without error. Just mvn clean install fails. I have looked at various posts for similar error but it did not solve my issue. Any leads will be really helpful. same pom file in other projects works perfectly fine.

Error:
     Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project junit5-sampletests: Compilation failure: Compilation failure:
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass2.java:[3,29]     package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestBaseClass.java:[3,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestBaseClass.java:[4,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass1.java:[3,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass3.java:[3,29] package org.junit.jupiter.api does not exist
  [ERROR] /E:/BestX/Workspace/junit5-sampletests/src/test/java/demoTest/TestDemoClass2.java:[7,10] cannot find symbol

Contents of my pom file:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>demo</groupId>
    <artifactId>junit5-sampletests</artifactId>
    <version>1.0.1</version>
    <packaging>jar</packaging>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>

                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                </dependencies>
                <configuration>

                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <additionalClasspathElements>
                        <additionalClasspathElement>src/test/java/</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <outputDirectory>${basedir}/target/site/surefire-report.html</outputDirectory>
                </configuration>

            </plugin>
        </plugins>
    </reporting>
    <repositories>
        <repository>
            <id>maven-repository</id>
            <url>file:///${project.basedir}/maven-repository</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite</artifactId>
            <scope>test</scope>
            <version>1.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-api</artifactId>
            <version>1.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>

Structure in Eclipse:

The test are very simple as of now as I am tryign to create and prorotype junit5 framwrok. One of teh test file is:

package demoTest;

import org.junit.jupiter.api.Test;

/**

@author ayesha

*/
public class TestDemoClass3 extends TestBaseClass {

@Test
public void test5() throws Exception {
    System.out.println("Test 1 from DemoClass 3 "  +Thread.currentThread().getName());
}

@Test

public void test6() throws Exception {
    System.out.println("Test 2 from DemoClass 3 " + Thread.currentThread().getName());

}

}


问:
How to install MapLibre-gl in React Native CLI
I am trying to install MapLibre-gl in react native CLI but I can't find any useful documentation or any step-by-step guide, all I found was some complex stuff that leads to many errors.

I need some explanation on how to install it since there is no npm for it.

thank you.

答:
here are a couple of resources that I found that might be useful:

How to use MapLibre GL Js in react native
https://visgl.github.io/react-map-gl/docs/get-started/get-started
https://docs.maptiler.com/maplibre-gl-js/
https://documentation.maptiler.com/hc/en-us/articles/4405444890897-How-to-display-MapLibre-GL-JS-map-using-React-JS

In case you would like to ask for further help, find me at support@maptiler.com

Jiri


问:
How to set max vale for input range slide dynamically?
I'm trying to do and input range slide with @angular-slider/ngx-slider following this examples and the official documentation and works well.

My component code is:

```<code>import { Options } from '@angular-slider/ngx-slider';

...
low_area_value: number = 1000;
high_area_value: number = 99999;
options: Options = {
  floor: 0,
  ceil: 9999
};
...
</code>```

My template code is:

```<code><ngx-slider formControlName="area" [(value)]="low_area_value" [(highValue)]="high_area_value" [options]="options"></ngx-slider>
</code>```

I would like to set ceil dynamically depende on max area value of objects and get the error.

ERROR Error: floor and ceil options must be supplied

Set ceil dynamically code:

```<code>this.plotService.getMaxArea().subscribe(result => {
  this.high_area_value = result.area;
  this.options = {
    floor: 0,
    ceil: result.area
  }
});
</code>```

Anybody could help me please ?
Thanks in a advance.

答:
I think the issue that you are getting is due to result.area not being a number.

Just for testing purposes edit it and add a random value like this

this.plotService.getMaxArea().subscribe(result => {
  const rand = Math.floor(Math.random() * (100 - 5 + 1)) + 3;
  this.high_area_value = randomNumber;
  this.options = {
    floor: 0,
    ceil: randomNumber
  }
});
```

If this works, it means the value in result.area is not a number, maybe a string? That you might have to convert to a number

Body:
I'm trying to do and input range slide with @angular-slider/ngx-slider following this examples and the official documentation and works well.

My component code is:

import { Options } from '@angular-slider/ngx-slider';

...
low_area_value: number = 1000;
high_area_value: number = 99999;
options: Options = {
  floor: 0,
  ceil: 9999
};
...

My template code is:

<ngx-slider formControlName="area" [(value)]="low_area_value" [(highValue)]="high_area_value" [options]="options"></ngx-slider>

I would like to set ceil dynamically depende on max area value of objects and get the error.

ERROR Error: floor and ceil options must be supplied

Set ceil dynamically code:

this.plotService.getMaxArea().subscribe(result => {
  this.high_area_value = result.area;
  this.options = {
    floor: 0,
    ceil: result.area
  }
});

Anybody could help me please ?
Thanks in a advance.

Body:
I think the issue that you are getting is due to result.area not being a number.

Just for testing purposes edit it and add a random value like this

this.plotService.getMaxArea().subscribe(result => {
  const rand = Math.floor(Math.random() * (100 - 5 + 1)) + 3;
  this.high_area_value = randomNumber;
  this.options = {
    floor: 0,
    ceil: randomNumber
  }
});

If this works, it means the value in result.area is not a number, maybe a string? That you might have to convert to a number


问:
How to find the workspace location in eclipse?
I had changed the workspace path in eclipse(I do not remember the same). Recently i got my laptop re-imaged and had to install the eclipse. I am not able to get back the new workspace. i searched for the folder in the laptop. i do not find the project folder in the laptop. not sure how to get back the changed workspace.</p>

答: Right click on Project > Properties > Resource > Linked Resources > Path Variables > WORKSPACE_LOC


问:
Auto-Generated AppData/Local folder being "incorrectly" created
when I run a .net exe, a corresponding folder is created is created C:\Users\UserName\AppData\Local\AppName

inside this folder, another folder is created AppName_Url_ABCXYZ

inside this folder, yet another folder is created for the assembly version of the .net exe 0.2.28.0

can anyone explain how windows decide to create the second level folder AppName_Url_ABCXYZ?

i am having an issue when i increment my assembly version and perform a single file publish and run the resulting exe, a new AppName_Url_ABCXYZ folder is created containing the new assembly version folder.

this causes issues because it breaks the functionality of  Properties.Settings.Default.Upgrade() as the settings to upgrade from are no longer in the expected directory

Good:

```<code>-AppData
 -Local
  -MyApp
   -MyApp_Url_ABCXYZ
    -0.2.13.0
    -0.2.14.0
    -0.2.15.0
</code>```

Bad:

```<code>-AppData
 -Local
  -MyApp
   -MyApp_Url_ABC1
    -0.2.13.0
   -MyApp_Url_ABC2
    -0.2.14.0
   -MyApp_Url_ABC3
    -0.2.15.0
</code>```

Update:

The information provided by @Richard Deeming indicates that the hash portion of the appdata folder is generated like so:

```<code>var uri = "file:///" + fullExePath; //or 'assemblyName.CodeBase' if vshost (you can check the 'FriendlyName')
uri = uri.ToUpperInvariant();

var ms = new MemoryStream();
var bSer = new BinaryFormatter();
bSer.Serialize(ms, uri);
ms.Position = 0;
var sha1 = new SHA1CryptoServiceProvider();
var hash = sha1.ComputeHash(ms);
var hashstring = ToBase32StringSuitableForDirName(hash);
</code>```

which makes no sense as the exe path is not changing

this issue does not occur with a brand new WPF .net 6 app and incrementing the assembly version, so its something specific to my application.

examining the resulting exe's in windows explorer does not help, they seem identical.

Update:

I have been unable to determine why this is occurring in my project. I don't even know how to debug it. I've never made any intentional changes to this behavior.

答:
If my understanding is correct, the folder in question (C:\Users\UserName\AppData\Local\AppName\AppName_Url_ABCXYZ)is used to store the user.config settings. Please check the following threads:

How to change the predefined userconfig directory of my .NET application?

Custom path of the user.config

Here is the quote from the FAQ:
https://learn.microsoft.com/en-us/archive/blogs/rprabhu/client-settings-faq

The exact path of the user.config files looks something like this:

<Profile Directory>\<Company Name>\<App Name>_<Evidence Type>_<Evidence Hash>\<Version>\user.config

where

<Profile Directory> - is either the roaming profile directory or the
local one. Settings are stored by default in the local user.config
file. To store a setting in the roaming user.config file, you need to
mark the setting with the SettingsManageabilityAttribute with
SettingsManageability set to Roaming.

<Company Name> - is typically the string specified by the
AssemblyCompanyAttribute (with the caveat that the string is escaped
and truncated as necessary, and if not specified on the assembly, we
have a fallback procedure).

<App Name> - is typically the string specified by the
AssemblyProductAttribute (same caveats as for company name).

<Evidence Type> and <Evidence Hash> - information derived from the app
domain evidence to provide proper app domain and assembly isolation.

<Version> - typically the version specified in the
AssemblyVersionAttribute. This is required to isolate different
versions of the app deployed side by side.

The file name is always simply user.config.

If you want to get to the path programmatically, you can do it using
the Configuration Management API (you need to add a reference to
System.Configuration.dll).

The path construction algorithm has to meet certain rigorous
requirements in terms of security, isolation and robustness. While we
tried to make the path as easily discoverable as possible by making
use of friendly, application supplied strings, it is not possible to
keep the path totally simple without running into issues like
collisions with other apps, spoofing etc.

The LocalFileSettingsProvider does not provide a way to change the
files in which settings are stored. Note that the provider itself
doesn't determine the config file locations in the first place - it is
the configuration system. If you need to store the settings in a
different location for some reason, the recommended way is to write
your own SettingsProvider.

It looks like Microsoft intentionally did not provide the way to configure the path to the config file to avoid collisions.
The SO threads mentioned above seem to provide some instructions on implementing the custom SettingsProvider.

In your case, the <Evidence Hash> part is different after updating the version. Here's one more thread describing the possible cause:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d87a0add-00ba-4074-8ef3-cf085e1122eb/userscope-settings-path-changed-after-upgrade?forum=netfxbcl

the Evidence Hash is changed, because this values is affected by two things, for a details, please check this link,

1.StrongName

2.URL

If neither of these is available, use the .exe path.

<Evidence Type> can be the URL, StrongName, or Path, based on the evidence available to hash. In the path in question, I can see it set to Url. As I have found in the book "Programming .NET Security", the Url evidence represents the URL from which the assembly was loaded from. If it was loaded from the disk, it would be the file:// URL. Have not checked it with the example though.

Probably, the URL change or EXE path change affected the hash value.

In addition, it's necessary to check if the assembly strong name has changed.

A strong name consists of the assembly's identity—its simple text name, version number, and culture information (if provided)—plus a public key and a digital signature. It is generated from an assembly file using the corresponding private key. (The assembly file contains the assembly manifest, which contains the names and hashes of all the files that make up the assembly.)
https://learn.microsoft.com/en-us/dotnet/standard/assembly/create-use-strong-named

Body:
when I run a .net exe, a corresponding folder is created is created C:\Users\UserName\AppData\Local\AppName

inside this folder, another folder is created AppName_Url_ABCXYZ

inside this folder, yet another folder is created for the assembly version of the .net exe 0.2.28.0

can anyone explain how windows decide to create the second level folder AppName_Url_ABCXYZ?

i am having an issue when i increment my assembly version and perform a single file publish and run the resulting exe, a new AppName_Url_ABCXYZ folder is created containing the new assembly version folder.

this causes issues because it breaks the functionality of  Properties.Settings.Default.Upgrade() as the settings to upgrade from are no longer in the expected directory

Good:

-AppData
 -Local
  -MyApp
   -MyApp_Url_ABCXYZ
    -0.2.13.0
    -0.2.14.0
    -0.2.15.0

Bad:

-AppData
 -Local
  -MyApp
   -MyApp_Url_ABC1
    -0.2.13.0
   -MyApp_Url_ABC2
    -0.2.14.0
   -MyApp_Url_ABC3
    -0.2.15.0

Update:

The information provided by @Richard Deeming indicates that the hash portion of the appdata folder is generated like so:

var uri = "file:///" + fullExePath; //or 'assemblyName.CodeBase' if vshost (you can check the 'FriendlyName')
uri = uri.ToUpperInvariant();

var ms = new MemoryStream();
var bSer = new BinaryFormatter();
bSer.Serialize(ms, uri);
ms.Position = 0;
var sha1 = new SHA1CryptoServiceProvider();
var hash = sha1.ComputeHash(ms);
var hashstring = ToBase32StringSuitableForDirName(hash);

which makes no sense as the exe path is not changing

this issue does not occur with a brand new WPF .net 6 app and incrementing the assembly version, so its something specific to my application.

examining the resulting exe's in windows explorer does not help, they seem identical.

Update:

I have been unable to determine why this is occurring in my project. I don't even know how to debug it. I've never made any intentional changes to this behavior.


问:
Available animations collection is empty, while using .loadModelAsync()
I am successfully loading USDZ file in my RealityKit scene asynchronously by using LoadModelAsync. I am using toy_biplane USDZ file provided by apple which has default animations. If I load model asynchronousely availableAnimations array is always empty!

My codes:

```<code>func loadASingleModel(name: String,
                completion: @escaping (_ model: ModelEntity?) -> Void) {

    var cancellable: AnyCancellable?
    cancellable = Entity.loadModelAsync(named: name)
        .sink(receiveCompletion: { handler in
            if case let .failure(error) = handler {
                print("Unable to load a model due to error \(error)")
            }
            cancellable?.cancel()
            completion(nil)

        }, receiveValue: { [self] (model: ModelEntity?) in
            if let model = model  {
                cancellable?.cancel()
                print("Congrats! Model is successfully loaded!")
                print(model.availableAnimations,
                      //Here availableAnimations is empty
                      "Debug: Any Animation?")
                            completion(model)
            }
        })
    }
}
</code>```

How to load USDZ file asynchronously with animations?

答:
Use ModelEntity.loadAsync. It loads full hierarchy including animation.

```<code>import RealityKit
import Combine

let anchor = AnchorEntity()
var cancellable: AnyCancellable? = nil

self.cancellable = ModelEntity.loadAsync(named: "biplane.usdz").sink(

    receiveCompletion: { completion in

        if case let .failure(error) = completion {
            print("Unable to load a model \(error)")
        }
        self.cancellable?.cancel()
    },

    receiveValue: { [self] planeModel in

        let animation = planeModel.availableAnimations[0]

        anchor.addChild(planeModel)
        anchor.position = [0, 0,-2]
        anchor.scale = [0.1, 0.1, 0.1]
        arView.scene.anchors.append(anchor)

        planeModel.playAnimation(animation.repeat(count: .max))
    }
)
</code>```

Body:
I am successfully loading USDZ file in my RealityKit scene asynchronously by using LoadModelAsync. I am using toy_biplane USDZ file provided by apple which has default animations. If I load model asynchronousely availableAnimations array is always empty!

My codes:

func loadASingleModel(name: String,
                completion: @escaping (_ model: ModelEntity?) -> Void) {

    var cancellable: AnyCancellable?
    cancellable = Entity.loadModelAsync(named: name)
        .sink(receiveCompletion: { handler in
            if case let .failure(error) = handler {
                print("Unable to load a model due to error \(error)")
            }
            cancellable?.cancel()
            completion(nil)

        }, receiveValue: { [self] (model: ModelEntity?) in
            if let model = model  {
                cancellable?.cancel()
                print("Congrats! Model is successfully loaded!")
                print(model.availableAnimations,
                      //Here availableAnimations is empty
                      "Debug: Any Animation?")
                            completion(model)
            }
        })
    }
}

How to load USDZ file asynchronously with animations?

Body:
Use ModelEntity.loadAsync. It loads full hierarchy including animation.

import RealityKit
import Combine

let anchor = AnchorEntity()
var cancellable: AnyCancellable? = nil

self.cancellable = ModelEntity.loadAsync(named: "biplane.usdz").sink(

    receiveCompletion: { completion in

        if case let .failure(error) = completion {
            print("Unable to load a model \(error)")
        }
        self.cancellable?.cancel()
    },

    receiveValue: { [self] planeModel in

        let animation = planeModel.availableAnimations[0]

        anchor.addChild(planeModel)
        anchor.position = [0, 0,-2]
        anchor.scale = [0.1, 0.1, 0.1]
        arView.scene.anchors.append(anchor)

        planeModel.playAnimation(animation.repeat(count: .max))
    }
)