问:
My Ec2 Host Down: Unhealthy for 1 hour and can't load the site in the instance
My host is unhealthy for 1 hour and when I access my site using the instance public IP (not ELB DNS), the page loads infinite and nothing happen.
I can't access the server via SSH because not connect.
I tried everything suggested on forums and articles and nothing works.

My last nginx access log:

```<code>172.31.47.107 - - [07/Jul/2017:21:48:19 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.25.106 - - [07/Jul/2017:21:48:20 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.47.107 - - [07/Jul/2017:21:50:49 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.25.106 - - [07/Jul/2017:21:50:49 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.47.107 - - [07/Jul/2017:21:51:05 -0300] "GET / HTTP/1.1" 502 54 "-" "ELB-HealthChecker/1.0"
172.31.25.106 - - [07/Jul/2017:21:51:13 -0300] "GET / HTTP/1.1" 502 54 "-" "ELB-HealthChecker/1.0"
</code>```

My health check config:

Response Timeout: 5

Interval: 30

Unhealthy threshold: 2

Healthy threshold: 10

More ELB info:

Idle timeout: 600 (was 60)

The maximum latency before down: 4616

When I access the site (Load Balancer), I got the error: HTTP ERROR 503

I rebooted the instance 3 times.

System Information: Linux with Nginx and Passenger

I apreciate any information.
Thanks!

答: If you can't ssh to this ec2 instance, it appears the instance if failing reachability check. Click on the instance status checks tab and ensure the instance passes both instance and system status check. If it doesn't then stop the instance (not reboot) and start it up again. This will migrate your ec2 instance to a healthy host

Body:
My host is unhealthy for 1 hour and when I access my site using the instance public IP (not ELB DNS), the page loads infinite and nothing happen.
I can't access the server via SSH because not connect.
I tried everything suggested on forums and articles and nothing works.

My last nginx access log:

