问:
dropdown values in the dialog are getting cleared when i save the dialog for the second time
i have a multifiled with country and cities dropdown cities dropdown is based on country selection .Issue: first time when i select a field in country dropdown and select city values are storing properly second time when i again open the dialog and with out changing any thing if i save the dialog then city drop down values are getting cleared

```<code>(function($, $document) {
    "use strict";

    var COUNTRY = "./mfCountry",
        CITY = "./mfCity";

    function loadCities(el) {
        el.each(function(i, element) {
              if ($(element).data("select")) {

                var value = $(element).data("select").getValue();
                console.log(value);
                var multifieldItemContenHandle = $(element).closest("coral-multifield-item-content");
                var citySelect = multifieldItemContenHandle.find(".cq-dialog-select-city").find("select");
                var cityID = citySelect.val();
                if (value.indexOf(",") == -1) {
                    $.get("/bin/getcitylist?countryID=" + value, function(dataSource) {
                        var citySpan = citySelect.closest(".coral-Select");
                        citySpan.find('option').remove().end();
                        var cityUl = citySpan.find('ul');
                        cityUl.find('li').remove().end();
                        var cityOl = citySpan.find('ol');
                        cityOl.find('li').remove().end();
                        $.each(dataSource, function(value, key) {
                            $("<option>").val(key).text(value).appendTo(citySelect);
                            cityUl.append('<li class="coral-SelectList-item coral-SelectList-item--option is-highlighted" aria-selected="false" role="option" data-value="' + key + '">' + value + '</a></li>');
                        });
                    });
                } else {
                    $.get("/bin/getallcities?city=all", function(dataSource) {
                        var citySpan = citySelect.closest(".coral-Select");
                        citySpan.find('option').remove().end();
                        var cityUl = citySpan.find('ul');
                        cityUl.find('li').remove().end();
                        var cityOl = citySpan.find('ol');
                        cityOl.find('li').remove().end();
                        $.each(dataSource, function(value, key) {
                            $("<option>").val(key).text(value).appendTo(citySelect);
                            cityUl.append('<li class="coral-SelectList-item coral-SelectList-item--option is-highlighted" aria-selected="false" role="option" data-value="' + key + '">' + value + '</a></li>');
                        });
                    });
                }

            }
        })
    }

    $document.on("dialog-ready", function() {

        $(document).on("selected", ".cq-dialog-select-country", function(e) {
            loadCities($(this));
        });

        var $multifields = $("coral-Multifield").find("coral-multifield-item");
       var mfCityFlag = $multifields.find("select[name='./mfCity']");

       if(mfCityFlag.length == 0){
       return true;
       }
        $multifields.each(function(i, multifield) {
            var v = $(multifield).find("select[name='./mfCountry']").find("option:selected").val();
            var citySpan = $(multifield).find("select[name='./mfCity']");
            var $citySelectedItem = $(multifield).find("ol").children();
            if (v.indexOf(",") == -1) {

                $.get("/bin/getcitylist?countryID=" + v, function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                    citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('<li class="coral-SelectList-item coral-SelectList-item--option is-highlighted" aria-selected="false" role="option" data-value="' + key + '">' + value + '</a></li>');
                    });
                    if ($citySelectedItem.length == 0) {
                        var itemVal = "All"
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    } else {
                        $citySelectedItem.each(function(i, citySelectedItem) {
                            var itemVal = $(this).attr("title");
                            $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                                .attr("selected", "selected");

                        });
                    }

                });

            } else {

                $.get("/bin/getallcities?city=all", function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                    citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('<li class="coral-SelectList-item coral-SelectList-item--option is-highlighted" aria-selected="false" role="option" data-value="' + key + '">' + value + '</a></li>');
                    });
                    $citySelectedItem.each(function(i, citySelectedItem) {
                        var itemVal = $(this).attr("title");
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    });

                });
            }

        });

    });

    $document.on("foundation-contentloaded", function() {

        $(document).on("selected", ".cq-dialog-select-country", function(e) {
            loadCities($(this));
        });
      var $multifields = $("coral-Multifield").find("coral-multifield-item");
       var mfCityFlag = $multifields.find("select[name='./mfCity']");
       if(mfCityFlag.length == 0){
       return true;
       }
        $multifields.each(function(i, multifield) {
            var v = $(multifield).find("select[name='./mfCountry']").find("option:selected").val();
            var citySpan = $(multifield).find("select[name='./mfCity']");
            var $citySelectedItem = $(multifield).find("ol").children();

            if (v.indexOf(",") == -1) {

                $.get("/bin/getcitylist?countryID=" + v, function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                    citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('<li class="coral-SelectList-item coral-SelectList-item--option is-highlighted" aria-selected="false" role="option" data-value="' + key + '">' + value + '</a></li>');
                    });
                    if ($citySelectedItem.length == 0) {
                        var itemVal = "All"
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    } else {
                        $citySelectedItem.each(function(i, citySelectedItem) {
                            var itemVal = $(this).attr("title");
                            $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                                .attr("selected", "selected");

                        });
                    }

                });

            } else {
                $.get("/bin/getallcities?city=all", function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                     citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('<li class="coral-SelectList-item coral-SelectList-item--option is-highlighted" aria-selected="false" role="option" data-value="' + key + '">' + value + '</a></li>');
                    });
                    $citySelectedItem.each(function(i, citySelectedItem) {
                        var itemVal = $(this).attr("title");
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    });

                });
            }

        });

    });

    // Dialog Submit Function

    $(document).on("click", ".cq-dialog-submit", function(e) {
        //$(window).adaptTo("foundation-ui").alert("Close", "Dialog closed, selector [.cq-dialog-submit]");
        var requestUrl = e.target.baseURI;
        if (requestUrl.indexOf("/offers/")) {
            requestUrl = requestUrl.split("editor.html").pop();
            requestUrl = requestUrl.replace(".html", "");

            $.ajax({
                url: requestUrl + ".qsOffer",
                beforeSend: function(xhr) {
                    xhr.overrideMimeType("text/plain; charset=x-user-defined");
                }
            }).done(function(data) {

                console.log("Sample of data:", data);
            });

        }

    });

})($, $(document));
</code>```

im expecting the cities dropdwon values should not get cleared even if i open and save the dialog with out doing any modifications

Body:
i have a multifiled with country and cities dropdown cities dropdown is based on country selection .Issue: first time when i select a field in country dropdown and select city values are storing properly second time when i again open the dialog and with out changing any thing if i save the dialog then city drop down values are getting cleared

(function($, $document) {
    "use strict";

    var COUNTRY = "./mfCountry",
        CITY = "./mfCity";

    function loadCities(el) {
        el.each(function(i, element) {
              if ($(element).data("select")) {

                var value = $(element).data("select").getValue();
                console.log(value);
                var multifieldItemContenHandle = $(element).closest("coral-multifield-item-content");
                var citySelect = multifieldItemContenHandle.find(".cq-dialog-select-city").find("select");
                var cityID = citySelect.val();
                if (value.indexOf(",") == -1) {
                    $.get("/bin/getcitylist?countryID=" + value, function(dataSource) {
                        var citySpan = citySelect.closest(".coral-Select");
                        citySpan.find('option').remove().end();
                        var cityUl = citySpan.find('ul');
                        cityUl.find('li').remove().end();
                        var cityOl = citySpan.find('ol');
                        cityOl.find('li').remove().end();
                        $.each(dataSource, function(value, key) {
                            $("<option>").val(key).text(value).appendTo(citySelect);
                            cityUl.append('
' + value + '
');
                        });
                    });
                } else {
                    $.get("/bin/getallcities?city=all", function(dataSource) {
                        var citySpan = citySelect.closest(".coral-Select");
                        citySpan.find('option').remove().end();
                        var cityUl = citySpan.find('ul');
                        cityUl.find('li').remove().end();
                        var cityOl = citySpan.find('ol');
                        cityOl.find('li').remove().end();
                        $.each(dataSource, function(value, key) {
                            $("<option>").val(key).text(value).appendTo(citySelect);
                            cityUl.append('
' + value + '
');
                        });
                    });
                }

            }
        })
    }

    $document.on("dialog-ready", function() {

        $(document).on("selected", ".cq-dialog-select-country", function(e) {
            loadCities($(this));
        });

        var $multifields = $("coral-Multifield").find("coral-multifield-item");
       var mfCityFlag = $multifields.find("select[name='./mfCity']");

       if(mfCityFlag.length == 0){
       return true;
       }
        $multifields.each(function(i, multifield) {
            var v = $(multifield).find("select[name='./mfCountry']").find("option:selected").val();
            var citySpan = $(multifield).find("select[name='./mfCity']");
            var $citySelectedItem = $(multifield).find("ol").children();
            if (v.indexOf(",") == -1) {

                $.get("/bin/getcitylist?countryID=" + v, function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                    citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('
' + value + '
');
                    });
                    if ($citySelectedItem.length == 0) {
                        var itemVal = "All"
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    } else {
                        $citySelectedItem.each(function(i, citySelectedItem) {
                            var itemVal = $(this).attr("title");
                            $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                                .attr("selected", "selected");

                        });
                    }

                });

            } else {

                $.get("/bin/getallcities?city=all", function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                    citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('
' + value + '
');
                    });
                    $citySelectedItem.each(function(i, citySelectedItem) {
                        var itemVal = $(this).attr("title");
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    });

                });
            }

        });

    });

    $document.on("foundation-contentloaded", function() {

        $(document).on("selected", ".cq-dialog-select-country", function(e) {
            loadCities($(this));
        });
      var $multifields = $("coral-Multifield").find("coral-multifield-item");
       var mfCityFlag = $multifields.find("select[name='./mfCity']");
       if(mfCityFlag.length == 0){
       return true;
       }
        $multifields.each(function(i, multifield) {
            var v = $(multifield).find("select[name='./mfCountry']").find("option:selected").val();
            var citySpan = $(multifield).find("select[name='./mfCity']");
            var $citySelectedItem = $(multifield).find("ol").children();

            if (v.indexOf(",") == -1) {

                $.get("/bin/getcitylist?countryID=" + v, function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                    citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('
' + value + '
');
                    });
                    if ($citySelectedItem.length == 0) {
                        var itemVal = "All"
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    } else {
                        $citySelectedItem.each(function(i, citySelectedItem) {
                            var itemVal = $(this).attr("title");
                            $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                                .attr("selected", "selected");

                        });
                    }

                });

            } else {
                $.get("/bin/getallcities?city=all", function(dataSource) {
                    var cityUl = $(citySpan).parent().find('ul');
                    $(cityUl).find('li').remove().end();
                     citySpan.find("option").remove().end();
                    $.each(dataSource, function(value, key) {
                        $("<option>").val(key).text(value).appendTo(citySpan);
                        $(cityUl).append('
' + value + '
');
                    });
                    $citySelectedItem.each(function(i, citySelectedItem) {
                        var itemVal = $(this).attr("title");
                        $(multifield).find("select[name='./mfCity']").find("option:contains(" + itemVal + ")")
                            .attr("selected", "selected");

                    });

                });
            }

        });

    });

    // Dialog Submit Function

    $(document).on("click", ".cq-dialog-submit", function(e) {
        //$(window).adaptTo("foundation-ui").alert("Close", "Dialog closed, selector [.cq-dialog-submit]");
        var requestUrl = e.target.baseURI;
        if (requestUrl.indexOf("/offers/")) {
            requestUrl = requestUrl.split("editor.html").pop();
            requestUrl = requestUrl.replace(".html", "");

            $.ajax({
                url: requestUrl + ".qsOffer",
                beforeSend: function(xhr) {
                    xhr.overrideMimeType("text/plain; charset=x-user-defined");
                }
            }).done(function(data) {

                console.log("Sample of data:", data);
            });

        }

    });

})($, $(document));

