问:
VMWare Ignores prefix in boot.cfg
I am trying to PXE boot VMWare ESXi and it gets to boot.cfg, tries to download all the modules,  but runs into problem when it doesn't follow the prefix directive.

I have configured boot.cfg as follows:

```<code>bootstate=0
title=Loading ESXi installer
timeout=5
kernel=/tboot.b00
prefix=/VMware-ESXi-6.5U2-RollupISO
kernelopt=runweasel
modules=/b.b00 --- /jumpstrt.gz --- /useropts.gz --- /features.gz --- /k.b00 --- /chardevs.b00 --- /a.b00 --- /user.b00 --- /uc_intel.b00 --- /uc_amd.b00 --- /sb.v00 --- /s.v00 --- /scsi_cel.v00 --- /scsi_esa.v00 --- /scsi_esa.v01 --- /scsi_cel.v01 --- /scsi_esa.v02 --- /scsi_aac.v00 --- /scsi_adp.v00 --- /dell_sha.v00 --- /lsi_mr3.v00 --- /lsi_msgp.v00 --- /scsi_meg.v00 --- /scsi_mpt.v00 --- /bnxtnet.v00 --- /bnxtroce.v00 --- /net_enic.v00 --- /scsi_fni.v00 --- /scsi_sni.v00 --- /cxl.v00 --- /ima_csio.v00 --- /net_cxgb.v00 --- /scsi_csi.v00 --- /ima_be2i.v00 --- /scsi_be2.v00 --- /sas_vgc.v00 --- /scsi_hps.v00 --- /hfcndd.v00 --- /scsi_hfc.v00 --- /block_hi.v00 --- /hiodrive.v00 --- /net_ibma.v00 --- /scsi_roc.v00 --- /i40en.v00 --- /iavmd.v00 --- /igbn.v00 --- /intel_nv.v00 --- /ixgben.v00 --- /net_i40e.v00 --- /net_igb.v00 --- /net_ixgb.v00 --- /mx_nvme.v00 --- /nmlx5_co.v00 --- /nmlx5_rd.v00 --- /net_mlx_.v00 --- /net_mlx4.v00 --- /net_mlx4.v01 --- /nhpsa.v00 --- /scsi_ocz.v00 --- /nqlcnic.v00 --- /qcnic.v00 --- /qedentv.v00 --- /qedrntv.v00 --- /qfle3.v00 --- /qfle3f.v00 --- /qfle3i.v00 --- /ima_qla4.v00 --- /misc_cni.v00 --- /net_bna.v00 --- /net_bnx2.v00 --- /net_bnx2.v01 --- /net_cnic.v00 --- /net_nx_n.v00 --- /net_qlcn.v00 --- /net_qlge.v00 --- /qlnative.v00 --- /scsi_bfa.v00 --- /scsi_bnx.v00 --- /scsi_bnx.v01 --- /scsi_qla.v00 --- /smgnvme.v00 --- /iomemory.v00 --- /native_s.v00 --- /net_sgb.v00 --- /net_sxgb.v00 --- /scsi_ste.v00 --- /ata_liba.v00 --- /ata_pata.v00 --- /ata_pata.v01 --- /ata_pata.v02 --- /ata_pata.v03 --- /ata_pata.v04 --- /ata_pata.v05 --- /ata_pata.v06 --- /ata_pata.v07 --- /block_cc.v00 --- /brcmfcoe.v00 --- /char_ran.v00 --- /ehci_ehc.v00 --- /elxnet.v00 --- /hid_hid.v00 --- /ipmi_ipm.v00 --- /ipmi_ipm.v01 --- /ipmi_ipm.v02 --- /lpfc.v00 --- /lsi_msgp.v01 --- /lsi_msgp.v02 --- /misc_dri.v00 --- /mtip32xx.v00 --- /ne1000.v00 --- /nenic.v00 --- /net_cdc_.v00 --- /net_e100.v00 --- /net_e100.v01 --- /net_fcoe.v00 --- /net_forc.v00 --- /net_libf.v00 --- /net_tg3.v00 --- /net_usbn.v00 --- /net_vmxn.v00 --- /nmlx4_co.v00 --- /nmlx4_en.v00 --- /nmlx4_rd.v00 --- /ntg3.v00 --- /nvme.v00 --- /nvmxnet3.v00 --- /ohci_usb.v00 --- /pvscsi.v00 --- /qflge.v00 --- /sata_ahc.v00 --- /sata_ata.v00 --- /sata_sat.v00 --- /sata_sat.v01 --- /sata_sat.v02 --- /sata_sat.v03 --- /sata_sat.v04 --- /scsi_adp.v01 --- /scsi_aic.v00 --- /scsi_ips.v00 --- /scsi_isc.v00 --- /scsi_lib.v00 --- /scsi_meg.v01 --- /scsi_meg.v02 --- /scsi_mpt.v01 --- /scsi_mpt.v02 --- /scsi_mpt.v03 --- /shim_isc.v00 --- /shim_isc.v01 --- /shim_lib.v00 --- /shim_lib.v01 --- /shim_lib.v02 --- /shim_lib.v03 --- /shim_lib.v04 --- /shim_lib.v05 --- /shim_vmk.v00 --- /shim_vmk.v01 --- /shim_vmk.v02 --- /smartpqi.v00 --- /uhci_usb.v00 --- /usb_stor.v00 --- /usbcore_.v00 --- /vmkata.v00 --- /vmkplexe.v00 --- /vmkusb.v00 --- /vmw_ahci.v00 --- /xhci_xhc.v00 --- /emulex_e.v00 --- /btldr.t00 --- /weaselin.t00 --- /esx_dvfi.v00 --- /esx_ui.v00 --- /lsu_hp_h.v00 --- /lsu_lsi_.v00 --- /lsu_lsi_.v01 --- /lsu_lsi_.v02 --- /lsu_lsi_.v03 --- /native_m.v00 --- /rste.v00 --- /vmware_e.v00 --- /vsan.v00 --- /vsanheal.v00 --- /vsanmgmt.v00 --- /tools.t00 --- /scsi_arc.v00 --- /xorg.v00 --- /imgdb.tgz --- /imgpayld.tgz
build=
updated=0
</code>```

It fails, and per Wireshark, the prefix path is not being included in the tftp path.

If I add the prefix path into the kernel= line, it successfully finds and downloads tboot.b00

```<code>bootstate=0
title=Loading ESXi installer
timeout=5
kernel=/VMware-ESXi-6.5U2-RollupISO/tboot.b00
prefix=/VMware-ESXi-6.5U2-RollupISO
kernelopt=runweasel
modules=/b.b00 --- /jumpstrt.gz --- /useropts.gz --- /features.gz --- /k.b00 --- /chardevs.b00 --- /a.b00 --- /user.b00 --- /uc_intel.b00 --- /uc_amd.b00 --- /sb.v00 --- /s.v00 --- /scsi_cel.v00 --- /scsi_esa.v00 --- /scsi_esa.v01 --- /scsi_cel.v01 --- /scsi_esa.v02 --- /scsi_aac.v00 --- /scsi_adp.v00 --- /dell_sha.v00 --- /lsi_mr3.v00 --- /lsi_msgp.v00 --- /scsi_meg.v00 --- /scsi_mpt.v00 --- /bnxtnet.v00 --- /bnxtroce.v00 --- /net_enic.v00 --- /scsi_fni.v00 --- /scsi_sni.v00 --- /cxl.v00 --- /ima_csio.v00 --- /net_cxgb.v00 --- /scsi_csi.v00 --- /ima_be2i.v00 --- /scsi_be2.v00 --- /sas_vgc.v00 --- /scsi_hps.v00 --- /hfcndd.v00 --- /scsi_hfc.v00 --- /block_hi.v00 --- /hiodrive.v00 --- /net_ibma.v00 --- /scsi_roc.v00 --- /i40en.v00 --- /iavmd.v00 --- /igbn.v00 --- /intel_nv.v00 --- /ixgben.v00 --- /net_i40e.v00 --- /net_igb.v00 --- /net_ixgb.v00 --- /mx_nvme.v00 --- /nmlx5_co.v00 --- /nmlx5_rd.v00 --- /net_mlx_.v00 --- /net_mlx4.v00 --- /net_mlx4.v01 --- /nhpsa.v00 --- /scsi_ocz.v00 --- /nqlcnic.v00 --- /qcnic.v00 --- /qedentv.v00 --- /qedrntv.v00 --- /qfle3.v00 --- /qfle3f.v00 --- /qfle3i.v00 --- /ima_qla4.v00 --- /misc_cni.v00 --- /net_bna.v00 --- /net_bnx2.v00 --- /net_bnx2.v01 --- /net_cnic.v00 --- /net_nx_n.v00 --- /net_qlcn.v00 --- /net_qlge.v00 --- /qlnative.v00 --- /scsi_bfa.v00 --- /scsi_bnx.v00 --- /scsi_bnx.v01 --- /scsi_qla.v00 --- /smgnvme.v00 --- /iomemory.v00 --- /native_s.v00 --- /net_sgb.v00 --- /net_sxgb.v00 --- /scsi_ste.v00 --- /ata_liba.v00 --- /ata_pata.v00 --- /ata_pata.v01 --- /ata_pata.v02 --- /ata_pata.v03 --- /ata_pata.v04 --- /ata_pata.v05 --- /ata_pata.v06 --- /ata_pata.v07 --- /block_cc.v00 --- /brcmfcoe.v00 --- /char_ran.v00 --- /ehci_ehc.v00 --- /elxnet.v00 --- /hid_hid.v00 --- /ipmi_ipm.v00 --- /ipmi_ipm.v01 --- /ipmi_ipm.v02 --- /lpfc.v00 --- /lsi_msgp.v01 --- /lsi_msgp.v02 --- /misc_dri.v00 --- /mtip32xx.v00 --- /ne1000.v00 --- /nenic.v00 --- /net_cdc_.v00 --- /net_e100.v00 --- /net_e100.v01 --- /net_fcoe.v00 --- /net_forc.v00 --- /net_libf.v00 --- /net_tg3.v00 --- /net_usbn.v00 --- /net_vmxn.v00 --- /nmlx4_co.v00 --- /nmlx4_en.v00 --- /nmlx4_rd.v00 --- /ntg3.v00 --- /nvme.v00 --- /nvmxnet3.v00 --- /ohci_usb.v00 --- /pvscsi.v00 --- /qflge.v00 --- /sata_ahc.v00 --- /sata_ata.v00 --- /sata_sat.v00 --- /sata_sat.v01 --- /sata_sat.v02 --- /sata_sat.v03 --- /sata_sat.v04 --- /scsi_adp.v01 --- /scsi_aic.v00 --- /scsi_ips.v00 --- /scsi_isc.v00 --- /scsi_lib.v00 --- /scsi_meg.v01 --- /scsi_meg.v02 --- /scsi_mpt.v01 --- /scsi_mpt.v02 --- /scsi_mpt.v03 --- /shim_isc.v00 --- /shim_isc.v01 --- /shim_lib.v00 --- /shim_lib.v01 --- /shim_lib.v02 --- /shim_lib.v03 --- /shim_lib.v04 --- /shim_lib.v05 --- /shim_vmk.v00 --- /shim_vmk.v01 --- /shim_vmk.v02 --- /smartpqi.v00 --- /uhci_usb.v00 --- /usb_stor.v00 --- /usbcore_.v00 --- /vmkata.v00 --- /vmkplexe.v00 --- /vmkusb.v00 --- /vmw_ahci.v00 --- /xhci_xhc.v00 --- /emulex_e.v00 --- /btldr.t00 --- /weaselin.t00 --- /esx_dvfi.v00 --- /esx_ui.v00 --- /lsu_hp_h.v00 --- /lsu_lsi_.v00 --- /lsu_lsi_.v01 --- /lsu_lsi_.v02 --- /lsu_lsi_.v03 --- /native_m.v00 --- /rste.v00 --- /vmware_e.v00 --- /vsan.v00 --- /vsanheal.v00 --- /vsanmgmt.v00 --- /tools.t00 --- /scsi_arc.v00 --- /xorg.v00 --- /imgdb.tgz --- /imgpayld.tgz
build=
updated=0
</code>```

And then it fails on the very next file, b.b00.  It's as if the prefix is being ignored.

What am I missing?

答:
I am not sure why the prefix gets ignored in the modules. I went and removed the / at the beginning of each module in my pxe environment.

It should be:

modules=b.b00 --- jumpstrt.gz --- useropts.gz

...and so on.

I don't even use the prefix option. I remove all / in my boot.cfg file.

Title: VMWare Ignores prefix in boot.cfg

Body:
I am trying to PXE boot VMWare ESXi and it gets to boot.cfg, tries to download all the modules,  but runs into problem when it doesn't follow the prefix directive.

I have configured boot.cfg as follows:

bootstate=0
title=Loading ESXi installer
timeout=5
kernel=/tboot.b00
prefix=/VMware-ESXi-6.5U2-RollupISO
kernelopt=runweasel
modules=/b.b00 --- /jumpstrt.gz --- /useropts.gz --- /features.gz --- /k.b00 --- /chardevs.b00 --- /a.b00 --- /user.b00 --- /uc_intel.b00 --- /uc_amd.b00 --- /sb.v00 --- /s.v00 --- /scsi_cel.v00 --- /scsi_esa.v00 --- /scsi_esa.v01 --- /scsi_cel.v01 --- /scsi_esa.v02 --- /scsi_aac.v00 --- /scsi_adp.v00 --- /dell_sha.v00 --- /lsi_mr3.v00 --- /lsi_msgp.v00 --- /scsi_meg.v00 --- /scsi_mpt.v00 --- /bnxtnet.v00 --- /bnxtroce.v00 --- /net_enic.v00 --- /scsi_fni.v00 --- /scsi_sni.v00 --- /cxl.v00 --- /ima_csio.v00 --- /net_cxgb.v00 --- /scsi_csi.v00 --- /ima_be2i.v00 --- /scsi_be2.v00 --- /sas_vgc.v00 --- /scsi_hps.v00 --- /hfcndd.v00 --- /scsi_hfc.v00 --- /block_hi.v00 --- /hiodrive.v00 --- /net_ibma.v00 --- /scsi_roc.v00 --- /i40en.v00 --- /iavmd.v00 --- /igbn.v00 --- /intel_nv.v00 --- /ixgben.v00 --- /net_i40e.v00 --- /net_igb.v00 --- /net_ixgb.v00 --- /mx_nvme.v00 --- /nmlx5_co.v00 --- /nmlx5_rd.v00 --- /net_mlx_.v00 --- /net_mlx4.v00 --- /net_mlx4.v01 --- /nhpsa.v00 --- /scsi_ocz.v00 --- /nqlcnic.v00 --- /qcnic.v00 --- /qedentv.v00 --- /qedrntv.v00 --- /qfle3.v00 --- /qfle3f.v00 --- /qfle3i.v00 --- /ima_qla4.v00 --- /misc_cni.v00 --- /net_bna.v00 --- /net_bnx2.v00 --- /net_bnx2.v01 --- /net_cnic.v00 --- /net_nx_n.v00 --- /net_qlcn.v00 --- /net_qlge.v00 --- /qlnative.v00 --- /scsi_bfa.v00 --- /scsi_bnx.v00 --- /scsi_bnx.v01 --- /scsi_qla.v00 --- /smgnvme.v00 --- /iomemory.v00 --- /native_s.v00 --- /net_sgb.v00 --- /net_sxgb.v00 --- /scsi_ste.v00 --- /ata_liba.v00 --- /ata_pata.v00 --- /ata_pata.v01 --- /ata_pata.v02 --- /ata_pata.v03 --- /ata_pata.v04 --- /ata_pata.v05 --- /ata_pata.v06 --- /ata_pata.v07 --- /block_cc.v00 --- /brcmfcoe.v00 --- /char_ran.v00 --- /ehci_ehc.v00 --- /elxnet.v00 --- /hid_hid.v00 --- /ipmi_ipm.v00 --- /ipmi_ipm.v01 --- /ipmi_ipm.v02 --- /lpfc.v00 --- /lsi_msgp.v01 --- /lsi_msgp.v02 --- /misc_dri.v00 --- /mtip32xx.v00 --- /ne1000.v00 --- /nenic.v00 --- /net_cdc_.v00 --- /net_e100.v00 --- /net_e100.v01 --- /net_fcoe.v00 --- /net_forc.v00 --- /net_libf.v00 --- /net_tg3.v00 --- /net_usbn.v00 --- /net_vmxn.v00 --- /nmlx4_co.v00 --- /nmlx4_en.v00 --- /nmlx4_rd.v00 --- /ntg3.v00 --- /nvme.v00 --- /nvmxnet3.v00 --- /ohci_usb.v00 --- /pvscsi.v00 --- /qflge.v00 --- /sata_ahc.v00 --- /sata_ata.v00 --- /sata_sat.v00 --- /sata_sat.v01 --- /sata_sat.v02 --- /sata_sat.v03 --- /sata_sat.v04 --- /scsi_adp.v01 --- /scsi_aic.v00 --- /scsi_ips.v00 --- /scsi_isc.v00 --- /scsi_lib.v00 --- /scsi_meg.v01 --- /scsi_meg.v02 --- /scsi_mpt.v01 --- /scsi_mpt.v02 --- /scsi_mpt.v03 --- /shim_isc.v00 --- /shim_isc.v01 --- /shim_lib.v00 --- /shim_lib.v01 --- /shim_lib.v02 --- /shim_lib.v03 --- /shim_lib.v04 --- /shim_lib.v05 --- /shim_vmk.v00 --- /shim_vmk.v01 --- /shim_vmk.v02 --- /smartpqi.v00 --- /uhci_usb.v00 --- /usb_stor.v00 --- /usbcore_.v00 --- /vmkata.v00 --- /vmkplexe.v00 --- /vmkusb.v00 --- /vmw_ahci.v00 --- /xhci_xhc.v00 --- /emulex_e.v00 --- /btldr.t00 --- /weaselin.t00 --- /esx_dvfi.v00 --- /esx_ui.v00 --- /lsu_hp_h.v00 --- /lsu_lsi_.v00 --- /lsu_lsi_.v01 --- /lsu_lsi_.v02 --- /lsu_lsi_.v03 --- /native_m.v00 --- /rste.v00 --- /vmware_e.v00 --- /vsan.v00 --- /vsanheal.v00 --- /vsanmgmt.v00 --- /tools.t00 --- /scsi_arc.v00 --- /xorg.v00 --- /imgdb.tgz --- /imgpayld.tgz
build=
updated=0

It fails, and per Wireshark, the prefix path is not being included in the tftp path.

If I add the prefix path into the kernel= line, it successfully finds and downloads tboot.b00

bootstate=0
title=Loading ESXi installer
timeout=5
kernel=/VMware-ESXi-6.5U2-RollupISO/tboot.b00
prefix=/VMware-ESXi-6.5U2-RollupISO
kernelopt=runweasel
modules=/b.b00 --- /jumpstrt.gz --- /useropts.gz --- /features.gz --- /k.b00 --- /chardevs.b00 --- /a.b00 --- /user.b00 --- /uc_intel.b00 --- /uc_amd.b00 --- /sb.v00 --- /s.v00 --- /scsi_cel.v00 --- /scsi_esa.v00 --- /scsi_esa.v01 --- /scsi_cel.v01 --- /scsi_esa.v02 --- /scsi_aac.v00 --- /scsi_adp.v00 --- /dell_sha.v00 --- /lsi_mr3.v00 --- /lsi_msgp.v00 --- /scsi_meg.v00 --- /scsi_mpt.v00 --- /bnxtnet.v00 --- /bnxtroce.v00 --- /net_enic.v00 --- /scsi_fni.v00 --- /scsi_sni.v00 --- /cxl.v00 --- /ima_csio.v00 --- /net_cxgb.v00 --- /scsi_csi.v00 --- /ima_be2i.v00 --- /scsi_be2.v00 --- /sas_vgc.v00 --- /scsi_hps.v00 --- /hfcndd.v00 --- /scsi_hfc.v00 --- /block_hi.v00 --- /hiodrive.v00 --- /net_ibma.v00 --- /scsi_roc.v00 --- /i40en.v00 --- /iavmd.v00 --- /igbn.v00 --- /intel_nv.v00 --- /ixgben.v00 --- /net_i40e.v00 --- /net_igb.v00 --- /net_ixgb.v00 --- /mx_nvme.v00 --- /nmlx5_co.v00 --- /nmlx5_rd.v00 --- /net_mlx_.v00 --- /net_mlx4.v00 --- /net_mlx4.v01 --- /nhpsa.v00 --- /scsi_ocz.v00 --- /nqlcnic.v00 --- /qcnic.v00 --- /qedentv.v00 --- /qedrntv.v00 --- /qfle3.v00 --- /qfle3f.v00 --- /qfle3i.v00 --- /ima_qla4.v00 --- /misc_cni.v00 --- /net_bna.v00 --- /net_bnx2.v00 --- /net_bnx2.v01 --- /net_cnic.v00 --- /net_nx_n.v00 --- /net_qlcn.v00 --- /net_qlge.v00 --- /qlnative.v00 --- /scsi_bfa.v00 --- /scsi_bnx.v00 --- /scsi_bnx.v01 --- /scsi_qla.v00 --- /smgnvme.v00 --- /iomemory.v00 --- /native_s.v00 --- /net_sgb.v00 --- /net_sxgb.v00 --- /scsi_ste.v00 --- /ata_liba.v00 --- /ata_pata.v00 --- /ata_pata.v01 --- /ata_pata.v02 --- /ata_pata.v03 --- /ata_pata.v04 --- /ata_pata.v05 --- /ata_pata.v06 --- /ata_pata.v07 --- /block_cc.v00 --- /brcmfcoe.v00 --- /char_ran.v00 --- /ehci_ehc.v00 --- /elxnet.v00 --- /hid_hid.v00 --- /ipmi_ipm.v00 --- /ipmi_ipm.v01 --- /ipmi_ipm.v02 --- /lpfc.v00 --- /lsi_msgp.v01 --- /lsi_msgp.v02 --- /misc_dri.v00 --- /mtip32xx.v00 --- /ne1000.v00 --- /nenic.v00 --- /net_cdc_.v00 --- /net_e100.v00 --- /net_e100.v01 --- /net_fcoe.v00 --- /net_forc.v00 --- /net_libf.v00 --- /net_tg3.v00 --- /net_usbn.v00 --- /net_vmxn.v00 --- /nmlx4_co.v00 --- /nmlx4_en.v00 --- /nmlx4_rd.v00 --- /ntg3.v00 --- /nvme.v00 --- /nvmxnet3.v00 --- /ohci_usb.v00 --- /pvscsi.v00 --- /qflge.v00 --- /sata_ahc.v00 --- /sata_ata.v00 --- /sata_sat.v00 --- /sata_sat.v01 --- /sata_sat.v02 --- /sata_sat.v03 --- /sata_sat.v04 --- /scsi_adp.v01 --- /scsi_aic.v00 --- /scsi_ips.v00 --- /scsi_isc.v00 --- /scsi_lib.v00 --- /scsi_meg.v01 --- /scsi_meg.v02 --- /scsi_mpt.v01 --- /scsi_mpt.v02 --- /scsi_mpt.v03 --- /shim_isc.v00 --- /shim_isc.v01 --- /shim_lib.v00 --- /shim_lib.v01 --- /shim_lib.v02 --- /shim_lib.v03 --- /shim_lib.v04 --- /shim_lib.v05 --- /shim_vmk.v00 --- /shim_vmk.v01 --- /shim_vmk.v02 --- /smartpqi.v00 --- /uhci_usb.v00 --- /usb_stor.v00 --- /usbcore_.v00 --- /vmkata.v00 --- /vmkplexe.v00 --- /vmkusb.v00 --- /vmw_ahci.v00 --- /xhci_xhc.v00 --- /emulex_e.v00 --- /btldr.t00 --- /weaselin.t00 --- /esx_dvfi.v00 --- /esx_ui.v00 --- /lsu_hp_h.v00 --- /lsu_lsi_.v00 --- /lsu_lsi_.v01 --- /lsu_lsi_.v02 --- /lsu_lsi_.v03 --- /native_m.v00 --- /rste.v00 --- /vmware_e.v00 --- /vsan.v00 --- /vsanheal.v00 --- /vsanmgmt.v00 --- /tools.t00 --- /scsi_arc.v00 --- /xorg.v00 --- /imgdb.tgz --- /imgpayld.tgz
build=
updated=0

And then it fails on the very next file, b.b00.  It's as if the prefix is being ignored.

What am I missing?


来源: stackexchange

问:
How to implement Full-Text Search in Google App Maker?
I'm making a Full-Text Search box to find any records that have the data entered in that box. I tried binding the value of the Search box to @datasource.query.parameters.SearchText, then assigned

