问:
How do you bind 2 controls?
In my app, there is a feature to customize it's own Controls (like Textbox, Labels, Textblocks, Buttons, etc), this feature interface is located inside a TabItem. Lets say i want to modify Button A, which is located in ANOTHER container. On the feature interface, i set it's Foreground property to White, at this moment i don't know whether the Button looks better or not, so i have to go to the container which contains that Button.

What am i trying to do is, i want to create a "preview" Control (which is the same type as the actual target) inside the feature interface. I want any changes on this "preview" control are reflected to the actual target Control. With this, i won't need to navigate to where the target Control located.

When i used the title ("How do you bind 2 controls)" with google, all results actually gives me "how to bind SINGLE property of a control to another control's property". What i want is how do you bind/link 2 Controls literally, i mean, i want to bind ALL properties of Control A to ALL properties of Control B.

Binding them one by one is one (tiring) way. Is there another way to achieve this?

I would prefer code-behind method.

答:
There is no "fast" way to do this, you will have to bind one by one according to your buisness logic.

Also a binding is not cheap regarding performance so binding each and every property of a control even those you dont explicitly need, is a warning sign.

Title: How do you bind 2 controls?


来源: stackexchange

问:
Hibernate insert cascade not inserting foreign key
I have two entities:

```<code>@Entity
public class File
.......
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@OneToMany(fetch=FetchType.LAZY, mappedBy="file", cascade=CascadeType.ALL)
private List<Tag> tags;
.......
OTHER PROPERTIES
.......

@Entity
public class Tag
.......
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@ManyToOne
@JoinColumn(name="file_id")
private File file;
@Column
private String tag;
.......
OTHER PROPERTIES
.......
</code>```

I am trying to insert into File (and subsequently Tag) by doing the following:

```<code>File file = new File();
Tag tag = new Tag();
tag.setTag("tag1");
Tag2 tag2 = new Tag();
tag2.setTag("tag2");
List<Tag> tags = new ArrayList<Tag>();
tags.add(tag);
tags.add(tag2);
file.setTags(tags);
---Add other file attributes here---
</code>```

I am then inserting the file in my DAO using:

```<code>sessionFactory.getCurrentSession().saveOrUpdate(file);
</code>```

In my logs I see an insert into my "file" table and 2 inserts into my tag table, however, the foreign key in my tag table that points to my file table (file_id) is NULL.

What could I possibly be doing wrong?

答:
Foreign key in the database reflects the state of Tag.file (since Tag is the owning side of the relationship as a "many" side in a bidirectional many-to-one relationship).

I can't see where you set it.

ContentLicense: CC BY-SA 2.5

Body:
I have two entities:

@Entity
public class File
.......
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@OneToMany(fetch=FetchType.LAZY, mappedBy="file", cascade=CascadeType.ALL)
private List<Tag> tags;
.......
OTHER PROPERTIES
.......

@Entity
public class Tag
.......
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@ManyToOne
@JoinColumn(name="file_id")
private File file;
@Column
private String tag;
.......
OTHER PROPERTIES
.......

I am trying to insert into File (and subsequently Tag) by doing the following:

File file = new File();
Tag tag = new Tag();
tag.setTag("tag1");
Tag2 tag2 = new Tag();
tag2.setTag("tag2");
List<Tag> tags = new ArrayList<Tag>();
tags.add(tag);
tags.add(tag2);
file.setTags(tags);
---Add other file attributes here---

I am then inserting the file in my DAO using:

sessionFactory.getCurrentSession().saveOrUpdate(file);

In my logs I see an insert into my "file" table and 2 inserts into my tag table, however, the foreign key in my tag table that points to my file table (file_id) is NULL.

What could I possibly be doing wrong?


问:
Why is MIME type different when using different PC but with same config?
I created a function to check the file extension of and imported Excel file. I have run same source on 2 different PCs.

PC-1 Configuration:

Win 7 64bit

XAMPP with PHP 7.0.x

Browser Google Chrome

Microsoft Office 2013 installed

PC-2 Configuration:

Win 10 64bit

XAMPP with PHP 7.1.x

Browser Google Chrome

Open Office installed. Not install MS Office

My Excel file was created by Google Spreadsheet and exported as an MS Office file with extension .xlsx.

In PC-1, when I debug the $_FILES['file']['type']; value I get the extension:

```<code>'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
</code>```

Yet on PC-2, I received:

```<code>'application/octet-stream'
</code>```

My question is: Why with same source, same import file, just different environments, does the debug output show a different file extension? Is the cause installing MS Office?

答:
It's because Microsoft office isn't installed on PC 2.

So it Chrome doesn't know how to interpret.

Octet-stream is a last ditch attempt to interpret.

This post goes into more detail and there's a way you can tweak registry to perhaps achieve same result.

ContentLicense: CC BY-SA 3.0

Body:
I created a function to check the file extension of and imported Excel file. I have run same source on 2 different PCs.

PC-1 Configuration:

Win 7 64bit

XAMPP with PHP 7.0.x

Browser Google Chrome

Microsoft Office 2013 installed

PC-2 Configuration:

Win 10 64bit

XAMPP with PHP 7.1.x

Browser Google Chrome

Open Office installed. Not install MS Office

My Excel file was created by Google Spreadsheet and exported as an MS Office file with extension .xlsx.

In PC-1, when I debug the $_FILES['file']['type']; value I get the extension:

'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'

Yet on PC-2, I received:

'application/octet-stream'

My question is: Why with same source, same import file, just different environments, does the debug output show a different file extension? Is the cause installing MS Office?


问:
passing boto3.client instance to celery tasks raises JSON serialization error
I have a method that I am trying to call as a celery task:

```<code>@app.task
def launch_compute_node(client, timeout=20, wait_interval=5):

try:
    status = client.run_instances(
        InstanceType='t2.micro',
        MinCount=1,
        MaxCount=1,
        ImageId=XXXXXXX,
        KeyName=KEY_NAME,
        SecurityGroupIds=[XXXXXXX, XXXXXXXX],
        SubnetId=SUBNET_ID,
        PrivateIpAddress=XXXXXXX,
        TagSpecifications=[
        {'ResourceType': 'instance',
            'Tags': [
             {'Key': 'Name',
            'Value': NODE_NAME}]}]
    )
except ClientError as ex:
    logger.error(str(ex))
    return None

state = get_instance_state(status)
instance_id = status['Instances'][0]['InstanceId']
counter = timeout

while state != 'running':
    logger.debug('Instance not in running state, waiting...')
    time.sleep(wait_interval)   # sleep `wait_interval' seconds
    counter = counter - 1
    if counter <= 0:
        logger.warning('Timed out after %s attempts' % timeout)
        # TODO: Probably it's a good idea do terminate the failed instance here.
        return None

    status = client.describe_instances(InstanceIds=[instance_id])
    state = get_instance_state(status['Reservations'][0])
    instance_id = status['Reservations'][0]['Instances'][0]['InstanceId']
    logger.debug('Instance \'%s\' in state \'%s\'' % (instance_id, state))

logger.info('Instance \'%s\' ready for jobs' % instance_id)

return instance_id
</code>```

A perfectly sound method but when I create a celery task I get:

kombu.exceptions.EncodeError: <botocore.client.EC2 object at 0x106113438> is not JSON serializable

Which makes sense -- no reason why a boto EC2 client should be JSON serializable.  But this leaves me in a bind -- without significantly overhauling the code, how can I create and check the state of an EC2 instance from a celery task?

Any ideas are greatly appreciated!

答:
By default every message to the broker in celery are encoded to JSON. Kombu is responsible for the serialization of these messages.

In your case, you are trying to send a botocore.client.EC2 object and Kombu tries to serialize that in order to make a proper AMQP message that is stored by the broker and fed to celery.
However, JSON can serialize only a limited set of types by default. Since JSON doesn't know how to serialize your object this error is thrown.

My guess would be that the problem happens when you return the instance_id. What happens when you return nothing instead?

This article for serializing Django tasks might be useful to you.

Body:
I have a method that I am trying to call as a celery task:

@app.task
def launch_compute_node(client, timeout=20, wait_interval=5):

try:
    status = client.run_instances(
        InstanceType='t2.micro',
        MinCount=1,
        MaxCount=1,
        ImageId=XXXXXXX,
        KeyName=KEY_NAME,
        SecurityGroupIds=[XXXXXXX, XXXXXXXX],
        SubnetId=SUBNET_ID,
        PrivateIpAddress=XXXXXXX,
        TagSpecifications=[
        {'ResourceType': 'instance',
            'Tags': [
             {'Key': 'Name',
            'Value': NODE_NAME}]}]
    )
except ClientError as ex:
    logger.error(str(ex))
    return None

state = get_instance_state(status)
instance_id = status['Instances'][0]['InstanceId']
counter = timeout

while state != 'running':
    logger.debug('Instance not in running state, waiting...')
    time.sleep(wait_interval)   # sleep `wait_interval' seconds
    counter = counter - 1
    if counter <= 0:
        logger.warning('Timed out after %s attempts' % timeout)
        # TODO: Probably it's a good idea do terminate the failed instance here.
        return None

    status = client.describe_instances(InstanceIds=[instance_id])
    state = get_instance_state(status['Reservations'][0])
    instance_id = status['Reservations'][0]['Instances'][0]['InstanceId']
    logger.debug('Instance \'%s\' in state \'%s\'' % (instance_id, state))

logger.info('Instance \'%s\' ready for jobs' % instance_id)

return instance_id

A perfectly sound method but when I create a celery task I get:

kombu.exceptions.EncodeError: <botocore.client.EC2 object at 0x106113438> is not JSON serializable

Which makes sense -- no reason why a boto EC2 client should be JSON serializable.  But this leaves me in a bind -- without significantly overhauling the code, how can I create and check the state of an EC2 instance from a celery task?

Any ideas are greatly appreciated!


问:
get all the latest entries from table linq
I have two tables like below: (date format : mm/dd/yyyy)

Parameter master table:

```<code>   Id  Parameter
    1      ST
    2      GP
    3     Interest
    4      CC
</code>```

And Second TaxValue table :

```<code>Date     ParameterId   Value
1/1/2017    1          4
2/1/2017    1          4.5
1/15/2017   2          15
3/20/2017   2          20
3/21/2017   3          18
4/28/2017   3          20
1/1/2017    4          10
</code>```

I want to write a linq query to get all the latest parameters values from the date specified.

Desired Result: (if I want to get latest entries for today)

```<code>Date     Parameter   Value
2/1/2017    ST          4.5
3/20/2017   GP          20
4/28/2017   Interest    20
1/1/2017    CC          10
</code>```

Please help!!

答:
User OrderByDescending

```<code>var result = from n in table
        group n by n.Value into g
        select g.OrderByDescending(t=>t.Date).FirstOrDefault();
</code>```

Body:
I have two tables like below: (date format : mm/dd/yyyy)

Parameter master table:

   Id  Parameter
    1      ST
    2      GP
    3     Interest
    4      CC

And Second TaxValue table :

Date     ParameterId   Value
1/1/2017    1          4
2/1/2017    1          4.5
1/15/2017   2          15
3/20/2017   2          20
3/21/2017   3          18
4/28/2017   3          20
1/1/2017    4          10

I want to write a linq query to get all the latest parameters values from the date specified.

Desired Result: (if I want to get latest entries for today)

Date     Parameter   Value
2/1/2017    ST          4.5
3/20/2017   GP          20
4/28/2017   Interest    20
1/1/2017    CC          10

Please help!!

Body:
User OrderByDescending

var result = from n in table
        group n by n.Value into g
        select g.OrderByDescending(t=>t.Date).FirstOrDefault();


问:
Continue playback of YouTube player while rotating device with separate orientation layouts
I am trying to add a View containing a YouTube Player to an Activity that keeps on playing when I rotate the device. Since the UI contains more than just the video, I am using a YouTubePlayerFragment.

When the orientation changes from portrait to landscape, the system should use a different layout file. This layout also includes the YouTube player as a view which does not take up the whole screen. Below you will find the bare minimum code to reproduce the problem (for a fresh Android app, minimum API level 19).

```<code>package com.example.youtubefragmenttest;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerFragment;

public class MainActivity extends AppCompatActivity implements YouTubePlayer.OnInitializedListener {

    private static final String YOUTUBE_DEV_KEY = "[your youtube dev key here]";

    private static final String TAG_YOUTUBE_FRAGMENT = "YoutubePlayerFragment";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        FragmentManager fm = getFragmentManager();
        YouTubePlayerFragment retainedYoutubeFragment = (YouTubePlayerFragment) fm.findFragmentByTag(TAG_YOUTUBE_FRAGMENT);
        if (retainedYoutubeFragment == null) {
            retainedYoutubeFragment = YouTubePlayerFragment.newInstance();
            retainedYoutubeFragment.setRetainInstance(true);
            FragmentTransaction fragmentTransaction = fm.beginTransaction();
            fragmentTransaction.add(R.id.youtube_fragment, retainedYoutubeFragment, TAG_YOUTUBE_FRAGMENT);
            fragmentTransaction.commit();
        }
        retainedYoutubeFragment.initialize(YOUTUBE_DEV_KEY, this);
    }

    @Override
    public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {

        if (!wasRestored) {
            youTubePlayer.cueVideo("um4TrbU2Eic");
        }
    }

    @Override
    public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

    }
}
</code>```

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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.youtubefragmenttest.MainActivity">

    <FrameLayout
        android:id="@+id/youtube_fragment"
        android:layout_width="200dp"
        android:layout_height="200dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

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

I know the developers of the YouTubePlayer API recommend handling orientation changes manually. This is also the accepted answer in How to retain instance of fragment of fragment playing video after change in orientation?. Unfortunately, this will not work for me because there are too many complex differences between the layouts of portrait view and landscape view.

The documentation hints at a way to fix this such that boolean wasRestored in the callback method onInitializationSuccess is true, but this is the actual problem: wasRestored in the code above is always false.

Bottom line: how do you keep the YouTube player continue playing on orientation change while keeping separate layouts per orientation (which is the main difference with linked question)?

答: onInitializationSuccess returns a YoutubePlayer object that has a function on getCurrentTimeMillis(). Save this object as an activity instance (this.player = youTubePlayer) inside onInitializationSuccess. Before the activity is destroyed(oPause/onStop), get the current time and pass is to the retained fragment to be stored.

Body:
I am trying to add a View containing a YouTube Player to an Activity that keeps on playing when I rotate the device. Since the UI contains more than just the video, I am using a YouTubePlayerFragment.

When the orientation changes from portrait to landscape, the system should use a different layout file. This layout also includes the YouTube player as a view which does not take up the whole screen. Below you will find the bare minimum code to reproduce the problem (for a fresh Android app, minimum API level 19).

package com.example.youtubefragmenttest;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerFragment;

public class MainActivity extends AppCompatActivity implements YouTubePlayer.OnInitializedListener {

    private static final String YOUTUBE_DEV_KEY = "[your youtube dev key here]";

    private static final String TAG_YOUTUBE_FRAGMENT = "YoutubePlayerFragment";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        FragmentManager fm = getFragmentManager();
        YouTubePlayerFragment retainedYoutubeFragment = (YouTubePlayerFragment) fm.findFragmentByTag(TAG_YOUTUBE_FRAGMENT);
        if (retainedYoutubeFragment == null) {
            retainedYoutubeFragment = YouTubePlayerFragment.newInstance();
            retainedYoutubeFragment.setRetainInstance(true);
            FragmentTransaction fragmentTransaction = fm.beginTransaction();
            fragmentTransaction.add(R.id.youtube_fragment, retainedYoutubeFragment, TAG_YOUTUBE_FRAGMENT);
            fragmentTransaction.commit();
        }
        retainedYoutubeFragment.initialize(YOUTUBE_DEV_KEY, this);
    }

    @Override
    public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {

        if (!wasRestored) {
            youTubePlayer.cueVideo("um4TrbU2Eic");
        }
    }

    @Override
    public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

    }
}

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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.youtubefragmenttest.MainActivity">

    <FrameLayout
        android:id="@+id/youtube_fragment"
        android:layout_width="200dp"
        android:layout_height="200dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

