问:
No implementation found for method Query#snapshots on channel plugins.flutter.io/firebase_firestore
I have problem reading data in real time with flutter and firebase.</p>
```<code>class _MovieInformationState extends State<MovieInformation> {
  final Stream<QuerySnapshot> _moviesStream = FirebaseFirestore.instance.collection("Movies").snapshots();
  @override
  Widget build(BuildContext context) {
    return StreamBuilder<QuerySnapshot>(
      stream: _moviesStream,
      builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
        if (snapshot.hasError) {
          return const Text('Something went wrong');
        }

        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Text("Loading");
        }

        return ListView(
          children: snapshot.data!.docs
              .map((DocumentSnapshot document) {
                Map<String, dynamic> data =
                    document.data()! as Map<String, dynamic>;
                return ListTile(
                  title: Text(data['name']),
                  subtitle: Text(data['poster']),
                );
              })
              .toList()
              .cast(),
        );
      },
    );
  }
}
</code>```

Body:
I have problem reading data in real time with flutter and firebase.

class _MovieInformationState extends State<MovieInformation> {
  final Stream<QuerySnapshot> _moviesStream = FirebaseFirestore.instance.collection("Movies").snapshots();
  @override
  Widget build(BuildContext context) {
    return StreamBuilder<QuerySnapshot>(
      stream: _moviesStream,
      builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
        if (snapshot.hasError) {
          return const Text('Something went wrong');
        }

        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Text("Loading");
        }

        return ListView(
          children: snapshot.data!.docs
              .map((DocumentSnapshot document) {
                Map<String, dynamic> data =
                    document.data()! as Map<String, dynamic>;
                return ListTile(
                  title: Text(data['name']),
                  subtitle: Text(data['poster']),
                );
              })
              .toList()
              .cast(),
        );
      },
    );
  }
}


来源: stackexchange

问:
How to Bypass 2FA process or take 2FA code from the user while running laravel dusk test on server?
Program Flow:
I am working on laravel dusk. I want to make automation program to download some file from the one website (Ex. www.abc.com) and that downloaded files are stored in our system (Ex. www.localsystem.com) and then uploaded to another website (Ex. www.xyz.com).

Problem:
While download the file from (Ex. www.abc.com)  this website first it's asking for logging. After logged in it's asking for 2FA code and then after i will proceed for download the files.
While running laravel dusk test in local system, I can enter 2FA code by disabled this below option in laravel dusk.
//'--disable-gpu'
//'--headless'
Then I can perform the download file operation.

But how can I enter 2FA code on server because the dusk test on server  is running on  headless ('--headless').

I want to bypass 2FA code process or other option is how can i automate 2FA code process on the server.

Note: 2FA code generate only in authenticator app. (Ex.Google Authenticator) or getting from the email.

ContentLicense: CC BY-SA 4.0


问:
Not able to do the migrate in Django, facing Attribute Error: 'str' object has no attribute '_meta'
I made a completely new project using the django-admin startproject and I also made an app using django-admin startapp and I am able to apply the initial migrations but not able to do the migrate. and I didn't add any code into the project. It's completely a new project.

```<code>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying auth.0013_user_following...Traceback (most recent call last):
  File "G:\My Drive\Django 4 by example\myshop\manage.py", line 22, in <module>
    main()
  File "G:\My Drive\Django 4 by example\myshop\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\migrate.py", line 349, in handle
    post_migrate_state = executor.migrate(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\migration.py", line 130, in apply
    operation.database_forwards(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\operations\fields.py", line 108, in database_forwards
    schema_editor.add_field(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\sqlite3\schema.py", line 383, in add_field
    if field.many_to_many and field.remote_field.through._meta.auto_created:
AttributeError: 'str' object has no attribute '_meta'

</code>```

I uninstalled all the packages which I installed for the project, uninstalled Django as well, and deleted all the migrations of all the projects but still it's not working.

Body:
I made a completely new project using the django-admin startproject and I also made an app using django-admin startapp and I am able to apply the initial migrations but not able to do the migrate. and I didn't add any code into the project. It's completely a new project.

