问:
Failed to initialize Angular compilation - The target entry-point "@angular/http" has missing dependencies: - rxjs/Observable
I got these errors after deleting and installing nodemodules. I think there is a mismatch of the project angular version and my CLI version.

```<code>./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit

Error: Failed to initialize Angular compilation - The target entry-point "@angular/http" has missing dependencies:
 - rxjs/Observable
</code>```

Here is what my pacakage.json looks like.

```<code>`{
  "name": "admindashboard",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^14.0.0",
    "@angular/common": "^14.2.12",
    "@angular/compiler": "^14.0.0",
    "@angular/core": "^14.0.0",
    "@angular/forms": "^14.0.0",
    "@angular/platform-browser": "^14.0.0",
    "@angular/platform-browser-dynamic": "^14.0.0",
    "@angular/router": "^14.0.0",
    "@auth0/angular-jwt": "^5.1.0",
    "@types/jwt-decode": "^3.1.0",
    "angular2-jwt": "^0.2.3",
    "bootstrap": "^5.2.3",
    "crypto-js": "^4.1.1",
    "datatables.net": "^1.13.1",
    "datatables.net-buttons": "^2.3.3",
    "datatables.net-buttons-dt": "^2.3.3",
    "datatables.net-dt": "^1.13.1",
    "jquery": "^3.6.1",
    "jszip": "^3.10.1",
    "jwt-decode": "^3.1.2",
    "ngx-bootstrap": "^9.0.0",
    "rxjs": "~7.5.0",
    "rxjs-compat": "^6.6.7",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.0.3",
    "@angular/cli": "^15.0.2",
    "@angular/compiler-cli": "^14.0.0",
    "@types/crypto-js": "^4.1.1",
    "@types/datatables.net": "^1.10.24",
    "@types/datatables.net-buttons": "^1.4.7",
    "@types/jasmine": "~4.0.0",
    "@types/jquery": "^3.5.14",
    "jasmine-core": "~4.1.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.7.2"

  },
  "overrides": {
    "autoprefixer": "10.4.5"
  }
}
`
</code>```

Body:
I got these errors after deleting and installing nodemodules. I think there is a mismatch of the project angular version and my CLI version.

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit

Error: Failed to initialize Angular compilation - The target entry-point "@angular/http" has missing dependencies:
 - rxjs/Observable

Here is what my pacakage.json looks like.

`{
  "name": "admindashboard",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^14.0.0",
    "@angular/common": "^14.2.12",
    "@angular/compiler": "^14.0.0",
    "@angular/core": "^14.0.0",
    "@angular/forms": "^14.0.0",
    "@angular/platform-browser": "^14.0.0",
    "@angular/platform-browser-dynamic": "^14.0.0",
    "@angular/router": "^14.0.0",
    "@auth0/angular-jwt": "^5.1.0",
    "@types/jwt-decode": "^3.1.0",
    "angular2-jwt": "^0.2.3",
    "bootstrap": "^5.2.3",
    "crypto-js": "^4.1.1",
    "datatables.net": "^1.13.1",
    "datatables.net-buttons": "^2.3.3",
    "datatables.net-buttons-dt": "^2.3.3",
    "datatables.net-dt": "^1.13.1",
    "jquery": "^3.6.1",
    "jszip": "^3.10.1",
    "jwt-decode": "^3.1.2",
    "ngx-bootstrap": "^9.0.0",
    "rxjs": "~7.5.0",
    "rxjs-compat": "^6.6.7",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.0.3",
    "@angular/cli": "^15.0.2",
    "@angular/compiler-cli": "^14.0.0",
    "@types/crypto-js": "^4.1.1",
    "@types/datatables.net": "^1.10.24",
    "@types/datatables.net-buttons": "^1.4.7",
    "@types/jasmine": "~4.0.0",
    "@types/jquery": "^3.5.14",
    "jasmine-core": "~4.1.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.7.2"

  },
  "overrides": {
    "autoprefixer": "10.4.5"
  }
}
`


来源: stackexchange

问:
How do i redirect different site visitors based on ip address?
I would like to redirect every user that visited my site to different url each. I'm limiting it to ten sites only though. For example;

When visitor 1 visit my website; www.youarelovely.com it would open.

When visitor 2 visit my website; www.youarelovely.com the visitor would be redirected to www.youarelovely.com/1

When visitor 3 visit my website; www.youarelovely.com the visitor would be redirected to www.youarelovely.com/2 etc... to 10.

I feel by detecting user IP address, storing it in a text file, then getting the next visitor ip address and search it in the list of visitor stored ip address, if it's there then the user would be redirected to that url, if not then the user would be directed to the next available url. How can i achieve it via pure html and javascript?

NOTE: This is for a proof of concept project that would be deployed on github pages or codepen. So basically we're not in the business of complicating things, and it's not location based redirecting because all the visitors would be in the same location, hence why the redirecting solution need to be base on IP address only.

```<code>var defaultCountry = ‘US’;
var defaultSite = ‘https://google.com';
var otherSite = ‘https://google.co.uk';
fetch(‘https://ipapi.co/country/')
 .then(response => {
   if (response.ok) {
     return response.text();
   } else {
     throw new Error(‘HTTP Error ‘ + response.status);
   }
 })
 .then(country => {
   if (country == defaultCountry) {
     // No action needed - already on the default site
     console.log(‘Already on default site’);
   } else {
     // Redirect rest of the world
     console.log(‘Redirecting to country specific website’);
     window.location = otherSite;
   }
 })
 .catch(function(error) {
   // Network error
   // Script blocked by browser extension
   // 429 error (too many requests)
   console.log(error);
 });
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I would like to redirect every user that visited my site to different url each. I'm limiting it to ten sites only though. For example;

When visitor 1 visit my website; www.youarelovely.com it would open.

When visitor 2 visit my website; www.youarelovely.com the visitor would be redirected to www.youarelovely.com/1

When visitor 3 visit my website; www.youarelovely.com the visitor would be redirected to www.youarelovely.com/2 etc... to 10.

I feel by detecting user IP address, storing it in a text file, then getting the next visitor ip address and search it in the list of visitor stored ip address, if it's there then the user would be redirected to that url, if not then the user would be directed to the next available url. How can i achieve it via pure html and javascript?

NOTE: This is for a proof of concept project that would be deployed on github pages or codepen. So basically we're not in the business of complicating things, and it's not location based redirecting because all the visitors would be in the same location, hence why the redirecting solution need to be base on IP address only.

var defaultCountry = ‘US’;
var defaultSite = ‘https://google.com';
var otherSite = ‘https://google.co.uk';
fetch(‘https://ipapi.co/country/')
 .then(response => {
   if (response.ok) {
     return response.text();
   } else {
     throw new Error(‘HTTP Error ‘ + response.status);
   }
 })
 .then(country => {
   if (country == defaultCountry) {
     // No action needed - already on the default site
     console.log(‘Already on default site’);
   } else {
     // Redirect rest of the world
     console.log(‘Redirecting to country specific website’);
     window.location = otherSite;
   }
 })
 .catch(function(error) {
   // Network error
   // Script blocked by browser extension
   // 429 error (too many requests)
   console.log(error);
 });


问:
API call - sp_OAMethod - A certificate is required to complete client authentication - msxml3.dll
```<code>DECLARE @obj INT
DECLARE @sUrl NVARCHAR(200) = 'https:xxxxxxx.com/xxxx'

EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', @sUrl, false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'application/x-www-form-urlencoded'

EXEC sp_OAMethod @obj, 'send'

EXEC sp_OAGetProperty @obj, 'responseText'
</code>```

EXEC sp_OAMethod @obj, 'send' statement in the above code returning the below error.
Help us fix this, please.

Error
Source
Description
HelpFile
HelpID

0x80072F0C
msxml3.dll
A certificate is required to complete client authentication
NULL
0

Body:
DECLARE @obj INT
DECLARE @sUrl NVARCHAR(200) = 'https:xxxxxxx.com/xxxx'

EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', @sUrl, false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'application/x-www-form-urlencoded'

EXEC sp_OAMethod @obj, 'send'

EXEC sp_OAGetProperty @obj, 'responseText'

EXEC sp_OAMethod @obj, 'send' statement in the above code returning the below error.
Help us fix this, please.

Error
Source
Description
HelpFile
HelpID

0x80072F0C
msxml3.dll
A certificate is required to complete client authentication
NULL
0


问:
Pagination with jquery for custom html
I have a problem while creating the pagination for my custom html in WordPress.  I need to create a custom card for each category item and sort them into alphabetical. But I can't find a plugin or some features for creating it. So, I decided to create my own custom html.

The code for pagination that I try didn't work for some reason. Only the sort code works.  I need to use the vanilla script for the pagination. And the result that I want is category items are sort into alphabetical and it shows 5 item per page.

```<code><div class="flowercontainer">
        <div class="flowercard">
            <a href="#" target="_blank" rel="noopener"><div class="card-image rose"></div></a>
            <div class="flowername"><a href="#" target="_blank" rel="noopener">ROSE</a></div>
        </div>
                <div class="flowercard">
            <a href="#" target="_blank" rel="noopener"><div class="card-image jasmine"></div></a>
            <div class="flowername"><a href="#" target="_blank" rel="noopener">JASMINE</a></div>
        </div>
                <div class="flowercard">
            <a href="#" target="_blank" rel="noopener"><div class="card-image orchid"></div></a>
            <div class="flowername"><a href="#" target="_blank" rel="noopener">ORCHID</a></div>
        </div>

<div class="pagination">
    <li class="page-item previous-page disable"><a class="page-link" href="#">Prev</a></li>
    <li class="page-item current-page active"><a class="page-link" href="#">1</a></li>
    <li class="page-item dots"><a class="page-link" href="#">...</a></li>
    <li class="page-item current-page"><a class="page-link" href="#">5</a></li>
    <li class="page-item current-page"><a class="page-link" href="#">6</a></li>
    <li class="page-item dots"><a class="page-link" href="#">...</a></li>
    <li class="page-item current-page"><a class="page-link" href="#">10</a></li>
    <li class="page-item next-page"><a class="page-link" href="#">Next</a></li>
  </div>
