问:
Hide button until we upload image or text
we have a button "save design" in page also we have option to upload image or text in the page.
until user upload image or Add text, we dont want to display button "save design"

we are using below code for "save design"

```<code>_getControlPanelHtml: function()
    {
        if (this.config.editorEnabled) {
            return '<div id="aitcg-control-panel">' +
                '<button id="submit-editorApply-{{rand}}" >SAVE DESIGN</button>' +
                '<button >Reset</button>' +
                '</div>';
        }
        return '';
    },

    initObservers: function()
    {
        if (this.config.editorEnabled) {
            $('submit-editorApply-' + this.config.rand).observe('click', this.submitApply.bindAsEventListener(this));
            $('submit-editorReset-' + this.config.rand).observe('click', this.submitReset.bindAsEventListener(this));
        }
    },

    submitApply: function(event)
    {
        Event.stop(event);
        this.option.apply();
    },
</code>```

I tried below code to hide the "save design" until we upload image or text.
i followed this link  i added style="display: none; and than used  show() jQuery method.

```<code><script>
    $('submit-editorApply-').show();
    _getControlPanelHtml: function()
    {
        if (this.config.editorEnabled) {
            return '<div id="aitcg-control-panel">' +
                '<button id="submit-editorApply-{{rand}}" style="display:none;" >SAVE DESIGN</button>' +
                '<button >Reset</button>' +
                '</div>';
        }
        return '';
    },

</script>
</code>```

答:
Hi well this might not be correct solution, but an example that works much similar to your codes, as in your codes you need an confirmation reply of successful upload of text or image to your server,

Here I have created two buttons one .save_design that needs to be hidden another .add_text or .add_image, now when your click .add_text a pop-up come-up for uploading of text or image which is just a div #box1 over-here, this is what you need to check, I have included textarea into it to check if any value has been added to it on blur of textarea and using condition I could check yes that includes some value, so similarly you need to check that for your upload that it isn't null, if not then .save-design fades-in.

$(document).ready(function(){
  $(".upload_text").on("click",function(){
  $("#box1").show();
});
$("#box1 > textarea").blur(function(){
 if($(this).val()){
   $(".save_design").show();
  }
  else{
    $(".save_design").hide();
     }
 });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#box1{
  width:400px;
  height:200px;
  background:#ccc;
  position:absolute;
  display:none;
}
#box1 > textarea{
  border:0px;
  background:transparent;
  width:99%;
  height:98%;
  resize:none;
}
.upload_text{
  width:150px;
  height:40px;
  background:orange;
  color:white;
  float:left;
  font-size:18px;
  text-align:center;
  padding-top:20px;
  margin-top:220px;
}
.save_design{
  width:150px;
  height:40px;
  background:orange;
  color:white;
  float:left;
  margin-left:10px;
  font-size:18px;
  text-align:center;
  padding-top:20px;
  margin-top:220px;
  display:none;
}</code>```

<textarea></textarea>

Add text

Save Design
```

Body:
we have a button "save design" in page also we have option to upload image or text in the page.
until user upload image or Add text, we dont want to display button "save design"

we are using below code for "save design"

_getControlPanelHtml: function()
    {
        if (this.config.editorEnabled) {
            return '
' +
                '<button id="submit-editorApply-{{rand}}" >SAVE DESIGN</button>' +
                '<button >Reset</button>' +
                '
';
        }
        return '';
    },

    initObservers: function()
    {
        if (this.config.editorEnabled) {
            $('submit-editorApply-' + this.config.rand).observe('click', this.submitApply.bindAsEventListener(this));
            $('submit-editorReset-' + this.config.rand).observe('click', this.submitReset.bindAsEventListener(this));
        }
    },

    submitApply: function(event)
    {
        Event.stop(event);
        this.option.apply();
    },

I tried below code to hide the "save design" until we upload image or text.
i followed this link  i added style="display: none; and than used  show() jQuery method.

Body:
Hi well this might not be correct solution, but an example that works much similar to your codes, as in your codes you need an confirmation reply of successful upload of text or image to your server,

Here I have created two buttons one .save_design that needs to be hidden another .add_text or .add_image, now when your click .add_text a pop-up come-up for uploading of text or image which is just a div #box1 over-here, this is what you need to check, I have included textarea into it to check if any value has been added to it on blur of textarea and using condition I could check yes that includes some value, so similarly you need to check that for your upload that it isn't null, if not then .save-design fades-in.

$(document).ready(function(){
  $(".upload_text").on("click",function(){
  $("#box1").show();
});
$("#box1 > textarea").blur(function(){
 if($(this).val()){
   $(".save_design").show();
  }
  else{
    $(".save_design").hide();
     }
 });
});