im expecting the cities dropdwon values should not get cleared even if i open and save the dialog with out doing any modifications


来源: stackexchange

问:
nestjs typeorm mysql] Can't add new command when connection is in closed state
Hi I am using typeorm and mysql, nestjs.

During testing I got the error below.

2022-12-22 16:18 : error: Error: Can't add new command when connection is in closed state
    at PoolConnection._addCommandClosedState (/home/ubuntu/myApi/node_modules/mysql2/lib/connection.js:148:17)
    at PoolConnection.query (/home/ubuntu/myApi/node_modules/mysql2/lib/connection.js:546:17)
    at MysqlQueryRunner.<anonymous> (/home/ubuntu/myApi/src/driver/mysql/MysqlQueryRunner.ts:185:36)
    at step (/home/ubuntu/myApi/node_modules/tslib/tslib.js:143:27)
    at Object.next (/home/ubuntu/myApi/node_modules/tslib/tslib.js:124:57)
    at fulfilled (/home/ubuntu/myApi/node_modules/tslib/tslib.js:114:62)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  fatal: true
}

```
<p>I don't know where or why this error occurred.</p>
<p>I create and use the repository as below.</p>
<pre class="lang-js prettyprint-override"><code>@Injectable()
@EntityRepository(Entity)
export class MyRepository extends Repository< Entity > {
    async saveEntity(
    @TransactionManager() transactionManager: EntityManager,
    en: Entity,
  ) {
    return await transactionManager.save(Entity, en);
  }
}
...

//service

constructor(
    private readonly myRepository: MyRepository,
){}

...

async aa(){
   const queryRunner = await getConnection().createQueryRunner();
   await queryRunner.startTransaction();
   try{
      ...
      const aa = await this.myRepository.findOne({1});
      await this.myRepository. saveEntity(queryRunner.manager, aa);
      await queryRunner.commitTransaction();
   }catch(error){
      await queryRunner.rollbackTransaction();
   }finally{
      await queryRunner.release();
   }
}

</code>```

Please tell me if there is any more information you need.

I'd definitely like to fix this.

Thank you!

ContentLicense: CC BY-SA 4.0

Body:
Hi I am using typeorm and mysql, nestjs.

During testing I got the error below.

2022-12-22 16:18 : error: Error: Can't add new command when connection is in closed state
    at PoolConnection._addCommandClosedState (/home/ubuntu/myApi/node_modules/mysql2/lib/connection.js:148:17)
    at PoolConnection.query (/home/ubuntu/myApi/node_modules/mysql2/lib/connection.js:546:17)
    at MysqlQueryRunner.<anonymous> (/home/ubuntu/myApi/src/driver/mysql/MysqlQueryRunner.ts:185:36)
    at step (/home/ubuntu/myApi/node_modules/tslib/tslib.js:143:27)
    at Object.next (/home/ubuntu/myApi/node_modules/tslib/tslib.js:124:57)
    at fulfilled (/home/ubuntu/myApi/node_modules/tslib/tslib.js:114:62)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  fatal: true
}

I don't know where or why this error occurred.

I create and use the repository as below.

@Injectable()
@EntityRepository(Entity)
export class MyRepository extends Repository< Entity > {
    async saveEntity(
    @TransactionManager() transactionManager: EntityManager,
    en: Entity,
  ) {
    return await transactionManager.save(Entity, en);
  }
}
...

//service

constructor(
    private readonly myRepository: MyRepository,
){}

...

async aa(){
   const queryRunner = await getConnection().createQueryRunner();
   await queryRunner.startTransaction();
   try{
      ...
      const aa = await this.myRepository.findOne({1});
      await this.myRepository. saveEntity(queryRunner.manager, aa);
      await queryRunner.commitTransaction();
   }catch(error){
      await queryRunner.rollbackTransaction();
   }finally{
      await queryRunner.release();
   }
}

Please tell me if there is any more information you need.

I'd definitely like to fix this.

Thank you!


问:
Could not open a file under a specific directory with a specific file name length in python
I was writing lots of small text files in a specific directory (/mnt/disks/hdd/chunk) in my Linux system using a python script. my disk is 3TB and formated as ext4

I check the disk space and the available inode is enough. When I remove some of the character from the file name of UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUpY_180.txt. It can open under /mnt/disks/hdd/chunk without any issue. For example, If I change the file name to

```<code>UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUp_180.txt
</code>```

It  opens without any issue. Here is some code snippets go get more clear idea

```<code>Cell In[5], line 1
----> 1 with open('/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUpY_180.txt', "w") as fp:
      2     print(fp)

File ~/miniconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:282, in _modified_open(file, *args, **kwargs)
    275 if file in {0, 1, 2}:
    276     raise ValueError(
    277         f"IPython won't let you open fd={file} by default "
    278         "as it is likely to crash IPython. If you know what you are doing, "
    279         "you can use builtins' open."
    280     )
--> 282 return io_open(file, *args, **kwargs)

OSError: [Errno 28] No space left on device: '/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUpY_180.txt'

In [6]: with open('/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUp_180.txt', "w") as fp:
   ...:     print(fp)
   ...:
<_io.TextIOWrapper name='/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUp_180.txt' mode='w' encoding='UTF-8'>
</code>```

Is this the file name length issue? I also try to open file in different directory (/mnt/disks/hdd/) rather than /mnt/disks/hdd/chunk and give long length file name like bellow

```<code>In [9]: with open('/mnt/disks/hdd/UCHLqIOMPk20w-6cFgkA90jw22222222222222222222222222_id_V_YudpRpUpY_180.txt', "w") as fp:
   ...:     print(fp)
   ...:
<_io.TextIOWrapper name='/mnt/disks/hdd/UCHLqIOMPk20w-6cFgkA90jw22222222222222222222222222_id_V_YudpRpUpY_180.txt' mode='w' encoding='UTF-8'>
</code>```

And it does not cause any No space left on device. Could not get what i'm doing wrong?

So far I try,

I try to clear /tmp directory and remount the HDD

check free inode

Please let me know if you need any other information

Thanks

Body:
I was writing lots of small text files in a specific directory (/mnt/disks/hdd/chunk) in my Linux system using a python script. my disk is 3TB and formated as ext4

I check the disk space and the available inode is enough. When I remove some of the character from the file name of UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUpY_180.txt. It can open under /mnt/disks/hdd/chunk without any issue. For example, If I change the file name to

UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUp_180.txt

It  opens without any issue. Here is some code snippets go get more clear idea

Cell In[5], line 1
----> 1 with open('/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUpY_180.txt', "w") as fp:
      2     print(fp)

File ~/miniconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:282, in _modified_open(file, *args, **kwargs)
    275 if file in {0, 1, 2}:
    276     raise ValueError(
    277         f"IPython won't let you open fd={file} by default "
    278         "as it is likely to crash IPython. If you know what you are doing, "
    279         "you can use builtins' open."
    280     )
--> 282 return io_open(file, *args, **kwargs)

OSError: [Errno 28] No space left on device: '/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUpY_180.txt'

In [6]: with open('/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUp_180.txt', "w") as fp:
   ...:     print(fp)
   ...:
<_io.TextIOWrapper name='/mnt/disks/hdd/chunk/UCHLqIOMPk20w-6cFgkA90jw_id_V_YudpRpUp_180.txt' mode='w' encoding='UTF-8'>

Is this the file name length issue? I also try to open file in different directory (/mnt/disks/hdd/) rather than /mnt/disks/hdd/chunk and give long length file name like bellow

In [9]: with open('/mnt/disks/hdd/UCHLqIOMPk20w-6cFgkA90jw22222222222222222222222222_id_V_YudpRpUpY_180.txt', "w") as fp:
   ...:     print(fp)
   ...:
<_io.TextIOWrapper name='/mnt/disks/hdd/UCHLqIOMPk20w-6cFgkA90jw22222222222222222222222222_id_V_YudpRpUpY_180.txt' mode='w' encoding='UTF-8'>

And it does not cause any No space left on device. Could not get what i'm doing wrong?

So far I try,

I try to clear /tmp directory and remount the HDD

check free inode

Please let me know if you need any other information

Thanks


问:
twitter-api-v2 / Bad Twitter streaming request: 403
```<code>var Twit = require('twit');

var replie = ['1','2','3'];

var T = new Twit({
....
})

var stream = T.stream('statuses/filter', { track: '@beykant_' });

stream.on('tweet',tweetEvent);

function tweetEvent(eventMsg) {
    var replyto = eventMsg.in_reply_to_screen_name;
    var text = eventMsg.text;
    var from = eventMsg.user.screen_name;

    if(replyto == 'beykant_'){
        var newTweet = '@' + from + replie[Math.floor(Math.random() * replie.length)];
        tuit(newTweet);
    }
}

function tuit(txt){

    var tweet = {
        status: txt
    }
    T.post('statuses/update',tweet, tweeted);
    function tweeted (err, data, response) {
        if(err){
            console.log('err');
        }else{
            console.log('ready')
        }
        console.log(data)
      }

}
</code>```

