问:
Error filling print... Error evaluating expression
```<code><?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="478ce75d-1606-47d2-88eb-f8079f50c69b">
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["D:\\newpackage\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_SUB" class="java.lang.Integer" isForPrompting="false">
        <defaultValueExpression><![CDATA[Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_MAIN" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[SELECT * FROM table_name WHERE atr = $P{MEMBER_CERTIFICATE_PARAM_SUB}]]>
    </queryString>
    <field name="national_id_number" class="java.lang.String"/>
    <field name="national_pin_number" class="java.lang.String"/>
    <field name="contact_email" class="java.lang.String"/>
    <field name="biometric_member_number" class="java.lang.String"/>
    <title>
        <band height="74" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="72" uuid="2cee9cb2-abe3-4739-9b64-ec405bf9912b"/>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\NhifHeader\\src\\nhifheader\\PotraitNhifHeader\\PortraitNhifHeader.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </title>
    <pageHeader>
        <band height="56" splitType="Stretch">
            <textField>
                <reportElement x="529" y="13" width="26" height="15" uuid="1d23b617-b659-4f87-acfd-e07b54913ccd"/>
                <textFieldExpression><![CDATA[$F{national_pin_number}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="367" y="13" width="173" height="15" uuid="e02099fe-b171-4a24-bb15-195a046921c8"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Personal Identification Number:]]></text>
            </staticText>
            <componentElement>
                <reportElement x="0" y="1" width="240" height="30" uuid="311343bc-7e09-4658-8a1e-810fe91d1a3f"/>
                <jr:Code39 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" textPosition="bottom">
                    <jr:codeExpression><![CDATA[$F{biometric_member_number}]]></jr:codeExpression>
                </jr:Code39>
            </componentElement>
            <staticText>
                <reportElement x="367" y="0" width="31" height="15" uuid="fefca1d6-a90f-4dba-996c-1c00883eba1c"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Date]]></text>
            </staticText>
            <textField pattern="MMMMM dd, yyyy">
                <reportElement x="398" y="0" width="142" height="20" uuid="c3c68a84-f1d6-43c9-9c83-8b5eaacd6c38"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <line>
                <reportElement x="0" y="33" width="555" height="1" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="003310a9-85b0-447a-bc29-8f97f0006c1d"/>
            </line>
            <staticText>
                <reportElement x="2" y="35" width="553" height="20" uuid="5d8caf66-df88-403d-b96a-1ba2d0e84087"/>
                <textElement textAlignment="Center"/>
                <text><![CDATA[This is to certify that person shown herein is a member of NHIF: National Hospital Insurance Fund]]></text>
            </staticText>
            <frame>
                <reportElement mode="Opaque" x="179" y="1" width="172" height="21" forecolor="#C0C0C0" backcolor="#C0C0C0" uuid="63309c64-53a9-41e7-b490-fa5278230357"/>
                <staticText>
                    <reportElement mode="Transparent" x="33" y="0" width="113" height="20" forecolor="#000000" backcolor="#000000" uuid="ca2b9d0e-5260-4fb3-9f20-308a4349852e"/>
                    <textElement>
                        <font size="12" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Member Certificate]]></text>
                </staticText>
            </frame>
        </band>
    </pageHeader>
    <detail>
        <band height="67" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="66" uuid="27c682e0-71b6-4232-8a7a-9efaad62240f"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateAddress.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="68">
            <subreport>
                <reportElement x="0" y="0" width="555" height="67" uuid="169130d8-125e-45c4-b455-4cdced7665d1"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateInfo.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="56">
            <subreport>
                <reportElement x="0" y="0" width="555" height="55" uuid="f36d8a91-96b9-44fc-a393-bbc5752b5316"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateIsuranceObligation.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>
</code>```

I  have a JasperReports's report with several subreports. I'm using iReport plugin with my NetBeans. I have passed the same integer parameter type to all sub reports and also to main report . Main report has two parameter , one that has prompt option enabled and is of type string. and the other that takes parameter as a string and coverts it to integer Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN}) ( this is found in all sub reports  ). This is how i always pass parameters. But when i run this report i get the following errors.

Error filling print... Error evaluating expression :
      Source text : Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})  net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
      Source text : Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})      at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:244)
      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
      at net.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:994)
      at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:635)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1280)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:900)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)
      at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:87)
      at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
      at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276)
      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)
      at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891)
      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
      at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
      at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)      at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
  Caused by: java.lang.NumberFormatException: null
      at java.lang.Integer.parseInt(Integer.java:542)      at java.lang.Integer.parseInt(Integer.java:615)

答:
```<code><?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="478ce75d-1606-47d2-88eb-f8079f50c69b">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\BranchHeader\\src\\PortraitBranchHeader\\newpackage\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_MAIN" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_SUB" class="java.lang.Integer" isForPrompting="false">
        <defaultValueExpression><![CDATA[Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[SELECT npi.national_id_number, npi.national_pin_number, npi.contact_email, npi.biometric_member_number
FROM (SELECT snpi.nhif_persons_identity_serial, snpi.person_identity_number, snpi.biometric_member_number,
      snpi.national_id_number, snpi.national_pin_number, snpi.national_nhif_number, snpi.address_physical,
      snpi.contact_address, snpi.contact_telephone, snpi.contact_mobile, snpi.address_district, snpi.marital_status,
      snpi.gender, snpi.first_name, snpi.middle_name, snpi.last_name, snpi.date_registered, snpi.contact_email
    FROM nhif_persons_identities snpi
    WHERE snpi.nhif_persons_identity_serial = $P{MEMBER_CERTIFICATE_PARAM_SUB}) npi]]>
    </queryString>
    <field name="national_id_number" class="java.lang.String"/>
    <field name="national_pin_number" class="java.lang.String"/>
    <field name="contact_email" class="java.lang.String"/>
    <field name="biometric_member_number" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="74" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="72" uuid="2cee9cb2-abe3-4739-9b64-ec405bf9912b"/>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\NhifHeader\\src\\nhifheader\\PotraitNhifHeader\\PortraitNhifHeader.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </title>
    <pageHeader>
        <band height="56" splitType="Stretch">
            <textField>
                <reportElement x="529" y="13" width="26" height="15" uuid="1d23b617-b659-4f87-acfd-e07b54913ccd"/>
                <textFieldExpression><![CDATA[$F{national_pin_number}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="367" y="13" width="173" height="15" uuid="e02099fe-b171-4a24-bb15-195a046921c8"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Personal Identification Number:]]></text>
            </staticText>
            <componentElement>
                <reportElement x="0" y="1" width="240" height="30" uuid="311343bc-7e09-4658-8a1e-810fe91d1a3f"/>
                <jr:Code39 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" textPosition="bottom">
                    <jr:codeExpression><![CDATA[$F{biometric_member_number}]]></jr:codeExpression>
                </jr:Code39>
            </componentElement>
            <staticText>
                <reportElement x="367" y="0" width="31" height="15" uuid="fefca1d6-a90f-4dba-996c-1c00883eba1c"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Date]]></text>
            </staticText>
            <textField pattern="MMMMM dd, yyyy">
                <reportElement x="398" y="0" width="142" height="20" uuid="c3c68a84-f1d6-43c9-9c83-8b5eaacd6c38"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <line>
                <reportElement x="0" y="33" width="555" height="1" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="003310a9-85b0-447a-bc29-8f97f0006c1d"/>
            </line>
            <staticText>
                <reportElement x="2" y="35" width="553" height="20" uuid="5d8caf66-df88-403d-b96a-1ba2d0e84087"/>
                <textElement textAlignment="Center"/>
                <text><![CDATA[This is to certify that person shown herein is a member of NHIF: National Hospital Insurance Fund]]></text>
            </staticText>
            <frame>
                <reportElement mode="Opaque" x="179" y="1" width="172" height="21" forecolor="#C0C0C0" backcolor="#C0C0C0" uuid="63309c64-53a9-41e7-b490-fa5278230357"/>
                <staticText>
                    <reportElement mode="Transparent" x="33" y="0" width="113" height="20" forecolor="#000000" backcolor="#000000" uuid="ca2b9d0e-5260-4fb3-9f20-308a4349852e"/>
                    <textElement>
                        <font size="12" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Member Certificate]]></text>
                </staticText>
            </frame>
        </band>
    </pageHeader>
    <detail>
        <band height="67" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="66" uuid="27c682e0-71b6-4232-8a7a-9efaad62240f"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateAddress.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="68">
            <subreport>
                <reportElement x="0" y="0" width="555" height="67" uuid="169130d8-125e-45c4-b455-4cdced7665d1"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateInfo.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="56">
            <subreport>
                <reportElement x="0" y="0" width="555" height="55" uuid="f36d8a91-96b9-44fc-a393-bbc5752b5316"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateIsuranceObligation.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <pageFooter>
        <band height="54" splitType="Stretch">
            <frame>
                <reportElement mode="Opaque" x="0" y="18" width="555" height="20" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="7f256e6e-c72d-4b8b-ad82-acb84e711f34"/>
                <staticText>
                    <reportElement x="3" y="1" width="59" height="19" uuid="209e1c39-a38d-4b3a-a095-95662b9707e5"/>
                    <textElement>
                        <font size="10" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Disclaimer :]]></text>
                </staticText>
                <staticText>
                    <reportElement x="62" y="1" width="493" height="19" uuid="3465db13-94ed-4a12-bb82-96732d370a8a"/>
                    <textElement>
                        <font size="10" isBold="false"/>
                    </textElement>
                    <text><![CDATA[This is an auto generated Certificate and does not require signature]]></text>
                </staticText>
            </frame>
        </band>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>
</code>```

