问:
How to calculate the SUM of rows values for one column of a table created using TCPDF?
Please could you help me to calculate and display the SUM VALUE of the rows of a column named "prime" in my table which is created in a PDF report using TCPDF (the data is being extracted from my database).
Thank you in advance. I would be very grateful if you could help me.
A better description of my result table in this link
The main part of my code is this:

```<code>    <?php
set_time_limit(0);
tcpdf();

 // create new PDF document
$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// set default monospaced font
//$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
//$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language dependent data:
$lg = Array();
$lg['a_meta_charset'] = 'UTF-8';
$lg['a_meta_dir'] = 'rtl';
$lg['a_meta_language'] = 'fa';
$lg['w_page'] = 'page';

// set some language-dependent strings (optional)
$pdf->setLanguageArray($lg);

// ---------------------------------------------------------

// add a page
$pdf->AddPage();

$pdf->SetXY(16, 10);

// set document information
$pdf->SetCreator(PDF_CREATOR);
//$pdf->SetAuthor('Nicola Asuni');
//$pdf->SetSubject('TCPDF Tutorial');
//$pdf->SetKeywords('TCPDF, PDF, example, navettes, guide');
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.'', PDF_HEADER_STRING);
 $pdf->setPrintHeader(false);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

$pdf->setRTL(true);

$pdf->SetFont('xzar', '', 10);

    $sql= "SELECT * FROM nav_agent WHERE matricule='$mat'";
    $query = $this->db->query($sql);

$saut=0;
$tbl = '<table cellspacing="0" cellpadding="1" border="1">
   <thead>
        <tr>
            <th style="border: 1px double #000000; text-align:center;"  colspan="2">الإذن </th>
            <th style="border: 1px double #000000; text-align:center;"  colspan="2">التنقل</th>
            <th style="border: 1px double #000000; text-align:center;"  colspan="2">التوقيت</th>
            <th style="border: 1px double #000000; text-align:center;"  colspan="4"> </th>
       </tr>

<tr>
<td style="border: 1px double #000000; text-align:center;">العدد</td>
<td style="border: 1px double #000000; text-align:center;">التاريخ</td>
<td style="border: 1px double #000000; text-align:center;">من</td>
<td style="border: 1px double #000000; text-align:center;">إلى</td>
<td style="border: 1px double #000000; text-align:center;">الإنطلاق</td>
<td style="border: 1px double #000000; text-align:center;">الرجوع</td>
<td style="border: 1px double #000000; text-align:center;">المدة المقضاة (بالساعة)</td>
<td style="border: 1px double #000000; text-align:center;"> مبلغ منحة التنقل </td>
<td style="border: 1px double #000000; text-align:center;">رقم السيارة</td>
</tr>
';

$prime=0;
foreach ($query->result() as $row){

 $sql1 = "SELECT * FROM fiche_nav WHERE id_navette='$row->id_navette'";

  $query1 = $this->db->query($sql1);
foreach ($query1->result() as $row1){

$delai = strtotime($row1->heureret) - strtotime($row1->heuredep);
$time_h = ($delai/60)/60;

if ($val_grade == 'A1' or   $val_grade == 'A2')
    $montant1 = 15.000;
    else
        if ($val_grade == 'A3' or   $val_grade == 'B'
         or     $val_grade =='ouv cat 8' or $val_grade =='ouv cat 9' or $val_grade =='ouv cat 10')

    $montant1 = 9.000;
    else
        if ($val_grade == 'C' or    $val_grade == 'D'
         or     $val_grade =='ouv cat 1' or $val_grade =='ouv cat 2' or $val_grade =='ouv cat 3'
         or $val_grade =='ouv cat 4' or $val_grade =='ouv cat 5' or $val_grade =='ouv cat 6' or $val_grade =='ouv cat 7')

    $montant1 = 6.750;

if ($val_grade == 'A1' or   $val_grade == 'A2')
    $montant2 = 35.000;
    else
        if ($val_grade == 'A3' or   $val_grade == 'B'
         or     $val_grade =='ouv cat 8' or $val_grade =='ouv cat 9' or $val_grade =='ouv cat 10')

    $montant2 = 25.000;
    else
        if ($val_grade == 'C' or    $val_grade == 'D'
         or     $val_grade =='ouv cat 1' or $val_grade =='ouv cat 2' or $val_grade =='ouv cat 3'
         or $val_grade =='ouv cat 4' or $val_grade =='ouv cat 5' or $val_grade =='ouv cat 6' or $val_grade =='ouv cat 7')

    $montant2 = 18.000;

if ( $time_h <= 7 )
$prime = 0;
else

    if ( $time_h >7 && $time_h <= 14 )
$prime = 0.5 * $montant1;

else

    if ( $time_h >14 && $time_h < 24 )
$prime = $montant1;

else

    if ( $time_h >=24 )
$prime = $montant2;

$tbl=$tbl. '<tr>
<td style="border: 0px solid #000000; text-align:center"></td>
<td style="border: 0px solid #000000; text-align:center">'. $row1->datedep .'</td>
<td style="border: 0px solid #000000; text-align:center">'. $row1->lieudep .'</td>
<td style="border: 0px solid #000000; text-align:center">'. $row1->destination .'</td>
<td style="border: 0px solid #000000; text-align:center">'. $row1->heuredep .'</td>
<td style="border: 0px solid #000000; text-align:center">'. $row1->heureret .'</td>
<td style="border: 0px solid #000000; text-align:center">'. $time_h .'</td>
<td style="border: 0px solid #000000; text-align:center">'. $prime .'</td>
<td style="border: 0px solid #000000; text-align:center;"> '.$row1->matriculevoiture .' </td>

<td style="border: 0px solid #000000; text-align:center"></td>
<td style="border: 0px solid #000000; text-align:center"></td>
<td style="border: 0px solid #000000; text-align:center"></td>
<td style="border: 0px solid #000000; text-align:center"></td>
<td style="border: 0px solid #000000; text-align:center"></td>
</tr>
' ;

}

}

$tbl=$tbl.' </thead></table> ';

$pdf->writeHTML($tbl, true, false, false, false, '');

  // WHAT SHALL I ADD HERE TO CALCULATE the TOTAL VALUE i.e SUM OF "$PRIME" ROWS?

// close and output PDF document
 $date_auj=date('dmY',NOW());
    $strr = "Rapport-".$date_auj.".pdf";
$pdf->Output($strr, 'I');
//ob_end_clean();
//$pdf->Output($strr, 'I');

//============================================================+
// END OF FILE
//============================================================+
?>
</code>```

答:
Thank you dear members for you precious help! Indeed, another sum variable was missing.
I resolved the problem by adding it as shown below:

```<code>$grandPrime=0; $prime=0;

foreach ($query->result() as $row)
</code>```

{ //MY IF CONDITIONS TO CALCULATE THE VALUE OF PRIME etc ..

```<code>$grandPrime+=$prime;

$tbl=$tbl. '<tr>
</code>```

//MY TABLE CONTENT..etc.

```<code></tr> ' ; }
$pdf->writeHTML($tbl, true, false, false, false, '');
</code>```

// THEN I ADDED A FOR LOOP TO DISPLAY grandPRIME VALUE, where $num_prime is simply the number of prime rows

```<code>$num_prime = count($prime);
 for($i = 0; $i < $num_prime; ++$i)
{ $pdf->SetFont('xzar', 'B', 11);
 $pdf->Cell(277,5, " المبلغ الجملي $grandPrime ",1,0,'C');
}
</code>```

This is the correct result I finally obtained: Please clic the link to see the picture

THANK YOU AGAIN :)) YOU REALLY HELPED ME !

Body:
Please could you help me to calculate and display the SUM VALUE of the rows of a column named "prime" in my table which is created in a PDF report using TCPDF (the data is being extracted from my database).
Thank you in advance. I would be very grateful if you could help me.
A better description of my result table in this link
The main part of my code is this:

    <?php
set_time_limit(0);
tcpdf();

 // create new PDF document
$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// set default monospaced font
//$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
//$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language dependent data:
$lg = Array();
$lg['a_meta_charset'] = 'UTF-8';
$lg['a_meta_dir'] = 'rtl';
$lg['a_meta_language'] = 'fa';
$lg['w_page'] = 'page';

// set some language-dependent strings (optional)
$pdf->setLanguageArray($lg);

// ---------------------------------------------------------

// add a page
$pdf->AddPage();

$pdf->SetXY(16, 10);

// set document information
$pdf->SetCreator(PDF_CREATOR);
//$pdf->SetAuthor('Nicola Asuni');
//$pdf->SetSubject('TCPDF Tutorial');
//$pdf->SetKeywords('TCPDF, PDF, example, navettes, guide');
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.'', PDF_HEADER_STRING);
 $pdf->setPrintHeader(false);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

