问:
PHP Call to undefined function How to resolve error?
```<code>public function Sale_bill($id){
    $data['Sales'] = $this->Sales_model->get_sales_by_id($id);
    $data['Sold_items'] = $this->Sales_model->sold_items_by_sale_id($id);
    $GST_Percentages = array(0, 2.5, 6, 9, 14);
    foreach($GST_Percentages as $GST_Percentage){
        $data['GST_data'][] = array($GST_Percentage => '');
        $data['GST_data'][$i][$GST_Percentage] = array_filter($data['Sold_items'], sold_item_by_gst_percentage($data['Sold_items'], $GST_Percentage));
    }
}
private function sold_item_by_gst_percentage($GST, $GST_Percentage){
    return ($GST['CGST_Percentage'] == $GST_Percentage);
}
</code>```

When I am calling sold_item_by_gst_percentage it saying Call to undefined function sold_item_by_gst_percentage() How can I resolve this please help me.

答:
Did you try the following:</p>

```<code>$this->sold_item_by_gst_percentage($data['Sold_items'], $GST_Percentage)
</code>```

Body:
public function Sale_bill($id){
    $data['Sales'] = $this->Sales_model->get_sales_by_id($id);
    $data['Sold_items'] = $this->Sales_model->sold_items_by_sale_id($id);
    $GST_Percentages = array(0, 2.5, 6, 9, 14);
    foreach($GST_Percentages as $GST_Percentage){
        $data['GST_data'][] = array($GST_Percentage => '');
        $data['GST_data'][$i][$GST_Percentage] = array_filter($data['Sold_items'], sold_item_by_gst_percentage($data['Sold_items'], $GST_Percentage));
    }
}
private function sold_item_by_gst_percentage($GST, $GST_Percentage){
    return ($GST['CGST_Percentage'] == $GST_Percentage);
}

When I am calling sold_item_by_gst_percentage it saying Call to undefined function sold_item_by_gst_percentage() How can I resolve this please help me.

Body:
Did you try the following:

$this->sold_item_by_gst_percentage($data['Sold_items'], $GST_Percentage)


来源: stackexchange

问:
How do I print a text file in .net
How do I print a .txt file in vb.net? Hopefully without using any third parties. </p>

答:
Have a look at this example on how to print files with VB.Net: MSDN How to: Print a Multi-Page Text File in Windows Forms

The most important class you need is PrintDocument. No third party tools or Dll's other than in System.Drawing and System.IO Namespace in .Net-Framework(> 1.1) are needed.

ContentLicense: CC BY-SA 2.5

Title: How do I print a text file in .net


问:
Swift - Parsing a Web Page
For the project I am currently working on, I need to download and parse the HTML for getting specific date and times.

I created a dummy project for that testing and here is the code:

```<code>import UIKit
import Alamofire
import SwiftSoup

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let diyanetURL = "https://namazvakitleri.diyanet.gov.tr/tr-TR/"

        let params = ["ulkeId" : 2, "ilId" : 500,"ilceId" : 9146]
        Alamofire.request(diyanetURL, method: .post, parameters: params, encoding: URLEncoding.default).validate(contentType: ["application/x-www-form-urlencoded"]).response { (response) in

            if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
                do {
                    let html: String = utf8Text
                    let doc: Document = try SwiftSoup.parse(html)
                    let bla = try doc.getElementsByAttribute("tbody")
                    for bl in bla {
                        print(bl)
                    }

                } catch let error {
                    print(error.localizedDescription)
                }

            }
        }
    }
}
</code>```

I want to get that part of the website but I couldn't:

```<code><tbody>

                                        <tr>

                                            <td>04.12.2017</td>

                                            <td>06:16</td>

                                            <td>07:47</td>

                                            <td>12:46</td>

                                            <td>15:10</td>

                                            <td>17:32</td>

                                            <td>18:56</td>

                                        </tr>

                                        <tr>

                                            <td>05.12.2017</td>

                                            <td>06:17</td>

                                            <td>07:48</td>

                                            <td>12:46</td>

                                            <td>15:09</td>

                                            <td>17:31</td>

                                            <td>18:56</td>

                                        </tr>
</code>```

How can I parse the web page and get these dates and times?

Thanks in advance.

答:
I found the solution:</p>

```<code>import UIKit
import Alamofire
import SwiftSoup

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let diyanetURL = "https://namazvakitleri.diyanet.gov.tr/tr-TR/8648"

//        let params = ["ulkeId" : 2, "ilId" : 500,"ilceId" : 9146]
        Alamofire.request(diyanetURL, method: .post, parameters: nil, encoding: URLEncoding.default).validate(contentType: ["application/x-www-form-urlencoded"]).response { (response) in

            if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
                do {
                    let html: String = utf8Text
                    let doc: Document = try SwiftSoup.parse(html)
                    for row in try! doc.select("tr") {
                        print("------------------")
                        for col in try! row.select("td") {
                            print(try col.text())
                        }
                    }

                } catch let error {
                    print(error.localizedDescription)
                }

            }
        }
    }
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: Swift - Parsing a Web Page

Body:
For the project I am currently working on, I need to download and parse the HTML for getting specific date and times.

I created a dummy project for that testing and here is the code:

import UIKit
import Alamofire
import SwiftSoup

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let diyanetURL = "https://namazvakitleri.diyanet.gov.tr/tr-TR/"

        let params = ["ulkeId" : 2, "ilId" : 500,"ilceId" : 9146]
        Alamofire.request(diyanetURL, method: .post, parameters: params, encoding: URLEncoding.default).validate(contentType: ["application/x-www-form-urlencoded"]).response { (response) in

            if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
                do {
                    let html: String = utf8Text
                    let doc: Document = try SwiftSoup.parse(html)
                    let bla = try doc.getElementsByAttribute("tbody")
                    for bl in bla {
                        print(bl)
                    }

                } catch let error {
                    print(error.localizedDescription)
                }

            }
        }
    }
}

I want to get that part of the website but I couldn't:

                                            04.12.2017

                                            06:16

                                            07:47

                                            12:46

                                            15:10

                                            17:32

                                            18:56

                                            05.12.2017

                                            06:17

                                            07:48

                                            12:46

                                            15:09

                                            17:31

                                            18:56

How can I parse the web page and get these dates and times?

Thanks in advance.

Body:
I found the solution:

import UIKit
import Alamofire
import SwiftSoup

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let diyanetURL = "https://namazvakitleri.diyanet.gov.tr/tr-TR/8648"

//        let params = ["ulkeId" : 2, "ilId" : 500,"ilceId" : 9146]
        Alamofire.request(diyanetURL, method: .post, parameters: nil, encoding: URLEncoding.default).validate(contentType: ["application/x-www-form-urlencoded"]).response { (response) in

            if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
                do {
                    let html: String = utf8Text
                    let doc: Document = try SwiftSoup.parse(html)
                    for row in try! doc.select("tr") {
                        print("------------------")
                        for col in try! row.select("td") {
                            print(try col.text())
                        }
                    }

                } catch let error {
                    print(error.localizedDescription)
                }

            }
        }
    }
}

ContentLicense: CC BY-SA 3.0


问:
When is a function too long?
35 lines, 55 lines, 100 lines, 300 lines? When you should start to break it apart? I'm asking because I have a function with 60 lines (including comments) and was thinking about breaking it apart.

```<code>long_function(){ ... }
</code>```

into:

```<code>small_function_1(){...}
small_function_2(){...}
small_function_3(){...}
</code>```

The functions are not going to be used outside of the long_function, making smaller functions means more function calls, etc.

When would you break apart a function into smaller ones? Why?

Methods should do only one logical thing (think about functionality)

You should be able to explain the method in a single sentence

It should fit into the height of your display

Avoid unnecessary overhead (comments that point out the obvious...)

Unit testing is easier for small logical functions

Check if part of the function can be reused by other classes or methods

Avoid excessive inter-class coupling

Avoid deeply nested control structures

Thanks everyone for the answers, edit the list and vote for the correct answer I'll choose that one ;)

I am refactoring now with those ideas in mind :)

答:
There has been some thorough research done on this very topic, if you want the fewest bugs, your code shouldn't be too long. But it also shouldn't be too short.

I disagree that a method should fit on your display in one, but if you are scrolling down by more than a page then the method is too long.

See
The Optimal Class Size for
Object-Oriented Software for further discussion.

LastEditorDisplayName: Movaxes

Title: When is a function too long?

Body:
35 lines, 55 lines, 100 lines, 300 lines? When you should start to break it apart? I'm asking because I have a function with 60 lines (including comments) and was thinking about breaking it apart.

long_function(){ ... }

into:

small_function_1(){...}
small_function_2(){...}
small_function_3(){...}

The functions are not going to be used outside of the long_function, making smaller functions means more function calls, etc.

When would you break apart a function into smaller ones? Why?

Methods should do only one logical thing (think about functionality)

You should be able to explain the method in a single sentence

It should fit into the height of your display

Avoid unnecessary overhead (comments that point out the obvious...)

Unit testing is easier for small logical functions

Check if part of the function can be reused by other classes or methods

Avoid excessive inter-class coupling

Avoid deeply nested control structures

Thanks everyone for the answers, edit the list and vote for the correct answer I'll choose that one ;)

I am refactoring now with those ideas in mind :)

OwnerDisplayName: Ian Hickman


问:
How to flush output after each `echo` call?
I have a php script that only produces logs to the client.

When I echo something, I want it to be transferred to client on-the-fly.

(Because while the script is processing, the page is blank)

I had already played around with ob_start() and ob_flush(), but they didn't work.

What's the best solution?

PS: it is a little dirty to put a flush at the end of the echo call...

EDIT: Neither the Answers worked, PHP or Apache Fault?

答:
I had a similar thing to do. Using

```<code>// ini_set("output_buffering", 0);  // off
ini_set("zlib.output_compression", 0);  // off
ini_set("implicit_flush", 1);  // on
</code>```

did make the output flushing frequent in my case.

But I had to flush the output right at a particular point(in a loop that I run), so using both

```<code>ob_flush();
flush();
</code>```

together worked for me.

I wasn't able to
  turn off "output_buffering" with
  ini_set(...), had to turn it directly
  in php.ini, phpinfo() shows its setting
  as "no value" when turned off, is that
  normal? .

Body:
I had a similar thing to do. Using

// ini_set("output_buffering", 0);  // off
ini_set("zlib.output_compression", 0);  // off
ini_set("implicit_flush", 1);  // on

did make the output flushing frequent in my case.

But I had to flush the output right at a particular point(in a loop that I run), so using both

ob_flush();
flush();

together worked for me.

I wasn't able to
  turn off "output_buffering" with
  ini_set(...), had to turn it directly
  in php.ini, phpinfo() shows its setting
  as "no value" when turned off, is that
  normal? .


问:
Continuous deployment with github and azure function project in visual studio 2017 preview
I am trying to set ci/cd from github to azure functions
I created an Azure function project in git "https://github.com/AmitayStrijevski/AppFunctionTest".

I published it once through the visual studio and it worked perfect.

Then i connected it to the github ci/cd described here
"https://learn.microsoft.com/en-us/azure/azure-functions/functions-continuous-deployment#continuous-deployment-requirements".

When pushing to git i can see it takes my code and "deploy" it but when i look at the the functions my new code is not there and the logs show the following message

"Found solution 'D:\home\site\repository\HeyArnold\HeyArnold.sln' with no deployable projects. Deploying files instead."

I spent  more than a day on this and i will really appreciate help in this issue

I was able to use the github deployment when using an empty web site and setting the same folder structure generated by the azure portal
This is still not solve my problem because i want to use Azure function project but i thought worth mentioning

答:
You can add a .deployment-file to the root of your repository and point Azure, and Kudu, to the correct project-path:

[config]
project = src/PathToYourProject

Or you can add a Application settings in the Azure Portal with the key PROJECT and the value pointing to the correct project-path.


问:
@Transient not working properly in JPA
I have a problem using JPA and @Transient annotation. I'm working with Spring Boot and MySQL database. Have no idea how to get rid of this mapping error. It seems that JPA is trying to create database entry for MultipartFile despite @Transient annotation. I've tried adding @Transient annotation to getter and setter as well, but error is the same. Help me please!

Error I'm getting:

```<code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at com.ajmaks.qaapp.Application.main(Application.java:10) [classes/:na]

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.MappingException: Could not determine type for: org.springframework.web.multipart.MultipartFile, at table: user, for columns: [org.hibernate.mapping.Column(user_image)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:431) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:398) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.Property.isValid(Property.java:225) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
</code>```

My model class:

```<code>package com.ajmaks.qaapp.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.annotation.Transient;
import org.springframework.web.multipart.MultipartFile;

