问:
Android - Load PDF inside webview
I have this webview  code and I want to make it possible to have the PDF files opened when a user clicks on a PDF link.  Here is the code, can you tell me what I have to put inside the PDF area of this? I've tried many different ways and I cannot get the PDF to view at all.  Thanks for the help.</p>

```<code>webview.setWebViewClient ( new WebViewClient() {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        // do your handling codes here, which url is the requested url
        // probably you need to open that url rather than redirect:
        if (url.startsWith("tel:")) {
            startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
        } else if (url.startsWith("mailto:")) {
            url = url.replaceFirst("mailto:", "");
            url = url.trim();
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL,
                    new String[]{url});
            startActivity(i);

        } else if (url.startsWith("geo:")) {
            try {
            } catch (Exception e) {
                System.out.println(e);
            }

        } else if (url.endsWith("pdf")) {

            try {

            } catch (Exception e) {
                System.out.println(e);
            }

        } else {
            view.loadUrl(url);
        }
        return true;
        // then it is not handled by default action
    }
});
</code>```

答:
Please checkout the example for handling redirect urls and open PDF without download, in webview.</p>

```<code>private void init()
{
    WebView webview = (WebView) findViewById(R.id.webview);
    WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);
    webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

    PdfWebViewClient pdfWebViewClient = new PdfWebViewClient(this, webview);
    pdfWebViewClient.loadPdfUrl(
                "https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjgwIfp3KXSAhXrhFQKHQqEDHYQFggZMAA&url=http%3A%2F%2Fwww.orimi.com%2Fpdf-test.pdf&usg=AFQjCNERYYcSfMLS5ukBcT2Qy11YxEhXqw&cad=rja");
}

private class PdfWebViewClient extends WebViewClient
{
    private static final String TAG = "PdfWebViewClient";
    private static final String PDF_EXTENSION = ".pdf";
    private static final String PDF_VIEWER_URL = "http://docs.google.com/gview?embedded=true&url=";

    private Context mContext;
    private WebView mWebView;
    private ProgressDialog mProgressDialog;
    private boolean isLoadingPdfUrl;

    public PdfWebViewClient(Context context, WebView webView)
    {
        mContext = context;
        mWebView = webView;
        mWebView.setWebViewClient(this);
    }

    public void loadPdfUrl(String url)
    {
        mWebView.stopLoading();

        if (!TextUtils.isEmpty(url))
        {
            isLoadingPdfUrl = isPdfUrl(url);
            if (isLoadingPdfUrl)
            {
                mWebView.clearHistory();
            }

            showProgressDialog();
        }

        mWebView.loadUrl(url);
    }

    @SuppressWarnings("deprecation")
    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, String url)
    {
        return shouldOverrideUrlLoading(url);
    }

    @SuppressWarnings("deprecation")
    @Override
    public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl)
    {
        handleError(errorCode, description.toString(), failingUrl);
    }

    @TargetApi(Build.VERSION_CODES.N)
    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request)
    {
        final Uri uri = request.getUrl();
        return shouldOverrideUrlLoading(webView, uri.toString());
    }

    @TargetApi(Build.VERSION_CODES.N)
    @Override
    public void onReceivedError(final WebView webView, final WebResourceRequest request, final WebResourceError error)
    {
        final Uri uri = request.getUrl();
        handleError(error.getErrorCode(), error.getDescription().toString(), uri.toString());
    }

    @Override
    public void onPageFinished(final WebView view, final String url)
    {
        Log.i(TAG, "Finished loading. URL : " + url);
        dismissProgressDialog();
    }

    private boolean shouldOverrideUrlLoading(final String url)
    {
        Log.i(TAG, "shouldOverrideUrlLoading() URL : " + url);

        if (!isLoadingPdfUrl && isPdfUrl(url))
        {
            mWebView.stopLoading();

            final String pdfUrl = PDF_VIEWER_URL + url;

            new Handler().postDelayed(new Runnable()
            {
                @Override
                public void run()
                {
                    loadPdfUrl(pdfUrl);
                }
            }, 300);

            return true;
        }

        return false; // Load url in the webView itself
    }

    private void handleError(final int errorCode, final String description, final String failingUrl)
    {
        Log.e(TAG, "Error : " + errorCode + ", " + description + " URL : " + failingUrl);
    }

    private void showProgressDialog()
    {
        dismissProgressDialog();
        mProgressDialog = ProgressDialog.show(mContext, "", "Loading...");
    }

    private void dismissProgressDialog()
    {
        if (mProgressDialog != null && mProgressDialog.isShowing())
        {
            mProgressDialog.dismiss();
            mProgressDialog = null;
        }
    }

    private boolean isPdfUrl(String url)
    {
        if (!TextUtils.isEmpty(url))
        {
            url = url.trim();
            int lastIndex = url.toLowerCase().lastIndexOf(PDF_EXTENSION);
            if (lastIndex != -1)
            {
                return url.substring(lastIndex).equalsIgnoreCase(PDF_EXTENSION);
            }
        }
        return false;
    }
}
</code>```

Title: Android - Load PDF inside webview

Body:
I have this webview  code and I want to make it possible to have the PDF files opened when a user clicks on a PDF link.  Here is the code, can you tell me what I have to put inside the PDF area of this? I've tried many different ways and I cannot get the PDF to view at all.  Thanks for the help.

webview.setWebViewClient ( new WebViewClient() {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        // do your handling codes here, which url is the requested url
        // probably you need to open that url rather than redirect:
        if (url.startsWith("tel:")) {
            startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
        } else if (url.startsWith("mailto:")) {
            url = url.replaceFirst("mailto:", "");
            url = url.trim();
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL,
                    new String[]{url});
            startActivity(i);

        } else if (url.startsWith("geo:")) {
            try {
            } catch (Exception e) {
                System.out.println(e);
            }

        } else if (url.endsWith("pdf")) {

            try {

            } catch (Exception e) {
                System.out.println(e);
            }

        } else {
            view.loadUrl(url);
        }
        return true;
        // then it is not handled by default action
    }
});

Body:
Please checkout the example for handling redirect urls and open PDF without download, in webview.

private void init()
{
    WebView webview = (WebView) findViewById(R.id.webview);
    WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);
    webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

    PdfWebViewClient pdfWebViewClient = new PdfWebViewClient(this, webview);
    pdfWebViewClient.loadPdfUrl(
                "https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjgwIfp3KXSAhXrhFQKHQqEDHYQFggZMAA&url=http%3A%2F%2Fwww.orimi.com%2Fpdf-test.pdf&usg=AFQjCNERYYcSfMLS5ukBcT2Qy11YxEhXqw&cad=rja");
}

private class PdfWebViewClient extends WebViewClient
{
    private static final String TAG = "PdfWebViewClient";
    private static final String PDF_EXTENSION = ".pdf";
    private static final String PDF_VIEWER_URL = "http://docs.google.com/gview?embedded=true&url=";

    private Context mContext;
    private WebView mWebView;
    private ProgressDialog mProgressDialog;
    private boolean isLoadingPdfUrl;

    public PdfWebViewClient(Context context, WebView webView)
    {
        mContext = context;
        mWebView = webView;
        mWebView.setWebViewClient(this);
    }

    public void loadPdfUrl(String url)
    {
        mWebView.stopLoading();

        if (!TextUtils.isEmpty(url))
        {
            isLoadingPdfUrl = isPdfUrl(url);
            if (isLoadingPdfUrl)
            {
                mWebView.clearHistory();
            }

            showProgressDialog();
        }

        mWebView.loadUrl(url);
    }

    @SuppressWarnings("deprecation")
    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, String url)
    {
        return shouldOverrideUrlLoading(url);
    }

    @SuppressWarnings("deprecation")
    @Override
    public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl)
    {
        handleError(errorCode, description.toString(), failingUrl);
    }

    @TargetApi(Build.VERSION_CODES.N)
    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request)
    {
        final Uri uri = request.getUrl();
        return shouldOverrideUrlLoading(webView, uri.toString());
    }

    @TargetApi(Build.VERSION_CODES.N)
    @Override
    public void onReceivedError(final WebView webView, final WebResourceRequest request, final WebResourceError error)
    {
        final Uri uri = request.getUrl();
        handleError(error.getErrorCode(), error.getDescription().toString(), uri.toString());
    }

    @Override
    public void onPageFinished(final WebView view, final String url)
    {
        Log.i(TAG, "Finished loading. URL : " + url);
        dismissProgressDialog();
    }

    private boolean shouldOverrideUrlLoading(final String url)
    {
        Log.i(TAG, "shouldOverrideUrlLoading() URL : " + url);

        if (!isLoadingPdfUrl && isPdfUrl(url))
        {
            mWebView.stopLoading();

            final String pdfUrl = PDF_VIEWER_URL + url;

            new Handler().postDelayed(new Runnable()
            {
                @Override
                public void run()
                {
                    loadPdfUrl(pdfUrl);
                }
            }, 300);

            return true;
        }

        return false; // Load url in the webView itself
    }

    private void handleError(final int errorCode, final String description, final String failingUrl)
    {
        Log.e(TAG, "Error : " + errorCode + ", " + description + " URL : " + failingUrl);
    }

    private void showProgressDialog()
    {
        dismissProgressDialog();
        mProgressDialog = ProgressDialog.show(mContext, "", "Loading...");
    }

    private void dismissProgressDialog()
    {
        if (mProgressDialog != null && mProgressDialog.isShowing())
        {
            mProgressDialog.dismiss();
            mProgressDialog = null;
        }
    }

    private boolean isPdfUrl(String url)
    {
        if (!TextUtils.isEmpty(url))
        {
            url = url.trim();
            int lastIndex = url.toLowerCase().lastIndexOf(PDF_EXTENSION);
            if (lastIndex != -1)
            {
                return url.substring(lastIndex).equalsIgnoreCase(PDF_EXTENSION);
            }
        }
        return false;
    }
}


来源: stackexchange

问:
facebook login give me already authorized this app without automatic returning to the app
My app should implement login with facebook but I have noticed that every time I want to login the facebook tell me you are already authorize this app , the question if I already authorized the app the facebook should return automatically without pressing the okey button as I saw in other applications ?

see the attached image

答:
You should check if there is a current session before logging in with FBSDKLoginManager. Do not use [loginManager logout] before logging in.

```<code>if ([FBSDKAccessToken currentAccessToken])
 {
      NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
      // Now get details using graphpath.
 } else {
     // login with permissions using FBSDKLoginManager and get details using graphpath in completion

 }
</code>```

ContentLicense: CC BY-SA 3.0

Body:
You should check if there is a current session before logging in with FBSDKLoginManager. Do not use [loginManager logout] before logging in.

if ([FBSDKAccessToken currentAccessToken])
 {
      NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
      // Now get details using graphpath.
 } else {
     // login with permissions using FBSDKLoginManager and get details using graphpath in completion

 }


问:
I want to retrieve all data from table between two dates

The above screenshot shows table data where ClNum - 97 has three rows of data with different dates. I want to get all dates data for CLNum-97 from

```<code>EntryDate >= '1-6-2017' to EntryDate <= '30-6-2017'
</code>```

and order by EntryDate ASC but retrieve only the last date data.

Please help me out here I want all data of that employee between this two dates.

答:
```<code>Select top 1 * from TimeSheet
where EntryDate between '2017-06-01' and '2017-06-30' and ClNum =97
order by EntryDate desc
</code>```

Body:
The above screenshot shows table data where ClNum - 97 has three rows of data with different dates. I want to get all dates data for CLNum-97 from

EntryDate >= '1-6-2017' to EntryDate <= '30-6-2017'

and order by EntryDate ASC but retrieve only the last date data.

Please help me out here I want all data of that employee between this two dates.


问:
Putting some HTML next to a radio button in Zend Form
I have built a form builder, and I need the ability to assign description to every option in a radio element. Upon creation of this radio element, I ask the user to assign each value a description, which should be shown next to the element. So, in my database, I have a value, a title and a description for each option in this radio element.

The question:
How do I put something next to a radio element? Do I have to create a new way for the form to render radio elements, or can it be done via decorators?

Any little bit helps, useful reading is welcome too!

A representation of what i need:

```<code>**A title of the Radio element**
      O Option 1       -    A description for option 1
      O Option 2       -    A description for option 2
      O Option 3       -    A description for option 3
      O Option 4       -    A description for option 4
</code>```

Any ideas?

答:
Check out the tutorial I wrote solving this problem.

http://wesleyalmeida.net/what-ive-learned/how-to-decorate-a-radio-element-in-zend/

ContentLicense: CC BY-SA 2.5

Body:
I have built a form builder, and I need the ability to assign description to every option in a radio element. Upon creation of this radio element, I ask the user to assign each value a description, which should be shown next to the element. So, in my database, I have a value, a title and a description for each option in this radio element.

The question:
How do I put something next to a radio element? Do I have to create a new way for the form to render radio elements, or can it be done via decorators?

Any little bit helps, useful reading is welcome too!

A representation of what i need:

**A title of the Radio element**
      O Option 1       -    A description for option 1
      O Option 2       -    A description for option 2
      O Option 3       -    A description for option 3
      O Option 4       -    A description for option 4

Any ideas?


问:
Google Chart: Pie Slice text weird position
When creating Pie Charts (using Google Chart) they would always output with very oddly positioned Slice Text/Annotations, and when a slice was very small the text would still be on the slice. See image below.

This would occur even using the copied Javascript code from the Google Charts examples. However, I would hide the chart div where the output needs to reside (using display:none) because I wanted to open the static chart in a new tab opposed to pasting it on the page.

答:
In order for the chart to generate correctly the DIV where your chart outputs to cannot be set to display: none. This seems to be a bug with Google Charts. I found a workaround if you want to hide the chart output DIV. You can set visibility: hidden which will hide the DIV and still allow the chart to generate properly. If you would like to completey mimic the display:none css, I used the following styles:

```<code>visibility: hidden;
position: absolute;
top: -9999px;
left: -9999px;
</code>```

Hope this helps you.

Body:
In order for the chart to generate correctly the DIV where your chart outputs to cannot be set to display: none. This seems to be a bug with Google Charts. I found a workaround if you want to hide the chart output DIV. You can set visibility: hidden which will hide the DIV and still allow the chart to generate properly. If you would like to completey mimic the display:none css, I used the following styles:

visibility: hidden;
position: absolute;
top: -9999px;
left: -9999px;

Hope this helps you.


问:
update x value using slider matplotlib
I try to draw a graph, which show the progress of a chemical reaction. The progress itself (time or reactionsteps) should be changeable using a slider.
The code I have so far:

```<code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button

fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
fig.canvas.set_window_title('Reaktionsfortschritt')

t0 = 0
t = np.arange(0, t0, .5)
k0 = 0.17
a = np.exp(- k0 * t)

l, = plt.plot(t, a, lw=3, color='crimson')
plt.axis([0, 20, 0, 1])

axrs = plt.axes([0.25, 0.1, 0.65, 0.03], facecolor='lightblue')
srs = Slider(axrs, 'Reaktionsschritte', 0, 20, valinit=0)

def xval(*args):
    x = srs.val
    t = np.arange(0, x, 0.5)
    #l.set_ydata(np.exp(- 0.6 * t))
    #plt.plot(t, a)
    fig.canvas.draw_idle()

srs.on_changed(xval)

plt.show()
</code>```

As far as I understand the plot-range (t) is updated using the xval-function. However, there is no plotting of the graph.
I tried both replotting using plt.plot(t, a) as well as l.set_ydata(...).

edited

Ok, so now I added a second function (b) that describes product formation. I added the function also in the same way to the update-function. As a result I get a very strange behaviour: using the slider, I can plot only in positive x-direction, e.g. there I no going back. Once the graph is drawn, it won't 'undraw' when reducing the slider value. Any suggestion why that is?

```<code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button

fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
fig.canvas.set_window_title('Reaktionsfortschritt')

t = np.arange(0, 0, .5)
k0 = 0.17
a = np.exp(- k0 * t)
b = 1 - np.exp(- k0 * t)
# plot
l, = plt.plot(t, a, lw=3, color='crimson')
m, = plt.plot(t, b, lw=3, color='dodgerblue')
plt.axis([0, 20, 0, 1])
plt.grid(True)

axrs = plt.axes([0.25, 0.1, 0.65, 0.03], facecolor='lightblue')
srs = Slider(axrs, 'Zeit', 0, 20, valinit=0)

def update(x):
    t = np.arange(0, x, 2)
    ax.lines.pop(0)  # remove previous line plot
    ax.plot(t, np.exp(- k0 * t), lw=3, color='crimson')
    ax.plot(t, 1 - np.exp(- k0 * t), lw=3, color='dodgerblue')
    fig.canvas.draw()

srs.on_changed(update)

plt.show()
</code>```

答:
Assuming you have time on the x-axis and want to change the maximum time of your plot that is created by the same function every time, I came up with this:

```<code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider

fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
fig.canvas.set_window_title('Reaktionsfortschritt')

t0 = 0
t = np.arange(0, t0, .5)
k0 = 0.17
a = np.exp(- k0 * t)

l, = ax.plot(t, a, lw=3, color='crimson')
plt.axis([0, 20, 0, 1])

axrs = plt.axes([0.25, 0.1, 0.65, 0.03])
srs = Slider(axrs, 'Reaktionsschritte', 0, 20, valinit=0)

def update(x):
    t0 = x
    t = np.arange(0, t0, .5)
    ax.lines.pop(0)  # remove previous line plot
    ax.plot(t, np.exp(- k0 * t), lw=3, color='crimson')  # plot new one
    fig.canvas.draw()

srs.on_changed(update)

plt.show()
</code>```

See what it does when changing the Slider value and let me know if this is what you wanted it to do.

To your edit:

When you add a second plot, you have two lines objects. Try to print ax.lines directly after you run the code (before touching the Slider) and see that it really is a list of two lines. Then call ax.lines.pop(0) and see that one element is popped from the list. That's what the above code does, it removes lines from the axes object ax every time you touch the Slider (because then update is called), which after calling fig.canvas.draw() leads to vanishing of previous plots. If you now touch the Slider once, then two new lines are added to ax and only one is removed. This is why you think there is no going back.

So if you now added a second plot, you just have to pop twice from the list ax.lines with ax.lines.pop(0) and the code works fine ;-)

Title: update x value using slider matplotlib

Body:
I try to draw a graph, which show the progress of a chemical reaction. The progress itself (time or reactionsteps) should be changeable using a slider.
The code I have so far:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button

fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
fig.canvas.set_window_title('Reaktionsfortschritt')

t0 = 0
t = np.arange(0, t0, .5)
k0 = 0.17
a = np.exp(- k0 * t)

l, = plt.plot(t, a, lw=3, color='crimson')
plt.axis([0, 20, 0, 1])

axrs = plt.axes([0.25, 0.1, 0.65, 0.03], facecolor='lightblue')
srs = Slider(axrs, 'Reaktionsschritte', 0, 20, valinit=0)

def xval(*args):
    x = srs.val
    t = np.arange(0, x, 0.5)
    #l.set_ydata(np.exp(- 0.6 * t))
    #plt.plot(t, a)
    fig.canvas.draw_idle()

srs.on_changed(xval)

plt.show()

As far as I understand the plot-range (t) is updated using the xval-function. However, there is no plotting of the graph.
I tried both replotting using plt.plot(t, a) as well as l.set_ydata(...).

edited

Ok, so now I added a second function (b) that describes product formation. I added the function also in the same way to the update-function. As a result I get a very strange behaviour: using the slider, I can plot only in positive x-direction, e.g. there I no going back. Once the graph is drawn, it won't 'undraw' when reducing the slider value. Any suggestion why that is?

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button

fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
fig.canvas.set_window_title('Reaktionsfortschritt')

t = np.arange(0, 0, .5)
k0 = 0.17
a = np.exp(- k0 * t)
b = 1 - np.exp(- k0 * t)
# plot
l, = plt.plot(t, a, lw=3, color='crimson')
m, = plt.plot(t, b, lw=3, color='dodgerblue')
plt.axis([0, 20, 0, 1])
plt.grid(True)

axrs = plt.axes([0.25, 0.1, 0.65, 0.03], facecolor='lightblue')
srs = Slider(axrs, 'Zeit', 0, 20, valinit=0)

def update(x):
    t = np.arange(0, x, 2)
    ax.lines.pop(0)  # remove previous line plot
    ax.plot(t, np.exp(- k0 * t), lw=3, color='crimson')
    ax.plot(t, 1 - np.exp(- k0 * t), lw=3, color='dodgerblue')
    fig.canvas.draw()

srs.on_changed(update)

plt.show()

Body:
Assuming you have time on the x-axis and want to change the maximum time of your plot that is created by the same function every time, I came up with this:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider

fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.25)
fig.canvas.set_window_title('Reaktionsfortschritt')

t0 = 0
t = np.arange(0, t0, .5)
k0 = 0.17
a = np.exp(- k0 * t)

l, = ax.plot(t, a, lw=3, color='crimson')
plt.axis([0, 20, 0, 1])

axrs = plt.axes([0.25, 0.1, 0.65, 0.03])
srs = Slider(axrs, 'Reaktionsschritte', 0, 20, valinit=0)

def update(x):
    t0 = x
    t = np.arange(0, t0, .5)
    ax.lines.pop(0)  # remove previous line plot
    ax.plot(t, np.exp(- k0 * t), lw=3, color='crimson')  # plot new one
    fig.canvas.draw()

srs.on_changed(update)

plt.show()

See what it does when changing the Slider value and let me know if this is what you wanted it to do.

To your edit:

When you add a second plot, you have two lines objects. Try to print ax.lines directly after you run the code (before touching the Slider) and see that it really is a list of two lines. Then call ax.lines.pop(0) and see that one element is popped from the list. That's what the above code does, it removes lines from the axes object ax every time you touch the Slider (because then update is called), which after calling fig.canvas.draw() leads to vanishing of previous plots. If you now touch the Slider once, then two new lines are added to ax and only one is removed. This is why you think there is no going back.

So if you now added a second plot, you just have to pop twice from the list ax.lines with ax.lines.pop(0) and the code works fine ;-)


问:
Visual Studio copies dll files which are set to "Do not copy"
In my VS 2015 project I have a folder with some .dll files that I wanted to copy to the output directory using a post build script depending on the platform.

To prevent Visual Studio from touching them I set the property "Copy to output directory" to "Do not copy". I also set "Build Action" to "None".

But when I build the project some, but not all, of the .dll files are copied to the output directory anyway.
I have commented out my post build script.

The build output log says that the files are copied during a target "_CopyFilesMarkedCopyLocal":

```<code>1>Target "_CopyFilesMarkedCopyLocal" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project
 "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverMain\InSQLMDASDriverMain.csproj" (target "CopyFilesToOutputDirectory" depends on it):
1>Task "Copy"

... Copying of referenced assembly project output:
1>  Copying file from "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverGui\bin\x86\Debug\InSQLMDASDriverGui.dll" to "bin\x86\Debug\InSQLMDASDriverGui.dll".

... Unwanted copying of static files below:

1>  Copying file from "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverMain\x64 Libraries\Historian.CBE.dll" to "bin\x86\Debug\Historian.CBE.dll".
1>  Copying file from "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverMain\x64 Libraries\Historian.DPAPI.dll" to "bin\x86\Debug\Historian.DPAPI.dll".

...

1>Done executing task "Copy".
1>Done building target "_CopyFilesMarkedCopyLocal" in project "InSQLMDASDriverMain.csproj".
</code>```

Why is this happening..?

答:
In my VS 2015 project I have a folder with some .dll files that I wanted to copy to the output directory using a post build script depending on the platform.

Do you want to use a post build script to copy the dlls to output directory instead of using Visual Studio? If I understand you correctly, you should set the copy local=False for the dll in the property of References. For example:

With this setting, Visual Studio will not touch the dlls.

Body:
In my VS 2015 project I have a folder with some .dll files that I wanted to copy to the output directory using a post build script depending on the platform.

To prevent Visual Studio from touching them I set the property "Copy to output directory" to "Do not copy". I also set "Build Action" to "None".

But when I build the project some, but not all, of the .dll files are copied to the output directory anyway.
I have commented out my post build script.

The build output log says that the files are copied during a target "_CopyFilesMarkedCopyLocal":

1>Target "_CopyFilesMarkedCopyLocal" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project
 "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverMain\InSQLMDASDriverMain.csproj" (target "CopyFilesToOutputDirectory" depends on it):
1>Task "Copy"

... Copying of referenced assembly project output:
1>  Copying file from "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverGui\bin\x86\Debug\InSQLMDASDriverGui.dll" to "bin\x86\Debug\InSQLMDASDriverGui.dll".

... Unwanted copying of static files below:

1>  Copying file from "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverMain\x64 Libraries\Historian.CBE.dll" to "bin\x86\Debug\Historian.CBE.dll".
1>  Copying file from "C:\SS\C#\InSQLMDASDriver2014R2\InSQLMDASDriverMain\x64 Libraries\Historian.DPAPI.dll" to "bin\x86\Debug\Historian.DPAPI.dll".

...

1>Done executing task "Copy".
1>Done building target "_CopyFilesMarkedCopyLocal" in project "InSQLMDASDriverMain.csproj".

Why is this happening..?


问:
Accessing external database using the wpdb class in WordPress
I have a custom page template in WordPress that is relying on an external database, and which is using the wpdb class for this purpose.

This is my code:

```<code><article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    </header><!-- .entry-header -->

<?php

class StudentsDatabase
{
    private $db;
    public function __construct() {
        try {
            $this->db = new wpdb(DB_USER, DB_PASSWORD, 'students_db', DB_HOST);
            $this->db->show_errors();
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
    public function getStudentById($student_id)
    {
        return $this->db->get_results("SELECT * FROM `students` WHERE id=$student_id");
    }
    public function getSchoolByAreaCode($area_code)
    {
        return $this->db->get_results("SELECT * FROM `schools` WHERE area_code=$area_code;--");
    }

}
$Students_DB = new StudentsDatabase();
$student_one = $Students_DB->getStudentById(1);
$school_one = $Students_DB->getSchoolByAreaCode(1);

?>
<div class="entry-content">
    <?php

    //do something with $student_one and $school_one ...

    the_content();

    ?>
</div><!-- .entry-content -->
</code>```

Well, I was wondering if this is the right way to do it. Security-wise or any 'other'-wise actually.

It feels kinda sketchy to make external db calls from within the page's template itself. Should I register these functions on some external file and then just use them inside the template?

答:
There is also more radical way to work with multiple DBs in Wordpress. As follows from wpdb Codex page:

The $wpdb object can talk to any number of tables, but only to one database at a time; by default the WordPress database. In the rare case you need to connect to another database, you will need to instantiate your own object from the wpdb class with your own database connection information. For extremely complicated setups with many databases, consider using hyperdb instead.

Hyperdb is a plugin that helps with multiple DBs and replaces your overthinking about code organization.

Body:
I have a custom page template in WordPress that is relying on an external database, and which is using the wpdb class for this purpose.

This is my code:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

        <?php the_title( '
', '
' ); ?>

<?php

class StudentsDatabase
{
    private $db;
    public function __construct() {
        try {
            $this->db = new wpdb(DB_USER, DB_PASSWORD, 'students_db', DB_HOST);
            $this->db->show_errors();
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
    public function getStudentById($student_id)
    {
        return $this->db->get_results("SELECT * FROM `students` WHERE id=$student_id");
    }
    public function getSchoolByAreaCode($area_code)
    {
        return $this->db->get_results("SELECT * FROM `schools` WHERE area_code=$area_code;--");
    }

}
$Students_DB = new StudentsDatabase();
$student_one = $Students_DB->getStudentById(1);
$school_one = $Students_DB->getSchoolByAreaCode(1);

?>

    <?php

    //do something with $student_one and $school_one ...

    the_content();

    ?>

Well, I was wondering if this is the right way to do it. Security-wise or any 'other'-wise actually.

It feels kinda sketchy to make external db calls from within the page's template itself. Should I register these functions on some external file and then just use them inside the template?


问:
How to pass Multiple Class Object in $http Request
My requirement is to pass multiple class object(which is going to map with request param or request body in rest controller) in angular $http service.

I can't pass class object in request body since one http call has only one request body.

When i'm trying to pass class object in $http param I'm getting class cast exception.

is there any way to pass multiple object in single $http call ??

```<code>@RequestMapping(value = "CommitObject", method = RequestMethod.POST)
public void Commit(@RequestParam(value = "clazz") final String clazz,
        @RequestParam(value = "Id") final String modelId,@RequestBody LinkedHashMap<String, Object> obj) {
    mService.Commit(Id,clazz workingmodelObj);
}
</code>```

答:
I tried it many times but always failed.So to overcome this I use to create a  Java Bean and encapsulate both objects into it at then accepting it in     @RequestBody.

Your Wrapper should look like this:

```<code>public class SampleWrapper {
    private Object1 object1;
    private Object2 object2;
    //getters setters and constructors go here
}
</code>```

And your constructor should look like this:

```<code>@RequestMapping(value = "/url",method= RequestMethod.POST)
public String getRequest(@RequestBody SampleWrapper wrapper) {
    Object1 o1 = wrapper.getObject1();
    Object2 o2 = wrapper.getObject2();
}
</code>```

JSON request should look like this:

```<code> {
 "object1" : {//object1 body },
 "object2" : {//object2 body }
 }
</code>```

Body:
My requirement is to pass multiple class object(which is going to map with request param or request body in rest controller) in angular $http service.

I can't pass class object in request body since one http call has only one request body.

When i'm trying to pass class object in $http param I'm getting class cast exception.

is there any way to pass multiple object in single $http call ??

@RequestMapping(value = "CommitObject", method = RequestMethod.POST)
public void Commit(@RequestParam(value = "clazz") final String clazz,
        @RequestParam(value = "Id") final String modelId,@RequestBody LinkedHashMap<String, Object> obj) {
    mService.Commit(Id,clazz workingmodelObj);
}

Body:
I tried it many times but always failed.So to overcome this I use to create a  Java Bean and encapsulate both objects into it at then accepting it in     @RequestBody.

Your Wrapper should look like this:

public class SampleWrapper {
    private Object1 object1;
    private Object2 object2;
    //getters setters and constructors go here
}

And your constructor should look like this:

@RequestMapping(value = "/url",method= RequestMethod.POST)
public String getRequest(@RequestBody SampleWrapper wrapper) {
    Object1 o1 = wrapper.getObject1();
    Object2 o2 = wrapper.getObject2();
}

JSON request should look like this:

 {
 "object1" : {//object1 body },
 "object2" : {//object2 body }
 }


问:
mapping structures in struct C
im trying to index number of struct under one struct.

im tying to pass the data in the first struct to the struct pointer but i get return null.

my code is :

```<code>struct complex{
char  * rNum;       /* real number */
char  *iNum;       /* imaginary number*/
};
 struct complex A = {"0","0"};
 struct complex B = {"0","0"};
 struct complex C = {"0","0"};
 struct complex D = {"0","0"};
 struct complex E = {"0","0"};
 struct complex F = {"0","0"};

struct mapping{
  char *key;
  struct complex *P;
 } complex_map [] = {
   { "A", &A },
   { "B", &B },
   { "C", &C },
   { "D", &D },
   { "E", &E },
   { "F", &F },
 };

 char call_complex(const char *name) {
  int i;

 for (i = 0; i < (sizeof(complex_map) / sizeof(complex_map[0])); i++) {
   if (!strcmp(complex_map[i].key, name) && complex_map[i].P->rNum) {
     complex_map[i].P->rNum;
     return 0;
   }
  }
  printf("Invalid\n");
 }
</code>```

and my call function is :

```<code>void read_comp(char *str){
printf(" %s",call_complex(str));
}
</code>```

when i run this code  i get return (null)

why?
thanks for helping

答:
Try This:

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

struct complex{
char  * rNum;       /* real number */
char  *iNum;       /* imaginary number*/
};
 struct complex A = {"1","0"};
 struct complex B = {"2","0"};
 struct complex C = {"3","0"};
 struct complex D = {"4","0"};
 struct complex E = {"5","0"};
 struct complex F = {"6","0"};

struct mapping{
  char *key;
  struct complex *P;
 } complex_map [] = {
   { "A", &A },
   { "B", &B },
   { "C", &C },
   { "D", &D },
   { "E", &E },
   { "F", &F },
 };

char call_complex(const char *name)
{
    int i;

    for (i = 0; i < (sizeof(complex_map) / sizeof(complex_map[0])); i++)
    {
        if (!strcmp(complex_map[i].key, name) && complex_map[i].P->rNum)
        {
            return *(complex_map[i].P->rNum); // Correction
        }
    }
    printf("Invalid\n");
}

int main()
{
    printf("Got: %c \n",call_complex("A")); // Just example
    return 0;
}
</code>```

Thanks.

Title: mapping structures in struct C

Body:
im trying to index number of struct under one struct.

im tying to pass the data in the first struct to the struct pointer but i get return null.

my code is :

struct complex{
char  * rNum;       /* real number */
char  *iNum;       /* imaginary number*/
};
 struct complex A = {"0","0"};
 struct complex B = {"0","0"};
 struct complex C = {"0","0"};
 struct complex D = {"0","0"};
 struct complex E = {"0","0"};
 struct complex F = {"0","0"};

struct mapping{
  char *key;
  struct complex *P;
 } complex_map [] = {
   { "A", &A },
   { "B", &B },
   { "C", &C },
   { "D", &D },
   { "E", &E },
   { "F", &F },
 };

 char call_complex(const char *name) {
  int i;

 for (i = 0; i < (sizeof(complex_map) / sizeof(complex_map[0])); i++) {
   if (!strcmp(complex_map[i].key, name) && complex_map[i].P->rNum) {
     complex_map[i].P->rNum;
     return 0;
   }
  }
  printf("Invalid\n");
 }

and my call function is :

void read_comp(char *str){
printf(" %s",call_complex(str));
}

when i run this code  i get return (null)

why?
thanks for helping

Body:
Try This:

#include <stdio.h>

struct complex{
char  * rNum;       /* real number */
char  *iNum;       /* imaginary number*/
};
 struct complex A = {"1","0"};
 struct complex B = {"2","0"};
 struct complex C = {"3","0"};
 struct complex D = {"4","0"};
 struct complex E = {"5","0"};
 struct complex F = {"6","0"};

struct mapping{
  char *key;
  struct complex *P;
 } complex_map [] = {
   { "A", &A },
   { "B", &B },
   { "C", &C },
   { "D", &D },
   { "E", &E },
   { "F", &F },
 };

char call_complex(const char *name)
{
    int i;

    for (i = 0; i < (sizeof(complex_map) / sizeof(complex_map[0])); i++)
    {
        if (!strcmp(complex_map[i].key, name) && complex_map[i].P->rNum)
        {
            return *(complex_map[i].P->rNum); // Correction
        }
    }
    printf("Invalid\n");
}

int main()
{
    printf("Got: %c \n",call_complex("A")); // Just example
    return 0;
}

Thanks.


问:
Wordpress and PHP
I have this code in my header.php for Wordpress to display a mini feed at the top of the page or not.

```<code><?php if ( !$noHeader ) { include('feed.php'); } ?>
</code>```

At the top of each page I set the $noHeader variable

```<code>$noHeader = true;
get_header();
</code>```

For some reason, this doesn't work. What am I doing wrong?

答:
Like Stephen said the get_header function doesn't give you access to variables in the scope you were in when you called it.  You can get around this by globalizing your variables before calling get_header.

```<code><?php // In your theme file
global $noheader;
$noheader = true;
get_header();

<?php
global $noheader;
if(!$noheader) {
    include(TEMPLATEPATH.'/feed.php');
}
</code>```

This may seem messy, and it is, but there's no reason not to do it because WordPress uses global variables all over the place.  As I said in a comment to Stephen, this is better than directly including the header.php file in case you ever want to use parent/child themes.

Title: Wordpress and PHP

Body:
I have this code in my header.php for Wordpress to display a mini feed at the top of the page or not.

<?php if ( !$noHeader ) { include('feed.php'); } ?>

At the top of each page I set the $noHeader variable

$noHeader = true;
get_header();

For some reason, this doesn't work. What am I doing wrong?

Body:
Like Stephen said the get_header function doesn't give you access to variables in the scope you were in when you called it.  You can get around this by globalizing your variables before calling get_header.

<?php // In your theme file
global $noheader;
$noheader = true;
get_header();

<?php
global $noheader;
if(!$noheader) {
    include(TEMPLATEPATH.'/feed.php');
}

This may seem messy, and it is, but there's no reason not to do it because WordPress uses global variables all over the place.  As I said in a comment to Stephen, this is better than directly including the header.php file in case you ever want to use parent/child themes.


问:
How to execute php script when auction completed and browser close
I have problem when timer of auction process is completed then one php script is executed at server.

Because i have problem is the after start auction it is not needed browser is opened.

I have not used cron job because i need execute php script exactly when timer will be completed.

I have also AWS server so please help if you have other way to execute php process at exact time in server automatically without help of browser.

答:
theres 3 standard way to do this
1. cron
2. daemon
3. user driven

this may help ya


问:
Convert individual json objects without delimiter to valid json file which can be processed at once
I have a JSON Lines format text file in which each line contains a valid JSON object. However,these JSON objects are not separated by a delimiter, so the file on a whole is not a valid JSON file.
I want to add a comma after each JSON object, so as to make the the whole file a valid JSON file, which can be processed at once using json.load().
I have written the following code to add a comma at the end of each line:

```<code>import json
import csv

testdata = open('resutdata.csv', 'wb')
csvwriter = csv.writer(testdata)

with open('data.json') as f:
    for line in f:
        csvwriter.writerow([json.loads(line), ','])
testdata.close()
</code>```

However, the csv file obtained adds a each line with quotes and a comma with quotes at the end. How do I solve my problem?

答:
As you need to convert json lines to json file, you can directly convert it into json file as follows:

```<code>import json

# Contains the output json file
resultfile = open('resultdata.json', 'wt')

data = []
with open('data.json') as f:
    for line in f:
        data.append(json.loads(line))

resultfile.write(json.dumps(data))
resultfile.close()
</code>```

Body:
I have a JSON Lines format text file in which each line contains a valid JSON object. However,these JSON objects are not separated by a delimiter, so the file on a whole is not a valid JSON file.
I want to add a comma after each JSON object, so as to make the the whole file a valid JSON file, which can be processed at once using json.load().
I have written the following code to add a comma at the end of each line:

import json
import csv

testdata = open('resutdata.csv', 'wb')
csvwriter = csv.writer(testdata)

with open('data.json') as f:
    for line in f:
        csvwriter.writerow([json.loads(line), ','])
testdata.close()

However, the csv file obtained adds a each line with quotes and a comma with quotes at the end. How do I solve my problem?

Body:
As you need to convert json lines to json file, you can directly convert it into json file as follows:

import json

# Contains the output json file
resultfile = open('resultdata.json', 'wt')

data = []
with open('data.json') as f:
    for line in f:
        data.append(json.loads(line))

resultfile.write(json.dumps(data))
resultfile.close()


问:
Android custom edittext with line design like in notepad
I am trying to make a custom edittext with lines like in a note pad. The biggest issue ive met that it breaks the line and doesn't draw it properly.

```<code>    public class NoteEditText extends EditText {
        private final int heightpixels;
        private Paint mPaint;
        private Rect mRect;
        private Canvas canvas;

        public NoteEditText(Context context, AttributeSet attrs) {
            super(context, attrs);
            TypedArray a = context.getTheme().obtainStyledAttributes(
                    attrs,
                    R.styleable.NoteEditText,
                    0, 0);

            this.heightpixels = getContext().getResources().getDisplayMetrics().heightPixels;
            this.mRect = new Rect();
            this.mPaint = new Paint();
            this.mPaint.setStyle(Paint.Style.STROKE);
            try {
                mPaint.setColor(Color.parseColor(a.getString(R.styleable.NoteEditText_lineColor)));
            } catch (NullPointerException e) {
                mPaint.setColor(Color.parseColor("#ffffff"));
            }
        }

        public NoteEditText(Context context) {
            super(context);
            this.heightpixels = getContext().getResources().getDisplayMetrics().heightPixels;
            this.mRect = new Rect();
            this.mPaint = new Paint();
            this.mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setColor(Color.parseColor("#ffffff"));
        }

        protected void onDraw(Canvas canvas) {
            int count;
            this.canvas = canvas;
            int lineheight = getLineHeight();
            if (TextUtils.isEmpty(getText())) {
                count = (this.heightpixels / lineheight) + 2;
            } else {
                count = getLineCount();
            }
            Rect r = this.mRect;
            Paint paint = this.mPaint;
            int baseline = getLineBounds(0, r);
            for (int i = 0; i < count; i++) {
                canvas.drawLine((float) r.left, (float) (baseline + 1), (float) r.right, (float) (baseline + 1), paint);
                baseline += lineheight;
            }
            super.onDraw(canvas);
        }

    @Override
    protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
        super.onTextChanged(text, start, lengthBefore, lengthAfter);
    }

    @Override
    public void onDrawForeground(Canvas canvas) {
        super.onDrawForeground(canvas);
    }
}
</code>```

This often happens when you try to add text in new lines and try to delete.
example

Here is XML also

```<code><com.example.dev.customedittext.NoteEditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@null"
    android:ems="10"
    android:gravity="top"
    android:textColor="@android:color/black"
    android:textColorHint="#AAAAAA"
    android:textSize="12sp"
    app:lineColor="#000000"
    />
</code>```

Are there any suggestions how to fix this issue ?

答:
Use this:

```<code><com.testing.remon.LineEditText
android:id="@+id/edit1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="@null"
android:inputType="textMultiLine|textNoSuggestions"
android:minLines="10"
android:singleLine="false"
android:imeOptions="actionNone"
/>
</code>```

Below is custom EditText Class.

```<code>import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;

public class LinedEditText extends EditText {
    private Rect mRect;
    private Paint mPaint;

    // we need this constructor for LayoutInflater
    public LinedEditText(Context context, AttributeSet attrs) {
        super(context, attrs);

        mRect = new Rect();
        mPaint = new Paint();
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(0x800000FF);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int height = getHeight();
        int line_height = getLineHeight();

        int count = height / line_height;

        if (getLineCount() > count)
            count = getLineCount();

        Rect r = mRect;
        Paint paint = mPaint;
        int baseline = getLineBounds(0, r);

        for (int i = 0; i < count; i++) {

            canvas.drawLine(r.left, baseline + 2, r.right, baseline + 2, paint);
            baseline += getLineHeight();
        }
        super.onDraw(canvas);

    }

}
</code>```

Body:
I am trying to make a custom edittext with lines like in a note pad. The biggest issue ive met that it breaks the line and doesn't draw it properly.

    public class NoteEditText extends EditText {
        private final int heightpixels;
        private Paint mPaint;
        private Rect mRect;
        private Canvas canvas;

        public NoteEditText(Context context, AttributeSet attrs) {
            super(context, attrs);
            TypedArray a = context.getTheme().obtainStyledAttributes(
                    attrs,
                    R.styleable.NoteEditText,
                    0, 0);

            this.heightpixels = getContext().getResources().getDisplayMetrics().heightPixels;
            this.mRect = new Rect();
            this.mPaint = new Paint();
            this.mPaint.setStyle(Paint.Style.STROKE);
            try {
                mPaint.setColor(Color.parseColor(a.getString(R.styleable.NoteEditText_lineColor)));
            } catch (NullPointerException e) {
                mPaint.setColor(Color.parseColor("#ffffff"));
            }
        }

        public NoteEditText(Context context) {
            super(context);
            this.heightpixels = getContext().getResources().getDisplayMetrics().heightPixels;
            this.mRect = new Rect();
            this.mPaint = new Paint();
            this.mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setColor(Color.parseColor("#ffffff"));
        }

        protected void onDraw(Canvas canvas) {
            int count;
            this.canvas = canvas;
            int lineheight = getLineHeight();
            if (TextUtils.isEmpty(getText())) {
                count = (this.heightpixels / lineheight) + 2;
            } else {
                count = getLineCount();
            }
            Rect r = this.mRect;
            Paint paint = this.mPaint;
            int baseline = getLineBounds(0, r);
            for (int i = 0; i < count; i++) {
                canvas.drawLine((float) r.left, (float) (baseline + 1), (float) r.right, (float) (baseline + 1), paint);
                baseline += lineheight;
            }
            super.onDraw(canvas);
        }

    @Override
    protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
        super.onTextChanged(text, start, lengthBefore, lengthAfter);
    }

    @Override
    public void onDrawForeground(Canvas canvas) {
        super.onDrawForeground(canvas);
    }
}

This often happens when you try to add text in new lines and try to delete.
example

Here is XML also

<com.example.dev.customedittext.NoteEditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@null"
    android:ems="10"
    android:gravity="top"
    android:textColor="@android:color/black"
    android:textColorHint="#AAAAAA"
    android:textSize="12sp"
    app:lineColor="#000000"
    />

Are there any suggestions how to fix this issue ?

Body:
Use this:

<com.testing.remon.LineEditText
android:id="@+id/edit1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="@null"
android:inputType="textMultiLine|textNoSuggestions"
android:minLines="10"
android:singleLine="false"
android:imeOptions="actionNone"
/>

Below is custom EditText Class.

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;

public class LinedEditText extends EditText {
    private Rect mRect;
    private Paint mPaint;

    // we need this constructor for LayoutInflater
    public LinedEditText(Context context, AttributeSet attrs) {
        super(context, attrs);

        mRect = new Rect();
        mPaint = new Paint();
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(0x800000FF);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int height = getHeight();
        int line_height = getLineHeight();

        int count = height / line_height;

        if (getLineCount() > count)
            count = getLineCount();

        Rect r = mRect;
        Paint paint = mPaint;
        int baseline = getLineBounds(0, r);

        for (int i = 0; i < count; i++) {

            canvas.drawLine(r.left, baseline + 2, r.right, baseline + 2, paint);
            baseline += getLineHeight();
        }
        super.onDraw(canvas);

    }

}

ContentLicense: CC BY-SA 4.0


问:
use jquery in angular js function is not working?
I am trying to just write jquery inside angularjs function.but don't know why it is not working?

HTML

```<code><div>
   <span ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon= false" ng-mouseover="image.showDeleteIcon=true" ng-mouseleave="image.showDeleteIcon=false">
   <span ng-if="$index == 3" ng-init="setImgCounter(post.postImages.length,$parent.$index+''+$index)"></span>
   <a id="{{$parent.$index}}{{$index}}" onclick="SetDataGallery(this.id)" ng-href="../upload/post-photos/{{image.attachmentURL}}">
   <img class="img-responsive feed-photo" ng-src="../upload/post-photos/{{image.attachmentURL}}" alt="Photo" style="display:inline;">
   <a href="#" class="imgDelete" ng-if="post.timelineStrore.hasControl" ng-show="image.showDeleteIcon" title="Delete Photo" ng-click="DeletePostAttachment(post.timelineStrore.id, image.postAttachmentId,'image')">
   <i class="fa fa-close"></i>
   </a>
   </a>
   </span>
</div>
</code>```

JS

```<code>$scope.setImgCounter = function (counter,id)
{
    $("#" + id + " img:first-child").css("opacity", "0.5");
}
</code>```

but its not working?

I also tried using =>

```<code>.att('style','opacity:0.5');
</code>```

答:
If there is possibility with angular then don't use JQuery

Do this instead and make sure document.querySelectorAll("#" + id + " img:first-child") this is getting correct element

```<code>$scope.setImgCounter = function (counter,id)
{
    angular.element(document.querySelectorAll("#" + id + " img:first-child")).css("opacity", "0.5");
}
</code>```

Body:
I am trying to just write jquery inside angularjs function.but don't know why it is not working?

HTML

   <span ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon= false" ng-mouseover="image.showDeleteIcon=true" ng-mouseleave="image.showDeleteIcon=false">

JS

$scope.setImgCounter = function (counter,id)
{
    $("#" + id + " img:first-child").css("opacity", "0.5");
}

but its not working?

I also tried using =>

.att('style','opacity:0.5');

Body:
If there is possibility with angular then don't use JQuery

Do this instead and make sure document.querySelectorAll("#" + id + " img:first-child") this is getting correct element

$scope.setImgCounter = function (counter,id)
{
    angular.element(document.querySelectorAll("#" + id + " img:first-child")).css("opacity", "0.5");
}


问:
Does it matter after running "configure" and find a lot of missing dependencies when I build OpenJDK9 on Ubuntu?
System:

```<code>Distributor ID: Ubuntu
Description:    Ubuntu 16.10
Release:    16.10
</code>```

JDK and JRE:

```<code>There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      auto mode
* 1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  2            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode
</code>```

Do I have to install all the dependencies that shows "no"?

```<code>username:~/sandboxJDK/jdk9$bash ./configure
Running generated-configure.sh
configure: Configuration created at Thu Jun  8 23:03:30 CDT 2017.
configure: configure script generated at timestamp 1494858828.
checking for basename... /usr/bin/basename
checking for bash... /bin/bash
checking for cat... /bin/cat
checking for chmod... /bin/chmod
checking for cmp... /usr/bin/cmp
checking for comm... /usr/bin/comm
checking for cp... /bin/cp
checking for cut... /usr/bin/cut
checking for date... /bin/date
checking for gdiff... no
checking for diff... /usr/bin/diff
checking for dirname... /usr/bin/dirname
checking for echo... /bin/echo
checking for expr... /usr/bin/expr
checking for file... /usr/bin/file
checking for find... /usr/bin/find
checking for head... /usr/bin/head
checking for gunzip... /bin/gunzip
checking for pigz... no
checking for gzip... /bin/gzip
checking for ln... /bin/ln
checking for ls... /bin/ls
checking for mkdir... /bin/mkdir
checking for mktemp... /bin/mktemp
checking for mv... /bin/mv
checking for nawk... /usr/bin/nawk
checking for printf... /usr/bin/printf
checking for rm... /bin/rm
checking for rmdir... /bin/rmdir
checking for sh... /bin/sh
checking for sort... /usr/bin/sort
checking for tail... /usr/bin/tail
checking for gtar... no
checking for tar... /bin/tar
checking for tee... /usr/bin/tee
checking for touch... /usr/bin/touch
checking for tr... /usr/bin/tr
checking for uname... /bin/uname
checking for uniq... /usr/bin/uniq
checking for wc... /usr/bin/wc
checking for which... /usr/bin/which
checking for xargs... /usr/bin/xargs
checking for gawk... gawk
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for a sed that does not truncate output... /bin/sed
checking for cygpath... no
checking for greadlink... no
checking for readlink... /bin/readlink
checking for df... /bin/df
checking for cpio... /bin/cpio
checking for nice... /usr/bin/nice
checking for pandoc... no
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking openjdk-build os-cpu... linux-x86_64
checking openjdk-target os-cpu... linux-x86_64
checking compilation type... native
checking for top-level directory... /home/xfwu/sandboxJDK/jdk9
checking if custom source is suppressed (openjdk-only)... no
checking which variant of the JDK to build... normal
checking which debug level to use... release
checking which variants of the JVM to build... server
checking for sysroot...
checking for toolchain path...
checking for extra path...
checking where to store configuration... in default location
checking what configuration name to use... linux-x86_64-normal-server-release
checking for apt-get... apt-get
checking for gmake... no
checking for make... /usr/bin/make
configure: Testing potential make at /usr/bin/make, found using make in PATH
configure: Using GNU make at /usr/bin/make (version: GNU Make 4.1)
checking if make --output-sync is supported... yes
checking for output-sync value... none
checking if find supports -delete... yes
checking what type of tar was found... gnu
checking that grep (/bin/grep) -Fx handles empty lines in the pattern list correctly... yes
checking for unzip... /usr/bin/unzip
checking for zip... /usr/bin/zip
checking for ldd... /usr/bin/ldd
checking for otool... no
checking for greadelf... no
checking for readelf... /usr/bin/readelf
checking for dot... no
checking for hg... /usr/bin/hg
checking for stat... /usr/bin/stat
checking for time... /usr/bin/time
checking for dtrace... no
checking for gpatch... no
checking for patch... /usr/bin/patch
checking bash version... 4.3.48
checking if bash supports pipefail... yes
checking if bash supports errexit (-e)... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking headless only... no
checking for graphviz dot... no, cannot generate full docs
checking for pandoc... no, cannot generate full docs
checking full docs... no, missing dependencies
checking if packaged modules are kept... yes (default)
checking for version string... 9-internal+0-adhoc.xfwu.jdk9
configure: Found potential Boot JDK using JAVA_HOME
checking for Boot JDK... /usr/lib/jvm/java-8-openjdk-amd64
checking Boot JDK version... openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.10.2-b11) OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
checking for java in Boot JDK... ok
checking for javac in Boot JDK... ok
checking for javah in Boot JDK... ok
checking for jar in Boot JDK... ok
checking for jarsigner in Boot JDK... ok
checking if Boot JDK supports modules... no
checking if Boot JDK is 32 or 64 bits... 64
checking for Build JDK... yes, will use output dir
configure: Using default toolchain gcc (GNU Compiler Collection)
checking for gcc... /usr/bin/gcc
checking resolved symbolic links for CC... /usr/bin/x86_64-linux-gnu-gcc-6
configure: Using gcc C compiler version 6.2.0 [gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005]
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking for g++... /usr/bin/g++
checking resolved symbolic links for CXX... /usr/bin/x86_64-linux-gnu-g++-6
configure: Using gcc C++ compiler version 6.2.0 [g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005]
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/g++ accepts -g... yes
checking how to run the C preprocessor... /usr/bin/gcc -E
checking how to run the C++ preprocessor... /usr/bin/g++ -E
checking for ar... ar
configure: Rewriting AR to "/usr/bin/ar"
checking for strip... strip
configure: Rewriting STRIP to "/usr/bin/strip"
checking for nm... nm
configure: Rewriting NM to "/usr/bin/nm"
checking for gobjcopy... no
checking for objcopy... objcopy
configure: Rewriting OBJCOPY to "/usr/bin/objcopy"
checking for gobjdump... no
checking for objdump... objdump
configure: Rewriting OBJDUMP to "/usr/bin/objdump"
checking if the C compiler supports "-Og"... yes
checking if the C++ compiler supports "-Og"... yes
checking if both compilers support "-Og"... yes
checking if linker supports "-Wl,-z,relro"... yes
checking if linker supports "-Wl,-z,now"... yes
checking for broken SuSE 'ld' which only understands anonymous version tags in executables... no
checking for jtreg... no
checking for jtreg test harness... no, not found
checking if @file is supported by gcc... yes
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking size of int *... 8
checking for target address size... 64 bits
checking whether byte ordering is bigendian... no
checking if the C++ compiler supports "-std=gnu++98 -Werror"... yes
configure: GCC >= 6 detected; adding -fno-delete-null-pointer-checks and -fno-lifetime-dse
checking if the C++ compiler supports "-std=gnu++98 -Werror"... yes
configure: GCC >= 6 detected; adding -fno-delete-null-pointer-checks and -fno-lifetime-dse
checking if the C compiler supports "-m64"... yes
checking if the C++ compiler supports "-m64"... yes
checking if both compilers support "-m64"... yes
checking if native warnings are errors... yes (default)
checking if the C compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if the C++ compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if both compilers support "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if the C compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if the C++ compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if both compilers support "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking what type of native debug symbols to use... zipped
checking for dtrace tool... not found, cannot build dtrace
checking sys/sdt.h usability... no
checking sys/sdt.h presence... no
checking for sys/sdt.h... no
checking if dtrace should be built... no, missing dependencies
checking if Hotspot gtest unit tests should be built... yes
checking if static link of stdc++ is possible... yes
checking how to link with libstdc++... static
checking for X... libraries , headers
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for X11/extensions/shape.h... yes
checking for X11/extensions/Xrender.h... yes
checking for X11/extensions/XTest.h... yes
checking for X11/Intrinsic.h... yes
checking if XlinearGradient is defined in Xrender.h... yes
checking cups/cups.h usability... yes
checking cups/cups.h presence... yes
checking for cups/cups.h... yes
checking cups/ppd.h usability... yes
checking cups/ppd.h presence... yes
checking for cups/ppd.h... yes
checking for FREETYPE... yes
checking for freetype... yes (using pkg-config)
checking if we can compile and link with freetype... yes
checking if we should bundle freetype... no
checking for ALSA... yes
checking for which libjpeg to use... bundled
checking for which giflib to use... bundled
checking for which libpng to use... bundled
checking for compress in -lz... yes
checking for which zlib to use... system
checking for which lcms to use... bundled
checking for cos in -lm... yes
checking for dlopen in -ldl... yes
checking for ELF... yes
checking if libelf works... yes
checking if jdk.internal.vm.compiler should be built... yes
checking if aot should be enabled... yes
checking if elliptic curve crypto implementation is present... yes
checking if jtreg failure handler should be built... no, missing jtreg
checking if the CDS classlist generation should be enabled... yes
checking for number of cores... 64
checking for memory size... 128694 MB
checking for appropriate number of jobs to run in parallel... 64
checking flags for boot jdk java command ...  -Duser.language=en -Duser.country=US
checking flags for boot jdk java command for big workloads...  -Xms64M -Xmx1600M -XX:ThreadStackSize=1536
checking flags for bootcycle boot jdk java command for big workloads... -Xms64M -Xmx1600M -XX:ThreadStackSize=1536
checking flags for boot jdk java command for small workloads...  -XX:+UseSerialGC -Xms32M -Xmx512M -XX:TieredStopAtLevel=1
checking whether to use sjavac... no
checking whether to use javac server... yes
checking If precompiled header is enabled... yes
checking that precompiled headers work... yes
checking is ccache enabled... no
checking if build directory is on local disk... yes
checking JVM features for JVM variant 'server'... all-gcs aot cds compiler1 compiler2 fprof graal jni-check jvmci jvmti management nmt services vm-structs
configure: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/configure-support/config.status
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/spec.gmk
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/bootcycle-spec.gmk
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/buildjdk-spec.gmk
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/compare.sh
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/Makefile

====================================================
The existing configuration has been successfully updated in
/home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release
using default settings.

Configuration summary:
* Debug level:    release
* HS debug level: product
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64
* Version string: 9-internal+0-adhoc.xfwu.jdk9 (9-internal)

Tools summary:
* Boot JDK:       openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.10.2-b11) OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)  (at /usr/lib/jvm/java-8-openjdk-amd64)
* Toolchain:      gcc (GNU Compiler Collection)
* C Compiler:     Version 6.2.0 (at /usr/bin/gcc)
* C++ Compiler:   Version 6.2.0 (at /usr/bin/g++)

Build performance summary:
* Cores to use:   64
* Memory limit:   128694 MB

WARNING: The result of this configuration has overridden an older
configuration. You *should* run 'make clean' to make sure you get a
proper build. Failure to do so might result in strange build problems.
</code>```

README-builds.html

In the official file, the suggested for Linux are

Install all the software development packages needed including alsa,
  freetype, cups, and xrender. See specific system packages.

答:
No, you don't need to install these, unless you get a clear error message.

The configurescript adapts the build to the concrete UNIX variant you are building on. For example if a library function is not natively available, it will compile in a replacement.

Body:
System:

Distributor ID: Ubuntu
Description:    Ubuntu 16.10
Release:    16.10

JDK and JRE:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      auto mode
* 1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  2            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode

Do I have to install all the dependencies that shows "no"?

username:~/sandboxJDK/jdk9$bash ./configure
Running generated-configure.sh
configure: Configuration created at Thu Jun  8 23:03:30 CDT 2017.
configure: configure script generated at timestamp 1494858828.
checking for basename... /usr/bin/basename
checking for bash... /bin/bash
checking for cat... /bin/cat
checking for chmod... /bin/chmod
checking for cmp... /usr/bin/cmp
checking for comm... /usr/bin/comm
checking for cp... /bin/cp
checking for cut... /usr/bin/cut
checking for date... /bin/date
checking for gdiff... no
checking for diff... /usr/bin/diff
checking for dirname... /usr/bin/dirname
checking for echo... /bin/echo
checking for expr... /usr/bin/expr
checking for file... /usr/bin/file
checking for find... /usr/bin/find
checking for head... /usr/bin/head
checking for gunzip... /bin/gunzip
checking for pigz... no
checking for gzip... /bin/gzip
checking for ln... /bin/ln
checking for ls... /bin/ls
checking for mkdir... /bin/mkdir
checking for mktemp... /bin/mktemp
checking for mv... /bin/mv
checking for nawk... /usr/bin/nawk
checking for printf... /usr/bin/printf
checking for rm... /bin/rm
checking for rmdir... /bin/rmdir
checking for sh... /bin/sh
checking for sort... /usr/bin/sort
checking for tail... /usr/bin/tail
checking for gtar... no
checking for tar... /bin/tar
checking for tee... /usr/bin/tee
checking for touch... /usr/bin/touch
checking for tr... /usr/bin/tr
checking for uname... /bin/uname
checking for uniq... /usr/bin/uniq
checking for wc... /usr/bin/wc
checking for which... /usr/bin/which
checking for xargs... /usr/bin/xargs
checking for gawk... gawk
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for a sed that does not truncate output... /bin/sed
checking for cygpath... no
checking for greadlink... no
checking for readlink... /bin/readlink
checking for df... /bin/df
checking for cpio... /bin/cpio
checking for nice... /usr/bin/nice
checking for pandoc... no
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking openjdk-build os-cpu... linux-x86_64
checking openjdk-target os-cpu... linux-x86_64
checking compilation type... native
checking for top-level directory... /home/xfwu/sandboxJDK/jdk9
checking if custom source is suppressed (openjdk-only)... no
checking which variant of the JDK to build... normal
checking which debug level to use... release
checking which variants of the JVM to build... server
checking for sysroot...
checking for toolchain path...
checking for extra path...
checking where to store configuration... in default location
checking what configuration name to use... linux-x86_64-normal-server-release
checking for apt-get... apt-get
checking for gmake... no
checking for make... /usr/bin/make
configure: Testing potential make at /usr/bin/make, found using make in PATH
configure: Using GNU make at /usr/bin/make (version: GNU Make 4.1)
checking if make --output-sync is supported... yes
checking for output-sync value... none
checking if find supports -delete... yes
checking what type of tar was found... gnu
checking that grep (/bin/grep) -Fx handles empty lines in the pattern list correctly... yes
checking for unzip... /usr/bin/unzip
checking for zip... /usr/bin/zip
checking for ldd... /usr/bin/ldd
checking for otool... no
checking for greadelf... no
checking for readelf... /usr/bin/readelf
checking for dot... no
checking for hg... /usr/bin/hg
checking for stat... /usr/bin/stat
checking for time... /usr/bin/time
checking for dtrace... no
checking for gpatch... no
checking for patch... /usr/bin/patch
checking bash version... 4.3.48
checking if bash supports pipefail... yes
checking if bash supports errexit (-e)... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking headless only... no
checking for graphviz dot... no, cannot generate full docs
checking for pandoc... no, cannot generate full docs
checking full docs... no, missing dependencies
checking if packaged modules are kept... yes (default)
checking for version string... 9-internal+0-adhoc.xfwu.jdk9
configure: Found potential Boot JDK using JAVA_HOME
checking for Boot JDK... /usr/lib/jvm/java-8-openjdk-amd64
checking Boot JDK version... openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.10.2-b11) OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
checking for java in Boot JDK... ok
checking for javac in Boot JDK... ok
checking for javah in Boot JDK... ok
checking for jar in Boot JDK... ok
checking for jarsigner in Boot JDK... ok
checking if Boot JDK supports modules... no
checking if Boot JDK is 32 or 64 bits... 64
checking for Build JDK... yes, will use output dir
configure: Using default toolchain gcc (GNU Compiler Collection)
checking for gcc... /usr/bin/gcc
checking resolved symbolic links for CC... /usr/bin/x86_64-linux-gnu-gcc-6
configure: Using gcc C compiler version 6.2.0 [gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005]
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking for g++... /usr/bin/g++
checking resolved symbolic links for CXX... /usr/bin/x86_64-linux-gnu-g++-6
configure: Using gcc C++ compiler version 6.2.0 [g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005]
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/g++ accepts -g... yes
checking how to run the C preprocessor... /usr/bin/gcc -E
checking how to run the C++ preprocessor... /usr/bin/g++ -E
checking for ar... ar
configure: Rewriting AR to "/usr/bin/ar"
checking for strip... strip
configure: Rewriting STRIP to "/usr/bin/strip"
checking for nm... nm
configure: Rewriting NM to "/usr/bin/nm"
checking for gobjcopy... no
checking for objcopy... objcopy
configure: Rewriting OBJCOPY to "/usr/bin/objcopy"
checking for gobjdump... no
checking for objdump... objdump
configure: Rewriting OBJDUMP to "/usr/bin/objdump"
checking if the C compiler supports "-Og"... yes
checking if the C++ compiler supports "-Og"... yes
checking if both compilers support "-Og"... yes
checking if linker supports "-Wl,-z,relro"... yes
checking if linker supports "-Wl,-z,now"... yes
checking for broken SuSE 'ld' which only understands anonymous version tags in executables... no
checking for jtreg... no
checking for jtreg test harness... no, not found
checking if @file is supported by gcc... yes
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking size of int *... 8
checking for target address size... 64 bits
checking whether byte ordering is bigendian... no
checking if the C++ compiler supports "-std=gnu++98 -Werror"... yes
configure: GCC >= 6 detected; adding -fno-delete-null-pointer-checks and -fno-lifetime-dse
checking if the C++ compiler supports "-std=gnu++98 -Werror"... yes
configure: GCC >= 6 detected; adding -fno-delete-null-pointer-checks and -fno-lifetime-dse
checking if the C compiler supports "-m64"... yes
checking if the C++ compiler supports "-m64"... yes
checking if both compilers support "-m64"... yes
checking if native warnings are errors... yes (default)
checking if the C compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if the C++ compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if both compilers support "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if the C compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if the C++ compiler supports "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking if both compilers support "-Wno-this-is-a-warning-that-do-not-exist"... yes
checking what type of native debug symbols to use... zipped
checking for dtrace tool... not found, cannot build dtrace
checking sys/sdt.h usability... no
checking sys/sdt.h presence... no
checking for sys/sdt.h... no
checking if dtrace should be built... no, missing dependencies
checking if Hotspot gtest unit tests should be built... yes
checking if static link of stdc++ is possible... yes
checking how to link with libstdc++... static
checking for X... libraries , headers
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for X11/extensions/shape.h... yes
checking for X11/extensions/Xrender.h... yes
checking for X11/extensions/XTest.h... yes
checking for X11/Intrinsic.h... yes
checking if XlinearGradient is defined in Xrender.h... yes
checking cups/cups.h usability... yes
checking cups/cups.h presence... yes
checking for cups/cups.h... yes
checking cups/ppd.h usability... yes
checking cups/ppd.h presence... yes
checking for cups/ppd.h... yes
checking for FREETYPE... yes
checking for freetype... yes (using pkg-config)
checking if we can compile and link with freetype... yes
checking if we should bundle freetype... no
checking for ALSA... yes
checking for which libjpeg to use... bundled
checking for which giflib to use... bundled
checking for which libpng to use... bundled
checking for compress in -lz... yes
checking for which zlib to use... system
checking for which lcms to use... bundled
checking for cos in -lm... yes
checking for dlopen in -ldl... yes
checking for ELF... yes
checking if libelf works... yes
checking if jdk.internal.vm.compiler should be built... yes
checking if aot should be enabled... yes
checking if elliptic curve crypto implementation is present... yes
checking if jtreg failure handler should be built... no, missing jtreg
checking if the CDS classlist generation should be enabled... yes
checking for number of cores... 64
checking for memory size... 128694 MB
checking for appropriate number of jobs to run in parallel... 64
checking flags for boot jdk java command ...  -Duser.language=en -Duser.country=US
checking flags for boot jdk java command for big workloads...  -Xms64M -Xmx1600M -XX:ThreadStackSize=1536
checking flags for bootcycle boot jdk java command for big workloads... -Xms64M -Xmx1600M -XX:ThreadStackSize=1536
checking flags for boot jdk java command for small workloads...  -XX:+UseSerialGC -Xms32M -Xmx512M -XX:TieredStopAtLevel=1
checking whether to use sjavac... no
checking whether to use javac server... yes
checking If precompiled header is enabled... yes
checking that precompiled headers work... yes
checking is ccache enabled... no
checking if build directory is on local disk... yes
checking JVM features for JVM variant 'server'... all-gcs aot cds compiler1 compiler2 fprof graal jni-check jvmci jvmti management nmt services vm-structs
configure: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/configure-support/config.status
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/spec.gmk
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/bootcycle-spec.gmk
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/buildjdk-spec.gmk
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/compare.sh
config.status: creating /home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release/Makefile

====================================================
The existing configuration has been successfully updated in
/home/xfwu/sandboxJDK/jdk9/build/linux-x86_64-normal-server-release
using default settings.

Configuration summary:
* Debug level:    release
* HS debug level: product
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64
* Version string: 9-internal+0-adhoc.xfwu.jdk9 (9-internal)

Tools summary:
* Boot JDK:       openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.10.2-b11) OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)  (at /usr/lib/jvm/java-8-openjdk-amd64)
* Toolchain:      gcc (GNU Compiler Collection)
* C Compiler:     Version 6.2.0 (at /usr/bin/gcc)
* C++ Compiler:   Version 6.2.0 (at /usr/bin/g++)

Build performance summary:
* Cores to use:   64
* Memory limit:   128694 MB

WARNING: The result of this configuration has overridden an older
configuration. You *should* run 'make clean' to make sure you get a
proper build. Failure to do so might result in strange build problems.

README-builds.html

In the official file, the suggested for Linux are

Install all the software development packages needed including alsa,
  freetype, cups, and xrender. See specific system packages.


问:
set size of div which contains svg text element
```<code><div id="maindiv" style="height:60px;width:100px;border:1px solid black;float:left">
    <svg width="100%" height="20">
    <text x="28" y="18" style="text-anchor: start">somedynamictext</text>
    </svg>
</div>
</code>```

I want to set width of maindiv so that it can properly contain somedynamictext.
Number of somedynamictext can be dynamic.

Can I show ... in svg text element?

As per comments I did following

```<code><div id="maindiv" style="height:60px;display:inline-block;border:1px solid black">
    <div id="MATCH" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">MATCH</text>
        </svg>
    </div>
    <div id="REGULAR" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">REGULAR</text>
        </svg>
    </div>
    <div id="EXPRESSION" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">EXPRESSION</text>
        </svg>
    </div>
    <div id="MATCH1" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">MATCH1</text>
        </svg>
    </div>
    <div id="REGULAR1" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">REGULAR1</text>
        </svg>
    </div>
    <div id="EXPRESSION1" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">EXPRESSION1</text>
        </svg>
    </div>
    <div id="MATCH2" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">MATCH2</text>
        </svg>
    </div>
    <div id="REGULAR2" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">REGULAR2</text>
        </svg>
    </div>
    <div id="EXPRESSION2" style="height:60px;display:inline-block;border:1px solid black;float:left">
        <svg width="100%" height="20">
            <text x="28" y="18">EXPRESSION2</text>
        </svg>
    </div>
</div>
</code>```

I cannt reduce size of divs based on text length.

答:
you can get the height and width of each svg element by using

```<code>var svgCoord=svg.getBoundingClientRect();
var svgHeight=svgCoord.height;
</code>```

then set the height of all svg element by to maindiv.

document.getElementById("maindiv").setAttribute("height","sum of heights of all svg");

Body:
    <svg width="100%" height="20">
    <text x="28" y="18" style="text-anchor: start">somedynamictext</text>
    </svg>

I want to set width of maindiv so that it can properly contain somedynamictext.
Number of somedynamictext can be dynamic.

Can I show ... in svg text element?

As per comments I did following

        <svg width="100%" height="20">
            <text x="28" y="18">MATCH</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">REGULAR</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">EXPRESSION</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">MATCH1</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">REGULAR1</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">EXPRESSION1</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">MATCH2</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">REGULAR2</text>
        </svg>

        <svg width="100%" height="20">
            <text x="28" y="18">EXPRESSION2</text>
        </svg>

I cannt reduce size of divs based on text length.

Body:
you can get the height and width of each svg element by using

var svgCoord=svg.getBoundingClientRect();
var svgHeight=svgCoord.height;

then set the height of all svg element by to maindiv.

document.getElementById("maindiv").setAttribute("height","sum of heights of all svg");


问:
Django downloading a csv file with variable in name
I am trying to write some code to allow a user to download a .csv file with the results bases on their search when they press a download button. I would like to include the date in the default name of the csv file but can't get it to work. The relevant code in views.py is:

```<code>now = datetime.datetime.now()
date = str(now.year)+'-'+str(now.month)+'-'+str(now.day)

response = HttpResponse(content_type='csv')
response['Content-Disposition'] = 'attachment; filename="results"+str(date)+".csv"'
</code>```

This returns a default filename 'results_+str(date)+_.csv'.

答:
You messed up your ' and ":

```<code>response['Content-Disposition'] = 'attachment; filename="results'+str(date)+'.csv"'
</code>```

This will work. I would suggest this though:

```<code>response['Content-Disposition'] = 'attachment; filename="results{}.csv"'.format(str(date))
</code>```

Also consider using strftime.

Body:
I am trying to write some code to allow a user to download a .csv file with the results bases on their search when they press a download button. I would like to include the date in the default name of the csv file but can't get it to work. The relevant code in views.py is:

now = datetime.datetime.now()
date = str(now.year)+'-'+str(now.month)+'-'+str(now.day)

response = HttpResponse(content_type='csv')
response['Content-Disposition'] = 'attachment; filename="results"+str(date)+".csv"'

This returns a default filename 'results_+str(date)+_.csv'.

Body:
You messed up your ' and ":

response['Content-Disposition'] = 'attachment; filename="results'+str(date)+'.csv"'

This will work. I would suggest this though:

response['Content-Disposition'] = 'attachment; filename="results{}.csv"'.format(str(date))

Also consider using strftime.


问:
Why am I not able to add click event to dynamically inserted element of a list?
I have code shown below for a project where I insert list elements using javascript and for click on each element I have to call a function. However, it does not seem to work.

var c = document.getElementById("content");

c.innerHTML += "
";

for(var j = 0; j<5; j++){

    c.innerHTML += "
some stuff"+j+"
";

    document.getElementById(j).addEventListener("click", function(){ alert('this is test'); }, false);

}
c.innerHTML += "
";```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id = "content"> </div></code>```

Why is the click event not being triggered? How can I make this work?

答:
The reason the OP doesn't work is because of this:

```<code>c.innerHTML += "<li id = '" + j +  "'>some stuff"+j+"</li>";
</code>```

When you concatenate to the innHTML property like that, the element content is first serialised, which removes any listeners that aren't inline (e.g. those added by addEventListener). So the only one remaining at the end of the loop is the last one.

But then you do:

```<code>c.innerHTML += "</ul>";
</code>```

which removes the last one too.

Far better to build a single string of markup and use innerHTML once.

Consider: what should the browser do with the opening UL tag until the closing tag is entered? You've added invalid markup to the document, so it has to use error correction to make something work, so you might end up with a structure that isn't what you expected.

For the listeners, you can include them in-line with the rest of the markup so they survive being serialised and parsed.

Alternatively, use DOM methods to create the elements and stop using innerHTML.

function doClick(){
  alert('this is a test ' + this.id);
}

window.onload = function() {
  var c = document.getElementById("content");
  var list = document.createElement('ul');

  for(var j = 0; j<5; j++){
    var li = list.appendChild(document.createElement('li'));
    li.textContent = 'some stuff ' + j;
    li.id = j;
    li.addEventListener('click', doClick, false);
  }
  c.appendChild(list);
};
  ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="content"></div></code>```

Body:
I have code shown below for a project where I insert list elements using javascript and for click on each element I have to call a function. However, it does not seem to work.

var c = document.getElementById("content");

c.innerHTML += "
";

for(var j = 0; j<5; j++){

    c.innerHTML += "
some stuff"+j+"
";

    document.getElementById(j).addEventListener("click", function(){ alert('this is test'); }, false);

}
c.innerHTML += "
";

Why is the click event not being triggered? How can I make this work?

Body:
The reason the OP doesn't work is because of this:

c.innerHTML += "<li id = '" + j +  "'>some stuff"+j+"</li>";

When you concatenate to the innHTML property like that, the element content is first serialised, which removes any listeners that aren't inline (e.g. those added by addEventListener). So the only one remaining at the end of the loop is the last one.

But then you do:

c.innerHTML += "</ul>";

which removes the last one too.

Far better to build a single string of markup and use innerHTML once.

Consider: what should the browser do with the opening UL tag until the closing tag is entered? You've added invalid markup to the document, so it has to use error correction to make something work, so you might end up with a structure that isn't what you expected.

For the listeners, you can include them in-line with the rest of the markup so they survive being serialised and parsed.

Alternatively, use DOM methods to create the elements and stop using innerHTML.

function doClick(){
  alert('this is a test ' + this.id);
}

window.onload = function() {
  var c = document.getElementById("content");
  var list = document.createElement('ul');

  for(var j = 0; j<5; j++){
    var li = list.appendChild(document.createElement('li'));
    li.textContent = 'some stuff ' + j;
    li.id = j;
    li.addEventListener('click', doClick, false);
  }
  c.appendChild(list);
};

<div id="content"></div>


问:
Accessing dynamic database in laravel
I am working on an application. I have a master database, where I store all database names. I have made an api, which sends db_name. If that db_name exists in master db, it fetches that value and credentials.

After that, I want to perform all my operations on that new database.

I have written controller function like this, but it does not seem to work:

```<code>public function test(Request $request) {

    $users = Config::where('db_name', '=', $request->db_name)->first();

    if ($users) {
        config(['database.mongodb' => [
            'database' => $users->db_name
        ]]);
    }

    $contacts = \DB::collection('contacts')->get();

    return response()->json($contacts);

}
</code>```

Url I am accessing :
http://localhost:8000/api/test?db_name=79b83e17125f770f0294619942586e57

api.php
Route::get('/test', 'SearchController@test');

I am using mongodb, and jenssegers/laravel-mongodb library. Any suggestions?

答:
you can get like that two way

```<code>public function test(Request $request) {

    $users = Config::where('db_name', '=', $request->db_name)->first();

    $contacts = \DB::collection($users->db_name.'.contacts')->get();

    return response()->json($contacts);
}
</code>```

also you can change database name run time into config file

```<code>  public function test(Request $request) {
        $users = Config::where('db_name', '=', $request->db_name)->first();

         if ($users) {
             \Config::set('database.connections.mongodb.database',$users->db_name);
          }
// retrun DB::connection()->getDatabaseName()
         $contacts = \DB::collection('contacts')->get();

         return response()->json($contacts);
}
</code>```

Title: Accessing dynamic database in laravel

Body:
I am working on an application. I have a master database, where I store all database names. I have made an api, which sends db_name. If that db_name exists in master db, it fetches that value and credentials.

After that, I want to perform all my operations on that new database.

I have written controller function like this, but it does not seem to work:

public function test(Request $request) {

    $users = Config::where('db_name', '=', $request->db_name)->first();

    if ($users) {
        config(['database.mongodb' => [
            'database' => $users->db_name
        ]]);
    }

    $contacts = \DB::collection('contacts')->get();

    return response()->json($contacts);

}

Url I am accessing :
http://localhost:8000/api/test?db_name=79b83e17125f770f0294619942586e57

api.php
Route::get('/test', 'SearchController@test');

I am using mongodb, and jenssegers/laravel-mongodb library. Any suggestions?

Body:
you can get like that two way

public function test(Request $request) {

    $users = Config::where('db_name', '=', $request->db_name)->first();

    $contacts = \DB::collection($users->db_name.'.contacts')->get();

    return response()->json($contacts);
}

also you can change database name run time into config file

  public function test(Request $request) {
        $users = Config::where('db_name', '=', $request->db_name)->first();

         if ($users) {
             \Config::set('database.connections.mongodb.database',$users->db_name);
          }
// retrun DB::connection()->getDatabaseName()
         $contacts = \DB::collection('contacts')->get();

         return response()->json($contacts);
}