Egan Wolf Idea works perfect. I just declared the main report parameter before sub report parameter!

Body:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="478ce75d-1606-47d2-88eb-f8079f50c69b">
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["D:\\newpackage\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_SUB" class="java.lang.Integer" isForPrompting="false">
        <defaultValueExpression><![CDATA[Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_MAIN" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[SELECT * FROM table_name WHERE atr = $P{MEMBER_CERTIFICATE_PARAM_SUB}]]>
    </queryString>
    <field name="national_id_number" class="java.lang.String"/>
    <field name="national_pin_number" class="java.lang.String"/>
    <field name="contact_email" class="java.lang.String"/>
    <field name="biometric_member_number" class="java.lang.String"/>
    <title>
        <band height="74" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="72" uuid="2cee9cb2-abe3-4739-9b64-ec405bf9912b"/>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\NhifHeader\\src\\nhifheader\\PotraitNhifHeader\\PortraitNhifHeader.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </title>
    <pageHeader>
        <band height="56" splitType="Stretch">
            <textField>
                <reportElement x="529" y="13" width="26" height="15" uuid="1d23b617-b659-4f87-acfd-e07b54913ccd"/>
                <textFieldExpression><![CDATA[$F{national_pin_number}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="367" y="13" width="173" height="15" uuid="e02099fe-b171-4a24-bb15-195a046921c8"/>
                <textElement>

                </textElement>
                <text><![CDATA[Personal Identification Number:]]></text>
            </staticText>
            <componentElement>
                <reportElement x="0" y="1" width="240" height="30" uuid="311343bc-7e09-4658-8a1e-810fe91d1a3f"/>
                <jr:Code39 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" textPosition="bottom">
                    <jr:codeExpression><![CDATA[$F{biometric_member_number}]]></jr:codeExpression>
                </jr:Code39>
            </componentElement>
            <staticText>
                <reportElement x="367" y="0" width="31" height="15" uuid="fefca1d6-a90f-4dba-996c-1c00883eba1c"/>
                <textElement>

                </textElement>
                <text><![CDATA[Date]]></text>
            </staticText>
            <textField pattern="MMMMM dd, yyyy">
                <reportElement x="398" y="0" width="142" height="20" uuid="c3c68a84-f1d6-43c9-9c83-8b5eaacd6c38"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <line>
                <reportElement x="0" y="33" width="555" height="1" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="003310a9-85b0-447a-bc29-8f97f0006c1d"/>
            </line>
            <staticText>
                <reportElement x="2" y="35" width="553" height="20" uuid="5d8caf66-df88-403d-b96a-1ba2d0e84087"/>
                <textElement textAlignment="Center"/>
                <text><![CDATA[This is to certify that person shown herein is a member of NHIF: National Hospital Insurance Fund]]></text>
            </staticText>
            <frame>
                <reportElement mode="Opaque" x="179" y="1" width="172" height="21" forecolor="#C0C0C0" backcolor="#C0C0C0" uuid="63309c64-53a9-41e7-b490-fa5278230357"/>
                <staticText>
                    <reportElement mode="Transparent" x="33" y="0" width="113" height="20" forecolor="#000000" backcolor="#000000" uuid="ca2b9d0e-5260-4fb3-9f20-308a4349852e"/>
                    <textElement>

                    </textElement>
                    <text><![CDATA[Member Certificate]]></text>
                </staticText>
            </frame>
        </band>
    </pageHeader>
    <detail>
        <band height="67" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="66" uuid="27c682e0-71b6-4232-8a7a-9efaad62240f"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateAddress.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="68">
            <subreport>
                <reportElement x="0" y="0" width="555" height="67" uuid="169130d8-125e-45c4-b455-4cdced7665d1"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateInfo.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="56">
            <subreport>
                <reportElement x="0" y="0" width="555" height="55" uuid="f36d8a91-96b9-44fc-a393-bbc5752b5316"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\MemberCertificate\\MemberCertificateIsuranceObligation.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>

I  have a JasperReports's report with several subreports. I'm using iReport plugin with my NetBeans. I have passed the same integer parameter type to all sub reports and also to main report . Main report has two parameter , one that has prompt option enabled and is of type string. and the other that takes parameter as a string and coverts it to integer Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN}) ( this is found in all sub reports  ). This is how i always pass parameters. But when i run this report i get the following errors.

Error filling print... Error evaluating expression :
      Source text : Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})  net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
      Source text : Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})      at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:244)
      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
      at net.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:994)
      at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:635)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1280)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:900)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)
      at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:87)
      at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
      at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276)
      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)
      at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891)
      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
      at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
      at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)      at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
  Caused by: java.lang.NumberFormatException: null
      at java.lang.Integer.parseInt(Integer.java:542)      at java.lang.Integer.parseInt(Integer.java:615)

