问:
UIView Expand to Content inside
I have a function that returns a UIView. I want to dynamically change the size of my UIView(fullView) based on how much text is shown in the UITextView (thirdTextView). I currently have my height set at 200. How can I achieve a 'dynamic height'?

EDIT: Updated code so far. Is only working when a subView is added to the View. I don't want this...

```<code>func returnView(text1: String, text2: String) -> UIView {

    let fullView = UIView()

    fullView.backgroundColor = UIColor(red:0.82, green:0.83, blue:0.85, alpha:1.0)
    fullView.translatesAutoresizingMaskIntoConstraints = false
    let firstButton = UIButton()
    firstButton.translatesAutoresizingMaskIntoConstraints = false
    let secondButton = UIButton()
    secondButton.translatesAutoresizingMaskIntoConstraints = false
    let thirdTextView = UITextView()
    thirdTextView.translatesAutoresizingMaskIntoConstraints = false
    thirdTextView.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
    thirdTextView.backgroundColor = .clear
    thirdTextView.isScrollEnabled = false

    firstButton.setTitle("Button1", for: .normal)
    firstButton.setTitleColor(.black, for: .normal)
    firstButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium)
    firstButton.contentHorizontalAlignment = .left

    secondButton.setTitle("Button2", for: .normal)
    secondButton.setTitleColor(.black, for: .normal)
    secondButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium)
    secondButton.contentHorizontalAlignment = .right

    let descriptionBarStackView =  UIStackView(arrangedSubviews: [firstButton, UIView() ,secondButton])
    descriptionBarStackView.translatesAutoresizingMaskIntoConstraints = false
    descriptionBarStackView.axis = .horizontal
    descriptionBarStackView.alignment = .fill

    let viewWithStackViews = UIStackView(arrangedSubviews: [descriptionBarStackView, thirdTextView])
    viewWithStackViews.translatesAutoresizingMaskIntoConstraints = false
    viewWithStackViews.axis = .vertical
    viewWithStackViews.layoutMargins = UIEdgeInsets(top: 15, left: 10, bottom: 10, right:10)
    viewWithStackViews.isLayoutMarginsRelativeArrangement = true
    fullView.addSubview(viewWithStackViews)

//        view.addSubview(fullView)

    fullView.leadingAnchor.constraint(equalTo: viewWithStackViews.leadingAnchor).isActive = true
    fullView.trailingAnchor.constraint(equalTo: viewWithStackViews.trailingAnchor).isActive = true
    fullView.topAnchor.constraint(equalTo: viewWithStackViews.topAnchor).isActive = true
    fullView.bottomAnchor.constraint(equalTo: viewWithStackViews.bottomAnchor).isActive = true

    fullView.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -10).isActive = true
    fullView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    fullView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

    fullView.layer.cornerRadius = 5

    return fullView
}
</code>```

答:
Give delegate of textview to the class

on textViewDidChange delegate method of textview, give height

In your scenario,

```<code>func textViewDidChange(_ textView: UITextView) {

    thirdTextView.contentSize.height = textView.contentSize.height

}
</code>```

Title: UIView Expand to Content inside

Body:
I have a function that returns a UIView. I want to dynamically change the size of my UIView(fullView) based on how much text is shown in the UITextView (thirdTextView). I currently have my height set at 200. How can I achieve a 'dynamic height'?

EDIT: Updated code so far. Is only working when a subView is added to the View. I don't want this...

func returnView(text1: String, text2: String) -> UIView {

    let fullView = UIView()

    fullView.backgroundColor = UIColor(red:0.82, green:0.83, blue:0.85, alpha:1.0)
    fullView.translatesAutoresizingMaskIntoConstraints = false
    let firstButton = UIButton()
    firstButton.translatesAutoresizingMaskIntoConstraints = false
    let secondButton = UIButton()
    secondButton.translatesAutoresizingMaskIntoConstraints = false
    let thirdTextView = UITextView()
    thirdTextView.translatesAutoresizingMaskIntoConstraints = false
    thirdTextView.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
    thirdTextView.backgroundColor = .clear
    thirdTextView.isScrollEnabled = false

    firstButton.setTitle("Button1", for: .normal)
    firstButton.setTitleColor(.black, for: .normal)
    firstButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium)
    firstButton.contentHorizontalAlignment = .left

    secondButton.setTitle("Button2", for: .normal)
    secondButton.setTitleColor(.black, for: .normal)
    secondButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium)
    secondButton.contentHorizontalAlignment = .right

    let descriptionBarStackView =  UIStackView(arrangedSubviews: [firstButton, UIView() ,secondButton])
    descriptionBarStackView.translatesAutoresizingMaskIntoConstraints = false
    descriptionBarStackView.axis = .horizontal
    descriptionBarStackView.alignment = .fill

    let viewWithStackViews = UIStackView(arrangedSubviews: [descriptionBarStackView, thirdTextView])
    viewWithStackViews.translatesAutoresizingMaskIntoConstraints = false
    viewWithStackViews.axis = .vertical
    viewWithStackViews.layoutMargins = UIEdgeInsets(top: 15, left: 10, bottom: 10, right:10)
    viewWithStackViews.isLayoutMarginsRelativeArrangement = true
    fullView.addSubview(viewWithStackViews)

//        view.addSubview(fullView)

    fullView.leadingAnchor.constraint(equalTo: viewWithStackViews.leadingAnchor).isActive = true
    fullView.trailingAnchor.constraint(equalTo: viewWithStackViews.trailingAnchor).isActive = true
    fullView.topAnchor.constraint(equalTo: viewWithStackViews.topAnchor).isActive = true
    fullView.bottomAnchor.constraint(equalTo: viewWithStackViews.bottomAnchor).isActive = true

    fullView.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -10).isActive = true
    fullView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    fullView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

    fullView.layer.cornerRadius = 5

    return fullView
}

Body:
Give delegate of textview to the class

on textViewDidChange delegate method of textview, give height

In your scenario,

func textViewDidChange(_ textView: UITextView) {

    thirdTextView.contentSize.height = textView.contentSize.height

}


来源: stackexchange

问:
Ruby on Rails Cron Job Example
Hi um quite new to rails platform and um looking for a rails cron job scheduling tutorials . I ve gone through with tutorials use whenever and the other scheduling gems , but um looking for a core ruby implementation with the cron tab on rails . Thank you in advance</p>

答:
I'm using rufus-scheduler, It uses threads to execute functions scheduled. Very simple to configure. just 3 steps:

1 - Add gem gem 'rufus-scheduler', '~> 3.6'

2 - Create file config/initializers/scheduler.rb

3 - Programming schedule in scheduler.rb:

```<code>require 'rufus-scheduler'
s = Rufus::Scheduler.singleton
s.every '5s' do
    #do every 5 seconds exec this code
    puts "WOWWWWWWWWWWWWWWWWWWWW"
end

s.in '2d' do
  # every 2 days exec this
  puts "Now it's me"
end
</code>```

For more doubts : https://github.com/jmettraux/rufus-scheduler

ContentLicense: CC BY-SA 3.0

Title: Ruby on Rails Cron Job Example

Body:
I'm using rufus-scheduler, It uses threads to execute functions scheduled. Very simple to configure. just 3 steps:

1 - Add gem gem 'rufus-scheduler', '~> 3.6'

2 - Create file config/initializers/scheduler.rb

3 - Programming schedule in scheduler.rb:

require 'rufus-scheduler'
s = Rufus::Scheduler.singleton
s.every '5s' do
    #do every 5 seconds exec this code
    puts "WOWWWWWWWWWWWWWWWWWWWW"
end

s.in '2d' do
  # every 2 days exec this
  puts "Now it's me"
end

For more doubts : https://github.com/jmettraux/rufus-scheduler

ContentLicense: CC BY-SA 4.0


问:
SQL Server : join table to itself to show data horizontally
I have a table that contains students marks (StudentsID, Subject, Year, Mark).

I want to display the Marks horizontally for the same Student, subject but different year.

The problem I have is that not all subjects available in all years, I mean the student can take different subject every year. and I want to show them all in one table horizontally.

Example:

I tried this query

```<code>SELECT TOP (100) PERCENT
    dbo.New_Portal_OldMarks.StudentID, dbo.New_Portal_OldMarks.[Student Name],
    dbo.New_Portal_OldMarks.SubjectName, dbo.New_Portal_OldMarks.AcademicYear,
    dbo.New_Portal_OldMarks.Class, dbo.New_Portal_OldMarks.Term1, dbo.New_Portal_OldMarks.Term2,
    dbo.New_Portal_OldMarks.Term3, dbo.New_Portal_OldMarks.Final,
    New_Portal_OldMarks_1.AcademicYear AS AcademicYear2,
    New_Portal_OldMarks_1.Class AS Class2,
    New_Portal_OldMarks_1.Term1 AS [Term1-2],
    New_Portal_OldMarks_1.Term2 AS [Term2-2],
    New_Portal_OldMarks_1.Term3 AS [Term3-2],
    New_Portal_OldMarks_1.Final AS [Final-2]
FROM
    dbo.New_Portal_OldMarks
FULL OUTER JOIN
    dbo.New_Portal_OldMarks AS New_Portal_OldMarks_1 ON dbo.New_Portal_OldMarks.StudentID = New_Portal_OldMarks_1.StudentID
                                                     AND dbo.New_Portal_OldMarks.SubjectName = New_Portal_OldMarks_1.SubjectName
WHERE
    (dbo.New_Portal_OldMarks.StudentID = 1004000)
ORDER BY
    AcademicYear2
</code>```

I tried all join query (ex JOIN, LEFT JOIN, RIGHT JOIN, etc) but all of them return wrong results

答:
You can use conditional aggregation:</p>

```<code>SELECT om.ID, om.StudentID, om.[Student Name], om.SubjectName,
       MAX(CASE WHEN om.class = 11 THEN academicyear END) as academicyear,
       MAX(CASE WHEN om.class = 11 THEN class END) as class,
       MAX(CASE WHEN om.class = 11 THEN term1 END) as term1,
       MAX(CASE WHEN om.class = 11 THEN term2 END) as term2,
       MAX(CASE WHEN om.class = 11 THEN term3 END) as term3,
       MAX(CASE WHEN om.class = 11 THEN final END) as final,
       MAX(CASE WHEN om.class = 12 THEN academicyear END) as academicyear,
       MAX(CASE WHEN om.class = 12 THEN class END) as class,
       MAX(CASE WHEN om.class = 12 THEN term1 END) as term1,
       MAX(CASE WHEN om.class = 12 THEN term2 END) as term2,
       MAX(CASE WHEN om.class = 12 THEN term3 END) as term3,
       MAX(CASE WHEN om.class = 12 THEN final END) as final
FROM dbo.New_Portal_OldMarks om
GROUP BY om.ID, om.StudentID, om.[Student Name], om.SubjectName
</code>```

Body:
I have a table that contains students marks (StudentsID, Subject, Year, Mark).

I want to display the Marks horizontally for the same Student, subject but different year.

The problem I have is that not all subjects available in all years, I mean the student can take different subject every year. and I want to show them all in one table horizontally.

Example:

I tried this query

SELECT TOP (100) PERCENT
    dbo.New_Portal_OldMarks.StudentID, dbo.New_Portal_OldMarks.[Student Name],
    dbo.New_Portal_OldMarks.SubjectName, dbo.New_Portal_OldMarks.AcademicYear,
    dbo.New_Portal_OldMarks.Class, dbo.New_Portal_OldMarks.Term1, dbo.New_Portal_OldMarks.Term2,
    dbo.New_Portal_OldMarks.Term3, dbo.New_Portal_OldMarks.Final,
    New_Portal_OldMarks_1.AcademicYear AS AcademicYear2,
    New_Portal_OldMarks_1.Class AS Class2,
    New_Portal_OldMarks_1.Term1 AS [Term1-2],
    New_Portal_OldMarks_1.Term2 AS [Term2-2],
    New_Portal_OldMarks_1.Term3 AS [Term3-2],
    New_Portal_OldMarks_1.Final AS [Final-2]
FROM
    dbo.New_Portal_OldMarks
FULL OUTER JOIN
    dbo.New_Portal_OldMarks AS New_Portal_OldMarks_1 ON dbo.New_Portal_OldMarks.StudentID = New_Portal_OldMarks_1.StudentID
                                                     AND dbo.New_Portal_OldMarks.SubjectName = New_Portal_OldMarks_1.SubjectName
WHERE
    (dbo.New_Portal_OldMarks.StudentID = 1004000)
ORDER BY
    AcademicYear2

I tried all join query (ex JOIN, LEFT JOIN, RIGHT JOIN, etc) but all of them return wrong results

Body:
You can use conditional aggregation:

SELECT om.ID, om.StudentID, om.[Student Name], om.SubjectName,
       MAX(CASE WHEN om.class = 11 THEN academicyear END) as academicyear,
       MAX(CASE WHEN om.class = 11 THEN class END) as class,
       MAX(CASE WHEN om.class = 11 THEN term1 END) as term1,
       MAX(CASE WHEN om.class = 11 THEN term2 END) as term2,
       MAX(CASE WHEN om.class = 11 THEN term3 END) as term3,
       MAX(CASE WHEN om.class = 11 THEN final END) as final,
       MAX(CASE WHEN om.class = 12 THEN academicyear END) as academicyear,
       MAX(CASE WHEN om.class = 12 THEN class END) as class,
       MAX(CASE WHEN om.class = 12 THEN term1 END) as term1,
       MAX(CASE WHEN om.class = 12 THEN term2 END) as term2,
       MAX(CASE WHEN om.class = 12 THEN term3 END) as term3,
       MAX(CASE WHEN om.class = 12 THEN final END) as final
FROM dbo.New_Portal_OldMarks om
GROUP BY om.ID, om.StudentID, om.[Student Name], om.SubjectName


问:
Check if Activity is started in Service
I have a service that is doing some background staff, then I need to start a Activity showing some results that the Service processed. But there is possibility that the activity is started many times from the service. Now, I want to start this Activity only if it is not active already.

What is the possibility and how to do this? And sample code would be nice if you don't mind.

Thanks!!

答:
You should change the launchMode of your activity to singleTask in the androidManifest.xml file.

The default value for this property is standard, which allows any number of instances to run.

"singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack. Moreover, the device can hold only one instance of the activity at a time — only one such task. [...]

The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It's the only activity in the task. If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.

Check out the Android Developers' Guide for a more detailed explanation (the quote is from there as well)

```<code><activity android:name=".activity.YourActivity"
    android:launchMode="singleTask"
    android:alwaysRetainTaskState="true"
    android:clearTaskOnLaunch="false"
    android:finishOnTaskLaunch="false">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
</code>```