#box1{
  width:400px;
  height:200px;
  background:#ccc;
  position:absolute;
  display:none;
}
#box1 > textarea{
  border:0px;
  background:transparent;
  width:99%;
  height:98%;
  resize:none;
}
.upload_text{
  width:150px;
  height:40px;
  background:orange;
  color:white;
  float:left;
  font-size:18px;
  text-align:center;
  padding-top:20px;
  margin-top:220px;
}
.save_design{
  width:150px;
  height:40px;
  background:orange;
  color:white;
  float:left;
  margin-left:10px;
  font-size:18px;
  text-align:center;
  padding-top:20px;
  margin-top:220px;
  display:none;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="box1"><textarea></textarea></div>
<div class="upload_text">Add text</div>
<div class="save_design">Save Design</div>


来源: stackexchange

问:
Taxonomy access control (TAC) for SAAS based solution in Drupal
My use case scenario is as follows.

I have a taxonomy vocabulary called "Company" with unique terms "Company 1", Company 2" and so on. Each node in my setup has a term reference for this as mandatory. Similarly, every user is associated with one term with a custom field.

What I want is to restrict a user to only see/edit the nodes that are attached to the same term ID. e.g. If user A is associated with "Company 1", he/she can only view the nodes that are associated with "Company 1".

I am using "TAC" module to achieve this. But it only allows for the taxonomy based access control based on hard coded values whereas I am looking for dynamic reference to the tid in userfield.

PS: I am relatively new to Drupal

答:
Do it on your own. Use hook_node_access and write your own logic there:

https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_access/7.x

ContentLicense: CC BY-SA 3.0


问:
oracle sql developer update query
I want to insert plane_id in bookhangar table where book column having value 'no'.
my bookhangar table is

```<code>hangar_id |  book | plane_id
-------------------------------
han103    |   no  | null

han104    |   yes |pla102
</code>```

my tried query is

```<code>insert into bookhangar (plane_id) values('pla104') where book='no';
</code>```

but it doesnot inserted.

I tried another query

```<code>update  bookhangar set plane_id='PLA104' where book='no';
</code>```

It also doesnot work.

答:
It will be updated if there is any row containing value 'no'</p>

```<code>update  bookhangar set plane_id='PLA104' where lower(trim(book))='no';
</code>```

Title: oracle sql developer update query

Body:
I want to insert plane_id in bookhangar table where book column having value 'no'.
my bookhangar table is

hangar_id |  book | plane_id
-------------------------------
han103    |   no  | null

han104    |   yes |pla102

my tried query is

insert into bookhangar (plane_id) values('pla104') where book='no';

but it doesnot inserted.

I tried another query

update  bookhangar set plane_id='PLA104' where book='no';

It also doesnot work.

Body:
It will be updated if there is any row containing value 'no'

update  bookhangar set plane_id='PLA104' where lower(trim(book))='no';


问:
docker service update vs docker stack deploy with existing stack
I have a doubt in using docker swarm mode commands to update existing services after having deployed a set of services using docker stack deploy.
As far I understood every service is pinned to the SHA256 digest of the image at the time of creation, so if you rebuild and push an image (with same tag) and you try to run a docker service update, service image is not updated (even if SHA256 is different). On the contrary, if you run a docker stack deploy again, all the services are updated with the new images.
I managed to update the service image also by using docker service update --image repository/image:tag <service>. Is this the normal behavior of these commands or is there something I didn't understood?

I'm using Docker 17.03.1-ce

答:
Docker stack deploy documentation says:
"Create and update a stack from a compose or a dab file on the swarm. This command has to be run targeting a manager node."
So the behaviour you described is as expected.

Docker service update documentation is not so clear but you yourself said it only runs with --image repository/image:tag <service> so the flag is necessary to update the image.

You have two ways to accomplish what you want.

ContentLicense: CC BY-SA 4.0


问:
How can I put validation in the getter and setter methods in C#?
In C#, I can have a property without having the need to declare a private variable.
My VB6 code that looked like this

```<code>'local variable(s) to hold property value(s)
Private mvarPhoneNumber As String 'local copy
Public Property Let PhoneNumber(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.PhoneNumber = 5
    mvarPhoneNumber = vData
End Property

Public Property Get PhoneNumber() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.PhoneNumber
    PhoneNumber = mvarPhoneNumber
End Property
</code>```

can now look like this.

```<code>public string PhoneNumber{get;set;}
</code>```

How can I put validation in the getter and setter methods in C#?
I tried adding a validation like this.

```<code>public string PhoneNumber
        {
            get
            {
                return PhoneNumber;
            }
            set
            {
                if (value.Length <= 30)
                {
                    PhoneNumber = value;
                }
                else
                {
                    PhoneNumber = "EXCEEDS LENGTH";
                }
            }
        }
</code>```

The get part of this code won't compile.
Do I need to revert to using a private variable?

答:
Yes, you will have to create a backing field:

```<code>string _phoneNumber;

public string PhoneNumber
{
    get
    {
        return _phoneNumber;
    }
    set
    {
        if (value.Length <= 30)
        {
            _phoneNumber = value;
        }
        else
        {
            _phoneNumber = "EXCEEDS LENGTH";
        }
    }
}
</code>```

Keep in mind that this implementation is no different from an automatically implemented property.  When you use an automatically implemented property you are simply allowing the compiler to create the backing field for you.  If you want to add any custom logic to the get or set you have to create the field yourself as I have shown above.

Body:
In C#, I can have a property without having the need to declare a private variable.
My VB6 code that looked like this

'local variable(s) to hold property value(s)
Private mvarPhoneNumber As String 'local copy
Public Property Let PhoneNumber(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.PhoneNumber = 5
    mvarPhoneNumber = vData
End Property

Public Property Get PhoneNumber() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.PhoneNumber
    PhoneNumber = mvarPhoneNumber
End Property

can now look like this.

public string PhoneNumber{get;set;}

How can I put validation in the getter and setter methods in C#?
I tried adding a validation like this.

public string PhoneNumber
        {
            get
            {
                return PhoneNumber;
            }
            set
            {
                if (value.Length <= 30)
                {
                    PhoneNumber = value;
                }
                else
                {
                    PhoneNumber = "EXCEEDS LENGTH";
                }
            }
        }

The get part of this code won't compile.
Do I need to revert to using a private variable?

Body:
Yes, you will have to create a backing field:

string _phoneNumber;

public string PhoneNumber
{
    get
    {
        return _phoneNumber;
    }
    set
    {
        if (value.Length <= 30)
        {
            _phoneNumber = value;
        }
        else
        {
            _phoneNumber = "EXCEEDS LENGTH";
        }
    }
}

Keep in mind that this implementation is no different from an automatically implemented property.  When you use an automatically implemented property you are simply allowing the compiler to create the backing field for you.  If you want to add any custom logic to the get or set you have to create the field yourself as I have shown above.

ContentLicense: CC BY-SA 2.5


问:
Sending Json data as an object into DataTables
I have been trying to use DataTables. But after my Ajax request i get a Json object which i cannot pass into dataTables.

The Json object i receive is the following

```<code>{"data": [{"attributes": {"purchasedate": "04/01/2017", "medication": "meds", "cost": 100.0, "expirydate": "04/03/2017", "quantity": 100.0}, "type": "medical_inventory"}, {"attributes": {"purchasedate": "04/01/2017", "medication": "Extra Meds", "cost": 100.0, "expirydate": "04/02/2017", "quantity": 100.0}, "type": "medical_inventory"}, {"attributes": {"purchasedate": "04/01/2017", "medication": "Extra Super Meds", "cost": 267.0, "expirydate": "04/11/2017", "quantity": 250.0}, "type": "medical_inventory"}], "links": {"self": "/medical_inventory/"}}
</code>```

Following is my HTML code

```<code><table id="myTable" class="display" cellspacing="0" width="90%">
    <thead>
        <tr>
            <th>Medication</th>
            <th>Medication Quantity</th>
            <th>Mediaction Cost</th>
            <th>Purchase Date</th>
            <th>Expiry Date</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>Medication</th>
            <th>Medication Quantity</th>
            <th>Mediaction Cost</th>
            <th>Purchase Date</th>
            <th>Expiry Date</th>
        </tr>
    </tfoot>
</table>
</code>```

The Ajax request i do is the following

```<code>$(document).ready(function () {
        $.ajax({
            url : '/api/medical_inventory/',
            type : 'GET',
            dataType : 'json',
            success : function(data) {
                assignToEventsColumns(data);
            }
        });

        function assignToEventsColumns(data) {
            var table = $('#myTable').dataTable({
                "bAutoWidth" : false,
                "aaData" : data,
                "columns" : [ {
                    "data" : "medication"
                }, {
                    "data" : "quantity"
                }, {
                    "data" : "cost"
                }, {
                    "data" : "purchasedate"
                }, {
                    "data" : "expirydate"
                } ]
            })
        }
    });
</code>```

This is the output i am currently getting

答:
You were very nearly there:

```<code>function assignToEventsColumns(data) {
    var table = $('#myTable').dataTable({
        "bAutoWidth": false,
        "aaData": data.data,
        "columns": [{
            "data": "attributes.medication"
        }, {
            "data": "attributes.quantity"
        }, {
            "data": "attributes.cost"
        }, {
            "data": "attributes.purchasedate"
        }, {
            "data": "attributes.expirydate"
        }]
    })
}
</code>```

All you were missing was the structure of your JSON, you needed to add attributes. as well as your data.data :-D.Working JSFiddle here.

Body:
I have been trying to use DataTables. But after my Ajax request i get a Json object which i cannot pass into dataTables.

The Json object i receive is the following

{"data": [{"attributes": {"purchasedate": "04/01/2017", "medication": "meds", "cost": 100.0, "expirydate": "04/03/2017", "quantity": 100.0}, "type": "medical_inventory"}, {"attributes": {"purchasedate": "04/01/2017", "medication": "Extra Meds", "cost": 100.0, "expirydate": "04/02/2017", "quantity": 100.0}, "type": "medical_inventory"}, {"attributes": {"purchasedate": "04/01/2017", "medication": "Extra Super Meds", "cost": 267.0, "expirydate": "04/11/2017", "quantity": 250.0}, "type": "medical_inventory"}], "links": {"self": "/medical_inventory/"}}

Following is my HTML code

            Medication
            Medication Quantity
            Mediaction Cost
            Purchase Date
            Expiry Date

            Medication
            Medication Quantity
            Mediaction Cost
            Purchase Date
            Expiry Date

The Ajax request i do is the following

$(document).ready(function () {
        $.ajax({
            url : '/api/medical_inventory/',
            type : 'GET',
            dataType : 'json',
            success : function(data) {
                assignToEventsColumns(data);
            }
        });

        function assignToEventsColumns(data) {
            var table = $('#myTable').dataTable({
                "bAutoWidth" : false,
                "aaData" : data,
                "columns" : [ {
                    "data" : "medication"
                }, {
                    "data" : "quantity"
                }, {
                    "data" : "cost"
                }, {
                    "data" : "purchasedate"
                }, {
                    "data" : "expirydate"
                } ]
            })
        }
    });

This is the output i am currently getting

Body:
You were very nearly there:

function assignToEventsColumns(data) {
    var table = $('#myTable').dataTable({
        "bAutoWidth": false,
        "aaData": data.data,
        "columns": [{
            "data": "attributes.medication"
        }, {
            "data": "attributes.quantity"
        }, {
            "data": "attributes.cost"
        }, {
            "data": "attributes.purchasedate"
        }, {
            "data": "attributes.expirydate"
        }]
    })
}

All you were missing was the structure of your JSON, you needed to add attributes. as well as your data.data :-D.Working JSFiddle here.


问:
Move a child array to parent array and change parent/child name
I know probably this was asked before not sure if was in this form but I did tried some replay from what I found here about this and failed.

ok I have this array

```<code>Array
(
    [0] => Array
        (
            [Data3] => Array
                (
                    [id] => 5
                    [category] => Whiskey
                    [name] => Some name
                    [description] => description
                    [image] => asdf.jpg
                    [price] => 83.99
                )

            [ammount] => 1
            [Data_id] => 3
        )

    [1] => Array
        (
            [Data3] => Array
                (
                    [id] => 4
                    [category] => Tequila
                    [name] => Something Red 75cl
                    [description] => description
                    [image] => sierratequilasilver100.jpg
                    [price] => 92.49
                )

            [ammount] => 2
            [Data_id] => 3
        )

    [2] => Array
        (
            [Data4] => Array
                (
                    [id] => 3
                    [category] => Whiskey
                    [name] => Some name Gold
                    [description] => description
                    [image] => asdf.jpg
                    [price] => 83.99
                )

            [ammount] => 1
            [Data_id] => 4
        )

    [3] => Array
        (
            [Data4] => Array
                (
                    [id] => 5
                    [category] => Vodka
                    [name] => Something Blue 100 cl
                    [description] => description
                    [image] => Something.jpg
                    [price] => 32.44
                )

            [ammount] => 1
            [Data_id] => 4
        )

)
</code>```

What I would like to be the result is something like this:

```<code>Array
(
    [0] => Array
        (
            [id] => 5
            [category] => Whiskey
            [name] => Some name
            [description] => description
            [image] => asdf.jpg
            [price] => 83.99
            [ammount] => 1
            [Data_id] => 3
        )

    [1] => Array
        (
            [id] => 4
            [category] => Tequila
            [name] => Something Red 75cl
            [description] => description
            [image] => sierratequilasilver100.jpg
            [price] => 92.49
            [ammount] => 2
            [Data_id] => 3
        )
    [2] => Array
        (
            [id] => 3
            [category] => Whiskey
            [name] => Some name Gold
            [description] => description
            [image] => asdf.jpg
            [price] => 83.99
            [ammount] => 1
            [Data_id] => 4
        )
    [3] => Array
        (
            [id] => 5
            [category] => Vodka
            [name] => Something Blue 100 cl
            [description] => description
            [image] => Something.jpg
            [price] => 32.44
            [ammount] => 1
            [Data_id] => 4
        )
)
</code>```

or another way I could work with is if I can change Data1, Data2, Data3 and so on ..

can be n Data depends how many producs a user select

into a same name ex simple Data or Info.

ex:

```<code>Array
(
    [0] => Array
        (
            [Info] => Array
                (
                    [id] => 5
                    [category] => Whiskey
                    [name] => Some name
                    [description] => description
                    [image] => asdf.jpg
                    [price] => 83.99
                )

            [ammount] => 1
            [Data_id] => 3
        )

    [1] => Array
        (
            [Info] => Array
                (
                    [id] => 4
                    [category] => Tequila
                    [name] => Something Red 75cl
                    [description] => description
                    [image] => sierratequilasilver100.jpg
                    [price] => 92.49
                )

            [ammount] => 2
            [Data_id] => 3
        )
</code>```

Any solution will be fine for me.

Thanks and regards

答:
Use this code for your result:</p>

```<code>$final_array = array();
foreach($array1 as $offset1 => $array2) {

    $tmp_array = array();

    foreach($array2 as $offset2 =>  $array3) {

        if(is_array($array3)) {
            $tmp_array = $array3;
        } else {
            $tmp_array[$offset2] = $array3
        }

    }

    $final_array = array_merge($final_array, $tmp_array;);
    //or
    $final_array[] = $tmp_array;

}
</code>```

Body:
I know probably this was asked before not sure if was in this form but I did tried some replay from what I found here about this and failed.

ok I have this array

Array
(
    [0] => Array
        (
            [Data3] => Array
                (
                    [id] => 5
                    [category] => Whiskey
                    [name] => Some name
                    [description] => description
                    [image] => asdf.jpg
                    [price] => 83.99
                )

            [ammount] => 1
            [Data_id] => 3
        )

    [1] => Array
        (
            [Data3] => Array
                (
                    [id] => 4
                    [category] => Tequila
                    [name] => Something Red 75cl
                    [description] => description
                    [image] => sierratequilasilver100.jpg
                    [price] => 92.49
                )

            [ammount] => 2
            [Data_id] => 3
        )

    [2] => Array
        (
            [Data4] => Array
                (
                    [id] => 3
                    [category] => Whiskey
                    [name] => Some name Gold
                    [description] => description
                    [image] => asdf.jpg
                    [price] => 83.99
                )

            [ammount] => 1
            [Data_id] => 4
        )

    [3] => Array
        (
            [Data4] => Array
                (
                    [id] => 5
                    [category] => Vodka
                    [name] => Something Blue 100 cl
                    [description] => description
                    [image] => Something.jpg
                    [price] => 32.44
                )

            [ammount] => 1
            [Data_id] => 4
        )

)

What I would like to be the result is something like this:

Array
(
    [0] => Array
        (
            [id] => 5
            [category] => Whiskey
            [name] => Some name
            [description] => description
            [image] => asdf.jpg
            [price] => 83.99
            [ammount] => 1
            [Data_id] => 3
        )

    [1] => Array
        (
            [id] => 4
            [category] => Tequila
            [name] => Something Red 75cl
            [description] => description
            [image] => sierratequilasilver100.jpg
            [price] => 92.49
            [ammount] => 2
            [Data_id] => 3
        )
    [2] => Array
        (
            [id] => 3
            [category] => Whiskey
            [name] => Some name Gold
            [description] => description
            [image] => asdf.jpg
            [price] => 83.99
            [ammount] => 1
            [Data_id] => 4
        )
    [3] => Array
        (
            [id] => 5
            [category] => Vodka
            [name] => Something Blue 100 cl
            [description] => description
            [image] => Something.jpg
            [price] => 32.44
            [ammount] => 1
            [Data_id] => 4
        )
)

or another way I could work with is if I can change Data1, Data2, Data3 and so on ..

can be n Data depends how many producs a user select

into a same name ex simple Data or Info.

ex:

Array
(
    [0] => Array
        (
            [Info] => Array
                (
                    [id] => 5
                    [category] => Whiskey
                    [name] => Some name
                    [description] => description
                    [image] => asdf.jpg
                    [price] => 83.99
                )

            [ammount] => 1
            [Data_id] => 3
        )

    [1] => Array
        (
            [Info] => Array
                (
                    [id] => 4
                    [category] => Tequila
                    [name] => Something Red 75cl
                    [description] => description
                    [image] => sierratequilasilver100.jpg
                    [price] => 92.49
                )

            [ammount] => 2
            [Data_id] => 3
        )

Any solution will be fine for me.

Thanks and regards

Body:
Use this code for your result:

$final_array = array();
foreach($array1 as $offset1 => $array2) {

    $tmp_array = array();

    foreach($array2 as $offset2 =>  $array3) {

        if(is_array($array3)) {
            $tmp_array = $array3;
        } else {
            $tmp_array[$offset2] = $array3
        }

    }

    $final_array = array_merge($final_array, $tmp_array;);
    //or
    $final_array[] = $tmp_array;

}


问:
Trouble converting Excel to R Dates
I have uploaded a CSV from Excel which has a column of dates.

The first 5 of these dates is the following:

```<code>dates <- c("25/09/2016","25/09/2016","25/09/2016","25/09/2016","25/09/2016", "25/09/2016")
</code>```

When I use the following code:

```<code>as.Date(dates)
</code>```

The result is

```<code>"0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20"
</code>```

I've tried setting the origin to Excel's origin date:

```<code>as.Date(dates, origin = "1899-12-30")
</code>```

But the result is still the same

```<code>"0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20"
</code>```

Any ideas why it's not converting properly and what I should do?

答:
With excel, you need to be very careful on the format under which the date is stored.

If your dates are in a character format, you need to use as.Date(dates, format = "%d/%m/%Y"). This will work for a character date in the format DD/MM/YYYY.

For others format of excel date, you need to modulate the format following the specifications gave in that link.

If your dates are in a numeric format, you need to use as.Date(dates, origin = "1899-12-30") for windows excel and as.Date(dates, origin = "1904-01-01") for mac excel.

Title: Trouble converting Excel to R Dates

Body:
I have uploaded a CSV from Excel which has a column of dates.

The first 5 of these dates is the following:

dates <- c("25/09/2016","25/09/2016","25/09/2016","25/09/2016","25/09/2016", "25/09/2016")

When I use the following code:

as.Date(dates)

The result is

"0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20"

I've tried setting the origin to Excel's origin date:

as.Date(dates, origin = "1899-12-30")

But the result is still the same

"0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20" "0025-09-20"

Any ideas why it's not converting properly and what I should do?


问:
Cannot call runOnUiThread()
I have a fragment called MyRequestFragment, that contains a RecyclerView and binding the data to the RecyclerView using onBindViewHolder() using my adapter class.

Now every ViewHolder I have a button. and for every click on the button a POST request fired to the server and update a value. My problem is, if a success response comes, I need to hide the button on the particular ViewHolder.

The actual problem is the runOnUiThread() is not accept on the onBindViewHolder()

```<code>runOnUiThread(new Runnable() {
    public void run() {

    }
});
</code>```

How do I call this inside the ViewHolder create / bind method.

My onBindViewHolder() full code is as bellow for reference.

```<code>@Override
    public void onBindViewHolder(MyServiceViewHolder holder, int position) {
        final MyServiceBean myServiceBean = serviceList.get(position);
        holder.service_name.setText(myServiceBean.getService_name());
        holder.last_updated.setText("Job Updated Date : " +myServiceBean.getDate(myServiceBean.getUpdated_at()));
        holder.created_date.setText("Job Created Date : " + myServiceBean.getDate(myServiceBean.getCreated_at()));
        holder.status.setText(myServiceBean.getStatus());
        holder.service_note.setText("Service Note : " + myServiceBean.getService_note());
        if (myServiceBean.getService_note().toString().isEmpty())
            holder.service_note.setVisibility(View.GONE);

        switch (myServiceBean.getStatus().toString().toLowerCase()) {
            case "completed":
                holder.status.setBackgroundColor(Color.GREEN);
                break;
            case "on progress":
                holder.status.setBackgroundColor(Color.YELLOW);
                break;
            case "canceled":
                holder.status.setBackgroundColor(Color.RED);
                break;
            case "rejected":
                holder.status.setBackgroundColor(Color.RED);
                break;
            case "accept":
                holder.status.setBackgroundColor(Color.BLUE);
                break;
            default:
                holder.status.setBackgroundColor(Color.GRAY);
                break;
        }

        if(myServiceBean.getEst_amount() != null) {
            holder.estimation_region.setVisibility(View.VISIBLE);
            holder.est_status.setText("Estimation is Available");
            holder.btn_approve.setVisibility(View.VISIBLE);

            holder.est_amount.setText("Estimation Amount: " + myServiceBean.getEst_amount());
            if(myServiceBean.getEst_note() != null)
               holder.est_note.setText("Estimation Note: " + myServiceBean.getEst_note());
            if(myServiceBean.getEst_presented_by() != null)
                holder.est_presented_by.setText("Estimation Prepared By: " + myServiceBean.getEst_presented_by());

            if(myServiceBean.getEst_approved_by_customer() == "true"){
                holder.btn_approve.setVisibility(View.GONE);
                holder.est_status.setText("Estimation Approved on : " + myServiceBean.getEst_approved_date());
            }else{
                holder.btn_approve.setVisibility(View.VISIBLE);
            }

        }else{
            holder.estimation_region.setVisibility(View.GONE);
            holder.est_status.setText("Estimation on Process");
            holder.btn_approve.setVisibility(View.GONE);
        }

        holder.btn_approve.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                updateRequest();
            }
        });

    }

    private void updateRequest() {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("est_approved_by_customer", true);
            jsonObject.put("est_approved_date", "2017-10-30");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        //progress_dialog.show();
        OkHttpClient client = new OkHttpClient();

        MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        okhttp3.RequestBody body = RequestBody.create(JSON, jsonObject.toString());

        okhttp3.Request request = new Request.Builder()
                .url(ApplicationContants.BASE_URL + ApplicationContants.MY_SERVICE_APPROVE_URL)
                .post(body)
                .build();

        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, final IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                try {
                    String responseString = response.body().string();

                    JSONObject jsonObject = new JSONObject(responseString);
                    Gson gson = new Gson();
                    final MyServiceBean myServiceBean = gson.fromJson(jsonObject.toString(), MyServiceBean.class);

                    runOnUiThread(new Runnable() {
                        public void run() {

                        }
                    });

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }
</code>```

答:
runOnUiThread() is a method of Activity.

Either call it on an Activity instance (if you have access to one), or use a Handler to post your Runnable to the message queue of the main thread:

```<code>new Handler(Looper.getMainLooper()).post(new Runnable() {
    public void run() {
        // do something
    }
});
</code>```

Title: Cannot call runOnUiThread()

Body:
I have a fragment called MyRequestFragment, that contains a RecyclerView and binding the data to the RecyclerView using onBindViewHolder() using my adapter class.

Now every ViewHolder I have a button. and for every click on the button a POST request fired to the server and update a value. My problem is, if a success response comes, I need to hide the button on the particular ViewHolder.

The actual problem is the runOnUiThread() is not accept on the onBindViewHolder()

runOnUiThread(new Runnable() {
    public void run() {

    }
});

How do I call this inside the ViewHolder create / bind method.

My onBindViewHolder() full code is as bellow for reference.

@Override
    public void onBindViewHolder(MyServiceViewHolder holder, int position) {
        final MyServiceBean myServiceBean = serviceList.get(position);
        holder.service_name.setText(myServiceBean.getService_name());
        holder.last_updated.setText("Job Updated Date : " +myServiceBean.getDate(myServiceBean.getUpdated_at()));
        holder.created_date.setText("Job Created Date : " + myServiceBean.getDate(myServiceBean.getCreated_at()));
        holder.status.setText(myServiceBean.getStatus());
        holder.service_note.setText("Service Note : " + myServiceBean.getService_note());
        if (myServiceBean.getService_note().toString().isEmpty())
            holder.service_note.setVisibility(View.GONE);

        switch (myServiceBean.getStatus().toString().toLowerCase()) {
            case "completed":
                holder.status.setBackgroundColor(Color.GREEN);
                break;
            case "on progress":
                holder.status.setBackgroundColor(Color.YELLOW);
                break;
            case "canceled":
                holder.status.setBackgroundColor(Color.RED);
                break;
            case "rejected":
                holder.status.setBackgroundColor(Color.RED);
                break;
            case "accept":
                holder.status.setBackgroundColor(Color.BLUE);
                break;
            default:
                holder.status.setBackgroundColor(Color.GRAY);
                break;
        }

        if(myServiceBean.getEst_amount() != null) {
            holder.estimation_region.setVisibility(View.VISIBLE);
            holder.est_status.setText("Estimation is Available");
            holder.btn_approve.setVisibility(View.VISIBLE);

            holder.est_amount.setText("Estimation Amount: " + myServiceBean.getEst_amount());
            if(myServiceBean.getEst_note() != null)
               holder.est_note.setText("Estimation Note: " + myServiceBean.getEst_note());
            if(myServiceBean.getEst_presented_by() != null)
                holder.est_presented_by.setText("Estimation Prepared By: " + myServiceBean.getEst_presented_by());

            if(myServiceBean.getEst_approved_by_customer() == "true"){
                holder.btn_approve.setVisibility(View.GONE);
                holder.est_status.setText("Estimation Approved on : " + myServiceBean.getEst_approved_date());
            }else{
                holder.btn_approve.setVisibility(View.VISIBLE);
            }

        }else{
            holder.estimation_region.setVisibility(View.GONE);
            holder.est_status.setText("Estimation on Process");
            holder.btn_approve.setVisibility(View.GONE);
        }

        holder.btn_approve.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                updateRequest();
            }
        });

    }

    private void updateRequest() {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("est_approved_by_customer", true);
            jsonObject.put("est_approved_date", "2017-10-30");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        //progress_dialog.show();
        OkHttpClient client = new OkHttpClient();

        MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        okhttp3.RequestBody body = RequestBody.create(JSON, jsonObject.toString());

        okhttp3.Request request = new Request.Builder()
                .url(ApplicationContants.BASE_URL + ApplicationContants.MY_SERVICE_APPROVE_URL)
                .post(body)
                .build();

        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, final IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                try {
                    String responseString = response.body().string();

                    JSONObject jsonObject = new JSONObject(responseString);
                    Gson gson = new Gson();
                    final MyServiceBean myServiceBean = gson.fromJson(jsonObject.toString(), MyServiceBean.class);

                    runOnUiThread(new Runnable() {
                        public void run() {

                        }
                    });

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }

Body:
runOnUiThread() is a method of Activity.

Either call it on an Activity instance (if you have access to one), or use a Handler to post your Runnable to the message queue of the main thread:

new Handler(Looper.getMainLooper()).post(new Runnable() {
    public void run() {
        // do something
    }
});


问:
Gulp: Cannot find module 'laravel-elixir-vue-2'
I get this error when I try to use gulp in my Laravel project. I tried deleting node_modules and running npm install, but no lock.

```<code>λ gulp
module.js:471
    throw err;
    ^

Error: Cannot find module 'laravel-elixir-vue-2'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\wamp64\www\ibpc\gulpfile.js:3:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
</code>```

I also tried to add it to package.json.

package.json

```<code>{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.3.7",
    "gulp": "^3.9.1",
    "jquery": "^3.1.0",
    "laravel-elixir": "^6.0.0-9",
    "laravel-elixir-webpack-official": "^1.0.2",
    "lodash": "^4.16.2",
    "vue": "^2.0.1",
    "vue-resource": "^1.0.3"
  }
}
</code>```

Any ideas?

答:
Probably, you don't have laravel-elixir-vue-2 in your package.json file.

Try to install package with the next command:

npm install laravel-elixir-vue-2 --save-dev

Or add in your package.json this line:

"laravel-elixir-vue-2": "^0.3.0"

Body:
I get this error when I try to use gulp in my Laravel project. I tried deleting node_modules and running npm install, but no lock.

λ gulp
module.js:471
    throw err;
    ^

Error: Cannot find module 'laravel-elixir-vue-2'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\wamp64\www\ibpc\gulpfile.js:3:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

I also tried to add it to package.json.

package.json

{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.3.7",
    "gulp": "^3.9.1",
    "jquery": "^3.1.0",
    "laravel-elixir": "^6.0.0-9",
    "laravel-elixir-webpack-official": "^1.0.2",
    "lodash": "^4.16.2",
    "vue": "^2.0.1",
    "vue-resource": "^1.0.3"
  }
}