query.keywords = query.parameters.SearchText;
return query.run();```

I made a button Search to reload the datasource with search value from the Search box but it continues to show all records, not the records that have the value I want:

Actual Search Result

Am I missing something? What is the right way to implement this function?

答:
There is a Google template called "Partner Management" that has this functionality. It looks like the difference is with the onValueEdit field of the widget. Add this to that field:

```<code>widget.datasource.query.pageIndex = 1;
widget.datasource.unload();
widget.datasource.load();
updateUrlForContactSearch();
</code>```

Hope that helps.

ContentLicense: CC BY-SA 4.0

Body:
I'm making a Full-Text Search box to find any records that have the data entered in that box. I tried binding the value of the Search box to @datasource.query.parameters.SearchText, then assigned

query.keywords = query.parameters.SearchText;
return query.run();

I made a button Search to reload the datasource with search value from the Search box but it continues to show all records, not the records that have the value I want:

Actual Search Result

Am I missing something? What is the right way to implement this function?

Body:
There is a Google template called "Partner Management" that has this functionality. It looks like the difference is with the onValueEdit field of the widget. Add this to that field:

widget.datasource.query.pageIndex = 1;
widget.datasource.unload();
widget.datasource.load();
updateUrlForContactSearch();

Hope that helps.


问:
what is the difference between binary_file_patterns and index_exclude_patterns in SublimeText3?
In SublimeText3 binary_file_patterns excludes files from being found in Files or fuzzy search (Goto Anything) while index_exclude_patterns prevents files from being indexed.

Since we know that not indexed files cannot be found and assuming that untraceable files do not need to be indexed, what are the differences and implications by the usage of one over another?

答:
Sublime maintains a catalog of all known files based on the folders that are currently open in the window/project, and that catalog of files is used to populate the Goto Anything file list and also the list of files that are searched when you do Find in Files.

You can control what appears in the catalog by using the file_exclude_patterns and folder_exclude_patterns settings to stop files from appearing in the sidebar (and thus in the catalog). As you mentioned you can also use binary_file_patterns to indicate that files should still appear in the side bar, but should not be offered in the Goto Anything panel or searched by Find in Files.

In addition to the above, as long as index_files is turned on, then in addition to the file catalog Sublime also runs an indexing process against the files in the side bar as well.

The indexer runs in the background using some number of threads (controlled by index_workers) and essentially loads every file in the side bar, applies the appropriate syntax definition, and then gathers the list of symbols that are marked as ones that should appear in the index (this is a per-syntax setting). The index_exclude_patterns setting specifies files which should not be indexed, even if they appear in the sidebar.

The index is used to power the Goto Definition/Goto Reference/Goto Symbol in Project functionality; it's literally just a list of all of the indexed symbols, what files they appear in, and where in that file that they appear.

Your assumption that files that are not indexed are ones that can't be found is not correct; files that are not indexed can still appear in the side bar and be found by Goto Anything, they just don't contribute symbols to the index, which means the above functionality will not show any content from those files, but you can still open and search them.

So overall, the implications of the two are:

If you want a file to appear in the side bar but you don't want to search inside it or have it eligible for opening with Goto Anything, add it to the binary_file_patterns.

If you want a file to appear in the side bar but not contribute symbols to the index, then add it to the index_exclude_patterns setting.

Files can appear in both settings, in which case you can see them in the side bar but Sublime pretends that they're not there for purposes of all of the above functionality.


问:
Condensing arrays in Presto
I have a query that produces strings of arrays using they array_agg() function

```<code>SELECT
array_agg(message) as sequence
from mytable
group by id
</code>```

which produces a table that looks like this:

```<code>                 sequence
1 foo foo bar baz bar baz
2     foo bar bar bar baz
3 foo foo foo bar bar baz
</code>```

but I aim to condense the array of strings so that none can repeat more than once in a row, for example, the desired output would look like this:

```<code>    sequence
1 foo bar baz bar baz
2 foo bar baz
3 foo bar baz
</code>```

How would one go about doing this with Presto SQL ?

答:
You can do this in one of two ways:

Remove duplicates from the resulting arrays using the array_distinct function:

WITH mytable(id, message) AS (VALUES
  (1, 'foo'), (1, 'foo'), (1, 'bar'), (1, 'bar'), (1, 'baz'), (1, 'baz'),
  (2, 'foo'), (2, 'bar'), (2, 'bar'), (2, 'bar'), (2, 'baz'),
  (3, 'foo'), (3, 'foo'), (3, 'foo'), (3, 'bar'), (3, 'bar'), (3, 'baz')
)
SELECT array_distinct(array_agg(message)) AS sequence
FROM mytable
GROUP BY id
```
<ol start="2">
<li>Use the <code>DISTINCT</code> qualifier in the aggregation to remove the duplicate values before they are passed into array_agg.</li>
</ol>
<pre class="lang-sql prettyprint-override"><code>WITH mytable(id, message) AS (VALUES
  (1, 'foo'), (1, 'foo'), (1, 'bar'), (1, 'bar'), (1, 'baz'), (1, 'baz'),
  (2, 'foo'), (2, 'bar'), (2, 'bar'), (2, 'bar'), (2, 'baz'), (3, 'foo'),
  (3, 'foo'), (3, 'foo'), (3, 'bar'), (3, 'bar'), (3, 'baz')
)
SELECT array_agg(DISTINCT message) AS sequence
FROM mytable
GROUP BY id
</code>```

Both alternatives produce the same result:

```<code>    sequence
-----------------
 [foo, bar, baz]
 [foo, bar, baz]
 [foo, bar, baz]
(3 rows)
</code>```

UPDATE: You can remove repeated sequences of elements with the recently introduced MATCH_RECOGNIZE feature:

WITH mytable(id, message) AS (VALUES
  (1, 'foo'), (1, 'foo'), (1, 'bar'), (1, 'baz'), (1, 'bar'), (1, 'baz'),
  (2, 'foo'), (2, 'bar'), (2, 'bar'), (2, 'bar'), (2, 'baz'),
  (3, 'foo'), (3, 'foo'), (3, 'foo'), (3, 'bar'), (3, 'bar'), (3, 'baz')
)
SELECT array_agg(value) AS sequence
FROM mytable
 MATCH_RECOGNIZE(
    PARTITION BY id
    MEASURES A.message AS value
    PATTERN (A B*)
    DEFINE B AS message = PREV(message)
)
GROUP BY id
```

Title: Condensing arrays in Presto

Body:
I have a query that produces strings of arrays using they array_agg() function

SELECT
array_agg(message) as sequence
from mytable
group by id

which produces a table that looks like this:

                 sequence
1 foo foo bar baz bar baz
2     foo bar bar bar baz
3 foo foo foo bar bar baz

but I aim to condense the array of strings so that none can repeat more than once in a row, for example, the desired output would look like this:

    sequence
1 foo bar baz bar baz
2 foo bar baz
3 foo bar baz

How would one go about doing this with Presto SQL ?

Body:
You can do this in one of two ways:

Remove duplicates from the resulting arrays using the array_distinct function:

WITH mytable(id, message) AS (VALUES
  (1, 'foo'), (1, 'foo'), (1, 'bar'), (1, 'bar'), (1, 'baz'), (1, 'baz'),
  (2, 'foo'), (2, 'bar'), (2, 'bar'), (2, 'bar'), (2, 'baz'),
  (3, 'foo'), (3, 'foo'), (3, 'foo'), (3, 'bar'), (3, 'bar'), (3, 'baz')
)
SELECT array_distinct(array_agg(message)) AS sequence
FROM mytable
GROUP BY id

Use the DISTINCT qualifier in the aggregation to remove the duplicate values before they are passed into array_agg.

WITH mytable(id, message) AS (VALUES
  (1, 'foo'), (1, 'foo'), (1, 'bar'), (1, 'bar'), (1, 'baz'), (1, 'baz'),
  (2, 'foo'), (2, 'bar'), (2, 'bar'), (2, 'bar'), (2, 'baz'), (3, 'foo'),
  (3, 'foo'), (3, 'foo'), (3, 'bar'), (3, 'bar'), (3, 'baz')
)
SELECT array_agg(DISTINCT message) AS sequence
FROM mytable
GROUP BY id

Both alternatives produce the same result:

    sequence
-----------------
 [foo, bar, baz]
 [foo, bar, baz]
 [foo, bar, baz]
(3 rows)

UPDATE: You can remove repeated sequences of elements with the recently introduced MATCH_RECOGNIZE feature:

WITH mytable(id, message) AS (VALUES
  (1, 'foo'), (1, 'foo'), (1, 'bar'), (1, 'baz'), (1, 'bar'), (1, 'baz'),
  (2, 'foo'), (2, 'bar'), (2, 'bar'), (2, 'bar'), (2, 'baz'),
  (3, 'foo'), (3, 'foo'), (3, 'foo'), (3, 'bar'), (3, 'bar'), (3, 'baz')
)
SELECT array_agg(value) AS sequence
FROM mytable
 MATCH_RECOGNIZE(
    PARTITION BY id
    MEASURES A.message AS value
    PATTERN (A B*)
    DEFINE B AS message = PREV(message)
)
GROUP BY id


问:
How to write to cygwin pipe from c#
I want to create a c# app that can be used in a cygwin pipe with "tail -f".

i.e.

tail -f SomeFile | MyCSharpApp

I can see (from debugging) that I am able to read stdinput correctly, but nothing is written back to cygwin terminal windows.

However,

tail -n10 SomeFile | MyCSharpApp

Works perfectly.

```<code>class Program
{
    static void Main(string[] args)
    {

        string s;
        while ((s = Console.ReadLine()) != null)
        {
           //Potentially process s here
           Console.WriteLine(s);
        }
    }
}
</code>```

答:
Edit: This answer was written wrongly about the opposite of the issue. That is to say that it was written for attempting myApp > tail -f and not tail -f file.txt > myApp.

tail -f works on a file and not a pipe.  The only way that I can get it to output the output of another command is if I use tail -F <(ls -lthr) where ls -lthr could be any command that prints output.

Let's think about why this is.  tail prints the contents of a file (particularly the the lines at the end).  If you have the ability to print to the console or stdout then you do not need tail.

Extra: and furthermore if you decided that you needed to output into a file then you could simply use > file.txt to put that console output into a file.

Title: How to write to cygwin pipe from c#

Body:
I want to create a c# app that can be used in a cygwin pipe with "tail -f".

i.e.

tail -f SomeFile | MyCSharpApp

I can see (from debugging) that I am able to read stdinput correctly, but nothing is written back to cygwin terminal windows.

However,

tail -n10 SomeFile | MyCSharpApp

Works perfectly.

class Program
{
    static void Main(string[] args)
    {

        string s;
        while ((s = Console.ReadLine()) != null)
        {
           //Potentially process s here
           Console.WriteLine(s);
        }
    }
}