<style>
{
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}
.flowercontainer {
    display: flex;
    justify-content: center;
        padding: 15px;
    flex-wrap: wrap;
}
.flowercard {
    background: white;
    width: 220px;
    height: 400px;
    margin: 12px;
    border-radius: 15px;
        outline: #8224e3 solid 5px;
}
.card-image {
    background-color: purple;
    height: 300px;
    margin-bottom: 15px;
    background-size: cover;
    border-radius: 15px 15px 0 0;
}

.flowername {
    padding: 0px;
    color: purple;
    display: inline-flex;
    text-align: center;
        font-size: 20px;
}

.rose {
    background-image: url(rose.jpg);
}
.jasmine {
    background-image: url(jasmine.jpg);
}
.orchid {
    background-image: url(orchid.jpg);
}
</style>
<script src="https://cdnjs.cloudflare.com/h5jax/libs/jquery/3.6.0/jquery.min.js" charset="utf-8"></script>
<script>
    function getPageList(totalPages, page, maxLength){
        function range(start, end){
            return Array.from(Array(end - start + 1), (_, i) => i + start);
        }

        var sideWidth = maxLength < 9 ? 1 : 2 ;
        var leftWidth = (maxLength - sideWidth * 2 - 3) >> 1;
        var rightWidth = (maxLength - sideWidth * 2 - 3) >> 1;

        if (totalPages <= maxLength){
            return range(1, totalPages);
        }

        if (page <= maxLength - sideWidth - 1 - rightWidth){
            return range(1, maxLength - sideWidth - 1).concat(0, range(totalPages - sideWidth + 1, totalPages));
        }

        if (page >= totalPages - sideWidth -1 - rightWidth){
            return range(1, sideWidth).concat(0, range(totalPages - sideWidth - 1 - rightWidth - leftWidth, totalPages));
        }

        return range(1, sideWidth).concat(0, range(page - leftWidth, page + rightWidth), 0, range(totalPages - sideWidth + 1, totalPages));
    }

    $(function(){
        var numberOfItems = $(".flowercontainer .flowercard").length;
        var limitPerPage = 3;
        var totalPages = Math.ceil(numberOfItems / limitPerPage);
        var paginationSize = 4;
        var currentPage;

        function showPage(whichPage){
            if (whichPage < 1 || whichPage > totalPages) return false;

            currentPage = whichPage;

            $(".flowercard").hide().slice((currentPage - 1) * limitPerPage, currentPage * limitPerPage).show();

            $(".pagination li").slice(1, -1).remove();

            getPageList(totalPages, currentPage, paginationSize).forEach(item => {
                $("<li>").addClass("page-item").addClass(item ? "current-page" : "dots")
                .toggleClass("active", item === currentPage).append($("<a>").addClass("page-link")
                    .attr({href: "javascript:void(0)"}).text(item || "...")).insertBefore(".next-page");
            });

            $(".previous-page").toggleClass("disable", currentPage === 1);
            $(".next-page").toggleClass("disable", currentPage === totalPages);
            return true;
        }

        $(".pagination").append(
            $("<li>").addClass("page-item").addClass("previous-page").append($("<a>").addClass("page-link").attr({href: "javascript:void(0)"}).text("Prev")),
            $("<li>").addClass("page-item").addClass("next-page").append($("<a>").addClass("page-link").attr({href: "javascript:void(0)"}).text("Next"))
            );

        $(".flowercard").show();
        showPage(1);

        $(document).on("click", ".pagination li.current-page:not(.active)", function(){
            return showPage(+$(this).text());
        });
    });
</script>
<script>
    const container = document.querySelector(".flowercontainer");
const key = (a) => a.querySelector(".flowername").textContent.trim();

Array.from(container.children)
     .sort((a, b) => key(a).localeCompare(key(b)))
     .forEach(child => container.appendChild(child));
</script>
</code>```

Title: Pagination with jquery for custom html

Body:
I have a problem while creating the pagination for my custom html in WordPress.  I need to create a custom card for each category item and sort them into alphabetical. But I can't find a plugin or some features for creating it. So, I decided to create my own custom html.

The code for pagination that I try didn't work for some reason. Only the sort code works.  I need to use the vanilla script for the pagination. And the result that I want is category items are sort into alphabetical and it shows 5 item per page.

ROSE

JASMINE

ORCHID

Prev

1

...

5

6

...

10

Next


问:
Can't integrate with Algolia DocSearch
I try to integrate with Algolia DocSearch and it doesn't work.
I followed exactly the steps listed here: https://docusaurus.io/docs/search#using-algolia-docsearch but notwhing happend for more then a month.

I created an Algolia account.

Created the Algolia configuration in my site as written in the docs.

Apply my site (for the crawler).

Bought the premium plan so I can create other crawler (but the crawler interface not recognize my App key!).
also, when I try to enter to the crawler admin I'm always got:
"Your Algolia plan does not allow you to access the Crawler.

What did I miss?

Title: Can't integrate with Algolia DocSearch


问:
Draw line shape with length and send length value to JTable
I created three classes: one is Gui class it includes JTable and JButton.

public class Gui {
    public void Gui() {
        JFrame frame = new JFrame();
        String data[][] = {};
        String column[] = {"Bar Mark", "Length"};
        JTable table = new JTable(data, column);
        table.setBounds(0, 0, 500, 500);
        JScrollPane pane = new JScrollPane(table);
        frame.getContentPane().add(BorderLayout.NORTH, pane);
        JButton button = new JButton("Create Rebar");
        frame.getContentPane().add(BorderLayout.SOUTH, button);
        frame.setSize(500, 500);
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                CreateRebar createRebar = new CreateRebar();
                createRebar.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
                JDialog bDialog = new JDialog();
                bDialog.setTitle("Create Rebar");
                bDialog.setPreferredSize(new Dimension(500, 300));
                bDialog.getContentPane().setLayout(new GridBagLayout());
                GridBagConstraints gbc = new GridBagConstraints();
                gbc.insets = new Insets(5, 5, 5, 5);
                gbc.fill = GridBagConstraints.BOTH;
                gbc.weightx = 0.1;
                gbc.weighty = 0.1;
                bDialog.add(createRebar, gbc);
                bDialog.setModal(true);
                bDialog.pack();
                bDialog.setLocationRelativeTo(null);
                bDialog.setVisible(true);
            }
        });
    }

    public static void main(String[] args) {
        Gui gui = new Gui();
        gui.Gui();
    }
}
```
<p><code>CreateRebar</code> is another class and it collects data to send to <code>JTable</code>.</p>
<pre class="lang-java prettyprint-override"><code>public class CreateRebar extends JPanel {
    private ShapeTwenty shapeTwenty = new ShapeTwenty();
    String[] diaSizes = {"20", "32"};
    JComboBox cmbDia = new JComboBox(diaSizes);
    JTextField txtMark = new JTextField(3);
    JLabel lblMark = new JLabel("Add Bar Mark");
    JLabel lblLength = new JLabel("Select Shape");
    JButton addBar = new JButton("Add Rebar");
    public CreateRebar() {
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(lblMark, gbc);
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(lblLength, gbc);
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(txtMark, gbc);
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(cmbDia, gbc);
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(addBar, gbc);
        cmbDia.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String type = (String) cmbDia.getSelectedItem();
                if (type.equals("20")) {
                    shapeTwenty.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
                    JDialog sDialog = new JDialog();
                    sDialog.setTitle("Shape 20");
                    sDialog.setPreferredSize(new Dimension(230, 150));
                    sDialog.getContentPane().setLayout(new GridBagLayout());
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(5, 5, 5, 5);
                    gbc.fill = GridBagConstraints.BOTH;
                    gbc.weightx = 0.1;
                    gbc.weighty = 0.1;
                    sDialog.add(shapeTwenty, gbc);
                    sDialog.setModal(true);
                    sDialog.pack();
                    sDialog.setLocationRelativeTo(null);
                    sDialog.setVisible(true);
                } else if (type.equals("32")) {
                }
            }
        });
        addBar.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ShapeTwenty shapeTwenty = new ShapeTwenty();
                String obj = shapeTwenty.getTxtLength().getText();
                if (txtMark.getText()
                        .isEmpty()) {
                    JOptionPane.showMessageDialog(null, "Add Bar Mark");
                } else {
                    String mark = (String) cmbDia.getSelectedItem();
                    if (mark.equals("20")) {
                        String barMark = txtMark.getText();
                        Object[] row = {barMark, obj};
                        AppUI.addRebar(row);
                    } else if (mark.equals("32")) {
                    }
                }
            }
        });
    }
}
</code>```

ShapeTwenty is another class and it includes line and JTextField.

public class ShapeTwenty extends JPanel {
    private JTextField txtLength = new JTextField(3);

    public ShapeTwenty() {
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        setBorder(BorderFactory.createTitledBorder("20"));
        this.add(txtLength);
        add(txtLength, gbc);
        txtLength.setText("A");
        txtLength.setHorizontalAlignment(SwingConstants.CENTER);
        txtLength.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Window w = SwingUtilities.getWindowAncestor(ShapeTwenty.this);
                w.setVisible(false);
            }
        });
    }

    public JTextField getTxtLength() {
        return txtLength;
    }

    public void setTxtLength(JTextField txtLength) {
        this.txtLength = txtLength;
    }

    @Override
    public Dimension getPreferredSize() {
        return (new Dimension(300, 200));
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setRenderingHints(rh);
        g2.setColor(Color.black);
        g2.setStroke(new BasicStroke(2));
        g2.drawLine(20, 65, 170, 65);
    }
}
```

