问:
How to avoid reusability of tableview cell?
When I click on select button at indexpath.row == 0 or any so , only  with respective "session label value" will change but here that will not happen.  it will change the below cell value also i.e. indexpath == 7 or 8 , I think here is reuse of cell so, how I can avoid it.

My code is like below.

1.UITableViewCell Class:

```<code>import UIKit

class DemoTableViewCell: UITableViewCell {

    @IBOutlet weak var mSelectButton: UIButton!
    @IBOutlet weak var mDateLabel: UILabel!
    @IBOutlet weak var mSessionLabel: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
}
</code>```

ViewController Class:-

import UIKit

```<code>    class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

        var month_year = ""
        var fromYear = ""
        var toYear = ""
        var monthYearList = ""
        var monthYearListArray = [String]()
        let picker : UIDatePicker = UIDatePicker()

        var from_date = ""
        var to_date = ""

        //
        var selectedTagValue = Int()
        var aSheetValue = ""
        var isFromActionSheet = Bool()
        var isFromFinalClick = Bool()
        var intArray = [Int]()

        @IBOutlet weak var mTableView: UITableView!

        // MARK:- ViewController Life Cycle Methods

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

        override func viewWillAppear(_ animated: Bool) {
            self.printDatesBetweenInterval(self.dateFromString("2017-07-01"), self.dateFromString("2017-07-12"))
        }

        //MARK:- UITableViewDataSource and Delegate Methods

        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

            return monthYearListArray.count
        }

        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

            let cell = tableView.dequeueReusableCell(withIdentifier: "DemoTableViewCell")! as! DemoTableViewCell

            cell.mDateLabel.text = monthYearListArray[indexPath.row]

            if isFromActionSheet{

                if indexPath.row == selectedTagValue{
                    cell.mSessionLabel.text = aSheetValue
                    isFromActionSheet = false
                }
            }

            cell.mSelectButton.tag = indexPath.row
            print("cell.mButtonOutlet.tag: \(cell.mSelectButton.tag)")

            cell.mSelectButton.addTarget(self, action: #selector(ViewController.actionOnSelectButtonClick(_:)), for: .touchUpInside)

            if isFromFinalClick{
                if cell.mSessionLabel.text == "Full Day"{
                    self.intArray.append(1)

                }else if cell.mSessionLabel.text == "First Half"{
                    self.intArray.append(2)
                }else{
                    self.intArray.append(3)
                }
            }

            return cell
        }

        // MARK:- IBAction Methods

        func actionOnSelectButtonClick(_ sender: UIButton)  {
            let mButton : UIButton = sender
            selectedTagValue = mButton.tag
            print("selectedTagValue: \(selectedTagValue)")
            isFromActionSheet = true
            openActionSheet()
        }

        // Submit Button

        @IBAction func actionOnSubmitButton(_ sender: Any) {
            isFromFinalClick = true
            mTableView.reloadData()
            print("intArray list: \(intArray)")

        }

        // MARK:- Instance Methods

        func openActionSheet()  {

            // 1
            let optionMenu = UIAlertController(title: nil, message: "Select Session", preferredStyle: .actionSheet)

            // 2
            let fullDayAction = UIAlertAction(title: "Full Day", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                print("Full Day")
                self.aSheetValue = "Full Day"
                self.mTableView.reloadData()
            })

            let firstHalfAction = UIAlertAction(title: "First Half", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                print("First Half")
                self.aSheetValue = "First Half"
                self.mTableView.reloadData()

            })
            let secondHalfAction = UIAlertAction(title: "Second Half", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                print("Second Half")
                self.aSheetValue = "Second Half"
                self.mTableView.reloadData()

            })

            //
            let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
                (alert: UIAlertAction!) -> Void in
                print("Cancelled")
            })

            // 4
            optionMenu.addAction(fullDayAction)
            optionMenu.addAction(firstHalfAction)
            optionMenu.addAction(secondHalfAction)
            optionMenu.addAction(cancelAction)

            // 5
            self.present(optionMenu, animated: true, completion: nil)
        }

        // MARK:- Date_List Method

        func printDatesBetweenInterval(_ startDate: Date, _ endDate: Date) {
            var startDate = startDate
            let calendar = Calendar.current

            let fmt = DateFormatter()
            fmt.dateFormat = "yyyy-MM-dd"

            while startDate <= endDate {
                print(fmt.string(from: startDate))
                self.monthYearList = fmt.string(from: startDate)
                print("self.monthYearList: \(self.monthYearList)")
                fmt.dateFormat = "yyyy-MM-dd"
                monthYearListArray.append(fmt.string(from: startDate))
                startDate = calendar.date(byAdding: .day, value: 1, to: startDate)!
            }

            print("monthYearListArray: \(monthYearListArray)")
            mTableView.reloadData()
        }

        func dateFromString(_ dateString: String) -> Date {
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "yyyy-MM-dd"

            return dateFormatter.date(from: dateString)!
        }

    }
</code>```

答:
Rather than avoiding reusing cells make sure that all UI elements are always in a defined state</p>

```<code> if isFromActionSheet && indexPath.row == selectedTagValue{
     cell.mSessionLabel.text = aSheetValue
     isFromActionSheet = false
 } else {
     cell.mSessionLabel.text = [default value]
     isFromActionSheet = [default value]
 }
</code>```

Body:
When I click on select button at indexpath.row == 0 or any so , only  with respective "session label value" will change but here that will not happen.  it will change the below cell value also i.e. indexpath == 7 or 8 , I think here is reuse of cell so, how I can avoid it.

My code is like below.

1.UITableViewCell Class:

import UIKit

class DemoTableViewCell: UITableViewCell {

    @IBOutlet weak var mSelectButton: UIButton!
    @IBOutlet weak var mDateLabel: UILabel!
    @IBOutlet weak var mSessionLabel: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
}

ViewController Class:-

import UIKit

    class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

        var month_year = ""
        var fromYear = ""
        var toYear = ""
        var monthYearList = ""
        var monthYearListArray = [String]()
        let picker : UIDatePicker = UIDatePicker()

        var from_date = ""
        var to_date = ""

        //
        var selectedTagValue = Int()
        var aSheetValue = ""
        var isFromActionSheet = Bool()
        var isFromFinalClick = Bool()
        var intArray = [Int]()

        @IBOutlet weak var mTableView: UITableView!

        // MARK:- ViewController Life Cycle Methods

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

        override func viewWillAppear(_ animated: Bool) {
            self.printDatesBetweenInterval(self.dateFromString("2017-07-01"), self.dateFromString("2017-07-12"))
        }

        //MARK:- UITableViewDataSource and Delegate Methods

        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

            return monthYearListArray.count
        }

        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

            let cell = tableView.dequeueReusableCell(withIdentifier: "DemoTableViewCell")! as! DemoTableViewCell

            cell.mDateLabel.text = monthYearListArray[indexPath.row]

            if isFromActionSheet{

                if indexPath.row == selectedTagValue{
                    cell.mSessionLabel.text = aSheetValue
                    isFromActionSheet = false
                }
            }

            cell.mSelectButton.tag = indexPath.row
            print("cell.mButtonOutlet.tag: \(cell.mSelectButton.tag)")

            cell.mSelectButton.addTarget(self, action: #selector(ViewController.actionOnSelectButtonClick(_:)), for: .touchUpInside)

            if isFromFinalClick{
                if cell.mSessionLabel.text == "Full Day"{
                    self.intArray.append(1)

                }else if cell.mSessionLabel.text == "First Half"{
                    self.intArray.append(2)
                }else{
                    self.intArray.append(3)
                }
            }

            return cell
        }

        // MARK:- IBAction Methods

        func actionOnSelectButtonClick(_ sender: UIButton)  {
            let mButton : UIButton = sender
            selectedTagValue = mButton.tag
            print("selectedTagValue: \(selectedTagValue)")
            isFromActionSheet = true
            openActionSheet()
        }

        // Submit Button

        @IBAction func actionOnSubmitButton(_ sender: Any) {
            isFromFinalClick = true
            mTableView.reloadData()
            print("intArray list: \(intArray)")

        }

        // MARK:- Instance Methods

        func openActionSheet()  {

            // 1
            let optionMenu = UIAlertController(title: nil, message: "Select Session", preferredStyle: .actionSheet)

            // 2
            let fullDayAction = UIAlertAction(title: "Full Day", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                print("Full Day")
                self.aSheetValue = "Full Day"
                self.mTableView.reloadData()
            })

            let firstHalfAction = UIAlertAction(title: "First Half", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                print("First Half")
                self.aSheetValue = "First Half"
                self.mTableView.reloadData()

            })
            let secondHalfAction = UIAlertAction(title: "Second Half", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                print("Second Half")
                self.aSheetValue = "Second Half"
                self.mTableView.reloadData()

            })

            //
            let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
                (alert: UIAlertAction!) -> Void in
                print("Cancelled")
            })

            // 4
            optionMenu.addAction(fullDayAction)
            optionMenu.addAction(firstHalfAction)
            optionMenu.addAction(secondHalfAction)
            optionMenu.addAction(cancelAction)

            // 5
            self.present(optionMenu, animated: true, completion: nil)
        }

        // MARK:- Date_List Method

        func printDatesBetweenInterval(_ startDate: Date, _ endDate: Date) {
            var startDate = startDate
            let calendar = Calendar.current

            let fmt = DateFormatter()
            fmt.dateFormat = "yyyy-MM-dd"

            while startDate <= endDate {
                print(fmt.string(from: startDate))
                self.monthYearList = fmt.string(from: startDate)
                print("self.monthYearList: \(self.monthYearList)")
                fmt.dateFormat = "yyyy-MM-dd"
                monthYearListArray.append(fmt.string(from: startDate))
                startDate = calendar.date(byAdding: .day, value: 1, to: startDate)!
            }

            print("monthYearListArray: \(monthYearListArray)")
            mTableView.reloadData()
        }

        func dateFromString(_ dateString: String) -> Date {
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "yyyy-MM-dd"

            return dateFormatter.date(from: dateString)!
        }

    }

Body:
Rather than avoiding reusing cells make sure that all UI elements are always in a defined state

 if isFromActionSheet && indexPath.row == selectedTagValue{
     cell.mSessionLabel.text = aSheetValue
     isFromActionSheet = false
 } else {
     cell.mSessionLabel.text = [default value]
     isFromActionSheet = [default value]
 }