@Entity
@Table(name = "user")
public class User {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_id")
private int id;

@Column(name = "email")
@Email(message = "*Please provide a valid Email")
@NotEmpty(message = "*Please provide an email")
private String email;

@Column(name = "password")
@Length(min = 5, message = "*Your password must have at least 5 characters")
@NotEmpty(message = "*Please provide your password")
@Transient
private String password;

@Column(name = "name")
private String name;

@Column(name = "last_name")
private String lastName;

@Transient
private MultipartFile userImage;

@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
private Set<Role> roles;

public MultipartFile getUserImage() {
    return userImage;
}

public void setUserImage(MultipartFile userImage) {
    this.userImage = userImage;
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}
@Transient
public String getPassword() {
    return password;
}

@Transient
public void setPassword(String password) {
    this.password = password;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

public Set<Role> getRoles() {
    return roles;
}

public void setRoles(Set<Role> roles) {
    this.roles = roles;
}
</code>```

}

答:
@Transient package is from

```<code>import javax.persistence.*
</code>```

not from

```<code>import org.springframework.data.annotation.Transient
</code>```

Title: @Transient not working properly in JPA

Body:
I have a problem using JPA and @Transient annotation. I'm working with Spring Boot and MySQL database. Have no idea how to get rid of this mapping error. It seems that JPA is trying to create database entry for MultipartFile despite @Transient annotation. I've tried adding @Transient annotation to getter and setter as well, but error is the same. Help me please!

Error I'm getting:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at com.ajmaks.qaapp.Application.main(Application.java:10) [classes/:na]

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.MappingException: Could not determine type for: org.springframework.web.multipart.MultipartFile, at table: user, for columns: [org.hibernate.mapping.Column(user_image)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:431) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:398) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.Property.isValid(Property.java:225) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]

My model class:

package com.ajmaks.qaapp.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.annotation.Transient;
import org.springframework.web.multipart.MultipartFile;

@Entity
@Table(name = "user")
public class User {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_id")
private int id;

@Column(name = "email")
@Email(message = "*Please provide a valid Email")
@NotEmpty(message = "*Please provide an email")
private String email;

@Column(name = "password")
@Length(min = 5, message = "*Your password must have at least 5 characters")
@NotEmpty(message = "*Please provide your password")
@Transient
private String password;

@Column(name = "name")
private String name;

@Column(name = "last_name")
private String lastName;

@Transient
private MultipartFile userImage;

@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
private Set<Role> roles;

public MultipartFile getUserImage() {
    return userImage;
}

public void setUserImage(MultipartFile userImage) {
    this.userImage = userImage;
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}
@Transient
public String getPassword() {
    return password;
}

@Transient
public void setPassword(String password) {
    this.password = password;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

public Set<Role> getRoles() {
    return roles;
}

public void setRoles(Set<Role> roles) {
    this.roles = roles;
}

}

Body:
@Transient package is from

import javax.persistence.*

not from

import org.springframework.data.annotation.Transient


问:
totals for a measure with LOG10 are wrong
I have a table 'Range' with strings in a [node] column.
I created a [measure] for a pivot that calculates a percentage of occurrences of each string.

```<code>measure = COUNTA(Range[node])/CALCULATE(COUNTA(Range[node]);ALL(Range[node]))
</code>```

This works very well and the total of the percentage =1 as it should:

```<code>+-------+---------------+---------+
| node  | count of node | measure |
+-------+---------------+---------+
| a     |             1 | 0.007   |
| b     |            22 | 0.162   |
| c     |           103 | 0.757   |
| d     |            10 | 0.074   |
| Total |           136 | 1.000   |
+-------+---------------+---------+
</code>```

But when I want to get a LOG10 of the measure, values are fine, but the total changes to 0.

When I use:

```<code>measure = LOG10((COUNTA(Range[node])/CALCULATE(COUNTA(Range[node]);ALL(Range[node]))))
</code>```

I get:

```<code>+-------+---------------+--------------+
| node  | count of node |   measure    |
+-------+---------------+--------------+
| a     |             1 | -2.134       |
| b     |            22 | -0.791       |
| c     |           103 | -0.120701684 |
| d     |            10 | -1.133538908 |
| Total |           136 | 0            |
+-------+---------------+--------------+
</code>```

What should I do to get the correct Total of -4.179?

答:
If you really want the sum of the logs then only copy your measure formula into rows a-d and make the total the sum of those 4 measures; as it is, you're calculating 136/136 to get 1, not adding 0.007+0.162... to get 1

So in the LOG10 example, the 0 appears because LOG10(136/136) = LOG10(1) which by definition is 0

Note that adding logs of numbers corresponds to finding the log of the product of all the entries,

i.e. log10( (1/136) x (22/136) x (103/136) x (10/136) ) = -4.179

As in log(a x b) = log(a) + log(b)

Maybe that's what you want but it seems unlikely.

Body:
I have a table 'Range' with strings in a [node] column.
I created a [measure] for a pivot that calculates a percentage of occurrences of each string.

measure = COUNTA(Range[node])/CALCULATE(COUNTA(Range[node]);ALL(Range[node]))

This works very well and the total of the percentage =1 as it should:

+-------+---------------+---------+
| node  | count of node | measure |
+-------+---------------+---------+
| a     |             1 | 0.007   |
| b     |            22 | 0.162   |
| c     |           103 | 0.757   |
| d     |            10 | 0.074   |
| Total |           136 | 1.000   |
+-------+---------------+---------+

But when I want to get a LOG10 of the measure, values are fine, but the total changes to 0.

When I use:

measure = LOG10((COUNTA(Range[node])/CALCULATE(COUNTA(Range[node]);ALL(Range[node]))))

I get:

+-------+---------------+--------------+
| node  | count of node |   measure    |
+-------+---------------+--------------+
| a     |             1 | -2.134       |
| b     |            22 | -0.791       |
| c     |           103 | -0.120701684 |
| d     |            10 | -1.133538908 |
| Total |           136 | 0            |
+-------+---------------+--------------+

What should I do to get the correct Total of -4.179?


问:
What's the difference between np.float64 and tf.float64?
When working with TensorFlow, and using the file load method from NumPy, it seems to be possible to specify everything as double precision with:

```<code>np.loadtxt(..., dtype=np.float64)
tf.placeholder(tf.float64...)
tf.Variable(..., dtype=tf.float64...)
</code>```

NumPy and TensorFlow have separate data type values.

If you say np.loadtxt(..., dtype=tf.float64) it fails with an error message. Okay, NP was written before TF, so it doesn't understand the TF data type values.

If you say tf.placeholder(np.float64...) on the other hand, it seems to work fine. Hmm? Well, TF was written after NP, maybe it's programmed to understand the NP data type values. But why, then, does it have its own separate data type values in the first place instead of just using the NP ones throughout?

What's the difference between the two, as far as TF is concerned? Is it okay to use np.float64 everywhere, or will that cause problems down the line? (The reason I ask is, I'm thinking of setting a parameter at the start of a program, where you can switch between single and double precision by changing one line, and that would be easier if you can indeed use np.float64 everywhere.)

答:
NumPy's dtype and TensorFlow's DType are actually different things (Basically, TensorFlow's DTypes are just values of an internal enum, whereas NumPy's dtypes are actual objects.), therefore NumPy does not understand TensorFlow DTypes. There are compatible pairs though. You can find out whether your DType is NumPy compatible via its property is_numpy_compatible. TensorFlow accepts NumPy dtypes as they sanitize dtype parameter inputs in their initialization methods via the as_dtype method, that also accepts NumPy dtypes, converting them to the proper TensorFlow DType value.

So, long story short: You can basically pass np.float64 and np.float32 everywhere and TensorFlow will properly handle this.

Body:
When working with TensorFlow, and using the file load method from NumPy, it seems to be possible to specify everything as double precision with:

np.loadtxt(..., dtype=np.float64)
tf.placeholder(tf.float64...)
tf.Variable(..., dtype=tf.float64...)

NumPy and TensorFlow have separate data type values.

If you say np.loadtxt(..., dtype=tf.float64) it fails with an error message. Okay, NP was written before TF, so it doesn't understand the TF data type values.

If you say tf.placeholder(np.float64...) on the other hand, it seems to work fine. Hmm? Well, TF was written after NP, maybe it's programmed to understand the NP data type values. But why, then, does it have its own separate data type values in the first place instead of just using the NP ones throughout?

What's the difference between the two, as far as TF is concerned? Is it okay to use np.float64 everywhere, or will that cause problems down the line? (The reason I ask is, I'm thinking of setting a parameter at the start of a program, where you can switch between single and double precision by changing one line, and that would be easier if you can indeed use np.float64 everywhere.)


问:
office 365 smtp vb.net
I developed a vp.net web app contains a function that sends emails it was running normally until last Monday any suggestions.
the following code explain what I am using to use smtp.office365.com:-</p>

```<code> `Dim SendMessage As New MailMessage

    SendMessage.To.Add("ToMail")
    SendMessage.CC.Add("CCMail")
    SendMessage.From = New MailAddress("MyMail")
    SendMessage.Subject = subject

    SendMessage.Body = "Test"

    SendMessage.IsBodyHtml = True

    Try

        Dim client As New SmtpClient("smtp.office365.com", 587)
        SendMessage.Priority = MailPriority.High
        client.EnableSsl = True

        client.UseDefaultCredentials = False
        Dim x As New Net.NetworkCredential("Mail", "Password")
        client.Credentials = x

        client.DeliveryMethod = SmtpDeliveryMethod.Network
        client.SendAsync(SendMessage, Nothing)

    Catch ex As Exception
        MsgBox(ex.ToString())

    End Try`
</code>```

答: the problem was from the firewall was blocking the port 587 and 25</p>

Title: office 365 smtp vb.net

Body:
I developed a vp.net web app contains a function that sends emails it was running normally until last Monday any suggestions.
the following code explain what I am using to use smtp.office365.com:-

 `Dim SendMessage As New MailMessage

    SendMessage.To.Add("ToMail")
    SendMessage.CC.Add("CCMail")
    SendMessage.From = New MailAddress("MyMail")
    SendMessage.Subject = subject

    SendMessage.Body = "Test"

    SendMessage.IsBodyHtml = True

    Try

        Dim client As New SmtpClient("smtp.office365.com", 587)
        SendMessage.Priority = MailPriority.High
        client.EnableSsl = True

        client.UseDefaultCredentials = False
        Dim x As New Net.NetworkCredential("Mail", "Password")
        client.Credentials = x

        client.DeliveryMethod = SmtpDeliveryMethod.Network
        client.SendAsync(SendMessage, Nothing)

    Catch ex As Exception
        MsgBox(ex.ToString())

    End Try`


问:
WEBrick: RequestURITooLarge: should I update or use a different server?
I currently have:

```<code>$ rails s
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-30 13:18:00] INFO  WEBrick 1.3.1
[2011-11-30 13:18:00] INFO  ruby 1.9.2 (2011-02-18) [x86_64-darwin10.8.0]
[2011-11-30 13:18:00] INFO  WEBrick::HTTPServer#start: pid=4204 port=3000
</code>```

The problem I'm having is I'm using openID for auth and getting the following error:

```<code>[2011-11-30 13:18:19] ERROR WEBrick::HTTPStatus::RequestURITooLarge
</code>```

In the browser:

```<code>Request-URI Too Large
WEBrick::HTTPStatus::RequestURITooLarge
WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) at macbook-pro.local:3000
</code>```

How can I fix this? Can I update WEBrick or do I really need to use a different web server?

Thanks

答:
Like said here, you could change the MAX_URI_LENGTH using this code:

WEBrick::HTTPRequest.const_set("MAX_URI_LENGTH", 10240)
```