python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying auth.0013_user_following...Traceback (most recent call last):
  File "G:\My Drive\Django 4 by example\myshop\manage.py", line 22, in <module>
    main()
  File "G:\My Drive\Django 4 by example\myshop\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\migrate.py", line 349, in handle
    post_migrate_state = executor.migrate(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\migration.py", line 130, in apply
    operation.database_forwards(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\migrations\operations\fields.py", line 108, in database_forwards
    schema_editor.add_field(
  File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\backends\sqlite3\schema.py", line 383, in add_field
    if field.many_to_many and field.remote_field.through._meta.auto_created:
AttributeError: 'str' object has no attribute '_meta'

I uninstalled all the packages which I installed for the project, uninstalled Django as well, and deleted all the migrations of all the projects but still it's not working.


问:
Initialization of DP array(whether inside or outside the function)
I was solving a problem related to DP https://leetcode.com/problems/climbing-stairs/description/.
Below is my code which is throwing TLE when i'm initialising the dp array inside the function.

```<code>class Solution {
public:

    int climbStairs(int n) {

        int dp[46];
        if(dp[n]!=0) return dp[n];
        if(n==1 ||n==2) return n;
        dp[n]=climbStairs(n-1)+climbStairs(n-2);
        return dp[n];
    }
};
</code>```

But when I intialised the dp array outside the scope of function my solution got accepted. I want to know why this is happening.
Below shown is my accepted solution:

```<code>class Solution {
public:
    int dp[46];
    int climbStairs(int n) {

        if(dp[n]!=0) return dp[n];
        if(n==1 ||n==2) return n;
        dp[n]=climbStairs(n-1)+climbStairs(n-2);
        return dp[n];
    }
};
</code>```

Body:
I was solving a problem related to DP https://leetcode.com/problems/climbing-stairs/description/.
Below is my code which is throwing TLE when i'm initialising the dp array inside the function.

class Solution {
public:

    int climbStairs(int n) {

        int dp[46];
        if(dp[n]!=0) return dp[n];
        if(n==1 ||n==2) return n;
        dp[n]=climbStairs(n-1)+climbStairs(n-2);
        return dp[n];
    }
};

But when I intialised the dp array outside the scope of function my solution got accepted. I want to know why this is happening.
Below shown is my accepted solution:

class Solution {
public:
    int dp[46];
    int climbStairs(int n) {

        if(dp[n]!=0) return dp[n];
        if(n==1 ||n==2) return n;
        dp[n]=climbStairs(n-1)+climbStairs(n-2);
        return dp[n];
    }
};


问:
qLineSeries always cover my widget, how can i deal with it?

like this, the lines alway cover my other widget. Althought I use Qt::WindowStaysOnTopHint to set other widget, it doesn't work.

how can I solve the problom?


问:
Assembly mov pointer calculation? How does it?

```<code>00007FF6FB15A7C0 | 48:8B05 594C6700           | mov rax,qword ptr ds:[7FF6FB7CF420]
</code>```

So how does computer calculate this 7FF6FB7CF420? I want to get data myself from there so I need a pointer.
Something to do with those bytes? Adding them to Exe module start currently at 0x7FF6FABF0000 doesn't wield anything sensible.

Body:
00007FF6FB15A7C0 | 48:8B05 594C6700           | mov rax,qword ptr ds:[7FF6FB7CF420]

So how does computer calculate this 7FF6FB7CF420? I want to get data myself from there so I need a pointer.
Something to do with those bytes? Adding them to Exe module start currently at 0x7FF6FABF0000 doesn't wield anything sensible.


问:
How to call 'open3d.cuda.pybind.visualization.Visualizer' in Windows10?
I have installed open3d 0.15.1 on both windows10 and ubuntu 18.04. And pytorch and cuda have been both installed. When I call the following codes:

vis = o3d.visualization.Visualizer()
...
vis.add_geometry(points)
```

I found in Ubuntu, the o3d.visualization.Visualizer() is an open3d.cuda.pybind.visualization.Visualizer, while in windows 10,  the o3d.visualization.Visualizer() is an open3d.cpu.pybind.visualization.Visualizer.
How could I use the open3d.cuda.pybind.visualization.Visualizer in windows 10?

Body:
I have installed open3d 0.15.1 on both windows10 and ubuntu 18.04. And pytorch and cuda have been both installed. When I call the following codes:

vis = o3d.visualization.Visualizer()
...
vis.add_geometry(points)

I found in Ubuntu, the o3d.visualization.Visualizer() is an open3d.cuda.pybind.visualization.Visualizer, while in windows 10,  the o3d.visualization.Visualizer() is an open3d.cpu.pybind.visualization.Visualizer.
How could I use the open3d.cuda.pybind.visualization.Visualizer in windows 10?


问:
Woocommerce product attributes to be able to use as links
We changed from Joomla to Wordpress and imported a lot of data. All the attributes have been imported correctly but I am facing the problem that some of the global attributes are YouTube or Vimeo or links to local download files.

I was wondering if there is a way to utilise the displayed value in

brochure.pdf

to convert it into a button through CSS?

I tried to use https://nicolamustone.blog/2016/03/11/make-product-attributes-linkable/

adding it to functions.php

adding as a code snippet

but both created a 500 error.


问:
Visual Studio Community 2019 and Windows Media Player control not appear
i add com component "Windows Media Player" but not appear in Toolbox the WMP Component to atach in a Windows Form. It's very strange.

Any idea?

Thanks, Oscar.


问:
How to use IMPORTXML with a colon?
I would just like to know how to use the 'importxml' function from Google Sheet if the source contains a colon.

Example of item with 'g:*'
Above is an example where I would like to get the id, title, and description values.

I've tried to use this formula:
=IMPORTXML("URLXMLFEED URL","//item/g:id")

But it came back with an error as I was hoping to have the list of id on the xml feed.

Title: How to use IMPORTXML with a colon?


问:
i am using Bootstrap 3 and wanted label text-middle respective input
I am new to bootstrap 3 with PHP, pleased suggest me for a small issue regarding label text-middle, I want label text vertical centre respective input box. here is my form code</p>
```<code>        <form method="POST" action="" name="seo-roi-form" id="seo-roi-form">
            <div class="col-sm-12">
                <div class="serp-radio-wrapper">
                    <h5><strong>SEO ROI Calculator</strong></h5>
                </div>
            </div>
            <div class="col-md-12 mt-3 ">
                <div class="row editable">
                    <div class="col-md-6 ">
                        <label class="" class="control-label align-middle" for="organic-traffic">Organic search traffic</label>
                    </div>
                    <div class="col-md-6 mt-2">
                        <input type="number" class="form-control border h-50" id="organic-traffic">
                    </div>
                </div>
            </div>
        </form>
</code>```

Body:
I am new to bootstrap 3 with PHP, pleased suggest me for a small issue regarding label text-middle, I want label text vertical centre respective input box. here is my form code

        <form method="POST" action="" name="seo-roi-form" id="seo-roi-form">

SEO ROI Calculator

                        Organic search traffic

                        <input type="number" class="form-control border h-50" id="organic-traffic">

        </form>


问:
How to get cloud based styling working in Android
I have followed the instructions here https://developers.google.com/maps/documentation/get-map-id to associate my SupportMapFragment with the cloud based styling. However, nothing happens when I run the app. It's the same default map style. What am I missing?

So, I have the SupportMapFragment set up like this:

```<code><fragment xmlns:map="http://schemas.android.com/apk/res-auto"
        class="com.google.android.gms.maps.SupportMapFragment"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        map:mapId="@string/mapId"/>
</code>```

And the map ID is in strings.xml.

Body:
I have followed the instructions here https://developers.google.com/maps/documentation/get-map-id to associate my SupportMapFragment with the cloud based styling. However, nothing happens when I run the app. It's the same default map style. What am I missing?

So, I have the SupportMapFragment set up like this:

<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
        class="com.google.android.gms.maps.SupportMapFragment"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        map:mapId="@string/mapId"/>

And the map ID is in strings.xml.


问:
How do I connect to Websockets program running on my server?
I have a Websocket program running on Ubuntu machine on Digital Ocean. The code is shortened below.

// server.ts
import ws from "ws";

const wss = new ws.Server({
  port: 3002,
});

const handler = applyWSSHandler({ wss, router: appRouter, createContext });
console.log("WebSocket Server listening on ws://localhost:3002");
...
```
<p>I host the server using <code>nodemon server.ts</code> or <code>pm2 start server.ts</code>. The program compiles and  logs that Websocket Server is listening.</p>
<p>Now, here is a minimum code for a client which just checks if Websockets is active.</p>
<pre class="lang-js prettyprint-override"><code>// client.js
const ws = new WebSocket('ws://xxx.xxx.xxx.xxx:3002'); // where xxx.xxx.xxx.xxx is the IPv4 of my Ubuntu machine

ws.onopen = function (event) {
    console.log('connected');
};
</code>```

Nothing gets logged, showing that the Websocket server isn't active.

I expect "connected" to be printed.

If I host my server locally instead of on Digital Ocean, and connect to "localhost:3002", "connected" does get printed out.

Is there something wrong with the way I am hosting the server, or am I connecting to the server wrongly?

Any help is appreciated. Thanks!

Body:
I have a Websocket program running on Ubuntu machine on Digital Ocean. The code is shortened below.

// server.ts
import ws from "ws";

const wss = new ws.Server({
  port: 3002,
});

const handler = applyWSSHandler({ wss, router: appRouter, createContext });
console.log("WebSocket Server listening on ws://localhost:3002");
...

I host the server using nodemon server.ts or pm2 start server.ts. The program compiles and  logs that Websocket Server is listening.

Now, here is a minimum code for a client which just checks if Websockets is active.

// client.js
const ws = new WebSocket('ws://xxx.xxx.xxx.xxx:3002'); // where xxx.xxx.xxx.xxx is the IPv4 of my Ubuntu machine

ws.onopen = function (event) {
    console.log('connected');
};

Nothing gets logged, showing that the Websocket server isn't active.

I expect "connected" to be printed.

If I host my server locally instead of on Digital Ocean, and connect to "localhost:3002", "connected" does get printed out.

Is there something wrong with the way I am hosting the server, or am I connecting to the server wrongly?

Any help is appreciated. Thanks!


问:
How can we reusable a Function With Different ViewController?
```<code>
    @objc func contextDidSave(_ notification: Notification) {
        DispatchQueue.main.async { [weak self] in
            guard let me = self else { return }

            let fileCount = CoreDataService.instance.getUploadedFilesCount(jobId: nil)
            if me.totalFiles == 0 || (fileCount > me.totalFiles) {
                me.totalFiles = fileCount
            }
            // For increase the progress lebel we need the range between 0.1(min) to 1.0(max)
            // So converting all values to float so that we can get decimal value within the range
            let progress = (Float(me.totalFiles) - Float(fileCount)) / Float(me.totalFiles)
            me.progressBarView.setProgress(progress, animated: true)

            if fileCount == 0 {
                me.progressView.isHidden = true
            } else {
                me.uploadFiles.text = "\("Uploading: ".localized() + (fileCount.description) + " Files left".localized())"
                me.progressView.isHidden = false
            }
        }
    }
</code>```

ProgressView is UIView
UploadFile is UILabel
This function is reusable in Two Different ViewController

Body:
    @objc func contextDidSave(_ notification: Notification) {
        DispatchQueue.main.async { [weak self] in
            guard let me = self else { return }

            let fileCount = CoreDataService.instance.getUploadedFilesCount(jobId: nil)
            if me.totalFiles == 0 || (fileCount > me.totalFiles) {
                me.totalFiles = fileCount
            }
            // For increase the progress lebel we need the range between 0.1(min) to 1.0(max)
            // So converting all values to float so that we can get decimal value within the range
            let progress = (Float(me.totalFiles) - Float(fileCount)) / Float(me.totalFiles)
            me.progressBarView.setProgress(progress, animated: true)

            if fileCount == 0 {
                me.progressView.isHidden = true
            } else {
                me.uploadFiles.text = "\("Uploading: ".localized() + (fileCount.description) + " Files left".localized())"
                me.progressView.isHidden = false
            }
        }
    }

ProgressView is UIView
UploadFile is UILabel
This function is reusable in Two Different ViewController


问:
How can I detect if two functions are the same (in a deep-equal sense)

What I need to do

I need to detect whether two objects are the same. By same I mean deep-equal: different objects that look and behave the same are the same to me. For instance {} is the same as {}, even though {} != {}.

I need to do this on Node.js.

Problem

This has been easy with most types I handle (undefined, null, numbers, NaN, strings, objects, arrays), but it's proving really hard with functions.

For function I would consider two functions to be the same if their name and code is identical. In case the functions are closures, then the variables they capture need to be the same instance.

I don't know how to implement that.

Attempted solutions

These are all the approaches I could think of to compare functions, but they all have issues:

Comparing the function with == or === doesn't work, of course. Example ()=>0 != ()=>0, but they should be the same.

Comparing the function name doesn't work, of course. Example: ()=>0 === ()=>1 when they shouldn't be the same.

Comparing the function's code (as reported by Function.prototype.toString) doesn't work:

```<code>const fnFactory=(n)=>{ return ()=>n; };
const fn1=fnFactory(0);
const fn2=fnFactory(1);
fn1.toString() === fn2.toString()
</code>```

But they shouldn't be the same.

Compare the functions' code. If it's the same, parse it and detect whether the function has any captured variables, if it doesn't, the functions are the same.

This solution however would be unbearably slow. Besides it still doesn't work for different functions that capture the same instances of variables.

What I need this for (example)

I need this in order to implement a factory function like this (this is just a minimal example, of course):

```<code>// Precondition:
// "factoryFn" is called only once for every value of "fn"
// the result is then reused for every future invocation.
const storage=new MagicStorage();
function createOrReuse(fn, ...opts)
{
  if(storage.has(fn, ...opts)){
    return storage.get(fn, ...opts);
  }
  else{
    const data=factoryFn(...opts);
    storage.set(data, fn, ...opts);
    return data;
  }
}
</code>```

Then I want to use it in several places around my code. For instance:

```<code>function f1(n) {
  // ...
  const buffer=createOrReuse((n)=>new Buffer.alloc(n*1024*1024), n);
  //...
}
function f2(){
  //...
  emitter.on('ev', async()=>{
    const buffer=await createOrReuse(()=>fs.readFile('file.txt'));
    // ...
  });
  //...
}
</code>```

Of course there are other ways to achieve the same result: For instance I could store the allocated values in variables with a lifetime long enough.

However similar solutions are much less ergonomic. I wish to have that small createOrReuse function. In other languages (like C++) such a createOrReuse could be implemented. Can I not implement it in Javascript?

Question

Is it possible to implement the function-comparison logic I need in pure JavaScript? I can use any ES version.

Otherwise is it possible to implement it as a native module for Node.js?

If yes, Is there any Node.js native module that can be used to achieve what I need?

Otherwise, where can I start to develop one?

Body:
What I need to do

I need to detect whether two objects are the same. By same I mean deep-equal: different objects that look and behave the same are the same to me. For instance {} is the same as {}, even though {} != {}.

I need to do this on Node.js.

Problem

This has been easy with most types I handle (undefined, null, numbers, NaN, strings, objects, arrays), but it's proving really hard with functions.

For function I would consider two functions to be the same if their name and code is identical. In case the functions are closures, then the variables they capture need to be the same instance.

I don't know how to implement that.

Attempted solutions

These are all the approaches I could think of to compare functions, but they all have issues:

Comparing the function with == or === doesn't work, of course. Example ()=>0 != ()=>0, but they should be the same.

Comparing the function name doesn't work, of course. Example: ()=>0 === ()=>1 when they shouldn't be the same.

Comparing the function's code (as reported by Function.prototype.toString) doesn't work:

const fnFactory=(n)=>{ return ()=>n; };
const fn1=fnFactory(0);
const fn2=fnFactory(1);
fn1.toString() === fn2.toString()

But they shouldn't be the same.

Compare the functions' code. If it's the same, parse it and detect whether the function has any captured variables, if it doesn't, the functions are the same.

This solution however would be unbearably slow. Besides it still doesn't work for different functions that capture the same instances of variables.

What I need this for (example)

I need this in order to implement a factory function like this (this is just a minimal example, of course):

// Precondition:
// "factoryFn" is called only once for every value of "fn"
// the result is then reused for every future invocation.
const storage=new MagicStorage();
function createOrReuse(fn, ...opts)
{
  if(storage.has(fn, ...opts)){
    return storage.get(fn, ...opts);
  }
  else{
    const data=factoryFn(...opts);
    storage.set(data, fn, ...opts);
    return data;
  }
}

Then I want to use it in several places around my code. For instance:

function f1(n) {
  // ...
  const buffer=createOrReuse((n)=>new Buffer.alloc(n*1024*1024), n);
  //...
}
function f2(){
  //...
  emitter.on('ev', async()=>{
    const buffer=await createOrReuse(()=>fs.readFile('file.txt'));
    // ...
  });
  //...
}

Of course there are other ways to achieve the same result: For instance I could store the allocated values in variables with a lifetime long enough.

However similar solutions are much less ergonomic. I wish to have that small createOrReuse function. In other languages (like C++) such a createOrReuse could be implemented. Can I not implement it in Javascript?

Question

Is it possible to implement the function-comparison logic I need in pure JavaScript? I can use any ES version.

Otherwise is it possible to implement it as a native module for Node.js?

If yes, Is there any Node.js native module that can be used to achieve what I need?

Otherwise, where can I start to develop one?


问:
How to overcome the error failed: missing) after argument list
it shows like thisUsing selenium IDE as source
For login questions authentication i used if else condition. Getting error failed missing) after argument list
Thanks</p>


问:
Why dataframe is not displayed in console using pyspark?
This is the session object I have created for dataframe

```<code>from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()
</code>```

This is the code for Dataframe creation

```<code>data = [("James","","Smith",30,"M",60000),
        ("Michael","Rose","",50,"M",70000),
        ("Robert","","Williams",42,"",400000),
        ("Maria","Anne","Jones",38,"F",500000),
        ("Jen","Mary","Brown",45,"F",0)]

columns = ["first_name","middle_name","last_name","Age","gender","salary"]
pysparkDF = spark.createDataFrame(data = data, schema = columns)
pysparkDF.printSchema()
pysparkDF.show(truncate=False)
</code>```

I want dataframe should be displayed in console of six columns but it is showing me the erro of Py4jjjavaerror exceeds size limit

```<code>    Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
Py4JJavaError                             Traceback (most recent call last)
Cell In[28], line 10
      8 pysparkDF = spark.createDataFrame(data = data, schema = columns)
      9 pysparkDF.printSchema()
---> 10 pysparkDF.show(truncate=False)

File c:\Users\baps\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyspark\sql\dataframe.py:615, in DataFrame.show(self, n, truncate, vertical)
    610 except ValueError:
    611     raise TypeError(
    612         "Parameter 'truncate={}' should be either bool or int.".format(truncate)
    613     )
--> 615 print(self._jdf.showString(n, int_truncate, vertical))

File c:\Users\baps\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py4j\java_gateway.py:1321, in JavaMember.__call__(self, *args)
   1315 command = proto.CALL_COMMAND_NAME +\
   1316     self.command_header +\
   1317     args_command +\
   1318     proto.END_COMMAND_PART
   1320 answer = self.gateway_client.send_command(command)
-> 1321 return_value = get_return_value(
   1322     answer, self.gateway_client, self.target_id, self.name)
   1324 for temp_arg in temp_args:
   1325     temp_arg._detach()
...
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:453)
    at java.lang.ProcessImpl.start(ProcessImpl.java:140)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 30 more
</code>```

Body:
This is the session object I have created for dataframe

from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()

This is the code for Dataframe creation

data = [("James","","Smith",30,"M",60000),
        ("Michael","Rose","",50,"M",70000),
        ("Robert","","Williams",42,"",400000),
        ("Maria","Anne","Jones",38,"F",500000),
        ("Jen","Mary","Brown",45,"F",0)]

columns = ["first_name","middle_name","last_name","Age","gender","salary"]
pysparkDF = spark.createDataFrame(data = data, schema = columns)
pysparkDF.printSchema()
pysparkDF.show(truncate=False)

I want dataframe should be displayed in console of six columns but it is showing me the erro of Py4jjjavaerror exceeds size limit

    Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
Py4JJavaError                             Traceback (most recent call last)
Cell In[28], line 10
      8 pysparkDF = spark.createDataFrame(data = data, schema = columns)
      9 pysparkDF.printSchema()
---> 10 pysparkDF.show(truncate=False)

File c:\Users\baps\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyspark\sql\dataframe.py:615, in DataFrame.show(self, n, truncate, vertical)
    610 except ValueError:
    611     raise TypeError(
    612         "Parameter 'truncate={}' should be either bool or int.".format(truncate)
    613     )
--> 615 print(self._jdf.showString(n, int_truncate, vertical))

File c:\Users\baps\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py4j\java_gateway.py:1321, in JavaMember.__call__(self, *args)
   1315 command = proto.CALL_COMMAND_NAME +\
   1316     self.command_header +\
   1317     args_command +\
   1318     proto.END_COMMAND_PART
   1320 answer = self.gateway_client.send_command(command)
-> 1321 return_value = get_return_value(
   1322     answer, self.gateway_client, self.target_id, self.name)
   1324 for temp_arg in temp_args:
   1325     temp_arg._detach()
...
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:453)
    at java.lang.ProcessImpl.start(ProcessImpl.java:140)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 30 more


问:
Linking html frontend and python backend integration
I wanted to integrate my frontend code with my python backend functionality

This is my frontend code with html.

```<code><!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Subtitle AI</title>
    ...
</head>

<body>

    <div class="upload">
        <h3>Step 1: upload a .wav file</h3>
        <input id="wavFile" type="file" name="myFile" accept=".wav" />
        <button id="submit-button">Submit</button>
    </div>

    <h3>Step 2: Wait for model to generate closed captioning</h3>
    <p id="result"></p>

    <script>
        $("#submit-button").click(function(event) {
            let parameter1 = {
                return1: $("#wavFile").val(),
            };
            $.post(
                "http://127.0.0.1:5000/predict",
                JSON.stringify(parameter1),
                function(transcription) {
                    $("#result").text(transcription.result);
                    console.log(transcription);
                }
            );
        });
    </script>
</body>

</html>
</code>```

And this is my pytohn backend code functionality + attempted integration. I tried to integrate it with Flask, not sure what went wrong, but when I clicked the button, the return value from my python backend function is not displaying.

```<code>...
from flask import Flask
from flask import jsonify

app = Flask(__name__)

@app.route('/predict', methods=['POST'])

...

# define the prediction function which takes in the file path to a wav file and outputs the predicted words

def predict (model, device, path):

    ...

    # decode the IDs to text
    transcription = processor.decode(predicted_ids[0])
    return jsonify(transcription)
</code>```

Body:
I wanted to integrate my frontend code with my python backend functionality

This is my frontend code with html.

<!DOCTYPE html>

    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Subtitle AI</title>
    ...

Step 1: upload a .wav file

        <input id="wavFile" type="file" name="myFile" accept=".wav" />
        <button id="submit-button">Submit</button>

Step 2: Wait for model to generate closed captioning

And this is my pytohn backend code functionality + attempted integration. I tried to integrate it with Flask, not sure what went wrong, but when I clicked the button, the return value from my python backend function is not displaying.

...
from flask import Flask
from flask import jsonify

app = Flask(__name__)

@app.route('/predict', methods=['POST'])

...

# define the prediction function which takes in the file path to a wav file and outputs the predicted words

def predict (model, device, path):

    ...

    # decode the IDs to text
    transcription = processor.decode(predicted_ids[0])
    return jsonify(transcription)


问:
Best practice for centralised management of Visual Studio Code extensions
We're trying to maintain a single set of Visual Studio Code extensions within our organisation, managed centrally. In our ideal scenario all end users have the same extensions installed, those extensions are updated on their behalf, and they are not able to install additional extensions.

We had achieved this to date by:

Installing extensions to a directory under C:\Program Files and setting the (undocumented) VSCODE_EXTENSIONS environment variable to point to that location.

Configuring a scheduled task (run as SYSTEM) that executes a powershell script with a list of extension_ids that calls code install-extension <extension_id> on each.

This solution worked until a breaking change in v1.74 expected to be able to write a new extensions.json file to the extensions directory.

Whilst we can get around this by creating a extensions.json file in that directory, I don't want to go too far down the wrong path. Is there a preferred method for centrally managing extensions for Visual Studio Code?


问:
How new version of data is read from Hfile or Memstore rather than old version of value from block cache in Hbase?
Let's say I have a key 100 with its value in HFile. During the read the key and its value is pulled from HBase and set in BlockCache and send to the client. Next when the value for key 100 is read it will be served from BlockCache.

Now I have updated the value of key 100 with a new value and the value is present in MemStore. But when a read is done for key 100 it will bring the latest version of updated value even if version is not specified. But the check happens in BlockCache initally and a value is found in BlockCache.

Why is the old value not pulled from BlockCache from Client. How is the new value pulled from MemStore or HFile during read even if a value for key is present in BlockCache and no specific version is specified? How does Hbase figures out there is an update for the value present in BlockCache is in MemStore or HFile?


问:
Winform designer resets Label size and position properties
I'm currently working on a project and I need a GUI for it, as I'm making the GUI I add a text/label to my form and when I tried to change the size of it, visual-studio/winform instantly resets it back to its original size, is this a bug?

( this isn't only for size, it also happens to position )


问:
how to perform listing item in react from user input in react in this form eg: {user1:[name,name2],user2:[name3,name4]} using input field
not able to list nested items how can I pass the key value from the map method to add the item to that particular key value and how to map that value in nested form

I want to get the key value of the 'li' inside the submit handler ... like onclick of the trigger popup I want to get that particular value on which the popup is triggered through which I can add the value of the array to that particular key

```<code>    const addPackage=(e)=>{
        let A2 =e.target.value
        setItem(A2)
    }

    const submitPackage=()=>{
        console.log(Object.keys(folder))
       // over here I have to pass the value that on the popup triggers inside the map method
       folder[val].push(item)
      console.log(folder)
    }

    return(
        <div>
            <h2 className='header'>drag and drop list</h2>
            <div className="compA">
            <strong>compA</strong><br/>
            <Popup trigger={<touchable>file</touchable>} position="right top">
         <>
             <table bgcolor='white'>
             <tbody>
             <tr><td><strong>create package:</strong></td></tr>
             <tr><td><input type='text' onChange={addItem}/></td></tr>
             <tr><td> <button onClick={submitValue}>create</button></td></tr>
             </tbody>
             </table>
         </>
         </Popup>
         <hr/>
           {Object.entries(folder).map((li)=>{return(
           <div align='left'  key={li}>
                    <Popup trigger={<touchable ><FaFolder/>{li[0]}</touchable>} //the li[0] value should assign ass the val over the submit handler
                        position="right top">
                            <>
                            <table  bgcolor='white'>
                            <tbody>
                            <tr><td><strong>package:</strong></td>
                            <td><input type='text' defaultValue={li[0]}/></td></tr>

                            <tr><td><strong>create class:</strong></td>
                            <td><input type='text' onChange={addPackage}/></td></tr>

                            <tr><td><button onClick={submitPackage}>create</button></td></tr>
                            </tbody>
                            </table>
                            </>

                    </Popup><br/>

            </div>)
        })}
            </div>
            <div className="compB">

            </div>

        </div>
    )

}
export default Input
</code>```

Body:
not able to list nested items how can I pass the key value from the map method to add the item to that particular key value and how to map that value in nested form

I want to get the key value of the 'li' inside the submit handler ... like onclick of the trigger popup I want to get that particular value on which the popup is triggered through which I can add the value of the array to that particular key

    const addPackage=(e)=>{
        let A2 =e.target.value
        setItem(A2)
    }

    const submitPackage=()=>{
        console.log(Object.keys(folder))
       // over here I have to pass the value that on the popup triggers inside the map method
       folder[val].push(item)
      console.log(folder)
    }

    return(

drag and drop list

            compA

            <Popup trigger={<touchable>file</touchable>} position="right top">
         <>

create package:

<input type='text' onChange={addItem}/>

 <button onClick={submitValue}>create</button>

         </>
         </Popup>

           {Object.entries(folder).map((li)=>{return(

                    <Popup trigger={<touchable ><FaFolder/>{li[0]}</touchable>} //the li[0] value should assign ass the val over the submit handler
                        position="right top">
                            <>

package:
                            <input type='text' defaultValue={li[0]}/>

create class:
                            <input type='text' onChange={addPackage}/>

<button onClick={submitPackage}>create</button>

                            </>

                    </Popup>

)
        })}

    )

}
export default Input


问:
D3 BSP v6.0.0 support with jetpack 5.0.2
I recently upgraded my hardware from D3 SerDes card to "DESIGNCORE® NVIDIA® JETSON AGX XAVIER FPD-LINK™ III INTERFACE CARD".

Hardware I have now:
1> Jetson Xavier AGX installed with jetpack v5.0.2
2> DESIGNCORE® NVIDIA® JETSON AGX XAVIER FPD-LINK™ III INTERFACE CARD

Question: Does D3 BSP v6.0.0 support above specified hardware with jetpack 5.0.2?

I am trying to install D3 BSP v6.0.0. but after installing it I verified using uname -a.
It did not give me desired response and still showing nvidia hardware rather than showing D3, as specified D3 BSP v6.0.0 release note.pdf.


问:
Disabling the taskbar thumbnail preview functionality for a C# application
Windows has a functionality of thumbnail preview, allowing the user to see a preview screenshot of the application when hovered over on the taskbar.

Is there any way to disable the thumbnail preview that pops up completely? I want there to have no popup/preview at all.

I've tried overriding the thumbnail through DwmSetIconicThumbnail, filling the HBITMAP with a zeroed IntPtr. However that just creates a infinite loading thumbnail.

```<code>DwmSetIconicThumbnail(this.Handle, IntPtr.Zero, 0);
</code>```

Body:
Windows has a functionality of thumbnail preview, allowing the user to see a preview screenshot of the application when hovered over on the taskbar.

Is there any way to disable the thumbnail preview that pops up completely? I want there to have no popup/preview at all.

I've tried overriding the thumbnail through DwmSetIconicThumbnail, filling the HBITMAP with a zeroed IntPtr. However that just creates a infinite loading thumbnail.

DwmSetIconicThumbnail(this.Handle, IntPtr.Zero, 0);


问:
How to proxy multipart file in fastify 2.15
I have implemented a gateway proxy server for backend server which actually serve all requests using axios .

In case on multipart request it fails and nothing reaches backend server.

proxy server:

using fastify multipart plugin in gateway.

```<code>app.register(require("fastify-multipart"), { addToBody: true });
</code>```

handelling request:

```<code>handle : async (request) => {

 const formData = new FormData();
    const keys = Object.keys(JSON.parse(request.body))
    const buffer = JSON.parse(request.body)[keys[0]][0]
    formData.append('my_field', keys[0]);
    formData.append('my_buffer', buffer.data.data[0]);

config = {
      qs : queryStringParameters,
      method : 'POST',
      headers : {
        "Content-Type" : headersNormalized['content-type'],
        "User-Agent" : headersNormalized['user-agent'],
        "client-version": headersNormalized['androidversionname'],
        "Content-Length": headersNormalized['content-length'],
      },
      body: formData,
      raw : true
    }

    const { status, data } = await http(request).LB("/downstream/upload", config)
}
</code>```

sending .png(which is recieved in body in gateway and then I am sending it in form/multipart data).

in downstream server, it is expecting data in form :

```<code>app.register(require("fastify-multipart"));
</code>```

I am trying above code but it's giving 500 every-time.

Please give some direction of how to proceed on implementing "multipart file upload proxy gateway" using fastify and nodejs.

Body:
I have implemented a gateway proxy server for backend server which actually serve all requests using axios .

In case on multipart request it fails and nothing reaches backend server.

proxy server:

using fastify multipart plugin in gateway.

app.register(require("fastify-multipart"), { addToBody: true });

handelling request:

handle : async (request) => {

 const formData = new FormData();
    const keys = Object.keys(JSON.parse(request.body))
    const buffer = JSON.parse(request.body)[keys[0]][0]
    formData.append('my_field', keys[0]);
    formData.append('my_buffer', buffer.data.data[0]);

config = {
      qs : queryStringParameters,
      method : 'POST',
      headers : {
        "Content-Type" : headersNormalized['content-type'],
        "User-Agent" : headersNormalized['user-agent'],
        "client-version": headersNormalized['androidversionname'],
        "Content-Length": headersNormalized['content-length'],
      },
      body: formData,
      raw : true
    }

    const { status, data } = await http(request).LB("/downstream/upload", config)
}

sending .png(which is recieved in body in gateway and then I am sending it in form/multipart data).

in downstream server, it is expecting data in form :

app.register(require("fastify-multipart"));

I am trying above code but it's giving 500 every-time.

Please give some direction of how to proceed on implementing "multipart file upload proxy gateway" using fastify and nodejs.


问:
Microphone permission is not working in webview_flutter android
I have attached a web link which required a microphone permission to work properly. In web it asks permission for microphone, but in my flutter android app it does not work properly even i gave the the microphone permission to the app.

package using for webview :

```<code>webview_flutter: ^3.0.4
</code>```

package using for permission handling:

```<code>permission_handler: ^10.2.0
</code>```

AndroidManifest.xml file

```<code><manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.xxx_app">
   <application
        android:label="xxx"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:showWhenLocked="true"
            android:turnScreenOn="true"

            >
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- pusher local notification -->
            <meta-data
                android:name="com.google.firebase.messaging.default_notification_channel_id"
                android:value="krack_app_notification"
            />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <!-- pusher local notification -->
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
          <intent-filter>
              <action android:name="android.intent.action.BOOT_COMPLETED"/>
              <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
              <action android:name="android.intent.action.QUICKBOOT_POWERON" />
              <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
          </intent-filter>
        </receiver>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <service
            android:name="com.dexterous.flutterlocalnotifications.ForegroundService"
            android:exported="false"
            android:stopWithTask="false"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
    <uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <!--  -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.AUDIO_CAPTURE" />

    <uses-permission android:name="android.permission.CAMERA" />
</manifest>

</code>```

Let me know any other details are required to get the microphone permission for my the webview in flutter.

Body:
I have attached a web link which required a microphone permission to work properly. In web it asks permission for microphone, but in my flutter android app it does not work properly even i gave the the microphone permission to the app.

package using for webview :

webview_flutter: ^3.0.4

package using for permission handling:

permission_handler: ^10.2.0

AndroidManifest.xml file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.xxx_app">
   <application
        android:label="xxx"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:showWhenLocked="true"
            android:turnScreenOn="true"

            >

            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />

            <meta-data
                android:name="com.google.firebase.messaging.default_notification_channel_id"
                android:value="krack_app_notification"
            />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
          <intent-filter>
              <action android:name="android.intent.action.BOOT_COMPLETED"/>
              <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
              <action android:name="android.intent.action.QUICKBOOT_POWERON" />
              <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
          </intent-filter>
        </receiver>

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <service
            android:name="com.dexterous.flutterlocalnotifications.ForegroundService"
            android:exported="false"
            android:stopWithTask="false"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
    <uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.AUDIO_CAPTURE" />

    <uses-permission android:name="android.permission.CAMERA" />
</manifest>

Let me know any other details are required to get the microphone permission for my the webview in flutter.


问:
Can I make this get and setvalues from many cell script faster or make it better?
I have many values in many cell that have to set it to another sheet.This script use around 10 sec to setvalues.Can I make it faster or make it better?
I have other function that similar to this run at the same time too. So it make process slower than 10 sec to be around 30 sec. Can I use .map and hoe to do it?</p>
```<code>const wsformPO = SpreadsheetApp.getActive().getSheetByName("formPO");
const doc_Type_V = wsformPO.getRange("H22").getDisplayValue();
const wsPOV = SpreadsheetApp.openById("SheetID1").getSheetByName("data_pov");
const wsPON = SpreadsheetApp.openById("SheetID1").getSheetByName("data_pon");

const item1_Data_1_V = [[wsformPO.getRange("H23").getDisplayValue(),
                       wsformPO.getRange("H24").getDisplayValue(),
                       wsformPO.getRange("C27:E27").getDisplayValue(),
                       wsformPO.getRange("C28").getDisplayValue(),
                       "1",
                       wsformPO.getRange("C33:D33").getDisplayValue(),
                       wsformPO.getRange("F33").getDisplayValue(),
                       "USE"]]

const po_data_1_V = [[wsformPO.getRange("C29").getDisplayValue(),
                      wsformPO.getRange("H27").getDisplayValue(),
                      wsformPO.getRange("H28").getDisplayValue(),
                      wsformPO.getRange("J27").getDisplayValue(),
                      wsformPO.getRange("J28").getDisplayValue()]]

const item1_Data_2_V = [[wsformPO.getRange("H33").getDisplayValue(),
                        wsformPO.getRange("I33").getDisplayValue(),
                        wsformPO.getRange("J33").getDisplayValue()]]

const po_data_2_V = [[wsformPO.getRange("J69").getDisplayValue(),
                      wsformPO.getRange("J70").getDisplayValue(),
                      wsformPO.getRange("J71").getDisplayValue(),
                      wsformPO.getRange("J73").getDisplayValue(),
                      wsformPO.getRange("J74").getDisplayValue(),
                      wsformPO.getRange("J75").getDisplayValue(),
                      wsformPO.getRange("J76").getDisplayValue(),
                      wsformPO.getRange("J77").getDisplayValue()]]

const item2_Data_1_V = [[wsformPO.getRange("H23").getDisplayValue(),
                       wsformPO.getRange("H24").getDisplayValue(),
                       wsformPO.getRange("C27:E27").getDisplayValue(),
                       wsformPO.getRange("C28").getDisplayValue(),
                       "2",
                       wsformPO.getRange("C45:D45").getDisplayValue(),
                       wsformPO.getRange("F45").getDisplayValue(),
                       "USE"]]

const item2_Data_2_V = [[wsformPO.getRange("H45").getDisplayValue(),
                        wsformPO.getRange("I45").getDisplayValue(),
                        wsformPO.getRange("J45").getDisplayValue()]]

const item3_Data_1_V = [[wsformPO.getRange("H23").getDisplayValue(),
                       wsformPO.getRange("H24").getDisplayValue(),
                       wsformPO.getRange("C27:E27").getDisplayValue(),
                       wsformPO.getRange("C28").getDisplayValue(),
                       "3",
                       wsformPO.getRange("C57:D57").getDisplayValue(),
                       wsformPO.getRange("F57").getDisplayValue(),
                       "USE"]]

const item3_Data_2_V = [[wsformPO.getRange("H57").getDisplayValue(),
                        wsformPO.getRange("I57").getDisplayValue(),
                        wsformPO.getRange("J57").getDisplayValue()]]

function savetoPOVN(){

  if(doc_Type_V === "V"){

  wsPOV.getRange(wsPOV.getLastRow()+1,2,1,8).setValues(item1_Data_1_V);
  wsPOV.getRange(wsPOV.getLastRow(),11,1,5).setValues(po_data_1_V);
  wsPOV.getRange(wsPOV.getLastRow(),17,1,3).setValues(item1_Data_2_V);
  wsPOV.getRange(wsPOV.getLastRow(),20,1,8).setValues(po_data_2_V);
  wsPOV.getRange(wsPOV.getLastRow(),60,1,4).setValues(note_V);

    if(item2_amount_V != ""){
      wsPOV.getRange(wsPOV.getLastRow()+1,2,1,8).setValues(item2_Data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),17,1,3).setValues(item2_Data_2_V);}

    if(item3_amount_V != ""){
      wsPOV.getRange(wsPOV.getLastRow()+1,2,1,8).setValues(item3_Data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),17,1,3).setValues(item3_Data_2_V);

  }
  var range = wsPOV.getRange(6,2,wsPOV.getLastRow()-1,63);
  range.sort({column: 2, ascending: true});}

  if(doc_Type_V === "N"){

  wsPON.getRange(wsPON.getLastRow()+1,2,1,8).setValues(item1_Data_1_V);
  wsPON.getRange(wsPON.getLastRow(),11,1,5).setValues(po_data_1_V);
  wsPON.getRange(wsPON.getLastRow(),17,1,3).setValues(item1_Data_2_V);
  wsPON.getRange(wsPON.getLastRow(),20,1,8).setValues(po_data_2_V);
  wsPON.getRange(wsPON.getLastRow(),60,1,4).setValues(note_V);

    if(item2_amount_V != ""){
      wsPON.getRange(wsPON.getLastRow()+1,2,1,8).setValues(item2_Data_1_V);
      wsPON.getRange(wsPON.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPON.getRange(wsPON.getLastRow(),17,1,3).setValues(item2_Data_2_V);}

    if(item3_amount_V != ""){
      wsPON.getRange(wsPON.getLastRow()+1,2,1,8).setValues(item3_Data_1_V);
      wsPON.getRange(wsPON.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPON.getRange(wsPON.getLastRow(),17,1,3).setValues(item3_Data_2_V);
      }
    var range = wsPON.getRange(6,2,wsPON.getLastRow()-1,63);
     range.sort({column: 2, ascending: true})
}};

</code>```

Body:
I have many values in many cell that have to set it to another sheet.This script use around 10 sec to setvalues.Can I make it faster or make it better?
I have other function that similar to this run at the same time too. So it make process slower than 10 sec to be around 30 sec. Can I use .map and hoe to do it?

const wsformPO = SpreadsheetApp.getActive().getSheetByName("formPO");
const doc_Type_V = wsformPO.getRange("H22").getDisplayValue();
const wsPOV = SpreadsheetApp.openById("SheetID1").getSheetByName("data_pov");
const wsPON = SpreadsheetApp.openById("SheetID1").getSheetByName("data_pon");

const item1_Data_1_V = [[wsformPO.getRange("H23").getDisplayValue(),
                       wsformPO.getRange("H24").getDisplayValue(),
                       wsformPO.getRange("C27:E27").getDisplayValue(),
                       wsformPO.getRange("C28").getDisplayValue(),
                       "1",
                       wsformPO.getRange("C33:D33").getDisplayValue(),
                       wsformPO.getRange("F33").getDisplayValue(),
                       "USE"]]

const po_data_1_V = [[wsformPO.getRange("C29").getDisplayValue(),
                      wsformPO.getRange("H27").getDisplayValue(),
                      wsformPO.getRange("H28").getDisplayValue(),
                      wsformPO.getRange("J27").getDisplayValue(),
                      wsformPO.getRange("J28").getDisplayValue()]]

const item1_Data_2_V = [[wsformPO.getRange("H33").getDisplayValue(),
                        wsformPO.getRange("I33").getDisplayValue(),
                        wsformPO.getRange("J33").getDisplayValue()]]

const po_data_2_V = [[wsformPO.getRange("J69").getDisplayValue(),
                      wsformPO.getRange("J70").getDisplayValue(),
                      wsformPO.getRange("J71").getDisplayValue(),
                      wsformPO.getRange("J73").getDisplayValue(),
                      wsformPO.getRange("J74").getDisplayValue(),
                      wsformPO.getRange("J75").getDisplayValue(),
                      wsformPO.getRange("J76").getDisplayValue(),
                      wsformPO.getRange("J77").getDisplayValue()]]

const item2_Data_1_V = [[wsformPO.getRange("H23").getDisplayValue(),
                       wsformPO.getRange("H24").getDisplayValue(),
                       wsformPO.getRange("C27:E27").getDisplayValue(),
                       wsformPO.getRange("C28").getDisplayValue(),
                       "2",
                       wsformPO.getRange("C45:D45").getDisplayValue(),
                       wsformPO.getRange("F45").getDisplayValue(),
                       "USE"]]

const item2_Data_2_V = [[wsformPO.getRange("H45").getDisplayValue(),
                        wsformPO.getRange("I45").getDisplayValue(),
                        wsformPO.getRange("J45").getDisplayValue()]]

const item3_Data_1_V = [[wsformPO.getRange("H23").getDisplayValue(),
                       wsformPO.getRange("H24").getDisplayValue(),
                       wsformPO.getRange("C27:E27").getDisplayValue(),
                       wsformPO.getRange("C28").getDisplayValue(),
                       "3",
                       wsformPO.getRange("C57:D57").getDisplayValue(),
                       wsformPO.getRange("F57").getDisplayValue(),
                       "USE"]]

const item3_Data_2_V = [[wsformPO.getRange("H57").getDisplayValue(),
                        wsformPO.getRange("I57").getDisplayValue(),
                        wsformPO.getRange("J57").getDisplayValue()]]

function savetoPOVN(){

  if(doc_Type_V === "V"){

  wsPOV.getRange(wsPOV.getLastRow()+1,2,1,8).setValues(item1_Data_1_V);
  wsPOV.getRange(wsPOV.getLastRow(),11,1,5).setValues(po_data_1_V);
  wsPOV.getRange(wsPOV.getLastRow(),17,1,3).setValues(item1_Data_2_V);
  wsPOV.getRange(wsPOV.getLastRow(),20,1,8).setValues(po_data_2_V);
  wsPOV.getRange(wsPOV.getLastRow(),60,1,4).setValues(note_V);

    if(item2_amount_V != ""){
      wsPOV.getRange(wsPOV.getLastRow()+1,2,1,8).setValues(item2_Data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),17,1,3).setValues(item2_Data_2_V);}

    if(item3_amount_V != ""){
      wsPOV.getRange(wsPOV.getLastRow()+1,2,1,8).setValues(item3_Data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPOV.getRange(wsPOV.getLastRow(),17,1,3).setValues(item3_Data_2_V);

  }
  var range = wsPOV.getRange(6,2,wsPOV.getLastRow()-1,63);
  range.sort({column: 2, ascending: true});}

  if(doc_Type_V === "N"){

  wsPON.getRange(wsPON.getLastRow()+1,2,1,8).setValues(item1_Data_1_V);
  wsPON.getRange(wsPON.getLastRow(),11,1,5).setValues(po_data_1_V);
  wsPON.getRange(wsPON.getLastRow(),17,1,3).setValues(item1_Data_2_V);
  wsPON.getRange(wsPON.getLastRow(),20,1,8).setValues(po_data_2_V);
  wsPON.getRange(wsPON.getLastRow(),60,1,4).setValues(note_V);

    if(item2_amount_V != ""){
      wsPON.getRange(wsPON.getLastRow()+1,2,1,8).setValues(item2_Data_1_V);
      wsPON.getRange(wsPON.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPON.getRange(wsPON.getLastRow(),17,1,3).setValues(item2_Data_2_V);}

    if(item3_amount_V != ""){
      wsPON.getRange(wsPON.getLastRow()+1,2,1,8).setValues(item3_Data_1_V);
      wsPON.getRange(wsPON.getLastRow(),11,1,5).setValues(po_data_1_V);
      wsPON.getRange(wsPON.getLastRow(),17,1,3).setValues(item3_Data_2_V);
      }
    var range = wsPON.getRange(6,2,wsPON.getLastRow()-1,63);
     range.sort({column: 2, ascending: true})
}};


问:
Karate : How to call java code in karate-config.js
Sometimes test fail because of random things such as network condition, some services occassionally chug, and many other things.

In this situation ，we hope the failed cases could rerun for specific times, and we can config the value of specific times.

I have add afterScenario in karate-config.js.
The "afterScenario===" is print as log,
but the java code doesn't executed.

What is the correct way to call java code in karate-config.js?

var afterScenario = function(){
karate.log('afterScenario===>', karate.info);
var retryClass = Java.type('utils.CheckUtils');
var retryInstance = new retryClass();
return retryInstance.reRunCases(karate.info.featureFileName, karate.info.scenarioName)
}

karate.configure("afterScenario", afterScenario)


问:
TypeError: Invalid shape (200, 200, 1) for image data

anyone can help me with this error

I want to show the result of my prediction but i've got errors


问:
Is it possible to convert a angular PWA to a flutter application or maybe combine the both?
I am trying to convert an Angular PWA to a Flutter application as the mobile version of the Angular app is not exactly performing all the necessary steps. I would be fine with combining the both languages to if that is possible.

I did research about it and what i found was that you can combine the databases but i would love to find any alternatives if available.


问:
How can I achieve this custom slider design in Flutter
I am developing a app where I need this design. Can you tell me how can I achieve this in flutter?

image of the ui

I tried with circular slider. But can not achieve the ui.


问:
How to use apply_along_axis to operate on parameters of objects held in a numpy array?
Setup: I have an 1d numpy array of PyTorch models, all copies of the same network. I would like to parallel train each model allow easier comparison of performance.

I currently am trying to implement this using the following:

model_con = np.array([model] * sample_size)
data_con = np.array([train_data] * sample_size)

train_res = np.apply_along_axis(train_model, 0, model_con, data_con)
```
<p>This kicks up a error however:</p>
```AttributeError: 'numpy.ndarray' object has no attribute 'parameters'
```

I'm familiar with this being due to apply_along_axis being passed the whole arrays as opposed to the individual elements. What I am stumped to is how to get numpy to dig deeper into the object attributes to fix this error. Since the different model instances are independent of each other, to my understanding there should be nothing stopping this from being parallelized with a numpy array. I would very much like to avoid using a for loop in this instance, given the compute intensive nature of model training.

Body:
Setup: I have an 1d numpy array of PyTorch models, all copies of the same network. I would like to parallel train each model allow easier comparison of performance.

I currently am trying to implement this using the following:

model_con = np.array([model] * sample_size)
data_con = np.array([train_data] * sample_size)

train_res = np.apply_along_axis(train_model, 0, model_con, data_con)

This kicks up a error however:

AttributeError: 'numpy.ndarray' object has no attribute 'parameters'

I'm familiar with this being due to apply_along_axis being passed the whole arrays as opposed to the individual elements. What I am stumped to is how to get numpy to dig deeper into the object attributes to fix this error. Since the different model instances are independent of each other, to my understanding there should be nothing stopping this from being parallelized with a numpy array. I would very much like to avoid using a for loop in this instance, given the compute intensive nature of model training.


问:
IPhone app notifications have a 30 second to 1 min delay
We have an iPhone app which uses firebase to handle in app notifications (chat notifications, push notifications) which are having a 30 seconds to 1 min delay before they arrive. The Android app does not have this issue. What do we need to correct? Thanks in advance.

The notifications should arrive promptly in real time as they are pushed or a chat message is received. Chat messages are received as floating notifications when the app is minimised.


问:
How can I randomize my image selection to test my CNN model
I want to predict the emotion in my cnn model using images first, before I apply it using web cam.

Please correct my code if it is wrong.

```<code>model = tf.keras.models.load_model("model/model.model")
label_dict = {0 : 'boredom',
              1 : 'confused',
              2 : 'drowsy',
              3 : 'engage',
              4 : 'frustrated',
              5 : 'looking away'}

def img():
    list_dir ='./Images/bored/'
    file_list = os.listdir(list_dir )
    img_path = random.choice(file_list)

    img = load_img(img_path, target_size=(48,48))

    x = img_to_array(img)
    x = np.expand_dims(x, axis=0)

    prediction = np.argmax(model.predict(x))
    print('The predicted emotion is : ' + label_dict[prediction])
    my_image = load_img(img_path)
    return my_image

plt.imshow(img())
</code>```

when I try to run it i got this error:

Body:
I want to predict the emotion in my cnn model using images first, before I apply it using web cam.

Please correct my code if it is wrong.

model = tf.keras.models.load_model("model/model.model")
label_dict = {0 : 'boredom',
              1 : 'confused',
              2 : 'drowsy',
              3 : 'engage',
              4 : 'frustrated',
              5 : 'looking away'}

def img():
    list_dir ='./Images/bored/'
    file_list = os.listdir(list_dir )
    img_path = random.choice(file_list)

    img = load_img(img_path, target_size=(48,48))

    x = img_to_array(img)
    x = np.expand_dims(x, axis=0)

    prediction = np.argmax(model.predict(x))
    print('The predicted emotion is : ' + label_dict[prediction])
    my_image = load_img(img_path)
    return my_image

plt.imshow(img())

when I try to run it i got this error:


问:
Convert MobX computed type with Typescript Higher-Order Types
I have a TS class in a MobX application which looks like

```<code>interface Wrapper {
    a: string;
    b: string;
}

class PartialClass {
    x: number;
    y: number;
    maybeObject?: Wrapper;

    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }

    @computed // using MobX decorators
    get a() {
        return this.maybeObject?.a
    }
    @computed
    get b() {
        return this.maybeObject?.b
    }
}

type TotalClass = Required<PartialClass>
</code>```

As expected, PartialClass.a is string|undefined because maybeObject can be Wrapper|undefined. However, TotalClass.a is also string|undefined even though in that mapped type, maybeObject can only be Wrapper.

Is there a way to get Typescript to know that the type of my computeds should change with the type of the thing they're computing?

Body:
I have a TS class in a MobX application which looks like

interface Wrapper {
    a: string;
    b: string;
}

class PartialClass {
    x: number;
    y: number;
    maybeObject?: Wrapper;

    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }

    @computed // using MobX decorators
    get a() {
        return this.maybeObject?.a
    }
    @computed
    get b() {
        return this.maybeObject?.b
    }
}

