问:
Unable to get success in react native jest test cases for Image and Image Background components while using local assets
I am writing test cases for ImageBackground and Image component in React native but the test cases is getting failed as I am using local assets. It is unable to fetch the location of the assets folder I guess. Can someone help me out with this issue?

```<code> test('renders Background image', () => {
        const { getByTestId } = render(LandingScreen);
        expect(getByTestId('logo').toBeInTheDocument);
    })

    test('Logo must have src = "/logo.svg" and alt = "Logo"', () => {
        render(LandingPage);
        const logo = screen.getByRole('logo');
        expect(logo).toHaveAttribute('source', '../../../assets/logo.png');
    });

    it(" Product introduction check background Image present or not", () => {
      const logoImg = LandingScreen.root.findByProps({
        testID: "logo",
      }).props;
      expect(logoImg).toBeDefined();
    });
    it('should display a local image when given a valid image file path', () => {

        // Render the Image component with the provided image file
        const imageComponent = shallow(<Image source={require("../../assets/authBg.png")} />);
        expect(imageComponent.find('logo').prop('src')).toEqual(logo);
    })
</code>```

I have tried these code for test cases but getting error this kind of error below are attached Screenshots
[enter image description here](https://i.stack.imgur.com/UX1mg.png)

Body:
I am writing test cases for ImageBackground and Image component in React native but the test cases is getting failed as I am using local assets. It is unable to fetch the location of the assets folder I guess. Can someone help me out with this issue?

 test('renders Background image', () => {
        const { getByTestId } = render(LandingScreen);
        expect(getByTestId('logo').toBeInTheDocument);
    })

    test('Logo must have src = "/logo.svg" and alt = "Logo"', () => {
        render(LandingPage);
        const logo = screen.getByRole('logo');
        expect(logo).toHaveAttribute('source', '../../../assets/logo.png');
    });

    it(" Product introduction check background Image present or not", () => {
      const logoImg = LandingScreen.root.findByProps({
        testID: "logo",
      }).props;
      expect(logoImg).toBeDefined();
    });
    it('should display a local image when given a valid image file path', () => {

        // Render the Image component with the provided image file
        const imageComponent = shallow(<Image source={require("../../assets/authBg.png")} />);
        expect(imageComponent.find('logo').prop('src')).toEqual(logo);
    })

I have tried these code for test cases but getting error this kind of error below are attached Screenshots
[enter image description here](https://i.stack.imgur.com/UX1mg.png)


来源: stackexchange

问:
Swift Run method if a specific framework is in the project
I have a framework "A", framework "B" and a host app.

In the framework "A" I have some methods what I want to run IF the framework "B" is existing in the host app.
How can I achieve that?

I tried this:

```<code>#if __has_include(<Framework_B/Framework_B.h>)
</code>```

but it does not work. Framework "A" does not see the framework "B".

ContentLicense: CC BY-SA 4.0

Body:
I have a framework "A", framework "B" and a host app.

In the framework "A" I have some methods what I want to run IF the framework "B" is existing in the host app.
How can I achieve that?

I tried this:

#if __has_include(<Framework_B/Framework_B.h>)

but it does not work. Framework "A" does not see the framework "B".


问:
Inclined prism Blender Python
By means of Blender Python construct a geometric model of the body surface: an inclined prism with a square normal section; the base is parallel to the plane x = 0. I would really appreciate if someone could help!</p>

Title: Inclined prism Blender Python


问:
Modal renders based on number of children
I have a tree chart in which each node has children nodes. when clicking on a node a drawer opens exactly like a modal. But the problem is that it rerenders based on number of children available on screen like 6 or 5 times. When I click on node it sets this setIsOpen(true) so I think it's it sets this for all nodes that's why it renders more than 1 time. I saw that in inspect. I tried to use use callback and memo but it didn't work.

```<code>const Root = (): JSX.Element => {
  return (
    <div className={styles.card}>
      <Flex style={{ marginTop: 25, gap: 8 }} flexCol itemsCenter justifyCenter>
        <OrgIcon />
        <Text typography="title" weight="bold" color="rgba(6, 6, 43, 0.6)">
          Jisr HR
        </Text>
      </Flex>
    </div>
  );
};

type ChartProps = {
  onSubmit: (vals: any) => void
};

const Chart = (props: ChartProps): JSX.Element => {
  const { onSubmit } = props;
  return (
    <Tree
      lineHeight="50px"
      lineWidth="1px"
      lineColor="rgb(8 15 54 / 24%);"
      lineBorderRadius="30px"
      label={<Root />}
    >
      {data.map((d, i) => (
        <Node data={d} key={i} onSubmit={onSubmit} />
      ))}
    </Tree>
  );
};

export default Chart;

const Node = ({ data, onSubmit }: Props): JSX.Element => {
  const [show, setShow] = useState(false);
  const [showEmployeeList, setShowEmployeeList] = useState(false);
  const count = data.child?.length || 0;
  const { setIsOpen, setIsEdit } = useDepartment();

  return (
    <>
      <TreeNode
        key={data.name}
        label={
          <Card
            onClick={(): void => setIsOpen(true)}
            onClickEmp={(): void => setShowEmployeeList(true)}
            onClickEdit={(): void => { setIsOpen(true); setIsEdit(true); }}
            name={data.name}
            collapse={
              <div
                className={styles.collapse}
                onClick={(): void => setShow(!show)}
              >
                <Text typography="paragraph14" color="#475467">
                  {count}
                </Text>
                <FAICon
                  icon={`fa-regular ${show ? 'fa-angle-down' : 'fa-angle-up'}`}
                  color={undefined}
                  fontSize={undefined}
                />
              </div>
            }
          />
        }
      >
        {show
          ? data.child &&
            data.child.map((d: any, i: number): JSX.Element =>
              <Node data={d} key={i} onSubmit={onSubmit} />)
          : null}
      </TreeNode>
      <AddDepartmentForm
        onSubmit={onSubmit}
      />
      <DepartmentEmployees
        showEmployeeList={showEmployeeList}
        setShowEmployeeList={setShowEmployeeList}
      />
    </>
  );
};

export default Node;

const Card = ({
  name,
  collapse,
  onClick,
  onClickEmp,
  onClickEdit,
}: ListData): JSX.Element => {
  return (
    <div
      className={styles.card}
    >
      <div
        className={styles.boxUp}
        onClick={onClick}
      >
        <PlusIcon className={styles.hoverPlus} />
      </div>
      <div
        className={styles.card_header}
        onClick={onClickEdit}
      >
        <Flex itemsCenter style={{ gap: 15 }}>
          <DepartmentIcon />
          <Text typography="paragraph16" color="rgba(6, 6, 43, 0.6)">
            {name}
          </Text>
        </Flex>
      </div>
      <div style={{ margin: '12px 10px 12px 10px' }}>
        <Flex style={{ gap: 8 }} itemsCenter>
          <PlusIcon className={styles.plusIcon} />
          <Text typography="paragraph16" color="#2353f5">
            Assign Manager
          </Text>
        </Flex>
        <Spacer height={10} />
        <Flex justifyBetween>
          <Badge
            label={
              <Flex style={{ gap: 7 }}>
                <EmployeeIcon />
                23
              </Flex>
            }
            size="large"
            type="gray"
            variant="stroke"
            onClick={onClickEmp}
          />
          {collapse}
        </Flex>
      </div>
      <div className={styles.boxDown}>
        <PlusIcon className={styles.hoverPlus} />
      </div>
    </div>
  );
};

export default Card;
</code>```

Body:
I have a tree chart in which each node has children nodes. when clicking on a node a drawer opens exactly like a modal. But the problem is that it rerenders based on number of children available on screen like 6 or 5 times. When I click on node it sets this setIsOpen(true) so I think it's it sets this for all nodes that's why it renders more than 1 time. I saw that in inspect. I tried to use use callback and memo but it didn't work.

const Root = (): JSX.Element => {
  return (

      <Flex style={{ marginTop: 25, gap: 8 }} flexCol itemsCenter justifyCenter>
        <OrgIcon />
        <Text typography="title" weight="bold" color="rgba(6, 6, 43, 0.6)">
          Jisr HR
        </Text>
      </Flex>

  );
};

type ChartProps = {
  onSubmit: (vals: any) => void
};

const Chart = (props: ChartProps): JSX.Element => {
  const { onSubmit } = props;
  return (
    <Tree
      lineHeight="50px"
      lineWidth="1px"
      lineColor="rgb(8 15 54 / 24%);"
      lineBorderRadius="30px"
      label={<Root />}
    >
      {data.map((d, i) => (
        <Node data={d} key={i} onSubmit={onSubmit} />
      ))}
    </Tree>
  );
};

export default Chart;

const Node = ({ data, onSubmit }: Props): JSX.Element => {
  const [show, setShow] = useState(false);
  const [showEmployeeList, setShowEmployeeList] = useState(false);
  const count = data.child?.length || 0;
  const { setIsOpen, setIsEdit } = useDepartment();

  return (
    <>
      <TreeNode
        key={data.name}
        label={
          <Card
            onClick={(): void => setIsOpen(true)}
            onClickEmp={(): void => setShowEmployeeList(true)}
            onClickEdit={(): void => { setIsOpen(true); setIsEdit(true); }}
            name={data.name}
            collapse={

 setShow(!show)}
              >
                <Text typography="paragraph14" color="#475467">
                  {count}
                </Text>
                <FAICon
                  icon={`fa-regular ${show ? 'fa-angle-down' : 'fa-angle-up'}`}
                  color={undefined}
                  fontSize={undefined}
                />

            }
          />
        }
      >
        {show
          ? data.child &&
            data.child.map((d: any, i: number): JSX.Element =>
              <Node data={d} key={i} onSubmit={onSubmit} />)
          : null}
      </TreeNode>
      <AddDepartmentForm
        onSubmit={onSubmit}
      />
      <DepartmentEmployees
        showEmployeeList={showEmployeeList}
        setShowEmployeeList={setShowEmployeeList}
      />
    </>
  );
};

export default Node;

const Card = ({
  name,
  collapse,
  onClick,
  onClickEmp,
  onClickEdit,
}: ListData): JSX.Element => {
  return (

        <PlusIcon className={styles.hoverPlus} />

        <Flex itemsCenter style={{ gap: 15 }}>
          <DepartmentIcon />
          <Text typography="paragraph16" color="rgba(6, 6, 43, 0.6)">
            {name}
          </Text>
        </Flex>

        <Flex style={{ gap: 8 }} itemsCenter>
          <PlusIcon className={styles.plusIcon} />
          <Text typography="paragraph16" color="#2353f5">
            Assign Manager
          </Text>
        </Flex>
        <Spacer height={10} />
        <Flex justifyBetween>
          <Badge
            label={
              <Flex style={{ gap: 7 }}>
                <EmployeeIcon />
                23
              </Flex>
            }
            size="large"
            type="gray"
            variant="stroke"
            onClick={onClickEmp}
          />
          {collapse}
        </Flex>

        <PlusIcon className={styles.hoverPlus} />

  );
};

export default Card;


问:
add event listeners to html objects added with javascript
how can I add event listeners to elements added in html with javascript like this ?

```<code>items.forEach((cors) => {
    const { top, left, width, height } = cors
    container.innerHTML +=
      `<div class='box'
      style='top:${top}px;left:${left}px;width:${width}px;height:${height}px'>`

  })
</code>```

I tried to make it with javascript but it did not work

Body:
how can I add event listeners to elements added in html with javascript like this ?

items.forEach((cors) => {
    const { top, left, width, height } = cors
    container.innerHTML +=
      `
`

  })

I tried to make it with javascript but it did not work


问:
App.xaml.cs will run again unexpectedly in Debug mode
I am using the APP to connect to a device in Xamarin debug mode.

When the system is trying to connect to the device(like the screenshot shows "Connecting to device..."), if I press the back button to home(desktop) and back to APP, I find that the code will run App.xaml.cs again, so I will see the screen will show Example_A_Page again and then show Example_B_Page afterward.

Then I tried again without the debug mode this time.
When I press the back button to home(desktop) and then back to APP, APP is still running Example_B_Page.

Does anybody know why this situation happened?

Here is the pseudo code

```<code>public partial class App : Application
{
    public App()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new Example_A_Page());
    }
}

public partial class Example_A_Page : ContentPage
{
    public Example_A_Page()
    {
        InitializeComponent();
    }

    protected async override void OnAppearing()
    {
        await Navigation.PushPopupAsync(new Example_B_Page());
    }
}

public partial class Example_B_Page : ContentPage
{
    public Example_B_Page()
    {
        InitializeComponent();
    }

    private async void Button_Clicked(object sender, EventArgs e)
    {
        //Do the connection behavior...
        //Connected to the device...
    }
}
</code>```

Body:
I am using the APP to connect to a device in Xamarin debug mode.

When the system is trying to connect to the device(like the screenshot shows "Connecting to device..."), if I press the back button to home(desktop) and back to APP, I find that the code will run App.xaml.cs again, so I will see the screen will show Example_A_Page again and then show Example_B_Page afterward.

Then I tried again without the debug mode this time.
When I press the back button to home(desktop) and then back to APP, APP is still running Example_B_Page.

Does anybody know why this situation happened?

Here is the pseudo code

public partial class App : Application
{
    public App()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new Example_A_Page());
    }
}