Body:
I currently have:

$ rails s
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-30 13:18:00] INFO  WEBrick 1.3.1
[2011-11-30 13:18:00] INFO  ruby 1.9.2 (2011-02-18) [x86_64-darwin10.8.0]
[2011-11-30 13:18:00] INFO  WEBrick::HTTPServer#start: pid=4204 port=3000

The problem I'm having is I'm using openID for auth and getting the following error:

[2011-11-30 13:18:19] ERROR WEBrick::HTTPStatus::RequestURITooLarge

In the browser:

Request-URI Too Large
WEBrick::HTTPStatus::RequestURITooLarge
WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) at macbook-pro.local:3000

How can I fix this? Can I update WEBrick or do I really need to use a different web server?

Thanks


答:
There are two mistakes I have noticed in your model class.
1. Import the import javax.persistence.Transient;
2. Remove Transient anotation from your setter method.</p>

```<code>@Transient
public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}
</code>```

Title: @Transient not working properly in JPA

Body:
There are two mistakes I have noticed in your model class.
1. Import the import javax.persistence.Transient;
2. Remove Transient anotation from your setter method.

@Transient
public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}


问:
Polylang: string translation to "Read More" link not working
I can't seem to work my way around this: I have included a string translation into my functions.php file, Polylang registered it in the admin panel and I have added my translations for both Croatian and English.

When using the pll_e('saznaj-vise') function the output is fine in both languages (Saznaj Više and Read More), however when I include this string translation into my function modify_read_more_link() it does not display the permalink to the post/page, just static text above the content.

My code in functions.php looks like this:

```<code>function modify_read_more_link() {
  return  '<a href="' . get_permalink() . '">' . pll_e('saznaj-vise') . '</a>';
{

  add_filter( 'the_content_more_link', 'modify_read_more_link' );

  pll_register_string('read-more', 'saznaj-vise', 'Wordpress');
</code>```

The code inside the loop (for displaying a page) looks like this:

```<code><div>
  <?php global $more; $more = 0; ?>
  <p>
  <?php the_content(pll_get_post(5)); ?>
  </p>
</code>```

What I would like is that my string translation becomes a permalink to the post/page on the desired cutoff, as usual in WordPress.
I'd really appreciate some help. Thank you!

答:
SOLVED!

This should be useful to anyone who wants to translate the Read More string, as the information online is quite hard to find.
The working code in functions.php looks like this:

```<code>function modify_read_more_link() {
  return  '<a href="' . get_permalink() . '">' . pll__('string translation') .  '</a>';
}

add_filter( 'the_content_more_link', 'modify_read_more_link' );
pll_register_string('my-theme', 'string translation');
</code>```

The problem was that the pll_e(string-translation) didn't work inside function modify_read_more_link() { instead we needed the polylang function which returns the translated string - the one with two underscores: pll__('string translation')

Simply replace 'string translation' with the name of your string and translate it inside the wordpress admin panel.

Polylang function reference sheet

Body:
I can't seem to work my way around this: I have included a string translation into my functions.php file, Polylang registered it in the admin panel and I have added my translations for both Croatian and English.

When using the pll_e('saznaj-vise') function the output is fine in both languages (Saznaj Više and Read More), however when I include this string translation into my function modify_read_more_link() it does not display the permalink to the post/page, just static text above the content.

My code in functions.php looks like this:

function modify_read_more_link() {
  return  '' . pll_e('saznaj-vise') . '';
{

  add_filter( 'the_content_more_link', 'modify_read_more_link' );

  pll_register_string('read-more', 'saznaj-vise', 'Wordpress');

The code inside the loop (for displaying a page) looks like this:

  <?php global $more; $more = 0; ?>

  <?php the_content(pll_get_post(5)); ?>

What I would like is that my string translation becomes a permalink to the post/page on the desired cutoff, as usual in WordPress.
I'd really appreciate some help. Thank you!

Body:
SOLVED!

This should be useful to anyone who wants to translate the Read More string, as the information online is quite hard to find.
The working code in functions.php looks like this:

function modify_read_more_link() {
  return  '<a href="' . get_permalink() . '">' . pll__('string translation') .  '</a>';
}

add_filter( 'the_content_more_link', 'modify_read_more_link' );
pll_register_string('my-theme', 'string translation');

The problem was that the pll_e(string-translation) didn't work inside function modify_read_more_link() { instead we needed the polylang function which returns the translated string - the one with two underscores: pll__('string translation')

Simply replace 'string translation' with the name of your string and translate it inside the wordpress admin panel.

Polylang function reference sheet


问:
Add certain class depending on viewport width in Bootstrap
Is there any way to apply a specific class only on specific viewport width? (other than using media queries)

For example
Hello world
 would apply a margin-bottom all the time.

but what if I wanted to apply it only when the view port is larger than sm?

I am using Angular, so the solution could use Angular helpers.

答:
Most of the Bootstrap classes also have responsive classes.

In your case it would be mb-sm-1.

You can find out the responsive classes for all components in the Bootstrap docs.

Here's for example the responsive classes for the spacing utilities you asked about.


问:
ios What is the difference between objc_getClass and objc_lookUpClass
Apple’s explanation is

objc_getClass is different from  objc_lookUpClass in that if the class is not registered,  objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered.  objc_lookUpClass does not call the class handler callback.

But I don't really understand "class handler callback". Can you explain in more detail ? and I hope some code to show their difference，Thanks a lot!

答:
They two methods' explanation is unclear in Apple's documentation, but Objective C runtime code is open source and available at Apple Opensource.

The two methods' implementations are:

Class objc_getClass(const char *aClassName)
{
    if (!aClassName) return Nil;

    // NO unconnected, YES class handler
    return look_up_class(aClassName, NO, YES);
}

Class objc_lookUpClass(const char *aClassName)
{
    if (!aClassName) return Nil;

    // NO unconnected, NO class handler
    return look_up_class(aClassName, NO, NO);
}
```
<p>Both of these methods delegate to the <code>look_up_class</code> method, with a different argument to the last parameter <code>includeClassHandler</code>.</p>
<p>But looking at the implementation of <code>look_up_class</code> we can see, the last two parameters aren't actually used at all!</p>
<pre class="lang-objectivec prettyprint-override"><code>Class
look_up_class(const char *name,
              bool includeUnconnected __attribute__((unused)),
              bool includeClassHandler __attribute__((unused)))
{
    if (!name) return nil;

    Class result;
    bool unrealized;
    {
        rwlock_reader_t lock(runtimeLock);
        result = getClass(name);
        unrealized = result  &&  !result->isRealized();
    }
    if (unrealized) {
        rwlock_writer_t lock(runtimeLock);
        realizeClass(result);
    }
    return result;
}
</code>```

So, in summary, both objc_getClass and objc_lookUpClass behave identically.

Body:
They two methods' explanation is unclear in Apple's documentation, but Objective C runtime code is open source and available at Apple Opensource.

The two methods' implementations are:

Class objc_getClass(const char *aClassName)
{
    if (!aClassName) return Nil;

    // NO unconnected, YES class handler
    return look_up_class(aClassName, NO, YES);
}

Class objc_lookUpClass(const char *aClassName)
{
    if (!aClassName) return Nil;

    // NO unconnected, NO class handler
    return look_up_class(aClassName, NO, NO);
}

Both of these methods delegate to the look_up_class method, with a different argument to the last parameter includeClassHandler.

But looking at the implementation of look_up_class we can see, the last two parameters aren't actually used at all!

Class
look_up_class(const char *name,
              bool includeUnconnected __attribute__((unused)),
              bool includeClassHandler __attribute__((unused)))
{
    if (!name) return nil;

    Class result;
    bool unrealized;
    {
        rwlock_reader_t lock(runtimeLock);
        result = getClass(name);
        unrealized = result  &&  !result->isRealized();
    }
    if (unrealized) {
        rwlock_writer_t lock(runtimeLock);
        realizeClass(result);
    }
    return result;
}

So, in summary, both objc_getClass and objc_lookUpClass behave identically.


问:
EmptyError: no elements in sequence
I'm upgrading my Angular2 app from 2.0.0 to 2.3.0, and I'm running into the following error.  Any ideas as to why?  I saw this other post (Angular 2.0.1 Router EmptyError: no elements in sequence), but after trying this, the issue still remains.  What causes this error?

```<code>Error: Uncaught (in promise): EmptyError: no elements in sequence
Error: no elements in sequence
    at EmptyError.ZoneAwareError (zone.js:672)
    at new EmptyError (EmptyError.ts:13)
    at FirstSubscriber._complete (first.ts:161)
    at FirstSubscriber.Subscriber.complete (Subscriber.ts:122)
    at Subject._subscribe (Subject.ts:109)
    at Subject.Observable.subscribe (Observable.ts:98)
    at Observable._subscribe (Observable.ts:158)
    at Observable.subscribe (Observable.ts:98)
    at Observable._subscribe (Observable.ts:158)
    at FirstOperator.call (first.ts:82)
    at Observable.subscribe (Observable.ts:96)
    at Object.subscribeToResult (subscribeToResult.ts:32)
    at MergeAllSubscriber._next (mergeAll.ts:82)
    at MergeAllSubscriber.Subscriber.next (Subscriber.ts:95)
    at MapSubscriber._next (map.ts:80)
    at resolvePromise (zone.js:475) [angular]
    at resolvePromise (zone.js:460) [angular]
    at /libs/zone.js/dist/zone.js:509:17 [angular]
    at Object.onInvokeTask (core.umd.min.js:32) [angular]
    at ZoneDelegate.invokeTask (zone.js:261) [angular]
    at Zone.runTask (zone.js:151) [<root> => angular]
    at drainMicroTaskQueue (zone.js:405) [<root>]
    at ZoneTask.invoke (zone.js:336) [<root>]ErrorHandler.handleError @ core.umd.min.js:31next @ core.umd.min.js:32generatorOrNext.object.schedulerFn @ core.umd.min.js:32SafeSubscriber.__tryOrUnsub @ Subscriber.ts:238SafeSubscriber.next @ Subscriber.ts:190Subscriber._next @ Subscriber.ts:135Subscriber.next @ Subscriber.ts:95Subject.next @ Subject.ts:61EventEmitter.emit @ core.umd.min.js:32NgZone.triggerError @ core.umd.min.js:32onHandleError @ core.umd.min.js:32ZoneDelegate.handleError @ zone.js:233Zone.runGuarded @ zone.js:129_loop_1 @ zone.js:416drainMicroTaskQueue @ zone.js:425ZoneTask.invoke @ zone.js:336
</code>```

I've also noticed that a NavigationError object is thrown when I try to change to a route that uses Guards.  But only the error above is what is shown in the console.

NavigationError {id: 2, url: "/home", error: EmptyError}

I'm kind of at a loss and would appreciate any help.

答:
This error happens when using RxJS 5.5.3 with angular (version 4/5), so just skip RxJS 5.5.3, and use RxJS 5.5.4 by adding "rxjs": "^5.5.4" to your project package.json.

Before RxJS 5.5.4 came out answer: (old, don't do this)

Lock version 5.5.2 RxJS on package.json source

add pathMatch: 'full' on empty paths source

It looks like this is an RxJS issue which should be patched pretty soon. source

Title: EmptyError: no elements in sequence

Body:
I'm upgrading my Angular2 app from 2.0.0 to 2.3.0, and I'm running into the following error.  Any ideas as to why?  I saw this other post (Angular 2.0.1 Router EmptyError: no elements in sequence), but after trying this, the issue still remains.  What causes this error?

Error: Uncaught (in promise): EmptyError: no elements in sequence
Error: no elements in sequence
    at EmptyError.ZoneAwareError (zone.js:672)
    at new EmptyError (EmptyError.ts:13)
    at FirstSubscriber._complete (first.ts:161)
    at FirstSubscriber.Subscriber.complete (Subscriber.ts:122)
    at Subject._subscribe (Subject.ts:109)
    at Subject.Observable.subscribe (Observable.ts:98)
    at Observable._subscribe (Observable.ts:158)
    at Observable.subscribe (Observable.ts:98)
    at Observable._subscribe (Observable.ts:158)
    at FirstOperator.call (first.ts:82)
    at Observable.subscribe (Observable.ts:96)
    at Object.subscribeToResult (subscribeToResult.ts:32)
    at MergeAllSubscriber._next (mergeAll.ts:82)
    at MergeAllSubscriber.Subscriber.next (Subscriber.ts:95)
    at MapSubscriber._next (map.ts:80)
    at resolvePromise (zone.js:475) [angular]
    at resolvePromise (zone.js:460) [angular]
    at /libs/zone.js/dist/zone.js:509:17 [angular]
    at Object.onInvokeTask (core.umd.min.js:32) [angular]
    at ZoneDelegate.invokeTask (zone.js:261) [angular]
    at Zone.runTask (zone.js:151) [<root> => angular]
    at drainMicroTaskQueue (zone.js:405) [<root>]
    at ZoneTask.invoke (zone.js:336) [<root>]ErrorHandler.handleError @ core.umd.min.js:31next @ core.umd.min.js:32generatorOrNext.object.schedulerFn @ core.umd.min.js:32SafeSubscriber.__tryOrUnsub @ Subscriber.ts:238SafeSubscriber.next @ Subscriber.ts:190Subscriber._next @ Subscriber.ts:135Subscriber.next @ Subscriber.ts:95Subject.next @ Subject.ts:61EventEmitter.emit @ core.umd.min.js:32NgZone.triggerError @ core.umd.min.js:32onHandleError @ core.umd.min.js:32ZoneDelegate.handleError @ zone.js:233Zone.runGuarded @ zone.js:129_loop_1 @ zone.js:416drainMicroTaskQueue @ zone.js:425ZoneTask.invoke @ zone.js:336

I've also noticed that a NavigationError object is thrown when I try to change to a route that uses Guards.  But only the error above is what is shown in the console.

NavigationError {id: 2, url: "/home", error: EmptyError}

I'm kind of at a loss and would appreciate any help.


问:
split string by commas, with exception
I have a string with color names, separated by commas or | characters:

```<code>$s = 'Blue | Red (light, dark) | Green, Yellow, Brown';
</code>```

I need to convert it to array:

```<code>$colors = preg_split('![\|,]!', $s);
</code>```

But the result is:

```<code>Array
(
    [0] => Blue
    [1] =>  Red (light
    [2] =>  dark)
    [3] =>  Green
    [4] =>  Yellow
    [5] =>  Brown
)
</code>```

It splits the "light, dark" string with comma. I'd like to split with commas not inside parentheses. Desired result:

```<code>Array
(
    [0] => Blue
    [1] =>  Red (light, dark)
    [2] =>  Green
    [3] =>  Yellow
    [4] =>  Brown
)
</code>```

How can I solve it?

答:
```<code>$str = 'Blue | Red (light, dark) | Green, Yellow, Brown (light | bright)';
$res = preg_split('/
                     (          # group 1
                       [^|,]*   # 0 or more not pipe or comma
                       \(       # open parenthesis
                       [^()]*   # 0 or more not parenthesis
                       \)       # close parenthesis
                     )          # end group 1
                    |           # OR
                     [|,]       # a pipe or a comma
                   /x',
                   $str, -1,
                    PREG_SPLIT_NO_EMPTY
                  | PREG_SPLIT_DELIM_CAPTURE);
print_r($res);
</code>```

Output:

```<code>Array
(
    [0] => Blue
    [1] =>  Red (light, dark)
    [2] =>
    [3] =>  Green
    [4] =>  Yellow
    [5] =>  Brown (light | bright)
)
</code>```

Title: split string by commas, with exception

Body:
I have a string with color names, separated by commas or | characters:

$s = 'Blue | Red (light, dark) | Green, Yellow, Brown';

I need to convert it to array:

$colors = preg_split('![\|,]!', $s);

But the result is:

Array
(
    [0] => Blue
    [1] =>  Red (light
    [2] =>  dark)
    [3] =>  Green
    [4] =>  Yellow
    [5] =>  Brown
)

It splits the "light, dark" string with comma. I'd like to split with commas not inside parentheses. Desired result:

Array
(
    [0] => Blue
    [1] =>  Red (light, dark)
    [2] =>  Green
    [3] =>  Yellow
    [4] =>  Brown
)

How can I solve it?

Body:
$str = 'Blue | Red (light, dark) | Green, Yellow, Brown (light | bright)';
$res = preg_split('/
                     (          # group 1
                       [^|,]*   # 0 or more not pipe or comma
                       \(       # open parenthesis
                       [^()]*   # 0 or more not parenthesis
                       \)       # close parenthesis
                     )          # end group 1
                    |           # OR
                     [|,]       # a pipe or a comma
                   /x',
                   $str, -1,
                    PREG_SPLIT_NO_EMPTY
                  | PREG_SPLIT_DELIM_CAPTURE);
print_r($res);

Output:

Array
(
    [0] => Blue
    [1] =>  Red (light, dark)
    [2] =>
    [3] =>  Green
    [4] =>  Yellow
    [5] =>  Brown (light | bright)
)


问:
Include attachment where the name matches recipient name
I have code in Excel which sends email to a list of recipients:

```<code>Sub SendEMail()
    Dim xEmail As String
    Dim xSubj As String
    Dim xMsg As String
    Dim xURL As String
    Dim i As Integer
    Dim k As Double
    Dim xCell As Range
    Dim xRg As Range
    Dim xTxt As String
    On Error Resume Next
    xTxt = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select the data range:", "Send emails to:", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    If xRg.Columns.Count <> 3 Then
        MsgBox "Incorrect number of columns: You have to choose Name, Email address, Account no.!"
        Exit Sub
    End If
    For i = 1 To xRg.Rows.Count
    '   Get the email address
        xEmail = xRg.Cells(i, 2)
    '   Message subject
        xSubj = "Your customer's account is on hold"
    '   Compose the message
        xMsg = ""
        xMsg = xMsg & "Dear client" & "," & vbCrLf & vbCrLf
        xMsg = xMsg & "We would like to inform you, that Your account has been put on hold - "
        xMsg = xMsg & xRg.Cells(i, 3).Text & "." & vbCrLf & vbCrLf
        xMsg = xMsg & "If you have any queries, please contact us on uk.ar@bodycote.com." & vbCrLf & vbCrLf
        xMsg = xMsg & "Kind regards," & vbCrLf
        xMsg = xMsg & "Jon and Martina"
    '   Replace spaces with %20 (hex)
        xSubj = Application.WorksheetFunction.Substitute(xSubj, " ", "%20")
        xMsg = Application.WorksheetFunction.Substitute(xMsg, " ", "%20")
    '   Replace carriage returns with %0D%0A (hex)
        xMsg = Application.WorksheetFunction.Substitute(xMsg, vbCrLf, "%0D%0A")
    '   Create the URL
        xURL = "mailto:" & xEmail & "?subject=" & xSubj & "&body=" & xMsg
    '   Execute the URL (start the email client)
        ShellExecute 0&, vbNullString, xURL, vbNullString, vbNullString, vbNormalFocus
    '   Wait two seconds before sending keystrokes
        Application.Wait (Now + TimeValue("0:00:02"))
        Application.SendKeys "%s"
    Next
End Sub
</code>```

I would like to add variable attachments. It will be a pdf file and its name will be the same as the name of customer (which is placed in column A). Basically it should look for "Name.pdf" in "S:\All Team\AX OTI\test\"

The source table looks like:

答:
Here you have something that works really nicely - Add attachement to outlook with varying file names

In your case, simply copy the code and make sure that in the part strLocation you write something like:

```<code>strLocation = "C:\Users\user\Desktop\" & Cells(i,2) & ".pdf"
</code>```

thus, you will be able to loop around it. In general, take a good look at the mentioned answer, it is really a good approach (IMHO quite better than sending keys).

Body:
I have code in Excel which sends email to a list of recipients:

Sub SendEMail()
    Dim xEmail As String
    Dim xSubj As String
    Dim xMsg As String
    Dim xURL As String
    Dim i As Integer
    Dim k As Double
    Dim xCell As Range
    Dim xRg As Range
    Dim xTxt As String
    On Error Resume Next
    xTxt = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select the data range:", "Send emails to:", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    If xRg.Columns.Count <> 3 Then
        MsgBox "Incorrect number of columns: You have to choose Name, Email address, Account no.!"
        Exit Sub
    End If
    For i = 1 To xRg.Rows.Count
    '   Get the email address
        xEmail = xRg.Cells(i, 2)
    '   Message subject
        xSubj = "Your customer's account is on hold"
    '   Compose the message
        xMsg = ""
        xMsg = xMsg & "Dear client" & "," & vbCrLf & vbCrLf
        xMsg = xMsg & "We would like to inform you, that Your account has been put on hold - "
        xMsg = xMsg & xRg.Cells(i, 3).Text & "." & vbCrLf & vbCrLf
        xMsg = xMsg & "If you have any queries, please contact us on uk.ar@bodycote.com." & vbCrLf & vbCrLf
        xMsg = xMsg & "Kind regards," & vbCrLf
        xMsg = xMsg & "Jon and Martina"
    '   Replace spaces with %20 (hex)
        xSubj = Application.WorksheetFunction.Substitute(xSubj, " ", "%20")
        xMsg = Application.WorksheetFunction.Substitute(xMsg, " ", "%20")
    '   Replace carriage returns with %0D%0A (hex)
        xMsg = Application.WorksheetFunction.Substitute(xMsg, vbCrLf, "%0D%0A")
    '   Create the URL
        xURL = "mailto:" & xEmail & "?subject=" & xSubj & "&body=" & xMsg
    '   Execute the URL (start the email client)
        ShellExecute 0&, vbNullString, xURL, vbNullString, vbNullString, vbNormalFocus
    '   Wait two seconds before sending keystrokes
        Application.Wait (Now + TimeValue("0:00:02"))
        Application.SendKeys "%s"
    Next
End Sub

I would like to add variable attachments. It will be a pdf file and its name will be the same as the name of customer (which is placed in column A). Basically it should look for "Name.pdf" in "S:\All Team\AX OTI\test\"

The source table looks like:

Body:
Here you have something that works really nicely - Add attachement to outlook with varying file names

In your case, simply copy the code and make sure that in the part strLocation you write something like:

strLocation = "C:\Users\user\Desktop\" & Cells(i,2) & ".pdf"

thus, you will be able to loop around it. In general, take a good look at the mentioned answer, it is really a good approach (IMHO quite better than sending keys).


问:
Textview inside Adapter not working
This code is not working correctly

```<code>  customViewHolder.increase.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

    Double rate=Double.parseDouble(customViewHolder.total.getText().toString());
    Log.e("rate",rate+"");
    Double newrate=rate-((Double.parseDouble(feedItem.getRate())-Double.parseDouble(feedItem.getDiscount()))*(minteger-1));
    Log.e("minusval",""+((Double.parseDouble(feedItem.getRate())-Double.parseDouble(feedItem.getDiscount()))*(minteger-1)));
    Double ratetext=newrate+(Double.parseDouble(feedItem.getRate())-Double.parseDouble(feedItem.getDiscount()))*minteger;
    Log.e("ratetext",ratetext+"");

    Double discrate=Double.parseDouble(customViewHolder.disctotal.getText().toString());
                        Double newdiscrate=discrate-(Double.parseDouble(feedItem.getDiscount())*(minteger-1));
                        Double disctext=newdiscrate+Double.parseDouble(feedItem.getDiscount())*minteger;

    Log.e("ratettttttttext",ratetext+"");
    customViewHolder.total.setText(""+ratetext);// not working
    ustomViewHolder.totalnew.setText(ratetext+"");// not working
    customViewHolder.disctotal.setText(disctext+"");// not working

    }
 });
</code>```

In this Adapter, inside onbindViewHolder my TextView not setting with the newvalue. Why it is happen?

答:
call notifyDataSetChanged after setting value,it will refresh the adapter

```<code>customViewHolder.total.setText(""+ratetext);// not working
ustomViewHolder.totalnew.setText(ratetext+"");// not working
customViewHolder.disctotal.setText(disctext+"");
adpter.notifyDataSetChanged();
</code>```

Title: Textview inside Adapter not working

Body:
This code is not working correctly

  customViewHolder.increase.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

    Double rate=Double.parseDouble(customViewHolder.total.getText().toString());
    Log.e("rate",rate+"");
    Double newrate=rate-((Double.parseDouble(feedItem.getRate())-Double.parseDouble(feedItem.getDiscount()))*(minteger-1));
    Log.e("minusval",""+((Double.parseDouble(feedItem.getRate())-Double.parseDouble(feedItem.getDiscount()))*(minteger-1)));
    Double ratetext=newrate+(Double.parseDouble(feedItem.getRate())-Double.parseDouble(feedItem.getDiscount()))*minteger;
    Log.e("ratetext",ratetext+"");

    Double discrate=Double.parseDouble(customViewHolder.disctotal.getText().toString());
                        Double newdiscrate=discrate-(Double.parseDouble(feedItem.getDiscount())*(minteger-1));
                        Double disctext=newdiscrate+Double.parseDouble(feedItem.getDiscount())*minteger;

    Log.e("ratettttttttext",ratetext+"");
    customViewHolder.total.setText(""+ratetext);// not working
    ustomViewHolder.totalnew.setText(ratetext+"");// not working
    customViewHolder.disctotal.setText(disctext+"");// not working

    }
 });