来源: stackexchange

问:
Take array value with radio input
I'm using javascript to clone a form according to the int value. I'm using [] brackets for taking array value from other input type.

```<code><input type="text" name="state[]" class="form-control" id="state" required>
</code>```

and used same for radio input.

```<code><input type="radio" name="gender[]" value="Male">Male
</code>```

using loop in server side to save those data into db.

```<code>for ($i = 0; $i <= $request->limit; $i++) {
    $user->name = $request->name[$i];
    $user->gender = $request->gender[$i];
    $user->address = $request->address[$i];
    $user->save();
}
</code>```

I'm getting error of Undefined offset: 1 on the line:

```<code>$user->gender = $request->gender[$i];
</code>```

as because radio input cannot hold data in array form. When I dump and die request all inputs except radio has data in array form. And value of radio input is succeeded by the value of next radio input of cloned form.

How can I get array value from radio input?

答:
The problem is that if you all your radio buttons have the name gender[], then they are all in the same group, and you can only select one of the options out of all the form clones.

So, for example, if your form looks like this:

```<code><form>
<input type="text" name="name[]" required>
<input type="radio" name="gender[]" value="Male">Male
<input type="radio" name="gender[]" value="Female">Female
<input type="text" name="name[]" required>
<input type="radio" name="gender[]" value="Male">Male
<input type="radio" name="gender[]" value="Female">Female
</form>
</code>```

If I try to fill it and put "John" in the first name field and then select "Male" from the first two button, then type in "Marry" in the second name field and select "Female" from the last two buttons, the "Male" selection for the first set will disappear - because the browser sees all radio buttons as the same group because they have the same name.

I suggest replacing radio buttons with <select> boxes.

ContentLicense: CC BY-SA 3.0

Title: Take array value with radio input

Body:
I'm using javascript to clone a form according to the int value. I'm using [] brackets for taking array value from other input type.

<input type="text" name="state[]" class="form-control" id="state" required>

and used same for radio input.

<input type="radio" name="gender[]" value="Male">Male

using loop in server side to save those data into db.

for ($i = 0; $i <= $request->limit; $i++) {
    $user->name = $request->name[$i];
    $user->gender = $request->gender[$i];
    $user->address = $request->address[$i];
    $user->save();
}

I'm getting error of Undefined offset: 1 on the line:

$user->gender = $request->gender[$i];

as because radio input cannot hold data in array form. When I dump and die request all inputs except radio has data in array form. And value of radio input is succeeded by the value of next radio input of cloned form.

How can I get array value from radio input?

Body:
The problem is that if you all your radio buttons have the name gender[], then they are all in the same group, and you can only select one of the options out of all the form clones.

So, for example, if your form looks like this:

<form>
<input type="text" name="name[]" required>
<input type="radio" name="gender[]" value="Male">Male
<input type="radio" name="gender[]" value="Female">Female
<input type="text" name="name[]" required>
<input type="radio" name="gender[]" value="Male">Male
<input type="radio" name="gender[]" value="Female">Female
</form>

If I try to fill it and put "John" in the first name field and then select "Male" from the first two button, then type in "Marry" in the second name field and select "Female" from the last two buttons, the "Male" selection for the first set will disappear - because the browser sees all radio buttons as the same group because they have the same name.

I suggest replacing radio buttons with <select> boxes.


问:
C++ Binary >> no operator found which takes a right hand operand type of const char error
im trying to learn c++ and can't figure out the reason for this error it seems to match up with my other cout lines that aren't getting any errors </p>

```<code>#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
    int number = 42;
    int guess;
    bool notguessed = true;
    while (notguessed);

    cout << "Guess my number";
    cin  >> "Guess";
    if (guess == number)
    {
        cout << "You got it" << endl;
        notguessed = false;
    }
    if (guess < number)
    {
        cout << "To low try again" << endl;
    }
    if (guess > number)
    {
        cout << "To high try again" << endl;
    }

    return 0;
}
</code>```

答:
Your program has two errors - Compilation error and Logical Error.

Compilation Error - Consider this code segment -

cin  >> "Guess";
Here you trying to give a value to a constant. What you intended to do is -
cin>>guess

Logical Error - When you make above changes your code will compile fine but will not work as you want it to, this is because of the following line -

while (notguessed);

The above while loop will run infinitely as notguessed is true and no where in the loop its value is modified.

Change that to -

```<code> while (notguessed){

    cout << "Guess my number";
    cin  >> guess;
    if (guess == number)
    {
        cout << "You got it" << endl;
        notguessed = false;
    }
    else if (guess < number)
    {
        cout << "Too low try again" << endl;
    }
    else
    {
        cout << "Too high try again" << endl;
    }
}
</code>```

Note - I converted your simple ifstatements to if else if, this is to avoid unecessary checking of other ifs when one if already evaluated to true.

There is an alternative approach to the above where you are not required to use the variable notguessed, by using break keyword -

```<code>  while (true){

    cout << "Guess my number";
    cin  >> guess;
    if (guess == number)
    {
        cout << "You got it" << endl;
        break;
    }
    else if (guess < number)
    {
        cout << "Too low try again" << endl;
    }
    else
    {
        cout << "Too high try again" << endl;
    }
}
</code>```

Body:
im trying to learn c++ and can't figure out the reason for this error it seems to match up with my other cout lines that aren't getting any errors

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
    int number = 42;
    int guess;
    bool notguessed = true;
    while (notguessed);

    cout << "Guess my number";
    cin  >> "Guess";
    if (guess == number)
    {
        cout << "You got it" << endl;
        notguessed = false;
    }
    if (guess < number)
    {
        cout << "To low try again" << endl;
    }
    if (guess > number)
    {
        cout << "To high try again" << endl;
    }

    return 0;
}

Body:
Your program has two errors - Compilation error and Logical Error.

Compilation Error - Consider this code segment -

cin  >> "Guess";
Here you trying to give a value to a constant. What you intended to do is -
cin>>guess

Logical Error - When you make above changes your code will compile fine but will not work as you want it to, this is because of the following line -

while (notguessed);

The above while loop will run infinitely as notguessed is true and no where in the loop its value is modified.

Change that to -

 while (notguessed){

    cout << "Guess my number";
    cin  >> guess;
    if (guess == number)
    {
        cout << "You got it" << endl;
        notguessed = false;
    }
    else if (guess < number)
    {
        cout << "Too low try again" << endl;
    }
    else
    {
        cout << "Too high try again" << endl;
    }
}

Note - I converted your simple ifstatements to if else if, this is to avoid unecessary checking of other ifs when one if already evaluated to true.

There is an alternative approach to the above where you are not required to use the variable notguessed, by using break keyword -

  while (true){

    cout << "Guess my number";
    cin  >> guess;
    if (guess == number)
    {
        cout << "You got it" << endl;
        break;
    }
    else if (guess < number)
    {
        cout << "Too low try again" << endl;
    }
    else
    {
        cout << "Too high try again" << endl;
    }
}


问:
How to create an RXjs RetryWhen with delay and limit on tries
I am trying to make an API call (using angular4), which retries when it fails, using retryWhen.
I want it to delay for 500 ms and retry again. This can be achieved with this code:

```<code>loadSomething(): Observable<SomeInterface> {
  return this.http.get(this.someEndpoint, commonHttpHeaders())
    .retryWhen(errors => errors.delay(500));
}
</code>```

But this will keep trying forever. How do I limit it to, let's say 10 times?

Thank you!

答:
You need to apply the limit to the retry signal, for instance if you only wanted 10 retries:

loadSomething(): Observable<SomeInterface> {
  return this.http.get(this.someEndpoint, commonHttpHeaders())
    .retryWhen(errors =>
      // Time shift the retry
      errors.delay(500)
            // Only take 10 items
            .take(10)
            // Throw an exception to signal that the error needs to be propagated
            .concat(Rx.Observable.throw(new Error('Retry limit exceeded!'))
    );
```
<p><strong>EDIT</strong></p>
<p>Some of the commenters asked how to make sure that the last error is the one that gets thrown. The answer is a bit less clean but no less powerful, just use one of the flattening map operators (concatMap, mergeMap, switchMap) to check which index you are at.</p>
<p>Note: Using the new RxJS 6 <code>pipe</code> syntax for future proofing (this is also available in later versions of RxJS 5).</p>
<pre class="lang-js prettyprint-override"><code>loadSomething(): Observable<SomeInterface> {
  const retryPipeline =
    // Still using retryWhen to handle errors
    retryWhen(errors => errors.pipe(
      // Use concat map to keep the errors in order and make sure they
      // aren't executed in parallel
      concatMap((e, i) =>
        // Executes a conditional Observable depending on the result
        // of the first argument
        iif(
          () => i > 10,
          // If the condition is true we throw the error (the last error)
          throwError(e),
          // Otherwise we pipe this back into our stream and delay the retry
          of(e).pipe(delay(500))
        )
      )
  ));

  return this.http.get(this.someEndpoint, commonHttpHeaders())
    // With the new syntax you can now share this pipeline between uses
    .pipe(retryPipeline)
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am trying to make an API call (using angular4), which retries when it fails, using retryWhen.
I want it to delay for 500 ms and retry again. This can be achieved with this code:

loadSomething(): Observable<SomeInterface> {
  return this.http.get(this.someEndpoint, commonHttpHeaders())
    .retryWhen(errors => errors.delay(500));
}

But this will keep trying forever. How do I limit it to, let's say 10 times?

Thank you!

Body:
You need to apply the limit to the retry signal, for instance if you only wanted 10 retries:

loadSomething(): Observable<SomeInterface> {
  return this.http.get(this.someEndpoint, commonHttpHeaders())
    .retryWhen(errors =>
      // Time shift the retry
      errors.delay(500)
            // Only take 10 items
            .take(10)
            // Throw an exception to signal that the error needs to be propagated
            .concat(Rx.Observable.throw(new Error('Retry limit exceeded!'))
    );

EDIT

Some of the commenters asked how to make sure that the last error is the one that gets thrown. The answer is a bit less clean but no less powerful, just use one of the flattening map operators (concatMap, mergeMap, switchMap) to check which index you are at.

Note: Using the new RxJS 6 pipe syntax for future proofing (this is also available in later versions of RxJS 5).

loadSomething(): Observable<SomeInterface> {
  const retryPipeline =
    // Still using retryWhen to handle errors
    retryWhen(errors => errors.pipe(
      // Use concat map to keep the errors in order and make sure they
      // aren't executed in parallel
      concatMap((e, i) =>
        // Executes a conditional Observable depending on the result
        // of the first argument
        iif(
          () => i > 10,
          // If the condition is true we throw the error (the last error)
          throwError(e),
          // Otherwise we pipe this back into our stream and delay the retry
          of(e).pipe(delay(500))
        )
      )
  ));

  return this.http.get(this.someEndpoint, commonHttpHeaders())
    // With the new syntax you can now share this pipeline between uses
    .pipe(retryPipeline)
}


问:
Invalid Function Error when running Cloud Function of Parse Server on back4app
The error code is below:

```<code>{"code":141,"message":"Invalid function: \"test\""}
</code>```

main.js

```<code> Parse.Cloud.define('test', function(request, response){
     response.success('OK');
 }, function(error){
     response.error(error);
 });
</code>```

app.js

```<code>app.get('/test', function(req, res){
    Parse.Cloud.run('test', null).then(function(result){
        return res.send(result);
    }, function(error){
        return res.status(400).send(error);
    });
});
</code>```

The Cloud Function defined in main.js does not work or isn't called successfully. Are there any dependencies missing to be declared in main.js in order to run on back4app or what?

答:
From what I could understand regarding Back4App's Cloud Code functions you won't need to have that "function(error)" within your main.js. The error treatment will be represented as an error code in your logs when the function present a problem.

I've done some tests and I'd update your example of main.js to be simple like this:

```<code>Parse.Cloud.define('test', function(request, response){
     response.success('OK');
 });
</code>```

Then your app.js would be valid and you could call that function simply by going to your_webhost.back4app.io/test or using REST API.

Body:
The error code is below:

{"code":141,"message":"Invalid function: \"test\""}

main.js

 Parse.Cloud.define('test', function(request, response){
     response.success('OK');
 }, function(error){
     response.error(error);
 });

app.js

app.get('/test', function(req, res){
    Parse.Cloud.run('test', null).then(function(result){
        return res.send(result);
    }, function(error){
        return res.status(400).send(error);
    });
});

The Cloud Function defined in main.js does not work or isn't called successfully. Are there any dependencies missing to be declared in main.js in order to run on back4app or what?

Body:
From what I could understand regarding Back4App's Cloud Code functions you won't need to have that "function(error)" within your main.js. The error treatment will be represented as an error code in your logs when the function present a problem.

I've done some tests and I'd update your example of main.js to be simple like this:

Parse.Cloud.define('test', function(request, response){
     response.success('OK');
 });

Then your app.js would be valid and you could call that function simply by going to your_webhost.back4app.io/test or using REST API.


问:
Django 'function' object has no attribute 'objects'
My apps allow you to like a picture  then it redirects you to the same page

I get then error when I try to like a picture I can create a like objects with the shell prompt but why I get this error? thank for helping me

```<code>AttributeError at /like/3/
function' object has no attribute 'objects'Request Method: GET
Request URL: http://127.0.0.1:8000/like/3/

Exception Value: 'function' object has no attribute 'objects'
Traceback:
File "C:\Python26\Lib\site-packages\django\core\handlers\base.py" in get_response
111.                         response = callback(request, *callback_args, **callback_kwargs)
File "C:\o\mysite\pet\views.py" in Like
195.     new_like, created = Like.objects.get_or_create(user=request.user, picture_id=picture_id)
</code>```

This is parts of my views.py

```<code>def Like(request,picture_id):
    pid = picture_id
    new_like, created = Like.objects.get_or_create(user=request.user, picture_id=picture_id)
    p = Picture.objects.get(pk=pid)
    if created:
        HttpResponseRedirect(reverse('world:url_name'))
    else:
        HttpResponseRedirect(reverse('world:url_name'))
</code>```

My URLconf:

```<code>     url(
</code>```

Parts of my model:
            r'^like/(?P\d+)/$',
            'pet.views.Like',
            name = 'Like'
        ),
My boat.html

```<code> {% if picture %}
 <ul>
    {% for pet in picture %}
    <li><b>description</b> = {{ pet.description}}<br/>
        {% if pet.image %}
 <li>
    <a href ="{% url world:Like pet.id %}">
        <img src= "{{ pet.image.url }}" style="cursor:pointer">
    </a>
 <li>
        {% endif %}
 {% endfor %}
 </ul>
 {% endif %}
 <a href="{% url world:PictureCreator %}">Add Pictures to your board</a><br/>
</code>```

My models.py

```<code>class Picture(models.Model):
    user = models.ForeignKey(User)
    board = models.ForeignKey(Board,blank=False,null=False)
    image = models.FileField(upload_to="images/",blank=True)
    description = models.TextField()
    is_primary = models.BooleanField(default=False)
    def __unicode__(self):
        return self.description

class Like(models.Model):
    user = models.ForeignKey(User)
    picture = models.ForeignKey(Picture)
    created = models.DateTimeField(auto_now_add=True)
</code>```

答:
I got this same error when doing

```<code> from django.contrib.auth import get_user_model
 User = get_user_model
</code>```

adding () solved the error:

```<code> from django.contrib.auth import get_user_model
 User = get_user_model()
</code>```

Body:
My apps allow you to like a picture  then it redirects you to the same page

I get then error when I try to like a picture I can create a like objects with the shell prompt but why I get this error? thank for helping me

AttributeError at /like/3/
function' object has no attribute 'objects'Request Method: GET
Request URL: http://127.0.0.1:8000/like/3/

Exception Value: 'function' object has no attribute 'objects'
Traceback:
File "C:\Python26\Lib\site-packages\django\core\handlers\base.py" in get_response
111.                         response = callback(request, *callback_args, **callback_kwargs)
File "C:\o\mysite\pet\views.py" in Like
195.     new_like, created = Like.objects.get_or_create(user=request.user, picture_id=picture_id)

This is parts of my views.py

def Like(request,picture_id):
    pid = picture_id
    new_like, created = Like.objects.get_or_create(user=request.user, picture_id=picture_id)
    p = Picture.objects.get(pk=pid)
    if created:
        HttpResponseRedirect(reverse('world:url_name'))
    else:
        HttpResponseRedirect(reverse('world:url_name'))

My URLconf:

     url(

Parts of my model:
            r'^like/(?P\d+)/$',
            'pet.views.Like',
            name = 'Like'
        ),
My boat.html

 {% if picture %}

    {% for pet in picture %}

description = {{ pet.description}}

        {% if pet.image %}

        {% endif %}
 {% endfor %}

 {% endif %}
 Add Pictures to your board

My models.py

class Picture(models.Model):
    user = models.ForeignKey(User)
    board = models.ForeignKey(Board,blank=False,null=False)
    image = models.FileField(upload_to="images/",blank=True)
    description = models.TextField()
    is_primary = models.BooleanField(default=False)
    def __unicode__(self):
        return self.description

class Like(models.Model):
    user = models.ForeignKey(User)
    picture = models.ForeignKey(Picture)
    created = models.DateTimeField(auto_now_add=True)

Body:
I got this same error when doing

 from django.contrib.auth import get_user_model
 User = get_user_model

adding () solved the error:

 from django.contrib.auth import get_user_model
 User = get_user_model()


问:
Settings only for GUI/Terminal emacs
I'm trying to set a theme - one only for terminal, and one only for gui.
I've read this thread: Run certain Emacs init commands only in GUI mode

Which led me here: https://superuser.com/questions/165335/how-can-i-show-the-emacs-menu-in-gui-emacs-frames-but-not-in-tty-frames-when-usi

And tried to create a function to suit my need.

```<code>(defun set-frame-theme (frame)
  (let ((want-theme (memq (framep frame) '(x w32 ns))))
    (set-frame-parameter frame '(load-theme '(if want-theme monokai solarized-dark) t))))
(add-hook 'after-make-frame-functions 'set-frame-theme)
</code>```

It doesn't work.
I'm trying him to load monokai only if gui, otherwise load solarized-dark.
It does work for the GUI interface, but causes the terminal to seemingly crash.

Suggestions?

答:
As mentioned at https://www.emacswiki.org/emacs/CustomizingFaces

"If you want different color schemes for different displays, you can customize this as well. In the customize buffer, click the [State] button and choose “Show all display specs”. Now you can use different specs for different displays."

Title: Settings only for GUI/Terminal emacs

Body:
I'm trying to set a theme - one only for terminal, and one only for gui.
I've read this thread: Run certain Emacs init commands only in GUI mode

Which led me here: https://superuser.com/questions/165335/how-can-i-show-the-emacs-menu-in-gui-emacs-frames-but-not-in-tty-frames-when-usi

And tried to create a function to suit my need.

(defun set-frame-theme (frame)
  (let ((want-theme (memq (framep frame) '(x w32 ns))))
    (set-frame-parameter frame '(load-theme '(if want-theme monokai solarized-dark) t))))
(add-hook 'after-make-frame-functions 'set-frame-theme)

It doesn't work.
I'm trying him to load monokai only if gui, otherwise load solarized-dark.
It does work for the GUI interface, but causes the terminal to seemingly crash.

Suggestions?


问:
How I search a string in core data with swift 3?
I want to search a string in my DB and it keeps returning all records from core data. The other questions I saw here didn't work. Suggestions? </p>

```<code>var users:[Users] = []

    override func viewDidLoad() {
        super.viewDidLoad()

        let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

        let myrequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Users")

        let predicate = NSPredicate(format: "name = '%@'", "alex")
        myrequest.predicate = predicate

        do{
            users = try context.fetch(myrequest) as! [Users]

        }catch{
            print("error")
        }

    }
</code>```

答:
it's working now. this is the final code. Maybe it will help someone in the future :) thanks for the help guys.</p>

```<code>let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

        let query:NSFetchRequest<Users> = Users.fetchRequest()
        let key = "alex"

        let predicate = NSPredicate(format: "name contains[c] %@", key)
        query.predicate = predicate

        do{
            users = try context.fetch(query)
            print(users.count)

        }catch{
            print("error")
        }
</code>```

Body:
I want to search a string in my DB and it keeps returning all records from core data. The other questions I saw here didn't work. Suggestions?

var users:[Users] = []

    override func viewDidLoad() {
        super.viewDidLoad()

        let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

        let myrequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Users")

        let predicate = NSPredicate(format: "name = '%@'", "alex")
        myrequest.predicate = predicate

        do{
            users = try context.fetch(myrequest) as! [Users]

        }catch{
            print("error")
        }

    }

Body:
it's working now. this is the final code. Maybe it will help someone in the future :) thanks for the help guys.

let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

        let query:NSFetchRequest<Users> = Users.fetchRequest()
        let key = "alex"

        let predicate = NSPredicate(format: "name contains[c] %@", key)
        query.predicate = predicate

        do{
            users = try context.fetch(query)
            print(users.count)

        }catch{
            print("error")
        }


问:
Rectangle turn 90 degrees libgdx
If I have a tiled map, where all tiles are 50x50px and I want to make a sliding effect where a tile block turns 90 degrees so his route looks like this:

http://i.imgur.com/L0eXY63.png

How can I mathematically implement this so the rectangle perfectly turns and lands on the perfect coordinates which are in this case x-50, y + 50 because it is going to the left and to the top.

I could not find anything similar to this.

thanks

答: Use a rotate function based off of whatever you're trying to rotate, whether it's a box2d object, or an image, and translate the object up as it rotates to accommodate for the rotation </p>

Title: Rectangle turn 90 degrees libgdx


问:
MongoDB: Find documents with key in subdocument
The $in operator works with arrays.

Is there an equivalent for dictionaries?

The following code creates two test documents and finds the ones containing one of the listed values in the array documents, but doesn't find the ones containing the same values in the sub-documents.

```<code>> use test
> db.stuff.drop()
> db.stuff.insertMany([{lst:['a','b'],dic:{a:1,b:2}},{lst:['a','c'],dic:{a:3,c:4}}])
{
        "acknowledged" : true,
        "insertedIds" : [
                ObjectId("595bbe8b3b0518bcca4b1530"),
                ObjectId("595bbe8b3b0518bcca4b1531")
        ]
}
> db.stuff.find({lst:{$in:['b','c']}},{_id:0})
{ "lst" : [ "a", "b" ], "dic" : { "a" : 1, "b" : 2 } }
{ "lst" : [ "a", "c" ], "dic" : { "a" : 3, "c" : 4 } }
> db.stuff.find({dic:{$in:['b','c']}},{_id:0})
>
</code>```

EDIT (in response to the answer below)

Using the list as suggested in the answer below prevents me from finding the desired element. For example, after executing both the insertMany above in this question and below in the answer, the following can be done with a dictionary, not with a list (or am I missing something?):

```<code>> x=db.stuff.findOne({lst:{$in:['b','c']}},{_id:0})
{ "lst" : [ "a", "b" ], "dic" : { "a" : 1, "b" : 2 } }
> x
{ "lst" : [ "a", "b" ], "dic" : { "a" : 1, "b" : 2 } }
> x.dic.a
1
> x.dic.b
2
</code>```

答:
For subdocuments, there's no exact equivalent to $in. You could use the $exists query operator combined with $or:

```<code>db.stuff.find({$or:[
    {'dic.b': {$exists: true}},
    {'dic.c': {$exists: true}}
]})
</code>```

The recommended approach, however, is to change your schema, so that the keys and values are changed into an array of {key: "key", value: 123} subdocuments:

```<code>db.stuff.insertMany([
   {dic: [{key: 'a', value: 1}, {key: 'b', value: 2}]},
   {dic: [{key: 'a', value: 3}, {key: 'c', value: 4}]}
])
</code>```

Then you can use $in to find documents with certain keys:

```<code>db.stuff.find({'dic.key': {$in: ['a', 'b']}})
</code>```

The especially good thing about this new schema is you can use an index for the $in query:

```<code>db.stuff.createIndex({'dic.key': 1})
</code>```

A disadvantage, as you point out above, is that simple element access like x.dic.a no longer works. You need to do a bit of coding in your language. E.g. in Javascript:

```<code>> var doc = {dic: [{key: 'a', value: 3}, {key: 'c', value: 4}]}
> function getValue(doc, key) {
...   return doc.dic.filter(function(elem) {
...     return elem.key == key;
...   })[0].value;
... }
> getValue(doc, "a")
3
> getValue(doc, "c")
4
</code>```

Body:
The $in operator works with arrays.

Is there an equivalent for dictionaries?

The following code creates two test documents and finds the ones containing one of the listed values in the array documents, but doesn't find the ones containing the same values in the sub-documents.

> use test
> db.stuff.drop()
> db.stuff.insertMany([{lst:['a','b'],dic:{a:1,b:2}},{lst:['a','c'],dic:{a:3,c:4}}])
{
        "acknowledged" : true,
        "insertedIds" : [
                ObjectId("595bbe8b3b0518bcca4b1530"),
                ObjectId("595bbe8b3b0518bcca4b1531")
        ]
}
> db.stuff.find({lst:{$in:['b','c']}},{_id:0})
{ "lst" : [ "a", "b" ], "dic" : { "a" : 1, "b" : 2 } }
{ "lst" : [ "a", "c" ], "dic" : { "a" : 3, "c" : 4 } }
> db.stuff.find({dic:{$in:['b','c']}},{_id:0})
>

EDIT (in response to the answer below)

Using the list as suggested in the answer below prevents me from finding the desired element. For example, after executing both the insertMany above in this question and below in the answer, the following can be done with a dictionary, not with a list (or am I missing something?):

> x=db.stuff.findOne({lst:{$in:['b','c']}},{_id:0})
{ "lst" : [ "a", "b" ], "dic" : { "a" : 1, "b" : 2 } }
> x
{ "lst" : [ "a", "b" ], "dic" : { "a" : 1, "b" : 2 } }
> x.dic.a
1
> x.dic.b
2

Body:
For subdocuments, there's no exact equivalent to $in. You could use the $exists query operator combined with $or:

db.stuff.find({$or:[
    {'dic.b': {$exists: true}},
    {'dic.c': {$exists: true}}
]})

The recommended approach, however, is to change your schema, so that the keys and values are changed into an array of {key: "key", value: 123} subdocuments:

db.stuff.insertMany([
   {dic: [{key: 'a', value: 1}, {key: 'b', value: 2}]},
   {dic: [{key: 'a', value: 3}, {key: 'c', value: 4}]}
])

Then you can use $in to find documents with certain keys:

db.stuff.find({'dic.key': {$in: ['a', 'b']}})

The especially good thing about this new schema is you can use an index for the $in query:

db.stuff.createIndex({'dic.key': 1})

A disadvantage, as you point out above, is that simple element access like x.dic.a no longer works. You need to do a bit of coding in your language. E.g. in Javascript:

> var doc = {dic: [{key: 'a', value: 3}, {key: 'c', value: 4}]}
> function getValue(doc, key) {
...   return doc.dic.filter(function(elem) {
...     return elem.key == key;
...   })[0].value;
... }
> getValue(doc, "a")
3
> getValue(doc, "c")
4


问:
React, use it to diff an object
I am new to React framework and am starting to use it. I read that it has an excellent diff algorithm. I was wondering can I use it on an object of mine? And run it a second time and get a resulting object with what was added/removed/changed with oldValue and newValue?

Thanks team

答:
I am able to do shallow comparison like this:

You have to use react-with-addons.js.

And then use the React.addons.shallowCompare function.

The first argument must be an object with two keys, props and state. Then the second arg is an object to compare with props key in first arg. And third arg is to an object to compare with state key in first arg. So if you want to use this outside of a React scope just ignore the third arg and do this:

```<code>var isDifferent = React.addons.shallowCompare({props:{a:1}}, {a:2});
</code>```

This will return true as a is 1 in left and 2 in right.

```<code>var isDifferent = React.addons.shallowCompare({props:{a:1}}, {a:1});
</code>```

This will return false as they are both the same.

Title: React, use it to diff an object

Body:
I am able to do shallow comparison like this:

You have to use react-with-addons.js.

And then use the React.addons.shallowCompare function.

The first argument must be an object with two keys, props and state. Then the second arg is an object to compare with props key in first arg. And third arg is to an object to compare with state key in first arg. So if you want to use this outside of a React scope just ignore the third arg and do this:

var isDifferent = React.addons.shallowCompare({props:{a:1}}, {a:2});

This will return true as a is 1 in left and 2 in right.

var isDifferent = React.addons.shallowCompare({props:{a:1}}, {a:1});

This will return false as they are both the same.


问:
The insert statement conflicted with the Foreign Key SQL
I have searched the internet but couldn't find a solution. I am using the following SQL Statement in order to update some cells or create a new row:

```<code>UPDATE [dbo].[PRCRDATALNS]

SET   FLD01 = :TIMX1
     ,FLD02 = :TIML1

WHERE DIM1= :vmtrl AND PRCRULE= '2' AND LINENUM = '1'

IF @@ROWCOUNT=0

INSERT INTO [dbo].[PRCRDATALNS] (

       COMPANY
      ,SODTYPE
      ,SOTYPE
      ,PRCRULE
      ,DIM1
      ,DIM2
      ,DIM3
      ,PRCRDATALNS
      ,LINENUM
      ,FROMDATE
      ,FLD01
      ,FLD02
      ,SCALEQTY
      )

VALUES
        ('1'
        ,'13'
        ,'1'
        ,2
        ,:vmtrl
        ,'0'
        ,'0'
        ,'1'
        ,'1'
        ,GETDATE ( )
        ,:TIMX1
        ,:TIML1
        ,'1'
        );
</code>```

When I execute it and a new row is to be inserted it says: The insert statement conflicted with the FOREIGN KEY constraint "XD_PRCRDATALNS_PRCRULE". The conflict occurred in database "KOMBOS", table "dbo.PRCRDATA". The statement has been terminated.

I am aware of what this means. First of all it isn't mentioned anything about issues in columns like others have. And secondly the table PRCRDATA has all the values that are needed like PRCRULE,SODTYPE,SOTYPE etc.

Where should I look at?

答:
Sorry, but I cannot comment yet, so I need to post an "answer". I would suggest:

Find out what column the FK violation appears against, by checking
the source for dbo.PRCRDATA and what column has the
XD_PRCRDATALNS_PRCRULE constraint.

Having done that you should now be able to see what value is the
offending value in the INSERT statement.

Please let us know how it goes.

Niels

Body:
I have searched the internet but couldn't find a solution. I am using the following SQL Statement in order to update some cells or create a new row:

UPDATE [dbo].[PRCRDATALNS]

SET   FLD01 = :TIMX1
     ,FLD02 = :TIML1

WHERE DIM1= :vmtrl AND PRCRULE= '2' AND LINENUM = '1'

IF @@ROWCOUNT=0

INSERT INTO [dbo].[PRCRDATALNS] (

       COMPANY
      ,SODTYPE
      ,SOTYPE
      ,PRCRULE
      ,DIM1
      ,DIM2
      ,DIM3
      ,PRCRDATALNS
      ,LINENUM
      ,FROMDATE
      ,FLD01
      ,FLD02
      ,SCALEQTY
      )

VALUES
        ('1'
        ,'13'
        ,'1'
        ,2
        ,:vmtrl
        ,'0'
        ,'0'
        ,'1'
        ,'1'
        ,GETDATE ( )
        ,:TIMX1
        ,:TIML1
        ,'1'
        );

When I execute it and a new row is to be inserted it says: The insert statement conflicted with the FOREIGN KEY constraint "XD_PRCRDATALNS_PRCRULE". The conflict occurred in database "KOMBOS", table "dbo.PRCRDATA". The statement has been terminated.

I am aware of what this means. First of all it isn't mentioned anything about issues in columns like others have. And secondly the table PRCRDATA has all the values that are needed like PRCRULE,SODTYPE,SOTYPE etc.

Where should I look at?


问:
CSS: How do I stop hover effects from pushing my text?
I hope you understood the question, you can see an example here:

http://jsfiddle.net/nFbJY/

When you scroll over any of the links they move :(

Any advice on how to solve this issue?

HTML:

```<code><div class="links">
<ul>
<li><a href="home.html">Home</a></li>
<li><a href="pricing.html">Pricing</a></li>
<li><a href="faq.html">FAQ</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
</code>```

CSS:

div.links {float: left; padding-top:15px;}
ul {list-style:none;}
li {float: left; margin: 0 .15em; padding: 3px 10px 3px 10px; border: 1px solid #CCC;          border-radius: 5px; -moz-border-radius: 5px;}
a:hover { border: 1px solid blue; border-radius: 5px; -moz-border-radius: 5px; padding: 3px 10px 3px 10px; background-color:yellow;}
```

答:
Switch the CSS definition a:hover to li:hover.

http://jsfiddle.net/nFbJY/3/

div.links
{
    float: left;
    padding-top:15px;
}
ul
{
    list-style:none;
}
li
{
    float: left;
    margin: 0 .15em;
    padding: 3px 10px 3px 10px;
    border: 1px solid #CCC;
    border-radius: 5px;
    -moz-border-radius: 5px;
}

li:hover
{
    border: 1px solid blue;
    border-radius: 5px;
    -moz-border-radius: 5px;
    padding: 3px 10px 3px 10px;
    background-color:yellow;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="links">
    <ul>
    <li>Home</li>
    <li>Pricing</li>
    <li>FAQ</li>
    <li>About</li>
    <li>Contact</li>
    </ul>
    </div></code>```

Body:
I hope you understood the question, you can see an example here:

http://jsfiddle.net/nFbJY/

When you scroll over any of the links they move :(

Any advice on how to solve this issue?

HTML:

Home

Pricing

FAQ

About

Contact

CSS:

div.links {float: left; padding-top:15px;}
ul {list-style:none;}
li {float: left; margin: 0 .15em; padding: 3px 10px 3px 10px; border: 1px solid #CCC;          border-radius: 5px; -moz-border-radius: 5px;}
a:hover { border: 1px solid blue; border-radius: 5px; -moz-border-radius: 5px; padding: 3px 10px 3px 10px; background-color:yellow;}

Body:
Switch the CSS definition a:hover to li:hover.

http://jsfiddle.net/nFbJY/3/

div.links
{
    float: left;
    padding-top:15px;
}
ul
{
    list-style:none;
}
li
{
    float: left;
    margin: 0 .15em;
    padding: 3px 10px 3px 10px;
    border: 1px solid #CCC;
    border-radius: 5px;
    -moz-border-radius: 5px;
}

li:hover
{
    border: 1px solid blue;
    border-radius: 5px;
    -moz-border-radius: 5px;
    padding: 3px 10px 3px 10px;
    background-color:yellow;
}

<div class="links">
    <ul>
    <li><a href="home.html">Home</a></li>
    <li><a href="pricing.html">Pricing</a></li>
    <li><a href="faq.html">FAQ</a></li>
    <li><a href="about.html">About</a></li>
    <li><a href="contact.html">Contact</a></li>
    </ul>
    </div>


问:
Boost Log: variable is not a member of ‘boost::log::v2s_mt_posix::trivial’
I'd like to switch over different boost::log severity levels using a single variable to control lots of BOOST_TRIVIAL_LOG(lvl) calls.

```<code>// Class header
const boost::log::trivial::severity_level _LVL_DEBUG;

// Class ctor initialize list
#ifdef FOO_MACRO
        _LVL_DEBUG(boost::log::trivial::severity_level::info)
#else
        _LVL_DEBUG(boost::log::trivial::severity_level::debug)
#endif

// Class method
BOOST_LOG_TRIVIAL(_LVL_DEBUG) << "Foo bar";
</code>```

But when g++ compiling I obtain

error: ‘_LVL_DEBUG’ is not a member of ‘boost::log::v2s_mt_posix::trivial’

I'd like to know where I'm missing the point.

Edit 1

Same output with boost::log::trivial::info (or other level ofc)

答:
It's not clear what you're trying to do. BOOST_LOG_TRIVIAL(x) expands the severity level x to boost::log::trivial::severity_level::x, where severity_level is an enum and x is supposed to be a value of that enum.

If you want to control severity levels in compile time then all you have to do is to define your macro like this:

```<code>#ifdef FOO_MACRO
#define _LVL_DEBUG info
#else
#define _LVL_DEBUG debug
#endif
</code>```

Then you use it in logging statements like this:

```<code>BOOST_LOG_TRIVIAL(_LVL_DEBUG) << "Foo bar";
</code>```

If you want runtime control then you can no longer use BOOST_LOG_TRIVIAL and have to use BOOST_LOG_SEV or other macros that take the severity level directly. This also means you would have to create and manage loggers yourself.

Body:
I'd like to switch over different boost::log severity levels using a single variable to control lots of BOOST_TRIVIAL_LOG(lvl) calls.

// Class header
const boost::log::trivial::severity_level _LVL_DEBUG;

// Class ctor initialize list
#ifdef FOO_MACRO
        _LVL_DEBUG(boost::log::trivial::severity_level::info)
#else
        _LVL_DEBUG(boost::log::trivial::severity_level::debug)
#endif

// Class method
BOOST_LOG_TRIVIAL(_LVL_DEBUG) << "Foo bar";

But when g++ compiling I obtain

error: ‘_LVL_DEBUG’ is not a member of ‘boost::log::v2s_mt_posix::trivial’

I'd like to know where I'm missing the point.

Edit 1

Same output with boost::log::trivial::info (or other level ofc)

Body:
It's not clear what you're trying to do. BOOST_LOG_TRIVIAL(x) expands the severity level x to boost::log::trivial::severity_level::x, where severity_level is an enum and x is supposed to be a value of that enum.

If you want to control severity levels in compile time then all you have to do is to define your macro like this:

#ifdef FOO_MACRO
#define _LVL_DEBUG info
#else
#define _LVL_DEBUG debug
#endif

Then you use it in logging statements like this:

BOOST_LOG_TRIVIAL(_LVL_DEBUG) << "Foo bar";

If you want runtime control then you can no longer use BOOST_LOG_TRIVIAL and have to use BOOST_LOG_SEV or other macros that take the severity level directly. This also means you would have to create and manage loggers yourself.


问:
C# non-class obj to JSON
I have several objects containing few variables in my js that are sent to c# with an ajax call. Is there a way to send that same object from c# to js as a json without creating a special custom c# class?
for example i have an object containing several paramaters that are sent to the db to retrieve some data. I want to be able to send those paramaters from c# so i can manipulate them on js.</p>

答:
use the JavaScriptSerializer class and Anonymous objects
you need to import it the JavaScriptSerializer

```<code>using System.Web.Script.Serialization;
//...
var obj = new {a="a", b="b"};//...
var json = new JavaScriptSerializer().Serialize(obj);
</code>```

then simply return it

Title: C# non-class obj to JSON

Body:
use the JavaScriptSerializer class and Anonymous objects
you need to import it the JavaScriptSerializer

using System.Web.Script.Serialization;
//...
var obj = new {a="a", b="b"};//...
var json = new JavaScriptSerializer().Serialize(obj);

then simply return it


问:
javascript absolute beginner = stuck on function returning "undefined"
Just for exercise, I'm trying to print out this pattern:

Here's the code so far:

  var even = " #";
  var odd = "# ";
  var size = 4;
  var rowCount = 1;
  var lineLength = 1;
  function writeOdd(size){
   while(lineLength<=size){
    document.write(odd)
    if(lineLength === size){
    document.write("
")
    }
    lineLength++;
   }
  }
  function writeEven(size){
   while(lineLength<=size){
    document.write(even)
    if(lineLength === size){
    document.write("
")
    }
    lineLength++;
   }
  }
   if(rowCount <= size && rowCount % 2 !== 0) {document.write(writeEven(size));}
      else if(rowCount <= size && rowCount % 2 === 0){document.write(writeOdd(size));}
  rowCount++;```

I'm stuck - first line prints out ok, second gives "undefined" and that's it.

答:
```<code>function print() {
  let flag = true;
  for(let i = 0; i < 4; i++) {
    for(let j = 0; j < 8; j++) {
      flag ? process.stdout.write('#') : process.stdout.write(' ');
      flag = !flag;
    }
    flag = !flag;
    process.stdout.write('\n');
  }
}
print();
</code>```

Body:
Just for exercise, I'm trying to print out this pattern:

Here's the code so far:

  var even = " #";
  var odd = "# ";
  var size = 4;
  var rowCount = 1;
  var lineLength = 1;
  function writeOdd(size){
   while(lineLength<=size){
    document.write(odd)
    if(lineLength === size){
    document.write("
")
    }
    lineLength++;
   }
  }
  function writeEven(size){
   while(lineLength<=size){
    document.write(even)
    if(lineLength === size){
    document.write("
")
    }
    lineLength++;
   }
  }
   if(rowCount <= size && rowCount % 2 !== 0) {document.write(writeEven(size));}
      else if(rowCount <= size && rowCount % 2 === 0){document.write(writeOdd(size));}
  rowCount++;

I'm stuck - first line prints out ok, second gives "undefined" and that's it.


问:
Hierarchical Edge Bundling d3 v4 - simplest 2 node example
I would like to do the simplest Hierarchical Edge Bundling example I can, with two nodes. Once I fully understand how to make that work properly I should (hopefully) be able to dynamically construct the full visualization.

I saw Mike Bostock's D3 V4 example: https://bl.ocks.org/mbostock/7607999 and would like to use the same pattern. However, going through the JSON data it is a bit overwhelming. I was hoping with two nodes I could see how the visualization is constructed.

How would the JSON file look with just two nodes? I am trying to make the absolute easiest I can to try and learn how it works. Any help is appreciated.

I can't paste the JSON in here because it exceeds the maximum number of characters. For reference please check out:
https://bl.ocks.org/mbostock/7607999#flare.json

答:
Here is the data using 3 nodes (visualization would not have been much useful with 2 nodes):

```<code>var data = [{
  "name": "iit.mumbai.pub1",
  "imports": ["iit.chennai.pub3"]
}, {
  "name": "iit.delhi.pub2",
  "imports": ["iit.mumbai.pub1"]
}, {
  "name": "iit.chennai.pub3",
  "imports": ["iit.delhi.pub2"]
}];
</code>```

Here is how it would look: https://bl.ocks.org/ckothari/raw/473320621a15a7ee1ed684bf3feb4255/.

I have taken example of academic publications in the above example. The dots in the names represent the hierarchal relationships, so in this example iit (Institute) has 3 children (locations) mumbai, delhi and chennai, and these have children (publications) pub1, pub2 and pub3 respectively.

imports in the json represents relation between the leaf nodes. Publication pub1 has citation for publication pub3, pub2 cites pub1 and pub3 cites pub2.

Body:
Here is the data using 3 nodes (visualization would not have been much useful with 2 nodes):

var data = [{
  "name": "iit.mumbai.pub1",
  "imports": ["iit.chennai.pub3"]
}, {
  "name": "iit.delhi.pub2",
  "imports": ["iit.mumbai.pub1"]
}, {
  "name": "iit.chennai.pub3",
  "imports": ["iit.delhi.pub2"]
}];

Here is how it would look: https://bl.ocks.org/ckothari/raw/473320621a15a7ee1ed684bf3feb4255/.

I have taken example of academic publications in the above example. The dots in the names represent the hierarchal relationships, so in this example iit (Institute) has 3 children (locations) mumbai, delhi and chennai, and these have children (publications) pub1, pub2 and pub3 respectively.

imports in the json represents relation between the leaf nodes. Publication pub1 has citation for publication pub3, pub2 cites pub1 and pub3 cites pub2.


答:
If you use apache2 just include following line into your .htaccess file:

```<code><IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{HTTP_USER_AGENT} ^(.*)Jorgee$
  RewriteRule .* - [F]
</IfModule>
</code>```

So the bot will receive a 403 error and the request is not forwarded to your php application (which probably would open a database connection to respond with a 404 error)

Title: What is the goal of somebody probing my aws ec2 instance with apache2?

Body:
From access.log I found weird visiting pattern. What would be the purpose of this kind of probing?

219.106.219.16 - - [11/Mar/2016:15:00:14 +0200] "HEAD my.aws.ec2.instance:80/1phpmyadmin/ HTTP/1.1" 404 195 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:14 +0200] "HEAD my.aws.ec2.instance:80/2phpmyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:14 +0200] "HEAD my.aws.ec2.instance:80/3phpmyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:15 +0200] "HEAD my.aws.ec2.instance:80/4phpmyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:15 +0200] "HEAD my.aws.ec2.instance:80/MyAdmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:15 +0200] "HEAD my.aws.ec2.instance:80/PMA/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:15 +0200] "HEAD my.aws.ec2.instance:80/PMA2011/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:16 +0200] "HEAD my.aws.ec2.instance:80/PMA2012/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:16 +0200] "HEAD my.aws.ec2.instance:80/PMA2013/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:16 +0200] "HEAD my.aws.ec2.instance:80/PMA2014/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:17 +0200] "HEAD my.aws.ec2.instance:80/PMA2015/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:17 +0200] "HEAD my.aws.ec2.instance:80/admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:17 +0200] "HEAD my.aws.ec2.instance:80/admin/db/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:17 +0200] "HEAD my.aws.ec2.instance:80/admin/pMA/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:18 +0200] "HEAD my.aws.ec2.instance:80/admin/phpMyAdmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:18 +0200] "HEAD my.aws.ec2.instance:80/admin/phpmyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:18 +0200] "HEAD my.aws.ec2.instance:80/admin/sqladmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:19 +0200] "HEAD my.aws.ec2.instance:80/admin/sysadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:19 +0200] "HEAD my.aws.ec2.instance:80/admin/web/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:19 +0200] "HEAD my.aws.ec2.instance:80/administrator/PMA/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:19 +0200] "HEAD my.aws.ec2.instance:80/administrator/admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:20 +0200] "HEAD my.aws.ec2.instance:80/administrator/db/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:20 +0200] "HEAD my.aws.ec2.instance:80/administrator/phpMyAdmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:20 +0200] "HEAD my.aws.ec2.instance:80/administrator/phpmyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:20 +0200] "HEAD my.aws.ec2.instance:80/administrator/pma/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:21 +0200] "HEAD my.aws.ec2.instance:80/administrator/web/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:21 +0200] "HEAD my.aws.ec2.instance:80/database/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:21 +0200] "HEAD my.aws.ec2.instance:80/db/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:22 +0200] "HEAD my.aws.ec2.instance:80/db/db-admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:22 +0200] "HEAD my.aws.ec2.instance:80/db/dbadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:22 +0200] "HEAD my.aws.ec2.instance:80/db/dbweb/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:22 +0200] "HEAD my.aws.ec2.instance:80/db/myadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:23 +0200] "HEAD my.aws.ec2.instance:80/db/phpMyAdmin-3/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:23 +0200] "HEAD my.aws.ec2.instance:80/db/phpMyAdmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:23 +0200] "HEAD my.aws.ec2.instance:80/db/phpMyAdmin3/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:24 +0200] "HEAD my.aws.ec2.instance:80/db/phpmyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:24 +0200] "HEAD my.aws.ec2.instance:80/db/phpmyadmin3/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:24 +0200] "HEAD my.aws.ec2.instance:80/db/webadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:24 +0200] "HEAD my.aws.ec2.instance:80/db/webdb/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:25 +0200] "HEAD my.aws.ec2.instance:80/db/websql/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:25 +0200] "HEAD my.aws.ec2.instance:80/dbadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:25 +0200] "HEAD my.aws.ec2.instance:80/myadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:26 +0200] "HEAD my.aws.ec2.instance:80/myadminphp/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:26 +0200] "HEAD my.aws.ec2.instance:80/mysql-admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:26 +0200] "HEAD my.aws.ec2.instance:80/mysql/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:26 +0200] "HEAD my.aws.ec2.instance:80/mysql/admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:27 +0200] "HEAD my.aws.ec2.instance:80/mysql/db/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:27 +0200] "HEAD my.aws.ec2.instance:80/mysql/dbadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:27 +0200] "HEAD my.aws.ec2.instance:80/mysql/mysqlmanager/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:27 +0200] "HEAD my.aws.ec2.instance:80/mysql/pMA/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:28 +0200] "HEAD my.aws.ec2.instance:80/mysql/pma/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:28 +0200] "HEAD my.aws.ec2.instance:80/mysql/sqlmanager/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:28 +0200] "HEAD my.aws.ec2.instance:80/mysql/web/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:29 +0200] "HEAD my.aws.ec2.instance:80/mysqladmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:29 +0200] "HEAD my.aws.ec2.instance:80/mysqlmanager/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:29 +0200] "HEAD my.aws.ec2.instance:80/php-my-admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:29 +0200] "HEAD my.aws.ec2.instance:80/php-myadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:30 +0200] "HEAD my.aws.ec2.instance:80/phpMyAdmin-2/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:30 +0200] "HEAD my.aws.ec2.instance:80/phpMyAdmin-3/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:30 +0200] "HEAD my.aws.ec2.instance:80/phpMyAdmin-4/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:31 +0200] "HEAD my.aws.ec2.instance:80/phpMyAdmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:31 +0200] "HEAD my.aws.ec2.instance:80/phpMyAdmin2/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:31 +0200] "HEAD my.aws.ec2.instance:80/phpMyAdmin3/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:31 +0200] "HEAD my.aws.ec2.instance:80/phpMyAdmin4/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:32 +0200] "HEAD my.aws.ec2.instance:80/phpMyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:32 +0200] "HEAD my.aws.ec2.instance:80/phpmanager/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:32 +0200] "HEAD my.aws.ec2.instance:80/phpmy-admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:32 +0200] "HEAD my.aws.ec2.instance:80/phpmy/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:33 +0200] "HEAD my.aws.ec2.instance:80/phpmyAdmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:33 +0200] "HEAD my.aws.ec2.instance:80/phpmyadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:33 +0200] "HEAD my.aws.ec2.instance:80/phpmyadmin1/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:34 +0200] "HEAD my.aws.ec2.instance:80/phpmyadmin2/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:34 +0200] "HEAD my.aws.ec2.instance:80/phpmyadmin3/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:34 +0200] "HEAD my.aws.ec2.instance:80/phpmyadmin4/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:34 +0200] "HEAD my.aws.ec2.instance:80/phppma/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:35 +0200] "HEAD my.aws.ec2.instance:80/pma/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:35 +0200] "HEAD my.aws.ec2.instance:80/pma2011/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:35 +0200] "HEAD my.aws.ec2.instance:80/pma2012/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:36 +0200] "HEAD my.aws.ec2.instance:80/pma2013/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:36 +0200] "HEAD my.aws.ec2.instance:80/pma2014/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:36 +0200] "HEAD my.aws.ec2.instance:80/pma2015/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:36 +0200] "HEAD my.aws.ec2.instance:80/program/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:37 +0200] "HEAD my.aws.ec2.instance:80/shopdb/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:37 +0200] "HEAD my.aws.ec2.instance:80/sql/myadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:37 +0200] "HEAD my.aws.ec2.instance:80/sql/php-myadmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:38 +0200] "HEAD my.aws.ec2.instance:80/sql/phpMyAdmin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:38 +0200] "HEAD my.aws.ec2.instance:80/sql/phpMyAdmin2/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:38 +0200] "HEAD my.aws.ec2.instance:80/sql/phpMyAdmin3/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:38 +0200] "HEAD my.aws.ec2.instance:80/sql/phpMyAdmin4/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:39 +0200] "HEAD my.aws.ec2.instance:80/sql/phpmanager/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:39 +0200] "HEAD my.aws.ec2.instance:80/sql/phpmy-admin/ HTTP/1.1" 404 194 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:39 +0200] "HEAD my.aws.ec2.instance:80/sql/phpmyadmin2/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:39 +0200] "HEAD my.aws.ec2.instance:80/sql/phpmyadmin3/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:40 +0200] "HEAD my.aws.ec2.instance:80/sql/phpmyadmin4/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:40 +0200] "HEAD my.aws.ec2.instance:80/sql/sql-admin/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:40 +0200] "HEAD my.aws.ec2.instance:80/sql/sql/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:41 +0200] "HEAD my.aws.ec2.instance:80/sql/sqladmin/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:41 +0200] "HEAD my.aws.ec2.instance:80/sql/sqlweb/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:41 +0200] "HEAD my.aws.ec2.instance:80/sql/webadmin/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:41 +0200] "HEAD my.aws.ec2.instance:80/sql/webdb/ HTTP/1.1" 404 193 "-" "Mozilla/5.0 Jorgee"
219.106.219.16 - - [11/Mar/2016:15:00:42 +0200] "HEAD my.aws.ec2.instance:80/sql/websql/ HTTP/1.1" 404 158 "-" "Mozilla/5.0 Jorgee"

