问:
enable SOAP on PHP
I would like to enable SOAP on my PHP5/Centos/Apache server.  I have full access to the server.  My php.ini file includes the below.  When I look at phpinfo(), it doesn't reference SOAP.  Any suggestions?  Thank you

```<code>[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=1
; Sets the directory name where SOAP extension will put cache files.
soap.wsdl_cache_dir="/tmp"
; (time to live) Sets the number of second while cached file will be used
; instead of original one.
soap.wsdl_cache_ttl=86400
</code>```

EDIT - Get the following.  Tried it on two different servers.

```<code>[root@localhost ~]# yum install php-soap
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ecvps.com
 * extras: mirror.spro.net
 * rpmforge: mirror.hmc.edu
 * updates: centos.mirror.facebook.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-soap.x86_64 0:5.1.6-34.el5_8 set to be updated
--> Processing Dependency: php-common = 5.1.6-34.el5_8 for package: php-soap
--> Finished Dependency Resolution
php-soap-5.1.6-34.el5_8.x86_64 from updates has depsolving problems
  --> Missing Dependency: php-common = 5.1.6-34.el5_8 is needed by package php-soap-5.1.6-34.el5_8.x86_64 (updates)
Error: Missing Dependency: php-common = 5.1.6-34.el5_8 is needed by package php-soap-5.1.6-34.el5_8.x86_64 (updates)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
</code>```

SECOND EDIT PART 1

```<code>[root@localhost ~]# yum --enablerepo=webtatic install php-soap
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ecvps.com
 * extras: mirrors.ecvps.com
 * rpmforge: mirror.hmc.edu
 * updates: mirror.5ninesolutions.com
adobe-linux-x86_64                                       |  951 B     00:00
base                                                     | 1.1 kB     00:00
extras                                                   | 2.1 kB     00:00
rpmforge                                                 | 1.9 kB     00:00
updates                                                  | 1.9 kB     00:00
webtatic                                                 |  951 B     00:00
webtatic/primary                                         |  40 kB     00:00
webtatic                                                                182/182
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-soap.x86_64 0:5.3.13-1.w5 set to be updated
--> Processing Dependency: php-common = 5.3.13-1.w5 for package: php-soap
--> Running transaction check
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-cli
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-mysql
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-xml
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-imap
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-odbc
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-xmlrpc
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-ldap
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-pdo
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-gd
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-mbstring
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-mcrypt
---> Package php-common.x86_64 0:5.3.13-1.w5 set to be updated
--> Running transaction check
--> Processing Dependency: php = 5.3.4-1.w5 for package: php-devel
---> Package php.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-cli.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-gd.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-imap.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-ldap.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-mbstring.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-mcrypt.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-mysql.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-odbc.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-pdo.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-xml.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-xmlrpc.x86_64 0:5.3.13-1.w5 set to be updated
--> Running transaction check
---> Package php-devel.x86_64 0:5.3.13-1.w5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch           Version             Repository        Size
================================================================================
Installing:
 php-soap             x86_64         5.3.13-1.w5         webtatic         144 k
Updating for dependencies:
 php                  x86_64         5.3.13-1.w5         webtatic         1.4 M
 php-cli              x86_64         5.3.13-1.w5         webtatic         2.6 M
 php-common           x86_64         5.3.13-1.w5         webtatic         653 k
 php-devel            x86_64         5.3.13-1.w5         webtatic         622 k
 php-gd               x86_64         5.3.13-1.w5         webtatic         107 k
 php-imap             x86_64         5.3.13-1.w5         webtatic          50 k
 php-ldap             x86_64         5.3.13-1.w5         webtatic          35 k
 php-mbstring         x86_64         5.3.13-1.w5         webtatic         1.2 M
 php-mcrypt           x86_64         5.3.13-1.w5         webtatic          30 k
 php-mysql            x86_64         5.3.13-1.w5         webtatic          91 k
 php-odbc             x86_64         5.3.13-1.w5         webtatic          50 k
 php-pdo              x86_64         5.3.13-1.w5         webtatic          66 k
 php-xml              x86_64         5.3.13-1.w5         webtatic         118 k
 php-xmlrpc           x86_64         5.3.13-1.w5         webtatic          50 k

Transaction Summary
================================================================================
Install       1 Package(s)
Upgrade      14 Package(s)

Total download size: 7.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/15): php-mcrypt-5.3.13-1.w5.x86_64.rpm                |  30 kB     00:00
(2/15): php-ldap-5.3.13-1.w5.x86_64.rpm                  |  35 kB     00:00
(3/15): php-xmlrpc-5.3.13-1.w5.x86_64.rpm                |  50 kB     00:00
(4/15): php-imap-5.3.13-1.w5.x86_64.rpm                  |  50 kB     00:00
(5/15): php-odbc-5.3.13-1.w5.x86_64.rpm                  |  50 kB     00:00
(6/15): php-pdo-5.3.13-1.w5.x86_64.rpm                   |  66 kB     00:00
(7/15): php-mysql-5.3.13-1.w5.x86_64.rpm                 |  91 kB     00:00
(8/15): php-gd-5.3.13-1.w5.x86_64.rpm                    | 107 kB     00:00
(9/15): php-xml-5.3.13-1.w5.x86_64.rpm                   | 118 kB     00:00
(10/15): php-soap-5.3.13-1.w5.x86_64.rpm                 | 144 kB     00:00
(11/15): php-devel-5.3.13-1.w5.x86_64.rpm                | 622 kB     00:00
(12/15): php-common-5.3.13-1.w5.x86_64.rpm               | 653 kB     00:01
(13/15): php-mbstring-5.3.13-1.w5.x86_64.rpm             | 1.2 MB     00:00
(14/15): php-5.3.13-1.w5.x86_64.rpm                      | 1.4 MB     00:02
(15/15): php-cli-5.3.13-1.w5.x86_64.rpm                  | 2.6 MB     00:02
--------------------------------------------------------------------------------
Total                                           604 kB/s | 7.1 MB     00:12
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cf4c4ff9
webtatic/gpgkey                                          | 1.6 kB     00:00

Public key for php-mbstring-5.3.13-1.w5.x86_64.rpm is not installed
</code>```

SECOND EDIT PART 2

```<code>[root@localhost ~]# yum --enablerepo=webtatic install  webtatic-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ecvps.com
 * extras: mirrors.ecvps.com
 * rpmforge: mirror.hmc.edu
 * updates: centos.mirror.facebook.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package webtatic-release.noarch 0:5-2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                   Arch            Version      Repository         Size
================================================================================
Updating:
 webtatic-release          noarch          5-2          webtatic           11 k

Transaction Summary
================================================================================
Install       0 Package(s)
Upgrade       1 Package(s)

Total download size: 11 k
Is this ok [y/N]: y
Downloading Packages:
webtatic-release-5-2.noarch.rpm                          |  11 kB     00:00
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cf4c4ff9
webtatic/gpgkey                                          | 1.6 kB     00:00

Public key for webtatic-release-5-2.noarch.rpm is not installed
</code>```

答:
In case that you have Ubuntu in your machine try  the following in your terminal:

sudo apt-get install php-soap

service apache2 restart

To check use php test file inside it only the following function phpinfo();
and check results in the browser which contains the following module like that image:

Title: enable SOAP on PHP

Body:
I would like to enable SOAP on my PHP5/Centos/Apache server.  I have full access to the server.  My php.ini file includes the below.  When I look at phpinfo(), it doesn't reference SOAP.  Any suggestions?  Thank you