In this Adapter, inside onbindViewHolder my TextView not setting with the newvalue. Why it is happen?

Body:
call notifyDataSetChanged after setting value,it will refresh the adapter

customViewHolder.total.setText(""+ratetext);// not working
ustomViewHolder.totalnew.setText(ratetext+"");// not working
customViewHolder.disctotal.setText(disctext+"");
adpter.notifyDataSetChanged();


问:
How to load local file in sc.textFile, instead of HDFS
I'm following the great spark tutorial

so i'm trying at 46m:00s to load the README.md but fail to what i'm doing is this:

```<code>$ sudo docker run -i -t -h sandbox sequenceiq/spark:1.1.0 /etc/bootstrap.sh -bash
bash-4.1# cd /usr/local/spark-1.1.0-bin-hadoop2.4
bash-4.1# ls README.md
README.md
bash-4.1# ./bin/spark-shell
scala> val f = sc.textFile("README.md")
14/12/04 12:11:14 INFO storage.MemoryStore: ensureFreeSpace(164073) called with curMem=0, maxMem=278302556
14/12/04 12:11:14 INFO storage.MemoryStore: Block broadcast_0 stored as values in memory (estimated size 160.2 KB, free 265.3 MB)
f: org.apache.spark.rdd.RDD[String] = README.md MappedRDD[1] at textFile at <console>:12
scala> val wc = f.flatMap(l => l.split(" ")).map(word => (word, 1)).reduceByKey(_ + _)
org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: hdfs://sandbox:9000/user/root/README.md
    at org.apache.hadoop.mapred.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:285)
</code>```

