问:
Unstashing a stash in multiple stages throughout a pipeline
I am using stash\unstash in my pipeline, and wondered could you unstash in multiple stages?

So for example:

```<code>stage('One') {
  steps {
    echo 'Stage one...'
    stash includes: 'dist/**/*', name: 'builtSources'
    dir('/some-dir/deploy') {
      unstash 'builtSources'
    }
  }
}
stage('Two') {
  steps {
    echo 'Stage two...'
    node('OtherNode') {
      dir('/some-other-dir/deploy') {
        unstash 'builtSources'
      }
    }
  }
}
</code>```

So can I retrieve a stash made in an earlier stage, in any of the following stages, any number of times?

答: Yes, you can definitely unstash the files multiple times across multiple stages and make the best use of it.</p>

Body:
I am using stash\unstash in my pipeline, and wondered could you unstash in multiple stages?

So for example:

stage('One') {
  steps {
    echo 'Stage one...'
    stash includes: 'dist/**/*', name: 'builtSources'
    dir('/some-dir/deploy') {
      unstash 'builtSources'
    }
  }
}
stage('Two') {
  steps {
    echo 'Stage two...'
    node('OtherNode') {
      dir('/some-other-dir/deploy') {
        unstash 'builtSources'
      }
    }
  }
}

So can I retrieve a stash made in an earlier stage, in any of the following stages, any number of times?


来源: stackexchange

问:
not submitted app for review
I wanted to submit my app for the App Store on iTunes Connect, but whatever I do I got this last message telling me there are still one or more errors on the page.

Things I completed till now:

Filled app information.

Filled contact information.

Uploaded screenshots for all supported sizes.

Uploaded binary / selected on iTunes connect.

Filled rating form.

Changes done for "Pricing".

Change app versions.

Screenshot of my error in iTunes connect:

Please help me to solve this error.

答:
Follow the step on Apple guide

One thing you might be missing is archiving the app on Xcode and uploading through there to iTunesConnect.

If you need more info on how to do that I will update my answer

ContentLicense: CC BY-SA 3.0

Title: not submitted app for review


问:
Pass a parameter to OWIN host
I'm self-hosting ASP.NET Web API and SignalR using OWIN. I start the server (on a console app) with this code:

```<code>using (WebApplication.Start<Startup>(url))
{
    Console.WriteLine("Running...");
    Console.ReadLine();
}
</code>```

This works fine. But now I need to pass a parameter (an object) to the Startup class. How can this be done?

答:
You can use the WebApp.Start Method (String, Action<IAppBuilder>) overload.

Example:

```<code>using (WebApplication.Start(url, appBuilder => new Startup(myObject).Configuration(appBuilder)))
{
    Console.WriteLine("Running...");
    Console.ReadLine();
}
</code>```

Title: Pass a parameter to OWIN host

Body:
I'm self-hosting ASP.NET Web API and SignalR using OWIN. I start the server (on a console app) with this code:

using (WebApplication.Start<Startup>(url))
{
    Console.WriteLine("Running...");
    Console.ReadLine();
}

This works fine. But now I need to pass a parameter (an object) to the Startup class. How can this be done?

Body:
You can use the WebApp.Start Method (String, Action<IAppBuilder>) overload.

Example:

using (WebApplication.Start(url, appBuilder => new Startup(myObject).Configuration(appBuilder)))
{
    Console.WriteLine("Running...");
    Console.ReadLine();
}


问:
Use invokeLater to show dialogs one by one
In 2 different action listeners, a dialog will be shown when some conditions are met.
If both of the action listeners need to show dialog, 2 dialogs will be shown at the same time. But I want them to be shown one by one.

Simplified code:

```<code>        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(getTopLevelAncestor(), "dialog 1");
            }
        });

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(getTopLevelAncestor(), "dialog 2");
            }
        });
</code>```

Those 2 "SwingUtilities.invokeLater" invocations are in different classes.

答: Make a class that keeps track about that; this class would contain a queue of dialogs to display; whenever a dialog is closed, the first one of the queue is shown and removed from the queue. When another class needs to show a dialog, it's immediately shown if the queue is empty, or inserted into the queue else.</p>

Body:
In 2 different action listeners, a dialog will be shown when some conditions are met.
If both of the action listeners need to show dialog, 2 dialogs will be shown at the same time. But I want them to be shown one by one.

Simplified code:

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(getTopLevelAncestor(), "dialog 1");
            }
        });

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(getTopLevelAncestor(), "dialog 2");
            }
        });

Those 2 "SwingUtilities.invokeLater" invocations are in different classes.

ContentLicense: CC BY-SA 2.5


问:
Image path upload and displaying image in mysql
I need to upload an image to database and path should be saved in table. I am using the below code to upload the image and store the path in database table. I have created a directory "images" for storing image which is uploaded by user.

```<code>if(isset($_POST['submit']))
{
  $errors= array();
  $file_name=$_FILES['photo']['name'];
  $file_size =$_FILES['photo']['size'];
  $file_tmp =$_FILES['photo']['tmp_name'];
  $file_type=$_FILES['photo']['type'];
  $file_ext=strtolower(end(explode('.',$_FILES['photo']['name'])));
  $expensions= array("jpeg","jpg","png");
  if(in_array($file_ext,$expensions)=== false){
  $errors[]="extension not allowed, please choose a JPEG or PNG file.";
  }
  if($file_size > 2097152){
  $errors[]='File size must be excately 2 MB';
  }
  if(empty($errors)==true){
  move_uploaded_file($file_tmp,"images/".$file_name);
  echo '<script language="javascript">';
  echo 'alert("Success")';
  echo '</script>';
  }
  else
  {
    echo '<script language="javascript">';
    echo 'alert("Failed")';
    echo '</script>';
    print_r($errors);
  }
  }
  $query = mysql_query("insert into e(photo) values ('$file_name')");
  echo '<script language="javascript">';
  echo 'alert("Ok")';
  echo '</script>';
 }
</code>```

Then the image should be displayed from database using the stored path in table. I am using the below code to display the image from database.

```<code>$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("s", $connection);
$sql = "SELECT * FROM e";
$result = mysql_query($sql);
while ($o = mysql_fetch_assoc($result))
{
    echo "<tbody>";
    echo "<tr>";
    echo "<td>".'<img src="$photo;"' ."</td>";
    echo "</tr>";
    echo "</tbody>";
}
?>
</code>```

答:
Here you are making mistake

```<code>echo "<td>".'<img src="$photo;"' ."</td>";
</code>```

Replace it with (Ensure that you are completing img tag)

```<code>echo '<td><img src="your_images_folder_path/'.$o['photo'].'"></td>';
</code>```

Please stop using mysql_* it's depreciated since PHP5.6

Body:
I need to upload an image to database and path should be saved in table. I am using the below code to upload the image and store the path in database table. I have created a directory "images" for storing image which is uploaded by user.

if(isset($_POST['submit']))
{
  $errors= array();
  $file_name=$_FILES['photo']['name'];
  $file_size =$_FILES['photo']['size'];
  $file_tmp =$_FILES['photo']['tmp_name'];
  $file_type=$_FILES['photo']['type'];
  $file_ext=strtolower(end(explode('.',$_FILES['photo']['name'])));
  $expensions= array("jpeg","jpg","png");
  if(in_array($file_ext,$expensions)=== false){
  $errors[]="extension not allowed, please choose a JPEG or PNG file.";
  }
  if($file_size > 2097152){
  $errors[]='File size must be excately 2 MB';
  }
  if(empty($errors)==true){
  move_uploaded_file($file_tmp,"images/".$file_name);
  echo '';
  }
  else
  {
    echo '';
    print_r($errors);
  }
  }
  $query = mysql_query("insert into e(photo) values ('$file_name')");
  echo '';
 }

Then the image should be displayed from database using the stored path in table. I am using the below code to display the image from database.