When Project is running Gui class is open and click on Create Rebar Button, Create Rebar open. After adding
Bar mark as "01" and select Shape 20 in cmbDia, ShapeTwenty open but "txtLength" JTextField is not visible.
I supposed to send Bar mark and length to JTable in Gui class. But due to invisible JTextField my attempt is unsuccessful.

Body:
I created three classes: one is Gui class it includes JTable and JButton.

public class Gui {
    public void Gui() {
        JFrame frame = new JFrame();
        String data[][] = {};
        String column[] = {"Bar Mark", "Length"};
        JTable table = new JTable(data, column);
        table.setBounds(0, 0, 500, 500);
        JScrollPane pane = new JScrollPane(table);
        frame.getContentPane().add(BorderLayout.NORTH, pane);
        JButton button = new JButton("Create Rebar");
        frame.getContentPane().add(BorderLayout.SOUTH, button);
        frame.setSize(500, 500);
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                CreateRebar createRebar = new CreateRebar();
                createRebar.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
                JDialog bDialog = new JDialog();
                bDialog.setTitle("Create Rebar");
                bDialog.setPreferredSize(new Dimension(500, 300));
                bDialog.getContentPane().setLayout(new GridBagLayout());
                GridBagConstraints gbc = new GridBagConstraints();
                gbc.insets = new Insets(5, 5, 5, 5);
                gbc.fill = GridBagConstraints.BOTH;
                gbc.weightx = 0.1;
                gbc.weighty = 0.1;
                bDialog.add(createRebar, gbc);
                bDialog.setModal(true);
                bDialog.pack();
                bDialog.setLocationRelativeTo(null);
                bDialog.setVisible(true);
            }
        });
    }

    public static void main(String[] args) {
        Gui gui = new Gui();
        gui.Gui();
    }
}

CreateRebar is another class and it collects data to send to JTable.

public class CreateRebar extends JPanel {
    private ShapeTwenty shapeTwenty = new ShapeTwenty();
    String[] diaSizes = {"20", "32"};
    JComboBox cmbDia = new JComboBox(diaSizes);
    JTextField txtMark = new JTextField(3);
    JLabel lblMark = new JLabel("Add Bar Mark");
    JLabel lblLength = new JLabel("Select Shape");
    JButton addBar = new JButton("Add Rebar");
    public CreateRebar() {
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(lblMark, gbc);
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(lblLength, gbc);
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(txtMark, gbc);
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(cmbDia, gbc);
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.weightx = 0.1;
        gbc.weighty = 0.1;
        gbc.insets = new Insets(5, 5, 5, 5);
        add(addBar, gbc);
        cmbDia.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String type = (String) cmbDia.getSelectedItem();
                if (type.equals("20")) {
                    shapeTwenty.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
                    JDialog sDialog = new JDialog();
                    sDialog.setTitle("Shape 20");
                    sDialog.setPreferredSize(new Dimension(230, 150));
                    sDialog.getContentPane().setLayout(new GridBagLayout());
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(5, 5, 5, 5);
                    gbc.fill = GridBagConstraints.BOTH;
                    gbc.weightx = 0.1;
                    gbc.weighty = 0.1;
                    sDialog.add(shapeTwenty, gbc);
                    sDialog.setModal(true);
                    sDialog.pack();
                    sDialog.setLocationRelativeTo(null);
                    sDialog.setVisible(true);
                } else if (type.equals("32")) {
                }
            }
        });
        addBar.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ShapeTwenty shapeTwenty = new ShapeTwenty();
                String obj = shapeTwenty.getTxtLength().getText();
                if (txtMark.getText()
                        .isEmpty()) {
                    JOptionPane.showMessageDialog(null, "Add Bar Mark");
                } else {
                    String mark = (String) cmbDia.getSelectedItem();
                    if (mark.equals("20")) {
                        String barMark = txtMark.getText();
                        Object[] row = {barMark, obj};
                        AppUI.addRebar(row);
                    } else if (mark.equals("32")) {
                    }
                }
            }
        });
    }
}

ShapeTwenty is another class and it includes line and JTextField.

public class ShapeTwenty extends JPanel {
    private JTextField txtLength = new JTextField(3);

    public ShapeTwenty() {
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        setBorder(BorderFactory.createTitledBorder("20"));
        this.add(txtLength);
        add(txtLength, gbc);
        txtLength.setText("A");
        txtLength.setHorizontalAlignment(SwingConstants.CENTER);
        txtLength.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Window w = SwingUtilities.getWindowAncestor(ShapeTwenty.this);
                w.setVisible(false);
            }
        });
    }

    public JTextField getTxtLength() {
        return txtLength;
    }

    public void setTxtLength(JTextField txtLength) {
        this.txtLength = txtLength;
    }

    @Override
    public Dimension getPreferredSize() {
        return (new Dimension(300, 200));
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setRenderingHints(rh);
        g2.setColor(Color.black);
        g2.setStroke(new BasicStroke(2));
        g2.drawLine(20, 65, 170, 65);
    }
}

When Project is running Gui class is open and click on Create Rebar Button, Create Rebar open. After adding
Bar mark as "01" and select Shape 20 in cmbDia, ShapeTwenty open but "txtLength" JTextField is not visible.
I supposed to send Bar mark and length to JTable in Gui class. But due to invisible JTextField my attempt is unsuccessful.


问:
Paypal transaction_id of Mass Payout item: is there a set of statuses when it's guaranteed to be undefined?
I use https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts-item_get api to request my payouts through Paypal.

From the documentation it's clear that transaction_id of an item sometimes is undefined. Is there any specific rules when we can say for sure it's not here/undefined?

I.e. can I assume that it depends on the status, i.e. status 'FAILED' would always have it not set?


问:
Can not assign iOS Charts valueFormatter to valueFormatter
I had to update Charts pod because of an xCode update. Now I'm troubling with this funny issue.

```<code>let formatter: AxisValueFormatter = XAxisNameFormater(dates: self.formatedDates)
lineChartView.xAxis.valueFormatter = formatter
</code>```

```<code>      public class XAxisNameFormater: NSObject, AxisValueFormatter {
        var dates:[String] = []

        init(dates: [String]) {
          self.dates = dates
        }

        public func stringForValue(_ value: Double, axis: AxisBase?) -> String {

          if value < 0 {return ""}
          if value == 0.5 {return ""}
          if Int(value) >= self.dates.count {return ""}

          let formatter = DateFormatter()
          formatter.locale = Locale(identifier: "tr")
          formatter.dateFormat = "dd MMM"

          let dateString = formatter.string(from: Date(timeIntervalSince1970: dates[Int(value)].convertToDouble()!))
          return dateString
        }
      }
</code>```

And the error:

How can this be even possible? Any ideas?

Body:
I had to update Charts pod because of an xCode update. Now I'm troubling with this funny issue.

let formatter: AxisValueFormatter = XAxisNameFormater(dates: self.formatedDates)
lineChartView.xAxis.valueFormatter = formatter

      public class XAxisNameFormater: NSObject, AxisValueFormatter {
        var dates:[String] = []

        init(dates: [String]) {
          self.dates = dates
        }

        public func stringForValue(_ value: Double, axis: AxisBase?) -> String {

          if value < 0 {return ""}
          if value == 0.5 {return ""}
          if Int(value) >= self.dates.count {return ""}

          let formatter = DateFormatter()
          formatter.locale = Locale(identifier: "tr")
          formatter.dateFormat = "dd MMM"

          let dateString = formatter.string(from: Date(timeIntervalSince1970: dates[Int(value)].convertToDouble()!))
          return dateString
        }
      }

And the error:

How can this be even possible? Any ideas?


问:
Register / Config center HA solution across DC with replication
We have deployed multiple Java applications (spring boot based) in multiple datacenters. For better centralized management, we decide to register them to a same config / register center (Consul, Eureka, Nacos, ZooKeeper...). How to set up a config / register center with proper HA solution across DC?

I've googled for the solution for:

If a config / register center support HA across DC: Consul support WAN gossip protocol to communicate between datacenters, but no data is replicated (see here), which is not I want. I need all the applications to be connected to the same config / register center cluster.

If a spring boot application support to connect to multiple register / config center: got no result so far.

Can anyone give me some ideas please? Thanks.


问:
Ideas to visualize confidence intervals with multiple lineplots and avoiding confusion
I created a dashboard containing the lineplots of forecast for similar (own + competition) products, which is used by sales people in order to plan their forecasts. The forecasts come with a level of precision. On average there are 8-10 lineplots for each diagram. I would like to visualize the uncertinty intervals as well (to let them know about the scale of uncertainty of different forecasts), but the graph gets very confusing.
Do you have any ideas/good practice on how could I visualize uncertainty of multiple lineplots without creating confusion because of too many expanding uncertainty intervals?
Thank you!</p>


问:
Change the number of CKAN Dataset views
In CKAN, in the process of deleting and reloading a dataset, I want to replace the number of views of the dataset before it was deleted with the number of views (i.e. instead of 0) after deleting and reloading. For example:

Suppose there is a dataset named "example" and this dataset has
already 25 views. When I delete and reload this dataset, I want the
number of views to be 25 instead of 0.

I've looked at the package_patch and package_update action API's so far, but I haven't been able to change the "total" value of the "tracking_summary" parameter in any way.

Any way to change this?

Title: Change the number of CKAN Dataset views


问:
How to Change the button text of Add to cart to Go to cart If the data from local Storage is available and how to set the has duplicate functionality

Below is my code in which I am storing my data if clicked on Add To Cart Button to Local Storage in an array object. But I don't want duplicate id's to store again if clicked again and if the id is stored once then change the text to Go To The Cart

This section shows how I set data to local storage.