Any ideas?


问:
Using regex to find sentence between tags in string?
I need to get the sentence between tags like
Hello world!
 using regex .

Attribute of tags may differ like
Hello world!

I have code like this

```<code>var result = elements.match(/<p>(.*?)<\/p>/g).map(function(val1){
    return val1.replace(/<\/?p>/g,'');
});
</code>```

答:
You could try something like this to get the text inside the
 tags, depending on how your tags are formatted:

```<code>var el = '<p class="test" style="color:red">Hello world!</p>';
var re = /<p class=".*?" style="color:.*?">(.*?)<\/p>/g;
result = re.exec(el);
console.log(result[1]);
</code>```

If you don't know what you're going to get inside the
 tag, you can do something like this instead:

```<code>var el = '<p class="test" style="color:red">Hello world!</p>';
var re = /<p .*?>(.*?)<\/p>/g;
result = re.exec(el);
console.log(result[1]);
</code>```

Of course, this assumes that there will never be other tags inside the
 tag.

Body:
I need to get the sentence between tags like
Hello world!
 using regex .

Attribute of tags may differ like
Hello world!

I have code like this

var result = elements.match(/
(.*?)<\/p>/g).map(function(val1){
    return val1.replace(/<\/?p>/g,'');
});

Body:
You could try something like this to get the text inside the <p> tags, depending on how your tags are formatted:

var el = '<p class="test" style="color:red">Hello world!</p>';
var re = /<p class=".*?" style="color:.*?">(.*?)<\/p>/g;
result = re.exec(el);
console.log(result[1]);

If you don't know what you're going to get inside the <p> tag, you can do something like this instead:

var el = '<p class="test" style="color:red">Hello world!</p>';
var re = /<p .*?>(.*?)<\/p>/g;
result = re.exec(el);
console.log(result[1]);

Of course, this assumes that there will never be other tags inside the <p> tag.


问:
Pass parameters to actionresult from jsonresult
I wrote code to filter results like following image ,

once after it filter I want to send model values of following field as parameters to another controller method, I can call that method once I click Generate Report button

this is view file

```<code>@model project_name.Models.SearchVM
....
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    ....
    <div class="row">
        <div class="col-xs-6">
            <div class="form-group">
                @Html.LabelFor(m => m.Type, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.DropDownListFor(m => m.Type, Model.TypeList, "Select the type", new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.Type, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>
    </div>
    ...............
    <div class="row">
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="button" value="Generate Report" class="btn btn-success submit" onclick="location.href='@Url.Action("ReportExport", "Home", new { type = Model.Type , ............. })'" />   <button id="search" type="button" class="btn btn-success submit">Search</button>
            </div>
        </div>
    </div>
}
<table class="table">
    <thead>
        <tr>
            <th>ID</th>
            <th>Product name</th>
            <th>Type</th>
            .........
            <th>Action</th>
        </tr>
    </thead>
    <tbody id="table"></tbody>
</table>

<table id="template" class="table" style="display: none;">
    <tr>
        <td></td>
        <td></td>
        <td></td>
        ........
        <td><a>Edit</a></td>
    </tr>
</table>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")

    <script type="text/javascript">
        $(function () {
            $('.datepicker').datepicker({
                dateFormat: 'yy/mm/dd', changeMonth: true,
                changeYear: true, yearRange: '1910:2015'
            });
        });
    </script>

    <script type="text/javascript">

        var url = '@Url.Action("FetchProducts")';
        var editUrl = '@Url.Action("Edit")';
        var type = $('#Type');
        ..............

        var template = $('#template');
        var table = $('#table');
        $('#search').click(function () {
            table.empty();
            $.getJSON(url, { type: type.val(), ......, function (data) {
                $.each(data, function (index, item) {
                    var clone = template.clone();
                    var cells = clone.find('td');
                    cells.eq(0).text(item.ID);
                    cells.eq(1).text(item.Name);
                    cells.eq(2).text(item.Type);
                    ........................
                    cells.eq(7).text(item.Status);
                    var href = '@Url.Action("Edit")' + '/' + item.ID;
                    cells.eq(8).children('a').attr('href', href);
                    table.append(clone.find('tr'));
                });
            });
        });
    </script>

}
</code>```