$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("s", $connection);
$sql = "SELECT * FROM e";
$result = mysql_query($sql);
while ($o = mysql_fetch_assoc($result))
{
    echo "
";
    echo "
";
    echo "".'

Body:
Here you are making mistake

echo "<td>".'<img src="$photo;"' ."</td>";

Replace it with (Ensure that you are completing img tag)

echo '<td><img src="your_images_folder_path/'.$o['photo'].'"></td>';

Please stop using mysql_* it's depreciated since PHP5.6


问:
pandas.read_csv(): Can't convert 'int' object to str implicitly
When importing my .txt file, I am getting the following error:

```<code>Can't convert 'int' object to str implicitly
</code>```

I import my .txt file as follows:

```<code>activityHeaders = ['Type', 'AccountID', 'ConID', 'SecurityID', 'Symbol', 'BBTicker', 'Currency', 'BaseCurrency', 'TradeDate', 'SettleDate', 'TransactionType', 'Quantity', 'UnitPrice', 'GrossAmount', 'SECFee', 'Commission', 'NetInBase', 'FXRatetoBase', 'Other1', 'Other2', 'Description']

dfActivity = pd.read_csv(activityFileUrl, skiprows=[1], header=activityHeaders, error_bad_lines=False)
</code>```

and my .txt file looks as follows:

```<code>"H","I000000","Activity","20100407","16:02:38","20100329","1.0"
"D","I000000","","","","","CAD","EUR","20100329","20100329","WITH","0","0","-14.88","0","0","0","-14.88","-10.8158","",,"CASH TRANSFER (INTERNAL)"
"D","I000000","","","","","AUD","EUR","20100328","20100328","ADJ","0","0","4","0","0","0","4","2.7211","",,"CLIENT FEE (U000001, Commission)"
"D","U000001","37036548","DE000A0F6MD5","PRA","STK","EUR","EUR","20100329","20100331","SELL","-300","7.776","-2332.8","0","-6","0","2326.8","2326.8","405346125","FI","TRADE PRAKTIKER BAU-UND HEIMWERK A"
</code>```

I don't understand where the int could come from. Note that I skip the first and last row using the skiprows and error_bad_lines. I put header also to None and it returned the same error.

答:
You need change header to names if need column names by list activityHeaders.

```<code>df = pd.read_csv(StringIO(temp), names=activityHeaders, skiprows=1, error_bad_lines=False)
print (df)
      Type   AccountID         ConID SecurityID Symbol BBTicker Currency  \
D  I000000         NaN           NaN        NaN    NaN      CAD      EUR
D  I000000         NaN           NaN        NaN    NaN      AUD      EUR
D  U000001  37036548.0  DE000A0F6MD5        PRA    STK      EUR      EUR

   BaseCurrency  TradeDate SettleDate                 ...                  \
D      20100329   20100329       WITH                 ...
D      20100328   20100328        ADJ                 ...
D      20100329   20100331       SELL                 ...

   Quantity  UnitPrice  GrossAmount  SECFee  Commission  NetInBase  \
D     0.000     -14.88            0       0           0     -14.88
D     0.000       4.00            0       0           0       4.00
D     7.776   -2332.80            0      -6           0    2326.80

   FXRatetoBase       Other1  Other2                         Description
D      -10.8158          NaN     NaN            CASH TRANSFER (INTERNAL)
D        2.7211          NaN     NaN    CLIENT FEE (U000001, Commission)
D     2326.8000  405346125.0      FI  TRADE PRAKTIKER BAU-UND HEIMWERK A

[3 rows x 21 columns]
</code>```

Also if need NOT skip second row omit skiprows:

```<code>df = pd.read_csv(StringIO(temp), names=activityHeaders, error_bad_lines=False)
print (df)
  Type AccountID     ConID    SecurityID    Symbol  BBTicker Currency  \
0    H   I000000  Activity      20100407  16:02:38  20100329      1.0
1    D   I000000       NaN           NaN       NaN       NaN      CAD
2    D   I000000       NaN           NaN       NaN       NaN      AUD
3    D   U000001  37036548  DE000A0F6MD5       PRA       STK      EUR

  BaseCurrency   TradeDate  SettleDate     ...      Quantity  UnitPrice  \
0          NaN         NaN         NaN     ...           NaN        NaN
1          EUR  20100329.0  20100329.0     ...           0.0      0.000
2          EUR  20100328.0  20100328.0     ...           0.0      0.000
3          EUR  20100329.0  20100331.0     ...        -300.0      7.776

   GrossAmount  SECFee  Commission  NetInBase  FXRatetoBase     Other1  \
0          NaN     NaN         NaN        NaN           NaN        NaN
1       -14.88     0.0         0.0        0.0        -14.88   -10.8158
2         4.00     0.0         0.0        0.0          4.00     2.7211
3     -2332.80     0.0        -6.0        0.0       2326.80  2326.8000

        Other2  Description
0          NaN          NaN
1          NaN          NaN
2          NaN          NaN
3  405346125.0           FI

[4 rows x 21 columns]
</code>```

Body:
When importing my .txt file, I am getting the following error:

Can't convert 'int' object to str implicitly

I import my .txt file as follows:

activityHeaders = ['Type', 'AccountID', 'ConID', 'SecurityID', 'Symbol', 'BBTicker', 'Currency', 'BaseCurrency', 'TradeDate', 'SettleDate', 'TransactionType', 'Quantity', 'UnitPrice', 'GrossAmount', 'SECFee', 'Commission', 'NetInBase', 'FXRatetoBase', 'Other1', 'Other2', 'Description']

dfActivity = pd.read_csv(activityFileUrl, skiprows=[1], header=activityHeaders, error_bad_lines=False)

and my .txt file looks as follows:

"H","I000000","Activity","20100407","16:02:38","20100329","1.0"
"D","I000000","","","","","CAD","EUR","20100329","20100329","WITH","0","0","-14.88","0","0","0","-14.88","-10.8158","",,"CASH TRANSFER (INTERNAL)"
"D","I000000","","","","","AUD","EUR","20100328","20100328","ADJ","0","0","4","0","0","0","4","2.7211","",,"CLIENT FEE (U000001, Commission)"
"D","U000001","37036548","DE000A0F6MD5","PRA","STK","EUR","EUR","20100329","20100331","SELL","-300","7.776","-2332.8","0","-6","0","2326.8","2326.8","405346125","FI","TRADE PRAKTIKER BAU-UND HEIMWERK A"

I don't understand where the int could come from. Note that I skip the first and last row using the skiprows and error_bad_lines. I put header also to None and it returned the same error.

Body:
You need change header to names if need column names by list activityHeaders.

df = pd.read_csv(StringIO(temp), names=activityHeaders, skiprows=1, error_bad_lines=False)
print (df)
      Type   AccountID         ConID SecurityID Symbol BBTicker Currency  \
D  I000000         NaN           NaN        NaN    NaN      CAD      EUR
D  I000000         NaN           NaN        NaN    NaN      AUD      EUR
D  U000001  37036548.0  DE000A0F6MD5        PRA    STK      EUR      EUR

   BaseCurrency  TradeDate SettleDate                 ...                  \
D      20100329   20100329       WITH                 ...
D      20100328   20100328        ADJ                 ...
D      20100329   20100331       SELL                 ...

   Quantity  UnitPrice  GrossAmount  SECFee  Commission  NetInBase  \
D     0.000     -14.88            0       0           0     -14.88
D     0.000       4.00            0       0           0       4.00
D     7.776   -2332.80            0      -6           0    2326.80

   FXRatetoBase       Other1  Other2                         Description
D      -10.8158          NaN     NaN            CASH TRANSFER (INTERNAL)
D        2.7211          NaN     NaN    CLIENT FEE (U000001, Commission)
D     2326.8000  405346125.0      FI  TRADE PRAKTIKER BAU-UND HEIMWERK A

[3 rows x 21 columns]

Also if need NOT skip second row omit skiprows:

df = pd.read_csv(StringIO(temp), names=activityHeaders, error_bad_lines=False)
print (df)
  Type AccountID     ConID    SecurityID    Symbol  BBTicker Currency  \
0    H   I000000  Activity      20100407  16:02:38  20100329      1.0
1    D   I000000       NaN           NaN       NaN       NaN      CAD
2    D   I000000       NaN           NaN       NaN       NaN      AUD
3    D   U000001  37036548  DE000A0F6MD5       PRA       STK      EUR

  BaseCurrency   TradeDate  SettleDate     ...      Quantity  UnitPrice  \
0          NaN         NaN         NaN     ...           NaN        NaN
1          EUR  20100329.0  20100329.0     ...           0.0      0.000
2          EUR  20100328.0  20100328.0     ...           0.0      0.000
3          EUR  20100329.0  20100331.0     ...        -300.0      7.776

   GrossAmount  SECFee  Commission  NetInBase  FXRatetoBase     Other1  \
0          NaN     NaN         NaN        NaN           NaN        NaN
1       -14.88     0.0         0.0        0.0        -14.88   -10.8158
2         4.00     0.0         0.0        0.0          4.00     2.7211
3     -2332.80     0.0        -6.0        0.0       2326.80  2326.8000

        Other2  Description
0          NaN          NaN
1          NaN          NaN
2          NaN          NaN
3  405346125.0           FI

[4 rows x 21 columns]


问:
Run roles according to host from Ansible playbook
I have to use two playbooks as my host are changing for each role. Is there any workaround so that I can get this done in single playbook??

Playbook-1:

```<code>- name: Install & configure SSH on servers
  gather_facts: True
  sudo: yes
  hosts: zookeeper
  roles:
  - { role: discover-zookeeper,         tags: ['discover-zookeeper']}
</code>```

Playbook-2:

```<code>- name: Install & configure SSH on servers
  gather_facts: True
  sudo: yes
  hosts: kafka
  roles:
  - { role: discover-kafka,             tags: ['discover-kafka']}
</code>```

I have tried this approach, but it seems that it's not how Ansible works..

playbook.yml:

```<code>- name: Install & configure SSH on servers
  gather_facts: True
  sudo: yes
  roles:
  - { role: discover-zookeeper,         tags: ['discover-zookeeper'],   hosts: zookeeper}
  - { role: discover-kafka,             tags: ['discover-kafka'],   hosts: kafka}
</code>```

答:
If I see it correctly, you are talking about two plays, NOT two playbooks. Because a playbook is, as fas as I understand your question, exactly what you are looking for. As an example:

```<code>- hosts: hostA
  roles:
    - roleA
    - roleB
- hosts: hostB
  roles:
    - roleC
    - roleD
</code>```

(comment: please use "(cmd/ctrl) + k" to format in better readable code-style)

Body:
I have to use two playbooks as my host are changing for each role. Is there any workaround so that I can get this done in single playbook??

Playbook-1:

- name: Install & configure SSH on servers
  gather_facts: True
  sudo: yes
  hosts: zookeeper
  roles:
  - { role: discover-zookeeper,         tags: ['discover-zookeeper']}

Playbook-2:

- name: Install & configure SSH on servers
  gather_facts: True
  sudo: yes
  hosts: kafka
  roles:
  - { role: discover-kafka,             tags: ['discover-kafka']}

I have tried this approach, but it seems that it's not how Ansible works..

playbook.yml:

- name: Install & configure SSH on servers
  gather_facts: True
  sudo: yes
  roles:
  - { role: discover-zookeeper,         tags: ['discover-zookeeper'],   hosts: zookeeper}
  - { role: discover-kafka,             tags: ['discover-kafka'],   hosts: kafka}

Body:
If I see it correctly, you are talking about two plays, NOT two playbooks. Because a playbook is, as fas as I understand your question, exactly what you are looking for. As an example:

- hosts: hostA
  roles:
    - roleA
    - roleB
- hosts: hostB
  roles:
    - roleC
    - roleD

(comment: please use "(cmd/ctrl) + k" to format in better readable code-style)


问:
Should you lock resources when reading values?
When doing thread synchronization in C# should I also lock an object when I read a value or just changing it?

for example I have Queue<T> object. Should I just lock it when doing the Enqueue and Dequeue or should I also lock it when checking values like Count?

答:
From MSDN:

A Queue<(Of <(T>)>) can support
  multiple readers concurrently, as long
  as the collection is not modified.
  Even so, enumerating through a
  collection is intrinsically not a
  thread-safe procedure. To guarantee
  thread safety during enumeration, you
  can lock the collection during the
  entire enumeration. To allow the
  collection to be accessed by multiple
  threads for reading and writing, you
  must implement your own
  synchronization.

You should ensure no reader is active while an item is queued (a lock is probably a good idea).

Looking at the count in reflector reveals a read from a private field. This can be okay depending on what you do with the value. This means you shouldn't do stuff like this (without proper locking):

```<code>if(queue.Count > 0)
    queue.Dequeue();
</code>```

OwnerDisplayName: Superdumbell

Body:
From MSDN:

A Queue<(Of <(T>)>) can support
  multiple readers concurrently, as long
  as the collection is not modified.
  Even so, enumerating through a
  collection is intrinsically not a
  thread-safe procedure. To guarantee
  thread safety during enumeration, you
  can lock the collection during the
  entire enumeration. To allow the
  collection to be accessed by multiple
  threads for reading and writing, you
  must implement your own
  synchronization.

You should ensure no reader is active while an item is queued (a lock is probably a good idea).

Looking at the count in reflector reveals a read from a private field. This can be okay depending on what you do with the value. This means you shouldn't do stuff like this (without proper locking):

if(queue.Count > 0)
    queue.Dequeue();

OwnerDisplayName: Cristian Libardo


问:
mod_wsgi WSGI script for non-frameworked Python web development
Most guides I saw for creating the WSGI file for use with mod_wsgi either sets it up for Django or Pylons. However, I would like to create the wsgi file without setting it up for any particular framework. How do I do this. The following is a code from the wsgi script for use with Django:

```<code>import os, sys
sys.path.append('/home/user/dev')
sys.path.append('/home/user/dev/site1')
os.environ['DJANGO_SETTINGS_MODULE'] = 'site1.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()
</code>```

The mod_wsgi integration from google said that I need to add the following code to the WSGI script to overlay the BASELINE environment (yep, I am using a baseline and application-specific virtualenv):

```<code>import site
site.addsitedir('/usr/local/pythonenv/PYLONS-1/lib/python2.5/site-packages')
</code>```

How will my WSGI script look like if I am not using it for any particular framework?

EDIT: This is for use with Apache server

答:
For the simple wsgi application in PEP 333:

```<code>def simple_app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)
    return ['Hello world!\n']

application = simple_app
</code>```

In other words, you don't have to do any setup at all.  You just have to make sure that mod_wsgi can find an application object that conforms to wsgi in your module.

For security reasons, you really ought to define your application in another module outside any directories published by apache, and limit the code in your wsgi file to the minimum required to import that module and bind the wsgi application within to the application variable.

Body:
Most guides I saw for creating the WSGI file for use with mod_wsgi either sets it up for Django or Pylons. However, I would like to create the wsgi file without setting it up for any particular framework. How do I do this. The following is a code from the wsgi script for use with Django:

import os, sys
sys.path.append('/home/user/dev')
sys.path.append('/home/user/dev/site1')
os.environ['DJANGO_SETTINGS_MODULE'] = 'site1.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

The mod_wsgi integration from google said that I need to add the following code to the WSGI script to overlay the BASELINE environment (yep, I am using a baseline and application-specific virtualenv):

import site
site.addsitedir('/usr/local/pythonenv/PYLONS-1/lib/python2.5/site-packages')

How will my WSGI script look like if I am not using it for any particular framework?

EDIT: This is for use with Apache server

Body:
For the simple wsgi application in PEP 333:

def simple_app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)
    return ['Hello world!\n']