public partial class Example_A_Page : ContentPage
{
    public Example_A_Page()
    {
        InitializeComponent();
    }

    protected async override void OnAppearing()
    {
        await Navigation.PushPopupAsync(new Example_B_Page());
    }
}

public partial class Example_B_Page : ContentPage
{
    public Example_B_Page()
    {
        InitializeComponent();
    }

    private async void Button_Clicked(object sender, EventArgs e)
    {
        //Do the connection behavior...
        //Connected to the device...
    }
}


问:
EntryDescription Object | Webpack
What does the dependOn means that "dependOn must not be circular" in Webpack entry point.

I am new to Webpack, but some what I understood how webpack is created by npx and its process. I also know webpack.config.js file is used for configuration of Webpack. But there was one point in documentation that "dependOn must not be circular", I was not able to understand it properly.

I need to also know when to use dependOn, import, library, runtime ?

Title: EntryDescription Object | Webpack


问:
Navdropdown move to right on windows
I'm trying to add navbar from sample as below:

```<code>const Header = () => {
  return (
    <>
      <Navbar bg="light" expand="lg">
        <Navbar.Brand href="#home">React-Bootstrap</Navbar.Brand>
        <Navbar.Toggle aria-controls="basic-navbar-nav" />
        <Navbar.Collapse id="basic-navbar-nav">
          <Nav className="mr-auto">
            <Nav.Link href="#home">Home</Nav.Link>
            <Nav.Link href="#link">Link</Nav.Link>
            <NavDropdown title="Dropdown" id="basic-nav-dropdown">
              <NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
              <NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
              <NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
              <NavDropdown.Divider />
              <NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
              <NavDropdown title="Dropdown" id="basic-nav-dropdown" className="dropdown-menu-right">
                <NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
                <NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
                <NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
                <NavDropdown.Divider />
                <NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
              </NavDropdown>
            </NavDropdown>
          </Nav>
        </Navbar.Collapse>
      </Navbar>
    </>
  );
};
export default Header;
</code>```

It's work fine, but I want to submenu [dropdown] move to right when run desktop (mobile keep same), while the all dropdown pop in the bottom

Can any one advise

Thank you

Title: Navdropdown move to right on windows

Body:
I'm trying to add navbar from sample as below:

const Header = () => {
  return (
    <>
      <Navbar bg="light" expand="lg">
        <Navbar.Brand href="#home">React-Bootstrap</Navbar.Brand>
        <Navbar.Toggle aria-controls="basic-navbar-nav" />
        <Navbar.Collapse id="basic-navbar-nav">

            Home
            Link
            <NavDropdown title="Dropdown" id="basic-nav-dropdown">
              <NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
              <NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
              <NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
              <NavDropdown.Divider />
              <NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
              <NavDropdown title="Dropdown" id="basic-nav-dropdown" className="dropdown-menu-right">
                <NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
                <NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
                <NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
                <NavDropdown.Divider />
                <NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
              </NavDropdown>
            </NavDropdown>

        </Navbar.Collapse>
      </Navbar>
    </>
  );
};
export default Header;

It's work fine, but I want to submenu [dropdown] move to right when run desktop (mobile keep same), while the all dropdown pop in the bottom

Can any one advise

Thank you


问:
How to connect Zebra ZT-411 with react native expo?
I am trying to connect and print barcode sticker from Zebra ZT-411 printer, but can not find any working solution. Also I am new to mobile app development. Can someone help he here? I have tried https://github.com/anmoljain10 this package but its not compatible with my react native version which is v18.1.0. Is there any other packages I can use?

When I am using:-

npm i react-native-zebra-bluetooth-printer

This is the error showing:-

```<code>npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: sq_sticker@1.0.0
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR!   react@"18.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.1" from react-native-zebra-bluetooth-printer@1.0.9
npm ERR! node_modules/react-native-zebra-bluetooth-printer
npm ERR!   react-native-zebra-bluetooth-printer@"^1.0.9" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\zihan\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\zihan\AppData\Local\npm-cache\_logs\2022-12-31T03_30_38_132Z-debug-0.log
</code>```

If I use:-

npm install --legacy-peer-deps react-native-zebra-bluetooth-printer

Then it installs the package without any problem but when I am trying to use any function from this package it says the function can not be found.

Here I am trying to use a function:-

```<code>import RNZebraBluetoothPrinter from 'react-native-zebra-bluetooth-printer';

RNZebraBluetoothPrinter.enableBluetooth().then((res) => {
        //do something with res
      })
</code>```

And here is the error:-

```<code>Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read properties of undefined (reading 'enableBluetooth')
TypeError: Cannot read properties of undefined (reading 'enableBluetooth')
</code>```

Body:
I am trying to connect and print barcode sticker from Zebra ZT-411 printer, but can not find any working solution. Also I am new to mobile app development. Can someone help he here? I have tried https://github.com/anmoljain10 this package but its not compatible with my react native version which is v18.1.0. Is there any other packages I can use?

When I am using:-

npm i react-native-zebra-bluetooth-printer

This is the error showing:-

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: sq_sticker@1.0.0
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR!   react@"18.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.1" from react-native-zebra-bluetooth-printer@1.0.9
npm ERR! node_modules/react-native-zebra-bluetooth-printer
npm ERR!   react-native-zebra-bluetooth-printer@"^1.0.9" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\zihan\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\zihan\AppData\Local\npm-cache\_logs\2022-12-31T03_30_38_132Z-debug-0.log

If I use:-

npm install --legacy-peer-deps react-native-zebra-bluetooth-printer

Then it installs the package without any problem but when I am trying to use any function from this package it says the function can not be found.