ContentLicense: CC BY-SA 2.5

Title: Check if Activity is started in Service

Body:
You should change the launchMode of your activity to singleTask in the androidManifest.xml file.

The default value for this property is standard, which allows any number of instances to run.

"singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack. Moreover, the device can hold only one instance of the activity at a time — only one such task. [...]

The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It's the only activity in the task. If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.

Check out the Android Developers' Guide for a more detailed explanation (the quote is from there as well)

<activity android:name=".activity.YourActivity"
    android:launchMode="singleTask"
    android:alwaysRetainTaskState="true"
    android:clearTaskOnLaunch="false"
    android:finishOnTaskLaunch="false">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>


问:
Redirect after a post request with data in react js / node js
I'm trying to send data to another component page after doing a post request to my node js server.

first component to redirect: (I cannot post all my code, it is to big

```<code>fetch('http://localhost:8080/createVolume', requestOptions)
                .then(response => response.json())
                .then(data => {
                    console.log(data);
                    this.setState({
                        ansibleAnswer: data,
                        submitted: true
                    })
                    console.log(this.state.ansibleAnswer);
                });
.
.
.
// uderneeth my render

        } else if (this.state.loaded === true && this.state.submitted === true) {
            return (
                <Redirect to={{
                    pathname: '/Completed',
                    state: { name: this.state.name, result: this.state.ansibleAnswer }
                }}
                />
            );
</code>```

new component after post request:

```<code>class Completed extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            name: this.props.location.state.name,
            result: this.props.location.state.ansibleAnswer
        };
    }

    render() {
        return (
            <div>
                <Header />
                <div>
                    <p>test successful</p>
                    <p>{this.state.result}</p>
                </div>
                <Footer />
            </div>
        );
    }
}

export default Completed;
</code>```

I get this error:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.

I understand that the data isn't saved in the state but I don't understand how I could save it (or wait) before sending the data to the other component.

thank you

答:
```<code>        class Completed extends React.Component {
            constructor(props) {
                super(props);
                this.state = {
                    name: '',
                    result: ''
                };
            }

        /** When the Completed component does anything with the new props,
        * componentWillReceiveProps is called, with the next props as the argument */

        componentWillReceiveProps(nextProps) {

            /** Update  state**/

            if (nextProps.location.state.result !==
            this.props.location.state.result) {
            this.setState({
                result:nextProps.location.state.result
                });
            }

        }

            render() {
                return (
                    <div>
                        <Header />
                        <div>
                            <p>test successful</p>
                            <p>{this.state.result}</p>
                        </div>
                        <Footer />
                    </div>
                );
            }
        }

        export default Completed;
</code>```

Body:
I'm trying to send data to another component page after doing a post request to my node js server.

first component to redirect: (I cannot post all my code, it is to big

fetch('http://localhost:8080/createVolume', requestOptions)
                .then(response => response.json())
                .then(data => {
                    console.log(data);
                    this.setState({
                        ansibleAnswer: data,
                        submitted: true
                    })
                    console.log(this.state.ansibleAnswer);
                });
.
.
.
// uderneeth my render

        } else if (this.state.loaded === true && this.state.submitted === true) {
            return (
                <Redirect to={{
                    pathname: '/Completed',
                    state: { name: this.state.name, result: this.state.ansibleAnswer }
                }}
                />
            );

new component after post request:

class Completed extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            name: this.props.location.state.name,
            result: this.props.location.state.ansibleAnswer
        };
    }

    render() {
        return (

test successful

{this.state.result}

        );
    }
}

export default Completed;

I get this error:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.

I understand that the data isn't saved in the state but I don't understand how I could save it (or wait) before sending the data to the other component.

thank you


问:
Does/ can Google's ARCore work on a Kindle?
I'm currently developing a Unity3D app for a Kindle Fire using Google's ARCore, and I'm running through their Android quickstart guide. With how Amazon blocks any external or foreign links (i.e. anything but their own "Appstore"), running the app and allowing it to download its required APK version of ARCore is near impossible without interruption (app store can't be disabled/ force stopped).

There's a glimmer of it working as I download the APK (the hopefully correct version) through the device's browser and installing it (no prompt on launch to open app store etc.), but soon after, the same "ARCore encountered a problem connecting. Please start the app again" prompt appears as before. If it's truly a connection issue, I'd assume Amazon's intervening.

I'm asking if anyone has had better luck with Kindle, older models of Kindle, APK versions, and thereafter, versions of Unity and API levels where they've successfully installed ARCore related apps.

Unity ver. 2019.1.3f1

Kindle Fire HD 8

Fire OS 6.3.0.1

API level 25

ARCore Unity SDK v1.9.0

I tried both of the latest versions of the ARCore APK, uninstalling between the two;

ARCore 1.9.190422066

ARCore 1.9.190422069

Thank you.

答: Google Arcore Supported Devices:  Google Pixel, Pixel XL , Samsung Galaxy S8 с Android 7.0 </p>


问:
Inserting multiple records in laravel
How do I multiple records in the bills_infos table?
It takes the data and stores in the array variable and even I can access it with the compact function. I have marked from where the problem starts.

public function store(Request $request){
    $request->validate([
            'from'=>'required',
            'to'=>'required',
            'textbox1'=>'required',
            'rate1'=>'required',
            'qty1'=>'required',
    ]);
    $store_bill=new Bills();
    $store_bill->from=request('from');
    $store_bill->name=request('to');
    $store_bill->discount=request('discount');
    if(is_null($store_bill->discount))
    {
        $store_bill->discount=0;
    }
    $store_bill->save();
    $invoice_no=Bills::orderBy('created_at','desc')->pluck('id')->first();
    for($i=1;$i<=10;$i++)
    {
        $item_name[$i]=request('textbox'.$i);
        $amount[$i]=request('rate'.$i);
        $quantity[$i]=request('qty'.$i);
    }
    //return compact('item_name','amount','quantity');
    //Works fine till here.
    /* Not Working From Here. */
    for($i=1;$i<=10;$i++)
    {
        if(!(is_null($item_name[$i]) || is_null($amount[$i]) || is_null($quantity[$i])))
        {
            $store_bills_info=new Bills_Infos();
            $store_bills_info->bills_id=$invoice_no;
            $store_bills_info->item_name=$item_name[$i];
            $store_bills_info->amount=$amount[$i];
            $store_bills_info->quantity=$quantity[$i];
            $store_bills_info->total=$amount[$i]*$quantity[$i];
            $store_bills_info->save();
            //return compact('store_bills_info');
            return view('print')->with('invoice_no',$invoice_no);
        }
    }
    return "Invoice can't be created due to some error";
}
```

答:
You can use laravel's 'insert' function instead.
Eg.

```<code> for($i=1;$i<=10;$i++)
        {
            if(!(is_null($i`enter code here`tem_name[$i]) || is_null($amount[$i]) || is_null($quantity[$i])))
           {
                $store_bills_info[$i]['bills_id']   =$invoice_no;
                $store_bills_info[$i]['item_name']  =$item_name[$i];
                $store_bills_info[$i]['amount']     =$amount[$i];
                $store_bills_info[$i]['quantity']   =$quantity[$i];
                $store_bills_info[$i]['total']      =$amount[$i]*$quantity[$i];
            }
        }