```<code>
const [dta, setDta] = React.useState([]);
const { data, cartVar } = props;

React.useEffect(() => {
  setDta(JSON.parse(localStorage.getItem("variants")));
}, []);

const handleAddToCart = (e) => {
  e.preventDefault();
  let newUsers = {
    id: cartVar,
  };
  localStorage.setItem(
    "variants",
    JSON.stringify([...allusers, newUsers])
  );
  setAllusers(allusers.concat(newUsers));
};
</code>```

This Section Shows the Add To Cart Button.

```<code><Button
  style={{ width: "50%" }}
  variant="contained"
  onClick={handleAddToCart}
>
  {cartVar !== dta ? "Add TO CART" : "Go TO CART"}
</Button>
</code>```

In local Storage I am getting an array of objects having repetitive duplicate IDs. How to not set Duplicate IDs?

```<code>:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
1
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjY="}
2
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjY="}
3
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
4
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
5
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
6
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
7
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
8
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
9
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
]

</code>```

Body:
Below is my code in which I am storing my data if clicked on Add To Cart Button to Local Storage in an array object. But I don't want duplicate id's to store again if clicked again and if the id is stored once then change the text to Go To The Cart

This section shows how I set data to local storage.

const [dta, setDta] = React.useState([]);
const { data, cartVar } = props;

React.useEffect(() => {
  setDta(JSON.parse(localStorage.getItem("variants")));
}, []);

const handleAddToCart = (e) => {
  e.preventDefault();
  let newUsers = {
    id: cartVar,
  };
  localStorage.setItem(
    "variants",
    JSON.stringify([...allusers, newUsers])
  );
  setAllusers(allusers.concat(newUsers));
};

This Section Shows the Add To Cart Button.

<Button
  style={{ width: "50%" }}
  variant="contained"
  onClick={handleAddToCart}
>
  {cartVar !== dta ? "Add TO CART" : "Go TO CART"}
</Button>

In local Storage I am getting an array of objects having repetitive duplicate IDs. How to not set Duplicate IDs?

:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
1
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjY="}
2
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjY="}
3
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
4
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
5
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
6
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
7
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
8
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
9
:
{id: "UHJvZHVjdFZhcmlhbnQ6NjU="}
]


问:
How to use lights in Ursina
I'm trying to make a horror type game in Ursina as a small project but I can't figure out how to position the point light. I want the point light to be pointing forward a bit and be at the players position. I practically just want to make a flashlight for my character.

This is the full code at the moment:

```<code>from ursina import *
from random import uniform
from ursina.prefabs.first_person_controller import FirstPersonController
from ursina.shaders import lit_with_shadows_shader
app = Ursina()
player = FirstPersonController(model='cube', color=color.orange, origin_y=-.5, speed=8, position = (-52, 0, 57))
player.collider = BoxCollider(player, Vec3(0,1,0))
player.visible = False
ammo = 10
playerHealth = 100
editor_camera = EditorCamera(enabled=False, ignore_paused=True)
ammoCounter = Text(text= ammo + ammo, position = (-0.4,-0.4), color = color.black)
ttt=PointLight(position= (-52, 0, 57), parent=camera.ui, color = color.rgba(100, 2, 100, 0), rotation = (0, 184, 0), shadows = True)

def update(): ##ammo counter ##
    ammoCounter.text = ammo

def pause_input(key): ##editor camera thing##
    if key == 'tab':    # press tab to toggle edit/play mode
        editor_camera.position = player.position
        editor_camera.rotation = (90,180,0)
        editor_camera.y = 50
        editor_camera.enabled = not editor_camera.enabled
        player.visible =True
        player.visible_self = editor_camera.enabled
        player.cursor.enabled = not editor_camera.enabled
        gun.enabled = not editor_camera.enabled
        mouse.locked = not editor_camera.enabled
        application.paused = editor_camera.enabled
pause_handler = Entity(ignore_paused=True, input=pause_input)

def input(key): ## gunshot, gun, player shift, and ammo crates destroys
    global ammo

    if key == "2":
        ttt.color = color.black

    if key == "1":
        ttt.color = color.white

    ## destroy ammo crates##
    if key == 'e':
        if mouse.hovered_entity == ammo1:
            if distance(player, ammo1) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo1)
                except:
                    print("ammo box issue")
        if mouse.hovered_entity == ammo2:
            if distance(player, ammo2) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo2)
                except:
                    print("ammo box issue")
        if mouse.hovered_entity == ammo3:
            if distance(player, ammo3) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo3)
                except:
                    print("ammo box issue")
        if mouse.hovered_entity == ammo4:
            if distance(player, ammo4) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo4)
                except:
                    print("ammo box issue")

    if key == 'k':
        print (player.position)
        print (player.rotation)
        print (ammo)
        print (ttt.position)

    if key=="left mouse down" and ammo > 0:
        ammo -= 1
        if mouse.hovered_entity and hasattr(mouse.hovered_entity, 'hp'):
            mouse.hovered_entity.hp -= 10
            mouse.hovered_entity.blink(color.black)
            print (ammo)
        Audio("gunshot")
        if gun.position == (0.45,-0.2,0):
            Animation("spark", parent=camera.ui, fps=5, scale=.15, position=(0.28, -0.01), loop=False)
            print (ammo)
        if gun.position == (0,-0.15,0):
            Animation("spark", parent=camera.ui, fps=5, scale=.15, position=(-0.005,0.08,0), loop=False)
            print (ammo)

    if held_keys["q"]:
            gun.position = (0,-0.15,0)
            gun.rotation = (0,0,0)
            Cursor = False
            player.speed = 1
            if held_keys["shift"]:
                player.speed = 100

    else:
        gun.position = (0.45,-0.2,0)
        gun.rotation = (5,30,0)
        player.speed = 250 * time.dt
    if held_keys["shift"]:
        player.speed = 400 * time.dt

class AmmoR(Entity): ## ammo refill class#
    def __init__(self, **kwargs):
        super().__init__(model='cube', texture = 'ammobox', scale = 1, origin_y=-0.5, collider = "mesh", **kwargs)

## amount of amo refill boxes##

ammo1 = AmmoR()
ammo2 = AmmoR()
ammo3 = AmmoR()
ammo4 = AmmoR()
ammo1.position = (-9,2,53)
ammo2.position = (50,1,21)
ammo3.position = (-17,0,31)
ammo4.position = (15,0,8)

class Enemy(Entity): ##enemy class#
    def __init__(self, **kwargs):
        super().__init__(model='cube', scale_y=4, origin_y=-0.5, color=color.light_gray, collider='box',  texture = "monster", **kwargs)
        self.health_bar = Entity(parent=self, y=1.2, model='cube', color=color.red, world_scale=(1.5,.1,.1))
        self.max_hp = 100
        self.hp = self.max_hp

    def update(self):
        global playerHealth
        dist = distance_xz(player.position, self.position)
        if dist > 40:
            self.health_bar.visible = False
            return

        self.health_bar.alpha = max(0, self.health_bar.alpha - time.dt)

        self.look_at_2d(player.position, 'y')
        hit_info = raycast(self.world_position + Vec3(0,1,0), self.forward, 30, ignore=(self,))
        if hit_info.entity == player:
            if dist > 1:
                self.position += self.forward * time.dt * 5

        if player.intersects(self).hit:
            print(playerHealth)
            playerHealth -= 0.3

    @property
    def hp(self):
        return self._hp

    @hp.setter
    def hp(self, value):
        self._hp = value
        if value <= 0:
            destroy(self)
            return

        self.health_bar.world_scale_x = self.hp / self.max_hp * 1.5
        self.health_bar.alpha = 1

## ENEMYS FIRST LEVEL
enemie1 = Enemy()
enemie2 = Enemy()
enemie3 = Enemy()
enemie4 = Enemy()
enemie5 = Enemy()
enemie6 = Enemy()
enemie7 = Enemy()
enemie8 = Enemy()
enemie9 = Enemy()
enemie10 = Enemy()
enemie11 = Enemy()

enemie1.position = (10,0,-2)
enemie2.position = (51.9096, 0, -57.6378)
enemie3.position = (53.7879, 0, -57.4827)
enemie4.position = (53.5366, 0, -39.0536)
enemie5.position = (50,0,-2)
enemie6.position = (50,0,-5)
enemie7.position = (22,0,-20)
enemie8.position = (55,0,-4)
enemie9.position = (15,0,-2)

Sky(color = color.black)

maze=Entity(model="maze", scale=10, texture="BK", color= color.gold ,collider="mesh")

gun=Entity(model="colt", parent=camera.ui, scale=0.07, texture='Maybe', position=(0.45,-0.2,0), rotation=(5,30,0))

app.run()
</code>```

I just need to figure out on:

ttt=PointLight(position= (-52, 0, 57), parent=camera.ui, color = color.rgba(100, 2, 100, 0), rotation = (0, 184, 0), shadows = True)

and see if I can add a def update() function to make it go to the player position. The only thing is that when I change the position of the light I see no change in the effect.

I tried to move the light to another position but it stayed the same. I am also trying to figure out how to change the brightness of the light.

Title: How to use lights in Ursina

Body:
I'm trying to make a horror type game in Ursina as a small project but I can't figure out how to position the point light. I want the point light to be pointing forward a bit and be at the players position. I practically just want to make a flashlight for my character.

This is the full code at the moment:

from ursina import *
from random import uniform
from ursina.prefabs.first_person_controller import FirstPersonController
from ursina.shaders import lit_with_shadows_shader
app = Ursina()
player = FirstPersonController(model='cube', color=color.orange, origin_y=-.5, speed=8, position = (-52, 0, 57))
player.collider = BoxCollider(player, Vec3(0,1,0))
player.visible = False
ammo = 10
playerHealth = 100
editor_camera = EditorCamera(enabled=False, ignore_paused=True)
ammoCounter = Text(text= ammo + ammo, position = (-0.4,-0.4), color = color.black)
ttt=PointLight(position= (-52, 0, 57), parent=camera.ui, color = color.rgba(100, 2, 100, 0), rotation = (0, 184, 0), shadows = True)