$pdf->setRTL(true);

$pdf->SetFont('xzar', '', 10);

    $sql= "SELECT * FROM nav_agent WHERE matricule='$mat'";
    $query = $this->db->query($sql);

$saut=0;
$tbl = '

            الإذن
            التنقل
            التوقيت

العدد
التاريخ
من
إلى
الإنطلاق
الرجوع
المدة المقضاة (بالساعة)
 مبلغ منحة التنقل
رقم السيارة

';

$prime=0;
foreach ($query->result() as $row){

 $sql1 = "SELECT * FROM fiche_nav WHERE id_navette='$row->id_navette'";

  $query1 = $this->db->query($sql1);
foreach ($query1->result() as $row1){

$delai = strtotime($row1->heureret) - strtotime($row1->heuredep);
$time_h = ($delai/60)/60;

if ($val_grade == 'A1' or   $val_grade == 'A2')
    $montant1 = 15.000;
    else
        if ($val_grade == 'A3' or   $val_grade == 'B'
         or     $val_grade =='ouv cat 8' or $val_grade =='ouv cat 9' or $val_grade =='ouv cat 10')

    $montant1 = 9.000;
    else
        if ($val_grade == 'C' or    $val_grade == 'D'
         or     $val_grade =='ouv cat 1' or $val_grade =='ouv cat 2' or $val_grade =='ouv cat 3'
         or $val_grade =='ouv cat 4' or $val_grade =='ouv cat 5' or $val_grade =='ouv cat 6' or $val_grade =='ouv cat 7')

    $montant1 = 6.750;

if ($val_grade == 'A1' or   $val_grade == 'A2')
    $montant2 = 35.000;
    else
        if ($val_grade == 'A3' or   $val_grade == 'B'
         or     $val_grade =='ouv cat 8' or $val_grade =='ouv cat 9' or $val_grade =='ouv cat 10')

    $montant2 = 25.000;
    else
        if ($val_grade == 'C' or    $val_grade == 'D'
         or     $val_grade =='ouv cat 1' or $val_grade =='ouv cat 2' or $val_grade =='ouv cat 3'
         or $val_grade =='ouv cat 4' or $val_grade =='ouv cat 5' or $val_grade =='ouv cat 6' or $val_grade =='ouv cat 7')

    $montant2 = 18.000;

if ( $time_h <= 7 )
$prime = 0;
else

    if ( $time_h >7 && $time_h <= 14 )
$prime = 0.5 * $montant1;

else

    if ( $time_h >14 && $time_h < 24 )
$prime = $montant1;

else

    if ( $time_h >=24 )
$prime = $montant2;

$tbl=$tbl. '

'. $row1->datedep .'
'. $row1->lieudep .'
'. $row1->destination .'
'. $row1->heuredep .'
'. $row1->heureret .'
'. $time_h .'
'. $prime .'
 '.$row1->matriculevoiture .'

' ;

}

}

$tbl=$tbl.'

 ';

$pdf->writeHTML($tbl, true, false, false, false, '');

  // WHAT SHALL I ADD HERE TO CALCULATE the TOTAL VALUE i.e SUM OF "$PRIME" ROWS?

// close and output PDF document
 $date_auj=date('dmY',NOW());
    $strr = "Rapport-".$date_auj.".pdf";
$pdf->Output($strr, 'I');
//ob_end_clean();
//$pdf->Output($strr, 'I');

//============================================================+
// END OF FILE
//============================================================+
?>

Body:
Thank you dear members for you precious help! Indeed, another sum variable was missing.
I resolved the problem by adding it as shown below:

$grandPrime=0; $prime=0;

foreach ($query->result() as $row)

{ //MY IF CONDITIONS TO CALCULATE THE VALUE OF PRIME etc ..

$grandPrime+=$prime;

$tbl=$tbl. '<tr>

//MY TABLE CONTENT..etc.

</tr> ' ; }
$pdf->writeHTML($tbl, true, false, false, false, '');

// THEN I ADDED A FOR LOOP TO DISPLAY grandPRIME VALUE, where $num_prime is simply the number of prime rows

$num_prime = count($prime);
 for($i = 0; $i < $num_prime; ++$i)
{ $pdf->SetFont('xzar', 'B', 11);
 $pdf->Cell(277,5, " المبلغ الجملي $grandPrime ",1,0,'C');
}

This is the correct result I finally obtained: Please clic the link to see the picture

THANK YOU AGAIN :)) YOU REALLY HELPED ME !


来源: stackexchange

问:
Is it possible to create postman environment scopes using pre-request in local?
I want to create postman scopes in local through pre-request. is it possible to create?

答:
You can set Global Variables in Pre-request Script section.

If you want to store some value which can be used further. Then you can store that value in global variable and afterwards you can use it.

Ex.
pm.globals.set("Variable-Name","Variable-value");

ContentLicense: CC BY-SA 4.0


问:
When I am running this query from back end, getting error
```<code>SQL> select
  2  DECODE (TNOT_NOTICE_TYPE,
  3      '1200', 'Duration Challenge ',
  4      '1400', 'Informal Overrun Warning ',
  5      '1500', 'Works Comments ',
  6      '1600', 'Direction on Timing ',
  7      '1601', 'Direction on Placing Apparatus ',
  8      '1602', 'Undue Delay ',
  9      '1611', 'Grant Permit ',
 10      '1613', 'Refuse Permit ',
 11      '2100', 'FPN Notice ',
 12      '2101', 'FPN Withdrawal ',
 13      '2200', 'FPN Comments ',
 14      '2600', 'Inspection ',
 15      '2800', 'Temporary Traffic Signal Application Responses '
 16      ) || 'Received' AS "Subject",
 17  DECODE (TNOT_NOTICE_TYPE,
 18      '1200', 'Duration Challenge - ',
 19      '1400', 'Informal Overrun Warning - ',
 20      '1500', 'Works Comments - ',
 21      '1600', 'Direction on Timing - ',
 22      '1601', 'Direction on Placing Apparatus - ',
 23      '1602', 'Undue Delay - ',
 24      '1611', 'Grant Permit - ',
 25      '1613', 'Refuse Permit - ',
 26      '2100', 'FPN Notice - ',
 27      '2101', 'FPN Withdrawal - ',
 28      '2200', 'FPN Comments - ',
 29      '2600', 'Inspection - ',
 30      '2800', 'Temporary Traffic Signal Application Responses - '
 31      ) || SUBSTR(TNOT_WORKS_REF, 3, 3) AS "Alert Description",
 32  SUBSTR(TNOT_WORKS_REF, 3, 3) AS "District"    ,
 33  TNOT_SENDER_ORG_REF as "Org Ref",
 34  TNOT_SENDER_DIST_REF as "Dist Ref",
 35  TNOT_DATE_MODIFIED as "Date Modified",
 36  TNOT_DATE_MODIFIED as "Date Modified",
 37  TNOT_WORKS_REF as "Works Ref",
 38  TNOT_COMMENTS as "Comments",
 39  TNOT_WORKS_DESCRIPTION AS "Works Description",
 40  TNOT_LOC_DESCRIPTION AS "Location Description",
 41  TNOT_NOTICE_TYPE ,
 42  TNOT_CREATED_DATIM
 43  from TMA_NOTICES
 44  where
 45  TNOT_SENT_RECEIVED = 'R'
 46  AND TNOT_WORKS_REF LIKE 'AY009%'
 47  AND TNOT_NOTICE_TYPE IN ('1200','1400', '1500', '1600', '1601', '1602', '16
11', '1613', '2100', '2101', '2200','2600', '2800')
 48  AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE
 49  ORDER BY TNOT_NOTICE_TYPE, TNOT_CREATED_DATIM DESC;
AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE
                               *
</code>```

****ERROR at line 48:

ORA-01830: date format picture ends before converting entire input
  string****

SQL>

答:
AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE

'01-OCT-19 00:00:00' is a STRING literal and not a DATE. You must always explicitly convert it to DATE data type when comparing with dates. I would prefer the ANSI date literal in your case:

```<code>AND TNOT_CREATED_DATIM BETWEEN DATE '2019-10-01' and SYSDATE
</code>```

The ANSI date literal contains no time portion, and must be specified in exactly this format ('YYYY-MM-DD'). If you have a time portion, then use TO_DATE:

```<code>TO_DATE('01-OCT-19 00:00:00','DD-MON-RR HH24:MI:SS')
</code>```

The default date format for an Oracle DATE value is specified by the initialization parameter NLS_DATE_FORMAT.