Bills_Infos::insert($store_bills_info);
</code>```

As a query in a loop in not a good practice, we should avoid doing so.

Title: Inserting multiple records in laravel

Body:
You can use laravel's 'insert' function instead.
Eg.

 for($i=1;$i<=10;$i++)
        {
            if(!(is_null($i`enter code here`tem_name[$i]) || is_null($amount[$i]) || is_null($quantity[$i])))
           {
                $store_bills_info[$i]['bills_id']   =$invoice_no;
                $store_bills_info[$i]['item_name']  =$item_name[$i];
                $store_bills_info[$i]['amount']     =$amount[$i];
                $store_bills_info[$i]['quantity']   =$quantity[$i];
                $store_bills_info[$i]['total']      =$amount[$i]*$quantity[$i];
            }
        }
Bills_Infos::insert($store_bills_info);

As a query in a loop in not a good practice, we should avoid doing so.


问:
Remove item with header from angular material list
I have material list with header. Similar item grouped under header.
I added remove button also.in it. If I remove last item from list then the header also should remove. What I tried is below:

https://stackblitz.com/edit/angular-material-list-brenrk?file=app/app.component.ts

But it is not getting removed . Please help.

答:
By default, Angular's change detection loops through your array, and check if there was a reference change to the previous change. Now, you did not change any reference, only a property of these objects.
Since the object reference in your array does not change, Angular does not recognise that there was a change. I recommend using immutable operators, which does not mutate the previous object but creates a now one:

```<code>removeFromList(obj){
  this.valmap = this.valmap
    .map(element => {
      return {category: element.category, values: element.values.filter(fruit => fruit.name !== obj.name)}
  })
    .filter(element => element.values.length > 0)
}
</code>```

Your other choice is to introduce trackBy in your ˙ngFor`, to tell Angular when a property changed.

Body:
By default, Angular's change detection loops through your array, and check if there was a reference change to the previous change. Now, you did not change any reference, only a property of these objects.
Since the object reference in your array does not change, Angular does not recognise that there was a change. I recommend using immutable operators, which does not mutate the previous object but creates a now one:

removeFromList(obj){
  this.valmap = this.valmap
    .map(element => {
      return {category: element.category, values: element.values.filter(fruit => fruit.name !== obj.name)}
  })
    .filter(element => element.values.length > 0)
}

Your other choice is to introduce trackBy in your ˙ngFor`, to tell Angular when a property changed.


问:
Can't install MySQL on raspberry
I had a lot of troubles trying to install MySQL on rspbian stretch,

so I ended up by deleting everything that has the word sql on it, I installed mysql-server back

```<code>sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install mysql-server mysql-client
</code>```

But now I'm having this error when I try to log as root

```<code>pi@raspberrypi:~ $ sudo mysql --user=root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
</code>```

When I tried to start the server I had this error :

```<code>Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
</code>```

the errors in the log were:

```<code>    ● mariadb.service - MariaDB 10.1.38 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-05-27 13:42:56 CET; 19s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 4740 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 4663 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 4657 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 4655 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 4740 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
</code>```

and :

```<code>  mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentica
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-sess
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warnin
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR]
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, co
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed sta
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exi
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authenti
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (sy
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-u
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/ra
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], objec
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/Authentica
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/Auth
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.5
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconn
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_F
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.50 [systemctl start mysql] (o
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconnected from bus)
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8)
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.50 [systemctl start mysql] (owned by unix-user:pi)
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconnected from bus)
lines 1835-1857/1857 (END)
</code>```

How can I solve this problem ? knowing that I have tried countless of solution but none has worked

答:
Making a guess at this fragment

```<code>ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/r
</code>```

possibly the mysql user doesn't have permission to update / create whatever folder it's pointing to at /var/<something>.

Title: Can't install MySQL on raspberry

Body:
I had a lot of troubles trying to install MySQL on rspbian stretch,

so I ended up by deleting everything that has the word sql on it, I installed mysql-server back

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install mysql-server mysql-client

But now I'm having this error when I try to log as root

pi@raspberrypi:~ $ sudo mysql --user=root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

When I tried to start the server I had this error :

Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.

the errors in the log were:

    ● mariadb.service - MariaDB 10.1.38 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-05-27 13:42:56 CET; 19s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 4740 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 4663 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 4657 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 4655 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 4740 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.

and :

  mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentica
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-sess
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warnin
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR]
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, co
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed sta
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exi
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authenti
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (sy
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-u
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/ra
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], objec
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/Authentica
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/Auth
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.5
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconn
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_F
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.50 [systemctl start mysql] (o
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconnected from bus)
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8)
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.50 [systemctl start mysql] (owned by unix-user:pi)
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconnected from bus)
lines 1835-1857/1857 (END)

How can I solve this problem ? knowing that I have tried countless of solution but none has worked

Body:
Making a guess at this fragment

ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/r

possibly the mysql user doesn't have permission to update / create whatever folder it's pointing to at /var/<something>.


问:
Constraint Layout - How to make an image view (frame) to move on whole screen
I have a constraint layout with card view like tinder. I have changed the size of that view and like can move (like/dislike). But image is getting cut(since its in the inner frame). I want to move the frame on whole screen manually.

Here is the layout file

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/root_content_list"
        android:background="@color/white"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <in.zapr.onemedia.custom.ZTextView
            android:id="@+id/heading"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintHeight_percent="0.1"
            android:text="@string/card_title"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_gravity="center"
            android:gravity="bottom"
            android:textColor="@color/cs_title"
            app:type_face="@string/font_heavy"
            android:textAppearance="?android:textAppearanceLarge"/>

    <in.zapr.onemedia.custom.ZTextView
            android:id="@+id/headingTip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="@string/card_tip"
            android:layout_gravity="center"
            android:gravity="center"
            android:textColor="@color/cs_subtitle"
            app:type_face="@string/font_heavy"
            app:layout_constraintLeft_toLeftOf="@id/heading"
            app:layout_constraintRight_toRightOf="@id/heading"
            app:layout_constraintTop_toBottomOf="@id/heading"
            android:textAppearance="?android:textAppearanceSmall"/>
    <ProgressBar
            android:id="@+id/pb_loading_content_selection"
            android:layout_width="50dp"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="@id/ll_cardView"
            app:layout_constraintRight_toRightOf="@id/ll_cardView"
            app:layout_constraintTop_toTopOf="@id/ll_cardView"
            app:layout_constraintBottom_toBottomOf="@id/ll_cardView"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_gravity="center"
            android:layout_marginRight="8dp"
            android:layout_marginTop="8dp"
            android:visibility="gone"/>

    <ImageView
            android:id="@+id/btn_retry_content_selection"
            android:layout_width="50dp"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="@id/ll_cardView"
            app:layout_constraintRight_toRightOf="@id/ll_cardView"
            app:layout_constraintTop_toTopOf="@id/ll_cardView"
            app:layout_constraintBottom_toBottomOf="@id/ll_cardView"
            android:padding="10dp"
            android:visibility="gone"
            android:layout_gravity="center"
            app:srcCompat="@drawable/reload"/>

    <LinearLayout
            android:id="@+id/ll_cardView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:orientation="vertical"
            app:layout_constraintHeight_percent="0.45"
            app:layout_constraintWidth_percent="0.6"
            android:layout_marginTop="10dp"
            app:layout_constraintTop_toBottomOf="@id/headingTip"
            app:layout_constraintBottom_toTopOf="@id/button_container"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent">

        <ImageView
                android:id="@+id/cardViewBackground"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone"
                app:srcCompat="@drawable/no_content_available"
                android:clipToPadding="false"/>

        <com.yuyakaido.android.cardstackview.CardStackView
                android:id="@+id/card_stack_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="visible"
                android:clipToPadding="false">
        </com.yuyakaido.android.cardstackview.CardStackView>

    </LinearLayout>

    <RelativeLayout
            android:id="@+id/button_container"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintHeight_percent="0.25"
            app:layout_constraintBottom_toTopOf="@id/ll_Next"
            app:layout_constraintTop_toBottomOf="@id/ll_cardView"
            android:clipChildren="false">

        <LinearLayout
                android:id="@+id/ll_floating"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center">

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/skip_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"
                    app:srcCompat="@drawable/onboarding_dislike"
                    app:backgroundTint="@android:color/white"/>

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/maybe_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:srcCompat="@drawable/onboarding_maybe"
                    app:backgroundTint="@android:color/transparent"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"/>

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/like_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:srcCompat="@drawable/onboarding_like"
                    app:backgroundTint="@android:color/transparent"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"/>
        </LinearLayout>

        <in.zapr.onemedia.custom.ZTextView
                android:textAppearance="?android:textAppearanceSmall"
                android:id="@+id/tv_not_seen"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textColor="@color/cs_not_seen"
                app:type_face="@string/font_heavy"
                android:text="@string/not_seen_text"
                android:layout_below="@id/ll_floating"/>

    </RelativeLayout>
    <in.zapr.onemedia.custom.ZButton
            android:id="@+id/ll_Next"
            android:layout_width="0dp"
            android:layout_height="70dp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:background="@drawable/layout_click_selector"
            android:text="@string/letsGo"
            android:textAppearance="?android:textAppearanceMedium"
            android:textColor="@color/white"
            android:focusable="false"
            android:gravity="center"
            app:type_face="@string/font_black"/>

</android.support.constraint.ConstraintLayout>
</code>```