I want to call and send parameters to ReportExport method once I click Generate Report button

But I'm getting null values , I think this is because of I'm doing searching using Json , So How can I get Type value and send that as parameter ,

```<code>[HttpGet]
public ActionResult ReportExport(string id, string type, ...........)
{
</code>```

答:
@Url.Action()
is razor code. It's evaluated on the server before it's sent to the view. So you have to build your URL like quoted above.

```<code> var url = $(this).data('baseurl') + '?type=' + $('#Type').val() + '&category=' + $('#Category').val() + ...;
</code>```

Body:
I wrote code to filter results like following image ,

once after it filter I want to send model values of following field as parameters to another controller method, I can call that method once I click Generate Report button

this is view file

@model project_name.Models.SearchVM
....
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    ....

                @Html.LabelFor(m => m.Type, htmlAttributes: new { @class = "control-label col-md-2" })

                    @Html.DropDownListFor(m => m.Type, Model.TypeList, "Select the type", new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.Type, "", new { @class = "text-danger" })

    ...............

                <input type="button" value="Generate Report" class="btn btn-success submit" onclick="location.href='@Url.Action("ReportExport", "Home", new { type = Model.Type , ............. })'" />   <button id="search" type="button" class="btn btn-success submit">Search</button>

}

            ID
            Product name
            Type
            .........
            Action

        ........
        Edit

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")

}

I want to call and send parameters to ReportExport method once I click Generate Report button

But I'm getting null values , I think this is because of I'm doing searching using Json , So How can I get Type value and send that as parameter ,