I used twitter-api-v2, I couldn't find the response event when @mentioned on it. When I tried the twit module, it gave such an error again, can anyone show a solution, it would be better if it can be done with the twitter-api-v2 module, thank you.

Body:
var Twit = require('twit');

var replie = ['1','2','3'];

var T = new Twit({
....
})

var stream = T.stream('statuses/filter', { track: '@beykant_' });

stream.on('tweet',tweetEvent);

function tweetEvent(eventMsg) {
    var replyto = eventMsg.in_reply_to_screen_name;
    var text = eventMsg.text;
    var from = eventMsg.user.screen_name;

    if(replyto == 'beykant_'){
        var newTweet = '@' + from + replie[Math.floor(Math.random() * replie.length)];
        tuit(newTweet);
    }
}

function tuit(txt){

    var tweet = {
        status: txt
    }
    T.post('statuses/update',tweet, tweeted);
    function tweeted (err, data, response) {
        if(err){
            console.log('err');
        }else{
            console.log('ready')
        }
        console.log(data)
      }

}

I used twitter-api-v2, I couldn't find the response event when @mentioned on it. When I tried the twit module, it gave such an error again, can anyone show a solution, it would be better if it can be done with the twitter-api-v2 module, thank you.


问:
Azure Backlog Tab Events
How to create the drag and drop event listener for the work item reparent  action in a custom extension for the Backlog Tab (same as observers on the work item form)?

Contribution type ms.vss-work-web.work-item-notification does not work on this tab

Title: Azure Backlog Tab Events


问:
Cannot assign array value in ngAfterViewInit()
I have an input field. Which will populate a list when I enter something in it. The problem I'm having is that I cannot empty an array value inside ngAfterViewInit()

```<code> ngAfterViewInit(): void {

      // remove suggestion field when goes out of focus()
        if (!$('.suggestionInput').is(':focus')) {
            setTimeout(() => {
              this.exmapleArray = [];
              }, 50)
            }
        });
    }
</code>```

exampleArray not updating to empty array though after debugging found out if (!$('.suggestionInput').is(':focus')) is working. But still array value isn't updating. I don't found any reason to support the cause.

I have tried using angular blur() inside input but it doesn't server my purpose and other solution regarding ngAfterViewInit()

Body:
I have an input field. Which will populate a list when I enter something in it. The problem I'm having is that I cannot empty an array value inside ngAfterViewInit()

 ngAfterViewInit(): void {

      // remove suggestion field when goes out of focus()
        if (!$('.suggestionInput').is(':focus')) {
            setTimeout(() => {
              this.exmapleArray = [];
              }, 50)
            }
        });
    }

exampleArray not updating to empty array though after debugging found out if (!$('.suggestionInput').is(':focus')) is working. But still array value isn't updating. I don't found any reason to support the cause.

I have tried using angular blur() inside input but it doesn't server my purpose and other solution regarding ngAfterViewInit()


问:
Why doReturn().when() is working in my Test method but not when().thenReturn getting error like calling unmocked method
Here I have commented out the code with issue which is working and which is not.

```<code>@RunWith(PowerMockRunner.class)
@PrepareForTest({ Hibernate.class })
@PowerMockIgnore({ "javax.management.*" })
public class DummyCaseManagerTest {

    @Test
    public void testDummyCaseCount() {

        // doReturn(2).when(dummyCaseDao).dummyCaseCount(anyInt()); mocking like this works
        // when(dummyCaseDao.dummyCaseCount(someId)).thenReturn(2); but this gives error call of unmocked method
        int someId = 1;
        Operator operator = TestHelperCommon.mockOperator(1);
        Brand brand = mockBrand();
        operator.setBrand(brand);
        int result = manager.casecount(someId, operator);
        verify( dummyCaseDao, never()).casecount(anyInt());
        verify( dummyCaseDao, times(1)).casecount(someId, brand);
        assertEquals( 2, result);
    }

}
</code>```

Could any one explain in simple words , what is the reason.
In my project I can see we have used this when().thenReturn() in test method implementation. so I tried same but the only diff is there we are not using PowerMockRunner. I sense this might be happening because of the powermock , but want to know to exact reason .
Thanks in advance.

Body:
Here I have commented out the code with issue which is working and which is not.

@RunWith(PowerMockRunner.class)
@PrepareForTest({ Hibernate.class })
@PowerMockIgnore({ "javax.management.*" })
public class DummyCaseManagerTest {

    @Test
    public void testDummyCaseCount() {

        // doReturn(2).when(dummyCaseDao).dummyCaseCount(anyInt()); mocking like this works
        // when(dummyCaseDao.dummyCaseCount(someId)).thenReturn(2); but this gives error call of unmocked method
        int someId = 1;
        Operator operator = TestHelperCommon.mockOperator(1);
        Brand brand = mockBrand();
        operator.setBrand(brand);
        int result = manager.casecount(someId, operator);
        verify( dummyCaseDao, never()).casecount(anyInt());
        verify( dummyCaseDao, times(1)).casecount(someId, brand);
        assertEquals( 2, result);
    }

}

Could any one explain in simple words , what is the reason.
In my project I can see we have used this when().thenReturn() in test method implementation. so I tried same but the only diff is there we are not using PowerMockRunner. I sense this might be happening because of the powermock , but want to know to exact reason .
Thanks in advance.


问:
ZeroMQ epgm error on Centos:93 Protocol not supported
I'm trying to multicast using zmq on Centos. My program dies on the line that tries to bind to the epgm address.

here is my code segment

```<code>pContext = zmq_ctx_new();
pPubSocket = zmq_socket(pContext, ZMQ_PUB);
std::stringstream ss;
ss<<"epgm://*:"<<port;
auto ret = zmq_bind(pSubSocket,ss.str().c_str());
</code>```

if bind with the unicast such as "tcp://*", it can work fine,
but bind with the multicast epgm, the code will return 93, which means Protocol not supported

os:centos
language:c++
I have installed openpgm-5.2， zeromq4.0.5, and I have enabled the --with-pgm options when build the zeromq by command:

```<code>./configure --with-pgm=libpgm-5.2.122~dfsg

</code>```

Please suggest me why is this still happening so...and how to solve this ?

Body:
I'm trying to multicast using zmq on Centos. My program dies on the line that tries to bind to the epgm address.

here is my code segment

pContext = zmq_ctx_new();
pPubSocket = zmq_socket(pContext, ZMQ_PUB);
std::stringstream ss;
ss<<"epgm://*:"<<port;
auto ret = zmq_bind(pSubSocket,ss.str().c_str());

if bind with the unicast such as "tcp://*", it can work fine,
but bind with the multicast epgm, the code will return 93, which means Protocol not supported

os:centos
language:c++
I have installed openpgm-5.2， zeromq4.0.5, and I have enabled the --with-pgm options when build the zeromq by command:

./configure --with-pgm=libpgm-5.2.122~dfsg

Please suggest me why is this still happening so...and how to solve this ?


问:
Create-daml-app testing not working，User already exists
I am following the tutorial here: Testing Your Web App to test the demo, but I got following error when I did npm run test:


问:
Metrics Ad Exchange Active View measurable impressions and Ad Exchange Active View % viewable impressions not showing in my data source
Why only these Metrics Ad Exchange Active View measurable impressions and Ad Exchange Active View % viewable impressions not showing in my data source?

Without thee metrics, we can not create report of viewability of ad exchange.

Please suggest, how to do.

Regards,
Kanhaiya Kumar


问:
React AG grid- issue with implementation of server side filter and sort on each column
Need working example of implementing server side filter and sort on each column in react AG-grid.

With below sample code - am not able to capture filter or sorting value to use it for server side request(api call).

import React, {
  useCallback,
  useEffect,
  useMemo,
  useRef,
  useState,
} from 'react';
import PropTypes from 'prop-types';
import { AgGridReact} from 'ag-grid-react';
import 'ag-grid-enterprise';
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';

function createServerSideDatasource(rowData) {
  return {
    getRows(params) {
       const { startRow, endRow, filterModel, sortModel } =
        params.request;
      params.successCallback(rowData, 500);

    },
  };
}

const AgGridComponent = props => {
  const gridRef = useRef();
  const { rowData, columnDefs } = props;

  const gridStyle = useMemo(
    () => ({ height: '100%', width: '100%' }),
    []
  );

  const defaultColDef = useMemo(
    () => ({
      filter: true,
      floatingFilter: true,
      sortable: true,
      enableServerSideSorting: true,
      enableServerSideFilter: true,
    }),
    []
  );

  const onGridReady = useCallback(params => {
    const columnToolPanel =
      params.api.getToolPanelInstance('columns');
    columnToolPanel.collapseColumnGroups();
    params.api.closeToolPanel();

    const datasource = createServerSideDatasource(rowData);
    params.api.setServerSideDatasource(datasource);
  }, []);

  return (

        <AgGridReact
          ref={gridRef}
          columnDefs={columnDefs}
          defaultColDef={defaultColDef}
         // pagination
          // paginationPageSize={20}
          domLayout="autoHeight"
          rowModelType="serverSide"
          onGridReady={onGridReady}
      />

  );
};

AgGridComponent.propTypes = {
  rowData: PropTypes.array,
  columnDefs: PropTypes.array,
};

