问:
How to get the images from gallery or camera and crop with high quality in android
Hi I have to set profile image for my app. I have done to take images from gallery and camera and then crop it for perfect shape and displaying in my image view, But it is in low quality pixels the images are not clear.
How to get the same quality as per the camera capture or images in gallery </p>

<p>My code is: </p>

```<code>public class ProfileActivity  extends AppCompatActivity {
    ImageView iv_dp;

    boolean checkpermission ;
    File file;
    Uri uri;
    Intent CamIntent, GalIntent, CropIntent ;

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

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        allowpermission();
       /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.CAMERA)
                    != PackageManager.PERMISSION_GRANTED) {

                requestPermissions(new String[]{Manifest.permission.CAMERA},
                        1);

                checkpermission = true;
            }*/

            iv_dp = (ImageView) findViewById(R.id.dp_iv);

            iv_dp.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                        AlertDialog.Builder alertbox = new AlertDialog.Builder(ProfileActivity.this);

                        alertbox.setTitle("Select an option")
                                .setItems(R.array.alert, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int pos) {

//pos will give the selected item position

                                        if (pos == 0) {
                                            //cameraoption();
                                            ClickImageFromCamera() ;

                                        } else if (pos == 1) {
                                            GetImageFromGallery();
                                        }

                                    }
                                });
                        alertbox.show();

                }
            });
        }
    public void ClickImageFromCamera() {

        CamIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        file = new File(Environment.getExternalStorageDirectory(),
                "file" + String.valueOf(System.currentTimeMillis()) + ".jpg");
        uri = Uri.fromFile(file);

        CamIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);

        CamIntent.putExtra("return-data", true);

        startActivityForResult(CamIntent, 0);

    }
    public void GetImageFromGallery(){

        GalIntent = new Intent(Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

        startActivityForResult(Intent.createChooser(GalIntent, "Select Image From Gallery"), 2);

    }

    private void allowpermission() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.CAMERA)
                    != PackageManager.PERMISSION_GRANTED) {

                requestPermissions(new String[]{Manifest.permission.CAMERA},
                        1);

                checkpermission = true;
            }
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        super.onOptionsItemSelected(item);
        switch (item.getItemId()) {
            case android.R.id.home:
                this.finish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 0 && resultCode == RESULT_OK) {

            ImageCropFunction();

        }
        else if (requestCode == 2) {

            if (data != null) {

                uri = data.getData();

                ImageCropFunction();

            }
        }
        else if (requestCode == 1) {

            if (data != null) {

                Bundle bundle = data.getExtras();

                Bitmap bitmap = bundle.getParcelable("data");

                iv_dp.setImageBitmap(bitmap);

            }
        }
    }

    public void ImageCropFunction() {

        // Image Crop Code
        try {
            CropIntent = new Intent("com.android.camera.action.CROP");

            CropIntent.setDataAndType(uri, "image/*");

            CropIntent.putExtra("crop", "true");
            CropIntent.putExtra("outputX", 180);
            CropIntent.putExtra("outputY", 180);
            CropIntent.putExtra("aspectX", 1);
            CropIntent.putExtra("aspectY", 1);
            CropIntent.putExtra("scaleUpIfNeeded", true);
            CropIntent.putExtra("return-data", true);

            startActivityForResult(CropIntent, 1);

        } catch (ActivityNotFoundException e) {

        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

        if (requestCode == 1) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Toast.makeText(this, "All set for your Profile Picture", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(this, "No Camera", Toast.LENGTH_SHORT).show();
            }
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }

    }
}

My XML is:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:src="@drawable/pro_image"
            android:layout_gravity="center"
            android:scaleType="fitXY"
            android:layout_alignParentTop="true"
            android:id="@+id/dp_iv" />

    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:layout_gravity="center"
            android:paddingLeft="20dp"
            android:layout_height="wrap_content">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:src="@drawable/smile_icon"
                android:id="@+id/imageView2" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="UserName"
                android:gravity="center"
                android:layout_margin="20dp"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:paddingLeft="20sp"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:src="@drawable/dob_icon"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Date Of Birth"
                android:layout_gravity="center"
                android:layout_margin="20dp"/>
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="#AAAAAA"
            />
        <LinearLayout
            android:layout_width="wrap_content"
            android:orientation="horizontal"
            android:layout_gravity="center"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:layout_margin="10dp"
                android:src="@drawable/fav_icon"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Favouries"
                android:id="@+id/fav_tv"
                android:layout_gravity="center"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="20dp"/>
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:layout_margin="5dp"
                android:background="#AAAAAA"
                />

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_margin="10dp"
                android:layout_gravity="center"
                android:src="@drawable/review_icon1"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Reviews"
                android:id="@+id/review_tv"
                android:layout_gravity="center"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="20dp"/>
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="#AAAAAA"
            />
    </LinearLayout>
</LinearLayout>

Please help me in my issues over quality of images. Thanks in advance.
</code>```

答:
Include the library as local library project. Add this line to your build.gradle file

```<code>compile 'com.yalantis:ucrop:2.2.0'
</code>```

Add UCropActivity into your AndroidManifest.xml

```<code> <activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
</code>```

The uCrop configuration is created using the builder pattern.

```<code>  UCrop.of(sourceUri, destinationUri)
.withAspectRatio(16, 9)
  .withMaxResultSize(maxWidth, maxHeight)
 .start(context);
</code>```

Override onActivityResult method and handle uCrop result.

```<code> @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
    final Uri resultUri = UCrop.getOutput(data);
} else if (resultCode == UCrop.RESULT_ERROR) {
    final Throwable cropError = UCrop.getError(data);
}
}
</code>```

Body:
Hi I have to set profile image for my app. I have done to take images from gallery and camera and then crop it for perfect shape and displaying in my image view, But it is in low quality pixels the images are not clear.
How to get the same quality as per the camera capture or images in gallery

My code is:

public class ProfileActivity  extends AppCompatActivity {
    ImageView iv_dp;

    boolean checkpermission ;
    File file;
    Uri uri;
    Intent CamIntent, GalIntent, CropIntent ;

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

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        allowpermission();
       /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.CAMERA)
                    != PackageManager.PERMISSION_GRANTED) {

                requestPermissions(new String[]{Manifest.permission.CAMERA},
                        1);

                checkpermission = true;
            }*/

            iv_dp = (ImageView) findViewById(R.id.dp_iv);

            iv_dp.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                        AlertDialog.Builder alertbox = new AlertDialog.Builder(ProfileActivity.this);

                        alertbox.setTitle("Select an option")
                                .setItems(R.array.alert, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int pos) {

//pos will give the selected item position

                                        if (pos == 0) {
                                            //cameraoption();
                                            ClickImageFromCamera() ;

                                        } else if (pos == 1) {
                                            GetImageFromGallery();
                                        }

                                    }
                                });
                        alertbox.show();

                }
            });
        }
    public void ClickImageFromCamera() {

        CamIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        file = new File(Environment.getExternalStorageDirectory(),
                "file" + String.valueOf(System.currentTimeMillis()) + ".jpg");
        uri = Uri.fromFile(file);

        CamIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);

        CamIntent.putExtra("return-data", true);

        startActivityForResult(CamIntent, 0);

    }
    public void GetImageFromGallery(){

        GalIntent = new Intent(Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

        startActivityForResult(Intent.createChooser(GalIntent, "Select Image From Gallery"), 2);

    }

    private void allowpermission() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.CAMERA)
                    != PackageManager.PERMISSION_GRANTED) {

                requestPermissions(new String[]{Manifest.permission.CAMERA},
                        1);

                checkpermission = true;
            }
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        super.onOptionsItemSelected(item);
        switch (item.getItemId()) {
            case android.R.id.home:
                this.finish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 0 && resultCode == RESULT_OK) {

            ImageCropFunction();

        }
        else if (requestCode == 2) {

            if (data != null) {

                uri = data.getData();

                ImageCropFunction();

            }
        }
        else if (requestCode == 1) {

            if (data != null) {

                Bundle bundle = data.getExtras();

                Bitmap bitmap = bundle.getParcelable("data");

                iv_dp.setImageBitmap(bitmap);

            }
        }
    }

    public void ImageCropFunction() {

        // Image Crop Code
        try {
            CropIntent = new Intent("com.android.camera.action.CROP");

            CropIntent.setDataAndType(uri, "image/*");

            CropIntent.putExtra("crop", "true");
            CropIntent.putExtra("outputX", 180);
            CropIntent.putExtra("outputY", 180);
            CropIntent.putExtra("aspectX", 1);
            CropIntent.putExtra("aspectY", 1);
            CropIntent.putExtra("scaleUpIfNeeded", true);
            CropIntent.putExtra("return-data", true);

            startActivityForResult(CropIntent, 1);

        } catch (ActivityNotFoundException e) {

        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

        if (requestCode == 1) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Toast.makeText(this, "All set for your Profile Picture", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(this, "No Camera", Toast.LENGTH_SHORT).show();
            }
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }

    }
}

My XML is:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:src="@drawable/pro_image"
            android:layout_gravity="center"
            android:scaleType="fitXY"
            android:layout_alignParentTop="true"
            android:id="@+id/dp_iv" />

    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:layout_gravity="center"
            android:paddingLeft="20dp"
            android:layout_height="wrap_content">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:src="@drawable/smile_icon"
                android:id="@+id/imageView2" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="UserName"
                android:gravity="center"
                android:layout_margin="20dp"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:paddingLeft="20sp"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:src="@drawable/dob_icon"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Date Of Birth"
                android:layout_gravity="center"
                android:layout_margin="20dp"/>
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="#AAAAAA"
            />
        <LinearLayout
            android:layout_width="wrap_content"
            android:orientation="horizontal"
            android:layout_gravity="center"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:layout_margin="10dp"
                android:src="@drawable/fav_icon"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Favouries"
                android:id="@+id/fav_tv"
                android:layout_gravity="center"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="20dp"/>
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:layout_margin="5dp"
                android:background="#AAAAAA"
                />

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_margin="10dp"
                android:layout_gravity="center"
                android:src="@drawable/review_icon1"/>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Reviews"
                android:id="@+id/review_tv"
                android:layout_gravity="center"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="20dp"/>
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="#AAAAAA"
            />
    </LinearLayout>
</LinearLayout>

Please help me in my issues over quality of images. Thanks in advance.

Body:
Include the library as local library project. Add this line to your build.gradle file

compile 'com.yalantis:ucrop:2.2.0'

Add UCropActivity into your AndroidManifest.xml

 <activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

The uCrop configuration is created using the builder pattern.

  UCrop.of(sourceUri, destinationUri)
.withAspectRatio(16, 9)
  .withMaxResultSize(maxWidth, maxHeight)
 .start(context);

Override onActivityResult method and handle uCrop result.

 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
    final Uri resultUri = UCrop.getOutput(data);
} else if (resultCode == UCrop.RESULT_ERROR) {
    final Throwable cropError = UCrop.getError(data);
}
}


来源: stackexchange

问:
How many threads can a Java VM support?
How many threads can a Java VM support? Does this vary by vendor? by operating system? other factors?</p>

答:
Additional information for modern (systemd) linux systems.

There are many resources about this of values that may need tweaking (such as How to increase maximum number of JVM threads (Linux 64bit)); however a new limit is imposed by way of the systemd "TasksMax" limit which sets pids.max on the cgroup.

For login sessions the UserTasksMax default is 33% of the kernel limit pids_max (usually 12,288) and can be override in /etc/systemd/logind.conf.

For services the DefaultTasksMax default is 15% of the kernel limit pids_max (usually 4,915).  You can override it for the service by setting TasksMax in "systemctl edit" or update DefaultTasksMax in /etc/systemd/system.conf

ContentLicense: CC BY-SA 3.0

Title: How many threads can a Java VM support?


问:
How does JS variable override work?
This code works fine:

```<code>const a = 1;
{
  const b = a; // let's use "a" in a sub-scope
}
{
  const a = 2; // let's override "a" in another sub-scope
}
</code>```

... but this code fails with a is not defined at line 3:

```<code>const a = 1;
{
  const b = a; // let's use "a" in a sub-scope <<< CRASH!! >>>
  const a = 2; // let's override "a" in the same sub-scope
}
</code>```

I tested this on node 7.7.4. It may be related to V8 only, I'm curious how Firefox would handle this.

Is it related to the way variable declaration is defined in the JS spec? const/let are not hoisted, but "something" (some metadata?) still seems to be hoisted, else we would have no issues.

答:
This is according to the ES6 spec for variable declarations using let and const.
They are both Block Scoped.

The time before the declaration within the scope is temporal dead zone.
According to the docs:

In ECMAScript 2015, let will hoist the variable to the top of the
  block. However, referencing the variable in the block before the
  variable declaration results in a ReferenceError. The variable is in a
  "temporal dead zone" from the start of the block until the declaration
  is processed.

As @Bergi mentioned it is the time before the actual declaration.

Title: How does JS variable override work?

Body:
This code works fine:

const a = 1;
{
  const b = a; // let's use "a" in a sub-scope
}
{
  const a = 2; // let's override "a" in another sub-scope
}

... but this code fails with a is not defined at line 3:

const a = 1;
{
  const b = a; // let's use "a" in a sub-scope <<< CRASH!! >>>
  const a = 2; // let's override "a" in the same sub-scope
}

I tested this on node 7.7.4. It may be related to V8 only, I'm curious how Firefox would handle this.

Is it related to the way variable declaration is defined in the JS spec? const/let are not hoisted, but "something" (some metadata?) still seems to be hoisted, else we would have no issues.


问:
React Js Appointment Calender
I need your help.

Is  there already a React js event calendar, wich is totaly FREE-to-use .. also commercially.

I should be able to change calendar weekday and month names in my language.

It should be easy to bind to a Event-list

答:
Here is a resource that can help you make the type of calendar you would like to see.

To take an example, here is a date picker that includes an internationalization option.  It's just a matter of importing the component, setting the configuration, then rendering it out to the page:

```<code>import React from 'react';
import { render } from 'react-dom';
import InfiniteCalendar from 'react-infinite-calendar';
import 'react-infinite-calendar/styles.css'; // only needs to be imported once

// Render the Calendar
var today = new Date();
var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);

render(
  <InfiniteCalendar
    width={400}
    height={600}
    selected={today}
    disabledDays={[0,6]}
    minDate={lastWeek}
  />,
  document.getElementById('root')
);
</code>```

If you have any specific issues with the code, we'll certainly be able to help out.

Title: React Js Appointment Calender

Body:
Here is a resource that can help you make the type of calendar you would like to see.

To take an example, here is a date picker that includes an internationalization option.  It's just a matter of importing the component, setting the configuration, then rendering it out to the page:

import React from 'react';
import { render } from 'react-dom';
import InfiniteCalendar from 'react-infinite-calendar';
import 'react-infinite-calendar/styles.css'; // only needs to be imported once

// Render the Calendar
var today = new Date();
var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);

render(
  <InfiniteCalendar
    width={400}
    height={600}
    selected={today}
    disabledDays={[0,6]}
    minDate={lastWeek}
  />,
  document.getElementById('root')
);

If you have any specific issues with the code, we'll certainly be able to help out.


问:
How to clear server and browser cache in WordPress
I have a plugin that randomly displays images on front-end. It's working good on non cache website, but for people using in siteground or wpengine, the same image is showing instead of random. I tried appending the unique id to each image like the below code, but it is not generating the unique id on server cache systems. Instead, it is showing the first time generated id with the same image every time.

```<code><img src="image.png?v=<?php echo mt_rand( 1000, 9999 ); ?>" />
</code>```

I also added the below code for siteground cache (SG Optimizer WP Plugin), but it still won't work:

```<code>if (function_exists('sg_cachepress_purge_cache')) {
    sg_cachepress_purge_cache();
}
</code>```

Is there any solution to solve this problem? How can I show random image on all server cache websites, too.

答: If you have the same name for images. Then Why not give each image a different name.</p>

Body:
I have a plugin that randomly displays images on front-end. It's working good on non cache website, but for people using in siteground or wpengine, the same image is showing instead of random. I tried appending the unique id to each image like the below code, but it is not generating the unique id on server cache systems. Instead, it is showing the first time generated id with the same image every time.

<img src="image.png?v=<?php echo mt_rand( 1000, 9999 ); ?>" />

I also added the below code for siteground cache (SG Optimizer WP Plugin), but it still won't work:

if (function_exists('sg_cachepress_purge_cache')) {
    sg_cachepress_purge_cache();
}

Is there any solution to solve this problem? How can I show random image on all server cache websites, too.


问:
How to better format all worksheets in VBA?
I have the below code that will loop through all worksheets of the workbookand will format each sheet by deleting, change page orientation, page margins and be able to print each sheet on 1 paper.

The below it's working but it takes time as the Call editingPropertiesis quite long and takes time to go through it for all sheets.

Is there a better way to write the editingProperties sub?

```<code> Dim ws As Worksheet

Public Sub editAllSheets()

' Keyboard Shortcut: Ctrl+Shift+E
'
Dim myResult As VbMsgBoxResult

myResult = MsgBox("Are you sure you want to edit all sheets in this workbook?", vbQuestion + vbOKCancel + vbDefaultButton1, "Edit workbook")
If myResult = vbCancel Then Exit Sub

   On Error GoTo ErrorHandler

        For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        Application.ScreenUpdating = False
        Call editingProperties
        Application.ScreenUpdating = True
            Next ws
        Sheets.Select
        MsgBox "Please note:" & vbNewLine & vbNewLine & "1. All the sheets are selected." & vbNewLine & "2. Proceed with print preview to view and print all reports." & vbNewLine & "3. To print preview or print only 1 report of this workbook you need to click on a different sheet to deselect all.", vbInformation, "Process Completed!"

    Exit Sub '<--- exit here if no error occured
ErrorHandler:
    MsgBox "Sorry, an error occured." & vbCrLf & Err.Description, vbCritical, "Error!"

End Sub

Private Sub editingProperties()

    Columns("A:E").Select
    Range("A4").Activate
    Selection.UnMerge
    Columns("B:C").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("E:G").Select
    Selection.Delete Shift:=xlToLeft
    Columns("H:J").Select
    Selection.Delete Shift:=xlToLeft
    Columns("K:K").Select
    Selection.Delete Shift:=xlToLeft
    Range("A1:B2").Select
    Selection.Merge
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.25)
        .RightMargin = Application.InchesToPoints(0.25)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.25)
        .RightMargin = Application.InchesToPoints(0.25)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.25)
        .RightMargin = Application.InchesToPoints(0.25)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
         Cells.Select
         Cells.EntireColumn.AutoFit
         Range("A3").Select

    End With

End Sub
</code>```

答:
Please take a look at the structure of my code below. I corrected some of the errors, made a few improvements and started you out on how to program your long list of properties. When you continue adding to the list make sure that you don't copy all the repetitions. It's enough to set a property once.</p>

```<code>Public Sub EditAllSheets()
    ' 01 Apr 2017
    ' Keyboard Shortcut: Ctrl+Shift+E

    Dim Ws As Worksheet
    Dim myResult As VbMsgBoxResult

    If MsgBox("Are you sure you want to edit all sheets in this workbook?", _
                      vbQuestion Or vbYesNo Or vbDefaultButton1, _
                      "Edit workbook") <> vbYes Then Exit Sub

    On Error GoTo ErrorHandler

    Application.ScreenUpdating = False
    For Each Ws In ActiveWorkbook.Worksheets
        EditProperties Ws
    Next Ws

    Sheets.Select
    MsgBox "Please note:" & vbCr & vbCr & _
           "1. All the sheets are selected." & vbCr & _
           "2. Proceed with print preview to view and print all reports." & vbCr & _
           "3. To print preview or print only 1 report of this workbook" & vbCr & _
           "    you need to click on a different sheet to deselect all.", _
           vbInformation, "Process Completed!"

    Application.ScreenUpdating = True
    Exit Sub '<--- exit here if no error occured

ErrorHandler:
    MsgBox "Sorry, an error occured." & vbCrLf & Err.Description, vbCritical, "Error!"
    Application.ScreenUpdating = True
End Sub

Private Sub EditProperties(Ws As Worksheet)
    ' 01 Apr 2017

    With Ws
        .Range(Columns(1), Columns(5)).UnMerge
        ' .Range(Columns("A"), Columns("E")).UnMerge      ' can also work
        .Range(Columns(2), Columns(11)).Delete shift:=xlToLeft
        .Range("A1:B2").Merge
        With .PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
            .PrintArea = ""
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = Application.InchesToPoints(0.7)
            .RightMargin = Application.InchesToPoints(0.7)
            .TopMargin = Application.InchesToPoints(0.75)
            .BottomMargin = Application.InchesToPoints(0.75)
            .HeaderMargin = Application.InchesToPoints(0.3)
            .FooterMargin = Application.InchesToPoints(0.3)
            .PrintHeadings = False
        End With
    End With
End Sub
</code>```

Body:
I have the below code that will loop through all worksheets of the workbookand will format each sheet by deleting, change page orientation, page margins and be able to print each sheet on 1 paper.

The below it's working but it takes time as the Call editingPropertiesis quite long and takes time to go through it for all sheets.

Is there a better way to write the editingProperties sub?

 Dim ws As Worksheet

Public Sub editAllSheets()

' Keyboard Shortcut: Ctrl+Shift+E
'
Dim myResult As VbMsgBoxResult

myResult = MsgBox("Are you sure you want to edit all sheets in this workbook?", vbQuestion + vbOKCancel + vbDefaultButton1, "Edit workbook")
If myResult = vbCancel Then Exit Sub

   On Error GoTo ErrorHandler

        For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        Application.ScreenUpdating = False
        Call editingProperties
        Application.ScreenUpdating = True
            Next ws
        Sheets.Select
        MsgBox "Please note:" & vbNewLine & vbNewLine & "1. All the sheets are selected." & vbNewLine & "2. Proceed with print preview to view and print all reports." & vbNewLine & "3. To print preview or print only 1 report of this workbook you need to click on a different sheet to deselect all.", vbInformation, "Process Completed!"

    Exit Sub '<--- exit here if no error occured
ErrorHandler:
    MsgBox "Sorry, an error occured." & vbCrLf & Err.Description, vbCritical, "Error!"

End Sub

Private Sub editingProperties()

    Columns("A:E").Select
    Range("A4").Activate
    Selection.UnMerge
    Columns("B:C").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("E:G").Select
    Selection.Delete Shift:=xlToLeft
    Columns("H:J").Select
    Selection.Delete Shift:=xlToLeft
    Columns("K:K").Select
    Selection.Delete Shift:=xlToLeft
    Range("A1:B2").Select
    Selection.Merge
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.25)
        .RightMargin = Application.InchesToPoints(0.25)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.25)
        .RightMargin = Application.InchesToPoints(0.25)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.25)
        .RightMargin = Application.InchesToPoints(0.25)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
         Cells.Select
         Cells.EntireColumn.AutoFit
         Range("A3").Select

    End With

End Sub

Body:
Please take a look at the structure of my code below. I corrected some of the errors, made a few improvements and started you out on how to program your long list of properties. When you continue adding to the list make sure that you don't copy all the repetitions. It's enough to set a property once.

Public Sub EditAllSheets()
    ' 01 Apr 2017
    ' Keyboard Shortcut: Ctrl+Shift+E

    Dim Ws As Worksheet
    Dim myResult As VbMsgBoxResult

    If MsgBox("Are you sure you want to edit all sheets in this workbook?", _
                      vbQuestion Or vbYesNo Or vbDefaultButton1, _
                      "Edit workbook") <> vbYes Then Exit Sub

    On Error GoTo ErrorHandler

    Application.ScreenUpdating = False
    For Each Ws In ActiveWorkbook.Worksheets
        EditProperties Ws
    Next Ws

    Sheets.Select
    MsgBox "Please note:" & vbCr & vbCr & _
           "1. All the sheets are selected." & vbCr & _
           "2. Proceed with print preview to view and print all reports." & vbCr & _
           "3. To print preview or print only 1 report of this workbook" & vbCr & _
           "    you need to click on a different sheet to deselect all.", _
           vbInformation, "Process Completed!"

    Application.ScreenUpdating = True
    Exit Sub '<--- exit here if no error occured

ErrorHandler:
    MsgBox "Sorry, an error occured." & vbCrLf & Err.Description, vbCritical, "Error!"
    Application.ScreenUpdating = True
End Sub

Private Sub EditProperties(Ws As Worksheet)
    ' 01 Apr 2017

    With Ws
        .Range(Columns(1), Columns(5)).UnMerge
        ' .Range(Columns("A"), Columns("E")).UnMerge      ' can also work
        .Range(Columns(2), Columns(11)).Delete shift:=xlToLeft
        .Range("A1:B2").Merge
        With .PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
            .PrintArea = ""
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = Application.InchesToPoints(0.7)
            .RightMargin = Application.InchesToPoints(0.7)
            .TopMargin = Application.InchesToPoints(0.75)
            .BottomMargin = Application.InchesToPoints(0.75)
            .HeaderMargin = Application.InchesToPoints(0.3)
            .FooterMargin = Application.InchesToPoints(0.3)
            .PrintHeadings = False
        End With
    End With
End Sub


问:
onClick is not working in chrome?
I have a slider menu which I want by clicking on that another page loaded. in firefox its works but I want to works my HTML in any browsers? could you please help me? thanks.

index.html:

```<code><!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<body>
<div >
    <a href="#" id="link1" >Vertical link 1</a>
</div>
<div id="content"></div>
<script>
    $("#link1").on("click", function () {
    $("#content").load("test.html");
    });
</script>
</body>
</html>
</code>```

test.html:

```<code><!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<div>
    <table>
        <thead>
            <tr>
                <th scope="col">A</th>
                <th scope="col">B</th>
                <th scope="col">C</th>
                <th scope="col">D</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
            </tr>
        </tbody>
    </table>
</div>
</body>
</html>
</code>```

答:
If you navigate to http://api.jquery.com/load/ you will notice this line :

Description: Load data from the server and place the returned HTML into the matched element.

So basically if you want to use load you should fire it up from a server.

try this if you have installed python3 on a command prompt :

python3 -m http.server 9000

Then open browser and navigate to http://localhost:9000. Click on the link it will work.

You can do this from any server but for load to work you should fire up your page from a server.

This is only in chrome.

Title: onClick is not working in chrome?

Body:
I have a slider menu which I want by clicking on that another page loaded. in firefox its works but I want to works my HTML in any browsers? could you please help me? thanks.

index.html:

<!DOCTYPE html>

    <title></title>

    Vertical link 1

test.html:

<!DOCTYPE html>

    <title></title>

                A
                B
                C
                D

                1
                2
                3
                4


问:
How to increase maximum number of JVM threads (Linux 64bit)
I cannot create more than 32k Java threads in Linux machine with 15G memory.</p>

答:
Additional information for modern (systemd) linux systems.

There are many resources about this of values that may need tweaking (the other answer is a good source for most of them); however a new limit is imposed by way of the systemd "TasksMax" limit which sets pids.max on the cgroup.

For login sessions the UserTasksMax default is 33% of the kernel limit pids_max (usually 12,288) and can be override in /etc/systemd/logind.conf.

For services the DefaultTasksMax default is 15% of the kernel limit pids_max (usually 4,915).  You can override it for the service by setting TasksMax in "systemctl edit" or update DefaultTasksMax in /etc/systemd/system.conf


问:
Which is better: Several SQL queries or one sql data with lots of data?
I am making a quiz and I am expecting a lot of players for it. The quiz has a fixed number of questions.The quiz system can either fetch individual questions one by one from the MySql database and display it to the user. Or alternatively  I can fetch all the questions when he/she logs in and display them one by one. Can the second method significantly help in reducing the load on the server due to large number of SQL queries? Here I am talking about 500-600 users simultaneously playing the game.</p>

答:
The only way to know for sure is to benchmark both methods.

For what it's worth, I've recently improved the throughput of a performance-critical piece of code ten-fold by replacing a large number of small SQL queries with a small number of large queries.

ContentLicense: CC BY-SA 2.5


问:
Push new table to heroku without having to reset existing database
I'm at the early stages of learning RoR and working with Heroku.  So i have a fledging app with local and production databases.  I've used pg:push to create the initial production database but I appreciate this requires you to reset the db every time.  I now have a new table in my local db that I wish to push to production, but I don't want to reset and lose the data.

It seems I could create a back up from production and then reload that.  Or could if run pg:pull to get the data into my local db, and then run a pg:push so that when I add the new table I'm also reloading my existing data.

All of this seems a little long winded.  From some knowledge of php and mysql, I would have simply ran an SQL query to add the new table, is there not a similar way?

答:
One option is to use pg_dump with the --table option to just dump out a single table. Save that to a .sql file and then run it on the database you want to import into.

In general, it isn't advisable to be porting data manually from development to production. As you may have noticed, migrations keep your database structure synced, but not the data.

If there is a set of particular database values that your application is expecting, and you want to set these up in any environment; you can set up seed data. Then it's a simple case of running heroku run rake db:seed to get that data into production.


问:
Take int of day, month, year and convert to DD/MM/YYYY
I am writing a method to take a DOB of 3 integers - day, month, year and return the formatted version DD/MM/YYYY.

I am currently using dateFormatter and simple date format. Although when I run this it defaults to 01/01/1970 and I cannot change the date.

Any suggestions?

Update

Guys thanks for the below posts, problem solved!

答:
Why use formatter? just do this:

```<code>   public String DateOfBirth(int day, int month, int year)
{
    String DOB = day + "/" + month + "/" + year;

    return DOB;
}
</code>```

If it's for an assignment, the teacher probably wants you to not use formatter.

Also, as someone else mentioned: If you are trying to concatenate integers as a string you need some string in between. Otherwise you are summing the values of the integers.

Body:
Why use formatter? just do this:

   public String DateOfBirth(int day, int month, int year)
{
    String DOB = day + "/" + month + "/" + year;

    return DOB;
}

If it's for an assignment, the teacher probably wants you to not use formatter.

Also, as someone else mentioned: If you are trying to concatenate integers as a string you need some string in between. Otherwise you are summing the values of the integers.


问:
Why is this program not waiting for input from user?
I currently have the following code wrote:

```<code>import java.util.Scanner;

public class TicketPriceWithDiscount {

public static void main(String[] args) {

    TicketPriceWithDiscount obj = new TicketPriceWithDiscount();

}

  public TicketPriceWithDiscount(){

    double regPrice = 9.25;
    double otherPrice = 5.25; // ages under 12 or over 65
    double discount = 2.00;
    String person;
    int pInput;

    Scanner keyboard = new Scanner(System.in);

    System.out.println("What is your age?");

    pInput = keyboard.nextInt();

    System.out.println("Do you have a coupon? Yes or no will do.");

    person = keyboard.nextLine();

    if(person == "yes" && pInput <= 12 || pInput >= 65){
        otherPrice = otherPrice - discount;
        System.out.println("Your ticket price is: " + otherPrice);

    }

    else if(person == "yes" && pInput >= 12 && pInput <= 65){
        regPrice = regPrice - discount;
        System.out.println("Your ticket price is: " + regPrice);
    }

    else if(pInput <= 12 || pInput >= 65){
        System.out.println("Your ticket price is: " + otherPrice);
    }

    else if(pInput >= 12 || pInput <= 65) {
        System.out.println("Your ticket price is: " + regPrice);
    }

}

}
</code>```

The program runs up to the point in which I ask for the person to input wither or not they have a coupon.

```<code>System.out.println("Do you have a coupon? Yes or no will do.");

    person = keyboard.nextLine();
</code>```

At this point, the program does not wait for an input and completes the if statement based on age input which it does wait for a reply from the user.

The output intended is for the user to input age, say yes or no to the coupon question and for the program to continue its run depending on those answers.

What I have tried:

closing the scanner - keyboard.close();

create a new scanner after closing the first instance of scanner.

Guidance is highly appreciated.

答: You seem to be having the same problem as in this question with solution. Certainly an odd quirk!</p>

Body:
I currently have the following code wrote:

import java.util.Scanner;

public class TicketPriceWithDiscount {

public static void main(String[] args) {

    TicketPriceWithDiscount obj = new TicketPriceWithDiscount();

}

  public TicketPriceWithDiscount(){

    double regPrice = 9.25;
    double otherPrice = 5.25; // ages under 12 or over 65
    double discount = 2.00;
    String person;
    int pInput;

    Scanner keyboard = new Scanner(System.in);

    System.out.println("What is your age?");

    pInput = keyboard.nextInt();

    System.out.println("Do you have a coupon? Yes or no will do.");

    person = keyboard.nextLine();

    if(person == "yes" && pInput <= 12 || pInput >= 65){
        otherPrice = otherPrice - discount;
        System.out.println("Your ticket price is: " + otherPrice);

    }

    else if(person == "yes" && pInput >= 12 && pInput <= 65){
        regPrice = regPrice - discount;
        System.out.println("Your ticket price is: " + regPrice);
    }

    else if(pInput <= 12 || pInput >= 65){
        System.out.println("Your ticket price is: " + otherPrice);
    }

    else if(pInput >= 12 || pInput <= 65) {
        System.out.println("Your ticket price is: " + regPrice);
    }

}

}

The program runs up to the point in which I ask for the person to input wither or not they have a coupon.

System.out.println("Do you have a coupon? Yes or no will do.");

    person = keyboard.nextLine();

At this point, the program does not wait for an input and completes the if statement based on age input which it does wait for a reply from the user.

The output intended is for the user to input age, say yes or no to the coupon question and for the program to continue its run depending on those answers.

What I have tried:

closing the scanner - keyboard.close();

create a new scanner after closing the first instance of scanner.

Guidance is highly appreciated.


问:
How to use curry function
I have a curried function on the object:

```<code>sealed trait Sum[A, B]

final case class Left[A, B](value: A) extends Sum[A, B]

final case class Right[A, B](value: B) extends Sum[A, B]

object Sum {

  def fold[A, B, C](s: Sum[A, B])(left: A => C)(right: B => C): C =
    s match {
      case Left(v) => left(v)
      case Right(v) => right(v)
    }

}
</code>```

How to use the fold function? I tried as follow:

```<code>object Main {
  def main(args: Array[String]): Unit = {

    val l = Sum.fold(Left(5))(l => l * l)

  }
}
</code>```

But I do not know, how to pass the third argument.

答:
You just need to give an explicit type to  B for the right function:

```<code> val l = Sum.fold(Left(5))(a => a * a)((b: Int) => b * b)
</code>```

Title: How to use curry function

Body:
I have a curried function on the object:

sealed trait Sum[A, B]

final case class Left[A, B](value: A) extends Sum[A, B]

final case class Right[A, B](value: B) extends Sum[A, B]

object Sum {

  def fold[A, B, C](s: Sum[A, B])(left: A => C)(right: B => C): C =
    s match {
      case Left(v) => left(v)
      case Right(v) => right(v)
    }

}

How to use the fold function? I tried as follow:

object Main {
  def main(args: Array[String]): Unit = {

    val l = Sum.fold(Left(5))(l => l * l)

  }
}

But I do not know, how to pass the third argument.

Body:
You just need to give an explicit type to  B for the right function:

 val l = Sum.fold(Left(5))(a => a * a)((b: Int) => b * b)


问:
is there a way to guarantee that all properties of an interface are addressed
STOP! IMPORTANT! READ FIRST:

i an NOT looking to solve the serialization problem below, i only used it as an example

the REAL QUESTION IS AT THE END, thank you

UPDATE:

i am aware of an option to iterate through all properties using Object.keys(), however this is not what i am looking for, i am looking for a way to address  each property personally

UPDATE:

problem solved, check out my answer below

ORIGINAL QUESTION:

say i have an interface

```<code>interface Data { one: number; another: string; }
</code>```

i have a serialization method

```<code>serialize(data: Data): string {
    return 'one: ' + data.one + ', another: ' + data.another;
}
</code>```

now i am doing refactoring and want to add a new property to the Data interface, so that

```<code>interface Data { one: number; another: string; yetAnother: boolean; }
</code>```

now by requirement the new property yetAnother must be serialized too, yet the compiler won't point out to that because i didn't ask for it, so there is a chance of a bug to slip in

now my question: is there a way to ask the TypeScript compiler if i addressed all properties of an interface?

crossposted to TypeScript: https://github.com/Microsoft/TypeScript/issues/14947

答:
found an elegant solution thanks everyone (try it live at playground):</p>

```<code>type Around<T, R> = { [P in keyof T]: (result: R, value: T[P], name: P) => R; }
function around<T, R>(data: T, result: R, around: Around<T, R>): R {
    for (const name in data) {
        result = around[name](result, data[name], name);
    }
    return result;/
}

function identity<T>(value: T): T { return value; }
function addOver<T>(toString: (value: T) => string) {
    return function add(values: string[], value: T, name: string): string[] {
         values.push(name + ': ' + toString(value));
         return values;
    };
}

interface Data { one: number, another: string, yetAnother: boolean }

function serialize(data: Data): string {
   return around<Data, string[]>(data, [], {
       one: addOver(String),
       another: addOver(identity),
       yetAnother: addOver(String)
   }).join(', ');
}

const serialized = serialize({ one: 1, another: 'hey', yetAnother: true });
alert(serialized) // one: 1, another: hey, yetAnother: true
</code>```

Body:
STOP! IMPORTANT! READ FIRST:

i an NOT looking to solve the serialization problem below, i only used it as an example

the REAL QUESTION IS AT THE END, thank you

UPDATE:

i am aware of an option to iterate through all properties using Object.keys(), however this is not what i am looking for, i am looking for a way to address  each property personally

UPDATE:

problem solved, check out my answer below

ORIGINAL QUESTION:

say i have an interface

interface Data { one: number; another: string; }

i have a serialization method

serialize(data: Data): string {
    return 'one: ' + data.one + ', another: ' + data.another;
}

now i am doing refactoring and want to add a new property to the Data interface, so that

interface Data { one: number; another: string; yetAnother: boolean; }

now by requirement the new property yetAnother must be serialized too, yet the compiler won't point out to that because i didn't ask for it, so there is a chance of a bug to slip in

now my question: is there a way to ask the TypeScript compiler if i addressed all properties of an interface?

crossposted to TypeScript: https://github.com/Microsoft/TypeScript/issues/14947

Body:
found an elegant solution thanks everyone (try it live at <a href="http://www.typescriptlang.org/play/#src=type%20Around%3CT%2C%20R%3E%20%3D%20%7B%20%5BP%20in%20keyof%20T%5D%3A%20(result%3A%20R%2C%20value%3A%20T%5BP%5D%2C%20name%3A%20P)%20%3D%3E%20R%3B%20%7D%0D%0Afunction%20around%3CT%2C%20R%3E(data%3A%20T%2C%20result%3A%20R%2C%20around%3A%20Around%3CT%2C%20R%3E)%3A%20R%20%7B%0D%0A%20%20%20%20for%20(const%20name%20in%20data)%20%7B%0D%0A%20%20%20%20%20%20%20%20result%20%3D%20around%5Bname%5D(result%2C%20data%5Bname%5D%2C%20name)%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20return%20result%3B%0D%0A%7D%0D%0A%0D%0Afunction%20identity%3CT%3E(value%3A%20T)%3A%20T%20%7B%20return%20value%3B%20%7D%0D%0Afunction%20addOver%3CT%3E(toString%3A%20(value%3A%20T)%20%3D%3E%20string)%20%7B%0D%0A%20%20%20%20return%20function%20add(values%3A%20string%5B%5D%2C%20value%3A%20T%2C%20name%3A%20string)%3A%20string%5B%5D%20%7B%0D%0A%20%20%20%20%20%20%20%20%20values.push(name%20%2B%20'%3A%20'%20%2B%20toString(value))%3B%0D%0A%20%20%20%20%20%20%20%20%20return%20values%3B%0D%0A%20%20%20%20%7D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20Data%20%7B%20one%3A%20number%2C%20another%3A%20string%2C%20yetAnother%3A%20boolean%20%7D%0D%0A%20%20%0D%0Afunction%20serialize(data%3A%20Data)%3A%20string%20%7B%0D%0A%20%20%20return%20around%3CData%2C%20string%5B%5D%3E(data%2C%20%5B%5D%2C%20%7B%0D%0A%20%20%20%20%20%20%20one%3A%20addOver(String)%2C%0D%0A%20%20%20%20%20%20%20another%3A%20addOver(identity)%2C%0D%0A%20%20%20%20%20%20%20yetAnother%3A%20addOver(String)%0D%0A%20%20%20%7D).join('%2C%20')%3B%0D%0A%7D%0D%0A%0D%0Aconst%20serialized%20%3D%20serialize(%7B%20one%3A%201%2C%20another%3A%20'hey'%2C%20yetAnother%3A%20true%20%7D)%3B%0D%0Aalert(serialized)%0D%0Aconsole.log(serialized)" rel="nofollow noreferrer">playground):

type Around<T, R> = { [P in keyof T]: (result: R, value: T[P], name: P) => R; }
function around<T, R>(data: T, result: R, around: Around<T, R>): R {
    for (const name in data) {
        result = around[name](result, data[name], name);
    }
    return result;/
}

function identity<T>(value: T): T { return value; }
function addOver<T>(toString: (value: T) => string) {
    return function add(values: string[], value: T, name: string): string[] {
         values.push(name + ': ' + toString(value));
         return values;
    };
}

interface Data { one: number, another: string, yetAnother: boolean }

function serialize(data: Data): string {
   return around<Data, string[]>(data, [], {
       one: addOver(String),
       another: addOver(identity),
       yetAnother: addOver(String)
   }).join(', ');
}

const serialized = serialize({ one: 1, another: 'hey', yetAnother: true });
alert(serialized) // one: 1, another: hey, yetAnother: true


问:
How to find sum of files for all directories and sub directories (separately) and them sort them by size
Could you please advise me how to find the sum of all files in directories and sub directories?
I try to make this script but is not working.</p>

```<code>find . -xdev -type d  | while read l;do ls -l "$l" |
  awk '{sum+=$5}END{print sum/1024/1024 "" $l }';done | sort -k 1
</code>```

答:
There's already a tool in the Unix toolbox for this. You don't have to reinvent the wheel:

```<code>du -x -s * | sort -n
</code>```

Your du(1) manual page (for disk usage) has all the bells and whistles explained.

Body:
Could you please advise me how to find the sum of all files in directories and sub directories?
I try to make this script but is not working.

find . -xdev -type d  | while read l;do ls -l "$l" |
  awk '{sum+=$5}END{print sum/1024/1024 "" $l }';done | sort -k 1

Body:
There's already a tool in the Unix toolbox for this. You don't have to reinvent the wheel:

du -x -s * | sort -n

Your du(1) manual page (for disk usage) has all the bells and whistles explained.


问:
webpack html-loader：  tag not triggering url-loader
When using html-loader, the  tag in the index.html did not trigger url-loader. Here's my webpack configs & html:

webpack config

```<code>// webpack config
module.exports = {
  entry: {
    "index": path.join(__dirname, "./src/js/app.js"),
    "guide_index": path.join(__dirname, './src/js/guide_app.js')
  },
  output: {
    path: path.join(__dirname, '/dist'),
    publicPath: '/',
    filename: '[name].[hash].js'
  },
  // loaders
  module: {
    rules: [
      {
        test: /\.(gif|jpe?g|png|svg|mp3|ttf)$/i,
        loader: "url-loader",
        include: [
          "/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/image",
          path.resolve(__dirname, "/src/image"),
          path.resolve(__dirname, "/../Travel/Resource/assets/image"),
          path.resolve(__dirname, "/../Travel/Resource/assets")
        ],
        query: {
          limit: 5000,
          name: '[name].[hash:16].[ext]'
          //name: "./assets/[name].[hash:16].[ext]"
        }
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      },
      {
        test: /\.(js|jsx)$/,
        loader: "babel-loader",
        // exclude: /node_modules/,
        query: { cacheDirectory: true }
      },
      {
        test: /\.html$/,
        use: [ {
          loader: 'html-loader',
          options: {
            minimize: false,
            removeComments: false,
            removeCommentsFromCDATA: false,
            removeCDATASectionsFromCDATA: false,
            collapseWhitespace: false,
            conservativeCollapse: false,
            // removeAttributeQuotes: false,
            // useShortDoctype: false,
            // keepClosingSlash: false,
            minifyJS: false,
            minifyCSS: false,
            // removeScriptTypeAttributes: false,
            // removeStyleTypeAttributes: false
          }
        }]
      }
    ]
  },
  // Plugins
  plugins: [
    new HtmlWebpackPlugin({
      filename: 'guide_index.html',
      template: path.join(__dirname, './src/html/guide_index.html'),
      inject: true,
      chunks: ["guide_index"],
      minify: false,
      chunksSortMode: 'dependency'
    }),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: path.join(__dirname, './src/html/index.html'),
      inject: true,
      chunks: ["index"],
      minify: false,
      chunksSortMode: 'dependency'
    }),
    new webpack.LoaderOptionsPlugin({
      debug: true
    }),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': "'development'"
    })
  ],
  resolve: {
    extensions: [ '.web.js', '.js', '.jsx' ]
  }
}
</code>```

index.html:

```<code><div class="button" ng-click="$backHistory()" ng-if="navbarType == 'backHistory'">
  <img src="back.png">
</div>
</code>```

error logs:

```<code>Module not found: Error: Can't resolve './back.png' in '/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/html':
Error: Can't resolve './back.png' in '/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/html'

  - compiler.js:76
    [Travel]/[.2.28.0@html-webpack-plugin]/lib/compiler.js:76:16

  - Compiler.js:291 Compiler.<anonymous>
    [Travel]/[.2.3.2@webpack]/lib/Compiler.js:291:10

  - Compiler.js:494
    [Travel]/[.2.3.2@webpack]/lib/Compiler.js:494:13

  - Tapable.js:138 next
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:138:11

  - CachePlugin.js:62 Compiler.<anonymous>
    [Travel]/[.2.3.2@webpack]/lib/CachePlugin.js:62:5

  - Tapable.js:142 Compiler.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:142:13

  - Compiler.js:491
    [Travel]/[.2.3.2@webpack]/lib/Compiler.js:491:10

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:645 self.applyPluginsAsync.err
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:645:19

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:636 self.applyPluginsAsync.err
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:636:11

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:631 self.applyPluginsAsync.err
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:631:10

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:627 sealPart2
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:627:9

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

 ......

Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks  Chunk Names
    index.html  7.51 kB       0

ERROR in ./~/.2.28.0@html-webpack-plugin/lib/loader.js!./Travel/Resource/assets/html/index.html
Module not found: Error: Can't resolve './back.png' in '/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/html'
  @ ./~/.2.28.0@html-webpack-plugin/lib/loader.js!./Travel/Resource/assets/html/index.html 1:2182-2203 1:2367-2388
</code>```

答:
It doesn't get to the url-loader because the file does not exist. Your HTML file is in Travel/Resource/assets/html/ and in the HTML file you have an  tag with the source back.png, so it will look in the same directory, therefore it tries to find Travel/Resource/assets/html/back.png but judging from your webpack configuration, the path to the image is Travel/Resource/assets/image/back.png. That means you have to import it as ../image/back.png:

```<code><div class="button" ng-click="$backHistory()" ng-if="navbarType == 'backHistory'">
  <img src="../image/back.png">
</div>
</code>```

It should find the file and apply the url-loader correctly, but your rule with the url-loader is not quite correct. You're including path.resolve(__dirname, "/src/image") and when path.resolve sees an absolute path it ignores the rest. So the path you include is /src/image not /path/to/project/src/image. You need to remove the leading /, and you can change your include to:

```<code>include: [
  path.resolve(__dirname, "src/image"),
  path.resolve(__dirname, "../Travel/Resource/assets/image"),
  path.resolve(__dirname, "../Travel/Resource/assets")
],
</code>```

With that you don't need the absolute path you added manually, because it's now covered by the second path.resolve.

Title: webpack html-loader： <img> tag not triggering url-loader

Body:
When using html-loader, the  tag in the index.html did not trigger url-loader. Here's my webpack configs & html:

webpack config

// webpack config
module.exports = {
  entry: {
    "index": path.join(__dirname, "./src/js/app.js"),
    "guide_index": path.join(__dirname, './src/js/guide_app.js')
  },
  output: {
    path: path.join(__dirname, '/dist'),
    publicPath: '/',
    filename: '[name].[hash].js'
  },
  // loaders
  module: {
    rules: [
      {
        test: /\.(gif|jpe?g|png|svg|mp3|ttf)$/i,
        loader: "url-loader",
        include: [
          "/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/image",
          path.resolve(__dirname, "/src/image"),
          path.resolve(__dirname, "/../Travel/Resource/assets/image"),
          path.resolve(__dirname, "/../Travel/Resource/assets")
        ],
        query: {
          limit: 5000,
          name: '[name].[hash:16].[ext]'
          //name: "./assets/[name].[hash:16].[ext]"
        }
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      },
      {
        test: /\.(js|jsx)$/,
        loader: "babel-loader",
        // exclude: /node_modules/,
        query: { cacheDirectory: true }
      },
      {
        test: /\.html$/,
        use: [ {
          loader: 'html-loader',
          options: {
            minimize: false,
            removeComments: false,
            removeCommentsFromCDATA: false,
            removeCDATASectionsFromCDATA: false,
            collapseWhitespace: false,
            conservativeCollapse: false,
            // removeAttributeQuotes: false,
            // useShortDoctype: false,
            // keepClosingSlash: false,
            minifyJS: false,
            minifyCSS: false,
            // removeScriptTypeAttributes: false,
            // removeStyleTypeAttributes: false
          }
        }]
      }
    ]
  },
  // Plugins
  plugins: [
    new HtmlWebpackPlugin({
      filename: 'guide_index.html',
      template: path.join(__dirname, './src/html/guide_index.html'),
      inject: true,
      chunks: ["guide_index"],
      minify: false,
      chunksSortMode: 'dependency'
    }),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: path.join(__dirname, './src/html/index.html'),
      inject: true,
      chunks: ["index"],
      minify: false,
      chunksSortMode: 'dependency'
    }),
    new webpack.LoaderOptionsPlugin({
      debug: true
    }),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': "'development'"
    })
  ],
  resolve: {
    extensions: [ '.web.js', '.js', '.jsx' ]
  }
}

index.html:

error logs:

Module not found: Error: Can't resolve './back.png' in '/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/html':
Error: Can't resolve './back.png' in '/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/html'

  - compiler.js:76
    [Travel]/[.2.28.0@html-webpack-plugin]/lib/compiler.js:76:16

  - Compiler.js:291 Compiler.<anonymous>
    [Travel]/[.2.3.2@webpack]/lib/Compiler.js:291:10

  - Compiler.js:494
    [Travel]/[.2.3.2@webpack]/lib/Compiler.js:494:13

  - Tapable.js:138 next
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:138:11

  - CachePlugin.js:62 Compiler.<anonymous>
    [Travel]/[.2.3.2@webpack]/lib/CachePlugin.js:62:5

  - Tapable.js:142 Compiler.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:142:13

  - Compiler.js:491
    [Travel]/[.2.3.2@webpack]/lib/Compiler.js:491:10

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:645 self.applyPluginsAsync.err
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:645:19

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:636 self.applyPluginsAsync.err
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:636:11

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:631 self.applyPluginsAsync.err
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:631:10

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

  - Compilation.js:627 sealPart2
    [Travel]/[.2.3.2@webpack]/lib/Compilation.js:627:9

  - Tapable.js:131 Compilation.applyPluginsAsyncSeries
    [Travel]/[.0.2.6@tapable]/lib/Tapable.js:131:46

 ......

Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks  Chunk Names
    index.html  7.51 kB       0

ERROR in ./~/.2.28.0@html-webpack-plugin/lib/loader.js!./Travel/Resource/assets/html/index.html
Module not found: Error: Can't resolve './back.png' in '/Users/chrishu/Projects/Wind/guideios/Travel/Travel/Resource/assets/html'
  @ ./~/.2.28.0@html-webpack-plugin/lib/loader.js!./Travel/Resource/assets/html/index.html 1:2182-2203 1:2367-2388

Body:
It doesn't get to the url-loader because the file does not exist. Your HTML file is in Travel/Resource/assets/html/ and in the HTML file you have an <img> tag with the source back.png, so it will look in the same directory, therefore it tries to find Travel/Resource/assets/html/back.png but judging from your webpack configuration, the path to the image is Travel/Resource/assets/image/back.png. That means you have to import it as ../image/back.png:

<div class="button" ng-click="$backHistory()" ng-if="navbarType == 'backHistory'">
  <img src="../image/back.png">
</div>

It should find the file and apply the url-loader correctly, but your rule with the url-loader is not quite correct. You're including path.resolve(__dirname, "/src/image") and when path.resolve sees an absolute path it ignores the rest. So the path you include is /src/image not /path/to/project/src/image. You need to remove the leading /, and you can change your include to:

include: [
  path.resolve(__dirname, "src/image"),
  path.resolve(__dirname, "../Travel/Resource/assets/image"),
  path.resolve(__dirname, "../Travel/Resource/assets")
],

With that you don't need the absolute path you added manually, because it's now covered by the second path.resolve.


问:
measure virtual machine live migration parameters in kvm/qemu
I am using kvm/qemu for vm live migration. how can i understand downtime, total migration time and data exchanged after migration? is there any tools for measuring them.</p>

答: I have been meausring the performance of openstack server migrate using wireshark. You can ping the openstack instance from your control node, and have wireshark capture the icmp packets sent to the instance. CArry out live migration while pinging it. Take note of the time for which the packets are not captured by wireshark, and there you have it, an approximate measurement of performance of openstack server migrate.</p>


问:
ASP.net: Display PDF in a asp.net web page
User click on a link button and it will direct them to a url that is dynmaically generated which a pdf file. The browser will prompt the user to either save or open it.

I want to know if it is possible to downlaod the pdf file to the server then show the pdf file in the asp.net web page. When i google on this question, 99% of top link are some third party component. Is it a way to do this without purchase any 3rd party component?

thank

答:
I don't think that you'll have much luck without a 3rd party component.  First, the issue isn't showing the PDF, it is generating it.  For that, you'll need a library to help.  Rolling one yourself would not be cheaper unless you have an enormous amount of unpaid time on your hands.

With respect to third-party controls, I recommend and use DynamicPDF from CeTe.

OwnerDisplayName: Jack


问:
Static shortcut not showing in pre-7.1 device
I've just implemented 3 static shortcuts and they work well in android 7.1 as expected. However, using static shortcuts, I expected them working also in devices with Android 7.0 (or 6, not tried) with Nova Launcher but they are not showing up. Why? Here's my code for one of them:</p>

```<code>    <shortcut
        android:shortcutId="ND Fragment"
        android:enabled="true"
        android:icon="@drawable/icon_filter"
        android:shortcutShortLabel="@string/title_nd"
        android:shortcutLongLabel="@string/title_nd">
        <intent
            android:action="android.intent.action.VIEW"
            android:targetPackage="com.gmail.nellorocca.dslrtools"
            android:targetClass="com.gmail.nellorocca.dslrtools.MainActivity">
            <extra android:name="extra_name" android:value="launch_nd"/>
        </intent>

        <categories android:name="android.shortcut.conversation" />
    </shortcut>
</code>```

答:
SOLVED thanks to Chris Lacy (Action Launcher's developer) guide.
You need to add android:exported=true in any activity you point to.

Source: http://theblerg.net/post/2016/10/1/integrating-android-71s-launcher-shortcuts-into-your-app

Body:
I've just implemented 3 static shortcuts and they work well in android 7.1 as expected. However, using static shortcuts, I expected them working also in devices with Android 7.0 (or 6, not tried) with Nova Launcher but they are not showing up. Why? Here's my code for one of them:

    <shortcut
        android:shortcutId="ND Fragment"
        android:enabled="true"
        android:icon="@drawable/icon_filter"
        android:shortcutShortLabel="@string/title_nd"
        android:shortcutLongLabel="@string/title_nd">
        <intent
            android:action="android.intent.action.VIEW"
            android:targetPackage="com.gmail.nellorocca.dslrtools"
            android:targetClass="com.gmail.nellorocca.dslrtools.MainActivity">
            <extra android:name="extra_name" android:value="launch_nd"/>
        </intent>

        <categories android:name="android.shortcut.conversation" />
    </shortcut>


问:
how to make connection between the provider and connection string web.config visual studio 2013
**web.config for visual studio 2013  **
i have tried lots of things but still get the same error what should i do ? that's the error i get

the web.config code the default connection string

the connection string i wrote

i know the problem is in provider but i don't know what to do ?
that's the whole problem and the images of the web config code ?
any ideas ?

答:
First off, why are you using VS 2013 when VS 2017 is available? Get VS 2017 and .NET Core.

https://www.visualstudio.com/downloads/

Second, what? What are you trying to do here? You can't connect to a server you're not the root user for. If you're attempting to connect to anyone's server but your own, you're going to have a bad time. A connection string is provided by the business hosting your server. For example, Microsoft Azure provides each of their cloud server subscribers with connection strings to connect to that server. In web.config, if I recall correctly, you simply scroll to the top of the page and paste the connection string into the connection string element. Then enter your password and name into the string where the password and name placeholders are.


问:
Z index is not working for a drop down component which is placed in side a disclosure panel.
I have a custom GWT drop down component which is a combination of a text box,vertical panel which contains check boxes.

I have to placed this component inside GWT disclosure panel.When the panel is expanded and when the user clicks on the component the drop down must appear on the top of the main page content instead of expanding the disclosure panel or going below the main page.

I have tried with z index with higher values still the drop down is going inside  the disclosure panel.

Is there any other CSS tricks which can help me to solve this issue.

答: Try adding position : relative; to the dropdown wrapper along with z-index. You might have to test different values of z-index's for it to work depending on your code.