how can I load that README.md?

答:
While Spark supports loading files from the local filesystem, it requires that the files are available at the same path on all nodes in your cluster.

Some network filesystems, like NFS, AFS, and MapR’s NFS layer, are exposed to the user as a regular filesystem.

If your data is already in one of these systems, then you can use it as an input by just specifying a file:// path; Spark will handle it as long as the filesystem is mounted at the same path on each node. Every node needs to have the same path

```<code> rdd = sc.textFile("file:///path/to/file")
</code>```

If your file isn’t already on all nodes in the cluster, you can load it locally on the driver without going through Spark and then call parallelize to distribute the contents to workers

Take care to put file:// in front and the use of "/" or "\" according to OS.

Body:
I'm following the great spark tutorial

so i'm trying at 46m:00s to load the README.md but fail to what i'm doing is this:

$ sudo docker run -i -t -h sandbox sequenceiq/spark:1.1.0 /etc/bootstrap.sh -bash
bash-4.1# cd /usr/local/spark-1.1.0-bin-hadoop2.4
bash-4.1# ls README.md
README.md
bash-4.1# ./bin/spark-shell
scala> val f = sc.textFile("README.md")
14/12/04 12:11:14 INFO storage.MemoryStore: ensureFreeSpace(164073) called with curMem=0, maxMem=278302556
14/12/04 12:11:14 INFO storage.MemoryStore: Block broadcast_0 stored as values in memory (estimated size 160.2 KB, free 265.3 MB)
f: org.apache.spark.rdd.RDD[String] = README.md MappedRDD[1] at textFile at <console>:12
scala> val wc = f.flatMap(l => l.split(" ")).map(word => (word, 1)).reduceByKey(_ + _)
org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: hdfs://sandbox:9000/user/root/README.md
    at org.apache.hadoop.mapred.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:285)

how can I load that README.md?

Body:
While Spark supports loading files from the local filesystem, it requires that the files are available at the same path on all nodes in your cluster.

Some network filesystems, like NFS, AFS, and MapR’s NFS layer, are exposed to the user as a regular filesystem.

If your data is already in one of these systems, then you can use it as an input by just specifying a file:// path; Spark will handle it as long as the filesystem is mounted at the same path on each node. Every node needs to have the same path

 rdd = sc.textFile("file:///path/to/file")

If your file isn’t already on all nodes in the cluster, you can load it locally on the driver without going through Spark and then call parallelize to distribute the contents to workers

Take care to put file:// in front and the use of "/" or "\" according to OS.


问:
Bootstrap Open/Collapse not working
I am trying to open div which is inside the div.

My second div is not opening, in fact, the first div is closing.

Try to click Part 1 then The div under it.

I want that div to be open when clicking on it, but it is closing the part1 div

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

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

          Part 1

          ऑडियो नंबर 15 छह काय के जीव

  <audio controls="controls">
    <source src="https://docs.google.com/uc?export=download&id=1HMEmwK4COifRjhe8IWM82Pn5tw3UO4xs">
</audio>

```

答:
Move the part1 div and its children outside the accordion div. And I renamed your 1.1 div to one because id's shouldn't begin with a number.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

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

                    Part 1

                            ऑडियो नंबर 15 छह काय के जीव

                            <audio controls="controls">
                                <source src="https://docs.google.com/uc?export=download&id=1HMEmwK4COifRjhe8IWM82Pn5tw3UO4xs">
                            </audio>

```

Title: Bootstrap Open/Collapse not working

Body:
Move the part1 div and its children outside the accordion div. And I renamed your 1.1 div to one because id's shouldn't begin with a number.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<center>
<strong>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <div class="panel-group" id="accordion">
        <div class="panel panel-default" data-toggle="collapse" data-parent="#accordion" href="#part1">
            <!--Date of Birth-->
            <div class="panel-heading">
                <h4 class="panel-title">
                    Part 1
                </h4>
            </div>
        </div>
    </div>
    <div id="part1" class="panel-collapse collapse">
        <div class="panel-body">

            <div class="panel-group" id="accordion1.1">
                <div class="panel panel-default" data-toggle="collapse" data-parent="#accordion1.1" href="#one">
                    <!--Date of Birth-->
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            ऑडियो नंबर 15 छह काय के जीव
                        </h4>
                    </div>
                    <div id="one" class="panel-collapse collapse">
                        <div class="panel-body">
                            <audio controls="controls">
                                <source src="https://docs.google.com/uc?export=download&id=1HMEmwK4COifRjhe8IWM82Pn5tw3UO4xs">
                            </audio>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</strong>
</center>


问:
Creating Update button and Cancel button using button group and then to add ( | ) between two buttons
I want to show two buttons as update button and cancel button like one button from user view.And then, I want to add (|) between two buttons.I added  tag to show | between two buttons. And then, I created two buttons for the update and delete.I tried a lot of time But I can't do that.How can I do that?Please help me.

.footer-button1{
     background-color: #85b59d;
           width: 60px;
           margin-top: 10px;
           display: inline-block;
           text-align: center;
           height: 30px;
           border-radius: 5px;
           border: none;
           margin-bottom: 10px;
      }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="btn-group">
         <button type="button" class="btn footer-button1">Update</button>
         <button type="button" class="btn footer-button1"> <span style="margin-left: -10px;">|</span> Delete</button>
                    </div></code>```

答:
I used the :after pseudo for this. If you specifically wanted a '|' instead of a border you can use content.

.footer-button1{
     background-color: #85b59d;
           width: 60px;
           margin-top: 10px;
           display: inline-block;
           text-align: center;
           height: 30px;
           border-radius: 5px;
           border: none;
           margin-bottom: 10px;
           position: relative;
           margin-right: 13px;
      }

 .footer-button1:first-child:after {
  display: none;
 }

.footer-button1:after {
  width: 1px;
  height: 28px;
  position: absolute;
  content: '';
  top: 0;
  left: -10px;
  border-left: 1px solid #000;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="btn-group">
         <button type="button" class="btn footer-button1">Update</button>
         <button type="button" class="btn footer-button1">Delete</button>
                    </div></code>```

Body:
I want to show two buttons as update button and cancel button like one button from user view.And then, I want to add (|) between two buttons.I added  tag to show | between two buttons. And then, I created two buttons for the update and delete.I tried a lot of time But I can't do that.How can I do that?Please help me.

.footer-button1{
     background-color: #85b59d;
           width: 60px;
           margin-top: 10px;
           display: inline-block;
           text-align: center;
           height: 30px;
           border-radius: 5px;
           border: none;
           margin-bottom: 10px;
      }

         <button type="button" class="btn footer-button1">Update</button>
         <button type="button" class="btn footer-button1"> | Delete</button>

Body:
I used the :after pseudo for this. If you specifically wanted a '|' instead of a border you can use content.

.footer-button1{
     background-color: #85b59d;
           width: 60px;
           margin-top: 10px;
           display: inline-block;
           text-align: center;
           height: 30px;
           border-radius: 5px;
           border: none;
           margin-bottom: 10px;
           position: relative;
           margin-right: 13px;
      }

 .footer-button1:first-child:after {
  display: none;
 }