type TotalClass = Required<PartialClass>

As expected, PartialClass.a is string|undefined because maybeObject can be Wrapper|undefined. However, TotalClass.a is also string|undefined even though in that mapped type, maybeObject can only be Wrapper.

Is there a way to get Typescript to know that the type of my computeds should change with the type of the thing they're computing?


问:
Developed sms app that has a function of setting the app as default sms app, after using Telephony plugin,couldn't received incomimg sms message
I have a question for Telephony plugin,

I am developing a sms app with Flutter framework,
and the developing sms app must have a function that can let my flutter sms app set as default sms app,In order to complete this,I invoked a method channel from Android native layer and worked normally,

It included several relative configure options in “AndroidManifest.xml”,the four configurations are all required,otherwise couldn’t work, according to the link https://stackoverflow.com/questions/30127564/how-do-i-set-my-app-as-the-default-sms-app to finish it, the above steps are correct, then followed Telephone plugin’s instructions to receive incoming sms message, once I sent any test sms message, would appear an error message that showed as below:

"java.lang.RuntimeException: Unable to instantiate receiver com.example.fluttertest7.SmsReceiver: java.lang.ClassNotFoundException: Didn't find class "com.example.fluttertest7.SmsReceiver" on path....."
According to Telephony's manual, the mapped configuration of “AndroidManifest.xml” is

