问:
does not display errors but does not update data in codeigniter
I want to edit some data after POST on CodeIgniter.

The problem is that when I edit, the data is not updated, but there is also no error message displayed. Why?

This my CONTROLLER

```<code>public function edit()
{

    $user = $this->db->get_where('user', ['user_name' => $this->session->userdata('user_name')])->row_array();

    $this->form_validation->set_rules( 'nama', 'Full Name', 'required',
                               array ( 'required'           => '%s Wajib Harus Diisi'));

    $this->form_validation->set_rules( 'company', 'Company', 'required',
                               array ( 'required'           => '%s Wajib Harus Diisi'));

    $this->form_validation->set_rules( 'hphone', 'Hphone', 'required',
                               array ( 'required'           => '%s Wajib Harus Diisi'));

    $this->form_validation->set_rules( 'website', 'Website');

    $this->form_validation->set_rules ( 'email', 'Email', 'required|valid_email',
                                array ( 'required'          => '%s Wajib Harus Diisi',
                                        'valid_email'       => 'Format $s tidak Valid'));

    if ($this->form_validation->run() == FALSE) {

    $data = array ( 'head_title'        => 'Edit User Profile- Edutech Solution',
                    'title'             => 'Edit Data User',
                    'head_menu'         => 'User Administrator',
                    'sub_title'         => 'Total User',
                    'user'              =>  $user,
                    'isi'               => 'superadmin/user/edit',
                  );

    $this->load->view('superadmin/template/wrapper_admin', $data, FALSE);

    } else  {

                $user_name  = $this->input->post('user_name');
                $nama       = $this->input->post('nama');
                $hphone     = $this->input->post('hphone');
                $company    = $this->input->post('company');
                $website    = $this->input->post('website');
                $email      = $this->input->post('email');

                        // jika ada gambar yang di upload
                        $upload_image = $_FILES['image']['nama'];

                        if($upload_image){

                            $config['allowed_types']    = 'gif|jpg|png';
                            $config['max_size']         = '2048'; // 2 MB
                            $config['upload_path']      = '.resch/dev/admin/assets/media/';

                            $this->load->library('upload', $config);

                            if($this->upload->do_upload('image')) {
                                // cek gambar agar tidak doble dan file default tidak terhapus
                                $old_image  = $data['user']['image'];
                                if ($old_image != 'default.png')
                                {
                                    unlink(FCPATH .'resch/dev/admin/assets/media/' .$old_image );
                                }

                                $new_image  = $this->upload->data('file_name');
                                $this->db->set('image', $new_image);

                            }else{
                                echo $this->upload->dispay_errors();
                            }
                        }
                        // END jika ada gambar yang di upload

                $this->db->set('nama', $nama);
                $this->db->set('hphone', $hphone);
                $this->db->set('company', $company);
                $this->db->set('website', $website);
                $this->db->set('email', $email);

                $this->db->where('id_user', $id_user);
                $this->db->update('user');

                // $this->user_model->edit($data);
                $this->session->set_flashdata('msg', 'Data Telah Diupdate');
                redirect(base_url('superadmin/user/edit'),'refresh');

        }
}
</code>```

and the second error, update data with picture not work.

this VIEW EDIT

```<code><?php
    echo form_open_multipart(base_url('superadmin/user/edit'));
    ?>

    <div class="kt-form kt-form--label-right">
      <div class="kt-portlet__body">
        <div class="kt-section kt-section--first">
          <div class="kt-section__body">
            <div class="row">
              <label class="col-xl-3"></label>
              <div class="col-lg-9 col-xl-6">
                <h3 class="kt-section__title kt-section__title-sm">User Info:</h3>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-xl-3 col-lg-3 col-form-label">Avatar</label>
              <div class="col-lg-9 col-xl-6">
                <div class="kt-avatar kt-avatar--outline" id="kt_user_avatar">
                  <div class="kt-avatar__holder" style="background-image: url(<?php echo base_url('resch/dev/admin/assets/media/').$user['image'] ?>)">
                  </div>
                  <label for="image" class="kt-avatar__upload" data-toggle="kt-tooltip" title="" data-original-title="Change avatar">
                    <i class="fa fa-pen"></i>
                    <input class="custom-file-input" type="file" name="image" id="image" accept="image/*">
                  </label>
                  <span class="kt-avatar__cancel" data-toggle="kt-tooltip" title="" data-original-title="Cancel avatar">
                    <i class="fa fa-times"></i>
                  </span>
                </div>
              </div>
            </div>
            <div class="form-group row">
              <label for="nama" class="col-xl-3 col-lg-3 col-form-label">Full Name</label>
              <div class="col-lg-9 col-xl-6">
                <input class="form-control" type="text" name="nama" id="nama" value="<?php echo set_value('$user->nama')?>">
              </div>
            </div>
</code>```

I have checked the code several times, but I found no errors. please help so that this problem can be resolved

答:
In your else, part of controller use the below code only to update the table

```<code>$data = array(
        'user_name'  => $this->input->post('user_name'),
        'nama'       => $this->input->post('nama'),
        'hphone'   => $this->input->post('hphone'),
        'company'    => $this->input->post('company'),
        'website'    => $this->input->post('website'),
        'email'      => $this->input->post('email')
        );
       $this->db->where('id_user', $id_user);
       $this->db->update('user',$data);
</code>```

in your view file change the code to

```<code> <form method = "post" action="base_url('superadmin/user/edit')" multipart >

        <div class="kt-form kt-form--label-right">
          <div class="kt-portlet__body">
            <div class="kt-section kt-section--first">
              <div class="kt-section__body">
                <div class="row">
                  <label class="col-xl-3"></label>
                  <div class="col-lg-9 col-xl-6">
                    <h3 class="kt-section__title kt-section__title-sm">User Info:</h3>
                  </div>
                </div>
                <div class="form-group row">
                  <label class="col-xl-3 col-lg-3 col-form-label">Avatar</label>
                  <div class="col-lg-9 col-xl-6">
                    <div class="kt-avatar kt-avatar--outline" id="kt_user_avatar">
                      <div class="kt-avatar__holder" style="background-image: url(<?php echo base_url('resch/dev/admin/assets/media/').$user['image'] ?>)">
                      </div>
                      <label for="image" class="kt-avatar__upload" data-toggle="kt-tooltip" title="" data-original-title="Change avatar">
                        <i class="fa fa-pen"></i>
                        <input class="custom-file-input" type="file" name="image" id="image" accept="image/*">
                      </label>
                      <span class="kt-avatar__cancel" data-toggle="kt-tooltip" title="" data-original-title="Cancel avatar">
                        <i class="fa fa-times"></i>
                      </span>
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="nama" class="col-xl-3 col-lg-3 col-form-label">Full Name</label>
                  <div class="col-lg-9 col-xl-6">
                    <input class="form-control" type="text" name="nama" id="nama" value="<?php echo set_value('$user->nama')?>">
                  </div>
                </div>

    <input type="submit" name="submit" value="sumbit" >
    </form>
</code>```

although I do not suggest you to update directly from controller, for any database related query you should always use models

Body:
I want to edit some data after POST on CodeIgniter.

The problem is that when I edit, the data is not updated, but there is also no error message displayed. Why?

This my CONTROLLER

public function edit()
{

    $user = $this->db->get_where('user', ['user_name' => $this->session->userdata('user_name')])->row_array();

    $this->form_validation->set_rules( 'nama', 'Full Name', 'required',
                               array ( 'required'           => '%s Wajib Harus Diisi'));

    $this->form_validation->set_rules( 'company', 'Company', 'required',
                               array ( 'required'           => '%s Wajib Harus Diisi'));

    $this->form_validation->set_rules( 'hphone', 'Hphone', 'required',
                               array ( 'required'           => '%s Wajib Harus Diisi'));

    $this->form_validation->set_rules( 'website', 'Website');

    $this->form_validation->set_rules ( 'email', 'Email', 'required|valid_email',
                                array ( 'required'          => '%s Wajib Harus Diisi',
                                        'valid_email'       => 'Format $s tidak Valid'));

    if ($this->form_validation->run() == FALSE) {

    $data = array ( 'head_title'        => 'Edit User Profile- Edutech Solution',
                    'title'             => 'Edit Data User',
                    'head_menu'         => 'User Administrator',
                    'sub_title'         => 'Total User',
                    'user'              =>  $user,
                    'isi'               => 'superadmin/user/edit',
                  );

    $this->load->view('superadmin/template/wrapper_admin', $data, FALSE);

    } else  {

                $user_name  = $this->input->post('user_name');
                $nama       = $this->input->post('nama');
                $hphone     = $this->input->post('hphone');
                $company    = $this->input->post('company');
                $website    = $this->input->post('website');
                $email      = $this->input->post('email');

                        // jika ada gambar yang di upload
                        $upload_image = $_FILES['image']['nama'];

                        if($upload_image){

                            $config['allowed_types']    = 'gif|jpg|png';
                            $config['max_size']         = '2048'; // 2 MB
                            $config['upload_path']      = '.resch/dev/admin/assets/media/';

                            $this->load->library('upload', $config);

                            if($this->upload->do_upload('image')) {
                                // cek gambar agar tidak doble dan file default tidak terhapus
                                $old_image  = $data['user']['image'];
                                if ($old_image != 'default.png')
                                {
                                    unlink(FCPATH .'resch/dev/admin/assets/media/' .$old_image );
                                }

                                $new_image  = $this->upload->data('file_name');
                                $this->db->set('image', $new_image);

                            }else{
                                echo $this->upload->dispay_errors();
                            }
                        }
                        // END jika ada gambar yang di upload

                $this->db->set('nama', $nama);
                $this->db->set('hphone', $hphone);
                $this->db->set('company', $company);
                $this->db->set('website', $website);
                $this->db->set('email', $email);

                $this->db->where('id_user', $id_user);
                $this->db->update('user');

                // $this->user_model->edit($data);
                $this->session->set_flashdata('msg', 'Data Telah Diupdate');
                redirect(base_url('superadmin/user/edit'),'refresh');

        }
}