def update(): ##ammo counter ##
    ammoCounter.text = ammo

def pause_input(key): ##editor camera thing##
    if key == 'tab':    # press tab to toggle edit/play mode
        editor_camera.position = player.position
        editor_camera.rotation = (90,180,0)
        editor_camera.y = 50
        editor_camera.enabled = not editor_camera.enabled
        player.visible =True
        player.visible_self = editor_camera.enabled
        player.cursor.enabled = not editor_camera.enabled
        gun.enabled = not editor_camera.enabled
        mouse.locked = not editor_camera.enabled
        application.paused = editor_camera.enabled
pause_handler = Entity(ignore_paused=True, input=pause_input)

def input(key): ## gunshot, gun, player shift, and ammo crates destroys
    global ammo

    if key == "2":
        ttt.color = color.black

    if key == "1":
        ttt.color = color.white

    ## destroy ammo crates##
    if key == 'e':
        if mouse.hovered_entity == ammo1:
            if distance(player, ammo1) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo1)
                except:
                    print("ammo box issue")
        if mouse.hovered_entity == ammo2:
            if distance(player, ammo2) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo2)
                except:
                    print("ammo box issue")
        if mouse.hovered_entity == ammo3:
            if distance(player, ammo3) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo3)
                except:
                    print("ammo box issue")
        if mouse.hovered_entity == ammo4:
            if distance(player, ammo4) <= 5:
                try:
                    ammo += 10
                except:
                    print('ammo issue')
                try:
                    destroy(ammo4)
                except:
                    print("ammo box issue")

    if key == 'k':
        print (player.position)
        print (player.rotation)
        print (ammo)
        print (ttt.position)

    if key=="left mouse down" and ammo > 0:
        ammo -= 1
        if mouse.hovered_entity and hasattr(mouse.hovered_entity, 'hp'):
            mouse.hovered_entity.hp -= 10
            mouse.hovered_entity.blink(color.black)
            print (ammo)
        Audio("gunshot")
        if gun.position == (0.45,-0.2,0):
            Animation("spark", parent=camera.ui, fps=5, scale=.15, position=(0.28, -0.01), loop=False)
            print (ammo)
        if gun.position == (0,-0.15,0):
            Animation("spark", parent=camera.ui, fps=5, scale=.15, position=(-0.005,0.08,0), loop=False)
            print (ammo)

    if held_keys["q"]:
            gun.position = (0,-0.15,0)
            gun.rotation = (0,0,0)
            Cursor = False
            player.speed = 1
            if held_keys["shift"]:
                player.speed = 100

    else:
        gun.position = (0.45,-0.2,0)
        gun.rotation = (5,30,0)
        player.speed = 250 * time.dt
    if held_keys["shift"]:
        player.speed = 400 * time.dt

class AmmoR(Entity): ## ammo refill class#
    def __init__(self, **kwargs):
        super().__init__(model='cube', texture = 'ammobox', scale = 1, origin_y=-0.5, collider = "mesh", **kwargs)

## amount of amo refill boxes##

ammo1 = AmmoR()
ammo2 = AmmoR()
ammo3 = AmmoR()
ammo4 = AmmoR()
ammo1.position = (-9,2,53)
ammo2.position = (50,1,21)
ammo3.position = (-17,0,31)
ammo4.position = (15,0,8)

class Enemy(Entity): ##enemy class#
    def __init__(self, **kwargs):
        super().__init__(model='cube', scale_y=4, origin_y=-0.5, color=color.light_gray, collider='box',  texture = "monster", **kwargs)
        self.health_bar = Entity(parent=self, y=1.2, model='cube', color=color.red, world_scale=(1.5,.1,.1))
        self.max_hp = 100
        self.hp = self.max_hp

    def update(self):
        global playerHealth
        dist = distance_xz(player.position, self.position)
        if dist > 40:
            self.health_bar.visible = False
            return

        self.health_bar.alpha = max(0, self.health_bar.alpha - time.dt)

        self.look_at_2d(player.position, 'y')
        hit_info = raycast(self.world_position + Vec3(0,1,0), self.forward, 30, ignore=(self,))
        if hit_info.entity == player:
            if dist > 1:
                self.position += self.forward * time.dt * 5

        if player.intersects(self).hit:
            print(playerHealth)
            playerHealth -= 0.3

    @property
    def hp(self):
        return self._hp

    @hp.setter
    def hp(self, value):
        self._hp = value
        if value <= 0:
            destroy(self)
            return

        self.health_bar.world_scale_x = self.hp / self.max_hp * 1.5
        self.health_bar.alpha = 1

## ENEMYS FIRST LEVEL
enemie1 = Enemy()
enemie2 = Enemy()
enemie3 = Enemy()
enemie4 = Enemy()
enemie5 = Enemy()
enemie6 = Enemy()
enemie7 = Enemy()
enemie8 = Enemy()
enemie9 = Enemy()
enemie10 = Enemy()
enemie11 = Enemy()

enemie1.position = (10,0,-2)
enemie2.position = (51.9096, 0, -57.6378)
enemie3.position = (53.7879, 0, -57.4827)
enemie4.position = (53.5366, 0, -39.0536)
enemie5.position = (50,0,-2)
enemie6.position = (50,0,-5)
enemie7.position = (22,0,-20)
enemie8.position = (55,0,-4)
enemie9.position = (15,0,-2)

Sky(color = color.black)

maze=Entity(model="maze", scale=10, texture="BK", color= color.gold ,collider="mesh")

gun=Entity(model="colt", parent=camera.ui, scale=0.07, texture='Maybe', position=(0.45,-0.2,0), rotation=(5,30,0))

app.run()

I just need to figure out on:

ttt=PointLight(position= (-52, 0, 57), parent=camera.ui, color = color.rgba(100, 2, 100, 0), rotation = (0, 184, 0), shadows = True)

and see if I can add a def update() function to make it go to the player position. The only thing is that when I change the position of the light I see no change in the effect.

I tried to move the light to another position but it stayed the same. I am also trying to figure out how to change the brightness of the light.


问:
'Incorrect syntax near 'X3'. The identifier that starts with........is too long
I trying to save datagridview data to the database. Here is my code.

```<code>Dim cmd3 As New SqlCommand("insert into Tab_sale_bill (Col_Date, Col_Time, Col_Bill_Id, Col_Bill_Ty, Col_Inv_No, Col_Acc_Ty, Col_Acc_Name, Col_Bar, Col_Pro_Name, Col_Color_Code, Col_Bra, pricategory, Col_HSN, Col_Sec, Col_Cate, Col_Subcate, Col_Pack_Size, Col_Quan, Col_Unit, COL_MRP, Col_Re_Rate, Col_C_Rate, Col_Rate_Ex, Col_Rate_Diff, Col_Dis_Val, Col_Inv_Val, Col_Taxable_Val, Col_Tax_Rate, Col_CGST, Col_SGST, Col_P_Rate, Col_P_Val, Col_Total_Val, Col_Freight, Col_Oth_Dis, Col_Bill_Amnt, Col_Multiunit, factoronoff, netdiscount, marginvalue, marginper, Col_Comm_Typ, Col_Comm, Col_Item_Id, Col_Cust_Name, Col_Mob, Col_GSTIN, Col_Cust_Add, Col_Narr, Col_User_Id, Col_User) values('" & row.Cells(0).Value & "', @time, '" & row.Cells(2).Value & "', '" & row.Cells(3).Value & "', '" & row.Cells(4).Value & "', '" & row.Cells(5).Value & "', '" & row.Cells(6).Value & "', '" & row.Cells(7).Value & "', '" & row.Cells(8).Value & "', '" & row.Cells(9).Value & "', '" & row.Cells(10).Value & "', @pricri, '" & row.Cells(12).Value & "', '" & row.Cells(13).Value & "', '" & row.Cells(14).Value & "', @subcate, '" & row.Cells(16).Value & "', '" & row.Cells(17).Value & "', '" & row.Cells(18).Value & "', @mrp, @rerate, @crate, @rateex, '" & row.Cells(23).Value & "', @disper, @totval, @taxableval, '" & row.Cells(27).Value & "', @cgst, @sgst, @prate, @pval, '" & row.Cells(32).Value & "', '" & row.Cells(33).Value & "', '" & row.Cells(34).Value & "', @debit, '" & row.Cells(36).Value & "', '" & row.Cells(37).Value & "', '" & row.Cells(41).Value & "', '" & row.Cells(42).Value & "', '" & row.Cells(43).Value & "', '" & row.Cells(48).Value & "', '" & row.Cells(49).Value & "', '" & row.Cells(50).Value & "', '" & row.Cells(51).Value & "', '" & row.Cells(52).Value & "', @gst, @address, '" & row.Cells(55).Value & "', '" & row.Cells(56).Value & "', '" & row.Cells(57).Value & "')", conn3)
                        cmd3.Parameters.Add("@debit", SqlDbType.NVarChar).Value = Decimal.Parse(row.Cells(35).Value)
                            cmd3.Parameters.Add("@time", SqlDbType.Time).Value = Date.Now.ToString("hh:mm:ss")
                        cmd3.Parameters.Add("@pricri", SqlDbType.NVarChar).Value = row.Cells(11).Value
                        cmd3.Parameters.Add("@subcate", SqlDbType.NVarChar).Value = row.Cells(15).Value
                        cmd3.Parameters.Add("@gst", SqlDbType.NVarChar).Value = row.Cells(53).Value
                        cmd3.Parameters.Add("@address", SqlDbType.NVarChar).Value = row.Cells(54).Value
                        cmd3.Parameters.Add("@mrp", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(19).Value)), 6)
                        cmd3.Parameters.Add("@rerate", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(20).Value)), 6)
                        cmd3.Parameters.Add("@crate", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(21).Value)), 6)
                        cmd3.Parameters.Add("@rateex", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(22).Value)), 6)
                        cmd3.Parameters.Add("@disper", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(24).Value)), 6)
                        cmd3.Parameters.Add("@totval", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(25).Value)), 6)
                        cmd3.Parameters.Add("@taxableval", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(26).Value)), 6)
                        cmd3.Parameters.Add("@cgst", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(28).Value)), 6)
                        cmd3.Parameters.Add("@sgst", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(29).Value)), 6)
                        cmd3.Parameters.Add("@prate", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(30).Value)), 6)
                        cmd3.Parameters.Add("@pval", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(31).Value)), 6)
                        conn3.Open()
                        cmd3.ExecuteNonQuery()
                            conn3.Close()
</code>```