application = simple_app

In other words, you don't have to do any setup at all.  You just have to make sure that mod_wsgi can find an application object that conforms to wsgi in your module.

For security reasons, you really ought to define your application in another module outside any directories published by apache, and limit the code in your wsgi file to the minimum required to import that module and bind the wsgi application within to the application variable.


问:
google charts vAxis to the right
I'm using google visualization

var data2 = new google.visualization.DataTable();
        data2.addColumn('string', 'time');
        data2.addColumn('number', 'amount');
        data2.addColumn({ type: 'string', role: 'tooltip' });
        data2.addRows(rows_data);
        var options2 = {
            vAxis: { textPosition: 'none', title: '', textStyle: { fontName: 'arial'} },
            hAxis: { slantedText: false, textStyle: { color: '#E6EFFA' }, gridlines: { color: '#E6EFFA', count: 20} },
            backgroundColor: '#E6EFFA',
            legend: 'none',
            chartArea: { top: 0 },
            colors: ['#435988'],
            chartArea: { width: 800 }
        };
        chart2 = new google.visualization.LineChart(document.getElementById('chart_div_volume'));
```

I want the vAxis position to be on the right.
is it possible ?

答:
        google.charts.load('current', { 'packages': ['corechart'] });
        google.charts.setOnLoadCallback(drawVisualization);

        function drawVisualization() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Productivity');
            data.addColumn('number', 'Composite');
            data.addColumn({ type: 'number', role: 'annotation' });
            data.addColumn('number', 'Average(N=5)');
            var compositeDataArry = [];
            compositeDataArry.push(["Ravi", 11, 11, 5]);
            compositeDataArry.push(["Wasif", 5, 5, 5]);
            compositeDataArry.push(["Vipin", 2, 2, 5]);
            compositeDataArry.push(["Ankur", 3, 3, 5]);
            compositeDataArry.push(["Pankaj", 1, 1, 5]);
            compositeDataArry.push(["Dheeraj", 4, 4, 5]);

            data.addRows(compositeDataArry);
            var options = {
                title: 'My Chart',
                titleTextStyle: { color: '#264158', fontSize: 24 },
                seriesType: 'bars',
                annotations: {
                    alwaysOutside: true,
                    textStyle: {
                        color: '#000000',
                        fontSize: 15
                    }
                },
                hAxis: {
                    slantedText: true,
                    slantedTextAngle: -45
                },
                series: {
                    0: { targetAxisIndex: 0, },
                    1: { targetAxisIndex: 1, type: 'line' }
                },
                vAxes: {
                    0: { textPosition: 'none' },
                    1: {}
                }
            };
            var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
            chart.draw(data, options);

        }
 ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

</head>
<body>
    <div id="chart_div" style="height: 500px; width: 100%"></div>

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

Title: google charts vAxis to the right

Body:
I'm using google visualization

var data2 = new google.visualization.DataTable();
        data2.addColumn('string', 'time');
        data2.addColumn('number', 'amount');
        data2.addColumn({ type: 'string', role: 'tooltip' });
        data2.addRows(rows_data);
        var options2 = {
            vAxis: { textPosition: 'none', title: '', textStyle: { fontName: 'arial'} },
            hAxis: { slantedText: false, textStyle: { color: '#E6EFFA' }, gridlines: { color: '#E6EFFA', count: 20} },
            backgroundColor: '#E6EFFA',
            legend: 'none',
            chartArea: { top: 0 },
            colors: ['#435988'],
            chartArea: { width: 800 }
        };
        chart2 = new google.visualization.LineChart(document.getElementById('chart_div_volume'));

I want the vAxis position to be on the right.
is it possible ?

Body:
        google.charts.load('current', { 'packages': ['corechart'] });
        google.charts.setOnLoadCallback(drawVisualization);

        function drawVisualization() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Productivity');
            data.addColumn('number', 'Composite');
            data.addColumn({ type: 'number', role: 'annotation' });
            data.addColumn('number', 'Average(N=5)');
            var compositeDataArry = [];
            compositeDataArry.push(["Ravi", 11, 11, 5]);
            compositeDataArry.push(["Wasif", 5, 5, 5]);
            compositeDataArry.push(["Vipin", 2, 2, 5]);
            compositeDataArry.push(["Ankur", 3, 3, 5]);
            compositeDataArry.push(["Pankaj", 1, 1, 5]);
            compositeDataArry.push(["Dheeraj", 4, 4, 5]);

            data.addRows(compositeDataArry);
            var options = {
                title: 'My Chart',
                titleTextStyle: { color: '#264158', fontSize: 24 },
                seriesType: 'bars',
                annotations: {
                    alwaysOutside: true,
                    textStyle: {
                        color: '#000000',
                        fontSize: 15
                    }
                },
                hAxis: {
                    slantedText: true,
                    slantedTextAngle: -45
                },
                series: {
                    0: { targetAxisIndex: 0, },
                    1: { targetAxisIndex: 1, type: 'line' }
                },
                vAxes: {
                    0: { textPosition: 'none' },
                    1: {}
                }
            };
            var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
            chart.draw(data, options);

        }

<html>
<head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

</head>
<body>
    <div id="chart_div" style="height: 500px; width: 100%"></div>

</body>
</html>


问:
Delete rows from sheet where match is found in excel
I have an excel sheet which has just over a thousand lines and I need to be delete all ROWS in it which are as follows:

column A, B,C,D,E,F AND G  MUST be an exact match.

Column H (hours) must have a negative value which matches the same value but positive forming a pair, then the pair is deleted.

so the following is an example of  a match:

```<code>date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42
</code>```

resulting in:

```<code>date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42
</code>```

I'm having trouble explaining it let alone writing a macro!

```<code>Dim LR As Long
Dim i As Long

'Remove rows
LR = Range("H" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    'How do i compare it against other rows?
Next i
</code>```

答:
One way to do this would be to join all of the columns together using a delimiter and add it to a dictionary as the key. This will only hold unique values. You could then split each one back into columns again and overwrite the whole sheet. There wold be many other ways to achieve this though and this is just an example of one way you could do it. Also, as always if you do try this try it first on a copy of your original data in case of any unexpected behaviour

```<code>Option Explicit
Public Sub ExampleRemoveDuplicates()
    Dim dict As Object
    Dim temp As String
    Dim calc As String
    Dim headers As Variant
    Dim NoCol As Long, i As Long, j As Long
    Dim c, key

    With Application
        .ScreenUpdating = False
        calc = .Calculation
        .Calculation = xlCalculationManual
    End With

    Set dict = CreateObject("Scripting.Dictionary")
    ' Change this to the sheet that is applicable
    With Sheet1
        NoCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
        ' Assumes first row of sheet is headers
        headers = .Range(.Cells(1, 1), .Cells(1, NoCol)).Value2
        For Each c In .Range(.Cells(2, 1), .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, 1))
            ReDim arr(1 To NoCol)
            temp = vbNullString
            j = 1
            Do
                arr(j) = c.Offset(0, j - 1).Value2
                If j = 8 Then
                    temp = temp & Abs(arr(j))
                Else
                    temp = temp & arr(j)
                End If
                j = j + 1
            Loop Until j = NoCol + 1

            If Not dict.exists(temp) And Not temp = vbNullString Then dict.Add key:=temp, Item:=arr
        Next c
        .Cells.ClearContents
        .Range(.Cells(1, 1), .Cells(1, NoCol)).Value2 = headers
        i = 1
        ReDim Results(1 To dict.Count, 1 To NoCol)
        For Each key In dict.keys
            For j = 1 To NoCol
                Results(i, j) = dict(key)(j)
            Next j
            i = i + 1
        Next key
        With .Cells(1, 1)
            .Range(.Offset(1, 0), .Offset(dict.Count, NoCol - 1)) = Results
        End With
    End With

    With Application
        .Calculation = calc
        .ScreenUpdating = True
    End With