and the second error, update data with picture not work.

this VIEW EDIT

<?php
    echo form_open_multipart(base_url('superadmin/user/edit'));
    ?>

User Info:

              Avatar

                  <div class="kt-avatar__holder" style="background-image: url(<?php echo base_url('resch/dev/admin/assets/media/').$user['image'] ?>)">

                    <input class="custom-file-input" type="file" name="image" id="image" accept="image/*">

              Full Name

                <input class="form-control" type="text" name="nama" id="nama" value="<?php echo set_value('$user->nama')?>">

I have checked the code several times, but I found no errors. please help so that this problem can be resolved

Body:
In your else, part of controller use the below code only to update the table

$data = array(
        'user_name'  => $this->input->post('user_name'),
        'nama'       => $this->input->post('nama'),
        'hphone'   => $this->input->post('hphone'),
        'company'    => $this->input->post('company'),
        'website'    => $this->input->post('website'),
        'email'      => $this->input->post('email')
        );
       $this->db->where('id_user', $id_user);
       $this->db->update('user',$data);

in your view file change the code to

 <form method = "post" action="base_url('superadmin/user/edit')" multipart >

        <div class="kt-form kt-form--label-right">
          <div class="kt-portlet__body">
            <div class="kt-section kt-section--first">
              <div class="kt-section__body">
                <div class="row">
                  <label class="col-xl-3"></label>
                  <div class="col-lg-9 col-xl-6">
                    <h3 class="kt-section__title kt-section__title-sm">User Info:</h3>
                  </div>
                </div>
                <div class="form-group row">
                  <label class="col-xl-3 col-lg-3 col-form-label">Avatar</label>
                  <div class="col-lg-9 col-xl-6">
                    <div class="kt-avatar kt-avatar--outline" id="kt_user_avatar">
                      <div class="kt-avatar__holder" style="background-image: url(<?php echo base_url('resch/dev/admin/assets/media/').$user['image'] ?>)">
                      </div>
                      <label for="image" class="kt-avatar__upload" data-toggle="kt-tooltip" title="" data-original-title="Change avatar">
                        <i class="fa fa-pen"></i>
                        <input class="custom-file-input" type="file" name="image" id="image" accept="image/*">
                      </label>
                      <span class="kt-avatar__cancel" data-toggle="kt-tooltip" title="" data-original-title="Cancel avatar">
                        <i class="fa fa-times"></i>
                      </span>
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="nama" class="col-xl-3 col-lg-3 col-form-label">Full Name</label>
                  <div class="col-lg-9 col-xl-6">
                    <input class="form-control" type="text" name="nama" id="nama" value="<?php echo set_value('$user->nama')?>">
                  </div>
                </div>

    <input type="submit" name="submit" value="sumbit" >
    </form>

although I do not suggest you to update directly from controller, for any database related query you should always use models


来源: stackexchange

问:
Is there any way I can output the variable name instead of the value? [JAVA]
for example, I have a list of integer variables

```<code>int CLUTCH_CASE = 8;
int CS20 = 6;
int DANGER_ZONE_CASE = 6;
int TOTAL_CASE = 0;
</code>```

I have an array:

```<code>int CaseValue[] = {CS20, CLUTCH_CASE, DANGER_ZONE_CASE};
</code>```

and I output the value of total cases, which is going to be:

```<code>for (int counter=0;counter<CaseValue.length;counter++) {
    TOTAL_CASE += CaseValue[counter];
}
System.out.println("You have "+CaseValue.length+" CSGO Cases");
System.out.println("You have a total of "+TOTAL_CASE+" CSGO Cases:");
</code>```

Output:

```<code>You have 3 CSGO Cases
You have a total of 20 CSGO Cases:
</code>```

yet I also want to output the name.