<receiver android:name="com.shounakmulay.telephony.sms.IncomingSmsReceiver" android:permission="android.permission.BROADCAST_SMS" android:exported="true"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED"/> </intent-filter> </receiver>

It looks like a conflict problem?They can not exist together?Once I removed the four configuration of “default sms app”,will receive incoming message,I am pretty confused for that, please help! Thanks a lot.


问:
Can't save YOLOv4 model because of array shape mismatch
I am able to run transfer learning on YOLOv4 and my custom dataset with the following command (which runs successfully and can identify test images I present to the model):

```<code>!./darknet detector train /content/darknet/build/darknet/x64/data/obj.data /content/darknet/build/darknet/x64/cfg/yolov4_train.cfg /content/darknet/build/darknet/x64/yolov4.conv.137 -dont_show
</code>```

I am using the save_model.py tool from this github site:

```<code>!git clone https://github.com/hunglc007/tensorflow-yolov4-tflite
</code>```

When I enter the following command to save the model it fails:

```<code>!python3 save_model.py --weights /content/darknet/build/darknet/x64/backup/yolov4_train_final.weights --output ./checkpoints/yolov4-224 --input_size 224
</code>```

The failure is a mismatch between the weights saved in training and the expected array shape in the core/utility module utils.py (line 63):