Body:
If you use apache2 just include following line into your .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{HTTP_USER_AGENT} ^(.*)Jorgee$
  RewriteRule .* - [F]
</IfModule>

So the bot will receive a 403 error and the request is not forwarded to your php application (which probably would open a database connection to respond with a 404 error)


问:
How to modify a MP3 metadata and save by Node.js?
I want to achieve below goals:

Read a MP3 metadata

Modify the encoding of that metadata (if I could modify the content of that metadata, that would be better)

Save the modification to that MP3 file

All these operations could be based on native Node.js (without browser). Is there any module provide such function or I can develop based on?

答:
So far i found jsmediatags is best npm package to read ID3v2 tags

```<code>var jsmediatags = require("jsmediatags");

jsmediatags.read("./song.mp3", {
  onSuccess: function(tag) {
    console.log(tag);
  },
  onError: function(error) {
    console.log(':(', error.type, error.info);
  }
});
</code>```

Body:
So far i found jsmediatags is best npm package to read ID3v2 tags

var jsmediatags = require("jsmediatags");

jsmediatags.read("./song.mp3", {
  onSuccess: function(tag) {
    console.log(tag);
  },
  onError: function(error) {
    console.log(':(', error.type, error.info);
  }
});


问:
AngularJS routeParam not working
I have url like this:

```<code>http://localhost:3000/details/59567bc1de7ddb2d5feff262
</code>```

and I want to get the parameter id

```<code>59567bc1de7ddb2d5feff262
</code>```

But for some reasons routeParam always returns undefined

My controller is:

```<code>task.controller('ctrla',  function($rootScope, $scope, $http, $timeout, $routeParams){
    $scope.first = 1;
    console.log($routeParams);
});
</code>```

routes :

```<code>task.config(function ($routeProvider, $locationProvider){
$routeProvider.when('/details/:id', {
      templateUrl: "details.html",
      controller: "ctrla"
    })

});
</code>```

any help will be a life save.

答:
Make sure you have defined the route urls as mentioned below,

```<code>app.config(['$routeProvider', function($routeProvider) {
  $routeProvider
    .when('/home', {
      template: "HI this is home Screen",
      controller: 'ctrla'
    })
    .when('/details/:id', {
      templateUrl: "template.html",
      controller: 'profileController'
    })
    .otherwise({
      redirectTo: '/home'
    })
}]);
</code>```

DEMO

Title: AngularJS routeParam not working

Body:
I have url like this:

http://localhost:3000/details/59567bc1de7ddb2d5feff262

and I want to get the parameter id

59567bc1de7ddb2d5feff262

But for some reasons routeParam always returns undefined