Example:
(CASENAME are just placeholders for this example. I wanted to use CaseValue[].NAME even that does not exist since it's an example)

```<code>for (int counter2=0;counter2<CaseValue.length;counter2++) {
    System.out.println(CASENAME+": "+CaseValue[counter2]);
}
</code>```

My expected and wanted output to be:

```<code>CLUTCH_CASE: 8
CS20: 6
DANGER_ZONE_CASE: 6
</code>```

Is there any way to output the name of the integer variable?

答:
You need to use java.lang.Class and its getFields() method to return an array of java.lang.reflect Field[] class object
Below will give you an idea of how, go take a look in the API docs for a better more suitable set of methods to design the process with a List or Set to use contains() method so you can put it in a class and call when you want in a program.</p>

```<code>import java.lang.Class;
import java.lang.reflect.*;

Field[] varFset = ((java.lang.Class)this).getFields();
// compare names processing code over the array here
String varname = varFset[x].getName();
</code>```

ContentLicense: CC BY-SA 4.0

Body:
for example, I have a list of integer variables

int CLUTCH_CASE = 8;
int CS20 = 6;
int DANGER_ZONE_CASE = 6;
int TOTAL_CASE = 0;

I have an array:

int CaseValue[] = {CS20, CLUTCH_CASE, DANGER_ZONE_CASE};

and I output the value of total cases, which is going to be:

for (int counter=0;counter<CaseValue.length;counter++) {
    TOTAL_CASE += CaseValue[counter];
}
System.out.println("You have "+CaseValue.length+" CSGO Cases");
System.out.println("You have a total of "+TOTAL_CASE+" CSGO Cases:");

Output:

You have 3 CSGO Cases
You have a total of 20 CSGO Cases:

yet I also want to output the name.

Example:
(CASENAME are just placeholders for this example. I wanted to use CaseValue[].NAME even that does not exist since it's an example)

for (int counter2=0;counter2<CaseValue.length;counter2++) {
    System.out.println(CASENAME+": "+CaseValue[counter2]);
}

My expected and wanted output to be:

CLUTCH_CASE: 8
CS20: 6
DANGER_ZONE_CASE: 6

Is there any way to output the name of the integer variable?

Body:
You need to use java.lang.Class and its getFields() method to return an array of java.lang.reflect Field[] class object
Below will give you an idea of how, go take a look in the API docs for a better more suitable set of methods to design the process with a List or Set to use contains() method so you can put it in a class and call when you want in a program.

import java.lang.Class;
import java.lang.reflect.*;

Field[] varFset = ((java.lang.Class)this).getFields();
// compare names processing code over the array here
String varname = varFset[x].getName();


问:
<form> Blocking actions in html
It seems like <form> in the code below is blocking the interaction with the menu and the button.

```<code>
<form style = "position:relative; left:50px; top:0px;" class="pure-form" align="left" top="20px" method="post" action="newtest.php">
   <p>
      Sort By Most
      <select name="sort" method=post action=newtest.php>
         <option value="Kills">Kills</option>
         <option value="Elo">Elo</option>
         <option value="Wins">Wins</option>
         <option value="Deaths">Deaths</option>
         <option value="Lost">Lost</option>
      </select>
      <input type="submit" name="playername" value="Sort" class="button-lightblue button-small pure-button">
   </p>
</form>

</code>```

How can I fix that?

答:
method and action attributes are used with <form> tag and not with <select> tag

```<code><form action="newtest.php" method="post" style = "position:relative; left:50px; top:0px;" class="pure-form" align="left" top="20px">
       <p>
          Sort By Most
          <select name="sort">
             <option value="Kills">Kills</option>
             <option value="Elo">Elo</option>
             <option value="Wins">Wins</option>
             <option value="Deaths">Deaths</option>
             <option value="Lost">Lost</option>
          </select>
          <input type="submit" name="playername" value="Sort" class="button-lightblue button-small pure-button">
       </p>
    </form>
</code>```

Title: <form> Blocking actions in html

Body:
It seems like <form> in the code below is blocking the interaction with the menu and the button.

<form style = "position:relative; left:50px; top:0px;" class="pure-form" align="left" top="20px" method="post" action="newtest.php">

      Sort By Most
      <select name="sort" method=post action=newtest.php>
         <option value="Kills">Kills</option>
         <option value="Elo">Elo</option>
         <option value="Wins">Wins</option>
         <option value="Deaths">Deaths</option>
         <option value="Lost">Lost</option>
      </select>
      <input type="submit" name="playername" value="Sort" class="button-lightblue button-small pure-button">

</form>

How can I fix that?

Body:
method and action attributes are used with <form> tag and not with <select> tag

<form action="newtest.php" method="post" style = "position:relative; left:50px; top:0px;" class="pure-form" align="left" top="20px">
       <p>
          Sort By Most
          <select name="sort">
             <option value="Kills">Kills</option>
             <option value="Elo">Elo</option>
             <option value="Wins">Wins</option>
             <option value="Deaths">Deaths</option>
             <option value="Lost">Lost</option>
          </select>
          <input type="submit" name="playername" value="Sort" class="button-lightblue button-small pure-button">
       </p>
    </form>


问:
Why am I getting an error when I try to do a bulk update in the Workfront API?
I am trying to do a bulk update of a user:

```<code>/attask/api/v9.0/user/5c74714a01438ddef4262ca7d2b589a3?&method=PUT&updates=[{"ID":"5c74714a01438ddef4262ca7d2b589a3","name":"ChefSkyFoxWasHere","homeTeamID":"5ebee6d202125cdad1a6914f47328cd1"}]&apiKey=xxxxxxxx
</code>```

but keep getting this message

```<code>{"error":{"message":"For bulk edits, the id of each object must be in the updates JSON"}}
</code>```

答:
I answered my own question. It was bad syntax:
/attask/api/v9.0/user/5c74714a01438ddef4262ca7d2b589a3/?updates={name:"ChefSkyFoxWasHere",homeTeamID:"5ebee6d202125cdad1a6914f47328cd1"}&method=PUT&apiKey=xxxxxxxx</p>

Body:
I am trying to do a bulk update of a user:

/attask/api/v9.0/user/5c74714a01438ddef4262ca7d2b589a3?&method=PUT&updates=[{"ID":"5c74714a01438ddef4262ca7d2b589a3","name":"ChefSkyFoxWasHere","homeTeamID":"5ebee6d202125cdad1a6914f47328cd1"}]&apiKey=xxxxxxxx

but keep getting this message

{"error":{"message":"For bulk edits, the id of each object must be in the updates JSON"}}


问:
Click a href button with no class, id or link text with Selenium
I'm crawling the webpage: www.ogimet.com and I want to click a href button.

This is the html code:

```<code><a href="/sondc.phtml"><b>S</b>ondeos por territorios</a>
</code>```

How can i click this button? If it's possible avoiding driver.find_element_by_xpath()

答:
Here's how I would do it, I created a re-usable function that returns the first element by tag and matching attributes.</p>

```<code>def getElementByTagAndAttributes(driver, tag, **kwargs):
    for element in driver.find_elements_by_tag_name(tag):
        for key, value in kwargs.items():
            attribute = element.get_attribute(key)
            if attribute != value:
                break
        else:
            return element

getElementByTagAndAttributes(driver, "a", href="/sondc.phtml").click()
</code>```

Body:
I'm crawling the webpage: www.ogimet.com and I want to click a href button.

This is the html code:

Sondeos por territorios

How can i click this button? If it's possible avoiding driver.find_element_by_xpath()

Body:
Here's how I would do it, I created a re-usable function that returns the first element by tag and matching attributes.

def getElementByTagAndAttributes(driver, tag, **kwargs):
    for element in driver.find_elements_by_tag_name(tag):
        for key, value in kwargs.items():
            attribute = element.get_attribute(key)
            if attribute != value:
                break
        else:
            return element

getElementByTagAndAttributes(driver, "a", href="/sondc.phtml").click()


问:
How to merge "sourced" bash scripts to single bash script
I wrote a bash script tool, which contains main.sh, common.sh, config.sh. The main.sh used the commond source to load relative files.

I want to merge all files to single file for the convenience of distribution. Is there any best practice for that?

答:
In your main.sh, replace source common.sh with the contents of common.sh and source config.sh with the contents of config.sh. When you use the command source, Bash executes the content of the file passed as argument in the current shell (as opposed to a subshell). So, removing the code from other files and moving them into main.sh will have the same effect.

Read more about source: https://ss64.com/bash/source.html

Relevant superuser question: https://superuser.com/questions/46139/what-does-source-do


问:
Implementing Selectable user controls inside a ListBox
I have widgets that display data of an entity. I have made user controls to display data for each entity.

```<code> <UserControl x:Class="Widget"
    <Border BorderBrush="#FF000000" CornerRadius="10" Width="220" Height="180">
        <Border.Style>
            <Style TargetType="{x:Type Border}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsSelected}" Value="True">
                        <Setter Property="BorderThickness" Value="5"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsSelected}" Value="False">
                        <Setter Property="BorderThickness" Value="1"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Border.Style>
        <StackPanel Orientation="Vertical">
          <Label>Name</Label>
        </StackPanel>
    </Border>
</UserControl>
</code>```

and the code behind

```<code>public partial class Widget: UserControl
    {
        /// <summary>
        /// Is Selected Dependency property
        /// </summary>
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(StationStatus), new PropertyMetadata(false));

        public bool IsSelected
        {
            get
            {
                return (bool)GetValue(IsSelectedProperty);
            }
            set
            {
                SetValue(IsSelectedProperty, value);
            }
        }

        public Widget()
        {
            InitializeComponent();
        }
    }
</code>```

The user control is rendered in ListBox

```<code>      <ListBox ItemsSource="{Binding WidgetData}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="Single">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel IsItemsHost="True" Grid.Row="0" ItemHeight="200" ItemWidth="230" Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>

                        <ListBox.ItemTemplate>
                            <DataTemplate>
  <view:StationStatus IsSelected="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}, Path=IsSelected}">
                            </view:StationStatus>
                                </view:Widget>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
</code>```

I was expecting the IsSelected of the ListBoxItem would be bound to the user control and the border thickness would change when the Listbox item is selected but is not working as expected.

答:
Name the usercontrol and change the binding in datatrigger to use element name to bind to IsSelected property.
This change is required because, the binding the usercontrol is inheriting doesn't contain IsSelected property i.e., listboxItem data</p>

```<code>    <UserControl x:Class="Widget" Name="widgetUC">
        <Border BorderBrush="#FF000000" CornerRadius="10" Width="220" Height="180">
            <Border.Style>
                <Style TargetType="{x:Type Border}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=widgetUC,Path=IsSelected}" Value="True">
                            <Setter Property="BorderThickness" Value="5"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=widgetUC,Path=IsSelected}" Value="False">
                            <Setter Property="BorderThickness" Value="1"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <!-- Check what is the data binding-->
            <ContentPresenter Content="{Binding}"/>
        </Border>
    </UserControl>
</code>```

Body:
I have widgets that display data of an entity. I have made user controls to display data for each entity.

 <UserControl x:Class="Widget"
    <Border BorderBrush="#FF000000" CornerRadius="10" Width="220" Height="180">
        <Border.Style>

            </Style>
        </Border.Style>
        <StackPanel Orientation="Vertical">
          Name
        </StackPanel>
    </Border>
</UserControl>

and the code behind

public partial class Widget: UserControl
    {
        ///
        /// Is Selected Dependency property
        ///
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(StationStatus), new PropertyMetadata(false));

        public bool IsSelected
        {
            get
            {
                return (bool)GetValue(IsSelectedProperty);
            }
            set
            {
                SetValue(IsSelectedProperty, value);
            }
        }

        public Widget()
        {
            InitializeComponent();
        }
    }

The user control is rendered in ListBox

      <ListBox ItemsSource="{Binding WidgetData}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="Single">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel IsItemsHost="True" Grid.Row="0" ItemHeight="200" ItemWidth="230" Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>

                        <ListBox.ItemTemplate>
                            <DataTemplate>
  <view:StationStatus IsSelected="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}, Path=IsSelected}">
                            </view:StationStatus>
                                </view:Widget>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

I was expecting the IsSelected of the ListBoxItem would be bound to the user control and the border thickness would change when the Listbox item is selected but is not working as expected.

Body:
Name the usercontrol and change the binding in datatrigger to use element name to bind to IsSelected property.
This change is required because, the binding the usercontrol is inheriting doesn't contain IsSelected property i.e., listboxItem data

    <UserControl x:Class="Widget" Name="widgetUC">
        <Border BorderBrush="#FF000000" CornerRadius="10" Width="220" Height="180">
            <Border.Style>
                <Style TargetType="{x:Type Border}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=widgetUC,Path=IsSelected}" Value="True">
                            <Setter Property="BorderThickness" Value="5"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=widgetUC,Path=IsSelected}" Value="False">
                            <Setter Property="BorderThickness" Value="1"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <!-- Check what is the data binding-->
            <ContentPresenter Content="{Binding}"/>
        </Border>
    </UserControl>


答:
The link you provided does have a link text that can be used to select it, you just need to remove the bold tags, so Sondeos por territorios instead of Sondeos por territorios.

Using driver.find_element_by_link_text:

link = driver.find_element_by_link_text('Sondeos por territorios')
```

Title: Click a href button with no class, id or link text with Selenium

Body:
The link you provided does have a link text that can be used to select it, you just need to remove the bold tags, so Sondeos por territorios instead of <b>S</b>ondeos por territorios.

Using driver.find_element_by_link_text:

link = driver.find_element_by_link_text('Sondeos por territorios')


问:
C# AutoMapper: set destination value by source value after validation in conditional mapping
I'm fairly new to AutoMapper and want to know how to set a destination member to a value based on a DIFFERENT source property value and if that value is null I just want to apply the default behaviour of Automapper (keep destination value when the source is null)

```<code> CreateMap<ClassA, ClassA>()
                    .ForMember(dest => dest.PropertyA, opt =>
                            opt.MapFrom(src => src.PropertyB!= null ? null : opt.UseDestinationValue())
                    )
</code>```

This doesn't work (don't compile) the opt.UseDestinationValue() , what option can I use here?
Please help

答:
Try setting a precondition for mapping destination property.

```<code>CreateMap<ClassA, ClassA>().ForMember(dest => dest.PropertyA, opt => opt.PreCondition((src, dest) => src.PropertyB != null));
</code>```

This will map PropertyA only when PropertyB is not null. I did try a quick sample which gave the desired result.

Body:
I'm fairly new to AutoMapper and want to know how to set a destination member to a value based on a DIFFERENT source property value and if that value is null I just want to apply the default behaviour of Automapper (keep destination value when the source is null)

 CreateMap<ClassA, ClassA>()
                    .ForMember(dest => dest.PropertyA, opt =>
                            opt.MapFrom(src => src.PropertyB!= null ? null : opt.UseDestinationValue())
                    )

This doesn't work (don't compile) the opt.UseDestinationValue() , what option can I use here?
Please help

Body:
Try setting a precondition for mapping destination property.

CreateMap<ClassA, ClassA>().ForMember(dest => dest.PropertyA, opt => opt.PreCondition((src, dest) => src.PropertyB != null));

This will map PropertyA only when PropertyB is not null. I did try a quick sample which gave the desired result.


问:
how can I access the window in an exported function?
given the module generated by opeapi generator, it expects configuration parameters in particular the baseUrl for API calls.
I need to recover the baseUrl from a configuration object injected into the window.
How can I recover it? I cannot directly access the window because the compiler blocks me.
How can I do?

imported angular module:

```<code>ApiModule.forRoot(apiConfig)
</code>```

the function:

```<code>export function apiConfig() {
  return new Configuration({
    basePath: '',
  });
}
</code>```

what i expect is:

```<code>export function apiConfig () {
   return new Configuration ({
     basePath: 'window.config.baseUrl',
   });
}
</code>```

the solution:

```<code>function _window(): any {
  return window
}