[HttpGet]
public ActionResult ReportExport(string id, string type, ...........)
{

Body:
@Url.Action()
is razor code. It's evaluated on the server before it's sent to the view. So you have to build your URL like quoted above.

 var url = $(this).data('baseurl') + '?type=' + $('#Type').val() + '&category=' + $('#Category').val() + ...;


问:
Single Quotes Instead of Double Quotes?
Since both are acceptable by HTML as well as languages like ASP.NET and PHP when using attributes or strings, why is it that some people use single quotes and double quotes interchangeably?

It is my understanding that it is syntactically correct to use double quotes where possible, single when you need to embed a double quote for inline logic.

Is there something I am missing?

For examples:

HTML

```<code><a href='http://google.com'>Google</a>
</code>```

PHP

```<code><? echo 'Hello World!'; ?>
</code>```

ASP.NET

```<code><form id='myForm' runat='server'></form>
</code>```

答:
In HTML, I don't think the "why" can be answered in anything but the obvious case: single quoted strings are more convenient when the string contains double quotes, and vice-versa.

In PHP, single quoted strings are more convenient when you don't want any special interpolation or escape characters.

My personal preference is always use double quotes in HTML, and to always use single quotes in PHP unless I need interpolation. Thus, I consider the single quoted strings to be "constants" of sorts in PHP, while the double quoted string implies something else is going on.

<opinion>But why do some people whimsically choose between the two? Probably because they are undisciplined and subsequently not very good programmers.</opinion>

Title: Single Quotes Instead of Double Quotes?

Body:
Since both are acceptable by HTML as well as languages like ASP.NET and PHP when using attributes or strings, why is it that some people use single quotes and double quotes interchangeably?

It is my understanding that it is syntactically correct to use double quotes where possible, single when you need to embed a double quote for inline logic.

Is there something I am missing?

For examples:

HTML

Google

PHP

<? echo 'Hello World!'; ?>

ASP.NET

<form id='myForm' runat='server'></form>


问:
find multiple occurences as part of larger pattern
I have a string the looks like such:

```<code>string = 0.033 0.0331
string2   =  0.0022e+002  123.4
</code>```

In this case the list of numbers is two for both strings, but this can be one or more.

I want to match the string and numbers such that I use the numbers and put them in a list. However I can't seem to match all the individual numbers. I use the following regex (example string as input):

```<code>matchNum = re.findall(r'(\S+)\s*=\s*((\d+\.?\d*e?[+-]?\d*)\s*)+', 'string2   =  0.0022e+002  123.4')
</code>```

This however only returns the string and the last number (twice), like such:

```<code>[('String2', '123.4\n', '123.4')]
</code>```

Any idea how I would be able to get this (?):

```<code>[('String2', '0.0022e+002', '123.4')]
</code>```

As mentioned there can also be one or more numbers but there will always be one string in the front.

Body:
I have a string the looks like such:

string = 0.033 0.0331
string2   =  0.0022e+002  123.4

In this case the list of numbers is two for both strings, but this can be one or more.

I want to match the string and numbers such that I use the numbers and put them in a list. However I can't seem to match all the individual numbers. I use the following regex (example string as input):

matchNum = re.findall(r'(\S+)\s*=\s*((\d+\.?\d*e?[+-]?\d*)\s*)+', 'string2   =  0.0022e+002  123.4')

This however only returns the string and the last number (twice), like such:

[('String2', '123.4\n', '123.4')]

Any idea how I would be able to get this (?):

[('String2', '0.0022e+002', '123.4')]

As mentioned there can also be one or more numbers but there will always be one string in the front.

Body:
Mabye something like this:

import re

s = """
string = 0.033 0.0331
string2   =  0.0022e+002  123.4
string3 = 0.8291
"""

rgx = re.compile(r'([^ \n]*) *= *([^ ]+) *([^ \n]+)?')
for x in rgx.finditer(s):
    print x.groups()

# ('string', '0.033', '0.0331')
# ('string2', '0.0022e+002', '123.4')
# ('string3', '0.8291', None)

You can use print tuple(x for x in x.groups() if x) if you don't need the None.

[Edit] Another aproach to support arbitrary quantity of numbers:

s = """
string = 0.033 0.0331
string2   =  0.0022e+002  123.4
string3 = 0.8291
string4= 0.1 0.2 0.3 0.4 0.5
"""

rgx = re.compile('[^ \n=]+')
print [rgx.findall(l) for l in s.splitlines() if l]

# [['string', '0.033', '0.0331'], ['string2', '0.0022e+002', '123.4'],
#  ['string3', '0.8291'], ['string4', '0.1', '0.2', '0.3', '0.4', '0.5']]


问:
Can not get the special charcter from query string value using PHP
I need one help. I need to fetch all data from query string using PHP but some special charcters like (i.e-+,- etc) are not coming. I am explaining my code below.

```<code>http://localhost/test/getmethod.php?name=Goro + Gun
</code>```

Here I need to get the value assign to name using the below code.

```<code><?php
$name=$_GET['name'];
echo $name;
?>
</code>```

Here I am getting the output like Goro Gun but I need the original value i.e-Goro + Gun .Please help me to resolve this issue.

答:
@subhra try this for this case name=Goro + Gun:</p>

```<code><?php
$nameArr = explode('=', $_SERVER['QUERY_STRING']);
$name = str_replace("%20", " ", $nameArr[1]);
echo $name;
?>
</code>```

Body:
I need one help. I need to fetch all data from query string using PHP but some special charcters like (i.e-+,- etc) are not coming. I am explaining my code below.

http://localhost/test/getmethod.php?name=Goro + Gun

Here I need to get the value assign to name using the below code.

<?php
$name=$_GET['name'];
echo $name;
?>

Here I am getting the output like Goro Gun but I need the original value i.e-Goro + Gun .Please help me to resolve this issue.

Body:
@subhra try this for this case name=Goro + Gun:

<?php
$nameArr = explode('=', $_SERVER['QUERY_STRING']);
$name = str_replace("%20", " ", $nameArr[1]);
echo $name;
?>


问:
Find name using like operator in SQL Server
I have table with columns

```<code>surname    forename
Dane jr    Carlo
Dane Br    Carlo
Daniel     Gerard
</code>```

forename should be same and surname partially same (means string before space  should be same after space should not same)

Output like

```<code>surname    forename
Dane jr    Carlo
Dane Br    Carlo
</code>```

答:
i have added id column for this

Dane Br    Carlo           2
Daniel     Gerard          3                                                                              Moore Jr         A           4                                                                              Moore Jr         A           5                                                                                i need this as out put                                                                      surname    forename  id
Dane jr    Carlo            1
Dane Br    Carlo           2                                                                                but the out put shows                                                                                surname    forename  id
Dane jr    Carlo            1
Dane Br    Carlo           2                                                                                Moore Jr         A           4                                                                              Moore Jr         A           5

Body:
I have table with columns

surname    forename
Dane jr    Carlo
Dane Br    Carlo
Daniel     Gerard

forename should be same and surname partially same (means string before space  should be same after space should not same)

Output like

surname    forename
Dane jr    Carlo
Dane Br    Carlo


问:
Javascript push method to populate array
I want to display the pushIssue array on screen with  object issue pushed into array pushIssue with help of Javascript only. According to my knowledge it can be done with pushIssue.push(issue), then I tried to display it on screen using document.write() but unable to display it

```<code>var issue = {
    id: 1,
    description: "This space is for description",
    severity: "This is severity",
    assignedTo: "Name of the assigned person",
    status: "Issue Status "
  }
var pushIssue = [];
</code>```

答:
After pushing the element to the array, you could use JSON.stringify

The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified.

for a stringified value in JSON notation of the array.

var issue = {
        id: 1,
        description: "This space is for description",
        severity: "This is severity",
        assignedTo: "Name of the assigned person",
        status: "Issue Status "
    },
    issues = [];

issues.push(issue);

document.write('```' + JSON.stringify(issues, 0, 4) + '```');```
</div>
</div>
</p>

<p>For a better solution, because if the page is already rendered and while <code>document.write</code> generates a new page, you could use an <code>``` tag and insert the stringified object.

var issue = {
        id: 1,
        description: "This space is for description",
        severity: "This is severity",
        assignedTo: "Name of the assigned person",
        status: "Issue Status "
    },
    issues = [];

issues.push(issue);

document.getElementById('out').appendChild(document.createTextNode(JSON.stringify(issues, 0, 4)));```
<pre class="snippet-code-html lang-html prettyprint-override"><code><pre id="out">``````

Body:
I want to display the pushIssue array on screen with  object issue pushed into array pushIssue with help of Javascript only. According to my knowledge it can be done with pushIssue.push(issue), then I tried to display it on screen using document.write() but unable to display it

var issue = {
    id: 1,
    description: "This space is for description",
    severity: "This is severity",
    assignedTo: "Name of the assigned person",
    status: "Issue Status "
  }
var pushIssue = [];

Body:
After pushing the element to the array, you could use JSON.stringify

The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified.

for a stringified value in JSON notation of the array.

var issue = {
        id: 1,
        description: "This space is for description",
        severity: "This is severity",
        assignedTo: "Name of the assigned person",
        status: "Issue Status "
    },
    issues = [];

issues.push(issue);

document.write('<pre>' + JSON.stringify(issues, 0, 4) + '</pre>');

For a better solution, because if the page is already rendered and while document.write generates a new page, you could use an <pre> tag and insert the stringified object.

var issue = {
        id: 1,
        description: "This space is for description",
        severity: "This is severity",
        assignedTo: "Name of the assigned person",
        status: "Issue Status "
    },
    issues = [];

issues.push(issue);

document.getElementById('out').appendChild(document.createTextNode(JSON.stringify(issues, 0, 4)));

<pre id="out"></pre>


问:
WPF Fade Out on a control
In my WPF app, I have a feedback control that I want to appear after a user action completes (save data, delete...).  The visibility is set to Hidden to begin and style set to the animateFadeOut style defined as a resource (see below).  Then I want to set the text and control Visibility to visible in my C# code and have the feedback control display the message and fade out after 5 seconds and remain hidden (Visibility.Hidden).

The following XAML works the first time I call control.Visiblity= Visibility.Visible but the control doesn't reappear the second time.  I figure that is because the animation is still running, which has control over the feedback control.  I then tried to set FillBehavior to "Stop" but that just made the control visible again and I want it hidden.  Then, with FillBehavior="Stop", I tried to set a trigger "when Opacity = 0, set the Visibility to Hidden".  The trigger didn't seem to fire and I was left with the visible control once more after the animation completed.

Please help point out what I am doing wrong here.

Alternatively, if you can suggest a better way to display a control that fades after 5 seconds and can be called over and over, I would appreciate it.

Thanks!

```<code><Style TargetType="{x:Type FrameworkElement}" x:Key="animateFadeOut">
        <Style.Triggers>
            <Trigger Property="Visibility" Value="Visible">
                <Trigger.EnterActions>
                    <BeginStoryboard >
                        <Storyboard>
                            <DoubleAnimation BeginTime="0:0:5.0" Storyboard.TargetProperty="Opacity"
                         From="1.0" To="0.0" Duration="0:0:0.5"/>
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
            </Trigger>
        </Style.Triggers>
    </Style>
</code>```

答:
This should fix your storyboard.

However, remember that once the animation is complete, your control is completely opaque - invisible, but your Visibility property is still set to Visible.  So you'll have to make sure that the Visibility property is reset to hidden or collapsed somewhere too.

```<code><Style TargetType="{x:Type FrameworkElement}" x:Key="animateFadeOut">
         <Style.Triggers>
            <Trigger Property="Visibility" Value="Visible">
               <Trigger.EnterActions>
                  <BeginStoryboard Name="MyFadeEffect">
                     <Storyboard>
                        <DoubleAnimation BeginTime="0:0:5.0" Storyboard.TargetProperty="Opacity"
                         From="1.0" To="0.0" Duration="0:0:0.5"/>
                     </Storyboard>
                  </BeginStoryboard>
               </Trigger.EnterActions>
               <Trigger.ExitActions>
                  <StopStoryboard BeginStoryboardName="MyFadeEffect"/>
               </Trigger.ExitActions>
            </Trigger>
         </Style.Triggers>
      </Style>
</code>```

Title: WPF Fade Out on a control

Body:
In my WPF app, I have a feedback control that I want to appear after a user action completes (save data, delete...).  The visibility is set to Hidden to begin and style set to the animateFadeOut style defined as a resource (see below).  Then I want to set the text and control Visibility to visible in my C# code and have the feedback control display the message and fade out after 5 seconds and remain hidden (Visibility.Hidden).

The following XAML works the first time I call control.Visiblity= Visibility.Visible but the control doesn't reappear the second time.  I figure that is because the animation is still running, which has control over the feedback control.  I then tried to set FillBehavior to "Stop" but that just made the control visible again and I want it hidden.  Then, with FillBehavior="Stop", I tried to set a trigger "when Opacity = 0, set the Visibility to Hidden".  The trigger didn't seem to fire and I was left with the visible control once more after the animation completed.

Please help point out what I am doing wrong here.

Alternatively, if you can suggest a better way to display a control that fades after 5 seconds and can be called over and over, I would appreciate it.

Thanks!

    </Style>

Body:
This should fix your storyboard.

However, remember that once the animation is complete, your control is completely opaque - invisible, but your Visibility property is still set to Visible.  So you'll have to make sure that the Visibility property is reset to hidden or collapsed somewhere too.

<Style TargetType="{x:Type FrameworkElement}" x:Key="animateFadeOut">
         <Style.Triggers>
            <Trigger Property="Visibility" Value="Visible">
               <Trigger.EnterActions>
                  <BeginStoryboard Name="MyFadeEffect">
                     <Storyboard>
                        <DoubleAnimation BeginTime="0:0:5.0" Storyboard.TargetProperty="Opacity"
                         From="1.0" To="0.0" Duration="0:0:0.5"/>
                     </Storyboard>
                  </BeginStoryboard>
               </Trigger.EnterActions>
               <Trigger.ExitActions>
                  <StopStoryboard BeginStoryboardName="MyFadeEffect"/>
               </Trigger.ExitActions>
            </Trigger>
         </Style.Triggers>
      </Style>


问:
How do I print oldest file and include its timestamp from a directory via UNIX
I have a number of files in a directory, and I would like to print the oldest file along with its timestamp.

The following command is giving me the correct filename, however it does not show me the timestamp.

```<code>ls -ltr | head -1
</code>```

EDIT: non-gnu based system.

答:
You can use stat to print modification timestamps in seconds since EPOCH and human readable form. Thereafter you can use numerical sort on first field and finally cut to discard first field.

```<code>stat -c $'%Y\t%y\t%n' * | sort -nk1 | cut -f 2-
</code>```

EDIT: TO use to gnu find, you can use:

```<code>find . -maxdepth 1 -printf '%T@\t%t\t%p\0' | sort -z -nk1 | cut -z -f2- | head -z -n1; echo
</code>```

Body:
I have a number of files in a directory, and I would like to print the oldest file along with its timestamp.

The following command is giving me the correct filename, however it does not show me the timestamp.

ls -ltr | head -1

EDIT: non-gnu based system.

Body:
You can use stat to print modification timestamps in seconds since EPOCH and human readable form. Thereafter you can use numerical sort on first field and finally cut to discard first field.

stat -c $'%Y\t%y\t%n' * | sort -nk1 | cut -f 2-

EDIT: TO use to gnu find, you can use:

find . -maxdepth 1 -printf '%T@\t%t\t%p\0' | sort -z -nk1 | cut -z -f2- | head -z -n1; echo


问:
`IORegisterForSystemPower failed` in file dialogs
I have a very simple Qt program that just opens a file dialog. For some reason in some cases I get a spinning beach ball for about 5 seconds before the dialog opens, and it prints IORegisterForSystemPower failed to the console.

I have also noticed similar delays before file dialogs in other programs, like LyX and even Chrome.

I'm on OSX 10.12.3. Any ideas?

答:
Actually I just worked out a cause, sort of. If I open two instances of the program, then open the dialog in the first one it is instant. If I leave it open and try to open it in the second instance I get the beach ball.

If I just have two instances of the program running then it is instance, it's only when I try to open a second file dialog that it breaks.

I'd say it was a Qt bug but since it happens in Chrome too I'm going with an OSX bug.


问:
How to expend a div to alway be 100% of the page?
I want to expand my menu height to always take 100% of the visible height.

For the moment it only take the 100% at the loading, then if I scroll down there is a white block and it's ugly.

I can't post images because I haven't 10points

The CSS of my menu is the following one:

```<code>.nav-sm .container.body .col-md-3.left_col {
    min-height: 100%;
    width: 70px;
    padding: 0;
    z-index: 9999;
    position: absolute;
}
</code>```

The thing I want to achieve is to have my menu who always took all the visible height and I can't find how to do that.

答:
Another possibility is to use vh (viewheight) instead of working with percentages:

```<code>.nav-sm .container.body .col-md-3.left_col {
    min-height: 100vh;
    width: 70px;
    padding: 0;
    z-index: 9999;
    position: absolute;
    border: 1px solid black;
}
</code>```

(For reference, check this W3Schools page

Hope this helps

Body:
I want to expand my menu height to always take 100% of the visible height.

For the moment it only take the 100% at the loading, then if I scroll down there is a white block and it's ugly.

I can't post images because I haven't 10points

The CSS of my menu is the following one:

.nav-sm .container.body .col-md-3.left_col {
    min-height: 100%;
    width: 70px;
    padding: 0;
    z-index: 9999;
    position: absolute;
}

The thing I want to achieve is to have my menu who always took all the visible height and I can't find how to do that.

Body:
Another possibility is to use vh (viewheight) instead of working with percentages:

.nav-sm .container.body .col-md-3.left_col {
    min-height: 100vh;
    width: 70px;
    padding: 0;
    z-index: 9999;
    position: absolute;
    border: 1px solid black;
}

(For reference, check this W3Schools page

Hope this helps


问:
Changing View Background Color with Soft Animation Infinitely Android
I want to create a color changing background animation that run continuously in my view, and I've been able to create the color changing animation with this code.

```<code>int prevColor = getRandomColor();
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), prevColor, getRandomColor(prevColor));
colorAnimation.setRepeatCount(ValueAnimator.INFINITE);
colorAnimation.setDuration(transitionTime); // milliseconds
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animator) {
        backgroundBase.setBackgroundColor((int) animator.getAnimatedValue());
    }
});
colorAnimation.start();
</code>```

It run smoothly, but...

When the animation end, it abruptly goes back changing color to the first one without the soft animation like the first time

Then, what I would like to do is when the animation finishes, I want the animation to get new Random Color from my Color List so that the color constantly changing from time to time (not just reversing back and forth)

I cannot find setAnimationListener in the colorAnimation, so I cannot use the override method onAnimationEnd

What should I do to achieve that?

答:
This happens the because your are changing the color you the initial animation... If you start your animation with the current color of the view, it may work.

Try this:

```<code>    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), backgroundBase.getBackgroundColor,
getRandomColor(backgroundBase.getBackgroundColor));
    colorAnimation.setRepeatCount(ValueAnimator.INFINITE);
    colorAnimation.setDuration(transitionTime); // milliseconds
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            backgroundBase.setBackgroundColor((int) animator.getAnimatedValue());
        }
    });
    colorAnimation.start();