My controller is:

task.controller('ctrla',  function($rootScope, $scope, $http, $timeout, $routeParams){
    $scope.first = 1;
    console.log($routeParams);
});

routes :

task.config(function ($routeProvider, $locationProvider){
$routeProvider.when('/details/:id', {
      templateUrl: "details.html",
      controller: "ctrla"
    })

});

any help will be a life save.

Body:
Make sure you have defined the route urls as mentioned below,

app.config(['$routeProvider', function($routeProvider) {
  $routeProvider
    .when('/home', {
      template: "HI this is home Screen",
      controller: 'ctrla'
    })
    .when('/details/:id', {
      templateUrl: "template.html",
      controller: 'profileController'
    })
    .otherwise({
      redirectTo: '/home'
    })
}]);

DEMO


问:
asp.net core nuspec project dependency
I got a couple of projects made with asp.net core that I wanted to export to NuGet. Everything was fine with the first version (0.9.0). But when I updated a package to 0.9.1, I started having version issues, cause the app started looking for all dependencies with version 0.9.1 (even though only one was updated and the others remained at 0.9.0)

Could anyone check my config and see where am I making my mistake?
Thanks!

These are the errors I got:

```<code>FileLoadException: Could not load file or assembly 'Framework.Web, Version=0.9.1.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

FileLoadException: Could not load file or assembly 'Framework.Web, Version=0.9.1.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
</code>```