```<code>Traceback (most recent call last):
File "save_model.py", line 58, in <module>
app.run(main)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 308, in run
    _run_main(main, args)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
File "save_model.py", line 54, in main
    save_tf()
File "save_model.py", line 49, in save_tf
    utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny)
File "/content/tensorflow-yolov4-tflite/core/utils.py", line 65, in load_weights
    conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0])
ValueError: cannot reshape array of size 4554552 into shape (1024,512,3,3)
</code>```

I added a debug print, and it looks like the it's getting all the way to the last layer before choking. In other words, the previous layers all get through this line of code in utils.py with a match between the saved weights and the array shape. I think this is somehow related to the fact I'm using image sizes of 224,224,3 instead of 416,416,3, but I did specify that in the input_size. For completeness, here's the last couple of debug prints before the Traceback above:

```<code>layer (out_dim, in_dim, height, width) 107 512 1024 1 1
layer (out_dim, in_dim, height, width) 108 1024 512 3 3
</code>```

If anyone has any ideas, that would be great!

Body:
I am able to run transfer learning on YOLOv4 and my custom dataset with the following command (which runs successfully and can identify test images I present to the model):

!./darknet detector train /content/darknet/build/darknet/x64/data/obj.data /content/darknet/build/darknet/x64/cfg/yolov4_train.cfg /content/darknet/build/darknet/x64/yolov4.conv.137 -dont_show