This causes the error as:
'Incorrect syntax near 'X3'.
The identifier that starts with '', '30', 'PCS', @mrp, @rerate, @crate, @rateex, '0', @disper, @totval, @taxableval, '18', @cgst, @sgst, @prate, @pval, '140049',' is too long. Maximum length is 128.
Unclosed quotation mark after the character string '', '30', 'PCS', @mrp, @rerate, @crate, @rateex, '0', @disper, @totval, @taxableval, '18', @cgst, @sgst, @prate, @pval, '140049', '.'

Can you please tell me what is this error indicate. What can I solved this error.
Thanks in Advance.

Body:
I trying to save datagridview data to the database. Here is my code.

Dim cmd3 As New SqlCommand("insert into Tab_sale_bill (Col_Date, Col_Time, Col_Bill_Id, Col_Bill_Ty, Col_Inv_No, Col_Acc_Ty, Col_Acc_Name, Col_Bar, Col_Pro_Name, Col_Color_Code, Col_Bra, pricategory, Col_HSN, Col_Sec, Col_Cate, Col_Subcate, Col_Pack_Size, Col_Quan, Col_Unit, COL_MRP, Col_Re_Rate, Col_C_Rate, Col_Rate_Ex, Col_Rate_Diff, Col_Dis_Val, Col_Inv_Val, Col_Taxable_Val, Col_Tax_Rate, Col_CGST, Col_SGST, Col_P_Rate, Col_P_Val, Col_Total_Val, Col_Freight, Col_Oth_Dis, Col_Bill_Amnt, Col_Multiunit, factoronoff, netdiscount, marginvalue, marginper, Col_Comm_Typ, Col_Comm, Col_Item_Id, Col_Cust_Name, Col_Mob, Col_GSTIN, Col_Cust_Add, Col_Narr, Col_User_Id, Col_User) values('" & row.Cells(0).Value & "', @time, '" & row.Cells(2).Value & "', '" & row.Cells(3).Value & "', '" & row.Cells(4).Value & "', '" & row.Cells(5).Value & "', '" & row.Cells(6).Value & "', '" & row.Cells(7).Value & "', '" & row.Cells(8).Value & "', '" & row.Cells(9).Value & "', '" & row.Cells(10).Value & "', @pricri, '" & row.Cells(12).Value & "', '" & row.Cells(13).Value & "', '" & row.Cells(14).Value & "', @subcate, '" & row.Cells(16).Value & "', '" & row.Cells(17).Value & "', '" & row.Cells(18).Value & "', @mrp, @rerate, @crate, @rateex, '" & row.Cells(23).Value & "', @disper, @totval, @taxableval, '" & row.Cells(27).Value & "', @cgst, @sgst, @prate, @pval, '" & row.Cells(32).Value & "', '" & row.Cells(33).Value & "', '" & row.Cells(34).Value & "', @debit, '" & row.Cells(36).Value & "', '" & row.Cells(37).Value & "', '" & row.Cells(41).Value & "', '" & row.Cells(42).Value & "', '" & row.Cells(43).Value & "', '" & row.Cells(48).Value & "', '" & row.Cells(49).Value & "', '" & row.Cells(50).Value & "', '" & row.Cells(51).Value & "', '" & row.Cells(52).Value & "', @gst, @address, '" & row.Cells(55).Value & "', '" & row.Cells(56).Value & "', '" & row.Cells(57).Value & "')", conn3)
                        cmd3.Parameters.Add("@debit", SqlDbType.NVarChar).Value = Decimal.Parse(row.Cells(35).Value)
                            cmd3.Parameters.Add("@time", SqlDbType.Time).Value = Date.Now.ToString("hh:mm:ss")
                        cmd3.Parameters.Add("@pricri", SqlDbType.NVarChar).Value = row.Cells(11).Value
                        cmd3.Parameters.Add("@subcate", SqlDbType.NVarChar).Value = row.Cells(15).Value
                        cmd3.Parameters.Add("@gst", SqlDbType.NVarChar).Value = row.Cells(53).Value
                        cmd3.Parameters.Add("@address", SqlDbType.NVarChar).Value = row.Cells(54).Value
                        cmd3.Parameters.Add("@mrp", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(19).Value)), 6)
                        cmd3.Parameters.Add("@rerate", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(20).Value)), 6)
                        cmd3.Parameters.Add("@crate", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(21).Value)), 6)
                        cmd3.Parameters.Add("@rateex", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(22).Value)), 6)
                        cmd3.Parameters.Add("@disper", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(24).Value)), 6)
                        cmd3.Parameters.Add("@totval", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(25).Value)), 6)
                        cmd3.Parameters.Add("@taxableval", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(26).Value)), 6)
                        cmd3.Parameters.Add("@cgst", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(28).Value)), 6)
                        cmd3.Parameters.Add("@sgst", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(29).Value)), 6)
                        cmd3.Parameters.Add("@prate", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(30).Value)), 6)
                        cmd3.Parameters.Add("@pval", SqlDbType.NVarChar).Value = Math.Round((Decimal.Parse(row.Cells(31).Value)), 6)
                        conn3.Open()
                        cmd3.ExecuteNonQuery()
                            conn3.Close()

This causes the error as:
'Incorrect syntax near 'X3'.
The identifier that starts with '', '30', 'PCS', @mrp, @rerate, @crate, @rateex, '0', @disper, @totval, @taxableval, '18', @cgst, @sgst, @prate, @pval, '140049',' is too long. Maximum length is 128.
Unclosed quotation mark after the character string '', '30', 'PCS', @mrp, @rerate, @crate, @rateex, '0', @disper, @totval, @taxableval, '18', @cgst, @sgst, @prate, @pval, '140049', '.'

Can you please tell me what is this error indicate. What can I solved this error.
Thanks in Advance.


问:
How to Export user input from one JS file to another JS file running on server side
How can I export user input from JS file which running on browser side to the JS file which will be running on server side?

I tried using module. Export but getting error and I also tried to write client side and server-side code in same JS file but again error. If I am using any npm package in client JS file, then gives error.
So how should I export value to server-side JS file.


问:
It's possible to use iframe with vscode.dev on my webapp
I'm developing (web app) project manager and I want to know if it's possible to integrate vscode.dev or github.dev with iframe to edit some code inside my app without leave it.

User is login with GitHub, so he has access to her allowed repository from my app

Do you have an idea to do this or alternative solution ?


问:
Dialer pad redirected from browser misses the # in the dial number used in anchor tag in android devices
I am using React JS, I want to implement a calling functionality in which there is an anchor tag on clicking which the user will be redirected to the dialer pad of his/her phone. But the number which is used here ends with a # and when the user is redirected to the dialer pad with this number, the # goes missing. This issue is happening in android devices but in iPhone it is ok.

`

```<code><a href="tel: some_number_ending_with_#">Dial me</a>
</code>```

Body:
I am using React JS, I want to implement a calling functionality in which there is an anchor tag on clicking which the user will be redirected to the dialer pad of his/her phone. But the number which is used here ends with a # and when the user is redirected to the dialer pad with this number, the # goes missing. This issue is happening in android devices but in iPhone it is ok.

`

Dial me


问:
Have location block with multi or condition on seperate line nginx
We want to send 30 specific url to a new service and rest traffic will go to old service.
So i created a location block with those 30 url

```<code> location ~* ^(/a|/b|/c|/d)$ {}
</code>```

But the issue is its too hard to add url on same line.
I tried writing on different line but it gives error

```<code>location ~* ^(/a|
/b)$ {
</code>```

Error

```<code>nginx: [emerg] invalid number of arguments in "location" directive in /usr/nginx/conf/nginx.conf:43
</code>```

Is there some way to write multi url path in same location block but on different lines.

Body:
We want to send 30 specific url to a new service and rest traffic will go to old service.
So i created a location block with those 30 url

 location ~* ^(/a|/b|/c|/d)$ {}

But the issue is its too hard to add url on same line.
I tried writing on different line but it gives error