Body:
SQL> select
  2  DECODE (TNOT_NOTICE_TYPE,
  3      '1200', 'Duration Challenge ',
  4      '1400', 'Informal Overrun Warning ',
  5      '1500', 'Works Comments ',
  6      '1600', 'Direction on Timing ',
  7      '1601', 'Direction on Placing Apparatus ',
  8      '1602', 'Undue Delay ',
  9      '1611', 'Grant Permit ',
 10      '1613', 'Refuse Permit ',
 11      '2100', 'FPN Notice ',
 12      '2101', 'FPN Withdrawal ',
 13      '2200', 'FPN Comments ',
 14      '2600', 'Inspection ',
 15      '2800', 'Temporary Traffic Signal Application Responses '
 16      ) || 'Received' AS "Subject",
 17  DECODE (TNOT_NOTICE_TYPE,
 18      '1200', 'Duration Challenge - ',
 19      '1400', 'Informal Overrun Warning - ',
 20      '1500', 'Works Comments - ',
 21      '1600', 'Direction on Timing - ',
 22      '1601', 'Direction on Placing Apparatus - ',
 23      '1602', 'Undue Delay - ',
 24      '1611', 'Grant Permit - ',
 25      '1613', 'Refuse Permit - ',
 26      '2100', 'FPN Notice - ',
 27      '2101', 'FPN Withdrawal - ',
 28      '2200', 'FPN Comments - ',
 29      '2600', 'Inspection - ',
 30      '2800', 'Temporary Traffic Signal Application Responses - '
 31      ) || SUBSTR(TNOT_WORKS_REF, 3, 3) AS "Alert Description",
 32  SUBSTR(TNOT_WORKS_REF, 3, 3) AS "District"    ,
 33  TNOT_SENDER_ORG_REF as "Org Ref",
 34  TNOT_SENDER_DIST_REF as "Dist Ref",
 35  TNOT_DATE_MODIFIED as "Date Modified",
 36  TNOT_DATE_MODIFIED as "Date Modified",
 37  TNOT_WORKS_REF as "Works Ref",
 38  TNOT_COMMENTS as "Comments",
 39  TNOT_WORKS_DESCRIPTION AS "Works Description",
 40  TNOT_LOC_DESCRIPTION AS "Location Description",
 41  TNOT_NOTICE_TYPE ,
 42  TNOT_CREATED_DATIM
 43  from TMA_NOTICES
 44  where
 45  TNOT_SENT_RECEIVED = 'R'
 46  AND TNOT_WORKS_REF LIKE 'AY009%'
 47  AND TNOT_NOTICE_TYPE IN ('1200','1400', '1500', '1600', '1601', '1602', '16
11', '1613', '2100', '2101', '2200','2600', '2800')
 48  AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE
 49  ORDER BY TNOT_NOTICE_TYPE, TNOT_CREATED_DATIM DESC;
AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE
                               *

****ERROR at line 48:

ORA-01830: date format picture ends before converting entire input
  string****

SQL>

Body:
AND TNOT_CREATED_DATIM BETWEEN '01-OCT-19 00:00:00' and SYSDATE

'01-OCT-19 00:00:00' is a STRING literal and not a DATE. You must always explicitly convert it to DATE data type when comparing with dates. I would prefer the ANSI date literal in your case:

AND TNOT_CREATED_DATIM BETWEEN DATE '2019-10-01' and SYSDATE

The ANSI date literal contains no time portion, and must be specified in exactly this format ('YYYY-MM-DD'). If you have a time portion, then use TO_DATE:

TO_DATE('01-OCT-19 00:00:00','DD-MON-RR HH24:MI:SS')

The default date format for an Oracle DATE value is specified by the initialization parameter NLS_DATE_FORMAT.


问:
using a jquery slider with processing.js
I am creating a simple bar graph in processing using values from an XML. The data is glacier mass balance for 9 mountain ranges for 28 years. I am trying to implement a jquery slider with this (I can post it into processing.js...I just don't know where to go from there). To be able to see all my data, right now I am just showing all 28 years at once.

With a jquery slider I want to be able to slide between the years 1980 to 2007 and show the bars with only one of those years. Do I need to change my processing code drastically to make this work? A lot of the examples I found weren't using arrays extensively and the processing sketches were simpler. (I am pretty new at this so please bear with my amateur question). Any hints/pointers are appreciated.

```<code>            float[] yearA = new float[28];
            String[] mountA = new String[9];
            float[] massA = new float[9];
            float[] recth = new float[9];
            float rectw;

            int rectx = 10;
            int recty = 20;
            float rectht;
            void setup()

            {
              size(500,800);
            }

            void draw()

            {
              XMLElement years = new XMLElement(this, "glacier2.xml");
              println(years.getChildCount());
              int nResults = years.getChildCount();
              int x=40;
              int y=40;

              background(255);
              fill(0);

              for(int j=0; j<28; j++) {

                XMLElement yearN = years.getChild(j);
                String yearn = yearN.getAttribute("id");
                float yearnf = float(yearn);
                yearA[j] = yearnf;
                println(yearA[j]);

                for(int i=0; i<9; i++) {
                  XMLElement mountains = yearN.getChild(i);
                  String mountain = mountains.getAttribute("id");
                  String massbalance = mountains.getAttribute("massbalance");
                  float massf = float(massbalance);
                  mountA[i] = mountain;
                  massA[i] = massf;
                  rectht = map(massf, -4260, 3700, 10, 750);
                  recth[i]=rectht;
                  rectw = floor(width/10);
                  rect(rectx, recty, rectw, recth[i]);
                  rectx+=(rectw+10);
                  text(massf, rectx, recty+rectht);
                  println(massf);
                }

                rectx=10;
              }
            }
</code>```

答:
Here's an example with code at the bottom of the page, which may help. However, you'll need a WebGL browser to render the page.

http://matrix.senecac.on.ca/~asalga/DPS909/release0.2/work/3d_demos/

ContentLicense: CC BY-SA 3.0

Body:
I am creating a simple bar graph in processing using values from an XML. The data is glacier mass balance for 9 mountain ranges for 28 years. I am trying to implement a jquery slider with this (I can post it into processing.js...I just don't know where to go from there). To be able to see all my data, right now I am just showing all 28 years at once.

With a jquery slider I want to be able to slide between the years 1980 to 2007 and show the bars with only one of those years. Do I need to change my processing code drastically to make this work? A lot of the examples I found weren't using arrays extensively and the processing sketches were simpler. (I am pretty new at this so please bear with my amateur question). Any hints/pointers are appreciated.

            float[] yearA = new float[28];
            String[] mountA = new String[9];
            float[] massA = new float[9];
            float[] recth = new float[9];
            float rectw;

            int rectx = 10;
            int recty = 20;
            float rectht;
            void setup()

            {
              size(500,800);
            }

            void draw()

            {
              XMLElement years = new XMLElement(this, "glacier2.xml");
              println(years.getChildCount());
              int nResults = years.getChildCount();
              int x=40;
              int y=40;

              background(255);
              fill(0);

              for(int j=0; j<28; j++) {

                XMLElement yearN = years.getChild(j);
                String yearn = yearN.getAttribute("id");
                float yearnf = float(yearn);
                yearA[j] = yearnf;
                println(yearA[j]);

                for(int i=0; i<9; i++) {
                  XMLElement mountains = yearN.getChild(i);
                  String mountain = mountains.getAttribute("id");
                  String massbalance = mountains.getAttribute("massbalance");
                  float massf = float(massbalance);
                  mountA[i] = mountain;
                  massA[i] = massf;
                  rectht = map(massf, -4260, 3700, 10, 750);
                  recth[i]=rectht;
                  rectw = floor(width/10);
                  rect(rectx, recty, rectw, recth[i]);
                  rectx+=(rectw+10);
                  text(massf, rectx, recty+rectht);
                  println(massf);
                }

                rectx=10;
              }
            }


问:
Cannot locate my php ini file on live server?
I tried different solutions suggested here, but still cannot find the file through cPanel on my live server.

I'm running

```<code>phpinfo();
</code>```

And getting this result:

```<code>Configuration File (php.ini) Path   /opt/alt/php56/etc
</code>```

I cannot find these folders: /opt/alt/php56
But I could find the etc folder, however the file is not there, and I made sure I checked "View hidden files" options

What else could be done?

答: enter in your server comand line: php -i to see all of your php's config and also in very first lines of this command output, location of your php.ini if you can't find file like php.ini in your output which may not happen make one with touch command and put your configuration in that file and reload server, depend on what you use (like fpm or ...).

Body:
I tried different solutions suggested here, but still cannot find the file through cPanel on my live server.

I'm running

phpinfo();

And getting this result:

Configuration File (php.ini) Path   /opt/alt/php56/etc

I cannot find these folders: /opt/alt/php56
But I could find the etc folder, however the file is not there, and I made sure I checked "View hidden files" options

What else could be done?


问:
Get instance of subtype of a model with Eloquent
I have an Animal model, based on the animal table.

This table contains a type field, that can contain values such as cat or dog.

I would like to be able to create objects such as :

```<code>class Animal extends Model { }
class Dog extends Animal { }
class Cat extends Animal { }
</code>```

Yet, being able to fetch an animal like this :

```<code>$animal = Animal::find($id);
</code>```

But where $animal would be an instance of Dog or Cat depending on the type field, that I can check using instance of or that will work with type hinted methods. The reason is that 90% of the code is shared, but one can bark, and the other can meow.

I know that I can do Dog::find($id), but it's not what I want : I can determine the type of the object only once it was fetched. I could also fetch the Animal, and then run find() on the right object, but this is doing two database calls, which I obviously don't want.

I tried to look for a way to "manually" instantiate an Eloquent model like Dog from Animal, but I could not find any method corresponding. Any idea or method I missed please ?

答:
I think you could override the newInstance method on the Animal model, and check the type from the attributes and then init the corresponding model.

    public function newInstance($attributes = [], $exists = false)
    {
        // This method just provides a convenient way for us to generate fresh model
        // instances of this current model. It is particularly useful during the
        // hydration of new objects via the Eloquent query builder instances.
        $modelName = ucfirst($attributes['type']);
        $model = new $modelName((array) $attributes);

        $model->exists = $exists;

        $model->setConnection(
            $this->getConnectionName()
        );

        $model->setTable($this->getTable());

        $model->mergeCasts($this->casts);

        return $model;
    }
```

<p>You'll also need to override the <code>newFromBuilder</code> method.</p>

<pre class="lang-php prettyprint-override"><code>
    /**
     * Create a new model instance that is existing.
     *
     * @param  array  $attributes
     * @param  string|null  $connection
     * @return static
     */
    public function newFromBuilder($attributes = [], $connection = null)
    {
        $model = $this->newInstance([
            'type' => $attributes['type']
        ], true);

        $model->setRawAttributes((array) $attributes, true);

        $model->setConnection($connection ?: $this->getConnectionName());

        $model->fireModelEvent('retrieved', false);

        return $model;
    }
</code>```

Body:
I have an Animal model, based on the animal table.

This table contains a type field, that can contain values such as cat or dog.

I would like to be able to create objects such as :

class Animal extends Model { }
class Dog extends Animal { }
class Cat extends Animal { }

Yet, being able to fetch an animal like this :

$animal = Animal::find($id);

But where $animal would be an instance of Dog or Cat depending on the type field, that I can check using instance of or that will work with type hinted methods. The reason is that 90% of the code is shared, but one can bark, and the other can meow.

I know that I can do Dog::find($id), but it's not what I want : I can determine the type of the object only once it was fetched. I could also fetch the Animal, and then run find() on the right object, but this is doing two database calls, which I obviously don't want.

I tried to look for a way to "manually" instantiate an Eloquent model like Dog from Animal, but I could not find any method corresponding. Any idea or method I missed please ?

Body:
I think you could override the newInstance method on the Animal model, and check the type from the attributes and then init the corresponding model.

    public function newInstance($attributes = [], $exists = false)
    {
        // This method just provides a convenient way for us to generate fresh model
        // instances of this current model. It is particularly useful during the
        // hydration of new objects via the Eloquent query builder instances.
        $modelName = ucfirst($attributes['type']);
        $model = new $modelName((array) $attributes);

        $model->exists = $exists;

        $model->setConnection(
            $this->getConnectionName()
        );

        $model->setTable($this->getTable());

        $model->mergeCasts($this->casts);

        return $model;
    }

You'll also need to override the newFromBuilder method.

    /**
     * Create a new model instance that is existing.
     *
     * @param  array  $attributes
     * @param  string|null  $connection
     * @return static
     */
    public function newFromBuilder($attributes = [], $connection = null)
    {
        $model = $this->newInstance([
            'type' => $attributes['type']
        ], true);

        $model->setRawAttributes((array) $attributes, true);

        $model->setConnection($connection ?: $this->getConnectionName());

        $model->fireModelEvent('retrieved', false);

        return $model;
    }


问:
How can i make sure that the footer stays at the bottom of the page?
I have a footer component which is currently being rendered at the end of another component.
How can I make sure that it stays at the bottom of the page irrespective of other components.
My other components include a header which is at the top,a side navigation which opens when a button is clicked on the toolbar.</p>

答:
Please try a markup like this.

```<code><div class="container">
  <div class="header">
  <nav>
    HEADER
  </nav>
  </div>
  <div class="content">
    page
    <router-outlet></router-outlet>
  </div>
  <div class="footer">
    <h2>footer</h2>
  </div>
</div>
</code>```

CSS

```<code>.container{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.header{
  flex-shrink: 0;
  flex-grow: 0;
  background: #039be5;
  padding: 3px 5px;
}
.content{
  flex-shrink: 1;
  flex-grow: 1;
  padding: 3px 5px;
  position: relative;
  overflow-y: auto;
}

.footer{
  flex-shrink: 0;
  flex-grow: 0;
  background: #eee;
  padding: 3px 15px;
}
</code>```

Body:
Please try a markup like this.

<div class="container">
  <div class="header">
  <nav>
    HEADER
  </nav>
  </div>
  <div class="content">
    page
    <router-outlet></router-outlet>
  </div>
  <div class="footer">
    <h2>footer</h2>
  </div>
</div>

CSS

.container{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.header{
  flex-shrink: 0;
  flex-grow: 0;
  background: #039be5;
  padding: 3px 5px;
}
.content{
  flex-shrink: 1;
  flex-grow: 1;
  padding: 3px 5px;
  position: relative;
  overflow-y: auto;
}

.footer{
  flex-shrink: 0;
  flex-grow: 0;
  background: #eee;
  padding: 3px 15px;
}


问:
Read an embedded binary resource
I have a binary file that holds a Dictionary object. I can access the data with the following code.

```<code>var result = new Dictionary<string, string>();
        using (FileStream fs1 = File.OpenRead("C:\\MyDictionary.bin"))
        {
            using (BinaryReader br = new BinaryReader(fs1))
            {
                int count = br.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    string key = br.ReadString();
                    string value = br.ReadString();
                    result[key] = value;
                }
            }
        }
</code>```

I would prefer to include this binary file within my application and not refer to an external file at run time. How do I do the same thing from an embedded binary file?

I found the following code in another thread but am struggling to understand how I can get it to work with the above data.

```<code>var assembly = Assembly.GetExecutingAssembly();
        var resourceName = "MyProgram.Resources.MyDictionary.bin";

        using (Stream stream = assembly.GetManifestResourceStream(resourceName))
        using (StreamReader reader = new StreamReader(stream))
        {
            string result = reader.ReadToEnd();
        }
</code>```

答:
You can use the following code:</p>

```<code>var result = new Dictionary<string, string>();
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "MyProgram.Resources.MyDictionary.bin";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (BinaryReader reader = new BinaryReader(stream))
  {
    int count = reader.ReadInt32();
    for (int i = 0; i < count; i++)
      {
        string key = reader.ReadString();
        string value = reader.ReadString();
        result[key] = value;
      }
  }
</code>```

Title: Read an embedded binary resource

Body:
I have a binary file that holds a Dictionary object. I can access the data with the following code.

var result = new Dictionary<string, string>();
        using (FileStream fs1 = File.OpenRead("C:\\MyDictionary.bin"))
        {
            using (BinaryReader br = new BinaryReader(fs1))
            {
                int count = br.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    string key = br.ReadString();
                    string value = br.ReadString();
                    result[key] = value;
                }
            }
        }

I would prefer to include this binary file within my application and not refer to an external file at run time. How do I do the same thing from an embedded binary file?

I found the following code in another thread but am struggling to understand how I can get it to work with the above data.

var assembly = Assembly.GetExecutingAssembly();
        var resourceName = "MyProgram.Resources.MyDictionary.bin";

        using (Stream stream = assembly.GetManifestResourceStream(resourceName))
        using (StreamReader reader = new StreamReader(stream))
        {
            string result = reader.ReadToEnd();
        }

Body:
You can use the following code:

var result = new Dictionary<string, string>();
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "MyProgram.Resources.MyDictionary.bin";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (BinaryReader reader = new BinaryReader(stream))
  {
    int count = reader.ReadInt32();
    for (int i = 0; i < count; i++)
      {
        string key = reader.ReadString();
        string value = reader.ReadString();
        result[key] = value;
      }
  }


问:
(Swift) How to get rid of "Left side of mutating operator isn't mutable"
complete error:

Left side of mutating operator isn't mutable: 'abc' is a 'let' constant

Happens because I am trying to change value of a variable sent by parameter to function.

Can I get rid of this, or find some other solution?

Code(My code is much complex, but in effect doing the same as this):

```<code>func generateABC() {
var abc = "this"
abc += "is"

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(abc)) )
tapGesture.delegate = self
webView.addGestureRecognizer(tapGesture)

abc += "function"
}
</code>```

handleTap function :

```<code>@objc
func handleTap(_ someString: String) {
     someString += "my"
}
</code>```

答:
All parameters passed into a Swift function are constants, so you can’t change them. If you want, you can pass in one or more parameters as inout, which means they can be changed inside your function, and those changes reflect in the original value outside the function.

```<code>func doubleInPlace(number: inout Int) {
    number *= 2
}
</code>```

Credit: Paul Hudson https://www.hackingwithswift.com/sixty/5/10/inout-parameters

Be careful if you are going with this approach, because you can end up with unexpected sideffects. You can also simply use a temp variable inside your function, and assign the parameter to it

```<code>@objc
func handleTap(_ someString: String)-> String {
     var tempString = someString
     tempString += "Whatever"
     return tempString
}
</code>```

Body:
complete error:

Left side of mutating operator isn't mutable: 'abc' is a 'let' constant

Happens because I am trying to change value of a variable sent by parameter to function.

Can I get rid of this, or find some other solution?

Code(My code is much complex, but in effect doing the same as this):

func generateABC() {
var abc = "this"
abc += "is"

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(abc)) )
tapGesture.delegate = self
webView.addGestureRecognizer(tapGesture)

abc += "function"
}

handleTap function :

@objc
func handleTap(_ someString: String) {
     someString += "my"
}

Body:
All parameters passed into a Swift function are constants, so you can’t change them. If you want, you can pass in one or more parameters as inout, which means they can be changed inside your function, and those changes reflect in the original value outside the function.

func doubleInPlace(number: inout Int) {
    number *= 2
}

Credit: Paul Hudson https://www.hackingwithswift.com/sixty/5/10/inout-parameters

Be careful if you are going with this approach, because you can end up with unexpected sideffects. You can also simply use a temp variable inside your function, and assign the parameter to it

@objc
func handleTap(_ someString: String)-> String {
     var tempString = someString
     tempString += "Whatever"
     return tempString
}


问:
BigQuery: How to create integer partitioned table via DML?
I try to understand how the integer partitioned tables work. So far however, I could not create one.

What is wrong with this query:

```<code> #standardSQL
 CREATE or Replace TABLE temp.test_int_partition

 PARTITION BY RANGE_BUCKET(id, GENERATE_ARRAY(0,100))
 OPTIONS(
   description="test int partition"
 )
as

WITH data as (
SELECT 12 as id, 'Alex' as name
UNION ALL
SELECT 23 as id, 'Chimp' as name
)

SELECT *
from data
</code>```

I'm getting this error:

Error: PARTITION BY expression must be DATE(<timestamp_column>), a DATE column, or RANGE_BUCKET(<int64_column>, GENERATE_ARRAY(<int64_value>, <int64_value>, <int64_value>))

答:
The issue is that despite GENERATE_ARRAY being documented as GENERATE_ARRAY(start_expression, end_expression [, step_expression]), meaning step_expression being optional, for the RANGE_BUCKET it's mandatory.

So the following will work:

```<code> #standardSQL
 CREATE or Replace TABLE temp.test_int_partition

 PARTITION BY RANGE_BUCKET(id, GENERATE_ARRAY(0,100,1))
 OPTIONS(
   description="test int partition"
 )
as

WITH data as (
SELECT 12 as id, 'Alex' as name
UNION ALL
SELECT 23 as id, 'Chimp' as name
)

SELECT *
from data
</code>```

Body:
I try to understand how the integer partitioned tables work. So far however, I could not create one.

What is wrong with this query:

 #standardSQL
 CREATE or Replace TABLE temp.test_int_partition

 PARTITION BY RANGE_BUCKET(id, GENERATE_ARRAY(0,100))
 OPTIONS(
   description="test int partition"
 )
as

WITH data as (
SELECT 12 as id, 'Alex' as name
UNION ALL
SELECT 23 as id, 'Chimp' as name
)

SELECT *
from data

I'm getting this error:

Error: PARTITION BY expression must be DATE(<timestamp_column>), a DATE column, or RANGE_BUCKET(<int64_column>, GENERATE_ARRAY(<int64_value>, <int64_value>, <int64_value>))

Body:
The issue is that despite GENERATE_ARRAY being documented as GENERATE_ARRAY(start_expression, end_expression [, step_expression]), meaning step_expression being optional, for the RANGE_BUCKET it's mandatory.

So the following will work:

 #standardSQL
 CREATE or Replace TABLE temp.test_int_partition

 PARTITION BY RANGE_BUCKET(id, GENERATE_ARRAY(0,100,1))
 OPTIONS(
   description="test int partition"
 )
as

WITH data as (
SELECT 12 as id, 'Alex' as name
UNION ALL
SELECT 23 as id, 'Chimp' as name
)

SELECT *
from data


问:
TextEditor component is marked secure='true' but the HTML Sanitizer was not found on the classpath
Error message:

TextEditor component is marked secure='true' but the HTML Sanitizer was not found on the classpath. Either add the HTML sanitizer to the classpath per the documentation or mark secure='false' if you would like to use the component without the sanitizer.

This is my pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                        https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.jsf</groupId>
    <artifactId>showcase</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

    <name>showcase</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>Prime Repo</name>
            <url>http://repository.primefaces.org</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>8.0.RC3</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-shaded</artifactId>
            <version>3.1.3.Final</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>8.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.faces</artifactId>
            <version>2.3.14</version>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet.jsp.jstl</groupId>
            <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
            <version>1.2.7</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

textEditor.xhtml:

```<code><html   xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui">

    <h:head>
        <h:outputStylesheet name="primeicons/primeicons.css" library="primefaces"/>
    </h:head>

    <h:body>
        <h:form>
            <h3 style="margin-top:0">Basic</h3>
            <p:textEditor widgetVar="editor1" value="#{editorView.text}" height="300" style="margin-bottom:10px"/>

            <p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()" icon="pi pi-save" />
            <p:commandButton value="Clear" type="button" onclick="PF('editor1').clear();" icon="pi pi-times" />

            <h3 class="first">Custom Toolbar</h3>
            <p:textEditor widgetVar="editor2" value="#{editorView.text2}" height="300" style="margin-bottom:10px" placeholder="Enter your content">
                <f:facet name="toolbar">
                     <span class="ql-formats">
                        <button class="ql-bold"></button>
                        <button class="ql-italic"></button>
                        <button class="ql-underline"></button>
                        <button class="ql-strike"></button>
                    </span>
                    <span class="ql-formats">
                        <select class="ql-font"></select>
                        <select class="ql-size"></select>
                    </span>
                </f:facet>
            </p:textEditor>

            <p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()" icon="pi pi-save" />
            <p:commandButton value="Clear" type="button" onclick="PF('editor2').clear();" icon="pi pi-times" />

            <p:dialog header="Content" widgetVar="dlg" showEffect="fade" hideEffect="fade">
                <p:outputPanel id="display">
                    <h3 style="margin-top:0">Basic</h3>
                    <h:outputText value="#{editorView.text}" escape="false" />

                    <h3>Custom</h3>
                    <h:outputText value="#{editorView.text2}" escape="false" />
                </p:outputPanel>
            </p:dialog>
        </h:form>
    </h:body>
</html>
</code>```

EditorView.java

```<code>package com.jsf.showcase.view.input;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

import lombok.Getter;
import lombok.Setter;

@Getter @Setter
@Named
@RequestScoped
public class EditorView {
    private String text;
    private String text2;
}
</code>```

PrimeFaces version: 8

答:
I have solved with this dependency. Thanks Kukeltje.</p>

```<code><dependency>
    <groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
    <artifactId>owasp-java-html-sanitizer</artifactId>
    <version>20191001.1</version>
</dependency>
</code>```

Body:
Error message:

TextEditor component is marked secure='true' but the HTML Sanitizer was not found on the classpath. Either add the HTML sanitizer to the classpath per the documentation or mark secure='false' if you would like to use the component without the sanitizer.

This is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                        https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.jsf</groupId>
    <artifactId>showcase</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

    <name>showcase</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>Prime Repo</name>
            <url>http://repository.primefaces.org</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>8.0.RC3</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-shaded</artifactId>
            <version>3.1.3.Final</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>8.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.faces</artifactId>
            <version>2.3.14</version>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet.jsp.jstl</groupId>
            <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
            <version>1.2.7</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

textEditor.xhtml:

    <h:head>
        <h:outputStylesheet name="primeicons/primeicons.css" library="primefaces"/>
    </h:head>

    <h:body>
        <h:form>

Basic

Custom Toolbar

                <f:facet name="toolbar">

                        <button class="ql-bold"></button>
                        <button class="ql-italic"></button>
                        <button class="ql-underline"></button>
                        <button class="ql-strike"></button>

                        <select class="ql-font"></select>
                        <select class="ql-size"></select>

                </f:facet>

Basic

                    <h:outputText value="#{editorView.text}" escape="false" />

Custom

                    <h:outputText value="#{editorView.text2}" escape="false" />

        </h:form>
    </h:body>

EditorView.java

package com.jsf.showcase.view.input;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

import lombok.Getter;
import lombok.Setter;

@Getter @Setter
@Named
@RequestScoped
public class EditorView {
    private String text;
    private String text2;
}

PrimeFaces version: 8

Body:
I have solved with this dependency. Thanks Kukeltje.

<dependency>
    <groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
    <artifactId>owasp-java-html-sanitizer</artifactId>
    <version>20191001.1</version>
</dependency>


问:
before_filter checking multiple roles
In application_controller I have the following method:

```<code>  def authorized_for_roles(*roles)
    roles.each{|role_name| return true if current_user.has_role?(role_name)}
    false
  end
</code>```

In one of my controllers, I have

```<code>private

  def authorize_administration
    authorized_for_roles :administrator
  end
</code>```

I am calling authorize_administration in my before_filter.  Currently getting 'undefined method roles" error.  Can someone tell me where I've gone wrong?  the current_user is valid/defined, and the role can be checked.

Thanks

答: Is the error really in the authorized_for_roles def, or perhaps in the User model?  Did you define has_many :roles for User?</p>

Title: before_filter checking multiple roles

Body:
In application_controller I have the following method:

  def authorized_for_roles(*roles)
    roles.each{|role_name| return true if current_user.has_role?(role_name)}
    false
  end

In one of my controllers, I have

private

  def authorize_administration
    authorized_for_roles :administrator
  end

I am calling authorize_administration in my before_filter.  Currently getting 'undefined method roles" error.  Can someone tell me where I've gone wrong?  the current_user is valid/defined, and the role can be checked.

Thanks


问:
Django Page not found (404) but URLs are correct
I encountered such an error, I get 404 error when trying to open the URL http://127.0.0.1:8000/account/

```<code># apps/account/urls.py

from django.urls import path
from django.contrib.auth.views import LoginView
from . import views

urlpatterns = [
    path('', views.index),
    path('login/', LoginView.as_view(template_name='account/login.html'), name="login")
]

</code>```

And the strangest thing is that if I add something like
qwe/ in path
http://127.0.0.1:8000/account/qwe it will work, and 2nd path login/ is working

Can anyone tell me what the problem is?

```<code>#apps/account/views.py

from django.shortcuts import render, HttpResponse

def index(request):
    return HttpResponse('<h1>Hello</h1>')

</code>```

Main urls.py

```<code>#project/urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
                  path('admin/', admin.site.urls),
                  path('', include("apps.main.urls")),
                  path('account/', include("apps.account.urls")),
              ]
</code>```

Screenshot

答:
Not sure this will work but I suggest you try a different import in account views.py.

Rather than below.

#apps/account/views.py
from django.shortcuts import render, HttpResponse
```

<p>Try below</p>

<pre class="lang-py prettyprint-override"><code>#apps/account/views.py
from django.shortcuts import render
from django.http import HttpResponse
</code>```

Body:
I encountered such an error, I get 404 error when trying to open the URL http://127.0.0.1:8000/account/

# apps/account/urls.py

from django.urls import path
from django.contrib.auth.views import LoginView
from . import views

urlpatterns = [
    path('', views.index),
    path('login/', LoginView.as_view(template_name='account/login.html'), name="login")
]

And the strangest thing is that if I add something like
qwe/ in path
http://127.0.0.1:8000/account/qwe it will work, and 2nd path login/ is working

Can anyone tell me what the problem is?

#apps/account/views.py

from django.shortcuts import render, HttpResponse

def index(request):
    return HttpResponse('
Hello
')

Main urls.py

#project/urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
                  path('admin/', admin.site.urls),
                  path('', include("apps.main.urls")),
                  path('account/', include("apps.account.urls")),
              ]

Screenshot

Body:
Not sure this will work but I suggest you try a different import in account views.py.

Rather than below.

#apps/account/views.py
from django.shortcuts import render, HttpResponse

Try below

#apps/account/views.py
from django.shortcuts import render
from django.http import HttpResponse


问:
How to correlate a dynamic value in the first request of script loadrunner
I have recorded following script snippet:

```<code>Action()
{

    /*Click on Continue to this website*/

    /*Login*/

    web_url("startSSO.ping",
        "URL=https://e4.pncie.com/sso/idp/0LEMc/resumeSAML20/idp/startSSO.ping",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTML",
        EXTRARES,
        "URL=/favicon.ico", ENDITEM,
        LAST);

    web_submit_data("ClaimCenter.do",
        "Action={P_url}",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/html",
        "Referer=https://e4.pncie.com/sso/idp/0LEMc/resumeSAML20/idp/startSSO.ping",
        "Snapshot=t2.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=SAMLResponse", "Value=PHNhbWxwOlJlc3BvbnNlIERlc3RpbmF0aW9uPSJodHRwczovL2Nhc3BlcmZwb2MudGVudC50cnQuY3NhYS5wcmkvY2MvQ2xhaW1DZW50ZXIuZG8iIElzc3VlSW5zdGFudD0iMjAxMy0wMS0yNFQwNjozNDozOS4wNzhaIiBJRD0iWVRaLlhPdjZ6Skd2MmNldFk1NE5qZS1BT3FqIiBWZXJzaW9uPSIyLjAiIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiPjxzYW1sOklzc3VlciB4bWxuczpzYW1sPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXNzZXJ0aW9uIj5DQVM6SWRQPC9zYW1sOklzc3Vlcj48ZHM6U2lnbmF0dXJlIHhtbG5zOmRzPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjIj4KPGRzOlNpZ25lZEluZm8+CjxkczpDYW5vbmljYWxpemF0aW9uTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+CjxkczpTaWduYXR1cmVNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjcnNhLXNoYTEiLz4KPGRzOlJlZmVyZW5jZSBVUkk9IiNZVFouWE92NnpKR3YyY2V0WTU0TmplLUFPcWoiPgo8ZHM6VHJhbnNmb3Jtcz4KPGRzOl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YS1pbnN0YW5jZSI+VGhvcm4xNTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjwvc2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PC9zYW1sOkFzc2VydGlvbj4"
        "8L3NhbWxwOlJlc3BvbnNlPg==", ENDITEM,
        EXTRARES,
        "URL=resources/Ocean/images/header_bg.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/modetabs_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/toolbar_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/menu_claim_search.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/unsaved_left_off.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/unsaved_middle.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/unsaved_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/btn2_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/btn2_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/btn2_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOn_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOn_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/menu-arrow-down-on.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOn_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOff_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOff_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/menu-arrow-down.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOff_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabDS_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabDS_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabDS_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/infobar_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/actionButton_middle.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/actionButton_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/actionButton_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/leftNav_select.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/pagetitle_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        LAST);
</code>```

where above in the first request send to the server a dynamic value "0LEMc" is occuring in the URL; likewise in the 2nd request.How do I correlate it ?

答:
There are some key points which need to be considered before analyzing dynamic values.

After recording the script, try to record it one more time in the same way.

When you compare these two created scripts, you will get to know what all values have changed in the second script. Those dynamic values can be treated with Correlation.

I would suggest to verify it once whether the value you are targeting is dynamic or common in other round of scripts.

If you are sure, then you can try conventional way of Manual correlation of values.
Try finding the value in response and just before the respective request, add web_reg_save_param parameter and fill all the LB, RB values.

Body:
I have recorded following script snippet:

Action()
{

    /*Click on Continue to this website*/

    /*Login*/

    web_url("startSSO.ping",
        "URL=https://e4.pncie.com/sso/idp/0LEMc/resumeSAML20/idp/startSSO.ping",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t1.inf",
        "Mode=HTML",
        EXTRARES,
        "URL=/favicon.ico", ENDITEM,
        LAST);

    web_submit_data("ClaimCenter.do",
        "Action={P_url}",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/html",
        "Referer=https://e4.pncie.com/sso/idp/0LEMc/resumeSAML20/idp/startSSO.ping",
        "Snapshot=t2.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=SAMLResponse", "Value=PHNhbWxwOlJlc3BvbnNlIERlc3RpbmF0aW9uPSJodHRwczovL2Nhc3BlcmZwb2MudGVudC50cnQuY3NhYS5wcmkvY2MvQ2xhaW1DZW50ZXIuZG8iIElzc3VlSW5zdGFudD0iMjAxMy0wMS0yNFQwNjozNDozOS4wNzhaIiBJRD0iWVRaLlhPdjZ6Skd2MmNldFk1NE5qZS1BT3FqIiBWZXJzaW9uPSIyLjAiIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiPjxzYW1sOklzc3VlciB4bWxuczpzYW1sPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXNzZXJ0aW9uIj5DQVM6SWRQPC9zYW1sOklzc3Vlcj48ZHM6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hzOnN0cmluZyIgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSI+QmFyYWN1ZGExNTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjxzYW1sOkF0dHJpYnV0ZSBOYW1lRm9ybWF0PSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXR0cm5hbWUtZm9ybWF0OmJhc2ljIiBOYW1lPSJMYXN0TmFtZSI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyIgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSI+VGhvcm4xNTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjwvc2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PC9zYW1sOkFzc2VydGlvbj4"
        "8L3NhbWxwOlJlc3BvbnNlPg==", ENDITEM,
        EXTRARES,
        "URL=resources/Ocean/images/header_bg.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/modetabs_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/toolbar_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/menu_claim_search.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/unsaved_left_off.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/unsaved_middle.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/unsaved_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/btn2_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/btn2_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/btn2_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOn_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOn_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/menu-arrow-down-on.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOn_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOff_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOff_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/menu-arrow-down.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabOff_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabDS_1px.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabDS_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/tabDS_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/infobar_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/actionButton_middle.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/actionButton_left.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/actionButton_right.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/leftNav_select.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        "URL=resources/Ocean/images/pagetitle_bgd.gif", "Referer={P_url}?inFrame=mainframe&r=44794921&__navigator_index=0", ENDITEM,
        LAST);

where above in the first request send to the server a dynamic value "0LEMc" is occuring in the URL; likewise in the 2nd request.How do I correlate it ?


问:
RxJS not correctly combing the result of a secondary http get
I have a searchbox that is serviced by three seperate search APIs; you can either enter a string or a number. The string value is pretty straightforward, just returns the found results -- this can be none or up to ten. For the numbers, it is either no results or a single result, but a second GET must be made in order to complete the result. The input has a debounce of 300ms and shouldn't start searching until there's three characters entered.

My problem is that in the case of a number, the second http call is made but never actually used in the result set. The MapId function needs to do something else -- a promise is obviously not the way to go.

Would it be better to use forkJoin instead of combineLatest?

I've tried flatMap, but couldn't get that to work in combination with forkJoin.

I'm kinda lost now. It shouldn't be that hard to do a get, check the results and do a second get if needed, in combination with the subscription waiting in the Angular component.

Angular component file:

```<code>searchTerm$ = new Subject<string>();
filterData$;

onFiltering(args: FilteringEventArgs): void {
    this.searchTerm$.next(args.text);
}

setupSearchDebouncer(): void {
    this.filterData$ = this.searchTerm$
        .pipe(
            debounceTime(300),
            switchMap(s =>
                iif(() => s.length >= 3,
                    this.searchService.find(s)
                        .pipe(
                            map((result) => {
                                return result.results
                            }),
                        ),
                    of<Result[]>([])
                ))
        );

    this.filterData$.subscribe(r => {
        this.filterArgs.updateData(r);
    });
}

</code>```

And the RxJS service file:

```<code>find(searchQuery: string) {
    return combineLatest(
        this.apiService1.search(searchQuery).pipe(),
        this.apiService2.search(searchQuery).pipe(),
        this.apiService3.search(searchQuery).pipe()
    ).pipe(
        map(([stringResult, idResult1, idResult2]) => {
            if (idResult1.length > 0 || idResult2.length > 0) {
                return this.mapName(idResult1, idResult2);
            }
            else {
                return this.mapId(stringResult);
            }
        })
    );
}

mapId(stringResult): SearchResult {
    // do some mapping
    return result;
}

mapName(idResult1, idResult2): SearchResult {
    const result = new SearchResult();

    let id = undefined;
    if (idResult1 && idResult1.length > 0) {
        id = idResult1[0].Id;
    }
    else if (idResult2 && idResult2.length > 0) {
        id = idResult2[0].Id;
    }

    this.apiService.fetchName(id).toPromise().then(succes => {
        result.results = [{ name: succes[0].name, id: id }];
    });
    return result;
}

</code>```

答:
combineLatest is probably the best option here because you want to trigger search when any of the sources emit. forkJoin would emit just once when all sources complete so it wouldn't work if the sources are Subjects. This depends on what this.apiService1.search(searchQuery) does inside.

So you can just make sure you always return an Observable from mapName with of():

```<code>mapName(idResult1, idResult2): Observable<SearchResult> {
    const result = new SearchResult();
    ...

    if (id) { // or whatever condition you need
      return this.apiService.fetchName(id).pipe(
        map(succes => {
          result.results = [{ name: succes[0].name, id: id }];
          return result;
        }),
      );
    }
    return of(result);
}
</code>```

Then in the main chain you'll use mergeMap instead of map and again make sure you always return an Observable with of():

```<code>mergeMap(([stringResult, idResult1, idResult2]) => {
  if (idResult1.length > 0 || idResult2.length > 0) {
     return this.mapName(idResult1, idResult2);
  } else {
     return of(this.mapId(stringResult));
  }
}),
</code>```

Body:
I have a searchbox that is serviced by three seperate search APIs; you can either enter a string or a number. The string value is pretty straightforward, just returns the found results -- this can be none or up to ten. For the numbers, it is either no results or a single result, but a second GET must be made in order to complete the result. The input has a debounce of 300ms and shouldn't start searching until there's three characters entered.

My problem is that in the case of a number, the second http call is made but never actually used in the result set. The MapId function needs to do something else -- a promise is obviously not the way to go.

Would it be better to use forkJoin instead of combineLatest?

I've tried flatMap, but couldn't get that to work in combination with forkJoin.

I'm kinda lost now. It shouldn't be that hard to do a get, check the results and do a second get if needed, in combination with the subscription waiting in the Angular component.

Angular component file:

searchTerm$ = new Subject<string>();
filterData$;

onFiltering(args: FilteringEventArgs): void {
    this.searchTerm$.next(args.text);
}

setupSearchDebouncer(): void {
    this.filterData$ = this.searchTerm$
        .pipe(
            debounceTime(300),
            switchMap(s =>
                iif(() => s.length >= 3,
                    this.searchService.find(s)
                        .pipe(
                            map((result) => {
                                return result.results
                            }),
                        ),
                    of<Result[]>([])
                ))
        );

    this.filterData$.subscribe(r => {
        this.filterArgs.updateData(r);
    });
}

And the RxJS service file:

find(searchQuery: string) {
    return combineLatest(
        this.apiService1.search(searchQuery).pipe(),
        this.apiService2.search(searchQuery).pipe(),
        this.apiService3.search(searchQuery).pipe()
    ).pipe(
        map(([stringResult, idResult1, idResult2]) => {
            if (idResult1.length > 0 || idResult2.length > 0) {
                return this.mapName(idResult1, idResult2);
            }
            else {
                return this.mapId(stringResult);
            }
        })
    );
}

mapId(stringResult): SearchResult {
    // do some mapping
    return result;
}

mapName(idResult1, idResult2): SearchResult {
    const result = new SearchResult();

    let id = undefined;
    if (idResult1 && idResult1.length > 0) {
        id = idResult1[0].Id;
    }
    else if (idResult2 && idResult2.length > 0) {
        id = idResult2[0].Id;
    }

    this.apiService.fetchName(id).toPromise().then(succes => {
        result.results = [{ name: succes[0].name, id: id }];
    });
    return result;
}

Body:
combineLatest is probably the best option here because you want to trigger search when any of the sources emit. forkJoin would emit just once when all sources complete so it wouldn't work if the sources are Subjects. This depends on what this.apiService1.search(searchQuery) does inside.

So you can just make sure you always return an Observable from mapName with of():

mapName(idResult1, idResult2): Observable<SearchResult> {
    const result = new SearchResult();
    ...

    if (id) { // or whatever condition you need
      return this.apiService.fetchName(id).pipe(
        map(succes => {
          result.results = [{ name: succes[0].name, id: id }];
          return result;
        }),
      );
    }
    return of(result);
}

Then in the main chain you'll use mergeMap instead of map and again make sure you always return an Observable with of():

mergeMap(([stringResult, idResult1, idResult2]) => {
  if (idResult1.length > 0 || idResult2.length > 0) {
     return this.mapName(idResult1, idResult2);
  } else {
     return of(this.mapId(stringResult));
  }
}),


问:
Detect Objective C event from PhoneGap
I want notification in phonegap  when any event/method get call in Objective C code?

Thanx in advance

答:
You can invoke your Javascript logic from Objective C by calling "stringByEvaluatingJavascriptFromString" on the WebView object:</p>

```<code>NSString* jsCallback = @"alert(\"Alert from Objective C!\");";
[webView stringByEvaluatingJavaScriptFromString:jsCallback ];
</code>```

Title: Detect Objective C event from PhoneGap

Body:
You can invoke your Javascript logic from Objective C by calling "stringByEvaluatingJavascriptFromString" on the WebView object:

NSString* jsCallback = @"alert(\"Alert from Objective C!\");";
[webView stringByEvaluatingJavaScriptFromString:jsCallback ];


问:
Request only method returns original request array
So I'm manipulating Request and setting an object to new value.

```<code>$assignable = ['seats'];
$request->seats = $this->myMethod($request->seats);

var_dump($request->seats); //works
$data = $request->only($assignable);
var_dump($data['seats']); // returns the initial value of 'seats' (without passing through $this->myMethod)
</code>```

Now I know I could first convert the request object to array and then manipulate the '$data', but the above code is a sample and the real code is much more complicated, it would require to change the whole architecture to do that way.

Has anyone experienced anything like this?

答:
Instead of this:

```<code>$request->seats = $this->myMethod($request->seats);
</code>```

Try this:

```<code>$request->merge(['seats' => $this->myMethod($request->seats)]);
</code>```

Body:
So I'm manipulating Request and setting an object to new value.

$assignable = ['seats'];
$request->seats = $this->myMethod($request->seats);

var_dump($request->seats); //works
$data = $request->only($assignable);
var_dump($data['seats']); // returns the initial value of 'seats' (without passing through $this->myMethod)

Now I know I could first convert the request object to array and then manipulate the '$data', but the above code is a sample and the real code is much more complicated, it would require to change the whole architecture to do that way.

Has anyone experienced anything like this?

Body:
Instead of this:

$request->seats = $this->myMethod($request->seats);

Try this:

$request->merge(['seats' => $this->myMethod($request->seats)]);


问:
Try to create a plugin to auto load all components in nuxt.js
I try to load and define globally all my components under nuxt.js.

When I try to load the *.vue file, I get the following error: "Cannot find module ....".

But the file is present in the specified location...

Here is the loading plugin :

```<code>import Vue from 'vue'
import fs from 'fs'
import path from 'path'

const componentDirectory = `.${path.sep}src${path.sep}components`;
const componentTypes = ['atom','molecule','organism'];

function getComponentType(componentName) {

    let compGroup = ( componentName || '' ).toLowerCase().split('.');

    if (compGroup.length < 3 || compGroup[ compGroup.length - 1 ] !== 'vue' ) {
        return null;
    }

    return compGroup[ compGroup.length - 2 ];
}

function allowedComponentType(componentFileName) {
    return componentTypes.indexOf(getComponentType(componentFileName)) !== -1;
}

// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
    var files = fs.readdirSync(dir);
    filelist = filelist || [];

    files.forEach(function (file) {
        if (fs.statSync(dir + path.sep + file).isDirectory()) {
            filelist = walkSync(dir + path.sep + file, filelist);
        } else if (allowedComponentType(file) ) {
            filelist.push(dir + path.sep + file);
        }
    });

    return filelist;
};

walkSync(componentDirectory).forEach(componentFileName => {
    try {
        let componentPath = path.resolve(path.resolve(), componentFileName);

        console.log('Component name : ', componentPath)
        const component = require(componentPath).default;
        Vue.component(component.name, component);
    }
    catch (e) {
        console.log('Error : ' , e )
    }
});

</code>```

P.S .: I will replace functions by a regular expression once the problem is solved.

答:
Make a js file with this content in your components folder:

```<code>import Vue from 'vue'

const requireComponent = require.context('@/components', true, /\.vue$/)

requireComponent.keys().forEach(fileName => {
  const componentConfig = requireComponent(fileName)
  const componentName = fileName
    .replace(/^\.\//, '')
    .replace(/\.\w+$/, '')
    .replace(/\//g, '-')
    .toLowerCase()
  Vue.component(componentName, componentConfig.default || componentConfig)
})
</code>```

then simply import that in your layout .vue file.

Body:
I try to load and define globally all my components under nuxt.js.

When I try to load the *.vue file, I get the following error: "Cannot find module ....".

But the file is present in the specified location...

Here is the loading plugin :

import Vue from 'vue'
import fs from 'fs'
import path from 'path'

const componentDirectory = `.${path.sep}src${path.sep}components`;
const componentTypes = ['atom','molecule','organism'];

function getComponentType(componentName) {

    let compGroup = ( componentName || '' ).toLowerCase().split('.');

    if (compGroup.length < 3 || compGroup[ compGroup.length - 1 ] !== 'vue' ) {
        return null;
    }

    return compGroup[ compGroup.length - 2 ];
}

function allowedComponentType(componentFileName) {
    return componentTypes.indexOf(getComponentType(componentFileName)) !== -1;
}

// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
    var files = fs.readdirSync(dir);
    filelist = filelist || [];

    files.forEach(function (file) {
        if (fs.statSync(dir + path.sep + file).isDirectory()) {
            filelist = walkSync(dir + path.sep + file, filelist);
        } else if (allowedComponentType(file) ) {
            filelist.push(dir + path.sep + file);
        }
    });

    return filelist;
};

walkSync(componentDirectory).forEach(componentFileName => {
    try {
        let componentPath = path.resolve(path.resolve(), componentFileName);

        console.log('Component name : ', componentPath)
        const component = require(componentPath).default;
        Vue.component(component.name, component);
    }
    catch (e) {
        console.log('Error : ' , e )
    }
});

P.S .: I will replace functions by a regular expression once the problem is solved.

Body:
Make a js file with this content in your components folder:

import Vue from 'vue'

const requireComponent = require.context('@/components', true, /\.vue$/)

requireComponent.keys().forEach(fileName => {
  const componentConfig = requireComponent(fileName)
  const componentName = fileName
    .replace(/^\.\//, '')
    .replace(/\.\w+$/, '')
    .replace(/\//g, '-')
    .toLowerCase()
  Vue.component(componentName, componentConfig.default || componentConfig)
})

then simply import that in your layout .vue file.


问:
External GPU for Mac
I'd like to buy an eGPU for my MaxBook Pro to use for simple deep learning tasks. My setup is:

```<code>MacBook Pro (15-inch, 2017)
Graphics: Radeon Pro 555 2 GB
Intel HD Graphics 630 1536 MB
Version: Mojave 10.14.5
</code>```

I understand for Deep Learning (i.e. use of tensorflow-gpu) this is not currently supported for my Mac. Due to previous disputes between Nvidia and Apple I assume that Nvidia's support is reluctant to offer any kind of hacky solution with their graphic cards. On saying that, I was recommended to purchase the NVIDIA TITAN RTX or NVIDIA Quadro® GV100, but they're quite pricey at 1000s of euros/dollars a piece. At first, I just want something to play around with.

I watched this and this to see how to configure the Mac with an eGPU that is CUDA supported.

What Nvidia eGPU would you recommend for simple i.e. not mega large data sets for DL processing? There seems to be so many models to choose from that it's not clear what would satisfy my needs. Would a GIGABYTE GeForce® GTX 1050 Ti OC 4GB suffice?

答: I decided to ditch using my Mac for using an external Nvidia graphic card. There are apparently some hacky solutions but I figured - after reading a many forum posts and online articles - the best way to proceed is just to buy a new (gaming) Desktop PC. One reoccurring theme I did see come up was that in order to have an effective Deep Learning workstation, one should consider at least 16 GB Ram (32 or more is ideal, Intel i7 or better, and 0.5 TB of SDD).</p>

Title: External GPU for Mac

Body:
I'd like to buy an eGPU for my MaxBook Pro to use for simple deep learning tasks. My setup is:

MacBook Pro (15-inch, 2017)
Graphics: Radeon Pro 555 2 GB
Intel HD Graphics 630 1536 MB
Version: Mojave 10.14.5

I understand for Deep Learning (i.e. use of tensorflow-gpu) this is not currently supported for my Mac. Due to previous disputes between Nvidia and Apple I assume that Nvidia's support is reluctant to offer any kind of hacky solution with their graphic cards. On saying that, I was recommended to purchase the NVIDIA TITAN RTX or NVIDIA Quadro® GV100, but they're quite pricey at 1000s of euros/dollars a piece. At first, I just want something to play around with.

I watched this and this to see how to configure the Mac with an eGPU that is CUDA supported.

What Nvidia eGPU would you recommend for simple i.e. not mega large data sets for DL processing? There seems to be so many models to choose from that it's not clear what would satisfy my needs. Would a GIGABYTE GeForce® GTX 1050 Ti OC 4GB suffice?