This is my nuspec file:

```<code><?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
    <!-- Required elements-->
    <id>Framework.Web.Mvc</id>
    <version>0.9.1</version>
    <description>Framework web MVC library</description>
    <authors>Lucas Leite</authors>

    <!-- Optional elements -->
    <dependencies>
      <dependency id="Framework.Web" version="0.9.0" />
      <dependency id="Framework.Model" version="0.9.0" />
      <dependency id="Microsoft.AspNetCore.Localization.Routing" version="1.1.2" />
      <dependency id="Microsoft.AspNetCore.Mvc" version="1.1.3" />
    </dependencies>
    <!-- ... -->
  </metadata>
  <!-- Optional 'files' node -->
  <files>
    <file src="bin\Release\netcoreapp1.1\Framework.Web.Mvc.dll" target="lib\netcoreapp1.1" />
    <file src="bin\Release\netcoreapp1.1\Framework.Web.Mvc.xml" target="lib\netcoreapp1.1" />
    <file src="bin\Release\netcoreapp1.1\pt-BR\Framework.Web.Mvc.resources.dll" target="lib\netcoreapp1.1\pt-BR" />
  </files>
</package>
</code>```

答:
Try to change dependency version to (,0.9.0]:

```<code><dependency id="Framework.Web" version="(,0.9.0]" />
</code>```

Accordingly to Nuget dependency versioning,

```<code><!-- Accepts any version 0.9.0 and above -->
<dependency id="Framework.Web" version="0.9.0" />
</code>```

and

```<code><!-- Accepts any version up below or include 0.9.0-->
<dependency id="ExamplePackage" version="(,0.9.0]" />
</code>```

Title: asp.net core nuspec project dependency

Body:
I got a couple of projects made with asp.net core that I wanted to export to NuGet. Everything was fine with the first version (0.9.0). But when I updated a package to 0.9.1, I started having version issues, cause the app started looking for all dependencies with version 0.9.1 (even though only one was updated and the others remained at 0.9.0)

Could anyone check my config and see where am I making my mistake?
Thanks!

These are the errors I got:

FileLoadException: Could not load file or assembly 'Framework.Web, Version=0.9.1.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

FileLoadException: Could not load file or assembly 'Framework.Web, Version=0.9.1.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This is my nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>

    <id>Framework.Web.Mvc</id>
    <version>0.9.1</version>
    <description>Framework web MVC library</description>
    <authors>Lucas Leite</authors>

    <dependencies>
      <dependency id="Framework.Web" version="0.9.0" />
      <dependency id="Framework.Model" version="0.9.0" />
      <dependency id="Microsoft.AspNetCore.Localization.Routing" version="1.1.2" />
      <dependency id="Microsoft.AspNetCore.Mvc" version="1.1.3" />
    </dependencies>

  </metadata>

  <files>
    <file src="bin\Release\netcoreapp1.1\Framework.Web.Mvc.dll" target="lib\netcoreapp1.1" />
    <file src="bin\Release\netcoreapp1.1\Framework.Web.Mvc.xml" target="lib\netcoreapp1.1" />
    <file src="bin\Release\netcoreapp1.1\pt-BR\Framework.Web.Mvc.resources.dll" target="lib\netcoreapp1.1\pt-BR" />
  </files>
</package>

Body:
Try to change dependency version to (,0.9.0]:

<dependency id="Framework.Web" version="(,0.9.0]" />

Accordingly to Nuget dependency versioning,

<!-- Accepts any version 0.9.0 and above -->
<dependency id="Framework.Web" version="0.9.0" />

and

<!-- Accepts any version up below or include 0.9.0-->
<dependency id="ExamplePackage" version="(,0.9.0]" />


问:
What does the following Array initialization syntax actually create?
What does the following actually create?

I ask because it cannot be enumerated with Array#foreach and it is represented (misleadingly?) in Chrome console as [undefined x 10].

```<code>const arr = new Array(10);
</code>```

答:
The following two snippets are equivalent:

```<code>const arr = new Array(10)
</code>```

and

```<code>const arr = [,,,,,,,,,,]
</code>```

as can be demonstrated here:

const arr1 = new Array(10)
const arr2 = [,,,,,,,,,,]

let empty1 = true

for (let index = 0; empty1 && index < arr1.length; index++) {
  if (arr1.hasOwnProperty(index)) {
    empty1 = false
  }
}