[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=1
; Sets the directory name where SOAP extension will put cache files.
soap.wsdl_cache_dir="/tmp"
; (time to live) Sets the number of second while cached file will be used
; instead of original one.
soap.wsdl_cache_ttl=86400

EDIT - Get the following.  Tried it on two different servers.

[root@localhost ~]# yum install php-soap
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ecvps.com
 * extras: mirror.spro.net
 * rpmforge: mirror.hmc.edu
 * updates: centos.mirror.facebook.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-soap.x86_64 0:5.1.6-34.el5_8 set to be updated
--> Processing Dependency: php-common = 5.1.6-34.el5_8 for package: php-soap
--> Finished Dependency Resolution
php-soap-5.1.6-34.el5_8.x86_64 from updates has depsolving problems
  --> Missing Dependency: php-common = 5.1.6-34.el5_8 is needed by package php-soap-5.1.6-34.el5_8.x86_64 (updates)
Error: Missing Dependency: php-common = 5.1.6-34.el5_8 is needed by package php-soap-5.1.6-34.el5_8.x86_64 (updates)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest

SECOND EDIT PART 1

[root@localhost ~]# yum --enablerepo=webtatic install php-soap
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ecvps.com
 * extras: mirrors.ecvps.com
 * rpmforge: mirror.hmc.edu
 * updates: mirror.5ninesolutions.com
adobe-linux-x86_64                                       |  951 B     00:00
base                                                     | 1.1 kB     00:00
extras                                                   | 2.1 kB     00:00
rpmforge                                                 | 1.9 kB     00:00
updates                                                  | 1.9 kB     00:00
webtatic                                                 |  951 B     00:00
webtatic/primary                                         |  40 kB     00:00
webtatic                                                                182/182
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-soap.x86_64 0:5.3.13-1.w5 set to be updated
--> Processing Dependency: php-common = 5.3.13-1.w5 for package: php-soap
--> Running transaction check
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-cli
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-mysql
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-xml
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-imap
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-odbc
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-xmlrpc
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-ldap
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-pdo
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-gd
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-mbstring
--> Processing Dependency: php-common = 5.3.4-1.w5 for package: php-mcrypt
---> Package php-common.x86_64 0:5.3.13-1.w5 set to be updated
--> Running transaction check
--> Processing Dependency: php = 5.3.4-1.w5 for package: php-devel
---> Package php.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-cli.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-gd.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-imap.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-ldap.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-mbstring.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-mcrypt.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-mysql.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-odbc.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-pdo.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-xml.x86_64 0:5.3.13-1.w5 set to be updated
---> Package php-xmlrpc.x86_64 0:5.3.13-1.w5 set to be updated
--> Running transaction check
---> Package php-devel.x86_64 0:5.3.13-1.w5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch           Version             Repository        Size
================================================================================
Installing:
 php-soap             x86_64         5.3.13-1.w5         webtatic         144 k
Updating for dependencies:
 php                  x86_64         5.3.13-1.w5         webtatic         1.4 M
 php-cli              x86_64         5.3.13-1.w5         webtatic         2.6 M
 php-common           x86_64         5.3.13-1.w5         webtatic         653 k
 php-devel            x86_64         5.3.13-1.w5         webtatic         622 k
 php-gd               x86_64         5.3.13-1.w5         webtatic         107 k
 php-imap             x86_64         5.3.13-1.w5         webtatic          50 k
 php-ldap             x86_64         5.3.13-1.w5         webtatic          35 k
 php-mbstring         x86_64         5.3.13-1.w5         webtatic         1.2 M
 php-mcrypt           x86_64         5.3.13-1.w5         webtatic          30 k
 php-mysql            x86_64         5.3.13-1.w5         webtatic          91 k
 php-odbc             x86_64         5.3.13-1.w5         webtatic          50 k
 php-pdo              x86_64         5.3.13-1.w5         webtatic          66 k
 php-xml              x86_64         5.3.13-1.w5         webtatic         118 k
 php-xmlrpc           x86_64         5.3.13-1.w5         webtatic          50 k

Transaction Summary
================================================================================
Install       1 Package(s)
Upgrade      14 Package(s)

Total download size: 7.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/15): php-mcrypt-5.3.13-1.w5.x86_64.rpm                |  30 kB     00:00
(2/15): php-ldap-5.3.13-1.w5.x86_64.rpm                  |  35 kB     00:00
(3/15): php-xmlrpc-5.3.13-1.w5.x86_64.rpm                |  50 kB     00:00
(4/15): php-imap-5.3.13-1.w5.x86_64.rpm                  |  50 kB     00:00
(5/15): php-odbc-5.3.13-1.w5.x86_64.rpm                  |  50 kB     00:00
(6/15): php-pdo-5.3.13-1.w5.x86_64.rpm                   |  66 kB     00:00
(7/15): php-mysql-5.3.13-1.w5.x86_64.rpm                 |  91 kB     00:00
(8/15): php-gd-5.3.13-1.w5.x86_64.rpm                    | 107 kB     00:00
(9/15): php-xml-5.3.13-1.w5.x86_64.rpm                   | 118 kB     00:00
(10/15): php-soap-5.3.13-1.w5.x86_64.rpm                 | 144 kB     00:00
(11/15): php-devel-5.3.13-1.w5.x86_64.rpm                | 622 kB     00:00
(12/15): php-common-5.3.13-1.w5.x86_64.rpm               | 653 kB     00:01
(13/15): php-mbstring-5.3.13-1.w5.x86_64.rpm             | 1.2 MB     00:00
(14/15): php-5.3.13-1.w5.x86_64.rpm                      | 1.4 MB     00:02
(15/15): php-cli-5.3.13-1.w5.x86_64.rpm                  | 2.6 MB     00:02
--------------------------------------------------------------------------------
Total                                           604 kB/s | 7.1 MB     00:12
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cf4c4ff9
webtatic/gpgkey                                          | 1.6 kB     00:00

Public key for php-mbstring-5.3.13-1.w5.x86_64.rpm is not installed

SECOND EDIT PART 2

[root@localhost ~]# yum --enablerepo=webtatic install  webtatic-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ecvps.com
 * extras: mirrors.ecvps.com
 * rpmforge: mirror.hmc.edu
 * updates: centos.mirror.facebook.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package webtatic-release.noarch 0:5-2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                   Arch            Version      Repository         Size
================================================================================
Updating:
 webtatic-release          noarch          5-2          webtatic           11 k

Transaction Summary
================================================================================
Install       0 Package(s)
Upgrade       1 Package(s)

Total download size: 11 k
Is this ok [y/N]: y
Downloading Packages:
webtatic-release-5-2.noarch.rpm                          |  11 kB     00:00
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cf4c4ff9
webtatic/gpgkey                                          | 1.6 kB     00:00

Public key for webtatic-release-5-2.noarch.rpm is not installed


来源: stackexchange

问:
Drawing tables in terminal using ANSI box characters
I'm trying to print a table that's more pleasant to the eye than the pure text representation of it. basically I want to convert something like this:

```<code>+-----+--------+
| age | weight |
+-----+--------+
| 10  | 100    |
| 80  | 500    |
+-----+--------+
</code>```

to something like this:

```<code>┌─────┬────────┐
| age | weight |
├─────┼────────┤
│ 10  │   100  │
│ 80  │  500   │
└─────┴────────┘
</code>```

here is the screenshot of what I see in terminal:

Notice the gaps between the rows. My problem is that they are not connecting properly while other Unix tools that use ANSI printing look fine in terminal. For example, tree, if I run tree -A in my terminal `I get this:

notice how vertical lines are connected together. it's funny because when I copy and paste the output of tree into my text editor and run my script I get something like this:

Obviously I'm missing something about printing ANSI chars in terminal and couldn't find anything about it by googling it. can anyone shed some light on this topic?

答:
You really should investigate ncurses and its variants. There are a range of different language bindings, though it was originally written for C. It provides a fairly substantial suite of libraries for producing TUIs (Text UIs) with windows, menus, boxed borders etc.
Hit up wikipedia to start with to find some other references.</p>

ContentLicense: CC BY-SA 2.5

Body:
I'm trying to print a table that's more pleasant to the eye than the pure text representation of it. basically I want to convert something like this:

+-----+--------+
| age | weight |
+-----+--------+
| 10  | 100    |
| 80  | 500    |
+-----+--------+

to something like this:

┌─────┬────────┐
| age | weight |
├─────┼────────┤
│ 10  │   100  │
│ 80  │  500   │
└─────┴────────┘

here is the screenshot of what I see in terminal:

Notice the gaps between the rows. My problem is that they are not connecting properly while other Unix tools that use ANSI printing look fine in terminal. For example, tree, if I run tree -A in my terminal `I get this:

notice how vertical lines are connected together. it's funny because when I copy and paste the output of tree into my text editor and run my script I get something like this:

Obviously I'm missing something about printing ANSI chars in terminal and couldn't find anything about it by googling it. can anyone shed some light on this topic?


问:
Parsing array into individual strings from a table view - Objective-C
I've been trying to parse an array and split it into separate strings. I have managed to successfully get this working by individually adding a fixed objectAtIndex when I set the strings.

Example:

```<code> NSString *weightString = [[[results valueForKey:@"Endurance"] objectAtIndex:7]objectAtIndex:2];
</code>```

However, when I try and set the strings in a tableView didSelectRowAtIndexPath using any objectAtIndex the string always returns null. I need to be able to click on the tableView row using objectAtIndex:indexPath.row. I can't work out where I am going wrong. Feel free to request more code or queries.

Query:

```<code>PFQuery *arrayQuery = [PFQuery queryWithClassName:@"Exercises"];
[arrayQuery selectKeys:@[@"Endurance"]];
[arrayQuery orderByAscending:@"ExerciseName"];
[arrayQuery findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
if (!error) { self.arrayResults = [results valueForKey:@"Endurance"];
</code>```

cellForRowAtIndexPath:

```<code>- (TableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"list";
TableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

UILabel *cellTitle;
cell.cellTitle.text = [[browseAllArray objectAtIndex: indexPath.row] objectForKey:@"ExerciseName"];

if (cell == nil) {
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    //Exercise Bar Label
    cellTitle = [[UILabel alloc] initWithFrame:CGRectMake(80, 20, 220, 60)];
    cellTitle.font = [UIFont fontWithName:@"ethnocentric" size:14];
    cellTitle.textColor = [UIColor blackColor];
    cellTitle.numberOfLines = 2;
    cellTitle.textAlignment = NSTextAlignmentCenter;

    cell.cellTitle.text = [[browseAllArray objectAtIndex: indexPath.row] objectForKey:@"ExerciseName"];
    [self.tableView reloadData];
}
cellTitle.text = [[browseAllArray objectAtIndex:indexPath.row]objectForKey:@"ExerciseName"];
return cell;
</code>```

答:
I have managed to solve my problem by changing the string in the didSelectRowAtIndexPath method.

Instead of using:

```<code> NSString *weightString = [[[results valueForKey:@"Endurance"] objectAtIndex:indexPath.row]objectAtIndex:2];
</code>```

I used:

```<code> NSString *weightString = [[arrayResults objectAtIndex:indexPath.row] objectAtIndex:2];
</code>```

I decided to try and use the array instead of results string as it wouldn't let me pull the information from the string. I would recommend following @Larme 's steps above as they definitely sent me in the right direction.

If people are trying to follow my steps make sure you remove the valueForKey as this was throwing a fatal error.

ContentLicense: CC BY-SA 3.0

Body:
I've been trying to parse an array and split it into separate strings. I have managed to successfully get this working by individually adding a fixed objectAtIndex when I set the strings.

Example:

 NSString *weightString = [[[results valueForKey:@"Endurance"] objectAtIndex:7]objectAtIndex:2];

However, when I try and set the strings in a tableView didSelectRowAtIndexPath using any objectAtIndex the string always returns null. I need to be able to click on the tableView row using objectAtIndex:indexPath.row. I can't work out where I am going wrong. Feel free to request more code or queries.

Query:

PFQuery *arrayQuery = [PFQuery queryWithClassName:@"Exercises"];
[arrayQuery selectKeys:@[@"Endurance"]];
[arrayQuery orderByAscending:@"ExerciseName"];
[arrayQuery findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
if (!error) { self.arrayResults = [results valueForKey:@"Endurance"];

cellForRowAtIndexPath:

- (TableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"list";
TableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

UILabel *cellTitle;
cell.cellTitle.text = [[browseAllArray objectAtIndex: indexPath.row] objectForKey:@"ExerciseName"];

if (cell == nil) {
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    //Exercise Bar Label
    cellTitle = [[UILabel alloc] initWithFrame:CGRectMake(80, 20, 220, 60)];
    cellTitle.font = [UIFont fontWithName:@"ethnocentric" size:14];
    cellTitle.textColor = [UIColor blackColor];
    cellTitle.numberOfLines = 2;
    cellTitle.textAlignment = NSTextAlignmentCenter;

    cell.cellTitle.text = [[browseAllArray objectAtIndex: indexPath.row] objectForKey:@"ExerciseName"];
    [self.tableView reloadData];
}
cellTitle.text = [[browseAllArray objectAtIndex:indexPath.row]objectForKey:@"ExerciseName"];
return cell;

Body:
I have managed to solve my problem by changing the string in the didSelectRowAtIndexPath method.

Instead of using:

 NSString *weightString = [[[results valueForKey:@"Endurance"] objectAtIndex:indexPath.row]objectAtIndex:2];

I used:

 NSString *weightString = [[arrayResults objectAtIndex:indexPath.row] objectAtIndex:2];

I decided to try and use the array instead of results string as it wouldn't let me pull the information from the string. I would recommend following @Larme 's steps above as they definitely sent me in the right direction.

If people are trying to follow my steps make sure you remove the valueForKey as this was throwing a fatal error.


问:
Where has "Message text garbled?" gone in gmail?
I want to see the text version of email in gmail. How can i check please some one help me.</p>

答:
Gmail removed “Message text garbled?” option now you can see text version of your email using following steps.

From the "More" menu, select "Show original"

In the address bar, update the "view" parameter in the query string from "om" to "dom"


问:
Weblogic 11g: Managed Server is not starting from Weblogic console
i have some strange situation:

When i am trying to start managed server on the console i get the following error on Nodemanager:

```<code>PM weblogic.nodemanager.server.Handler run
WARNING: I/O error while closing socket connection
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:135)
        at java.net.SocketInputStream.read(SocketInputStream.java:122)
        at weblogic.utils.io.ChunkedInputStream.read(ChunkedInputStream.java:159)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner$Context.fillBufferNetIn(JaSSLEngineRunner.java:323)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner$Transition_NeedUnwrap.getNextState(JaSSLEngineRunner.java:822)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner.doTransitions(JaSSLEngineRunner.java:763)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner.closeInbound(JaSSLEngineRunner.java:1279)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner.close(JaSSLEngineRunner.java:1365)
        at weblogic.security.SSL.jsseadapter.JaAbstractSSLSocket.close(JaAbstractSSLSocket.java:245)
        at weblogic.nodemanager.server.Handler.run(Handler.java:85)
        at java.lang.Thread.run(Thread.java:745)
</code>```

But when i am trying to start Managed Servers from command-line then it works correctly:

```<code>nohup ./startManagedWebLogic.sh server1 t3://xx.xx.xx.xx:7001 >/dev/null 2>&1 &
</code>```

In oracle Documentation i found that this issue can happen when in nodemanager.properties file the following line is set to false:

```<code>NativeVersionEnabled=false
</code>```

After i set it to true the issue is still persists.
The issue started after i did an Upgrade for Java from java jrockit to java JDK 1.80. I have also changed the certificates from Demo to custom.

Did someone had this issue before and knows how to fix it?

答:
In the nodemanager.properties file set the SecureListener attribute to false.
In the weblogic server admin console, configure the machine to not use a secured connection with the node manager (Node Manager tab)
These 2 options configure a non secured connection between the admin server and the node manager.</p>

Body:
i have some strange situation:

When i am trying to start managed server on the console i get the following error on Nodemanager:

PM weblogic.nodemanager.server.Handler run
WARNING: I/O error while closing socket connection
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:135)
        at java.net.SocketInputStream.read(SocketInputStream.java:122)
        at weblogic.utils.io.ChunkedInputStream.read(ChunkedInputStream.java:159)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner$Context.fillBufferNetIn(JaSSLEngineRunner.java:323)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner$Transition_NeedUnwrap.getNextState(JaSSLEngineRunner.java:822)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner.doTransitions(JaSSLEngineRunner.java:763)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner.closeInbound(JaSSLEngineRunner.java:1279)
        at weblogic.security.SSL.jsseadapter.JaSSLEngineRunner.close(JaSSLEngineRunner.java:1365)
        at weblogic.security.SSL.jsseadapter.JaAbstractSSLSocket.close(JaAbstractSSLSocket.java:245)
        at weblogic.nodemanager.server.Handler.run(Handler.java:85)
        at java.lang.Thread.run(Thread.java:745)

But when i am trying to start Managed Servers from command-line then it works correctly:

nohup ./startManagedWebLogic.sh server1 t3://xx.xx.xx.xx:7001 >/dev/null 2>&1 &

In oracle Documentation i found that this issue can happen when in nodemanager.properties file the following line is set to false:

NativeVersionEnabled=false

After i set it to true the issue is still persists.
The issue started after i did an Upgrade for Java from java jrockit to java JDK 1.80. I have also changed the certificates from Demo to custom.

Did someone had this issue before and knows how to fix it?


问:
Rails - Given a block of text, auto-link links
on mysite I have the ability to add comments. Sometimes users enter comments will links (href. ...)

I would like to have those links to be clickable/linkable (a href) when the comment is displayed to users.

how with Rails 3 can I take a comment, and look for links and then wrap those links in an a href tag that opens in a new window?

Thanks

答: idlefinger's suggestion of #auto_link is perfect.  I know it's not the question you originally posed, but wanted to suggest: also check out #simple_format, which will nicely format your users' use of newlines into br and p tags.</p>


问:
ActiveMQ access to previously published data on subscription
We're using ActiveMQ locally to transfer data between 5 processes that turn simultaneously.

I have some data I need to send to a process, both at runtime (which works perfectly fine), but also a default value on start. Thing is it is published when the process starts, it just doesn't read because it wasn't subscribed to the topic at the time the data was sent.

I have multiple solutions : I could delay the first publishing for a moment so that the process has time to launch (which doesn't seem very appealing) ; or is there a way to send all stored previously non-treated messages to some process that just subscribed ?

I'm coding in C#.

答: I went around the issue by sending a message from each process when they're launched back to the main one, and then only sending the info I needed to send.</p>


问:
how to show random two li in jquery?
Could you please tell me how to show random two li in jQuery ? I tried like this

$('#id_show12').click(function() {
    var random1 = Math.floor(Math.random() * 7);
    var random2 = Math.floor(Math.random() * 7);
    $('.show12 li').not(':eq(' + random1 + '), :eq(' + random2 + ')').hide();
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="show12">
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
  </ul>
</div>

<button id="id_show12">show only one two li</button></code>```

https://jsbin.com/dafurasaye/edit?html,js,output

答:
You need to reset to show all the elements, then run your logic over it, see below

$('#id_show12').click(function() {
  var random1 = Math.floor(Math.random() * 7);
  var random2 = Math.floor(Math.random() * 7);

  $('.show12 li')
    .show() /* <-- reset */
    .not(':eq(' + random1 + '), :eq(' + random2 + ')')
    .hide();
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="show12">
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
  </ul>
</div>
<button id="id_show12">show only one two li</button></code>```

Title: how to show random two li in jquery?

Body:
Could you please tell me how to show random two li in jQuery ? I tried like this

$('#id_show12').click(function() {
    var random1 = Math.floor(Math.random() * 7);
    var random2 = Math.floor(Math.random() * 7);
    $('.show12 li').not(':eq(' + random1 + '), :eq(' + random2 + ')').hide();
});

1

2

3

4

5

6

7

<button id="id_show12">show only one two li</button>

https://jsbin.com/dafurasaye/edit?html,js,output

Body:
You need to reset to show all the elements, then run your logic over it, see below

$('#id_show12').click(function() {
  var random1 = Math.floor(Math.random() * 7);
  var random2 = Math.floor(Math.random() * 7);

  $('.show12 li')
    .show() /* <-- reset */
    .not(':eq(' + random1 + '), :eq(' + random2 + ')')
    .hide();
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="show12">
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
  </ul>
</div>
<button id="id_show12">show only one two li</button>


问:
Regex Replace between groups
So I have the following regex.replace in C#:

```<code>Regex.Replace(inputString, @"^([^,]*,){5}(.*)", @"$1somestring,$2");
</code>```

where 5 is a variable number in code, but that's not really relevant since at the time of execution it will always have a set value (like 5, for example). Same with somestring,.

Essentially I want to input somestring, between the two groups. The output works for somestring,$2, but $1 is just printed as $1. So say whatever (.*) grabs = "2, a, f2" the resulting string I'd get out is $1somestring,2,a,f2 no matter what $1 is. Is this because of the repeating group feature {5}? If so, how do I grab the collection of repeats and put it in place of where I have $1 right now?

Edit: I know the first group captures correctly, as well. I grab the content of somestring, using this regex:

```<code>Regex.Match(line, @"^([^,]*,){5}([0-9]+\.[0-9]+),.*");
</code>```

The first part is identical the the first group in the replacement regex, and it works fine, so there shouldn't be an issue (and they're both used on the same string).

Edit2:

Ok I'll try to explain more of the process since someone said it was hard to understand. I have three variables, line a string I work with, and latIndex and lonIndex which are just ints (tells me between what ,'s two doubles I look for are located). I have the two following matches:

```<code>var latitudeMatch = Regex.Match(line, @"^([^,]*,){" + latIndex + @"}([0-9]+\.[0-9]+),.*");
var longitudeMatch = Regex.Match(line, @"^([^,]*,){" + lonIndex + @"}([0-9]+\.[0-9]+),.*");
</code>```

I then grab the doubles:

```<code>var latitude = latitudeMatch.Groups[2].Value;
var longitude = longitudeMatch.Groups[2].Value;
</code>```

I use these doubles to get a string from a web API, which i store in a variable called veiRef. Then I want to insert these after the doubles, using the following code (insert after lat or lon, depending on which one appears last):

```<code>if (latIndex > lonIndex)
{
    line = Regex.Replace(line, @"^([^,]*,){" + (latIndex+1) + @"}(.*)",$@"$1{veiRef},$2");
}
else
{
    line = Regex.Replace(line, @"^([^,]*,){" + (lonIndex + 1) + @"}(.*)", $@"$1{veiRef},$2");
}
</code>```

However, this results in a string line which doesn't have the content of $1 inserted before it ($2 works fine).

答:
You have a repeated capturing group at the start of the pattern that you need to turn into a non-capturing one and wrap with a capturing group. Then, you may access the whole part of the match with the $1  backreference.

```<code>var line = "a, s, f, double, double, 12, sd, 1";
var latIndex = 5;
var pat = $@"^((?:[^,]*,){{{latIndex+1}}})(.*)";
// Console.WriteLine(pat); // => ^((?:[^,]*,){6})(.*)
var veiRef = "str";
line = Regex.Replace(line, pat, $"${{1}}{veiRef.Replace("$","$$")}$2");
Console.WriteLine(line); // => a, s, f, double, double, 12,str sd, 1
</code>```

See the C# demo

The pattern - ^((?:[^,]*,){6})(.*) - now contains ((?:[^,]*,){6}) after ^, and this is now what $1 holds after a match is found.

Since your replacement string is dynamic, you need to make sure any $ inside gets doubled (hence, .Replace("$","$$")) and that the first backreference is unambiguous, thus it should look like ${1} (it will work regardless whether the veiRef starts with a digit or not).

Replacement string in details:

It is an interpolated string literal...

$" - declaration of the interpolated string literal (start)

${{1}} - a literal ${1} string (the { and } must be doubled to denote literal symbols)

{veiRef.Replace("$","$$")} - a piece of C# code inside the interpolated string literal (we delimit this part where code is permitted with single {...})

$2 - a literal $2 string

" - end of the interpolated string literal.

Title: Regex Replace between groups

Body:
So I have the following regex.replace in C#:

Regex.Replace(inputString, @"^([^,]*,){5}(.*)", @"$1somestring,$2");

where 5 is a variable number in code, but that's not really relevant since at the time of execution it will always have a set value (like 5, for example). Same with somestring,.

Essentially I want to input somestring, between the two groups. The output works for somestring,$2, but $1 is just printed as $1. So say whatever (.*) grabs = "2, a, f2" the resulting string I'd get out is $1somestring,2,a,f2 no matter what $1 is. Is this because of the repeating group feature {5}? If so, how do I grab the collection of repeats and put it in place of where I have $1 right now?

Edit: I know the first group captures correctly, as well. I grab the content of somestring, using this regex:

Regex.Match(line, @"^([^,]*,){5}([0-9]+\.[0-9]+),.*");

The first part is identical the the first group in the replacement regex, and it works fine, so there shouldn't be an issue (and they're both used on the same string).

Edit2:

Ok I'll try to explain more of the process since someone said it was hard to understand. I have three variables, line a string I work with, and latIndex and lonIndex which are just ints (tells me between what ,'s two doubles I look for are located). I have the two following matches:

var latitudeMatch = Regex.Match(line, @"^([^,]*,){" + latIndex + @"}([0-9]+\.[0-9]+),.*");
var longitudeMatch = Regex.Match(line, @"^([^,]*,){" + lonIndex + @"}([0-9]+\.[0-9]+),.*");

I then grab the doubles:

var latitude = latitudeMatch.Groups[2].Value;
var longitude = longitudeMatch.Groups[2].Value;

I use these doubles to get a string from a web API, which i store in a variable called veiRef. Then I want to insert these after the doubles, using the following code (insert after lat or lon, depending on which one appears last):

if (latIndex > lonIndex)
{
    line = Regex.Replace(line, @"^([^,]*,){" + (latIndex+1) + @"}(.*)",$@"$1{veiRef},$2");
}
else
{
    line = Regex.Replace(line, @"^([^,]*,){" + (lonIndex + 1) + @"}(.*)", $@"$1{veiRef},$2");
}

However, this results in a string line which doesn't have the content of $1 inserted before it ($2 works fine).

Body:
You have a repeated capturing group at the start of the pattern that you need to turn into a non-capturing one and wrap with a capturing group. Then, you may access the whole part of the match with the $1  backreference.

var line = "a, s, f, double, double, 12, sd, 1";
var latIndex = 5;
var pat = $@"^((?:[^,]*,){{{latIndex+1}}})(.*)";
// Console.WriteLine(pat); // => ^((?:[^,]*,){6})(.*)
var veiRef = "str";
line = Regex.Replace(line, pat, $"${{1}}{veiRef.Replace("$","$$")}$2");
Console.WriteLine(line); // => a, s, f, double, double, 12,str sd, 1

See the C# demo

The pattern - ^((?:[^,]*,){6})(.*) - now contains ((?:[^,]*,){6}) after ^, and this is now what $1 holds after a match is found.

Since your replacement string is dynamic, you need to make sure any $ inside gets doubled (hence, .Replace("$","$$")) and that the first backreference is unambiguous, thus it should look like ${1} (it will work regardless whether the veiRef starts with a digit or not).

Replacement string in details:

It is an interpolated string literal...

$" - declaration of the interpolated string literal (start)

${{1}} - a literal ${1} string (the { and } must be doubled to denote literal symbols)

{veiRef.Replace("$","$$")} - a piece of C# code inside the interpolated string literal (we delimit this part where code is permitted with single {...})

$2 - a literal $2 string

" - end of the interpolated string literal.


问:
chrome extension to access content of downloaded files
I'm working on a Chrome extension and I'd like to have the extension:

Click on a link to initiate a file download

Once the download is complete, open and read the contents of the downloaded file

Do something with the contents of the file in JavaScript

I see that the chrome.downloads API allows me to initiate the download and open the file, but is it possible for me to read the contents of the file (without writing native code)?

答:
I'm copying the answer I gave here.

You just need to add a permission to file://*in your manifest file and once you have your file's path in the system (with chrome.downloads.search in the filename property), make a GET XMLHttpRequest to the url file://{filepath}.


问:
Get data that is newer than given date
I am using Oracle

I want to see the result my data, where the date is after Jun 25th 2017. But I am seeing results from data that is older than the 25th Jun 2017. Some of it go all the way back to 1998 etc.

Here is my code:

```<code>   select DATE_OF_LAST_CHANGE_OF_IMMU
from recipient_treatment
where DATE_OF_LAST_CHANGE_OF_IMMU > TO_DATE('25-JUN-2017', 'DD-MON-YYYY')
;
</code>```

Is there something in my code that isn't right for what I wish to see?

The column: DATE_OF_LAST_CHANGE_OF_IMMU is of type date in the table

答:
Please use the trunc command while filtering the date field as specified below </p>

```<code>select DATE_OF_LAST_CHANGE_OF_IMMU
from recipient_treatment
where TRUNC (DATE_OF_LAST_CHANGE_OF_IMMU) > TO_DATE('25-JUN-2017', 'DD-MON-YYYY')
;
</code>```

Title: Get data that is newer than given date

Body:
I am using Oracle

I want to see the result my data, where the date is after Jun 25th 2017. But I am seeing results from data that is older than the 25th Jun 2017. Some of it go all the way back to 1998 etc.

Here is my code:

   select DATE_OF_LAST_CHANGE_OF_IMMU
from recipient_treatment
where DATE_OF_LAST_CHANGE_OF_IMMU > TO_DATE('25-JUN-2017', 'DD-MON-YYYY')
;

Is there something in my code that isn't right for what I wish to see?

The column: DATE_OF_LAST_CHANGE_OF_IMMU is of type date in the table

Body:
Please use the trunc command while filtering the date field as specified below

select DATE_OF_LAST_CHANGE_OF_IMMU
from recipient_treatment
where TRUNC (DATE_OF_LAST_CHANGE_OF_IMMU) > TO_DATE('25-JUN-2017', 'DD-MON-YYYY')
;


问:
Difference between ./usr and /usr when running a command
I have two directories in my new CentOS7:

Work_Folder1/my_project/linux_dev.cfg

Work_Folder2/my_project/linux_dev.cfg

If I try to run the command ./usr/bin/buildout -c linux_dev.cfg the build works fine from dir (1). If I try the same from (2) it says the ./usr/bin/buildout not exists.

After trying I see that from (2), /usr/bin/buildout -c linux_dev.cfg command works. So whats the role of . in here?

答: The command ./usr/bin/buildout looks for usr folder in the current directory.. While /usr/bin/buildout looks for usr in the root folder.. You might have usr folder in root as well as Work_Folder1, but not in WorkFolder2</p>


问:
CasperJS, trying to scrape a table
This function should extract all table rows but it doesn't work. It makes no output.

```<code>var casper = require("casper").create({
pageSettings: {
    userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"
},
verbose: true,
logLevel: 'debug'
});

var url = 'http://cnt.rm.ingv.it/';
casper.start(url);//
casper.waitForSelector('#dataTablesEvents', processPage, stopScript);
casper.run();

var stopScript = function() {
     casper.echo("STOPPING SCRIPT").exit();
};

var processPage = function() {

    pageData = this.evaluate(getPageData);

    if (this.exists('a[rel="next"]') == false) {
        stopScript();
    }

    this.thenClick('a[rel="next"]').then(function() {
        this.waitForSelector("#dataTablesEvents", processPage, stopScript);
    });
 };

function getPageData(){

   var rows = casper.evaluate(function(){
       return document.querySelectorAll("table tbody tr");
   });

   return rows;
}
</code>```

I try to debug and this is the result:

```<code>[debug] [phantom] opening url: http://cnt.rm.ingv.it/, HTTP GET
[debug] [phantom] Navigation requested: url=http://cnt.rm.ingv.it/,
type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "http://cnt.rm.ingv.it/"
[debug] [phantom] Successfully injected Casper client-side utilities
[debug] [phantom] start page is loaded
[info] [phantom] Step _step 3/3 http://cnt.rm.ingv.it/ (HTTP 200)
[info] [phantom] Step _step 3/3: done in 945ms.
[info] [phantom] waitFor() finished in 40ms.
[info] [phantom] Done 3 steps in 1003ms
[debug] [phantom] Navigation requested: url=about:blank, type=Other,
willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"
</code>```

I'm not able to understand well this.. It's like WaitForSelector doesn't start.. Any Help ?

答:
here is a way which should work for you:</p>

```<code>var casper = require('casper').create();
var url = 'http://cnt.rm.ingv.it/';
var length;

casper.start(url);

casper.then(function() {
    this.waitForSelector('table#dataTablesEvents');
});

function getCellContent(row, cell) {
    cellText = casper.evaluate(function(row, cell) {
        return document.querySelectorAll('table tbody tr')[row].childNodes[cell].innerText.trim();
    }, row, cell);
    return cellText;
}

casper.then(function() {
    var rows = casper.evaluate(function() {
        return document.querySelectorAll('table tbody tr');
    });
    length = rows.length;
    this.echo("table length: " + length);
});

// This part can be done nicer, but it's the way it should work ...
casper.then(function() {
    for (var i = 0; i < length; i++) {
        this.echo("Data: " + getCellContent(i, 1));
        this.echo("Magnitudo: " + getCellContent(i, 3));
        this.echo("Zona: " + getCellContent(i, 5));
        this.echo("Profondità: " + getCellContent(i, 7));
        this.echo("Latitudine: " + getCellContent(i, 9));
        this.echo("Longitudine: " + getCellContent(i, 11));
    }
});

casper.run();
</code>```

Title: CasperJS, trying to scrape a table

Body:
This function should extract all table rows but it doesn't work. It makes no output.

var casper = require("casper").create({
pageSettings: {
    userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"
},
verbose: true,
logLevel: 'debug'
});

var url = 'http://cnt.rm.ingv.it/';
casper.start(url);//
casper.waitForSelector('#dataTablesEvents', processPage, stopScript);
casper.run();

var stopScript = function() {
     casper.echo("STOPPING SCRIPT").exit();
};

var processPage = function() {

    pageData = this.evaluate(getPageData);

    if (this.exists('a[rel="next"]') == false) {
        stopScript();
    }

    this.thenClick('a[rel="next"]').then(function() {
        this.waitForSelector("#dataTablesEvents", processPage, stopScript);
    });
 };

function getPageData(){

   var rows = casper.evaluate(function(){
       return document.querySelectorAll("table tbody tr");
   });

   return rows;
}

I try to debug and this is the result:

[debug] [phantom] opening url: http://cnt.rm.ingv.it/, HTTP GET
[debug] [phantom] Navigation requested: url=http://cnt.rm.ingv.it/,
type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "http://cnt.rm.ingv.it/"
[debug] [phantom] Successfully injected Casper client-side utilities
[debug] [phantom] start page is loaded
[info] [phantom] Step _step 3/3 http://cnt.rm.ingv.it/ (HTTP 200)
[info] [phantom] Step _step 3/3: done in 945ms.
[info] [phantom] waitFor() finished in 40ms.
[info] [phantom] Done 3 steps in 1003ms
[debug] [phantom] Navigation requested: url=about:blank, type=Other,
willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"

I'm not able to understand well this.. It's like WaitForSelector doesn't start.. Any Help ?

Body:
here is a way which should work for you:

var casper = require('casper').create();
var url = 'http://cnt.rm.ingv.it/';
var length;

casper.start(url);

casper.then(function() {
    this.waitForSelector('table#dataTablesEvents');
});

function getCellContent(row, cell) {
    cellText = casper.evaluate(function(row, cell) {
        return document.querySelectorAll('table tbody tr')[row].childNodes[cell].innerText.trim();
    }, row, cell);
    return cellText;
}

casper.then(function() {
    var rows = casper.evaluate(function() {
        return document.querySelectorAll('table tbody tr');
    });
    length = rows.length;
    this.echo("table length: " + length);
});

// This part can be done nicer, but it's the way it should work ...
casper.then(function() {
    for (var i = 0; i < length; i++) {
        this.echo("Data: " + getCellContent(i, 1));
        this.echo("Magnitudo: " + getCellContent(i, 3));
        this.echo("Zona: " + getCellContent(i, 5));
        this.echo("Profondità: " + getCellContent(i, 7));
        this.echo("Latitudine: " + getCellContent(i, 9));
        this.echo("Longitudine: " + getCellContent(i, 11));
    }
});

casper.run();


问:
PHP parse error on hello world
(warning: beginner)
So i set up a web server with a apache, mysql, php for OS X tutorial online.

https://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/

Everything is working and i can get on localhost/user/sites/ to open .php scripts. When im doing the simplest things like :

```<code><?php
echo "Hi";
?>
</code>```

Parse error: parse error, expecting `"identifier (T_STRING)"' in
  /Users/xyz/Sites/test.php on line 11

But there is not even a line 11 to correct something?

I even tried it with html body and so on. not working either.

Apache is working and the mysql server too.
phpMyAdmin is working, i can edit lists on mysql and so on.
phpInfo tells me its version 5.5.38

What can i do to get a simple browser view of what i wrote in my .php doc?

答:
Make a folder in your htdocs.
After that make in your new folder a file that named "index.php"and put your code in this file.
Than go to your browser and put this link: "localhost/youfoldername"

Is see your link /Users/xyz/Sites/test.php. You have to work in your htdocs folder

To find you the htdocs folder: Open your xampp surface and than click on "Open application folder"

Title: PHP parse error on hello world

Body:
(warning: beginner)
So i set up a web server with a apache, mysql, php for OS X tutorial online.

https://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/

Everything is working and i can get on localhost/user/sites/ to open .php scripts. When im doing the simplest things like :

<?php
echo "Hi";
?>

Parse error: parse error, expecting `"identifier (T_STRING)"' in
  /Users/xyz/Sites/test.php on line 11

But there is not even a line 11 to correct something?

I even tried it with html body and so on. not working either.

Apache is working and the mysql server too.
phpMyAdmin is working, i can edit lists on mysql and so on.
phpInfo tells me its version 5.5.38

What can i do to get a simple browser view of what i wrote in my .php doc?


答:
You all logic works great when you show before you hide them.

```<code>$('.show12 li').show();
$('.show12 li').not(':eq('+random1+'), :eq('+random2+')').hide();
</code>```

Currently it is not working because you are hiding them and not showing them back when you click again.

Note that you are not handling the case when the random numbers are same. (0,0 | 3,3) If you don't handle the case, sometimes it just show only one option.

Title: how to show random two li in jquery?

Body:
You all logic works great when you show before you hide them.

$('.show12 li').show();
$('.show12 li').not(':eq('+random1+'), :eq('+random2+')').hide();

Currently it is not working because you are hiding them and not showing them back when you click again.

Note that you are not handling the case when the random numbers are same. (0,0 | 3,3) If you don't handle the case, sometimes it just show only one option.


问:
How to save multiple user details in user defaults?
I got a task to store multiple user details.

```<code>@IBOutlet weak var userName: UITextField!

@IBOutlet weak var email_id: UITextField!

@IBOutlet weak var password: UITextField!
</code>```

I know in user defaults we can store a value for a particular key and retrieve it but i would like to know how to save multiple values. like the key should be the email_id i have mentioned above and all the three fields should be its values, also i need to maintain all the details even if there is n number of users.

答:
Create a model

```<code>Class User: NSObject, NSCoding{
var userName: String
var email_id: String
var password: String

init(userName: String, email_id: String, password: String){
 self.userName = userName
 self.email_id = email_id
 self.password = password
}
required conveniece init(coder decoder: NSCoder){
 let userName = decoder.decodeObject(forKey: "userName") as? String ?? ""
 let email_id = decoder.decodeObject(forKey: "email_id") as? String ?? ""
 let password = decoder.decodeObject(forKey: "password") as? String ?? ""
 self.init(
   userName=userName,
   email_id=email_id,
   password=password
 )
}

func encode(with coder: NSCoder){
 coder.encode(self.userName, forKet="userName")
 coder.encode(self.email_id, forKet="email_id")
 coder.encode(self.password, forKet="password")
}
}
</code>```

After you can instanciate your model with your data

```<code>let currentUser = User(userName: userName.text!, email_id: email_id.text!, password: password.text!)
</code>```

Or a list :

```<code> let listUsers = [User(userName: "user_1", email_id: "email@abc.com", password: "password")]
</code>```

Now you can store the currentUser or listUsers with archivedData

```<code>let encodedData = NSKeyedArchiver.archivedData(withRootObject: currentUser)
UserDefaults.standard.set(encodedData, forKey: "currentUser")
UserDefaults.standard.synchronize()

let encodedDataForList = NSKeyedArchiver.archivedData(withRootObject: listUsers)
UserDefaults.standard.set(encodedData, forKey: "listUsers")
UserDefaults.standard.synchronize()
</code>```

To get the stored user :

```<code>if let data = UserDefaults.standard.data(forKey: "currentUser"){
 let _currentUser = (NSKeyedUnarchiver.unarchiveObject(with: data) as? User)!
}
</code>```

Body:
I got a task to store multiple user details.

@IBOutlet weak var userName: UITextField!

@IBOutlet weak var email_id: UITextField!

@IBOutlet weak var password: UITextField!

I know in user defaults we can store a value for a particular key and retrieve it but i would like to know how to save multiple values. like the key should be the email_id i have mentioned above and all the three fields should be its values, also i need to maintain all the details even if there is n number of users.

Body:
Create a model

Class User: NSObject, NSCoding{
var userName: String
var email_id: String
var password: String

init(userName: String, email_id: String, password: String){
 self.userName = userName
 self.email_id = email_id
 self.password = password
}
required conveniece init(coder decoder: NSCoder){
 let userName = decoder.decodeObject(forKey: "userName") as? String ?? ""
 let email_id = decoder.decodeObject(forKey: "email_id") as? String ?? ""
 let password = decoder.decodeObject(forKey: "password") as? String ?? ""
 self.init(
   userName=userName,
   email_id=email_id,
   password=password
 )
}

func encode(with coder: NSCoder){
 coder.encode(self.userName, forKet="userName")
 coder.encode(self.email_id, forKet="email_id")
 coder.encode(self.password, forKet="password")
}
}

After you can instanciate your model with your data

let currentUser = User(userName: userName.text!, email_id: email_id.text!, password: password.text!)

Or a list :

 let listUsers = [User(userName: "user_1", email_id: "email@abc.com", password: "password")]

Now you can store the currentUser or listUsers with archivedData

let encodedData = NSKeyedArchiver.archivedData(withRootObject: currentUser)
UserDefaults.standard.set(encodedData, forKey: "currentUser")
UserDefaults.standard.synchronize()

let encodedDataForList = NSKeyedArchiver.archivedData(withRootObject: listUsers)
UserDefaults.standard.set(encodedData, forKey: "listUsers")
UserDefaults.standard.synchronize()

To get the stored user :

if let data = UserDefaults.standard.data(forKey: "currentUser"){
 let _currentUser = (NSKeyedUnarchiver.unarchiveObject(with: data) as? User)!
}


问:
Get SQL Server instance name from registry
I'm trying to create a database and run some SQL scripts from my Windows installer, which works fine as long as I hard-code the server name. If I try to get the server name from the registry, the installer will fail. In this case, I have the 32-bit SQL Server installed on a 64-bit OS, so I'm using the following registry key:

```<code><Property Id="SQL_SERVER_INSTANCE">
  <RegistrySearch Id="rs_ServerInstance"
                  Type="directory"
                  Root="HKLM"
                  Key="Software\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL"
                  Name="SQLEXPRESS" />
</Property>
</code>```

Then I plug this property into my database setup:

```<code>    <sql:SqlDatabase Id="NewSQLDB" Database="wix_test_DB" User="Users" Server="[SQL_SERVER_INSTANCE]"
                     CreateOnInstall="yes" DropOnUninstall="yes" ContinueOnError="no" >
      <sql:SqlScript ..."/>
    </sql:SqlDatabase>
</code>```

And it will fail. I've checked the registry and the only Name/Value pair there is "SQLEXPRESS" and the value is not a server instance. The server itself is called "SQLEXPRESS", but if it's stored as the Name, then I need to know it in advance to be able to search for it, defeating the purpose of attaining it in the first place.

I understand why this code doesn't work, but I don't know how I can get the server name. I've read that you can use [SQLSERVER] as the SqlDatabase@Server to get the default server, but the installer still failed when I tried this.

Is there a way to get the server name (not necessarily using the registry)?

答:
actually the  MSSQLSERVER is the default SQL instance, and its a reserved keyword that can't be used in an instance name according to this, so what I think you are looking for is SQL instances, if you are you can find in the path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server there is a value that is called InstalledInstances it contains the instances names and if you use the code the registry keys are brought as lists.
keep in mind that this path works if you have default named instances or named instances, and after that you should exclude MSSQLSERVER from the list

Body:
I'm trying to create a database and run some SQL scripts from my Windows installer, which works fine as long as I hard-code the server name. If I try to get the server name from the registry, the installer will fail. In this case, I have the 32-bit SQL Server installed on a 64-bit OS, so I'm using the following registry key:

<Property Id="SQL_SERVER_INSTANCE">
  <RegistrySearch Id="rs_ServerInstance"
                  Type="directory"
                  Root="HKLM"
                  Key="Software\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL"
                  Name="SQLEXPRESS" />
</Property>

Then I plug this property into my database setup:

    <sql:SqlDatabase Id="NewSQLDB" Database="wix_test_DB" User="Users" Server="[SQL_SERVER_INSTANCE]"
                     CreateOnInstall="yes" DropOnUninstall="yes" ContinueOnError="no" >
      <sql:SqlScript ..."/>
    </sql:SqlDatabase>

And it will fail. I've checked the registry and the only Name/Value pair there is "SQLEXPRESS" and the value is not a server instance. The server itself is called "SQLEXPRESS", but if it's stored as the Name, then I need to know it in advance to be able to search for it, defeating the purpose of attaining it in the first place.

I understand why this code doesn't work, but I don't know how I can get the server name. I've read that you can use [SQLSERVER] as the SqlDatabase@Server to get the default server, but the installer still failed when I tried this.

Is there a way to get the server name (not necessarily using the registry)?


问:
Cannot set variable from %% value inside batch script
Based from this answer I am trying to save the %%a and %%b values into variables but it does not work:

```<code>@ECHO OFF
SETLOCAL
set "path_of_folder=C:\folderA\folderB"

if exist "%path_of_folder%" (
  echo Path exists.
  for /f "skip=5 tokens=1,2,4 delims= " %%a in (
   'dir /ad /tc "%path_of_folder%\."') do IF "%%c"=="." (
    set "dt=%%a"
    echo Created on: %%a, %%b
    set "vara=%%a"
    set "varb=%%b"
    echo %vara%, %varb%

    REM substring
    set day=%vara:~0,2%
  )
) else (
  echo Path does not exist.
)

GOTO :EOF
</code>```

But the output of the echo %vara%, %varb% is empty even though the previous echo Created on: %%a, %%b prints the correct information!. The idea is that I can manipulate that variable afterwards for example for extracting substrings.

After searching online, I found this answer from which I tried the setlocal ENABLEDELAYEDEXPANSION, and the approach with the exclamation marks, but they too failed.

[UPDATE to include my other attempt and partly fix when using exclamation marks]

```<code>@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set "path_of_folder=C:\folderA\folderB"

if exist "%path_of_folder%" (
  echo Path exists.
  for /f "skip=5 tokens=1,2,4 delims= " %%a in (
   'dir /ad /tc "%path_of_folder%\."') do IF "%%c"=="." (
    set "dt=%%a"
    echo Created on: %%a, %%b
    set vara=%%a
    set varb=%%b
    echo !vara!, !varb!

    REM substring
    set day=%vara:~0,2%
  )
) else (
  echo Path does not exist.
)

GOTO :EOF
</code>```

Where the vara and varb are now saved and echoed appropriately but the substring now does not work..

I tried reading more about the specifics of a %% variable (link) but that did not help me either.

Any suggestions/examples please?

答:
Your 2nd script works perfectly. The only error I can spot is in this line: set day=%vara:~0,2%. It should be set day=!vara:~0,2!.

```<code>@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set "path_of_folder=C:\folderA\folderB"

if exist "%path_of_folder%" (
  echo Path exists.
  for /f "skip=5 tokens=1,2,4 delims= " %%a in (
   'dir /ad /tc "%path_of_folder%\."') do IF "%%c"=="." (
    set "dt=%%a"
    echo Created on: %%a, %%b
    set vara=%%a
    set varb=%%b
    echo !vara!, !varb!

    REM substring
    set day=!vara:~0,2!
  )
) else (
  echo Path does not exist.
)
</code>```

Body:
Based from this answer I am trying to save the %%a and %%b values into variables but it does not work:

@ECHO OFF
SETLOCAL
set "path_of_folder=C:\folderA\folderB"

if exist "%path_of_folder%" (
  echo Path exists.
  for /f "skip=5 tokens=1,2,4 delims= " %%a in (
   'dir /ad /tc "%path_of_folder%\."') do IF "%%c"=="." (
    set "dt=%%a"
    echo Created on: %%a, %%b
    set "vara=%%a"
    set "varb=%%b"
    echo %vara%, %varb%

    REM substring
    set day=%vara:~0,2%
  )
) else (
  echo Path does not exist.
)

GOTO :EOF

But the output of the echo %vara%, %varb% is empty even though the previous echo Created on: %%a, %%b prints the correct information!. The idea is that I can manipulate that variable afterwards for example for extracting substrings.

After searching online, I found this answer from which I tried the setlocal ENABLEDELAYEDEXPANSION, and the approach with the exclamation marks, but they too failed.

[UPDATE to include my other attempt and partly fix when using exclamation marks]

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set "path_of_folder=C:\folderA\folderB"

if exist "%path_of_folder%" (
  echo Path exists.
  for /f "skip=5 tokens=1,2,4 delims= " %%a in (
   'dir /ad /tc "%path_of_folder%\."') do IF "%%c"=="." (
    set "dt=%%a"
    echo Created on: %%a, %%b
    set vara=%%a
    set varb=%%b
    echo !vara!, !varb!

    REM substring
    set day=%vara:~0,2%
  )
) else (
  echo Path does not exist.
)

GOTO :EOF

Where the vara and varb are now saved and echoed appropriately but the substring now does not work..

I tried reading more about the specifics of a %% variable (link) but that did not help me either.

Any suggestions/examples please?

Body:
Your 2nd script works perfectly. The only error I can spot is in this line: set day=%vara:~0,2%. It should be set day=!vara:~0,2!.

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set "path_of_folder=C:\folderA\folderB"

if exist "%path_of_folder%" (
  echo Path exists.
  for /f "skip=5 tokens=1,2,4 delims= " %%a in (
   'dir /ad /tc "%path_of_folder%\."') do IF "%%c"=="." (
    set "dt=%%a"
    echo Created on: %%a, %%b
    set vara=%%a
    set varb=%%b
    echo !vara!, !varb!

    REM substring
    set day=!vara:~0,2!
  )
) else (
  echo Path does not exist.
)


问:
How to check a radio button based on some other value?
I have a bootstrap radio button which needs to get selected based on what value the user gives. Suppose the user enters 'male', male radio button should be selected. Consider the user enters the value in lower case.

    function check(){
    var val = document.getElementById("inp").value;
    if( val == "male"){
        //select male radio button
        }
    if(val == "female"){
         //select female radio button
        }
    }

    ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <div class="btn-group" data-toggle="buttons">
                  <p>Gender <span>*</span></p>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" style="width: 0px;" value="M" type="radio" name="gender" />M</label>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" style="width: 0px;" type="radio" value="F" name="gender" />F</label>

                </div><br><br>
    <input id="inp" type="text" onblur="check()"/>

    </code>```

答:
Try with id attribute and use toLowerCase() convert the value to lowercase

function check(){
    var val = document.getElementById("inp").value;
    console.log(val)
   document.getElementById(val.trim().toLowerCase()).click();
        }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <div class="btn-group" data-toggle="buttons">
                  <p>Gender <span>*</span></p>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" style="width: 10px;" value="M" type="radio" name="gender" id="male" checked/>M</label>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" id="female"type="radio" value="F" name="gender" />F</label>

                </div><br><br>
    <input id="inp" type="text" onblur="check()"/></code>```

Body:
I have a bootstrap radio button which needs to get selected based on what value the user gives. Suppose the user enters 'male', male radio button should be selected. Consider the user enters the value in lower case.

    function check(){
    var val = document.getElementById("inp").value;
    if( val == "male"){
        //select male radio button
        }
    if(val == "female"){
         //select female radio button
        }
    }

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

Gender *

                    <input class="form-control input-sm" style="width: 0px;" value="M" type="radio" name="gender" />M

                    <input class="form-control input-sm" style="width: 0px;" type="radio" value="F" name="gender" />F

    <input id="inp" type="text" onblur="check()"/>

Body:
Try with id attribute and use toLowerCase() convert the value to lowercase

function check(){
    var val = document.getElementById("inp").value;
    console.log(val)
   document.getElementById(val.trim().toLowerCase()).click();
        }

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <div class="btn-group" data-toggle="buttons">
                  <p>Gender <span>*</span></p>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" style="width: 10px;" value="M" type="radio" name="gender" id="male" checked/>M</label>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" id="female"type="radio" value="F" name="gender" />F</label>

                </div><br><br>
    <input id="inp" type="text" onblur="check()"/>


问:
Match any word of a List/Array in a Sentence java
I have an List of word like below

```<code>List<String> forbiddenWordList = Arrays.asList("LATE", "S/O", "SO", "W/O", "WO");
</code>```

How can I understand a String Contains any one of the word of the List. like....

```<code>String name1 = "Adam Smith";      // false (not found)
String name2 = "Late H Milton";   // true  (found Late)
String name3 = "S/O Furi Kerman"; // true  (found S/O)
String name4 = "Conl Faruk";      // false (not found)
String name5 = "Furi Kerman WO";  // true  (found WO)
</code>```

Regular Expression highly appreciated.

答:
The list can be expressed as a pattern:

```<code>Pattern forbiddenWordPattern
        = Pattern.compile("LATE|S/O|SO|W/O|WO", Pattern.CASE_INSENSITIVE);
</code>```

To test the presence of a word in a text, you would do:

```<code>boolean hasForbiddenWord = forbiddenWordPattern.matcher(text).find();
</code>```

Body:
I have an List of word like below

List<String> forbiddenWordList = Arrays.asList("LATE", "S/O", "SO", "W/O", "WO");

How can I understand a String Contains any one of the word of the List. like....

String name1 = "Adam Smith";      // false (not found)
String name2 = "Late H Milton";   // true  (found Late)
String name3 = "S/O Furi Kerman"; // true  (found S/O)
String name4 = "Conl Faruk";      // false (not found)
String name5 = "Furi Kerman WO";  // true  (found WO)

Regular Expression highly appreciated.

Body:
The list can be expressed as a pattern:

Pattern forbiddenWordPattern
        = Pattern.compile("LATE|S/O|SO|W/O|WO", Pattern.CASE_INSENSITIVE);

To test the presence of a word in a text, you would do:

boolean hasForbiddenWord = forbiddenWordPattern.matcher(text).find();


问:
Strangest language feature
What is, in your opinion, the most surprising, weird, strange or really "WTF" language feature you have encountered?

Please only one feature per answer.

答: The C++ templating mechanism is Turing-complete: As long as you don't need input at run time, you can do arbitrary calculations at compile time. Arbitrary. Or you can easily write a C++ program that never compiles - but is syntactically correct.</p>

Title: Strangest language feature


答:
The best way to do it in this situation is to use a local database, like sqlite. You can follow this tutorial for dealing with a local database. In your situation, you will need a user table to store your users.

If you prefer not to use a local database and use UserDefault instead, you can indeed store an array of objects in UserDefault. Simply use the following code

```<code>UserDefaults.standard.set([YourUserObj], forKey: "users")

let userArr = UserDefaults.standard.array(forKey: "users") as? [YourUserObj]
</code>```

Title: How to save multiple user details in user defaults?

Body:
The best way to do it in this situation is to use a local database, like sqlite. You can follow this tutorial for dealing with a local database. In your situation, you will need a user table to store your users.

If you prefer not to use a local database and use UserDefault instead, you can indeed store an array of objects in UserDefault. Simply use the following code

UserDefaults.standard.set([YourUserObj], forKey: "users")

let userArr = UserDefaults.standard.array(forKey: "users") as? [YourUserObj]


问:
How to get a substring between two strings in PHP?
I need a function that returns the substring between two words (or two characters).
I'm wondering whether there is a php function that achieves that. I do not want to think about regex (well, I could do one but really don't think it's the best way to go). Thinking of strpos and substr functions.
Here's an example:

```<code>$string = "foo I wanna a cake foo";
</code>```

We call the function: $substring = getInnerSubstring($string,"foo");

It returns: " I wanna a cake ".

Update:
Well, till now, I can just get a substring beteen two words in just one string, do you permit to let me go a bit farther and ask if I can extend the use of getInnerSubstring($str,$delim) to get any strings that are between delim value, example:

```<code>$string =" foo I like php foo, but foo I also like asp foo, foo I feel hero  foo";
</code>```

I get an array like {"I like php", "I also like asp", "I feel hero"}.

答:
UTF-8 version of @Alejandro Iglesias answer, will work for non-latin characters:</p>

```<code>function get_string_between($string, $start, $end){
    $string = ' ' . $string;
    $ini = mb_strpos($string, $start, 0, 'UTF-8');
    if ($ini == 0) return '';
    $ini += mb_strlen($start, 'UTF-8');
    $len = mb_strpos($string, $end, $ini, 'UTF-8') - $ini;
    return mb_substr($string, $ini, $len, 'UTF-8');
}

$fullstring = 'this is my [tag]dog[/tag]';
$parsed = get_string_between($fullstring, '[tag]', '[/tag]');

echo $parsed; // (result = dog)
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I need a function that returns the substring between two words (or two characters).
I'm wondering whether there is a php function that achieves that. I do not want to think about regex (well, I could do one but really don't think it's the best way to go). Thinking of strpos and substr functions.
Here's an example:

$string = "foo I wanna a cake foo";

We call the function: $substring = getInnerSubstring($string,"foo");

It returns: " I wanna a cake ".

Update:
Well, till now, I can just get a substring beteen two words in just one string, do you permit to let me go a bit farther and ask if I can extend the use of getInnerSubstring($str,$delim) to get any strings that are between delim value, example:

$string =" foo I like php foo, but foo I also like asp foo, foo I feel hero  foo";

I get an array like {"I like php", "I also like asp", "I feel hero"}.

Body:
UTF-8 version of @Alejandro Iglesias answer, will work for non-latin characters:

function get_string_between($string, $start, $end){
    $string = ' ' . $string;
    $ini = mb_strpos($string, $start, 0, 'UTF-8');
    if ($ini == 0) return '';
    $ini += mb_strlen($start, 'UTF-8');
    $len = mb_strpos($string, $end, $ini, 'UTF-8') - $ini;
    return mb_substr($string, $ini, $len, 'UTF-8');
}

$fullstring = 'this is my [tag]dog[/tag]';
$parsed = get_string_between($fullstring, '[tag]', '[/tag]');

echo $parsed; // (result = dog)


问:
WPF - Binding custom DataGridTextColumn template's Content property to parent's property
First of, I am coming back to WPF after several years of leaving it behind, I knew a little of it before and develop a few windows but now I am beyond rusty.
I am trying to build a DataGrid with filter headers, now I understand that there isn't a ready made control for that and needs to be created, which I have started using a Template.

My template consists of a Label control to the left which contains the title of the header, and a DatePick control to the right which I will use as part of my filtering process. I am trying to get Label.Content property inside my template to pick the DataGridTextColumn.Header property value of template parent.

I have tried RelativeSource, TemplatedParent and everything else there is, I also couldn't find any post on here that described a similar issue to mine nor a solution. Any help would be greatly appreciated. Thanks.

My code

```<code><UserControl x:Class="CustomControls.ReportsListingControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d"
         d:DesignHeight="100" d:DesignWidth="600">
<UserControl.Resources>
    <Style x:Key="ColumnHeaderStyle1" TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridColumnHeader">
                    <Grid Width="200" Height="35">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Label Grid.Column="0"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Width="50"
                               Content="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridTextColumn}}, Path=Header}" />
                        <DatePicker Grid.Column="1"
                                    HorizontalAlignment="Right"
                                    VerticalAlignment="Center"
                                    Width="30"
                                    BorderThickness="0" Text="" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>
<Grid>
    <DataGrid Name="DataGrid1" >
        <DataGrid.Columns>
            <DataGridTextColumn  HeaderStyle="{StaticResource ColumnHeaderStyle1}" Header="The Text I want displayed in my template label" />
        </DataGrid.Columns>
    </DataGrid>
</Grid>
</code>```

答:
Bind to the DataContext itself:

```<code><Label ... Content="{Binding}" />
</code>```

The DataContext of a DataGridColumnHeader is the Header object itself, i.e. the string in your case.

Body:
First of, I am coming back to WPF after several years of leaving it behind, I knew a little of it before and develop a few windows but now I am beyond rusty.
I am trying to build a DataGrid with filter headers, now I understand that there isn't a ready made control for that and needs to be created, which I have started using a Template.

My template consists of a Label control to the left which contains the title of the header, and a DatePick control to the right which I will use as part of my filtering process. I am trying to get Label.Content property inside my template to pick the DataGridTextColumn.Header property value of template parent.

I have tried RelativeSource, TemplatedParent and everything else there is, I also couldn't find any post on here that described a similar issue to mine nor a solution. Any help would be greatly appreciated. Thanks.

My code

<UserControl x:Class="CustomControls.ReportsListingControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d"
         d:DesignHeight="100" d:DesignWidth="600">
<UserControl.Resources>

</UserControl.Resources>
<Grid>
    <DataGrid Name="DataGrid1" >
        <DataGrid.Columns>
            <DataGridTextColumn  HeaderStyle="{StaticResource ColumnHeaderStyle1}" Header="The Text I want displayed in my template label" />
        </DataGrid.Columns>
    </DataGrid>
</Grid>

Body:
Bind to the DataContext itself:

<Label ... Content="{Binding}" />

The DataContext of a DataGridColumnHeader is the Header object itself, i.e. the string in your case.


问:
Without reloading the page, how do I display the image using the AJAX success function?
Without reloading the page, how do I display the image using the AJAX success function?

In my form, the if ... else condition is already there, and if the images exist in the database, the if condition will execute. The else condition will display the default image.

form

```<code><form  id="data_form" action="#" method="post"  enctype="multipart/form-data">
                <div class="photoContainer">
                    <a href="#" class="user-img">
                        <div class="profile-pic">
                            <?php if (empty($s_profile_imagee[0]) || empty($s_profile_imagee)) { ?>
                                <img src="<?php echo base_url(); ?>images/default.jpg" class="img-user" alt="" width="150px;" height="150px;"/>
                            <?php } else { ?>
                                <img src="<?php echo 'data:image;base64,' . $s_profile_imagee; ?>" class="img-user" alt="" width="150px;" height="150px;"/>
                            <?php } ?>
                            <?php if (empty($s_profile_imagee[0]) || empty($s_profile_imagee)) { ?>
                                <div id="profile-pic"><i class="fa fa-camera"><input type="file" class="fileInput" value="Add Photo" onchange="this.form.submit()" name="image"> Add Photo</i></div>
                            <?php } else { ?>
                                <div id="profile-pic"><i class="fa fa-camera"><input type="file" class="fileInput" value="Change Photo" onchange="this.form.submit()" name="image"> Change Photo</i></div>
                            <?php } ?>
                        </div>
                    </a>
                </div>
            </form>
</code>```

script

```<code><script>
              $(document).ready(function () {

                  $('#data_form').on('submit', function (e) {

                      var form_data = $(this).serialize();

                      $.ajax({
                          type: "POST",
                          url: '<?php echo base_url(); ?>index.php/Profile_cntrl/supplier_profile_imagee',
                          data: form_data,
                          success: function (data)
                          {

                                 $('.photoContainer').text($("#image").val());

                          },
                          error: function ()
                          {
                              alert('failed');
                          }
                      });

                      e.preventDefault();
                  });

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

答:
try this

```<code> $(".img-user").setAttribute("src","<?php echo base_url();?>img/"+data);
</code>```

Body:
Without reloading the page, how do I display the image using the AJAX success function?

In my form, the if ... else condition is already there, and if the images exist in the database, the if condition will execute. The else condition will display the default image.

form

<form  id="data_form" action="#" method="post"  enctype="multipart/form-data">

                            <?php if (empty($s_profile_imagee[0]) || empty($s_profile_imagee)) { ?>
                                <img src="<?php echo base_url(); ?>images/default.jpg" class="img-user" alt="" width="150px;" height="150px;"/>
                            <?php } else { ?>
                                <img src="<?php echo 'data:image;base64,' . $s_profile_imagee; ?>" class="img-user" alt="" width="150px;" height="150px;"/>
                            <?php } ?>
                            <?php if (empty($s_profile_imagee[0]) || empty($s_profile_imagee)) { ?>

<input type="file" class="fileInput" value="Add Photo" onchange="this.form.submit()" name="image"> Add Photo

                            <?php } else { ?>

<input type="file" class="fileInput" value="Change Photo" onchange="this.form.submit()" name="image"> Change Photo

                            <?php } ?>

            </form>

script

Body:
try this

 $(".img-user").setAttribute("src","<?php echo base_url();?>img/"+data);


问:
rspec giving incorrect error messages
Following the RailsTutorial, I keep getting this error message (one of four actually) when it should be working:

```<code>UsersController authentication of edit/update pages for signed-in
users should require matching users for 'edit'
Failure/Error: @users = [@user, second, third] undefined local variable
or method 'second' for
#<RSpec::Core::ExampleGroup::Nested_3::Nested_7::Nested_2:0x000001040dcb68> #
./spec/controllers/users_controller_spec.rb:275:in 'block
(4 levels) in <top (required)>'
</code>```

I have tried to fix it by looking at other questions on stack overflow but to no avail. My gemfile now looks like this:

```<code>gem 'rails', '3.0.3'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'gravatar_image_tag', '0.1.0'
gem 'will_paginate', '3.0.pre2'

group :development do
  gem 'rspec-rails', '2.0.1'
  gem 'annotate-models', '1.0.4'
  gem 'faker', '0.3.1'
end

group :test do
  gem 'rspec-rails', '2.0.1'
  gem 'webrat', '0.7.1'
  gem 'spork', '0.8.4'
  gem 'factory_girl_rails', '1.0'
end
</code>```

Any suggestions would be greatly appreciated!

答:
I'm guessing second and third don't exist when you're calling [@user, second, third] (well, more than guessing. Its what the error says ;) ). They're probably in the tutorial to suggest you could be handling multiple objects in this code. Try removing them.

If that's not it, can you post a link to the tutorial you're following, or provide more background about where second and third are supposed to be coming from?

Title: rspec giving incorrect error messages

Body:
Following the RailsTutorial, I keep getting this error message (one of four actually) when it should be working:

UsersController authentication of edit/update pages for signed-in
users should require matching users for 'edit'
Failure/Error: @users = [@user, second, third] undefined local variable
or method 'second' for
#<RSpec::Core::ExampleGroup::Nested_3::Nested_7::Nested_2:0x000001040dcb68> #
./spec/controllers/users_controller_spec.rb:275:in 'block
(4 levels) in <top (required)>'

I have tried to fix it by looking at other questions on stack overflow but to no avail. My gemfile now looks like this:

gem 'rails', '3.0.3'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'gravatar_image_tag', '0.1.0'
gem 'will_paginate', '3.0.pre2'

group :development do
  gem 'rspec-rails', '2.0.1'
  gem 'annotate-models', '1.0.4'
  gem 'faker', '0.3.1'
end

group :test do
  gem 'rspec-rails', '2.0.1'
  gem 'webrat', '0.7.1'
  gem 'spork', '0.8.4'
  gem 'factory_girl_rails', '1.0'
end

Any suggestions would be greatly appreciated!


问:
Header is not allowing  to align in the same line
I have a css header that is not allowing me to align a text in the same line using . I imagine there is a weird default to the header that doesnt allow me to do this how do i prevent the default or what else can i use instead?

HTML

```<code>h3>Size:</h3>
<?php echo "<span class='sP'>".$pSize ."</span><br>"?>
</code>```

CSS

```<code>h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;

}
</code>```

答:
I think this would be the answer you are looking for - Just put display:inline-block. I have put a working sample with the answer.please try this, if there is any issue please do ask.

h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
display:inline-block;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
display:inline-block;

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><h3>Size:</h3>
<span class='sP'>hi</span><br></code>```

Title: Header is not allowing <span> to align in the same line

Body:
I have a css header that is not allowing me to align a text in the same line using . I imagine there is a weird default to the header that doesnt allow me to do this how do i prevent the default or what else can i use instead?

HTML

h3>Size:

<?php echo "".$pSize ."
"?>

CSS

h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;

}

Body:
I think this would be the answer you are looking for - Just put display:inline-block. I have put a working sample with the answer.please try this, if there is any issue please do ask.

h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
display:inline-block;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
display:inline-block;

}

<h3>Size:</h3>
<span class='sP'>hi</span><br>


答:
    function check(){
    var val = document.getElementById("inp").value;
    if( val == "male"){
        $("input[value='M']").click();
        }
    if(val == "female"){
         $("input[value='F']").click();
        }
    }

    ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <div class="btn-group" data-toggle="buttons">
                  <p>Gender <span>*</span></p>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" style="width: 10px;" value="M" type="radio" name="gender" />M</label>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" type="radio" value="F" name="gender" />F</label>

                </div><br><br>
    <input id="inp" onKeyup="check()" type="text"/>

    </code>```

Title: How to check a radio button based on some other value?

Body:
    function check(){
    var val = document.getElementById("inp").value;
    if( val == "male"){
        $("input[value='M']").click();
        }
    if(val == "female"){
         $("input[value='F']").click();
        }
    }

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <div class="btn-group" data-toggle="buttons">
                  <p>Gender <span>*</span></p>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" style="width: 10px;" value="M" type="radio" name="gender" />M</label>
                  <label class="btn btn-default">
                    <input class="form-control input-sm" type="radio" value="F" name="gender" />F</label>

                </div><br><br>
    <input id="inp" onKeyup="check()" type="text"/>


问:
Unicorn service failing to start on Ubuntu 16.10
I'm working on a project which requires Unicorn to run. I have set up a service which will start on boot. However, it fails to start. Here is an excerpt from the log with the errors:

```<code>jul 05 08:21:04 ubuntu3 su[1255]: pam_systemd(su:session): Failed to create session: Connection timed out
jul 05 08:21:06 ubuntu3 unicorn_consul[1116]: ruby-2.3.2 is not installed.
jul 05 08:21:06 ubuntu3 unicorn_consul[1116]: To install do: 'rvm install ruby-2.3.2'
</code>```

I do have Ruby installed, if I run ruby -v it returns ruby 2.3.2p217 (2016-11-15 revision 56796) [i686-linux]. Is it maybe because I installed Ruby via rbenv instead of rvm? If so, how can I make it use my Ruby installation?

Here I pasted the contents of my service's bash file.

Then I'd start Nginx. Here are the contents of its config file.

UPDATE 1:

I fixed the Ruby problem when I uninstalled rvm from my computer. Now the only problem left is the timeout problem.

答:
I finally managed to run the service. Here is what I did:

The first problem was the service timeout. I edited my config/unicorn.rb file and I changed the timeout from 30 to 120.

The second problem was Ruby not being found despite having it installed. I solved it by uninstalling rvm (aside from running rvm implode I had to delete some files, folders and references in other files).

Body:
I'm working on a project which requires Unicorn to run. I have set up a service which will start on boot. However, it fails to start. Here is an excerpt from the log with the errors:

jul 05 08:21:04 ubuntu3 su[1255]: pam_systemd(su:session): Failed to create session: Connection timed out
jul 05 08:21:06 ubuntu3 unicorn_consul[1116]: ruby-2.3.2 is not installed.
jul 05 08:21:06 ubuntu3 unicorn_consul[1116]: To install do: 'rvm install ruby-2.3.2'

I do have Ruby installed, if I run ruby -v it returns ruby 2.3.2p217 (2016-11-15 revision 56796) [i686-linux]. Is it maybe because I installed Ruby via rbenv instead of rvm? If so, how can I make it use my Ruby installation?

Here I pasted the contents of my service's bash file.

Then I'd start Nginx. Here are the contents of its config file.

UPDATE 1:

I fixed the Ruby problem when I uninstalled rvm from my computer. Now the only problem left is the timeout problem.


问:
foreach loop count function total
I would like to make a total count on my variable : $nb_quota_lic_simples

In the foreach i check how many free licences i have, i would like to get the total of the licences if there is many equipes. Hope someone help me. Thanks a lot in advance !

Actually i have :

```<code>foreach ($equipes as $equipe) {
    $nb_quota_lic_simples = $equipe->catg_equipe->nb_licences;
}
dd($nb_quota_lic_simples);
</code>```

答:
try something like this  </p>

```<code>    $total = 0;
    foreach ($equipes as $equipe) {
        $total += $equipe->catg_equipe->nb_licences;
    }
    dd($total);
</code>```

Title: foreach loop count function total

Body:
I would like to make a total count on my variable : $nb_quota_lic_simples

In the foreach i check how many free licences i have, i would like to get the total of the licences if there is many equipes. Hope someone help me. Thanks a lot in advance !

Actually i have :

foreach ($equipes as $equipe) {
    $nb_quota_lic_simples = $equipe->catg_equipe->nb_licences;
}
dd($nb_quota_lic_simples);

Body:
try something like this

    $total = 0;
    foreach ($equipes as $equipe) {
        $total += $equipe->catg_equipe->nb_licences;
    }
    dd($total);