Body:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="478ce75d-1606-47d2-88eb-f8079f50c69b">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\BranchHeader\\src\\PortraitBranchHeader\\newpackage\\"]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_MAIN" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="MEMBER_CERTIFICATE_PARAM_SUB" class="java.lang.Integer" isForPrompting="false">
        <defaultValueExpression><![CDATA[Integer.parseInt($P{MEMBER_CERTIFICATE_PARAM_MAIN})]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[SELECT npi.national_id_number, npi.national_pin_number, npi.contact_email, npi.biometric_member_number
FROM (SELECT snpi.nhif_persons_identity_serial, snpi.person_identity_number, snpi.biometric_member_number,
      snpi.national_id_number, snpi.national_pin_number, snpi.national_nhif_number, snpi.address_physical,
      snpi.contact_address, snpi.contact_telephone, snpi.contact_mobile, snpi.address_district, snpi.marital_status,
      snpi.gender, snpi.first_name, snpi.middle_name, snpi.last_name, snpi.date_registered, snpi.contact_email
    FROM nhif_persons_identities snpi
    WHERE snpi.nhif_persons_identity_serial = $P{MEMBER_CERTIFICATE_PARAM_SUB}) npi]]>
    </queryString>
    <field name="national_id_number" class="java.lang.String"/>
    <field name="national_pin_number" class="java.lang.String"/>
    <field name="contact_email" class="java.lang.String"/>
    <field name="biometric_member_number" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="74" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="72" uuid="2cee9cb2-abe3-4739-9b64-ec405bf9912b"/>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\NhifHeader\\src\\nhifheader\\PotraitNhifHeader\\PortraitNhifHeader.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </title>
    <pageHeader>
        <band height="56" splitType="Stretch">
            <textField>
                <reportElement x="529" y="13" width="26" height="15" uuid="1d23b617-b659-4f87-acfd-e07b54913ccd"/>
                <textFieldExpression><![CDATA[$F{national_pin_number}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="367" y="13" width="173" height="15" uuid="e02099fe-b171-4a24-bb15-195a046921c8"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Personal Identification Number:]]></text>
            </staticText>
            <componentElement>
                <reportElement x="0" y="1" width="240" height="30" uuid="311343bc-7e09-4658-8a1e-810fe91d1a3f"/>
                <jr:Code39 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" textPosition="bottom">
                    <jr:codeExpression><![CDATA[$F{biometric_member_number}]]></jr:codeExpression>
                </jr:Code39>
            </componentElement>
            <staticText>
                <reportElement x="367" y="0" width="31" height="15" uuid="fefca1d6-a90f-4dba-996c-1c00883eba1c"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Date]]></text>
            </staticText>
            <textField pattern="MMMMM dd, yyyy">
                <reportElement x="398" y="0" width="142" height="20" uuid="c3c68a84-f1d6-43c9-9c83-8b5eaacd6c38"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <line>
                <reportElement x="0" y="33" width="555" height="1" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="003310a9-85b0-447a-bc29-8f97f0006c1d"/>
            </line>
            <staticText>
                <reportElement x="2" y="35" width="553" height="20" uuid="5d8caf66-df88-403d-b96a-1ba2d0e84087"/>
                <textElement textAlignment="Center"/>
                <text><![CDATA[This is to certify that person shown herein is a member of NHIF: National Hospital Insurance Fund]]></text>
            </staticText>
            <frame>
                <reportElement mode="Opaque" x="179" y="1" width="172" height="21" forecolor="#C0C0C0" backcolor="#C0C0C0" uuid="63309c64-53a9-41e7-b490-fa5278230357"/>
                <staticText>
                    <reportElement mode="Transparent" x="33" y="0" width="113" height="20" forecolor="#000000" backcolor="#000000" uuid="ca2b9d0e-5260-4fb3-9f20-308a4349852e"/>
                    <textElement>
                        <font size="12" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Member Certificate]]></text>
                </staticText>
            </frame>
        </band>
    </pageHeader>
    <detail>
        <band height="67" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="0" width="555" height="66" uuid="27c682e0-71b6-4232-8a7a-9efaad62240f"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateAddress.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="68">
            <subreport>
                <reportElement x="0" y="0" width="555" height="67" uuid="169130d8-125e-45c4-b455-4cdced7665d1"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateInfo.jasper"]]></subreportExpression>
            </subreport>
        </band>
        <band height="56">
            <subreport>
                <reportElement x="0" y="0" width="555" height="55" uuid="f36d8a91-96b9-44fc-a393-bbc5752b5316"/>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_MAIN">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_MAIN}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="MEMBER_CERTIFICATE_PARAM_SUB">
                    <subreportParameterExpression><![CDATA[$P{MEMBER_CERTIFICATE_PARAM_SUB}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="SUBREPORT_DIR">
                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["D:\\DOCUMENTS\\NetBeansProjects\\MemberCertificate11212017\\src\\MemberCertificate\\MemberCertificateIsuranceObligation.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <pageFooter>
        <band height="54" splitType="Stretch">
            <frame>
                <reportElement mode="Opaque" x="0" y="18" width="555" height="20" forecolor="#E6DAC3" backcolor="#E6DAC3" uuid="7f256e6e-c72d-4b8b-ad82-acb84e711f34"/>
                <staticText>
                    <reportElement x="3" y="1" width="59" height="19" uuid="209e1c39-a38d-4b3a-a095-95662b9707e5"/>
                    <textElement>
                        <font size="10" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Disclaimer :]]></text>
                </staticText>
                <staticText>
                    <reportElement x="62" y="1" width="493" height="19" uuid="3465db13-94ed-4a12-bb82-96732d370a8a"/>
                    <textElement>
                        <font size="10" isBold="false"/>
                    </textElement>
                    <text><![CDATA[This is an auto generated Certificate and does not require signature]]></text>
                </staticText>
            </frame>
        </band>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

Egan Wolf Idea works perfect. I just declared the main report parameter before sub report parameter!


来源: stackexchange

问:
How to parse zendesk ticket and act base on some scripting result
I looked into zendesk support which includes target action. That only allow me to notify an external server about the events happened in zendesk. This is only half of what I want, I also want to run a script over the content of zendesk ticket then generate a result that should be applied back to zendesk, e.g. a serial of keystrokes.

My current thought is to write a chrome extension that can parse the current page and try to extract the ticket context, then based on the ticket context, I can simulate some keystrokes.

Is there any other way to achieve this?

答: Run the script on the external Server and then post back to Zendesk Ticket via API?</p>

ContentLicense: CC BY-SA 3.0


问:
Executing a batch script on Windows shutdown
Is there any way, in Windows 7 Professional, to run a batch script (e.g., a .BAT file) when the user clicks on "shutdown" (not a batch file scheduled to shut down the machine, just one that runs only if the user clicks on "shutdown")?

Ideally, such a script would show the command prompt window and offer an option to cancel the shutdown procedure.

Solutions that do not require a third-party utility would be preferable.

答:
Well, its an easy way of doing some registry changes:
I tried this on 2008 r2 and 2016 servers.

Things need to be done:

Create a text file "regedit.txt"

Paste the following code in it:

```<code>Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0]
"Script"="terminate_script.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0\0]
"Script"="terminate_script.bat"
"Parameters"=""
"IsPowershell"=dword:00000000
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
</code>```

Save this file as regedit.reg extension

Run it on any command line using below command:

```<code>regedit.exe /s regedit.reg
</code>```

Body:
Well, its an easy way of doing some registry changes:
I tried this on 2008 r2 and 2016 servers.

Things need to be done:

Create a text file "regedit.txt"

Paste the following code in it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0]
"Script"="terminate_script.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0\0]
"Script"="terminate_script.bat"
"Parameters"=""
"IsPowershell"=dword:00000000
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

Save this file as regedit.reg extension

Run it on any command line using below command:

regedit.exe /s regedit.reg

ContentLicense: CC BY-SA 4.0


问:
Set layout from responder?
I am trying to figure out how to set the layout from a custom made responder. I want to use the request.xhr? to set the layout for render to 'ajax'.  Does anybody know how to do that?
I am using Rails 3 and I have a responder like this:

```<code>module AjaxLayoutResponder
  def to_html
    if request.xhr?
      # do something here to change layout...
    end
    super
  end
end
</code>```

It seem to me like a responder is the best way to accomplish this 'ajax' layout switching.

答:
you could simply do this:

```<code>module AjaxLayoutResponder
  def to_html
    if request.xhr?
      options[:layout] = 'ajax'
    end
    super
  end
end
</code>```

because what is called at the end of responder execution is:

```<code># from https://github.com/plataformatec/responders/blob/master/lib/action_controller/responder.rb
def default_render
  if @default_response
    @default_response.call(options)
  else
    controller.render(options)
  end
end
</code>```

ContentLicense: CC BY-SA 2.5

Title: Set layout from responder?

Body:
I am trying to figure out how to set the layout from a custom made responder. I want to use the request.xhr? to set the layout for render to 'ajax'.  Does anybody know how to do that?
I am using Rails 3 and I have a responder like this:

module AjaxLayoutResponder
  def to_html
    if request.xhr?
      # do something here to change layout...
    end
    super
  end
end

It seem to me like a responder is the best way to accomplish this 'ajax' layout switching.

Body:
you could simply do this:

module AjaxLayoutResponder
  def to_html
    if request.xhr?
      options[:layout] = 'ajax'
    end
    super
  end
end

because what is called at the end of responder execution is:

# from https://github.com/plataformatec/responders/blob/master/lib/action_controller/responder.rb
def default_render
  if @default_response
    @default_response.call(options)
  else
    controller.render(options)
  end
end


问:
Use Storyboard References While Retaining Icons & Text for Tab Bar Controller
I started refactoring one of my projects to make the code easier to manage and the Tab Bar Controller lost its icons for which tab represents what. Without this I'm a bit lost which tab is what for re-ordering purposes.

How do I get the icons to show up again for a tab bar controller when I'm using storyboard references?

Refer to my attached image.  Notice how the first 3 tabs are 'blank' but the other tabs that I have not refactored yet show with the icons and titles.

For those unfamiliar with storyboard references I was following the tutorial here: http://code.tutsplus.com/tutorials/ios-9-staying-organized-with-storyboard-references--cms-24226

Sample of Tasks Storyboard to show Icon set Correctly

答:
For some weird reason, I wasn't able to see the tab bar in my reference view controller in IB. Although while selecting it and expanding the Document Outline, I was able to see it in my view list. I could make my changes through it.

Hope this helps! :)


问:
Can't get stderr with Paramiko
For some reasons, I have to use mysql over Paramiko.

I have this (simplified) snippet:

```<code>stdin, stdout, stderr = c.exec_command("mysql stuff -e 'rename table foo to bar'")
print stdout.read()
print stderr.read()
</code>```