Here I am trying to use a function:-

import RNZebraBluetoothPrinter from 'react-native-zebra-bluetooth-printer';

RNZebraBluetoothPrinter.enableBluetooth().then((res) => {
        //do something with res
      })

And here is the error:-

Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read properties of undefined (reading 'enableBluetooth')
TypeError: Cannot read properties of undefined (reading 'enableBluetooth')


问:
how to add a new column in already existing table in the java class file?
I have my collegue's java web application, where i was asked to edit the table that has been existing, where i have to add a new column.
Everytime i try to add a new column, the alignment of the table changes.
before adding.
enter image description here

after

enter image description here

now the code goes something like this

```<code>data="<table id='v_esTable' class='table table-bordered color-bordered-table inverse-bordered-table'><thead style=\"background-color: #064b87\">"
                 + "<tr><th class=\"text-white\">JEN No.</th >"
                    + "<th class=\"text-white\">Village Name</th>"
                       +"<th class=\"text-white\">Village Name</th>"

                    + "<th class=\"text-white\">Applicant Name</th>"
                    + "<th class=\"text-white\">Awardee Name</th><th class=\"text-white\">Relation To Awardee</th><th class=\"text-white\">Award Date</th>"
                    + "<th class=\"text-white\">Awardee No</th><th class=\"text-white\">Land Extent</th><th class=\"text-white\">Job Status</th>"
                    + "<th class=\"text-white\">ITI Dicipline</th><th class=\"text-white\">Diploma Dicipline</th><th class=\"text-white\">Engg. Dicipline</th>"

</code>```

Body:
I have my collegue's java web application, where i was asked to edit the table that has been existing, where i have to add a new column.
Everytime i try to add a new column, the alignment of the table changes.
before adding.
enter image description here

after

enter image description here

now the code goes something like this

data="

"
                 + "
JEN No.	"
                    + "Village Name	"
                       +"Village Name	"

                    + "Applicant Name	"
                    + "Awardee Name	Relation To Awardee	Award Date	"
                    + "Awardee No	Land Extent	Job Status	"
                    + "ITI Dicipline	Diploma Dicipline	Engg. Dicipline	"


问:
What are the new unique-id's for CUDA streams and contexts useful for?
CUDA 12 introduces two new API calls, cuStreamGetId() and cuCtxGetId() which return "unique ID"s associated with a stream or a context respectively. I'm struggling to understand why this is useful, or how this would be used. Are the handles for streams and contexts not unique? i.e. does CUDA create copies of CUstream_st and CUctx_st structures with the same values, or which describe the same entities? If it does - under what circumstances?


问:
Change from select to value assignment
Am having difficulty enhancing my code to remove the "SELECT" option and use the ASSIGNMENT. Meaning to change from the SELECT, COPY and PASTE to the assigning Values Directly. Am an absolute beginner, if anyone could lead me through. My main issue is in the loop, however, here is the full code, any suggestion, recommendation is welcomed, just to make it more efficient!

Here is my code:

Sub LINK_ANALYSIS()

    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    Application.DisplayStatusBar = False
    Application.EnableEvents = False
    ActiveSheet.DisplayPageBreaks = False

Dim NumberOfColumns As Integer

Dim rng As Range

NumberOfColumns = ActiveSheet.UsedRange.Columns.Count

Sheets("Sheet2").Range("A1").Value2 = Sheets("Sheet1").Range("A1").Value2
Sheets("Sheet2").Range("A2:B2").Value2 = "SUBJECT"

Let x = 4

Do While x <= NumberOfColumns

ActiveSheet.UsedRange.AutoFilter Field:=x, Criteria1:="1", Criteria2:="2", Operator:=xlOr

ActiveSheet.UsedRange.Cells(2, x).Select

Set rng = Range(Cells(ActiveCell.Row + 1, ActiveCell.Column), Cells(Rows.Count, ActiveCell.Column))

rng.SpecialCells(xlCellTypeVisible).Cells(1).Select