End Sub
</code>```

Body:
I have an excel sheet which has just over a thousand lines and I need to be delete all ROWS in it which are as follows:

column A, B,C,D,E,F AND G  MUST be an exact match.

Column H (hours) must have a negative value which matches the same value but positive forming a pair, then the pair is deleted.

so the following is an example of  a match:

date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42

resulting in:

date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42

I'm having trouble explaining it let alone writing a macro!

Dim LR As Long
Dim i As Long

'Remove rows
LR = Range("H" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    'How do i compare it against other rows?
Next i

Body:
One way to do this would be to join all of the columns together using a delimiter and add it to a dictionary as the key. This will only hold unique values. You could then split each one back into columns again and overwrite the whole sheet. There wold be many other ways to achieve this though and this is just an example of one way you could do it. Also, as always if you do try this try it first on a copy of your original data in case of any unexpected behaviour

Option Explicit
Public Sub ExampleRemoveDuplicates()
    Dim dict As Object
    Dim temp As String
    Dim calc As String
    Dim headers As Variant
    Dim NoCol As Long, i As Long, j As Long
    Dim c, key

    With Application
        .ScreenUpdating = False
        calc = .Calculation
        .Calculation = xlCalculationManual
    End With

    Set dict = CreateObject("Scripting.Dictionary")
    ' Change this to the sheet that is applicable
    With Sheet1
        NoCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
        ' Assumes first row of sheet is headers
        headers = .Range(.Cells(1, 1), .Cells(1, NoCol)).Value2
        For Each c In .Range(.Cells(2, 1), .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, 1))
            ReDim arr(1 To NoCol)
            temp = vbNullString
            j = 1
            Do
                arr(j) = c.Offset(0, j - 1).Value2
                If j = 8 Then
                    temp = temp & Abs(arr(j))
                Else
                    temp = temp & arr(j)
                End If
                j = j + 1
            Loop Until j = NoCol + 1

            If Not dict.exists(temp) And Not temp = vbNullString Then dict.Add key:=temp, Item:=arr
        Next c
        .Cells.ClearContents
        .Range(.Cells(1, 1), .Cells(1, NoCol)).Value2 = headers
        i = 1
        ReDim Results(1 To dict.Count, 1 To NoCol)
        For Each key In dict.keys
            For j = 1 To NoCol
                Results(i, j) = dict(key)(j)
            Next j
            i = i + 1
        Next key
        With .Cells(1, 1)
            .Range(.Offset(1, 0), .Offset(dict.Count, NoCol - 1)) = Results
        End With
    End With

    With Application
        .Calculation = calc
        .ScreenUpdating = True
    End With
End Sub


问:
How can I get or/and from two expressions in SQL?
```<code>SELECT Count(*)
FROM   table A
WHERE  CONVERT (DATE, GETDATE()) IN
       (CONVERT(DATE, time_created), CONVERT(DATE, time_updated))
</code>```

I tried or after the , but it didn't work out.

答:
Are you using SQL Server?  If so, is this what you intend?

```<code>SELECT Count(*)
FROM table A
WHERE CONVERT(DATE, time_created) = CONVERT(DATE, GETDATE()) OR
      CONVERT(DATE, time_updated) = CONVERT(DATE, GETDATE());