But if table foo doesn't exist, I have no output (there is no stdout or stdin output).

But it is strange, because:

```<code>stdin, stdout, stderr = c.exec_command("mysql stuff -e 'rename table foo to bar'")
if stderr.read()
    print "Error: %s" % stderr.read()
    print type(stderr.read())
</code>```

Has this output:

```<code>Error:
<type 'str'>
</code>```

Whereas the mysql error would normally be:

ERROR 1017 (HY000) at line 1: Can't find file: './stuff/foo.frm' (errno: 2 - No such file or directory)

I'd like to have this more verbose error output, but I can't have it. Why?

答:
You cannot read stdin. It's input, not output.

That's why you get "File is not open for reading". It has nothing to do with your mysql command.

Title: Can't get stderr with Paramiko

Body:
For some reasons, I have to use mysql over Paramiko.

I have this (simplified) snippet:

stdin, stdout, stderr = c.exec_command("mysql stuff -e 'rename table foo to bar'")
print stdout.read()
print stderr.read()

But if table foo doesn't exist, I have no output (there is no stdout or stdin output).

But it is strange, because:

stdin, stdout, stderr = c.exec_command("mysql stuff -e 'rename table foo to bar'")
if stderr.read()
    print "Error: %s" % stderr.read()
    print type(stderr.read())

Has this output:

Error:
<type 'str'>

Whereas the mysql error would normally be:

ERROR 1017 (HY000) at line 1: Can't find file: './stuff/foo.frm' (errno: 2 - No such file or directory)

I'd like to have this more verbose error output, but I can't have it. Why?


问:
Windows Phone 7 download pure HTML as string?
I have been trying to get a clear answer on how to download a page's HTML as a string for months, but have made zero progress. I can mess with all of the parsing myself, and I'll be able to figure out where it needs to fit into the application as I mess around with it. I would be very very grateful if someone could give me a clear code block to download a page's HTML as a string from a given url.</p>

答:
System.Net.HttpWebRequest.Create(url);

docs are here


问:
How to extract/view all frames of a multi-frame DICOM file?
I know I can view a dicom file using following code:

```<code>import dicom
from dicom.contrib.pydicom_PIL import show_PIL

f = "CT-MONO2-8-abdo.dcm"
ds = dicom.read_file(f, force=True)
show_PIL(ds)
</code>```

However, how can I extract and view all frames from a multi-frame DICOM file? I tried using above code but got following error:

```<code>File "/home/auser/.local/lib/python3.5/site-packages/dicom/dataset.py", line 399, in _get_pixel_array
  raise NotImplementedError("Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array
</code>```

I had tried with some multi-frame files located at http://www.barre.nom.fr/medical/samples/. The pixel size etc are available for these files.

How can I extract and/or view different frames of a multi-frame DICOM file?

Edit: Following command using gdcm works on Linux to convert these to uncompressed file:

```<code>$ gdcmconv --raw compressed.dcm uncompressed.dcm
</code>```