And this is the issue

The output of xml will me

I am using the CardStackView from here,

https://github.com/yuyakaido/CardStackView

答:
Try to add to ll_cardView and root_content_list this attributes

```<code>android:clipChildren="false"
android:clipToPadding="false"
</code>```

Body:
I have a constraint layout with card view like tinder. I have changed the size of that view and like can move (like/dislike). But image is getting cut(since its in the inner frame). I want to move the frame on whole screen manually.

Here is the layout file

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/root_content_list"
        android:background="@color/white"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <in.zapr.onemedia.custom.ZTextView
            android:id="@+id/heading"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintHeight_percent="0.1"
            android:text="@string/card_title"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_gravity="center"
            android:gravity="bottom"
            android:textColor="@color/cs_title"
            app:type_face="@string/font_heavy"
            android:textAppearance="?android:textAppearanceLarge"/>

    <in.zapr.onemedia.custom.ZTextView
            android:id="@+id/headingTip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="@string/card_tip"
            android:layout_gravity="center"
            android:gravity="center"
            android:textColor="@color/cs_subtitle"
            app:type_face="@string/font_heavy"
            app:layout_constraintLeft_toLeftOf="@id/heading"
            app:layout_constraintRight_toRightOf="@id/heading"
            app:layout_constraintTop_toBottomOf="@id/heading"
            android:textAppearance="?android:textAppearanceSmall"/>
    <ProgressBar
            android:id="@+id/pb_loading_content_selection"
            android:layout_width="50dp"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="@id/ll_cardView"
            app:layout_constraintRight_toRightOf="@id/ll_cardView"
            app:layout_constraintTop_toTopOf="@id/ll_cardView"
            app:layout_constraintBottom_toBottomOf="@id/ll_cardView"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_gravity="center"
            android:layout_marginRight="8dp"
            android:layout_marginTop="8dp"
            android:visibility="gone"/>

    <ImageView
            android:id="@+id/btn_retry_content_selection"
            android:layout_width="50dp"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="@id/ll_cardView"
            app:layout_constraintRight_toRightOf="@id/ll_cardView"
            app:layout_constraintTop_toTopOf="@id/ll_cardView"
            app:layout_constraintBottom_toBottomOf="@id/ll_cardView"
            android:padding="10dp"
            android:visibility="gone"
            android:layout_gravity="center"
            app:srcCompat="@drawable/reload"/>

    <LinearLayout
            android:id="@+id/ll_cardView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:orientation="vertical"
            app:layout_constraintHeight_percent="0.45"
            app:layout_constraintWidth_percent="0.6"
            android:layout_marginTop="10dp"
            app:layout_constraintTop_toBottomOf="@id/headingTip"
            app:layout_constraintBottom_toTopOf="@id/button_container"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent">

        <ImageView
                android:id="@+id/cardViewBackground"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone"
                app:srcCompat="@drawable/no_content_available"
                android:clipToPadding="false"/>

        <com.yuyakaido.android.cardstackview.CardStackView
                android:id="@+id/card_stack_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="visible"
                android:clipToPadding="false">
        </com.yuyakaido.android.cardstackview.CardStackView>

    </LinearLayout>

    <RelativeLayout
            android:id="@+id/button_container"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintHeight_percent="0.25"
            app:layout_constraintBottom_toTopOf="@id/ll_Next"
            app:layout_constraintTop_toBottomOf="@id/ll_cardView"
            android:clipChildren="false">

        <LinearLayout
                android:id="@+id/ll_floating"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center">

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/skip_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"
                    app:srcCompat="@drawable/onboarding_dislike"
                    app:backgroundTint="@android:color/white"/>

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/maybe_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:srcCompat="@drawable/onboarding_maybe"
                    app:backgroundTint="@android:color/transparent"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"/>

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/like_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:srcCompat="@drawable/onboarding_like"
                    app:backgroundTint="@android:color/transparent"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"/>
        </LinearLayout>

        <in.zapr.onemedia.custom.ZTextView
                android:textAppearance="?android:textAppearanceSmall"
                android:id="@+id/tv_not_seen"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textColor="@color/cs_not_seen"
                app:type_face="@string/font_heavy"
                android:text="@string/not_seen_text"
                android:layout_below="@id/ll_floating"/>

    </RelativeLayout>
    <in.zapr.onemedia.custom.ZButton
            android:id="@+id/ll_Next"
            android:layout_width="0dp"
            android:layout_height="70dp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:background="@drawable/layout_click_selector"
            android:text="@string/letsGo"
            android:textAppearance="?android:textAppearanceMedium"
            android:textColor="@color/white"
            android:focusable="false"
            android:gravity="center"
            app:type_face="@string/font_black"/>

</android.support.constraint.ConstraintLayout>

And this is the issue

The output of xml will me

I am using the CardStackView from here,

https://github.com/yuyakaido/CardStackView

Body:
Try to add to ll_cardView and root_content_list this attributes

android:clipChildren="false"
android:clipToPadding="false"


问:
haskell-stack store-0.3: libz.so
When building haskell-stack from I get the following error:

```<code>store-0.3: download
store-0.3: configure
store-0.3: build

--  While building package store-0.3 using:
      /tmp/haskell-stack-20170403-52407-1rpyzwy/stack-1.4.0/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.22.5.0_ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /tmp/haskell-stack-20170403-52407-1rpyzwy/stack-1.4.0/.stack-work/logs/store-0.3.log

    Configuring store-0.3...
    Building store-0.3...
    Preprocessing library store-0.3...
    [ 1 of 11] Compiling Data.Store.Streaming.Internal ( src/Data/Store/Streaming/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/Streaming/Internal.o )
    [ 2 of 11] Compiling System.IO.ByteBuffer ( src/System/IO/ByteBuffer.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/System/IO/ByteBuffer.o )
    [ 3 of 11] Compiling Data.Store.Impl  ( src/Data/Store/Impl.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/Impl.o )
    [ 4 of 11] Compiling Data.Store.TH    ( src/Data/Store/TH.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/TH.o )
    [ 5 of 11] Compiling Data.Store.TH.Internal ( src/Data/Store/TH/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/TH/Internal.o )
    [ 6 of 11] Compiling Data.Store.Internal ( src/Data/Store/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/Internal.o )
    <command line>: can't load .so/.DLL for: libz.so (libz.so: cannot open shared object file: No such file or directory)
</code>```

Does anyone know what might be causing this? I have zlib development installed on my machine.

答:
In my case, libz-dev package installation solved it.

```<code>sudo apt install libz-dev
</code>```

Title: haskell-stack store-0.3: libz.so

Body:
When building haskell-stack from I get the following error:

store-0.3: download
store-0.3: configure
store-0.3: build

--  While building package store-0.3 using:
      /tmp/haskell-stack-20170403-52407-1rpyzwy/stack-1.4.0/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.22.5.0_ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /tmp/haskell-stack-20170403-52407-1rpyzwy/stack-1.4.0/.stack-work/logs/store-0.3.log

    Configuring store-0.3...
    Building store-0.3...
    Preprocessing library store-0.3...
    [ 1 of 11] Compiling Data.Store.Streaming.Internal ( src/Data/Store/Streaming/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/Streaming/Internal.o )
    [ 2 of 11] Compiling System.IO.ByteBuffer ( src/System/IO/ByteBuffer.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/System/IO/ByteBuffer.o )
    [ 3 of 11] Compiling Data.Store.Impl  ( src/Data/Store/Impl.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/Impl.o )
    [ 4 of 11] Compiling Data.Store.TH    ( src/Data/Store/TH.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/TH.o )
    [ 5 of 11] Compiling Data.Store.TH.Internal ( src/Data/Store/TH/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/TH/Internal.o )
    [ 6 of 11] Compiling Data.Store.Internal ( src/Data/Store/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Data/Store/Internal.o )
    <command line>: can't load .so/.DLL for: libz.so (libz.so: cannot open shared object file: No such file or directory)

Does anyone know what might be causing this? I have zlib development installed on my machine.

Body:
In my case, libz-dev package installation solved it.

sudo apt install libz-dev


问:
sql query to get the transaction for all the users having specific timestamp
I have sql table structure as follows:

```<code>id INT(11),
amount DOUBLE(10,2),
createdAt DATETIME,
user_id INT(11),
tx_status INT(11).
</code>```

value of tx_status can be 1 (credit) , 2 (debit) and 3(settled). Now what I want is , I want all the latest transactions of all the users where transaction createdAt is greater than last createdAt when tx_status = 3 for particular user.

The data is as shown below :

```<code>id .  amount . createdAt .          user_id .      tx_status
112   500 .    2019-05-15 00:30:40  345 .          1
113 . 300      2019-05-16 06:45:29  345 .          2
116 . 600 .    2019-05-16 06:45:33  345 .          3
119 . 567 .    2019-05-17 07:56:55  345 .          1
121   500 .    2019-05-18 00:30:40  346 .          1
123 . 300      2019-05-19 06:45:29  346 .          2
124 . 600 .    2019-05-20 06:45:33  346 .          3
126 . 567 .    2019-05-21 07:56:55  346 .          1
</code>```

The output should be :

```<code>id .  amount . createdAt .          user_id .      tx_status
119 . 567 .    2019-05-17 07:56:55  345 .          1
126 . 567 .    2019-05-21 07:56:55  346 .          1
</code>```

答:
This query will give you the results you want. It uses a derived table of the maximum times at which settlement occurred, using conditional aggregation to ensure that if no settlements have occurred, that time is '1970-01-01' (so that all records will be returned).

```<code>SELECT t1.*
FROM transactions t1
JOIN (SELECT user_id, MAX(CASE WHEN tx_status = 3 THEN createdAt ELSE '1970-01-01' END) AS last_settlement
      FROM transactions t2
      GROUP BY user_id) t2 ON t2.user_id = t1.user_id AND t2.last_settlement < t1.createdAt
</code>```

Output (for your sample data)

```<code>id  amount  createdAt           user_id tx_status
119 567     2019-05-17 07:56:55 345     1
126 567     2019-05-21 07:56:55 346     1
</code>```

Demo on dbfiddle

Body:
I have sql table structure as follows:

id INT(11),
amount DOUBLE(10,2),
createdAt DATETIME,
user_id INT(11),
tx_status INT(11).

value of tx_status can be 1 (credit) , 2 (debit) and 3(settled). Now what I want is , I want all the latest transactions of all the users where transaction createdAt is greater than last createdAt when tx_status = 3 for particular user.

The data is as shown below :

id .  amount . createdAt .          user_id .      tx_status
112   500 .    2019-05-15 00:30:40  345 .          1
113 . 300      2019-05-16 06:45:29  345 .          2
116 . 600 .    2019-05-16 06:45:33  345 .          3
119 . 567 .    2019-05-17 07:56:55  345 .          1
121   500 .    2019-05-18 00:30:40  346 .          1
123 . 300      2019-05-19 06:45:29  346 .          2
124 . 600 .    2019-05-20 06:45:33  346 .          3
126 . 567 .    2019-05-21 07:56:55  346 .          1

The output should be :

id .  amount . createdAt .          user_id .      tx_status
119 . 567 .    2019-05-17 07:56:55  345 .          1
126 . 567 .    2019-05-21 07:56:55  346 .          1

Body:
This query will give you the results you want. It uses a derived table of the maximum times at which settlement occurred, using conditional aggregation to ensure that if no settlements have occurred, that time is '1970-01-01' (so that all records will be returned).

SELECT t1.*
FROM transactions t1
JOIN (SELECT user_id, MAX(CASE WHEN tx_status = 3 THEN createdAt ELSE '1970-01-01' END) AS last_settlement
      FROM transactions t2
      GROUP BY user_id) t2 ON t2.user_id = t1.user_id AND t2.last_settlement < t1.createdAt

Output (for your sample data)

id  amount  createdAt           user_id tx_status
119 567     2019-05-17 07:56:55 345     1
126 567     2019-05-21 07:56:55 346     1

Demo on dbfiddle


问:
Set custom height for Ngx Editor
I am using ngx-editor for creating wysiwyg editor for my MEAN stack application. Everything is working fine but I want to set height for this editor. I have tried to set height in the css file for the component like

```<code>.ngx-editor[_ngcontent-c4] .ngx-editor-textarea[_ngcontent-c4] {
    height: 300px !important;
}
</code>```

but still its not working.

Even I tried to set height from the component.html file like this

```<code><div class="form-group">
      <label for="desc">Description</label>
      <app-ngx-editor style="height: 300px" [style]="{'min-height':'320px'}" formControlName="desc" [placeholder]="'Enter text here...'" [spellcheck]="true" [(ngModel)]="htmlContent"></app-ngx-editor>
    </div>
</code>```