AgGridComponent.defaultProps = {
  rowData: [],
  columnDefs: [],
};```

export default AgGridCmp;

Don't need local filter or sort everything, need to be done through server side.

Not looking for infinite pagination, using traditional one only.

Body:
Need working example of implementing server side filter and sort on each column in react AG-grid.

With below sample code - am not able to capture filter or sorting value to use it for server side request(api call).

import React, {
  useCallback,
  useEffect,
  useMemo,
  useRef,
  useState,
} from 'react';
import PropTypes from 'prop-types';
import { AgGridReact} from 'ag-grid-react';
import 'ag-grid-enterprise';
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';

function createServerSideDatasource(rowData) {
  return {
    getRows(params) {
       const { startRow, endRow, filterModel, sortModel } =
        params.request;
      params.successCallback(rowData, 500);

    },
  };
}

const AgGridComponent = props => {
  const gridRef = useRef();
  const { rowData, columnDefs } = props;

  const gridStyle = useMemo(
    () => ({ height: '100%', width: '100%' }),
    []
  );

  const defaultColDef = useMemo(
    () => ({
      filter: true,
      floatingFilter: true,
      sortable: true,
      enableServerSideSorting: true,
      enableServerSideFilter: true,
    }),
    []
  );

  const onGridReady = useCallback(params => {
    const columnToolPanel =
      params.api.getToolPanelInstance('columns');
    columnToolPanel.collapseColumnGroups();
    params.api.closeToolPanel();

    const datasource = createServerSideDatasource(rowData);
    params.api.setServerSideDatasource(datasource);
  }, []);

  return (

        <AgGridReact
          ref={gridRef}
          columnDefs={columnDefs}
          defaultColDef={defaultColDef}
         // pagination
          // paginationPageSize={20}
          domLayout="autoHeight"
          rowModelType="serverSide"
          onGridReady={onGridReady}
      />

  );
};

AgGridComponent.propTypes = {
  rowData: PropTypes.array,
  columnDefs: PropTypes.array,
};

AgGridComponent.defaultProps = {
  rowData: [],
  columnDefs: [],
};

export default AgGridCmp;

Don't need local filter or sort everything, need to be done through server side.

Not looking for infinite pagination, using traditional one only.


问:
Is there a way to filter on each value (e.g. seperated by semicolon or comma) within a "list" in a single cell?
I am trying to filter on each person within a "list" of people in a single cell, so I can choose a person a see what reports they receive. The problem is, when I use the filter function, I can only choose the entire cell, not each value in the cell (see example below). Is there any way to filter on each value in a single cell, without separating the values into multiple cells?

Small example of problem

I have tried separating the values in the cell with semicolon, commas, and tabs, but nothing seems to work. I hope it is possible without dividing the cell into multiple cells.


问:
android java how to access welcome image and video when restarting the device?
I have android box mbox and when I turn on the box it show at first 10 seconds one video or GIF image like welcoming the user to the android system, then the main menu is showing after that.
My question is how can I access this video or welcome GIF to change it ? i need to override this with another one
Hope someone get what i need exactly</p>


问:
Tie destinations to menu items, from fragment
This guide explains how to use NavigationComponent to make it easier to use the menu in the toolbar. All great when it comes to Activity but, how can I do the same thing with a fragment?

My project has 3 fragments: Login,Map,Settings.

The Login fragment has no toolbar, so the rest all have a custom toolbar.

The Map fragment has in the toolbar the menu that server to reach the Settings fragment.

This is how I added the toolbar in my Map fragment:

```<code> private void setupToolbar(View view) {
        mNavController = Navigation.findNavController(view);
        AppBarConfiguration appBarConfiguration =
                new AppBarConfiguration.Builder(R.id.settingsFragment, R.id.mapsFragment).build();
        NavigationUI.setupWithNavController(
                mToolbar, mNavController, appBarConfiguration);
    }
    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        return NavigationUI.onNavDestinationSelected(item, mNavController)
                || super.onOptionsItemSelected(item);
    }

    @Override
    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
        inflater.inflate(R.menu.main_menu, menu);
    }
</code>```

Obviously i call setHasOptions(true) inside the OnCreateView of the Map fragment.

The setUpToolbar method is called inside the OnViewCreate of the Map fragment.

This code allows me to show the toolbar inside the Map fragment but what it doesn't allow me to do is to reach (Using the navigation component) the settings fragment by clicking on the menu.

And, yes, the menu id is the same as the fragment name.

Solved

The call to the setSupportActionBar method in the onCreateView of the Map fragment was missing

```<code> @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container,
                             Bundle savedInstanceState) {
        binding = FragmentMapsBinding.inflate(inflater, container, false);

        ((AppCompatActivity) requireActivity()).setSupportActionBar(binding.toolbar);
        setHasOptionsMenu(true);
        return binding.getRoot();
    }
</code>```

Body:
This guide explains how to use NavigationComponent to make it easier to use the menu in the toolbar. All great when it comes to Activity but, how can I do the same thing with a fragment?

My project has 3 fragments: Login,Map,Settings.

The Login fragment has no toolbar, so the rest all have a custom toolbar.

The Map fragment has in the toolbar the menu that server to reach the Settings fragment.

This is how I added the toolbar in my Map fragment:

 private void setupToolbar(View view) {
        mNavController = Navigation.findNavController(view);
        AppBarConfiguration appBarConfiguration =
                new AppBarConfiguration.Builder(R.id.settingsFragment, R.id.mapsFragment).build();
        NavigationUI.setupWithNavController(
                mToolbar, mNavController, appBarConfiguration);
    }
    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        return NavigationUI.onNavDestinationSelected(item, mNavController)
                || super.onOptionsItemSelected(item);
    }

    @Override
    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
        inflater.inflate(R.menu.main_menu, menu);
    }

Obviously i call setHasOptions(true) inside the OnCreateView of the Map fragment.

The setUpToolbar method is called inside the OnViewCreate of the Map fragment.

This code allows me to show the toolbar inside the Map fragment but what it doesn't allow me to do is to reach (Using the navigation component) the settings fragment by clicking on the menu.

And, yes, the menu id is the same as the fragment name.

Solved

The call to the setSupportActionBar method in the onCreateView of the Map fragment was missing

 @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container,
                             Bundle savedInstanceState) {
        binding = FragmentMapsBinding.inflate(inflater, container, false);

        ((AppCompatActivity) requireActivity()).setSupportActionBar(binding.toolbar);
        setHasOptionsMenu(true);
        return binding.getRoot();
    }


问:
How to shift cursor position in a text using javascript
How to shift the cursor position:

For example: if the cursor is at the last letter of the word the how to shift it to the middle or any other place in that word?

I am working on a text editor, so i need it.


问:
Get a URL that will load ajax content of a packed solution
I have a packaged web application with multiple ajax calls that will load html content in the middle of the website.

Is there a way to go directly to one of the ajax calls from the URL instead of manually clicking the buttons to reach the required content on the page immediately?

As a sample, i want to show the content of this page like i clicked the button without clicking it using JavaScript, jQuery, or manual click.

https://www.w3schools.com/xml/tryit.asp?filename=tryajax_first


问:
how to print invalid characters using DB2 SQL Query
I have a XML column in my db2 table, some XML's having invalid characters.

how to print invalid characters using DB2 SQL Query

Error : Invalid XML character (Unicode: 0x2)

XML having non ascii characters


问:
Traefik IngressRoute multiple TLS certificates not possible?
Learning about how to connect my 2 domains (foo.com, bar.com) to a VPS with on it a single node K3s cluster.

Completely new to this I concluded I need for each domain a TLS certificate. I read about DNS.01 challenge but that is for sub domains like blog.foo.com and foo.com.

Using K3s, Traefik is adviced, cert-manager with let's encrypt is the free option.

First question
Am i correct so far?

Going further, I was reading about how to implement a TLS certificate in my IngressRoute (not kind:Ingress) and it looks there is only 1 TLS option in an IngressRoute. Next bit is of the Traefik website

```<code>tls:                              # [11]
  secretName: supersecret         # [12]
  options:                        # [13]
    name: opt                     # [14]
    namespace: default            # [15]
  certResolver: foo               # [16]
  domains:                        # [17]
  - main: example.net             # [18]
    sans:                         # [19]
    - a.example.net
    - b.example.net
</code>```

Second question Do I then need multiple IngressRoute files? (not sure if this is possible)

What I have so far is a simple IngressRoute file with 3 rules (foo.com, foo.com/api, bar.com) and this works when I curl to them.

Extra question Is my plan missing something? I can curl on the VPS and in a normal browser the domain is routing to a missing certificate page, so the only thing left is TLS?

Body:
Learning about how to connect my 2 domains (foo.com, bar.com) to a VPS with on it a single node K3s cluster.

Completely new to this I concluded I need for each domain a TLS certificate. I read about DNS.01 challenge but that is for sub domains like blog.foo.com and foo.com.

Using K3s, Traefik is adviced, cert-manager with let's encrypt is the free option.

First question
Am i correct so far?

Going further, I was reading about how to implement a TLS certificate in my IngressRoute (not kind:Ingress) and it looks there is only 1 TLS option in an IngressRoute. Next bit is of the Traefik website

tls:                              # [11]
  secretName: supersecret         # [12]
  options:                        # [13]
    name: opt                     # [14]
    namespace: default            # [15]
  certResolver: foo               # [16]
  domains:                        # [17]
  - main: example.net             # [18]
    sans:                         # [19]
    - a.example.net
    - b.example.net

Second question Do I then need multiple IngressRoute files? (not sure if this is possible)

What I have so far is a simple IngressRoute file with 3 rules (foo.com, foo.com/api, bar.com) and this works when I curl to them.

Extra question Is my plan missing something? I can curl on the VPS and in a normal browser the domain is routing to a missing certificate page, so the only thing left is TLS?


问:
How do I connect onto const in HTML Javascript within Google Apps Script to Code.gs?
Using Google Apps Script, I am wondering how do I connect the document/chart.gs onto the html? Since the place I wanted to connect, is on here to boot.

```<code>const ctx = document.getElementById('Daily Total Jobs and Applicants - Wage w/o Break per Day2Day.');

    const labels = [1,2,3,4,5,6,7];
    // create random Data
    const helpData1 = labels.map( _ => Math.random() * 5000);
    const helpData2 = labels.map( _ => Math.random() * 1000);
    const helpData3 = labels.map( _ => Math.random() * 1000);
    const helpData4 = labels.map( _ => Math.random() * 1000);
</code>```

The tutorial never mentioned on const when connecting html to chart.gs so I'm wondering on if its possible.

```<code>//     Add this at the end fo <script> tag
    var ctx = document.getElementById('histogram');
    // // If you want test this locally, you should replace above line with something like this:
    // var HISTOGRAM = [{"x":"Clear", "y":501.0}, {"y":193.0, "x":"Clouds"}, {"y":2.0, "x":"Drizzle"}, {"x":"Fog", "y":3.0}, {"x":"Mist", "y":17.0}, {"y":4.0, "x":"Rain"}, {"y":2.0, "x":"Snow"}];
    var HISTOGRAM = JSON.parse(<?= JSON.stringify(getHistogramData()); ?>);