I am using the save_model.py tool from this github site:

!git clone https://github.com/hunglc007/tensorflow-yolov4-tflite

When I enter the following command to save the model it fails:

!python3 save_model.py --weights /content/darknet/build/darknet/x64/backup/yolov4_train_final.weights --output ./checkpoints/yolov4-224 --input_size 224

The failure is a mismatch between the weights saved in training and the expected array shape in the core/utility module utils.py (line 63):

Traceback (most recent call last):
File "save_model.py", line 58, in <module>
app.run(main)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 308, in run
    _run_main(main, args)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
File "save_model.py", line 54, in main
    save_tf()
File "save_model.py", line 49, in save_tf
    utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny)
File "/content/tensorflow-yolov4-tflite/core/utils.py", line 65, in load_weights
    conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0])
ValueError: cannot reshape array of size 4554552 into shape (1024,512,3,3)

I added a debug print, and it looks like the it's getting all the way to the last layer before choking. In other words, the previous layers all get through this line of code in utils.py with a match between the saved weights and the array shape. I think this is somehow related to the fact I'm using image sizes of 224,224,3 instead of 416,416,3, but I did specify that in the input_size. For completeness, here's the last couple of debug prints before the Traceback above:

layer (out_dim, in_dim, height, width) 107 512 1024 1 1
layer (out_dim, in_dim, height, width) 108 1024 512 3 3