.footer-button1:after {
  width: 1px;
  height: 28px;
  position: absolute;
  content: '';
  top: 0;
  left: -10px;
  border-left: 1px solid #000;
}

<div class="btn-group">
         <button type="button" class="btn footer-button1">Update</button>
         <button type="button" class="btn footer-button1">Delete</button>
                    </div>


问:
Comparing 2 arrays fast in PHP
So there are 2 csv files that i read , with around 25k records. One is Old CSV and one is New CSV.  I need to compare if 'primary_contact' field is different in the new CSV file as compared to the old CSV record, while the 'name' , 'state' and 'city' fields are same in both old and new CSV.

New CSV :

```<code>Array(

[0] => Array
    (
        [0] => ID
        [1] => NAME
        [2] => STATE
        [3] => CITY
        [4] => COUNTY
        [5] => ADDRESS
        [6] => PHONE
        [7] => PRIMARY CONTACT
        [8] => POSITION
        [9] => EMAIL
    )

[1] => Array
    (
        [0] => 2002
        [1] => Abbeville Christian Academy
        [2] => Alabama
        [3] => Abbeville
        [4] => Henry
        [5] => Po Box 9 Abbeville, AL 36310-0009
        [6] => (334) 585-5100
        [7] => Ashley Carlisle
        [8] => Athletic Director
        [9] => acarlisle@acagenerals.org
    )

}
</code>```

The issue is that i did 2 foreach nested loops to compare and it was fine for smal records , but when i ran Old and New CSV files containing 25k records each, the process took forever to complete.

There are some duplicates in both CSVs , so i remove them first ;

```<code>function multi_unique($data){
    $data = array_reverse($data);

    $result = array_reverse( // Reverse array to the initial order.
        array_values( // Get rid of string keys (make array indexed again).
            array_combine( // Create array taking keys from column and values from the base array.
                array_column($data, 1),
                $data
            )
        )
    );

    return $result;
}

$old_csv=multi_unique($old_csv);
$new_csv=multi_unique($new_csv);
</code>```

Here is my comparison code, i need something faster than this;

```<code>$name_index_no = 1;
$state_index_no = 2;
$city_index_no = 3;
$country_index_no = 4;
$address_index_no = 5;
$primary_contact_index_no = 7;
$new_export_records[] = $old_csv[0];

foreach($new_csv as $key=>$value){

    foreach($old_csv as $key1=>$value1){

        if( $old_csv[$key1][$state_index_no] == $new_csv[$key][$state_index_no] &&
            $old_csv[$key1][$city_index_no] == $new_csv[$key][$city_index_no] &&
            $old_csv[$key1][$name_index_no] == $new_csv[$key][$name_index_no] ){

            if($old_csv[$key1][$primary_contact_index_no] !=
               $new_csv[$key][$primary_contact_index_no]){

                $new_export_records[] = $new_csv[$key];

            }

            unset($old_csv[$key1]);
            break;
        }

    }

}
</code>```

答:
As Michael pointed out, your current solution runs n * m times. With each being 25k, this is simply too much. But if you run through your old data first, create an index, and then run through the new data and check against that index, you'll be done in m + n iterations.

An example would be:

```<code>$name_index_no            = 1;
$state_index_no           = 2;
$city_index_no            = 3;
$country_index_no         = 4;
$address_index_no         = 5;
$primary_contact_index_no = 7;

$genKey = function ($row, $glue = '|') use ($state_index_no, $city_index_no, $name_index_no) {
    return implode($glue, [
        $row[$state_index_no],
        $row[$city_index_no],
        $row[$name_index_no],
    ]);
};

// create an index using the old data
$t = microtime(true);
$index = [];
foreach ($old_csv as $row) {
    $index[$genKey($row)] = $row;
}

printf('index generation: %.5fs', microtime(true) - $t);

// collect changed/new entries
$t = microtime(true);
$changed = [];
$new = [];
foreach ($new_csv as $row) {
    $key = $genKey($row);

    // key doesn't exist => new entry
    if (!isset($index[$key])) {
        $new[] = $row;
    }

    // primary contact differs => changed entry
    elseif ($row[$primary_contact_index_no] !== $index[$key][$primary_contact_index_no]) {
        $changed[] = $row;
    }
}

printf('comparison: %.5fs', microtime(true) - $t);
print_r($changed);
print_r($new);
</code>```

Title: Comparing 2 arrays fast in PHP

Body:
So there are 2 csv files that i read , with around 25k records. One is Old CSV and one is New CSV.  I need to compare if 'primary_contact' field is different in the new CSV file as compared to the old CSV record, while the 'name' , 'state' and 'city' fields are same in both old and new CSV.

New CSV :

Array(

[0] => Array
    (
        [0] => ID
        [1] => NAME
        [2] => STATE
        [3] => CITY
        [4] => COUNTY
        [5] => ADDRESS
        [6] => PHONE
        [7] => PRIMARY CONTACT
        [8] => POSITION
        [9] => EMAIL
    )

[1] => Array
    (
        [0] => 2002
        [1] => Abbeville Christian Academy
        [2] => Alabama
        [3] => Abbeville
        [4] => Henry
        [5] => Po Box 9 Abbeville, AL 36310-0009
        [6] => (334) 585-5100
        [7] => Ashley Carlisle
        [8] => Athletic Director
        [9] => acarlisle@acagenerals.org
    )

}

The issue is that i did 2 foreach nested loops to compare and it was fine for smal records , but when i ran Old and New CSV files containing 25k records each, the process took forever to complete.

There are some duplicates in both CSVs , so i remove them first ;

function multi_unique($data){
    $data = array_reverse($data);

    $result = array_reverse( // Reverse array to the initial order.
        array_values( // Get rid of string keys (make array indexed again).
            array_combine( // Create array taking keys from column and values from the base array.
                array_column($data, 1),
                $data
            )
        )
    );

    return $result;
}

$old_csv=multi_unique($old_csv);
$new_csv=multi_unique($new_csv);

Here is my comparison code, i need something faster than this;

$name_index_no = 1;
$state_index_no = 2;
$city_index_no = 3;
$country_index_no = 4;
$address_index_no = 5;
$primary_contact_index_no = 7;
$new_export_records[] = $old_csv[0];

foreach($new_csv as $key=>$value){

    foreach($old_csv as $key1=>$value1){

        if( $old_csv[$key1][$state_index_no] == $new_csv[$key][$state_index_no] &&
            $old_csv[$key1][$city_index_no] == $new_csv[$key][$city_index_no] &&
            $old_csv[$key1][$name_index_no] == $new_csv[$key][$name_index_no] ){

            if($old_csv[$key1][$primary_contact_index_no] !=
               $new_csv[$key][$primary_contact_index_no]){

                $new_export_records[] = $new_csv[$key];

            }

            unset($old_csv[$key1]);
            break;
        }

    }

}

Body:
As Michael pointed out, your current solution runs n * m times. With each being 25k, this is simply too much. But if you run through your old data first, create an index, and then run through the new data and check against that index, you'll be done in m + n iterations.

An example would be:

$name_index_no            = 1;
$state_index_no           = 2;
$city_index_no            = 3;
$country_index_no         = 4;
$address_index_no         = 5;
$primary_contact_index_no = 7;

$genKey = function ($row, $glue = '|') use ($state_index_no, $city_index_no, $name_index_no) {
    return implode($glue, [
        $row[$state_index_no],
        $row[$city_index_no],
        $row[$name_index_no],
    ]);
};

// create an index using the old data
$t = microtime(true);
$index = [];
foreach ($old_csv as $row) {
    $index[$genKey($row)] = $row;
}

printf('index generation: %.5fs', microtime(true) - $t);

// collect changed/new entries
$t = microtime(true);
$changed = [];
$new = [];
foreach ($new_csv as $row) {
    $key = $genKey($row);

    // key doesn't exist => new entry
    if (!isset($index[$key])) {
        $new[] = $row;
    }

    // primary contact differs => changed entry
    elseif ($row[$primary_contact_index_no] !== $index[$key][$primary_contact_index_no]) {
        $changed[] = $row;
    }
}

printf('comparison: %.5fs', microtime(true) - $t);
print_r($changed);
print_r($new);


问:
Using Include() with anonymous types in Entity Framework
I am trying to eager load some properties using Include method as following:

```<code>var dbData = dbContext.Locators.Include(x => x.PhysicalObjects.Select(p => p.Parent)).Include(x => x.PhysicalObjects.Select(p =>p.Type.AllowedSubTypes))
                .Where(x => x.id==1)).Select(x => new
                {
                    newContainer = x.PhysicalObjects.Where(p => p.Id== newContainerId).FirstOrDefault(),
                    phyiscalObject = x.PhysicalObjects.Where(p => p.Id == id).FirstOrDefault()
                }).FirstOrDefault();
</code>```

But it returns Parent and Type properties as null(I checked database they are not null).

So how can I eager load those properties?

P.S

I am using Entity Framework V6.1.3

答:
Depending on DevilSuichiro's comment above the query will be like this:

```<code> var dbData = dbContext.Locators.Include(x => x.PhysicalObjects.Select(p => p.Parent)).Include(x => x.PhysicalObjects.Select(p =>p.Type.AllowedSubTypes))
                .Where(x => x.Id==1)).Take(2).ToList().Select(x => new
                {
                    newContainer = x.PhysicalObjects.Where(p => p.Id== newContainerId).FirstOrDefault(),
                    phyiscalObject = x.PhysicalObjects.Where(p => p.Id == id).FirstOrDefault()
                }).FirstOrDefault();
</code>```

It worked for me, but I will still be waiting for better answer if any.

Body:
I am trying to eager load some properties using Include method as following:

var dbData = dbContext.Locators.Include(x => x.PhysicalObjects.Select(p => p.Parent)).Include(x => x.PhysicalObjects.Select(p =>p.Type.AllowedSubTypes))
                .Where(x => x.id==1)).Select(x => new
                {
                    newContainer = x.PhysicalObjects.Where(p => p.Id== newContainerId).FirstOrDefault(),
                    phyiscalObject = x.PhysicalObjects.Where(p => p.Id == id).FirstOrDefault()
                }).FirstOrDefault();

But it returns Parent and Type properties as null(I checked database they are not null).

So how can I eager load those properties?

P.S

I am using Entity Framework V6.1.3

Body:
Depending on DevilSuichiro's comment above the query will be like this:

 var dbData = dbContext.Locators.Include(x => x.PhysicalObjects.Select(p => p.Parent)).Include(x => x.PhysicalObjects.Select(p =>p.Type.AllowedSubTypes))
                .Where(x => x.Id==1)).Take(2).ToList().Select(x => new
                {
                    newContainer = x.PhysicalObjects.Where(p => p.Id== newContainerId).FirstOrDefault(),
                    phyiscalObject = x.PhysicalObjects.Where(p => p.Id == id).FirstOrDefault()
                }).FirstOrDefault();

It worked for me, but I will still be waiting for better answer if any.


问:
Put data side by side after the end of the csv file
I have a macro who allows me to import data of several csv file into a workbook containing several sheets :

```<code>Option Explicit
Sub ImportCSVs()
'Import all CSV files from a folder into separate sheets

Dim fPath   As String
Dim fCSV    As String
Dim wbCSV   As Workbook
Dim wbMST   As Workbook

Set wbMST = ActiveWorkbook

'Update the path to your CSV files below. Add your-username and your-folder
'Don't remove the the final \ from the file path

fPath = "C:\Users\your-username\Documents\your-folder\"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
fCSV = Dir(fPath & "*.csv")

    Do While Len(fCSV) > 0
        Set wbCSV = Workbooks.Open(fPath & fCSV)
        ActiveSheet.Move After:=wbMST.Sheets(wbMST.Sheets.Count)

        fCSV = Dir
    Loop

Set wbCSV = Nothing

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

I would like to get each csv file into the same Excel file, thus, when a csv is finish, go to the column just after (A, B, C....)

Hope that's possible with the existing code...

答:
This assumes all csv's have data in every column of top row</p>

```<code>Sub ImportCSVs()
 'Import all CSV files from a folder into separate sheets

 Dim fPath   As String
 Dim fCSV    As String
 Dim wbCSV   As Workbook
 'Dim wbMST   As Workbook
 Dim target as range

 'Set wbMST = ActiveWorkbook
  set target = activeworkbook.worksheets(1).range("a1")

 'Update the path to your CSV files below. Add your-username and your-folder
 'Don't remove the the final \ from the file path

 fPath = "C:\Users\your-username\Documents\your-folder\"
 Application.ScreenUpdating = False
 Application.DisplayAlerts = False
 fCSV = Dir(fPath & "*.csv")

Do While Len(fCSV) > 0
    Set wbCSV = Workbooks.Open(fPath & fCSV)
    'ActiveSheet.Move After:=wbMST.Sheets(wbMST.Sheets.Count)
    wbcsv.sheets(1).usedrange.copy target
   set target = target.offset(0,target.currentregion.columns.count +1)
    '=======================New Line
     wbcsv.close False
     '==========End New line
    fCSV = Dir
Loop

 Set wbCSV = Nothing

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

Body:
I have a macro who allows me to import data of several csv file into a workbook containing several sheets :

Option Explicit
Sub ImportCSVs()
'Import all CSV files from a folder into separate sheets

Dim fPath   As String
Dim fCSV    As String
Dim wbCSV   As Workbook
Dim wbMST   As Workbook

Set wbMST = ActiveWorkbook

'Update the path to your CSV files below. Add your-username and your-folder
'Don't remove the the final \ from the file path

fPath = "C:\Users\your-username\Documents\your-folder\"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
fCSV = Dir(fPath & "*.csv")

    Do While Len(fCSV) > 0
        Set wbCSV = Workbooks.Open(fPath & fCSV)
        ActiveSheet.Move After:=wbMST.Sheets(wbMST.Sheets.Count)

        fCSV = Dir
    Loop

Set wbCSV = Nothing

Application.ScreenUpdating = True
End Sub

I would like to get each csv file into the same Excel file, thus, when a csv is finish, go to the column just after (A, B, C....)

Hope that's possible with the existing code...

Body:
This assumes all csv's have data in every column of top row

Sub ImportCSVs()
 'Import all CSV files from a folder into separate sheets

 Dim fPath   As String
 Dim fCSV    As String
 Dim wbCSV   As Workbook
 'Dim wbMST   As Workbook
 Dim target as range

 'Set wbMST = ActiveWorkbook
  set target = activeworkbook.worksheets(1).range("a1")

 'Update the path to your CSV files below. Add your-username and your-folder
 'Don't remove the the final \ from the file path

 fPath = "C:\Users\your-username\Documents\your-folder\"
 Application.ScreenUpdating = False
 Application.DisplayAlerts = False
 fCSV = Dir(fPath & "*.csv")

Do While Len(fCSV) > 0
    Set wbCSV = Workbooks.Open(fPath & fCSV)
    'ActiveSheet.Move After:=wbMST.Sheets(wbMST.Sheets.Count)
    wbcsv.sheets(1).usedrange.copy target
   set target = target.offset(0,target.currentregion.columns.count +1)
    '=======================New Line
     wbcsv.close False
     '==========End New line
    fCSV = Dir
Loop

 Set wbCSV = Nothing

 Application.ScreenUpdating = True
 End Sub


问:
SQL Azure and CakePHP
Has anyone connected CakePHP to SQL Azure? Google doesn't come up with anything. I am finding more examples of RoR connecting to SQL Azure actually, so given that Azure is relatively new, does this mean RoR is evolving faster than CakePHP? Having read numerous comparisons between the two frameworks, I have yet to settle on one, so maybe a better understanding here will tip the balance. Please assume my learning-curve is equal for both.</p>

答:
You can implement and add DataSources for CakePHP to connect to databases not already defined.

There also is an existing DataSource for Azure available here.

Title: SQL Azure and CakePHP


问:
How to delete projects in IntelliJ 12?
I created some dummy projects. Now I don't see any way to delete the projects that I don't want. Per this suggestion I can delete files, the project is going away but there is traces of it still available. For example, on the Recent Projects you can still see the name of the project you just deleted. So I am thinking there should be another (and really easy way) to delete a project.</p>

答:
In my case, I had to delete home/.IntelliJIdea2017.2/config/options/recentProjects.xml
. In my file system (Ubuntu) this file appeared for some weird reason not writable and hold a list of projects I couldn't get rid of. Deleting this file and restarting will force Intellij IDEA to create a new one with an empty list of projects.

Title: How to delete projects in IntelliJ 12?


问:
asp.net core 2.0 not getting exact path of css or view page
net core 2.0 and i have getting issue to getting full path as shown as given below if you have any idea please give me solution

```<code> string filePath = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"), "Demopath"), "Views"), "DemoViews"), "Views.cshtml");
</code>```

From this i am getting this path

```<code>D:\ILYAS\\nop4.0\Presentation\Nop.Web\bin\Debug\net461\Plugins\Demopath\Views\DemoViews\Views.cshtml
</code>```

But i don't need \bin\Debug\net461\

becuase of this extra line i am not getting my CSS and view page
Is any one have idea please inform me

thank you in advance

答:
Use this one

```<code>Path.Combine(Environment.CurrentDirectory.ToString(), "Plugins", "MyDemo", "Content", "css", "style.css");
</code>```

It'll work

Body:
net core 2.0 and i have getting issue to getting full path as shown as given below if you have any idea please give me solution

 string filePath = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"), "Demopath"), "Views"), "DemoViews"), "Views.cshtml");

From this i am getting this path

D:\ILYAS\\nop4.0\Presentation\Nop.Web\bin\Debug\net461\Plugins\Demopath\Views\DemoViews\Views.cshtml

But i don't need \bin\Debug\net461\

becuase of this extra line i am not getting my CSS and view page
Is any one have idea please inform me

thank you in advance

Body:
Use this one

Path.Combine(Environment.CurrentDirectory.ToString(), "Plugins", "MyDemo", "Content", "css", "style.css");

It'll work


问:
What is the difference between !empty($data['name']) and $data['name'] != '' in PHP?
Can anybody please me what is the difference between these two statements in PHP?

```<code>if ($data['name'] != '')
{
  ...
}
</code>```

and

```<code>if (!empty($data['name']))
{
  ...
}
</code>```

When I replaced the first statement with second it fixes the undefined array element error.

Thanks in advance.

答:
$data['name'] != is called comparison, that's why it is called comparison operator.

empty($data['name'] is checking either it contains data or not.

Doc: PHP Comparison operations

Body:
Can anybody please me what is the difference between these two statements in PHP?

if ($data['name'] != '')
{
  ...
}

and

if (!empty($data['name']))
{
  ...
}

When I replaced the first statement with second it fixes the undefined array element error.

Thanks in advance.


问:
Get the click event from the listview and open the video
I am making a small application, namely a custom listview, when I click on a line on the listview will open a new layout and play video online. I'm wrong every time click on the picture

Here is a video class

Here is the click event in the main activity

The one thing I want to ask is that can make the user click on a line on the listview, then the video will open in full screen (automatic screen rotation) is not? And how do you know how many users click on the number line on the listview?
Thank you everyone, look forward to helping everyone :D

p/s: Does the video view support real-time video playback? Because I making watch TV online app

答:
do check you have declared ModuleDetailActivity in manifest file like below

```<code> <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

 <activity android:name=".ModuleDetailActivity"/>
</code>```

Body:
do check you have declared ModuleDetailActivity in manifest file like below

 <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

 <activity android:name=".ModuleDetailActivity"/>