but still its not working.

Can someone tell me how to set the height for the editor? I have gone through its docs but not got any help so far. So can someone tell me how to set its height? Any help and suggestions will be really appreciable

答:
I think below solution should work.

```<code><app-ngx-editor [height]="'100px'" [minHeight]="'50px'"></app-ngx-editor>
</code>```

Please see the "'" inside the attribute value.

Title: Set custom height for Ngx Editor

Body:
I am using ngx-editor for creating wysiwyg editor for my MEAN stack application. Everything is working fine but I want to set height for this editor. I have tried to set height in the css file for the component like

.ngx-editor[_ngcontent-c4] .ngx-editor-textarea[_ngcontent-c4] {
    height: 300px !important;
}

but still its not working.

Even I tried to set height from the component.html file like this

      Description
      <app-ngx-editor style="height: 300px" [style]="{'min-height':'320px'}" formControlName="desc" [placeholder]="'Enter text here...'" [spellcheck]="true" [(ngModel)]="htmlContent"></app-ngx-editor>

but still its not working.

Can someone tell me how to set the height for the editor? I have gone through its docs but not got any help so far. So can someone tell me how to set its height? Any help and suggestions will be really appreciable

Body:
I think below solution should work.

<app-ngx-editor [height]="'100px'" [minHeight]="'50px'"></app-ngx-editor>

Please see the "'" inside the attribute value.


问:
gets() problem in C
I wrote the following code:

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 128

int main ()

{
    char mychar , string [SIZE];
    int i;
    int const count =0 ;

    printf ("Please enter your string: \n\n");
    fgets (string, SIZE, stdin);

    printf ("Please enter char to find: ");
    mychar = getchar();

    for (i=0 ; (string[i] == '\0') ; i++ )
        if ( string[i]  == mychar )
            count++;

    printf ("The char %c appears %d times" ,mychar ,count);

    return 0;
}
</code>```

The problem is that the gcc gives me an error for the 'int const count': " increment of read-only variable ‘count’".

What seems to be wrong ?

Thank !

答:
gets is dangerous because it can take in more data than the size of the variable. Thereby exposing the system to attacks and compromising security.
fgets should be used as it limits no. of characters to be read.</p>

Title: gets() problem in C

Body:
I wrote the following code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 128

int main ()

{
    char mychar , string [SIZE];
    int i;
    int const count =0 ;

    printf ("Please enter your string: \n\n");
    fgets (string, SIZE, stdin);

    printf ("Please enter char to find: ");
    mychar = getchar();

    for (i=0 ; (string[i] == '\0') ; i++ )
        if ( string[i]  == mychar )
            count++;

    printf ("The char %c appears %d times" ,mychar ,count);

    return 0;
}

The problem is that the gcc gives me an error for the 'int const count': " increment of read-only variable ‘count’".

What seems to be wrong ?

Thank !


问:
Exclude supported language by external dependency (aar)
How to exclude supported languages by an external dependency (.aar)? The external dependency is supporting more languages that my application, and I'm trying to avoid having activities with different languages according if it comes from the external dependency or not.

I've been trying something like this, but without success:

compile ('...-3.17.1@aar') { exclude("res/values-es") }

答:
You can use packagingOptions available in gradle and exclude specific values folder from dependent aar file

https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html

You can follow above link for more details.


问:
When creating new process using exec() in nodejs, does it run in parallel with current process, how nodejs handles it?
Since nodejs is single threaded language, how does it creates new processes and handles it. </p>

```<code>const exec = require('child_process').exec;
exec('my.bat', (err, stdout, stderr) => {
  if (err) {
    console.error(err);
    return;
  }
  console.log(stdout);
});
</code>```

答:
The child_process.spawn(), child_process.fork(), child_process.exec(), and child_process.execFile() methods all follow the idiomatic asynchronous programming pattern typical of other Node.js APIs.

Each of the methods returns a ChildProcess instance. These objects implement the Node.js EventEmitter API, allowing the parent process to register listener functions that are called when certain events occur during the life cycle of the child process.

The child_process.exec() and child_process.execFile() methods additionally allow for an optional callback function to be specified that is invoked when the child process terminates.

Documentation link.

Body:
Since nodejs is single threaded language, how does it creates new processes and handles it.

const exec = require('child_process').exec;
exec('my.bat', (err, stdout, stderr) => {
  if (err) {
    console.error(err);
    return;
  }
  console.log(stdout);
});


问:
find the index from the exists value (check if) dictionary
I am using python-3.x and I would like to check if the value exists or not in the dictionary if it exists then I want to find and print the index number of that value in the dictionary.

here an example of my code:

```<code># import numpy
import numpy as np

# my first array
my_array_1 = np.array([[ 1  , 2  , 3  ],
                       [ 32 , 42 , 11 ],
                       [ 9  , 21 , 22 ],
                       [ 9  , 21 , 22 ],
                       [ 9  , 21 , 22 ],
                       [ 32 , 42 , 11 ],
                       [ 1  , 2  , 3  ]])

# here I want to find the unique values from my_array_1
indx = np.unique(my_array_1, return_index=True, return_counts= True,axis=0)

#save the result to dictionary
dic_t= {"my_array_uniq":indx[0],
       "counts":indx[1]}

# my 2nd array
my_array_2 = np.array([[ 1  , 2   , 3  ],
                       [ 32 , 422 , 11 ],
                       [ 9  , 221 , 22 ],
                       [ 9  , 221 , 22 ],
                       [ 9  , 21  , 22 ],
                       [ 32 , 242 , 11 ],
                       [ 1  , 22  , 3] ])

for i in range (len(my_array_2)):

# here I want to check if the vlue exist or not

    if any((my_array_2[i] == j).all() for j in dic_t["my_array_uniq"]):

######(if it exists print the index number of the existing vlue in dic_t["my_array_uniq"])######

        print (50*"*", i, "Yes")
        print (my_array_2[i], "\n")
        print (dic_t["my_array_uniq"])

    else:
        print (50*"*", i, "No")
        dic_t["my_array_uniq"] = np.vstack((dic_t["my_array_uniq"], my_array_2[i]))
</code>```

All I need is the index number I did my best to find the right way but none of them works...

答:
The problem is that in the line that tests whether the element exists, you do not keep the index where it is found.

You should use enumerate to process both the index and the value from a list:

```<code>for i, a in enumerate(my_array_2):

# here I want to check if the vlue exist or not

    ix = [k for k,j in enumerate(dic_t["my_array_uniq"]) if (a == j).all()]
    if ix:

######(if it exists print the index number of the existing vlue in dic_t["my_array_uniq"])######

        print (50*"*", i, "Yes", "at", ix[0])
        print (my_array_2[i], "\n")
        print (dic_t["my_array_uniq"])

    else:
        print (50*"*", i, "No")
        dic_t["my_array_uniq"] = np.vstack((dic_t["my_array_uniq"], my_array_2[i]))