If anyone has any ideas, that would be great!


问:
Androiddriver not compatible with Selenium 4.0 latest version
When I upgraded my Selenium webdriver to latest 4.0 (4.7 version to be specific), it throws exceptions 'Reference to type 'IFindsByClassName' claims it is defined in 'WebDriver', but it could not be found'.

By digging a bit, I found that androiddriver is not compatible with latest selenium webdriver 4.0 on-wards.

Is there any workaround to this? I want to upgrade make my android driver compatible with latest version of selenium webdriver.

Any help in this regard will be super appreciated.

I did not find any workaround to try in this regard.


问:
Problems with grid column rendering in Vaadin
I am using a Grid to display books information. Those books a historical novels and they are sorted by the year in which action is occurred. My first column in the grid is this year. Book object has this year as integer where positive numbers are AD and negative are BC. I am rendering this column with following class:

```<code>    public class ActionYearRenderer extends ComponentRenderer<Div, Book> {

    private Integer lastYear = Integer.MIN_VALUE;

    public void reset() {
        this.lastYear = Integer.MIN_VALUE;
    }

    @Override
    public Div createComponent(Book item) {
        Integer actionYear = item.getActionYear();
        Div result = new Div();
        if(!Objects.equals(actionYear, lastYear)) {
            lastYear = actionYear;
            if(actionYear < -10000) {
                result.setText("Prehistoric times");
            } else if (actionYear >= 0) {
                result.setText("year " + actionYear.toString());
            } else {
                result.setText("year " + Integer.toString(Math.abs(actionYear)) + " B.C.E.");
            }
        }
        result.getStyle().set("word-wrap", "normal");
        return result;
    }
}
</code>```