</code>```

[Tutorial in question](https://netlabe.com/how-to-create-dashboard-for-free-with-google-sheets-and-chart-js-8c319ab8809b Tutorial in question) Do I just connect it through const or?

Body:
Using Google Apps Script, I am wondering how do I connect the document/chart.gs onto the html? Since the place I wanted to connect, is on here to boot.

const ctx = document.getElementById('Daily Total Jobs and Applicants - Wage w/o Break per Day2Day.');

    const labels = [1,2,3,4,5,6,7];
    // create random Data
    const helpData1 = labels.map( _ => Math.random() * 5000);
    const helpData2 = labels.map( _ => Math.random() * 1000);
    const helpData3 = labels.map( _ => Math.random() * 1000);
    const helpData4 = labels.map( _ => Math.random() * 1000);

The tutorial never mentioned on const when connecting html to chart.gs so I'm wondering on if its possible.

//     Add this at the end fo


问:
Replace WCF NetNamedPipeBinding
I'm using a WCF service with NetNamedPipeBinding for IPC. This prevents the code to be updated to .Net 7 so I want to replace the WCF server with a client compatible solution. I can't afford breaking changes, so replacing server and client with sth else is no option.

Getting the windows name of the named pipe works

```<code>//localhost replaced by + or *, capitals, trailing slash
string normalizedName = "net.pipe://+/SOME/PATH/";
var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(normalizedName));
string namedPipeMMFName = string.Format(@"Global\net.pipe:E{0}", base64);
</code>```

For the server

```<code>mmf = MemoryMappedFile.CreateOrOpen(namedPipeMMFName, 20, MemoryMappedFileAccess.ReadWrite);
{
    using (var accessor = mmf.CreateViewAccessor(0, 20, MemoryMappedFileAccess.Write))
    {
        //Reverse engineered. Meaning unclear
        accessor.Write(0, 1);
        accessor.Write(1, 0);
        accessor.Write(2, 0);
        accessor.Write(3, 0);

        Guid pipeGuid = Guid.NewGuid();

        accessor.Write<Guid>(4, ref pipeGuid);
        retVal = pipeGuid.ToString();
    }
}
</code>```

For the client

```<code>using (var mmf = MemoryMappedFile.OpenExisting(namedPipeMMFName, MemoryMappedFileRights.Read))
{
    using (var accessor = mmf.CreateViewAccessor(4, 16, MemoryMappedFileAccess.Read))
    {
        accessor.Read(0, out Guid pipeGuid);
        retVal = pipeGuid.ToString();
    }
}
</code>```

The server now looks like that

```<code>var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.InOut, maxNumberOfServerInstances, PipeTransmissionMode.Message, PipeOptions.Asynchronous);
pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, null);
</code>```

When the client (WCF!) opens the connection the new server recognizes it and begins to read.

After calling EndRead() I get the first result

```<code>"\0\u0001\0\u0001\u0002\u0002\u0019net.pipe://localhost/IF13\u0003\b\f"
</code>```

which looks like sth from the client. Further read calls result in no data as if the pipe was closed by the client

I expect that WCF client requires some kind of hand shake.

What do I have to answer after the first successful read?

Thanks
Tom

Title: Replace WCF NetNamedPipeBinding

Body:
I'm using a WCF service with NetNamedPipeBinding for IPC. This prevents the code to be updated to .Net 7 so I want to replace the WCF server with a client compatible solution. I can't afford breaking changes, so replacing server and client with sth else is no option.

Getting the windows name of the named pipe works

//localhost replaced by + or *, capitals, trailing slash
string normalizedName = "net.pipe://+/SOME/PATH/";
var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(normalizedName));
string namedPipeMMFName = string.Format(@"Global\net.pipe:E{0}", base64);

For the server

mmf = MemoryMappedFile.CreateOrOpen(namedPipeMMFName, 20, MemoryMappedFileAccess.ReadWrite);
{
    using (var accessor = mmf.CreateViewAccessor(0, 20, MemoryMappedFileAccess.Write))
    {
        //Reverse engineered. Meaning unclear
        accessor.Write(0, 1);
        accessor.Write(1, 0);
        accessor.Write(2, 0);
        accessor.Write(3, 0);

        Guid pipeGuid = Guid.NewGuid();

        accessor.Write<Guid>(4, ref pipeGuid);
        retVal = pipeGuid.ToString();
    }
}

For the client

using (var mmf = MemoryMappedFile.OpenExisting(namedPipeMMFName, MemoryMappedFileRights.Read))
{
    using (var accessor = mmf.CreateViewAccessor(4, 16, MemoryMappedFileAccess.Read))
    {
        accessor.Read(0, out Guid pipeGuid);
        retVal = pipeGuid.ToString();
    }
}

The server now looks like that

var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.InOut, maxNumberOfServerInstances, PipeTransmissionMode.Message, PipeOptions.Asynchronous);
pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, null);

When the client (WCF!) opens the connection the new server recognizes it and begins to read.

After calling EndRead() I get the first result

"\0\u0001\0\u0001\u0002\u0002\u0019net.pipe://localhost/IF13\u0003\b\f"

which looks like sth from the client. Further read calls result in no data as if the pipe was closed by the client

I expect that WCF client requires some kind of hand shake.

What do I have to answer after the first successful read?

Thanks
Tom


问:
Unable to Mock Static /private methods with JUnit5 as PowerMockito is not supported to JUnit5
We are planning to use Junit4 ,Mockito and Powermockito for testing purpose.
FrameWork Functionality
Junit4- : For running test case.
Powermockito - Allow us to mock private , protected methods of a class.
Mockito - : To mock static classes.

We wanted to use Junit5 with PowerMockito -:

Junit5 -  It allows multiple runners to work simultaneously as compared to Junit4. It uses java 8 features.
But as per the resource we found Junit5 and PowerMockito cannot be used together.
As we have old Legacy code so there might be some scenario where we might need PowerMockito Framework.

Want to use Junit5 with PowerMockito or without PowerMockito but want to resolve mocking problems coming while mocking private static method


问:
How Can File Download without using File saver in Angular
I used below code to download file using Angular. But I need to download that file without using npm file saver.. Is it possible for Angular file downloading?
Can I download a file without using npm file saver in angular?</p>
```<code> saveAsPDF() {

   this.http.get("/Home/SavePDF", { responseType: 'blob' }).subscribe(blob => {
    saveAs(blob, 'Test.pdf', {
      type: 'text/plain;
    });
      console.log("success")
    },
    error => {
     console.log("error")

  });}
</code>```

Body:
I used below code to download file using Angular. But I need to download that file without using npm file saver.. Is it possible for Angular file downloading?
Can I download a file without using npm file saver in angular?

 saveAsPDF() {

   this.http.get("/Home/SavePDF", { responseType: 'blob' }).subscribe(blob => {
    saveAs(blob, 'Test.pdf', {
      type: 'text/plain;
    });
      console.log("success")
    },
    error => {
     console.log("error")

  });}


问:
How would I be able to have this section of code re-check X,Y and run again based off that data?
```<code>from src.common import config, settings, utils
import time
import math
from src.routine.components import Command
from src.common.vkeys import press, key_down, key_up

</code>```
```<code>class Adjust(Command):
    """Fine-tunes player position using small movements."""

    def __init__(self, x, y, max_steps=5):
        super().__init__(locals())
        self.target = (float(x), float(y))
        self.max_steps = settings.validate_nonnegative_int(max_steps)

    def main(self):
        counter = self.max_steps
        toggle = True
        error = utils.distance(config.player_pos, self.target)
        while config.enabled and counter > 0 and error > settings.adjust_tolerance:
            if toggle:
                d_x = self.target[0] - config.player_pos[0]
                threshold = settings.adjust_tolerance / math.sqrt(2)
                if abs(d_x) > threshold:
                    walk_counter = 0
                    if d_x < 0:
                        key_down('left')
                        while config.enabled and d_x < -1 * threshold and walk_counter < 60:
                            time.sleep(0.05)
                            walk_counter += 1
                            d_x = self.target[0] - config.player_pos[0]
                        key_up('left')
                    else:
                        key_down('right')
                        while config.enabled and d_x > threshold and walk_counter < 60:
                            time.sleep(0.05)
                            walk_counter += 1
                            d_x = self.target[0] - config.player_pos[0]
                        key_up('right')
                    counter -= 1
            else:
                d_y = self.target[1] - config.player_pos[1]
                if abs(d_y) > settings.adjust_tolerance / math.sqrt(2):
                    if d_y < 0:
                        time.sleep(0.25)
                        press(Key.ROPE, 1, up_time=0.1)
                        time.sleep(2)
#                        press(Key.JUMP, 1, up_time=0.1)
#                        time.sleep(0.175)
#                        UpJump('up').main()
                    else:
                        key_down('down')
                        time.sleep(0.05)
                        press(Key.JUMP, 3, down_time=0.1)
                        key_up('down')
                        time.sleep(0.5)
                    counter -= 1
            error = utils.distance(config.player_pos, self.target)
            toggle = not toggle