location ~* ^(/a|
/b)$ {

Error

nginx: [emerg] invalid number of arguments in "location" directive in /usr/nginx/conf/nginx.conf:43

Is there some way to write multi url path in same location block but on different lines.


问:
Why POST request creates new record if my code logic is for update?
I read many articles like https://restfulapi.net/rest-put-vs-post/ and there is mentioned that, PUT is for update records and POST for create, because PUT is idempotent. It means if I will send the same request multiple times, it will not create new records instead of POST. But if my code logic is like, on the PUT request I create new record, or on the POST request I update record, why it doesn't work? code logic is more important right? because two of these methods body is similar.</p>


问:
Custom hook to add items into a todo list
I would highly appreciate advice regarding my custom hook.
the hook performs the functionality I'm expecting it to perform however I'm not sure that I'm utilizing the best practices of React or whether my code can be improved.

thanks in advance!

useAddItem (custom hook):

```<code>import { useRef, useState, useEffect } from 'react';

export const useAddItem = (refItem) => {
    const [list, setList] = useState([]);

    const adddingItem = e => {
        if (e.which === 13 && e.target.value.length > 0) {
            console.log(e);
            setList(prev => [...prev, e.target.value]);
        };
    };

    // Clearing the input field after submition, not sure that this is the correct way
    useEffect(() => {
        refItem.current.value = "";
    }, [list]);

    return [list, adddingItem];
};
</code>```

todo list page component:

```<code>import { NextFunctionComponent } from 'next';
import Image from 'next/image';
import styles from "./list_items_index.module.scss";
import { useAddItem } from 'hooks/useAddItem';
import { useRef } from 'react';

export const ListItems : NextFunctionComponent = ({theme}) => {
    const inputRef = useRef(null);
    const [list, adddingItem] = useAddItem(inputRef);

    return (
        <div className={styles["list-items"]} data-theme={theme} data-testid="list-items">
            <input ref={inputRef} className={styles["list-items_input"]} type="text" onKeyPress={(e) => adddingItem(e)} />
            <div className={styles["list-items_content"]}>
                <ul className={styles["list-items_content__list"]}>
                    {list.map((item, index) => {
                        return <li key={index}><span></span>{item}</li>
                    })}
                </ul>
                <div className={styles["list-items_footer"]}>
                    <p>items left</p>
                    <ul className={styles["list-items_filters"]}>
                        <li>All</li>
                        <li>Active</li>
                        <li>Completed</li>
                    </ul>
                    <p>Clear Completed</p>
                </div>
            </div>
        </div>
    );
};
</code>```

Body:
I would highly appreciate advice regarding my custom hook.
the hook performs the functionality I'm expecting it to perform however I'm not sure that I'm utilizing the best practices of React or whether my code can be improved.

thanks in advance!

useAddItem (custom hook):

import { useRef, useState, useEffect } from 'react';

export const useAddItem = (refItem) => {
    const [list, setList] = useState([]);

    const adddingItem = e => {
        if (e.which === 13 && e.target.value.length > 0) {
            console.log(e);
            setList(prev => [...prev, e.target.value]);
        };
    };

    // Clearing the input field after submition, not sure that this is the correct way
    useEffect(() => {
        refItem.current.value = "";
    }, [list]);

    return [list, adddingItem];
};

todo list page component:

import { NextFunctionComponent } from 'next';
import Image from 'next/image';
import styles from "./list_items_index.module.scss";
import { useAddItem } from 'hooks/useAddItem';
import { useRef } from 'react';

export const ListItems : NextFunctionComponent = ({theme}) => {
    const inputRef = useRef(null);
    const [list, adddingItem] = useAddItem(inputRef);

    return (

            <input ref={inputRef} className={styles["list-items_input"]} type="text" onKeyPress={(e) => adddingItem(e)} />

                    {list.map((item, index) => {
                        return
{item}

                    })}

items left

All

Active

Completed

Clear Completed

    );
};


问:
Selection of very first datapoint of annual cyclicality time series for forecasting
I am new to time series, sorry if my question is stupid.
I have an annual cyclicality (cycle starts from January), monthly frequency time series data. I would like to forecast the next few months on this data.

My question is that the very first datapoint (starting date) must be January (start of the cycle) or it can be any months and the models (I am using auto arima and prophet) do not care about the very first datapoint?

The alternative is to drop the first few months datapoint till I get to the very first January datapoint.

Which option should I use?

Thank you in advance!


问:
Dynamically add a client certificate to a HttpClient
Problem statement

What is the best way to dynamically add a client certificate to a HttpClient in C#? I have an application that needs to call the same endpoint with different client certificates (We are calling an API on behalf of our clients).

Scenario:

We are not able to use named HttpClients because our customer base will grow and shrink dynamically. What I had in mind was to create a HttpClientFactory so you could do the following. Doing so creates new problems e.g. socket exhaustion.

var factory = new HttpClientFactory()
var certificate = new X509Certificate2();
HttpClient customerClient = factory.CreateClient(certificate)
```

Research:

https://github.com/dotnet/extensions/issues/932

Body:
Problem statement

What is the best way to dynamically add a client certificate to a HttpClient in C#? I have an application that needs to call the same endpoint with different client certificates (We are calling an API on behalf of our clients).

Scenario:

We are not able to use named HttpClients because our customer base will grow and shrink dynamically. What I had in mind was to create a HttpClientFactory so you could do the following. Doing so creates new problems e.g. socket exhaustion.

var factory = new HttpClientFactory()
var certificate = new X509Certificate2();
HttpClient customerClient = factory.CreateClient(certificate)

Research:

https://github.com/dotnet/extensions/issues/932


问:
How to access Document object same like WebBrowser control with WebView2 in WPF?
In my project we were using WebBrowser control and it has print html functionality implemented by using below code, as you all know IE is no more supported I am replacing WebBrowser control with WebView2 in my WPF application.

```<code> IOleServiceProvider sp = webBrowser1.Document as IOleServiceProvider;
            if (sp != null)
            {
                Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
                Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E");
                const int OLECMDID_PRINT = 6;
                const int OLECMDEXECOPT_DONTPROMPTUSER = 1;

                dynamic wb; // will be of IWebBrowser2 type, but dynamic is cool

                sp.QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, out wb);
                if (wb != null)
                {

                    wb.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, null, null);

                }
            }
</code>```

When I replaced the WebView2 and try to achieve the same functionality, I replaced the above code with webBrowser1.ExecuteScriptAsync("window.print();"). Unable to achieve the same and there is no Document object associated the WebView2.

Body:
In my project we were using WebBrowser control and it has print html functionality implemented by using below code, as you all know IE is no more supported I am replacing WebBrowser control with WebView2 in my WPF application.

 IOleServiceProvider sp = webBrowser1.Document as IOleServiceProvider;
            if (sp != null)
            {
                Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
                Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E");
                const int OLECMDID_PRINT = 6;
                const int OLECMDEXECOPT_DONTPROMPTUSER = 1;

                dynamic wb; // will be of IWebBrowser2 type, but dynamic is cool

                sp.QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, out wb);
                if (wb != null)
                {

                    wb.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, null, null);

                }
            }

When I replaced the WebView2 and try to achieve the same functionality, I replaced the above code with webBrowser1.ExecuteScriptAsync("window.print();"). Unable to achieve the same and there is no Document object associated the WebView2.


问:
jinja2 keep indentaion when render multi line string
I'm using jinja2 with python to config network device automatically.Now I'm in trouble with line indentaion. Here is my demo: reading config info from csv file and render into config string.

.j2 file

```<code>interface {{ interface }}
    description {{ ip }}-{{ server }}-{{ contact }}
    port link-type {{ port_type }}
    {% if port_type == "access" -%}
    port default vlan {{ vlan }}
    {% endif %}
</code>```

.py

```<code>def generate_config():
    """
    Parameter:None
    Return:device config string
    """

    template_fd = open(template_file,'r')
    server_info_fd = open(server_info_file,'r')

    jinja_template = Template(template_fd.read(),keep_trailing_newline=True)
    server_info = csv.DictReader(server_info_fd)

    config_set=''
    for info in server_info:
        interface_config = jinja_template.render(
            interface=info['Interface'],
            ip=info['Ip'],
            server=info['Server'],
            contact=info['Contact'],
            vlan=info['Vlan'],
            port_type=info['Port-type']
        )
        config_set += interface_config

    template_fd.close()
    server_info_fd.close()
    return config_set
</code>```

What I got is:

```<code>interface GigabitEthernet0/0/17
    description x.x.x.x-test-101
    port link-type access
    port default vlan 2101
    interface GigabitEthernet0/0/18
    description x.x.x.x-test-102
    port link-type access
    port default vlan 2101