I need to display a year only once for the all books referring to a single year. It is working almost as I wanted it to do. It displays everything correctly at the beginning, but I also have ItemDetailsRenderer, which opens book annotation and review. When details are closed, action year disappears from the grid. I presume, that the item is being re-rendered and it is causing this behavior. How can I preserve the content of this cell?

Body:
I am using a Grid to display books information. Those books a historical novels and they are sorted by the year in which action is occurred. My first column in the grid is this year. Book object has this year as integer where positive numbers are AD and negative are BC. I am rendering this column with following class:

    public class ActionYearRenderer extends ComponentRenderer
 {

    private Integer lastYear = Integer.MIN_VALUE;

    public void reset() {
        this.lastYear = Integer.MIN_VALUE;
    }

    @Override
    public Div createComponent(Book item) {
        Integer actionYear = item.getActionYear();
        Div result = new Div();
        if(!Objects.equals(actionYear, lastYear)) {
            lastYear = actionYear;
            if(actionYear < -10000) {
                result.setText("Prehistoric times");
            } else if (actionYear >= 0) {
                result.setText("year " + actionYear.toString());
            } else {
                result.setText("year " + Integer.toString(Math.abs(actionYear)) + " B.C.E.");
            }
        }
        result.getStyle().set("word-wrap", "normal");
        return result;
    }
}

I need to display a year only once for the all books referring to a single year. It is working almost as I wanted it to do. It displays everything correctly at the beginning, but I also have ItemDetailsRenderer, which opens book annotation and review. When details are closed, action year disappears from the grid. I presume, that the item is being re-rendered and it is causing this behavior. How can I preserve the content of this cell?


问:
Is it correct to assume that HTTPResponse.read() returning empty buffer means the response was read to the end?
I am sending some not exactly standard HTTP-like request, so I am using raw TCP socket for that. However once I am done, I do get a very normal HTTP response from the other side. I don't want to write a parser for that, so I am using http.client.HTTPResponse like this:

```<code>    def read_response(self):
        self.http_response = HTTPResponse(self.tcp_socket)
        self.http_response.begin()
        assert(self.http_response.status == 200)
        # this while loop is bit of a simplification
        while True:
            res = self.http_response.read(1024)
            if res is None or len(res) == 0:
                self.finished = True
                return
</code>```

I am just not so sure if this is the right way to check all data is read. If it matters, in this case server is supposed to close the socket once all has been sent.

Body:
I am sending some not exactly standard HTTP-like request, so I am using raw TCP socket for that. However once I am done, I do get a very normal HTTP response from the other side. I don't want to write a parser for that, so I am using http.client.HTTPResponse like this:

    def read_response(self):
        self.http_response = HTTPResponse(self.tcp_socket)
        self.http_response.begin()
        assert(self.http_response.status == 200)
        # this while loop is bit of a simplification
        while True:
            res = self.http_response.read(1024)
            if res is None or len(res) == 0:
                self.finished = True
                return

I am just not so sure if this is the right way to check all data is read. If it matters, in this case server is supposed to close the socket once all has been sent.


问:
How to test a matInput field only by name
I am searching all over the internet for a solution. But maybe i am using the wrong word to search for.
I am using angular 14 and have the following element:

```<code><mat-form-field *ngIf="isCustomer()">
  <input [disabled]="true" matInput placeholder="{{'attributes.person' | translate}}"
         [ngModel]="data.person[0].vorname + ' ' + data.person[0].nachname"
         name="person">
</mat-form-field>
</code>```

I know there is properly a lot to improve this code, but it works fine.

The problem is the test:

```<code>fixture.detectChanges();
// check rendered response
fixture.whenStable().then(() => {
   const compiled = fixture.debugElement.queryAll(By.css('input'));

expect(compiled[7].nativeElement.value).toBe('Peter');
</code>```

As you can see, there are multiple input fields within my html file.

My question is, is there a way to get the element by 'name="person" and not as shown? Because if someone adds more input fields that would properly crash this test because eyerything could be out of order.

I tried :

```<code>fixture.debugElement.query(By.css('input')).nativeElement;
expect(compiled.getAttribute('person').toBe('Peter'));
</code>```

although .getElementByName .....

Body:
I am searching all over the internet for a solution. But maybe i am using the wrong word to search for.
I am using angular 14 and have the following element:

<mat-form-field *ngIf="isCustomer()">
  <input [disabled]="true" matInput placeholder="{{'attributes.person' | translate}}"
         [ngModel]="data.person[0].vorname + ' ' + data.person[0].nachname"
         name="person">
</mat-form-field>

I know there is properly a lot to improve this code, but it works fine.

The problem is the test:

fixture.detectChanges();
// check rendered response
fixture.whenStable().then(() => {
   const compiled = fixture.debugElement.queryAll(By.css('input'));

expect(compiled[7].nativeElement.value).toBe('Peter');

As you can see, there are multiple input fields within my html file.

My question is, is there a way to get the element by 'name="person" and not as shown? Because if someone adds more input fields that would properly crash this test because eyerything could be out of order.

I tried :

fixture.debugElement.query(By.css('input')).nativeElement;
expect(compiled.getAttribute('person').toBe('Peter'));

although .getElementByName .....


问:
Patch Merging and Pooling layer difference
I want to ask what the difference between Patch Merging in Swin Transformer and Pooling layer (e.x. Max Pooling) in CNNs. Why do they use Patch Merging instead of Pooling layer.

I understand that Patch Merging will reduce the spatial dimension in half and increase the channel dimension, so there will no information loss when using Patch Merging, while Pooling layer will cause a loss of information of input future


问:
How to deploy my own backend with AWS amplify
I'm pretty new to AWS Amplify and I'm trying to deploy an app with my own frontend and backend, I have successfully deployed the frontend but I can't figure out how to connect the backend (it seems like the server is not responding).

Here's my project structure:

And Here's my amplify.yml

```<code>version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    # IMPORTANT - Please verify your build commands
    build:
      commands: []
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: 'client'
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
</code>```

I got a warning on the website:
Failed to load resource: the server responded with a status of 404 ()

I also tried adding the code below to the yml

```<code>version: 1
env:
  variables:
    key: value
backend:
  phases:
    build:
      commands:
        - amplifyPush --simple
</code>```

But the application failed when building

Not sure if this has something to do with using express.js in node.js

Body:
I'm pretty new to AWS Amplify and I'm trying to deploy an app with my own frontend and backend, I have successfully deployed the frontend but I can't figure out how to connect the backend (it seems like the server is not responding).

Here's my project structure:

And Here's my amplify.yml

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    # IMPORTANT - Please verify your build commands
    build:
      commands: []
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: 'client'
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

I got a warning on the website:
Failed to load resource: the server responded with a status of 404 ()

I also tried adding the code below to the yml

version: 1
env:
  variables:
    key: value
backend:
  phases:
    build:
      commands:
        - amplifyPush --simple

But the application failed when building

Not sure if this has something to do with using express.js in node.js


问:
Write a python code to get the wait in program without using time.sleep method and print it continues
Write a python code to continue print the functions in a time delay without using time.sleep method and inbuilt function

Please help me to do this