</code>```

If so, then your original query should also work.

Body:
SELECT Count(*)
FROM   table A
WHERE  CONVERT (DATE, GETDATE()) IN
       (CONVERT(DATE, time_created), CONVERT(DATE, time_updated))

I tried or after the , but it didn't work out.

Body:
Are you using SQL Server?  If so, is this what you intend?

SELECT Count(*)
FROM table A
WHERE CONVERT(DATE, time_created) = CONVERT(DATE, GETDATE()) OR
      CONVERT(DATE, time_updated) = CONVERT(DATE, GETDATE());

If so, then your original query should also work.


问:
Prevent browser predicting input in input box
I am trying to prevent the browser giving me recommendations when I type into an input box. For example, if I type 'a' it will give me a list of items beginning with'a' that I have typed into an input box in my browser in the past.

I have tried autocomplete="false" but this doesnt work as far as I can tell. Autocomplete must be different to what I am looking for.

Perhaps it is a browser setting that cannot be controlled by the developer. Does anyone know if there is a way to do this?

答:
It is working for me on this codepen link. It doesn't display prediction for email field, but it does show prediction for first name and last name field.

If it doesn't work for you then it must be your system software causing this. I'm using Chrome on Linux.

<form action="/action_page.php" autocomplete="on">
  First name:<input type="text" name="fname">

  Last name: <input type="text" name="lname">

  E-mail: <input type="email" name="email" autocomplete="off">

  <input type="submit">
</form>

http://codepen.io/piyushpatel2005/pen/aJQaNN

Body:
It is working for me on this codepen link. It doesn't display prediction for email field, but it does show prediction for first name and last name field.

If it doesn't work for you then it must be your system software causing this. I'm using Chrome on Linux.

<form action="/action_page.php" autocomplete="on">
  First name:<input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  E-mail: <input type="email" name="email" autocomplete="off"><br>
  <input type="submit">
</form>

http://codepen.io/piyushpatel2005/pen/aJQaNN


问:
Distinct is not working?
```<code>  $data = Districts::distinct()->whereRaw('LOWER(district) like ?', [strtolower('%'.$district . '%')])->orWhereRaw('LOWER(region) like ?', [strtolower('%'.$district . '%')])->select('region', 'district')->get();
</code>```

I have this query, but problem is that distinct not working. I get for example three records for same thing. Any suggestion?

答:
try to this may i think its could be work

```<code>  $data = Districts::select( DB::raw('DISTINCT(district)'))->whereRaw('LOWER(district) like ?', [strtolower('%'.$district . '%')])->orWhereRaw('LOWER(region) like ?', [strtolower('%'.$district . '%')])->get();
</code>```

Title: Distinct is not working?

Body:
  $data = Districts::distinct()->whereRaw('LOWER(district) like ?', [strtolower('%'.$district . '%')])->orWhereRaw('LOWER(region) like ?', [strtolower('%'.$district . '%')])->select('region', 'district')->get();

I have this query, but problem is that distinct not working. I get for example three records for same thing. Any suggestion?

Body:
try to this may i think its could be work

  $data = Districts::select( DB::raw('DISTINCT(district)'))->whereRaw('LOWER(district) like ?', [strtolower('%'.$district . '%')])->orWhereRaw('LOWER(region) like ?', [strtolower('%'.$district . '%')])->get();


问:
Is increment an atomic operation in JavaScript?
Is increment an atomic operation in JavaScript? If one thread is accessing
++i; and at the same time another one starts to access the operation will there be any problems?

答: Javascript does not support multithreading. It may have web workers, but your question would not apply to this case, as workers do not share variables.</p>


问:
Warning: mysql_num_rows(): supplied argument is not a valid
Hi i'm receiving the error below, i've double checked everything and don't know why its being displayed.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/namebob/public_html/site_reg/statlookup.php on line 6</p>

```<code><?php
    include_once('common.php');
    $cid        =   $_REQUEST['cid'];
    $_elmID     =   $_REQUEST['elmID'];
    $scan = mysql_query("SELECT  `id`, `state` FROM `mast_state` WHERE `countryid` = $cid");
    if(mysql_num_rows($scan)>0)
    {
...
</code>```

答: It's worth trying var_dump($scan), if you get something like null / false, that means the query fails. If that's the case, try echo mysql_error() to check for any sql error (missing table etc)

Body:
Hi i'm receiving the error below, i've double checked everything and don't know why its being displayed.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/namebob/public_html/site_reg/statlookup.php on line 6

<?php
    include_once('common.php');
    $cid        =   $_REQUEST['cid'];
    $_elmID     =   $_REQUEST['elmID'];
    $scan = mysql_query("SELECT  `id`, `state` FROM `mast_state` WHERE `countryid` = $cid");
    if(mysql_num_rows($scan)>0)
    {
...


问:
Why can minValue == maxValue in Random.Next?
http://msdn.microsoft.com/en-us/library/2dx6wyd4.aspx

Apparently maxValue is an exclusive upper bound. So Random.Next(2,3) will always return 2. Random.Next(2,2) will also always return 2. Why do you suppose they even allow the min to be equal to the max in this case? It's misleading!

答:
It's just a convention, if somewhat misleading. You'd be able to construct such a scenario (where the output is the same every time) in any case. It's useful for selecting a random element of an array, for example:

```<code>var random = new Random();
var element = someArray[random.Next(0, someArray.Length)]; // Of course, the lower bound needn't be specified here.
</code>```

Edit: Misunderstood your question! My guess is that it's either a) poor design or b) a convenience for when your two bounds will potentially be the same. I'd agree that it's unintuitive though.

Body:
It's just a convention, if somewhat misleading. You'd be able to construct such a scenario (where the output is the same every time) in any case. It's useful for selecting a random element of an array, for example:

var random = new Random();
var element = someArray[random.Next(0, someArray.Length)]; // Of course, the lower bound needn't be specified here.

Edit: Misunderstood your question! My guess is that it's either a) poor design or b) a convenience for when your two bounds will potentially be the same. I'd agree that it's unintuitive though.


问:
What is a StackOverflowError?
What is a StackOverflowError, what causes it, and how should I deal with them?

答:
A StackOverflowError is a runtime error in Java.

It is thrown when the amount of call stack memory allocated by the JVM is exceeded.

A common case of a StackOverflowError being thrown, is when the call stack exceeds due to excessive deep or infinite recursion.

Example:

```<code>public class Factorial {
    public static int factorial(int n){
        if(n == 1){
            return 1;
        }
        else{
            return n * factorial(n-1);
        }
    }

    public static void main(String[] args){
         System.out.println("Main method started");
        int result = Factorial.factorial(-1);
        System.out.println("Factorial ==>"+result);
        System.out.println("Main method ended");
    }
}
</code>```

Stack trace:

Main method started
Exception in thread "main" java.lang.StackOverflowError
at com.program.stackoverflow.Factorial.factorial(Factorial.java:9)
at com.program.stackoverflow.Factorial.factorial(Factorial.java:9)
at com.program.stackoverflow.Factorial.factorial(Factorial.java:9)
```

In the above case, it can be avoided by doing programmatic changes.
But if the program logic is correct and it still occurs then your stack size needs to be increased.

OwnerDisplayName: Ziggy

Title: What is a StackOverflowError?

Body:
A StackOverflowError is a runtime error in Java.

It is thrown when the amount of call stack memory allocated by the JVM is exceeded.

A common case of a StackOverflowError being thrown, is when the call stack exceeds due to excessive deep or infinite recursion.

Example:

public class Factorial {
    public static int factorial(int n){
        if(n == 1){
            return 1;
        }
        else{
            return n * factorial(n-1);
        }
    }

    public static void main(String[] args){
         System.out.println("Main method started");
        int result = Factorial.factorial(-1);
        System.out.println("Factorial ==>"+result);
        System.out.println("Main method ended");
    }
}

Stack trace:

Main method started
Exception in thread "main" java.lang.StackOverflowError
at com.program.stackoverflow.Factorial.factorial(Factorial.java:9)
at com.program.stackoverflow.Factorial.factorial(Factorial.java:9)
at com.program.stackoverflow.Factorial.factorial(Factorial.java:9)

In the above case, it can be avoided by doing programmatic changes.
But if the program logic is correct and it still occurs then your stack size needs to be increased.

ContentLicense: CC BY-SA 4.0


问:
How to make a span with glyphicon as a hyperlink?
I have some form with glyphicon question mark for field inline tooltip on right:

```<code><div class="form-group required">
    <label for="username" class="col-sm-2 control-label">User Name:</label>
    <div class="col-sm-3 tooltip-box">
        <input id="username" type="text" class="form-control" placeholder="username"/>
        <div class="row tooltip-block"><a href="#" data-toggle="popover" data-trigger="hover" data-placement="auto right" data-content="Test tooltip.">
            <span class="glyphicon glyphicon-question-sign"></span></a>
        </div>
    </div>
</div>
</code>```

In full screen it looks as I need:

But on mobile devices or small screens it works only with hovering some very small area within my glyphicon mark and the tooltip overlays it:

Also when I inspect the corresponding a element in Chrome's developer tools, it points to some area outside the span element:

Here is the fiddle: https://jsfiddle.net/r2cm9c9u/

How is it possible to make the whole span with glyphicon as a hyperlink for tooltip?

答:
I would move the positioning to the actual link and make the link and glyphicon a block element:

I have added a class to the link below

  User Name:

    <input id="username" type="text" class="form-control" placeholder="username" />

```

<p>And changed your classes: </p>

<pre class="lang-css prettyprint-override"><code>.tooltip-box .glyphicon-holder {
  position: absolute;
  top: 8px;
  right: 22px;
  font-size: 1.25em;
  display: block;
}

.tooltip-box .glyphicon-holder:hover {
    text-decoration: none;
}

.glyphicon.glyphicon-question-sign {
  color: gray;
  display: block;
}
</code>```

Updated fiddle

Body:
I have some form with glyphicon question mark for field inline tooltip on right:

    User Name:

        <input id="username" type="text" class="form-control" placeholder="username"/>

In full screen it looks as I need:

But on mobile devices or small screens it works only with hovering some very small area within my glyphicon mark and the tooltip overlays it:

Also when I inspect the corresponding a element in Chrome's developer tools, it points to some area outside the span element:

Here is the fiddle: https://jsfiddle.net/r2cm9c9u/

How is it possible to make the whole span with glyphicon as a hyperlink for tooltip?

Body:
I would move the positioning to the actual link and make the link and glyphicon a block element:

I have added a class to the link below

<div class="form-group required">
  <label for="username" class="col-sm-2 control-label">User Name:</label>
  <div class="col-sm-3 tooltip-box">
    <input id="username" type="text" class="form-control" placeholder="username" />
    <div class="row tooltip-block">
      <a href="#" data-toggle="popover" data-trigger="hover" data-placement="auto right" data-content="Test tooltip." class="glyphicon-holder">
        <span class="glyphicon glyphicon-question-sign"></span></a>
    </div>
  </div>
</div>

And changed your classes:

.tooltip-box .glyphicon-holder {
  position: absolute;
  top: 8px;
  right: 22px;
  font-size: 1.25em;
  display: block;
}

.tooltip-box .glyphicon-holder:hover {
    text-decoration: none;
}

.glyphicon.glyphicon-question-sign {
  color: gray;
  display: block;
}

Updated fiddle


问:
How to fix that taxes are not showing in PrestaShop 1.6
I am using PrestaShop 1.6.0.9.

I have added a tax rule for our local Spanish Sales tax rate at 21%. All of my products have this listed as the tax rule to follow. In our area I am required to charge this flat tax rate to all purchases regardless of the shipping destination. When I enter the prices for the products the tax rule is not showing directly. I have to click 2-3 times on save and stay button then it shows in the back office and then it comes and I have to select it every time and the separate line of tax is showing in the shopping cart but tax is always showing 0.

I have changed all the things but unable to show the tax in the shopping cart. I am also required to show the amount of tax on a separate line in the checkout process.

Currently I have the settings as follows.

Product set up:

Tax Rule is set to my special tax rule added as an additional option in the state taxes.

Tax Options:

Enable Tax: Yes

Display Taxes in Cart: Yes

Base on: Invoice Address

Use EcoTax: No

The taxes are not being calculated nor are they being displayed in the shopping cart or during the checkout process. Is there something I need to be doing differently?

This is the last thing to do before I go live and if I can't get it fixed.

Thank you for your assistance in advance!

答:
I was facing similar case.
I imported the localization pack ....and it worked.
Didn't do anything else, just import localization pack.</p>


问:
Route53 Private Hosted Zone Parameterised List of VPCs
I'm trying to create a Cloud Formation Template for a Route53 Private Hosted Zone where lists of VPCs and Regions that the PHZ is associated are supplied as a Parameter

```<code>  VPCIds:
    Type: List<AWS::EC2::VPC::Id>
    Description: The Evertz VPC Id

  Regions:
    Type: CommaDelimitedList
    Description: A list that containing the matching regions for the VPCs given

  NumberOfVPC:
    Type: Number
</code>```

I've got conditions set up to for specifying the number of VPCs.

```<code>Conditions:
  2VPC: !Or [
    !Equals [!Ref NumberOfVPC, 2],
    Condition: 3VPC,
    Condition: 4VPC,
    Condition: 5VPC,
    Condition: 6VPC,
    Condition: 7VPC,
    Condition: 8VPC
    ]
  3VPC: !Or [
    !Equals [!Ref NumberOfVPC, 3],
    Condition: 4VPC,
    Condition: 5VPC,
    Condition: 6VPC,
    Condition: 7VPC,
    Condition: 8VPC
    ]...
</code>```

unfortunately I've not been able to create the list of HostedZoneVPCs

I was hoping to use these conditions to supply AWS::NoValue to when building the list

```<code>  Route53PrivateHostedZone:
    Type: "AWS::Route53::HostedZone"
    Properties:
      Name: !Ref ZoneName
      HostedZoneConfig:
        Comment: String
      HostedZoneTags:
        - Key: Name
          Value: Hosted Zone
      VPCs:
        -
          VPCId: !If [2VPC, !Ref "AWS::NoValue", !Select [0, !Ref VPCIds]]
          VPCRegion: !If [2VPC, !Ref "AWS::NoValue", !Select [0, !Ref Regions]]

      VPCs:
        - VPCId: !If [2VPC, !Select [0, !Ref VPCIds], !Ref "AWS::NoValue"]
          VPCRegion: !If [2VPC, !Select [0, !Ref Regions], !Ref "AWS::NoValue"]

        - VPCId: !If [2VPC, !Select [1, !Ref VPCIds], !Ref "AWS::NoValue"]
          VPCRegion: !If [2VPC, !Select [1, !Ref Regions], !Ref "AWS::NoValue"]
</code>```

However this does not work and fails to create the Hosted Zone.

Is there any way within Cloudformation that I can construct the list of HostedZoneVPCs using the xVPC Conditions I've created?

答:
The solution I've currently found is to nest !If and use here to fall down to the next VPC/Region List is the count does not much. Also change Conditions so that they are not cumulative;

```<code>Conditions:
  1VPC: !Equals [!Ref NumberOfVPC, 1]
  2VPC: !Equals [!Ref NumberOfVPC, 2]
  3VPC: !Equals [!Ref NumberOfVPC, 3]
  4VPC: !Equals [!Ref NumberOfVPC, 4]
  5VPC: !Equals [!Ref NumberOfVPC, 5]
  6VPC: !Equals [!Ref NumberOfVPC, 6]
  7VPC: !Equals [!Ref NumberOfVPC, 7]
  8VPC: !Equals [!Ref NumberOfVPC, 8]
</code>```

and the VPCs Property then becomes;

```<code>  VPCs:
    !If [1VPC,
    [
      {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]}
    ],
      !If [2VPC,
      [
        {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
        {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]}
      ],
        !If [3VPC,
        [
          {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
          {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
          {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]}
        ],
          !If [4VPC,
          [
            {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
            {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
            {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
            {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]}
          ],
            !If [5VPC,
            [
              {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
              {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
              {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
              {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
              {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]}
            ],
              !If [6VPC,
              [
                {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
                {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
                {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
                {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
                {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
                {VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]}
              ],
                !If [7VPC,
                [
                  {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
                  {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
                  {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
                  {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
                  {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
                  {VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]},
                  {VPCId: !Select [6, !Ref VPCIds], VPCRegion: !Select [6, !Ref Regions]}
                ],
                  !If [8VPC,
                  [
                    {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
                    {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
                    {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
                    {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
                    {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
                    {VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]},
                    {VPCId: !Select [6, !Ref VPCIds], VPCRegion: !Select [6, !Ref Regions]},
                    {VPCId: !Select [7, !Ref VPCIds], VPCRegion: !Select [7, !Ref Regions]}
                  ],
                  !Ref "AWS::NoValue"
                  ]
                ]
              ]
            ]
          ]
        ]
      ]
    ]
</code>```

Body:
I'm trying to create a Cloud Formation Template for a Route53 Private Hosted Zone where lists of VPCs and Regions that the PHZ is associated are supplied as a Parameter

  VPCIds:
    Type: List<AWS::EC2::VPC::Id>
    Description: The Evertz VPC Id

  Regions:
    Type: CommaDelimitedList
    Description: A list that containing the matching regions for the VPCs given

  NumberOfVPC:
    Type: Number

I've got conditions set up to for specifying the number of VPCs.

Conditions:
  2VPC: !Or [
    !Equals [!Ref NumberOfVPC, 2],
    Condition: 3VPC,
    Condition: 4VPC,
    Condition: 5VPC,
    Condition: 6VPC,
    Condition: 7VPC,
    Condition: 8VPC
    ]
  3VPC: !Or [
    !Equals [!Ref NumberOfVPC, 3],
    Condition: 4VPC,
    Condition: 5VPC,
    Condition: 6VPC,
    Condition: 7VPC,
    Condition: 8VPC
    ]...

unfortunately I've not been able to create the list of HostedZoneVPCs

I was hoping to use these conditions to supply AWS::NoValue to when building the list

  Route53PrivateHostedZone:
    Type: "AWS::Route53::HostedZone"
    Properties:
      Name: !Ref ZoneName
      HostedZoneConfig:
        Comment: String
      HostedZoneTags:
        - Key: Name
          Value: Hosted Zone
      VPCs:
        -
          VPCId: !If [2VPC, !Ref "AWS::NoValue", !Select [0, !Ref VPCIds]]
          VPCRegion: !If [2VPC, !Ref "AWS::NoValue", !Select [0, !Ref Regions]]

      VPCs:
        - VPCId: !If [2VPC, !Select [0, !Ref VPCIds], !Ref "AWS::NoValue"]
          VPCRegion: !If [2VPC, !Select [0, !Ref Regions], !Ref "AWS::NoValue"]

        - VPCId: !If [2VPC, !Select [1, !Ref VPCIds], !Ref "AWS::NoValue"]
          VPCRegion: !If [2VPC, !Select [1, !Ref Regions], !Ref "AWS::NoValue"]

However this does not work and fails to create the Hosted Zone.

Is there any way within Cloudformation that I can construct the list of HostedZoneVPCs using the xVPC Conditions I've created?

Body:
The solution I've currently found is to nest !If and use here to fall down to the next VPC/Region List is the count does not much. Also change Conditions so that they are not cumulative;

Conditions:
  1VPC: !Equals [!Ref NumberOfVPC, 1]
  2VPC: !Equals [!Ref NumberOfVPC, 2]
  3VPC: !Equals [!Ref NumberOfVPC, 3]
  4VPC: !Equals [!Ref NumberOfVPC, 4]
  5VPC: !Equals [!Ref NumberOfVPC, 5]
  6VPC: !Equals [!Ref NumberOfVPC, 6]
  7VPC: !Equals [!Ref NumberOfVPC, 7]
  8VPC: !Equals [!Ref NumberOfVPC, 8]

and the VPCs Property then becomes;

  VPCs:
    !If [1VPC,
    [
      {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]}
    ],
      !If [2VPC,
      [
        {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
        {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]}
      ],
        !If [3VPC,
        [
          {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
          {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
          {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]}
        ],
          !If [4VPC,
          [
            {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
            {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
            {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
            {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]}
          ],
            !If [5VPC,
            [
              {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
              {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
              {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
              {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
              {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]}
            ],
              !If [6VPC,
              [
                {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
                {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
                {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
                {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
                {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
                {VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]}
              ],
                !If [7VPC,
                [
                  {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
                  {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
                  {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
                  {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
                  {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
                  {VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]},
                  {VPCId: !Select [6, !Ref VPCIds], VPCRegion: !Select [6, !Ref Regions]}
                ],
                  !If [8VPC,
                  [
                    {VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
                    {VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
                    {VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
                    {VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
                    {VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
                    {VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]},
                    {VPCId: !Select [6, !Ref VPCIds], VPCRegion: !Select [6, !Ref Regions]},
                    {VPCId: !Select [7, !Ref VPCIds], VPCRegion: !Select [7, !Ref Regions]}
                  ],
                  !Ref "AWS::NoValue"
                  ]
                ]
              ]
            ]
          ]
        ]
      ]
    ]


问:
Image path upload and displaying image in mysql
I need to upload an image to database and path should be saved in table. I am using the below code to upload the image and store the path in database table. I have created a directory "images" for storing image which is uploaded by user.

```<code>if(isset($_POST['submit']))
{
  $errors= array();
  $file_name=$_FILES['photo']['name'];
  $file_size =$_FILES['photo']['size'];
  $file_tmp =$_FILES['photo']['tmp_name'];
  $file_type=$_FILES['photo']['type'];
  $file_ext=strtolower(end(explode('.',$_FILES['photo']['name'])));
  $expensions= array("jpeg","jpg","png");
  if(in_array($file_ext,$expensions)=== false){
  $errors[]="extension not allowed, please choose a JPEG or PNG file.";
  }
  if($file_size > 2097152){
  $errors[]='File size must be excately 2 MB';
  }
  if(empty($errors)==true){
  move_uploaded_file($file_tmp,"images/".$file_name);
  echo '<script language="javascript">';
  echo 'alert("Success")';
  echo '</script>';
  }
  else
  {
    echo '<script language="javascript">';
    echo 'alert("Failed")';
    echo '</script>';
    print_r($errors);
  }
  }
  $query = mysql_query("insert into e(photo) values ('$file_name')");
  echo '<script language="javascript">';
  echo 'alert("Ok")';
  echo '</script>';
 }
</code>```

Then the image should be displayed from database using the stored path in table. I am using the below code to display the image from database.

```<code>$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("s", $connection);
$sql = "SELECT * FROM e";
$result = mysql_query($sql);
while ($o = mysql_fetch_assoc($result))
{
    echo "<tbody>";
    echo "<tr>";
    echo "<td>".'<img src="$photo;"' ."</td>";
    echo "</tr>";
    echo "</tbody>";
}
?>
</code>```

答:
```<code>$connection = mysql_connect("localhost", "root", "password", "s");
$sql = "SELECT * FROM e";
$result = mysql_query($sql);
while ($o = mysql_fetch_assoc($result))
{
    echo "<tbody>";
    echo "<tr>";
    echo "<td>".'<img src="path/'.$o['photo']."></td>";
    echo "</tr>";
    echo "</tbody>";
}
?>
</code>```

Where photo is the column name from your database.
Also, you can simply pass the database name in your connection declaration instead of using the mysql_select_db

Body:
I need to upload an image to database and path should be saved in table. I am using the below code to upload the image and store the path in database table. I have created a directory "images" for storing image which is uploaded by user.

if(isset($_POST['submit']))
{
  $errors= array();
  $file_name=$_FILES['photo']['name'];
  $file_size =$_FILES['photo']['size'];
  $file_tmp =$_FILES['photo']['tmp_name'];
  $file_type=$_FILES['photo']['type'];
  $file_ext=strtolower(end(explode('.',$_FILES['photo']['name'])));
  $expensions= array("jpeg","jpg","png");
  if(in_array($file_ext,$expensions)=== false){
  $errors[]="extension not allowed, please choose a JPEG or PNG file.";
  }
  if($file_size > 2097152){
  $errors[]='File size must be excately 2 MB';
  }
  if(empty($errors)==true){
  move_uploaded_file($file_tmp,"images/".$file_name);
  echo '';
  }
  else
  {
    echo '';
    print_r($errors);
  }
  }
  $query = mysql_query("insert into e(photo) values ('$file_name')");
  echo '';
 }

Then the image should be displayed from database using the stored path in table. I am using the below code to display the image from database.

$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("s", $connection);
$sql = "SELECT * FROM e";
$result = mysql_query($sql);
while ($o = mysql_fetch_assoc($result))
{
    echo "
";
    echo "
";
    echo "".'

Body:
$connection = mysql_connect("localhost", "root", "password", "s");
$sql = "SELECT * FROM e";
$result = mysql_query($sql);
while ($o = mysql_fetch_assoc($result))
{
    echo "<tbody>";
    echo "<tr>";
    echo "<td>".'<img src="path/'.$o['photo']."></td>";
    echo "</tr>";
    echo "</tbody>";
}
?>

Where photo is the column name from your database.
Also, you can simply pass the database name in your connection declaration instead of using the mysql_select_db


问:
Cordova - Android SDK not found
I saw a lot of thread in here related to this, but any of them helped me.

With Cordova 6.5.0 installed and Android Studio also installed with Android 6.0 (API 23) and Android 4.4 (API 19), I'm trying to run:

```<code>cordova requirements
</code>```

I got the following error:

```<code>Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
</code>```

Ok. I set up the ANDROID_HOME and the PATH:

```<code>export ANDROID_HOME=/Users/USER/Library/Android/sdk
export PATH=${PATH}:/Users/USER/Library/Android/sdk/platform-tools:/Users/italoborges/Library/Android/sdk/tools
</code>```

I also changed inside platforms/project.properties the line:

```<code>target=android-23
</code>```

And inside platforms/android/AndroidManifest.xml the line:

```<code><uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />
</code>```

And inside platforms/android/CordovaLib/AndroidManifest.xml the same line above.

Right now I'm stuck because I have tried all the possibilities that I found.

Thanks.

答:
I found a workaround to fix the error:

```<code>https://github.com/apache/cordova-android/pull/367#issuecomment-286166329
</code>```

Reason of the error:
The latest Android SDK Tools (25.3.1) turfed the android command, which all of cordova's underlying functionality relied on.

Title: Cordova - Android SDK not found

Body:
I saw a lot of thread in here related to this, but any of them helped me.

With Cordova 6.5.0 installed and Android Studio also installed with Android 6.0 (API 23) and Android 4.4 (API 19), I'm trying to run:

cordova requirements

I got the following error:

Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.

Ok. I set up the ANDROID_HOME and the PATH:

export ANDROID_HOME=/Users/USER/Library/Android/sdk
export PATH=${PATH}:/Users/USER/Library/Android/sdk/platform-tools:/Users/italoborges/Library/Android/sdk/tools

I also changed inside platforms/project.properties the line:

target=android-23

And inside platforms/android/AndroidManifest.xml the line:

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />

And inside platforms/android/CordovaLib/AndroidManifest.xml the same line above.

Right now I'm stuck because I have tried all the possibilities that I found.

Thanks.

Body:
I found a workaround to fix the error:

https://github.com/apache/cordova-android/pull/367#issuecomment-286166329

Reason of the error:
The latest Android SDK Tools (25.3.1) turfed the android command, which all of cordova's underlying functionality relied on.


问:
How to add basic UI components in cordova project?
I am beginner of cordova learning project and creating a sample application using eclipse. Using CSS file I am able to change image, height, width, margin and padding around it.

Now, to show Labels, Buttons and Radio button, listview how to add such UI components and where to add in index.html or css and handling a click event of button?

答:
You could add any HTML component in the body tag.

```<code><body>
//your code for various elements goes here.
</body>
</code>```

But, if you want to add these components in real time use the innerHTML property (javascript) and allocate an event listener to that component.

HTML-

```<code><label id="alpha1" onclick="fx()">Placeholder</label>
</code>```

JS-

```<code>document.getElementById('alpha1').innerHTML="Content"
  function fx (){
    alert('Label Clicked');
}
</code>```

Body:
You could add any HTML component in the body tag.

<body>
//your code for various elements goes here.
</body>

But, if you want to add these components in real time use the innerHTML property (javascript) and allocate an event listener to that component.

HTML-

<label id="alpha1" onclick="fx()">Placeholder</label>

JS-

document.getElementById('alpha1').innerHTML="Content"
  function fx (){
    alert('Label Clicked');
}


问:
How to handle chrome extension panel's onSearch event?
How can I handle the onSearch event in my chrome devtools extension panel, which will fire when hitting Ctrl + F and typing some query string.

In my panel's background page I can listen for that event, but I don't know how to access it within the panel itself neither how to respond with the number of matches to get the search navigation working like in Elements Panel:

This functionality is very poorly documented on this link:
https://developer.chrome.com/extensions/devtools_panels

答:
Maybe it is not clear, but still documented by the link you specified.

You can set listener when creating a dev panel:

```<code>chrome.devtools.panels.create("My Dev Panel", null, "panel.html", function(panel) {
    panel.onSearch.addListener(function(action, querySearch) {
        // action - May be:
        //   "performSearch", "cancelSearch", "nextSearchResult", "previousSearchResult"
        // querySearch - search text
    });
});
</code>```

Btw, I suggest you to use debounce function for search implementation, because onSearch event fires on each key down.

Body:
Maybe it is not clear, but still documented by the link you specified.

You can set listener when creating a dev panel:

chrome.devtools.panels.create("My Dev Panel", null, "panel.html", function(panel) {
    panel.onSearch.addListener(function(action, querySearch) {
        // action - May be:
        //   "performSearch", "cancelSearch", "nextSearchResult", "previousSearchResult"
        // querySearch - search text
    });
});

Btw, I suggest you to use debounce function for search implementation, because onSearch event fires on each key down.


答:
Most probably your query is failing.  Try:</p>

```<code>if($scan) {
  if(mysql_num_rows($scan) > 0) {
    //...
  }
} else {
   trigger_error(mysql_error());
};
</code>```

Title: Warning: mysql_num_rows(): supplied argument is not a valid

Body:
Most probably your query is failing.  Try:

if($scan) {
  if(mysql_num_rows($scan) > 0) {
    //...
  }
} else {
   trigger_error(mysql_error());
};


问:
Reload page after click ok button in jquery alert
Following link is the example of which is am faced as issue. I should reload the page when i click ok button. Unless the page should not be reload. I have google for this. Still no result. How to achieve this.

Jsfiddle

```<code> $(function () {
bootbox.alert({
    message: "I'm the first!"
});
location.reload(true);
});
</code>```

答:
```<code>$(function () {
    bootbox.alert({
    message: "I'm the first!",
    callback: function () { location.reload(true); }
});
</code>```

Body:
Following link is the example of which is am faced as issue. I should reload the page when i click ok button. Unless the page should not be reload. I have google for this. Still no result. How to achieve this.

Jsfiddle

 $(function () {
bootbox.alert({
    message: "I'm the first!"
});
location.reload(true);
});


问:
My PHP mail() doesn't work
I'm having a big headache because PHP mail() funcion does not work. I've already reinstalled the postfix app, but still no change!
If I do a telnet to localhost in port 25, I can send mails from the command line

```<code>root@server:/etc/postfix# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 myserver.com.br ESMTP Postfix
ehlo
401 Syntax: EHLO hostname
ehlo localhost
250-myserver.com.br
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: info@myserver.com.br
250 2.1.0 Ok
rcpt to: testes@gmail.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: Ola

Boas t
.
250 2.0.0 Ok: queued as A71558AB472
</code>```

I have installed the Zpanel before, don't really know if it's this what's messing with PHP mail... What else can it be?

The PHP mail() function I'm using is very simple and works on other servers:

```<code>mail("testes@hotmail.com","Tell","and","FROM: info@myserver.com.br\n\n");
</code>```

The error Log that I get is something like this:

```<code>Nov 19 15:28:43 myserver postfix/pickup[6186]: 89B898AB477: uid=33 from=<www-data>
Nov 19 15:28:43 myserver postfix/cleanup[6630]: 89B898AB477: message-id=<20131119172843.89B898AB477@myserver.com.br>
Nov 19 15:28:43 myserver postfix/qmgr[6187]: 89B898AB477: from=<www-data@myserver.com.br>, size=361, nrcpt=1 (queue active)
Nov 19 15:28:44 myserver postfix/smtp[6634]: 89B898AB477: to=<testes@hotmail.com>, relay=mx1.hotmail.com[65.55.37.120]:25, delay=0.99, delays=0.17/0.01/0.6/0.2, dsn=4.0.0, status=SOFTBOUNCE (host mx1.hotmail.com[65.55.37.120] said: 550 SC-001 (COL0-MC4-F39) Unfortunately, messages from 201.33.21.60 weren't sent. Please contact your Internet service provider since part of their network is on our block list. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors. (in reply to MAIL FROM command))
Nov 19 15:28:44 myserver postfix/smtp[6634]: 89B898AB477: lost connection with mx1.hotmail.com[65.55.37.120] while sending RCPT TO
</code>```

EDIT : Figured out now that I can send this email to another server, but somehow Hotmail is blocking it.

答:
You may refer on these links to have your IP address remove from Hotmail black list

https://sender.office.com/

https://support.microsoft.com/en-us/getsupport?oaspworkflow=start_1.0.0.0&wfname=capsub&productkey=edfsmsbl3&locale=en-us&wa=wsignin1.0&ccsid=635965844486152513

Title: My PHP mail() doesn't work

Body:
I'm having a big headache because PHP mail() funcion does not work. I've already reinstalled the postfix app, but still no change!
If I do a telnet to localhost in port 25, I can send mails from the command line

root@server:/etc/postfix# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 myserver.com.br ESMTP Postfix
ehlo
401 Syntax: EHLO hostname
ehlo localhost
250-myserver.com.br
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: info@myserver.com.br
250 2.1.0 Ok
rcpt to: testes@gmail.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: Ola

Boas t
.
250 2.0.0 Ok: queued as A71558AB472

I have installed the Zpanel before, don't really know if it's this what's messing with PHP mail... What else can it be?

The PHP mail() function I'm using is very simple and works on other servers:

mail("testes@hotmail.com","Tell","and","FROM: info@myserver.com.br\n\n");

The error Log that I get is something like this:

Nov 19 15:28:43 myserver postfix/pickup[6186]: 89B898AB477: uid=33 from=<www-data>
Nov 19 15:28:43 myserver postfix/cleanup[6630]: 89B898AB477: message-id=<20131119172843.89B898AB477@myserver.com.br>
Nov 19 15:28:43 myserver postfix/qmgr[6187]: 89B898AB477: from=<www-data@myserver.com.br>, size=361, nrcpt=1 (queue active)
Nov 19 15:28:44 myserver postfix/smtp[6634]: 89B898AB477: to=<testes@hotmail.com>, relay=mx1.hotmail.com[65.55.37.120]:25, delay=0.99, delays=0.17/0.01/0.6/0.2, dsn=4.0.0, status=SOFTBOUNCE (host mx1.hotmail.com[65.55.37.120] said: 550 SC-001 (COL0-MC4-F39) Unfortunately, messages from 201.33.21.60 weren't sent. Please contact your Internet service provider since part of their network is on our block list. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors. (in reply to MAIL FROM command))
Nov 19 15:28:44 myserver postfix/smtp[6634]: 89B898AB477: lost connection with mx1.hotmail.com[65.55.37.120] while sending RCPT TO

EDIT : Figured out now that I can send this email to another server, but somehow Hotmail is blocking it.


问:
How do I align a TextBox and Label in TableLayoutPanel?
I have read a few articles on this but none seem to help. How do I align the label and textbox in the following case:</p>

```<code> Using frm As New frmWithTableLayout
     frm.TableLayoutPanel1.ColumnCount = 2
     frm.TableLayoutPanel1.RowCount = 3

     'create report Type'
     Dim lblReportType As New Label
     lblReportType.Text = "Report Type"
     lblReportType.Dock = DockStyle.Right
     Dim reportType As New System.Windows.Forms.TextBox()
     reportType.Text = "Income"
     frm.TableLayoutPanel1.Controls.Add(lblReportType, 0, 0)
     frm.TableLayoutPanel1.Controls.Add(reportType, 1, 0)
 End Using
</code>```

答:
There are a few ways to approach it but doing it this way means you get the changes at design time (so no need to run the code to see how it will look), and it will retroactively correct all your existing layouts without needing to fix the TextAlignment and Anchor properties on each Label on a control-by-control basis.

1)

```<code>public class TableLayoutPanelEx : TableLayoutPanel
 {
    public TableLayoutPanelEx()
    {
        ControlAdded += OnControlAdded;
    }

    private void OnControlAdded(object sender, ControlEventArgs args)
    {
        var control = args.Control as Label;
        if (control != null) {
            control.TextAlign = ContentAlignment.MiddleLeft;
            control.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left);
        }
    }
}
</code>```

2) Project-wide search/replace new TableLayoutPanel( with new TableLayoutPanelEx(.

3) ?

4) Profit

Before:

After:

Body:
I have read a few articles on this but none seem to help. How do I align the label and textbox in the following case:

 Using frm As New frmWithTableLayout
     frm.TableLayoutPanel1.ColumnCount = 2
     frm.TableLayoutPanel1.RowCount = 3

     'create report Type'
     Dim lblReportType As New Label
     lblReportType.Text = "Report Type"
     lblReportType.Dock = DockStyle.Right
     Dim reportType As New System.Windows.Forms.TextBox()
     reportType.Text = "Income"
     frm.TableLayoutPanel1.Controls.Add(lblReportType, 0, 0)
     frm.TableLayoutPanel1.Controls.Add(reportType, 1, 0)
 End Using

Body:
There are a few ways to approach it but doing it this way means you get the changes at design time (so no need to run the code to see how it will look), and it will retroactively correct all your existing layouts without needing to fix the TextAlignment and Anchor properties on each Label on a control-by-control basis.

1)

public class TableLayoutPanelEx : TableLayoutPanel
 {
    public TableLayoutPanelEx()
    {
        ControlAdded += OnControlAdded;
    }

    private void OnControlAdded(object sender, ControlEventArgs args)
    {
        var control = args.Control as Label;
        if (control != null) {
            control.TextAlign = ContentAlignment.MiddleLeft;
            control.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left);
        }
    }
}

2) Project-wide search/replace new TableLayoutPanel( with new TableLayoutPanelEx(.

3) ?

4) Profit

Before:

After:


问:
CompletableFuture | thenApply vs thenCompose
I can't get my head around the difference between thenApply and thenCompose.

So, could someone provide a valid use case?

From the Java docs:

```<code>thenApply(Function<? super T,? extends U> fn)
</code>```

Returns a new CompletionStage that, when this stage completes
normally, is executed with this stage's result as the argument to the
supplied function.

```<code>thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
</code>```

Returns a new CompletionStage that, when this stage completes
normally, is executed with this stage as the argument to the supplied
function.

I get that the 2nd argument of thenCompose extends the CompletionStage where thenApply does not.

Could someone provide an example in which case I have to use thenApply and when thenCompose?

答:
The updated Javadocs in Java 9 will probably help understand it better:

thenApply

 CompletionStage thenApply(Function<? super T,? extends U> fn)

Returns a new CompletionStage that, when this stage completes
  normally, is executed with this stage's result as the argument to the
  supplied function.

This method is analogous to Optional.map and Stream.map.

See the CompletionStage documentation for rules covering
  exceptional completion.

thenCompose

```<code><U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
</code>```

Returns a new CompletionStage that is completed with the same
  value as the CompletionStage returned by the given function.

When this stage completes normally, the given function is invoked with
  this stage's result as the argument, returning another
  CompletionStage. When that stage completes normally, the
  CompletionStage returned by this method is completed with the same
  value.

To ensure progress, the supplied function must arrange eventual
  completion of its result.

This method is analogous to Optional.flatMap and
  Stream.flatMap.

See the CompletionStage documentation for rules covering
  exceptional completion.

Body:
I can't get my head around the difference between thenApply and thenCompose.

So, could someone provide a valid use case?

From the Java docs:

thenApply(Function<? super T,? extends U> fn)

Returns a new CompletionStage that, when this stage completes
normally, is executed with this stage's result as the argument to the
supplied function.

thenCompose(Function<? super T,? extends CompletionStage> fn)

Returns a new CompletionStage that, when this stage completes
normally, is executed with this stage as the argument to the supplied
function.

I get that the 2nd argument of thenCompose extends the CompletionStage where thenApply does not.

Could someone provide an example in which case I have to use thenApply and when thenCompose?

Body:
The updated Javadocs in Java 9 will probably help understand it better:

thenApply

<U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)

Returns a new CompletionStage that, when this stage completes
  normally, is executed with this stage's result as the argument to the
  supplied function.

This method is analogous to Optional.map and Stream.map.

See the CompletionStage documentation for rules covering
  exceptional completion.

thenCompose

<U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)

Returns a new CompletionStage that is completed with the same
  value as the CompletionStage returned by the given function.

When this stage completes normally, the given function is invoked with
  this stage's result as the argument, returning another
  CompletionStage. When that stage completes normally, the
  CompletionStage returned by this method is completed with the same
  value.

To ensure progress, the supplied function must arrange eventual
  completion of its result.

This method is analogous to Optional.flatMap and
  Stream.flatMap.

See the CompletionStage documentation for rules covering
  exceptional completion.


问:
Mutliple URL Segments to Index Function With CodeIgniter
Please excuse me if this is an incredibly stupid question, as I'm new to CodeIgniter.

I have a controller for my verification system called Verify. I'd like to be able to use it something like site.com/verify/123/abcd, but I only want to use the index function, so both URL segments need to go to it.

I'm sure this can be done with URL routing somehow, but I can't figure out how to pass both URL segments into Verify's index function..

答:
Something like this in routes.php should do the job:

$route['verify/(:any)/(:any)'] = "verify/index/$1/$2";


问:
Delete rows from sheet where match is found in excel
I have an excel sheet which has just over a thousand lines and I need to be delete all ROWS in it which are as follows:

column A, B,C,D,E,F AND G  MUST be an exact match.

Column H (hours) must have a negative value which matches the same value but positive forming a pair, then the pair is deleted.

so the following is an example of  a match:

```<code>date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42
</code>```

resulting in:

```<code>date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42
</code>```

I'm having trouble explaining it let alone writing a macro!

```<code>Dim LR As Long
Dim i As Long

'Remove rows
LR = Range("H" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    'How do i compare it against other rows?
Next i
</code>```

答:
I think (meaning I didn't test :-)) this should do the job.

```<code>Option Explicit

Sub DeleteMatchingRow()
    ' 30 Mar 2017

    Dim Rl As Long
    Dim R As Long

    Application.ScreenUpdating = False
    With ActiveSheet
        Rl = .Range("H" & .Rows.Count).End(xlUp).Row
        For R = Rl To 2 Step -1
            If FindMatch(CompString(.Rows(R)), Val(.Cells(R, 8).Value), R) Then
                .Rows(R).EntireRow.Delete
            End If
        Next R
    End With
    Application.ScreenUpdating = Treu
End Sub

Private Function FindMatch(ByVal Comp1 As String, _
                           ByVal Gval As Integer, _
                           ByVal LR As Long) As Long
    ' 30 Mar 2017
    ' return the row number where a match was found
    ' or return 0, if no match was found

    Dim R As Long
    Dim Comp2 As String

    With ActiveSheet
        For R = LR To 1 Step -1
            Comp2 = CompString(.Rows(R))
            If StrComp(Comp1, Comp2, vbBinaryCompare) = 0 Then
                If .Cells(R, 8).Value = (Gval * -1) Then
                    FindMatch = R
                    Exit Function
                End If
            End If
        Next R
    End With
End Function

Private Function CompString(Row As Range) As String
    ' 30 Mar 2017

    Dim Fun As String
    Dim C As Long

    With Row
        For C = 1 To 7
            Fun = Fun & CStr(.Cells(C).Value)
        Next C
    End With
    CompString = Fun
End Function
</code>```

The code prepares two strings consisting of A+B+C+D+E+F (all as strings, not numbers) and compares them. If they are identical, the value in column G is compares with its pendent in the match row * -1. If the two values are identical the row is identified as a match.

The function CompString prepares the comparison strings. The function FindMatch finds the match, and the main routine DeleteMatchingRow does the deleting. I don't have the data to test it on, but in theory it sounds good, doesn't it?

You can use the following function to get a visual of rows which you consider matching but the code doesn't.

```<code>Private Sub TestMatch()
    ' 31 Mar 2017

    Dim R As Long

    R = 3
    With ActiveSheet
        Debug.Print CompString(.Rows(R)), "Column G has "; .Cells(R, 8).Value
    End With
End Sub
</code>```

Paste this code in the same code sheet as the function CompString. Make sure that the sheet from which you want to read a line is active (look at it before switching to the VBE window). Replace the value 3 in the code with the number of the row you wish to read. The compare string will be printed in the VB Editor's Immediate Window (press Ctl+G if you don't see it). Repeat the exercise with the other string. You can then compare them visually and determine why VBA considers them different.

Body:
I have an excel sheet which has just over a thousand lines and I need to be delete all ROWS in it which are as follows:

column A, B,C,D,E,F AND G  MUST be an exact match.

Column H (hours) must have a negative value which matches the same value but positive forming a pair, then the pair is deleted.

so the following is an example of  a match:

date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42

resulting in:

date    prod    Item    Title   Code    person      number  hours
2016    xxx     123     test    a12d    John Smith  78901   -8
2016    xxx     123     test    a12d    John Smith  78901   -42

I'm having trouble explaining it let alone writing a macro!

Dim LR As Long
Dim i As Long

'Remove rows
LR = Range("H" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    'How do i compare it against other rows?
Next i

Body:
I think (meaning I didn't test :-)) this should do the job.

Option Explicit

Sub DeleteMatchingRow()
    ' 30 Mar 2017

    Dim Rl As Long
    Dim R As Long

    Application.ScreenUpdating = False
    With ActiveSheet
        Rl = .Range("H" & .Rows.Count).End(xlUp).Row
        For R = Rl To 2 Step -1
            If FindMatch(CompString(.Rows(R)), Val(.Cells(R, 8).Value), R) Then
                .Rows(R).EntireRow.Delete
            End If
        Next R
    End With
    Application.ScreenUpdating = Treu
End Sub

Private Function FindMatch(ByVal Comp1 As String, _
                           ByVal Gval As Integer, _
                           ByVal LR As Long) As Long
    ' 30 Mar 2017
    ' return the row number where a match was found
    ' or return 0, if no match was found

    Dim R As Long
    Dim Comp2 As String

    With ActiveSheet
        For R = LR To 1 Step -1
            Comp2 = CompString(.Rows(R))
            If StrComp(Comp1, Comp2, vbBinaryCompare) = 0 Then
                If .Cells(R, 8).Value = (Gval * -1) Then
                    FindMatch = R
                    Exit Function
                End If
            End If
        Next R
    End With
End Function

Private Function CompString(Row As Range) As String
    ' 30 Mar 2017

    Dim Fun As String
    Dim C As Long

    With Row
        For C = 1 To 7
            Fun = Fun & CStr(.Cells(C).Value)
        Next C
    End With
    CompString = Fun
End Function

The code prepares two strings consisting of A+B+C+D+E+F (all as strings, not numbers) and compares them. If they are identical, the value in column G is compares with its pendent in the match row * -1. If the two values are identical the row is identified as a match.

The function CompString prepares the comparison strings. The function FindMatch finds the match, and the main routine DeleteMatchingRow does the deleting. I don't have the data to test it on, but in theory it sounds good, doesn't it?

You can use the following function to get a visual of rows which you consider matching but the code doesn't.

Private Sub TestMatch()
    ' 31 Mar 2017

    Dim R As Long

    R = 3
    With ActiveSheet
        Debug.Print CompString(.Rows(R)), "Column G has "; .Cells(R, 8).Value
    End With
End Sub

Paste this code in the same code sheet as the function CompString. Make sure that the sheet from which you want to read a line is active (look at it before switching to the VBE window). Replace the value 3 in the code with the number of the row you wish to read. The compare string will be printed in the VB Editor's Immediate Window (press Ctl+G if you don't see it). Repeat the exercise with the other string. You can then compare them visually and determine why VBA considers them different.


问:
Regex to remove all except XML
I need help with a Regex for notepad++ to match all but XML

The regex I'm using:
(!?\<.*\>) <-- I want the opposite of this (in first three lines)

The example code:

```<code>[20173003] This text is what I want to delete [<Person><Name>Foo</Name><Surname>Bar</Surname></Person>], and this text too.
[20173003] This is another text to delete [<Person><Name>Bar</Name><Surname>Foo</Surname></Person>]
[20173003] This text too... [<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>], delete me!
[20173003] But things like this make the regex to fail < [<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>], or this>
</code>```

Expected result:

```<code><Person><Name>Foo</Name><Surname>Bar</Surname></Person>
<Person><Name>Bar</Name><Surname>Foo</Surname></Person>
<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>
<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>
</code>```

Thanks in advance!

答:
This is not perfect, but should work with your input that looks quite simple and well-structured.

If you need to handle just a single unnested <Person> tag, you may use simple (<Person>.*?</Person>)|. regex (that will match and capture into Group 1 any <Person> tag and will match any other char) and replace with a conditional replacement pattern (?{1}$1\n:) (that will reinsert Person tag with a newline after it or will replace the match with an empty string):

To make it a bit more generic, you may capture the opening and corresponding closing XML tags with a recursion-based Boost regex, and the appropriate conditional replacement pattern:

Find What:      (<(\w+)[^>]*>(?:(?!</?\2\b).|(?1))*</\2>)|.

Replace With: (?{1}$1\n:)

. matches newline: ON

Regex Details:

(<(\w+)[^>]*>(?:(?!</?\2\b).|(?1))*</\2>) - Capturing group 1 (that will be later recursed with the (?1) subrouting call) matching

<(\w+)[^>]*> - any opening tag with its name captured into Group 2

(?:(?!</?\2\b).|(?1))* - zero or more occurrences of:

(?!</?\2\b). - any char (.) not starting a sequence of </ + tag name as a whole word with an optional / in front

| - or

(?1) - the whole  Group 1 subpattern is recursed (repeated)

</\2> - the corresponding closing tag

| - or

. - any single char.

Replacement pattern:

(?{1}  - if Group 1 matches:

$1\n - replace with its contents + a newline

: - else replace with an empty string

) -  end of the replacement pattern.

Title: Regex to remove all except XML

Body:
I need help with a Regex for notepad++ to match all but XML

The regex I'm using:
(!?\<.*\>) <-- I want the opposite of this (in first three lines)

The example code:

[20173003] This text is what I want to delete [<Person><Name>Foo</Name><Surname>Bar</Surname></Person>], and this text too.
[20173003] This is another text to delete [<Person><Name>Bar</Name><Surname>Foo</Surname></Person>]
[20173003] This text too... [<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>], delete me!
[20173003] But things like this make the regex to fail < [<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>], or this>

Expected result:

<Person><Name>Foo</Name><Surname>Bar</Surname></Person>
<Person><Name>Bar</Name><Surname>Foo</Surname></Person>
<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>
<Person><Name>Lorem</Name><Surname>Ipsum</Surname></Person>

Thanks in advance!