</code>```

Body:
I want to create a color changing background animation that run continuously in my view, and I've been able to create the color changing animation with this code.

int prevColor = getRandomColor();
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), prevColor, getRandomColor(prevColor));
colorAnimation.setRepeatCount(ValueAnimator.INFINITE);
colorAnimation.setDuration(transitionTime); // milliseconds
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animator) {
        backgroundBase.setBackgroundColor((int) animator.getAnimatedValue());
    }
});
colorAnimation.start();

It run smoothly, but...

When the animation end, it abruptly goes back changing color to the first one without the soft animation like the first time

Then, what I would like to do is when the animation finishes, I want the animation to get new Random Color from my Color List so that the color constantly changing from time to time (not just reversing back and forth)

I cannot find setAnimationListener in the colorAnimation, so I cannot use the override method onAnimationEnd

What should I do to achieve that?

Body:
This happens the because your are changing the color you the initial animation... If you start your animation with the current color of the view, it may work.

Try this:

    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), backgroundBase.getBackgroundColor,
getRandomColor(backgroundBase.getBackgroundColor));
    colorAnimation.setRepeatCount(ValueAnimator.INFINITE);
    colorAnimation.setDuration(transitionTime); // milliseconds
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            backgroundBase.setBackgroundColor((int) animator.getAnimatedValue());
        }
    });
    colorAnimation.start();


问:
SQL Search Query
I'm currently working on a query to search a specific table.  The requirements say that I need to grab all records where any of a group of fields are like the input value.  As such I have a query that looks similar to

```<code>SELECT * FROM MyTable
WHERE Col1 like @input
    or Col2 like @input
    or Col3 like @input