</android.support.constraint.ConstraintLayout>

I know the developers of the YouTubePlayer API recommend handling orientation changes manually. This is also the accepted answer in How to retain instance of fragment of fragment playing video after change in orientation?. Unfortunately, this will not work for me because there are too many complex differences between the layouts of portrait view and landscape view.

The documentation hints at a way to fix this such that boolean wasRestored in the callback method onInitializationSuccess is true, but this is the actual problem: wasRestored in the code above is always false.

Bottom line: how do you keep the YouTube player continue playing on orientation change while keeping separate layouts per orientation (which is the main difference with linked question)?


问:
How to program Linux .dts device tree files?
I'm going to launch a Linux on my development board, and i need a dts file (device tree file) to describe the whole hardware. But I only know very little about the syntax of this file which is not enough to run Linux properly on the board.

What i know now are only how to describe a unit's interrupt number, frequency, address, parent-unit and its compatible driver type (as described below):

```<code>ps7_scuwdt_0: ps7-scuwdt@f8f00620 {
                        compatible = "xlnx,ps7-scuwdt-1.00.a";
                        device_type = "watchdog";
                        interrupt-parent = <&ps7_scugic_0>;
                        interrupts = < 1 14 769 >;
                        reg = < 0xf8f00620 0xe0 >;
                } ;
</code>```

Other advanced usage or grammar is unfamiliar to me.

答:
Minimal reg + interrupt example with QEMU virtual device

Our example will add the following device tree node to the versatilepb device tree which QEMU will use due to -M versatilepb:

```<code>lkmc_platform_device@101e9000 {
    compatible = "lkmc_platform_device";
    reg = <0x101e9000 0x1000>;
    interrupts = <18>;
    interrupt-controller;
    #interrupt-cells = <2>;
    clocks = <&pclk>;
    clock-names = "apb_pclk";
    lkmc-asdf = <0x12345678>;
};
</code>```

Then, by using a Linux kernel module to interact with the device, we will test the following DTS features:

registers addresses

IRQs

read custom properties from the driver

These are the main components of the example:

Linux versatile .dts patch on Linux fork

reg and interrupt match numbers hard-coded in the QEMU versatile machine (which represents the SoC)

compatible matches the platform_driver.name in the kernel module, and informs the kernel which module will handle this device

we also pass a custom property to the driver: lkmc-asdf = <0x12345678>;, which is read with of_property_read_u32

the device tree is passed to QEMU's firmware with the -dtb argument

QEMU fork:

device that reads a register and generates interrupts

insert device into -M versatilepb

kernel module Writes to memory on probe to test things out, which also generates an IRQ.

Device trees have many more features that we haven't covered, but this example should get you started, and easily allow you to play around with any new features that come up.

Further resources:

indispensable elinux tutorial: http://elinux.org/Device_Tree_Usage

play around with dtc for purely syntaxical questions. E.g., it shows how nodes are simply merged by path: https://unix.stackexchange.com/a/375923/32558

https://unix.stackexchange.com/questions/118683/what-is-a-device-tree-and-a-device-tree-blob

Body:
I'm going to launch a Linux on my development board, and i need a dts file (device tree file) to describe the whole hardware. But I only know very little about the syntax of this file which is not enough to run Linux properly on the board.

What i know now are only how to describe a unit's interrupt number, frequency, address, parent-unit and its compatible driver type (as described below):

ps7_scuwdt_0: ps7-scuwdt@f8f00620 {
                        compatible = "xlnx,ps7-scuwdt-1.00.a";
                        device_type = "watchdog";
                        interrupt-parent = <&ps7_scugic_0>;
                        interrupts = < 1 14 769 >;
                        reg = < 0xf8f00620 0xe0 >;
                } ;

Other advanced usage or grammar is unfamiliar to me.

Body:
Minimal reg + interrupt example with QEMU virtual device

Our example will add the following device tree node to the versatilepb device tree which QEMU will use due to -M versatilepb:

lkmc_platform_device@101e9000 {
    compatible = "lkmc_platform_device";
    reg = <0x101e9000 0x1000>;
    interrupts = <18>;
    interrupt-controller;
    #interrupt-cells = <2>;
    clocks = <&pclk>;
    clock-names = "apb_pclk";
    lkmc-asdf = <0x12345678>;
};

Then, by using a Linux kernel module to interact with the device, we will test the following DTS features:

registers addresses

IRQs

read custom properties from the driver

These are the main components of the example:

Linux versatile .dts patch on Linux fork

reg and interrupt match numbers hard-coded in the QEMU versatile machine (which represents the SoC)

compatible matches the platform_driver.name in the kernel module, and informs the kernel which module will handle this device

we also pass a custom property to the driver: lkmc-asdf = <0x12345678>;, which is read with of_property_read_u32

the device tree is passed to QEMU's firmware with the -dtb argument

QEMU fork:

device that reads a register and generates interrupts

insert device into -M versatilepb

kernel module Writes to memory on probe to test things out, which also generates an IRQ.

Device trees have many more features that we haven't covered, but this example should get you started, and easily allow you to play around with any new features that come up.

Further resources:

indispensable elinux tutorial: http://elinux.org/Device_Tree_Usage

play around with dtc for purely syntaxical questions. E.g., it shows how nodes are simply merged by path: https://unix.stackexchange.com/a/375923/32558

https://unix.stackexchange.com/questions/118683/what-is-a-device-tree-and-a-device-tree-blob


问:
Periodic HTML Text Centering
Im building a stopwatch with javascript and the issue is that although centering does work, the dynamic nature of the stopwatch means a very jittery effect when it constantly tries to recenter on every new number. As some  numbers are wider or thinner, it means it keeps on "jittering". This is very distracting.

However, I still do wish for the time to centered on screen. I had success with keeping the time on just one side of the screen however it was not aesthetically pleasing. I was wondering if there was a way to only center the text once in say 1 min? (I was thinking of centering and then using padding to pad up to where it was centered, thus meaning it would be aligned against the padding and maybe redoing this proccess every 30secs or something)

Thank you

答:
To stop the jittering effect, you could place the text inside a div and center the div. </p>

```<code>stopwatch_container{
  width: 100px;
  margin: auto; /*This will center the div*/
}

stopwatch_text {
  text-align: left;
}
</code>```

<p>Hope it helps. </p>

Title: Periodic HTML Text Centering

Body:
To stop the jittering effect, you could place the text inside a div and center the div.

stopwatch_container{
  width: 100px;
  margin: auto; /*This will center the div*/
}

stopwatch_text {
  text-align: left;
}

Hope it helps.


问:
iOS: Animating a circle slice into a wider one
Core-Animation treats angles as described in this image:
(image from http://btk.tillnagel.com/tutorials/rotation-translation-matrix.html)

EDIT: Adding an animated gif to explain better what I'm needing:

I need to animate a slice to grow wider, starting at 300:315 degrees, and ending 300:060.

To create each slice I'm using this function:

```<code>extension CGFloat {
    func toRadians() -> CGFloat {
        return self * CGFloat(Double.pi) / 180.0
    }
}
func createSlice(angle1:CGFloat, angle2:CGFloat) -> UIBezierPath! {
    let path: UIBezierPath = UIBezierPath()
    let width: CGFloat = self.frame.size.width/2
    let height: CGFloat = self.frame.size.height/2
    let centerToOrigin: CGFloat = sqrt((height)*(height)+(width)*(width));
    let ctr: CGPoint = CGPoint(x: width, y: height)
    path.move(to: ctr)
    path.addArc( withCenter: ctr,
                 radius: centerToOrigin,
                 startAngle: CGFloat(angle1).toRadians(),
                 endAngle: CGFloat(angle2).toRadians(),
                 clockwise: true
    )
    path.close()
    return path
}
</code>```

I can now create the two slices and a sublayer with the smaller one, but I can't find how to proceed from this point:

```<code>func doStuff() {
    path1 = self.createSlice(angle1: 300,angle2: 315)
    path2 = self.createSlice(angle1: 300,angle2: 60)

    let shapeLayer = CAShapeLayer()
    shapeLayer.path = path1.cgPath
    shapeLayer.fillColor = UIColor.cyan.cgColor
    self.layer.addSublayer(shapeLayer)
</code>```

I would highly appreciate any help here!

答:
I'm adding a slight improvement for David's class. (David - you are welcome to copy into your book-quality answer!)

You can add the following init function:

```<code>convenience init(frame:CGRect, startAngle:CGFloat, endAngle:CGFloat, fillColor:UIColor,
                 strokeColor:UIColor, strokeWidth:CGFloat) {
    self.init()
    self.frame = frame
    self.startAngle = startAngle
    self.endAngle = endAngle
    self.fillColor = fillColor
    self.strokeColor = strokeColor
    self.strokeWidth = strokeWidth
}
</code>```

and then call it like this (Objective-C in my case):

```<code>PieSegmentLayer *sliceLayer = [[PieSegmentLayer alloc] initWithFrame:r startAngle:30 endAngle:180 fillColor:[UIColor cyanColor] strokeColor:[UIColor redColor] strokeWidth:4];
[self.view.layer addSublayer:sliceLayer];
</code>```

Body:
Core-Animation treats angles as described in this image:
(image from http://btk.tillnagel.com/tutorials/rotation-translation-matrix.html)

EDIT: Adding an animated gif to explain better what I'm needing:

I need to animate a slice to grow wider, starting at 300:315 degrees, and ending 300:060.

To create each slice I'm using this function:

extension CGFloat {
    func toRadians() -> CGFloat {
        return self * CGFloat(Double.pi) / 180.0
    }
}
func createSlice(angle1:CGFloat, angle2:CGFloat) -> UIBezierPath! {
    let path: UIBezierPath = UIBezierPath()
    let width: CGFloat = self.frame.size.width/2
    let height: CGFloat = self.frame.size.height/2
    let centerToOrigin: CGFloat = sqrt((height)*(height)+(width)*(width));
    let ctr: CGPoint = CGPoint(x: width, y: height)
    path.move(to: ctr)
    path.addArc( withCenter: ctr,
                 radius: centerToOrigin,
                 startAngle: CGFloat(angle1).toRadians(),
                 endAngle: CGFloat(angle2).toRadians(),
                 clockwise: true
    )
    path.close()
    return path
}

I can now create the two slices and a sublayer with the smaller one, but I can't find how to proceed from this point:

func doStuff() {
    path1 = self.createSlice(angle1: 300,angle2: 315)
    path2 = self.createSlice(angle1: 300,angle2: 60)

    let shapeLayer = CAShapeLayer()
    shapeLayer.path = path1.cgPath
    shapeLayer.fillColor = UIColor.cyan.cgColor
    self.layer.addSublayer(shapeLayer)

I would highly appreciate any help here!

Body:
I'm adding a slight improvement for David's class. (David - you are welcome to copy into your book-quality answer!)

You can add the following init function:

convenience init(frame:CGRect, startAngle:CGFloat, endAngle:CGFloat, fillColor:UIColor,
                 strokeColor:UIColor, strokeWidth:CGFloat) {
    self.init()
    self.frame = frame
    self.startAngle = startAngle
    self.endAngle = endAngle
    self.fillColor = fillColor
    self.strokeColor = strokeColor
    self.strokeWidth = strokeWidth
}

and then call it like this (Objective-C in my case):

PieSegmentLayer *sliceLayer = [[PieSegmentLayer alloc] initWithFrame:r startAngle:30 endAngle:180 fillColor:[UIColor cyanColor] strokeColor:[UIColor redColor] strokeWidth:4];
[self.view.layer addSublayer:sliceLayer];


问:
How to split a String with null until the end in Java?
I have to stringify a simple Double array in order to put it in my database (in this case this is the best way I found)

I'm using StringUtils.join() to stringify but I have a problem with the splitting because there is a lot of null values at the end of my array (which is expected).

Here is some code example :

```<code>final String NEEDLE = "_";
Double[] dblArray = new Double[]{2.0, 2.0, 2.0, 0.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null};
String joined = StringUtils.join(dblArray, NEEDLE);
String[] split = joined.split(NEEDLE); //I will then cast the string to double

Log.d("MyApp", "joined=" + joined);
Log.d("MyApp", "1 - split=" + Arrays.toString(split));
Log.d("MyApp", "2 - StringUtils.split=" + Arrays.toString(StringUtils.split(joined, NEEDLE)));
Log.d("MyApp", "3 - split+xxx=" + Arrays.toString((joined+"xxx").split(NEEDLE)));
Log.d("MyApp", "4 - StringUtils.split+xxx=" + Arrays.toString(StringUtils.split(joined+"xxx", NEEDLE)));
</code>```

And here ARE the results :

D: joined=2.0_2.0_2.0_0.0_______________________________________________________

  D: 1 - split=[2.0, 2.0, 2.0, 0.0]

  D: 2 - StringUtils.split=[2.0, 2.0, 2.0, 0.0]

  D: 3 - split+xxx=[2.0, 2.0, 2.0, 0.0, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , xxx]

  D: 4 - StringUtils.split+xxx=[2.0, 2.0, 2.0, 0.0, xxx]

The expected behaviour is the #3, but as you can see, for my split result to contain the null values, I have to add something at the end of the string, which is highly unexpected.

Is there a clean way to split it with null values until the end but without adding dummy value in the end ?

答:
Assuming Java 8:

```<code>String joined = Arrays.stream(dblArray)
    .filter(Objects::nonNull)
    .map(Double::toString)
    .collect(joining(","))
</code>```

Edit:

If not using Java 8, Guava Joiner can do this as well.

Edit 2 ( pre Java 8 and not using third-party lib):

```<code>StringBuilder buffer = new StringBuilder();

for (Double d : dblArray) {
    if (Objects.nonNull(d)) {
        buffer.append(d + ",");
    }
}

String joined = buffer.substring(0, buffer.length() - 1);
</code>```

Body:
I have to stringify a simple Double array in order to put it in my database (in this case this is the best way I found)

I'm using StringUtils.join() to stringify but I have a problem with the splitting because there is a lot of null values at the end of my array (which is expected).

Here is some code example :

final String NEEDLE = "_";
Double[] dblArray = new Double[]{2.0, 2.0, 2.0, 0.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null};
String joined = StringUtils.join(dblArray, NEEDLE);
String[] split = joined.split(NEEDLE); //I will then cast the string to double

Log.d("MyApp", "joined=" + joined);
Log.d("MyApp", "1 - split=" + Arrays.toString(split));
Log.d("MyApp", "2 - StringUtils.split=" + Arrays.toString(StringUtils.split(joined, NEEDLE)));
Log.d("MyApp", "3 - split+xxx=" + Arrays.toString((joined+"xxx").split(NEEDLE)));
Log.d("MyApp", "4 - StringUtils.split+xxx=" + Arrays.toString(StringUtils.split(joined+"xxx", NEEDLE)));

And here ARE the results :

D: joined=2.0_2.0_2.0_0.0_______________________________________________________

  D: 1 - split=[2.0, 2.0, 2.0, 0.0]

  D: 2 - StringUtils.split=[2.0, 2.0, 2.0, 0.0]

  D: 3 - split+xxx=[2.0, 2.0, 2.0, 0.0, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , xxx]

  D: 4 - StringUtils.split+xxx=[2.0, 2.0, 2.0, 0.0, xxx]

The expected behaviour is the #3, but as you can see, for my split result to contain the null values, I have to add something at the end of the string, which is highly unexpected.

Is there a clean way to split it with null values until the end but without adding dummy value in the end ?

Body:
Assuming Java 8:

String joined = Arrays.stream(dblArray)
    .filter(Objects::nonNull)
    .map(Double::toString)
    .collect(joining(","))

Edit:

If not using Java 8, Guava Joiner can do this as well.

Edit 2 ( pre Java 8 and not using third-party lib):

StringBuilder buffer = new StringBuilder();

for (Double d : dblArray) {
    if (Objects.nonNull(d)) {
        buffer.append(d + ",");
    }
}

String joined = buffer.substring(0, buffer.length() - 1);


问:
Javascript Abstract Class with Object create
This is my Abstract class:

```<code>var Animal = function(){
    this.name = ''
    this.legs = 0;
    throw new Error("cannot instantiate abstract class");
}
Animal.prototype.walk = function(){ console.log(this.name+ " walked")};
</code>```

Creating a new Concrete Class:

```<code>var Dog = function(){} ;
</code>```

Now I want to make a concrete class Dog to inherit from abstract class Animal.  I tried both ways below.  Which one is the standard?:

```<code>Dog.prototype = Object.create(Animal.prototype)
</code>```

OR

```<code>Dog.prototype = Animal.prototype
</code>```

I also tried var Dog = Object.create(Animal)which gave me an error.

答:
Inside Animal class you can make if check to see if the current constructor is Animal and throw an Error if it is. When you call parent constructor inside Dog and inherit from prototype you also need to set its constructor pointer to Dog.

var Animal = function() {
  this.name = ''
  this.legs = 0;
  if (this.constructor == Animal) {
    throw new Error("cannot instantiate abstract class");
  }
}
Animal.prototype.walk = function() {
  console.log(this.name + " walked")
};

function Dog() {
  Animal.call(this);
}

Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;

var inst = new Dog;
inst.name = 'lorem';
inst.walk()```

Body:
This is my Abstract class:

var Animal = function(){
    this.name = ''
    this.legs = 0;
    throw new Error("cannot instantiate abstract class");
}
Animal.prototype.walk = function(){ console.log(this.name+ " walked")};

Creating a new Concrete Class:

var Dog = function(){} ;

Now I want to make a concrete class Dog to inherit from abstract class Animal.  I tried both ways below.  Which one is the standard?:

Dog.prototype = Object.create(Animal.prototype)

OR

Dog.prototype = Animal.prototype

I also tried var Dog = Object.create(Animal)which gave me an error.


问:
Is it possible to render table at end tag
Let's say I have a large table (a couple of thousand rows) and I want the whole table to render as fast as possible.

Is it possible to somehow delay rendering of a table until the whole table is downloaded ? Otherwise the width calculations after each row seem to take up too much time.

When I use IE without a declared doctype the browser seem to wait until it gets the table’s closing tag. However when I do declare a doctype the table start rendering at once and therefore have to calculate the table width after each new row.
I don't want to use table-layout:fixed since I don’t want the content to line break where it shouldn’t.

It only seem to be a significant time difference in IE(8)?

(Pagination is not an option)

Thanks!

答:
Although it would be an ugly solution, you could propably wrap that HTML in a document.write()-call or so which would propably delay rendering.

Something like this:

```<code><script>document.write('<table>...</table>')</script>
</code>```

Body:
Although it would be an ugly solution, you could propably wrap that HTML in a document.write()-call or so which would propably delay rendering.

Something like this:

<script>document.write('<table>...</table>')</script>


问:
how to pass selected value in a DropDownList as input parameter in @Ajax.ActionLink
i want to pass a parameter from dropdownlist to actionlink.

DropDownList :
@Html.DropDownList("Zpy_moisId", null, "")

actionlink :
@Ajax.ActionLink("PRI", "_PRI",
        new AjaxOptions
        {
            HttpMethod = "GET",
            UpdateTargetId = "PRI",
            InsertionMode = InsertionMode.Replace
        })

Thanks a lot

答:
if have a select like this :

```<code><select>
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>
</code>```

can pass selected value after select with jQuery $.ajax:

```<code> $("select").change(function () {
        var data = $(this).find(":selected").text();
        $.ajax({
            url : "url/address" ,
            type: "GET",
            data : data,
            success : function () {
                alert("success done");
            }
        })
    });
</code>```

Body:
if have a select like this :

<select>
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>

can pass selected value after select with jQuery $.ajax:

 $("select").change(function () {
        var data = $(this).find(":selected").text();
        $.ajax({
            url : "url/address" ,
            type: "GET",
            data : data,
            success : function () {
                alert("success done");
            }
        })
    });


问:
Endless RecyclerView data loading logic is not consistent on all devices
I'm loading data from SQLite database in RecyclerView in batch of 25 records per load cycle. I figure out every thing but having problem with logic of calling data loading method in RecyclerView scroll listener.

Problem is list is loading nicely on scroll of recyclerView in emulator but when i tested in physical device, on Lenovo Phab 2 it worked fine but in Mi note 3, list doesn't load consistenly (sometime it loads, sometime not) more records on reaching bottom of scroll.

Below is the code I'm using in RecyclerView scrolle listener

```<code>private val RecyclerView_ScrollListener = object : RecyclerView.OnScrollListener(){
    override fun onScrolled(recyclerView1: RecyclerView?, dx: Int, dy: Int) {
        super.onScrolled(recyclerView1, dx, dy)

        if (dy > 0) {
            if (limit < rowCount_fromDatabase) {
                visibleItemCount = layoutManager_MemberList.childCount
                totalItemCount = layoutManager_MemberList.itemCount
                firstVisibleItemPosition = layoutManager_MemberList.findFirstVisibleItemPosition()

                if (visibleItemCount + firstVisibleItemPosition >= totalItemCount) {
                    limit += 25
                    load_Data()
                }
            }
        }
}
</code>```

答:
What i use to scroll more is :

```<code>        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
           if (!recyclerView.canScrollVertically(1)){
             //Load more data here. It will only trigger when you reach the end of your list and cannot scroll further
           }
        }
    });
</code>```

Hope this helps.

Body:
I'm loading data from SQLite database in RecyclerView in batch of 25 records per load cycle. I figure out every thing but having problem with logic of calling data loading method in RecyclerView scroll listener.

Problem is list is loading nicely on scroll of recyclerView in emulator but when i tested in physical device, on Lenovo Phab 2 it worked fine but in Mi note 3, list doesn't load consistenly (sometime it loads, sometime not) more records on reaching bottom of scroll.

Below is the code I'm using in RecyclerView scrolle listener

private val RecyclerView_ScrollListener = object : RecyclerView.OnScrollListener(){
    override fun onScrolled(recyclerView1: RecyclerView?, dx: Int, dy: Int) {
        super.onScrolled(recyclerView1, dx, dy)

        if (dy > 0) {
            if (limit < rowCount_fromDatabase) {
                visibleItemCount = layoutManager_MemberList.childCount
                totalItemCount = layoutManager_MemberList.itemCount
                firstVisibleItemPosition = layoutManager_MemberList.findFirstVisibleItemPosition()

                if (visibleItemCount + firstVisibleItemPosition >= totalItemCount) {
                    limit += 25
                    load_Data()
                }
            }
        }
}

Body:
What i use to scroll more is :

        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
           if (!recyclerView.canScrollVertically(1)){
             //Load more data here. It will only trigger when you reach the end of your list and cannot scroll further
           }
        }
    });

Hope this helps.


问:
How do I continue a mercurial merge
I've spent the last few hours doing an enormous merge in mercurial.  After 131 files merged, my merge tool, meld, crashed showing a python traceback.  Trying to quit meld, I've inadvertently also quit out of the mercurial merge.

I'd quite like to just continue the merge from where I left off, e.g. something like hg merge --continue but I can't find an option to do that.

If I re-run hg merge it warns about uncommitted outstanding changes.  hg resolve doesn't list anything to resolve, but I am most likely only about 60% of the way through the merge.

Is there a command to continue the merge from where I was?

答:
In TortoiseHg:

Select all files which are still marked as conflicted

Right-click on the files, and select "Restart merge"

Resolve the files

Commit the change

From command line:

hg resolve --all (continue the merge with all files that are still marked as conflicted)

Resolve the files

hg commit (commit the change)

hg resolve does nothing. To list files which have outstanding conflicts, use hg resolve --list. (The prefix U means that the file is unresolved, R is resolved.)

Title: How do I continue a mercurial merge


问:
Gluon javafx with netbeans error android install
Error while trying to to do android install

  Execution failed for task ':mergeClassesIntoJar'.

Cannot expand ZIP 'C:\Users\Path..\AppData\Local\Android\sdk\extras\android\support\multidex\library\libs\android-support-multidex.jar' as it does not exist.

```<code>Can any one pleas help am fed up of this issue no proper solution below is my code
buildscript {
    repositories {

        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.9'

    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.netbeansdemo.NetbeansDemo'

dependencies {
    compile 'com.gluonhq:charm:3.0.0'

    androidRuntime 'com.gluonhq:charm-android:3.0.0'
    iosRuntime 'com.gluonhq:charm-ios:3.0.0'
    desktopRuntime 'com.gluonhq:charm-desktop:3.0.0'
}

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
        androidSdk = 'C:/Users/ee209275/AppData/Local/Android/Sdk'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'io.datafx.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}
</code>```

答:
You need to update the Gluon plugin for your IDE, so you can generate a project with updated dependencies. Current versions of the plugin are 2.5.0 for NetBeans and IntelliJ, 2.4.0 for Eclipse.

For a single view project, this will be the build.gradle file you will get:

```<code>buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.6'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.gluonhq.testplugin.GluonTestPlugin'

dependencies {
    compile 'com.gluonhq:charm:4.3.5'
}

jfxmobile {
    downConfig {
        version = '3.3.0'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}
</code>```

You have an issue with the Android SDK path. This question shows how to solve it.

Basically:

Open the Android SDK Manager and make sure you have installed Extras/Google Repository and Extras/Android Support Repository.

Remove the androidSdk line from the android block on your build.gradle file and move it to a properties file. For that, just create a properties file under C:\Users\<user>\.gradle\gradle.properties, and add the ANDROID_HOME variable: ANDROID_HOME=C:/<path.to.Android>/sdk.

Then reload your project, see that it works on desktop, and then deploy to mobile.

Body:
Error while trying to to do android install

  Execution failed for task ':mergeClassesIntoJar'.

Cannot expand ZIP 'C:\Users\Path..\AppData\Local\Android\sdk\extras\android\support\multidex\library\libs\android-support-multidex.jar' as it does not exist.

Can any one pleas help am fed up of this issue no proper solution below is my code
buildscript {
    repositories {

        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.9'

    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.netbeansdemo.NetbeansDemo'

dependencies {
    compile 'com.gluonhq:charm:3.0.0'

    androidRuntime 'com.gluonhq:charm-android:3.0.0'
    iosRuntime 'com.gluonhq:charm-ios:3.0.0'
    desktopRuntime 'com.gluonhq:charm-desktop:3.0.0'
}

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
        androidSdk = 'C:/Users/ee209275/AppData/Local/Android/Sdk'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'io.datafx.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

Body:
You need to update the Gluon plugin for your IDE, so you can generate a project with updated dependencies. Current versions of the plugin are 2.5.0 for NetBeans and IntelliJ, 2.4.0 for Eclipse.

For a single view project, this will be the build.gradle file you will get:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.6'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.gluonhq.testplugin.GluonTestPlugin'

dependencies {
    compile 'com.gluonhq:charm:4.3.5'
}

jfxmobile {
    downConfig {
        version = '3.3.0'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

You have an issue with the Android SDK path. This question shows how to solve it.

Basically:

Open the Android SDK Manager and make sure you have installed Extras/Google Repository and Extras/Android Support Repository.

Remove the androidSdk line from the android block on your build.gradle file and move it to a properties file. For that, just create a properties file under C:\Users\<user>\.gradle\gradle.properties, and add the ANDROID_HOME variable: ANDROID_HOME=C:/<path.to.Android>/sdk.

Then reload your project, see that it works on desktop, and then deploy to mobile.


问:
Java - tree data structure with multiple nodes - how to search efficiently
I am searching for a implementation/data structure for some categories and child categories that i have.  I am thinking to use a search tree but not sure how to begin implementation.

Let me show you what the data looks like. its acutally coming to me as a json structure from back end but it looks like this:

```<code>  [
    {
      "id": 94,
      "category_name": "New In", //this is the category category_name
      "description": "",
      "children": [ //this is the category children which can also be a sub-category
        {
          "id": 322,
          "category_name": "New Studio",
          "description": "Chic, sophisticated and polished with a classic edge."
        },
        {
          "id": 365,
          "category_name": "New Soho",
          "description": "Fresh, eclectic, and trendy. Oozes effortless cool."
        },
        {
          "id": 809,
          "category_name": "Summer Collection",
          "description": "Your ultimate summer look"
        }
      ]
    },
    {
      "id": 12,
      "category_name": "Clothes",
      "description": "",
      "children": [
        {
          "id": 22,
          "category_name": "All Clothes",
          "description": ""
        },
        {
          "id": 63,
          "category_name": "Tops",
          "description": "",
          "children": [
            {
              "id": 5,
              "category_name": "All Tops",
              "description": ""
            }

          ]
        },
        {
          "id": 641,
          "category_name": "Accessories",
          "description": "",
          "children": [
            {
              "id": 61,
              "category_name": "All Accessories",
              "description": ""
            },
            {
              "id": 622,
              "category_name": "Jewelry",
              "description": "",
              "children": [ // here is an example of a child that is a sub-category also
                {
                  "id": 52,
                  "category_name": "All Jewelry",
                  "description": ""
                },
                {
                  "id": 68,
                  "name": "Necklaces",
                  "description": ""
                },
                {
                  "id": 69,
                  "name": "Bracelets",
                  "description": ""
                },

              ]
            },

  ]
</code>```

so if i had to draw this out it would look something like this:

So i want to be able to get path to anything.  So for example if i want to search for Necklaces, then i want as well as getting a necklace to get the path of : Categories/Accessories/Jewelry/Necklaces

Is there a built in data structure for this ? i am coding in java.  I suppose i also need the nodes sorted in some kind of order maybe A-Z.

so far i have this:

```<code>class Node{
 String label;
 List<Node> children;
}
</code>```

but then how to search ? and is there a better data structure ? I do not want to iterate over all the nodes during a search, is there a way to sort the tree so i dont have to do that ? How i have it now i'd have to iterate over all the children. is there a way to maybe sort alphaetically perhaps or some kind of sort that would make the lookup faster ?

答:
I had a project this semester for searching on trees. I used different kind of algorithms. For example, BFS or DFS  it depends on what you want and how you want to move on nodes in your tree. But, I prefer IDS(Iterative deepening depth-first search). To use this algorithm you can access this links.

it is better to have father instead of children cause it works better and you will not run out of memory.

clip in Youtube to show IDS

complete teaching about IDS

There are other good algorithms if you want you can just ask me.
You need to define a State class.

```<code>
    class State{
    String name;
    State father;
    }

</code>```

Body:
I am searching for a implementation/data structure for some categories and child categories that i have.  I am thinking to use a search tree but not sure how to begin implementation.

Let me show you what the data looks like. its acutally coming to me as a json structure from back end but it looks like this:

  [
    {
      "id": 94,
      "category_name": "New In", //this is the category category_name
      "description": "",
      "children": [ //this is the category children which can also be a sub-category
        {
          "id": 322,
          "category_name": "New Studio",
          "description": "Chic, sophisticated and polished with a classic edge."
        },
        {
          "id": 365,
          "category_name": "New Soho",
          "description": "Fresh, eclectic, and trendy. Oozes effortless cool."
        },
        {
          "id": 809,
          "category_name": "Summer Collection",
          "description": "Your ultimate summer look"
        }
      ]
    },
    {
      "id": 12,
      "category_name": "Clothes",
      "description": "",
      "children": [
        {
          "id": 22,
          "category_name": "All Clothes",
          "description": ""
        },
        {
          "id": 63,
          "category_name": "Tops",
          "description": "",
          "children": [
            {
              "id": 5,
              "category_name": "All Tops",
              "description": ""
            }

          ]
        },
        {
          "id": 641,
          "category_name": "Accessories",
          "description": "",
          "children": [
            {
              "id": 61,
              "category_name": "All Accessories",
              "description": ""
            },
            {
              "id": 622,
              "category_name": "Jewelry",
              "description": "",
              "children": [ // here is an example of a child that is a sub-category also
                {
                  "id": 52,
                  "category_name": "All Jewelry",
                  "description": ""
                },
                {
                  "id": 68,
                  "name": "Necklaces",
                  "description": ""
                },
                {
                  "id": 69,
                  "name": "Bracelets",
                  "description": ""
                },

              ]
            },

  ]

so if i had to draw this out it would look something like this:

So i want to be able to get path to anything.  So for example if i want to search for Necklaces, then i want as well as getting a necklace to get the path of : Categories/Accessories/Jewelry/Necklaces

Is there a built in data structure for this ? i am coding in java.  I suppose i also need the nodes sorted in some kind of order maybe A-Z.

so far i have this:

class Node{
 String label;
 List<Node> children;
}

but then how to search ? and is there a better data structure ? I do not want to iterate over all the nodes during a search, is there a way to sort the tree so i dont have to do that ? How i have it now i'd have to iterate over all the children. is there a way to maybe sort alphaetically perhaps or some kind of sort that would make the lookup faster ?

Body:
I had a project this semester for searching on trees. I used different kind of algorithms. For example, BFS or DFS  it depends on what you want and how you want to move on nodes in your tree. But, I prefer IDS(Iterative deepening depth-first search). To use this algorithm you can access this links.

it is better to have father instead of children cause it works better and you will not run out of memory.

clip in Youtube to show IDS

complete teaching about IDS

There are other good algorithms if you want you can just ask me.
You need to define a State class.

    class State{
    String name;
    State father;
    }

ContentLicense: CC BY-SA 4.0


问:
How to use .split() while setting an argument to skip a specific tag
I am trying to split all text group from a readme file, this is to get all the individual words, however words written inside the markdown syntax for embeding a URL.. []() are showing unwanted results.

So, if I use .split() on this sentence

The site uses the [stackoverlow api](https://api.stackexchange.com/docs)  to fetch all existing tags and create a

.split() will treat [stackoverflow api](.. as two words and yield this result

```<code>>>> r = "The site uses the [stackoverlow api](https://api.stackexchange.com/docs)  to fetch"
>>> print(r.split())
['The', 'site', 'uses', 'the', '[stackoverlow', 'api](https://api.stackexchange.com/docs)', 'to', 'fetch']
>>>
</code>```

Since this is unintended, is there way to ignore anything inside []() or treat it as a single word?

答:
The solution using re.findall() function:

```<code>import re

s = "The site uses the [stackoverlow api](https://api.stackexchange.com/docs)  to fetch"
result = re.findall(r'\[[^]]+\]\([^)]+\)|\S+', s)

print(result)
</code>```

The output:

```<code>['The', 'site', 'uses', 'the', '[stackoverlow api](https://api.stackexchange.com/docs)', 'to', 'fetch']
</code>```

\[[^]]+\]\([^)]+\) - matches sequence [...](...) as a single item

\S+ - matches non-whitespace character sequence (word)

Body:
I am trying to split all text group from a readme file, this is to get all the individual words, however words written inside the markdown syntax for embeding a URL.. []() are showing unwanted results.

So, if I use .split() on this sentence

The site uses the [stackoverlow api](https://api.stackexchange.com/docs)  to fetch all existing tags and create a

.split() will treat [stackoverflow api](.. as two words and yield this result

>>> r = "The site uses the [stackoverlow api](https://api.stackexchange.com/docs)  to fetch"
>>> print(r.split())
['The', 'site', 'uses', 'the', '[stackoverlow', 'api](https://api.stackexchange.com/docs)', 'to', 'fetch']
>>>

Since this is unintended, is there way to ignore anything inside []() or treat it as a single word?

Body:
The solution using re.findall() function:

import re

s = "The site uses the [stackoverlow api](https://api.stackexchange.com/docs)  to fetch"
result = re.findall(r'\[[^]]+\]\([^)]+\)|\S+', s)

print(result)

The output:

['The', 'site', 'uses', 'the', '[stackoverlow api](https://api.stackexchange.com/docs)', 'to', 'fetch']

\[[^]]+\]\([^)]+\) - matches sequence [...](...) as a single item

\S+ - matches non-whitespace character sequence (word)


问:
Why does an inline function have lower efficiency than an in-built function?
I was trying a question on arrays in InterviewBit. In this question I made an inline function returning the absolute value of an integer. But I was told that my algorithm was not efficient on submitting it. But when I changed to using abs() from C++ library it gave a correct answer verdict.

Here is my function that got an inefficient verdict -

```<code>inline int abs(int x){return x>0 ? x : -x;}

int Solution::coverPoints(vector<int> &X, vector<int> &Y) {
    int l = X.size();
    int i = 0;
    int ans = 0;
    while (i<l-1){
        ans = ans + max(abs(X[i]-X[i+1]), abs(Y[i]-Y[i+1]));
        i++;
    }
    return ans;
}
</code>```

Here's the one that got the correct answer -

```<code>int Solution::coverPoints(vector<int> &X, vector<int> &Y) {
    int l = X.size();
    int i = 0;
    int ans = 0;
    while (i<l-1){
        ans = ans + max(abs(X[i]-X[i+1]), abs(Y[i]-Y[i+1]));
        i++;
    }
    return ans;
}
</code>```

Why did this happened, as I thought that inline functions are fastest as no calling is done? Or is the site having an error? And if the site is correct, what does C++ abs() use that is faster than inline abs()?

答:
I don't agree with their verdict. They are clearly wrong.

On current, optimizing compilers, both solutions produce the exact same output. And even, if they didn't produce the exact same, they would produce as efficient code as the library one (it could be a little surprising that everything matches: the algorithm, the registers used. Maybe because the actual library implementation is the same as OP's one?).

No sane optimizing compiler will create branch in your abs() code (if it can be done without a branch), as other answer suggests. If the compiler is not optimizing, then it may not inline library abs(), so it won't be fast either.

Optimizing abs() is one of the easiest thing to do for a compiler (just add an entry for it in the peephole optimizer, and done).

Furthermore, I've seen library implementations in the past, where abs() were implemented as a non-inline, library function (it was long time ago, though).

Proof that both implementations are the same:

GCC:

```<code>myabs:
    mov     edx, edi    ; argument passed in EDI by System V AMD64 calling convention
    mov     eax, edi
    sar     edx, 31
    xor     eax, edx
    sub     eax, edx
    ret

libabs:
    mov     edx, edi    ; argument passed in EDI by System V AMD64 calling convention
    mov     eax, edi
    sar     edx, 31
    xor     eax, edx
    sub     eax, edx
    ret
</code>```

Clang:

```<code>myabs:
    mov     eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    neg     eax
    cmovl   eax, edi
    ret

libabs:
    mov     eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    neg     eax
    cmovl   eax, edi
    ret
</code>```

Visual Studio (MSVC):

```<code>libabs:
    mov      eax, ecx    ; argument passed in ECX by Windows 64-bit calling convention
    cdq
    xor      eax, edx
    sub      eax, edx
    ret      0

myabs:
    mov      eax, ecx    ; argument passed in ECX by Windows 64-bit calling convention
    cdq
    xor      eax, edx
    sub      eax, edx
    ret      0
</code>```

ICC:

```<code>myabs:
    mov       eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    cdq
    xor       edi, edx
    sub       edi, edx
    mov       eax, edi
    ret

libabs:
    mov       eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    cdq
    xor       edi, edx
    sub       edi, edx
    mov       eax, edi
    ret
</code>```

See for yourself on Godbolt Compiler Explorer, where you can inspect the machine code generated by various compilers. (Link kindly provided by Peter Cordes.)

Body:
I was trying a question on arrays in InterviewBit. In this question I made an inline function returning the absolute value of an integer. But I was told that my algorithm was not efficient on submitting it. But when I changed to using abs() from C++ library it gave a correct answer verdict.

Here is my function that got an inefficient verdict -

inline int abs(int x){return x>0 ? x : -x;}

int Solution::coverPoints(vector<int> &X, vector<int> &Y) {
    int l = X.size();
    int i = 0;
    int ans = 0;
    while (i<l-1){
        ans = ans + max(abs(X[i]-X[i+1]), abs(Y[i]-Y[i+1]));
        i++;
    }
    return ans;
}

Here's the one that got the correct answer -

int Solution::coverPoints(vector<int> &X, vector<int> &Y) {
    int l = X.size();
    int i = 0;
    int ans = 0;
    while (i<l-1){
        ans = ans + max(abs(X[i]-X[i+1]), abs(Y[i]-Y[i+1]));
        i++;
    }
    return ans;
}

Why did this happened, as I thought that inline functions are fastest as no calling is done? Or is the site having an error? And if the site is correct, what does C++ abs() use that is faster than inline abs()?

Body:
I don't agree with their verdict. They are clearly wrong.

On current, optimizing compilers, both solutions produce the exact same output. And even, if they didn't produce the exact same, they would produce as efficient code as the library one (it could be a little surprising that everything matches: the algorithm, the registers used. Maybe because the actual library implementation is the same as OP's one?).

No sane optimizing compiler will create branch in your abs() code (if it can be done without a branch), as other answer suggests. If the compiler is not optimizing, then it may not inline library abs(), so it won't be fast either.

Optimizing abs() is one of the easiest thing to do for a compiler (just add an entry for it in the peephole optimizer, and done).

Furthermore, I've seen library implementations in the past, where abs() were implemented as a non-inline, library function (it was long time ago, though).

Proof that both implementations are the same:

GCC:

myabs:
    mov     edx, edi    ; argument passed in EDI by System V AMD64 calling convention
    mov     eax, edi
    sar     edx, 31
    xor     eax, edx
    sub     eax, edx
    ret

libabs:
    mov     edx, edi    ; argument passed in EDI by System V AMD64 calling convention
    mov     eax, edi
    sar     edx, 31
    xor     eax, edx
    sub     eax, edx
    ret

Clang:

myabs:
    mov     eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    neg     eax
    cmovl   eax, edi
    ret

libabs:
    mov     eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    neg     eax
    cmovl   eax, edi
    ret

Visual Studio (MSVC):

libabs:
    mov      eax, ecx    ; argument passed in ECX by Windows 64-bit calling convention
    cdq
    xor      eax, edx
    sub      eax, edx
    ret      0

myabs:
    mov      eax, ecx    ; argument passed in ECX by Windows 64-bit calling convention
    cdq
    xor      eax, edx
    sub      eax, edx
    ret      0

ICC:

myabs:
    mov       eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    cdq
    xor       edi, edx
    sub       edi, edx
    mov       eax, edi
    ret

libabs:
    mov       eax, edi    ; argument passed in EDI by System V AMD64 calling convention
    cdq
    xor       edi, edx
    sub       edi, edx
    mov       eax, edi
    ret

<a href="https://gcc.godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAM1QDsCBlZAQwBtMQAGAOgA4BOAKwB2IQEZ%2BkqVNIArEGNIBnVAFdiyDgHIApACYAzHlrJWqrAGodBgMLIAtswIJr2HZwAi7gIL6jJs0trOyUCdFY8ACNXCwsAejiLdDowLQILGmJgTHSiC2NTc0wLZzwlDJJ8%2Bkxs4gtUADdMYlZUZnQldy9OX08fYwjaYuN0%2BwBPAH1mSKUIEYsADwBKLp8dYQAhVZ7Y2OIc9VpF105rADEFkABaBestvp717u7el4SLJTx7AAd2CxYlJhtt55swshNQuhprN5stget7i9dhZ9gRDhYQCBIZjoRA4QZEWthM9%2BvQLGDgBNxlMZnMyXCHr5NsDkaj0dTcfjCY9ifDGe9sgQCMZgBYGmxVMUqMRUPYPrLMAB3BDNYqYViA4HzQUTcWsCANVB4dArAl8l7zVF6iFhXGwlaMhEs3Zs4hHTHYkC4nV6iBLU3cpkknqWnLWjm0%2B3w5mM1kHN0WCOzH1sP0B6PB7xaJakVggLSCLSkWj5zhF1D5mz6LZ6Dby9SaKyGMRFgil7M5gDWIAMem4ADZOJx%2BAZeLwh8IACyCTiCQS5/OTov2BRD4vt0gVrRFpRcUhtrRlnNwWAwRAoWXfPDsMgUCBoH7X5ogYD9gykKjXgjNXcQSIbh97EwegAHlaFYMYN3wfZkGFJpd0PIsRnVdscxoegmDYDgeAEERxGkAjN2%2BYU6AQq4QIMCwrkhawPGQatqzEMQqPsftJxYtEhlo2gnDwJodzUDQODEHM8wLIsS0Qzd8wWXh%2ByuNiLGAZBkAsftuEoiBcEISo/EUCwbEvJ86j0pZW1QnMVXaZ8/VIbsDEnAcDDEPRDAMfhJ0nMRZz0BctCXUgVxndcpK3Hc9wPI9SBPc8HyvG9yEoOLjJAPAVLEYQPy/H9KH/KTAOAggwIgqC8BguDMAQstyGqMSovQxgWHYLg%2BCEURBAkAiZFQYi8FI/NyMo6iwlo%2Bja0Y5irlY9ips4oEDA8HiKoEhthNE/NCxC6qt1k%2BTFLS1SMosLT8CIEzm1IAyjJvJtezM/cLL8gKgs4Lby3zcLXsijs7J7PthH7YReAMIHOEnXhPMnd8xIMCSNzCh7EOPM8YogJBkoSu8MefUxmFoYBJzXT9WG/Yhfzy6qCtA8DIKk6DMFgvjKo3ZC6uzD86EarCWtw9rOq6/giJI2gyIoqiaIWsaaw2JiWMU2bVC4halqZlahIUdbxLe6StF2hT2Nx/GLEcnhOGO7Sztu/TDMfG6/AMe7vv9UgrKwYhKC7HtHLfFy3I8ryfKe5cQGCyTto%2B5QItQ6KUfR67mkS%2B94/d0wJAmNispJnK/wA2UgOpkq6bKhmKqqpDaujhrMOanC2vwgXBZ64XRb0cWRslhja1lhWlcW3j%2BOUQTNA1vzNrD97dbk/WDIAGQsCQLD0TgjoAJQAFQAdXN07dIuq7beaW7J0dx7XZszXnpD17x51z7EaPT2HKc32DHczzvMEXyYbh0KI6dzW9A/3Dtue%2BP0mhkz6iWScQA%3D%3D%3D" rel="noreferrer">See for yourself on Godbolt Compiler Explorer, where you can inspect the machine code generated by various compilers. (Link kindly provided by Peter Cordes.)


问:
I have a Objective C function that takes any type of object by reference. But when i pass a NSMutableArray My function does not recognise It
I have a function  That takes by reference any kind of object
-(BOOL)RemoteCall:(id**)DataClass;
in the implementation i use [*DataClass isMemberOfClass:[NSMutableArray class] to find out the type of the object. The problem is it does not work with NSMUtableArrays Does anybody have a solution to this problem ? Here is the relevant code:

Implementation:

```<code>-(BOOL)RemoteCall:(id**)DataClass
{
    if([*DataClass isMemberOfClass:[NSMutableArray class] ] == YES)
    {
            NSMutableArray * SW =(NSMutableArray *)*DataClass;
                       //do something with SW
            DataClass= (id**)SW;
                        return TRUE;
    }
}
</code>```

Any help and I mean anything at all will be appreciated, I'm stuck.

```<code>Method Call:
NSMutableArray * channelArray = [[NSMutableArray alloc]init]
Services * serv = [[Services alloc] init];
return [serv RemoteCall:&channelArray];
</code>```

答:
NSArray is a class cluster. That means that every NSArray instance is actually an instance of some subclass. Only isKindOfClass: is useful for class-membership testing with class clusters.

Also... thats horrible code - please accept this:

```<code>-(BOOL)remoteCall:(id)dataClass {
    if([dataClass isKindOfClass:[NSMutableArray class]]) {
            NSMutableArray *sw =(NSMutableArray *)dataClass;
            return YES;
    }
}
</code>```

that should work.

Constructive critisism of coding: You need to adhere to coding conventions. Although your code will work... its not brilliant to read and theres a lot of unnecessary *s and such.

Function names should be camel coded with a preceeding lower-case letter as should variable names. Passing (id) into a function doesn't require *s at all. Objects you pass into a function only available throughout the scope of the method anyway and that method doesn't own it, I'm not sure what you're trying to do with all the extra *s, but just treat objects you pass into the method as if you don't own them. :)

Body:
I have a function  That takes by reference any kind of object
-(BOOL)RemoteCall:(id**)DataClass;
in the implementation i use [*DataClass isMemberOfClass:[NSMutableArray class] to find out the type of the object. The problem is it does not work with NSMUtableArrays Does anybody have a solution to this problem ? Here is the relevant code:

Implementation:

-(BOOL)RemoteCall:(id**)DataClass
{
    if([*DataClass isMemberOfClass:[NSMutableArray class] ] == YES)
    {
            NSMutableArray * SW =(NSMutableArray *)*DataClass;
                       //do something with SW
            DataClass= (id**)SW;
                        return TRUE;
    }
}

Any help and I mean anything at all will be appreciated, I'm stuck.

Method Call:
NSMutableArray * channelArray = [[NSMutableArray alloc]init]
Services * serv = [[Services alloc] init];
return [serv RemoteCall:&channelArray];

Body:
NSArray is a class cluster. That means that every NSArray instance is actually an instance of some subclass. Only isKindOfClass: is useful for class-membership testing with class clusters.

Also... thats horrible code - please accept this:

-(BOOL)remoteCall:(id)dataClass {
    if([dataClass isKindOfClass:[NSMutableArray class]]) {
            NSMutableArray *sw =(NSMutableArray *)dataClass;
            return YES;
    }
}

that should work.

Constructive critisism of coding: You need to adhere to coding conventions. Although your code will work... its not brilliant to read and theres a lot of unnecessary *s and such.

Function names should be camel coded with a preceeding lower-case letter as should variable names. Passing (id) into a function doesn't require *s at all. Objects you pass into a function only available throughout the scope of the method anyway and that method doesn't own it, I'm not sure what you're trying to do with all the extra *s, but just treat objects you pass into the method as if you don't own them. :)


问:
how to change the body's border radius in Bootstrap
I want to change the border radius of the first div container that has class .container-fluid , how I can do that using bootstrap body's border radius in Bootstrap</p>

答:
Wrap your content in
 and apply border-radius to wrapper

UPD: Add following to your css code

```<code>body > .container-fluid:first-child {
    border-radius: 20px; //for example
}
</code>```

Body:
Wrap your content in <div> and apply border-radius to wrapper

UPD: Add following to your css code

body > .container-fluid:first-child {
    border-radius: 20px; //for example
}


问:
.jpg file compression as a url parameter
I noticed that the following file from a website could compress the image depending on the size passed as parameters in the url.

This is the following url.

```<code> https://images.pexels.com/photos/207301/pexels-photo-207301.jpeg
</code>```

and when passed as a parameter :

```<code> https://images.pexels.com/photos/207301/pexels-photo-207301.jpeg?w=440&auto=compress&cs=tinysrgb
</code>```

it gives a smaller image.

Now what I did:

I downloaded the image uploaded it to my website:
       http://auraquotes.com/images/pexels-photo-207301.jpeg

I also tried passing the parameters: http://auraquotes.com/images/pexels-photo-207301.jpeg?w=440&auto=compress&cs=tinysrgb

but nothing happened.

I wonder the reason?

答: That website is running a solution called imgix which handles the image request and the compression.  Without imgix installed, you won't get the same effect.</p>

Body:
I noticed that the following file from a website could compress the image depending on the size passed as parameters in the url.

This is the following url.

 https://images.pexels.com/photos/207301/pexels-photo-207301.jpeg

and when passed as a parameter :

 https://images.pexels.com/photos/207301/pexels-photo-207301.jpeg?w=440&auto=compress&cs=tinysrgb

it gives a smaller image.

Now what I did:

I downloaded the image uploaded it to my website:
       http://auraquotes.com/images/pexels-photo-207301.jpeg

I also tried passing the parameters: http://auraquotes.com/images/pexels-photo-207301.jpeg?w=440&auto=compress&cs=tinysrgb

but nothing happened.

I wonder the reason?