</code>```

This section of code is from a bot i'm working on for a game, essentially. The bot checks my X and Y and will make my character move left or right to adjust for an X,Y I give it. The issue with this is if I over-jump the target, since my character walks through the correct (X,Y) while overshooting, it will consider itself as done.

I want it to sleep for a second or two after running once, then recheck my (X,Y) and rerun if needed to avoid overshooting.

I've been trying for a while, and want to avoid just running the same thing tons of times

Body:
from src.common import config, settings, utils
import time
import math
from src.routine.components import Command
from src.common.vkeys import press, key_down, key_up

class Adjust(Command):
    """Fine-tunes player position using small movements."""

    def __init__(self, x, y, max_steps=5):
        super().__init__(locals())
        self.target = (float(x), float(y))
        self.max_steps = settings.validate_nonnegative_int(max_steps)

    def main(self):
        counter = self.max_steps
        toggle = True
        error = utils.distance(config.player_pos, self.target)
        while config.enabled and counter > 0 and error > settings.adjust_tolerance:
            if toggle:
                d_x = self.target[0] - config.player_pos[0]
                threshold = settings.adjust_tolerance / math.sqrt(2)
                if abs(d_x) > threshold:
                    walk_counter = 0
                    if d_x < 0:
                        key_down('left')
                        while config.enabled and d_x < -1 * threshold and walk_counter < 60:
                            time.sleep(0.05)
                            walk_counter += 1
                            d_x = self.target[0] - config.player_pos[0]
                        key_up('left')
                    else:
                        key_down('right')
                        while config.enabled and d_x > threshold and walk_counter < 60:
                            time.sleep(0.05)
                            walk_counter += 1
                            d_x = self.target[0] - config.player_pos[0]
                        key_up('right')
                    counter -= 1
            else:
                d_y = self.target[1] - config.player_pos[1]
                if abs(d_y) > settings.adjust_tolerance / math.sqrt(2):
                    if d_y < 0:
                        time.sleep(0.25)
                        press(Key.ROPE, 1, up_time=0.1)
                        time.sleep(2)
#                        press(Key.JUMP, 1, up_time=0.1)
#                        time.sleep(0.175)
#                        UpJump('up').main()
                    else:
                        key_down('down')
                        time.sleep(0.05)
                        press(Key.JUMP, 3, down_time=0.1)
                        key_up('down')
                        time.sleep(0.5)
                    counter -= 1
            error = utils.distance(config.player_pos, self.target)
            toggle = not toggle

This section of code is from a bot i'm working on for a game, essentially. The bot checks my X and Y and will make my character move left or right to adjust for an X,Y I give it. The issue with this is if I over-jump the target, since my character walks through the correct (X,Y) while overshooting, it will consider itself as done.

I want it to sleep for a second or two after running once, then recheck my (X,Y) and rerun if needed to avoid overshooting.

I've been trying for a while, and want to avoid just running the same thing tons of times


问:
Change style of dropdown list
Anyone has any solution to remove borders oon options in a dropdown list.
Im about to create this view:

The code i tried is below

https://stackblitz.com/edit/angular-ivy-jfauvw?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.css

Saw lots of codes that use Jquery but this is not possible in my project.

Title: Change style of dropdown list


问:
Docker in Docker in Gitlab runner : entrypoint.sh no such file in directory
I am running a gitlab runner to validate unit test for my project, which uses Docker Compose ( a mariadb and a nodejs container). When running docker compose locally, everything works as expected, however when the CI is launched, files cannot be found. I get the following error:

```<code>server-nodejs-1   | sh: can't open 'entrypoint.sh': No such file or directory
</code>```

Furthermore, the mariadb container is supposed to run every *.sql files in ./docker-entrypoint-startdb.d yet this directory is empty when I run docker-compose exec -T mariadb ls -al docker-entrypoint-startdb.d (both entrypoint.sh and every *.sql files are contained in the repository that triggers the CI).

This is the first time I try to setup a Docker in Docker, so I am by no means expert, I have seen other issues somewhat related to my problem yet they seem a little different.

My gitlab runner config is the following :

[[runners]]
  name = "boj-arch"
  url = "https://gitlab.sfa.univ-poitiers.fr/"
  id = 7
  token = "<...>"
  token_obtained_at = 2022-11-23T11:05:54Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    Insecure = true
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
  [runners.machine]
    IdleCount = 3
    IdleScaleFactor = 0.0
    IdleCountMin = 0
    MachineDriver = ""
    MachineName = "boj-arch"
```
<p>The <code>gitlab-ci.yml</code> :</p>
<pre class="lang-yaml prettyprint-override"><code>stages:
  - build

variables:
  DOCKER_TLS_CERTDIR: ""

# install docker-compose
before_script:
  - export CRYPTOGRAPHY_DONT_BUILD_RUST=1
  - apk update
  - apk add py-pip rust cargo python3-dev libffi-dev openssl-dev gcc libc-dev make
  - pip install docker-compose

build-compose:
  image: docker:latest
  stage: build
  services:
    - docker:dind
  variables:
    ALLOW_EMPTY_PASSWORD: "yes"
    MARIADB_USER: "<...>"
    MARIADB_PASSWORD: "<...>"
    MARIADB_DATABASE: "<...>"
  script:
    - docker-compose up -d
    - sleep 30
    - docker-compose logs
    - docker-compose down # launch tests there or whatever
</code>```

And the docker-compose.yml :

version: '2'

services:

  nodejs:
    image: "node:current-alpine"
    user: "node"
    working_dir: /home/node/app
    environment:
      - NODE_ENV=dev
    volumes:
      - ./nodejs:/home/node/app
    ports:
      - "8081:8081"
    command: "sh entrypoint.sh"

  mariadb:
    image: docker.io/bitnami/mariadb:latest
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=<...>
      - MARIADB_PASSWORD=<...>
      - MARIADB_DATABASE=<...>
    ports:
      - '3306:3306'
    healthcheck:
      test: mysqladmin -u$${MARIADB_USER} -p$${MARIADB_PASSWORD} ping -h localhost
      start_period: 20s
      timeout: 10s
      retries: 5
      interval: 5s
    volumes:
      - ./database/mariadb:/docker-entrypoint-startdb.d

```
<p>Note: the repository has the following architecture :</p>
<pre class="lang-bash prettyprint-override"><code>.
├── docker-compose.yml
├── database
│   └── mariadb # contains *.sql files required at launch
└── nodejs
    ├── entrypoint.sh
    ├── package-lock.json
    ├── package.json
    ├── src
    └── test
</code>```

As the expected behaviour is not the same as the actual behaviour (files not passed to the docker), I'm wondering what is the cause thus where to look to fix this issue.

In order to diagnose the problem, i ran the docker-compose in local, which doesn't encounter the same issue. I also added debug ls -l in the gitlab-ci.yml after docker-compose up -d to better understand the problem, eg :

$ docker-compose exec -T mariadb ls -al docker-entrypoint-startdb.d
total 8
drwxr-xr-x 2 root root 4096 Dec 20 21:29 .
drwxr-xr-x 1 root root 4096 Dec 21 14:25 ..
```

Body:
I am running a gitlab runner to validate unit test for my project, which uses Docker Compose ( a mariadb and a nodejs container). When running docker compose locally, everything works as expected, however when the CI is launched, files cannot be found. I get the following error:

server-nodejs-1   | sh: can't open 'entrypoint.sh': No such file or directory

Furthermore, the mariadb container is supposed to run every *.sql files in ./docker-entrypoint-startdb.d yet this directory is empty when I run docker-compose exec -T mariadb ls -al docker-entrypoint-startdb.d (both entrypoint.sh and every *.sql files are contained in the repository that triggers the CI).

This is the first time I try to setup a Docker in Docker, so I am by no means expert, I have seen other issues somewhat related to my problem yet they seem a little different.

My gitlab runner config is the following :

[[runners]]
  name = "boj-arch"
  url = "https://gitlab.sfa.univ-poitiers.fr/"
  id = 7
  token = "<...>"
  token_obtained_at = 2022-11-23T11:05:54Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    Insecure = true
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
  [runners.machine]
    IdleCount = 3
    IdleScaleFactor = 0.0
    IdleCountMin = 0
    MachineDriver = ""
    MachineName = "boj-arch"

The gitlab-ci.yml :

stages:
  - build

variables:
  DOCKER_TLS_CERTDIR: ""

# install docker-compose
before_script:
  - export CRYPTOGRAPHY_DONT_BUILD_RUST=1
  - apk update
  - apk add py-pip rust cargo python3-dev libffi-dev openssl-dev gcc libc-dev make
  - pip install docker-compose

build-compose:
  image: docker:latest
  stage: build
  services:
    - docker:dind
  variables:
    ALLOW_EMPTY_PASSWORD: "yes"
    MARIADB_USER: "<...>"
    MARIADB_PASSWORD: "<...>"
    MARIADB_DATABASE: "<...>"
  script:
    - docker-compose up -d
    - sleep 30
    - docker-compose logs
    - docker-compose down # launch tests there or whatever

And the docker-compose.yml :

version: '2'

services:

  nodejs:
    image: "node:current-alpine"
    user: "node"
    working_dir: /home/node/app
    environment:
      - NODE_ENV=dev
    volumes:
      - ./nodejs:/home/node/app
    ports:
      - "8081:8081"
    command: "sh entrypoint.sh"

  mariadb:
    image: docker.io/bitnami/mariadb:latest
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=<...>
      - MARIADB_PASSWORD=<...>
      - MARIADB_DATABASE=<...>
    ports:
      - '3306:3306'
    healthcheck:
      test: mysqladmin -u$${MARIADB_USER} -p$${MARIADB_PASSWORD} ping -h localhost
      start_period: 20s
      timeout: 10s
      retries: 5
      interval: 5s
    volumes:
      - ./database/mariadb:/docker-entrypoint-startdb.d

Note: the repository has the following architecture :

.
├── docker-compose.yml
├── database
│   └── mariadb # contains *.sql files required at launch
└── nodejs
    ├── entrypoint.sh
    ├── package-lock.json
    ├── package.json
    ├── src
    └── test

As the expected behaviour is not the same as the actual behaviour (files not passed to the docker), I'm wondering what is the cause thus where to look to fix this issue.

In order to diagnose the problem, i ran the docker-compose in local, which doesn't encounter the same issue. I also added debug ls -l in the gitlab-ci.yml after docker-compose up -d to better understand the problem, eg :

$ docker-compose exec -T mariadb ls -al docker-entrypoint-startdb.d
total 8
drwxr-xr-x 2 root root 4096 Dec 20 21:29 .
drwxr-xr-x 1 root root 4096 Dec 21 14:25 ..


问:
Even after upgrading my python library to 3.10 the package is getting installed in 2.7 dir
I am trying to upgrade my python debian package from python2.7 to python3.10. I have upgraded the source code with help of py2to3 library and modified the debian/rules, debian/control with suitable dependencies. But still when I install the package with apt, it is installing under /usr/lib/python2.7/dist-packages/ directory.

My folder structure:

```<code>├── README.md
├── build
│   └── lib
│       └── foo
│           ├── __init__.py
│           ├── foo_func1.py
│           ├── foo_func2.py
│           ├── foo_func3.py
│           ├── tests
│           │   ├── __init__.py
│           │   ├── test1.py
│           │   ├── test2.py
│           │   └── test3.py
├── foo
│   ├── __init__.py
│   ├── foo_func1.py
│   ├── foo_func2.py
│   ├── foo_func3.py
│   ├── tests
│   │   ├── __init__.py
│   │   ├── test1.py
│   │   ├── test2.py
│   │   ├── test3.py
├── foo.egg-info
│   ├── PKG-INFO
│   ├── SOURCES.txt
│   ├── dependency_links.txt
│   ├── entry_points.txt
│   ├── requires.txt
│   └── top_level.txt
├── debian
│   ├── changelog
│   ├── compat
│   ├── control
│   ├── copyright
│   ├── install
│   ├── rules
│   └── source
│       └── format
├── requirements.txt
├── setup.py
├── test-requirements.txt
└── tox.ini
</code>```

My setup.py file