</code>```

There could be any number of columns in the where clause.  One particular customer is going to have 50 columns. As such, this where clause is going to get fairly expensive.

Is there another syntax or method that can be used so that I could say "does the input value exist in any of x columns?"

Would you write the query differently?

答:
I'd structure the data differently. Are the types of these 50 columns all going to be the same? Since you're using "like", I'm going to assume they are all varchar columns. Why not have 3 tables, 'MyTable', a table with the string data (whatever it may be), and a join table with references to both.

At this point, your query becomes:

```<code>select mt.*
from MyTable mt
    inner join JoinTable jt
        on jt.MyTableId = mt.Id
    inner join DataTable dt
        on dt.Id = jt.DataTableId
where dt.Data like @Input
</code>```

Obviously, on SO, we see a lot of answers that are simply, "Your data is structured wrong. Redo it." This is not always the most helpful. If for some reason (bureaucracy around database structure, legacy dependencies on this structure, etc.) you cannot restructure it, you need to realize you're pivoting these columns. At this point you'll need to look at options for pivoting this, which will vary based on how analytical/transactional (read/write heavy) this db is. If you are very read heavy, you might be ok duplicating the data into a pivot table that you update each time you update 'MyTable'. If you're more transactional, a function or view will at least abstract this pivoted structure but the query will be expensive. MS SQL full text search capabilities would work similarly to duplicating the data and updating on inserts and depending on the nature of your "like" queries, may read faster.

Title: SQL Search Query

Body:
I'm currently working on a query to search a specific table.  The requirements say that I need to grab all records where any of a group of fields are like the input value.  As such I have a query that looks similar to

SELECT * FROM MyTable
WHERE Col1 like @input
    or Col2 like @input
    or Col3 like @input

There could be any number of columns in the where clause.  One particular customer is going to have 50 columns. As such, this where clause is going to get fairly expensive.

Is there another syntax or method that can be used so that I could say "does the input value exist in any of x columns?"

Would you write the query differently?

Body:
I'd structure the data differently. Are the types of these 50 columns all going to be the same? Since you're using "like", I'm going to assume they are all varchar columns. Why not have 3 tables, 'MyTable', a table with the string data (whatever it may be), and a join table with references to both.

At this point, your query becomes:

select mt.*
from MyTable mt
    inner join JoinTable jt
        on jt.MyTableId = mt.Id
    inner join DataTable dt
        on dt.Id = jt.DataTableId
where dt.Data like @Input

Obviously, on SO, we see a lot of answers that are simply, "Your data is structured wrong. Redo it." This is not always the most helpful. If for some reason (bureaucracy around database structure, legacy dependencies on this structure, etc.) you cannot restructure it, you need to realize you're pivoting these columns. At this point you'll need to look at options for pivoting this, which will vary based on how analytical/transactional (read/write heavy) this db is. If you are very read heavy, you might be ok duplicating the data into a pivot table that you update each time you update 'MyTable'. If you're more transactional, a function or view will at least abstract this pivoted structure but the query will be expensive. MS SQL full text search capabilities would work similarly to duplicating the data and updating on inserts and depending on the nature of your "like" queries, may read faster.


问:
Get latest updated records
I have an "Observation" table in SQL Server 2008. This table has a locationId column for a bunch of geographic locations, a few columns for observation details and a column for latest updated date.

Every week, a new observation record for each location is appended. So a location has many occurrences in the table.

What I want to achieve is to be able to get the most recent observation record for each location.

Can anyone help with any idea?

答:
Use the Getdate function as I used as below.</p>

```<code>select * from TBL_MP_QC_CustomerWiseCOA_Master  order by getdate() desc
</code>```

Title: Get latest updated records

Body:
Use the Getdate function as I used as below.

select * from TBL_MP_QC_CustomerWiseCOA_Master  order by getdate() desc


问: How to remove only one inline

答:
Go to your header file, probably in the  you will find

```<code><?php echo get_template_part('customcss'); ?>
</code>```

And also there is customcss.php in your theme folder. But you should be aware this is the styles you assign in your WordPress Dashboard and deleting it, won't be as happy ever after as you think. You can delete the code or change customcss.php. If it is not as that, look for some phrase of php that echo your CSS file.

Title: How to remove only one inline <style> from Wordpress head

Body:
I'm designing a Wordpress site that's not yet live. There is a block of inline css in the head of the home page that needs to go. I'm not sure where it's being generated from but the I've modified the css since and the inline css isn't updating to match it.

I've tried overruling it by using !important in my custom.css.

I've tried adding my style sheet just above the  so it loads last.

<link rel='stylesheet' href='http://mywebsite/wpnew/wp-content/themes/mytheme/custom.css?counter=1491147962' type='text/css' media='all' />

I've tried adding this to my functions.php:

wp_enqueue_style( 'customcss', get_template_directory_uri() . '/custom.css', array(), time() );

I've deleted the widget that the css belongs to thinking the page might render without the inline css since the widget was gone but it's still there.

I'm at a loss. I'm not a programmer and not entirely comfortable with php. I found a plugin that strips all inline tags but I only want to get rid of this one block of css.

Any help would be appreciated!

Body:
Go to your header file, probably in the <head> you will find

<?php echo get_template_part('customcss'); ?>

And also there is customcss.php in your theme folder. But you should be aware this is the styles you assign in your WordPress Dashboard and deleting it, won't be as happy ever after as you think. You can delete the code or change customcss.php. If it is not as that, look for some phrase of php that echo your CSS file.


问:
which access permissions required by co-administrator to see azure active directory
administrator user added in our azure subscription and when this user logins to azure portal and trying to access azure active directory it showing there is no access to it.

my question is : which access permissions required by co-administrator to see azure active directory

答: So basically depending on your needs you need to assign different permission to the user. Here is the list of roles and their description, and here is the guide to assign them using the portal</p>