问:
RegEx for passing space and single quote
I'm fairly new to RegEx's and am having some issues getting my RegEx to do what I'd like it to. I'm attempting to create a RegEx that prevents any special character OTHER THAN single quote ('), dash (-), and period (.).
The RegEx needs to allow spaces, and empty strings.

What I have for now is:

```<code>^[a-zA-Z0-9-.]*$
</code>```

What would I need to add in order to make it work for example the name "Kevin O'Leary"?

I've attempted to allow spaces by adding \s, but it broke other parts of my RegEx.

```<code>^[a-zA-Z0-9-.]*$
</code>```

Expected: Should allow names like Kevin O'Leary
Actual: Does not allow names like Kevin O'Leary

答:
You can use i flag and use this expression:

```<code>^[a-z0-9'-.\s]+$
</code>```

where \x27 is ' and \s is space.

const regex = /^[a-z0-9'-.\s]+$/gmi;
const str = `Kevin O'Leary`;
let m;

while ((m = regex.exec(str)) !== null) {
    // This is necessary to avoid infinite loops with zero-width matches
    if (m.index === regex.lastIndex) {
        regex.lastIndex++;
    }

    // The result can be accessed through the `m`-variable.
    m.forEach((match, groupIndex) => {
        console.log(`Found match, group ${groupIndex}: ${match}`);
    });
}```

DEMO

RegEx

If this expression wasn't desired, it can be modified/changed in regex101.com.

RegEx Circuit

jex.im visualizes regular expressions:

Body:
I'm fairly new to RegEx's and am having some issues getting my RegEx to do what I'd like it to. I'm attempting to create a RegEx that prevents any special character OTHER THAN single quote ('), dash (-), and period (.).
The RegEx needs to allow spaces, and empty strings.

What I have for now is:

^[a-zA-Z0-9-.]*$

What would I need to add in order to make it work for example the name "Kevin O'Leary"?

I've attempted to allow spaces by adding \s, but it broke other parts of my RegEx.

^[a-zA-Z0-9-.]*$

Expected: Should allow names like Kevin O'Leary
Actual: Does not allow names like Kevin O'Leary

Body:
You can use i flag and use this expression:

^[a-z0-9'-.\s]+$

where \x27 is ' and \s is space.

const regex = /^[a-z0-9'-.\s]+$/gmi;
const str = `Kevin O'Leary`;
let m;

while ((m = regex.exec(str)) !== null) {
    // This is necessary to avoid infinite loops with zero-width matches
    if (m.index === regex.lastIndex) {
        regex.lastIndex++;
    }

    // The result can be accessed through the `m`-variable.
    m.forEach((match, groupIndex) => {
        console.log(`Found match, group ${groupIndex}: ${match}`);
    });
}

DEMO

RegEx

If this expression wasn't desired, it can be modified/changed in regex101.com.

RegEx Circuit

jex.im visualizes regular expressions:


问:
Postgres query to check a string is a number
Can anyone tell me the query to check whether a string is a number(double precision). It should return true if the string is number. else it should return false.

consider :

```<code>       s1 character varying;
       s2 character varying;

       s1 ='12.41212' => should return true
       s2 = 'Service' => should return false
</code>```

答:
If you want to check with exponential , +/- . then the best expression is :

```<code>^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$
</code>```

resulting in:

```<code>select '12.41212e-5' ~ '^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$' ;
</code>```

as true.

The expression is from: https://www.regular-expressions.info/floatingpoint.html

You can check for other types of numbers, for example if you expect decimal, with a sign.

```<code> select '-12.1254' ~ '^[-+]?[0-9]*\.?[0-9]+$';
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Can anyone tell me the query to check whether a string is a number(double precision). It should return true if the string is number. else it should return false.

consider :

       s1 character varying;
       s2 character varying;

       s1 ='12.41212' => should return true
       s2 = 'Service' => should return false

Body:
If you want to check with exponential , +/- . then the best expression is :

^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$

resulting in:

select '12.41212e-5' ~ '^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$' ;

as true.

The expression is from: https://www.regular-expressions.info/floatingpoint.html

You can check for other types of numbers, for example if you expect decimal, with a sign.

 select '-12.1254' ~ '^[-+]?[0-9]*\.?[0-9]+$';


问:
jQuery .keyup() function
I'm not receiving any output from this code. What could be the error.

terminal.html

```<code><html>
<head>
<link href="/css/webterminal.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.5.2.js"/>
<script type="text/javascript">
function shell_execute(str) {
  $.ajax({
    url: 'exec.php',
    dataType: 'text',
    data: {
      q: str
    },
    success: function (response) {
      $('#txtOut').append(response);

  });
}
</script>
</head
<body">
    <div class="container">

    <h2>UNIX Web Based Terminal 1.0</h2>
        <br />
    <p><b>output</b></p>
<form>
<span id="User"></span>< <input type="text" id="txtcmd" onkeyup="shell_execute(this.value)" class="textbox" size="20" />
</form>
<div class="output">
<p><span id="txtOut"></span></p>

    </div>
</div>
</body>
</html>
</code>```

exec.php

```<code><?php

$q=$_GET["q"];
$output=shell_exec($q);
echo "```$output```";
?>
</code>```

答:
You need to get the value from your text input element and put that into str before you pass it to your script.

Like:

```<code> var str = $("#txtcmd").val();
</code>```

Title: jQuery .keyup() function

Body:
I'm not receiving any output from this code. What could be the error.

terminal.html

<link href="/css/webterminal.css" rel="stylesheet" type="text/css" />

</head

UNIX Web Based Terminal 1.0

output

<form>
< <input type="text" id="txtcmd" onkeyup="shell_execute(this.value)" class="textbox" size="20" />
</form>

exec.php

<?php

$q=$_GET["q"];
$output=shell_exec($q);
echo "
$output
";
?>

Body:
You need to get the value from your text input element and put that into str before you pass it to your script.

Like:

 var str = $("#txtcmd").val();


问:
How to try to invite friends on Facebook Instant Game SDK? (ShareAsync not working)
I want to know how to invite or request. but FBInstant SDK doesn't ask me any target IDs when sharing.

my code is following (Typescript),

```<code>const options : FBInstant.SharePayload = {
    intent  : "INVITE",
    text    : "SomeText",
    image   : base64Image, // exist.
    data    : {}
};
FBInstant.shareAsync(options);
</code>```

and this shows "SHARE" window. FBInstant.shareAsync() not work exactly.

答:
You should actually use FBInstant.context.chooseAsync/FBInstant.context.createAsync for invites in Instant Games. Your goal should be to move the players you want to play together into the same context (as specified by FBInstant.context methods).

Sharing (shareAsync) is intended for broadcast sharing and despite the intent parameter, it is not that useful for invitations.

Body:
I want to know how to invite or request. but FBInstant SDK doesn't ask me any target IDs when sharing.

my code is following (Typescript),

const options : FBInstant.SharePayload = {
    intent  : "INVITE",
    text    : "SomeText",
    image   : base64Image, // exist.
    data    : {}
};
FBInstant.shareAsync(options);

and this shows "SHARE" window. FBInstant.shareAsync() not work exactly.


问:
How to call two separate functions on dictionaries and lists?
I'm doing the practice project in chapter 5 of automate the boring stuff. It asks to define a function with two parameters (a dictionary and a list) and for the numerical dictionary values to be updated with each common occurrence between the dictionary key and list value.

I've tried defining a function to return a listed inventory based on value key pairs when a dictionary is passed as a parameter (first practice project). Then  I created a second function to account for additional items to be added to the dictionary inventory, passed as a list.

```<code>backpack = {'gold coin':42, 'rope':1}
dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby']

def addToInventory(inventory, addedItems):
    for item in addedItems:
        inventory.setdefault(item,0)
        inventory[item] = inventory[item] + 1

def displayInventory(inv):
    print('Inventory:')
    itemTotal = 0
    for k, v in inv.items():
        print(v, k, sep= ' ')
        itemTotal += v
    print('Total number of items:' + str(itemTotal))

backpack = addToInventory(backpack, dragonLoot)
displayInventory(backpack)
</code>```

I receive the following error:

```<code>for k, v in inv.items():
AttributeError: 'NoneType' object has no attribute 'items'
</code>```

I've tried but cant see the fault, especially since the first project, returning the value-key inventory, worked OK and is essentially the same as the displayInventory() function.

I could have found a solution easily  but want to see where I am going wrong specifically. Thanks

答: What is happening is that you are reassigning the variable backpack to the output of addToInventory.  However, addToInventory does not return any values, so backpack is being assigned to None by default.  The NoneType error then occurs when you pass the backpack variable containing None to the displayInventory function.</p>

Body:
I'm doing the practice project in chapter 5 of automate the boring stuff. It asks to define a function with two parameters (a dictionary and a list) and for the numerical dictionary values to be updated with each common occurrence between the dictionary key and list value.

I've tried defining a function to return a listed inventory based on value key pairs when a dictionary is passed as a parameter (first practice project). Then  I created a second function to account for additional items to be added to the dictionary inventory, passed as a list.

backpack = {'gold coin':42, 'rope':1}
dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby']

def addToInventory(inventory, addedItems):
    for item in addedItems:
        inventory.setdefault(item,0)
        inventory[item] = inventory[item] + 1

def displayInventory(inv):
    print('Inventory:')
    itemTotal = 0
    for k, v in inv.items():
        print(v, k, sep= ' ')
        itemTotal += v
    print('Total number of items:' + str(itemTotal))

backpack = addToInventory(backpack, dragonLoot)
displayInventory(backpack)

I receive the following error:

for k, v in inv.items():
AttributeError: 'NoneType' object has no attribute 'items'

I've tried but cant see the fault, especially since the first project, returning the value-key inventory, worked OK and is essentially the same as the displayInventory() function.

I could have found a solution easily  but want to see where I am going wrong specifically. Thanks


问:
How to use a defined type inside a class as a val in Ocaml?
I am writing a class which stores an array of defined types. I am having problem -i think- with the syntax of my code. I want to get a defined type inside of array but my code keeps giving error.

I have already created a class, write down the array i need. i have tried already writing it these ways;

```<code>
[|(Rook, Black, (Alive of (A, 1)))]
[|(Rook, Black, (Alive of A, 1))]
[|(Rook, Black, Alive of (A,1))]
[|(Rook, Black, Alive of A,1)]
[|(Rook, Black, (A,1))

</code>```

but sadly, it shows my array as chess_piece * chess_colour *  (chess_letter * int) or it gives operating error.

this is my defined type

```<code>type chess_letter = A | B | C | D | E | F | G | H
and chess_piece = King | Queen | Rook | Bishop | Knight | Pawn
and chess_colour = Black | White
and chess_position = Alive of chess_letter * int | Dead
</code>```

array should include [|(chess_piece, chess_colour, chess_position)|]

答:
The syntax for constructing a value of the variant Alive is:

```<code>Alive (A, 1)
</code>```

of is only used in the type definition. And it dosn't make a difference whether it's inside or outside an array.

Also, none of your arrays are syntactically correct. The first four are missing a | before the terminating ], and the last is missing both.

Body:
I am writing a class which stores an array of defined types. I am having problem -i think- with the syntax of my code. I want to get a defined type inside of array but my code keeps giving error.

I have already created a class, write down the array i need. i have tried already writing it these ways;

[|(Rook, Black, (Alive of (A, 1)))]
[|(Rook, Black, (Alive of A, 1))]
[|(Rook, Black, Alive of (A,1))]
[|(Rook, Black, Alive of A,1)]
[|(Rook, Black, (A,1))

but sadly, it shows my array as chess_piece * chess_colour *  (chess_letter * int) or it gives operating error.

this is my defined type

type chess_letter = A | B | C | D | E | F | G | H
and chess_piece = King | Queen | Rook | Bishop | Knight | Pawn
and chess_colour = Black | White
and chess_position = Alive of chess_letter * int | Dead

array should include [|(chess_piece, chess_colour, chess_position)|]

Body:
The syntax for constructing a value of the variant Alive is:

Alive (A, 1)

of is only used in the type definition. And it dosn't make a difference whether it's inside or outside an array.

Also, none of your arrays are syntactically correct. The first four are missing a | before the terminating ], and the last is missing both.


问:
Setting a Response Header after doFilter call
So I've been observing some answers about this topic and I understand that after the doFilter() call is completed it is now too late to modify a repsonse header, and to best handle this case I should use a response wrapper.

I want to know how to handle the case where I only want to set a header if the response that has bubbled back up to my filter has a specific status code. Should that logic be handled before doFilter? In the Request Wrapper class?  I'm a bit confused.

```<code>@Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
        HttpServletRequest httpRequest;
        HttpServletResponse servlettResponse = (HttpServletResponse)response;
    CrossOriginResponseWrapper crossOriginResponseWrapper = new CrossOriginResponseWrapper(servlettResponse);
    if (crossOriginResponseWrapper.getStatus() == 404) {
        crossOriginResponseWrapper.addHeader("Access-Control-Allow-Origin", "*");
    }
    chain.doFilter(request, crossOriginResponseWrapper);

    LOG.info(crossOriginResponseWrapper.getHeader("Access-Control-Allow-Origin"));

    LOG.info(servlettResponse.getStatus());
}
</code>```

UPDATE:

Is the only way to solve this overriding methods in the wrapper so that the response isn't written/flushed before it gets to my filter? Is there any simpler solution?

(Referencing this answer)
Response is committing and doFilter chain is broken

答:
Nop, that is the only way.
Here you have a working example.
https://github.com/sercasti/spring-httpserver-timings/blob/master/src/main/java/io/github/sercasti/tracing/filter/TracingFilter.java

I wrap the original Response with a Wrapper, thus avoiding other filters from calling the .write method, which instantly commits the response and locks you out from adding headers.

By using this wrapper, other filters write to my wrapper, and then when my filter gets the control back, I add my headers, and effectively write the original response.

Body:
So I've been observing some answers about this topic and I understand that after the doFilter() call is completed it is now too late to modify a repsonse header, and to best handle this case I should use a response wrapper.

I want to know how to handle the case where I only want to set a header if the response that has bubbled back up to my filter has a specific status code. Should that logic be handled before doFilter? In the Request Wrapper class?  I'm a bit confused.

@Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
        HttpServletRequest httpRequest;
        HttpServletResponse servlettResponse = (HttpServletResponse)response;
    CrossOriginResponseWrapper crossOriginResponseWrapper = new CrossOriginResponseWrapper(servlettResponse);
    if (crossOriginResponseWrapper.getStatus() == 404) {
        crossOriginResponseWrapper.addHeader("Access-Control-Allow-Origin", "*");
    }
    chain.doFilter(request, crossOriginResponseWrapper);

    LOG.info(crossOriginResponseWrapper.getHeader("Access-Control-Allow-Origin"));

    LOG.info(servlettResponse.getStatus());
}

UPDATE:

Is the only way to solve this overriding methods in the wrapper so that the response isn't written/flushed before it gets to my filter? Is there any simpler solution?

(Referencing this answer)
Response is committing and doFilter chain is broken


问:
Database backup script
i'm pretty new to Oracle and i'm trying to make a script that backups the database everytime it's ran from cronjob.

I've been looking on a lot of discussions online but i didn't really manage to find anything even tho i made some small steps.
What i need to do is run everything from 1 single script, wether it goes from creating the database directory backup location to running the backup itself

```<code>sqlplus / as SYSDBA << EOF
CREATE DIRECTORY dmpdir AS '/nfs/ora_bck/';
exit
EOF
</code>```

It should give me some positive output but instead i get some database not mounted error which doesn't make sense because it's our production database which is up and running without any issues

答:
So it turns out all i needed to add is:
export ORACLE_SID=SID (which you can find from ps -ef | grep pmon )
and then the remaining parts of the script.

Hopefully this will help someone who had the same issues.

Just in case anyone needs the scripts to:

command.sh

```<code>export ORACLE_SID=SID
sqlplus / as SYSDBA <<EOF
CREATE DIRECTORY fulldp_dir AS '/mnt/nfs/backup_ora/';
exit
EOF
</code>```

backup.sh

```<code>export ORACLE_SID=SID
expdp \"/ as sysdba\" directory=fulldp_dir full=y dumpfile=full_exp.dmp logfile=full_exp.log
</code>```

Title: Database backup script

Body:
i'm pretty new to Oracle and i'm trying to make a script that backups the database everytime it's ran from cronjob.

I've been looking on a lot of discussions online but i didn't really manage to find anything even tho i made some small steps.
What i need to do is run everything from 1 single script, wether it goes from creating the database directory backup location to running the backup itself

sqlplus / as SYSDBA << EOF
CREATE DIRECTORY dmpdir AS '/nfs/ora_bck/';
exit
EOF

It should give me some positive output but instead i get some database not mounted error which doesn't make sense because it's our production database which is up and running without any issues

Body:
So it turns out all i needed to add is:
export ORACLE_SID=SID (which you can find from ps -ef | grep pmon )
and then the remaining parts of the script.

Hopefully this will help someone who had the same issues.

Just in case anyone needs the scripts to:

command.sh

export ORACLE_SID=SID
sqlplus / as SYSDBA <<EOF
CREATE DIRECTORY fulldp_dir AS '/mnt/nfs/backup_ora/';
exit
EOF

backup.sh

export ORACLE_SID=SID
expdp \"/ as sysdba\" directory=fulldp_dir full=y dumpfile=full_exp.dmp logfile=full_exp.log


问:
React Native Webview not resetting injected JavaScript
I have to retrieve the html content of the WebView when a certain URL is reached. To do this I inject window.postMessage(document.documentElement.innerHTML); using the injectJavaScript function provided by the WebView component when this URL is reached.

This works fine the first time, but when trying the same thing again after a restart, redirects are not handled and the injectedJavaScript is called at the first page as if it was never removed. This behaviour is present on iOS, not on Android.

Anyone encountered the same problem or has a fix for this?

答:
Use react-native-webview package:

```<code>import { WebView } from 'react-native-webview';

<WebView
    ref={(ref) => { this.webview = ref; }}
    source={{ uri: this.state.webViewUrl }}
    originWhitelist={['*']}
    javaScriptEnabledAndroid={true}
    injectedJavaScript={jsCode}
    onMessage={this._onMessage} // only if you want connection back
/>
</code>```

and you can pass js code:

```<code>const jsCode = `
document.querySelector('button.btn-success').addEventListener("click", function() {
    window.ReactNativeWebView.postMessage(JSON.stringify({type: "click", message : "ok"}));
});
true;
`
</code>```

Body:
Use react-native-webview package:

import { WebView } from 'react-native-webview';

<WebView
    ref={(ref) => { this.webview = ref; }}
    source={{ uri: this.state.webViewUrl }}
    originWhitelist={['*']}
    javaScriptEnabledAndroid={true}
    injectedJavaScript={jsCode}
    onMessage={this._onMessage} // only if you want connection back
/>

and you can pass js code:

const jsCode = `
document.querySelector('button.btn-success').addEventListener("click", function() {
    window.ReactNativeWebView.postMessage(JSON.stringify({type: "click", message : "ok"}));
});
true;
`


问:
Grab the first and last element for every sequence
I have a file with 3 types of sequences and their positions that are reoccurring as such:

```<code>seq1 2
seq1 5
seq1 10
seq3 15
seq3 34
seq3 60
seq2 100
seq2 110
seq2 200
seq3 210
seq3 250
seq3 300
seq1 310
seq1 330
seq1 400
</code>```

The second value is always unique denoting a position and is sorted, hence why the sequences are scattered.

For every time a sequence starts, I want to grab the minimum and max of that sequence. Output should be (seq min max)

```<code>seq1 2 10
seq3 15 60
seq2 100 200
seq3 210 300
seq1 310 400
</code>```

Is it possible to do this in bash with awk or anything else?

答:
You may use this awk:

```<code>awk 'p != $1 {if (NR>1) print p, first, last; first=$2} {p=$1; last=$2}
END{print p, first, last}' file
</code>```

```<code>seq1 2 10
seq3 15 60
seq2 100 200
seq3 210 300
seq1 310 400
</code>```

Body:
I have a file with 3 types of sequences and their positions that are reoccurring as such:

seq1 2
seq1 5
seq1 10
seq3 15
seq3 34
seq3 60
seq2 100
seq2 110
seq2 200
seq3 210
seq3 250
seq3 300
seq1 310
seq1 330
seq1 400

The second value is always unique denoting a position and is sorted, hence why the sequences are scattered.

For every time a sequence starts, I want to grab the minimum and max of that sequence. Output should be (seq min max)

seq1 2 10
seq3 15 60
seq2 100 200
seq3 210 300
seq1 310 400

Is it possible to do this in bash with awk or anything else?

Body:
You may use this awk:

awk 'p != $1 {if (NR>1) print p, first, last; first=$2} {p=$1; last=$2}
END{print p, first, last}' file

seq1 2 10
seq3 15 60
seq2 100 200
seq3 210 300
seq1 310 400


答:
Your function call to

```<code>backpack = addToInventory(backpack, dragonLoot)
</code>```

is not returning anything, so your backpack variable is None by default, hence the NoneType error.

To fix this, remove the assignment to backpack when you call the function:

```<code>addToInventory(backpack, dragonLoot)
</code>```

Title: How to call two separate functions on dictionaries and lists?

Body:
Your function call to

backpack = addToInventory(backpack, dragonLoot)

is not returning anything, so your backpack variable is None by default, hence the NoneType error.

To fix this, remove the assignment to backpack when you call the function:

addToInventory(backpack, dragonLoot)


问:
Flutter colorize background ExpansionPanelList
in this below flutter ExpansionPanelList widget i'm trying to colorize white background to other color such as indigo, i can't find any documentation or helpful link to achieve that

```<code>ExpansionPanelList(
  expansionCallback: (int index, bool isExpanded) {
    setState(() {
      _categoryExpansionStateMap[_categoryExpansionStateMap.keys
          .toList()[index]] = !isExpanded;
    });
  },
  children: <ExpansionPanel>[
    ExpansionPanel(
        headerBuilder: (BuildContext context, bool isExpanded) {
          return ListTile(
            contentPadding: EdgeInsets.all(3.0),
            leading: Container(
              padding:
                  EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
              decoration: BoxDecoration(
                  border: Border(
                      left: BorderSide(
                          width: 3.0, color: Colors.white54))),
              child: Icon(
                Icons.account_circle,
                size: 30.0,
                color: Colors.black,
              ),
            ),
            title: ListTile(
              contentPadding: EdgeInsets.all(0.0),
              title: Text(
                Strings.yourBasicInformation,
                style: TextStyle(
                    color: Colors.black,
                    fontSize: 14.0,),
              )
            ),
          );
        },
        body: Biography(),
        isExpanded: _categoryExpansionStateMap["Biography"]),
  ],
),
</code>```

答:
You can try two moves. One. Wrap your ExpansionPanelList in a Container and pass the color in the Container, I think it should work, I don't know the rest of your code.

The second move it to wrap your ExpansionPanelList in a Theme component. Pass a data, then call ThemeData().copyWith(canvasColor: Colors.white). Then, it'll look like this:

```<code>    Theme(
        data: ThemeData().copyWith(canvasColor: Colors.white),
        child: ExpansionPanelList(
          expansionCallback: (int index, bool isExpanded) {
            setState(() {
              _categoryExpansionStateMap[_categoryExpansionStateMap.keys
                  .toList()[index]] = !isExpanded;
            });
          },
          children: <ExpansionPanel>[
            ExpansionPanel(
                headerBuilder: (BuildContext context, bool isExpanded) {
                  return ListTile(
                    contentPadding: EdgeInsets.all(3.0),
                    leading: Container(
                      padding:
                      EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
                      decoration: BoxDecoration(
                          border: Border(
                              left: BorderSide(
                                  width: 3.0, color: Colors.white54))),
                      child: Icon(
                        Icons.account_circle,
                        size: 30.0,
                        color: Colors.black,
                      ),
                    ),
                    title: ListTile(
                        contentPadding: EdgeInsets.all(0.0),
                        title: Text(
                          Strings.yourBasicInformation,
                          style: TextStyle(
                            color: Colors.black,
                            fontSize: 14.0,),
                        )
                    ),
                  );
                },
                body: Biography(),
                isExpanded: _categoryExpansionStateMap["Biography"]),
          ],
        ),
      )
</code>```

Body:
in this below flutter ExpansionPanelList widget i'm trying to colorize white background to other color such as indigo, i can't find any documentation or helpful link to achieve that

ExpansionPanelList(
  expansionCallback: (int index, bool isExpanded) {
    setState(() {
      _categoryExpansionStateMap[_categoryExpansionStateMap.keys
          .toList()[index]] = !isExpanded;
    });
  },
  children: <ExpansionPanel>[
    ExpansionPanel(
        headerBuilder: (BuildContext context, bool isExpanded) {
          return ListTile(
            contentPadding: EdgeInsets.all(3.0),
            leading: Container(
              padding:
                  EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
              decoration: BoxDecoration(
                  border: Border(
                      left: BorderSide(
                          width: 3.0, color: Colors.white54))),
              child: Icon(
                Icons.account_circle,
                size: 30.0,
                color: Colors.black,
              ),
            ),
            title: ListTile(
              contentPadding: EdgeInsets.all(0.0),
              title: Text(
                Strings.yourBasicInformation,
                style: TextStyle(
                    color: Colors.black,
                    fontSize: 14.0,),
              )
            ),
          );
        },
        body: Biography(),
        isExpanded: _categoryExpansionStateMap["Biography"]),
  ],
),

Body:
You can try two moves. One. Wrap your ExpansionPanelList in a Container and pass the color in the Container, I think it should work, I don't know the rest of your code.

The second move it to wrap your ExpansionPanelList in a Theme component. Pass a data, then call ThemeData().copyWith(canvasColor: Colors.white). Then, it'll look like this:

    Theme(
        data: ThemeData().copyWith(canvasColor: Colors.white),
        child: ExpansionPanelList(
          expansionCallback: (int index, bool isExpanded) {
            setState(() {
              _categoryExpansionStateMap[_categoryExpansionStateMap.keys
                  .toList()[index]] = !isExpanded;
            });
          },
          children: <ExpansionPanel>[
            ExpansionPanel(
                headerBuilder: (BuildContext context, bool isExpanded) {
                  return ListTile(
                    contentPadding: EdgeInsets.all(3.0),
                    leading: Container(
                      padding:
                      EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
                      decoration: BoxDecoration(
                          border: Border(
                              left: BorderSide(
                                  width: 3.0, color: Colors.white54))),
                      child: Icon(
                        Icons.account_circle,
                        size: 30.0,
                        color: Colors.black,
                      ),
                    ),
                    title: ListTile(
                        contentPadding: EdgeInsets.all(0.0),
                        title: Text(
                          Strings.yourBasicInformation,
                          style: TextStyle(
                            color: Colors.black,
                            fontSize: 14.0,),
                        )
                    ),
                  );
                },
                body: Biography(),
                isExpanded: _categoryExpansionStateMap["Biography"]),
          ],
        ),
      )


问:
How to parse python b' before dict
How to access id or nickname value with python3:</p>

```<code>response._content = b'{"id":44564,"nickname":'Demo'}
</code>```

答:
This is a byte string that includes JSON as stated above. Another way to look at it is that is a dict definition (i.e python code). You can use eval for that:

```<code>foo = eval( b'{"id":44564,"nickname":"Demo"}')
foo['nickname']
</code>```

Probably this is not the preferred or secure way to do it because eval is considered dangerous

https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html

Title: How to parse python b' before dict

Body:
How to access id or nickname value with python3:

response._content = b'{"id":44564,"nickname":'Demo'}

Body:
This is a byte string that includes JSON as stated above. Another way to look at it is that is a dict definition (i.e python code). You can use eval for that:

foo = eval( b'{"id":44564,"nickname":"Demo"}')
foo['nickname']

Probably this is not the preferred or secure way to do it because eval is considered dangerous

https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html


问:
Conform to 'CBCentralManagerDelegate' protocol
I am getting a No type or protocol named 'CBCentralManagerDelegate' in project-Swift.h file. Not sure where I am going wrong here. I think it has something to do with with the swift.h but i'm new to CoreBluetooth so it could be that </p>

```<code>@objcMembers
class KestrelDeviceConnect: NSObject, CBCentralManagerDelegate, CBPeripheralManagerDelegate {

    var manager:CBCentralManager!
    var peripheral:CBPeripheral!
    let serviceCBUUID = CBUUID(string: "0x181A")
    var FieldSummaryModalLoaded = false

    override init() {
        super.init()
        manager = CBCentralManager(delegate: self, queue: nil)
    }

    @objc func fieldSummaryReportMCLoaded(){
        FieldSummaryModalLoaded = true
    }
    @objc func fieldSummaryReportMCChanged() {
        FieldSummaryModalLoaded = false
    }

    func getWeatherReading() -> WeatherThirdPartyReadings {

        var weatherReading = WeatherThirdPartyReadings(temperature: 0.00, speed: 0.00, direction: 0.00, observationTime: 0.00, isSummaryLoaded: false)

        manager.scanForPeripherals(withServices: nil)
        return weatherReading
    }

    func centralManagerDidUpdateState(_ central : CBCentralManager){

        switch central.state {
            case .poweredOff:
                print("off")

            case .poweredOn:
                print("on")
                manager.scanForPeripherals(withServices: [serviceCBUUID])
            case .resetting:
                print("resetting")

            case .unauthorized:
                print("unauthorized")
            case .unknown:
                print("unknown")

            case .unsupported:
                print("unsupported")

            default:
                break
        }
    }
    func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {

    }

}
</code>```

答: Had to <code>#import <CoreBluetooth/CoreBluetooth.h></code> in bridging header </p>

Body:
I am getting a No type or protocol named 'CBCentralManagerDelegate' in project-Swift.h file. Not sure where I am going wrong here. I think it has something to do with with the swift.h but i'm new to CoreBluetooth so it could be that

@objcMembers
class KestrelDeviceConnect: NSObject, CBCentralManagerDelegate, CBPeripheralManagerDelegate {

    var manager:CBCentralManager!
    var peripheral:CBPeripheral!
    let serviceCBUUID = CBUUID(string: "0x181A")
    var FieldSummaryModalLoaded = false

    override init() {
        super.init()
        manager = CBCentralManager(delegate: self, queue: nil)
    }

    @objc func fieldSummaryReportMCLoaded(){
        FieldSummaryModalLoaded = true
    }
    @objc func fieldSummaryReportMCChanged() {
        FieldSummaryModalLoaded = false
    }

    func getWeatherReading() -> WeatherThirdPartyReadings {

        var weatherReading = WeatherThirdPartyReadings(temperature: 0.00, speed: 0.00, direction: 0.00, observationTime: 0.00, isSummaryLoaded: false)

        manager.scanForPeripherals(withServices: nil)
        return weatherReading
    }

    func centralManagerDidUpdateState(_ central : CBCentralManager){

        switch central.state {
            case .poweredOff:
                print("off")

            case .poweredOn:
                print("on")
                manager.scanForPeripherals(withServices: [serviceCBUUID])
            case .resetting:
                print("resetting")

            case .unauthorized:
                print("unauthorized")
            case .unknown:
                print("unknown")

            case .unsupported:
                print("unsupported")

            default:
                break
        }
    }
    func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {

    }

}

Body: Had to #import <CoreBluetooth/CoreBluetooth.h> in bridging header


问:
Does the android application may allow another app to modify own files?
I am wondering about new skinning mechanism for my app. However I don't want to make my application bigger.

Is it possible to create another app, which will be able add/change files of another my app in /data/data/com.myfirstapp directory ?

答: The answer is simply no, you can access other applications from your own application but you cannot edit or change them.</p>


问:
Alternative eval() to execute the string
My array is A=['Apple','Peach','Orange']in Javascript, someone pass me the string like "A[1]" , how to convert the string "A[1]" to an executable item, so I can get 'Peach' as the result.

eval(A[1]) used to work but is not allowed here.

答:
Using regex you can parse out the variable and the index, then grab them off the window object.

A=['Apple','Peach','Orange'];

let string = "A[1]";
let variable = string.match(/[^[]*/)[0];
let index = string.match(/\[(.*)\]/)[1];
console.log(window[variable][index]);```


问:
.NET framework 4.0 install fails
I am having issues installing a program by Cornelsen.

The setup dialog prompts that NET framework 4.0 is needed in order to install.

I have installed NET framework 4.8 and I have not found a way to downgrade.

Any idea on how to fix the prompt?

EDIT: @Filburt I have tried following your link and get this prompt

FIX: Thanks to @Stein Åsmul using SuperOrca and simply changing the RegLocator Value from .../1031 to .../1033 enabled the MSI to run.

答:
LaunchCondition: This looks like a regular MSI LaunchCondition. These are logical conditions that must be met (be true) for the installation to be allowed to proceed. You should be able to disable the condition by opening the MSI and removing the launch condition in question from the LaunchCondition table. You need an MSI tool to do so. Orca is Microsoft's own tool, it is installed with Visual Studio and the Windows SDK. Try searching for Orca-x86_en-us.msi - under Program Files (x86) and install the MSI you find, or maybe try SuperOrca.

Modifying MSI: You are supposed to create an MST (transform) to change an MSI file (essentially a database change fragment to apply to the original MSI database file at runtime), but you can "hotfix" an existing MSI if you are in a hurry. Make a zip or copy of the original MSI first. Then just delete offending entries from the LaunchCondition table. I suppose you can add "OR 1" to the existing condition as well - I think that should work to make the condition always true.

Error Condition: Removing a launch condition will allow you to install the MSI whilst the condition in question is not true, but it will not fix the actual error condition that your MSI is warning you about - you just suppress the error. In your case, you could try to install the German language pack for .NET 4.8 yourself first (that might even satisfy the current launch condition - I do not know): https://dotnet.microsoft.com/download/dotnet-framework/net48

Title: .NET framework 4.0 install fails


问:
c++ code won't run on Visual Studios due to errors but no errors are shown
I have written a simple program to output different temperature units using conversions given. When I run the code on Visual Studios, it won't run due to build errors but no errors are shown. I have seen similar questions asked but couldn't really see any answer that solved my issue. I was also wondering whether I should be declaring the variables before or after the main function.</p>

```<code>#include <iostream>

using namespace std;

int fahrenheit, i=0;
float celsius, absolute_value;

main() {
    cout.width(20);
    cout << "Fahrenheit" << "Celsius" << "Absolute value\n";
    for (i = 0; i = 15; i += 1) {
        fahrenheit = i * 20;
        celsius = ((fahrenheit - 30) * 5) / 9;
        absolute_value = celsius + 273.15;
        cout.width(20); /*each item in next output will have width of at least 20*/
        cout << fahrenheit << celsius << absolute_value;
    }
    system("pause");
    return 0;
}
</code>```

答:
You need to add the int return type to the main signature.

In c++, the standard expects the main function to return an int, just as it expects the function to be called main. The return is most often used as an exit code, where 0 usually means successful execution without error.

Adding this in should allow your program to compile and run.

Body:
I have written a simple program to output different temperature units using conversions given. When I run the code on Visual Studios, it won't run due to build errors but no errors are shown. I have seen similar questions asked but couldn't really see any answer that solved my issue. I was also wondering whether I should be declaring the variables before or after the main function.

#include <iostream>

using namespace std;

int fahrenheit, i=0;
float celsius, absolute_value;

main() {
    cout.width(20);
    cout << "Fahrenheit" << "Celsius" << "Absolute value\n";
    for (i = 0; i = 15; i += 1) {
        fahrenheit = i * 20;
        celsius = ((fahrenheit - 30) * 5) / 9;
        absolute_value = celsius + 273.15;
        cout.width(20); /*each item in next output will have width of at least 20*/
        cout << fahrenheit << celsius << absolute_value;
    }
    system("pause");
    return 0;
}


问:
How can I make the data that is displayed on the table change with value chosen in a select box?
Based on the user that is chosen within the combo box, I want the table that is displaying user data from the database to only show the data corresponding to the user selected in the combo box.

I mainly tried using an array to store values but I couldn't get that working.

Combo Box that displays the name to pick

```<code>    <select>
        <?php
        $res = mysqli_query($db, "SELECT * FROM shifts");
        while ($row = mysqli_fetch_array($res))
        {
            ?>
            <option><?php echo $row ["name"]; ?></option>
            <?php
        }
        ?>
        <button class="btn-primary rounded">Find</button>
    </select>
</form>
</code>```

Table that shows the data from the database.

```<code><table class="table table-hover">
    <thead class="thead-dark"></thead>
    <tr>
        <th scope="col">Shift ID</th>
        <th scope="col">Name</th>
        <th scope="col">Origin</th>
        <th scope="col">Destination</th>
        <th scope="col">Date</th>
    </tr>
    </thead>
    <?php
    global $result;
    //Fetch Data form database
    if($result->num_rows > 0){
        while($row = $result->fetch_assoc()){
            ?>
         <tbody>
            <tr>
                <td><?php echo $row['shift_id']; ?></td>
                <td><?php echo $row['name']; ?></td>
                <td><?php echo $row['origin']; ?></td>
                <td><?php echo $row['destination']; ?></td>
                <td><?php echo $row['date']; ?></td>
            </tr>
         </tbody>
</table>
</code>```

I'm wondering if by using the form and doing a function that on pressing the Find button it looks up the user and displays only it's data. Thanks

答:
Check my code here, there are some thing you must add, like a WHERE statement to your query, when fetching data to only show results with the selected name in the form</p>

```<code><!-- Create a form with a select for all the names -->
<form method="POST" action="">
    <select name="name">
        <?php
        $res = mysqli_query($db, "SELECT * FROM shifts");
        while ($row = mysqli_fetch_array($res))
        {
            ?>
            <option><?php echo $row ["name"]; ?></option>
            <?php
        }
        ?>
        <button class="btn-primary rounded" name="find_info">Find</button>
    </select>
</form>

<?php
if(isset($_POST['find_info'])){ //If find button is pressed, show this:
?>
    <table class="table table-hover">
        <thead class="thead-dark"></thead>
        <tr>
            <th scope="col">Shift ID</th>
            <th scope="col">Name</th>
            <th scope="col">Origin</th>
            <th scope="col">Destination</th>
            <th scope="col">Date</th>
        </tr>
        </thead>
        <?php
        global $result;
        $nameSelected = strip_tags(mysqli_real_escape_string(htmlspecialchars($_POST['name'])));
        // Use WHERE in your mysqli query to fetch data where name in database is equal to $nameSelected
        if($result->num_rows > 0){
            while($row = $result->fetch_assoc()){
                ?>
             <tbody>
                <tr>
                    <td><?php echo $row['shift_id']; ?></td>
                    <td><?php echo $row['name']; ?></td>
                    <td><?php echo $row['origin']; ?></td>
                    <td><?php echo $row['destination']; ?></td>
                    <td><?php echo $row['date']; ?></td>
                </tr>
             </tbody>
    </table>
<?php
}
?>
</code>```

Body:
Based on the user that is chosen within the combo box, I want the table that is displaying user data from the database to only show the data corresponding to the user selected in the combo box.

I mainly tried using an array to store values but I couldn't get that working.

Combo Box that displays the name to pick

    <select>
        <?php
        $res = mysqli_query($db, "SELECT * FROM shifts");
        while ($row = mysqli_fetch_array($res))
        {
            ?>
            <option><?php echo $row ["name"]; ?></option>
            <?php
        }
        ?>
        <button class="btn-primary rounded">Find</button>
    </select>
</form>

Table that shows the data from the database.

        Shift ID
        Name
        Origin
        Destination
        Date

    <?php
    global $result;
    //Fetch Data form database
    if($result->num_rows > 0){
        while($row = $result->fetch_assoc()){
            ?>

                <?php echo $row['shift_id']; ?>
                <?php echo $row['name']; ?>
                <?php echo $row['origin']; ?>
                <?php echo $row['destination']; ?>
                <?php echo $row['date']; ?>

I'm wondering if by using the form and doing a function that on pressing the Find button it looks up the user and displays only it's data. Thanks

Body:
Check my code here, there are some thing you must add, like a WHERE statement to your query, when fetching data to only show results with the selected name in the form

<!-- Create a form with a select for all the names -->
<form method="POST" action="">
    <select name="name">
        <?php
        $res = mysqli_query($db, "SELECT * FROM shifts");
        while ($row = mysqli_fetch_array($res))
        {
            ?>
            <option><?php echo $row ["name"]; ?></option>
            <?php
        }
        ?>
        <button class="btn-primary rounded" name="find_info">Find</button>
    </select>
</form>

<?php
if(isset($_POST['find_info'])){ //If find button is pressed, show this:
?>
    <table class="table table-hover">
        <thead class="thead-dark"></thead>
        <tr>
            <th scope="col">Shift ID</th>
            <th scope="col">Name</th>
            <th scope="col">Origin</th>
            <th scope="col">Destination</th>
            <th scope="col">Date</th>
        </tr>
        </thead>
        <?php
        global $result;
        $nameSelected = strip_tags(mysqli_real_escape_string(htmlspecialchars($_POST['name'])));
        // Use WHERE in your mysqli query to fetch data where name in database is equal to $nameSelected
        if($result->num_rows > 0){
            while($row = $result->fetch_assoc()){
                ?>
             <tbody>
                <tr>
                    <td><?php echo $row['shift_id']; ?></td>
                    <td><?php echo $row['name']; ?></td>
                    <td><?php echo $row['origin']; ?></td>
                    <td><?php echo $row['destination']; ?></td>
                    <td><?php echo $row['date']; ?></td>
                </tr>
             </tbody>
    </table>
<?php
}
?>


问:
Creating NumPy matrix of a given size in a vectorized manner
If there a built-in NumPy function or any vectorized approach to generate the following 2D NumPy matrices for value of n > 1? Let me give some examples for the desired matrices for n equal to 2, 3, and 4.

One approach would be to construct a matrix of 1’s in the lower triangular part and then simply multiply by a vector np.arange(1, n+1). Any other alternatives?

```<code>import numpy as np
</code>```

For n = 2

```<code>n = 2
arr = np.array([[1, 0], [2, 2]])

# array([[1, 0],
#        [2, 2]])
</code>```

For n = 3

```<code>n = 3
arr = np.array([[1, 0, 0], [2, 2, 0], [3, 3, 3]])

# array([[1, 0, 0],
#        [2, 2, 0],
#        [3, 3, 3]])
</code>```

For n = 4

```<code>n = 4
arr = np.array([[1, 0, 0, 0], [2, 2, 0, 0], [3, 3, 3, 0], [4, 4, 4, 4]])

# array([[1, 0, 0, 0],
#        [2, 2, 0, 0],
#        [3, 3, 3, 0],
#        [4, 4, 4, 4]])
</code>```

My attempt (example for n = 4) using nested for loops. It works for any value of n > 1:

```<code>import numpy as np

n = 4
arr = np.zeros((n, n))

for i in range(n):
    for j in range(0, i+1):
        arr[i][j] = i+1

# array([[1., 0., 0., 0.],
#        [2., 2., 0., 0.],
#        [3., 3., 3., 0.],
#        [4., 4., 4., 4.]])
</code>```

答:
You can use np.tril and np.broadcast_to to create the initial arange variant.

```<code>import numpy as np

n = 4
np.tril(np.broadcast_to(np.arange(1, n+1)[:, None], (n, n)))
</code>```

```<code>array([[1, 0, 0, 0],
       [2, 2, 0, 0],
       [3, 3, 3, 0],
       [4, 4, 4, 4]])
</code>```

Body:
If there a built-in NumPy function or any vectorized approach to generate the following 2D NumPy matrices for value of n > 1? Let me give some examples for the desired matrices for n equal to 2, 3, and 4.

One approach would be to construct a matrix of 1’s in the lower triangular part and then simply multiply by a vector np.arange(1, n+1). Any other alternatives?

import numpy as np

For n = 2

n = 2
arr = np.array([[1, 0], [2, 2]])

# array([[1, 0],
#        [2, 2]])

For n = 3

n = 3
arr = np.array([[1, 0, 0], [2, 2, 0], [3, 3, 3]])

# array([[1, 0, 0],
#        [2, 2, 0],
#        [3, 3, 3]])

For n = 4

n = 4
arr = np.array([[1, 0, 0, 0], [2, 2, 0, 0], [3, 3, 3, 0], [4, 4, 4, 4]])

# array([[1, 0, 0, 0],
#        [2, 2, 0, 0],
#        [3, 3, 3, 0],
#        [4, 4, 4, 4]])

My attempt (example for n = 4) using nested for loops. It works for any value of n > 1:

import numpy as np

n = 4
arr = np.zeros((n, n))

for i in range(n):
    for j in range(0, i+1):
        arr[i][j] = i+1

# array([[1., 0., 0., 0.],
#        [2., 2., 0., 0.],
#        [3., 3., 3., 0.],
#        [4., 4., 4., 4.]])

Body:
You can use np.tril and np.broadcast_to to create the initial arange variant.

import numpy as np

n = 4
np.tril(np.broadcast_to(np.arange(1, n+1)[:, None], (n, n)))

array([[1, 0, 0, 0],
       [2, 2, 0, 0],
       [3, 3, 3, 0],
       [4, 4, 4, 4]])


问:
One-line "for" loop using list comprehension
Someone has challenged me to create a program that sorts their pictures into folders based on the month they were taken, and I want to do it in one line (I know, it's inefficient and unreadable, but I still want to do it because one-liners are cool)

I needed a for loop to accomplish this, but the only way I know of to use a for loop in one line is list comprehension, so that's what I did, but it creates an empty list, and doesn't print anything from the list or anything.

What I'm doing is renaming the file to be the month created + original filename (ex: bacon.jpg --> May\bacon.jpg)

Here is my code (Python 3.7.3):

import time
import os.path
[os.rename(str(os.fspath(f)), str(time.ctime(os.path.getctime(str(os.fspath(f))))).split()[1] + '\\' + str(os.fspath(f))) for f in os.listdir() if f.endswith('.jpg')]
```

<p>and the more readable, non-list-comprehension version:</p>

<pre class="lang-py prettyprint-override"><code>import time
import os.path
for f in os.listdir():
    fn = str(os.fspath(f))
    dateCreated = str(time.ctime(os.path.getctime(fn)))
    monthCreated = dateCreated.split()[1]
    os.rename(fn, monthCreated + '\\' + fn)
</code>```

Is list comprehension a bad way to do it? Also, is there a reason why, if I print the list it's [] instead of [None, None, None, None, None, (continuing "None"s for every image moved)]?

Please note: I understand that it's inefficient and bad practice. If I were doing this for purposes other than just for fun to see if I could do it, I would obviously not try to do it in one line.

答:
This is bad in two immediate respects:

You're using a list comprehension when you're not actually interested in constructing a list -- you ignore the object you just constructed.

Your construction has an ugly side effect in the OS.

Your purpose appears to be renaming a sequence of files, not constructing a list.  The Python facility you want is, I believe, the map function.  Write a function to change one file name, and then use map on a list of file names -- or tuples of old, new file names -- to run through the sequence of desired changes.

Body:
Someone has challenged me to create a program that sorts their pictures into folders based on the month they were taken, and I want to do it in one line (I know, it's inefficient and unreadable, but I still want to do it because one-liners are cool)

I needed a for loop to accomplish this, but the only way I know of to use a for loop in one line is list comprehension, so that's what I did, but it creates an empty list, and doesn't print anything from the list or anything.

What I'm doing is renaming the file to be the month created + original filename (ex: bacon.jpg --> May\bacon.jpg)

Here is my code (Python 3.7.3):

import time
import os.path
[os.rename(str(os.fspath(f)), str(time.ctime(os.path.getctime(str(os.fspath(f))))).split()[1] + '\\' + str(os.fspath(f))) for f in os.listdir() if f.endswith('.jpg')]

and the more readable, non-list-comprehension version:

import time
import os.path
for f in os.listdir():
    fn = str(os.fspath(f))
    dateCreated = str(time.ctime(os.path.getctime(fn)))
    monthCreated = dateCreated.split()[1]
    os.rename(fn, monthCreated + '\\' + fn)

Is list comprehension a bad way to do it? Also, is there a reason why, if I print the list it's [] instead of [None, None, None, None, None, (continuing "None"s for every image moved)]?

Please note: I understand that it's inefficient and bad practice. If I were doing this for purposes other than just for fun to see if I could do it, I would obviously not try to do it in one line.


问:
Importing HTML to Excel using VSTO
I have some html files and I need to import the data to excel. I am using VSTO (VB.NET) to achieve the same. Unfortunately, I am getting some error. I am new to parsing html. Can somebody tell me where I am going wrong in the code below.

I tried to read header 2 text from the HTML collection, but its not working. Can some one let me know where am I going wrong?

```<code>        Dim doc As HtmlDocument, htmlTable As Object, htmlBody As
        HtmlElementCollection
        Dim wbrowser As New WebBrowser
        Dim header2 as String
        wbrowser.Visible = False
        wbrowser.Navigate(InputHtmlFile)
        'Do
        '
        'Loop Until Not wbrowser.IsBusy

        doc = wbrowser.Document

        htmlBody = doc.GetElementsByTagName("BODY")
        htmlheadings = doc.GetElementsByTagName("H2")
        header2 = htmlheadings(0).Innertext
</code>```

Below is the html code

```<code>    <HEAD>
    <TITLE> SOME TITLE </TITLE>
    </HEAD>
    <BODY>
    <H2> HEADER 2 TEXT </H2>
    <HR NOSHADE>
    <H3> <U>DATA</U> </H3>
    <BLOCKQUOTE>
    VERSION NUMBER X.X.XXX
    </BLOCKQUOTE>
    <HR SIZE = 5>
    <H3> <U>DATA SET 2</U></H3>
    <BLOCKQUOTE>
    <H4>DATA SET 3 </H4>
    <BLOCKQUOTE>

    <TABLE border=1>
    <TR> <TH> TableHeader1 </TH> <TH>TTableHeader2</TH>
    <TH>TableHeader3</TH><TH>TableHeader4</TH><TH>TableHeader5</TH>
    <TH>TableHeader6</TH></TR><TR ALIGN=CENTER><TD>1</TD><TD> 6.4</TD><TD>
    StringData</TD><TD> No</TD><TD> </TD><TD> </TD> </TR></TABLE><BR>
    </BLOCKQUOTE>
</code>```

I expect "HEADER 2 TEXT" is assigned to the variable header2 but I get the following error at the line

```<code>    header2 = htmlheadings(0).Innertext
</code>```

System.ArgumentOutOfRangeException: 'Value of '0' is not valid for 'index'. 'index' should be between 0 and -1.
Parameter name: index'

htmlheadings(0).InnerHtml = 'htmlheadings(0).InnerHtml' threw an exception of type 'System.ArgumentOutOfRangeException'

Also the collections htmlBody and htmlheadings are empty.

答:
Your HTML code is not proper HTML. There are no  tags, no ending  tag, more opening
 tags than closing ones etc. I removed what was incorrect:

```<code>    <?xml version="1.0" encoding="utf-8" ?>
    <html>
      <head>
        <title>SOME TITLE</title>
      </head>
      <body>
        <h2>HEADER 2 TEXT </h2>
        <h3>
          <u>DATA</u>
        </h3>
        <blockquote>VERSION NUMBER X.X.XXX</blockquote>
        <h3><u>DATA SET 2</u></h3>
        <h4>DATA Set 3</h4>
        <table border="1">
          <tr><th>TableHeader1</th><th>TTableHeader2</th><th>TableHeader3</th><th>TableHeader4</th><th>TableHeader5</th><th>TableHeader6</th></tr>
          <tr align="CENTER"><td>1</td><td>6.4</td><td>StringData</td><td>No</td><td></td><td></td></tr>
        </table>
        <br />
      </body>
    </html>
</code>```

The elements are working fine in the DocumentCompleted event handler of the browser control (double-click it to generate the event handler):

```<code>Public Class Form1

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        wbrowser.Visible = False
        wbrowser.Navigate("C:\temp\foo.html")
    End Sub

    Private Sub wbrowser_DocumentCompleted(sender As Object, e As Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wbrowser.DocumentCompleted
        Dim doc = wbrowser.Document
        Dim htmlBody = doc.GetElementsByTagName("BODY")(0)
        Dim htmlheadings = htmlBody.GetElementsByTagName("H2")
        Dim header2 = htmlheadings(0).InnerText
        MsgBox(header2)
    End Sub

End Class
</code>```

Title: Importing HTML to Excel using VSTO

Body:
I have some html files and I need to import the data to excel. I am using VSTO (VB.NET) to achieve the same. Unfortunately, I am getting some error. I am new to parsing html. Can somebody tell me where I am going wrong in the code below.

I tried to read header 2 text from the HTML collection, but its not working. Can some one let me know where am I going wrong?

        Dim doc As HtmlDocument, htmlTable As Object, htmlBody As
        HtmlElementCollection
        Dim wbrowser As New WebBrowser
        Dim header2 as String
        wbrowser.Visible = False
        wbrowser.Navigate(InputHtmlFile)
        'Do
        '
        'Loop Until Not wbrowser.IsBusy

        doc = wbrowser.Document

        htmlBody = doc.GetElementsByTagName("BODY")
        htmlheadings = doc.GetElementsByTagName("H2")
        header2 = htmlheadings(0).Innertext

Below is the html code

    <TITLE> SOME TITLE </TITLE>

 HEADER 2 TEXT

 DATA

    VERSION NUMBER X.X.XXX

 DATA SET 2

DATA SET 3

  TableHeader1 	 TTableHeader2
    TableHeader3	TableHeader4	TableHeader5
    TableHeader6

1	 6.4
    StringData	 No

I expect "HEADER 2 TEXT" is assigned to the variable header2 but I get the following error at the line

    header2 = htmlheadings(0).Innertext

System.ArgumentOutOfRangeException: 'Value of '0' is not valid for 'index'. 'index' should be between 0 and -1.
Parameter name: index'

htmlheadings(0).InnerHtml = 'htmlheadings(0).InnerHtml' threw an exception of type 'System.ArgumentOutOfRangeException'

Also the collections htmlBody and htmlheadings are empty.

Body:
Your HTML code is not proper HTML. There are no <HTML> tags, no ending </BODY> tag, more opening <BLOCKQUOTE> tags than closing ones etc. I removed what was incorrect:

    <?xml version="1.0" encoding="utf-8" ?>
    <html>
      <head>
        <title>SOME TITLE</title>
      </head>
      <body>
        <h2>HEADER 2 TEXT </h2>
        <h3>
          <u>DATA</u>
        </h3>
        <blockquote>VERSION NUMBER X.X.XXX</blockquote>
        <h3><u>DATA SET 2</u></h3>
        <h4>DATA Set 3</h4>
        <table border="1">
          <tr><th>TableHeader1</th><th>TTableHeader2</th><th>TableHeader3</th><th>TableHeader4</th><th>TableHeader5</th><th>TableHeader6</th></tr>
          <tr align="CENTER"><td>1</td><td>6.4</td><td>StringData</td><td>No</td><td></td><td></td></tr>
        </table>
        <br />
      </body>
    </html>

The elements are working fine in the DocumentCompleted event handler of the browser control (double-click it to generate the event handler):

Public Class Form1

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        wbrowser.Visible = False
        wbrowser.Navigate("C:\temp\foo.html")
    End Sub

    Private Sub wbrowser_DocumentCompleted(sender As Object, e As Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wbrowser.DocumentCompleted
        Dim doc = wbrowser.Document
        Dim htmlBody = doc.GetElementsByTagName("BODY")(0)
        Dim htmlheadings = htmlBody.GetElementsByTagName("H2")
        Dim header2 = htmlheadings(0).InnerText
        MsgBox(header2)
    End Sub

End Class


问:
If cell in a range has value "x" copy and paste a range of cells into a different sheet
I am not a programmer by trade but I am trying to automate a small portion of a report I use every day out of curiosity and self interest. Basically, we receive and manually enter contact information (name, e-mail, phone number, etc.) and mark select groups that a person is interested in joining. We then copy and paste that contact information entered into a different sheet for each group.

I want to have a macro that checks the specific columns for each interest group for a "x" and if it finds that value copy and paste the contact information collected to the specific interest groups worksheet. People are able to select multiple interest groups and their contact information is added to each separate interest group spreadsheet.

Report columns look as follows:

```<code>Group 1 Group 2 Group 3 Name Organization Phone E-mail  Notes

Row Contact Information looks similar to:
  x  x John ABC Inc. 000-000-0000 john.smith@fake.com  Call me ASAP!
</code>```

The macro checks the column I have marked interest in Group 1 in and if it finds "x" then it copies the full range to the Group 1 worksheet.

I want it to be able to check multiple columns (i.e. Group 1, 2, 3) for "x" and then copy and paste the information to the right of those columns to the appropriate sheet for the group. If they have interest in multiple groups, their contact info should be copied to each specific worksheet.\

Do I need to have separate counters for each group worksheet and is there a way to write a if then statement that checks for x in each of the columns and then runs the appropriate code to copy and paste into that group?

```<code>Sub Update()

    Dim c As Range
    Dim j As Integer
    Dim Source As Worksheet
    Dim Target1 As Worksheet
    Dim Target2 As Worksheet
    Dim Target3 As Worksheet

    Set Source = ActiveWorkbook.Worksheets("Interest Group Tracking")
    Set Target1 = ActiveWorkbook.Worksheets("Group 1")

    j = 1   'Start copying to row 1 in target sheet
    For Each c In Source.Range("A1:A1000") 'not sure if there is a way to not set a limit for the range
        If c = "x" Then
            Source.Rows(c.Row).Copy Target1.Rows(j + 1)
            j = j + 1
            End If
    Next c

End Sub
</code>```

No errors besides the occasional syntax but don't really know how to structure the loop for checking for each group. I am continuing to research and test things I find and will update if I need to.

答:
See if this helps... I've added comments in the code, but please feel free to ask any other questions:

Sub Update()
    Dim wb As Workbook: Set wb = ThisWorkbook
    Dim Source As Worksheet: Set Source = wb.Worksheets("Interest Group Tracking")
    Dim Target As Worksheet

    Dim R As Long, C As Long, lRowSrc As Long, lRowDst As Long

    With Source
        lRowSrc = .Cells(.Rows.Count, 1).End(xlUp).Row 'get the last row in your source sheet

        For R = 1 To lRowSrc    'Loop through all rows in the source
            For C = 1 To 3      'Loop through the 3 columns in the source
                If .Cells(R, C) = "x" Then
                    Set Target = wb.Worksheets("Group " & C)    'Assuming all groups have the same names, Group 1, Group 2, etc
                    lRowDst = Target.Cells(Target.Rows.Count, 1).End(xlUp).Row + 1 'get last row + 1 in the target sheet
                    .Rows(R).Copy Target.Rows(lRowDst)
                End If
            Next C
        Next R
    End With

End Sub
```

<p><strong>EDIT:</strong> additional sample</p>

<pre class="lang-vb prettyprint-override"><code>Sub Update()
    Dim wb As Workbook: Set wb = ThisWorkbook
    Dim Source As Worksheet: Set Source = wb.Worksheets("Interest Group Tracking")
    Dim Target As Worksheet
    Dim shNames() As String: shNames = Split("ABC Group,Voter Accesibility,Animal Rights Activism", ",") 'Add sheet names here in the order of the groups

    Dim R As Long, C As Long, lRowSrc As Long, lColSrc As Long, lRowDst As Long

    With Source
        lRowSrc = .Cells(.Rows.Count, 1).End(xlUp).Row 'get the last row in your source sheet

        For R = 1 To lRowSrc    'Loop through all rows in the source
            For C = 1 To 3      'Loop through the 3 columns in the source
                If .Cells(R, C) = "x" Then
                    Set Target = wb.Worksheets(shNames(C - 1)) 'shNames array starts at 0
                    lRowDst = Target.Cells(Target.Rows.Count, 1).End(xlUp).Row + 1 'get last row + 1 in the target sheet
                    Target.Range(Target.Cells(lRowDst, 1), Target.Cells(lRowDst, 10 - C + 1)) = .Range(.Cells(R, C), .Cells(R, 10)).Value 'allocate the values
                End If
            Next C
        Next R
    End With

End Sub
</code>```

Body:
I am not a programmer by trade but I am trying to automate a small portion of a report I use every day out of curiosity and self interest. Basically, we receive and manually enter contact information (name, e-mail, phone number, etc.) and mark select groups that a person is interested in joining. We then copy and paste that contact information entered into a different sheet for each group.

I want to have a macro that checks the specific columns for each interest group for a "x" and if it finds that value copy and paste the contact information collected to the specific interest groups worksheet. People are able to select multiple interest groups and their contact information is added to each separate interest group spreadsheet.

Report columns look as follows:

Group 1 Group 2 Group 3 Name Organization Phone E-mail  Notes

Row Contact Information looks similar to:
  x  x John ABC Inc. 000-000-0000 john.smith@fake.com  Call me ASAP!

The macro checks the column I have marked interest in Group 1 in and if it finds "x" then it copies the full range to the Group 1 worksheet.

I want it to be able to check multiple columns (i.e. Group 1, 2, 3) for "x" and then copy and paste the information to the right of those columns to the appropriate sheet for the group. If they have interest in multiple groups, their contact info should be copied to each specific worksheet.\

Do I need to have separate counters for each group worksheet and is there a way to write a if then statement that checks for x in each of the columns and then runs the appropriate code to copy and paste into that group?

Sub Update()

    Dim c As Range
    Dim j As Integer
    Dim Source As Worksheet
    Dim Target1 As Worksheet
    Dim Target2 As Worksheet
    Dim Target3 As Worksheet

    Set Source = ActiveWorkbook.Worksheets("Interest Group Tracking")
    Set Target1 = ActiveWorkbook.Worksheets("Group 1")

    j = 1   'Start copying to row 1 in target sheet
    For Each c In Source.Range("A1:A1000") 'not sure if there is a way to not set a limit for the range
        If c = "x" Then
            Source.Rows(c.Row).Copy Target1.Rows(j + 1)
            j = j + 1
            End If
    Next c

End Sub

No errors besides the occasional syntax but don't really know how to structure the loop for checking for each group. I am continuing to research and test things I find and will update if I need to.

Body:
See if this helps... I've added comments in the code, but please feel free to ask any other questions:

Sub Update()
    Dim wb As Workbook: Set wb = ThisWorkbook
    Dim Source As Worksheet: Set Source = wb.Worksheets("Interest Group Tracking")
    Dim Target As Worksheet

    Dim R As Long, C As Long, lRowSrc As Long, lRowDst As Long

    With Source
        lRowSrc = .Cells(.Rows.Count, 1).End(xlUp).Row 'get the last row in your source sheet

        For R = 1 To lRowSrc    'Loop through all rows in the source
            For C = 1 To 3      'Loop through the 3 columns in the source
                If .Cells(R, C) = "x" Then
                    Set Target = wb.Worksheets("Group " & C)    'Assuming all groups have the same names, Group 1, Group 2, etc
                    lRowDst = Target.Cells(Target.Rows.Count, 1).End(xlUp).Row + 1 'get last row + 1 in the target sheet
                    .Rows(R).Copy Target.Rows(lRowDst)
                End If
            Next C
        Next R
    End With

End Sub

EDIT: additional sample

Sub Update()
    Dim wb As Workbook: Set wb = ThisWorkbook
    Dim Source As Worksheet: Set Source = wb.Worksheets("Interest Group Tracking")
    Dim Target As Worksheet
    Dim shNames() As String: shNames = Split("ABC Group,Voter Accesibility,Animal Rights Activism", ",") 'Add sheet names here in the order of the groups

    Dim R As Long, C As Long, lRowSrc As Long, lColSrc As Long, lRowDst As Long

    With Source
        lRowSrc = .Cells(.Rows.Count, 1).End(xlUp).Row 'get the last row in your source sheet

        For R = 1 To lRowSrc    'Loop through all rows in the source
            For C = 1 To 3      'Loop through the 3 columns in the source
                If .Cells(R, C) = "x" Then
                    Set Target = wb.Worksheets(shNames(C - 1)) 'shNames array starts at 0
                    lRowDst = Target.Cells(Target.Rows.Count, 1).End(xlUp).Row + 1 'get last row + 1 in the target sheet
                    Target.Range(Target.Cells(lRowDst, 1), Target.Cells(lRowDst, 10 - C + 1)) = .Range(.Cells(R, C), .Cells(R, 10)).Value 'allocate the values
                End If
            Next C
        Next R
    End With

End Sub


问:
Unchecked CheckBox in jsPDF AcroForms
The examples of jsPDF AcroForm fields in the jsPDF documentation show how to create a CheckBox field but that field is always checked initially. How do you create a CheckBox that initializes to unchecked?</p>

答:
After digging around in the PDF spec (ISO 32000-1:2008) I found in section 12.7.4.2.3 that the checked and unchecked appearances correspond to entries in the field's appearance dictionary. I downloaded this PDF generated by jsPDF:

```<code>var doc = new jsPDF();
doc.text('CheckBox:', 10, 125);
var checkBox = new CheckBox();
checkBox.fieldName = "CheckBox1";
checkBox.Rect = [50, 120, 30, 10];
checkBox.value = 'Yes'
doc.addField(checkBox);
</code>```

I opened the PDF in a text editor and found my field definition:

```<code><<
/F 4
/Rect [141.73 473.39 226.77 501.73]
/FT /Btn
/T (CheckBox1)
/DA (/F13 0 Tf 0.000 g)
/V /Yes
/Type /Annot
/Subtype /Widget
/Q 1
/MK <<
/CA (3)
>>
/AS /On
/AP <<
/N <</On 7 0 R >>/D <</On 8 0 R /Off 9 0 R >>>>
>>
</code>```

The /N there is the dictionary and the AS value is whether the CheckBox is checked or not. So this means you can control the appearance with:

```<code>checkBox.appearanceState = 'Off' //unchecked
checkBox.appearanceState = 'On' //checked
</code>```

Title: Unchecked CheckBox in jsPDF AcroForms

Body:
After digging around in the PDF spec (ISO 32000-1:2008) I found in section 12.7.4.2.3 that the checked and unchecked appearances correspond to entries in the field's appearance dictionary. I downloaded this PDF generated by jsPDF:

var doc = new jsPDF();
doc.text('CheckBox:', 10, 125);
var checkBox = new CheckBox();
checkBox.fieldName = "CheckBox1";
checkBox.Rect = [50, 120, 30, 10];
checkBox.value = 'Yes'
doc.addField(checkBox);

I opened the PDF in a text editor and found my field definition:

<<
/F 4
/Rect [141.73 473.39 226.77 501.73]
/FT /Btn
/T (CheckBox1)
/DA (/F13 0 Tf 0.000 g)
/V /Yes
/Type /Annot
/Subtype /Widget
/Q 1
/MK <<
/CA (3)
>>
/AS /On
/AP <<
/N <</On 7 0 R >>/D <</On 8 0 R /Off 9 0 R >>>>
>>

The /N there is the dictionary and the AS value is whether the CheckBox is checked or not. So this means you can control the appearance with:

checkBox.appearanceState = 'Off' //unchecked
checkBox.appearanceState = 'On' //checked


问:
Can we assume testing Facebook Web InstantGame will cover testing Facebook APP InstantGame as well?
We have an Instant Game for Facebook and we would like to test it on both Web and Mobile. We had already completed automation-testing it on Web with Selenium. Now before going deeper, we wonder if Web testing covers mobile as well. Since Facebook Instant Game platform is basically an iFrame that loads our code, we wonder if it differs. Does anybody have experience on testing FB Instant Games?</p>

答: The platform (browser) is different, so no, not the same.  Events are also different.  (ex: Most phones don't generate hover...) </p>