```<code>from setuptools import setup, find_packages

with open('requirements.txt') as f:
    install_requires = f.read().splitlines()

setup(
    name='foo',
    version='0.4',
    python_requires='>=3',
    description='Description',
    author='User1',
    author_email='user@example.com',
    url='http://www.myweb.com',
    packages=find_packages(),
    include_package_data=True,
    license='Apache 2.0',
    install_requires=install_requires,
    entry_points = {
        'console_scripts': ['key=foo.func1:main'],
    },
)
</code>```

My debian/control file

```<code>Source: foo
Section: admin
Priority: optional
Maintainer: User1
Build-Depends: python3-setuptools, python3-all, debhelper (>= 8)
Standards-Version: 3.9.5
Homepage: http://www.user@example.com

Package: foo
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends},
Description: description
</code>```

My debian/rules

```<code>#!/usr/bin/make -f
%:
        dh $@ --with=python3
</code>```

My python --version is 3.10. When I manually run the python setup.py install after pulling the code, the package is getting installed and I am able to import my module in python shell.
But when I install the package via apt get install foo its getting installed in /usr/lib/python2.7/dist-packages/foo directory.
Let me know what am I missing here.

Body:
I am trying to upgrade my python debian package from python2.7 to python3.10. I have upgraded the source code with help of py2to3 library and modified the debian/rules, debian/control with suitable dependencies. But still when I install the package with apt, it is installing under /usr/lib/python2.7/dist-packages/ directory.

My folder structure:

├── README.md
├── build
│   └── lib
│       └── foo
│           ├── __init__.py
│           ├── foo_func1.py
│           ├── foo_func2.py
│           ├── foo_func3.py
│           ├── tests
│           │   ├── __init__.py
│           │   ├── test1.py
│           │   ├── test2.py
│           │   └── test3.py
├── foo
│   ├── __init__.py
│   ├── foo_func1.py
│   ├── foo_func2.py
│   ├── foo_func3.py
│   ├── tests
│   │   ├── __init__.py
│   │   ├── test1.py
│   │   ├── test2.py
│   │   ├── test3.py
├── foo.egg-info
│   ├── PKG-INFO
│   ├── SOURCES.txt
│   ├── dependency_links.txt
│   ├── entry_points.txt
│   ├── requires.txt
│   └── top_level.txt
├── debian
│   ├── changelog
│   ├── compat
│   ├── control
│   ├── copyright
│   ├── install
│   ├── rules
│   └── source
│       └── format
├── requirements.txt
├── setup.py
├── test-requirements.txt
└── tox.ini

My setup.py file

from setuptools import setup, find_packages

with open('requirements.txt') as f:
    install_requires = f.read().splitlines()

setup(
    name='foo',
    version='0.4',
    python_requires='>=3',
    description='Description',
    author='User1',
    author_email='user@example.com',
    url='http://www.myweb.com',
    packages=find_packages(),
    include_package_data=True,
    license='Apache 2.0',
    install_requires=install_requires,
    entry_points = {
        'console_scripts': ['key=foo.func1:main'],
    },
)

My debian/control file

Source: foo
Section: admin
Priority: optional
Maintainer: User1
Build-Depends: python3-setuptools, python3-all, debhelper (>= 8)
Standards-Version: 3.9.5
Homepage: http://www.user@example.com

Package: foo
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends},
Description: description

My debian/rules

#!/usr/bin/make -f
%:
        dh $@ --with=python3

My python --version is 3.10. When I manually run the python setup.py install after pulling the code, the package is getting installed and I am able to import my module in python shell.
But when I install the package via apt get install foo its getting installed in /usr/lib/python2.7/dist-packages/foo directory.
Let me know what am I missing here.


问:
How to handle Concurrence or Multiple Queue in C# Coravel?
At the moment I have event with a queued listener that handle generating payslip-report and sending emails when user clickes on send payslip by mail , everything runs fine but every user has to wait until the current running task is completed before the server starts a new task. Since they can take several minutes to complete this can represent a problem.

How can I execute multiple background tasks at the same time?


问:
Submodule initialization for already clone project android
So we started using gitsubmodule recently in our project.

This is the .gitmodule file generated

```<code>[submodule "ProjectNane"]
    path = ProjectNane
    url = git url
    branch = develop
</code>```

Now the issue is when any developer who has already cloned the repo earlier run the submodule command
"git submodule update --init"
It clones the submodule project to his local but , it points to the initial commit id of the submodule.
It should point latest develop branch.
Why the "git submodule update --init" is not pointing to latest commit and develop branch.

Body:
So we started using gitsubmodule recently in our project.

This is the .gitmodule file generated

[submodule "ProjectNane"]
    path = ProjectNane
    url = git url
    branch = develop

Now the issue is when any developer who has already cloned the repo earlier run the submodule command
"git submodule update --init"
It clones the submodule project to his local but , it points to the initial commit id of the submodule.
It should point latest develop branch.
Why the "git submodule update --init" is not pointing to latest commit and develop branch.


问:
ESC/POS printer device Unable to claim interface
I try to use WebUSB api to connect to print characters to my POS printer with this code:

    <textarea id="printContent"></textarea>
    <input type="submit" onclick="connectAndPrint()" value="Print" />

      Type text into box and click on submit button.

```
</div>
</div>
</p>
<p>The Object of the USBDevice
<img src="https://i.stack.imgur.com/8zSdo.png" alt="enter image description here" /></p>
<p>Why I can't claim the interface eventhought the 'claimed' variable is <code>false</code></p>
<p>The error:</p>
```DOMException: Failed to execute 'claimInterface' on 'USBDevice': Unable to claim interface.
```

Body:
I try to use WebUSB api to connect to print characters to my POS printer with this code:

    <textarea id="printContent"></textarea>
    <input type="submit" onclick="connectAndPrint()" value="Print" />

      Type text into box and click on submit button.

The Object of the USBDevice

Why I can't claim the interface eventhought the 'claimed' variable is false

The error:

DOMException: Failed to execute 'claimInterface' on 'USBDevice': Unable to claim interface.


问:
I have a JS bug when launching a wizard from an action in Odoo 16
The proccess to produce this error is like that: in the tree view I select a record, added an action button when clicked it open a wizard that takes the selected record and when I click on the line of this record this error message came in:

This is a video to see the problem (it’s a custom module).

In the beginning, I thought the bug was because Odoo 16 is not stable yet so I waited and tested every new release but nothing changed.

edit: I found  out that the tree mode view of the many2many field (lines) in wizard form view is the reason of that JS error here is the code of wizard and its view:

```<code>from odoo import models, fields

class LockPlannedMoney(models.TransientModel):
    _name = 'lock.planned.money'
    _description = 'Verrouillage de ligne de trésorerie'

    lines = fields.Many2many('planned.money', string='Lignes')

    def confirm_date(self):
        for line in self.lines:
            line.lock_button()
</code>```

and  this is the form view:

```<code><?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <!--     ================ view  form  peridique ==============    -->
        <record id="lock_planned_money_form_view" model="ir.ui.view">
            <field name="name">lock.planned.money.view</field>
            <field name="model">lock.planned.money</field>
            <field name="arch" type="xml">
                <form>
                    <field name="lines" widget="one2many" mode="tree" nolabel="1" readonly="0">
                        <tree editable="bottom">
                            <field name="label" readonly="1" />
                            <field name="partner_id" readonly="1" />
                            <field name="type_id" readonly="1" />
                            <field name="date" readonly="1" />
                            <field name="predicted_date" readonly="1" />
                            <field name="due_date" />
                            <field name="lock_status" string=" " />
                        </tree>
                    </field>
                    <footer>
                        <button name="confirm_date" string="Confirmer" type="object" class="oe_highlight" />
                        <button special="cancel" string="Annuler" />
                    </footer>
                </form>
            </field>
        </record>

        <!-- Action de Verrouillage-->
        <record id="lock_button_action_wizard" model="ir.actions.act_window">
            <field name="name">Vérrouiller</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">lock.planned.money</field>
            <field name="view_id" ref="lock_planned_money_form_view" />
            <field name="context">{'default_lines': active_ids}</field>
            <field name="binding_model_id" ref="eloapps_cash_flow_forecast.model_planned_money" />
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>
    </data>
</odoo>
</code>```

Body:
The proccess to produce this error is like that: in the tree view I select a record, added an action button when clicked it open a wizard that takes the selected record and when I click on the line of this record this error message came in:

This is a video to see the problem (it’s a custom module).

In the beginning, I thought the bug was because Odoo 16 is not stable yet so I waited and tested every new release but nothing changed.

edit: I found  out that the tree mode view of the many2many field (lines) in wizard form view is the reason of that JS error here is the code of wizard and its view:

from odoo import models, fields

class LockPlannedMoney(models.TransientModel):
    _name = 'lock.planned.money'
    _description = 'Verrouillage de ligne de trésorerie'

    lines = fields.Many2many('planned.money', string='Lignes')

    def confirm_date(self):
        for line in self.lines:
            line.lock_button()

and  this is the form view:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>

        <record id="lock_planned_money_form_view" model="ir.ui.view">
            <field name="name">lock.planned.money.view</field>
            <field name="model">lock.planned.money</field>
            <field name="arch" type="xml">
                <form>
                    <field name="lines" widget="one2many" mode="tree" nolabel="1" readonly="0">
                        <tree editable="bottom">
                            <field name="label" readonly="1" />
                            <field name="partner_id" readonly="1" />
                            <field name="type_id" readonly="1" />
                            <field name="date" readonly="1" />
                            <field name="predicted_date" readonly="1" />
                            <field name="due_date" />
                            <field name="lock_status" string=" " />
                        </tree>
                    </field>

                        <button name="confirm_date" string="Confirmer" type="object" class="oe_highlight" />
                        <button special="cancel" string="Annuler" />

                </form>
            </field>
        </record>

        <record id="lock_button_action_wizard" model="ir.actions.act_window">
            <field name="name">Vérrouiller</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">lock.planned.money</field>
            <field name="view_id" ref="lock_planned_money_form_view" />
            <field name="context">{'default_lines': active_ids}</field>
            <field name="binding_model_id" ref="eloapps_cash_flow_forecast.model_planned_money" />
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>
    </data>
</odoo>


问:
eMMC Enhanced Area configuration on the running system
I am trying to configure my Linux system installed and run from the eMMC MLC drive, and setup second partition to be pSLC.

I have two partitions in the User Area:

p1 - system, including user and root home

p2 - data

I want to configure part of the User Area assigned to the p2 to Enhanced Area.

According mmc-utils documentation, I must use next command:

mmc enh_area set -y OFFSET_KIB SIZE_KIB /dev/mmcblk0
```
<p>I found OFFSET at the <code>/sys/class/block/mmcblk0p10/start</code>:</p>
<pre class="lang-bash prettyprint-override"><code># cat /sys/class/block/mmcblk0p10/start
1318664
</code>```

Start in the 512-bytes blocks, so OFFSET_KIB is 1318664 * 512 / 1024 = 659332.

Size is a whole remain disk size, divided by 2 (MLC - two bits per cell, four states, Enhanced mode limit it by two states 00/11):

# cat /sys/class/block/mmcblk0p10/size
13951224
```
<p>Size also in the 512-bytes blocks, so <code>SIZE_KIB</code> is <code>13951224 * 512 / 1024 / 2 = 3487806</code></p>
<p>After that I did:</p>
<ul>
<li><code>mmc enh_area set -y 659332 3487806 /dev/mmcblk0</code></li>
<li>power cycle (power off a whole board and power on it again)</li>
<li>...</li>
</ul>
<p>And my system is broken. Sound like, all partitions, including p1 lost.</p>
<p>I recreate partitions and reinstall systems. And sounds like, that pSLC mode for the part of the User Area successfuly turned on:</p>
<pre class="lang-bash prettyprint-override"><code>Partitions attribute [PARTITIONS_ATTRIBUTE]: 0x01
Partitioning Setting [PARTITION_SETTING_COMPLETED]: 0x01
 Device partition setting complete