(I used http://www.barre.nom.fr/medical/samples/files/US-PAL-8-10x-echo.gz file after extraction).

This is then read by python code above but that shows only first frame. How can I extract and view other frames?

答:
pydicom supports reading pixel data. Refer this documentation.

pydicom tends to be “lazy” in interpreting DICOM data. For example, by
  default it doesn’t do anything with pixel data except read in the raw
  bytes:

```<code>import dicom
ds=dicom.read_file("MR_small.dcm")
ds.PixelData
'\x89\x03\xfb\x03\xcb\x04\xeb\x04\xf9\x02\x94\x01\x7f ...
...
</code>```

About pixel_array

A property of Dataset called pixel_array provides more useful pixel
  data for uncompressed images. The NumPy numerical package must be
  installed on your system to use this property, because pixel_array
  returns a NumPy array:

```<code>import dicom
ds=dicom.read_file("MR_small.dcm")
ds.pixel_array
array([[ 905, 1019, 1227, ...,  302,  304,  328],
       [ 628,  770,  907, ...,  298,  331,  355],
       [ 498,  566,  706, ...,  280,  285,  320],
       ...,
       [ 334,  400,  431, ..., 1094, 1068, 1083],
       [ 339,  377,  413, ..., 1318, 1346, 1336],
       [ 378,  374,  422, ..., 1369, 1129,  862]], dtype=int16)
ds.pixel_array.shape
(64, 64)
</code>```

Document also explains about viewing images at http://pydicom.readthedocs.io/en/stable/viewing_images.html.

As explained in error message (and by @kritzel_sw in comment) the pydicom does not support the Transfer Syntax of source image yet. Change the Transfer Syntax using some other tool before attempting to extract the frames.

Another helpful blog of Rony http://dicomiseasy.blogspot.in/2012/08/chapter-12-pixel-data.html

Also check this Stack Overflow question; it is about old version but may be helpful.

Body:
I know I can view a dicom file using following code:

import dicom
from dicom.contrib.pydicom_PIL import show_PIL

f = "CT-MONO2-8-abdo.dcm"
ds = dicom.read_file(f, force=True)
show_PIL(ds)

However, how can I extract and view all frames from a multi-frame DICOM file? I tried using above code but got following error:

File "/home/auser/.local/lib/python3.5/site-packages/dicom/dataset.py", line 399, in _get_pixel_array
  raise NotImplementedError("Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array

I had tried with some multi-frame files located at http://www.barre.nom.fr/medical/samples/. The pixel size etc are available for these files.

How can I extract and/or view different frames of a multi-frame DICOM file?

Edit: Following command using gdcm works on Linux to convert these to uncompressed file:

$ gdcmconv --raw compressed.dcm uncompressed.dcm

(I used http://www.barre.nom.fr/medical/samples/files/US-PAL-8-10x-echo.gz file after extraction).

This is then read by python code above but that shows only first frame. How can I extract and view other frames?

Body:
pydicom supports reading pixel data. Refer this documentation.

pydicom tends to be “lazy” in interpreting DICOM data. For example, by
  default it doesn’t do anything with pixel data except read in the raw
  bytes:

import dicom
ds=dicom.read_file("MR_small.dcm")
ds.PixelData
'\x89\x03\xfb\x03\xcb\x04\xeb\x04\xf9\x02\x94\x01\x7f ...
...

About pixel_array

A property of Dataset called pixel_array provides more useful pixel
  data for uncompressed images. The NumPy numerical package must be
  installed on your system to use this property, because pixel_array
  returns a NumPy array:

import dicom
ds=dicom.read_file("MR_small.dcm")
ds.pixel_array
array([[ 905, 1019, 1227, ...,  302,  304,  328],
       [ 628,  770,  907, ...,  298,  331,  355],
       [ 498,  566,  706, ...,  280,  285,  320],
       ...,
       [ 334,  400,  431, ..., 1094, 1068, 1083],
       [ 339,  377,  413, ..., 1318, 1346, 1336],
       [ 378,  374,  422, ..., 1369, 1129,  862]], dtype=int16)
ds.pixel_array.shape
(64, 64)

Document also explains about viewing images at http://pydicom.readthedocs.io/en/stable/viewing_images.html.

As explained in error message (and by @kritzel_sw in comment) the pydicom does not support the Transfer Syntax of source image yet. Change the Transfer Syntax using some other tool before attempting to extract the frames.

Another helpful blog of Rony http://dicomiseasy.blogspot.in/2012/08/chapter-12-pixel-data.html

Also check this Stack Overflow question; it is about old version but may be helpful.


问:
How to set the CommandParameter to the ListView item itself in Xamarin.Forms
I'm using a custom ViewCell defined in C# to populate a ListView in Xamarin.Forms. The ViewCell contains an Image, that acts as a button and when clicked, should be able to manipulate the underlying data of the ListView.

Basically I am looking for the code behind equivalent for:

```<code><Image.GestureRecognizers>
    <TapGestureRecognizer
        Command="{Binding Path=BindingContext.PlusClickedCommand, Source={x:Reference Name=ChallengesLV}}"
        CommandParameter="{Binding}"/>
</Image.GestureRecognizers>
</code>```

I have tried:

```<code>plusButton.GestureRecognizers.Add(new TapGestureRecognizer() {
Command = bindingContext.AddProgressToChallengeCommand,
CommandParameter = new Binding(".")} });
</code>```

But it gives me an NullReference exception when I try to access the object of type Challenge in my viewmodel like so:

```<code>AddProgressToChallengeCommand = new Command( (sender) => doSomething((Challenge)sender) );
</code>```

When I inspect the sender object in debug mode, it tells me it is an object of type Binding with every property null except path="."

How do I get the Item this Binding refers to?

答:
Thanks to Jason:
The Command needs to be initialized like that, to access the parameter:

```<code>AddProgressToChallengeCommand = new Command<Challenge>( (challenge) =>
doSomething(challenge);
</code>```

And for the recognizer binding, I needed to change it to:

```<code>var recognizer = new TapGestureRecognizer() {Command = bindingContext.AddProgressToChallengeCommand};
recognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, ".");
plusButton.GestureRegognizers.Add(recognizer);
</code>```

Body:
I'm using a custom ViewCell defined in C# to populate a ListView in Xamarin.Forms. The ViewCell contains an Image, that acts as a button and when clicked, should be able to manipulate the underlying data of the ListView.

Basically I am looking for the code behind equivalent for:

<Image.GestureRecognizers>
    <TapGestureRecognizer
        Command="{Binding Path=BindingContext.PlusClickedCommand, Source={x:Reference Name=ChallengesLV}}"
        CommandParameter="{Binding}"/>
</Image.GestureRecognizers>

I have tried:

plusButton.GestureRecognizers.Add(new TapGestureRecognizer() {
Command = bindingContext.AddProgressToChallengeCommand,
CommandParameter = new Binding(".")} });

But it gives me an NullReference exception when I try to access the object of type Challenge in my viewmodel like so:

AddProgressToChallengeCommand = new Command( (sender) => doSomething((Challenge)sender) );

When I inspect the sender object in debug mode, it tells me it is an object of type Binding with every property null except path="."

How do I get the Item this Binding refers to?

Body:
Thanks to Jason:
The Command needs to be initialized like that, to access the parameter:

AddProgressToChallengeCommand = new Command<Challenge>( (challenge) =>
doSomething(challenge);

And for the recognizer binding, I needed to change it to:

var recognizer = new TapGestureRecognizer() {Command = bindingContext.AddProgressToChallengeCommand};
recognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, ".");
plusButton.GestureRegognizers.Add(recognizer);


问:
JAX WS Server implementation performance issue for Linux JVM?
I've faced with a very weird problem. The built-in JAX WS server implementation works 100 times slower on linux machines then on Mac OS X or Windows.

I've created and shared a JMH test: https://github.com/Andremoniy/linuxjvmjaxwstest

Basically it does the following:

starts a JAX WS with one SOAP method:

endpoint = Endpoint.publish("http://localhost:8888/", new FooServiceImpl());

performs client requests to this method:

String result = state.client.foo(state.foo);

On Mac OS X with 2 Cores Intel Core i7 it gives me:

```<code># JMH version: 1.19
# VM version: JDK 1.8.0_151, VM 25.151-b12
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/bin/java
...
Result "test.openjdk.MyBenchmark.testMethod":
  3077.813 ±(99.9%) 51.818 ops/s [Average]
  (min, avg, max) = (1718.347, 3077.813, 3315.271), stdev = 219.400
  CI (99.9%): [3025.995, 3129.630] (assumes normal distribution)

# Run complete. Total time: 00:06:49

Benchmark                Mode  Cnt     Score    Error  Units
MyBenchmark.testMethod  thrpt  200  3077.813 ± 51.818  ops/s
</code>```

The same machine, docker without CPU limitations:

```<code># JMH version: 1.19
# VM version: JDK 1.8.0_151, VM 25.151-b12
# VM invoker: /usr/java/jdk1.8.0_151/jre/bin/java
...
Result "test.openjdk.MyBenchmark.testMethod":
  19.882 ?(99.9%) 0.169 ops/s [Average]
  (min, avg, max) = (10.031, 19.882, 20.104), stdev = 0.715
  CI (99.9%): [19.714, 20.051] (assumes normal distribution)

# Run complete. Total time: 00:07:01

Benchmark                Mode  Cnt   Score   Error  Units
MyBenchmark.testMethod  thrpt  200  19.882 ? 0.169  ops/s
</code>```

I've tried docker openjdk:8u151 as well as OracleJava. I've also tried to run it on VirtualBox Ubuntu 16.04, on AWS EC2 Ubuntu instance - on linux machines it is always around ~20 ops/s.

But when I change server implementation to Jetty:

```<code>    ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
    server.setHandler(contextHandlerCollection);

    JettyHttpServerProvider.setServer(server);
    HttpContext context = new JettyHttpServerProvider().createHttpServer(new InetSocketAddress(8888), 5).createContext("/");

    Endpoint endpoint = Endpoint.create(new MyBenchmark.FooServiceImpl());
    endpoint.publish(context);

    server.start();
</code>```

the difference between performance on linux and other OS's disappears. That means that there is some bug in builtin HTTP Server implementation for JRE/OpenJDK for Linux. Or am I missing something?

答:
This was admitted as a bug by the Java Developer Support team:

https://bugs.openjdk.java.net/browse/JDK-8193236

Body:
I've faced with a very weird problem. The built-in JAX WS server implementation works 100 times slower on linux machines then on Mac OS X or Windows.

I've created and shared a JMH test: https://github.com/Andremoniy/linuxjvmjaxwstest

Basically it does the following:

starts a JAX WS with one SOAP method:

endpoint = Endpoint.publish("http://localhost:8888/", new FooServiceImpl());

performs client requests to this method:

String result = state.client.foo(state.foo);

On Mac OS X with 2 Cores Intel Core i7 it gives me:

# JMH version: 1.19
# VM version: JDK 1.8.0_151, VM 25.151-b12
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/bin/java
...
Result "test.openjdk.MyBenchmark.testMethod":
  3077.813 ±(99.9%) 51.818 ops/s [Average]
  (min, avg, max) = (1718.347, 3077.813, 3315.271), stdev = 219.400
  CI (99.9%): [3025.995, 3129.630] (assumes normal distribution)

# Run complete. Total time: 00:06:49

Benchmark                Mode  Cnt     Score    Error  Units
MyBenchmark.testMethod  thrpt  200  3077.813 ± 51.818  ops/s

The same machine, docker without CPU limitations:

# JMH version: 1.19
# VM version: JDK 1.8.0_151, VM 25.151-b12
# VM invoker: /usr/java/jdk1.8.0_151/jre/bin/java
...
Result "test.openjdk.MyBenchmark.testMethod":
  19.882 ?(99.9%) 0.169 ops/s [Average]
  (min, avg, max) = (10.031, 19.882, 20.104), stdev = 0.715
  CI (99.9%): [19.714, 20.051] (assumes normal distribution)

# Run complete. Total time: 00:07:01

Benchmark                Mode  Cnt   Score   Error  Units
MyBenchmark.testMethod  thrpt  200  19.882 ? 0.169  ops/s

I've tried docker openjdk:8u151 as well as OracleJava. I've also tried to run it on VirtualBox Ubuntu 16.04, on AWS EC2 Ubuntu instance - on linux machines it is always around ~20 ops/s.

But when I change server implementation to Jetty:

    ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
    server.setHandler(contextHandlerCollection);

    JettyHttpServerProvider.setServer(server);
    HttpContext context = new JettyHttpServerProvider().createHttpServer(new InetSocketAddress(8888), 5).createContext("/");

    Endpoint endpoint = Endpoint.create(new MyBenchmark.FooServiceImpl());
    endpoint.publish(context);

    server.start();

the difference between performance on linux and other OS's disappears. That means that there is some bug in builtin HTTP Server implementation for JRE/OpenJDK for Linux. Or am I missing something?


问:
Return multiple elements inside React.render()
I am new in react and I encountered with this problem:

```<code>render: function(){
    return (
        <h3>Account</h3>
        <a href="#" onClick={some_event}>Login</a>
        <a href="#" onClick={some_event}>Logout</a>
)}
</code>```

When I am rendering like this it gives me error saying like multiple components must wrapt with end

Should I make one componenet for each html tag or each line or I can render in that way..

Any suggestion ?

答:
You can use the following syntax for fragments in React 16.2+:</p>

```<code>render() {
  return (
    <>
      <ChildA />
      <ChildB />
      <ChildC />
    </>
  );
}
</code>```

Body:
I am new in react and I encountered with this problem:

render: function(){
    return (

Account

        Login
        Logout
)}

When I am rendering like this it gives me error saying like multiple components must wrapt with end

Should I make one componenet for each html tag or each line or I can render in that way..

Any suggestion ?

Body:
You can use the following syntax for fragments in React 16.2+:

render() {
  return (
    <>
      <ChildA />
      <ChildB />
      <ChildC />
    </>
  );
}


问:
What are the advantages of developing applications in C++ as compared to managed languages?
Hi I want to know why people develop library applications and employee management applications in C++ (this application, for example), when clearly the same thing can be done in C# and VB.NET in a much prettier way. Even banking applications are mostly in C++. Is there a good reason why, apart from the fact that compiled C++ code executes faster?

Can anyone shed some light on this?

答:
C: 1972

C++: 1979

C#: 2000

Now think of the lifetime of a library, especially in a bank, plus, you get to use the libraries (theoretically) on almost every computersystem in existence (as opposed to C#)

You will also still find a lot of COBOL (1960) there.


问:
Cannot change style in Word using VBA
I have a paragraph like this:

Nov 19, 2014 - You are running the search on the Selection, but you're
  not changing that selection between runs. So you just end up making
  the same text bold over and over again. Here's a way to do what you're
  doing without the Selection object: Sub ParaStyle() Dim objPara As
  Paragraph For Each objPara In ... Word VBA Paragraph
  formatting-VBForums

And I am trying to change the style of the entire paragraph to a local style. I am using the following code:

```<code>Dim rgePages As Range
Dim p As Paragraph

Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=3
Set rgePages = Selection.Range
Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=6
rgePages.End = Selection.Bookmarks("\Page").Range.End
rgePages.Select

For Each p In rgePages.Paragraphs
If p.Style <> "Heading 1" Then

p.Style = "Body Text"
'p.Style = Word.WdBuiltinStyle.wdStyleBodyText
rgePages.Collapse Word.WdCollapseDirection.wdCollapseEnd

End If
Next
</code>```

It is working fine till the time any line or a few words are in different style. Say for example if the line

So you just end up making

in the paragraph is in different style, it is marking the whole paragraph as "Body Text" except for that part. Is there a solution to this?

答:
You could try to clear formatting first before you apply your own style. It could go this way:</p>

```<code>....
If p.Style <> "Heading 1" Then

    p.Range.Select
    Selection.ClearFormatting 'it rather works with selection only

p.Style = "Body Text"
....
</code>```

Title: Cannot change style in Word using VBA

Body:
I have a paragraph like this:

Nov 19, 2014 - You are running the search on the Selection, but you're
  not changing that selection between runs. So you just end up making
  the same text bold over and over again. Here's a way to do what you're
  doing without the Selection object: Sub ParaStyle() Dim objPara As
  Paragraph For Each objPara In ... Word VBA Paragraph
  formatting-VBForums

And I am trying to change the style of the entire paragraph to a local style. I am using the following code:

Dim rgePages As Range
Dim p As Paragraph

Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=3
Set rgePages = Selection.Range
Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=6
rgePages.End = Selection.Bookmarks("\Page").Range.End
rgePages.Select

For Each p In rgePages.Paragraphs
If p.Style <> "Heading 1" Then

p.Style = "Body Text"
'p.Style = Word.WdBuiltinStyle.wdStyleBodyText
rgePages.Collapse Word.WdCollapseDirection.wdCollapseEnd

End If
Next

It is working fine till the time any line or a few words are in different style. Say for example if the line

So you just end up making

in the paragraph is in different style, it is marking the whole paragraph as "Body Text" except for that part. Is there a solution to this?

Body:
You could try to clear formatting first before you apply your own style. It could go this way:

....
If p.Style <> "Heading 1" Then

    p.Range.Select
    Selection.ClearFormatting 'it rather works with selection only

p.Style = "Body Text"
....


问:
How the example from Java Concurrency in practice is thread safe
Below is an example from book Java Concurrency in Practice(Listing 2.8) of a thread safe class.

My question is how the below class is thread safe?

For example if two threads Thread A and Thread B enter into service method of CachedFactorizer. Thread B followed by Thread A. Now if Thread A is executing first synchronized block and Thread B obviously waits for the intrinsic lock of the object. And if Thread B makes it to the first synchronized block before the Thread A makes it to the second synchronized block, it will be viewing a stale value and potentially this condition is known as Race Condition.

So, is my understanding right here? Or am I lacking some basic understanding of concurrency?

```<code>@ThreadSafe
public class CachedFactorizer implements Servlet {

    @GuardedBy("this") private BigInteger lastNumber;

    @GuardedBy("this") private BigInteger[] lastFactors;

    @GuardedBy("this") private long hits;

    @GuardedBy("this") private long cacheHits;

    public synchronized long getHits() { return hits; }

    public synchronized double getCacheHitRatio() {

        return (double) cacheHits / (double) hits;

    }

    public void service(ServletRequest req, ServletResponse resp) {

        BigInteger i = extractFromRequest(req);
        BigInteger[] factors = null;
        synchronized (this) {
            ++hits;
            if (i.equals(lastNumber)) {
                ++cacheHits;
                factors = lastFactors.clone();
            }
        }
        if (factors == null) {
            factors = factor(i);
            synchronized (this) {
                lastNumber = i;
                lastFactors = factors.clone();
            }
        }
        encodeIntoResponse(resp, factors);
    }
}
</code>```

答: The only thing used from within the first block after its exited is factors, which was cloned(), so is unaffected by any other threads getting into the first or second blocks. </p>

Body:
Below is an example from book Java Concurrency in Practice(Listing 2.8) of a thread safe class.

My question is how the below class is thread safe?

For example if two threads Thread A and Thread B enter into service method of CachedFactorizer. Thread B followed by Thread A. Now if Thread A is executing first synchronized block and Thread B obviously waits for the intrinsic lock of the object. And if Thread B makes it to the first synchronized block before the Thread A makes it to the second synchronized block, it will be viewing a stale value and potentially this condition is known as Race Condition.

So, is my understanding right here? Or am I lacking some basic understanding of concurrency?

@ThreadSafe
public class CachedFactorizer implements Servlet {

    @GuardedBy("this") private BigInteger lastNumber;

    @GuardedBy("this") private BigInteger[] lastFactors;

    @GuardedBy("this") private long hits;

    @GuardedBy("this") private long cacheHits;

    public synchronized long getHits() { return hits; }

    public synchronized double getCacheHitRatio() {

        return (double) cacheHits / (double) hits;

    }

    public void service(ServletRequest req, ServletResponse resp) {

        BigInteger i = extractFromRequest(req);
        BigInteger[] factors = null;
        synchronized (this) {
            ++hits;
            if (i.equals(lastNumber)) {
                ++cacheHits;
                factors = lastFactors.clone();
            }
        }
        if (factors == null) {
            factors = factor(i);
            synchronized (this) {
                lastNumber = i;
                lastFactors = factors.clone();
            }
        }
        encodeIntoResponse(resp, factors);
    }
}


问:
Finding the min and max values in a list of objects, but where the min object must be older than max
Apologies... I'm not exactly great at coding, but here goes.

Basically I've got a list of a class, that I want to get the min and max for. The part that is tripping me up is that i need the min and max to be in chronological order. Hopefully the drawing helps show what i mean.

Graph of object with date and value

As you can see above, the first value is actually the max, but the minimum is not for another 2 increments.

So i was trying to construct a where statement, but I couldn't figure out how to mix class variable types to query properly... Also how to note that the date of the min must be older than the max, without yet knowing the max (or vice versa).

Obviously the code below doesn't work at all, and the logic on getting the min/max values is flawed, but hopefully it helps make sense of what I'm trying to do...

```<code>public static MinMax MinandMax(List<ValueHistoric> InputList, int take)
{
    InputList.Reverse();
    var CutList = InputList.Take(take);
    var CutListMax = CutList.Where(a => a.Value == CutList.Max(b => b.Value) && a.Date > CutList.Min.Date);
    var CutListMin = CutList.Where(a => a.Value == CutList.Min(b => b.Value) && a.Date < CutList.Max.Date>);

    //Put Min and Max into variables here

    MinMax results = new MinMax();
    results.Max = last12max;
    results.Min = last12min;
    return results;
}

public class ValueHistoric
{
    public ObjectId Id { get; set; }
    public DateTime Date { get; set; }
    public double Value { get; set; }
    public string Name { get; set; }
}
</code>```

答:
I would first determine the min date OrderBy to get the lowest value first

```<code>var min = CutList.OrderBy(x => x.Value).First();
</code>```

afterwards I would determine the max date - which has to be > min.Date
, OrderByDesc to get the highest value first

```<code>var max = CutList.OrderByDesc(x => x.Value).First(a => a.Date > min.Date);
</code>```

Update.. You have to order by the Value, not the Date

Body:
Apologies... I'm not exactly great at coding, but here goes.

Basically I've got a list of a class, that I want to get the min and max for. The part that is tripping me up is that i need the min and max to be in chronological order. Hopefully the drawing helps show what i mean.

Graph of object with date and value

As you can see above, the first value is actually the max, but the minimum is not for another 2 increments.

So i was trying to construct a where statement, but I couldn't figure out how to mix class variable types to query properly... Also how to note that the date of the min must be older than the max, without yet knowing the max (or vice versa).

Obviously the code below doesn't work at all, and the logic on getting the min/max values is flawed, but hopefully it helps make sense of what I'm trying to do...

public static MinMax MinandMax(List<ValueHistoric> InputList, int take)
{
    InputList.Reverse();
    var CutList = InputList.Take(take);
    var CutListMax = CutList.Where(a => a.Value == CutList.Max(b => b.Value) && a.Date > CutList.Min.Date);
    var CutListMin = CutList.Where(a => a.Value == CutList.Min(b => b.Value) && a.Date < CutList.Max.Date>);

    //Put Min and Max into variables here

    MinMax results = new MinMax();
    results.Max = last12max;
    results.Min = last12min;
    return results;
}

public class ValueHistoric
{
    public ObjectId Id { get; set; }
    public DateTime Date { get; set; }
    public double Value { get; set; }
    public string Name { get; set; }
}

Body:
I would first determine the min date OrderBy to get the lowest value first

var min = CutList.OrderBy(x => x.Value).First();

afterwards I would determine the max date - which has to be > min.Date
, OrderByDesc to get the highest value first

var max = CutList.OrderByDesc(x => x.Value).First(a => a.Date > min.Date);

Update.. You have to order by the Value, not the Date


问:
How can I remove padding property from an element? (CSS)
```<code>   <th style="padding-left:40px;" id="lbl_vehicleType">
     <h5> Vehicle Type </h5>
  </th>
</code>```

How can I remove the padding-left with media query I tried using this approach.

```<code>    @media only screen and (max-width: 480px){
        #drp_per_page2{
            color:red;
        }

        #lbl_vehicleType{
            padding-left: 0;
        }
    }
</code>```

I tried to change the color of the dropdown to see if it works.
    It did although the padding-left did not.
    I even tried making it padding-left: -40px; Still it didn't work.

答:
The only way an inline style rule can be over-qualified, using an external style rule, is by using the !important declaration, e.g:

```<code>#lbl_vehicleType{
   padding-left: 0 !important;
}
</code>```

For this reason, it's usually considered best practice to declare your styles externally whenever possible.

However, if it is not, using the !important declaration is the only method, as selector weight (i.e: using an id selector instead of a class selector) and selector specificity (i.e: being more specific with your selectors, .e.g: table th#lbl_vehicleType) will not be enough.

Consider the below for reference:

external styles (style.css) < internal styles () < inline styles (style="")

Side note

On a side note, you can't use negative values (percentage units or length units) for the padding property.

Body:
 Vehicle Type

How can I remove the padding-left with media query I tried using this approach.

    @media only screen and (max-width: 480px){
        #drp_per_page2{
            color:red;
        }

        #lbl_vehicleType{
            padding-left: 0;
        }
    }

I tried to change the color of the dropdown to see if it works.
    It did although the padding-left did not.
    I even tried making it padding-left: -40px; Still it didn't work.

Body:
The only way an inline style rule can be over-qualified, using an external style rule, is by using the !important declaration, e.g:

#lbl_vehicleType{
   padding-left: 0 !important;
}

For this reason, it's usually considered best practice to declare your styles externally whenever possible.

However, if it is not, using the !important declaration is the only method, as selector weight (i.e: using an id selector instead of a class selector) and selector specificity (i.e: being more specific with your selectors, .e.g: table th#lbl_vehicleType) will not be enough.

Consider the below for reference:

external styles (style.css) < internal styles (<style></style>) < inline styles (style="")

Side note

On a side note, you can't use negative values (percentage units or length units) for the padding property.


问:
How do I customize the documentation blocks Enterprise Architect Generates?
I'm using Enterprise Architect to model my software and to generate code skeletons. As part of this process, the tool will automatically add documentation blocks for classes, functions, and data members. This is fine, but I don't see any obvious way to customize the output. For example, this is what comes out for class Foo:

```<code>/**
 * Text from the properties window in EA for Foo.
 * @author My Name
 * @version 1.0
 * @created 26-Oct-2017 12:32:57
 */
class Foo
{
</code>```

I've looked through the Code Template Editor but things like this all seem to be hidden behind a magic function. For example, the C++ Class Notes template includes %JAVADOC_COMMENT($wrapLen) but I haven't seen where I can have any effect on what goes in that comment.

Is there a way to customize JavaDoc output in EA? Or perhaps to define my own "Comment Style"? For example, maybe I want to switch the order in which items are displayed, I want to add some blank lines in between parameters, or I want to eliminate @created from my documentation blocks altogether.

答:
The magic function you are referring too is a documented macro:

JAVADOC_COMMENT([wrap_length])

  Converts the notes for the element currently in scope to javadoc -style comments.

So you won't be able to tweak the way the macro works.

But you can of course replace the standard macro with your own comment section, if you really think that is worth it.

Body:
I'm using Enterprise Architect to model my software and to generate code skeletons. As part of this process, the tool will automatically add documentation blocks for classes, functions, and data members. This is fine, but I don't see any obvious way to customize the output. For example, this is what comes out for class Foo:

/**
 * Text from the properties window in EA for Foo.
 * @author My Name
 * @version 1.0
 * @created 26-Oct-2017 12:32:57
 */
class Foo
{

I've looked through the Code Template Editor but things like this all seem to be hidden behind a magic function. For example, the C++ Class Notes template includes %JAVADOC_COMMENT($wrapLen) but I haven't seen where I can have any effect on what goes in that comment.

Is there a way to customize JavaDoc output in EA? Or perhaps to define my own "Comment Style"? For example, maybe I want to switch the order in which items are displayed, I want to add some blank lines in between parameters, or I want to eliminate @created from my documentation blocks altogether.


问:
Change the URL of a docker-machine
I created a machine via docker-machine create -d azure --azure-static-public-IP. But what I did is I intentionally changed the public IP address of that VM. With this move, I can not docker-machine ssh or any docker-machine related command. Seems like it’s still sending request to the previous public-IP. How can I change that IP and convert it to the new one? I tried docker-machine regenerate-certs and even changing the config.json but nothing going to be happened…

The only way I saw fixing this is to reverting back the previous public IP of that VM

答:
You should be fine with a change of the IP in "config.json". For Example, if i have to change my IP on my default docker-machine, i would go here:

```<code>/Users/arne/.docker/machine/machines/default/config.json
</code>```

Adjust the IP and run

```<code>docker-machine regenerate-certs myVM
</code>```

This should work.

Title: Change the URL of a docker-machine

Body:
You should be fine with a change of the IP in "config.json". For Example, if i have to change my IP on my default docker-machine, i would go here:

/Users/arne/.docker/machine/machines/default/config.json

Adjust the IP and run

docker-machine regenerate-certs myVM

This should work.


问:
Onclick function button inside a javascript
I want to direct the button to another page

```<code>function showInput() {
    document.getElementById("demo").innerHTML = '<input type="submit"
    onclick="location.href = "addnewcustomer.php";" id ="newcust"
    class="btnRegister" value = "New Customer">';
}
</code>```

I want when i click the New Customer button, it will redirect to addnewcustomer.php but when i run the code, nothing happened.

There are no errors. Just the button didn't function the way i want it to

答:
It is because you didn’t close your input tag
Try this...

```<code>function showInput() {
document.getElementById("demo").innerHTML = '<input type="submit"
 onclick="location.href =     "addnewcustomer.php";" id ="newcust"
 class="btnRegister" value = "New Customer"/>';
}
</code>```

If you don’t close it the button will not work.

Body:
I want to direct the button to another page

function showInput() {
    document.getElementById("demo").innerHTML = '<input type="submit"
    onclick="location.href = "addnewcustomer.php";" id ="newcust"
    class="btnRegister" value = "New Customer">';
}

I want when i click the New Customer button, it will redirect to addnewcustomer.php but when i run the code, nothing happened.

There are no errors. Just the button didn't function the way i want it to

Body:
It is because you didn’t close your input tag
Try this...

function showInput() {
document.getElementById("demo").innerHTML = '<input type="submit"
 onclick="location.href =     "addnewcustomer.php";" id ="newcust"
 class="btnRegister" value = "New Customer"/>';
}

If you don’t close it the button will not work.


问:
What is the fastest sorting algorithm for a small number of integers?
I am wondering what the fastest algorithm would be for this.  I have 8 integers between 0 and 3000 and I need to sort them.  Although there are only 8 integers, this operation will be performed millions of times.</p>

答:
The following citation from Bentley et al., Engineering a sort function could be interesting here:

Various improvements to insertion sort, including binary search, loop unrolling, and handling n=2 as a special case, were not helpful. The simplest code was the fastest.

(Emphasis mine.)

This suggests that plain insertion sort without fancy modifications would indeed be a good starting point. As Peter has noted, eight items is indeed a bit tricky because that lies squarely in the range which usually marks the cut-off between insertion sort and quicksort.


问:
Change URL with wildcard
I don't know if The tittle suitable or not (sorry for that).
First, I have to tell you that I am very novice at javascript.

I want to make javascirpt that change URL and redirect it on click (create on boookmark bar).
The idea is to change URL:

https://mail.google.com/mail/u/0/h/[12_random_aphanumeric]/?&th=[16_random_aphanumeric]&v=c&s=a

to

https://mail.google.com/mail/u/0/#all/[16_random_aphanumeric]

for example Change:

https://mail.google.com/mail/u/0/h/bv293r3qycgk/?&th=16032287bb796882&v=c&s=a

to

https://mail.google.com/mail/u/0/#all/16032287bb796882

so I use "window.location.assign" like :

```<code>javascript: window.location.assign(window.location.toString().replace('*?&th=', 'https://mail.google.com/mail/u/0/#all/')); window.location.assign(window.location.toString().replace('&v=c&s=a', ' '));
</code>```

and of course its not working.

I just don't know how to use [*] wildcard on it.

Any suggestion would be appreciated.

答:
.replace supports no such thing as a "wildcard". What you are looking for is called a regular expression. The * in regexp is called a Kleene closure.

```<code>gmailUrlRegex = /(https:\/\/mail\.google\.com\/mail\/u\/0)\/h\/[A-z0-9]{12}\/\?&th=([A-z0-9]{16}).*/;
location.href = location.href.replace(gmailUrlRegex, "$1/#all/$2");
</code>```

Visualize regex: https://www.debuggex.com/r/eAkLwrgNQcuUCisN

var input = "https://mail.google.com/mail/u/0/h/bv293r3qycgk/?&th=16032287bb796882&v=c&s=a";
console.log(input.replace(/(https:\/\/mail\.google\.com\/mail\/u\/0)\/h\/[A-z0-9]{12}\/\?&th=([A-z0-9]{16}).*/, "$1/#all/$2"));```

Title: Change URL with wildcard

Body:
I don't know if The tittle suitable or not (sorry for that).
First, I have to tell you that I am very novice at javascript.

I want to make javascirpt that change URL and redirect it on click (create on boookmark bar).
The idea is to change URL:

https://mail.google.com/mail/u/0/h/[12_random_aphanumeric]/?&th=[16_random_aphanumeric]&v=c&s=a

to

https://mail.google.com/mail/u/0/#all/[16_random_aphanumeric]

for example Change:

https://mail.google.com/mail/u/0/h/bv293r3qycgk/?&th=16032287bb796882&v=c&s=a

to

https://mail.google.com/mail/u/0/#all/16032287bb796882

so I use "window.location.assign" like :

javascript: window.location.assign(window.location.toString().replace('*?&th=', 'https://mail.google.com/mail/u/0/#all/')); window.location.assign(window.location.toString().replace('&v=c&s=a', ' '));

and of course its not working.

I just don't know how to use [*] wildcard on it.

Any suggestion would be appreciated.

Body:
.replace supports no such thing as a "wildcard". What you are looking for is called a regular expression. The * in regexp is called a Kleene closure.

gmailUrlRegex = /(https:\/\/mail\.google\.com\/mail\/u\/0)\/h\/[A-z0-9]{12}\/\?&th=([A-z0-9]{16}).*/;
location.href = location.href.replace(gmailUrlRegex, "$1/#all/$2");

Visualize regex: https://www.debuggex.com/r/eAkLwrgNQcuUCisN

var input = "https://mail.google.com/mail/u/0/h/bv293r3qycgk/?&th=16032287bb796882&v=c&s=a";
console.log(input.replace(/(https:\/\/mail\.google\.com\/mail\/u\/0)\/h\/[A-z0-9]{12}\/\?&th=([A-z0-9]{16}).*/, "$1/#all/$2"));


问:
InstanceApp can not access from feature to feature module resources in java code
I do not understand what exactly happens, but it seems when I want to access a resource in a feature module, when the resource also is located in that feature module, then the InstanceApp always looks for the resource in the base module (or maybe somewhere else). To make this work I can move the resource from feature module into the base and access those resources with the base module package name: com.module.base.R. Now the question is why de.module.feature.R or just R can't retrieve the respective resource at runtime, when it is working properly for XML usages.

EDIT 1: I am also using multidex can this be a problem?
ANSWER 1: Disabling of multidexing didn't help.

答:
The latest build-tools have been patched in with a fix for this issue.

Please update your Android SDK Build-Tools to 27.0.2 version.

Ensure you are on Android Studio 3.0.1 or newer.

Note: The Google issue tracker post regarding the Android Instant Application error crash has also been updated.


问:
Use python + Selenium to login,but can't find div
```<code># _*_coding:utf-8_*_
from selenium import webdriver

driver=webdriver.Chrome()
url="https://login.alibaba.com"
driver.get(url)
driver.implicitly_wait(3)
print(driver.page_source)
driver.quit()
</code>```

i want to login by selenium, but can't find the login id "fm-login-id"

答:
As per the URL you have shared url="https://login.alibaba.com", to locate the Email Address field i.e fm-login-id through Selenium-Java you can use either of the following :

xpath :

```<code>driver.find_element_by_xpath("//input[@id='fm-login-id']")
</code>```

cssSelector :

```<code>driver.find_element_by_css_selector("input#fm-login-id")
</code>```

Body:
# _*_coding:utf-8_*_
from selenium import webdriver

driver=webdriver.Chrome()
url="https://login.alibaba.com"
driver.get(url)
driver.implicitly_wait(3)
print(driver.page_source)
driver.quit()

i want to login by selenium, but can't find the login id "fm-login-id"

Body:
As per the URL you have shared url="https://login.alibaba.com", to locate the Email Address field i.e fm-login-id through Selenium-Java you can use either of the following :

xpath :

driver.find_element_by_xpath("//input[@id='fm-login-id']")

cssSelector :

driver.find_element_by_css_selector("input#fm-login-id")


问:
Using TensorFlow's Dataset API with multi-GPU training
Using Tensorflow's new Dataset API for multi-GPU training (from TFRecords format) appears to perform considerably slower (1/4 slower) than running on a single GPU (1 vs. 4 Tesla K80s).

Looking at the output of nvidia-smi it appears that using 4 GPUs only causes gpu-utilization to be around 15% each, while with a single GPU it is around 45%.

Does loading data from disk (tfrecords-format) cause a bottleneck in the training speed? Using regular feed-dicts, where the entire dataset is loaded into memory is substantially faster than using the dataset API as well.

答:
It seems your network is throttled by:

IO from the disc, as mentioned in your last paragraph
If you are starting your Dataset with reading off TFRecords, then it will read from disc; Instead, you could read them into a list/dict, and start with range sequence. Eg.

tf.data.Dataset()\
.range(your_data_size)\
.prefetch(20)\
.shuffle(buffer_size=20)\
.map(lambda i: your_loaded_list[i], num_parallel_calls=8)

Heavy pre/post-processing, as mentioned in your 2nd paragraph where single GPU utilization is 45%; if that was when you already pre-load data to memory, it suggests your network taking efforts outside of the "main" computation body.

First you may work to check if using multi-threading with the map call like above helps; also trimming down some tf.summary operations which could potentially feed back lots of unnecessary data which throttles your bandwidth/write to disc afterwards.

Hope this helps.