export function apiConfig() {
  return new Configuration({
    basePath: _window().config,
  });
}
</code>```

答: You may have to wrap the window object reference and then add it as a provider to use it in your component. See here: https://juristr.com/blog/2016/09/ng2-get-window-ref/</p>

Body:
given the module generated by opeapi generator, it expects configuration parameters in particular the baseUrl for API calls.
I need to recover the baseUrl from a configuration object injected into the window.
How can I recover it? I cannot directly access the window because the compiler blocks me.
How can I do?

imported angular module:

ApiModule.forRoot(apiConfig)

the function:

export function apiConfig() {
  return new Configuration({
    basePath: '',
  });
}

what i expect is:

export function apiConfig () {
   return new Configuration ({
     basePath: 'window.config.baseUrl',
   });
}

the solution:

function _window(): any {
  return window
}

export function apiConfig() {
  return new Configuration({
    basePath: _window().config,
  });
}


问:
Does CakePHP finderQuery work with SQL Server? Where would I debug that?
I'm new to cakePHP, so I may be missing the obvious.

The system is running the latest download using Microsoft SQL Server 2005 as database.  I appreciate that is slightly unusual, but having fixed the URL rewrite I have seen no other issues.

I'd like use a custom finderQuery, but I cannot even seem to replace the default.  Specifically if I use

```<code>    var $hasMany = array(
        'RecyclateTypeConversion' => array(
        'className' => 'RecyclateTypeConversion',
        'foreignKey' => 'recyclate_type_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => 'select RecyclateTypeConversion.* from recyclate_type_conversions AS RecyclateTypeConversion WHERE RecyclateTypeConversion.recyclate_type_id IN ({$__cakeID__$});',
        'counterQuery' => ''
    ),
     };
