问:
Convert a List to String to populate webpage in JSP
I have DAO bean rows retrieved in a List. In my JSP I am accessing the List to iterate thru to populate my page.  My JSP can't access the List because it says it must be a String when I execute a request.getParameter. How I convert this to String eventually populate my page?

```<code>public List getAccessRequest()
{
    List accessRequesttList = new ArrayList());  // parse List to string
    //AccessRequest accessrequest = null;
    AccessRequest accessRequest = new AccessRequest());

    try
    {
        System.out.println("Try statement begins AccessRequestDAO");
        PreparedStatement accrqststmt = super.getConnection().prepareStatement(AccRqstSqlStmt);

        ResultSet resultSet = accrqststmt.executeQuery();

        while (resultSet.next())
        {
            // Creating an instant of job follows
            accessRequest = new Accessrequest();

            accessRequest.setJOB_NAME(resultSet.getString("job_name"));
            accessRequest.setRequest_ts(resultSet.getTime("request_ts"));
            accessRequestList.add(accessRequest);
            Iterator iterator = accessRequestList.iterator();

            while (iterator.hasNext())
            {
                accessRequest = (Accessrequest) iterator.next();
            }
        }
        return (accessRequestList);
</code>```

My JSP look like below:

```<code>        <%
            List jobList = request.getParameter("acccessrequests"); // parse List to String

            Iterator iterator = jobList.iterator();
            while (iterator.hasNext())
            {
                accessRequest = (AccessRequest) iterator.next());
        %>
                <tr>
                <td><input type="checkbox" name="<%accessRequest.getApproval_ind(); %>"></td>
                <td><input type="text" id="jobname' name="accessRequests" value="job_name"></td>
</code>```

答:
Alhamdulillah, thanks God!

This help me a lot. I try to build my own java Web framework.
Before reading this QA, I don't know how to access an object (say, row of table) from a JSP.
I just redirect it, and leave the database code in JSP, generated by DreamWeaver. Now I  know how to do it. For example, this is a BiroController, which display data from Biro Table :

```<code> public void index() throws IOException, ServletException {
    List list=new ArrayList();
    list.add(BiroModel.create("1", "SDM"));
    list.add(BiroModel.create("2", "Keuangan"));
    request.setAttribute("list", list);
    super.index();
}
</code>```

firstly, I populate an array (subsequently, this will come from database table). and then set request attribute, then call superclass index method :

```<code> public void index() throws IOException, ServletException {
    RequestDispatcher rd = request.getRequestDispatcher(viewPage);
    if(rd!=null){
        rd.forward(request, response);
    }else{
       PrintWriter out = response.getWriter();
       out.print("can not dispatch to " + viewPage);
    }
    //OLD Code : response.sendRedirect(ServletUtil.getBaseUrl(request) + viewPage)
}
</code>```

And, I did as you instructed in the JSP :

```<code>   <c:forEach items="${list}" var="item">
    <tr>
        <td>${item.idbiro}</td>
        <td>${item.biro}</td>
    </tr>
</c:forEach>
</code>```

I use Netbeans, so I can easily pick JSTL library from the list of available library

It works charmingly.. :) tq

Body:
I have DAO bean rows retrieved in a List. In my JSP I am accessing the List to iterate thru to populate my page.  My JSP can't access the List because it says it must be a String when I execute a request.getParameter. How I convert this to String eventually populate my page?

public List getAccessRequest()
{
    List accessRequesttList = new ArrayList());  // parse List to string
    //AccessRequest accessrequest = null;
    AccessRequest accessRequest = new AccessRequest());

    try
    {
        System.out.println("Try statement begins AccessRequestDAO");
        PreparedStatement accrqststmt = super.getConnection().prepareStatement(AccRqstSqlStmt);

        ResultSet resultSet = accrqststmt.executeQuery();

        while (resultSet.next())
        {
            // Creating an instant of job follows
            accessRequest = new Accessrequest();

            accessRequest.setJOB_NAME(resultSet.getString("job_name"));
            accessRequest.setRequest_ts(resultSet.getTime("request_ts"));
            accessRequestList.add(accessRequest);
            Iterator iterator = accessRequestList.iterator();

            while (iterator.hasNext())
            {
                accessRequest = (Accessrequest) iterator.next();
            }
        }
        return (accessRequestList);

My JSP look like below:

        <%
            List jobList = request.getParameter("acccessrequests"); // parse List to String

            Iterator iterator = jobList.iterator();
            while (iterator.hasNext())
            {
                accessRequest = (AccessRequest) iterator.next());
        %>

                <input type="checkbox" name="<%accessRequest.getApproval_ind(); %>">
                <input type="text" id="jobname' name="accessRequests" value="job_name">

Body:
Alhamdulillah, thanks God!

This help me a lot. I try to build my own java Web framework.
Before reading this QA, I don't know how to access an object (say, row of table) from a JSP.
I just redirect it, and leave the database code in JSP, generated by DreamWeaver. Now I  know how to do it. For example, this is a BiroController, which display data from Biro Table :

 public void index() throws IOException, ServletException {
    List list=new ArrayList();
    list.add(BiroModel.create("1", "SDM"));
    list.add(BiroModel.create("2", "Keuangan"));
    request.setAttribute("list", list);
    super.index();
}

firstly, I populate an array (subsequently, this will come from database table). and then set request attribute, then call superclass index method :

 public void index() throws IOException, ServletException {
    RequestDispatcher rd = request.getRequestDispatcher(viewPage);
    if(rd!=null){
        rd.forward(request, response);
    }else{
       PrintWriter out = response.getWriter();
       out.print("can not dispatch to " + viewPage);
    }
    //OLD Code : response.sendRedirect(ServletUtil.getBaseUrl(request) + viewPage)
}

And, I did as you instructed in the JSP :

   <c:forEach items="${list}" var="item">
    <tr>
        <td>${item.idbiro}</td>
        <td>${item.biro}</td>
    </tr>
</c:forEach>

I use Netbeans, so I can easily pick JSTL library from the list of available library

It works charmingly.. :) tq


来源: stackexchange

问:
sending an email with python, html + css, reading an .txt file
I am trying to code something very simple. The idea is to read a .txt where a html code is written. Specifically it is a table with some css and style modifiers like:

```<code> <td style=""background-color:red"" >-49,2%</td>
</code>```

I can sucessfully read the content of the file and send the email. However, when the email is sent, no background style is applied. The rest of the table is created perfectly.
My code is something like:

```<code>fp = open(r"filepath", 'r',encoding='utf-8-sig')
# Create a text/plain message
msg = MIMEText(fp.read()) #Here I also tried with the argument 'html'
fp.close()
s.sendmail("email1", "email2",msg.as_string())
</code>```

Is there any way I can also get the style applied? The email provider is gmail and I know it can work because if I try to use the 'msg' variable as a literal string, like:

```<code>msg= r"<table...> <td style=""background-color:red"" >-49,2%</td> </table>"
</code>```

it sends the background format correctly. The issue must be of other sort.

Thank you very much!

答:
Solved.

I hope it helps,
The modifier.as_string() was the issue. Removing it on:

```<code>s.sendmail("email1", "email2",msg.as_string())
</code>```

to

```<code>s.sendmail("email1", "email2",msg)
</code>```

made it work.

ContentLicense: CC BY-SA 3.0

Body:
I am trying to code something very simple. The idea is to read a .txt where a html code is written. Specifically it is a table with some css and style modifiers like:

 -49,2%

I can sucessfully read the content of the file and send the email. However, when the email is sent, no background style is applied. The rest of the table is created perfectly.
My code is something like:

fp = open(r"filepath", 'r',encoding='utf-8-sig')
# Create a text/plain message
msg = MIMEText(fp.read()) #Here I also tried with the argument 'html'
fp.close()
s.sendmail("email1", "email2",msg.as_string())

Is there any way I can also get the style applied? The email provider is gmail and I know it can work because if I try to use the 'msg' variable as a literal string, like:

msg= r"
 -49,2%
"

it sends the background format correctly. The issue must be of other sort.

Thank you very much!

Body:
Solved.

I hope it helps,
The modifier.as_string() was the issue. Removing it on:

s.sendmail("email1", "email2",msg.as_string())

to

s.sendmail("email1", "email2",msg)

made it work.


问:
How to get a ddl of an existing table using apache pheonix
This is possible with oracl sql developer. I want that same functionality in pheonix is that possible
Ddl along with dcl statements </p>

答:
You probably want to refer to this question
How to export table schemas in apache phoenix?</p>

```<code>!describe <table_id> is a popular
</code>```

Body:
You probably want to refer to this question
How to export table schemas in apache phoenix?

!describe <table_id> is a popular


问:
removing default document from current URL
I use the following code to get the URL of current page.

```<code>thispage ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring
</code>```

I want to check if user has typed the default document (index.asp) at the end of URL and remove it (by redirecting to the clean URL without default document in address bar).

But this code always contains the default document even when if not typed in address bar e.g. the code above returns http://example.com/index.asp when I have http://example.com in address bar.

How do I edit the above code to distinguish those URLs?

答:
you can do soemthing like:</p>

```<code>url = Request.ServerVariables("URL")
url = Left( url, Len( url, Right( url, InStrRev( url, "/" ) - 1 )
thispage ="http://" & Request.ServerVariables("SERVER_NAME") & url & "/?" & Request.Querystring
</code>```

Body:
I use the following code to get the URL of current page.

thispage ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring

I want to check if user has typed the default document (index.asp) at the end of URL and remove it (by redirecting to the clean URL without default document in address bar).

But this code always contains the default document even when if not typed in address bar e.g. the code above returns http://example.com/index.asp when I have http://example.com in address bar.

How do I edit the above code to distinguish those URLs?

Body:
you can do soemthing like:

url = Request.ServerVariables("URL")
url = Left( url, Len( url, Right( url, InStrRev( url, "/" ) - 1 )
thispage ="http://" & Request.ServerVariables("SERVER_NAME") & url & "/?" & Request.Querystring


问:
Using .NET Core to create windows applications
Can I create windows services with .NET Core or do I still need using .NET Framework?</p>

答: Based on the comments the windows service creation is not possible with .NET Core right now.</p>


问:
How is the ionic project closed?
I'm a MacBook user.
How can I close the project from the terminal?

When I go directly from the terminal, the project is reset. What should I do?

答: press     fn + c  it will stop the app.

Title: How is the ionic project closed?

Body: press     fn + c  it will stop the app.


问:
Excel VBA link two user selected cells with hyperlink
I am currently trying to link two user selected cells automatically with hyperlinks.
The user can select two different cells (one after another via inputboxes). To those two cells hyperlinks should be added which point from cell 1 to cell 2 and cell 2 to cell 1.

So far I have this:

```<code> Option Explicit

Sub Hyperlinks()
Dim FirstHyperlink As Range
Dim SecondHyperlink As Range

Set FirstHyperlink = Application.InputBox("Please select first cell to contain hyperlink", "Hyperlink 1 selection", Type:=8)
Set SecondHyperlink = Application.InputBox("Please select second cell to contain hyperlink", "Hyperlink 2 selection", Type:=8)

ActiveSheet.Hyperlinks.Add Anchor:=FirstHyperlink.Address, Address:="", SubAddress:= _
    SecondHyperlink.Address, TextToDisplay:=FirstHyperlink.Value

ActiveSheet.Hyperlinks.Add Anchor:=SecondHyperlink.Address, Address:="", SubAddress:= _
    FirstHyperlink.Address, TextToDisplay:=SecondHyperlink.Value

End Sub
</code>```

However I get a run-time error 13: Type mismatch pointing to

```<code>ActiveSheet.Hyperlinks.Add Anchor:=FirstHyperlink.Address, Address:="", SubAddress:= _
        SecondHyperlink.Address, TextToDisplay:=FirstHyperlink.Value
</code>```

Anyone an idea what causes the problem?

答:
For completeness reasons:

Here is the code that I finally worked with. I wrote some more lines of code to make it work on different worksheets and not only on one single worksheet.

```<code>Option Explicit

Sub Hyperlinks()
Dim FirstHyperlink As Range
Dim SecondHyperlink As Range
Dim FirstSheet As Worksheet
Dim SecondSheet As Worksheet

Set FirstHyperlink = Application.InputBox("Please select first cell to contain hyperlink", "Hyperlink 1 selection", Type:=8)
Set FirstSheet = FirstHyperlink.Worksheet
Set SecondHyperlink = Application.InputBox("Please select second cell to contain hyperlink", "Hyperlink 2 selection", Type:=8)
Set SecondSheet = SecondHyperlink.Worksheet

ActiveSheet.Hyperlinks.Add Anchor:=FirstHyperlink, Address:="", SubAddress:= _
    "'" & SecondSheet.Name & "'" & "!" & SecondHyperlink.Address, TextToDisplay:=FirstHyperlink.Value

ActiveSheet.Hyperlinks.Add Anchor:=SecondHyperlink, Address:="", SubAddress:= _
    "'" & FirstSheet.Name & "'" & "!" & FirstHyperlink.Address, TextToDisplay:=SecondHyperlink.Value

End Sub
</code>```

Body:
I am currently trying to link two user selected cells automatically with hyperlinks.
The user can select two different cells (one after another via inputboxes). To those two cells hyperlinks should be added which point from cell 1 to cell 2 and cell 2 to cell 1.

So far I have this:

 Option Explicit

Sub Hyperlinks()
Dim FirstHyperlink As Range
Dim SecondHyperlink As Range

Set FirstHyperlink = Application.InputBox("Please select first cell to contain hyperlink", "Hyperlink 1 selection", Type:=8)
Set SecondHyperlink = Application.InputBox("Please select second cell to contain hyperlink", "Hyperlink 2 selection", Type:=8)

ActiveSheet.Hyperlinks.Add Anchor:=FirstHyperlink.Address, Address:="", SubAddress:= _
    SecondHyperlink.Address, TextToDisplay:=FirstHyperlink.Value

ActiveSheet.Hyperlinks.Add Anchor:=SecondHyperlink.Address, Address:="", SubAddress:= _
    FirstHyperlink.Address, TextToDisplay:=SecondHyperlink.Value

End Sub

However I get a run-time error 13: Type mismatch pointing to

ActiveSheet.Hyperlinks.Add Anchor:=FirstHyperlink.Address, Address:="", SubAddress:= _
        SecondHyperlink.Address, TextToDisplay:=FirstHyperlink.Value

Anyone an idea what causes the problem?

Body:
For completeness reasons:

Here is the code that I finally worked with. I wrote some more lines of code to make it work on different worksheets and not only on one single worksheet.

Option Explicit

Sub Hyperlinks()
Dim FirstHyperlink As Range
Dim SecondHyperlink As Range
Dim FirstSheet As Worksheet
Dim SecondSheet As Worksheet

Set FirstHyperlink = Application.InputBox("Please select first cell to contain hyperlink", "Hyperlink 1 selection", Type:=8)
Set FirstSheet = FirstHyperlink.Worksheet
Set SecondHyperlink = Application.InputBox("Please select second cell to contain hyperlink", "Hyperlink 2 selection", Type:=8)
Set SecondSheet = SecondHyperlink.Worksheet

ActiveSheet.Hyperlinks.Add Anchor:=FirstHyperlink, Address:="", SubAddress:= _
    "'" & SecondSheet.Name & "'" & "!" & SecondHyperlink.Address, TextToDisplay:=FirstHyperlink.Value

ActiveSheet.Hyperlinks.Add Anchor:=SecondHyperlink, Address:="", SubAddress:= _
    "'" & FirstSheet.Name & "'" & "!" & FirstHyperlink.Address, TextToDisplay:=SecondHyperlink.Value

End Sub


问:
Select shapes within a range and align them
I want to write a function where I can select one shape after which a macro aligns all the shapes that are within a 'short range' of the selected shape.

Therefore I wrote the following code that selects all the object within a range:

```<code>Sub Shape_Dimensions()

Dim L As Long
Dim T As Long
Dim H As Long
Dim W As Long

With ActiveWindow.Selection
    If .Type = ppSelectionShapes Then
        L = .ShapeRange.Left
        T = .ShapeRange.Top
        H = .ShapeRange.Height
        W = .ShapeRange.Width
    Else
        MsgBox "You have not selected an OBJECT in PowerPoint to dimension."
        Exit Sub
    End If
End With

 'Set range for selection
 TopRange = L + 30
 DownRange = T + H + 20
 'Left and right are 0 - 600

End Sub
</code>```

Now the final step I want to take is select all shapes that are within the top range and down range and align them with the top of the selected box. Any thoughts on how I should proceed?

答:
```<code>Sub Shape_Align()

    Dim L As Long
    Dim T As Long
    Dim H As Long, TopRange As Long, DownRange As Long
    Dim W As Long, s As Shape, n As String

    With ActiveWindow.Selection
        If .Type = ppSelectionShapes Then
            L = .ShapeRange.Left
            T = .ShapeRange.Top
            H = .ShapeRange.Height
            W = .ShapeRange.Width
            n = .ShapeRange.Name
        Else
            MsgBox "You have not selected an OBJECT in PowerPoint to dimension."
            Exit Sub
        End If
    End With

     'Set range for selection
     TopRange = L + 30
     DownRange = T + H + 20
     'Left and right are 0 - 600

     For Each s In ActiveWindow.View.Slide.Shapes
        If s.Name <> n Then
           'in scope for lining up?
           If Abs(s.Top - T) < 60 Then
               s.Top = T
           End If
        End If
     Next s

End Sub
</code>```

Body:
I want to write a function where I can select one shape after which a macro aligns all the shapes that are within a 'short range' of the selected shape.

Therefore I wrote the following code that selects all the object within a range:

Sub Shape_Dimensions()

Dim L As Long
Dim T As Long
Dim H As Long
Dim W As Long

With ActiveWindow.Selection
    If .Type = ppSelectionShapes Then
        L = .ShapeRange.Left
        T = .ShapeRange.Top
        H = .ShapeRange.Height
        W = .ShapeRange.Width
    Else
        MsgBox "You have not selected an OBJECT in PowerPoint to dimension."
        Exit Sub
    End If
End With

 'Set range for selection
 TopRange = L + 30
 DownRange = T + H + 20
 'Left and right are 0 - 600

End Sub

Now the final step I want to take is select all shapes that are within the top range and down range and align them with the top of the selected box. Any thoughts on how I should proceed?


问:
Zeppelin and Spark Configuration
I'm working with Zeppelin (0.7.1) on Spark (2.1.1) on my localhost, and trying to add some configuration values to the jobs I run.

Specifically, I'm trying to set the es.nodes value for elasticsearch-hadoop.

I tried adding the key and value to the interpreter configuration, but that didn't show up in sc.getConf. Adding to the interpreter's "args" configuration key the value of "--conf mykey:myvalue" didn't register as well.
Is that not what the spark interpreter configuration is supposed to do?

答:
Apparently this is an intentional change in Zeppelin, implemented not long ago...
It only allows spark.* properties to be delegated to the SparkConf. I have submitted a comment to change this, as I believe it is problematic.
https://github.com/apache/zeppelin/pull/1970</p>

Title: Zeppelin and Spark Configuration


问:
Where can I download Coldfusion MX 7 for Mac?
It seems like it is no longer downloadable from Adobe, so I was wondering if anyone out there knows where I can download it from. </p>

答:
Dave Watts has advised on the cf-talk list that Figleaf is an authorised distributor of old versions. Try following up with him.

http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339621

ContentLicense: CC BY-SA 2.5


问:
How to map chars to (playing) cards?
I have an android card game app.
In my app i send data about the game cards that has been played between the players, and i try to make the messages as short as possible.
I have a class that represents each card.
Now, in order to make the messages smaller, i refer to each card as a single char.
For example ace of spades would be 'a'
Ace of diamonds would be 'b' and so on..

My question is, how can i map the chars back to the corresponding card, in the most effective way?
(For example hashmap of chars and cards)
For example if a player receives 'a, b' he translates it to aces of spades and diamonds.

Thanks!

答:
I'd map each card to a character starting with ' ' (32 decimal, 0x20 hex, so you'll always be dealing with printable characters) then just have a switch statement to cover all the cards.  One switch statement to encode, and the other to decode into "Ace of Diamonds" for example.

Although lengthy, a large switch statement is better than chained if-elseif statements, and easier to understand than a binary encoding.  If I were doing it for a very memory constrained device I might choose binary encoding but for a real computer I'd just use the switch as it's easy to understand.

Title: How to map chars to (playing) cards?


问:
can I used body.insertFileFromBase64 from Base64String comes from doc file not docx
I have webservice it reads .doc or .docx and send it Base64String by ajax into my plugin
this is code of web service

```<code>public string ReadDocument(string path)
        {

            FileStream fsStream = null;
            BinaryReader objReader = null;
            try
            {

                ////////////////////////

                // Now, read binary file
                //path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Copy.docx";
                fsStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                byte[] fileContent = new byte[fsStream.Length];
                objReader = new BinaryReader(fsStream);
                objReader.Read(fileContent, 0, fileContent.Length);
                //toRet.FileContent = fileContent;
                //toRet.FileName = "Test.doc";
                string StrBase64 = Convert.ToBase64String(fileContent);
                string _Document = StrBase64 ;
                return _Document;
                // FlushResponse(_Document, "application/pdf");
            }
            catch (Exception ex)
            {
                // FlushResponse("error");
                return "Error " + ex.Message;
            }
            finally
            {
                if (objReader != null) objReader.Close();
                if (fsStream != null) fsStream.Close();
            }
        }
</code>```

I have a problem with body.insertFileFromBase64 when my Base64String  comes from .docx it is working but when Base64String  comes from .doc it is not working any
this is my code in my plugin I send result param it is Base64String comes from ajax

```<code>function InsertDocument(result) {
    Word.run(function (context) {

        // Create a proxy object for the document body.
        var body = context.document.body;
        body.clear();
        // Queue a commmand to insert base64 encoded .docx at the beginning of the content body.
        // You will need to implement getBase64() to pass in a string of a base64 encoded docx file.
        body.insertFileFromBase64(result, Word.InsertLocation.start);

        // Synchronize the document state by executing the queued commands,
        // and return a promise to indicate task completion.
        return context.sync().then(function () {
            console.log('Added base64 encoded text to the beginning of the document body.');
            $("#loading").hide();
        });
    })
</code>```

Is any Idea to I can insert .doc to office 2016 by office.js or any other function

答:
The reference for the body.insertFileFromBase64 method implies that the first parameter has to be a docx file:

base64File string Required. The base64 encoded content of a .docx file

.

Body:
I have webservice it reads .doc or .docx and send it Base64String by ajax into my plugin
this is code of web service

public string ReadDocument(string path)
        {

            FileStream fsStream = null;
            BinaryReader objReader = null;
            try
            {

                ////////////////////////

                // Now, read binary file
                //path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Copy.docx";
                fsStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                byte[] fileContent = new byte[fsStream.Length];
                objReader = new BinaryReader(fsStream);
                objReader.Read(fileContent, 0, fileContent.Length);
                //toRet.FileContent = fileContent;
                //toRet.FileName = "Test.doc";
                string StrBase64 = Convert.ToBase64String(fileContent);
                string _Document = StrBase64 ;
                return _Document;
                // FlushResponse(_Document, "application/pdf");
            }
            catch (Exception ex)
            {
                // FlushResponse("error");
                return "Error " + ex.Message;
            }
            finally
            {
                if (objReader != null) objReader.Close();
                if (fsStream != null) fsStream.Close();
            }
        }

I have a problem with body.insertFileFromBase64 when my Base64String  comes from .docx it is working but when Base64String  comes from .doc it is not working any
this is my code in my plugin I send result param it is Base64String comes from ajax

function InsertDocument(result) {
    Word.run(function (context) {

        // Create a proxy object for the document body.
        var body = context.document.body;
        body.clear();
        // Queue a commmand to insert base64 encoded .docx at the beginning of the content body.
        // You will need to implement getBase64() to pass in a string of a base64 encoded docx file.
        body.insertFileFromBase64(result, Word.InsertLocation.start);

        // Synchronize the document state by executing the queued commands,
        // and return a promise to indicate task completion.
        return context.sync().then(function () {
            console.log('Added base64 encoded text to the beginning of the document body.');
            $("#loading").hide();
        });
    })

Is any Idea to I can insert .doc to office 2016 by office.js or any other function


问:
Return first word in sentence?
Heres the question I have to answer for school

For the purposes of this question, we will define a word as ending a sentence if that word is immediately followed by a period. For example, in the text “This is a sentence. The last sentence had four words.”, the ending words are ‘sentence’ and ‘words’. In a similar fashion, we will define the starting word of a sentence as any word that is preceded by the end of a sentence. The starting words from the previous example text would be “The”. You do not need to consider the first word of the text as a starting word. Write a program that has:

An endwords function that takes a single string argument. This functioin must return a list of all sentence ending words that appear in the given string. There should be no duplicate entries in the returned list and the periods should not be included in the ending words.

The code I have so far is:

```<code>def startwords(astring):
    mylist = astring.split()
    if mylist.endswith('.') == True:
        return my list
</code>```

but I don't know if I'm using the right approach. I need some help

答:
This creates a set so there are no duplicates. Then goes on a for loop in a list of sentences (split by ".") then for each sentence, splits it in words then using [:-1] makes a list of the last word only and gets [0] item in that list.

```<code>print (set([ x.split()[:-1][0] for x in s.split(".") if len(x.split())>0]))
</code>```

The if in theory is not needed but i couldn't make it work without it.

This works as well:

```<code> print (set([ x.split() [len(x.split())-1] for x in s.split(".") if len(x.split())>0]))
</code>```

Title: Return first word in sentence?

Body:
Heres the question I have to answer for school

For the purposes of this question, we will define a word as ending a sentence if that word is immediately followed by a period. For example, in the text “This is a sentence. The last sentence had four words.”, the ending words are ‘sentence’ and ‘words’. In a similar fashion, we will define the starting word of a sentence as any word that is preceded by the end of a sentence. The starting words from the previous example text would be “The”. You do not need to consider the first word of the text as a starting word. Write a program that has:

An endwords function that takes a single string argument. This functioin must return a list of all sentence ending words that appear in the given string. There should be no duplicate entries in the returned list and the periods should not be included in the ending words.

The code I have so far is:

def startwords(astring):
    mylist = astring.split()
    if mylist.endswith('.') == True:
        return my list

but I don't know if I'm using the right approach. I need some help

Body:
This creates a set so there are no duplicates. Then goes on a for loop in a list of sentences (split by ".") then for each sentence, splits it in words then using [:-1] makes a list of the last word only and gets [0] item in that list.

print (set([ x.split()[:-1][0] for x in s.split(".") if len(x.split())>0]))

The if in theory is not needed but i couldn't make it work without it.

This works as well:

 print (set([ x.split() [len(x.split())-1] for x in s.split(".") if len(x.split())>0]))


问:
How to make CSS shaped button/border?
Please, can you give me tips on how to make shaped button/menu navigation?
It should look like this:

I have tried something with borders, but it's working only if there is no text inside the div.

Here is the code I tried:

```<code>.border-right {
  font-size: 0px; line-height: 0%; width: 0px;
  width: 0px;
  border-top: 50px solid #93D1C1;
  border-bottom: 50px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
}
</code>```

It looks like this (Codepen)

Any ideas, please?

答:
Is this what you are looking for?
https://codepen.io/anon/pen/RgNbvV</p>

```<code>body {
  background-color: #4F4135;
}
.border-right {
  font-size: 0px; line-height: 0%; width: 0px;
  width: 0px;
  border-top: 50px solid #93D1C1;
  border-bottom: 50px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
  display: inline-block;
}

.border-wrong {
  width: 100px;
  background-color: #93D1C1;
  display: inline-block;
  position: relative;
  z-index: 1;
  text-align: center;
  padding-top: 10px;
}
.border-wrong:after {
  position: absolute;
  content: "";
  z-index: -1;
  left: 0;
  right: 0;
  width: 0px;
  background-color: #93D1C1;
  border-top: 25px solid #93D1C1;
  border-bottom: 25px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
  display: inline-block;
  text-align: center;
}
</code>```

Title: How to make CSS shaped button/border?

Body:
Please, can you give me tips on how to make shaped button/menu navigation?
It should look like this:

I have tried something with borders, but it's working only if there is no text inside the div.

Here is the code I tried:

.border-right {
  font-size: 0px; line-height: 0%; width: 0px;
  width: 0px;
  border-top: 50px solid #93D1C1;
  border-bottom: 50px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
}

It looks like this (Codepen)

Any ideas, please?

Body:
Is this what you are looking for?
https://codepen.io/anon/pen/RgNbvV

body {
  background-color: #4F4135;
}
.border-right {
  font-size: 0px; line-height: 0%; width: 0px;
  width: 0px;
  border-top: 50px solid #93D1C1;
  border-bottom: 50px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
  display: inline-block;
}

.border-wrong {
  width: 100px;
  background-color: #93D1C1;
  display: inline-block;
  position: relative;
  z-index: 1;
  text-align: center;
  padding-top: 10px;
}
.border-wrong:after {
  position: absolute;
  content: "";
  z-index: -1;
  left: 0;
  right: 0;
  width: 0px;
  background-color: #93D1C1;
  border-top: 25px solid #93D1C1;
  border-bottom: 25px solid #4F4135;
  border-left: 50px solid #93D1C1;
  border-right: 50px solid #93D1C1;
  display: inline-block;
  text-align: center;
}


问:
Windows Container swarm publish port and not access
I use windows container and try to create docker swarm ，I create three virtual machine use hyper-v , and each OS is windows server 2016.There machines ip is :

```<code>windocker211    192.168.1.211
windocker212    192.168.1.212
windocker219    192.168.1.219
</code>```

The docker swarm node is :

```<code>PS C:\ConsoleZ> docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
4c0g0o0uognheugw4do1a1h7y     windocker212          Ready               Active
bbxot0c8zijq7xw4lm86svgwp *   windocker219          Ready               Active              Leader
wftwpiqpqpbqfdvgenn787psj     windocker211          Ready               Active
</code>```

I create use command:

```<code>docker service create --name=demo5 -p 5005:5005 --replicas 6 192.168.1.245/cqgis/wintestcore:0.6
</code>```

The docker image is asp.net core app , the Dockerfile is:

```<code>FROM  192.168.1.245/win/aspnetcore-runtime:1.1.2
COPY . /app
WORKDIR /app

ENV ASPNETCORE_URLS http://*:5005

EXPOSE 5005/tcp

ENTRYPOINT ["dotnet", "dotnetcore.dll"]
</code>```

then  it create success:

```<code>PS C:\ConsoleZ> docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                                 PORTS
omhu7e0vo96s        demo5               replicated          6/6                 192.168.1.245/cqgis/wintestcore:0.6   *:5005->5005/tcp

PS C:\ConsoleZ> docker service ps demo5
ID                  NAME                IMAGE                                 NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS
8pihnak9a2ei        demo5.1             192.168.1.245/cqgis/wintestcore:0.6   windocker212          Running             Running 59 seconds ago
ut3f3b9giu4w        demo5.2             192.168.1.245/cqgis/wintestcore:0.6   windocker219          Running             Running 47 seconds ago
iy1xjevt67yl        demo5.3             192.168.1.245/cqgis/wintestcore:0.6   windocker211          Running             Running about a minute ago
q7f1gnbwslr3        demo5.4             192.168.1.245/cqgis/wintestcore:0.6   windocker212          Running             Running about a minute ago
8zewaktcu32h        demo5.5             192.168.1.245/cqgis/wintestcore:0.6   windocker219          Running             Running about a minute ago
xq820kqwf3v9        demo5.6             192.168.1.245/cqgis/wintestcore:0.6   windocker211          Running             Running 55 seconds ago
</code>```

but my question is  I cann't  accessing The Site  each by

```<code>http://192.168.1.219:5005/
http://192.168.1.219:5005/
http://192.168.1.219:5005/
</code>```

When I use command

```<code>docker run -it -p 5010:5005 192.168.1.245/cqgis/wintestcore:0.6
</code>```

I can use http://192.168.1.219:5010/ get the right result

my docker info is

```<code>PS C:\ConsoleZ> docker info
Containers: 4
 Running: 3
 Paused: 0
 Stopped: 1
Images: 5
Server Version: 17.06.0-ce-rc1
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd json-file logentries splunk syslog
Swarm: active
 NodeID: bbxot0c8zijq7xw4lm86svgwp
 Is Manager: true
 ClusterID: 32vsgwrbn6ihvpevly71gkgxk
 Managers: 1
 Nodes: 3
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Root Rotation In Progress: false
 Node Address: 192.168.1.219
 Manager Addresses:
  192.168.1.219:2377
Default Isolation: process
Kernel Version: 10.0 14393 (14393.1198.amd64fre.rs1_release_sec.170427-1353)
Operating System: Windows Server 2016 Datacenter
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 2.89GiB
Name: windock219
ID: 7AOY:OT6V:BTJV:NCHA:3OF5:5WR5:K2YR:CFG3:VXLD:QTMD:GA3D:ZFJ2
Docker Root Dir: C:\ProgramData\docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 297
 System Time: 2017-06-04T19:58:20.7582294+08:00
 EventsListeners: 2
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 192.168.1.245
 127.0.0.0/8
Live Restore Enabled: false
</code>```

答:
There are some differences in the network between Docker for windows container and Docker for Linux. Windows Containers uses the HyperV Network technologies to provide the virtual networking features that docker uses. From there are some restrictions that are not work like you would expect or maybe found in standard Docker Documentation.

First you cannot access the web side running inside your container by
using the lookback address (127.0.0.1) or the host address (192.168.1.xxx) You have to call it
always from a remote machine.

I saw you are using the expose command in your Dockerfile. It is not
so self-explaining but expose is to expose a port in any other
network then the host or ingress network. It’s not a problem if you
do that in a non swarm configuration but it does not work in a swarm.
I Suggest to remove the Expose command.

There are some unsolved problems with windows networking. Sometimes the port stays in use after the container gets restarted.
For example, after a reboot of the host system.
[https://github.com/moby/moby/issues/21558][1]

With this scrip you can remove the all virtual network settings:

```<code>Stop-Service docker
Get-ContainerNetwork | Remove-ContainerNetwork
Get-NetNat | Remove-NetNat
Get-VMSwitch | Remove-VMSwitch
Start-Service docker
</code>```

Body:
I use windows container and try to create docker swarm ，I create three virtual machine use hyper-v , and each OS is windows server 2016.There machines ip is :

windocker211    192.168.1.211
windocker212    192.168.1.212
windocker219    192.168.1.219

The docker swarm node is :

PS C:\ConsoleZ> docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
4c0g0o0uognheugw4do1a1h7y     windocker212          Ready               Active
bbxot0c8zijq7xw4lm86svgwp *   windocker219          Ready               Active              Leader
wftwpiqpqpbqfdvgenn787psj     windocker211          Ready               Active

I create use command:

docker service create --name=demo5 -p 5005:5005 --replicas 6 192.168.1.245/cqgis/wintestcore:0.6

The docker image is asp.net core app , the Dockerfile is:

FROM  192.168.1.245/win/aspnetcore-runtime:1.1.2
COPY . /app
WORKDIR /app

ENV ASPNETCORE_URLS http://*:5005

EXPOSE 5005/tcp

ENTRYPOINT ["dotnet", "dotnetcore.dll"]

then  it create success:

PS C:\ConsoleZ> docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                                 PORTS
omhu7e0vo96s        demo5               replicated          6/6                 192.168.1.245/cqgis/wintestcore:0.6   *:5005->5005/tcp

PS C:\ConsoleZ> docker service ps demo5
ID                  NAME                IMAGE                                 NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS
8pihnak9a2ei        demo5.1             192.168.1.245/cqgis/wintestcore:0.6   windocker212          Running             Running 59 seconds ago
ut3f3b9giu4w        demo5.2             192.168.1.245/cqgis/wintestcore:0.6   windocker219          Running             Running 47 seconds ago
iy1xjevt67yl        demo5.3             192.168.1.245/cqgis/wintestcore:0.6   windocker211          Running             Running about a minute ago
q7f1gnbwslr3        demo5.4             192.168.1.245/cqgis/wintestcore:0.6   windocker212          Running             Running about a minute ago
8zewaktcu32h        demo5.5             192.168.1.245/cqgis/wintestcore:0.6   windocker219          Running             Running about a minute ago
xq820kqwf3v9        demo5.6             192.168.1.245/cqgis/wintestcore:0.6   windocker211          Running             Running 55 seconds ago

but my question is  I cann't  accessing The Site  each by

http://192.168.1.219:5005/
http://192.168.1.219:5005/
http://192.168.1.219:5005/

When I use command

docker run -it -p 5010:5005 192.168.1.245/cqgis/wintestcore:0.6

I can use http://192.168.1.219:5010/ get the right result

my docker info is

PS C:\ConsoleZ> docker info
Containers: 4
 Running: 3
 Paused: 0
 Stopped: 1
Images: 5
Server Version: 17.06.0-ce-rc1
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd json-file logentries splunk syslog
Swarm: active
 NodeID: bbxot0c8zijq7xw4lm86svgwp
 Is Manager: true
 ClusterID: 32vsgwrbn6ihvpevly71gkgxk
 Managers: 1
 Nodes: 3
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Root Rotation In Progress: false
 Node Address: 192.168.1.219
 Manager Addresses:
  192.168.1.219:2377
Default Isolation: process
Kernel Version: 10.0 14393 (14393.1198.amd64fre.rs1_release_sec.170427-1353)
Operating System: Windows Server 2016 Datacenter
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 2.89GiB
Name: windock219
ID: 7AOY:OT6V:BTJV:NCHA:3OF5:5WR5:K2YR:CFG3:VXLD:QTMD:GA3D:ZFJ2
Docker Root Dir: C:\ProgramData\docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 297
 System Time: 2017-06-04T19:58:20.7582294+08:00
 EventsListeners: 2
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 192.168.1.245
 127.0.0.0/8
Live Restore Enabled: false

Body:
There are some differences in the network between Docker for windows container and Docker for Linux. Windows Containers uses the HyperV Network technologies to provide the virtual networking features that docker uses. From there are some restrictions that are not work like you would expect or maybe found in standard Docker Documentation.

First you cannot access the web side running inside your container by
using the lookback address (127.0.0.1) or the host address (192.168.1.xxx) You have to call it
always from a remote machine.

I saw you are using the expose command in your Dockerfile. It is not
so self-explaining but expose is to expose a port in any other
network then the host or ingress network. It’s not a problem if you
do that in a non swarm configuration but it does not work in a swarm.
I Suggest to remove the Expose command.

There are some unsolved problems with windows networking. Sometimes the port stays in use after the container gets restarted.
For example, after a reboot of the host system.
[https://github.com/moby/moby/issues/21558][1]

With this scrip you can remove the all virtual network settings:

Stop-Service docker
Get-ContainerNetwork | Remove-ContainerNetwork
Get-NetNat | Remove-NetNat
Get-VMSwitch | Remove-VMSwitch
Start-Service docker


问:
Mount Network Drive Locally in MFC(VC++)?
How to Mount Network Drive Locally in MFC(VC++) ?
Currently I am using WNetAddConnection2 to mount drive but it mount drive on network, I want to mount it has locally.

Any help is appreciated.
Thanks.

答:
Do you mean that you want to use a drive letter to attach a network share? I would call the system command net, like so:

net use X: \server\share /PERSISTENT:NO

where X is the drive letter you want to use. The PERSISTENT flag prevents it from remounting on boot. When you're finished, call net again with:

net use X: /DELETE

and it will umount the share.


问:
Load more hide previous content
I have this code using jquery, as I do when to display 4 new content it hid the previous 4 and when it reaches the end back to the beginning. Like a carousel.

Currently when you click on load more it keeps all the contents ready, current and previous.

```<code><html>
<head>

<style>

div {
    display:none;
    padding: 10px;
    border-width: 0 1px 1px 0;
    border-style: solid;
    border-color: #fff;
    box-shadow: 0 1px 1px #ccc;
    margin-bottom: 5px;
    background-color: #f1f1f1;
}

</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>

<body>

<div>Content</div>
<div>Content 1</div>
<div>Content 2</div>
<div>Content 3</div>
<div>Content 4</div>

<div>Content 5</div>
<div>Content 6</div>
<div>Content 7</div>
<div>Content 8</div>
<div>Content 9</div>
<div>Content 10</div>

<a href="#" id="loadMore">Load More</a>

<script>
$(function () {
    $("div").slice(0, 4).show();
    $("#loadMore").on('click', function (e) {
        e.preventDefault();
        $("div:hidden").slice(0, 4).slideDown();
        if ($("div:hidden").length == 0) {
            $("#load").fadeOut('slow');
        }
        $('html,body').animate({
            scrollTop: $(this).offset().top
        }, 1500);
    });
});

</script>
</body>
</htmL>
</code>```

答:
i think a better way to do this is to make the sets and then work with these sets ...
i have make some changes to give you idea...
checkout and let me know that is this the same that you want ?

$(function() {

  $(".set").first().show();

  $("#loadMore").on('click', function(e) {
    e.preventDefault();

    $(".set:visible").slideUp();
    $(".set:visible").next().slideDown();

    if ($(".set:visible").length == 1) {
      $(".set:visible").slideUp();
      $(".set").first().slideDown();
    }

    $('html,body').animate({
      scrollTop: $(this).offset().top
    }, 1500);
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>div {
  //display:none;
  padding: 10px;
  border-width: 0 1px 1px 0;
  border-style: solid;
  border-color: #fff;
  box-shadow: 0 1px 1px #ccc;
  margin-bottom: 5px;
  background-color: #f1f1f1;
}

.set {
  display: none;
}</code>```

Content 1

Content 2

Content 3

Content 4

Content 5

Content 6

Content 7

Content 8

Content 9

Content 10

Content 11

Content 12

  Load More

```

Title: Load more hide previous content

Body:
I have this code using jquery, as I do when to display 4 new content it hid the previous 4 and when it reaches the end back to the beginning. Like a carousel.

Currently when you click on load more it keeps all the contents ready, current and previous.

Content

Content 1

Content 2

Content 3

Content 4

Content 5

Content 6

Content 7

Content 8

Content 9

Content 10

Load More

Body:
i think a better way to do this is to make the sets and then work with these sets ...
i have make some changes to give you idea...
checkout and let me know that is this the same that you want ?

$(function() {

  $(".set").first().show();

  $("#loadMore").on('click', function(e) {
    e.preventDefault();

    $(".set:visible").slideUp();
    $(".set:visible").next().slideDown();

    if ($(".set:visible").length == 1) {
      $(".set:visible").slideUp();
      $(".set").first().slideDown();
    }

    $('html,body').animate({
      scrollTop: $(this).offset().top
    }, 1500);
  });
});

div {
  //display:none;
  padding: 10px;
  border-width: 0 1px 1px 0;
  border-style: solid;
  border-color: #fff;
  box-shadow: 0 1px 1px #ccc;
  margin-bottom: 5px;
  background-color: #f1f1f1;
}

.set {
  display: none;
}

<html>

<head>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
  </script>
</head>

<body>

  <div class="set">
    <div>Content 1</div>
    <div>Content 2</div>
    <div>Content 3</div>
    <div>Content 4</div>
  </div>

  <div class="set">
    <div>Content 5</div>
    <div>Content 6</div>
    <div>Content 7</div>
    <div>Content 8</div>
  </div>

  <div class="set">
    <div>Content 9</div>
    <div>Content 10</div>
    <div>Content 11</div>
    <div>Content 12</div>
  </div>

  <a href="#" id="loadMore">Load More</a>

</body>

</htmL>


问:
How can I perform an ICMP ping in react-native
I'd like to have pure network level verification that an IP is reachable, not the HTTP level, since I am trying to verify connectivity with devices that may not implement HTTP.

I already use react-native-udp, react-native-tcp and other native bindings, but does not seem a method to achieve this goal.

Thanks

答: If you have not found a package that does it, I would go with a native solution. There are several packages for iOS, like GBPing or Apple SimplePing and a quick search in Google showed some pointers on how to implement it for Android. Then you just have to do the binding to JS, for which you can find some help on the documentation.</p>


问:
Lua: Convert PCRE into Lua
I understand Lua does not have PCRE. How can I convert this into Lua?

```<code># Quote shell chars
$a =~ s/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~\|\; \"\!\$\&\'\202-\377]/\\$&/go;
# quote newline as '\n'
$a =~ s/[\n]/'\n'/go;
</code>```

Is there a general converter that can convert any PCRE into Lua?

答:
You may use

```<code>local a = "\002\003\004\005\006\007\008\009\010\011\012\\\n"
res, _ = a:gsub("([\002-\009\011-\026\\#?`(){}%[%]^*<>=~|; \"!$&'\130-\255])", "\\%1")
res, _ = res:gsub("\n", "'\n'")
print(res)
</code>```

See Lua code demo

Note that in Lua patterns, \ is not a special char, % is used to replace special chars (like [) and \ddd escapes reference the decimal, not octal codes.

Title: Lua: Convert PCRE into Lua

Body:
I understand Lua does not have PCRE. How can I convert this into Lua?

# Quote shell chars
$a =~ s/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~\|\; \"\!\$\&\'\202-\377]/\\$&/go;
# quote newline as '\n'
$a =~ s/[\n]/'\n'/go;

Is there a general converter that can convert any PCRE into Lua?

Body:
You may use

local a = "\002\003\004\005\006\007\008\009\010\011\012\\\n"
res, _ = a:gsub("([\002-\009\011-\026\\#?`(){}%[%]^*<>=~|; \"!$&'\130-\255])", "\\%1")
res, _ = res:gsub("\n", "'\n'")
print(res)

See Lua code demo

Note that in Lua patterns, \ is not a special char, % is used to replace special chars (like [) and \ddd escapes reference the decimal, not octal codes.


问:
How to get jQuery Visual Studio 2010 IntelliSense to work inside a noconflict wrapper
I added the vsdoc jquery reference in my js file:

```<code>/// <reference path="../jquery-1.4.1.vsdoc.js" />
</code>```

This works fine, but once I write inside a no conflict wrapper...

```<code>(function ($) {

...here...

})(jQuery);
</code>```

...IntelliSense does not work.

Why is this, and is there any way to solve this?

Body:
I added the vsdoc jquery reference in my js file:

/// <reference path="../jquery-1.4.1.vsdoc.js" />

This works fine, but once I write inside a no conflict wrapper...

(function ($) {

...here...

})(jQuery);

...IntelliSense does not work.

Why is this, and is there any way to solve this?

Body: /// <reference path="../jquery-1.4.1.js" />


问:
how to parse a string to a function from a textbox to the onclick event
Hi Guys I have a function called PlayVideo which works in the 'onclick event' from a button on a form.

'The onclick event' is =PlayVideo("C:\Users\Public\Videos\Sample Videos\Lake.wp4")

I need to replace the path name in the 'onclick event' with whatever path name is in the TBox1 at the time.

The Tbox1 is formatted so the string is the same ie:("H:\Stormy Weather.mp4")

I'm just unsure how to attach it so it works in the 'onclick event' or as a sub.

Thanks any help is appreciated.

答:
Change th button's OnClick event to "[Event Procedure]". This will create a routine in the module behind file like the one shown below. Paste the rest.

```<code>Private Sub YourButtonName_Click()
    Dim file_ As String
        file_ = Me.TBox1.Value

    'Validate file exists
    If Len(Dir(file_)) > 0 Then
        PlayVideo file_
    End If
End Sub
</code>```

Body:
Change th button's OnClick event to "[Event Procedure]". This will create a routine in the module behind file like the one shown below. Paste the rest.

Private Sub YourButtonName_Click()
    Dim file_ As String
        file_ = Me.TBox1.Value

    'Validate file exists
    If Len(Dir(file_)) > 0 Then
        PlayVideo file_
    End If
End Sub


问:
cURL download progress in PHP
I'm pretty new to cURL so I've been struggling with this one for hours. I'm trying to download the source of a website in an iframe using cURL and while it's loading to show how much of it is loaded. So far I have successfully downloaded the source without showing the loading progress. Can you explain how to show the download progress? Without cURL I would read the file byte by byte and divide the total amount of downloaded bytes with the total size of the file. How can this be done in cURL since it reads the source as a whole? (at least I think that this is the only way, not sure) Here's what I've got so far:</p>

```<code>/* Download source */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $adress);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$html = curl_exec($ch);
curl_close($ch);
</code>```

答:
To use the callback inside a class, you must do it like this:

```<code>curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'progress'));
</code>```

or if using static functions, like this:

```<code>curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array('self', 'progress'));
</code>```

... to a callback function to do whatever you need:

```<code>private static function progress($resource, $downloadSize, $downloaded, $uploadSize, $uploaded)
{
    // emit the progress
    Cache::put('download_status', [
        'resource' => $resource,
        'download_size' => $downloadSize,
        'downloaded' => $downloaded,
        'upload_size' => $uploadSize,
        'uploaded' => $uploaded
    ], 10);
}
</code>```

Title: cURL download progress in PHP

Body:
I'm pretty new to cURL so I've been struggling with this one for hours. I'm trying to download the source of a website in an iframe using cURL and while it's loading to show how much of it is loaded. So far I have successfully downloaded the source without showing the loading progress. Can you explain how to show the download progress? Without cURL I would read the file byte by byte and divide the total amount of downloaded bytes with the total size of the file. How can this be done in cURL since it reads the source as a whole? (at least I think that this is the only way, not sure) Here's what I've got so far:

/* Download source */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $adress);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$html = curl_exec($ch);
curl_close($ch);

Body:
To use the callback inside a class, you must do it like this:

curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'progress'));

or if using static functions, like this:

curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array('self', 'progress'));

... to a callback function to do whatever you need:

private static function progress($resource, $downloadSize, $downloaded, $uploadSize, $uploaded)
{
    // emit the progress
    Cache::put('download_status', [
        'resource' => $resource,
        'download_size' => $downloadSize,
        'downloaded' => $downloaded,
        'upload_size' => $uploadSize,
        'uploaded' => $uploaded
    ], 10);
}


问:
Error on compiling AOSP: make: [out/build-aosp_arm.ninja] Killed
Trying to build android from aosp follow the android doc on ubuntu 16.04 x64,jdk and toolchain installed finished,but the build stopped after a few minutes.here is the build log:

```<code>e@ubuntu:/e/aosp$ make -j4
find: ‘vendor’: No such file or directory
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=7.0
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-45-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=NYC
OUT_DIR=out
AUX_OS_VARIANT_LIST=
============================================
ninja: no work to do.
[1/1] soong_build out/soong/build.ninja
Running kati to generate build-aosp_arm.ninja...
out/build-aosp_arm.ninja is missing, regenerating...
find: ‘vendor’: No such file or directory
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=7.0
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-45-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=NYC
OUT_DIR=out
AUX_OS_VARIANT_LIST=
============================================
including out/soong/Android-aosp_arm.mk ...
including ./art/Android.mk ...
including ./bionic/Android.mk ...
including ./bootable/recovery/Android.mk ...
including ./build/make/Android.mk ...
including ./build/target/board/Android.mk ...
including ./build/target/product/security/Android.mk ...
including ./build/tools/Android.mk ...
including ./cts/Android.mk ...
FindEmulator: find: `cts/apps/CtsVerifier/src/android': No such file or directory
FindEmulator: find: `cts/hostsidetests/os/test-apps/HostLinkVerificationApp/src': No such file or directory
FindEmulator: find: `cts/libs/commonutil/src': No such file or directory
FindEmulator: cd: cts/tests/libcore/ojluni/resources: No such file or directory
including ./dalvik/Android.mk ...
including ./developers/samples/android/security/FingerprintDialog/Application/src/main/Android.mk ...
including ./development/apps/BluetoothDebug/Android.mk ...
including ./development/apps/BuildWidget/Android.mk ...
...
including ./development/samples/Support7Demos/Android.mk ...
build/core/package_internal.mk:143: Empty argument supplied to find-subdir-assets
including ./development/samples/SupportAppNavigation/Android.mk ...
including ./development/samples/SupportDesignDemos/Android.mk ...
including ./development/samples/SupportLeanbackDemos/Android.mk ...
including ./development/samples/SupportLeanbackShowcase/app/src/main/Android.mk ...
including ./development/samples/SupportPercentDemos/Android.mk ...
...
including ./external/tlsdate/Android.mk ...
including ./external/toybox/Android.mk ...
awk: line 1: syntax error at or near ,
including ./external/tpm2/Android.mk ...
including ./external/tremolo/Android.mk ...
...
including ./frameworks/av/tools/resampler_tools/Android.mk ...
including ./frameworks/base/Android.mk ...
build/core/package_internal.mk:143: Empty argument supplied to find-subdir-assets
including ./frameworks/compile/libbcc/Android.mk ...
including ./frameworks/compile/mclinker/Android.mk ...
including ./frameworks/compile/slang/Android.mk ...
including ./frameworks/data-binding/Android.mk ...
including ./frameworks/ex/camera2/Android.mk ...
including ./frameworks/ex/common/Android.mk ...
including ./frameworks/ex/framesequence/Android.mk ...
including ./frameworks/minikin/app/Android.mk ...
including ./frameworks/minikin/libs/minikin/Android.mk ...
including ./frameworks/minikin/sample/Android.mk ...
including ./frameworks/minikin/tests/Android.mk ...
including ./frameworks/ml/Android.mk ...
including ./frameworks/multidex/Android.mk ...
including ./frameworks/native/cmds/bugreportz/Android.mk ...
including ./frameworks/native/cmds/cmd/Android.mk ...
including ./frameworks/native/cmds/dumpstate/Android.mk ...
including ./frameworks/native/cmds/flatland/Android.mk ...
including ./frameworks/native/cmds/installd/Android.mk ...
including ./frameworks/native/cmds/ip-up-vpn/Android.mk ...
including ./frameworks/native/cmds/rawbu/Android.mk ...
including ./frameworks/native/opengl/libagl/Android.mk ...
including ./frameworks/native/opengl/libs/Android.mk ...
including ./frameworks/native/opengl/tests/Android.mk ...
including ./frameworks/native/services/inputflinger/Android.mk ...
including ./frameworks/native/services/nativeperms/Android.mk ...
including ./frameworks/native/services/sensorservice/Android.mk ...
including ./frameworks/native/services/surfaceflinger/Android.mk ...
including ./frameworks/native/vulkan/Android.mk ...
including ./frameworks/opt/bitmap/Android.mk ...
including ./frameworks/opt/bluetooth/Android.mk ...
FindEmulator: find: `frameworks/opt/bluetooth/src/android/bluetooth/client/pbap': No such file or directory
including ./frameworks/opt/calendar/Android.mk ...
including ./frameworks/opt/chips/Android.mk ...
including ./frameworks/opt/colorpicker/Android.mk ...
including ./frameworks/opt/datetimepicker/Android.mk ...
including ./frameworks/opt/inputmethodcommon/Android.mk ...
including ./frameworks/opt/net/ethernet/Android.mk ...
including ./frameworks/opt/net/ims/Android.mk ...
including ./frameworks/opt/net/voip/Android.mk ...
including ./frameworks/opt/net/wifi/libwifi_hal/Android.mk ...
including ./frameworks/opt/net/wifi/libwifi_system/Android.mk ...
including ./frameworks/opt/net/wifi/service/Android.mk ...
including ./frameworks/opt/net/wifi/tests/Android.mk ...
including ./frameworks/opt/photoviewer/Android.mk ...
including ./frameworks/opt/setupwizard/library/Android.mk ...
including ./frameworks/opt/setupwizard/navigationbar/Android.mk ...
including ./frameworks/opt/telephony/Android.mk ...
including ./frameworks/opt/timezonepicker/Android.mk ...
including ./frameworks/opt/vcard/Android.mk ...
including ./frameworks/rs/Android.mk ...
including ./frameworks/support/Android.mk ...
FindEmulator: find: `frameworks/support/design/dummy': No such file or directory
FindEmulator: find: `frameworks/support/v17/leanback/dummy': No such file or directory
FindEmulator: find: `frameworks/support/v17/preference-leanback/dummy': No such file or directory
including ./frameworks/volley/Android.mk ...
including ./frameworks/webview/Android.mk ...
including ./frameworks/wilhelm/src/Android.mk ...
including ./frameworks/wilhelm/tests/Android.mk ...
including ./hardware/akm/AK8975_FS/akmdfs/Android.mk ...
including ./hardware/akm/AK8975_FS/libsensors/Android.mk ...
including ./hardware/broadcom/libbt/Android.mk ...
including ./hardware/broadcom/wlan/bcmdhd/Android.mk ...
including ./hardware/google/apf/Android.mk ...
including ./hardware/intel/audio_media/hdmi/Android.mk ...
including ./hardware/intel/bootstub/Android.mk ...
including ./hardware/intel/common/libmix/Android.mk ...
including ./hardware/intel/common/libstagefrighthw/Android.mk ...
including ./hardware/intel/common/libva/Android.mk ...
including ./hardware/intel/common/libwsbm/src/Android.mk ...
including ./hardware/intel/common/omx-components/Android.mk ...
including ./hardware/intel/common/utils/ISV/Android.mk ...
including ./hardware/intel/common/utils/ituxd/Android.mk ...
including ./hardware/intel/common/utils/media_resource_manager/Android.mk ...
including ./hardware/intel/common/wrs_omxil_core/Android.mk ...
including ./hardware/intel/img/hwcomposer/merrifield/Android.mk ...
including ./hardware/intel/img/hwcomposer/moorefield_hdmi/Android.mk ...
including ./hardware/intel/img/psb_headers/Android.mk ...
including ./hardware/intel/img/psb_video/Android.mk ...
including ./hardware/interfaces/bluetooth/1.0/Android.mk ...
including ./hardware/interfaces/boot/1.0/Android.mk ...
including ./hardware/interfaces/nfc/1.0/Android.mk ...
including ./hardware/interfaces/radio/1.0/Android.mk ...
including ./hardware/interfaces/tests/baz/1.0/Android.mk ...
including ./hardware/interfaces/tests/expression/1.0/Android.mk ...
including ./hardware/interfaces/tests/libhwbinder/1.0/Android.mk ...
including ./hardware/interfaces/tests/libhwbinder/aidl/Android.mk ...
including ./hardware/interfaces/wifi/1.0/Android.mk ...
including ./hardware/interfaces/wifi/supplicant/1.0/Android.mk ...
including ./hardware/invensense/Android.mk ...
including ./hardware/libhardware/Android.mk ...
including ./hardware/libhardware_legacy/Android.mk ...
including ./hardware/marvell/bt/Android.mk ...
including ./hardware/qcom/audio/Android.mk ...
including ./hardware/qcom/bootctrl/Android.mk ...
including ./hardware/qcom/bt/Android.mk ...
including ./hardware/qcom/camera/Android.mk ...
including ./hardware/qcom/display/Android.mk ...
including ./hardware/qcom/gps/Android.mk ...
including ./hardware/qcom/keymaster/Android.mk ...
including ./hardware/qcom/media/Android.mk ...
including ./hardware/qcom/power/Android.mk ...
including ./hardware/qcom/wlan/Android.mk ...
including ./hardware/ril/libril/Android.mk ...
including ./hardware/ril/librilutils/Android.mk ...
including ./hardware/ril/reference-ril/Android.mk ...
including ./hardware/ril/rild/Android.mk ...
including ./libcore/Android.mk ...
including ./out/Android.mk ...
including ./packages/apps/BasicSmsReceiver/Android.mk ...
including ./packages/apps/Bluetooth/Android.mk ...
including ./packages/apps/Browser2/Android.mk ...
including ./packages/apps/Calculator/Android.mk ...
including ./packages/apps/Calendar/Android.mk ...
including ./packages/apps/Camera2/Android.mk ...
including ./packages/apps/CarrierConfig/Android.mk ...
including ./packages/apps/CellBroadcastReceiver/Android.mk ...
including ./packages/apps/CertInstaller/Android.mk ...
including ./packages/apps/Contacts/Android.mk ...
FindEmulator: find: `packages/apps/Contacts/src-N': No such file or directory
FindEmulator: find: `packages/apps/PhoneCommon/src-N': No such file or directory
including ./packages/apps/DeskClock/Android.mk ...
including ./packages/apps/DevCamera/Android.mk ...
including ./packages/apps/Dialer/Android.mk ...
FindEmulator: find: `packages/apps/Dialer/InCallUI/src-N': No such file or directory
FindEmulator: find: `packages/apps/PhoneCommon/src-N': No such file or directory
including ./packages/apps/Email/Android.mk ...
including ./packages/apps/EmergencyInfo/Android.mk ...
including ./packages/apps/ExactCalculator/Android.mk ...
including ./packages/apps/Gallery/Android.mk ...
including ./packages/apps/Gallery2/Android.mk ...
including ./packages/apps/HTMLViewer/Android.mk ...
including ./packages/apps/KeyChain/Android.mk ...
including ./packages/apps/Launcher2/Android.mk ...
including ./packages/apps/Launcher3/Android.mk ...
including ./packages/apps/LegacyCamera/Android.mk ...
including ./packages/apps/ManagedProvisioning/Android.mk ...
including ./packages/apps/Messaging/Android.mk ...
including ./packages/apps/Music/Android.mk ...
including ./packages/apps/MusicFX/Android.mk ...
including ./packages/apps/Nfc/Android.mk ...
including ./packages/apps/OneTimeInitializer/Android.mk ...
including ./packages/apps/PackageInstaller/Android.mk ...
including ./packages/apps/PhoneCommon/Android.mk ...
including ./packages/apps/Protips/Android.mk ...
including ./packages/apps/Provision/Android.mk ...
including ./packages/apps/QuickSearchBox/Android.mk ...
including ./packages/apps/Settings/Android.mk ...
including ./packages/apps/SoundRecorder/Android.mk ...
including ./packages/apps/SpareParts/Android.mk ...
including ./packages/apps/SpeechRecorder/Android.mk ...
including ./packages/apps/Stk/Android.mk ...
including ./packages/apps/TV/Android.mk ...
including ./packages/apps/Tag/Android.mk ...
including ./packages/apps/Terminal/Android.mk ...
including ./packages/apps/Test/connectivity/sl4n/Android.mk ...
including ./packages/apps/TvSettings/QuickSettings/Android.mk ...
including ./packages/apps/TvSettings/Settings/Android.mk ...
including ./packages/apps/UnifiedEmail/Android.mk ...
including ./packages/experimental/Android.mk ...
including ./packages/inputmethods/LatinIME/Android.mk ...
including ./packages/inputmethods/OpenWnn/Android.mk ...
including ./packages/providers/BlockedNumberProvider/Android.mk ...
including ./packages/providers/BookmarkProvider/Android.mk ...
including ./packages/providers/CalendarProvider/Android.mk ...
including ./packages/providers/CallLogProvider/Android.mk ...
including ./packages/providers/ContactsProvider/Android.mk ...
including ./packages/providers/DownloadProvider/Android.mk ...
including ./packages/providers/MediaProvider/Android.mk ...
including ./packages/providers/PartnerBookmarksProvider/Android.mk ...
including ./packages/providers/TelephonyProvider/Android.mk ...
including ./packages/providers/TvProvider/Android.mk ...
including ./packages/providers/UserDictionaryProvider/Android.mk ...
including ./packages/screensavers/Basic/Android.mk ...
including ./packages/screensavers/PhotoTable/Android.mk ...
including ./packages/screensavers/WebView/Android.mk ...
including ./packages/services/Car/Android.mk ...
FindEmulator: find: `packages/services/Car/car-support-lib/dummy': No such file or directory
including ./packages/services/Mms/Android.mk ...
including ./packages/services/Telecomm/Android.mk ...
including ./packages/services/Telephony/Android.mk ...
including ./packages/wallpapers/LivePicker/Android.mk ...
including ./pdk/apps/HelloPDK/Android.mk ...
including ./pdk/apps/TestingCamera/Android.mk ...
including ./pdk/apps/TestingCamera2/Android.mk ...
including ./platform_testing/libraries/annotations/Android.mk ...
including ./platform_testing/libraries/app-helpers/Android.mk ...
FindEmulator: find: `platform_testing/libraries/app-helpers/src': No such file or directory
FindEmulator: find: `platform_testing/libraries/app-helpers/src': No such file or directory
including ./platform_testing/libraries/aupt-lib/Android.mk ...
including ./platform_testing/libraries/base-app-helpers/Android.mk ...
including ./platform_testing/libraries/chrome-app-helper/Android.mk ...
including ./platform_testing/libraries/facebook-app-helper/Android.mk ...
including ./platform_testing/libraries/flightdemo-app-helper/Android.mk ...
including ./platform_testing/libraries/gmail-app-helper/Android.mk ...
including ./platform_testing/libraries/google-app-camera-helper/Android.mk ...
including ./platform_testing/libraries/google-docs-app-helper/Android.mk ...
including ./platform_testing/libraries/google-keyboard-app-helper/Android.mk ...
including ./platform_testing/libraries/google-messenger-app-helper/Android.mk ...
including ./platform_testing/libraries/launcher-helper/Android.mk ...
including ./platform_testing/libraries/maps-app-helper/Android.mk ...
including ./platform_testing/libraries/photos-app-helper/Android.mk ...
including ./platform_testing/libraries/play-books-app-helper/Android.mk ...
including ./platform_testing/libraries/play-movies-app-helper/Android.mk ...
including ./platform_testing/libraries/play-music-app-helper/Android.mk ...
including ./platform_testing/libraries/play-store-app-helper/Android.mk ...
including ./platform_testing/libraries/power-helper/Android.mk ...
including ./platform_testing/libraries/recents-app-helper/Android.mk ...
including ./platform_testing/libraries/reddit-app-helper/Android.mk ...
including ./platform_testing/libraries/settings-app-helper/Android.mk ...
including ./platform_testing/libraries/timeresult-helper/Android.mk ...
including ./platform_testing/libraries/tunein-app-helper/Android.mk ...
including ./platform_testing/libraries/youtube-app-helper/Android.mk ...
including ./platform_testing/scripts/perf-setup/Android.mk ...
including ./platform_testing/tests/androidbvt/Android.mk ...
including ./platform_testing/tests/camera/aupt-profile/Android.mk ...
including ./platform_testing/tests/functional/applinktests/Android.mk ...
including ./platform_testing/tests/functional/appsmoke/Android.mk ...
including ./platform_testing/tests/functional/downloadapp/Android.mk ...
including ./platform_testing/tests/functional/externalstorage/Android.mk ...
including ./platform_testing/tests/functional/launchertests/Android.mk ...
including ./platform_testing/tests/functional/notificationtests/Android.mk ...
including ./platform_testing/tests/functional/otatests/Android.mk ...
including ./platform_testing/tests/functional/permission/Android.mk ...
including ./platform_testing/tests/functional/settingstests/Android.mk ...
including ./platform_testing/tests/functional/testapks/applinktestapp/Android.mk ...
including ./platform_testing/tests/functional/testapks/permissiontestappmv1/Android.mk ...
including ./platform_testing/tests/jank/UbSystemUiJankTests/Android.mk ...
including ./platform_testing/tests/jank/androidtvjanktests/Android.mk ...
including ./platform_testing/tests/jank/dialer/Android.mk ...
including ./platform_testing/tests/jank/jankmicrobenchmark/Android.mk ...
including ./platform_testing/tests/jank/sysapp/Android.mk ...
including ./platform_testing/tests/jank/sysapp_wear/Android.mk ...
including ./platform_testing/tests/jank/uibench/Android.mk ...
including ./platform_testing/tests/jank/uibench_wear/Android.mk ...
including ./platform_testing/tests/jank/webview/Android.mk ...
including ./platform_testing/tests/perf/PerformanceAppTest/Android.mk ...
including ./platform_testing/tests/perf/PerformanceLaunch/Android.mk ...
including ./platform_testing/tests/perf/PowerPerfTest/Android.mk ...
including ./platform_testing/tests/smokefast/Android.mk ...
including ./platform_testing/utils/crashcollector/Android.mk ...
including ./platform_testing/utils/dialogs/Android.mk ...
including ./platform_testing/utils/permissions/Android.mk ...
including ./prebuilts/clang/host/linux-x86/Android.mk ...
including ./prebuilts/misc/Android.mk ...
build/core/ninja.mk:168: recipe for target 'out/build-aosp_arm.ninja' failed
make: *** [out/build-aosp_arm.ninja] Killed

#### make failed to build some targets (10:06 (mm:ss)) ####
</code>```

and i have try the showcommands arg but it did't tell me any details.how can i get more verbose by the way?
thanks.

答:
Make sure that you run all the previous commands before make such as:

```<code>$ source build/envsetup.sh
$ lunch aosp_arm-user
$ make -j4
</code>```

See: Preparing to Build for more details.

If you did, most likely you run of the memory which would explain why the compilation process got killed:

make: *** [out/build-aosp_arm.ninja] Killed

As I had similar problem when compiling on EC2 instance and I had this when running dmesg:

```<code>aosp$ sudo dmesg | tail
Out of memory: Kill process 3252 (ckati) score 903 or sacrifice child
Killed process 3252 (ckati) total-vm:982496kB, anon-rss:916824kB, file-rss:20kB
</code>```

Solution

First of all, check the resource limits by: ulimit -a and increase max memory size if needed.

If your total system memory is low (top -m), for example when you're running this compilation on VM instance (like EC2), try increasing your memory and try again.

Another easier solution is to add a swap file to increase your total system memory.

If you've got another memory issue later on, consider increasing heap size for java as well.

Body:
Trying to build android from aosp follow the android doc on ubuntu 16.04 x64,jdk and toolchain installed finished,but the build stopped after a few minutes.here is the build log:

e@ubuntu:/e/aosp$ make -j4
find: ‘vendor’: No such file or directory
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=7.0
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-45-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=NYC
OUT_DIR=out
AUX_OS_VARIANT_LIST=
============================================
ninja: no work to do.
[1/1] soong_build out/soong/build.ninja
Running kati to generate build-aosp_arm.ninja...
out/build-aosp_arm.ninja is missing, regenerating...
find: ‘vendor’: No such file or directory
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=7.0
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-45-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=NYC
OUT_DIR=out
AUX_OS_VARIANT_LIST=
============================================
including out/soong/Android-aosp_arm.mk ...
including ./art/Android.mk ...
including ./bionic/Android.mk ...
including ./bootable/recovery/Android.mk ...
including ./build/make/Android.mk ...
including ./build/target/board/Android.mk ...
including ./build/target/product/security/Android.mk ...
including ./build/tools/Android.mk ...
including ./cts/Android.mk ...
FindEmulator: find: `cts/apps/CtsVerifier/src/android': No such file or directory
FindEmulator: find: `cts/hostsidetests/os/test-apps/HostLinkVerificationApp/src': No such file or directory
FindEmulator: find: `cts/libs/commonutil/src': No such file or directory
FindEmulator: cd: cts/tests/libcore/ojluni/resources: No such file or directory
including ./dalvik/Android.mk ...
including ./developers/samples/android/security/FingerprintDialog/Application/src/main/Android.mk ...
including ./development/apps/BluetoothDebug/Android.mk ...
including ./development/apps/BuildWidget/Android.mk ...
...
including ./development/samples/Support7Demos/Android.mk ...
build/core/package_internal.mk:143: Empty argument supplied to find-subdir-assets
including ./development/samples/SupportAppNavigation/Android.mk ...
including ./development/samples/SupportDesignDemos/Android.mk ...
including ./development/samples/SupportLeanbackDemos/Android.mk ...
including ./development/samples/SupportLeanbackShowcase/app/src/main/Android.mk ...
including ./development/samples/SupportPercentDemos/Android.mk ...
...
including ./external/tlsdate/Android.mk ...
including ./external/toybox/Android.mk ...
awk: line 1: syntax error at or near ,
including ./external/tpm2/Android.mk ...
including ./external/tremolo/Android.mk ...
...
including ./frameworks/av/tools/resampler_tools/Android.mk ...
including ./frameworks/base/Android.mk ...
build/core/package_internal.mk:143: Empty argument supplied to find-subdir-assets
including ./frameworks/compile/libbcc/Android.mk ...
including ./frameworks/compile/mclinker/Android.mk ...
including ./frameworks/compile/slang/Android.mk ...
including ./frameworks/data-binding/Android.mk ...
including ./frameworks/ex/camera2/Android.mk ...
including ./frameworks/ex/common/Android.mk ...
including ./frameworks/ex/framesequence/Android.mk ...
including ./frameworks/minikin/app/Android.mk ...
including ./frameworks/minikin/libs/minikin/Android.mk ...
including ./frameworks/minikin/sample/Android.mk ...
including ./frameworks/minikin/tests/Android.mk ...
including ./frameworks/ml/Android.mk ...
including ./frameworks/multidex/Android.mk ...
including ./frameworks/native/cmds/bugreportz/Android.mk ...
including ./frameworks/native/cmds/cmd/Android.mk ...
including ./frameworks/native/cmds/dumpstate/Android.mk ...
including ./frameworks/native/cmds/flatland/Android.mk ...
including ./frameworks/native/cmds/installd/Android.mk ...
including ./frameworks/native/cmds/ip-up-vpn/Android.mk ...
including ./frameworks/native/cmds/rawbu/Android.mk ...
including ./frameworks/native/opengl/libagl/Android.mk ...
including ./frameworks/native/opengl/libs/Android.mk ...
including ./frameworks/native/opengl/tests/Android.mk ...
including ./frameworks/native/services/inputflinger/Android.mk ...
including ./frameworks/native/services/nativeperms/Android.mk ...
including ./frameworks/native/services/sensorservice/Android.mk ...
including ./frameworks/native/services/surfaceflinger/Android.mk ...
including ./frameworks/native/vulkan/Android.mk ...
including ./frameworks/opt/bitmap/Android.mk ...
including ./frameworks/opt/bluetooth/Android.mk ...
FindEmulator: find: `frameworks/opt/bluetooth/src/android/bluetooth/client/pbap': No such file or directory
including ./frameworks/opt/calendar/Android.mk ...
including ./frameworks/opt/chips/Android.mk ...
including ./frameworks/opt/colorpicker/Android.mk ...
including ./frameworks/opt/datetimepicker/Android.mk ...
including ./frameworks/opt/inputmethodcommon/Android.mk ...
including ./frameworks/opt/net/ethernet/Android.mk ...
including ./frameworks/opt/net/ims/Android.mk ...
including ./frameworks/opt/net/voip/Android.mk ...
including ./frameworks/opt/net/wifi/libwifi_hal/Android.mk ...
including ./frameworks/opt/net/wifi/libwifi_system/Android.mk ...
including ./frameworks/opt/net/wifi/service/Android.mk ...
including ./frameworks/opt/net/wifi/tests/Android.mk ...
including ./frameworks/opt/photoviewer/Android.mk ...
including ./frameworks/opt/setupwizard/library/Android.mk ...
including ./frameworks/opt/setupwizard/navigationbar/Android.mk ...
including ./frameworks/opt/telephony/Android.mk ...
including ./frameworks/opt/timezonepicker/Android.mk ...
including ./frameworks/opt/vcard/Android.mk ...
including ./frameworks/rs/Android.mk ...
including ./frameworks/support/Android.mk ...
FindEmulator: find: `frameworks/support/design/dummy': No such file or directory
FindEmulator: find: `frameworks/support/v17/leanback/dummy': No such file or directory
FindEmulator: find: `frameworks/support/v17/preference-leanback/dummy': No such file or directory
including ./frameworks/volley/Android.mk ...
including ./frameworks/webview/Android.mk ...
including ./frameworks/wilhelm/src/Android.mk ...
including ./frameworks/wilhelm/tests/Android.mk ...
including ./hardware/akm/AK8975_FS/akmdfs/Android.mk ...
including ./hardware/akm/AK8975_FS/libsensors/Android.mk ...
including ./hardware/broadcom/libbt/Android.mk ...
including ./hardware/broadcom/wlan/bcmdhd/Android.mk ...
including ./hardware/google/apf/Android.mk ...
including ./hardware/intel/audio_media/hdmi/Android.mk ...
including ./hardware/intel/bootstub/Android.mk ...
including ./hardware/intel/common/libmix/Android.mk ...
including ./hardware/intel/common/libstagefrighthw/Android.mk ...
including ./hardware/intel/common/libva/Android.mk ...
including ./hardware/intel/common/libwsbm/src/Android.mk ...
including ./hardware/intel/common/omx-components/Android.mk ...
including ./hardware/intel/common/utils/ISV/Android.mk ...
including ./hardware/intel/common/utils/ituxd/Android.mk ...
including ./hardware/intel/common/utils/media_resource_manager/Android.mk ...
including ./hardware/intel/common/wrs_omxil_core/Android.mk ...
including ./hardware/intel/img/hwcomposer/merrifield/Android.mk ...
including ./hardware/intel/img/hwcomposer/moorefield_hdmi/Android.mk ...
including ./hardware/intel/img/psb_headers/Android.mk ...
including ./hardware/intel/img/psb_video/Android.mk ...
including ./hardware/interfaces/bluetooth/1.0/Android.mk ...
including ./hardware/interfaces/boot/1.0/Android.mk ...
including ./hardware/interfaces/nfc/1.0/Android.mk ...
including ./hardware/interfaces/radio/1.0/Android.mk ...
including ./hardware/interfaces/tests/baz/1.0/Android.mk ...
including ./hardware/interfaces/tests/expression/1.0/Android.mk ...
including ./hardware/interfaces/tests/libhwbinder/1.0/Android.mk ...
including ./hardware/interfaces/tests/libhwbinder/aidl/Android.mk ...
including ./hardware/interfaces/wifi/1.0/Android.mk ...
including ./hardware/interfaces/wifi/supplicant/1.0/Android.mk ...
including ./hardware/invensense/Android.mk ...
including ./hardware/libhardware/Android.mk ...
including ./hardware/libhardware_legacy/Android.mk ...
including ./hardware/marvell/bt/Android.mk ...
including ./hardware/qcom/audio/Android.mk ...
including ./hardware/qcom/bootctrl/Android.mk ...
including ./hardware/qcom/bt/Android.mk ...
including ./hardware/qcom/camera/Android.mk ...
including ./hardware/qcom/display/Android.mk ...
including ./hardware/qcom/gps/Android.mk ...
including ./hardware/qcom/keymaster/Android.mk ...
including ./hardware/qcom/media/Android.mk ...
including ./hardware/qcom/power/Android.mk ...
including ./hardware/qcom/wlan/Android.mk ...
including ./hardware/ril/libril/Android.mk ...
including ./hardware/ril/librilutils/Android.mk ...
including ./hardware/ril/reference-ril/Android.mk ...
including ./hardware/ril/rild/Android.mk ...
including ./libcore/Android.mk ...
including ./out/Android.mk ...
including ./packages/apps/BasicSmsReceiver/Android.mk ...
including ./packages/apps/Bluetooth/Android.mk ...
including ./packages/apps/Browser2/Android.mk ...
including ./packages/apps/Calculator/Android.mk ...
including ./packages/apps/Calendar/Android.mk ...
including ./packages/apps/Camera2/Android.mk ...
including ./packages/apps/CarrierConfig/Android.mk ...
including ./packages/apps/CellBroadcastReceiver/Android.mk ...
including ./packages/apps/CertInstaller/Android.mk ...
including ./packages/apps/Contacts/Android.mk ...
FindEmulator: find: `packages/apps/Contacts/src-N': No such file or directory
FindEmulator: find: `packages/apps/PhoneCommon/src-N': No such file or directory
including ./packages/apps/DeskClock/Android.mk ...
including ./packages/apps/DevCamera/Android.mk ...
including ./packages/apps/Dialer/Android.mk ...
FindEmulator: find: `packages/apps/Dialer/InCallUI/src-N': No such file or directory
FindEmulator: find: `packages/apps/PhoneCommon/src-N': No such file or directory
including ./packages/apps/Email/Android.mk ...
including ./packages/apps/EmergencyInfo/Android.mk ...
including ./packages/apps/ExactCalculator/Android.mk ...
including ./packages/apps/Gallery/Android.mk ...
including ./packages/apps/Gallery2/Android.mk ...
including ./packages/apps/HTMLViewer/Android.mk ...
including ./packages/apps/KeyChain/Android.mk ...
including ./packages/apps/Launcher2/Android.mk ...
including ./packages/apps/Launcher3/Android.mk ...
including ./packages/apps/LegacyCamera/Android.mk ...
including ./packages/apps/ManagedProvisioning/Android.mk ...
including ./packages/apps/Messaging/Android.mk ...
including ./packages/apps/Music/Android.mk ...
including ./packages/apps/MusicFX/Android.mk ...
including ./packages/apps/Nfc/Android.mk ...
including ./packages/apps/OneTimeInitializer/Android.mk ...
including ./packages/apps/PackageInstaller/Android.mk ...
including ./packages/apps/PhoneCommon/Android.mk ...
including ./packages/apps/Protips/Android.mk ...
including ./packages/apps/Provision/Android.mk ...
including ./packages/apps/QuickSearchBox/Android.mk ...
including ./packages/apps/Settings/Android.mk ...
including ./packages/apps/SoundRecorder/Android.mk ...
including ./packages/apps/SpareParts/Android.mk ...
including ./packages/apps/SpeechRecorder/Android.mk ...
including ./packages/apps/Stk/Android.mk ...
including ./packages/apps/TV/Android.mk ...
including ./packages/apps/Tag/Android.mk ...
including ./packages/apps/Terminal/Android.mk ...
including ./packages/apps/Test/connectivity/sl4n/Android.mk ...
including ./packages/apps/TvSettings/QuickSettings/Android.mk ...
including ./packages/apps/TvSettings/Settings/Android.mk ...
including ./packages/apps/UnifiedEmail/Android.mk ...
including ./packages/experimental/Android.mk ...
including ./packages/inputmethods/LatinIME/Android.mk ...
including ./packages/inputmethods/OpenWnn/Android.mk ...
including ./packages/providers/BlockedNumberProvider/Android.mk ...
including ./packages/providers/BookmarkProvider/Android.mk ...
including ./packages/providers/CalendarProvider/Android.mk ...
including ./packages/providers/CallLogProvider/Android.mk ...
including ./packages/providers/ContactsProvider/Android.mk ...
including ./packages/providers/DownloadProvider/Android.mk ...
including ./packages/providers/MediaProvider/Android.mk ...
including ./packages/providers/PartnerBookmarksProvider/Android.mk ...
including ./packages/providers/TelephonyProvider/Android.mk ...
including ./packages/providers/TvProvider/Android.mk ...
including ./packages/providers/UserDictionaryProvider/Android.mk ...
including ./packages/screensavers/Basic/Android.mk ...
including ./packages/screensavers/PhotoTable/Android.mk ...
including ./packages/screensavers/WebView/Android.mk ...
including ./packages/services/Car/Android.mk ...
FindEmulator: find: `packages/services/Car/car-support-lib/dummy': No such file or directory
including ./packages/services/Mms/Android.mk ...
including ./packages/services/Telecomm/Android.mk ...
including ./packages/services/Telephony/Android.mk ...
including ./packages/wallpapers/LivePicker/Android.mk ...
including ./pdk/apps/HelloPDK/Android.mk ...
including ./pdk/apps/TestingCamera/Android.mk ...
including ./pdk/apps/TestingCamera2/Android.mk ...
including ./platform_testing/libraries/annotations/Android.mk ...
including ./platform_testing/libraries/app-helpers/Android.mk ...
FindEmulator: find: `platform_testing/libraries/app-helpers/src': No such file or directory
FindEmulator: find: `platform_testing/libraries/app-helpers/src': No such file or directory
including ./platform_testing/libraries/aupt-lib/Android.mk ...
including ./platform_testing/libraries/base-app-helpers/Android.mk ...
including ./platform_testing/libraries/chrome-app-helper/Android.mk ...
including ./platform_testing/libraries/facebook-app-helper/Android.mk ...
including ./platform_testing/libraries/flightdemo-app-helper/Android.mk ...
including ./platform_testing/libraries/gmail-app-helper/Android.mk ...
including ./platform_testing/libraries/google-app-camera-helper/Android.mk ...
including ./platform_testing/libraries/google-docs-app-helper/Android.mk ...
including ./platform_testing/libraries/google-keyboard-app-helper/Android.mk ...
including ./platform_testing/libraries/google-messenger-app-helper/Android.mk ...
including ./platform_testing/libraries/launcher-helper/Android.mk ...
including ./platform_testing/libraries/maps-app-helper/Android.mk ...
including ./platform_testing/libraries/photos-app-helper/Android.mk ...
including ./platform_testing/libraries/play-books-app-helper/Android.mk ...
including ./platform_testing/libraries/play-movies-app-helper/Android.mk ...
including ./platform_testing/libraries/play-music-app-helper/Android.mk ...
including ./platform_testing/libraries/play-store-app-helper/Android.mk ...
including ./platform_testing/libraries/power-helper/Android.mk ...
including ./platform_testing/libraries/recents-app-helper/Android.mk ...
including ./platform_testing/libraries/reddit-app-helper/Android.mk ...
including ./platform_testing/libraries/settings-app-helper/Android.mk ...
including ./platform_testing/libraries/timeresult-helper/Android.mk ...
including ./platform_testing/libraries/tunein-app-helper/Android.mk ...
including ./platform_testing/libraries/youtube-app-helper/Android.mk ...
including ./platform_testing/scripts/perf-setup/Android.mk ...
including ./platform_testing/tests/androidbvt/Android.mk ...
including ./platform_testing/tests/camera/aupt-profile/Android.mk ...
including ./platform_testing/tests/functional/applinktests/Android.mk ...
including ./platform_testing/tests/functional/appsmoke/Android.mk ...
including ./platform_testing/tests/functional/downloadapp/Android.mk ...
including ./platform_testing/tests/functional/externalstorage/Android.mk ...
including ./platform_testing/tests/functional/launchertests/Android.mk ...
including ./platform_testing/tests/functional/notificationtests/Android.mk ...
including ./platform_testing/tests/functional/otatests/Android.mk ...
including ./platform_testing/tests/functional/permission/Android.mk ...
including ./platform_testing/tests/functional/settingstests/Android.mk ...
including ./platform_testing/tests/functional/testapks/applinktestapp/Android.mk ...
including ./platform_testing/tests/functional/testapks/permissiontestappmv1/Android.mk ...
including ./platform_testing/tests/jank/UbSystemUiJankTests/Android.mk ...
including ./platform_testing/tests/jank/androidtvjanktests/Android.mk ...
including ./platform_testing/tests/jank/dialer/Android.mk ...
including ./platform_testing/tests/jank/jankmicrobenchmark/Android.mk ...
including ./platform_testing/tests/jank/sysapp/Android.mk ...
including ./platform_testing/tests/jank/sysapp_wear/Android.mk ...
including ./platform_testing/tests/jank/uibench/Android.mk ...
including ./platform_testing/tests/jank/uibench_wear/Android.mk ...
including ./platform_testing/tests/jank/webview/Android.mk ...
including ./platform_testing/tests/perf/PerformanceAppTest/Android.mk ...
including ./platform_testing/tests/perf/PerformanceLaunch/Android.mk ...
including ./platform_testing/tests/perf/PowerPerfTest/Android.mk ...
including ./platform_testing/tests/smokefast/Android.mk ...
including ./platform_testing/utils/crashcollector/Android.mk ...
including ./platform_testing/utils/dialogs/Android.mk ...
including ./platform_testing/utils/permissions/Android.mk ...
including ./prebuilts/clang/host/linux-x86/Android.mk ...
including ./prebuilts/misc/Android.mk ...
build/core/ninja.mk:168: recipe for target 'out/build-aosp_arm.ninja' failed
make: *** [out/build-aosp_arm.ninja] Killed

#### make failed to build some targets (10:06 (mm:ss)) ####

and i have try the showcommands arg but it did't tell me any details.how can i get more verbose by the way?
thanks.

Body:
Make sure that you run all the previous commands before make such as:

$ source build/envsetup.sh
$ lunch aosp_arm-user
$ make -j4

See: Preparing to Build for more details.

If you did, most likely you run of the memory which would explain why the compilation process got killed:

make: *** [out/build-aosp_arm.ninja] Killed

As I had similar problem when compiling on EC2 instance and I had this when running dmesg:

aosp$ sudo dmesg | tail
Out of memory: Kill process 3252 (ckati) score 903 or sacrifice child
Killed process 3252 (ckati) total-vm:982496kB, anon-rss:916824kB, file-rss:20kB

Solution

First of all, check the resource limits by: ulimit -a and increase max memory size if needed.

If your total system memory is low (top -m), for example when you're running this compilation on VM instance (like EC2), try increasing your memory and try again.

Another easier solution is to add a swap file to increase your total system memory.

If you've got another memory issue later on, consider increasing heap size for java as well.


问:
Why do we have implicit receiver in Ruby?
I have two questions regarding Ruby core OOP concepts.

I understand the differences between explicit call  (i.e. with self) and implicit call (i.e. without initialized class object or self in an instance method) of a method. When we have explicit receivers that do very neat and clear job of receiving a method with self (since it refers to the current object) rather than implicit ones (which I believe is very uncertain in situations like when to use method or variable of same name initialized), then why do we still have to call methods implicitly? Is it just a preference or is it necessary because of proper usage of private and public methods?.

In general, OOP private methods are bound within the class itself and cannot be accessed in subclasses or outside. However, those methods that need to be private but also need to be accessed in subclasses then protected methods are used over there. But in Ruby, both private and
protected methods are accessed in inherited classes, and the only difference is that private methods can only be called implicitly and protected methods can either be called implicitly or explicitly. I don't understand the philosophy over here that only because of implicit calling functionality in ruby, general definitions of private methods differ?

答:
In the discussion below, recall that the only way to call an instance method with an implicit receiver (self) is to do so from within an instance method of the same class.

The question is why Ruby was designed to permit most1 instance methods to be called with an implicit receiver.

One would probably have to ask Matz to get an authoritative answer, but my guess is that it traces back to the way private instance methods were implemented. Requiring that they be called with an implicit receiver was seen (I'm guessing) as a simple way to prevent them from being called from anywhere other than from within an instance method of the same class.

But if private methods must be called with an implicit receiver, in the interest of consistency wouldn't it have made sense to permit (nearly all) public and protected instance methods to be called with an implicit receiver?

Some Rubiests see the use of the explicit receiver self as redundant, and therefore use an implicit receiver (except where self. is required). Others see the use of implicit receivers as a potential source of confusion, so use self., knowing (or possibly not knowing), that is optional. So far as I know, all core Ruby methods implemented in Ruby use implicit receivers. Those in the first camp might argue that using self. redundantly is akin to saying "Meet me at the blue wall that is colored blue".

1 There are a handful of cases where the explicit receiver self is required to avoid ambiguity. The two most common are when invoking the method class (considering class is also a keyword) and invoking a setter, which Ruby might otherwise confuse with the assignment of a value to a newly-created local variable. Another example is that we cannot write Array methods def a; [1]; end nor def a; [](1); end. Again, an explicit receiver is needed: self[1] or self.[](1).