问:
Get EOFException while reading serialized object in Java
I have two methods, one that serialize the Object, and it works ok:

```<code>public void record()throws RecordingException
    {
        ObjectOutputStream outputStream = null;
        try
        {
            outputStream = new ObjectOutputStream(new FileOutputStream("src/data/employee.dat"));
            outputStream.writeObject(this);
        } catch (FileNotFoundException ex)
        {
            ex.printStackTrace();
            throw new RecordingException(ex);
        } catch (IOException ex)
        {
            ex.printStackTrace();
            throw new RecordingException(ex);
        }finally
        {
            try
            {
                if (outputStream != null) outputStream.close();
            } catch (IOException ex){}
        }
    }
</code>```

The problem here when deserializing the object, I get EOFException!:

```<code>public final User loadObject(UserType usertype) throws InvalidLoadObjectException
    {
        ObjectInputStream istream = null;
        String path = null;
        if (usertype == UserType.EMPLOYEE)
        {
            path = "data/employee.dat";
        }else if (usertype == UserType.CUSTOMER)
        {
            path = "data/customer.dat";
        }else
            throw new InvalidLoadObjectException("Object is not a sub class of User");

        try
        {
            istream = new ObjectInputStream(ObjectLoader.class.getClassLoader().getResourceAsStream(path));

            User u = loadObject(istream);
            istream.close();
            return u;
        }catch (EOFException ex)
        {
            System.out.println(ex.getMessage());
            return null;
        }catch(Exception ex)
        {
            ex.printStackTrace();
            throw new InvalidLoadObjectException(ex);
        }
    }

private User loadObject(ObjectInputStream stream) throws InvalidLoadObjectException
    {
        try
        {
            return (User) stream.readObject();
        } catch (IOException ex)
        {
            ex.printStackTrace();
            throw new InvalidLoadObjectException(ex);
        } catch (ClassNotFoundException ex)
        {
            ex.printStackTrace();
            throw new InvalidLoadObjectException(ex);
        }
    }
</code>```

答: I don't know if this is the cause of your problem, but the code that writes the file has a subtle flaw.  In the finally block, you close the stream and ignore any exceptions.  If the close() method performs a final flush(), then any exceptions thrown in the flush will go unreported.

Body:
I have two methods, one that serialize the Object, and it works ok:

public void record()throws RecordingException
    {
        ObjectOutputStream outputStream = null;
        try
        {
            outputStream = new ObjectOutputStream(new FileOutputStream("src/data/employee.dat"));
            outputStream.writeObject(this);
        } catch (FileNotFoundException ex)
        {
            ex.printStackTrace();
            throw new RecordingException(ex);
        } catch (IOException ex)
        {
            ex.printStackTrace();
            throw new RecordingException(ex);
        }finally
        {
            try
            {
                if (outputStream != null) outputStream.close();
            } catch (IOException ex){}
        }
    }

The problem here when deserializing the object, I get EOFException!:

public final User loadObject(UserType usertype) throws InvalidLoadObjectException
    {
        ObjectInputStream istream = null;
        String path = null;
        if (usertype == UserType.EMPLOYEE)
        {
            path = "data/employee.dat";
        }else if (usertype == UserType.CUSTOMER)
        {
            path = "data/customer.dat";
        }else
            throw new InvalidLoadObjectException("Object is not a sub class of User");

        try
        {
            istream = new ObjectInputStream(ObjectLoader.class.getClassLoader().getResourceAsStream(path));

            User u = loadObject(istream);
            istream.close();
            return u;
        }catch (EOFException ex)
        {
            System.out.println(ex.getMessage());
            return null;
        }catch(Exception ex)
        {
            ex.printStackTrace();
            throw new InvalidLoadObjectException(ex);
        }
    }

private User loadObject(ObjectInputStream stream) throws InvalidLoadObjectException
    {
        try
        {
            return (User) stream.readObject();
        } catch (IOException ex)
        {
            ex.printStackTrace();
            throw new InvalidLoadObjectException(ex);
        } catch (ClassNotFoundException ex)
        {
            ex.printStackTrace();
            throw new InvalidLoadObjectException(ex);
        }
    }


来源: stackexchange

问:
Can not append option element dynamically using Jquery/Javascript and css
I have an issue. I am trying to append option tag dynamically but its not coming properly using Jquery/Javascript.Here also I am using bootstrap chosen-select class. I am explaining my code below.

```<code><div class="popover-content">
<p>
<select class="chosen-select text-left" style="width:100%;" id="ctid">
<option value="" selected>Select City</option>
</select>
</p>
</div>
</code>```

My javascript code is given below.

```<code>var url="common.php?action=getCity";
$.post(url,{"con_data":conval.options[conval.selectedIndex].value},function(data){
    var obj=JSON.parse(data);
    if(obj.isData==1){
        $('#ctid').find('option').not(':first').remove();
        $.each(obj.cid, function() {
    $("#ctid").append("<option value="+this.city_id+">"+this.city_name+"</option>");
        })
    }
})
</code>```

Here also i am getting the data properly and the loop is also running.But its not reflecting at front end.when I did inspect element i got the below generated html code.

```<code><div class="popover-content">
<p>
<select class="chosen-select text-left" style="width: 100%; display: none;" id="ctid">
<option value="" selected="">Select City</option>
<option value="18">Bhubaneswar</option>
<option value="17">Delhi</option>
<option value="16">Bangalore</option>
<option value="15">Mumbai</option>
</select>
<div class="chosen-container chosen-container-single chosen-with-drop chosen-container-active" style="width: 0px;" title="" id="ctid_chosen">
<a class="chosen-single" tabindex="-1"><span>Select City</span>
<div><b></b>
</div>
</a>
<div class="chosen-drop">
<div class="chosen-search">
<input type="text" autocomplete="off">
</div>
<ul class="chosen-results">
<li class="active-result result-selected" data-option-array-index="0">Select City</li>
</ul>
</div>
</div>
</p>
</div>
</code>```

The raw html code is generating the above part after option added dynamically.But my problem is thosze are not display on the front end view.Please help me to resolve thisz issue.

答:
I think each loop every object and gives index as its first param and val as second, try this:

```<code>$.each(obj.cid, function(idx, o) {
  $("#ctid").append("<option value="+o.city_id+">"+o.city_name+"</option>");
});
</code>```

If you would like to get the options in the resulting ul, then make sure to append them first before initing chosen.

```<code>$.each(obj, function(idx, o) {
  $("#ctid").append("<option value=" + o.city_id + ">" + o.city_name + "</option>");
});

$('#ctid').addClass('chosen-select');
$('.chosen-select').chosen();
</code>```

HTML

```<code><div class="popover-content">
  <p>
    <select class="text-left" style="width:100%;" id="ctid">
      <option value="" selected>Select City</option>
    </select>
  </p>
</div>
</code>```

Hope this helps

ContentLicense: CC BY-SA 3.0

Body:
I have an issue. I am trying to append option tag dynamically but its not coming properly using Jquery/Javascript.Here also I am using bootstrap chosen-select class. I am explaining my code below.

<select class="chosen-select text-left" style="width:100%;" id="ctid">
<option value="" selected>Select City</option>
</select>

My javascript code is given below.

var url="common.php?action=getCity";
$.post(url,{"con_data":conval.options[conval.selectedIndex].value},function(data){
    var obj=JSON.parse(data);
    if(obj.isData==1){
        $('#ctid').find('option').not(':first').remove();
        $.each(obj.cid, function() {
    $("#ctid").append("<option value="+this.city_id+">"+this.city_name+"</option>");
        })
    }
})

Here also i am getting the data properly and the loop is also running.But its not reflecting at front end.when I did inspect element i got the below generated html code.

<select class="chosen-select text-left" style="width: 100%; display: none;" id="ctid">
<option value="" selected="">Select City</option>
<option value="18">Bhubaneswar</option>
<option value="17">Delhi</option>
<option value="16">Bangalore</option>
<option value="15">Mumbai</option>
</select>

Select City

<input type="text" autocomplete="off">

Select City

The raw html code is generating the above part after option added dynamically.But my problem is thosze are not display on the front end view.Please help me to resolve thisz issue.

Body:
I think each loop every object and gives index as its first param and val as second, try this:

$.each(obj.cid, function(idx, o) {
  $("#ctid").append("<option value="+o.city_id+">"+o.city_name+"</option>");
});

If you would like to get the options in the resulting ul, then make sure to append them first before initing chosen.

$.each(obj, function(idx, o) {
  $("#ctid").append("<option value=" + o.city_id + ">" + o.city_name + "</option>");
});

$('#ctid').addClass('chosen-select');
$('.chosen-select').chosen();

HTML

<div class="popover-content">
  <p>
    <select class="text-left" style="width:100%;" id="ctid">
      <option value="" selected>Select City</option>
    </select>
  </p>
</div>

Hope this helps


问:
Deleting message after using sendirect() on it in omnetpp
In my project I have the following code snippet

```<code>if(strcmp(msg->getName(),"failedAck") == 0 || ......)
{
    msg->removeControlInfo();
    msg->setControlInfo(info);
    recvControls++;
    sendDirect(msg, table, "ackIn");
}
</code>```

Essentially the a message arrives at its final destination (lets call it A*), and if it is a type of specified messages, it is sent to another module (B*) which uses the information it carries to perform an operation.

The problem I am having is that after sending the message to the other B*, I delete the message after I am done using it. However, it still appears as part of A* when I look in the inspector. And when I try and delete the message in A* I get an error message saying can't delete the message because it is currently scheduled.
I can't figure out why this happens, Does this mean that sendDirect() does not change the ownership of the message (contrary to the manual)?

Help in this matter will be greatly appreciated, currently dealing with memory management issues in my simulation, and this is a part of it.

答: I would like to withdraw this question and say thanks to everyone who looked at it. I just recently discovered that the items were being deleted when they were supposed to be. however, i had forgotten that i was making a clone of the object for other uses, that why it was showing up in the inspector. My apologies.</p>

Body:
In my project I have the following code snippet

if(strcmp(msg->getName(),"failedAck") == 0 || ......)
{
    msg->removeControlInfo();
    msg->setControlInfo(info);
    recvControls++;
    sendDirect(msg, table, "ackIn");
}

Essentially the a message arrives at its final destination (lets call it A*), and if it is a type of specified messages, it is sent to another module (B*) which uses the information it carries to perform an operation.

The problem I am having is that after sending the message to the other B*, I delete the message after I am done using it. However, it still appears as part of A* when I look in the inspector. And when I try and delete the message in A* I get an error message saying can't delete the message because it is currently scheduled.
I can't figure out why this happens, Does this mean that sendDirect() does not change the ownership of the message (contrary to the manual)?

Help in this matter will be greatly appreciated, currently dealing with memory management issues in my simulation, and this is a part of it.


问:
Centering div vertically and horizontally
Is there any way to center .polygon_container and .polygon vertically and horizontally? Also is there a possibility to make the size of it responsive like the  tag below?

http://cichyone.linuxpl.eu/ranestwen/ex/

I've tried text-align, margin auto etc and nothing works.

When I set it in the middle using margin-left and margin-top it is working only for one resolution.

答:
You can Center the polygon div using tansform:

I created the following HTML:

```<code><div class="polygon_container">
    <div class="polygon">
        <h1>hello</h1>
    </div>
</div>
</code>```

And for that I´m using this css:

```<code>    body
    {
        margin: 0;
        padding: 0;
    }
    .polygon_container
    {
        width: 100%;
        height: 100%;
        background: red;
    }

    .polygon
    {
        width: 50%;
        height: 50%;
        background: white;
        transform: translateX(50%) translateY(50%);
    }
</code>```

Hope this is a solution for you.

Body:
You can Center the polygon div using tansform:

I created the following HTML:

<div class="polygon_container">
    <div class="polygon">
        <h1>hello</h1>
    </div>
</div>

And for that I´m using this css:

    body
    {
        margin: 0;
        padding: 0;
    }
    .polygon_container
    {
        width: 100%;
        height: 100%;
        background: red;
    }

    .polygon
    {
        width: 50%;
        height: 50%;
        background: white;
        transform: translateX(50%) translateY(50%);
    }

Hope this is a solution for you.


问:
Sending JSON object to a service
I have written a simple service which, if sent the name of a football player, will return the team of said footballer. It's a learning project for myself.

I want to test the accuracy of my service.

I have made a JSON file with a list of footballers and their expected team. I want to send this off to my service and create a report to see how accurate I am.

The JSON looks like this -

```<code>{"Team": "Man Utd", "Players": "Ryan Giggs"}
{"Team": "Chelsea", "Players": "John Terry"}
.....
</code>```

A simple start on my code -

```<code>import json
from pprint import pprint

with open('C:\\Users\\ADMIN\\Desktop\\Service_Testing\\service_json.json') as data_file:
    data = json.load(data_file)

pprint(data)
</code>```

Trying to load it in, however, I get the error -

```<code>    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 47)
</code>```

What is going wrong here? How can I load my JSON correctly? There are 46k lines in my json file which may be part of the issue !!

答:
As mentioned in the comments, this isn't valid JSON. You seem to have one JSON object per line; you could potentially load and parse those individually:

```<code>data = []
with open('C:\\Users\\ADMIN\\Desktop\\Service_Testing\\service_json.json') as data_file:
    for line in data_file:
        data.append(json.loads(line))
</code>```

Although it would be better to fix the input file in the first place, so that it is correctly wrapped in an array with each object separated by commas.

Title: Sending JSON object to a service

Body:
I have written a simple service which, if sent the name of a football player, will return the team of said footballer. It's a learning project for myself.

I want to test the accuracy of my service.

I have made a JSON file with a list of footballers and their expected team. I want to send this off to my service and create a report to see how accurate I am.

The JSON looks like this -

{"Team": "Man Utd", "Players": "Ryan Giggs"}
{"Team": "Chelsea", "Players": "John Terry"}
.....

A simple start on my code -

import json
from pprint import pprint

with open('C:\\Users\\ADMIN\\Desktop\\Service_Testing\\service_json.json') as data_file:
    data = json.load(data_file)

pprint(data)

Trying to load it in, however, I get the error -

    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 47)

What is going wrong here? How can I load my JSON correctly? There are 46k lines in my json file which may be part of the issue !!

Body:
As mentioned in the comments, this isn't valid JSON. You seem to have one JSON object per line; you could potentially load and parse those individually:

data = []
with open('C:\\Users\\ADMIN\\Desktop\\Service_Testing\\service_json.json') as data_file:
    for line in data_file:
        data.append(json.loads(line))

Although it would be better to fix the input file in the first place, so that it is correctly wrapped in an array with each object separated by commas.


问:
Is SOA mostly a bunch of web services?
Learning about SOA.  Is it mostly decoupling by way of web services, one service provides web services to another, thereby staying decoupled and encapsulated?  Thanks.

edit:  that and maybe a good front end to them like some MVC design?

答:
Here is a good selection of links that challenge the idea that SOA is only about web services, it explores the idea that every class in the application is a service and we can use many different transports (web, tcp, queues) within our SOA. SOA is the methodology you use to build a service orientated application.

Here are some practical examples of how to build a SOA.

I would suggest you read articles by Thomas Erl and Roger Sessions, this will give you a firm handle on what SOA is all about.

SOA Design Pattern

Achieving integrity in a SOA

Why your SOA should be like a VW Beetle

SOA explained for your boss

Building a SOA

WCF Service Performance

Choosing a presentation pattern for a new or enterprise web development  is a daunting task, in my opinion there are only three; View Model, Model-View-Presenter (MVP) or ASP.NET MVC (a Model2 derivative).

You can read the full article here ASP.NET MVC Patterns

ContentLicense: CC BY-SA 2.5

Title: Is SOA mostly a bunch of web services?


答:
Yes it is possible. Try this.

```<code>.polygon_container {
    position: absolute;
    height: 500px;
    width: 500px;
    top: 50%;left: 50;
    margin-left: -250px;
    margin-top: -250px;
}
</code>```

html, body {
  height: 100%;width: 100%;
  margin: 0;padding: 0;
}

.container {
  height: 100%;width: 100%;
  background: url('http://cichyone.linuxpl.eu/ranestwen/ex/assets/img/slider1/1.png') no-repeat;
  background-size: cover;
}

.polygon_container {
  position: absolute;
  height: 100px;
  width: 100px;
  left: 50%;top: 50%;
  margin-top: -50px;
  margin-left: -50px;
}

.polygon_container .polygon {
  background: #fff;
  height: 100%;
  width: 100%;

  transform: rotate(45deg);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="polygon_container">
    <div class="polygon"></div>
  </div>
</div></code>```

Title: Centering div vertically and horizontally

Body:
Is there any way to center .polygon_container and .polygon vertically and horizontally? Also is there a possibility to make the size of it responsive like the  tag below?

http://cichyone.linuxpl.eu/ranestwen/ex/

I've tried text-align, margin auto etc and nothing works.

When I set it in the middle using margin-left and margin-top it is working only for one resolution.

Body:
Yes it is possible. Try this.

.polygon_container {
    position: absolute;
    height: 500px;
    width: 500px;
    top: 50%;left: 50;
    margin-left: -250px;
    margin-top: -250px;
}

html, body {
  height: 100%;width: 100%;
  margin: 0;padding: 0;
}

.container {
  height: 100%;width: 100%;
  background: url('http://cichyone.linuxpl.eu/ranestwen/ex/assets/img/slider1/1.png') no-repeat;
  background-size: cover;
}

.polygon_container {
  position: absolute;
  height: 100px;
  width: 100px;
  left: 50%;top: 50%;
  margin-top: -50px;
  margin-left: -50px;
}

.polygon_container .polygon {
  background: #fff;
  height: 100%;
  width: 100%;

  transform: rotate(45deg);
}

<div class="container">
  <div class="polygon_container">
    <div class="polygon"></div>
  </div>
</div>


问:
Why my server side code is not firing on ASP.net Button click?
I don't understand why my server side is not executed.

Here is my code

ASP code

```<code><div class="row" style="padding-top:20px;">
    <div class="col-lg-4">
        <input id="btnSave" type="button" class="btn btn-info"  value="Save" />
        <input id="btnLoad" type="button" class="btn btn-info"  value="Load" />

         <%-- SAVE DIALOG  --%>
         <div id="saveDialog" title="Basic dialog">
         <div class="row">
             <div class="col-lg-4">
                 <asp:Label ID="lblFileName" CssClass="control-label" runat="server" Text="File Name"></asp:Label>
             </div>
             <div class="col-lg-6">
                 <asp:TextBox ID="txtFileName" CssClass="form-control" runat="server"></asp:TextBox>
             </div>
         </div>
         <div class="row">
             <div class="col-lg-12" style="text-align:center;">
                 <asp:Label ID="lblSaveErrorMsg" runat="server" Text="" ForeColor="Red"></asp:Label>
             </div>
         </div>
         <div class="row" style="padding-top:10px;">
             <div class="col-lg-12" style="text-align:center;">
                <asp:Button ID="btnSaveFile" runat="server" Text="Save" OnClick="btnSaveFile_Click"/>

             </div>
         </div>
     </div>
</div>
</code>```

Server Side Code

```<code>protected void btnSaveFile_Click(object sender, EventArgs e)
    {
        string cs = ConfigurationManager.ConnectionStrings["xxx"].ConnectionString;

        using (SqlConnection con = new SqlConnection(cs))
        {
            byte[] byteArray = Encoding.UTF8.GetBytes(ASPxPivotGrid1.SaveLayoutToString());
            MemoryStream stream = new MemoryStream(byteArray);

            DateTime currentDate = DateTime.Now;

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = "INSERT INTO ReportSave(UserID,ReportName,UserFileName,ReportData,Time,ReportFilter)VALUES(@UserID,@ReportName,@UserFileName,@ReportData,@Time,@ReportFilter);";

            cmd.Parameters.AddWithValue("@UserID", UserID);
            cmd.Parameters.AddWithValue("@ReportName", ReportName);
            cmd.Parameters.AddWithValue("@UserFileName", txtFileName.Text);
            cmd.Parameters.AddWithValue("@ReportData", stream);
            cmd.Parameters.AddWithValue("@Time", currentDate);
            cmd.Parameters.AddWithValue("@ReportFilter", txtFilterRecord.Text);

            con.Open();
            cmd.ExecuteNonQuery();

            //string message = "Your details have been saved successfully.";
            //string script = "window.onload = function(){ alert('";
            //script += message;
            //script += "')};";
            //ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
        }
    }
</code>```

Note:

It doesn't show any error message and it is not reloading the page as well. It was weird.

I call jquery functions, after it execute also it never call the server code. For testing purpose, I removed the entire jquery code for this button. So no Jquery function for this button now. But still I couldn't call the server side code why???

UPDATED

I found something, I have one button on the form called btnSave, once user click it will call

```<code>$('#btnSave').click(function () {
    $('#saveDialog').dialog();
});
</code>```

IMPORTANT NOTE: Then Dialog box will appear. In that dialog box I have added that button btnSaveFile. But When I add this button outside the dialog, it's calling the server side code.

答:
Hey friend protected void btnSaveFile_Click(object sender, EventArgs e) copied this method from other page or application then it will not work, So delete the event and event name assigned to the button. Go to design and go to button even properties go to OnClick event double click it, It will generate event and automatically assigns event name to the button. It will work.

Or

Give the new Onclick function name in the code

```<code><asp:Button ID="btnSaveFile" runat="server" Text="Save" OnClick="btnSaveFile_Click"/>
</code>```

Use full Links:

asp.net Button OnClick event not firing

ASP.NET button not firing on click event

OnClick events not working in ASP.NET page

https://www.codeproject.com/Questions/681648/button-click-event-not-firing-asp-net

You may use this code in Jquery:

```<code>$(document).on('click', '#btnSave', function() {
{
   $('#saveDialog').dialog();
});
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I don't understand why my server side is not executed.

Here is my code

ASP code

        <input id="btnSave" type="button" class="btn btn-info"  value="Save" />
        <input id="btnLoad" type="button" class="btn btn-info"  value="Load" />

         <%-- SAVE DIALOG  --%>

                 <asp:Label ID="lblFileName" CssClass="control-label" runat="server" Text="File Name"></asp:Label>

                 <asp:TextBox ID="txtFileName" CssClass="form-control" runat="server"></asp:TextBox>

                 <asp:Label ID="lblSaveErrorMsg" runat="server" Text="" ForeColor="Red"></asp:Label>

                <asp:Button ID="btnSaveFile" runat="server" Text="Save" OnClick="btnSaveFile_Click"/>

Server Side Code

protected void btnSaveFile_Click(object sender, EventArgs e)
    {
        string cs = ConfigurationManager.ConnectionStrings["xxx"].ConnectionString;

        using (SqlConnection con = new SqlConnection(cs))
        {
            byte[] byteArray = Encoding.UTF8.GetBytes(ASPxPivotGrid1.SaveLayoutToString());
            MemoryStream stream = new MemoryStream(byteArray);

            DateTime currentDate = DateTime.Now;

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = "INSERT INTO ReportSave(UserID,ReportName,UserFileName,ReportData,Time,ReportFilter)VALUES(@UserID,@ReportName,@UserFileName,@ReportData,@Time,@ReportFilter);";

            cmd.Parameters.AddWithValue("@UserID", UserID);
            cmd.Parameters.AddWithValue("@ReportName", ReportName);
            cmd.Parameters.AddWithValue("@UserFileName", txtFileName.Text);
            cmd.Parameters.AddWithValue("@ReportData", stream);
            cmd.Parameters.AddWithValue("@Time", currentDate);
            cmd.Parameters.AddWithValue("@ReportFilter", txtFilterRecord.Text);

            con.Open();
            cmd.ExecuteNonQuery();

            //string message = "Your details have been saved successfully.";
            //string script = "window.onload = function(){ alert('";
            //script += message;
            //script += "')};";
            //ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
        }
    }

Note:

It doesn't show any error message and it is not reloading the page as well. It was weird.

I call jquery functions, after it execute also it never call the server code. For testing purpose, I removed the entire jquery code for this button. So no Jquery function for this button now. But still I couldn't call the server side code why???

UPDATED

I found something, I have one button on the form called btnSave, once user click it will call

$('#btnSave').click(function () {
    $('#saveDialog').dialog();
});

IMPORTANT NOTE: Then Dialog box will appear. In that dialog box I have added that button btnSaveFile. But When I add this button outside the dialog, it's calling the server side code.

Body:
Hey friend protected void btnSaveFile_Click(object sender, EventArgs e) copied this method from other page or application then it will not work, So delete the event and event name assigned to the button. Go to design and go to button even properties go to OnClick event double click it, It will generate event and automatically assigns event name to the button. It will work.

Or

Give the new Onclick function name in the code

<asp:Button ID="btnSaveFile" runat="server" Text="Save" OnClick="btnSaveFile_Click"/>

Use full Links:

asp.net Button OnClick event not firing

ASP.NET button not firing on click event

OnClick events not working in ASP.NET page

https://www.codeproject.com/Questions/681648/button-click-event-not-firing-asp-net

You may use this code in Jquery:

$(document).on('click', '#btnSave', function() {
{
   $('#saveDialog').dialog();
});


问:
How to configure fetchPolicy to network-only
How can I set the fetchPolicy to network-only in apollo-client? I can't understand how to do it!

答:
ran into the same issue, but an upgrade to apollo-client@1.0.0-rc.9 and react-apollo@1.0.0-rc.3 seems to have solved it: the connected component now refetches its query every time it's rendered. Try upgrading.

(Can't comment, so posting this as an "answer". Sorry about that.)


问:
xcrun Unable to copy to /var/folders
I'm getting errors when trying to run /usr/bin/xcrun

```<code> /usr/bin/xcrun -sdk iphoneos PackageApplication /Users/xxxx/bamboo-agent-home/xml-data/build-dir/BEAM-IOS0-JOB1/archive.xcarchive/Products/Applications/MyApp.app -o /Users/xxxxx/bamboo-agent-home/xml-data/build-dir/BEAM-IOS0-JOB1/MyApp.ipa --sign "iPhone Distribution: MyComp" --embed /Users/xxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision
</code>```

and error is like this:

```<code>error: Unable to copy '/Users/xxxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision'

to    '/var/folders/1t/pgh7fy550vl8nrvtmqhvn_780000gn/T/cjftmH0k7i/Payload/MyApp.app/embedded.mobileprovision'
</code>```

Any idea?
What's wrong with this case?

答:
The provisioning file has been already embedded in your application (MyApp.app)
You can check this by extracting the .app using Archive Utility.

Remove the part --embed /Users/xxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision from the command line and try again.

Title: xcrun Unable to copy to /var/folders

Body:
I'm getting errors when trying to run /usr/bin/xcrun

 /usr/bin/xcrun -sdk iphoneos PackageApplication /Users/xxxx/bamboo-agent-home/xml-data/build-dir/BEAM-IOS0-JOB1/archive.xcarchive/Products/Applications/MyApp.app -o /Users/xxxxx/bamboo-agent-home/xml-data/build-dir/BEAM-IOS0-JOB1/MyApp.ipa --sign "iPhone Distribution: MyComp" --embed /Users/xxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision

and error is like this:

error: Unable to copy '/Users/xxxxx/bamboo-agent-home/xml-data/build-dir/iOS_Team_Provisioning_Profile_.mobileprovision'

to    '/var/folders/1t/pgh7fy550vl8nrvtmqhvn_780000gn/T/cjftmH0k7i/Payload/MyApp.app/embedded.mobileprovision'

Any idea?
What's wrong with this case?


问:
Concatenating proprocessor macro __FUNCTION__ with a string
This should be trivial but I cannot seem to figure out how to concatenate __FUNCTION__ with strings especially on GCC -- although it works on VC++ (I'm porting some code to Linux)

```<code>#include <iostream>
#include <string>

#define KLASS_NAME  "Global"

int main()
{
    std::string msg = KLASS_NAME "::" __FUNCTION__;
    std::cout << msg << std::endl;
}
</code>```

Online VC++ version

GCC error message

```<code>Test.cpp:9:36: error: expected ‘,’ or ‘;’ before ‘__FUNCTION__’
  std::string msg = KLASS_NAME "::" __FUNCTION__;
</code>```

Update

Thanks to Chris, apparently adjacent string literals are concatenated [reference]. So VC++ may be correct in this case, until you consider that __FUNCTION__ is non-standard.

答:
You need a concatenation operator and explicitly construct the string such that the right concatenation operator is found:

```<code>#include <iostream>
#include <string>

#define KLASS_NAME  "Global"

int main()
{
    std::string msg = std::string(KLASS_NAME) + "::" + __FUNCTION__;
    std::cout << msg << std::endl;
}
</code>```

Live example: http://ideone.com/vn4yra

Body:
This should be trivial but I cannot seem to figure out how to concatenate __FUNCTION__ with strings especially on GCC -- although it works on VC++ (I'm porting some code to Linux)

#include <iostream>
#include <string>

#define KLASS_NAME  "Global"

int main()
{
    std::string msg = KLASS_NAME "::" __FUNCTION__;
    std::cout << msg << std::endl;
}

Online VC++ version

GCC error message

Test.cpp:9:36: error: expected ‘,’ or ‘;’ before ‘__FUNCTION__’
  std::string msg = KLASS_NAME "::" __FUNCTION__;

Update

Thanks to Chris, apparently adjacent string literals are concatenated [reference]. So VC++ may be correct in this case, until you consider that __FUNCTION__ is non-standard.

Body:
You need a concatenation operator and explicitly construct the string such that the right concatenation operator is found:

#include <iostream>
#include <string>

#define KLASS_NAME  "Global"

int main()
{
    std::string msg = std::string(KLASS_NAME) + "::" + __FUNCTION__;
    std::cout << msg << std::endl;
}

Live example: http://ideone.com/vn4yra


问:
Multiple-angled css shape, is it possible?
Hi guys consider the picture below

is it possible to create such a shape with css? If so can you give me some clues or an example?

答:
I have tried this, check this once

#chevron {
position: relative;
text-align: center;
padding: 12px;
margin-bottom: 6px;
height: 60px; width: 100%;
}
#chevron:before {
content: '';
position: absolute;
top: -32px;
left: 0;
height: 140px;
width: 51%;
background: -webkit-linear-gradient(left, #9cb0ed, #a1ceec); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right,#9cb0ed, #a1ceec); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, #9cb0ed, #a1ceec); /* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #9cb0ed, #a1ceec); /* Standard syntax (must be last) */
-webkit-transform: skew(0deg, 6deg);
-moz-transform: skew(0deg, 6deg);
-ms-transform: skew(0deg, 6deg);
-o-transform: skew(0deg, 6deg);
transform: skew(0deg, 6deg);
}
#chevron:after {
content: '';
position: absolute;
top: -110px;
right: 90px;
height: 140px;
width: 35%;
background: -webkit-linear-gradient(left, #a1ceec, #9cb0ed); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right, #a1ceec, #9cb0ed); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, #a1ceec, #9cb0ed); /* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #a1ceec, #9cb0ed); /* Standard syntax (must be last) */
-webkit-transform: skew(0deg, -6deg);
-moz-transform: skew(0deg, -40deg);
-ms-transform: skew(0deg, -40deg);
-o-transform: skew(0deg, -40deg);
transform: skew(0deg, -40deg);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="chevron"></div></code>```

Body:
I have tried this, check this once

#chevron {
position: relative;
text-align: center;
padding: 12px;
margin-bottom: 6px;
height: 60px; width: 100%;
}
#chevron:before {
content: '';
position: absolute;
top: -32px;
left: 0;
height: 140px;
width: 51%;
background: -webkit-linear-gradient(left, #9cb0ed, #a1ceec); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right,#9cb0ed, #a1ceec); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, #9cb0ed, #a1ceec); /* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #9cb0ed, #a1ceec); /* Standard syntax (must be last) */
-webkit-transform: skew(0deg, 6deg);
-moz-transform: skew(0deg, 6deg);
-ms-transform: skew(0deg, 6deg);
-o-transform: skew(0deg, 6deg);
transform: skew(0deg, 6deg);
}
#chevron:after {
content: '';
position: absolute;
top: -110px;
right: 90px;
height: 140px;
width: 35%;
background: -webkit-linear-gradient(left, #a1ceec, #9cb0ed); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right, #a1ceec, #9cb0ed); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, #a1ceec, #9cb0ed); /* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #a1ceec, #9cb0ed); /* Standard syntax (must be last) */
-webkit-transform: skew(0deg, -6deg);
-moz-transform: skew(0deg, -40deg);
-ms-transform: skew(0deg, -40deg);
-o-transform: skew(0deg, -40deg);
transform: skew(0deg, -40deg);
}

<div id="chevron"></div>


问:
Only receive unique warning messages
Warning messages are a good information i want to know. But i just want to know it one time!

So this function throws 2 different warnings and repeats it 20 times.

How can i tell R to only print unique warnings. Im looking for a gerenal solution.

```<code>Warning messages:
1: NAs introduced by coercion
2: In sqrt(-1) : NaNs produced
</code>```

Here is my example:

```<code>foobar <- function(n=20) {
    for (i in 1:n) {
        as.numeric("b")
        sqrt(-1)
        }
}

foobar()
</code>```

答:
To return only unique warning strings, use

```<code>unique(warnings())
</code>```

Now, a problem you may have is that your function has more than 50 warnings, in which case warnings() will not catch them all. To workaround this, you can increase nwarnings in options to e.g. 10000 as suggested in the help page of warnings.

```<code>options(nwarnings = 10000)
</code>```

Example:

```<code>foobar <- function(n=20) {
    warning("First warning")
    for (i in 1:n) {
        as.numeric("b")
        sqrt(-1)
    }
    warning("Last warning")
}

foobar(60)
unique(warnings())
## Warning messages:
## 1: In foobar(60) : First warning
## 2: NAs introduced by coercion
## 3: In sqrt(-1) : NaNs produced

op <- options(nwarnings = 10000)
foobar(60)
unique(warnings())
## Warning messages:
## 1: In foobar(60) : First warning
## 2: NAs introduced by coercion
## 3: In sqrt(-1) : NaNs produced
## 4: In foobar(60) : Last warning

options(op)
</code>```

Title: Only receive unique warning messages

Body:
Warning messages are a good information i want to know. But i just want to know it one time!

So this function throws 2 different warnings and repeats it 20 times.

How can i tell R to only print unique warnings. Im looking for a gerenal solution.

Warning messages:
1: NAs introduced by coercion
2: In sqrt(-1) : NaNs produced

Here is my example:

foobar <- function(n=20) {
    for (i in 1:n) {
        as.numeric("b")
        sqrt(-1)
        }
}

foobar()

Body:
To return only unique warning strings, use

unique(warnings())

Now, a problem you may have is that your function has more than 50 warnings, in which case warnings() will not catch them all. To workaround this, you can increase nwarnings in options to e.g. 10000 as suggested in the help page of warnings.

options(nwarnings = 10000)

Example:

foobar <- function(n=20) {
    warning("First warning")
    for (i in 1:n) {
        as.numeric("b")
        sqrt(-1)
    }
    warning("Last warning")
}

foobar(60)
unique(warnings())
## Warning messages:
## 1: In foobar(60) : First warning
## 2: NAs introduced by coercion
## 3: In sqrt(-1) : NaNs produced

op <- options(nwarnings = 10000)
foobar(60)
unique(warnings())
## Warning messages:
## 1: In foobar(60) : First warning
## 2: NAs introduced by coercion
## 3: In sqrt(-1) : NaNs produced
## 4: In foobar(60) : Last warning

options(op)


问:
Env var returning null in path
I have set up to ENV Vars (Ubuntu 14.04)

```<code>CERT_PATH=/home/ubuntu/certs/developer.cert.co.uk.pem
CA_PATH=/home/ubuntu/certs/ca.pem
</code>```

I am then grabbing those values in a JS script

```<code>var certPath = process.env.CERT_PATH;
var caPath = process.env.CA_PATH;
</code>```

But I am stumped as to why one of the vars return null in the path:

```<code>-- console log here
CERT Path: null/certs/developer.cert.co.uk.pem
CA Path: /home/ubuntu/certs/ca.pem
</code>```

What I don't understand is the same setup on OSX does not have this issue.

答:
Though I cannot explain why i was getting null in my path, using the withEnv block around the relevant piece of my pipeline was what i ended up doing.

I normally do this but thought i could set the ENV var globally and be able to read from that without the need to so this, but seems to not be the case

```<code>withEnv(["CA_PATH=/home/ubuntu/certs/ca.pem", "CERT_PATH=/home/ubuntu/certs/developer.cert.co.uk.pem"]) {
 try {
   sh '''#!/bin/bash -l
         run tests
      '''
     TESTS = 'success'
 } catch (Exception err) {
     TESTS = "failure"
 }
}
</code>```

Title: Env var returning null in path

Body:
I have set up to ENV Vars (Ubuntu 14.04)

CERT_PATH=/home/ubuntu/certs/developer.cert.co.uk.pem
CA_PATH=/home/ubuntu/certs/ca.pem

I am then grabbing those values in a JS script

var certPath = process.env.CERT_PATH;
var caPath = process.env.CA_PATH;

But I am stumped as to why one of the vars return null in the path:

-- console log here
CERT Path: null/certs/developer.cert.co.uk.pem
CA Path: /home/ubuntu/certs/ca.pem

What I don't understand is the same setup on OSX does not have this issue.

Body:
Though I cannot explain why i was getting null in my path, using the withEnv block around the relevant piece of my pipeline was what i ended up doing.

I normally do this but thought i could set the ENV var globally and be able to read from that without the need to so this, but seems to not be the case

withEnv(["CA_PATH=/home/ubuntu/certs/ca.pem", "CERT_PATH=/home/ubuntu/certs/developer.cert.co.uk.pem"]) {
 try {
   sh '''#!/bin/bash -l
         run tests
      '''
     TESTS = 'success'
 } catch (Exception err) {
     TESTS = "failure"
 }
}


问:
display image in detail view with one to many reation yii2
I have two tables with one-to-many relation,

This code will display the path not image. how to display image?

答:
Try this.</p>

```<code>[
    'attribute'=>'photo',
    'value'=>$model->photo,
    'format' => ['image',['width'=>'100','height'=>'100']],
 ],
</code>```

Body:
Try this.

[
    'attribute'=>'photo',
    'value'=>$model->photo,
    'format' => ['image',['width'=>'100','height'=>'100']],
 ],


问:
How to add an animated layer at a specific index
I am adding two CAText layers to a view and animating one of them. I want to animate one layer above the other but it doesn't get positioned correctly in the layer hierarchy until the animation has finished. Can anyone see what I have done wrong? The animation works, it is just running behind 'topcharlayer2' until the animation has finished.

```<code>- (CABasicAnimation *)topCharFlap
{
CABasicAnimation *flipAnimation;

flipAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
flipAnimation.toValue      = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(1.57f, 1, 0, 0)];
flipAnimation.fromValue    = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 1, 0, 0)];
flipAnimation.autoreverses = NO;
flipAnimation.duration     = 0.5f;
flipAnimation.repeatCount  = 10;

return flipAnimation;
}

- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
    [self setBackgroundColor:[UIColor clearColor]]; //makes this view transparent other than what is drawn.

    [self initChar];
}

return self;
}

static CATransform3D CATransform3DMakePerspective(CGFloat z)
{
CATransform3D t = CATransform3DIdentity;
t.m34 = - 1. / z;
return t;
}

-(void) initChar
{
UIFont *theFont = [UIFont fontWithName:@"AmericanTypewriter" size:FONT_SIZE];

self.layer.sublayerTransform = CATransform3DMakePerspective(-1000.0f);

topHalfCharLayer2 = [CATextLayer layer];

topHalfCharLayer2.bounds = CGRectMake(0.0f, 0.0f, CHARACTERS_WIDTH, 100.0f);
topHalfCharLayer2.string = @"R";
topHalfCharLayer2.font = theFont.fontName;
topHalfCharLayer2.fontSize = FONT_SIZE;
topHalfCharLayer2.backgroundColor = [UIColor blackColor].CGColor;
topHalfCharLayer2.position = CGPointMake(CGRectGetMidX(self.bounds),CGRectGetMidY(self.bounds));

topHalfCharLayer2.wrapped = NO;

topHalfCharLayer1 = [CATextLayer layer];

topHalfCharLayer1.bounds = CGRectMake(0.0f, 0.0f, CHARACTERS_WIDTH, 100.0f);
topHalfCharLayer1.string = @"T";

topHalfCharLayer1.font = theFont.fontName;
topHalfCharLayer1.fontSize = FONT_SIZE;

topHalfCharLayer1.backgroundColor = [UIColor redColor].CGColor;
topHalfCharLayer1.position = CGPointMake(CGRectGetMidX(self.bounds),CGRectGetMidY(self.bounds));
topHalfCharLayer1.wrapped = NO;
//topHalfCharLayer1.zPosition = 100;

[topHalfCharLayer1 setAnchorPoint:CGPointMake(0.5f,1.0f)];

[[self layer] addSublayer:topHalfCharLayer1 ];
[[self layer] insertSublayer:topHalfCharLayer2 atIndex:0];

[topHalfCharLayer1 addAnimation:[self topCharFlap] forKey:@"anythingILikeApparently"];

}
</code>```

The View which contains this code is loaded by a view controller in loadView. The initChar method is called in the view's initWithFrame method. The target is iOS4. I'm not using setWantsLayer as I've read that UIView in iOS is automatically layer backed and doesn't require this.

答:
```<code>/* Insert 'layer' at position 'idx' in the receiver's sublayers array.
 * If 'layer' already has a superlayer, it will be removed before being
 * inserted. */

open func insertSublayer(_ layer: CALayer, at idx: UInt32)
</code>```

Body:
I am adding two CAText layers to a view and animating one of them. I want to animate one layer above the other but it doesn't get positioned correctly in the layer hierarchy until the animation has finished. Can anyone see what I have done wrong? The animation works, it is just running behind 'topcharlayer2' until the animation has finished.

- (CABasicAnimation *)topCharFlap
{
CABasicAnimation *flipAnimation;

flipAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
flipAnimation.toValue      = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(1.57f, 1, 0, 0)];
flipAnimation.fromValue    = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 1, 0, 0)];
flipAnimation.autoreverses = NO;
flipAnimation.duration     = 0.5f;
flipAnimation.repeatCount  = 10;

return flipAnimation;
}

- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
    [self setBackgroundColor:[UIColor clearColor]]; //makes this view transparent other than what is drawn.

    [self initChar];
}

return self;
}

static CATransform3D CATransform3DMakePerspective(CGFloat z)
{
CATransform3D t = CATransform3DIdentity;
t.m34 = - 1. / z;
return t;
}

-(void) initChar
{
UIFont *theFont = [UIFont fontWithName:@"AmericanTypewriter" size:FONT_SIZE];

self.layer.sublayerTransform = CATransform3DMakePerspective(-1000.0f);

topHalfCharLayer2 = [CATextLayer layer];

topHalfCharLayer2.bounds = CGRectMake(0.0f, 0.0f, CHARACTERS_WIDTH, 100.0f);
topHalfCharLayer2.string = @"R";
topHalfCharLayer2.font = theFont.fontName;
topHalfCharLayer2.fontSize = FONT_SIZE;
topHalfCharLayer2.backgroundColor = [UIColor blackColor].CGColor;
topHalfCharLayer2.position = CGPointMake(CGRectGetMidX(self.bounds),CGRectGetMidY(self.bounds));

topHalfCharLayer2.wrapped = NO;

topHalfCharLayer1 = [CATextLayer layer];

topHalfCharLayer1.bounds = CGRectMake(0.0f, 0.0f, CHARACTERS_WIDTH, 100.0f);
topHalfCharLayer1.string = @"T";

topHalfCharLayer1.font = theFont.fontName;
topHalfCharLayer1.fontSize = FONT_SIZE;

topHalfCharLayer1.backgroundColor = [UIColor redColor].CGColor;
topHalfCharLayer1.position = CGPointMake(CGRectGetMidX(self.bounds),CGRectGetMidY(self.bounds));
topHalfCharLayer1.wrapped = NO;
//topHalfCharLayer1.zPosition = 100;

[topHalfCharLayer1 setAnchorPoint:CGPointMake(0.5f,1.0f)];

[[self layer] addSublayer:topHalfCharLayer1 ];
[[self layer] insertSublayer:topHalfCharLayer2 atIndex:0];

[topHalfCharLayer1 addAnimation:[self topCharFlap] forKey:@"anythingILikeApparently"];

}

The View which contains this code is loaded by a view controller in loadView. The initChar method is called in the view's initWithFrame method. The target is iOS4. I'm not using setWantsLayer as I've read that UIView in iOS is automatically layer backed and doesn't require this.


问:
Validation not working on Ranges?
Can someone explain to me why my validation won't get triggered when I submit a string such as "foo" to number?

```<code>class Course < ActiveRecord::Base

  validates :number, :inclusion => 0..100

end
</code>```

Only when I change my code to this...

```<code>class Course < ActiveRecord::Base

  validates :number, :inclusion  => 0..100, :numericality => true

end
</code>```

... the validation gets triggered.

Is this a Rails bug or am I missing something really fundamental here?

I am using Rails 4.2.0 by the way.

答:
It's because rails is converting the string to a number (assuming you've got it persisted as an integer) before doing the validation. If you call to_i on a string you get 0 which is valid for your range.

For example:

```<code>> c = Course.new
> c.number = 'hi'
> c.number
=> 0
> c.valid?
=> true
</code>```

The reason the numericality validators is triggering when you add it is, I think, because it checks the value before any type casting happens:

```<code>> c.number = 'hi'
> c.number_before_type_cast
=> 'hi'
</code>```

Title: Validation not working on Ranges?

Body:
Can someone explain to me why my validation won't get triggered when I submit a string such as "foo" to number?

class Course < ActiveRecord::Base

  validates :number, :inclusion => 0..100

end

Only when I change my code to this...

class Course < ActiveRecord::Base

  validates :number, :inclusion  => 0..100, :numericality => true

end

... the validation gets triggered.

Is this a Rails bug or am I missing something really fundamental here?

I am using Rails 4.2.0 by the way.

Body:
It's because rails is converting the string to a number (assuming you've got it persisted as an integer) before doing the validation. If you call to_i on a string you get 0 which is valid for your range.

For example:

> c = Course.new
> c.number = 'hi'
> c.number
=> 0
> c.valid?
=> true

The reason the numericality validators is triggering when you add it is, I think, because it checks the value before any type casting happens:

> c.number = 'hi'
> c.number_before_type_cast
=> 'hi'


答:
```<code>.slider .polygon_container {
    width: 500px;
    height: 500px;
    position: absolute;
    z-index: 99999;
    text-align: center;
    color: white;
    margin: 0 auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
</code>```

Updated your class.

Body:
.slider .polygon_container {
    width: 500px;
    height: 500px;
    position: absolute;
    z-index: 99999;
    text-align: center;
    color: white;
    margin: 0 auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

Updated your class.


问:
Simplifying regex to replace underscores adhering to some substring logic
The input string is:

```<code>s = 'The\ue000 Project\ue000Gutenber g\ue000 E Book \ue000of\ue000 The\ue000 Ad vent ure s\ue000of\ue000 Sherlock\ue000 Holmes\n '
</code>```

And the output string is:

```<code>o = 'The Project Gutenber_ _g E_ _Book of The Ad_ _vent_ _ure_ _s of Sherlock Holmes\n'
</code>```

Note that from the input string, the \ue000 are the hard delimiters between words.

The aim is to do something like this:

[Cell 28]: replace the spaces with an underscore (to represent that there is a connection between two non-\ue000 characters)

[Cell 29]: then if there are _ \uE000 sequences, remove the underscore since there's no connections between the previous char ending with the underscore and the next word, (remember \ue000 is a hard word delimiter).

[Cell 30]: then replace the \ue000 with a space, so we're left with words with underscores that are either connected to an ending char of words or underscores hanging between two spaces:

[Cell 31]: deduplicate the spaces

[Cell 32]: delete the underscore hanging between two spaces

[Cell 33]: now that we're left with the underscores attached to the end of words, we can safely replace them with _ _ to indicate that the two sub-words are combinable.

The full set of replacements in the order described above:

```<code>text = text.replace(u'\n ', '\n')
text = text.replace(u' ', '_ ')
text = text.replace(u'_ \uE000', u' \uE000')
text = text.replace(u"\uE000", u' ')
text = text.replace(u'  ', u' ')
text = text.replace(u' _ ', u' ')
text = text.replace(u'_ ', u'_ _')
text = text.replace(u'  ', u' ')
</code>```

Note: the first replacement for text.replace(u'\n ', '\n') is necessary because the string could have been a full text file and simply using str.strip() would not be sufficient to clear out the non-necessary spaces between the \n and the new line.

Is there a less convoluted way to achieve the same output string that keeps the logic of why the replacements are done in the way described above?

答:
I don't quite follow your penultimate paragraph regarding newlines, but that aside, a single re.sub() is sufficient to get you most of the way:

```<code>>>> import re
>>>
>>> re.sub(r'[ \ue000]+', lambda m: ' ' if '\ue000' in m.group() else '_ _', s)
'The Project Gutenber_ _g E_ _Book of The Ad_ _vent_ _ure_ _s of Sherlock Holmes\n_ _'
</code>```

This finds all sequences of \ue000 and spaces, then replaces those sequences using a lambda that returns either a space or  '_ _' depending on whether the match contains \ue000.

After that, as far as I can tell (as I said, your penultimate paragraph is somewhat confusing), you just need to strip underscores and spaces:

```<code>>>> re.sub(r'[ \ue000]+', lambda m: ' ' if '\ue000' in m.group() else '_ _', s).strip('_ ')
'The Project Gutenber_ _g E_ _Book of The Ad_ _vent_ _ure_ _s of Sherlock Holmes\n'
</code>```

Body:
The input string is:

s = 'The\ue000 Project\ue000Gutenber g\ue000 E Book \ue000of\ue000 The\ue000 Ad vent ure s\ue000of\ue000 Sherlock\ue000 Holmes\n '

And the output string is:

o = 'The Project Gutenber_ _g E_ _Book of The Ad_ _vent_ _ure_ _s of Sherlock Holmes\n'

Note that from the input string, the \ue000 are the hard delimiters between words.

The aim is to do something like this:

[Cell 28]: replace the spaces with an underscore (to represent that there is a connection between two non-\ue000 characters)

[Cell 29]: then if there are _ \uE000 sequences, remove the underscore since there's no connections between the previous char ending with the underscore and the next word, (remember \ue000 is a hard word delimiter).

[Cell 30]: then replace the \ue000 with a space, so we're left with words with underscores that are either connected to an ending char of words or underscores hanging between two spaces:

[Cell 31]: deduplicate the spaces

[Cell 32]: delete the underscore hanging between two spaces

[Cell 33]: now that we're left with the underscores attached to the end of words, we can safely replace them with _ _ to indicate that the two sub-words are combinable.

The full set of replacements in the order described above:

text = text.replace(u'\n ', '\n')
text = text.replace(u' ', '_ ')
text = text.replace(u'_ \uE000', u' \uE000')
text = text.replace(u"\uE000", u' ')
text = text.replace(u'  ', u' ')
text = text.replace(u' _ ', u' ')
text = text.replace(u'_ ', u'_ _')
text = text.replace(u'  ', u' ')

Note: the first replacement for text.replace(u'\n ', '\n') is necessary because the string could have been a full text file and simply using str.strip() would not be sufficient to clear out the non-necessary spaces between the \n and the new line.

Is there a less convoluted way to achieve the same output string that keeps the logic of why the replacements are done in the way described above?

Body:
I don't quite follow your penultimate paragraph regarding newlines, but that aside, a single re.sub() is sufficient to get you most of the way:

>>> import re
>>>
>>> re.sub(r'[ \ue000]+', lambda m: ' ' if '\ue000' in m.group() else '_ _', s)
'The Project Gutenber_ _g E_ _Book of The Ad_ _vent_ _ure_ _s of Sherlock Holmes\n_ _'

This finds all sequences of \ue000 and spaces, then replaces those sequences using a lambda that returns either a space or  '_ _' depending on whether the match contains \ue000.

After that, as far as I can tell (as I said, your penultimate paragraph is somewhat confusing), you just need to strip underscores and spaces:

>>> re.sub(r'[ \ue000]+', lambda m: ' ' if '\ue000' in m.group() else '_ _', s).strip('_ ')
'The Project Gutenber_ _g E_ _Book of The Ad_ _vent_ _ure_ _s of Sherlock Holmes\n'


问:
Addressing localhost from a VirtualBox virtual machine
I have a local test/development server (HTTP, of course), listening to port 8000.

I'm working on Linux, so to test the page on Internet Explorer 6, 7, 8, etc. I run a virtual machine using VirtualBox; I also need to see how it look on Firefox in a windows environment (fonts for instance are different).

In my real machine, I open the website simply using the URL http://localhost:8000, how do I address this localhost from the virtual machine?

Right now my workaround is to use the IP address. Any better ideas?

答:
A combination of a few things eventually got things working on my end.
Running a flask server on macosx.

In my windows VM I edited the hosts file:

Run notepad as administrator

open C:\windows\system32\drivers\etc\hosts

add this entry: 10.0.2.2   outer

Shutdown VM and on my Mac in VirtualBox:

Go to  VirtualBox > preferences > Network > Host-only Networks > + to add a network vboxnet1

Go to My_VM > settings > Network > Adapter 1.

Select Enable Network Adapter and set Attached to: to Bridged Adapter.

Then set Advanced > Promiscuous Mode: to Allow VMs.

Click OK

Go to My_VM > settings > Network > Adapter 1.

Set Attached to: back to NAT.

Then I went to Adapter 2

Set Attached to: to Host-only Adapter and select the previous added network vboxnet1.

I started my server on my mac, running on 127.0.0.1:5000 and this was now accessible on my vm at http://10.0.2.2:5000

Man what a nightmare to test on IE on mac. How is there not a simpler way?


问:
nginx limit bandwidth per Client/IP
I have limit nginx bandwidth to 1mb/s and 1 connection maximum .
But I dont want "per connection" limit, I need per IP or per file bandwidth limitations .

Is it possible to do it by nginx ? if not what is the correct way?

答: it seems nginx doesn't have such feature. one can only limit the speed per connection, and number of connection per ip. thats all i know so far.</p>

Title: nginx limit bandwidth per Client/IP


问:
MongoDB and Big Data
I have a big database with one collection counting nearly 500 million documents, which looks as follow:

```<code>{'WP43234' : '12312312'}
</code>```

First one is an accession, second is ID - basically it's a collection of links between two datasets. The problem is that many accessions point to the same ID, which makes it huge. I have an index on the first field, which speeds up lookup procedure, but it's still too slow (about 2 min per record):

```<code>[
    {
        "v" : 2,
        "key" : {
            "_id" : 1
        },
        "name" : "_id_",
        "ns" : "TaxIDMapper.links"
    },
    {
        "v" : 2,
        "unique" : true,
        "key" : {
            "ProteinID" : 1
        },
        "name" : "ProteinID_1",
        "ns" : "TaxIDMapper.links"
    }
]
</code>```

Main aim is to speed up following procedure in my app (written in python):

User uploads file with accessions (protein ID) (say up to 100k)

Look up accession and associated ID (most time consuming part)

Get data from second collection (small, works fast, no need to do anything with it)

Personally I think these should work:

Database on SSD instead of HDD

More powerful CPU

Multiprocessing - requesting data in parallel (maybe threads are better?)

However I am not sure the speed up will be significant enough to process huge user requests. Is there anything else one could do? I was thinking about switching to SQL but it seems that MongoDB performs better.

答:
You should use a different structure for your collection : group the accession by taxonId like this:

```<code>{
  _id: taxonID,
  acc: [ "WP43234",
         "WP43234.1",
         "WP43234.2"
       ]
}
</code>```

then create an index on acc field.
Before thinking of upgrading hardware, make sur that your queries are optimized. Look at the explain() and make sure that index are correctly used (IXSCAN and not COLLSCAN).
Use mongodb 3.4, wiredTiger engine with snappy compression

Title: MongoDB and Big Data

Body:
I have a big database with one collection counting nearly 500 million documents, which looks as follow:

{'WP43234' : '12312312'}

First one is an accession, second is ID - basically it's a collection of links between two datasets. The problem is that many accessions point to the same ID, which makes it huge. I have an index on the first field, which speeds up lookup procedure, but it's still too slow (about 2 min per record):

[
    {
        "v" : 2,
        "key" : {
            "_id" : 1
        },
        "name" : "_id_",
        "ns" : "TaxIDMapper.links"
    },
    {
        "v" : 2,
        "unique" : true,
        "key" : {
            "ProteinID" : 1
        },
        "name" : "ProteinID_1",
        "ns" : "TaxIDMapper.links"
    }
]

Main aim is to speed up following procedure in my app (written in python):

User uploads file with accessions (protein ID) (say up to 100k)

Look up accession and associated ID (most time consuming part)

Get data from second collection (small, works fast, no need to do anything with it)

Personally I think these should work:

Database on SSD instead of HDD

More powerful CPU

Multiprocessing - requesting data in parallel (maybe threads are better?)

However I am not sure the speed up will be significant enough to process huge user requests. Is there anything else one could do? I was thinking about switching to SQL but it seems that MongoDB performs better.

Body:
You should use a different structure for your collection : group the accession by taxonId like this:

{
  _id: taxonID,
  acc: [ "WP43234",
         "WP43234.1",
         "WP43234.2"
       ]
}

then create an index on acc field.
Before thinking of upgrading hardware, make sur that your queries are optimized. Look at the explain() and make sure that index are correctly used (IXSCAN and not COLLSCAN).
Use mongodb 3.4, wiredTiger engine with snappy compression


问:
Variable substitution in PL/pgSQL
I have a select statement that is generated dynamically based on the supplied parameter. The problem is that postgresql always says:

argument of WHERE must be type boolean, not type character varying no matter what the parameter is. Did I miss anything?

```<code>CREATE OR REPLACE FUNCTION getuid(name character varying) RETURNS integer AS $$
    DECLARE
        statement varchar;
        uid integer;
    BEGIN
        IF ($1 = '') THEN
            statement := 'TRUE';
            statement := CAST(statement AS BOOLEAN);
        ELSE
            statement := 'users.keywords ILIKE''' || '%' || $1 || '%''';
        END IF;
        SELECT INTO uid id FROM users WHERE "statement";
        RETURN uid;
    END;
$$ LANGUAGE plpgsql
</code>```

答:
You need EXECUTE if you want to generate dynamic commands inside a function. You could also use two different sections:</p>

```<code>CREATE OR REPLACE FUNCTION getuid(name character varying) RETURNS integer AS $$
    DECLARE
        statement varchar;
        uid integer;
    BEGIN
        IF ($1 = '' OR $1 IS NULL) THEN -- section 1
            SELECT id INTO uid FROM users;
        ELSE -- section 2
            SELECT id INTO uid FROM users WHERE users.keywords ILIKE '%' || $1 || '%';
        END IF;

        RETURN uid;
    END;
$$ LANGUAGE plpgsql;
</code>```

Title: Variable substitution in PL/pgSQL

Body:
I have a select statement that is generated dynamically based on the supplied parameter. The problem is that postgresql always says:

argument of WHERE must be type boolean, not type character varying no matter what the parameter is. Did I miss anything?

CREATE OR REPLACE FUNCTION getuid(name character varying) RETURNS integer AS $$
    DECLARE
        statement varchar;
        uid integer;
    BEGIN
        IF ($1 = '') THEN
            statement := 'TRUE';
            statement := CAST(statement AS BOOLEAN);
        ELSE
            statement := 'users.keywords ILIKE''' || '%' || $1 || '%''';
        END IF;
        SELECT INTO uid id FROM users WHERE "statement";
        RETURN uid;
    END;
$$ LANGUAGE plpgsql

Body:
You need EXECUTE if you want to generate dynamic commands inside a function. You could also use two different sections:

CREATE OR REPLACE FUNCTION getuid(name character varying) RETURNS integer AS $$
    DECLARE
        statement varchar;
        uid integer;
    BEGIN
        IF ($1 = '' OR $1 IS NULL) THEN -- section 1
            SELECT id INTO uid FROM users;
        ELSE -- section 2
            SELECT id INTO uid FROM users WHERE users.keywords ILIKE '%' || $1 || '%';
        END IF;

        RETURN uid;
    END;
$$ LANGUAGE plpgsql;


问:
Shorter way to test range for a certain string
Trying to create code that will export my Excel invoice sheet to PDF, to a specified file path. The path is based on the whether the invoice lists a certain product, ProductX.

This is what I came up with, but seems cumbersome to loop through every single cell in a range to see if ProductX is there.

Is there an easier way to do this? Appreciate any help!

```<code>Sub ExportToPDF()
'
Dim file_path As String
Dim search_range As Range
Dim each_cell As Range

' Set search_range as desired search range
Set search_range = ActiveSheet.Range("A53:R56")

For Each each_cell In search_range.Cells
    If InStr(1, each_cell.Value, "ProductX", vbTextCompare) Then
        file_path = Some_path_A
    Else: file_path = Some_path_B
    End If
Next each_cell

'Export the sheet as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=file_path, Quality:=xlQualityStandard _
        , IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        True
End Sub
</code>```

答:
I think the shortest way is the following:

```<code>If WorksheetFunction.CountIf(ActiveSheet.Range("A53:R56"), "*ProductX*") = 0 Then Exit Sub
</code>```

which can be further reduced to:

```<code>If WorksheetFunction.CountIf(Range("A53:R56"), "*ProductX*") = 0 Then Exit Sub
</code>```

since ActiveSheet is the default ragnge worksheet qualification

Body:
Trying to create code that will export my Excel invoice sheet to PDF, to a specified file path. The path is based on the whether the invoice lists a certain product, ProductX.

This is what I came up with, but seems cumbersome to loop through every single cell in a range to see if ProductX is there.

Is there an easier way to do this? Appreciate any help!

Sub ExportToPDF()
'
Dim file_path As String
Dim search_range As Range
Dim each_cell As Range

' Set search_range as desired search range
Set search_range = ActiveSheet.Range("A53:R56")

For Each each_cell In search_range.Cells
    If InStr(1, each_cell.Value, "ProductX", vbTextCompare) Then
        file_path = Some_path_A
    Else: file_path = Some_path_B
    End If
Next each_cell

'Export the sheet as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=file_path, Quality:=xlQualityStandard _
        , IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        True
End Sub

Body:
I think the shortest way is the following:

If WorksheetFunction.CountIf(ActiveSheet.Range("A53:R56"), "*ProductX*") = 0 Then Exit Sub

which can be further reduced to:

If WorksheetFunction.CountIf(Range("A53:R56"), "*ProductX*") = 0 Then Exit Sub

since ActiveSheet is the default ragnge worksheet qualification


问:
express-formidable returns " undefined" when i console.log req.files.path
I'm trying to get the path for my uploaded picture to later assign it to a profile picture src.

the problem is when i try to get the path it returns " undefined "

Here's the code:

```<code>var formidable=require('express-formidable');
var express=require('express');

var app=express();
app.set('view engine', 'ejs');

app.use(formidable({
  uploadDir: 'C:/Users/me/Desktop/formidable/pics',
  multiples: true,
  keepExtensions : true,
  hash:false
}));

app.get('/',function(req, res) {
  res.render('layout')
});

app.post('/upload',(req, res) => {
console.log(req.files.path);

});

app.listen(5000,console.log('Server is running'));
</code>```

Would appreciate it if anyone could give me a hint on the problem.

Thx

result of console.log(req.files);

答:
From your console.log(req.files) statement, you have a file inside the picture key. So you need to use,

req.files.picture.path

```<code> app.post('/upload',(req, res) => {
    console.log(req.files.picture.path);
    console.log(req.files);
});
</code>```

Body:
I'm trying to get the path for my uploaded picture to later assign it to a profile picture src.

the problem is when i try to get the path it returns " undefined "

Here's the code:

var formidable=require('express-formidable');
var express=require('express');

var app=express();
app.set('view engine', 'ejs');

app.use(formidable({
  uploadDir: 'C:/Users/me/Desktop/formidable/pics',
  multiples: true,
  keepExtensions : true,
  hash:false
}));

app.get('/',function(req, res) {
  res.render('layout')
});

app.post('/upload',(req, res) => {
console.log(req.files.path);

});

app.listen(5000,console.log('Server is running'));

Would appreciate it if anyone could give me a hint on the problem.

Thx

result of console.log(req.files);

Body:
From your console.log(req.files) statement, you have a file inside the picture key. So you need to use,

req.files.picture.path

 app.post('/upload',(req, res) => {
    console.log(req.files.picture.path);
    console.log(req.files);
});


问:
Selenium: Wait for element's width to be greater than X
I have a page that does some processing and displays a progress bar.

I want to press the cancel button when the filling of the progress bar has at least 50% width.

How can I create a custom wait condition ?

```<code>    driver.findElement(By.id('bar')).then(function (stateEl) {
      // driver.wait(until. ?? By.xpath?
    }).then(done);
</code>```

答:
please try below code</p>

```<code>WebDriverWait wait = new WebDriverWait(dr,10);
wait.until(new ExpectedCondition<boolean>(){
    @Override
    public boolean apply(WebDriver d) {
        return d.findElement(By.id("origressid")).getAttribute("value")>50%;
    }}).click();
</code>```

Body:
I have a page that does some processing and displays a progress bar.

I want to press the cancel button when the filling of the progress bar has at least 50% width.

How can I create a custom wait condition ?

    driver.findElement(By.id('bar')).then(function (stateEl) {
      // driver.wait(until. ?? By.xpath?
    }).then(done);

Body:
please try below code

WebDriverWait wait = new WebDriverWait(dr,10);
wait.until(new ExpectedCondition<boolean>(){
    @Override
    public boolean apply(WebDriver d) {
        return d.findElement(By.id("origressid")).getAttribute("value")>50%;
    }}).click();


问:
How to list unique values of a particular field in Kibana
I am having a field named rpc in my elasticsearch database and I am displaying it using Kibana. When I search in search bar of kibana like:

```<code>rpc:*
</code>```

It display all the values of rpc field but I want to have only those value to be displayed which are unique.

答:
I wanted to achieve something similar but I'm stuck with Kibana 3.1.

I simply added a panel of type "TERMS" and configured its Field = User-agent and left everything else on default values. This gave me a nice bar chart with one bar for each User-agent.

Body:
I am having a field named rpc in my elasticsearch database and I am displaying it using Kibana. When I search in search bar of kibana like:

rpc:*

It display all the values of rpc field but I want to have only those value to be displayed which are unique.


问:
LocalStorage - detect if local storage is already full
is there a way to detect if local storage has reached its maximum value to store?
Or at least something like an error message that tells that i can't store anymore because i have reached the maximum size?  I want to catch this so i can remove the oldest items in my local storage and insert new ones. </p>

<p>I am using local storage to store some of my queries from my database so users would be able to load them immediately if that specific item exist on local storage. if not then, that is the time i retrieve the data in the server. </p>

答:
Upon attempting to add to localstorage, if there is not enough space, this error will be thrown. In you particular scenario, you could use this event to free up some space.

```<code>try {
  localStorage.setItem("name", "Hello World!"); //saves to the database, "key", "value"
} catch (e) {
  if (e == QUOTA_EXCEEDED_ERR) {
    alert('Quota exceeded!'); //data wasn't successfully saved due to quota exceed so throw an error
  }
}
</code>```

credit to - http://chrisberkhout.com/blog/localstorage-errors/

Body:
is there a way to detect if local storage has reached its maximum value to store?
Or at least something like an error message that tells that i can't store anymore because i have reached the maximum size?  I want to catch this so i can remove the oldest items in my local storage and insert new ones.

I am using local storage to store some of my queries from my database so users would be able to load them immediately if that specific item exist on local storage. if not then, that is the time i retrieve the data in the server.

Body:
Upon attempting to add to localstorage, if there is not enough space, this error will be thrown. In you particular scenario, you could use this event to free up some space.

try {
  localStorage.setItem("name", "Hello World!"); //saves to the database, "key", "value"
} catch (e) {
  if (e == QUOTA_EXCEEDED_ERR) {
    alert('Quota exceeded!'); //data wasn't successfully saved due to quota exceed so throw an error
  }
}

credit to - http://chrisberkhout.com/blog/localstorage-errors/


问:
Better way of returning the values of a column in Active Record?
Quick one, but thought I'd ask.

Is there a better way of getting the column values from a model's column than something like this?

```<code>Item.count(:all, :group => 'status').reject! { |i, e| i.blank? }.collect { |i,e| i}
</code>```

答:
```<code>Item.find(:all, :select=>:status, :group => 'status', :conditions => "status != ''").collect{|r| r.status}
</code>```

OwnerDisplayName: The Pied Pipes

Body:
Quick one, but thought I'd ask.

Is there a better way of getting the column values from a model's column than something like this?

Item.count(:all, :group => 'status').reject! { |i, e| i.blank? }.collect { |i,e| i}

OwnerDisplayName: aivarsak


问:
What is new() function here?
I've been learning design patterns and I saw such a method call from a class :

```<code>class Client: SubjectAccessor {
    static void Main() {
        Console.WriteLine("Proxy Pattern\n");

        ISubject subject = new Proxy();
        Console.WriteLine(subject.Requesy());

        subject = new(); //Here is what I am asking
        COnsole.WriteLine(subject.Request());
    }
}
</code>```

As you can see there is a subject = new(); call there and I am wondering whether it is creating a new instance of Proxy or something else. I've not found anything related to this.

Your help is much appreciated.

If you need, I can paste the whole code or actually it is written on a book so I need to write it down here.

Thanks.

答: That would be the proxy class. never seen such syntax before tho. Best not to use such things as it will only reduce readability..</p>

Title: What is new() function here?

Body:
I've been learning design patterns and I saw such a method call from a class :

class Client: SubjectAccessor {
    static void Main() {
        Console.WriteLine("Proxy Pattern\n");

        ISubject subject = new Proxy();
        Console.WriteLine(subject.Requesy());

        subject = new(); //Here is what I am asking
        COnsole.WriteLine(subject.Request());
    }
}

As you can see there is a subject = new(); call there and I am wondering whether it is creating a new instance of Proxy or something else. I've not found anything related to this.

Your help is much appreciated.

If you need, I can paste the whole code or actually it is written on a book so I need to write it down here.

Thanks.


问:
need spacing like the screen
need spacing like the screen

About The Movie

Cover is a one-page template for building simple and
        beautiful home pages. Download, edit the text, and add your own
        fullscreen background color and photo to make it your own.

director by

Rob W.king

casting by

Deb Green

writing  by

Dave Schultz

costume design by

colleen Bryant

Director photography  by

Peter la rocque, francis laliberte

Produced by

darren benning, jesse bryant, kelly rae buchan

 ```
</div>
</div>
</p>

```enter code here
```

答:
Use center tag.

About The Movie

Cover is a one-page template for building simple and
        beautiful home pages. Download, edit the text, and add your own
        fullscreen background color and photo to make it your own.

director by

Rob W.king

casting by

Deb Green

writing  by

Dave Schultz

costume design by

colleen Bryant

Director photography  by

Peter la rocque, francis laliberte

Produced by

darren benning, jesse bryant, kelly rae buchan

 ```

Title: need spacing like the screen

Body:
need spacing like the screen

About The Movie

Cover is a one-page template for building simple and
        beautiful home pages. Download, edit the text, and add your own
        fullscreen background color and photo to make it your own.

director by

Rob W.king

casting by

Deb Green

writing  by

Dave Schultz

costume design by

colleen Bryant

Director photography  by

Peter la rocque, francis laliberte

Produced by

darren benning, jesse bryant, kelly rae buchan

enter code here

Body:
Use center tag.

<center>

<section id="team">
<div class="container">
            <div class="row">
   <div class="col-lg-12 col-lg-push-6 ">
 <div class = "col-md-6  ">

        <h1 class="cover-heading">About The Movie</h1>

        <p class="">Cover is a one-page template for building simple and
        beautiful home pages. Download, edit the text, and add your own
        fullscreen background color and photo to make it your own.</p>

<div class = "col-md-6   ">
director by
<p style="font-weight: 600;">Rob W.king</p>

    </div>

  <div class = "col-md-6  ">
casting by
<p style="font-weight: 600;">Deb Green</p>
    </div>

   <div class = "col-md-6   ">
writing  by
<p style="font-weight: 600;">Dave Schultz</p>

    </div>

   <div class = "col-md-6   ">
costume design by
<p style="font-weight: 600;">colleen Bryant</p>
    </div>

   <div class = "col-md-6   ">
Director photography  by
<p style="font-weight: 600;">Peter la rocque, <span>francis laliberte</span></p>

    </div>

   <div class = "col-md-6  ">
Produced by
<p style="font-weight: 600;">darren benning,<span> jesse bryant,</span> <span>kelly rae buchan</span></p>
    </div>

   </div>

</div>
</div>
 </div>
  </section>

 </center>


问:
Centering div vertically and horizontally
Is there any way to center .polygon_container and .polygon vertically and horizontally? Also is there a possibility to make the size of it responsive like the  tag below?

http://cichyone.linuxpl.eu/ranestwen/ex/

I've tried text-align, margin auto etc and nothing works.

When I set it in the middle using margin-left and margin-top it is working only for one resolution.

答:
Just Use following css</p>

```<code>.slider .polygon_container {
    position: absolute;
    left:0px;
    right:0px;
    top:0px;
    bottom:0px;
    margin: auto;
    color: white;
    height: 500px;
    text-align: center;
    width: 500px;
    z-index: 99999;
}
.slider .polygon {
    color: white;
    height: 500px;
    margin: auto;
    position: absolute;
    left:0px;
    right:0px;
    top:0px;
    bottom:0px;
    width: 500px;
    z-index: 99999;
}
</code>```

Body:
Just Use following css

.slider .polygon_container {
    position: absolute;
    left:0px;
    right:0px;
    top:0px;
    bottom:0px;
    margin: auto;
    color: white;
    height: 500px;
    text-align: center;
    width: 500px;
    z-index: 99999;
}
.slider .polygon {
    color: white;
    height: 500px;
    margin: auto;
    position: absolute;
    left:0px;
    right:0px;
    top:0px;
    bottom:0px;
    width: 500px;
    z-index: 99999;
}


问:
Kubernetes deploying container in master
I have set up a kubernetes cluster and is working fine.

As of now, Kubernetes cluster deploying container in the master as well. I dont want this to be happened . Can anybody let me know, how to prevent to deploy container in the master ?

答:
If you want no Pods to be scheduled on the master you will need to taint the master node:

```<code>kubectl taint nodes nameofmaster dedicated=master:NoSchedule
</code>```

Read up on taints and tolerations to understand the consequences and how to schedule specific Pods on the now tainted master node. To undo use kubectl taint nodes nameofmaster dedicated-

Body:
If you want no Pods to be scheduled on the master you will need to taint the master node:

kubectl taint nodes nameofmaster dedicated=master:NoSchedule

Read up on taints and tolerations to understand the consequences and how to schedule specific Pods on the now tainted master node. To undo use kubectl taint nodes nameofmaster dedicated-


问:
Calculate the time stamp of year
Given that I have $num_years, how can I add it to Time()  to get a time stamp $num_years hence?

答:
is this what you want ?</p>

```<code>//Example to add 1 year to a date object
$num_years = 1;

$currentDate = date("Y-m-d");// current date

//Display the current date
echo "Current Date: ".$currentDate."<br>";

//Add one year to current date
$dateOneYearAdded = strtotime(date("Y-m-d", strtotime($currentDate)) . " +$num_years years");
echo "Date After adding one year: ".date('l dS \o\f F Y', $dateOneYearAdded)."<br>";
</code>```

Title: Calculate the time stamp of year

Body:
is this what you want ?

//Example to add 1 year to a date object
$num_years = 1;

$currentDate = date("Y-m-d");// current date

//Display the current date
echo "Current Date: ".$currentDate."<br>";

//Add one year to current date
$dateOneYearAdded = strtotime(date("Y-m-d", strtotime($currentDate)) . " +$num_years years");
echo "Date After adding one year: ".date('l dS \o\f F Y', $dateOneYearAdded)."<br>";


问:
One page menu on scroll with underline sliding links as active
I have a one page scroll menu with an underline sliding in from left to right when hovering a link. I need help on how to make a link active (meaning the line full) when in specific section such as "About".

Heres a picture that might help to show what I'm talking about (notice the link "Run" being highlighted):

I've seen many examples of a link being active online but its very confusing cause I haven't found one with my specific problem.

The closest example I found online was this http://jsfiddle.net/mdesdev/zkrh7/ but i still can't figure out how to fix the underline active.

I have created a js fiddle to show what I have so far:
    https://jsfiddle.net/rsrsrs/36rtdboh/

HTML:

```<code><div id="nav_Wrapper_dk">
<nav id="dk_Nav" role="navigation" class="cf">

    <div><a href="#home" class="link_Button sliding-u-l-r scroll">Home</a>      </div>
    <div><a href="#about" class="link_Button sliding-u-l-r scroll">About us</a></div>
    <div><a href="#link3" class="link_Button sliding-u-l-r">Gallery</a></div>
    <div><a href="#link4" class="link_Button sliding-u-l-r">Find Us</a></div>
    <div><a href="#link5" class="link_Button sliding-u-l-r">Contact</a></div>
    <div><a href="#link6" class="link_Button sliding-u-l-r">Catering</a></div>
    <div><a href="#link7" class="link_Button sliding-u-l-r">Blog</a></div>

</nav>

</div>

<div id="home"></div>

<div id="about"></div>
</code>```

CSS:

```<code>#nav_Wrapper_dk {
  position: fixed;
  width: 100%;
  height: 50px;
  background: white;
  border-bottom: 1px solid #f1f1f1;
}

#dk_Nav {
    width: 742.6167px;
    height: 50px;
    margin-left: auto;
    margin-right: auto;
    top: 0;
    right: 0;
    left: 0;
    z-index: 2001;
    background: white;
}

    #dk_Nav div {
        margin-top: 11px;
    }

    .link_Button {
        display: block;
        float: left;
        height: 40px;
        font-family: 'Open Sans', sans-serif;
        font-size: .7em;
        color: black;
        line-height: 3.3em;
        text-transform: uppercase;
        letter-spacing: .2em;
        margin-right: 44.8px;
    }

#dk_Nav div a {
  text-decoration: none
}

    /* LEFT TO RIGHT */
    .sliding-u-l-r {
        display: inline-block;
    }

    .sliding-u-l-r:after {
        content: '';
        display: block;
        height: 3px;
        width: 0;
        background: transparent;
        transition: width .3s ease, background-color .3s ease;
    }

    .sliding-u-l-r:hover:after {
        width: 100%;
        background: black;
    }

#home {
  width: 100%;
  height: 1000px;
  background: #ccc;
}

#about {
  width: 100%;
  height: 1000px;
  background: white;
}
</code>```

Javascript:

```<code>// Scroll Menu
jQuery(document).ready(function($) {
  $(".scroll").click(function(event) {
  event.preventDefault();
  $('html,body').animate( { scrollTop:$(this.hash).offset().top } , 1000);
  });
});
</code>```

Any sort of help would be highly appreciated, thanks!

答:
You jsfiddle example in this snippet with your requirement. Hope this will help.

// Scroll Menu
jQuery(document).ready(function($) {
  $("div a").click(function(event) {
    event.preventDefault();

1
    $( "nav" ).find( ".active" ).removeClass('active');
     $(this).addClass('active');
    $('html,body').animate( { scrollTop:$(this.hash).offset().top } , 1000,'linear');
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#nav_Wrapper_dk {
 position: fixed;
 width: 100%;
 height: 50px;
 background: white;
 border-bottom: 1px solid #f1f1f1;
}

 #dk_Nav {
  width: 742.6167px;
  height: 50px;
  margin-left: auto;
  margin-right: auto;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2001;
    background: white;
 }

  #dk_Nav div {
   margin-top: 11px;
  }

  .link_Button {
   display: block;
   float: left;
   height: 40px;
   font-family: 'Open Sans', sans-serif;
   font-size: .7em;
   color: black;
   line-height: 3.3em;
   text-transform: uppercase;
   letter-spacing: .2em;
   margin-right: 44.8px;
  }

    #dk_Nav div a {
      text-decoration: none
    }

  /* LEFT TO RIGHT */
  .sliding-u-l-r {
   display: inline-block;
  }

  .sliding-u-l-r:after {
   content: '';
   display: block;
   height: 3px;
   width: 0;
   background: transparent;
   transition: width .3s ease, background-color .3s ease;
  }

  .sliding-u-l-r:hover:after ,.sliding-u-l-r.active:after{
   width: 100%;
   background: black;
  }

    #home {
      width: 100%;
      height: 1000px;
      background: #ccc;
    }

    #about {
      width: 100%;
      height: 1000px;
      background: white;
    }</code>```

Home

About us

Gallery

Find Us

Contact

Catering

Blog

```

Body:
I have a one page scroll menu with an underline sliding in from left to right when hovering a link. I need help on how to make a link active (meaning the line full) when in specific section such as "About".

Heres a picture that might help to show what I'm talking about (notice the link "Run" being highlighted):

I've seen many examples of a link being active online but its very confusing cause I haven't found one with my specific problem.

The closest example I found online was this http://jsfiddle.net/mdesdev/zkrh7/ but i still can't figure out how to fix the underline active.

I have created a js fiddle to show what I have so far:
    https://jsfiddle.net/rsrsrs/36rtdboh/

HTML:

Home

About us

Gallery

Find Us

Contact

Catering

Blog

CSS:

#nav_Wrapper_dk {
  position: fixed;
  width: 100%;
  height: 50px;
  background: white;
  border-bottom: 1px solid #f1f1f1;
}

#dk_Nav {
    width: 742.6167px;
    height: 50px;
    margin-left: auto;
    margin-right: auto;
    top: 0;
    right: 0;
    left: 0;
    z-index: 2001;
    background: white;
}

    #dk_Nav div {
        margin-top: 11px;
    }

    .link_Button {
        display: block;
        float: left;
        height: 40px;
        font-family: 'Open Sans', sans-serif;
        font-size: .7em;
        color: black;
        line-height: 3.3em;
        text-transform: uppercase;
        letter-spacing: .2em;
        margin-right: 44.8px;
    }

#dk_Nav div a {
  text-decoration: none
}

    /* LEFT TO RIGHT */
    .sliding-u-l-r {
        display: inline-block;
    }

    .sliding-u-l-r:after {
        content: '';
        display: block;
        height: 3px;
        width: 0;
        background: transparent;
        transition: width .3s ease, background-color .3s ease;
    }

    .sliding-u-l-r:hover:after {
        width: 100%;
        background: black;
    }

#home {
  width: 100%;
  height: 1000px;
  background: #ccc;
}

#about {
  width: 100%;
  height: 1000px;
  background: white;
}

Javascript:

// Scroll Menu
jQuery(document).ready(function($) {
  $(".scroll").click(function(event) {
  event.preventDefault();
  $('html,body').animate( { scrollTop:$(this.hash).offset().top } , 1000);
  });
});

Any sort of help would be highly appreciated, thanks!

Body:
You jsfiddle example in this snippet with your requirement. Hope this will help.

// Scroll Menu
jQuery(document).ready(function($) {
  $("div a").click(function(event) {
    event.preventDefault();

1
    $( "nav" ).find( ".active" ).removeClass('active');
     $(this).addClass('active');
    $('html,body').animate( { scrollTop:$(this.hash).offset().top } , 1000,'linear');
  });
});

#nav_Wrapper_dk {
 position: fixed;
 width: 100%;
 height: 50px;
 background: white;
 border-bottom: 1px solid #f1f1f1;
}

 #dk_Nav {
  width: 742.6167px;
  height: 50px;
  margin-left: auto;
  margin-right: auto;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2001;
    background: white;
 }

  #dk_Nav div {
   margin-top: 11px;
  }

  .link_Button {
   display: block;
   float: left;
   height: 40px;
   font-family: 'Open Sans', sans-serif;
   font-size: .7em;
   color: black;
   line-height: 3.3em;
   text-transform: uppercase;
   letter-spacing: .2em;
   margin-right: 44.8px;
  }

    #dk_Nav div a {
      text-decoration: none
    }

  /* LEFT TO RIGHT */
  .sliding-u-l-r {
   display: inline-block;
  }

  .sliding-u-l-r:after {
   content: '';
   display: block;
   height: 3px;
   width: 0;
   background: transparent;
   transition: width .3s ease, background-color .3s ease;
  }

  .sliding-u-l-r:hover:after ,.sliding-u-l-r.active:after{
   width: 100%;
   background: black;
  }

    #home {
      width: 100%;
      height: 1000px;
      background: #ccc;
    }

    #about {
      width: 100%;
      height: 1000px;
      background: white;
    }

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="nav_Wrapper_dk">
 <nav id="dk_Nav" role="navigation" class="cf">

  <div><a href="#home" class="link_Button sliding-u-l-r scroll active">Home</a></div>
  <div><a href="#about" class="link_Button sliding-u-l-r scroll">About us</a></div>
  <div><a href="#link3" class="link_Button sliding-u-l-r">Gallery</a></div>
  <div><a href="#link4" class="link_Button sliding-u-l-r">Find Us</a></div>
  <div><a href="#link5" class="link_Button sliding-u-l-r">Contact</a></div>
  <div><a href="#link6" class="link_Button sliding-u-l-r">Catering</a></div>
  <div><a href="#link7" class="link_Button sliding-u-l-r">Blog</a></div>

 </nav>

</div>

<div id="home"></div>

<div id="about"></div>