If ActiveCell.Value >= "1" Then

       Cells(1, (x - 1)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A2").Select
        Selection.End(xlToRight).Select
        ActiveCell.Offset(0, 1).Select
        ActiveSheet.Paste
        Sheets("Sheet1").Select
        Application.CutCopyMode = False
        Range("A1").Select

End If

ActiveSheet.UsedRange.AutoFilter Field:=x

x = x + 2

Loop

Sheets("Sheet2").Select
ActiveSheet.Cells.EntireColumn.AutoFit
Range("A1").Select

Sheets("Sheet2").Copy

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    Application.DisplayStatusBar = True
    Application.EnableEvents = True
    ActiveSheet.DisplayPageBreaks = True

End Sub
```
<p>The contention...</p>
<pre class="lang-vb prettyprint-override"><code>If ActiveCell.Value >= "1" Then

Sheets("Sheet2").Range("A2").Selection.End(xlToRight).ActiveCell.Offset(0, 1).Value2 = Cells(1, (x - 1)).Range(Selection, Selection.End(xlDown)).Value2

End If
</code>```

I expected this assignment code to copy the selected cells in sheet1 and assign them to the selected cell in sheet2

The copy paste code works but, when i make attempt to use the assignment code it return error "out of range". I design the code to filter selected columns on certain criteria and copy the results from the leftcolmn and past to sheet2, the loop continues until the last column.

Title: Change from select to value assignment

Body:
Am having difficulty enhancing my code to remove the "SELECT" option and use the ASSIGNMENT. Meaning to change from the SELECT, COPY and PASTE to the assigning Values Directly. Am an absolute beginner, if anyone could lead me through. My main issue is in the loop, however, here is the full code, any suggestion, recommendation is welcomed, just to make it more efficient!

Here is my code:

Sub LINK_ANALYSIS()

    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    Application.DisplayStatusBar = False
    Application.EnableEvents = False
    ActiveSheet.DisplayPageBreaks = False

Dim NumberOfColumns As Integer

Dim rng As Range

NumberOfColumns = ActiveSheet.UsedRange.Columns.Count

Sheets("Sheet2").Range("A1").Value2 = Sheets("Sheet1").Range("A1").Value2
Sheets("Sheet2").Range("A2:B2").Value2 = "SUBJECT"

Let x = 4

Do While x <= NumberOfColumns

ActiveSheet.UsedRange.AutoFilter Field:=x, Criteria1:="1", Criteria2:="2", Operator:=xlOr

ActiveSheet.UsedRange.Cells(2, x).Select

Set rng = Range(Cells(ActiveCell.Row + 1, ActiveCell.Column), Cells(Rows.Count, ActiveCell.Column))

rng.SpecialCells(xlCellTypeVisible).Cells(1).Select

If ActiveCell.Value >= "1" Then

       Cells(1, (x - 1)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A2").Select
        Selection.End(xlToRight).Select
        ActiveCell.Offset(0, 1).Select
        ActiveSheet.Paste
        Sheets("Sheet1").Select
        Application.CutCopyMode = False
        Range("A1").Select

End If

ActiveSheet.UsedRange.AutoFilter Field:=x

x = x + 2

Loop

Sheets("Sheet2").Select
ActiveSheet.Cells.EntireColumn.AutoFit
Range("A1").Select

Sheets("Sheet2").Copy

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    Application.DisplayStatusBar = True
    Application.EnableEvents = True
    ActiveSheet.DisplayPageBreaks = True

End Sub

The contention...

If ActiveCell.Value >= "1" Then

Sheets("Sheet2").Range("A2").Selection.End(xlToRight).ActiveCell.Offset(0, 1).Value2 = Cells(1, (x - 1)).Range(Selection, Selection.End(xlDown)).Value2

End If

I expected this assignment code to copy the selected cells in sheet1 and assign them to the selected cell in sheet2

The copy paste code works but, when i make attempt to use the assignment code it return error "out of range". I design the code to filter selected columns on certain criteria and copy the results from the leftcolmn and past to sheet2, the loop continues until the last column.


问:
How to make two rows inside one row react-virtualized?
I need to make for some rows react-virtualized from table, create 2 rows,  1 row it is row react-virtualized second row it is my custom row
Ho to do it, maybe has some example?

I tried use defaultTableRowRenderer() function,as far as I understand, this embeds newlines in react-virtualized table, but I not need this

its must look like this
table

My code look like this

```<code>return (
    <>
      <div style={{ height: "90vh" }}>
        <AutoSizer>
          {({ width, height }) => (
            <TableVirtualized
              headerHeight={70}
              height={height}
              overscanRowCount={5}
              rowHeight={ 80}
              rowCount={rowItems.length}
              rowGetter={({index}) => rowItems[index]}
              width={width}
              className={className}
              rowRenderer={rowRenderer}

            >
              {headerTitles.map((v:any, i:any)=>{
                  const key = Object.keys(v);
                  return (
                      <Column
                        label={v[`${key}`]}
                        dataKey={key}
                        width={200}
                        cellRenderer={(v: any)=> cell(v)}
                        key={i}
                        headerRenderer={()=> formatHeader(v[`${key}`])}
                      />
                  )
                }
                )}
            </TableVirtualized>
          )}
        </AutoSizer>
</code>```

this my rowRender function. I think this is a bad way, because row react-virtualized height is fixed

```<code>  const rowRenderer = (props: any) => {
    const { index, style, className, key, rowData } = props;

      if(rowData.attributes){
        return (
          <div className={cellProps.attributes.className}>
            {defaultTableRowRenderer(props)}
            <div className='blabla'>1</div>
          </div>
        )
      }
    return defaultTableRowRenderer(props);
}
</code>```

Body:
I need to make for some rows react-virtualized from table, create 2 rows,  1 row it is row react-virtualized second row it is my custom row
Ho to do it, maybe has some example?

I tried use defaultTableRowRenderer() function,as far as I understand, this embeds newlines in react-virtualized table, but I not need this

its must look like this
table

My code look like this

return (
    <>

        <AutoSizer>
          {({ width, height }) => (
            <TableVirtualized
              headerHeight={70}
              height={height}
              overscanRowCount={5}
              rowHeight={ 80}
              rowCount={rowItems.length}
              rowGetter={({index}) => rowItems[index]}
              width={width}
              className={className}
              rowRenderer={rowRenderer}

            >
              {headerTitles.map((v:any, i:any)=>{
                  const key = Object.keys(v);
                  return (
                      <Column
                        label={v[`${key}`]}
                        dataKey={key}
                        width={200}
                        cellRenderer={(v: any)=> cell(v)}
                        key={i}
                        headerRenderer={()=> formatHeader(v[`${key}`])}
                      />
                  )
                }
                )}
            </TableVirtualized>
          )}
        </AutoSizer>

this my rowRender function. I think this is a bad way, because row react-virtualized height is fixed

  const rowRenderer = (props: any) => {
    const { index, style, className, key, rowData } = props;

      if(rowData.attributes){
        return (

            {defaultTableRowRenderer(props)}

1

        )
      }
    return defaultTableRowRenderer(props);
}


问:
shp2pgsql can't open a .dbf file on while importing data to Postgres
I am trying to import data to postgres on macOs. I already installed PostGis extension and added it to my database. But whenever I run the command

```<code>shp2pgsql -s <SRID> -c -D -I <path. to file> | \
  psql -d <dbname> -h <host> -U <username>
</code>```

I get the following error:

/Downloads/data/FR_communes.DBF: dbf file (.dbf) can not be opened.

I tried to change files permission but still got the same error.

Body:
I am trying to import data to postgres on macOs. I already installed PostGis extension and added it to my database. But whenever I run the command

shp2pgsql -s <SRID> -c -D -I <path. to file> | \
  psql -d <dbname> -h <host> -U <username>

I get the following error:

/Downloads/data/FR_communes.DBF: dbf file (.dbf) can not be opened.

I tried to change files permission but still got the same error.


问:
module exports giving undefined value while getting called from other than config.js
config.js

```<code>const dotenv = require("dotenv");
dotenv.config();

if (process.env.NODE_ENV === "production") {
  process.env.NODE_ENV = "PRODUCTION";
} else {
  process.env.NODE_ENV = "LOCAL";
}
console.log("Environment : ", process.env.NODE_ENV);
console.log("AIRTABLE_API_KEY : ", process.env.AIRTABLE_API_KEY);

module.exports = {
  AIRTABLE_API_KEY: process.env.AIRTABLE_API_KEY,
};
</code>```

Output of Config.js

Environment :  LOCAL

AIRTABLE_API_KEY :  xxxxxx (config.js is working and giving the expected result)

netowrking.js

```<code>const Airtable = require("airtable");
const https = require("https");
let config = require("../../../config.js");
</code>```

Output of netowrking.js

Environment : LOCAL

AIRTABLE_API_KEY : undefined (networking.js is not working and giving undefined)

I have restarted the IDE multiple times. Process.env is showing undefined values for every other .js file except config.js
Also I have node v 18.something which is LTS
I have dotenv package installed too

Please help

Body:
config.js

const dotenv = require("dotenv");
dotenv.config();

if (process.env.NODE_ENV === "production") {
  process.env.NODE_ENV = "PRODUCTION";
} else {
  process.env.NODE_ENV = "LOCAL";
}
console.log("Environment : ", process.env.NODE_ENV);
console.log("AIRTABLE_API_KEY : ", process.env.AIRTABLE_API_KEY);

module.exports = {
  AIRTABLE_API_KEY: process.env.AIRTABLE_API_KEY,
};

Output of Config.js

Environment :  LOCAL

AIRTABLE_API_KEY :  xxxxxx (config.js is working and giving the expected result)

netowrking.js

const Airtable = require("airtable");
const https = require("https");
let config = require("../../../config.js");

Output of netowrking.js

Environment : LOCAL

AIRTABLE_API_KEY : undefined (networking.js is not working and giving undefined)

I have restarted the IDE multiple times. Process.env is showing undefined values for every other .js file except config.js
Also I have node v 18.something which is LTS
I have dotenv package installed too

Please help


问:
How to create proxy redirects in Netlify dynamically for Contentful assets
How can I create a dynamic proxy for all the assets uploaded in Contentful in netlify.toml file.

Ex- I want to create proxy like example.com/image/Banner.jpg which should point to
Contentful Banner.jpg file,

I want to create proxy redirects dynamically for all asset files so that I do not need to add redirects for each file manually in netlify.toml file


问:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports"
I'm trying to run MERN application. After installing node modules, npm start will throw this error:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in C:\Users\Deeksha\mern-social-media\client\node_modules\postcss-safe-parser\node_modules\postcss\package.json

deleted node modules , installed it again still facing the same isssue


问:
How to link two documents of different collection in firebase
I need to know to link how to link two documents of different collection in firebase.

The method to link them.


问:
How to send email with attachment in PHP using jspdf & Html2PDF
I am creating pdf using jsPDF & Html2PDF . Pdf is generating perfectly and also pdf is downloaded and saved on my pc as I click on button. But I also want to send PDF in mail when i click on submit.

This is the code for generating the PDF

```<code> function generatePDF() {

        // Choose the element id which you want to export.
        $("#TitleHide_BE").attr("hidden", true);
        var element = document.getElementById('content2');
        element.style.width = '800px';
        element.style.height = '1100px';
        var opt = {
            filename: 'invoice.pdf',
            html2canvas: { scale: 1 },
            jsPDF: { unit: 'in', format: 'A4', orientation: 'portrait', precision: '10' }
        };

        // choose the element and pass it to html2pdf() function and call the save() on it to save as pdf.
        html2pdf().set(opt).from(element).save();
    }
</code>```

How can i send this pdf as a attachment in mail

Body:
I am creating pdf using jsPDF & Html2PDF . Pdf is generating perfectly and also pdf is downloaded and saved on my pc as I click on button. But I also want to send PDF in mail when i click on submit.

This is the code for generating the PDF

 function generatePDF() {

        // Choose the element id which you want to export.
        $("#TitleHide_BE").attr("hidden", true);
        var element = document.getElementById('content2');
        element.style.width = '800px';
        element.style.height = '1100px';
        var opt = {
            filename: 'invoice.pdf',
            html2canvas: { scale: 1 },
            jsPDF: { unit: 'in', format: 'A4', orientation: 'portrait', precision: '10' }
        };

        // choose the element and pass it to html2pdf() function and call the save() on it to save as pdf.
        html2pdf().set(opt).from(element).save();
    }

How can i send this pdf as a attachment in mail


问:
PowerShell cannot open shim file for read
I have installed scoop in my Windows PowerShell for ability to install some apps.
When I install app and then try to run it I get an error that there is no possibility to find shim file.  'C:\Windows\System32\apps\scoop\new'  from my logs actually really doesn't exist. Maybe somebody had the same problem. I have found a clue that scoop could be out of date. I checked it and it really is but I cannot update it because i have still the same problem that it cannot read shim file.'scoop config rm SCOOP_REPO' also doesn't help. Any idea how to solve this problem?

```<code>PS C:\Windows\System32\apps\railway\current> scoop update
Updating Scoop...
Cannot open shim file for read.
Could not read shim file.
Remove-Item : Cannot find path 'C:\Windows\System32\apps\scoop\new' because it does not exist.
At C:\Windows\System32\apps\scoop\current\libexec\scoop-update.ps1:79 char:13
+             Remove-Item $newdir -Force -Recurse
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\System32\apps\scoop\new:String) [Remove-Item], ItemNotFoun
   dException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Scoop download failed. If this appears several times, try removing SCOOP_REPO by 'scoop config rm SCOOP_REPO'
</code>```

Body:
I have installed scoop in my Windows PowerShell for ability to install some apps.
When I install app and then try to run it I get an error that there is no possibility to find shim file.  'C:\Windows\System32\apps\scoop\new'  from my logs actually really doesn't exist. Maybe somebody had the same problem. I have found a clue that scoop could be out of date. I checked it and it really is but I cannot update it because i have still the same problem that it cannot read shim file.'scoop config rm SCOOP_REPO' also doesn't help. Any idea how to solve this problem?

PS C:\Windows\System32\apps\railway\current> scoop update
Updating Scoop...
Cannot open shim file for read.
Could not read shim file.
Remove-Item : Cannot find path 'C:\Windows\System32\apps\scoop\new' because it does not exist.
At C:\Windows\System32\apps\scoop\current\libexec\scoop-update.ps1:79 char:13
+             Remove-Item $newdir -Force -Recurse
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\System32\apps\scoop\new:String) [Remove-Item], ItemNotFoun
   dException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Scoop download failed. If this appears several times, try removing SCOOP_REPO by 'scoop config rm SCOOP_REPO'


问:
driver.getTitle() and driver.getCurrentURL() is not workign and throwing error "org.openqa.selenium.UnsupportedCommandException"
Currently working on Mobile Responsive automation testing using Appium 8.0.0 and selenium 4.1.2 version and I could able to invoke the device and load the application url also but when tried to get the title of the web application which is launched in Android chrome browser, getting the below error:
"Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource"

Please find below the code snippet that is used.

```<code>    ChromeOptions browserOptions = new ChromeOptions();
    browserOptions.addArguments("use-fake-device-for-media-stream");
    browserOptions.addArguments("use-fake-ui-for-media-stream");
    Map<String, Object> sauceOptions = new HashMap<>();
    sauceOptions.put("name", "Android Chrome Sample Test");
    sauceOptions.put("tunnelIdentifier", "gopinath_tunnel");
    sauceOptions.put("parentTunnel", "oauth-engineering-8859e");
    sauceOptions.put("name", "Android Chrome Sample Test");
    MutableCapabilities caps = new MutableCapabilities();
    caps.setCapability("appium:deviceName", "Google Pixel 3a GoogleAPI Emulator");
    //caps.setCapability("orientation", "portrait");
    caps.setCapability("browserName", "Chrome");
    caps.setCapability("appium:platformVersion", "12.0");
    caps.setCapability("platformName", "Android");
    caps.setCapability(ChromeOptions.CAPABILITY, browserOptions);
    caps.setCapability("sauce:options", sauceOptions);
    URL url = new URL(
            "https://<Sauclabs username and accesskey>:443/wd/hub");
    driver = new AndroidDriver(url, caps);
    driver.get("<Application URL>");
    Thread.sleep(5000);
    //to allow the location popup
    driver.context("NATIVE_APP");
    driver.findElement(By.xpath(".//android.widget.Button[@text='Allow']")).click();
    System.out.println("Pop up allow is clicked successfully");
    driver.getTitle(); // not executing this line and throwing the mentioned error.
</code>```

Also getting error when trying to switch tabs, getCurrentUrl() and some more methods when used.

I guess the issue is because of W3C compliant but not sure how to resolve this. Could anyone please help or guide me to resolve the above mentioned issue??

Body:
Currently working on Mobile Responsive automation testing using Appium 8.0.0 and selenium 4.1.2 version and I could able to invoke the device and load the application url also but when tried to get the title of the web application which is launched in Android chrome browser, getting the below error:
"Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource"

Please find below the code snippet that is used.

    ChromeOptions browserOptions = new ChromeOptions();
    browserOptions.addArguments("use-fake-device-for-media-stream");
    browserOptions.addArguments("use-fake-ui-for-media-stream");
    Map<String, Object> sauceOptions = new HashMap<>();
    sauceOptions.put("name", "Android Chrome Sample Test");
    sauceOptions.put("tunnelIdentifier", "gopinath_tunnel");
    sauceOptions.put("parentTunnel", "oauth-engineering-8859e");
    sauceOptions.put("name", "Android Chrome Sample Test");
    MutableCapabilities caps = new MutableCapabilities();
    caps.setCapability("appium:deviceName", "Google Pixel 3a GoogleAPI Emulator");
    //caps.setCapability("orientation", "portrait");
    caps.setCapability("browserName", "Chrome");
    caps.setCapability("appium:platformVersion", "12.0");
    caps.setCapability("platformName", "Android");
    caps.setCapability(ChromeOptions.CAPABILITY, browserOptions);
    caps.setCapability("sauce:options", sauceOptions);
    URL url = new URL(
            "https://<Sauclabs username and accesskey>:443/wd/hub");
    driver = new AndroidDriver(url, caps);
    driver.get("<Application URL>");
    Thread.sleep(5000);
    //to allow the location popup
    driver.context("NATIVE_APP");
    driver.findElement(By.xpath(".//android.widget.Button[@text='Allow']")).click();
    System.out.println("Pop up allow is clicked successfully");
    driver.getTitle(); // not executing this line and throwing the mentioned error.

Also getting error when trying to switch tabs, getCurrentUrl() and some more methods when used.

I guess the issue is because of W3C compliant but not sure how to resolve this. Could anyone please help or guide me to resolve the above mentioned issue??


问:
AWS organization without SCP
In the AWS documentation of Policy evaluation logic there is the following image, describing the evaluation of policies logic:

The part for SCP has the following description (upper square in the second from the left): "is the principal's account a member of an organization with an applicable SCP?"

Further, the description below the image for the organization SCP say: "If there is no SCP, or if the SCP allows the requested action, the code continues.".
What I infer is that it is possible for an account member of an organization to not have any applicable SCP. Does that mean that an Organization may have no SCPs at all?

If so, why when trying to detach all policies I get the error: "you cannot remove the last policy attached to specific target. you must have at least one attached at all times".

Quick search in google gives me this result from the documentation: "Every root, OU, and account must have at least one SCP attached."

There is something I am missing but I can't figure out what: how can I have no SCP to check if I must have at least one SCP?

Note: I can have an organization without any SCP if I completely disable the SCP feature. My question is: is it possible for an account to be a member of an organization with the SCP feature on but not have any applicable SCP to it?

Tried what is described above

Title: AWS organization without SCP


问:
I want to use Scratch-gui instead of what provided by snap! submissions plugin on Moodle but when I do so the file does not submit
In moodle I want to assign a assignment to a student, but the assignment submission should be using the snap! submissions plugin. Everything works fine when using the snap! submission Gui for creating a project on the student's end but when I change the iframe GUI to the Scratch-GUI which is running on the localhost the file does not submit.
This is the templates/snapview.mustache file which was there in snap! submissions plugin

```<code>{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template assignsubmission_snap/snapview

    This template will render an iframe for Snap! content.

    Variables required for this template:
    * snapurl - The base Snap! URL.
    * loaded - The mode to display this Snap! project
    * userid - The creator of this Snap! content.
    * attempt - The attempt number.
    * width - Container width.
    * height - Container height.
    * snap_xmlproject - The XML project to load.
    * editable - Edit mode.
    * cloudenabled - If Snap! use cloud features
    * langmoodle - If Snap! use Moodle lang

    Example context (json):
    {
        "snapurl": "https://snap.berkeley.edu/snap.snap.html",
        "loaded": false,
        "userid": "3",
        "attempt": "1",
        "width": "100%",
        "height": "400px",
        "snap_xmlproject": "<project name='projectName' app='Snap! 1.0, http://snap.berkeley.edu' version='1'><notes>...</notes></project>",
        "editable": false,
        "cloudenabled": "0",
        "langmoodle": "ca"
    }

}}
<div class="snap-button_snap{{#loaded}} snap-hidden_snap"{{/loaded}}">
    <span id="snapButton_snap-{{userid}}-{{attempt}}" onclick="require(['assignsubmission_snap/view'], function(View) {View.start('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}');});">{{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}</span>
    <a href="#" id="play_snap-{{userid}}-{{attempt}}" onclick="require(['assignsubmission_snap/view'], function(View) {View.start('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}');}); return false;"><i id="playicon_snap-{{userid}}-{{attempt}}" class="fa fa-fw fa-play"></i></a>
</div>

<div id="snapContainer_snap-{{userid}}-{{attempt}}"{{^loaded}} class="snap-hidden_snap"{{/loaded}} style="width: {{width}}; height: {{height}}; overflow: auto;">
    <div id="snapNavBar_snap-{{userid}}-{{attempt}}" class="snap-navbar_snap" style="width:910px">
        <span onclick="require(['assignsubmission_snap/view'], function(View) {View.toogleFullScreen('{{userid}}', '{{attempt}}');});">{{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}</span>
        <a href="#" id="togglingFS_snap-{{userid}}-{{attempt}}" onclick="require(['assignsubmission_snap/view'], function(View) {View.toogleFullScreen('{{userid}}', '{{attempt}}');}); return false;"><i id="togglingFSicon_snap-{{userid}}-{{attempt}}" class="fa fa-fw fa-expand"></i></a>
        {{#editable}}<a href="#" onclick="document.getElementById('id_submitbutton').click()"><i class="fa fa-fw fa-save"></i></a>{{/editable}}
        {{^editable}}<span class="snap-readonlyWarning_snap">{{#str}} snap_readonlywarning, assignsubmission_snap {{/str}}</span>{{/editable}}
    </div>
        <iframe src="{{snapurl}}#run:{{snap_xmlproject}}&noRun&editMode&noExitWarning{{#langmoodle}}&lang={{langmoodle}}{{/langmoodle}}{{^cloudenabled}}&noCloud{{/cloudenabled}}" id="snap_snap-{{userid}}-{{attempt}}" style="width:910px; height: 500px">
    </iframe>
</div>
{{#editable}}{{#js}}
    require(['assignsubmission_snap/init'], function(Init) {Init.init('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}', true);});
{{/js}}{{/editable}}
</code>```

I just changed the iframe url to the scratch gui on which is running on localhost

```<code>{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template assignsubmission_snap/snapview

    This template will render an iframe for Snap! content.

    Variables required for this template:
    * snapurl - The base Snap! URL.
    * loaded - The mode to display this Snap! project
    * userid - The creator of this Snap! content.
    * attempt - The attempt number.
    * width - Container width.
    * height - Container height.
    * snap_xmlproject - The XML project to load.
    * editable - Edit mode.
    * cloudenabled

     If Snap! use cloud features
    * langmoodle - If Snap! use Moodle lang

    Example context (json):
    {
        "snapurl": "https://snap.berkeley.edu/snap.snap.html",
        "loaded": false,
        "userid": "3",
        "attempt": "1",
        "width": "100%",
        "height": "400px",
        "snap_xmlproject": "<project name='projectName' app='Snap! 1.0, http://snap.berkeley.edu' version='1'><notes>...</notes></project>",
        "editable": false,
        "cloudenabled": "0",
        "langmoodle": "ca"
    }

}}
<div class="snap-button_snap{{#loaded}} snap-hidden_snap"{{/loaded}}">
    <span id="snapButton_snap-{{userid}}-{{attempt}}" onclick="require(['assignsubmission_snap/view'], function(View) {View.start('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}');});">{{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}</span>
    <a href="#" id="play_snap-{{userid}}-{{attempt}}" onclick="require(['assignsubmission_snap/view'], function(View) {View.start('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}');}); return false;"><i id="playicon_snap-{{userid}}-{{attempt}}" class="fa fa-fw fa-play"></i></a>
</div>

<div id="snapContainer_snap-{{userid}}-{{attempt}}"{{^loaded}} class="snap-hidden_snap"{{/loaded}} style="width: {{width}}; height: {{height}}; overflow: auto;">
    <div id="snapNavBar_snap-{{userid}}-{{attempt}}" class="snap-navbar_snap" style="width:910px">
        <span onclick="require(['assignsubmission_snap/view'], function(View) {View.toogleFullScreen('{{userid}}', '{{attempt}}');});">{{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}</span>
        <a href="#" id="togglingFS_snap-{{userid}}-{{attempt}}" onclick="require(['assignsubmission_snap/view'], function(View) {View.toogleFullScreen('{{userid}}', '{{attempt}}');}); return false;"><i id="togglingFSicon_snap-{{userid}}-{{attempt}}" class="fa fa-fw fa-expand"></i></a>
        {{#editable}}<a href="#" onclick="document.getElementById('id_submitbutton').click()"><i class="fa fa-fw fa-save"></i></a>{{/editable}}
        {{^editable}}<span class="snap-readonlyWarning_snap">{{#str}} snap_readonlywarning, assignsubmission_snap {{/str}}</span>{{/editable}}
    </div>
    <iframe src="http://localhost:8601#run:{{snap_xmlproject}}&noRun&editMode&noExitWarning{{#langmoodle}}&lang={{langmoodle}}{{/langmoodle}}{{^cloudenabled}}&noCloud{{/cloudenabled}}" id="snap_snap-{{userid}}-{{attempt}}" style="width:910px; height: 500px">
    </iframe>
</div>
{{#editable}}{{#js}}
    require(['assignsubmission_snap/init'], function(Init) {Init.init('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}', true);});
{{/js}}{{/editable}}
</code>```

This change in code shows the scratch-Gui which is running on localhost but when a student tries to submit the project nothing happens. can I know why does it does not submit the assignment

Body:
In moodle I want to assign a assignment to a student, but the assignment submission should be using the snap! submissions plugin. Everything works fine when using the snap! submission Gui for creating a project on the student's end but when I change the iframe GUI to the Scratch-GUI which is running on the localhost the file does not submit.
This is the templates/snapview.mustache file which was there in snap! submissions plugin

{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template assignsubmission_snap/snapview

    This template will render an iframe for Snap! content.

    Variables required for this template:
    * snapurl - The base Snap! URL.
    * loaded - The mode to display this Snap! project
    * userid - The creator of this Snap! content.
    * attempt - The attempt number.
    * width - Container width.
    * height - Container height.
    * snap_xmlproject - The XML project to load.
    * editable - Edit mode.
    * cloudenabled - If Snap! use cloud features
    * langmoodle - If Snap! use Moodle lang

    Example context (json):
    {
        "snapurl": "https://snap.berkeley.edu/snap.snap.html",
        "loaded": false,
        "userid": "3",
        "attempt": "1",
        "width": "100%",
        "height": "400px",
        "snap_xmlproject": "<project name='projectName' app='Snap! 1.0, http://snap.berkeley.edu' version='1'><notes>...</notes></project>",
        "editable": false,
        "cloudenabled": "0",
        "langmoodle": "ca"
    }

}}

    {{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}

        {{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}

        {{#editable}}{{/editable}}
        {{^editable}}{{#str}} snap_readonlywarning, assignsubmission_snap {{/str}}{{/editable}}

{{#editable}}{{#js}}
    require(['assignsubmission_snap/init'], function(Init) {Init.init('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}', true);});
{{/js}}{{/editable}}

I just changed the iframe url to the scratch gui on which is running on localhost

{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template assignsubmission_snap/snapview

    This template will render an iframe for Snap! content.

    Variables required for this template:
    * snapurl - The base Snap! URL.
    * loaded - The mode to display this Snap! project
    * userid - The creator of this Snap! content.
    * attempt - The attempt number.
    * width - Container width.
    * height - Container height.
    * snap_xmlproject - The XML project to load.
    * editable - Edit mode.
    * cloudenabled

     If Snap! use cloud features
    * langmoodle - If Snap! use Moodle lang

    Example context (json):
    {
        "snapurl": "https://snap.berkeley.edu/snap.snap.html",
        "loaded": false,
        "userid": "3",
        "attempt": "1",
        "width": "100%",
        "height": "400px",
        "snap_xmlproject": "<project name='projectName' app='Snap! 1.0, http://snap.berkeley.edu' version='1'><notes>...</notes></project>",
        "editable": false,
        "cloudenabled": "0",
        "langmoodle": "ca"
    }

}}

    {{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}

        {{#pix}} snapMoodle, assignsubmission_snap, Snap! in Moodle {{/pix}}

        {{#editable}}{{/editable}}
        {{^editable}}{{#str}} snap_readonlywarning, assignsubmission_snap {{/str}}{{/editable}}

{{#editable}}{{#js}}
    require(['assignsubmission_snap/init'], function(Init) {Init.init('{{snap_xmlproject}}', '{{userid}}', '{{attempt}}', true);});
{{/js}}{{/editable}}

This change in code shows the scratch-Gui which is running on localhost but when a student tries to submit the project nothing happens. can I know why does it does not submit the assignment


问:
Docker container and image is removed automatically, where to look for the reason?
docker-compose.yml

```<code>version: '3.7'
services:
  dev-zeppelin:
    image: zeppelin-docker:latest
    container_name: dev-zeppelin
    hostname: dev-zeppelin
    user: '0'
    volumes:
      - ./logs:/logs
      - ./notebook:/notebook
      - ./interpreter-setting.json:/opt/zeppelin/interpreter/solr/interpreter-setting.json
    ports:
      - 8888:8080
    environment:
      - ZEPPELIN_LOG_DIR=/logs
      - ZEPPELIN_NOTEBOOK_DIR=/notebook
</code>```

Dockerfile

```<code>Base Image
FROM apache/zeppelin:0.10.1

# Set the working directory
WORKDIR /opt/zeppelin

# Run container with root user
USER 0

# Install zeppelin solr lib.
RUN ./bin/install-interpreter.sh --name solr --artifact com.lucidworks.zeppelin:zeppelin-solr:0.1.6
</code>```

after i spinup the container using "docker compose up -d" the container is up and running for few days and suddenly disappear (removed) and also i cannot see the image, i don't know where to look for the reason.

if it just stopped/exited with code, then i can do "docker logs container-name", but here everything is gone.

Body:
docker-compose.yml

version: '3.7'
services:
  dev-zeppelin:
    image: zeppelin-docker:latest
    container_name: dev-zeppelin
    hostname: dev-zeppelin
    user: '0'
    volumes:
      - ./logs:/logs
      - ./notebook:/notebook
      - ./interpreter-setting.json:/opt/zeppelin/interpreter/solr/interpreter-setting.json
    ports:
      - 8888:8080
    environment:
      - ZEPPELIN_LOG_DIR=/logs
      - ZEPPELIN_NOTEBOOK_DIR=/notebook

Dockerfile

Base Image
FROM apache/zeppelin:0.10.1

# Set the working directory
WORKDIR /opt/zeppelin

# Run container with root user
USER 0

# Install zeppelin solr lib.
RUN ./bin/install-interpreter.sh --name solr --artifact com.lucidworks.zeppelin:zeppelin-solr:0.1.6

after i spinup the container using "docker compose up -d" the container is up and running for few days and suddenly disappear (removed) and also i cannot see the image, i don't know where to look for the reason.

if it just stopped/exited with code, then i can do "docker logs container-name", but here everything is gone.


问:
visual-studio-code: fatal error C1090: PDB API call failed, error code '3': vc143.pdb?
I am building vtk using vs code with CMake.

The configuring is OK:

Then, I build CommonCore projection, and the bug is reported:

```<code>[build] C:\Users\qiang_zhang\Desktop\VTK-9.2.2\Common\Core\SMP\STDThread\vtkSMPToolsImpl.cxx : fatal error C1090: PDB API call failed，error code “3”: C:\Users\qiang_zhang\Desktop\VTK-9.2.2\build\Common\Core\CommonCore.dir\Debug\vc143.pdb [C:\Users\qiang_zhang\Desktop\VTK-9.2.2\build\Common\Core\CommonCore.vcxproj]
[proc] The command: "D:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/qiang_zhang/Desktop/VTK-9.2.2/build --config Debug --target CommonCore -j 10 -- exited with code: 1 and signal: null
[build] Build finished with exit code 1
</code>```

My environment is:

```<code>win10, 64 operation system
CMake:
    variant: Debug
    kit: Visual Studio Community 2022 Release-amd64
</code>```

The availabel kits are:

How can I fix the fatal error C1090 bug? Any suggestion is appreciated~~~

Body:
I am building vtk using vs code with CMake.

The configuring is OK:

Then, I build CommonCore projection, and the bug is reported:

[build] C:\Users\qiang_zhang\Desktop\VTK-9.2.2\Common\Core\SMP\STDThread\vtkSMPToolsImpl.cxx : fatal error C1090: PDB API call failed，error code “3”: C:\Users\qiang_zhang\Desktop\VTK-9.2.2\build\Common\Core\CommonCore.dir\Debug\vc143.pdb [C:\Users\qiang_zhang\Desktop\VTK-9.2.2\build\Common\Core\CommonCore.vcxproj]
[proc] The command: "D:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/qiang_zhang/Desktop/VTK-9.2.2/build --config Debug --target CommonCore -j 10 -- exited with code: 1 and signal: null
[build] Build finished with exit code 1

My environment is:

win10, 64 operation system
CMake:
    variant: Debug
    kit: Visual Studio Community 2022 Release-amd64

The availabel kits are:

How can I fix the fatal error C1090 bug? Any suggestion is appreciated~~~


问:
Thumbnail close button is not working in Javascript
I am trying to upload multiple images using a form. Selecting multiple images, all the image Thumbnails are displayed with close icon. If I click the close icon, the Thumbnail disappears but the number of selected images did not decreases.

Suppose, I select 5 images, 5 image Thumbnails are displayed with a close icon. When I click the close icon, 4 Thumbnails are displayed but the number of selected images still remains 5.

I have submitted my script and HTML code below.

thank you all...

HTML

```<code><div class="upload__box">
      <div class="upload__btn-box">
          <label class="form-label">Select Images</label>
          <input name="image_mul[]" type="file" class="form-control upload__inputfile" id="" multiple accept="image/*">
      </div>
      <div class="upload__img-wrap"></div>
    </div>
</code>```

Javascript

```<code><script>
jQuery(document).ready(function () {
  ImgUpload();
});

function ImgUpload() {
  var imgWrap = "";
  var imgArray = [];

  $('.upload__inputfile').each(function () {
    $(this).on('change', function (e) {
      imgWrap = $(this).closest('.upload__box').find('.upload__img-wrap');
      var maxLength = $(this).attr('data-max_length');
      var files = e.target.files;
      var filesArr = Array.prototype.slice.call(files);
      var iterator = 0;
      filesArr.forEach(function (f, index) {

    if (!f.type.match('image.*')) {
      return;
    }

    if (imgArray.length > maxLength) {
      return false
    } else {
      var len = 0;
      for (var i = 0; i < imgArray.length; i++) {
        if (imgArray[i] !== undefined) {
          len++;
        }
      }
      if (len > maxLength) {
        return false;
      } else {
        imgArray.push(f);

        var reader = new FileReader();
        reader.onload = function (e) {
          var html = "<div class='upload__img-box'><div style='background-image: url(" + e.target.result + ")' data-number='" + $(".upload__img-close").length + "' data-file='" + f.name + "' class='img-bg'><div class='upload__img-close'></div></div></div>";
          imgWrap.append(html);
          iterator++;
        }
        reader.readAsDataURL(f);
      }
    }
  });
});

 });
  $('body').on('click', ".upload__img-close", function (e) {
    var file = $(this).parent().data("file");
    for (var i = 0; i < imgArray.length; i++) {
      if (imgArray[i].name === file) {
        imgArray.splice(i, 1);
        break;
      }
    }
    $(this).parent().parent().remove();
  });
}
</script>
</code>```

Body:
I am trying to upload multiple images using a form. Selecting multiple images, all the image Thumbnails are displayed with close icon. If I click the close icon, the Thumbnail disappears but the number of selected images did not decreases.

Suppose, I select 5 images, 5 image Thumbnails are displayed with a close icon. When I click the close icon, 4 Thumbnails are displayed but the number of selected images still remains 5.

I have submitted my script and HTML code below.

thank you all...

HTML

          Select Images
          <input name="image_mul[]" type="file" class="form-control upload__inputfile" id="" multiple accept="image/*">

Javascript


问:
hls.js play backward and forward by currentTime
I play the video by currentTime property forward, but sometimes the video stop and for few second, the video jump forward. You can see the seeked function below.

How do I use currentTime property to play instead of play() function. Here is a demo below.

<video id="video" controls></video>
<button id="test">Play</button>
```
<pre class="lang-css prettyprint-override"><code>video {
  width: 600px;
  height: 300px;
}
</code>```

 var video = document.getElementById('video')
  var hls = new Hls({
    // debug: true
  })
  hls.loadSource('https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8')
  hls.attachMedia(video)
  video.pause()

  var testBtn = document.getElementById('test')
  var timer = null
  let index = 0;
  video.addEventListener('seeked', () => {
    console.log('seeked', index++); // something it stop and run, this is abnormal
  })

  testBtn.addEventListener('click', () => {
    clearInterval(timer)

    // seek to 00:00
    video.currentTime = 0

    // play forwards
    timer = setInterval(() => {
      video.currentTime += 0.05
    }, 50)
  })
```

demo

Body:
I play the video by currentTime property forward, but sometimes the video stop and for few second, the video jump forward. You can see the seeked function below.

How do I use currentTime property to play instead of play() function. Here is a demo below.

<video id="video" controls></video>
<button id="test">Play</button>

video {
  width: 600px;
  height: 300px;
}

 var video = document.getElementById('video')
  var hls = new Hls({
    // debug: true
  })
  hls.loadSource('https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8')
  hls.attachMedia(video)
  video.pause()

  var testBtn = document.getElementById('test')
  var timer = null
  let index = 0;
  video.addEventListener('seeked', () => {
    console.log('seeked', index++); // something it stop and run, this is abnormal
  })

  testBtn.addEventListener('click', () => {
    clearInterval(timer)

    // seek to 00:00
    video.currentTime = 0

    // play forwards
    timer = setInterval(() => {
      video.currentTime += 0.05
    }, 50)
  })

demo


问:
How to import Tailwind configuration values from Qwik components?
I'm trying to import some configurations from Tailwin in Qwik component.

Inside tailwind.config.js I have this code:

```<code>// tailwind.config.js file

const defaultTheme = require('tailwindcss/defaultTheme')
// custom configuration

const { sm, md, lg, xl } = defaultTheme.screens

module.exports.sm = sm.replace('px', '') * 1;
module.exports.md = md.replace('px', '') * 1;
module.exports.lg = lg.replace('px', '') * 1;
module.exports.xl = xl.replace('px', '') * 1;
</code>```

And inside my Qwik component:

```<code>import { sm, md, lg, xl } from '../../tailwind.config.js'
</code>```

However, I get this error:

[vite] Internal server error: require is not defined

How can I export config from Tailwind and import it in my Qwik components?

Body:
I'm trying to import some configurations from Tailwin in Qwik component.

Inside tailwind.config.js I have this code:

// tailwind.config.js file

const defaultTheme = require('tailwindcss/defaultTheme')
// custom configuration

const { sm, md, lg, xl } = defaultTheme.screens

module.exports.sm = sm.replace('px', '') * 1;
module.exports.md = md.replace('px', '') * 1;
module.exports.lg = lg.replace('px', '') * 1;
module.exports.xl = xl.replace('px', '') * 1;

And inside my Qwik component:

import { sm, md, lg, xl } from '../../tailwind.config.js'

However, I get this error:

[vite] Internal server error: require is not defined

How can I export config from Tailwind and import it in my Qwik components?


问:
JSONDecodeError: Expecting value: line 1 column 1 (char 0) when using google api
I'm using google api in python. My purpose is find and download any image similar with my image. This my error:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Administrator\.vscode\tempCodeRunnerFile.python", line 27, in <module>
    results = response.json()["items"]
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```
<p>What was wrong with my code? I noticed <code>response</code> was return <code><Response [400]></code>, i guess it is problem with my code. How to fix it? Any help is appreciated. Below is the code:</p>
<pre class="lang-python prettyprint-override"><code>import requests
import urllib.request

# Replace YOUR_API_KEY with your actual API key
api_key = "YOUR_API_KEY"

# Load the image you want to search for
# image_data = open("path/to/image.jpg", "rb").read()
image_data = open("C:\\Users\\Administrator\\Downloads\\theme\\3f559715-f407-47de-8540-1cd9e4fdc56c.jpg", "rb").read()

# Send the request to the Google Search API's "similar images" feature
response = requests.post(
    "https://www.googleapis.com/customsearch/v1/similar?",
    params={
        "key": api_key,
        # "cx": "YOUR_CX_VALUE",  # Replace YOUR_CX_VALUE with your actual CX value
        "cx": "d47119ff66e004d6b",
    },
    headers={
        "Content-Type": "image/jpeg",
    },
    data=image_data,
)
# print(response) -><Response [400]>

# Get the search results from the response
results = response.json()["items"]

# Iterate through the search results and download the images
for result in results:
    image_url = result["link"]
    image_filename = image_url.split("/")[-1]
    urllib.request.urlretrieve(image_url, image_filename)
    print(f"Downloaded image: {image_filename}")

</code>```

Body:
I'm using google api in python. My purpose is find and download any image similar with my image. This my error:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Administrator\.vscode\tempCodeRunnerFile.python", line 27, in <module>
    results = response.json()["items"]
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

What was wrong with my code? I noticed response was return <Response [400]>, i guess it is problem with my code. How to fix it? Any help is appreciated. Below is the code:

import requests
import urllib.request

# Replace YOUR_API_KEY with your actual API key
api_key = "YOUR_API_KEY"

# Load the image you want to search for
# image_data = open("path/to/image.jpg", "rb").read()
image_data = open("C:\\Users\\Administrator\\Downloads\\theme\\3f559715-f407-47de-8540-1cd9e4fdc56c.jpg", "rb").read()

# Send the request to the Google Search API's "similar images" feature
response = requests.post(
    "https://www.googleapis.com/customsearch/v1/similar?",
    params={
        "key": api_key,
        # "cx": "YOUR_CX_VALUE",  # Replace YOUR_CX_VALUE with your actual CX value
        "cx": "d47119ff66e004d6b",
    },
    headers={
        "Content-Type": "image/jpeg",
    },
    data=image_data,
)
# print(response) -><Response [400]>

# Get the search results from the response
results = response.json()["items"]

# Iterate through the search results and download the images
for result in results:
    image_url = result["link"]
    image_filename = image_url.split("/")[-1]
    urllib.request.urlretrieve(image_url, image_filename)
    print(f"Downloaded image: {image_filename}")


问:
ERROR Error: formGroup expects a FormGroup instance. in dynamic form
I'm creating dynamic form control in angular with this data

```<code>"data": [
            {
                "sno": 1,
                "name": "name",
                "nameLabel": "Name",
                "isRequired": 1,
                "maxLen": 50,
                "order": 1,

            },
            {
                "sno": 2,
                "name": "desc",
                "nameLabel": "Description",
                "isRequired": 1,
                "maxLen": 50,
                "order": 2,
            },
            ..
            ..
</code>```

in Oninit method

```<code>  rForm: FormGroup;
  Data:any=[];
  ngOnInit(): void {
    let json = {
      ....
    }
    this.Service.Info(json).subscribe((data) => {

      this.Data=data;
     for (const field of this.Data) {
      let validators = [];
      validators.push(Validators.required);
      this.rForm.addControl(field.name, this.fb.control('', validators));
    }
    });
  }
</code>```

in html component using this

```<code> <form *ngIf="Data?.length" [formGroup]="rForm">
            <div class="col-lg-4 col-md-12 col-12" >
                <div class="form-group">
                    <label for="">Email</label>
                    <input type="text" class="form-control" placeholder="Email">
                </div>
            </div>
</code>```

but unable to render dynamic fields

ERROR Error: formGroup expects a FormGroup instance. Please pass one
in.

Any solution to fix this issue. Thanks

Body:
I'm creating dynamic form control in angular with this data

"data": [
            {
                "sno": 1,
                "name": "name",
                "nameLabel": "Name",
                "isRequired": 1,
                "maxLen": 50,
                "order": 1,

            },
            {
                "sno": 2,
                "name": "desc",
                "nameLabel": "Description",
                "isRequired": 1,
                "maxLen": 50,
                "order": 2,
            },
            ..
            ..

in Oninit method

  rForm: FormGroup;
  Data:any=[];
  ngOnInit(): void {
    let json = {
      ....
    }
    this.Service.Info(json).subscribe((data) => {

      this.Data=data;
     for (const field of this.Data) {
      let validators = [];
      validators.push(Validators.required);
      this.rForm.addControl(field.name, this.fb.control('', validators));
    }
    });
  }

in html component using this

 <form *ngIf="Data?.length" [formGroup]="rForm">

                    Email
                    <input type="text" class="form-control" placeholder="Email">

but unable to render dynamic fields

ERROR Error: formGroup expects a FormGroup instance. Please pass one
in.

Any solution to fix this issue. Thanks


问:
unable to initialize kubernetes cluster
I was learning to set up a single node Kubernetes cluster but was not able to initalise it. Ive done some research and have done a few fixes but still couldn't get my kubelet running. Can someone help tks a lot!
My environment (on my Ubuntu 64 bit, VMware Workstation 17 Player ) :
Distributor ID:  Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename:    jammy

The errors are shown below.

```<code>liming@liming-virtual-machine-3:/$ sudo kubeadm init

[init] Using Kubernetes version: v1.26.0
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local liming-virtual-machine-3] and IPs [10.96.0.1 192.168.2.132]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [liming-virtual-machine-3 localhost] and IPs [192.168.2.132 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [liming-virtual-machine-3 localhost] and IPs [192.168.2.132 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.

Unfortunately, an error has occurred:
    timed out waiting for the condition

This error is likely caused by:
    - The kubelet is not running
    - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
    - 'systemctl status kubelet'
    - 'journalctl -xeu kubelet'

Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI.
Here is one example how you may list all running Kubernetes containers by using crictl:
    - 'crictl --runtime-endpoint unix:///var/run/containerd/containerd.sock ps -a | grep kube | grep -v pause'
    Once you have found the failing container, you can inspect its logs with:
    - 'crictl --runtime-endpoint unix:///var/run/containerd/containerd.sock logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster

</code>```
```<code>liming@liming-virtual-machine-3:~$ systemctl status kubelet
× kubelet.service - kubelet
     Loaded: loaded (/etc/systemd/system/kubelet.service; enabled; vendor pres>
     Active: failed (Result: exit-code) since Mon 2022-12-26 17:05:54 +08; 2h >
   Main PID: 3223 (code=exited, status=217/USER)
        CPU: 1ms

Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Schedule>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Stopped kubelet.
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Start re>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Failed w>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Failed to start kubelet.
lines 1-11/11 (END)
</code>```

Fixes Ive done beforehand are shown below .

```<code>$ iptables -F
$ swapoff -a
$ free -m
$ kubeadm reset
$ kubeadm init
</code>```

Ive also set the docker cgroup driver to systemd

```<code>docker info |grep -i cgroup

Cgroup Driver: systemd
Cgroup Version: 2
cgroupns
</code>```

Below is the kubelet log:

```<code>liming@liming-virtual-machine-3:~$ journalctl -xeu kubelet
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ Automatic restarting of the unit kubelet.service has been scheduled, as the>
░░ the configured Restart= setting for the unit.
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Stopped kubelet.
░░ Subject: A stop job for unit kubelet.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit kubelet.service has finished.
░░
░░ The job identifier is 3203 and the job result is done.
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Start re>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Failed w>
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit kubelet.service has entered the 'failed' state with result 'exit-c>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Failed to start kubelet.
░░ Subject: A start job for unit kubelet.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit kubelet.service has finished with a failure.
░░
░░ The job identifier is 3203 and the job result is failed.
</code>```

My swap should have already been disabled as shown below.

```<code>liming@liming-virtual-machine-3:~$ systemctl list-units --type=swap --state=active
  UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.
</code>```

Title: unable to initialize kubernetes cluster

Body:
I was learning to set up a single node Kubernetes cluster but was not able to initalise it. Ive done some research and have done a few fixes but still couldn't get my kubelet running. Can someone help tks a lot!
My environment (on my Ubuntu 64 bit, VMware Workstation 17 Player ) :
Distributor ID:  Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename:    jammy

The errors are shown below.

liming@liming-virtual-machine-3:/$ sudo kubeadm init

[init] Using Kubernetes version: v1.26.0
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local liming-virtual-machine-3] and IPs [10.96.0.1 192.168.2.132]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [liming-virtual-machine-3 localhost] and IPs [192.168.2.132 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [liming-virtual-machine-3 localhost] and IPs [192.168.2.132 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.

Unfortunately, an error has occurred:
    timed out waiting for the condition

This error is likely caused by:
    - The kubelet is not running
    - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
    - 'systemctl status kubelet'
    - 'journalctl -xeu kubelet'

Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI.
Here is one example how you may list all running Kubernetes containers by using crictl:
    - 'crictl --runtime-endpoint unix:///var/run/containerd/containerd.sock ps -a | grep kube | grep -v pause'
    Once you have found the failing container, you can inspect its logs with:
    - 'crictl --runtime-endpoint unix:///var/run/containerd/containerd.sock logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster

liming@liming-virtual-machine-3:~$ systemctl status kubelet
× kubelet.service - kubelet
     Loaded: loaded (/etc/systemd/system/kubelet.service; enabled; vendor pres>
     Active: failed (Result: exit-code) since Mon 2022-12-26 17:05:54 +08; 2h >
   Main PID: 3223 (code=exited, status=217/USER)
        CPU: 1ms

Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Schedule>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Stopped kubelet.
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Start re>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Failed w>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Failed to start kubelet.
lines 1-11/11 (END)

Fixes Ive done beforehand are shown below .

$ iptables -F
$ swapoff -a
$ free -m
$ kubeadm reset
$ kubeadm init

Ive also set the docker cgroup driver to systemd

docker info |grep -i cgroup

Cgroup Driver: systemd
Cgroup Version: 2
cgroupns

Below is the kubelet log:

liming@liming-virtual-machine-3:~$ journalctl -xeu kubelet
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ Automatic restarting of the unit kubelet.service has been scheduled, as the>
░░ the configured Restart= setting for the unit.
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Stopped kubelet.
░░ Subject: A stop job for unit kubelet.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit kubelet.service has finished.
░░
░░ The job identifier is 3203 and the job result is done.
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Start re>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: kubelet.service: Failed w>
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit kubelet.service has entered the 'failed' state with result 'exit-c>
Dec 26 17:05:54 liming-virtual-machine-3 systemd[1]: Failed to start kubelet.
░░ Subject: A start job for unit kubelet.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit kubelet.service has finished with a failure.
░░
░░ The job identifier is 3203 and the job result is failed.

My swap should have already been disabled as shown below.

liming@liming-virtual-machine-3:~$ systemctl list-units --type=swap --state=active
  UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.