</code>```

I see this error

Notice (8): Undefined index:
  RecyclateTypeConversion
  [CORE\cake\libs\model\datasources\dbo_source.php,
  line 1099]

However the SQL debug output confirms that the query itself runs fine and returns 4 records, and the view runs perfectly when the finderQuery is not specified.  I've tried for other hasMany tables too - with exactly the same issue.

I've attempted to replace the select all with specific field selects but I still see the same result.  Certainly the query looks correct according to the manual - so what is the issue (and could it be related to using MSSQL?)

EDIT: Also, as this hasn't picked up any answers yet, what would be the best approach to debugging this?  I've started hunting through the cake debugging class, but so far with no results that have enlightened me.  Of course if there is a problem I'll be submitting the fix back to the project.

答:
Try removing the alias from the select - the casting in in the "AS RecyclateTypeConversion" part should handle that for you. I also like to wrap custom queries in double quotes. I might just be paranoid but string parsing errors have bit me in the ass before.

```<code>var $hasMany = array(
    'RecyclateTypeConversion' => array(
    'className' => 'RecyclateTypeConversion',
    'foreignKey' => 'recyclate_type_id',
    'dependent' => false,
    'finderQuery' => "select * from recyclate_type_conversions AS RecyclateTypeConversion WHERE RecyclateTypeConversion.recyclate_type_id IN ({$__cakeID__$});",
);
</code>```

Also, I highly suggest you use the DebugKit plugin and post back to us the query log and a debug output of the find results that cause the errors.

ContentLicense: CC BY-SA 3.0

Body:
I'm new to cakePHP, so I may be missing the obvious.

The system is running the latest download using Microsoft SQL Server 2005 as database.  I appreciate that is slightly unusual, but having fixed the URL rewrite I have seen no other issues.

I'd like use a custom finderQuery, but I cannot even seem to replace the default.  Specifically if I use

    var $hasMany = array(
        'RecyclateTypeConversion' => array(
        'className' => 'RecyclateTypeConversion',
        'foreignKey' => 'recyclate_type_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => 'select RecyclateTypeConversion.* from recyclate_type_conversions AS RecyclateTypeConversion WHERE RecyclateTypeConversion.recyclate_type_id IN ({$__cakeID__$});',
        'counterQuery' => ''
    ),
     };

I see this error

Notice (8): Undefined index:
  RecyclateTypeConversion
  [CORE\cake\libs\model\datasources\dbo_source.php,
  line 1099]

However the SQL debug output confirms that the query itself runs fine and returns 4 records, and the view runs perfectly when the finderQuery is not specified.  I've tried for other hasMany tables too - with exactly the same issue.

I've attempted to replace the select all with specific field selects but I still see the same result.  Certainly the query looks correct according to the manual - so what is the issue (and could it be related to using MSSQL?)

EDIT: Also, as this hasn't picked up any answers yet, what would be the best approach to debugging this?  I've started hunting through the cake debugging class, but so far with no results that have enlightened me.  Of course if there is a problem I'll be submitting the fix back to the project.

Body:
Try removing the alias from the select - the casting in in the "AS RecyclateTypeConversion" part should handle that for you. I also like to wrap custom queries in double quotes. I might just be paranoid but string parsing errors have bit me in the ass before.

var $hasMany = array(
    'RecyclateTypeConversion' => array(
    'className' => 'RecyclateTypeConversion',
    'foreignKey' => 'recyclate_type_id',
    'dependent' => false,
    'finderQuery' => "select * from recyclate_type_conversions AS RecyclateTypeConversion WHERE RecyclateTypeConversion.recyclate_type_id IN ({$__cakeID__$});",
);

Also, I highly suggest you use the DebugKit plugin and post back to us the query log and a debug output of the find results that cause the errors.


问:
Precache html pages in flutter
I have a list of some HTML pages that i show in my web_view. The problem is that it will load slowly when network is slow or wont show at all if user is offline. So i want to pre-cache all the URLs before navigating to that page. After that I want to load from the cache and navigate through the URLs on swipe. (The Swipe part is done with URLs loading real-time). My question to you is how do I pre-cache every URLs and call it in my web_view later</p>

答:
If you are sure that those pages are static..I have a suggestion for you..

Like you said, you can pre-cache..

Initially, when internet is available you get the code of those URLs using
http package and store it in local storage, say some .txt file.

And then, when you want to show the page in your app, again..as it being static page, you can read the html code from local storage and show it in your app using html package.

Hope it answers your question.

Title: Precache html pages in flutter


问:
Spring boot application as a service + VM Options
I have a Spring boot application that is started as a service using Linux's systemd.

It is based on this documentation :
http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html

With the default script, the jar file start. It works fine.

/etc/systemd/system/myapp.service :

```<code>[Unit]
Description=myapp
After=syslog.target

[Service]
User=myapp
ExecStart=/var/myapp/myapp.jar
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
</code>```

Now I want to add VM Option when the jar start.
I tried to add a .conf file to the project but it doesn't work.

/var/myapp/myapp.conf :

```<code>JAVA_OPTS=-Xms256M -Xmx512M
</code>```

How can I add JVM option to start the application with systemd ?

答:
Another good way is to create a configuration file myapp.conf in the same directory with the myapp.jar file

```<code>/var/myapp/
</code>```

and put the following content:

```<code>JAVA_OPTS="-Xms256m -Xmx512m"
</code>```

Then restart the application.

Note that the name of configuration file should be the same with the jar file except the extension, .conf instead of .jar or .war.

This way have some other advantages:

Keep the settings separately for the myapp application only.

We can have additional parameters in the file too.

More detail can be found here.

Body:
I have a Spring boot application that is started as a service using Linux's systemd.

It is based on this documentation :
http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html

With the default script, the jar file start. It works fine.

/etc/systemd/system/myapp.service :

[Unit]
Description=myapp
After=syslog.target

[Service]
User=myapp
ExecStart=/var/myapp/myapp.jar
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

Now I want to add VM Option when the jar start.
I tried to add a .conf file to the project but it doesn't work.

/var/myapp/myapp.conf :

JAVA_OPTS=-Xms256M -Xmx512M

How can I add JVM option to start the application with systemd ?

Body:
Another good way is to create a configuration file myapp.conf in the same directory with the myapp.jar file

/var/myapp/

and put the following content:

JAVA_OPTS="-Xms256m -Xmx512m"

Then restart the application.

Note that the name of configuration file should be the same with the jar file except the extension, .conf instead of .jar or .war.

This way have some other advantages:

Keep the settings separately for the myapp application only.

We can have additional parameters in the file too.

More detail can be found here.


问:
C# and Html Agility Pack
I have multiple files, from which I have to extract tables containing data. Problem is tables don't have IDs, so I have to search based on the  content (which is constant in each file). There are multiple tables in each file and the table of interest doesn't have constant XPath.

```<code><table border="0" cellspacing="0" cellpadding="0" style="BORDER-COLLAPSE: collapse" bordercolor="#111111">
    <tbody>
        <tr>
            <td class="s">CONSTANT_TEXT</td>
            <td class="l">CHANGING_VALUE</td>
        </tr>

        <tr>
            <td class="s"> </td>
            <td class="l"><a style="" id="CONSTANT_ID" href="mailto: XXXX</a>
 </td>
        </tr>
    </tbody>

</table>
</code>```

How do I:
1. Search based on the CONSTANT_TEXT  CONSTANT_TEXT , return the value of 2nd TD  CHANGING_VALUE , without knowing the  Path (it doesn't have ID and it's position changes from file to file).
2. Search based on CONSTANT_TEXT  CONSTANT_TEXT , return the Parent table of that TD

What I did is to search and return  CONSTANT_TEXT , with Html Agility Pack, then iterate the XPath upwards until the Table is reached.

```<code>var output= document.DocumentNode.SelectNodes("//a[@id='CONSTANT_ID']");
output[0].XPath ="/html[1]/body[1]/table[1]/thead[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[2]/td[2]/a[1]"
</code>```

My plan was to iterate each output and get the XPath for lowest table occurring, table[1], then extract the data.

Thanks,
Mike

答:
Strictly speaking, you'll need the following XPath :

Search based on the CONSTANT_TEXT CONSTANT_TEXT , return the value of
  2nd TD CHANGING_VALUE

```<code>//td[.="CONSTANT_TEXT"]/following-sibling::td[1]/text()
</code>```

Output : CHANGING_VALUE

Search based on CONSTANT_TEXT CONSTANT_TEXT , return the Parent table of that TD

```<code>//td[.="CONSTANT_TEXT"]/ancestor::table[1]
</code>```

Output :
 element

Title: C# and Html Agility Pack

Body:
I have multiple files, from which I have to extract tables containing data. Problem is tables don't have IDs, so I have to search based on the  content (which is constant in each file). There are multiple tables in each file and the table of interest doesn't have constant XPath.

            CONSTANT_TEXT
            CHANGING_VALUE

            <a style="" id="CONSTANT_ID" href="mailto: XXXX

How do I:
1. Search based on the CONSTANT_TEXT  CONSTANT_TEXT , return the value of 2nd TD  CHANGING_VALUE , without knowing the  Path (it doesn't have ID and it's position changes from file to file).
2. Search based on CONSTANT_TEXT  CONSTANT_TEXT , return the Parent table of that TD

What I did is to search and return  CONSTANT_TEXT , with Html Agility Pack, then iterate the XPath upwards until the Table is reached.

var output= document.DocumentNode.SelectNodes("//a[@id='CONSTANT_ID']");
output[0].XPath ="/html[1]/body[1]/table[1]/thead[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[2]/td[2]/a[1]"

My plan was to iterate each output and get the XPath for lowest table occurring, table[1], then extract the data.

Thanks,
Mike

Body:
Strictly speaking, you'll need the following XPath :

Search based on the CONSTANT_TEXT CONSTANT_TEXT , return the value of
  2nd TD CHANGING_VALUE

//td[.="CONSTANT_TEXT"]/following-sibling::td[1]/text()

Output : CHANGING_VALUE

Search based on CONSTANT_TEXT CONSTANT_TEXT , return the Parent table of that TD

//td[.="CONSTANT_TEXT"]/ancestor::table[1]

Output : <table> element


问:
White panel arrives on double tap from bottom in PWA in standalone mode
We have found a behaviour that in my opinion is a bug in Safari. Install the PWA on iOS to Home Screen, open app in standalone mode and tap to any text input, close the keyboard and double-tap on free space (it zooms out if zoomed, then double tap again), the white block appears from bottom of the page. Probably it is caused by the “keyboard” to offset the content when keyboard is active. I have tried with Angular and with React to create empty project and adding just an input and some coloring so the block is more visible. Both repositories are available on GitHub and deployed to Firebase. I have tried with a few production PWA of different companies, all apps had the same (buggy) behavior. I have reported to Apple already. Does anybody found a solution or tip how to prevent the scrolling?

Angular

https://github.com/lenkavon/pwa-double-tap-bug-ng

https://pwa-double-tap-bug-ng.firebaseapp.com

React

https://github.com/lenkavon/pwa-react-double-tap

https://pwa-double-tap-bug.firebaseapp.com

Steps to reproduce

 - on iPhone iOS11.*, iOS12.*

 - install the PWA app to homescreen add PWA to homescreen

 - open the app from home - standalone mode

 - tap the input to open the keyboard

 - close keyboard

 - double tap on any free space

Behavior: white panel arrives from bottom of the display (probably the 'space' for keyboard)

Expected behavior: zoom or nothing depending on meta tags.

https://i.makeagif.com/media/3-12-2019/WQwlCk.gif

答:
This is still a bug today in iOS13 but I have found a work around.

You can add an empty touchstart event listener to a parent element. Ideally you select an element that covers the entire viewport that isn't document.body. The event listener will prevent the double-tap from triggering the invisible keyboard.

Using your angular example, the problem is fixed with the following:

```<code>document.querySelector('app-root').addEventListener('touchstart', (e) => {});
</code>```

Body:
This is still a bug today in iOS13 but I have found a work around.

You can add an empty touchstart event listener to a parent element. Ideally you select an element that covers the entire viewport that isn't document.body. The event listener will prevent the double-tap from triggering the invisible keyboard.

Using your angular example, the problem is fixed with the following:

document.querySelector('app-root').addEventListener('touchstart', (e) => {});


问:
Cant assign a string to a list to manipulate a value

current_game = [
    ['y', 1, 1],
      [1, 1, 1],
      [1, 1, 1]
]
current_game[0][0][0] = "X"
print(current_game)
```

This gives me an error when I run the code. "TypeError: 'str' object does not support item assignment"

答:
Look at what you've written and break it down:

current_game[0] refers to

```<code>['y', 1, 1]
</code>```

And current_game[0][0] refers to

```<code>'y'
</code>```

So current_game[0][0][0] is referring to the first letter of your string (of length one).

You're trying to change the first letter of that string, but strings are immutable in Python.

I think you might intend to replace the string in the list, not modify it. In that case, remove one level of array access:

```<code>current_game[0][0] = "X"
</code>```

Body:
current_game = [
    ['y', 1, 1],
      [1, 1, 1],
      [1, 1, 1]
]
current_game[0][0][0] = "X"
print(current_game)

This gives me an error when I run the code. "TypeError: 'str' object does not support item assignment"

Body:
Look at what you've written and break it down:

current_game[0] refers to

['y', 1, 1]

And current_game[0][0] refers to

'y'

So current_game[0][0][0] is referring to the first letter of your string (of length one).

You're trying to change the first letter of that string, but strings are immutable in Python.

I think you might intend to replace the string in the list, not modify it. In that case, remove one level of array access:

current_game[0][0] = "X"


问:
Can I force CloudFormation to delete non-empty S3 Bucket?
Is there any way to force CloudFormation to delete a non-empty S3 Bucket?</p>

答:
botocore.vendored is deprecated and will be removed from Lambda after 2021/01/30.

Here is an update version

```<code>Type: AWS::Lambda::Function
Properties:
  Code:
    ZipFile:
      !Sub |
        import json, boto3, logging
        import cfnresponse
        logger = logging.getLogger()
        logger.setLevel(logging.INFO)

        def lambda_handler(event, context):
            logger.info("event: {}".format(event))
            try:
                bucket = event['ResourceProperties']['BucketName']
                logger.info("bucket: {}, event['RequestType']: {}".format(bucket,event['RequestType']))
                if event['RequestType'] == 'Delete':
                    s3 = boto3.resource('s3')
                    bucket = s3.Bucket(bucket)
                    for obj in bucket.objects.filter():
                        logger.info("delete obj: {}".format(obj))
                        s3.Object(bucket.name, obj.key).delete()

                sendResponseCfn(event, context, cfnresponse.SUCCESS)
            except Exception as e:
                logger.info("Exception: {}".format(e))
                sendResponseCfn(event, context, cfnresponse.FAILED)

        def sendResponseCfn(event, context, responseStatus):
            responseData = {}
            responseData['Data'] = {}
            cfnresponse.send(event, context, responseStatus, responseData, "CustomResourcePhysicalID")

  Handler: "index.lambda_handler"
  Runtime: python3.7
  MemorySize: 128
  Timeout: 60
  Role: !GetAtt TSIemptyBucketOnDeleteFunctionRole.Arn
</code>```

Body:
botocore.vendored is deprecated and will be removed from Lambda after 2021/01/30.

Here is an update version

Type: AWS::Lambda::Function
Properties:
  Code:
    ZipFile:
      !Sub |
        import json, boto3, logging
        import cfnresponse
        logger = logging.getLogger()
        logger.setLevel(logging.INFO)

        def lambda_handler(event, context):
            logger.info("event: {}".format(event))
            try:
                bucket = event['ResourceProperties']['BucketName']
                logger.info("bucket: {}, event['RequestType']: {}".format(bucket,event['RequestType']))
                if event['RequestType'] == 'Delete':
                    s3 = boto3.resource('s3')
                    bucket = s3.Bucket(bucket)
                    for obj in bucket.objects.filter():
                        logger.info("delete obj: {}".format(obj))
                        s3.Object(bucket.name, obj.key).delete()

                sendResponseCfn(event, context, cfnresponse.SUCCESS)
            except Exception as e:
                logger.info("Exception: {}".format(e))
                sendResponseCfn(event, context, cfnresponse.FAILED)

        def sendResponseCfn(event, context, responseStatus):
            responseData = {}
            responseData['Data'] = {}
            cfnresponse.send(event, context, responseStatus, responseData, "CustomResourcePhysicalID")

  Handler: "index.lambda_handler"
  Runtime: python3.7
  MemorySize: 128
  Timeout: 60
  Role: !GetAtt TSIemptyBucketOnDeleteFunctionRole.Arn


问:
Selecting data in two tables
I have two tables: who contains these fields:

gmdc_employee

```<code>file_id     company_id  employee_id     employee_name   file_description    file_date      file_name              folder_access        upload_date  confirmation
    1        20111253     20080407         Mariel             file1         2000-01-01  agent_masterlist.xls    documents/20111253/     2011-05-16    Pending
    2        20112301     20864125         Keisha             file2         2000-02-01  auto_lapsed.xls         documents/20112301/     2011-05-16    Pending
   11        20111253     65513215          Rovy              file15        2008-01-01  attendancesheet.xls     documents/20111253/     2011-06-01    Pending
</code>```

gmdc_user

```<code>company_id  company_name    employee_id     employee_name   username    password_clear           password_hash              login_number         last_login
 25014462       NCST          20132248          Danica      ncst            ncst         c7b080d11d6766a27c02591f74b2ea4d        3           2011-05-23 11:25:03
 20112301       EAC           20113318          Emilio      eac             each         933dd8674c563081260867dfa95b5e74        4           2011-05-23 11:52:58
 20111253       DLSU          20080040          John        dlsu            dasma        3c26c824914144d0addf0ceb850ed78a        15          2011-06-01 10:45:32
</code>```

This is the query I used when I first need to get items in my gmdc_employee tables: the '%$search%' is my name for my search button and '$listname%' is my name for my panel tabs(A-Z list):

```<code>select *
   from gmdc_employee
   where employee_name like '%$search%'
     AND employee_name like '$listname%'
</code>```

The problem is in my search button. Before, my search button will only search the employee_name (my code above is the one i used which is working). But the conditions changed unfortunately :( I was asked that aside from searching the employee_name(found in gmdc_employee table) the user may also search for employee_id (which is found in the gmdc_employee) and company_name (which is found in the gmdc_user), but I don't know how to do that :( I haven't learnt from school yet about the joining of two tables, although I learned a way to do that and tried it. Unfortunately it produced wrong results. So may I give an example?

If the user searched for the company name DLSU, the output should look like this:

```<code>employee_id     employee_name   title   file_date    status    confirmation
  20080407        Mariel        file1   2000-01-01   Pending     delete //delete is a link
  65513215         Rovy         file15  2008-01-01   Pending     delete
</code>```

as to what you see,it searches and echoes files under the company name "DLSU" I hope someone could help me here :( I already tried everything but nothing works the way it was suppose to.

This is what I tried to used that produces wrong outputs. :( it echoed all data needed where and did not look in the condition that only the searched company_name info should output:

```<code>select
      a.employee_id,
      a.employee_name,
      a.file_description,
      a.file_date,
      a.confirmation
   from
      gmdc_employee  AS a
         JOIN gmdc_user AS b
   WHERE
          a.employee_name like'%'
      AND a.employee_id like '%'
      AND b.company_name like 'DLSU'
</code>```

答:
I've formatted your queries, and it looks like you were very close... you just didn't have the ON condition for your join

```<code>select
      a.employee_id,
      a.employee_name,
      a.file_description,
      a.file_date,
      a.confirmation
   from
      gmdc_employee  AS a
         JOIN gmdc_user AS b
            on a.employee_id = b.employee_id
   WHERE
          ( a.employee_name like'%$search%'
          OR b.employee_name like '%$search%' )
      AND b.company_name like 'DLSU'
</code>```

I'm not really sure this is the proper join is by the employee ID or not... you don't show any instances of same "employee" vs "user".  With no "ON" condition, its basically going to create a Cartesian join otherwise (or outright error out)...  You may also want to logically OR if you are looking for multiple criteria... such as the name found in one field OR the other... if found in both, no problem...

Title: Selecting data in two tables

Body:
I have two tables: who contains these fields:

gmdc_employee

file_id     company_id  employee_id     employee_name   file_description    file_date      file_name              folder_access        upload_date  confirmation
    1        20111253     20080407         Mariel             file1         2000-01-01  agent_masterlist.xls    documents/20111253/     2011-05-16    Pending
    2        20112301     20864125         Keisha             file2         2000-02-01  auto_lapsed.xls         documents/20112301/     2011-05-16    Pending
   11        20111253     65513215          Rovy              file15        2008-01-01  attendancesheet.xls     documents/20111253/     2011-06-01    Pending

gmdc_user

company_id  company_name    employee_id     employee_name   username    password_clear           password_hash              login_number         last_login
 25014462       NCST          20132248          Danica      ncst            ncst         c7b080d11d6766a27c02591f74b2ea4d        3           2011-05-23 11:25:03
 20112301       EAC           20113318          Emilio      eac             each         933dd8674c563081260867dfa95b5e74        4           2011-05-23 11:52:58
 20111253       DLSU          20080040          John        dlsu            dasma        3c26c824914144d0addf0ceb850ed78a        15          2011-06-01 10:45:32

This is the query I used when I first need to get items in my gmdc_employee tables: the '%$search%' is my name for my search button and '$listname%' is my name for my panel tabs(A-Z list):

select *
   from gmdc_employee
   where employee_name like '%$search%'
     AND employee_name like '$listname%'

The problem is in my search button. Before, my search button will only search the employee_name (my code above is the one i used which is working). But the conditions changed unfortunately :( I was asked that aside from searching the employee_name(found in gmdc_employee table) the user may also search for employee_id (which is found in the gmdc_employee) and company_name (which is found in the gmdc_user), but I don't know how to do that :( I haven't learnt from school yet about the joining of two tables, although I learned a way to do that and tried it. Unfortunately it produced wrong results. So may I give an example?

If the user searched for the company name DLSU, the output should look like this:

employee_id     employee_name   title   file_date    status    confirmation
  20080407        Mariel        file1   2000-01-01   Pending     delete //delete is a link
  65513215         Rovy         file15  2008-01-01   Pending     delete

as to what you see,it searches and echoes files under the company name "DLSU" I hope someone could help me here :( I already tried everything but nothing works the way it was suppose to.

This is what I tried to used that produces wrong outputs. :( it echoed all data needed where and did not look in the condition that only the searched company_name info should output:

select
      a.employee_id,
      a.employee_name,
      a.file_description,
      a.file_date,
      a.confirmation
   from
      gmdc_employee  AS a
         JOIN gmdc_user AS b
   WHERE
          a.employee_name like'%'
      AND a.employee_id like '%'
      AND b.company_name like 'DLSU'

Body:
I've formatted your queries, and it looks like you were very close... you just didn't have the ON condition for your join

select
      a.employee_id,
      a.employee_name,
      a.file_description,
      a.file_date,
      a.confirmation
   from
      gmdc_employee  AS a
         JOIN gmdc_user AS b
            on a.employee_id = b.employee_id
   WHERE
          ( a.employee_name like'%$search%'
          OR b.employee_name like '%$search%' )
      AND b.company_name like 'DLSU'

I'm not really sure this is the proper join is by the employee ID or not... you don't show any instances of same "employee" vs "user".  With no "ON" condition, its basically going to create a Cartesian join otherwise (or outright error out)...  You may also want to logically OR if you are looking for multiple criteria... such as the name found in one field OR the other... if found in both, no problem...


问:
Sort the array according to the alphabetic order of the last names of the students
Sort the array according to the alphabetic order of the last names of the students and print the array to the console.

But the code does not show the output correctly, why?

If i give input. Suppose,

input:

```<code>Enter the value of number: 2
Please enter the name of the student:
Nihan ahmed
</code>```

output:

```<code>After sorting the array:
Nihan ahmed
</code>```

Why can't I input more than one name?

```<code>#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
void main()
{
    char name[10][8], temp[8];
    int i,j,n,L,k;
    printf("Enter the value of number:\n");
    scanf("%d", &n);
    fflush(stdin);
    printf("\n");
    printf("Please enter the name of the student:\n");
    for(i=0;i<n;i++)
    {
        gets(name[i]);
    }
    for(i=0;i<n-1;i++)
    {
        k=0;
        while(1)
        {
            ++k;
            if(name[i][k]==' ')
            break;
        }
        for(j=i+1;j<n;j++)
        {
           L=0;
           while(1)
           {
               ++L;
               if(name[j][L]==' ')
               break;
           }
            if(name[i][k+1]>name[j][L+1])
            {
               strcpy(temp,name[i]);
               strcpy(name[i],name[j]);
               strcpy(name[j],temp);
            }
        }
    }
    printf("After sorting the array:\n");
    for(i=0;i<n;i++)
    {
        puts(name[i]);
    }
    return 0;
}
</code>```

答:
you are reading n times according to this loop :

```<code>for(i=0;i<n;i++)
{
   gets(name[i]);
}
</code>```

what this loop is doing is reading a 10 words, when you write nihan ahmed you are storing 2 string name[0] has Nisan in it and name[1] has Ahmed in it

what you need to do (if you are not familiar with structures which seems like) is:

```<code>for(i=0;i<2*n;i++)
{
   printf ("\n please enter the name of the student number %d: ", i);
   gets(name[i]);
}
</code>```

Body:
Sort the array according to the alphabetic order of the last names of the students and print the array to the console.

But the code does not show the output correctly, why?

If i give input. Suppose,

input:

Enter the value of number: 2
Please enter the name of the student:
Nihan ahmed

output:

After sorting the array:
Nihan ahmed

Why can't I input more than one name?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
void main()
{
    char name[10][8], temp[8];
    int i,j,n,L,k;
    printf("Enter the value of number:\n");
    scanf("%d", &n);
    fflush(stdin);
    printf("\n");
    printf("Please enter the name of the student:\n");
    for(i=0;i<n;i++)
    {
        gets(name[i]);
    }
    for(i=0;i<n-1;i++)
    {
        k=0;
        while(1)
        {
            ++k;
            if(name[i][k]==' ')
            break;
        }
        for(j=i+1;j<n;j++)
        {
           L=0;
           while(1)
           {
               ++L;
               if(name[j][L]==' ')
               break;
           }
            if(name[i][k+1]>name[j][L+1])
            {
               strcpy(temp,name[i]);
               strcpy(name[i],name[j]);
               strcpy(name[j],temp);
            }
        }
    }
    printf("After sorting the array:\n");
    for(i=0;i<n;i++)
    {
        puts(name[i]);
    }
    return 0;
}

Body:
you are reading n times according to this loop :

for(i=0;i<n;i++)
{
   gets(name[i]);
}

what this loop is doing is reading a 10 words, when you write nihan ahmed you are storing 2 string name[0] has Nisan in it and name[1] has Ahmed in it

what you need to do (if you are not familiar with structures which seems like) is:

for(i=0;i<2*n;i++)
{
   printf ("\n please enter the name of the student number %d: ", i);
   gets(name[i]);
}


问:
A logical condiditon in "with" operator doesn't work
I have this code:

```<code>  def edit(conn, params) do
    with m1 <- Repo.get(Model1, params["model1_id"]),
      m2 <- Repo.get(Model2, params["model2_id"]),
      !is_nil(m1) and !is_nil(m2)
    do
      # 1
      res = !is_nil(m1) and !is_nil(m2)
      IO.puts("***** res: #{res}")                              # ===> false

      IO.puts("***** m1: #{Kernel.inspect(m1)}")                # ===> prints a struct
      IO.puts("***** m1 is_nil: #{is_nil(m1)}")                 # ===> false

      IO.puts("***** m2: #{Kernel.inspect(m2)}")                # ===> nil
      IO.puts("***** m2 is_nil: #{is_nil(m2)}")                 # ===> true

    else
      #2
      _ -> raise ArgumentError, "not found"
    end
  end
</code>```

The flow #1 gets executed even though m2 is nil. How can it be? How to fix it?
Goal - ensure that m1 and m2 aren't nil and then execute the flow #1.

答:
Kernel.SpecialtForms.with/1 “early returns” if and only there was no match in the clause.

In the third clause, you have !is_nil(m1) and !is_nil(m2) which roughly means _ <- !is_nil(m1) and !is_nil(m2) and it matches no matter what. To achieve what you want you need to explicitly use proper with clause with <-:

with m1 <- Repo.get(Model1, params["model1_id"]),
     m2 <- Repo.get(Model2, params["model2_id"]),
     true <- !is_nil(m1) and !is_nil(m2), do: ...
```

<p>More natural would be to use proper guards to early return errors:</p>

<pre class="lang-rb prettyprint-override"><code>with m1 when not is_nil(m1) <- Repo.get(Model1, params["model1_id"]),
     m2 when not is_nil(m2) <- Repo.get(Model2, params["model2_id"]),
       do: ...
</code>```

In fact, you don’t need with/1 here. This would do perfectly (thanks for nil being falsey):

if Repo.get(Model1, params["model1_id"]) &&
   Repo.get(Model2, params["model2_id"]), do: ...
```

Body:
I have this code:

  def edit(conn, params) do
    with m1 <- Repo.get(Model1, params["model1_id"]),
      m2 <- Repo.get(Model2, params["model2_id"]),
      !is_nil(m1) and !is_nil(m2)
    do
      # 1
      res = !is_nil(m1) and !is_nil(m2)
      IO.puts("***** res: #{res}")                              # ===> false

      IO.puts("***** m1: #{Kernel.inspect(m1)}")                # ===> prints a struct
      IO.puts("***** m1 is_nil: #{is_nil(m1)}")                 # ===> false

      IO.puts("***** m2: #{Kernel.inspect(m2)}")                # ===> nil
      IO.puts("***** m2 is_nil: #{is_nil(m2)}")                 # ===> true

    else
      #2
      _ -> raise ArgumentError, "not found"
    end
  end

The flow #1 gets executed even though m2 is nil. How can it be? How to fix it?
Goal - ensure that m1 and m2 aren't nil and then execute the flow #1.

Body:
Kernel.SpecialtForms.with/1 “early returns” if and only there was no match in the clause.

In the third clause, you have !is_nil(m1) and !is_nil(m2) which roughly means _ <- !is_nil(m1) and !is_nil(m2) and it matches no matter what. To achieve what you want you need to explicitly use proper with clause with <-:

with m1 <- Repo.get(Model1, params["model1_id"]),
     m2 <- Repo.get(Model2, params["model2_id"]),
     true <- !is_nil(m1) and !is_nil(m2), do: ...

More natural would be to use proper guards to early return errors:

with m1 when not is_nil(m1) <- Repo.get(Model1, params["model1_id"]),
     m2 when not is_nil(m2) <- Repo.get(Model2, params["model2_id"]),
       do: ...

In fact, you don’t need with/1 here. This would do perfectly (thanks for nil being falsey):

if Repo.get(Model1, params["model1_id"]) &&
   Repo.get(Model2, params["model2_id"]), do: ...


问:
Using table function in OBIEE RPD (physical layer) and pass parameter from dashboard prompt to it
I have a almost serious problem. Of course there have been some questions in the same concept of mine, but without any result for me, so I am forced to ask again in different words.
(like:
Passing parameters to stored procedure in OBIEE 12c rpd from OBIEE 12c dashboard
or
table function as physical table in Oracle BI EE
)

To provide a report, I am supposed to use table function(means select * from table(valueof(NQ_SESSION.var .....)) in OBIEE physical layer, then pass value through dashboard prompt in order to update its specified session variable.

To achieve this matter, I have created a non-system session variable and named it as var. Then I have defined a physical object with 'select' table type in physical layer and put the specified SQL code (in above) in it (and have not done anything in logical layer), then a dashboard prompt is crated with a request variable (and is named with defined session variable's name, means var).

Now I receive error ( [nQSError: 27002] Near  '<'var'>' Syntax error (HY000) ). It is worth mentioning that my made BI answer(analysis) works as alone but gets error when used in dashboard with dashboard prompt.

Dose anyone know where I am wrong?

Thanks

答: I found that where and why I was wrong. The problem was around session variables which I had defined. The reason was that I had used reserved name (to and from) for my variables. I hope this experience be useful for others like me. </p>


问:
Facing problem when looping through over list of objects
```<code>public class PriceDetail
{

    public int ID{ get; set; }
    public string Package { get; set; }
    public string Currency { get; set; }
    public int Price { get; set; }
    public string PackageType { get; set; }
    public List<string> Items { get; set; }

}

[WebMethod]
    public static string GetCardDetail(string category)
    {

        string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
        List<PriceDetail> pricingCard = new List<PriceDetail>();
        string query = "select [PricingID],[Package],[Currency],[Price],[PackageType] from [SeoDatabase].[dbo].[tbl_Pricing] where Category = @Category";

        SqlConnection con = new SqlConnection(cs);

        SqlCommand cmd = new SqlCommand(query, con);
        cmd.Parameters.AddWithValue("@Category", category);
        con.Open();

        SqlDataReader rdr = cmd.ExecuteReader();

        while (rdr.Read())
        {

            PriceDetail priceDetail = new PriceDetail();

            priceDetail.ID = Convert.ToInt16(rdr["PricingID"]);

            priceDetail.Package = rdr["Package"].ToString();

            priceDetail.Currency = rdr["Currency"].ToString();

            priceDetail.Price = Convert.ToInt16(rdr["Price"]);

            priceDetail.PackageType = rdr["PackageType"].ToString();

            pricingCard.Add(priceDetail);

        }
        con.Close();

        List<string> items = new List<string>();

        string queryList = "select [Item] from [SeoDatabase].[dbo].[tbl_PricingItem] where PricingID = @pricingID";

        int i = 0;
        while(i < pricingCard.Count)
        {
            SqlCommand listCmd = new SqlCommand(queryList, con);

            con.Open();

            listCmd.Parameters.AddWithValue("@pricingID", pricingCard[i].ID);

            SqlDataReader listReader = listCmd.ExecuteReader();

            while (listReader.Read())
            {
                items.Add(listReader["Item"].ToString());
            }

            pricingCard[i].Items = items;

            items.Clear();

            con.Close();

            i++;
        }

        string obj = JsonConvert.SerializeObject(pricingCard);

        return obj;

    }
</code>```

<p>Every thing is going good when i reached on second loop while(i < pricingCard.Count) in this loop on 0 index its working properly and assigning right value to pricingCard[i].Items = items; problem is that when it goes for second index(1) it assigns the value correctly but also change the value of first index(0) and when loop moves for third time it changes the value of index(0).Items and index(1).Items with index(2).Items values
Please help me to solve </p>

答:
The reason this is not behaving as you might expect is that items, being of type List<string>, is a reference type, not a value type. This a concept that you will need to understand well whilst developing with managed languages such as C#. MSDN - Reference and Value

Simplistically , what you are saying by pricingCard[i].Items = items; is that pricingCard[i].Items is now a reference to items. That means, at any given point after, an evaluation of pricingCard[i].Items will just "refer" you to items, therefore any changes to items will reflect on all reference you have made to it.

What you need to do, at the being of each loop, is to "re-instantiating" items with items = new List<string>(). This is to say: create a new instance of the list, and new instance to with the next iteration of pricingCard[i].Items will refer.

```<code>while(i < pricingCard.Count)
{
    items = new List<string>();
    // Do the rest of your process
}
</code>```

Alternatively, add the items directly:

```<code>while (listReader.Read())
{
    pricingCard[i].Items.Add(listReader["Item"].ToString());
}
</code>```

P.S.

Rather than using:

```<code>int i = 0;
while(i < pricingCard.Count)
{
    i++;
}
</code>```

Try:

```<code>for (int i = 0; i < pricingCard.Count; i++)
{}
</code>```

Body:
public class PriceDetail
{

    public int ID{ get; set; }
    public string Package { get; set; }
    public string Currency { get; set; }
    public int Price { get; set; }
    public string PackageType { get; set; }
    public List<string> Items { get; set; }

}

[WebMethod]
    public static string GetCardDetail(string category)
    {

        string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
        List<PriceDetail> pricingCard = new List<PriceDetail>();
        string query = "select [PricingID],[Package],[Currency],[Price],[PackageType] from [SeoDatabase].[dbo].[tbl_Pricing] where Category = @Category";

        SqlConnection con = new SqlConnection(cs);

        SqlCommand cmd = new SqlCommand(query, con);
        cmd.Parameters.AddWithValue("@Category", category);
        con.Open();

        SqlDataReader rdr = cmd.ExecuteReader();

        while (rdr.Read())
        {

            PriceDetail priceDetail = new PriceDetail();

            priceDetail.ID = Convert.ToInt16(rdr["PricingID"]);

            priceDetail.Package = rdr["Package"].ToString();

            priceDetail.Currency = rdr["Currency"].ToString();

            priceDetail.Price = Convert.ToInt16(rdr["Price"]);

            priceDetail.PackageType = rdr["PackageType"].ToString();

            pricingCard.Add(priceDetail);

        }
        con.Close();

        List<string> items = new List<string>();

        string queryList = "select [Item] from [SeoDatabase].[dbo].[tbl_PricingItem] where PricingID = @pricingID";

        int i = 0;
        while(i < pricingCard.Count)
        {
            SqlCommand listCmd = new SqlCommand(queryList, con);

            con.Open();

            listCmd.Parameters.AddWithValue("@pricingID", pricingCard[i].ID);

            SqlDataReader listReader = listCmd.ExecuteReader();

            while (listReader.Read())
            {
                items.Add(listReader["Item"].ToString());
            }

            pricingCard[i].Items = items;

            items.Clear();

            con.Close();

            i++;
        }

        string obj = JsonConvert.SerializeObject(pricingCard);

        return obj;

    }

Every thing is going good when i reached on second loop while(i < pricingCard.Count) in this loop on 0 index its working properly and assigning right value to pricingCard[i].Items = items; problem is that when it goes for second index(1) it assigns the value correctly but also change the value of first index(0) and when loop moves for third time it changes the value of index(0).Items and index(1).Items with index(2).Items values
Please help me to solve

Body:
The reason this is not behaving as you might expect is that items, being of type List<string>, is a reference type, not a value type. This a concept that you will need to understand well whilst developing with managed languages such as C#. MSDN - Reference and Value

Simplistically , what you are saying by pricingCard[i].Items = items; is that pricingCard[i].Items is now a reference to items. That means, at any given point after, an evaluation of pricingCard[i].Items will just "refer" you to items, therefore any changes to items will reflect on all reference you have made to it.

What you need to do, at the being of each loop, is to "re-instantiating" items with items = new List<string>(). This is to say: create a new instance of the list, and new instance to with the next iteration of pricingCard[i].Items will refer.

while(i < pricingCard.Count)
{
    items = new List<string>();
    // Do the rest of your process
}

Alternatively, add the items directly:

while (listReader.Read())
{
    pricingCard[i].Items.Add(listReader["Item"].ToString());
}

P.S.

Rather than using:

int i = 0;
while(i < pricingCard.Count)
{
    i++;
}

Try:

for (int i = 0; i < pricingCard.Count; i++)
{}


问:
python3.6 ffmpeg call MacOSX (closed)
I'm using Python 3.6 on MacOSX. I would like to use FFmpeg as Python sub-process. Everything works fine when using the OSX embedded Python 2.7 but using 3.6, this doesn't work.

I get an error message because it doesn't find FFmepg:

```<code>raise FFExecutableNotFoundError("Executable '{0}' not found".format(self.executable))
ffmpy.FFExecutableNotFoundError: Executable 'ffmpeg' not found
</code>```

I tried with ffmpy but I also got the same result by invoking FFmpeg directly:

```<code>>>> from subprocess import call
>>> call(["ffmpeg"])
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    call(["ffmpeg"])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
</code>```

I installed the FFmpeg lib. by using Brew through Terminal. It was well installed but only visible by Python 2.7, not 3.6.

Calling it from terminal is working :

```<code>$ ffmpeg

ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
</code>```

I'm not (yet) a Linux specialist but I think that a path is missing for 3.6 to find FFmpeg.

Any clue to solve this annoying issue ?

答:
Your particular issue was solved, but let me share how I solved the same error:

```<code>FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
</code>```

Anybody's first reaction would be to check whether ffmpeg was installed properly in the relevant environment. In my case, I had run conda install -c conda-forge ffmpeg without error messages. When I ran find / -name ffmpeg, I found the ffmpeg directory located where I expected it to be, that is /Users/PatrickT/miniconda3/envs/sp/bin/ffmpeg. The version was ffmpeg-4.2.2. I ran conda search ffmpeg --channel conda-forge and found an update was available, so I installed it again, but this time using a slightly different syntax, just in case:

```<code>conda config --add channels conda-forge
conda install ffmpeg
</code>```

And this time it worked!

Conclusion: For whatever reason ffmpeg had not been installed properly on my system and while the ffmpeg directory had been created in the right place, invoking the application failed. In short, the problem was exactly as the error message stated: No such file or directory: 'ffmpeg'

Title: python3.6 ffmpeg call MacOSX (closed)

Body:
I'm using Python 3.6 on MacOSX. I would like to use FFmpeg as Python sub-process. Everything works fine when using the OSX embedded Python 2.7 but using 3.6, this doesn't work.

I get an error message because it doesn't find FFmepg:

raise FFExecutableNotFoundError("Executable '{0}' not found".format(self.executable))
ffmpy.FFExecutableNotFoundError: Executable 'ffmpeg' not found

I tried with ffmpy but I also got the same result by invoking FFmpeg directly:

>>> from subprocess import call
>>> call(["ffmpeg"])
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    call(["ffmpeg"])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

I installed the FFmpeg lib. by using Brew through Terminal. It was well installed but only visible by Python 2.7, not 3.6.

Calling it from terminal is working :

$ ffmpeg

ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda

I'm not (yet) a Linux specialist but I think that a path is missing for 3.6 to find FFmpeg.

Any clue to solve this annoying issue ?

Body:
Your particular issue was solved, but let me share how I solved the same error:

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

Anybody's first reaction would be to check whether ffmpeg was installed properly in the relevant environment. In my case, I had run conda install -c conda-forge ffmpeg without error messages. When I ran find / -name ffmpeg, I found the ffmpeg directory located where I expected it to be, that is /Users/PatrickT/miniconda3/envs/sp/bin/ffmpeg. The version was ffmpeg-4.2.2. I ran conda search ffmpeg --channel conda-forge and found an update was available, so I installed it again, but this time using a slightly different syntax, just in case:

conda config --add channels conda-forge
conda install ffmpeg

And this time it worked!

Conclusion: For whatever reason ffmpeg had not been installed properly on my system and while the ffmpeg directory had been created in the right place, invoking the application failed. In short, the problem was exactly as the error message stated: No such file or directory: 'ffmpeg'


问:
How can my app users view a lot of images (and possible download them) without me having to rent a server
So, I now have an app, and the idea is the same as a wallpaper app, a lot of images people can download and use for themselves. There are a little over 200 images in the app right now, but I want to increase this number to a couple of thousand. The problem is, the size of the app will increase very rapidly, so the best idea (I think) is to use some sort of server. Google Photos and Firebase both have quota's, and I know I will reach those both very soon (with only 200 images and the active users I have right now, the limit would be reached very quickly). So, I need another way to let people view the images (my images, I do not just copy them from another site, or any other place online) and be able to download them to their phones, without it costing me money (sorry, Im very poor) or using a service that has a quota. So, I need my android app users to view and download a lot (2500+) of my images, without it costing me money.
Thanks!</p>

答: You can go for amazon web services. It's very effective and it's free for a year.after that you have to pay accordingly.</p>


问:
ScrollView stacked with another page
The issue is the background of my scrollview is somewhat have pretty same content as my scroll view. i have try looking but can't found the problem, because every place tell that i just have to place the content into the scrollview. Please Help!

The design of the layout

This is my layout code

```<code><?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.home.HomeFragment">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/category_rv"
        android:layout_width="match_parent"
        android:background="@color/colorAccent"
        android:elevation="3dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
            <LinearLayout
                android:id="@+id/LinearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/category_rv">

                <include layout="@layout/horizontal_scroll_layout" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/LinearLayout1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/LinearLayout">

                <include layout="@layout/sliding_ad_layout" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/LinearLayout2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/LinearLayout1">

                <include layout="@layout/grid_product_layout" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>
</code>```

答:
Put recyclerview and scrollview into nestedscrollview

This will solve your problem.

Title: ScrollView stacked with another page

Body:
The issue is the background of my scrollview is somewhat have pretty same content as my scroll view. i have try looking but can't found the problem, because every place tell that i just have to place the content into the scrollview. Please Help!

The design of the layout

This is my layout code

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.home.HomeFragment">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/category_rv"
        android:layout_width="match_parent"
        android:background="@color/colorAccent"
        android:elevation="3dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
            <LinearLayout
                android:id="@+id/LinearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/category_rv">

                <include layout="@layout/horizontal_scroll_layout" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/LinearLayout1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/LinearLayout">

                <include layout="@layout/sliding_ad_layout" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/LinearLayout2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/LinearLayout1">

                <include layout="@layout/grid_product_layout" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>