let empty2 = true

for (let index = 0; empty1 && index < arr2.length; index++) {
  if (arr2.hasOwnProperty(index)) {
    empty2 = false
  }
}

console.log(empty1)
console.log(empty2)```
</div>
</div>
</p>

<p>This means that for all indices from <code>[0, length - 1]</code>, they don't actually exist on the array because <code>arr.hasOwnProperty(index)</code> is <code>false</code>. This is distinguished from this example:</p>

```const arr = new Array(10).fill()
```

<p>demonstrated here:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const arr = new Array(10).fill()

console.log(arr.every((_, index) => arr.hasOwnProperty(index)))</code>```

So if you want to initialize each index in a constructed array with undefined, just call .fill() without any arguments.

Body:
What does the following actually create?

I ask because it cannot be enumerated with Array#foreach and it is represented (misleadingly?) in Chrome console as [undefined x 10].

const arr = new Array(10);

Body:
The following two snippets are equivalent:

const arr = new Array(10)

and

const arr = [,,,,,,,,,,]

as can be demonstrated here:

const arr1 = new Array(10)
const arr2 = [,,,,,,,,,,]

let empty1 = true

for (let index = 0; empty1 && index < arr1.length; index++) {
  if (arr1.hasOwnProperty(index)) {
    empty1 = false
  }
}

let empty2 = true

for (let index = 0; empty1 && index < arr2.length; index++) {
  if (arr2.hasOwnProperty(index)) {
    empty2 = false
  }
}

console.log(empty1)
console.log(empty2)

This means that for all indices from [0, length - 1], they don't actually exist on the array because arr.hasOwnProperty(index) is false. This is distinguished from this example:

const arr = new Array(10).fill()

demonstrated here:

const arr = new Array(10).fill()

console.log(arr.every((_, index) => arr.hasOwnProperty(index)))

So if you want to initialize each index in a constructed array with undefined, just call .fill() without any arguments.


答:
The issue is in document.write(writeEven(size)) and document.write(writeOdd(size)). writeEven and writeOdd don't explicitly return anything. When a function doesn't explicitly return anything, it will return undefined by default. So when those functions return, undefined gets passed in to document.write, and is written to the screen.

Note that document.write(writeOdd(size)) gets evaluated from the inside out. First writeOdd(size) is executed. Then it returns. The return value basically takes its place, giving us document.write(undefined). Then document.write(undefined) is executed, and prints "undefined" to the screen.

Check out https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Return_values for more information on return values.

Title: javascript absolute beginner = stuck on function returning "undefined"


问:
Is it considered accepted using var's as "shortcuts" in c#?
One use for the var type in c# seems to be shortcuts/simplifying/save unnecessary typing. One thing that I've considered is this:

MyApp.Properties.Settings.Default.Value=1;

That's a ton of unnecessary code. An alternative to this is declaring:

```<code>using MyApp.Properties;
</code>```

-- or --

```<code>using appsettings = MyAppp.Properties.Settings;
</code>```

leading to: appsettings.Default.Value=1 or Settings.Default.Value=1

Abit better, but I'd like it shorter still:

```<code>var appsettings = MyFirstCSharpApp.Properties.Settings.Default;
appsettings.Value=1;
</code>```

Finally, it's short enough, and it could be used for other annoyingly long calls too but is this an accepted way of doing it? I'm considering whether the "shortcut var" will always be pointing to the existing instance of whatever I'm making a shortcut too? (obviously not just the settings as in this example)

答:
Just be careful to know that the static variables you are referencing do not change from underneath you.  For instance, the following would break your "shortcut":

```<code>var appsettings = MyFirstCSharpApp.Properties.Settings.Default;
MyFirstCSharpApp.Properties.Settings.Default = new DefaultSettings(); // new reference
appsettings.Value=1;
</code>```

Of course, I am not suggesting that you would ever write code that does this, but we are talking about global variables here... any code anywhere can change out this reference.  Caching the reference in appsettings CAN be dangerous in cases like these... one of the many pitfalls of being coupled to static variables, IMO.

ContentLicense: CC BY-SA 2.5

Body:
One use for the var type in c# seems to be shortcuts/simplifying/save unnecessary typing. One thing that I've considered is this:

MyApp.Properties.Settings.Default.Value=1;

That's a ton of unnecessary code. An alternative to this is declaring:

using MyApp.Properties;

-- or --

using appsettings = MyAppp.Properties.Settings;

leading to: appsettings.Default.Value=1 or Settings.Default.Value=1

Abit better, but I'd like it shorter still:

var appsettings = MyFirstCSharpApp.Properties.Settings.Default;
appsettings.Value=1;

Finally, it's short enough, and it could be used for other annoyingly long calls too but is this an accepted way of doing it? I'm considering whether the "shortcut var" will always be pointing to the existing instance of whatever I'm making a shortcut too? (obviously not just the settings as in this example)

Body:
Just be careful to know that the static variables you are referencing do not change from underneath you.  For instance, the following would break your "shortcut":

var appsettings = MyFirstCSharpApp.Properties.Settings.Default;
MyFirstCSharpApp.Properties.Settings.Default = new DefaultSettings(); // new reference
appsettings.Value=1;

Of course, I am not suggesting that you would ever write code that does this, but we are talking about global variables here... any code anywhere can change out this reference.  Caching the reference in appsettings CAN be dangerous in cases like these... one of the many pitfalls of being coupled to static variables, IMO.


问:
Got Apache Tomcat error that access denied on this file localhost_access_log.2014-08-30.txt?
I installed Tomcat on Windows 7 OS. I just installed Tomcat and made it available in eclipse. When i run any simple application on server it will say 404: page not found and in console it will print the error message like this.

```<code>SEVERE: Failed to open access log file [C:\Program Files\Apache Software           Foundation\Tomcat 7.0\logs\localhost_access_log.2014-08-30.txt]
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat      7.0\logs\localhost_access_log.2014-08-30.txt (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.catalina.valves.AccessLogValve.open(AccessLogValve.java:1117)
at org.apache.catalina.valves.AccessLogValve.startInternal(AccessLogValve.java:1224)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:185)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1137)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
</code>```

I cannot understand what the things is happen is this??? Please help me.

答:
 Open Tomcat C:\Program Files\Apache Software Foundation
(Right Click on Tomcat 8.5 ( as per Your Version)

→Properties

→Select Security Tab

→Edit
 →Select Your System
 →Check or Allow all the Boxes

→Click on Apply

→Restart Program

Body:
I installed Tomcat on Windows 7 OS. I just installed Tomcat and made it available in eclipse. When i run any simple application on server it will say 404: page not found and in console it will print the error message like this.

SEVERE: Failed to open access log file [C:\Program Files\Apache Software           Foundation\Tomcat 7.0\logs\localhost_access_log.2014-08-30.txt]
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat      7.0\logs\localhost_access_log.2014-08-30.txt (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.catalina.valves.AccessLogValve.open(AccessLogValve.java:1117)
at org.apache.catalina.valves.AccessLogValve.startInternal(AccessLogValve.java:1224)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:185)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1137)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I cannot understand what the things is happen is this??? Please help me.

Body:
 Open Tomcat C:\Program Files\Apache Software Foundation <br>(Right Click on Tomcat 8.5 ( as per Your Version)<br>
→Properties <br>
→Select Security Tab <br>
→Edit <br> →Select Your System <br> →Check or Allow all the Boxes <br>
→Click on Apply <br>
→Restart Program


问:
Service fabric actors state
We are planning to use Service fabric actor model for one of our user services. We have thousands of users and they have their own profile data. By far reading the materials, service fabric actor model maintains its states with their service fabric cluster. I couldn't get a clear picture in disaster recovery/planned shutdown scenarios/offline data access. In such cases, Is it needed to persist the data out side of these actor service?

What happens to the data, if we decided to shutdown all the service fabric cluster one day, and wanted to reactivate few days later?

答:
In an SF cluster in Azure, the data is stored on the temp drive. There's no guarantee that a node that is shutdown retains the temp drive. So shutting down all nodes simultaneously will result in data loss.

To avoid this, you should regularly create backups of your (Actor) Services. For instance by using this Nuget package. Store the resulting files outside the cluster.

The cluster technology will help keep your data safe during failures of nodes, e.g. in a 5 node cluster, 4 remaining healthy nodes can take over the work of a failed node. Data is stored redundantly, so your services remain operational. The same functionality also allows for rolling upgrades of services/actors.

Here's an article about DR.

Title: Service fabric actors state


问:
c++ , error: 'shared_ptr' in namespace 'std' does not name a template type
I tried to define a smart pointer to my structure with rhapsody and I have already  included the header file "memory". But I ve got the error above</p>

```<code> typedef std::shared_ptr<my_structure> %s;
</code>```

答:
no %  needed
access specifier comes up with % usually in printf("%s",arg);

best way is
std::shared_ptr ptr;

Body:
I tried to define a smart pointer to my structure with rhapsody and I have already  included the header file "memory". But I ve got the error above

 typedef std::shared_ptr<my_structure> %s;


问:
Tableau - Filter has one value always selected
I need to create a dashboard in which there is one chart with bars for different Product Types. I am using this chart as a filter. I want one value of Product Type as always selected while I can select/deselect other product types.

For Example I have 4 product Types - A,B,C,D. I want A to be always selected while I can select one of B, C or D to filter other charts based on this selection.

I can have the product type A hidden from the chart too.

答:
I hope if you follow the steps given in below answer then you should be able to solve your issue.
Hide value in filter - Tableau

The only change which you would require is in the definition of calculated field:

```<code>IF [parm_field] == 'All' THEN 'Y'
ELSE
  IF (([parm_field]=[dim_field]) or ([dim_field]=='0')) THEN 'Y'     //in your case just replace '0' by 'A'
  ELSE 'N'
  END
END
</code>```

Kindly don't forget to let us know if it solves your problem :)

Body:
I hope if you follow the steps given in below answer then you should be able to solve your issue.
Hide value in filter - Tableau

The only change which you would require is in the definition of calculated field:

IF [parm_field] == 'All' THEN 'Y'
ELSE
  IF (([parm_field]=[dim_field]) or ([dim_field]=='0')) THEN 'Y'     //in your case just replace '0' by 'A'
  ELSE 'N'
  END
END

Kindly don't forget to let us know if it solves your problem :)