</code>```

The second interface 0/0/18 still keeps indentation which I don't want.
Thx for you great help

Body:
I'm using jinja2 with python to config network device automatically.Now I'm in trouble with line indentaion. Here is my demo: reading config info from csv file and render into config string.

.j2 file

interface {{ interface }}
    description {{ ip }}-{{ server }}-{{ contact }}
    port link-type {{ port_type }}
    {% if port_type == "access" -%}
    port default vlan {{ vlan }}
    {% endif %}

.py

def generate_config():
    """
    Parameter:None
    Return:device config string
    """

    template_fd = open(template_file,'r')
    server_info_fd = open(server_info_file,'r')

    jinja_template = Template(template_fd.read(),keep_trailing_newline=True)
    server_info = csv.DictReader(server_info_fd)

    config_set=''
    for info in server_info:
        interface_config = jinja_template.render(
            interface=info['Interface'],
            ip=info['Ip'],
            server=info['Server'],
            contact=info['Contact'],
            vlan=info['Vlan'],
            port_type=info['Port-type']
        )
        config_set += interface_config

    template_fd.close()
    server_info_fd.close()
    return config_set

What I got is:

interface GigabitEthernet0/0/17
    description x.x.x.x-test-101
    port link-type access
    port default vlan 2101
    interface GigabitEthernet0/0/18
    description x.x.x.x-test-102
    port link-type access
    port default vlan 2101

The second interface 0/0/18 still keeps indentation which I don't want.
Thx for you great help


问:
How to store Array in Array Object ? please solution to this question . and explain which changes are required
```<code>    const serviceAndProduct = async (req, res) => {
  try {
    let {
      serviceName,
      subServiceId,
      serviceId,
      title,
      text,
      id,
      oldTitle,
      newTitle,
      newText,
      oldurl,
      dotId,
      dotName,
      slug,
    } = req.body;
    const options = {
      replacement: "", // replace spaces with replacement character, defaults to `-`
      remove: undefined, // remove characters that match regex, defaults to `undefined`
      lower: true, // convert to lower case, defaults to `false`
      strict: true, // strip special characters except replacement, defaults to `false`
      locale: "en", // language code of the locale to use
    };
    let slugData = slugify(req.body.title, options);
    let checkData = await ServiceAndProduct.findOne({ _id: id });
    if (checkData === null) {
      let logCoin = new Blockchain();
      console.log("mining logcoin in progress...");
      logCoin.addNewBlock(
        new Block(0, new Date().toLocaleString(), {
          serviceName: serviceName,
          serviceId: mongoose.Types.ObjectId(serviceId),
          title: title,
          text: text,
          imageName: req.file.filename,
          imageUrl: req.fileurl,
          slug: slugData,
          [{
            dotId: mongoose.Types.ObjectId(dotId),
          dotName: dotName
          }],

        })
      );
      res.send({
        status: HttpCode.OK,
        message: HttpMessage.BLOCK_ADDED,
      });
    } else {
      console.log(req.fileurl);
      let updateData = await ServiceAndProduct.updateOne(
        { _id: id, "data.title": oldTitle },
        {
          $set: {
            "data.$.title": title,
            "data.$.text": text,
            "data.$.serviceName": serviceName,
            "data.$.serviceId": mongoose.Types.ObjectId(serviceId),
            "data.$.slug": slugData,
            // "data.$.imageName": req.file.filename?req.file.filename:'',
            "data.$.imageUrl":
              req.fileurl && req.fileurl != "" ? req.fileurl : oldurl,
            timestamp: new Date().toLocaleString(),
          },
        }
      );
      if (updateData.modifiedCount === 1) {
        res.send({
          status: HttpCode.OK,
          message: HttpMessage.BLOCK_UPDATED,
        });
      } else {
        res.send({
          status: HttpCode.BAD_REQUEST,
          message: HttpMessage.BLOCK_NOT_UPDATED,
        });
      }
    }
  } catch (error) {
    console.log(error);
    res.send(error);
  }
};
</code>```

and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required
and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required
and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required
and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required

```<code>const serviceAndProductSchema=new mongoose.Schema({
    index:{
        type:Number,
        require:false
    },
    // timestamp:{
    //     type:String,
    //     require:false
    // },
    previousHash:{
        type:String,
        require:false
    },
    hash:{
        type:String,
        require:false
    },
    data:{
        type:Array,
        require:false
    },

},
{timestamp:true}
);
</code>```

Body:
    const serviceAndProduct = async (req, res) => {
  try {
    let {
      serviceName,
      subServiceId,
      serviceId,
      title,
      text,
      id,
      oldTitle,
      newTitle,
      newText,
      oldurl,
      dotId,
      dotName,
      slug,
    } = req.body;
    const options = {
      replacement: "", // replace spaces with replacement character, defaults to `-`
      remove: undefined, // remove characters that match regex, defaults to `undefined`
      lower: true, // convert to lower case, defaults to `false`
      strict: true, // strip special characters except replacement, defaults to `false`
      locale: "en", // language code of the locale to use
    };
    let slugData = slugify(req.body.title, options);
    let checkData = await ServiceAndProduct.findOne({ _id: id });
    if (checkData === null) {
      let logCoin = new Blockchain();
      console.log("mining logcoin in progress...");
      logCoin.addNewBlock(
        new Block(0, new Date().toLocaleString(), {
          serviceName: serviceName,
          serviceId: mongoose.Types.ObjectId(serviceId),
          title: title,
          text: text,
          imageName: req.file.filename,
          imageUrl: req.fileurl,
          slug: slugData,
          [{
            dotId: mongoose.Types.ObjectId(dotId),
          dotName: dotName
          }],

        })
      );
      res.send({
        status: HttpCode.OK,
        message: HttpMessage.BLOCK_ADDED,
      });
    } else {
      console.log(req.fileurl);
      let updateData = await ServiceAndProduct.updateOne(
        { _id: id, "data.title": oldTitle },
        {
          $set: {
            "data.$.title": title,
            "data.$.text": text,
            "data.$.serviceName": serviceName,
            "data.$.serviceId": mongoose.Types.ObjectId(serviceId),
            "data.$.slug": slugData,
            // "data.$.imageName": req.file.filename?req.file.filename:'',
            "data.$.imageUrl":
              req.fileurl && req.fileurl != "" ? req.fileurl : oldurl,
            timestamp: new Date().toLocaleString(),
          },
        }
      );
      if (updateData.modifiedCount === 1) {
        res.send({
          status: HttpCode.OK,
          message: HttpMessage.BLOCK_UPDATED,
        });
      } else {
        res.send({
          status: HttpCode.BAD_REQUEST,
          message: HttpMessage.BLOCK_NOT_UPDATED,
        });
      }
    }
  } catch (error) {
    console.log(error);
    res.send(error);
  }
};

and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required
and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required
and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required
and this was a model of API
How to store Array in Array Object ?please solution to this question
and explain which changes are required

const serviceAndProductSchema=new mongoose.Schema({
    index:{
        type:Number,
        require:false
    },
    // timestamp:{
    //     type:String,
    //     require:false
    // },
    previousHash:{
        type:String,
        require:false
    },
    hash:{
        type:String,
        require:false
    },
    data:{
        type:Array,
        require:false
    },

},
{timestamp:true}
);


问:
Cross compiling kernel module throwing error "/bin/sh: 1: scripts/mod/modpost: not found"
I am cross compiling kernel module using my own generated toolchain of yocto kirkston source but it's throwing error that "/bin/sh: 1: scripts/mod/modpost: not found". I could see modpost.c & modpost.h files in toolchain but couldn't find shell script for the same. Find the same source & header file in linux-libc-headers also but script is missing. Attaching the detailed logs below, any suggestion on this will be really helpful.

```<code>make ARCH=arm64 -I/opt/poky/4.0.5/sysroots/cortexa72-poky-linux/usr/include/asm -C /opt/poky/4.0.5/sysroots/cortexa72-poky-linux/lib/modules/5.15.72-yocto-standard/build M=/home/agl/Automotive/ADAS_Infotainment/project/Application/Xen modules
make[1]: Entering directory '/opt/poky/4.0.5/sysroots/cortexa72-poky-linux/lib/modules/5.15.72-yocto-standard/build'
arch/arm64/Makefile:36: Detected assembler with broken .inst; disassembly will be unreliable
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
  You are using:           aarch64-poky-linux-gcc (GCC) 11.3.0
  MODPOST /home/agl/Automotive/ADAS_Infotainment/project/Application/Xen/Module.symvers
/bin/sh: 1: scripts/mod/modpost: not found
make[2]: *** [scripts/Makefile.modpost:133: /home/agl/Automotive/ADAS_Infotainment/project/Application/Xen/Module.symvers] Error 127
make[1]: *** [Makefile:1813: modules] Error 2
make[1]: Leaving directory '/opt/poky/4.0.5/sysroots/cortexa72-poky-linux/lib/modules/5.15.72-yocto-standard/build'
make: *** [Makefile:5: all] Error 2
</code>```

I have included kernel-modules, kernel-devsrc & kernel-dev in local.conf file.
Expecting that modpost should be generated.

Body:
I am cross compiling kernel module using my own generated toolchain of yocto kirkston source but it's throwing error that "/bin/sh: 1: scripts/mod/modpost: not found". I could see modpost.c & modpost.h files in toolchain but couldn't find shell script for the same. Find the same source & header file in linux-libc-headers also but script is missing. Attaching the detailed logs below, any suggestion on this will be really helpful.

make ARCH=arm64 -I/opt/poky/4.0.5/sysroots/cortexa72-poky-linux/usr/include/asm -C /opt/poky/4.0.5/sysroots/cortexa72-poky-linux/lib/modules/5.15.72-yocto-standard/build M=/home/agl/Automotive/ADAS_Infotainment/project/Application/Xen modules
make[1]: Entering directory '/opt/poky/4.0.5/sysroots/cortexa72-poky-linux/lib/modules/5.15.72-yocto-standard/build'
arch/arm64/Makefile:36: Detected assembler with broken .inst; disassembly will be unreliable
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
  You are using:           aarch64-poky-linux-gcc (GCC) 11.3.0
  MODPOST /home/agl/Automotive/ADAS_Infotainment/project/Application/Xen/Module.symvers
/bin/sh: 1: scripts/mod/modpost: not found
make[2]: *** [scripts/Makefile.modpost:133: /home/agl/Automotive/ADAS_Infotainment/project/Application/Xen/Module.symvers] Error 127
make[1]: *** [Makefile:1813: modules] Error 2
make[1]: Leaving directory '/opt/poky/4.0.5/sysroots/cortexa72-poky-linux/lib/modules/5.15.72-yocto-standard/build'
make: *** [Makefile:5: all] Error 2

I have included kernel-modules, kernel-devsrc & kernel-dev in local.conf file.
Expecting that modpost should be generated.


问:
Log-in with Facebook in messenger's embedded browser (Android) - web application
we're developing web application that significantly relies on logging in via Facebook. One of the most popular sources of traffic will be messenger - and our page will be opened in messenger's embedded browser.

And here we have a problem - In opposition to the embedded browsers in other applications (for example Slack and even Facebook app), log-in via Facebook in messenger's embedded browser doesn’t seem to work. After providing credentials, the page is displayed as in the attached picture (it says close this tab) instead of redirecting to our website. Without redirection, we are not able to get the token.

The interesting fact is that in some other websites log-in via Facebook in messenger's embedded browsers works perfectly (so redirection to the origin page works). The way how they implement that seems the same as ours. Working example: https://sprii.live.

So, what can be the difference? Some Facebook application settings? We were testing different configurations without success. Any ideas / tips? I've seen similar topics, but most of them concerned mobile apps - our case is different, because we have web application and rely mostly on messenger's embedded browser.


问:
Remove Background of an Image using ML KIT gives poor result

How to smooth edges, I have read many articles about anti Aliasing but did not get much helpful

Can anyone share an alternative for removing background that shows good results?

Note: Using Kotlin.

I'm expecting this type of result: