问:
Different modes of invocation of a JavaScript function from a Razor view
I am building a Web application with ASP.NET Core MVC 6 and have a JavaScript function like the following in a file associated with a Razor view:

```<code>function DuplicateProcessName(textbox, existingProcessNames) {

    if (existingProcessNames.includes(textbox.value)) {

        // ...
    }
}
</code>```

With the following code in the view, the function works:

```<code><script>
    let existingProcessNames = ["External","Internal","Local","Rescue"];
</script>

<textarea name='ProcessName'
    onfocusout="DuplicateProcessName(this, existingProcessNames)">
</textarea>
</code>```

This has the drawback of creating a global variable, "existingProcessNames".

To avoid this, I generated the following code instead:

```<code><textarea name='ProcessName'
    onfocusout="DuplicateProcessName(this, ["External","Internal","Local","Rescue"])">
</code>```

With this form of invocation, the function does not run.

Can you explain the reason?

Thank you in advance!

Body:
I am building a Web application with ASP.NET Core MVC 6 and have a JavaScript function like the following in a file associated with a Razor view:

function DuplicateProcessName(textbox, existingProcessNames) {

    if (existingProcessNames.includes(textbox.value)) {

        // ...
    }
}

With the following code in the view, the function works:

<textarea name='ProcessName'
    onfocusout="DuplicateProcessName(this, existingProcessNames)">
</textarea>

This has the drawback of creating a global variable, "existingProcessNames".

To avoid this, I generated the following code instead:

<textarea name='ProcessName'
    onfocusout="DuplicateProcessName(this, ["External","Internal","Local","Rescue"])">

With this form of invocation, the function does not run.

Can you explain the reason?

Thank you in advance!


来源: stackexchange

问:
Flatten Nested XML file in Pyspark
I have the following nested xml file below which leads to my 2 questions.

How and what functions should I use to flatten the file into dataframe table? Examples would be very helpful, please?

How can I use field "CNTL_ID" (PK) to link it with "ENRLMTS" record? If this cannot be achieved easily, how can I create a surrogate key on the fly to link "PRVDR_INFO" with "ENRLMTS"?

XML File:

```<code><PRVDR>
    <PRVDR_INFO>
        <INDVDL_INFO>
            <CNTL_ID>12345678</CNTL_ID>
            <BIRTH_DT>19200609</BIRTH_DT>
            <BIRTH_STATE_CD>VA</BIRTH_STATE_CD>
            <BIRTH_STATE_NAME>VIRGINIA</BIRTH_STATE_NAME>
            <BIRTH_CNTRY_CD>US</BIRTH_CNTRY_CD>
            <BIRTH_CNTRY_NAME>UNITED STATES</BIRTH_CNTRY_NAME>
            <BIRTH_FRGN_SW>Z</BIRTH_FRGN_SW>
            <NAME_LIST>
                <PEC_INDVDL_NAME>
                    <NAME_CD>I</NAME_CD>
                    <NAME_DESC>INDIVIDUAL NAME</NAME_DESC>
                    <FIRST_NAME>WILL</FIRST_NAME>
                    <MDL_NAME>J</MDL_NAME>
                    <LAST_NAME>SMITH</LAST_NAME>
                    <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                </PEC_INDVDL_NAME>
                <PEC_INDVDL_NAME>
                    <NAME_CD>I</NAME_CD>
                    <NAME_DESC>INDIVIDUAL NAME</NAME_DESC>
                    <FIRST_NAME>WILL</FIRST_NAME>
                    <LAST_NAME>SMITH</LAST_NAME>
                    <TRMNTN_DT>2010-09-10T13:19:38</TRMNTN_DT>
                    <DATA_STUS_CD>HISTORY</DATA_STUS_CD>
                </PEC_INDVDL_NAME>
            </NAME_LIST>
            <PEC_TIN>
                <TIN>555778888</TIN>
                <TAX_IDENT_TYPE_CD>T</TAX_IDENT_TYPE_CD>
                <TAX_IDENT_DESC>SSN</TAX_IDENT_DESC>
                <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
            </PEC_TIN>
            <PEC_NPI>
                <NPI>3334211156</NPI>
                <VRFYD_BUSNS_SW>Y</VRFYD_BUSNS_SW>
                <CREAT_TS>2010-09-10T13:16:28</CREAT_TS>
                <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
            </PEC_NPI>
        </INDVDL_INFO>
    </PRVDR_INFO>
    <ENRLMTS>
        <ABC_855X>
            <ENRLMT_INFO>
                <ENRLMT_DTLS>
                    <FORM_TYPE_CD>9999A</FORM_TYPE_CD>
                    <ENRLMT_ID>123444555666778899000</ENRLMT_ID>
                    <ENRLMT_STUS_DLTS>
                        <STUS_CD>06</STUS_CD>
                        <STUS_DESC>APPROVED</STUS_DESC>
                        <STUS_DT>2012-05-14T16:04:22</STUS_DT>
                        <DATA_STUS_CD>HISTORY</DATA_STUS_CD>
                        <ENRLMT_STUS_RSN_DLTS>
                        <STUS_RSN_CD>047</STUS_RSN_CD>
                        <STUS_RSN_DESC>APPROVED</STUS_RSN_DESC>
                        <DATA_STUS_CD>HISTORY</DATA_STUS_CD>
                        </ENRLMT_STUS_RSN_DLTS>
                    </ENRLMT_STUS_DLTS>
                    <ENRLMT_STUS_DLTS>
                        <STUS_CD>06</STUS_CD>
                        <STUS_DESC>APPROVED</STUS_DESC>
                        <STUS_DT>2016-08-09T14:33:40</STUS_DT>
                        <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                        <ENRLMT_STUS_RSN_DLTS>
                        <STUS_RSN_CD>081</STUS_RSN_CD>
                        <STUS_RSN_DESC>APPROVED FOR REVALIDATION</STUS_RSN_DESC>
                        <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                        </ENRLMT_STUS_RSN_DLTS>
                    </ENRLMT_STUS_DLTS>
                    <BUSNS_STATE>VA</BUSNS_STATE>
                    <BUSNS_STATE_NAME>VIRGINIA</BUSNS_STATE_NAME>
                    <CNTRCTR_LIST>
                        <CNTRCTR_INFO>
                            <CNTRCTR_ID>11111</CNTRCTR_ID>
                            <CNTRCTR_NAME>SOLUTIONS, INC.</CNTRCTR_NAME>
                            <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                        </CNTRCTR_INFO>
                    </CNTRCTR_LIST>
                </ENRLMT_DTLS>
            </ENRLMT_INFO>
            <PEC_ENRLMT_REVLDTN>
                <REVLDTN_INSTNC_NUM>1</REVLDTN_INSTNC_NUM>
                <REVLDTN_STUS_CD>03</REVLDTN_STUS_CD>
                <REVLDTN_STUS_DESC>CANCELLED</REVLDTN_STUS_DESC>
            </PEC_ENRLMT_REVLDTN>
            <ACPT_NEW_PTNT_SW>Y</ACPT_NEW_PTNT_SW>
        </ABC_855X>
    </ENRLMTS>
</PRVDR>
</code>```

Schema is below:

```<code>root
 |-- ENRLMTS: struct (nullable = true)
 |    |-- ABC_855X: struct (nullable = true)
 |    |    |-- ACPT_NEW_PTNT_SW: string (nullable = true)
 |    |    |-- ENRLMT_INFO: struct (nullable = true)
 |    |    |    |-- ENRLMT_DTLS: struct (nullable = true)
 |    |    |    |    |-- BUSNS_STATE: string (nullable = true)
 |    |    |    |    |-- BUSNS_STATE_NAME: string (nullable = true)
 |    |    |    |    |-- CNTRCTR_LIST: struct (nullable = true)
 |    |    |    |    |    |-- CNTRCTR_INFO: struct (nullable = true)
 |    |    |    |    |    |    |-- CNTRCTR_ID: integer (nullable = true)
 |    |    |    |    |    |    |-- CNTRCTR_NAME: string (nullable = true)
 |    |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |-- ENRLMT_ID: double (nullable = true)
 |    |    |    |    |-- ENRLMT_STUS_DLTS: array (nullable = true)
 |    |    |    |    |    |-- element: struct (containsNull = true)
 |    |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |    |    |-- ENRLMT_STUS_RSN_DLTS: struct (nullable = true)
 |    |    |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |    |    |    |-- STUS_RSN_CD: integer (nullable = true)
 |    |    |    |    |    |    |    |-- STUS_RSN_DESC: string (nullable = true)
 |    |    |    |    |    |    |-- STUS_CD: integer (nullable = true)
 |    |    |    |    |    |    |-- STUS_DESC: string (nullable = true)
 |    |    |    |    |    |    |-- STUS_DT: string (nullable = true)
 |    |    |    |    |-- FORM_TYPE_CD: string (nullable = true)
 |    |    |-- PEC_ENRLMT_REVLDTN: struct (nullable = true)
 |    |    |    |-- REVLDTN_INSTNC_NUM: integer (nullable = true)
 |    |    |    |-- REVLDTN_STUS_CD: integer (nullable = true)
 |    |    |    |-- REVLDTN_STUS_DESC: string (nullable = true)
 |-- PRVDR_INFO: struct (nullable = true)
 |    |-- INDVDL_INFO: struct (nullable = true)
 |    |    |-- BIRTH_CNTRY_CD: string (nullable = true)
 |    |    |-- BIRTH_CNTRY_NAME: string (nullable = true)
 |    |    |-- BIRTH_DT: integer (nullable = true)
 |    |    |-- BIRTH_FRGN_SW: string (nullable = true)
 |    |    |-- BIRTH_STATE_CD: string (nullable = true)
 |    |    |-- BIRTH_STATE_NAME: string (nullable = true)
 |    |    |-- CNTL_ID: integer (nullable = true)
 |    |    |-- NAME_LIST: struct (nullable = true)
 |    |    |    |-- PEC_INDVDL_NAME: array (nullable = true)
 |    |    |    |    |-- element: struct (containsNull = true)
 |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |    |-- FIRST_NAME: string (nullable = true)
 |    |    |    |    |    |-- LAST_NAME: string (nullable = true)
 |    |    |    |    |    |-- MDL_NAME: string (nullable = true)
 |    |    |    |    |    |-- NAME_CD: string (nullable = true)
 |    |    |    |    |    |-- NAME_DESC: string (nullable = true)
 |    |    |    |    |    |-- TRMNTN_DT: string (nullable = true)
 |    |    |-- PEC_NPI: struct (nullable = true)
 |    |    |    |-- CREAT_TS: string (nullable = true)
 |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |-- NPI: long (nullable = true)
 |    |    |    |-- VRFYD_BUSNS_SW: string (nullable = true)
 |    |    |-- PEC_TIN: struct (nullable = true)
 |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |-- TAX_IDENT_DESC: string (nullable = true)
 |    |    |    |-- TAX_IDENT_TYPE_CD: string (nullable = true)
 |    |    |    |-- TIN: integer (nullable = true)
</code>```

My current nested dataframe output below. I would to break this nested output to multiple rows if possible.

```<code>+--------------------+--------------------+
|             ENRLMTS|          PRVDR_INFO|
+--------------------+--------------------+
|{{Y, {{VA, VIRGIN...|{{US, UNITED STAT...|
+--------------------+--------------------+
</code>```

Thank you much.

ContentLicense: CC BY-SA 4.0

Title: Flatten Nested XML file in Pyspark

Body:
I have the following nested xml file below which leads to my 2 questions.

How and what functions should I use to flatten the file into dataframe table? Examples would be very helpful, please?

How can I use field "CNTL_ID" (PK) to link it with "ENRLMTS" record? If this cannot be achieved easily, how can I create a surrogate key on the fly to link "PRVDR_INFO" with "ENRLMTS"?

XML File:

<PRVDR>
    <PRVDR_INFO>
        <INDVDL_INFO>
            <CNTL_ID>12345678</CNTL_ID>
            <BIRTH_DT>19200609</BIRTH_DT>
            <BIRTH_STATE_CD>VA</BIRTH_STATE_CD>
            <BIRTH_STATE_NAME>VIRGINIA</BIRTH_STATE_NAME>
            <BIRTH_CNTRY_CD>US</BIRTH_CNTRY_CD>
            <BIRTH_CNTRY_NAME>UNITED STATES</BIRTH_CNTRY_NAME>
            <BIRTH_FRGN_SW>Z</BIRTH_FRGN_SW>
            <NAME_LIST>
                <PEC_INDVDL_NAME>
                    <NAME_CD>I</NAME_CD>
                    <NAME_DESC>INDIVIDUAL NAME</NAME_DESC>
                    <FIRST_NAME>WILL</FIRST_NAME>
                    <MDL_NAME>J</MDL_NAME>
                    <LAST_NAME>SMITH</LAST_NAME>
                    <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                </PEC_INDVDL_NAME>
                <PEC_INDVDL_NAME>
                    <NAME_CD>I</NAME_CD>
                    <NAME_DESC>INDIVIDUAL NAME</NAME_DESC>
                    <FIRST_NAME>WILL</FIRST_NAME>
                    <LAST_NAME>SMITH</LAST_NAME>
                    <TRMNTN_DT>2010-09-10T13:19:38</TRMNTN_DT>
                    <DATA_STUS_CD>HISTORY</DATA_STUS_CD>
                </PEC_INDVDL_NAME>
            </NAME_LIST>
            <PEC_TIN>
                <TIN>555778888</TIN>
                <TAX_IDENT_TYPE_CD>T</TAX_IDENT_TYPE_CD>
                <TAX_IDENT_DESC>SSN</TAX_IDENT_DESC>
                <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
            </PEC_TIN>
            <PEC_NPI>
                <NPI>3334211156</NPI>
                <VRFYD_BUSNS_SW>Y</VRFYD_BUSNS_SW>
                <CREAT_TS>2010-09-10T13:16:28</CREAT_TS>
                <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
            </PEC_NPI>
        </INDVDL_INFO>
    </PRVDR_INFO>
    <ENRLMTS>
        <ABC_855X>
            <ENRLMT_INFO>
                <ENRLMT_DTLS>
                    <FORM_TYPE_CD>9999A</FORM_TYPE_CD>
                    <ENRLMT_ID>123444555666778899000</ENRLMT_ID>
                    <ENRLMT_STUS_DLTS>
                        <STUS_CD>06</STUS_CD>
                        <STUS_DESC>APPROVED</STUS_DESC>
                        <STUS_DT>2012-05-14T16:04:22</STUS_DT>
                        <DATA_STUS_CD>HISTORY</DATA_STUS_CD>
                        <ENRLMT_STUS_RSN_DLTS>
                        <STUS_RSN_CD>047</STUS_RSN_CD>
                        <STUS_RSN_DESC>APPROVED</STUS_RSN_DESC>
                        <DATA_STUS_CD>HISTORY</DATA_STUS_CD>
                        </ENRLMT_STUS_RSN_DLTS>
                    </ENRLMT_STUS_DLTS>
                    <ENRLMT_STUS_DLTS>
                        <STUS_CD>06</STUS_CD>
                        <STUS_DESC>APPROVED</STUS_DESC>
                        <STUS_DT>2016-08-09T14:33:40</STUS_DT>
                        <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                        <ENRLMT_STUS_RSN_DLTS>
                        <STUS_RSN_CD>081</STUS_RSN_CD>
                        <STUS_RSN_DESC>APPROVED FOR REVALIDATION</STUS_RSN_DESC>
                        <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                        </ENRLMT_STUS_RSN_DLTS>
                    </ENRLMT_STUS_DLTS>
                    <BUSNS_STATE>VA</BUSNS_STATE>
                    <BUSNS_STATE_NAME>VIRGINIA</BUSNS_STATE_NAME>
                    <CNTRCTR_LIST>
                        <CNTRCTR_INFO>
                            <CNTRCTR_ID>11111</CNTRCTR_ID>
                            <CNTRCTR_NAME>SOLUTIONS, INC.</CNTRCTR_NAME>
                            <DATA_STUS_CD>CURRENT</DATA_STUS_CD>
                        </CNTRCTR_INFO>
                    </CNTRCTR_LIST>
                </ENRLMT_DTLS>
            </ENRLMT_INFO>
            <PEC_ENRLMT_REVLDTN>
                <REVLDTN_INSTNC_NUM>1</REVLDTN_INSTNC_NUM>
                <REVLDTN_STUS_CD>03</REVLDTN_STUS_CD>
                <REVLDTN_STUS_DESC>CANCELLED</REVLDTN_STUS_DESC>
            </PEC_ENRLMT_REVLDTN>
            <ACPT_NEW_PTNT_SW>Y</ACPT_NEW_PTNT_SW>
        </ABC_855X>
    </ENRLMTS>
</PRVDR>

Schema is below:

root
 |-- ENRLMTS: struct (nullable = true)
 |    |-- ABC_855X: struct (nullable = true)
 |    |    |-- ACPT_NEW_PTNT_SW: string (nullable = true)
 |    |    |-- ENRLMT_INFO: struct (nullable = true)
 |    |    |    |-- ENRLMT_DTLS: struct (nullable = true)
 |    |    |    |    |-- BUSNS_STATE: string (nullable = true)
 |    |    |    |    |-- BUSNS_STATE_NAME: string (nullable = true)
 |    |    |    |    |-- CNTRCTR_LIST: struct (nullable = true)
 |    |    |    |    |    |-- CNTRCTR_INFO: struct (nullable = true)
 |    |    |    |    |    |    |-- CNTRCTR_ID: integer (nullable = true)
 |    |    |    |    |    |    |-- CNTRCTR_NAME: string (nullable = true)
 |    |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |-- ENRLMT_ID: double (nullable = true)
 |    |    |    |    |-- ENRLMT_STUS_DLTS: array (nullable = true)
 |    |    |    |    |    |-- element: struct (containsNull = true)
 |    |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |    |    |-- ENRLMT_STUS_RSN_DLTS: struct (nullable = true)
 |    |    |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |    |    |    |-- STUS_RSN_CD: integer (nullable = true)
 |    |    |    |    |    |    |    |-- STUS_RSN_DESC: string (nullable = true)
 |    |    |    |    |    |    |-- STUS_CD: integer (nullable = true)
 |    |    |    |    |    |    |-- STUS_DESC: string (nullable = true)
 |    |    |    |    |    |    |-- STUS_DT: string (nullable = true)
 |    |    |    |    |-- FORM_TYPE_CD: string (nullable = true)
 |    |    |-- PEC_ENRLMT_REVLDTN: struct (nullable = true)
 |    |    |    |-- REVLDTN_INSTNC_NUM: integer (nullable = true)
 |    |    |    |-- REVLDTN_STUS_CD: integer (nullable = true)
 |    |    |    |-- REVLDTN_STUS_DESC: string (nullable = true)
 |-- PRVDR_INFO: struct (nullable = true)
 |    |-- INDVDL_INFO: struct (nullable = true)
 |    |    |-- BIRTH_CNTRY_CD: string (nullable = true)
 |    |    |-- BIRTH_CNTRY_NAME: string (nullable = true)
 |    |    |-- BIRTH_DT: integer (nullable = true)
 |    |    |-- BIRTH_FRGN_SW: string (nullable = true)
 |    |    |-- BIRTH_STATE_CD: string (nullable = true)
 |    |    |-- BIRTH_STATE_NAME: string (nullable = true)
 |    |    |-- CNTL_ID: integer (nullable = true)
 |    |    |-- NAME_LIST: struct (nullable = true)
 |    |    |    |-- PEC_INDVDL_NAME: array (nullable = true)
 |    |    |    |    |-- element: struct (containsNull = true)
 |    |    |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |    |    |-- FIRST_NAME: string (nullable = true)
 |    |    |    |    |    |-- LAST_NAME: string (nullable = true)
 |    |    |    |    |    |-- MDL_NAME: string (nullable = true)
 |    |    |    |    |    |-- NAME_CD: string (nullable = true)
 |    |    |    |    |    |-- NAME_DESC: string (nullable = true)
 |    |    |    |    |    |-- TRMNTN_DT: string (nullable = true)
 |    |    |-- PEC_NPI: struct (nullable = true)
 |    |    |    |-- CREAT_TS: string (nullable = true)
 |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |-- NPI: long (nullable = true)
 |    |    |    |-- VRFYD_BUSNS_SW: string (nullable = true)
 |    |    |-- PEC_TIN: struct (nullable = true)
 |    |    |    |-- DATA_STUS_CD: string (nullable = true)
 |    |    |    |-- TAX_IDENT_DESC: string (nullable = true)
 |    |    |    |-- TAX_IDENT_TYPE_CD: string (nullable = true)
 |    |    |    |-- TIN: integer (nullable = true)

My current nested dataframe output below. I would to break this nested output to multiple rows if possible.

+--------------------+--------------------+
|             ENRLMTS|          PRVDR_INFO|
+--------------------+--------------------+
|{{Y, {{VA, VIRGIN...|{{US, UNITED STAT...|
+--------------------+--------------------+

Thank you much.


问:
Change cell contents to bold after inserting text from another cell
I'm using vba code to copy a value from another column into blank cells in Column B. I want the copied value to be bold.

I'm using the following to populate the blank cells in column B:

```<code>Sub CatLabels()
    x = Range("B" & Rows.Count).End(xlUp).Row

    If x > 1 Then
        With Range("B2:B" & x).SpecialCells(xlCellTypeBlanks)
            .FormulaR1C1 = "=(R[+1]C[+2])"
        End With
    End If

End Sub
</code>```

How do I get the copied value to be changed to a bold font?

Body:
I'm using vba code to copy a value from another column into blank cells in Column B. I want the copied value to be bold.

I'm using the following to populate the blank cells in column B:

Sub CatLabels()
    x = Range("B" & Rows.Count).End(xlUp).Row

    If x > 1 Then
        With Range("B2:B" & x).SpecialCells(xlCellTypeBlanks)
            .FormulaR1C1 = "=(R[+1]C[+2])"
        End With
    End If

End Sub

How do I get the copied value to be changed to a bold font?


问:
Gitlab CI job's script runs multiple time
I have only one job in Gitlab CI:

```<code>develop:
  stage: deploy
  tags:
    - intellect
  only:
    - develop
  before_script:
    - npm i
  script:
    - ng build --output-path /var/www/oko-front-develop
  after_script:
    - echo "Deploy test stage end"
</code>```

I noticed that my job's script duplicates in the htop command.

Did anybody else face this situation and can recommend a solution?

Body:
I have only one job in Gitlab CI:

develop:
  stage: deploy
  tags:
    - intellect
  only:
    - develop
  before_script:
    - npm i
  script:
    - ng build --output-path /var/www/oko-front-develop
  after_script:
    - echo "Deploy test stage end"

I noticed that my job's script duplicates in the htop command.

Did anybody else face this situation and can recommend a solution?


问:
accidentally added space character in md5 string
accidently adding space character( ) on md5 string when pasting password after generating a md5 encryption for my samp login page..
is there a way to accesing with broken code like this:

```<code><?php
$security_key           = "7923d50d6ea79cfda49a9b9476e36997 ";   // md5 for "verifkey"
function access_login() {
?>
<!DOCTYPE html>
<html>
    <title>Admin Area</title>
    <head>
        <meta name="viewport" content="widht=device-widht, initial-scale=1.0"/>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css"/>
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"/>
    </head>
    <body class="bg-dark text-light">
        <center>
            <div class="container" style="margin-top: 15%">
                <div class="col-lg-6">
                    <div class="form-group">
                        <center><h5>Administrator Page</a></h5></center>
                        <form method="post">
                            <input type="password" name="key" placeholder="SECURITYKEY" class="form-control"><br/>
                            <input type="submit" class="btn btn-danger btn-block" class="form-control" value="Login">
                        </form>
                 </div>
            </div>
        </center>
    </body>
</html>

<?php
exit;
}
if(!isset($_SESSION[md5($_SERVER['HTTP_HOST'])]))
if( empty($security_key) || ( isset($_POST['key']) && (md5($_POST['key']) == $security_key) ) )
    $_SESSION[md5($_SERVER['HTTP_HOST'])] = true;
</code>```

on

```<code>$security_key           = "7923d50d6ea79cfda49a9b9476e36997 ";
</code>```

im forgot to checking if there have a space character.
that should be

```<code>$security_key           = "7923d50d6ea79cfda49a9b9476e36997";
</code>```

without space( ) after md5string.

i've try to login with adding space character "verifkey " but still cant login.

anyone can help?

Body:
accidently adding space character( ) on md5 string when pasting password after generating a md5 encryption for my samp login page..
is there a way to accesing with broken code like this:

<?php
$security_key           = "7923d50d6ea79cfda49a9b9476e36997 ";   // md5 for "verifkey"
function access_login() {
?>
<!DOCTYPE html>

    <title>Admin Area</title>

        <meta name="viewport" content="widht=device-widht, initial-scale=1.0"/>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css"/>
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"/>

Administrator Page

                        <form method="post">
                            <input type="password" name="key" placeholder="SECURITYKEY" class="form-control">

                            <input type="submit" class="btn btn-danger btn-block" class="form-control" value="Login">
                        </form>

<?php
exit;
}
if(!isset($_SESSION[md5($_SERVER['HTTP_HOST'])]))
if( empty($security_key) || ( isset($_POST['key']) && (md5($_POST['key']) == $security_key) ) )
    $_SESSION[md5($_SERVER['HTTP_HOST'])] = true;

on

$security_key           = "7923d50d6ea79cfda49a9b9476e36997 ";

im forgot to checking if there have a space character.
that should be

$security_key           = "7923d50d6ea79cfda49a9b9476e36997";

without space( ) after md5string.

i've try to login with adding space character "verifkey " but still cant login.

anyone can help?


问:
Jacoco missing coverage when test is created
I have a project with spring-boot 2, JUnit 4, jacoco 0.8.6 and I use maven to run unit test, I have the following class:

@Component
public class AccountVOValidator implements FormValidator<AccountVO> {

    @Override
    public void validate(AccountVO object, Object... params) throws GenericException {
            //logic
        }
}
```
<p>This implements <code>FormValidator</code> interface, it looks like this:</p>
<pre class="lang-java prettyprint-override"><code>public interface FormValidator<T> {

    public void validate(T object, Object... params) throws GenericException;

}
</code>```

I already created the test class for that, it looks like this:

@RunWith(MockitoJUnitRunner.class)
public class AccountVOValidatorTest {

    private TestUtils testUtils = new TestUtils();

    @InjectMocks
    private AccountVOValidator accountVOValidator;

        @Test
    public void shouldValidateOk() throws GenericException {
        accountVOValidator.validate(accountVO, transaction);
    }
}
```

I have several unit test for different packages and jacoco report looks like this:
enter image description here

When I run "mvn clean test", AccountVOValidatorTest ran without problems and all tests passed successfully.
All classes that implements FormValidator interface have a missing coverage in jacoco report, I implements interfaces in my services classes and they got coverage in report, do you have an idea what it happens?

I am not sure why all classes that implements FormValidator interface don't get coverage in jacoco report.

Body:
I have a project with spring-boot 2, JUnit 4, jacoco 0.8.6 and I use maven to run unit test, I have the following class:

@Component
public class AccountVOValidator implements FormValidator<AccountVO> {

    @Override
    public void validate(AccountVO object, Object... params) throws GenericException {
            //logic
        }
}

This implements FormValidator interface, it looks like this:

public interface FormValidator<T> {

    public void validate(T object, Object... params) throws GenericException;

}

I already created the test class for that, it looks like this:

@RunWith(MockitoJUnitRunner.class)
public class AccountVOValidatorTest {

    private TestUtils testUtils = new TestUtils();

    @InjectMocks
    private AccountVOValidator accountVOValidator;

        @Test
    public void shouldValidateOk() throws GenericException {
        accountVOValidator.validate(accountVO, transaction);
    }
}

I have several unit test for different packages and jacoco report looks like this:
enter image description here

When I run "mvn clean test", AccountVOValidatorTest ran without problems and all tests passed successfully.
All classes that implements FormValidator interface have a missing coverage in jacoco report, I implements interfaces in my services classes and they got coverage in report, do you have an idea what it happens?

I am not sure why all classes that implements FormValidator interface don't get coverage in jacoco report.


问:
Topaz Workbench - where is the XML beautifier?
Topaz Workbench used to have the XML beautifier under Format -> Beautify. The Format drop down has been removed from the taskbar in a recent update and there is no mention of the XML beautifier when I search in the Help tool. Does anyone know where it was moved to?</p>


问:
HTACCESS rewrite if multiple cookies found
I'm scratching my head trying to do make a htaccess redirect in case of a cookie is found.

I have several directories /fr-be/, /nl-be/, /en/, ...
When a user visits a page in those directories a cookie named "lang" is dropped with the corresponding directory name so 'fr-be', 'nl-be', 'en', ... as value.

If the user manually type the url : 'https://testme.com' and if the cookie is found it should be redirected to the corresponding dir.

If there is no cookie found, it should be redirected to a default dir '/en/'
If there is something else than '/en/' like https://testme.com/en/test-page/ it should not be redirect.

It is a wordpress that's why there is a ". /index.php [L]" at the end.

I can't use php redirect because the website is on a static (strattic) server

Thanks for you help !

Here is my code :

```<code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} lang=fr-be
RewriteRule ^/$ /fr-be/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} lang=nl-be
RewriteRule ^/$ /nl-be/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} lang=en
RewriteRule ^/$ /en/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/$ /en/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>```

Body:
I'm scratching my head trying to do make a htaccess redirect in case of a cookie is found.

I have several directories /fr-be/, /nl-be/, /en/, ...
When a user visits a page in those directories a cookie named "lang" is dropped with the corresponding directory name so 'fr-be', 'nl-be', 'en', ... as value.

If the user manually type the url : 'https://testme.com' and if the cookie is found it should be redirected to the corresponding dir.

If there is no cookie found, it should be redirected to a default dir '/en/'
If there is something else than '/en/' like https://testme.com/en/test-page/ it should not be redirect.

It is a wordpress that's why there is a ". /index.php [L]" at the end.

I can't use php redirect because the website is on a static (strattic) server

Thanks for you help !

Here is my code :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} lang=fr-be
RewriteRule ^/$ /fr-be/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} lang=nl-be
RewriteRule ^/$ /nl-be/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} lang=en
RewriteRule ^/$ /en/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/$ /en/ [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


问:
How do I create a Firebase Dynamic Link with a wildcard in the path?
I am trying to create a Firebase Dynamic Link that has a wildcard in the path, like this: https://my-site.pages.link/daily-post/* where * is a wildcard that can be any string. In my case it would be a date like: https://my-site.pages.link/daily-post/2023-01-01.

Does the ability to have wildcards exist or do I have to create each link individually?

If not does branch.io have this ability?

Alternatively would a redirect from https://links.my-site.com/daily-post/2023-01-01 to a manually built Firebase Dynamic Link work or does this causes any issues with google analytics / google ads communication?

I've tried searching but have not found a clear answer to this question.


问:
Entity doesn't appear sometimes with its texture | Python Ursina
I was making a Windows knockoff meme project for fun until I stumbled upon a devastating error. Here's a cut out of my code

```<code>class DESKTOP(Entity):

    class OPTIONS(Entity):

        def __init__(self):

            super().__init__(
                model='cube',
                scale=Vec2(0.35,0.35),
                texture=load_texture("NymphOS\\SYSTEM\\RES\\Desktop\\opt.jpg"),
                position=Vec2(-6.75,-3.75),
            )

    class TASKBAR(Entity):

        def __init__(self):

            super().__init__(
                model='cube',
                scale=Vec2(14.3,0.5),
                color=color.gray,
                y=-3.75,
            )

    class BACKGROUND(Entity):

        def __init__(self):

            super().__init__(
                model='cube',
                scale=Vec2(14.3,8),
                texture=WALLPAPER,
            )
</code>```

Now, all Classes spawn the according Entity when called. But when calling the OPTIONS() class, SOMETIMES an Entity spawns and sometimes it just doesn't spawn. What's crucial is that if I remove the texture=foobar part, then the Entity spawns as normal. When moving the Entity up a bit I discovered that the texture seems to be blocked by the taskbar Entity for some reason. How can I set the texture to the foreground?

I tried going from texture=load_texture("bla\bla\bla.jpg") to texture=WALLPAPER and I tried converting to png. What I'm trying to do is make the Options button appear on top of the taskbar entity. When there's no texture assigned the options button works normal but when there is it just moves to the background and gets blocked off

Body:
I was making a Windows knockoff meme project for fun until I stumbled upon a devastating error. Here's a cut out of my code

class DESKTOP(Entity):

    class OPTIONS(Entity):

        def __init__(self):

            super().__init__(
                model='cube',
                scale=Vec2(0.35,0.35),
                texture=load_texture("NymphOS\\SYSTEM\\RES\\Desktop\\opt.jpg"),
                position=Vec2(-6.75,-3.75),
            )

    class TASKBAR(Entity):

        def __init__(self):

            super().__init__(
                model='cube',
                scale=Vec2(14.3,0.5),
                color=color.gray,
                y=-3.75,
            )

    class BACKGROUND(Entity):

        def __init__(self):

            super().__init__(
                model='cube',
                scale=Vec2(14.3,8),
                texture=WALLPAPER,
            )

Now, all Classes spawn the according Entity when called. But when calling the OPTIONS() class, SOMETIMES an Entity spawns and sometimes it just doesn't spawn. What's crucial is that if I remove the texture=foobar part, then the Entity spawns as normal. When moving the Entity up a bit I discovered that the texture seems to be blocked by the taskbar Entity for some reason. How can I set the texture to the foreground?

I tried going from texture=load_texture("bla\bla\bla.jpg") to texture=WALLPAPER and I tried converting to png. What I'm trying to do is make the Options button appear on top of the taskbar entity. When there's no texture assigned the options button works normal but when there is it just moves to the background and gets blocked off


问:
How to configure ejabberd to use SQL Server with integrated authentication?
I currently am using ejabberd connected to a Microsoft SQL Server database. I am using a SQL Server login with username/password, per the documentation here: https://docs.ejabberd.im/admin/configuration/database/#microsoft-sql-server

How can I configure the ejabberd SQL Server storage to use SQL Server integrated security instead? I've not found documentation yet to address this.

A couple of ideas I have are to have the ejabberd service run as a kerberos/AD account, and configure the sql_server option as an ODBC connection string and use the integrated security option.  Or to define the sql_username as the integrated login name, but remove the sql_password option.

Has anyone else tried doing this?


问:
Flutter - Feed with future builder is not updated on the first build of the screen, only after scrolling
I am building an application in flutter which include a feed of posts, where each post is a card, and each post can be liked by user. The build of the screen depends on future builder that get the collections from posts from Firestore, but something weird is happening : On the first build of the screen, the variable "isliked" (by specific user) of a post is not updated, even all the variables are loaded as it has to be, causing the like icone to be wrong (filled when liked, empty else). After scrolling through the posts, the variable is updated and also the like icon.

The code of the feed :

```<code>Widget build(BuildContext context) {
    return FutureBuilder(
      future: context.watch<Storage>().getAllPosts(context.read<AuthNotifier>().user!.uid),
      builder: (context, snapshot) {
        if (snapshot.hasError) {
          return Scaffold(
              body: Center(
                  child: Text(snapshot.error.toString(),
                      textDirection: TextDirection.ltr)
              )
          );
        }
        if (snapshot.connectionState == ConnectionState.done) {
          return  Scaffold(
              body: Padding(
                padding: const EdgeInsets.all(8.0),
                child: ListView.builder(
                  itemCount: snapshot.data?.length,
                  itemBuilder: (BuildContext context, int index) {
                    for (var element in snapshot.data!) {
                      print('hello - ${element.is_liked}');
                    }

                    return Padding  (
                        padding: const EdgeInsets.all(8.0),
                        child: PostWidget(
                            snapshot: snapshot,
                            index: index,
                            isliked : snapshot.data![index].is_liked)
                    );
                  },

                ),
              )
          );
        }
</code>```

And the post widget:

```<code>Widget build(BuildContext context) {
    print('helllooooo ${widget.isliked}');
    print(widget.snapshot.data?[widget.index].is_liked);
    return Card(
        elevation: 4,
        shadowColor: Colors.black,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10),
        ),
        child: Column(
            children: [
              [Some text widgets]

              Row(
                children: [
                  IconButton (
                      onPressed: () async {
                        if(widget.isliked){
                          await context.read<Storage>().removeLike(widget.snapshot.data![widget.index].id, context.read<AuthNotifier>().user!.uid);
                          setState(() {
                            widget.isliked = false;
                            widget.snapshot.data![widget.index].likes --;
                          });
                        }
                        else {
                          await context.read<Storage>().addLike(widget.snapshot.data![widget.index].id, context.read<AuthNotifier>().user!.uid);
                          setState(() {
                            widget.isliked = true;
                            widget.snapshot.data![widget.index].likes ++;
                          });
                        }
                      },
                      icon: Icon (
                        widget.isliked ? Icons.thumb_up : Icons.thumb_up_outlined,
                        color: Colors.blue,)),
                  Text(widget.snapshot.data![widget.index].likes.toString()),
</code>```

When I try to put the post widget into the feed, the problem disappear, but for all press on like button I have to rebuild the entire feed screen, which is not appreciable by user, and also problematic because the transaction that update the like can take more time than rebuild the screen.

Body:
I am building an application in flutter which include a feed of posts, where each post is a card, and each post can be liked by user. The build of the screen depends on future builder that get the collections from posts from Firestore, but something weird is happening : On the first build of the screen, the variable "isliked" (by specific user) of a post is not updated, even all the variables are loaded as it has to be, causing the like icone to be wrong (filled when liked, empty else). After scrolling through the posts, the variable is updated and also the like icon.

The code of the feed :

Widget build(BuildContext context) {
    return FutureBuilder(
      future: context.watch<Storage>().getAllPosts(context.read<AuthNotifier>().user!.uid),
      builder: (context, snapshot) {
        if (snapshot.hasError) {
          return Scaffold(
              body: Center(
                  child: Text(snapshot.error.toString(),
                      textDirection: TextDirection.ltr)
              )
          );
        }
        if (snapshot.connectionState == ConnectionState.done) {
          return  Scaffold(
              body: Padding(
                padding: const EdgeInsets.all(8.0),
                child: ListView.builder(
                  itemCount: snapshot.data?.length,
                  itemBuilder: (BuildContext context, int index) {
                    for (var element in snapshot.data!) {
                      print('hello - ${element.is_liked}');
                    }

                    return Padding  (
                        padding: const EdgeInsets.all(8.0),
                        child: PostWidget(
                            snapshot: snapshot,
                            index: index,
                            isliked : snapshot.data![index].is_liked)
                    );
                  },

                ),
              )
          );
        }

And the post widget:

Widget build(BuildContext context) {
    print('helllooooo ${widget.isliked}');
    print(widget.snapshot.data?[widget.index].is_liked);
    return Card(
        elevation: 4,
        shadowColor: Colors.black,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10),
        ),
        child: Column(
            children: [
              [Some text widgets]

              Row(
                children: [
                  IconButton (
                      onPressed: () async {
                        if(widget.isliked){
                          await context.read<Storage>().removeLike(widget.snapshot.data![widget.index].id, context.read<AuthNotifier>().user!.uid);
                          setState(() {
                            widget.isliked = false;
                            widget.snapshot.data![widget.index].likes --;
                          });
                        }
                        else {
                          await context.read<Storage>().addLike(widget.snapshot.data![widget.index].id, context.read<AuthNotifier>().user!.uid);
                          setState(() {
                            widget.isliked = true;
                            widget.snapshot.data![widget.index].likes ++;
                          });
                        }
                      },
                      icon: Icon (
                        widget.isliked ? Icons.thumb_up : Icons.thumb_up_outlined,
                        color: Colors.blue,)),
                  Text(widget.snapshot.data![widget.index].likes.toString()),

When I try to put the post widget into the feed, the problem disappear, but for all press on like button I have to rebuild the entire feed screen, which is not appreciable by user, and also problematic because the transaction that update the like can take more time than rebuild the screen.


问:
In OAS3.0, Can you set the required fields in a request body of fields in a "oneOf" or "anyOf"
This question relates to Open API spec 3 and writing API specifications.

I have been trying to work out how to set fields as required for a specific method requestBody when I am using a "oneOf" in a schema object.

I know how to set required fields of a referenced object, but when you try set the required properties of oneOf objects the same way, it does not work.

I also know that I can set the required fields in the schema object itself, however I do not want to do this as the required fields differ on each method (i.e all fields required for a post, but only some required for a patch).

So essentially, how do I set the required fields in a request body of a schema used in oneOf?

I have created an example below, in it, I want to:

Set the fields Bird - wingSpan and beakLength as required in the Post method

Set the fields Cat - tailLength as required in the Post method

Not have any required fields for Bird and Cat in the Patch method.

```<code>openapi: 3.0.3
servers:
  - description: SwaggerHub API Auto Mocking
    url: https://virtserver.swaggerhub.com/Enable-Networks/TroubleTicket/1.0.0

info:
  title: Pet API
  version: 1.0.0

paths:
  /pet:
    patch:
      summary: Update a pet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/Pet"
                - type: object
                  required:
                    - age
      responses:
        "204":
          description: The request was a success and the pet was successfully created.

    post:
      summary: Create a pet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/Pet"
                - type: object
                  required:
                    - name
                    - age
                    - species
                  properties:
                    species:
                      type: object
                      required:
                        - ???
      responses:
        "204":
          description: The request was a success and the pet was successfully created.

components:
  schemas:
    Cat:
      type: object
      properties:
        tailLength:
          type: integer
        whiskerLength:
          type: integer
    Bird:
      type: object
      properties:
        wingSpan:
          type: integer
        beakLength:
          type: integer
        highestAltitude:
          type: integer

    Pet:
      type: object
      properties:
        name:
          type: string
        age:
          type: string
        species:
          oneOf:
            - $ref: '#/components/schemas/Cat'
            - $ref: '#/components/schemas/Bird'
</code>```

Any help on this would be appreciated!

I have read the documentation 10x, tried everything from discriminators to not using refs.

I have tried many different combinations of the below and still nothing works.

```<code> requestBody:
    required: true
    content:
      application/json:
        schema:
          allOf:
            - $ref: "#/components/schemas/Pet"
            - type: object
              required:
                - name
                - age
                - species
              properties:
                species:
                  type: object
                  required:
                    - ???
</code>```

Body:
This question relates to Open API spec 3 and writing API specifications.

I have been trying to work out how to set fields as required for a specific method requestBody when I am using a "oneOf" in a schema object.

I know how to set required fields of a referenced object, but when you try set the required properties of oneOf objects the same way, it does not work.

I also know that I can set the required fields in the schema object itself, however I do not want to do this as the required fields differ on each method (i.e all fields required for a post, but only some required for a patch).

So essentially, how do I set the required fields in a request body of a schema used in oneOf?

I have created an example below, in it, I want to:

Set the fields Bird - wingSpan and beakLength as required in the Post method

Set the fields Cat - tailLength as required in the Post method

Not have any required fields for Bird and Cat in the Patch method.

openapi: 3.0.3
servers:
  - description: SwaggerHub API Auto Mocking
    url: https://virtserver.swaggerhub.com/Enable-Networks/TroubleTicket/1.0.0

info:
  title: Pet API
  version: 1.0.0

paths:
  /pet:
    patch:
      summary: Update a pet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/Pet"
                - type: object
                  required:
                    - age
      responses:
        "204":
          description: The request was a success and the pet was successfully created.

    post:
      summary: Create a pet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/Pet"
                - type: object
                  required:
                    - name
                    - age
                    - species
                  properties:
                    species:
                      type: object
                      required:
                        - ???
      responses:
        "204":
          description: The request was a success and the pet was successfully created.

components:
  schemas:
    Cat:
      type: object
      properties:
        tailLength:
          type: integer
        whiskerLength:
          type: integer
    Bird:
      type: object
      properties:
        wingSpan:
          type: integer
        beakLength:
          type: integer
        highestAltitude:
          type: integer

    Pet:
      type: object
      properties:
        name:
          type: string
        age:
          type: string
        species:
          oneOf:
            - $ref: '#/components/schemas/Cat'
            - $ref: '#/components/schemas/Bird'

Any help on this would be appreciated!

I have read the documentation 10x, tried everything from discriminators to not using refs.

I have tried many different combinations of the below and still nothing works.

 requestBody:
    required: true
    content:
      application/json:
        schema:
          allOf:
            - $ref: "#/components/schemas/Pet"
            - type: object
              required:
                - name
                - age
                - species
              properties:
                species:
                  type: object
                  required:
                    - ???


问:
Error when passing Spark SQL higher order functions lambda variable to custom SQL user defined function (UDF)
I have created a SQL UDF which takes one string parameter and returns string.

Reference doc : https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-create-sql-function.html#parameters

I am trying to use this function inside Spark SQL's array_transform method.

SQL UDF function DDL

```<code>CREATE or REPLACE FUNCTION printStr(str String )
  RETURNS STRING
  COMMENT 'print given string'
  LANGUAGE SQL
  RETURN str
</code>```

Temp view to test SQL UDF

```<code>CREATE or REPLACE TEMP VIEW values AS
select * from values (array("1","2","3")),(array("2","3","5")),(array("3","44"))
</code>```

Calling this SQL UDF inside Spark SQL's array_transform method.

select transform(col1, val -> printStr(val)) from VALUES

Exception: (Spark version - 3.2.1, Scala - 2.12, Databricks runtime - 10.4 LTS)

```<code>Error in SQL statement: AnalysisException: Resolved attribute(s) val#1298163 missing from  in operator !Project [cast(lambda val#1298163 as string) AS str#1298165].; line 1 pos 30

com.databricks.backend.common.rpc.DatabricksExceptions$SQLExecutionException: org.apache.spark.sql.AnalysisException: Resolved attribute(s) val#1298163 missing from  in operator !Project [cast(lambda val#1298163 as string) AS str#1298165].; line 1 pos 30
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.failAnalysis(CheckAnalysis.scala:60)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.failAnalysis$(CheckAnalysis.scala:59)
    at org.apache.spark.sql.catalyst.analysis.Analyzer.failAnalysis(Analyzer.scala:225)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$2(CheckAnalysis.scala:533)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$2$adapted(CheckAnalysis.scala:105)
    at org.apache.spark.sql.catalyst.trees.TreeNode.foreachUp(TreeNode.scala:358)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$foreachUp$1(TreeNode.scala:357)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$foreachUp$1$adapted(TreeNode.scala:357)
    at scala.collection.Iterator.foreach(Iterator.scala:943)
    at scala.collection.Iterator.foreach$(Iterator.scala:943)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
    at scala.collection.IterableLike.foreach(IterableLike.scala:74)
    at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
    at org.apache.spark.sql.catalyst.trees.TreeNode.foreachUp(TreeNode.scala:357)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$1(CheckAnalysis.scala:105)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at com.databricks.spark.util.FrameProfiler$.record(FrameProfiler.scala:80)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.checkAnalysis(CheckAnalysis.scala:100)

</code>```

Am guessing namedLambdaVariable is not getting resolved inside SQL UDf's

Body:
I have created a SQL UDF which takes one string parameter and returns string.

Reference doc : https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-create-sql-function.html#parameters

I am trying to use this function inside Spark SQL's array_transform method.

SQL UDF function DDL

CREATE or REPLACE FUNCTION printStr(str String )
  RETURNS STRING
  COMMENT 'print given string'
  LANGUAGE SQL
  RETURN str

Temp view to test SQL UDF

CREATE or REPLACE TEMP VIEW values AS
select * from values (array("1","2","3")),(array("2","3","5")),(array("3","44"))

Calling this SQL UDF inside Spark SQL's array_transform method.

select transform(col1, val -> printStr(val)) from VALUES

Exception: (Spark version - 3.2.1, Scala - 2.12, Databricks runtime - 10.4 LTS)

Error in SQL statement: AnalysisException: Resolved attribute(s) val#1298163 missing from  in operator !Project [cast(lambda val#1298163 as string) AS str#1298165].; line 1 pos 30

com.databricks.backend.common.rpc.DatabricksExceptions$SQLExecutionException: org.apache.spark.sql.AnalysisException: Resolved attribute(s) val#1298163 missing from  in operator !Project [cast(lambda val#1298163 as string) AS str#1298165].; line 1 pos 30
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.failAnalysis(CheckAnalysis.scala:60)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.failAnalysis$(CheckAnalysis.scala:59)
    at org.apache.spark.sql.catalyst.analysis.Analyzer.failAnalysis(Analyzer.scala:225)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$2(CheckAnalysis.scala:533)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$2$adapted(CheckAnalysis.scala:105)
    at org.apache.spark.sql.catalyst.trees.TreeNode.foreachUp(TreeNode.scala:358)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$foreachUp$1(TreeNode.scala:357)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$foreachUp$1$adapted(TreeNode.scala:357)
    at scala.collection.Iterator.foreach(Iterator.scala:943)
    at scala.collection.Iterator.foreach$(Iterator.scala:943)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
    at scala.collection.IterableLike.foreach(IterableLike.scala:74)
    at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
    at org.apache.spark.sql.catalyst.trees.TreeNode.foreachUp(TreeNode.scala:357)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.$anonfun$checkAnalysis$1(CheckAnalysis.scala:105)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at com.databricks.spark.util.FrameProfiler$.record(FrameProfiler.scala:80)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis.checkAnalysis(CheckAnalysis.scala:100)

Am guessing namedLambdaVariable is not getting resolved inside SQL UDf's


问:
Package install includes Groovy and Kotlin but no Java
I will install Applovin in my React native project. The installation documentation includes Groovy and Kotlin. Should I consider the locations described for Groovy when installing in my own project?


问:
Insert generated URL into python script after authorization
I would like to know how to render a newly generated URL to my Python script without manually copy and pasting it.

I am being redirected from my script to the web page where I need to authenticate.
I want after I authenticate on a page that the new link is passed to the script.

Specifically, this is an OAuth1 process. This link is used to get my access token.

Thanks in advance!

If I copy and paste the link, i can perfectly get all the information and connect, but this is manually.


问:
Apollo Client : (Query) get 400 error response
I am working on a project using React and GraphQL. This is my first time using Apollo client, and I encountered a problem when I tried using the useQuery hook on this query.

getAllUsers query

```<code>query {
        getAllUsers {
            rows {
                    username
                    email
                    group_id
                    created_dtm
                    status
            }
        }
    }
</code>```

implemented it in the code like this:

Table.js (Component)

```<code>import React, { useState } from "react";
import { useMutation } from "@apollo/client";
import { Table, Button } from "react-bootstrap";

import ModalEdit from "./Modals/ModalEdit";
import { DELETE_USER } from "../../gql/mutation";
import { useHistory } from "react-router-dom";

const TableUserInfo = ({ users }) => {
  const history = useHistory();

  // fetch all user data
  const usersList = users ? users.getAllUsers : [];

  // show modals

  const [showModal, setShowModal] = useState(false);

  // get username as id
  const [username, setUsername] = useState('');

  const handleShowModal = () => setShowModal(true);
  const handleCloseModal = () => setShowModal(false);

  // delete user
  const [deleteUser] = useMutation(DELETE_USER, {
    variables: {
      username
    },
    refetchQueries: [{ query: usersList }],
    onCompleted: data => {
      history.push('/konfigurasi/pengaturan-pengguna')
    },
    onError: err => {
      console.error(err)
    }
  })

  return (
    <Table responsive>
      <thead>
        <tr>
          <th>No</th>
          <th>Nama Pengguna</th>
          <th>Role Akun</th>
          <th>Email</th>
          <th>Tanggal Daftar</th>
          <th>Status Akun</th>
          <th>Pengaturan</th>
        </tr>
      </thead>
      <tbody>
        {usersList.rows.map((user) => (
          <tr key={user.username}>

            <td>{user.username}</td>
            <td>{user.group_id}</td>
            <td>{user.email}</td>
            <td>{user.created_dtm}</td>
            <td>{user.status}</td>
            <td>
              {user.status !== "ACTIVE"
                ? [
                    <Button key="Aktifkan Akun" className="d-block mb-2 text-white bg-secondary w-100">
                      Aktifkan Akun
                    </Button>,
                    <Button
                      key="Ganti Role Akun"
                      className="d-block mb-2 btn-block btn-sm w-100"
                      disabled
                    >
                      Ganti Role Akun
                    </Button>,
                  ]
                : user.group_id === "admin"
                ? [
                    <Button key="Ganti Role Akun" variant="outline-success" className="d-block btn-sm mb-2 w-100">
                      Ganti Role Akun
                    </Button>,
                  ]
                : [
                    <Button key="Pilih Role Akun" className="d-block btn-sm mb-2 w-100">
                      Pilih Role Akun
                    </Button>,
                  ]}
              <Button key="Edit" variant="outline-primary" onClick={() => { setShowModal(true); setUsername(user.username); }} className="d-block btn-block btn-sm mb-2 w-100">
                Edit
              </Button>
              <Button key="Hapus" variant="outline-danger" onClick={deleteUser} className="d-block btn-block btn-sm mb-2 w-100">
                Hapus
              </Button>
            </td>
          </tr>
        ))}
      </tbody>
          {
            showModal ? (
              <ModalEdit show={handleShowModal} onClose={handleCloseModal} username={username}/>
            ) : null
          }
    </Table>
  );
};

export default TableUserInfo;
</code>```

index.js (page)

```<code>import React from 'react';
import { useQuery } from '@apollo/client';
import { Container, Card, Button, InputGroup, FormControl, Form } from 'react-bootstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSearch } from '@fortawesome/fontawesome-free-solid';

import CardInfo from '../../../component/PengaturanPengguna/CardInfo';
import TableUserInfo from '../../../component/PengaturanPengguna/Table';

import { GET_ALL_USERS } from '../../../gql/query';
import { Loading } from '../../../component/Common';

const SearchInput = () => {
    return (
        <InputGroup className="mb-3">
            <InputGroup.Text>
                <FontAwesomeIcon icon={faSearch} />
            </InputGroup.Text>
            <FormControl
                type="text"
                placeholder="Search..."
            />
      </InputGroup>
    )
}

const PengaturanPengguna = () => {
    const { data: usersdata, loading: usersloading, error: userserror } = useQuery(GET_ALL_USERS);
    const { refetch, loading } = useQuery(GET_ALL_USERS);

    const handleRefreshClick = () => {
        refetch();
    }

    if (usersloading) return <Loading/>
    if (userserror) return <p>{userserror.message}</p>

    return (
        <Container>
            <CardInfo/>
            <Card>
                <Card.Title>
                    <span className='base-md text-regular mt-2 std-txt-primary-200'>Data Pengguna Dashboard</span>
                </Card.Title>
                <Card.Body>
                    <div className='d-flex justify-content-between'>
                        <Form inline>
                            <SearchInput/>
                            <Button variant='secondary' onClick={handleRefreshClick} disabled={loading}>{loading ? 'Loading...' : 'Muat Ulang'}</Button>
                        </Form>
                        <div>
                            <Button variant='success'>Daftar Akun</Button>
                        </div>
                    </div>
                    <TableUserInfo users={usersdata}/>
                </Card.Body>
            </Card>
        </Container>
    )
}

export default PengaturanPengguna;
</code>```

but I received this error

Here is the server response for success:

```<code>{
  "data": {
    "getAllUsers": {
      "rows": [
        {
          "username": "alexis",
          "email": "alexiasdasds@gdasdfl.com",
          "group_id": "super admin",
          "created_dtm": "2022-09-21T19:55:31.162Z",
          "status": "ACTIVE"
        },
        {
          "username": "husni",
          "email": "husasdni@sadasda.id",
          "group_id": "admin",
          "created_dtm": "2022-10-10T02:10:13.821Z",
          "status": "ACTIVE"
        },
      ]
    }
  }
}
</code>```

I have tried various methods, but I still get the same error. any help will be appreciated. thank you

Body:
I am working on a project using React and GraphQL. This is my first time using Apollo client, and I encountered a problem when I tried using the useQuery hook on this query.

getAllUsers query

query {
        getAllUsers {
            rows {
                    username
                    email
                    group_id
                    created_dtm
                    status
            }
        }
    }

implemented it in the code like this:

Table.js (Component)

import React, { useState } from "react";
import { useMutation } from "@apollo/client";
import { Table, Button } from "react-bootstrap";

import ModalEdit from "./Modals/ModalEdit";
import { DELETE_USER } from "../../gql/mutation";
import { useHistory } from "react-router-dom";

const TableUserInfo = ({ users }) => {
  const history = useHistory();

  // fetch all user data
  const usersList = users ? users.getAllUsers : [];

  // show modals

  const [showModal, setShowModal] = useState(false);

  // get username as id
  const [username, setUsername] = useState('');

  const handleShowModal = () => setShowModal(true);
  const handleCloseModal = () => setShowModal(false);

  // delete user
  const [deleteUser] = useMutation(DELETE_USER, {
    variables: {
      username
    },
    refetchQueries: [{ query: usersList }],
    onCompleted: data => {
      history.push('/konfigurasi/pengaturan-pengguna')
    },
    onError: err => {
      console.error(err)
    }
  })

  return (

          No
          Nama Pengguna
          Role Akun
          Email
          Tanggal Daftar
          Status Akun
          Pengaturan

        {usersList.rows.map((user) => (

            {user.username}
            {user.group_id}
            {user.email}
            {user.created_dtm}
            {user.status}

              {user.status !== "ACTIVE"
                ? [
                    <Button key="Aktifkan Akun" className="d-block mb-2 text-white bg-secondary w-100">
                      Aktifkan Akun
                    </Button>,
                    <Button
                      key="Ganti Role Akun"
                      className="d-block mb-2 btn-block btn-sm w-100"
                      disabled
                    >
                      Ganti Role Akun
                    </Button>,
                  ]
                : user.group_id === "admin"
                ? [
                    <Button key="Ganti Role Akun" variant="outline-success" className="d-block btn-sm mb-2 w-100">
                      Ganti Role Akun
                    </Button>,
                  ]
                : [
                    <Button key="Pilih Role Akun" className="d-block btn-sm mb-2 w-100">
                      Pilih Role Akun
                    </Button>,
                  ]}
              <Button key="Edit" variant="outline-primary" onClick={() => { setShowModal(true); setUsername(user.username); }} className="d-block btn-block btn-sm mb-2 w-100">
                Edit
              </Button>
              <Button key="Hapus" variant="outline-danger" onClick={deleteUser} className="d-block btn-block btn-sm mb-2 w-100">
                Hapus
              </Button>

        ))}

          {
            showModal ? (
              <ModalEdit show={handleShowModal} onClose={handleCloseModal} username={username}/>
            ) : null
          }

  );
};

export default TableUserInfo;

index.js (page)

import React from 'react';
import { useQuery } from '@apollo/client';
import { Container, Card, Button, InputGroup, FormControl, Form } from 'react-bootstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSearch } from '@fortawesome/fontawesome-free-solid';

import CardInfo from '../../../component/PengaturanPengguna/CardInfo';
import TableUserInfo from '../../../component/PengaturanPengguna/Table';

import { GET_ALL_USERS } from '../../../gql/query';
import { Loading } from '../../../component/Common';

const SearchInput = () => {
    return (
        <InputGroup className="mb-3">
            <InputGroup.Text>
                <FontAwesomeIcon icon={faSearch} />
            </InputGroup.Text>
            <FormControl
                type="text"
                placeholder="Search..."
            />
      </InputGroup>
    )
}

const PengaturanPengguna = () => {
    const { data: usersdata, loading: usersloading, error: userserror } = useQuery(GET_ALL_USERS);
    const { refetch, loading } = useQuery(GET_ALL_USERS);

    const handleRefreshClick = () => {
        refetch();
    }

    if (usersloading) return <Loading/>
    if (userserror) return
{userserror.message}

    return (
        <Container>
            <CardInfo/>
            <Card>
                <Card.Title>
                    Data Pengguna Dashboard
                </Card.Title>
                <Card.Body>

                        <Form inline>
                            <SearchInput/>
                            <Button variant='secondary' onClick={handleRefreshClick} disabled={loading}>{loading ? 'Loading...' : 'Muat Ulang'}</Button>
                        </Form>

                            <Button variant='success'>Daftar Akun</Button>

                    <TableUserInfo users={usersdata}/>
                </Card.Body>
            </Card>
        </Container>
    )
}

export default PengaturanPengguna;

but I received this error

Here is the server response for success:

{
  "data": {
    "getAllUsers": {
      "rows": [
        {
          "username": "alexis",
          "email": "alexiasdasds@gdasdfl.com",
          "group_id": "super admin",
          "created_dtm": "2022-09-21T19:55:31.162Z",
          "status": "ACTIVE"
        },
        {
          "username": "husni",
          "email": "husasdni@sadasda.id",
          "group_id": "admin",
          "created_dtm": "2022-10-10T02:10:13.821Z",
          "status": "ACTIVE"
        },
      ]
    }
  }
}

I have tried various methods, but I still get the same error. any help will be appreciated. thank you


问:
How can I draw a square onto a grid when clicked with Pygame?
I'm using the code from Python: How to make drawn elements snap to grid in pygame to draw a grid and show a square that snaps onto the grid. The thing is that the square only stays there until you stop clicking, which is not what I want.

So, what I did was changing the code from this:

```<code>def draw(self, surface):
    click = pygame.mouse.get_pressed()
    if click[0]:
        pygame.draw.rect(surface, (255, 255, 255), self.square)
</code>```

To this:

```<code>def draw(self, surface):
    pygame.draw.rect(surface, (255, 255, 255), self.square) #it draws the square without the need to keep the mouse button down
    click = pygame.mouse.get_pressed()
    if click[0]:
        pygame.draw.rect(surface, (255, 255, 255), self.square)
</code>```

And this makes the square follow the cursor and snap onto the grid. But when clicked, it doesn't draw a square into the grid.

So my overall question is, how can I draw a square onto the grid when mouse clicked using the code from the link provided?

Body:
I'm using the code from Python: How to make drawn elements snap to grid in pygame to draw a grid and show a square that snaps onto the grid. The thing is that the square only stays there until you stop clicking, which is not what I want.

So, what I did was changing the code from this:

def draw(self, surface):
    click = pygame.mouse.get_pressed()
    if click[0]:
        pygame.draw.rect(surface, (255, 255, 255), self.square)

To this:

def draw(self, surface):
    pygame.draw.rect(surface, (255, 255, 255), self.square) #it draws the square without the need to keep the mouse button down
    click = pygame.mouse.get_pressed()
    if click[0]:
        pygame.draw.rect(surface, (255, 255, 255), self.square)

And this makes the square follow the cursor and snap onto the grid. But when clicked, it doesn't draw a square into the grid.

So my overall question is, how can I draw a square onto the grid when mouse clicked using the code from the link provided?


问:
Where clauses are not working in flutter GraphQL query?
I'm using GraphQL in flutter project, While fetching data from query working fine but when i use where clauses i get null in response with error RangeError (index): Invalid value: Valid value range is empty: 0. I really need help to find out how to fetch data with where clauses and also to post data with mutation on GraphQl both are not working

```<code>static String LoginInUser(String email, String password) {
return '''
query MyQuery {
login(where: {email: {\_eq: "ali@gmail.com"}, password: {\_eq: "12345"}}) {
id
name
}
}

''';
}
</code>```

I have tried multiple time again and again with different ways but result is same

Body:
I'm using GraphQL in flutter project, While fetching data from query working fine but when i use where clauses i get null in response with error RangeError (index): Invalid value: Valid value range is empty: 0. I really need help to find out how to fetch data with where clauses and also to post data with mutation on GraphQl both are not working

static String LoginInUser(String email, String password) {
return '''
query MyQuery {
login(where: {email: {\_eq: "ali@gmail.com"}, password: {\_eq: "12345"}}) {
id
name
}
}

''';
}

I have tried multiple time again and again with different ways but result is same


问:
Comment a part of a JS script with Babel
I am trying to comment out a function inside a JS code. So far, I am able to add a comment above it, but not comment it completely.

Here is the code I have:

```<code>const babel = require('@babel/core');
const t = require("@babel/types");

const code = `
function greet(name) {
  return 'Hello ' + name;
}
console.log(greet('Bob'));`;

const output = babel.transformSync(code, {
      plugins: [
        function CommentOut() {
          return {
            visitor: {
              FunctionDeclaration(path) {
                t.addComment(path.node, 'leading', 'My first comment');
              }
            }
          }
        }
      ]
    });
</code>```

This is the result I get:

```<code>/*My first comment*/
function greet(name) {
  return 'Hello ' + name;
}
console.log(greet('Bob'));
</code>```

This is what I am looking to achieve:

```<code>/*My first comment
function greet(name) {
  return 'Hello ' + name;
}*/
console.log(greet('Bob'));
</code>```

Body:
I am trying to comment out a function inside a JS code. So far, I am able to add a comment above it, but not comment it completely.

Here is the code I have:

const babel = require('@babel/core');
const t = require("@babel/types");

const code = `
function greet(name) {
  return 'Hello ' + name;
}
console.log(greet('Bob'));`;

const output = babel.transformSync(code, {
      plugins: [
        function CommentOut() {
          return {
            visitor: {
              FunctionDeclaration(path) {
                t.addComment(path.node, 'leading', 'My first comment');
              }
            }
          }
        }
      ]
    });

This is the result I get:

/*My first comment*/
function greet(name) {
  return 'Hello ' + name;
}
console.log(greet('Bob'));

This is what I am looking to achieve:

/*My first comment
function greet(name) {
  return 'Hello ' + name;
}*/
console.log(greet('Bob'));


问:
Dependency not found: please run 'pip3 install pyserial'
So I have been trying to run a program of a ti 84 plus ce. It asks to run this program bridge.py with the command python3 bridge.py. Python version is 3.9, pyserial version is 3.5 (c:\users\megam\appdata\local\programs\python\python39\lib\site-packages\pyserial-3.5-py3.9.egg (3.5)) and pip version is 22.3.1. I have installed everything but whenever I try that command it always gives me this error 'Dependency not found: please run 'pip3 install pyserial'. If anyone knows how to solve this, really thank you.

I tried reistalling and installing a bunch of times but probably messed up things even more.


问:
Flutter: Add a Note count from Firebase Database
Im trying to add a note count next to the "child: Text('Calculus 2)" but it give me a red underline for _noteCount = snapshot.data!.docs; . The result would be to get all note count under 'ACALnotes' and place it next to the calculus 2 text. Is that possible to do?

```<code>import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';

class _AdminScreenState extends State<AdminScreen> {
  final Color backgroundColor;
  int _noteCount = 0;

  @override
  void initState() {
    super.initState();
    _getNoteCount();
  }

  void _getNoteCount() async {
    DocumentReference<Map<String, dynamic>> snapshot =
        FirebaseFirestore.instance.collection('ACALnotes').doc();
    setState(() {
      _noteCount = snapshot.data!.docs;
    });
  }

Row(
  mainAxisAlignment: MainAxisAlignment.start,
  children: [
    const SizedBox(width: 45, child: Icon(Icons.calculate_outlined)),
    Flexible(
      child: Text('Calculus 2 ($_noteCount notes)',
        style: GoogleFonts.roboto(
          color: Colors.black,
          fontWeight: FontWeight.bold,
          fontSize: 18
        ),
      ),
    ),
  ],
),
</code>```

I have tried _noteCount = snapshot.documents.length; but it doesnt seem to work. Currently changed to _noteCount = snapshot.data!.docs; like my home_screen.dart but same issue.

Body:
Im trying to add a note count next to the "child: Text('Calculus 2)" but it give me a red underline for _noteCount = snapshot.data!.docs; . The result would be to get all note count under 'ACALnotes' and place it next to the calculus 2 text. Is that possible to do?

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';

class _AdminScreenState extends State<AdminScreen> {
  final Color backgroundColor;
  int _noteCount = 0;

  @override
  void initState() {
    super.initState();
    _getNoteCount();
  }

  void _getNoteCount() async {
    DocumentReference<Map<String, dynamic>> snapshot =
        FirebaseFirestore.instance.collection('ACALnotes').doc();
    setState(() {
      _noteCount = snapshot.data!.docs;
    });
  }

Row(
  mainAxisAlignment: MainAxisAlignment.start,
  children: [
    const SizedBox(width: 45, child: Icon(Icons.calculate_outlined)),
    Flexible(
      child: Text('Calculus 2 ($_noteCount notes)',
        style: GoogleFonts.roboto(
          color: Colors.black,
          fontWeight: FontWeight.bold,
          fontSize: 18
        ),
      ),
    ),
  ],
),

I have tried _noteCount = snapshot.documents.length; but it doesnt seem to work. Currently changed to _noteCount = snapshot.data!.docs; like my home_screen.dart but same issue.


问:
Checking tags for some aws resources using aws-sdk-go
I want to check whether some aws resources are tagged with certain key and value pairs. I am trying to do this in aws-sdk-go code and I am new to this.
This is the code I tried,

```<code>func TestTagging(t *testing.T) {

region := "us-west-2"

cfg, err := config.LoadDefaultConfig(context.TODO(),
    config.WithRegion(region),
)

if err != nil {
    log.Fatalf("unable to load SDK config, %v", err)
}

// Using the Config value, create the Resource Groups Tagging API client
svc := resourcegroupstaggingapi.NewFromConfig(cfg)
params := &resourcegroupstaggingapi.GetResourcesInput{
    ResourceARNList: []string{
        "arn:aws:eks:XXX:XXX:cluster/XXX",
        "arn:aws:eks:XXX:XXX:nodegroup/XXX/ops-XXX/XXX",
    },
}

resp, err := svc.GetResources(context.TODO(), params)
if err != nil {
    log.Fatalf("failed to list resources, %v", err)
}
for _,res := range resp.ResourceTagMappingList {
    tags_map := map[string]int{"Application" : 0, "Customer" : 0, "Department" : 0, "test" : 0, "Environment" : 0, "Level" : 0, "ManagedBy" : 0, "Name": 0}
    fmt.Println("\n####################")
    fmt.Println(*res.ResourceARN)
    for _,tag := range res.Tags {
        fmt.Println(*tag.Key, *tag.Value)
        if _,ok := tags_map[*tag.Key]; ok {
            tags_map[*tag.Key] = 1
        }

    }
    for k,v := range tags_map {
        if v == 0 {
            fmt.Printf("This resource does not contain the tag %s\n", k)
        }
    }
}
</code>```

}

It works fine.
But I am not sure how I can pass the arns of resources in the params every time. Is there any other better approach to achieve this?

Body:
I want to check whether some aws resources are tagged with certain key and value pairs. I am trying to do this in aws-sdk-go code and I am new to this.
This is the code I tried,

func TestTagging(t *testing.T) {

region := "us-west-2"

cfg, err := config.LoadDefaultConfig(context.TODO(),
    config.WithRegion(region),
)

if err != nil {
    log.Fatalf("unable to load SDK config, %v", err)
}

// Using the Config value, create the Resource Groups Tagging API client
svc := resourcegroupstaggingapi.NewFromConfig(cfg)
params := &resourcegroupstaggingapi.GetResourcesInput{
    ResourceARNList: []string{
        "arn:aws:eks:XXX:XXX:cluster/XXX",
        "arn:aws:eks:XXX:XXX:nodegroup/XXX/ops-XXX/XXX",
    },
}

resp, err := svc.GetResources(context.TODO(), params)
if err != nil {
    log.Fatalf("failed to list resources, %v", err)
}
for _,res := range resp.ResourceTagMappingList {
    tags_map := map[string]int{"Application" : 0, "Customer" : 0, "Department" : 0, "test" : 0, "Environment" : 0, "Level" : 0, "ManagedBy" : 0, "Name": 0}
    fmt.Println("\n####################")
    fmt.Println(*res.ResourceARN)
    for _,tag := range res.Tags {
        fmt.Println(*tag.Key, *tag.Value)
        if _,ok := tags_map[*tag.Key]; ok {
            tags_map[*tag.Key] = 1
        }

    }
    for k,v := range tags_map {
        if v == 0 {
            fmt.Printf("This resource does not contain the tag %s\n", k)
        }
    }
}

}

It works fine.
But I am not sure how I can pass the arns of resources in the params every time. Is there any other better approach to achieve this?


问:
Convert JSON style array string into PostgreSQL array
I'm trying to convert a string that is a JSON-style array into a PostgreSQL array and have not been able to find the syntax I need to do it.

My string looks like this:

```<code>'["Team","Stretch","Regional"]'
</code>```

I know I can do this by replacing the [ and ] with { and } and using ::text[], but I feel like there has to be a better, cleaner way to do this. I've tried multiple JSON manipulation functions and so far haven't had any luck as most of them are designed to work in the context of an object. I'm using Postgres 14.x, for the record.

Body:
I'm trying to convert a string that is a JSON-style array into a PostgreSQL array and have not been able to find the syntax I need to do it.

My string looks like this:

'["Team","Stretch","Regional"]'

I know I can do this by replacing the [ and ] with { and } and using ::text[], but I feel like there has to be a better, cleaner way to do this. I've tried multiple JSON manipulation functions and so far haven't had any luck as most of them are designed to work in the context of an object. I'm using Postgres 14.x, for the record.


问:
HTTP Request for Ruby on Flutter Not Working
The Api request is working on Postman without any issues but with Flutter it is not getting a match

This is my request method that I'm currently using to get the response

```<code>static Future getRequest(
      {required String baseUrl,
      required String path,
      required Map<String, String> headers,
      required Map<String, String> params,
      bool? parsed}) async {
    http.Response response;

response = await http.get(
    Uri.parse(Uri.http(baseUrl, path, params).toString()),
    headers: headers);
print(baseUrl);
print(path);

print(headers.toString());
print(response.body.toString());
if (response.statusCode == HttpStatus.ok) {
  return {
    "header": {"success": true},
    "response": (parsed == null || parsed == true)
        ? json.decode(response.body)
        : response.body
  };
} else {
  return {
    "header": {"success": false},
    "httpCode": response.statusCode
  };
}
}
</code>```

How to send a http request to Ruby from flutter?

Body:
The Api request is working on Postman without any issues but with Flutter it is not getting a match

This is my request method that I'm currently using to get the response

static Future getRequest(
      {required String baseUrl,
      required String path,
      required Map<String, String> headers,
      required Map<String, String> params,
      bool? parsed}) async {
    http.Response response;

response = await http.get(
    Uri.parse(Uri.http(baseUrl, path, params).toString()),
    headers: headers);
print(baseUrl);
print(path);

print(headers.toString());
print(response.body.toString());
if (response.statusCode == HttpStatus.ok) {
  return {
    "header": {"success": true},
    "response": (parsed == null || parsed == true)
        ? json.decode(response.body)
        : response.body
  };
} else {
  return {
    "header": {"success": false},
    "httpCode": response.statusCode
  };
}
}

How to send a http request to Ruby from flutter?


问:
Snowflake tasks combining CRON scheduling (set time) with NON-CRON scheduling (every minute)
Every hour, new data will be loaded in a table. As soon as that is ready I want to call a stored procedure.

Is it possible with Snowflake Tasks and Streams to schedule that starting every hour on the hour, check every minute if the table has new data and if it does, call a stored procedure and stop checking every minute?

At first I thougt about having 1 task with an hourly schedule. The next task would be scheduled every minute and have the hourly task as its predecessor. Unfortunately it is not possible for a task to have both a predecessor and a schedule. What would be a way to create this kind of scheduling?

For example

```<code>    CREATE OR REPLACE TASK tsk_X_X_1
        WAREHOUSE = X
        SCHEDULE = 'USING CRON 0 1 * * * UTC'
        AS INSERT INTO XX.Test SELECT 'hourly', sysdate()
    ;

    CREATE OR REPLACE TASK tsk_X_X_2
        WAREHOUSE = X
        SCHEDULE = '5 minutes'
        AFTER TASK tsk_X_X_1
        As INSERT INTO XX.Testing SELECT '5min', sysdate()
    ;
</code>```

Error: Task TSK_X_X_2 cannot have both a schedule and a predecessor.

Body:
Every hour, new data will be loaded in a table. As soon as that is ready I want to call a stored procedure.

Is it possible with Snowflake Tasks and Streams to schedule that starting every hour on the hour, check every minute if the table has new data and if it does, call a stored procedure and stop checking every minute?

At first I thougt about having 1 task with an hourly schedule. The next task would be scheduled every minute and have the hourly task as its predecessor. Unfortunately it is not possible for a task to have both a predecessor and a schedule. What would be a way to create this kind of scheduling?

For example

    CREATE OR REPLACE TASK tsk_X_X_1
        WAREHOUSE = X
        SCHEDULE = 'USING CRON 0 1 * * * UTC'
        AS INSERT INTO XX.Test SELECT 'hourly', sysdate()
    ;

    CREATE OR REPLACE TASK tsk_X_X_2
        WAREHOUSE = X
        SCHEDULE = '5 minutes'
        AFTER TASK tsk_X_X_1
        As INSERT INTO XX.Testing SELECT '5min', sysdate()
    ;

Error: Task TSK_X_X_2 cannot have both a schedule and a predecessor.


问:
Emojis in the dataset cause problems when editing the irregular dataset and exporting it to txt file
I'm stuck while editing the irregular data set and exporting to txt file.

Here is my code and data set;

```<code>import re

liste = []
with open("magaza_yorumlari_duygu_analizi (1).csv", "r", encoding='utf-16') as f:
    liste = f.readlines()
    f.close()

metin = ""
for satir in liste:
    metin += satir

metin = metin.replace("\n", "")
metin = metin.replace(",Olumsuz", "#0#")
metin = metin.replace(",Olumlu", "#1#")
metin = metin.replace(",Tarafsız", "#2#")
# print(metin)

spt = re.split("#[0-2]#", metin)
etiketler = []

for gorus in spt:
    inx = metin.find(gorus)
    etiketler.append(metin[inx+len(gorus):inx+len(gorus)+3])

with open("sinav_veri_seti.txt", "a") as f:
    for k in range(len(spt)):
        f.write(spt[k]+";;"+etiketler[k]+"\n")
    f.close()
</code>```

I can't use "utf-8" cause it's not supporting emoji(yes there is emoji in data set).

Error code;
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f44d' in position 42: character maps to

I can't upload the .csv file to here because it's above the 3mb.
https://s6.dosya.tc/server11/97vwee/magaza_yorumlari_duygu_analizi__1_.csv.html
I uploaded the data set file to another website.

Anyone can help me about this?

I tried to editing the data set file(.csv).
I want to removing the emoji from the data set so I can edit the data set without any problems.

Body:
I'm stuck while editing the irregular data set and exporting to txt file.

Here is my code and data set;

import re

liste = []
with open("magaza_yorumlari_duygu_analizi (1).csv", "r", encoding='utf-16') as f:
    liste = f.readlines()
    f.close()

metin = ""
for satir in liste:
    metin += satir

metin = metin.replace("\n", "")
metin = metin.replace(",Olumsuz", "#0#")
metin = metin.replace(",Olumlu", "#1#")
metin = metin.replace(",Tarafsız", "#2#")
# print(metin)

spt = re.split("#[0-2]#", metin)
etiketler = []

for gorus in spt:
    inx = metin.find(gorus)
    etiketler.append(metin[inx+len(gorus):inx+len(gorus)+3])

with open("sinav_veri_seti.txt", "a") as f:
    for k in range(len(spt)):
        f.write(spt[k]+";;"+etiketler[k]+"\n")
    f.close()

I can't use "utf-8" cause it's not supporting emoji(yes there is emoji in data set).

Error code;
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f44d' in position 42: character maps to

I can't upload the .csv file to here because it's above the 3mb.
https://s6.dosya.tc/server11/97vwee/magaza_yorumlari_duygu_analizi__1_.csv.html
I uploaded the data set file to another website.

Anyone can help me about this?

I tried to editing the data set file(.csv).
I want to removing the emoji from the data set so I can edit the data set without any problems.


问:
SvelteKit page only returning redirect
My SvelteKit page seems to only ever return

```<code><meta http-equiv="refresh" content="0;url=/">
</code>```

When it should return my HTML (which comes from the Svelte component:

```<code><script lang="ts">
    import Notebook from "svelte-material-icons/Notebook.svelte";

    export const ssr = false;
    export const prerender = false;
</script>

<main>
    <section class="buttons">
        <a href="/something">
            <Notebook size="30"/>

        </a>
    </section>
</main>

<style lang="less">
    @import '../../styles/variables.less';
    /* some styles */
</style>

</code>```

)

It works fine on localhost, returning the correct HTML, but not on my production build.

I set up lots of logs around the page, in handle in hooks.server.ts, load in +layout.server.ts etc. and none of them are reached when I request that page, although logs in the wrapper Express server are reached correctly. I have also tried directly requesting the page with Postman and same result.

In +layout.server.ts I do have

console.log(`User '${ username }' failed to authenticate`);
throw redirect(307, '/');
```
<p>however it shouldn't be reached, and doesn't get reached on localhost, and the status code of the requested page with the redirect is 200 not 307, and I don't ever see the log, so I'm not sure how this could be the cause.</p>
<p>I can only think that SvelteKit is SSR/caching this page, however I have</p>
<pre class="lang-js prettyprint-override"><code>export const ssr = false;
export const prerender = false;
</code>```

on the page, in +layout.svelte, hooks.server.ts and +layout.server.svelte, so I'm not sure what else I can do?

I'm running the SvelteKit server on CentOS and the dev server on Ubuntu, with:

        "svelte": "^3.55.0",
        "svelte-check": "^2.7.1",
        "svelte-preprocess": "^4.10.7",
        "vite": "^4.0.0"
```
<p>My <code>svelte.config.js</code>:</p>
<pre class="lang-js prettyprint-override"><code>import adapter from '@sveltejs/adapter-node';
import preprocess from 'svelte-preprocess';

const config = {
    // Consult https://github.com/sveltejs/svelte-preprocess
    // for more information about preprocessors
    preprocess: preprocess(),

    kit: {
        adapter: adapter(),
        prerender: { entries: [] }
    }
};

export default config;
</code>```

Title: SvelteKit page only returning redirect

Body:
My SvelteKit page seems to only ever return

<meta http-equiv="refresh" content="0;url=/">

When it should return my HTML (which comes from the Svelte component:

            <Notebook size="30"/>

)

It works fine on localhost, returning the correct HTML, but not on my production build.

I set up lots of logs around the page, in handle in hooks.server.ts, load in +layout.server.ts etc. and none of them are reached when I request that page, although logs in the wrapper Express server are reached correctly. I have also tried directly requesting the page with Postman and same result.

In +layout.server.ts I do have

console.log(`User '${ username }' failed to authenticate`);
throw redirect(307, '/');

however it shouldn't be reached, and doesn't get reached on localhost, and the status code of the requested page with the redirect is 200 not 307, and I don't ever see the log, so I'm not sure how this could be the cause.

I can only think that SvelteKit is SSR/caching this page, however I have

export const ssr = false;
export const prerender = false;

on the page, in +layout.svelte, hooks.server.ts and +layout.server.svelte, so I'm not sure what else I can do?

I'm running the SvelteKit server on CentOS and the dev server on Ubuntu, with:

        "svelte": "^3.55.0",
        "svelte-check": "^2.7.1",
        "svelte-preprocess": "^4.10.7",
        "vite": "^4.0.0"

My svelte.config.js:

import adapter from '@sveltejs/adapter-node';
import preprocess from 'svelte-preprocess';

const config = {
    // Consult https://github.com/sveltejs/svelte-preprocess
    // for more information about preprocessors
    preprocess: preprocess(),

    kit: {
        adapter: adapter(),
        prerender: { entries: [] }
    }
};

export default config;


问:
Reveal animated background for specified text spans on mouse hover

Goal

A hero section with text

The hero text contains spans

A circle follows the mouse position

Where the circle overlaps the spans, an animated background is revealed

All other text remains black, even if they are within the circle

Ideally, I'd like to use a single animated background that is shared across all spans

Mockup

I can't figure out how to set up the HTML and CSS for this.

What I have So Far

I got a part of it working, though it's in a round-about way and I'm not sure the approach will let me continue on toward the desired goal.

The solution uses a background image applied to the heading text with background-clip: text;. If I'm not mistaken, this approach won't let me achieve the circle-reveal effect. I assume for that the image needs to be a separate layer below the text so I can mask it with the circle that follows the mouse.

Instead of revealing the background for the selected spans, I'm revealing the background for the entire h1, and using spans to define which text should remain black. For some reason I couldn't get it to work the other way around.

  This is some text that I wrote with various words that reveal an animated background

```
<pre class="lang-css prettyprint-override"><code>.text-animated-bg {
    padding-top: 20px;
    padding-bottom: 20px;
    background-image: url("animation.gif");
    background-position: 0px 0px;
    background-size: cover;
    font-family: Ogg, sans-serif;
    color: #000;
    font-style: italic;
    font-weight: 700;
    text-align: center;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-black {
    background-image: -webkit-gradient(linear, left top, left bottom, from(#000), to(#000));
    background-image: linear-gradient(180deg, #000, #000);
    font-family: Inconsolata, monospace;
    font-style: normal;
    font-weight: 400;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
</code>```

Ask

Any ideas on how to approach the HTML and CSS to achieve the desired effect?

Body:
Goal

A hero section with text

The hero text contains spans

A circle follows the mouse position

Where the circle overlaps the spans, an animated background is revealed

All other text remains black, even if they are within the circle

Ideally, I'd like to use a single animated background that is shared across all spans

Mockup

I can't figure out how to set up the HTML and CSS for this.

What I have So Far

I got a part of it working, though it's in a round-about way and I'm not sure the approach will let me continue on toward the desired goal.

The solution uses a background image applied to the heading text with background-clip: text;. If I'm not mistaken, this approach won't let me achieve the circle-reveal effect. I assume for that the image needs to be a separate layer below the text so I can mask it with the circle that follows the mouse.

Instead of revealing the background for the selected spans, I'm revealing the background for the entire h1, and using spans to define which text should remain black. For some reason I couldn't get it to work the other way around.

  This is some text that I wrote with various words that reveal an animated background

.text-animated-bg {
    padding-top: 20px;
    padding-bottom: 20px;
    background-image: url("animation.gif");
    background-position: 0px 0px;
    background-size: cover;
    font-family: Ogg, sans-serif;
    color: #000;
    font-style: italic;
    font-weight: 700;
    text-align: center;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-black {
    background-image: -webkit-gradient(linear, left top, left bottom, from(#000), to(#000));
    background-image: linear-gradient(180deg, #000, #000);
    font-family: Inconsolata, monospace;
    font-style: normal;
    font-weight: 400;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

Ask

Any ideas on how to approach the HTML and CSS to achieve the desired effect?