172.31.47.107 - - [07/Jul/2017:21:48:19 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.25.106 - - [07/Jul/2017:21:48:20 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.47.107 - - [07/Jul/2017:21:50:49 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.25.106 - - [07/Jul/2017:21:50:49 -0300] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/1.0"
172.31.47.107 - - [07/Jul/2017:21:51:05 -0300] "GET / HTTP/1.1" 502 54 "-" "ELB-HealthChecker/1.0"
172.31.25.106 - - [07/Jul/2017:21:51:13 -0300] "GET / HTTP/1.1" 502 54 "-" "ELB-HealthChecker/1.0"

My health check config:

Response Timeout: 5

Interval: 30

Unhealthy threshold: 2

Healthy threshold: 10

More ELB info:

Idle timeout: 600 (was 60)

The maximum latency before down: 4616

When I access the site (Load Balancer), I got the error: HTTP ERROR 503

I rebooted the instance 3 times.

System Information: Linux with Nginx and Passenger

I apreciate any information.
Thanks!


来源: stackexchange

问:
'Linker command failed with exit code 1' when using Google Analytics via CocoaPods
I'm trying to add Google Analytics to an iOS app written in Swift. I've followed the guide that adds the frameworks via CocoaPods and added a bridging header but I'm still getting:

```<code>Linker command failed with exit code 1
</code>```

My podfile does have use_frameworks! so I'm wondering if that has anything to do with it... there is no additional information on the Analytics site from what I can see.

EDIT:
I've noticed that after viewing the full error message the following is displayed:

```<code>ld: '/Users/simon/Programming/VenueNow/Pods/GoogleUtilities/Libraries/libGTM_NSData+zlib.a(GTMNSData+zlib.o)' does not contain bitcode.
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
</code>```

And searching for that issue brings up that Google updated to support bit code but hadn't updated the cocoa pods framework at that time.

答:
Try to remove any trace of cocoapods pods using pod deintegrate then
Run pod install

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to add Google Analytics to an iOS app written in Swift. I've followed the guide that adds the frameworks via CocoaPods and added a bridging header but I'm still getting:

Linker command failed with exit code 1

My podfile does have use_frameworks! so I'm wondering if that has anything to do with it... there is no additional information on the Analytics site from what I can see.

EDIT:
I've noticed that after viewing the full error message the following is displayed:

ld: '/Users/simon/Programming/VenueNow/Pods/GoogleUtilities/Libraries/libGTM_NSData+zlib.a(GTMNSData+zlib.o)' does not contain bitcode.
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

And searching for that issue brings up that Google updated to support bit code but hadn't updated the cocoa pods framework at that time.


问:
Deleting duplicate values occurring more than one time in Pandas dataframe
Please tell me how to get the ImgFileNames whose HashCodes occur more than one time in Python. Note: To retain only the first occurrence and delete the remaining even if the value occurs in-between or last or anywhere.

I have a data frame like below :

```<code>ImgFileName         HashCodes
Img_0001 - Copy.tif 162a47470f021a60
Img_0001.tif        162a47470f021a60
Img_0002.tif        1b5b5b1aa638dac8
Img_0003.tif        adadadadadadadad
Img_0004.tif        adadadadadadadad
Img_0005 - Copy.tif a5b8648c8c666670
Img_0005.tif        a5b8648c8c666670
Img_0006.tif        71b392da6a699392
Img_0007.tif        71b392da6a699392
Img_0008.tif        b1b1f2fa6bf97292
Img_0009.tif        86e82ae4c8b6c9c9
Img_0010 - Copy.tif 86e8aae4c8b6c9c9
Img_0010.tif        86e8aae4c8b6c9c9
</code>```

And I want the output as below:

```<code>ImgFileName         HashCodes
Img_0001 - Copy.tif 162a47470f021a60
Img_0003.tif        adadadadadadadad
Img_0005 - Copy.tif a5b8648c8c666670
Img_0006.tif        71b392da6a699392
Img_0009.tif        86e82ae4c8b6c9c9
</code>```

答:
You need boolean indexing with duplicated - first filter all dupes and second filter last value of dupe or first value of dupe (keep='last'):

```<code>df =df[ df.duplicated('HashCodes', keep=False) & df.duplicated('HashCodes')]
print (df)
     ImgFileName         HashCodes
1   Img_0001.tif  162a47470f021a60
4   Img_0004.tif  adadadadadadadad
6   Img_0005.tif  a5b8648c8c666670
8   Img_0007.tif  71b392da6a699392
12  Img_0010.tif  86e8aae4c8b6c9c9
</code>```

Or:

```<code>df =df[ df.duplicated('HashCodes', keep=False) & df.duplicated('HashCodes', keep='last')]
print (df)
           ImgFileName         HashCodes
0   Img_0001 -Copy.tif  162a47470f021a60
3         Img_0003.tif  adadadadadadadad
5   Img_0005 -Copy.tif  a5b8648c8c666670
7         Img_0006.tif  71b392da6a699392
11  Img_0010 -Copy.tif  86e8aae4c8b6c9c9
</code>```

Body:
Please tell me how to get the ImgFileNames whose HashCodes occur more than one time in Python. Note: To retain only the first occurrence and delete the remaining even if the value occurs in-between or last or anywhere.

I have a data frame like below :

ImgFileName         HashCodes
Img_0001 - Copy.tif 162a47470f021a60
Img_0001.tif        162a47470f021a60
Img_0002.tif        1b5b5b1aa638dac8
Img_0003.tif        adadadadadadadad
Img_0004.tif        adadadadadadadad
Img_0005 - Copy.tif a5b8648c8c666670
Img_0005.tif        a5b8648c8c666670
Img_0006.tif        71b392da6a699392
Img_0007.tif        71b392da6a699392
Img_0008.tif        b1b1f2fa6bf97292
Img_0009.tif        86e82ae4c8b6c9c9
Img_0010 - Copy.tif 86e8aae4c8b6c9c9
Img_0010.tif        86e8aae4c8b6c9c9

And I want the output as below:

ImgFileName         HashCodes
Img_0001 - Copy.tif 162a47470f021a60
Img_0003.tif        adadadadadadadad
Img_0005 - Copy.tif a5b8648c8c666670
Img_0006.tif        71b392da6a699392
Img_0009.tif        86e82ae4c8b6c9c9

Body:
You need boolean indexing with duplicated - first filter all dupes and second filter last value of dupe or first value of dupe (keep='last'):

df =df[ df.duplicated('HashCodes', keep=False) & df.duplicated('HashCodes')]
print (df)
     ImgFileName         HashCodes
1   Img_0001.tif  162a47470f021a60
4   Img_0004.tif  adadadadadadadad
6   Img_0005.tif  a5b8648c8c666670
8   Img_0007.tif  71b392da6a699392
12  Img_0010.tif  86e8aae4c8b6c9c9

Or:

df =df[ df.duplicated('HashCodes', keep=False) & df.duplicated('HashCodes', keep='last')]
print (df)
           ImgFileName         HashCodes
0   Img_0001 -Copy.tif  162a47470f021a60
3         Img_0003.tif  adadadadadadadad
5   Img_0005 -Copy.tif  a5b8648c8c666670
7         Img_0006.tif  71b392da6a699392
11  Img_0010 -Copy.tif  86e8aae4c8b6c9c9


问:
Derived class initialization with parameter of another derived class
I am new in Abstract classes so please excuse any ignorant mistakes

The exercise is given from my school, so the main.cpp file is to be used, almost as it is

I am trying to create a simple calculator in Eclipse using C++11

There exists a simple Abstract class with two virtual methods.

The two derived classes are simply the "Result" and the "Const" classes.
This is the header file of the Abstract class called

Expression.h

```<code>class Expression
{
public:
    Expression();
    virtual ~Expression();
   //methods
};
</code>```

Following is the source file of Expression

Expression.cpp

```<code>#include "expression.h"
#include <iostream>

Expression::Expression(){}
Expression::~Expression(){}
</code>```

Then I have created two classes called Const and Result

Const.h

```<code>#include <iostream>
#include "expression.h"

class  Const : public Expression
{
public:
    Const(int value);
    //inherited methods
private:
    int value;
};
</code>```

and the source file

Const.cpp

```<code>#include "expression.h"
#include "Const.h"

Const::Const(int x)
{
    value=x;
};

//inherited methods
</code>```

Result.h

```<code>#include <iostream>
#include "expression.h"
#include "Const.h"

class  Result : public Expression
{
public:
    Result(Const& c);
    //inherited methods
private:
    double value;
};
</code>```

Result.cpp

```<code>#include "expression.h"
#include "Result.h"
Result::Result(Const& c)
{
    value=c.point;
};
//inherited methods
</code>```

So what i need is to understand

main.cpp

```<code>#include <iostream>
#include "expression.h"
#include "const.h"
#include "result.h"
void testResult()
{
    Result  res (new Const(4));
    //Here an inherited method will be used to print the contents of object res
}
int main()
{
    testResult();
    return 0;
}
</code>```

The problem i can't solve is the line

```<code>Result res (new Const(4));
</code>```

The error i get is

Conversion from 'Const* to non-scalar type 'Result' requested

The thing is that what is described in this line should be used as it is, and i can't seem to find exactly what it is.

EDIT

The question as asked firstly was apparently misleading due to my fault, tried to fix the question so as to describe exactly my problem

答:
You started correctly, by creating a common base class for both Const and Result, but then completely ignored it.
All your problems are indeed in this line:

```<code>Result  res = (new Const(4));
</code>```

First of all, operator new in C++ returns a pointer, not a reference. Also, this would be a good place to make use of your base class:

```<code>Expression* res = new Const(4);
</code>```

Since you declared methods evaluate() and print() as virtual, the object res is pointing to will be correctly resolved as an instance of Const when you call res->print() or res->evaluate().

This will use Const version of print(). If you want to use the Result version - abstract classes won't help you here, you need to use casting. Create your own operator=(Const &) in Result or operator Result() in Const.

Body:
I am new in Abstract classes so please excuse any ignorant mistakes

The exercise is given from my school, so the main.cpp file is to be used, almost as it is

I am trying to create a simple calculator in Eclipse using C++11

There exists a simple Abstract class with two virtual methods.

The two derived classes are simply the "Result" and the "Const" classes.
This is the header file of the Abstract class called

Expression.h

class Expression
{
public:
    Expression();
    virtual ~Expression();
   //methods
};

Following is the source file of Expression

Expression.cpp

#include "expression.h"
#include <iostream>

Expression::Expression(){}
Expression::~Expression(){}

Then I have created two classes called Const and Result

Const.h

#include <iostream>
#include "expression.h"

class  Const : public Expression
{
public:
    Const(int value);
    //inherited methods
private:
    int value;
};

and the source file

Const.cpp

#include "expression.h"
#include "Const.h"

Const::Const(int x)
{
    value=x;
};

//inherited methods

Result.h

#include <iostream>
#include "expression.h"
#include "Const.h"

class  Result : public Expression
{
public:
    Result(Const& c);
    //inherited methods
private:
    double value;
};

Result.cpp

#include "expression.h"
#include "Result.h"
Result::Result(Const& c)
{
    value=c.point;
};
//inherited methods

So what i need is to understand

main.cpp

#include <iostream>
#include "expression.h"
#include "const.h"
#include "result.h"
void testResult()
{
    Result  res (new Const(4));
    //Here an inherited method will be used to print the contents of object res
}
int main()
{
    testResult();
    return 0;
}

The problem i can't solve is the line

Result res (new Const(4));

The error i get is

Conversion from 'Const* to non-scalar type 'Result' requested

The thing is that what is described in this line should be used as it is, and i can't seem to find exactly what it is.

EDIT

The question as asked firstly was apparently misleading due to my fault, tried to fix the question so as to describe exactly my problem

Body:
You started correctly, by creating a common base class for both Const and Result, but then completely ignored it.
All your problems are indeed in this line:

Result  res = (new Const(4));

First of all, operator new in C++ returns a pointer, not a reference. Also, this would be a good place to make use of your base class:

Expression* res = new Const(4);

Since you declared methods evaluate() and print() as virtual, the object res is pointing to will be correctly resolved as an instance of Const when you call res->print() or res->evaluate().

This will use Const version of print(). If you want to use the Result version - abstract classes won't help you here, you need to use casting. Create your own operator=(Const &) in Result or operator Result() in Const.


问:
anaconda installing numpy/pandas/matplotlib error
first post here, so I'm going to try to be as thorough as possible.

I'm trying to install numpy/matplotlib/pandas for a project. First time trying to use them. I'm following the steps of a tutorial, so I can't vary from that too much (have to use anaconda). I'm using mac OS Sierra 10.12.5

What I've done:
installed python 3, anaconda, and create and initialize a virtual environment using Anaconda. I then type:

conda install numpy pandas matplotlib

The terminal then tells me what new packages will be installed, I proceed. A few are installed successfully, and then I get this error:

CondaError: CondaHTTPError: HTTP None None for url https://repo.continuum.io/pkgs/free/osx-64/mkl-2017.0.3-0.tar.bz2
Elapsed: None

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

I thought this might be a connection issue, as I'm in China, but I've tried multiple times both using and not using a VPN. This problem is really stopping me in my tracks, any ideas?

答:
Have you tried using the pip installer, or installing using the Anaconda navigator? To install using pip, after creating the virtual environment, open a terminal console, and type

```<code>source activate [name of virtual environment]
pip install numpy
pip install matplotlib
pip install pandas
</code>```

Pip is included in the base anaconda installation, so this should work. If your Anaconda installation included the Anaconda Navigator, you can also install these modules through the GUI, by opening the Anaconda Navigator, clicking on the environments tab, selecting the virtual environment, searching for module in the search bar (make sure you select All and not Installed in the dropdown menu next to it), and then selecting the desired modules and clicking the apply button (this is an example).

Body:
Have you tried using the pip installer, or installing using the Anaconda navigator? To install using pip, after creating the virtual environment, open a terminal console, and type

source activate [name of virtual environment]
pip install numpy
pip install matplotlib
pip install pandas

Pip is included in the base anaconda installation, so this should work. If your Anaconda installation included the Anaconda Navigator, you can also install these modules through the GUI, by opening the Anaconda Navigator, clicking on the environments tab, selecting the virtual environment, searching for module in the search bar (make sure you select All and not Installed in the dropdown menu next to it), and then selecting the desired modules and clicking the apply button (this is an example).


问:
Wait for function to execute first before moving to next line of code
I am using CloudKit in my app and facing problem showing data in table view. In viewDidLoad() I am fetching data from CloudKit database.

Then in table view functions I do CKRecord object count for number of rows.

But count returns 0 to table view and after few seconds returns number of row. Because of this table view does not show the results.

```<code>override func viewDidLoad() {
    super.viewDidLoad()
    loadNewData()
}

func loadNewData() {
    self.loadData = [CKRecord]()
    let publicData = CKContainer.default().publicCloudDatabase
    let qry = CKQuery(recordType: "Transactions", predicate: NSPredicate(format: "TRUEPREDICATE", argumentArray: nil))
    qry.sortDescriptors = [NSSortDescriptor(key: "Transaction_ID", ascending: true)]
    publicData.perform(qry, inZoneWith: nil) { (results, error) in
        if let rcds = results {
            self.loadData = rcds
        }
        if error != nil {
            self.showAlert(msg: (error?.localizedDescription)!)
        }
    }
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return loadData.count
}

func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell2", for: indexPath) as! ViewAllTransactionsTVCell

    let pn = loadData[indexPath.row].value(forKey: "Party_Name") as! String
    let amt = loadData[indexPath.row].value(forKey: "Amount") as! String
    let nrt = loadData[indexPath.row].value(forKey: "Narattions") as! String
    let dt = loadData[indexPath.row].value(forKey: "Trans_Date") as! String

    cell.partyNameLabel.text = pn
    cell.dateLabel.text = dt
    cell.narationLabel.text = nrt
    cell.amountLabel.text = amt

    return cell
}
</code>```

答:
You shouldn't wait, but instead trigger the reloading of the data when the perform completion handler is called:

```<code>publicData.perform(qry, inZoneWith: nil) { (results, error) in
    if let rcds = results {
        DispatchQueue.main.async {
            self.loadData = rcds
            self.tableView.reloadData()
        }
    }
    if error != nil {
        self.showAlert(msg: (error?.localizedDescription)!)
    }
}
</code>```

Note, I'm dispatching the reload process to the main queue, because you're not guaranteed to have this run on the main thread. As the documentation says:

Your block must be capable of running on any thread of the app ...

And because UI updates must happen on the main thread (and because you want to synchronize your access to loadData), just dispatch this to the main queue, like above.

Body:
I am using CloudKit in my app and facing problem showing data in table view. In viewDidLoad() I am fetching data from CloudKit database.

Then in table view functions I do CKRecord object count for number of rows.

But count returns 0 to table view and after few seconds returns number of row. Because of this table view does not show the results.

override func viewDidLoad() {
    super.viewDidLoad()
    loadNewData()
}

func loadNewData() {
    self.loadData = [CKRecord]()
    let publicData = CKContainer.default().publicCloudDatabase
    let qry = CKQuery(recordType: "Transactions", predicate: NSPredicate(format: "TRUEPREDICATE", argumentArray: nil))
    qry.sortDescriptors = [NSSortDescriptor(key: "Transaction_ID", ascending: true)]
    publicData.perform(qry, inZoneWith: nil) { (results, error) in
        if let rcds = results {
            self.loadData = rcds
        }
        if error != nil {
            self.showAlert(msg: (error?.localizedDescription)!)
        }
    }
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return loadData.count
}

func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell2", for: indexPath) as! ViewAllTransactionsTVCell

    let pn = loadData[indexPath.row].value(forKey: "Party_Name") as! String
    let amt = loadData[indexPath.row].value(forKey: "Amount") as! String
    let nrt = loadData[indexPath.row].value(forKey: "Narattions") as! String
    let dt = loadData[indexPath.row].value(forKey: "Trans_Date") as! String

    cell.partyNameLabel.text = pn
    cell.dateLabel.text = dt
    cell.narationLabel.text = nrt
    cell.amountLabel.text = amt

    return cell
}

Body:
You shouldn't wait, but instead trigger the reloading of the data when the perform completion handler is called:

publicData.perform(qry, inZoneWith: nil) { (results, error) in
    if let rcds = results {
        DispatchQueue.main.async {
            self.loadData = rcds
            self.tableView.reloadData()
        }
    }
    if error != nil {
        self.showAlert(msg: (error?.localizedDescription)!)
    }
}

Note, I'm dispatching the reload process to the main queue, because you're not guaranteed to have this run on the main thread. As the documentation says:

Your block must be capable of running on any thread of the app ...

And because UI updates must happen on the main thread (and because you want to synchronize your access to loadData), just dispatch this to the main queue, like above.


问:
pods file with multiple platforms for iOS
I want to combine 2 pods in my project. One is :

```<code>source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'DJKFlipper'
</code>```

and the other is:

```<code>platform :ios, '9.0'
pod 'HQPagerViewController', :git=> 'https://github.com/quangpc/HQPagerViewController.git', :branch=> 'master'
</code>```

The issue is that one is asking for platform 8.0 and other is 9.0

I tried changing the whole file platform to 8.0, but get the following error: Specs satisfying the HQPagerViewController (from https://github.com/quangpc/HQPagerViewController.git, branch master), HQPagerViewController (= 1.0) dependency were found, but they required a higher minimum deployment target.

And if keep the target to 9.0, I get above 100 issues in the app after installing pod, as the target platform is incorrect.

I also tried this:

```<code>target 'Bhaskar' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks

 platform :ios, ‘9.0’
  use_frameworks!

  pod 'HQPagerViewController', :git=> 'https://github.com/quangpc/HQPagerViewController.git', :branch=> 'master'

end

target 'Bhaskar - FlipView’ do
  source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'DJKFlipper'
end
</code>```

but getting an error here too. I have used pods maybe for the second time ever, and always worked with same platform. How can I combine these both?

Any help will be appreciated!
Thanks!

答: It's because your 'Deployment Target' in your project settings is lower than 9.0 (which is the minimum required by HQPagerViewController), so you'd have to change that to 9.0.

Body:
I want to combine 2 pods in my project. One is :

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'DJKFlipper'

and the other is:

platform :ios, '9.0'
pod 'HQPagerViewController', :git=> 'https://github.com/quangpc/HQPagerViewController.git', :branch=> 'master'

The issue is that one is asking for platform 8.0 and other is 9.0

I tried changing the whole file platform to 8.0, but get the following error: Specs satisfying the HQPagerViewController (from https://github.com/quangpc/HQPagerViewController.git, branch master), HQPagerViewController (= 1.0) dependency were found, but they required a higher minimum deployment target.

And if keep the target to 9.0, I get above 100 issues in the app after installing pod, as the target platform is incorrect.

I also tried this:

target 'Bhaskar' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks

 platform :ios, ‘9.0’
  use_frameworks!

  pod 'HQPagerViewController', :git=> 'https://github.com/quangpc/HQPagerViewController.git', :branch=> 'master'

end

target 'Bhaskar - FlipView’ do
  source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'DJKFlipper'
end

but getting an error here too. I have used pods maybe for the second time ever, and always worked with same platform. How can I combine these both?

Any help will be appreciated!
Thanks!


问:
C++ std::mutex lock() access violation in Visual Studio 2017
When I'm trying to run executable compiled using VS2017 I catch
Exception thrown at 0x00007FFF05BC1063 (msvcp140d.dll) in a.exe: 0xC0000005: Access violation reading location 0x0000000000000000. immediately after launching.

After debugging i figured out that it happens when I'm trying to lock static mutex _coutMutex. How can I fix it because when I have compiled using mingw it worked fine. Here is part of my code:

Game.hpp:

#include "Logger.hpp"

class Game
{
public:
    static Logger logger;
};
```

<p>Game.cpp:
</p>

<pre class="lang-cpp prettyprint-override"><code>#include "Game.hpp"

Logger Game::logger{ "logs/client", Logger::LoggingLevels::Info,
  Logger::LoggingLevels::Trace, 2, 100 };
</code>```

Logger.hpp:

#include <mutex>

class Logger
{
public:
    Logger(std::string path, short consoleLoggingLevel, short
      fileLoggingLevel, uint32_t count, size_t maxSize);

    enum LoggingLevels : short
    {
        Off = 0,
        Fatal = 1,
        Error = 2,
        Warn = 3,
        Info = 4,
        Debug = 5,
        Trace = 6
    };

void _addToQueue(std::string data);
private:
    static std::mutex _coutMutex;
};
```

<p>Logger.cpp:
</p>

<pre class="lang-cpp prettyprint-override"><code>std::mutex Logger::_coutMutex;

Logger::Logger(std::string path, short consoleLoggingLevel,
   short fileLoggingLevel, uint32_t count, size_t maxSize)
{
    _addToQueue("dd/mm/yyyy hh:mm:ss.sss\n");
}

void Logger::_addToQueue(std::string data)
{
    _coutMutex.lock();
    std::cout << data;
    _coutMutex.unlock();
}
</code>```

main.cpp:

#include "Logger.hpp"
#include "Game.hpp"

int main()
{
    Game game;
}
```

答:
As Richard Critten suggests, this must be the global initialisation order problem.

You have 2 global variables, logger and _coutMutex, and these are in a different compilation unit. The order which they are initialized is not defined.

When Logger's constructor runs, _coutMutex is not initialized yet, but _addToQueue wants to use it.

You could have three solutions:

Avoid using global objects. Or avoid using global constructors which do something serious (if you remove _addToQueue from logger constructor, it will work).

put these global variables into one compilation unit, in correct order

add an accessor function for _coutMutex, and define mutex inside of it (as a static variable). Beware of this solution, as it has its drawbacks (speed, thread safety)

Body:
When I'm trying to run executable compiled using VS2017 I catch
Exception thrown at 0x00007FFF05BC1063 (msvcp140d.dll) in a.exe: 0xC0000005: Access violation reading location 0x0000000000000000. immediately after launching.

After debugging i figured out that it happens when I'm trying to lock static mutex _coutMutex. How can I fix it because when I have compiled using mingw it worked fine. Here is part of my code:

Game.hpp:

#include "Logger.hpp"

class Game
{
public:
    static Logger logger;
};

Game.cpp:

#include "Game.hpp"

Logger Game::logger{ "logs/client", Logger::LoggingLevels::Info,
  Logger::LoggingLevels::Trace, 2, 100 };

Logger.hpp:

#include <mutex>

class Logger
{
public:
    Logger(std::string path, short consoleLoggingLevel, short
      fileLoggingLevel, uint32_t count, size_t maxSize);

    enum LoggingLevels : short
    {
        Off = 0,
        Fatal = 1,
        Error = 2,
        Warn = 3,
        Info = 4,
        Debug = 5,
        Trace = 6
    };

void _addToQueue(std::string data);
private:
    static std::mutex _coutMutex;
};

Logger.cpp:

std::mutex Logger::_coutMutex;

Logger::Logger(std::string path, short consoleLoggingLevel,
   short fileLoggingLevel, uint32_t count, size_t maxSize)
{
    _addToQueue("dd/mm/yyyy hh:mm:ss.sss\n");
}

void Logger::_addToQueue(std::string data)
{
    _coutMutex.lock();
    std::cout << data;
    _coutMutex.unlock();
}

main.cpp:

#include "Logger.hpp"
#include "Game.hpp"

int main()
{
    Game game;
}


问:
javax.servlet.ServletException: org.apache.jasper.JasperException: Unable to compile class for JSP
While trying to run my sample project, I am getting below error:</p>
```<code>HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 23 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

root cause

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 23 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:95)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:139)
    org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs.
</code>```

答:
This is possible error of placing your jar files at right place.

refer this

Also

refer this too

ContentLicense: CC BY-SA 4.0

Body:
While trying to run my sample project, I am getting below error:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 23 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

root cause

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 23 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:95)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:139)
    org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs.


问:
Is there a risk of injection using mail function
Hi
I'm developing a contact form. I'm using the mail function to email it over to the webmaster.

Is there a risk someone could inject malicious javascript and any other injection attack?

```<code>$to = (this is from config xml file)
$message = $_POST['message'];
mail($to ,'feedback',$message);
</code>```

答:
If registers globals are ON (which should NOT be) there is a (huge) risk of injection (depending on where $to is really set).

Also as David pointed out you could sanitize $_POST['message'] if you use HTML messages (maybe with htmlspecialchars).

ContentLicense: CC BY-SA 2.5

Body:
Hi
I'm developing a contact form. I'm using the mail function to email it over to the webmaster.

Is there a risk someone could inject malicious javascript and any other injection attack?

$to = (this is from config xml file)
$message = $_POST['message'];
mail($to ,'feedback',$message);


答:
Class Result and Const are two different classes. This means the type conversion

```<code>Result *res = (new Const(4));
</code>```

is not possible. To do what you want, since both classes inherit from Expression, do:

```<code>  Expression * res = new Result( objConst);
</code>```

Where objConst is a Const object.

Title: Derived class initialization with parameter of another derived class

Body:
Class Result and Const are two different classes. This means the type conversion

Result *res = (new Const(4));

is not possible. To do what you want, since both classes inherit from Expression, do:

  Expression * res = new Result( objConst);

Where objConst is a Const object.


问:
How do I keep a reference when using nested views in AngularJS?
I have 4 pages.

2 pages in English and 2 pages in French.

Here are the 4 options :

EN > Page1 - Content: Computer

EN > Page2 - Content: Keyboard

FR > Page1 - Content: Ordinateur

FR > Page2 - Content: Clavier

How do switch a nested view for its equivalent?

I have put together a plnkr.

https://embed.plnkr.co/SZPp0C8guVeTtcLeWJ3T/

Any help is appreciated! Thanks!

Expected Behaviour. When I click on "Francais", say I am on /en/page1/, I want it to properly re-route to, in this case, /fr/page1.

Actual Behaviour. When I click on "Francais", say I am on /en/page1/, it re-routes me to /fr and I don't know how to approach the problem at hand.

答:
I forked a new plunker and updated it. The challenge was to watch the scope of the route provider to see what prior values existed. Looking at the current state and name you can conditionally control in the controller which view is persisted. to do this I created a new function:

```<code>  //evaluate routes
  let checkRouteValues = (oldVal, newVal)=>{
    $scope.vm.message1 = oldVal;
    $scope.vm.message2 = newVal;

    //first check to see if language has changed
    if(newVal === 'english'&& oldVal ==='francais.page1'){
     $state.go('english.page1');
    }else if(newVal === 'english' && oldVal ==='francais.page2'){
         $state.go('english.page2')
    }else if(newVal ==='francais' && oldVal === 'english.page1' ){
        $state.go('francais.page1');
    }else if (newVal ==='francais' && oldVal === 'english.page2' ){
      $state.go('francais.page2');
    }
  }
</code>```

Then added a watch to see when the state changed:

```<code> //added a watch to monitor the current state
  $scope.currState =$state;
  $scope.$watch('currState.current.name', function (newValue, oldValue){

     checkRouteValues(oldValue, newValue)
  });
</code>```

The function checkRouteValues() monitors the new and old values and then sets the state based upon the condition.
*caveat: I think this solution works for something small scale like this navigation here however if you had multiple pages I would look to go a different route.

updated plunker

I did add some logging in the html so you could see the values change
I did change the name of the app from theApp to app so be careful if you cpoy paste.

I did use arrow functions in the code if you don't like arrow functions you can convert it back to

```<code>let checkRouteValues = function(oldVal, newVal){...}
</code>```

I also used let declaration vs. var to isolate variable scope but you can use var as if you prefer.

And finally with my changes change the route english, page one, is always the default loaded route when your app starts but this should give you enough to get you going.

Body:
I forked a new plunker and updated it. The challenge was to watch the scope of the route provider to see what prior values existed. Looking at the current state and name you can conditionally control in the controller which view is persisted. to do this I created a new function:

  //evaluate routes
  let checkRouteValues = (oldVal, newVal)=>{
    $scope.vm.message1 = oldVal;
    $scope.vm.message2 = newVal;

    //first check to see if language has changed
    if(newVal === 'english'&& oldVal ==='francais.page1'){
     $state.go('english.page1');
    }else if(newVal === 'english' && oldVal ==='francais.page2'){
         $state.go('english.page2')
    }else if(newVal ==='francais' && oldVal === 'english.page1' ){
        $state.go('francais.page1');
    }else if (newVal ==='francais' && oldVal === 'english.page2' ){
      $state.go('francais.page2');
    }
  }

Then added a watch to see when the state changed:

 //added a watch to monitor the current state
  $scope.currState =$state;
  $scope.$watch('currState.current.name', function (newValue, oldValue){

     checkRouteValues(oldValue, newValue)
  });

The function checkRouteValues() monitors the new and old values and then sets the state based upon the condition.
*caveat: I think this solution works for something small scale like this navigation here however if you had multiple pages I would look to go a different route.

updated plunker

I did add some logging in the html so you could see the values change
I did change the name of the app from theApp to app so be careful if you cpoy paste.

I did use arrow functions in the code if you don't like arrow functions you can convert it back to

let checkRouteValues = function(oldVal, newVal){...}

I also used let declaration vs. var to isolate variable scope but you can use var as if you prefer.

And finally with my changes change the route english, page one, is always the default loaded route when your app starts but this should give you enough to get you going.


问:
Get a 24-bit screenshot with XCB-SHM
Is there any way to get a 24-bit BGR ZPixmap from xcb_shm_get_image? All I can seem to get are 32-bit BGRA images, and that alpha channel seems really unnecessary. Editing the bitmask to exclude the alpha doesn't work, it only sets it to zero.

答: Well, for convenience 32 bits are always used when dealing with 24 bit color spaces. A CPU is much more efficient at handling 4 bytes at a time... The 'wasted' alpha byte is a good tradeoff between efficiency and memory consumption. So just copy the data yourself, packing the RGB bytes into 3 bytes per pixel.</p>

Title: Get a 24-bit screenshot with XCB-SHM


问:
used arabic and persian in XWPFDocument
I want to convert word to pdf with arabic letters,
after a little R&D I decided to use

org.apache.poi.xwpf.converter.pdf.PdfConverter

but when I write below code , the final result is left to right , and the words  Are cluttered,for example for "سعید" result in pdf is "س ع ی د" my docx is very big And not one paragraph:

```<code>public class ConvertWord {
    public static void ConvertToPDF(String docPath, String pdfPath) {
        try {
            InputStream doc = new FileInputStream(new File(docPath));
            XWPFDocument document = new

            PdfOptions options = PdfOptions.create();
            options.fontEncoding("UTF-8")

            OutputStream out = new FileOutputStream(new File(pdfPath));

            PdfConverter.getInstance().convert(document,out,options);

        } catch (FileNotFoundException ex) {

        } catch (IOException ex) {

        }
    }

    public static void main(String[] args) {
        ConvertWord cwoWord=new ConvertWord();
        cwoWord.ConvertToPDF("D://" + "usc.docx","D://test12.pdf");

    }

   }
</code>```

答: This thread: Creating PDF document from Word document using java api, contains other libraries you could use. I dont think this library, you are using, will support the layout options; it is also contains many bugs and doesn't support tables, graphs, page numbers as mentioned here: https://github.com/opensagres/xdocreport/wiki/XWPFConverterPDFViaIText</p>

Title: used arabic and persian in XWPFDocument

Body:
I want to convert word to pdf with arabic letters,
after a little R&D I decided to use

org.apache.poi.xwpf.converter.pdf.PdfConverter

but when I write below code , the final result is left to right , and the words  Are cluttered,for example for "سعید" result in pdf is "س ع ی د" my docx is very big And not one paragraph:

public class ConvertWord {
    public static void ConvertToPDF(String docPath, String pdfPath) {
        try {
            InputStream doc = new FileInputStream(new File(docPath));
            XWPFDocument document = new

            PdfOptions options = PdfOptions.create();
            options.fontEncoding("UTF-8")

            OutputStream out = new FileOutputStream(new File(pdfPath));

            PdfConverter.getInstance().convert(document,out,options);

        } catch (FileNotFoundException ex) {

        } catch (IOException ex) {

        }
    }

    public static void main(String[] args) {
        ConvertWord cwoWord=new ConvertWord();
        cwoWord.ConvertToPDF("D://" + "usc.docx","D://test12.pdf");

    }

   }


问:
Design requires heading text to break into boostrap responsive column with background
I'm using a grid of rectangles to display content on a boostrap 3 responsive grid.

I need text to be like in the orange area in the mockup below (where it says category):

This represents one rectangle within a grid of other rectangles.

I also need a heading bottom right (secondary question).

I don't even know what to search for in Google - I tried a few things that returned nothing.

It steps both into the padding / margin / column of the grid.

Is this possible in a bootstrap 3 grid?

I need this to work in at least 99% of installed browsers. Ideally it will look the same on mobile responsive width too (just with the usual single column).

Thanks.

答:
I quickly designed this using this template for the gallery.

I wrote 3 classes, a heading, category and triangle class:

```<code>.heading {
  display: inline-block;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 5px;
  position: absolute;
  bottom: 30px;
  right: 35px;
  color: white;
}

.category {
  display: inline-block;
  background-color: #ff9800;
  padding: 5px;
  position: absolute;
  left: 5px;
  color: white;
}
.triangle {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 10px 16px 0;
  border-color: transparent #e65100 transparent transparent;
  left:5px;
  top: 55px;
}
</code>```

If you want to see the source of the whole website just click here

Desktop view:

Mobile view:

Body:
I quickly designed this using this template for the gallery.

I wrote 3 classes, a heading, category and triangle class:

.heading {
  display: inline-block;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 5px;
  position: absolute;
  bottom: 30px;
  right: 35px;
  color: white;
}

.category {
  display: inline-block;
  background-color: #ff9800;
  padding: 5px;
  position: absolute;
  left: 5px;
  color: white;
}
.triangle {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 10px 16px 0;
  border-color: transparent #e65100 transparent transparent;
  left:5px;
  top: 55px;
}

If you want to see the source of the whole website just click here

Desktop view:

Mobile view:


问:
Cloud Functions for Firebase: How to get the value of the data that was deleted
When I add a cloud function responding to a delete event, like this one:

exports.onDeleteSector = functions.database.ref('/sectores/{idSector}').onDelete((event) =>

I can get the key to the sector being deleted in event.params.idSector proving the trigger works, however, event.data.val() returns null.

The deleted record contains the references to the children to be deleted.  How can I get those before the parent is gone?

Thanks

答:
event.data.val() returns null, because that's the current value of the database at the time of the trigger.  For all kinds of database triggers, this is going to be the case.  For onDelete, this will always be null.

If you want to see what was previously at that location, before the event happened, take a look at event.data.previous.val().  Also see the docs for DeltaSnapshot, which is the data type for event.data.


答:
You mis understand floating point.

You get a max of about 14 digits as there is no more precision than. 2^52

The max number is a number that has three parts.

The sign, positive or negative and is 1 bit. Thus you get 0 and -0

The Fraction 52 bits that gives the precision of about 14 digits.

The exponent 11 bits and is a signed value that is the amount to multiply the Fraction value with. 2 ^ exponent

See wiki Double-precision_floating-point_format for more info.

Title: Get the exact decimal representation of a JavaScript number

Body:
Every finite number in JavaScript has an exact real value. For example:

const x = Number.MAX_VALUE

Here, x has the precise value of 21024 - 2971 =

179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368

and we can demonstrate this by using x in arithmetic:

console.log(x % 10000) // 8368

But how can I get all of those decimal digits?

I'd like it if the solution also worked for non-integers, for example const y = Number.EPSILON is precisely 2-52 =

0.0000000000000002220446049250313080847263336181640625


问:
How to display images from storage path?
How to display images from storage folder (outside public) ? I stored my image files in storage/cover but unable to display it to view.
My show method :

```<code>public function index() {
        $categories = Category::with('post')->orderBy('id', 'desc')->paginate(4);
        return view('dashboard/categories/index', compact('categories', $categories));
    }
</code>```

The view :

```<code><?php foreach ($categories as $cat): ?>
            <div class="col-xs-6 col-sm-4 col-md-3">
                <div class="blog-item">
                    <a href="{{ url('dashboard/categories/' . $cat->titleslug) }}" class="blog-img"><img src="{{asset('cover/'. $cat->cover)}}" class="img-responsive" alt=""/></a>
                </div><!-- blog-item -->
            </div><!-- col-xs-6 -->
        <?php endforeach; ?>
</code>```

That's all and thanks!

答:
The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to  storage/app/public

https://laravel.com/docs/5.4/filesystem#configuration

Then you'll be able to do something like this:

```<code><img src="{{ asset('storage/cover/'.$cat->cover) }}" ....
</code>```

Body:
How to display images from storage folder (outside public) ? I stored my image files in storage/cover but unable to display it to view.
My show method :

public function index() {
        $categories = Category::with('post')->orderBy('id', 'desc')->paginate(4);
        return view('dashboard/categories/index', compact('categories', $categories));
    }

The view :

<?php foreach ($categories as $cat): ?>

                    titleslug) }}" class="blog-img">cover)}}" class="img-responsive" alt=""/>

        <?php endforeach; ?>

That's all and thanks!

Body:
The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to  storage/app/public

https://laravel.com/docs/5.4/filesystem#configuration

Then you'll be able to do something like this:

<img src="{{ asset('storage/cover/'.$cat->cover) }}" ....


问:
Does Android theme-color and favicon work with https?
In Chrome for Android on Lollipop, you can set a meta theme-color tag and favicon: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android?hl=en

My code:

```<code><link rel="icon" sizes="192x192" href="//static.rizzo.co.uk/images/favicon_192.png">

<meta name="theme-color" content="#95c676">
</code>```

This works for me on parts of the site that are http but as soon as it goes to https it loses the theme-color and favicon for the rest of the session.

I have tried the theme-color and favicon separately but can get neither to work with https.  The favicon is available on https as well as http.  Has anyone used these successfully with https or had a similar problem?

答:
I thought I had the same issue, turns out it was a caching problem that somehow was fixed when I used android remote debugging (caching only the head tag?).

Anyway, it should work. You can try copy pasting the html in this page to your https server: http://useragentman.com/tests/theme-color/?test

or attach the following script (from useragentman, in case page is down):

```<code><script>
    var $themeColor = document.querySelector("meta[name='theme-color']");
    function startAnim() {
        if ($themeColor.content === '#ff0000') {
            $themeColor.content = '#ffffff';
        } else {
            $themeColor.content = '#ff0000';
        }
        setTimeout(startAnim, 500);
    }
    startAnim();
</script>
</code>```

Body:
In Chrome for Android on Lollipop, you can set a meta theme-color tag and favicon: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android?hl=en

My code:

<link rel="icon" sizes="192x192" href="//static.rizzo.co.uk/images/favicon_192.png">

<meta name="theme-color" content="#95c676">

This works for me on parts of the site that are http but as soon as it goes to https it loses the theme-color and favicon for the rest of the session.

I have tried the theme-color and favicon separately but can get neither to work with https.  The favicon is available on https as well as http.  Has anyone used these successfully with https or had a similar problem?

Body:
I thought I had the same issue, turns out it was a caching problem that somehow was fixed when I used android remote debugging (caching only the head tag?).

Anyway, it should work. You can try copy pasting the html in this page to your https server: http://useragentman.com/tests/theme-color/?test

or attach the following script (from useragentman, in case page is down):

<script>
    var $themeColor = document.querySelector("meta[name='theme-color']");
    function startAnim() {
        if ($themeColor.content === '#ff0000') {
            $themeColor.content = '#ffffff';
        } else {
            $themeColor.content = '#ff0000';
        }
        setTimeout(startAnim, 500);
    }
    startAnim();
</script>


问:
Get params inside a Ruby gem
It there a way to read the params inside a class of a gem
I tried require "cgi" and require "action_pack" but no chance...
Any clues ?

Thanx

答:
Be more precise.  The params of what?  A submitted form?

If yes, you could do that:

```<code>require "cgi"

...

cgi = CGI.new
h = cgi.params

login = h['login'][0]
password = h['password'][0]
</code>```

and so on.

OwnerDisplayName: PanosJee

Title: Get params inside a Ruby gem

Body:
Be more precise.  The params of what?  A submitted form?

If yes, you could do that:

require "cgi"

...

cgi = CGI.new
h = cgi.params

login = h['login'][0]
password = h['password'][0]

and so on.

OwnerDisplayName: Keltia


问:
SOAP exception : axis2ns2:selectionFailure
im getting an unknown exception when doing a request to a webservice:

```<code>axis2ns2:selectionFailure
</code>```

Anyone know what the problem is ?

Edit: detailed error:

```<code>{"Message":"axis2ns5:selectionFailure","StackTrace":"   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)\r\n   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)\r\n
</code>```

答: This problem occurs when there is an error with the xml namespace.</p>

Body:
im getting an unknown exception when doing a request to a webservice:

axis2ns2:selectionFailure

Anyone know what the problem is ?

Edit: detailed error:

{"Message":"axis2ns5:selectionFailure","StackTrace":"   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)\r\n   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)\r\n


问:
RabbitMQ direct exchange queue not created
I am trying to send message through direct exchange. I have not declared the queue as mentioned in the official page tutorial. Below is my code:

```<code>import sys
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))  # Connect to AMQP

def setup():
        channel = connection.channel()
        channel.exchange_declare(exchange='direct_logs', type='direct')
        return channel

def log_emitter(message, severity):
        channel = setup()
        channel.basic_publish(exchange='direct_logs',
                      routing_key=severity,
                      body=message)

def logger():
        severity = sys.argv[1] if len(sys.argv) > 2 else 'info'
        print severity
        exit = 'N'
        message = ' '.join(sys.argv[2:]) or "Hello World!"
        log_emitter(message, severity)
        print(" [x] Sent %r:%r" % (severity, message))
    connection.close()

logger()
</code>```

I am executing with

```<code>python direct_log_publisher.py info "Info testing"
</code>```

It is creating the direct_logs exchange but I cannot see any "info" queue is created in the admin console. As per my understanding no queue binding is required at publisher side.
Thanks in advance.

答: Why would you want the queue to be created automatically? Since you don't bind a queue anywhere, the message is dropped basically (because it has nowhere to go). Either your consumer or your producer have to declare and bind the queue to the exchange (depending on what makes sense to you).</p>

Body:
I am trying to send message through direct exchange. I have not declared the queue as mentioned in the official page tutorial. Below is my code:

import sys
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))  # Connect to AMQP

def setup():
        channel = connection.channel()
        channel.exchange_declare(exchange='direct_logs', type='direct')
        return channel

def log_emitter(message, severity):
        channel = setup()
        channel.basic_publish(exchange='direct_logs',
                      routing_key=severity,
                      body=message)

def logger():
        severity = sys.argv[1] if len(sys.argv) > 2 else 'info'
        print severity
        exit = 'N'
        message = ' '.join(sys.argv[2:]) or "Hello World!"
        log_emitter(message, severity)
        print(" [x] Sent %r:%r" % (severity, message))
    connection.close()

logger()

I am executing with

python direct_log_publisher.py info "Info testing"

It is creating the direct_logs exchange but I cannot see any "info" queue is created in the admin console. As per my understanding no queue binding is required at publisher side.
Thanks in advance.


问:
ScriptError: The script completed but the returned value is not a supported return type
So I have been experimenting with Google Apps Script and the Charts API all day, and have gotten nowhere, unfortunately.

I did many things - including following Mogsdad's well-written tutorial here. Here's the code I have so far - including from that tutorial, but I keep getting an error saying the script has completed but returned a different type from what is accepted, or something of the like.

Dashboard-Code.gs:

```<code>/**
 * Serves HTML of the application for HTTP GET requests.
 * From gist.github.com/mogsdad/24518dff348ad14d3929
 *
 * @param {Object} e event parameter that can contain information
 *     about any URL parameters provided.
 */
function doGet(e) {
  var template = HtmlService.createTemplateFromFile('Index');

  // Build and return HTML in IFRAME sandbox mode.
  return template.evaluate()
      .setTitle('Dashboard demo')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

/**
 * Return all data from first spreadsheet as an array. Can be used
 * via google.script.run to get data without requiring publication
 * of spreadsheet.
 * From gist.github.com/mogsdad/24518dff348ad14d3929
 *
 * Returns null if spreadsheet does not contain more than one row.
 */
function getSpreadsheetData() {
  // This does not work, see https://code.google.com/p/google-apps-script-issues/issues/detail?id=5233
//  var ss = SpreadsheetApp.getActiveSpreadsheet();
//  var data = ss.getSheets()[0].getDataRange().getValues();
  var sheetId = '1-EE_WDD6QYi257_utUf_D0v5e9Gf8Lj5tETPqqllvxk';  // Replace with your spreadsheet ID. (Ick.)
  var data = SpreadsheetApp.openById(sheetId).getSheets()[0].getDataRange().getValues();
  return (data.length > 1) ? data : null;
}
</code>```

Index.html:

```<code><!-- Use a templated HTML printing scriptlet to import common

stylesheet. -->
<?!= HtmlService.createHtmlOutputFromFile('Stylesheet').getContent(); ?>
<html>
  <body>
    <h1 id="main-heading">Loading...</h1>
    <div id="dashboard-div">
      <div id="control-div">
        <div id="selector-div">
        </div>
        <div id="selector1-div">
        </div>
      </div>
      <div id="charts-div">

        <div id="table-div">
        </div>
      </div>
    </div>
    <div class="hidden" id="error-message">
    </div>
  </body>
</html>

<!-- Store data passed to template here, so it is available to the
     imported JavaScript. -->
<script>
</script>

<!-- Use a templated HTML printing scriptlet to import JavaScript. -->
<?!= HtmlService.createHtmlOutputFromFile('JavaScript').getContent(); ?>
</code>```

and JavaScript.html (I decided to stick to what Mogsdad was saying):

```<code><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript"  src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
    google.charts.load('45', {packages: ['corechart']});
    google.charts.setOnLoadCallback(drawChart);
</script>
<script>
  // Load the Visualization API and desired package(s).
  google.load('visualization', '1.0', {'packages':['controls']});
  /**
   * Run initializations on dialog load.
   */
  $(function() {
    // Set a callback to run when the Google Visualization API is loaded.
    // Note: could also be accomplished via google.load options.
    google.setOnLoadCallback(sendQuery);
    // Assign handler functions to dialog elements here, if needed.
    // Call the server here to retrieve any information needed to build
    // the dialog, if necessary.
  });
  /**
   * Issue asynchronous request for spreadsheet data.
   * From gist.github.com/mogsdad/60dcc4116ed74fceb5f9
   */
  function sendQuery() {
    google.script.run
      .withSuccessHandler(drawDashboard)
      .withFailureHandler(function(msg) {
            // Respond to failure conditions here.
            $('#main-heading').text(msg);
            $('#main-heading').addClass("error");
            $('#error-message').show();
          })
      .getSpreadsheetData();
  }
  /**
   * Callback function to generate visualization using data in response parameter.
   * From gist.github.com/mogsdad/60dcc4116ed74fceb5f9
   *
   * @param {Object[][]}  Two-Dim array of visualization data
   */
  function drawDashboard(response) {
    $('#main-heading').addClass("hidden");
    if (response == null) {
      alert('Error: Invalid source data.')
      return;
    }
    else {
      // Transmogrify spreadsheet contents (array) to a DataTable object
      var data = google.visualization.arrayToDataTable(response,false);
      var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard-div'));

      var table = new google.visualization.ChartWrapper({
        'chartType': 'Table',
        'containerId': 'table-div'
      });

      var categoryPicker = new google.visualization.ControlWrapper({
        'controlType': 'CategoryFilter',
        'containerId': 'selector-div',
        'options': {
          'filterColumnLabel': 'Category'
        }
      });

      var subCategoryPicker = new google.visualization.ControlWrapper({
      'controlType': 'CategoryFilter',
      'containerId': 'selector1-div',
      'options': {
      'filterColumnLabel': 'Category'
      }
      });

      // Set up dependencies between controls and charts
      dashboard.bind([categoryPicker,subCategoryPicker], table);
      // Draw all visualization components of the dashboard
      dashboard.draw(data);
    }
  }
</script>
</code>```

I do not need the Numerical Filter, all I need is something analagous to a cascading dropdown + table.

I would appreciate any pointers. Where am I going wrong? I don't think the issue is in the JS.html file - it's probably something to do with the acquisition of data from the Google sheet.

答:
first, don't need both chart libraries, jsapi & loader.js

according to the release notes...

The version of Google Charts that remains available via the jsapi loader is no longer being updated consistently. Please use the new gstatic loader.js from now on.

next, a callback is being set to a function that does not exist...

here --> google.charts.setOnLoadCallback(drawChart);

recommend setup similar to following...

```<code><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script>
  // Load the Visualization API and desired package(s).
  google.charts.load('45', {
    callback: sendQuery,
    packages: ['controls', 'corechart']
  });

  /**
   * Issue asynchronous request for spreadsheet data.
   * From gist.github.com/mogsdad/60dcc4116ed74fceb5f9
   */
  function sendQuery() {
    google.script.run
      .withSuccessHandler(drawDashboard)
      .withFailureHandler(function(msg) {
            // Respond to failure conditions here.
            $('#main-heading').text(msg);
            $('#main-heading').addClass("error");
            $('#error-message').show();
          })
      .getSpreadsheetData();
  }

  /**
   * Callback function to generate visualization using data in response parameter.
   * From gist.github.com/mogsdad/60dcc4116ed74fceb5f9
   *
   * @param {Object[][]}  Two-Dim array of visualization data
   */
  function drawDashboard(response) {
    $('#main-heading').addClass("hidden");
    if (response == null) {
      alert('Error: Invalid source data.')
      return;
    }
    else {
      // Transmogrify spreadsheet contents (array) to a DataTable object
      var data = google.visualization.arrayToDataTable(response,false);
      var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard-div'));

      var table = new google.visualization.ChartWrapper({
        'chartType': 'Table',
        'containerId': 'table-div'
      });

      var categoryPicker = new google.visualization.ControlWrapper({
        'controlType': 'CategoryFilter',
        'containerId': 'selector-div',
        'options': {
          'filterColumnLabel': 'Category'
        }
      });

      var subCategoryPicker = new google.visualization.ControlWrapper({
        'controlType': 'CategoryFilter',
        'containerId': 'selector1-div',
        'options': {
          'filterColumnLabel': 'Category'
        }
      });

      // Set up dependencies between controls and charts
      dashboard.bind([categoryPicker,subCategoryPicker], table);
      // Draw all visualization components of the dashboard
      dashboard.draw(data);
    }
  }
</script>
</code>```

EDIT

working example using query class --> google.visualization.Query

google.charts.load('45', {
  callback: sendQuery,
  packages: ['controls', 'corechart']
});

function sendQuery() {
  var url = 'https://docs.google.com/spreadsheets/d/1-EE_WDD6QYi257_utUf_D0v5e9Gf8Lj5tETPqqllvxk/edit#gid=0';
  new google.visualization.Query(url).send(function (response) {
    if (response.isError()) {
      console.log('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
    } else {
      drawDashboard(response.getDataTable());
    }
  });
}

function drawDashboard(data) {
  $('#main-heading').addClass("hidden");
  var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard-div'));

  var table = new google.visualization.ChartWrapper({
    chartType: 'Table',
    containerId: 'table-div'
  });

  var categoryPicker = new google.visualization.ControlWrapper({
    controlType: 'CategoryFilter',
    containerId: 'selector-div',
    options: {
      filterColumnLabel: 'Category'
    }
  });

  var subCategoryPicker = new google.visualization.ControlWrapper({
    controlType: 'CategoryFilter',
    containerId: 'selector1-div',
    options: {
      filterColumnLabel: 'Category'
    }
  });

  dashboard.bind([categoryPicker,subCategoryPicker], table);
  dashboard.draw(data);
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.hidden {
  display: none;
}</code>```

Loading...

```

Body:
So I have been experimenting with Google Apps Script and the Charts API all day, and have gotten nowhere, unfortunately.

I did many things - including following Mogsdad's well-written tutorial here. Here's the code I have so far - including from that tutorial, but I keep getting an error saying the script has completed but returned a different type from what is accepted, or something of the like.

Dashboard-Code.gs:

/**
 * Serves HTML of the application for HTTP GET requests.
 * From gist.github.com/mogsdad/24518dff348ad14d3929
 *
 * @param {Object} e event parameter that can contain information
 *     about any URL parameters provided.
 */
function doGet(e) {
  var template = HtmlService.createTemplateFromFile('Index');

  // Build and return HTML in IFRAME sandbox mode.
  return template.evaluate()
      .setTitle('Dashboard demo')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

/**
 * Return all data from first spreadsheet as an array. Can be used
 * via google.script.run to get data without requiring publication
 * of spreadsheet.
 * From gist.github.com/mogsdad/24518dff348ad14d3929
 *
 * Returns null if spreadsheet does not contain more than one row.
 */
function getSpreadsheetData() {
  // This does not work, see https://code.google.com/p/google-apps-script-issues/issues/detail?id=5233
//  var ss = SpreadsheetApp.getActiveSpreadsheet();
//  var data = ss.getSheets()[0].getDataRange().getValues();
  var sheetId = '1-EE_WDD6QYi257_utUf_D0v5e9Gf8Lj5tETPqqllvxk';  // Replace with your spreadsheet ID. (Ick.)
  var data = SpreadsheetApp.openById(sheetId).getSheets()[0].getDataRange().getValues();
  return (data.length > 1) ? data : null;
}

Index.html:

<?!= HtmlService.createHtmlOutputFromFile('Stylesheet').getContent(); ?>

Loading...

<?!= HtmlService.createHtmlOutputFromFile('JavaScript').getContent(); ?>

and JavaScript.html (I decided to stick to what Mogsdad was saying):

I do not need the Numerical Filter, all I need is something analagous to a cascading dropdown + table.

I would appreciate any pointers. Where am I going wrong? I don't think the issue is in the JS.html file - it's probably something to do with the acquisition of data from the Google sheet.

Body:
first, don't need both chart libraries, jsapi & loader.js

according to the release notes...

The version of Google Charts that remains available via the jsapi loader is no longer being updated consistently. Please use the new gstatic loader.js from now on.

next, a callback is being set to a function that does not exist...

here --> google.charts.setOnLoadCallback(drawChart);

recommend setup similar to following...

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script>
  // Load the Visualization API and desired package(s).
  google.charts.load('45', {
    callback: sendQuery,
    packages: ['controls', 'corechart']
  });

  /**
   * Issue asynchronous request for spreadsheet data.
   * From gist.github.com/mogsdad/60dcc4116ed74fceb5f9
   */
  function sendQuery() {
    google.script.run
      .withSuccessHandler(drawDashboard)
      .withFailureHandler(function(msg) {
            // Respond to failure conditions here.
            $('#main-heading').text(msg);
            $('#main-heading').addClass("error");
            $('#error-message').show();
          })
      .getSpreadsheetData();
  }

  /**
   * Callback function to generate visualization using data in response parameter.
   * From gist.github.com/mogsdad/60dcc4116ed74fceb5f9
   *
   * @param {Object[][]}  Two-Dim array of visualization data
   */
  function drawDashboard(response) {
    $('#main-heading').addClass("hidden");
    if (response == null) {
      alert('Error: Invalid source data.')
      return;
    }
    else {
      // Transmogrify spreadsheet contents (array) to a DataTable object
      var data = google.visualization.arrayToDataTable(response,false);
      var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard-div'));

      var table = new google.visualization.ChartWrapper({
        'chartType': 'Table',
        'containerId': 'table-div'
      });

      var categoryPicker = new google.visualization.ControlWrapper({
        'controlType': 'CategoryFilter',
        'containerId': 'selector-div',
        'options': {
          'filterColumnLabel': 'Category'
        }
      });

      var subCategoryPicker = new google.visualization.ControlWrapper({
        'controlType': 'CategoryFilter',
        'containerId': 'selector1-div',
        'options': {
          'filterColumnLabel': 'Category'
        }
      });

      // Set up dependencies between controls and charts
      dashboard.bind([categoryPicker,subCategoryPicker], table);
      // Draw all visualization components of the dashboard
      dashboard.draw(data);
    }
  }
</script>

EDIT

working example using query class --> google.visualization.Query

google.charts.load('45', {
  callback: sendQuery,
  packages: ['controls', 'corechart']
});

function sendQuery() {
  var url = 'https://docs.google.com/spreadsheets/d/1-EE_WDD6QYi257_utUf_D0v5e9Gf8Lj5tETPqqllvxk/edit#gid=0';
  new google.visualization.Query(url).send(function (response) {
    if (response.isError()) {
      console.log('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
    } else {
      drawDashboard(response.getDataTable());
    }
  });
}

function drawDashboard(data) {
  $('#main-heading').addClass("hidden");
  var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard-div'));

  var table = new google.visualization.ChartWrapper({
    chartType: 'Table',
    containerId: 'table-div'
  });

  var categoryPicker = new google.visualization.ControlWrapper({
    controlType: 'CategoryFilter',
    containerId: 'selector-div',
    options: {
      filterColumnLabel: 'Category'
    }
  });

  var subCategoryPicker = new google.visualization.ControlWrapper({
    controlType: 'CategoryFilter',
    containerId: 'selector1-div',
    options: {
      filterColumnLabel: 'Category'
    }
  });

  dashboard.bind([categoryPicker,subCategoryPicker], table);
  dashboard.draw(data);
}

.hidden {
  display: none;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<h1 id="main-heading">Loading...</h1>
<div id="dashboard-div">
  <div id="control-div">
    <div id="selector-div">
    </div>
    <div id="selector1-div">
    </div>
  </div>
  <div id="charts-div">

    <div id="table-div">
    </div>
  </div>
</div>
<div class="hidden" id="error-message">
</div>


答:
The value of the entry being deleted is available at:</p>

```<code>event.data.previous.val()
</code>```

Title: Cloud Functions for Firebase: How to get the value of the data that was deleted

Body:
When I add a cloud function responding to a delete event, like this one:

exports.onDeleteSector = functions.database.ref('/sectores/{idSector}').onDelete((event) =>

I can get the key to the sector being deleted in event.params.idSector proving the trigger works, however, event.data.val() returns null.

The deleted record contains the references to the children to be deleted.  How can I get those before the parent is gone?

Thanks

Body:
The value of the entry being deleted is available at:

event.data.previous.val()


问:
Xpath - grabbing each line separately that used BR tags
```<code><div class="school_row_cell_content">
<div class="center_div">
    <img src="/assets/isbiimages/c1504.jpg" alt="School Crest" width="190"></div>
                 Shelburne Road,
<br class="">Cheltenham,
<br class="">Gloucestershire,
<br class="">United Kingdom,
<br class="">GL51 6HE
<br class="">
<br class=""><strong>Tel:</strong> +44 1242 258000
<br class=""><strong>Fax:</strong> +44 1242 258004
<br class=""><br class=""><strong><a href="http://www.deanclose.org.uk" rel="nofollow" target="_blank" id="154" title="opens in new window" class="school_website_btn">Visit School Website</a></strong>
<br class="">
<br class=""><strong>Founded:</strong>1886<br class=""><br class=""><strong>Headmaster:</strong>
<br class=""><a href="/assets/isbiimages/ph1504.jpg" class="iframe_popups">Mr Bradley Salisbury</a>
<br class=""><br class=""><strong>Registrar:</strong>
<br class="">Mrs Kelly Serjeant
<br class="">
<br class="">This school offers flexi-boarding.
<br class="">
<br class=""><strong>Accreditations and affiliations:</strong>
<br class="">ISBA, HMC, BSA, AGBIS
<br class=""><strong>Religious affiliation:</strong>
<br class="">Church of England<br class=""><strong>Teaching languages:</strong>
<br class="">English
<br class="">
</div>
</code>```

I want to grab each line of this information separately but as there are only br tags I am struggling to do this. Especially given the classes are empty. I am trying this type of thing:

```<code>//div[@class='school_row_cell_content']/@br
//div[@class='school_row_cell_content']/br[@class=''][1]
</code>```

but don't seem to be getting anywhere.

答:
The trick is to isolate a br node first, then get the preceding or following text node. So to get the text node containing "Shelburne Road":

```<code>//div[@class='school_row_cell_content']/br[1]/preceding-sibling::text()[1]
</code>```

To get the text node containing "Cheltenham":

```<code>//div[@class='school_row_cell_content']/br[1]/following-sibling::text()[1]
</code>```

To get the text node containing "Gloucestershire":

```<code>//div[@class='school_row_cell_content']/br[2]/following-sibling::text()[1]
</code>```

Body:
                 Shelburne Road,

Cheltenham,

Gloucestershire,

United Kingdom,

GL51 6HE

Tel: +44 1242 258000

Fax: +44 1242 258004

Visit School Website

Founded:1886

Headmaster:

Mr Bradley Salisbury

Registrar:

Mrs Kelly Serjeant

This school offers flexi-boarding.

Accreditations and affiliations:

ISBA, HMC, BSA, AGBIS

Religious affiliation:

Church of England
Teaching languages:

English

I want to grab each line of this information separately but as there are only br tags I am struggling to do this. Especially given the classes are empty. I am trying this type of thing:

//div[@class='school_row_cell_content']/@br
//div[@class='school_row_cell_content']/br[@class=''][1]

but don't seem to be getting anywhere.

Body:
The trick is to isolate a br node first, then get the preceding or following text node. So to get the text node containing "Shelburne Road":

//div[@class='school_row_cell_content']/br[1]/preceding-sibling::text()[1]

To get the text node containing "Cheltenham":

//div[@class='school_row_cell_content']/br[1]/following-sibling::text()[1]

To get the text node containing "Gloucestershire":

//div[@class='school_row_cell_content']/br[2]/following-sibling::text()[1]


问:
Asymptotically optimal algorithm to compute if a line intersects a convex polygon
An O(n) algorithm to detect if a line intersects a convex polygon consists in checking if any edge of the polygon intersects the line, and look if the number of intersections is odd or even.

Is there an asymptotically faster algorithm, e.g. an O(log n) one?

答: You just need to find a point A that is on the left side of the line and another point that is on the right side. The remaining question is how to find that points quickly.</p>