General Purpose Partition Size
 [GP_SIZE_MULT_4]: 0x000000
 [GP_SIZE_MULT_3]: 0x000000
 [GP_SIZE_MULT_2]: 0x000000
 [GP_SIZE_MULT_1]: 0x000000
Enhanced User Data Area Size [ENH_SIZE_MULT]: 0x0001aa
 i.e. 3489792 KiB
Enhanced User Data Start Address [ENH_START_ADDR]: 0x00140000
 i.e. 671088640 bytes offset
</code>```

But I expected, that only p2 will be damaged, So, my questions:

Is it legal to make mmc enh_area set ... on the running system (for the logical disk) and I just make a wrong calculation for the Enhanced area start area and damaging p1? Or does mmc enh_area set ... affect a whole User Data Area partition that cause complete data lost?

If just start position wrong, how to calculate it right?

Thanks for answers!

Body:
I am trying to configure my Linux system installed and run from the eMMC MLC drive, and setup second partition to be pSLC.

I have two partitions in the User Area:

p1 - system, including user and root home

p2 - data

I want to configure part of the User Area assigned to the p2 to Enhanced Area.

According mmc-utils documentation, I must use next command:

mmc enh_area set -y OFFSET_KIB SIZE_KIB /dev/mmcblk0

I found OFFSET at the /sys/class/block/mmcblk0p10/start:

# cat /sys/class/block/mmcblk0p10/start
1318664

Start in the 512-bytes blocks, so OFFSET_KIB is 1318664 * 512 / 1024 = 659332.

Size is a whole remain disk size, divided by 2 (MLC - two bits per cell, four states, Enhanced mode limit it by two states 00/11):

# cat /sys/class/block/mmcblk0p10/size
13951224

Size also in the 512-bytes blocks, so SIZE_KIB is 13951224 * 512 / 1024 / 2 = 3487806

After that I did:

mmc enh_area set -y 659332 3487806 /dev/mmcblk0

power cycle (power off a whole board and power on it again)

...

And my system is broken. Sound like, all partitions, including p1 lost.

I recreate partitions and reinstall systems. And sounds like, that pSLC mode for the part of the User Area successfuly turned on:

Partitions attribute [PARTITIONS_ATTRIBUTE]: 0x01
Partitioning Setting [PARTITION_SETTING_COMPLETED]: 0x01
 Device partition setting complete
General Purpose Partition Size
 [GP_SIZE_MULT_4]: 0x000000
 [GP_SIZE_MULT_3]: 0x000000
 [GP_SIZE_MULT_2]: 0x000000
 [GP_SIZE_MULT_1]: 0x000000
Enhanced User Data Area Size [ENH_SIZE_MULT]: 0x0001aa
 i.e. 3489792 KiB
Enhanced User Data Start Address [ENH_START_ADDR]: 0x00140000
 i.e. 671088640 bytes offset

But I expected, that only p2 will be damaged, So, my questions:

Is it legal to make mmc enh_area set ... on the running system (for the logical disk) and I just make a wrong calculation for the Enhanced area start area and damaging p1? Or does mmc enh_area set ... affect a whole User Data Area partition that cause complete data lost?

If just start position wrong, how to calculate it right?

Thanks for answers!


问:
How to get an rgl plot output under Ubuntu 22.04?
When plotting something with the rgl package for R on an Ubuntu 22.04 LTS machine, how can I get any plot output?

When I run a plot command, I am not getting any plot window or visual output. E.g., the README of rgl suggests the following to run a demo:

```<code>library("rgl")
demo("rgl")
</code>```

but it shows no plot windows when I browse through the demos (by hitting return several times). All I get is text in the R console.

What I have tried:

I noticed the following during the rgl package installation:

```<code>install.packages("rgl")
</code>```

This completes without error, but I get the following message during the configure phase of the build process:

```<code>checking for X... no
configure: WARNING: X11 not found, continuing without OpenGL support.
</code>```

and if I load rgl afterwards, using library(rgl), you get a notice:

```<code> library(rgl)
This build of rgl does not include OpenGL functions.  Use
 rglwidget() to display results, e.g. via options(rgl.printRglwidget = TRUE).
</code>```

If I follow the advice given there, i.e., first run options(rgl.printRglwidget = TRUE); demo(rgl);, then it opens one tab in my browser (firefox) per demo, and all tabs show File not found errors for temporary files like /tmp/RtmpWqj4zX/viewhtml53511cd8b2f5/index.html..

I am running a graphical user interface, so I found it strange that X11 was not being found, maybe this is because my system is using Wayland: grep -i wayland /etc/gdm3/custom.conf outputs WaylandEnable=true. However, this is pure speculation.

To repeat, my question is, how can I get rgl plot output under Ubuntu 22.04? I would prefer to have an X11 window open, but the browser-based rendering would be better than nothing.

System info:

Ubuntu version (the VERSION of cat /etc/os-release): 22.04.1 LTS (Jammy Jellyfish)

R version (from R --version in shell): 4.1.2 (2021-11-01) -- "Bird Hippie"

rgl version (from packageVersion("rgl") in R): 0.110.2

Note: This is a machine under control of our IT department, I have no root access.

Body:
When plotting something with the rgl package for R on an Ubuntu 22.04 LTS machine, how can I get any plot output?

When I run a plot command, I am not getting any plot window or visual output. E.g., the README of rgl suggests the following to run a demo:

library("rgl")
demo("rgl")

but it shows no plot windows when I browse through the demos (by hitting return several times). All I get is text in the R console.

What I have tried:

I noticed the following during the rgl package installation:

install.packages("rgl")

This completes without error, but I get the following message during the configure phase of the build process:

checking for X... no
configure: WARNING: X11 not found, continuing without OpenGL support.

and if I load rgl afterwards, using library(rgl), you get a notice:

 library(rgl)
This build of rgl does not include OpenGL functions.  Use
 rglwidget() to display results, e.g. via options(rgl.printRglwidget = TRUE).

If I follow the advice given there, i.e., first run options(rgl.printRglwidget = TRUE); demo(rgl);, then it opens one tab in my browser (firefox) per demo, and all tabs show File not found errors for temporary files like /tmp/RtmpWqj4zX/viewhtml53511cd8b2f5/index.html..

I am running a graphical user interface, so I found it strange that X11 was not being found, maybe this is because my system is using Wayland: grep -i wayland /etc/gdm3/custom.conf outputs WaylandEnable=true. However, this is pure speculation.

To repeat, my question is, how can I get rgl plot output under Ubuntu 22.04? I would prefer to have an X11 window open, but the browser-based rendering would be better than nothing.

System info:

Ubuntu version (the VERSION of cat /etc/os-release): 22.04.1 LTS (Jammy Jellyfish)

R version (from R --version in shell): 4.1.2 (2021-11-01) -- "Bird Hippie"

rgl version (from packageVersion("rgl") in R): 0.110.2

Note: This is a machine under control of our IT department, I have no root access.


问:
React-leaflet i cant use styled components in divicon
I need to use styled component for leaflet marker I try the code below but it returns [object Object] as marker icon. How can i solve this? I tried lots of things but i cant use components for react-leaflet marker

```<code>                                        const icon = L.divIcon({
                                        iconAnchor: [10, 10],
                                        html: <StyledDiv
                                        class= {`markerWithId ${
                                          item.last_state
                                            ? "MarkerWithId"
                                            : "MarkerWithId"
                                        }`}
                                        ><p
                                        id="${item.id}"
                                        >${item.order_device}</p></StyledDiv>,
                                    });
</code>```

Body:
I need to use styled component for leaflet marker I try the code below but it returns [object Object] as marker icon. How can i solve this? I tried lots of things but i cant use components for react-leaflet marker

                                        const icon = L.divIcon({
                                        iconAnchor: [10, 10],
                                        html: ,
                                    });


问:
invalid mount config for type "bind": bind source path does not exist:
I've
     - type: bind source: /usr/share/fonts/truetype target: /usr/share/fonts/truetype
On Ubuntu 20.
I've checked and path in host and in docker exists
I used also    privileged: true

Any ideas? I've removed all volumes and add them again.


问:
Vertical Side Bar in ReactJS
I need to build a vertical sidemenu with two levels. One level should be displayed on down of the list item, if the particular list item is clicked and In submenu if another element is clicked particular dropdown should display to right of that element. Now i have done the ui but "I get an error" like clicking on first element its getting displayed but if i click on second element the first element is getting closed. But I need to show both menus. Please Help.
Attaching the code below

In the above image if we click on second element the particular submenu must be displayed and the top menu as well

REACTJS UI IMAGE

In this Image i have should how the ui must look. I have kept an red arrow where if user clicks that particular menu must also need to be displayed.

Title: Vertical Side Bar in ReactJS


问:
Add a new QuickSight Font
Does someone knows if it possible to add new Font in QuickSight ? I have to respect my company chart for report and I can’t find the font I have to use.

I have only 8 Font available in the theme creation menu.

Thanks for your help

Title: Add a new QuickSight Font