</code>```

Body:
I am using python-3.x and I would like to check if the value exists or not in the dictionary if it exists then I want to find and print the index number of that value in the dictionary.

here an example of my code:

# import numpy
import numpy as np

# my first array
my_array_1 = np.array([[ 1  , 2  , 3  ],
                       [ 32 , 42 , 11 ],
                       [ 9  , 21 , 22 ],
                       [ 9  , 21 , 22 ],
                       [ 9  , 21 , 22 ],
                       [ 32 , 42 , 11 ],
                       [ 1  , 2  , 3  ]])

# here I want to find the unique values from my_array_1
indx = np.unique(my_array_1, return_index=True, return_counts= True,axis=0)

#save the result to dictionary
dic_t= {"my_array_uniq":indx[0],
       "counts":indx[1]}

# my 2nd array
my_array_2 = np.array([[ 1  , 2   , 3  ],
                       [ 32 , 422 , 11 ],
                       [ 9  , 221 , 22 ],
                       [ 9  , 221 , 22 ],
                       [ 9  , 21  , 22 ],
                       [ 32 , 242 , 11 ],
                       [ 1  , 22  , 3] ])

for i in range (len(my_array_2)):

# here I want to check if the vlue exist or not

    if any((my_array_2[i] == j).all() for j in dic_t["my_array_uniq"]):

######(if it exists print the index number of the existing vlue in dic_t["my_array_uniq"])######

        print (50*"*", i, "Yes")
        print (my_array_2[i], "\n")
        print (dic_t["my_array_uniq"])

    else:
        print (50*"*", i, "No")
        dic_t["my_array_uniq"] = np.vstack((dic_t["my_array_uniq"], my_array_2[i]))

All I need is the index number I did my best to find the right way but none of them works...

Body:
The problem is that in the line that tests whether the element exists, you do not keep the index where it is found.

You should use enumerate to process both the index and the value from a list:

for i, a in enumerate(my_array_2):

# here I want to check if the vlue exist or not

    ix = [k for k,j in enumerate(dic_t["my_array_uniq"]) if (a == j).all()]
    if ix:

######(if it exists print the index number of the existing vlue in dic_t["my_array_uniq"])######

        print (50*"*", i, "Yes", "at", ix[0])
        print (my_array_2[i], "\n")
        print (dic_t["my_array_uniq"])

    else:
        print (50*"*", i, "No")
        dic_t["my_array_uniq"] = np.vstack((dic_t["my_array_uniq"], my_array_2[i]))


问:
How to set style on a specific header in ag-grid
Im' trying to set style on a specific header in an ag-grid array generated dynamically. How Can I do this without manipulating the DOM ?
This is a timeslot array and I want to highlight the current day.

I already tried to apply cellStyle, but it can't affect headers. Do you have some ideas ?

Some code generating the array :

```<code>this.tmpDefs = [{ headerName: '', field: 'user', width: 90, suppressSizeToFit: true }];

for(wantedDays){
   this.tmpDefs.push([Some generated children])
}

this.gridApi.setColumnDefs(this.tmpDefs);
</code>```

答:
You can use the headerClass property in your column definition.

Here is the full documentation about column properties:
https://www.ag-grid.com/javascript-grid-column-properties/

Body:
Im' trying to set style on a specific header in an ag-grid array generated dynamically. How Can I do this without manipulating the DOM ?
This is a timeslot array and I want to highlight the current day.

I already tried to apply cellStyle, but it can't affect headers. Do you have some ideas ?

Some code generating the array :

this.tmpDefs = [{ headerName: '', field: 'user', width: 90, suppressSizeToFit: true }];

for(wantedDays){
   this.tmpDefs.push([Some generated children])
}

this.gridApi.setColumnDefs(this.tmpDefs);


问:
How to paste special preserving the format in a new WorkBook in VBA
I would like copy and paste special (values & format) a range from workbook A to workbook B.
The problem is : the values are paste but not the format

I've tried all the PasteSpecial, but none of it worked...

```<code>Sub Macro_copy_paste_pivot()
    Dim date_report As String
    Dim appExcel As Excel.Application
    Dim XLBook As Workbook

    Set appExcel = CreateObject("Excel.Application")
    Set XLBook = appExcel.Workbooks.Add
    date_report = WorksheetFunction.WorkDay(Date, -1)
    date_report = Format(date_report, "yyyy-mm-dd")

    ' COPY and PASTE the pivot EXO
    Worksheets("Pivot EXO").Activate
    ActiveSheet.PivotTables("Pivot EXO").PivotFields( _
        "[Context].[AsOfDate].[AsOfDate]").VisibleItemsList = Array( _
        "[Context].[AsOfDate].&[" & date_report & "T00:00:00]")

    Range("P7:A24").Copy
    XLBook.Sheets.Add.Name = "EXO"
    XLBook.Worksheets("EXO").Range("P7:A24").PasteSpecial Paste:=xlPasteFormats

End Sub
</code>```

So, how can I paste format from a workbook A to workbook B?

答:
Well basically the values in the pivot range your copying are not formatted at all, is only the pivot table style that shows them formatted.

One work around that would be to copy your values, then transform your copied values into a table and apply the same formatting your pivot table has (see comments for further details):

Sub Macro_copy_paste_pivot()
    Dim date_report As String
    Dim appExcel As Excel.Application
    Dim XLBook As Workbook, XLBookSource As Workbook    'Declare your source workbook too

    Set appExcel = CreateObject("Excel.Application")
    Set XLBookSource = ThisWorkbook                     'Set the source workbook.. alternatively use ActiveWorkbook or specific book
    Set XLBook = appExcel.Workbooks.Add
    date_report = WorksheetFunction.WorkDay(Date, -1)
    date_report = Format(date_report, "yyyy-mm-dd")

    ' COPY and PASTE the pivot EXO
    XLBookSource.Worksheets("Pivot EXO").PivotTables("Pivot EXO").PivotFields( _
        "[Context].[AsOfDate].[AsOfDate]").VisibleItemsList = Array( _
        "[Context].[AsOfDate].&[" & date_report & "T00:00:00]")

    Range("P7:A24").Copy
    XLBook.Sheets.Add.Name = "EXO"
    With XLBook.Worksheets("EXO")
        .Range("P7:A24").PasteSpecial Paste:=xlPasteValues
        .ListObjects.Add(xlSrcRange, .Range("P7:A24"), , xlYes).Name = "TableNameWhatever"  'Add a table for this range.. note this adds headers as well, review as needed
        .ListObjects("TableNameWhatever").TableStyle = XLBookSource.Worksheets("Pivot EXO").PivotTables("PivotTable1").TableStyle2  'Give the same style as the pivot table
    End With
End Sub
```

Body:
I would like copy and paste special (values & format) a range from workbook A to workbook B.
The problem is : the values are paste but not the format

I've tried all the PasteSpecial, but none of it worked...

Sub Macro_copy_paste_pivot()
    Dim date_report As String
    Dim appExcel As Excel.Application
    Dim XLBook As Workbook

    Set appExcel = CreateObject("Excel.Application")
    Set XLBook = appExcel.Workbooks.Add
    date_report = WorksheetFunction.WorkDay(Date, -1)
    date_report = Format(date_report, "yyyy-mm-dd")

    ' COPY and PASTE the pivot EXO
    Worksheets("Pivot EXO").Activate
    ActiveSheet.PivotTables("Pivot EXO").PivotFields( _
        "[Context].[AsOfDate].[AsOfDate]").VisibleItemsList = Array( _
        "[Context].[AsOfDate].&[" & date_report & "T00:00:00]")

    Range("P7:A24").Copy
    XLBook.Sheets.Add.Name = "EXO"
    XLBook.Worksheets("EXO").Range("P7:A24").PasteSpecial Paste:=xlPasteFormats

End Sub

So, how can I paste format from a workbook A to workbook B?