问:
Jquery Masking returning Float/Int Value
how can i returned back the original value of the input that masked using jquery masking plugin ?

this case, i'm using money currency masking. if i get the value using jQuery, it returning string, not float/int.

how can i returned it back to original value ?

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = $('.money').val();
  console.log(mon);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>

<input type="text" class="money" value="30000"></code>```

答:
You need to call .cleanVal() on the element. Read the section Getting a masked value programmatically of this link.

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = $('.money').cleanVal();
  console.log(mon);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>

<input type="text" class="money" value="30000"></code>```

Textboxes always return string values. You have to parse it as number manually using parseInt() or parseFloat() as per your need.

Body:
how can i returned back the original value of the input that masked using jquery masking plugin ?

this case, i'm using money currency masking. if i get the value using jQuery, it returning string, not float/int.

how can i returned it back to original value ?

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = $('.money').val();
  console.log(mon);
});

<input type="text" class="money" value="30000">

Body:
You need to call .cleanVal() on the element. Read the section Getting a masked value programmatically of this link.

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = $('.money').cleanVal();
  console.log(mon);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>

<input type="text" class="money" value="30000">

Textboxes always return string values. You have to parse it as number manually using parseInt() or parseFloat() as per your need.


来源: stackexchange

问:
HelpAndroid map marker change start and end color, put different details and add polylines
Is there a way I can change the icon of start and end of marker like blue for start and red for end, add different details and add connecting polyline?

Button:

```<code>b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (int i = 0; i < list_location.size(); i++) {
                    createMarker(list_location.get(i).getLatitude(), list_location.get(i).getLongitude());
                }
            }
            });
</code>```

Marker:

```<code>private void createMarker(String latitude, String longitude) {
    // Adding the taped point to the ArrayList
    BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_menu_camera);
    Double lat = Double.parseDouble(latitude);
    Double Longitude = Double.parseDouble(longitude);

    map.addMarker(new MarkerOptions()
            .position(new LatLng(lat, Longitude))
            .anchor(0.5f, 0.5f)
            .title("title")
            .snippet("snippet")
            .icon(icon));

}
</code>```

答:
It's easy but seems you haven't tried much

you can use index to find first and last points
and draw different color based on position

i.e.

```<code>for (int i = 0; i < list_location.size(); i++) {
    createMarker(i, list_location.get(i).getLatitude(),list_location.get(i).getLongitude());
}
</code>```

and in your createMarker() method

```<code>private void createMarker(int index, String latitude, String longitude) {
    // Adding the taped point to the ArrayList
if (index == 0)
color = BitmapDescriptorFactory.COLOR_THAT_SUITS;
else if (index == list_location.size()-1)
color = BitmapDescriptorFactory.COLOR_THAT_SUITS;

//set this color to your marker
.....
.....
.icon(BitmapDescriptorFactory.defaultMarker(color)));
</code>```

}

ContentLicense: CC BY-SA 3.0

Body:
Is there a way I can change the icon of start and end of marker like blue for start and red for end, add different details and add connecting polyline?

Button:

b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (int i = 0; i < list_location.size(); i++) {
                    createMarker(list_location.get(i).getLatitude(), list_location.get(i).getLongitude());
                }
            }
            });

Marker:

private void createMarker(String latitude, String longitude) {
    // Adding the taped point to the ArrayList
    BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_menu_camera);
    Double lat = Double.parseDouble(latitude);
    Double Longitude = Double.parseDouble(longitude);

    map.addMarker(new MarkerOptions()
            .position(new LatLng(lat, Longitude))
            .anchor(0.5f, 0.5f)
            .title("title")
            .snippet("snippet")
            .icon(icon));

}

Body:
It's easy but seems you haven't tried much

you can use index to find first and last points
and draw different color based on position

i.e.

for (int i = 0; i < list_location.size(); i++) {
    createMarker(i, list_location.get(i).getLatitude(),list_location.get(i).getLongitude());
}

and in your createMarker() method

private void createMarker(int index, String latitude, String longitude) {
    // Adding the taped point to the ArrayList
if (index == 0)
color = BitmapDescriptorFactory.COLOR_THAT_SUITS;
else if (index == list_location.size()-1)
color = BitmapDescriptorFactory.COLOR_THAT_SUITS;

//set this color to your marker
.....
.....
.icon(BitmapDescriptorFactory.defaultMarker(color)));

}


问:
How to have two password fields controlled by one checkbox?
```<code><form>
<fieldset>
Password: <span id="capsalert">CAPS LOCK = on</span><br>
<input type="password" id="pwd">
<script type="text/javascript">
  document.write(
    '<input type="checkbox" name="masking" onclick="unmask(this.checked)"> ' +
    'Show the password as I type'
  );
</script>
<br>
Password2:<br>
<input type="password" id="pwd2">
</fieldset>
</form>
<script type="text/javascript">
function chkCaps(e) {
ev = (e ? e : window.event);
kc = (ev.which ? ev.which : (ev.keyCode ? ev.keyCode : false));
sk = (ev.shiftKey ? ev.shiftKey : (ev.modifiers ? !!(ev.modifiers & 4) : false));
if(
  (kc >= 97 && kc <= 122 && sk) ||
  (kc >= 65 && kc <= 90 && !sk)
) {
  document.getElementById('capsalert').style.display = 'inline';
}
else {
  document.getElementById('capsalert').style.display = 'none';
}//end if
}//end function
function unmask(truefalse) {
oldElem = document.getElementById('pwd');
elem = document.createElement('input');
elem.setAttribute('type', (truefalse == true ? 'text' : 'password'));
elem.setAttribute('value', document.getElementById('pwd').value);
elem.id = 'pwd';
oldElem.parentNode.replaceChild(elem,oldElem);

document.getElementById('pwd').onkeypress = function(e) { chkCaps(e); };
}//end function
document.getElementById('pwd').onkeypress = function(e) { chkCaps(e); };
</script>
</code>```

I'm using the above code in a slightly more complex form.

I have two separate "password" fields on the form.  With the current code I can have the first password field show the characters as they are typed when the checkbox is ticked.

Also, the code notifies the user if they are typing with CAPS Lock enabled.

I would like to have both password fields exhibiting the same behavior rather than the first field only.  Unfortunately, I do not know how to make that happen.

Thanks for the help.

EDIT:

A simple solution might be easier to find with the following code.  I'm willing to use either one.

```<code><script>
function changeType()
{
    document.myform.pass.type=(document.myform.option.value=(document.myform.option.value==1)?'-1':'1')=='1'?'password':'text';
}
</script>

<body>
<form name="myform">
   <input type="password" name="pass" />
   <input type="password" name="pass2" />
   <input type="checkbox" name="option" value='1' onchange="changeType()" />
</form>
</body>
</code>```

答:
Try this:

```<code>function chkCaps(e) {
    ev = (e ? e : window.event);
    kc = (ev.which ? ev.which : (ev.keyCode ? ev.keyCode : false));
    sk = (ev.shiftKey ? ev.shiftKey : (ev.modifiers ? !! (ev.modifiers & 4) : false));
    if ((kc >= 97 && kc <= 122 && sk) || (kc >= 65 && kc <= 90 && !sk)) {
        document.getElementById('capsalert').style.display = 'inline';
    } else {
        document.getElementById('capsalert').style.display = 'none';
    }
    //end if
}
//end function

function unmask(truefalse) {
    for (var f in new Array('pwd', 'pwd2')) {
        oldElem = document.getElementById(f);
        elem = document.createElement('input');
        elem.setAttribute('type', (truefalse == true ? 'text' : 'password'));
        elem.setAttribute('value', document.getElementById(f).value);
        elem.id = f;
        oldElem.parentNode.replaceChild(elem, oldElem);
        document.getElementById(f).onkeypress = function (e) {
            chkCaps(e);
        };
    }
}
//end function
document.getElementById('pwd').onkeypress = function (e) {
    chkCaps(e);
};
document.getElementById('pwd2').onkeypress = function (e) {
    chkCaps(e);
};
</code>```

What this does is make it so your code works on pwd and pwd2 by repeating it for each element in the array new Array('pwd', 'pwd2').

ContentLicense: CC BY-SA 2.5

Body:
<form>
<fieldset>
Password: CAPS LOCK = on

<input type="password" id="pwd">

Password2:

<input type="password" id="pwd2">
</fieldset>
</form>

I'm using the above code in a slightly more complex form.

I have two separate "password" fields on the form.  With the current code I can have the first password field show the characters as they are typed when the checkbox is ticked.

Also, the code notifies the user if they are typing with CAPS Lock enabled.

I would like to have both password fields exhibiting the same behavior rather than the first field only.  Unfortunately, I do not know how to make that happen.

Thanks for the help.

EDIT:

A simple solution might be easier to find with the following code.  I'm willing to use either one.

<form name="myform">
   <input type="password" name="pass" />
   <input type="password" name="pass2" />
   <input type="checkbox" name="option" value='1' onchange="changeType()" />
</form>

Body:
Try this:

function chkCaps(e) {
    ev = (e ? e : window.event);
    kc = (ev.which ? ev.which : (ev.keyCode ? ev.keyCode : false));
    sk = (ev.shiftKey ? ev.shiftKey : (ev.modifiers ? !! (ev.modifiers & 4) : false));
    if ((kc >= 97 && kc <= 122 && sk) || (kc >= 65 && kc <= 90 && !sk)) {
        document.getElementById('capsalert').style.display = 'inline';
    } else {
        document.getElementById('capsalert').style.display = 'none';
    }
    //end if
}
//end function

function unmask(truefalse) {
    for (var f in new Array('pwd', 'pwd2')) {
        oldElem = document.getElementById(f);
        elem = document.createElement('input');
        elem.setAttribute('type', (truefalse == true ? 'text' : 'password'));
        elem.setAttribute('value', document.getElementById(f).value);
        elem.id = f;
        oldElem.parentNode.replaceChild(elem, oldElem);
        document.getElementById(f).onkeypress = function (e) {
            chkCaps(e);
        };
    }
}
//end function
document.getElementById('pwd').onkeypress = function (e) {
    chkCaps(e);
};
document.getElementById('pwd2').onkeypress = function (e) {
    chkCaps(e);
};

What this does is make it so your code works on pwd and pwd2 by repeating it for each element in the array new Array('pwd', 'pwd2').


问:
How to get values from multidimensional array using checkbox in php
this is my array and back end (controller)

```<code>$newA = array("agents" => array("value" => array( "65" => array( "drive" => "number","cars" => "78"),"68" => array( "drive" => "num","cars" => "98"))));

$test2 = $r->myCheckbox;
</code>```

Now I can display '65' and '68' this values I get from checkbox selected by users, but I want to display values in the 65 and 68.
please help me thank you.

答:
```<code>$test2 = array_column($newA, 'value')[0];
$get_res  = array_keys($test2);
print_r($get_res);
</code>```

Body:
this is my array and back end (controller)

$newA = array("agents" => array("value" => array( "65" => array( "drive" => "number","cars" => "78"),"68" => array( "drive" => "num","cars" => "98"))));

$test2 = $r->myCheckbox;

Now I can display '65' and '68' this values I get from checkbox selected by users, but I want to display values in the 65 and 68.
please help me thank you.


问:
Issue with CodeIgniter redirect
Here i'm creating a login system. Once the user is verified the controller redirects the page to home.php.

There are 2 pages here login_registration.php and home.php

login_registration.php consists login and registration form from here the user is redirected to home.php. both the files are in path C:\wamp\www\CI-Project_1\application\views\login

The issue is it show 404 Page Not Found when redirected.

```<code> class Login extends CI_Controller {
    public function __construct(){
        parent::__construct();
                $this->load->helper('url');
        //LOAD MODELS HERE
        $this->load->model('Login_model');
    }

    public function index(){
        $this->load->view('login/login_registration.php');
    }

    function login_user(){
        $login_btn = $this->input->post('login_btn');

        if($login_btn == TRUE){
            $arr['login'] = array(
                'username'=>$this->input->post('username'),
                'password'=>$this->input->post('password')
            );

            $query = $this->Login_model->users_login($arr);

            if($query->num_rows() > 0 && $query->num_rows() == 1){
                $this->load->library('session');
                $this->session->set_userdata($arr['login']);
                redirect('login/home.php', 'location');
            }
            else
            {
                $this->index();
            }
        }
        else
        {
            $this->index();
        }
    }
}
</code>```

THANKS IN ADVANCE

答:
For redirect and $this->load->view, don't use .php.

Use something like this:
    redirect('login/home', 'location');

Title: Issue with CodeIgniter redirect

Body:
Here i'm creating a login system. Once the user is verified the controller redirects the page to home.php.

There are 2 pages here login_registration.php and home.php

login_registration.php consists login and registration form from here the user is redirected to home.php. both the files are in path C:\wamp\www\CI-Project_1\application\views\login

The issue is it show 404 Page Not Found when redirected.

 class Login extends CI_Controller {
    public function __construct(){
        parent::__construct();
                $this->load->helper('url');
        //LOAD MODELS HERE
        $this->load->model('Login_model');
    }

    public function index(){
        $this->load->view('login/login_registration.php');
    }

    function login_user(){
        $login_btn = $this->input->post('login_btn');

        if($login_btn == TRUE){
            $arr['login'] = array(
                'username'=>$this->input->post('username'),
                'password'=>$this->input->post('password')
            );

            $query = $this->Login_model->users_login($arr);

            if($query->num_rows() > 0 && $query->num_rows() == 1){
                $this->load->library('session');
                $this->session->set_userdata($arr['login']);
                redirect('login/home.php', 'location');
            }
            else
            {
                $this->index();
            }
        }
        else
        {
            $this->index();
        }
    }
}

THANKS IN ADVANCE


问:
AspectJ pointcut on method variable, is it possible?
I have been using AspectJ for a while and it works great on object scope fields containing annotations. I just ran into a situation where I want to annotate a variable of method scope that will work with my pointcut but I am having trouble with it.

Here is the pointcut that I am using. It works fine if my variable is a field for the object, but if I reduce the scope to a method (variable declared inside the method), then it doesn't work anymore and I am not sure why. Let me know what I can do, thanks.

```<code> after(final Trigger trigger): set(@Triggereable * *) && args(trigger)
 {
  System.out.println("trigger flush");
 }
</code>```

Also, here is an exmaple of what I want to work. That System.out.println above should fire when the Trigger is instantiated:

```<code>public void foo()
{
   @Triggereable
   private Trigger trigger = new Trigger();
}
</code>```

答:
If you came to such situation, you probably trying to change implementation instead of applying actual cross cutting concerns. Basically, it is not what AOP and AspectJ is supposed to be used for.

As a work around, you can either extract relevant functionality into a separate method and then apply your aspects to that method or alternatively, you can replace an entire method with that local variable, using around advice.

More over, in your particular example, the pointcut can be applied to the constructor execution within scope of a given method, so you can do practically the same thing without binding to a local variable.

Body:
I have been using AspectJ for a while and it works great on object scope fields containing annotations. I just ran into a situation where I want to annotate a variable of method scope that will work with my pointcut but I am having trouble with it.

Here is the pointcut that I am using. It works fine if my variable is a field for the object, but if I reduce the scope to a method (variable declared inside the method), then it doesn't work anymore and I am not sure why. Let me know what I can do, thanks.

 after(final Trigger trigger): set(@Triggereable * *) && args(trigger)
 {
  System.out.println("trigger flush");
 }

Also, here is an exmaple of what I want to work. That System.out.println above should fire when the Trigger is instantiated:

public void foo()
{
   @Triggereable
   private Trigger trigger = new Trigger();
}


问:
In what way is grequests asynchronous?
I've been using the python requests library for some time, and recently had a need to make a request asynchronously, meaning I would like to send off the HTTP request, have my main thread continue to execute, and have a callback called when the request returns.

Naturally, I was lead to the grequests library (https://github.com/kennethreitz/grequests), but i'm confused about the behavior. For example:

```<code>import grequests

def print_res(res):
    from pprint import pprint
    pprint (vars(res))

req = grequests.get('http://www.codehenge.net/blog', hooks=dict(response=print_res))
res = grequests.map([req])

for i in range(10):
    print i
</code>```

The above code will produce the following output:

```<code><...large HTTP response output...>

0
1
2
3
4
5
6
7
8
9
</code>```

The grequests.map() call obviously blocks until the HTTP response is available. It seems likely I misunderstood the 'asynchronous' behavior here, and the grequests library is just for performing multiple HTTP requests concurrently and sending all responses to a single callback. Is this accurate?

答:
If you don't want to use grequests you can just implement requests with callbacks using requests + the threading module from the standard library. It's actually really easy, and if all you want to do is send requests with callbacks the API is nicer than the one provided by grequests.

```<code>from threading import Thread

from requests import get, post, put, patch, delete, options, head

request_methods = {
    'get': get,
    'post': post,
    'put': put,
    'patch': patch,
    'delete': delete,
    'options': options,
    'head': head,
}

def async_request(method, *args, callback=None, timeout=15, **kwargs):
    """Makes request on a different thread, and optionally passes response to a
    `callback` function when request returns.
    """
    method = request_methods[method.lower()]
    if callback:
        def callback_with_args(response, *args, **kwargs):
            callback(response)
        kwargs['hooks'] = {'response': callback_with_args}
    kwargs['timeout'] = timeout
    thread = Thread(target=method, args=args, kwargs=kwargs)
    thread.start()
</code>```

You can verify that it works like an AJAX calls in JS: you send a request on another thread, do some stuff on the main thread, and when the request returns you invoke a callback. This callback just prints out the response content.

```<code>async_request('get', 'http://httpbin.org/anything', callback=lambda r: print(r.json()))
for i in range(10):
    print(i)
</code>```

Title: In what way is grequests asynchronous?

Body:
I've been using the python requests library for some time, and recently had a need to make a request asynchronously, meaning I would like to send off the HTTP request, have my main thread continue to execute, and have a callback called when the request returns.

Naturally, I was lead to the grequests library (https://github.com/kennethreitz/grequests), but i'm confused about the behavior. For example:

import grequests

def print_res(res):
    from pprint import pprint
    pprint (vars(res))

req = grequests.get('http://www.codehenge.net/blog', hooks=dict(response=print_res))
res = grequests.map([req])

for i in range(10):
    print i

The above code will produce the following output:

<...large HTTP response output...>

0
1
2
3
4
5
6
7
8
9

The grequests.map() call obviously blocks until the HTTP response is available. It seems likely I misunderstood the 'asynchronous' behavior here, and the grequests library is just for performing multiple HTTP requests concurrently and sending all responses to a single callback. Is this accurate?

Body:
If you don't want to use grequests you can just implement requests with callbacks using requests + the threading module from the standard library. It's actually really easy, and if all you want to do is send requests with callbacks the API is nicer than the one provided by grequests.

from threading import Thread

from requests import get, post, put, patch, delete, options, head

request_methods = {
    'get': get,
    'post': post,
    'put': put,
    'patch': patch,
    'delete': delete,
    'options': options,
    'head': head,
}

def async_request(method, *args, callback=None, timeout=15, **kwargs):
    """Makes request on a different thread, and optionally passes response to a
    `callback` function when request returns.
    """
    method = request_methods[method.lower()]
    if callback:
        def callback_with_args(response, *args, **kwargs):
            callback(response)
        kwargs['hooks'] = {'response': callback_with_args}
    kwargs['timeout'] = timeout
    thread = Thread(target=method, args=args, kwargs=kwargs)
    thread.start()

You can verify that it works like an AJAX calls in JS: you send a request on another thread, do some stuff on the main thread, and when the request returns you invoke a callback. This callback just prints out the response content.

async_request('get', 'http://httpbin.org/anything', callback=lambda r: print(r.json()))
for i in range(10):
    print(i)


问:
How to sudo run a local script over ssh
I try to sudo run a local script over ssh,

```<code>ssh $HOST < script.sh
</code>```

and I tried

```<code>ssh -t $HOST "sudo -s && bash" < script.sh
</code>```

Actually, I searched a lot in google, find some similar questions, however, I don't find a solution which can sudo run a local script.

答: First of all divide your objective in 2 parts. 1) ssh to the host. 2) run the command you want as sudo. After you are certain that you can 1) access the host and 2) have sudo privileges then you can combine the two commands with &&. What x_cmd && y_cmd does is that the y_cmd gets executed after x_cmd has exited successfully.

ContentLicense: CC BY-SA 4.0

Title: How to sudo run a local script over ssh

Body:
I try to sudo run a local script over ssh,

ssh $HOST < script.sh

and I tried

ssh -t $HOST "sudo -s && bash" < script.sh

Actually, I searched a lot in google, find some similar questions, however, I don't find a solution which can sudo run a local script.


问:
Cannot change the background image while the radio button is hovered
I wrote a radio list with image animate. When it was hovered and checked, it can change to another image.
it's works on all of the browsers but on IE its not work when I hover on it.
I don't know if I wrote some css wrong or miss something about ie issue?
the html is:

```<code><ul>
<li>
<input type="radio" id="f-option" name="gender">
<label for="f-option" class="gender female"><img src="images/52x42.png"></label>
<div class="check"></div>
</li>
</ul>
</code>```

and my css is:

```<code>.user-form ul li label.gender.female {
background-image: url(../images/female.png);
}

.user-form input[type=radio]:checked ~ label.gender.female,
.user-form input[type=radio]:hover ~ label.gender.female {
background-image: url(../images/female-checked.png);
}
</code>```

its works all of the browser but not work on ie
can anybody help me fix it?

The online demo is in this bottom of page:
http://bestinthink.com/wg/buy-p1.html

答:
Try the below. I'm accessing the female class directly after the label as .gender and .female were siblings.</p>

```<code>.user-form ul li label.gender.female {
background-image: url(../images/female.png);
}

.user-form input[type=radio]:checked ~ label .female,
.user-form input[type=radio]:hover ~ label .female {
background-image: url(../images/female-checked.png);
}
</code>```

Body:
I wrote a radio list with image animate. When it was hovered and checked, it can change to another image.
it's works on all of the browsers but on IE its not work when I hover on it.
I don't know if I wrote some css wrong or miss something about ie issue?
the html is:

<input type="radio" id="f-option" name="gender">

and my css is:

.user-form ul li label.gender.female {
background-image: url(../images/female.png);
}

.user-form input[type=radio]:checked ~ label.gender.female,
.user-form input[type=radio]:hover ~ label.gender.female {
background-image: url(../images/female-checked.png);
}

its works all of the browser but not work on ie
can anybody help me fix it?

The online demo is in this bottom of page:
http://bestinthink.com/wg/buy-p1.html

Body:
Try the below. I'm accessing the female class directly after the label as .gender and .female were siblings.

.user-form ul li label.gender.female {
background-image: url(../images/female.png);
}

.user-form input[type=radio]:checked ~ label .female,
.user-form input[type=radio]:hover ~ label .female {
background-image: url(../images/female-checked.png);
}


问:
TYPO3 Remove "Select & Upload Files" button
Removing the "Select & Upload Files" button from Page properties works with the following line in PageTSConfig:

```<code>TCEFORM.pages.media.config.appearance.fileUploadAllowed = 0
</code>```

Now I want to remove the "Select & Upload Files" button within content elements (for example with CType "textmedia"), too.

I tried out several things, but with no success. I found no working PageTSConfig "rule" for this case. Does somebody know how the "Select & Upload Files" button can be removed for content elements like textmedia elements?

Using TYPO3 8.7.1

答:
This is a very simple way to remove "Select & Upload Files" button

User settings -> Edit and Advanced functions -> File upload directly
  in Doc-module(uncheck this checkbox)

Body:
Removing the "Select & Upload Files" button from Page properties works with the following line in PageTSConfig:

TCEFORM.pages.media.config.appearance.fileUploadAllowed = 0

Now I want to remove the "Select & Upload Files" button within content elements (for example with CType "textmedia"), too.

I tried out several things, but with no success. I found no working PageTSConfig "rule" for this case. Does somebody know how the "Select & Upload Files" button can be removed for content elements like textmedia elements?

Using TYPO3 8.7.1


问:
Java, Lucene : Sort search results with highest hit rate.
I am working on a Spring-MVC application in which I am saving contents of user-data and using Lucene to index and search. Currently the functionality is working fine. Is it possible to sort the result with the highest matching probability first? I am currently saving paragraphs or more of text in indexes. Thank you.

Save code :

```<code> Directory directory = org.apache.lucene.store.FSDirectory.open(path);
            IndexWriterConfig config = new IndexWriterConfig(new SimpleAnalyzer());
            IndexWriter indexWriter = new IndexWriter(directory, config);
            indexWriter.commit();
            org.apache.lucene.document.Document doc = new org.apache.lucene.document.Document();
            if (filePath != null) {
                File file = new File(filePath); // current directory
                doc.add(new TextField("path", file.getPath(), Field.Store.YES));
            }
            doc.add(new StringField("id", String.valueOf(objectId), Field.Store.YES));
FieldType fieldType = new FieldType(TextField.TYPE_STORED);
                fieldType.setTokenized(false);
                if(groupNotes!=null) {
                    doc.add(new Field("contents", text + "\n" + tagFileName+"\n"+String.valueOf(groupNotes.getNoteNumber()), fieldType));
                }else {
                    doc.add(new Field("contents", text + "\n" + tagFileName, fieldType));
                }
</code>```

Search code :

```<code>File file = new File(path.toString());
                if ((file.isDirectory()) && (file.list().length > 0)) {
                    if(text.contains(" ")) {
                        String[] textArray = text.split(" ");
                        for(String str : textArray) {
                            Directory directory = FSDirectory.open(path);
                            IndexReader indexReader = DirectoryReader.open(directory);
                            IndexSearcher indexSearcher = new IndexSearcher(indexReader);
                            Query query = new WildcardQuery(new Term("contents","*"+str + "*"));
                            TopDocs topDocs = indexSearcher.search(query, 100);

                            for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
                                System.out.println("Score is "+scoreDoc.score);
                                org.apache.lucene.document.Document document = indexSearcher.doc(scoreDoc.doc);
                                objectIds.add(Integer.valueOf(document.get("id")));
                            }
                            indexSearcher.getIndexReader().close();
                            directory.close();
                        }
                    }
}
}
</code>```

Thank you.

答:
Your question is not a bit very clear to me so below are just guessed answers ,

There are methods in IndexSearcher which take org.apache.lucene.search.Sort as argument ,

public TopFieldDocs search(Query query, int n,
  Sort sort, boolean doDocScores, boolean doMaxScore) throws IOException OR

public TopFieldDocs search(Query query, int n, Sort sort) throws IOException

See if these methods solve your issue.

If you simply want to sort on the basis of scores then don't collect only document Ids but collect score too in a pojo that has that score field .

Collect all these pojos in some List then outside loop sort list on the basis
of score.

for (ScoreDoc hit : hits) {
          //additional code
         pojo.setScore(hit.score);

```<code>    list.add(pojo);

   }
</code>```

then outside for loop ,

list.sort((POJO p1, POJO p2) -> p2
            .getScore().compareTo(p1.getScore()));

Body:
I am working on a Spring-MVC application in which I am saving contents of user-data and using Lucene to index and search. Currently the functionality is working fine. Is it possible to sort the result with the highest matching probability first? I am currently saving paragraphs or more of text in indexes. Thank you.

Save code :

 Directory directory = org.apache.lucene.store.FSDirectory.open(path);
            IndexWriterConfig config = new IndexWriterConfig(new SimpleAnalyzer());
            IndexWriter indexWriter = new IndexWriter(directory, config);
            indexWriter.commit();
            org.apache.lucene.document.Document doc = new org.apache.lucene.document.Document();
            if (filePath != null) {
                File file = new File(filePath); // current directory
                doc.add(new TextField("path", file.getPath(), Field.Store.YES));
            }
            doc.add(new StringField("id", String.valueOf(objectId), Field.Store.YES));
FieldType fieldType = new FieldType(TextField.TYPE_STORED);
                fieldType.setTokenized(false);
                if(groupNotes!=null) {
                    doc.add(new Field("contents", text + "\n" + tagFileName+"\n"+String.valueOf(groupNotes.getNoteNumber()), fieldType));
                }else {
                    doc.add(new Field("contents", text + "\n" + tagFileName, fieldType));
                }

Search code :

File file = new File(path.toString());
                if ((file.isDirectory()) && (file.list().length > 0)) {
                    if(text.contains(" ")) {
                        String[] textArray = text.split(" ");
                        for(String str : textArray) {
                            Directory directory = FSDirectory.open(path);
                            IndexReader indexReader = DirectoryReader.open(directory);
                            IndexSearcher indexSearcher = new IndexSearcher(indexReader);
                            Query query = new WildcardQuery(new Term("contents","*"+str + "*"));
                            TopDocs topDocs = indexSearcher.search(query, 100);

                            for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
                                System.out.println("Score is "+scoreDoc.score);
                                org.apache.lucene.document.Document document = indexSearcher.doc(scoreDoc.doc);
                                objectIds.add(Integer.valueOf(document.get("id")));
                            }
                            indexSearcher.getIndexReader().close();
                            directory.close();
                        }
                    }
}
}

Thank you.

Body:
Your question is not a bit very clear to me so below are just guessed answers ,

There are methods in IndexSearcher which take org.apache.lucene.search.Sort as argument ,

public TopFieldDocs search(Query query, int n,
  Sort sort, boolean doDocScores, boolean doMaxScore) throws IOException OR

public TopFieldDocs search(Query query, int n, Sort sort) throws IOException

See if these methods solve your issue.

If you simply want to sort on the basis of scores then don't collect only document Ids but collect score too in a pojo that has that score field .

Collect all these pojos in some List then outside loop sort list on the basis
of score.

for (ScoreDoc hit : hits) {
          //additional code
         pojo.setScore(hit.score);

    list.add(pojo);

   }

then outside for loop ,

list.sort((POJO p1, POJO p2) -> p2
            .getScore().compareTo(p1.getScore()));


问:
(VueJS) vue-router match multiple paths
I am using vue-router, and am looking to match two very distinct paths.  Is there some kind of array notation I can use?</p>

答:
You can use an alias in the routes:

```<code>routes: [
  { path: '/foo', component: Foo, alias: '/bar'}
]
</code>```

There are some nice examples here:

https://github.com/vuejs/vue-router/blob/dev/examples/route-alias/app.js

Title: (VueJS) vue-router match multiple paths

Body:
You can use an alias in the routes:

routes: [
  { path: '/foo', component: Foo, alias: '/bar'}
]

There are some nice examples here:

https://github.com/vuejs/vue-router/blob/dev/examples/route-alias/app.js


问:
Updating the input value on button click Jquery
For The code below, when the button is clicked, it's supposed to update the name of the text. ie hisally, hellosally, supsally,
but instead the current is hitomsally, hellotomsally, suptomsally.
i m wondering is there any way to update the name while keeping the text hi,hellop and sup.
Many thanks

$(".ok").on('click', function() {
  var set = $(this).closest('tr').find('.done').val();
  if (set) {
    $(this).closest('tr').find('.text').each(function() {
      $(this).val($(this).attr("data-value") + set);
    })
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tr>

    <td>
     <input type="button" value="ok" class="ok"></td>
    <td>done<input type="text" value="sally" class="done" \> </td>
    <td>text1<textarea class="text" data-value="hitom">hitom</textarea> </td>
    <td>text2<textarea class="text" data-value="hellotom">hellotom</textarea> </td>
    <td>text3<textarea class="text" data-value="suptom">suptom</textarea> </td>

  </tr>
</table>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script></code>```

答:
I am deleting the 'tom' from every string.

$(".ok").on('click', function() {
  var set = $(this).closest('tr').find('.done').val();
  if (set) {
    $(this).closest('tr').find('.text').each(function() {
      $(this).val($(this).attr("data-value").replace(/tom/g,"")+set);
    })
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tr>

    <td>
     <input type="button" value="ok" class="ok"></td>
    <td>done<input type="text" value="sally" class="done" \> </td>
    <td>text1<textarea class="text" data-value="hitom">hitom</textarea> </td>
    <td>text2<textarea class="text" data-value="hellotom">hellotom</textarea> </td>
    <td>text3<textarea class="text" data-value="suptom">suptom</textarea> </td>

  </tr>
</table>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script></code>```

Body:
For The code below, when the button is clicked, it's supposed to update the name of the text. ie hisally, hellosally, supsally,
but instead the current is hitomsally, hellotomsally, suptomsally.
i m wondering is there any way to update the name while keeping the text hi,hellop and sup.
Many thanks

$(".ok").on('click', function() {
  var set = $(this).closest('tr').find('.done').val();
  if (set) {
    $(this).closest('tr').find('.text').each(function() {
      $(this).val($(this).attr("data-value") + set);
    })
  }
});

     <input type="button" value="ok" class="ok">
    done<input type="text" value="sally" class="done" \>
    text1<textarea class="text" data-value="hitom">hitom</textarea>
    text2<textarea class="text" data-value="hellotom">hellotom</textarea>
    text3<textarea class="text" data-value="suptom">suptom</textarea>

Body:
I am deleting the 'tom' from every string.

$(".ok").on('click', function() {
  var set = $(this).closest('tr').find('.done').val();
  if (set) {
    $(this).closest('tr').find('.text').each(function() {
      $(this).val($(this).attr("data-value").replace(/tom/g,"")+set);
    })
  }
});

<table>
  <tr>

    <td>
     <input type="button" value="ok" class="ok"></td>
    <td>done<input type="text" value="sally" class="done" \> </td>
    <td>text1<textarea class="text" data-value="hitom">hitom</textarea> </td>
    <td>text2<textarea class="text" data-value="hellotom">hellotom</textarea> </td>
    <td>text3<textarea class="text" data-value="suptom">suptom</textarea> </td>

  </tr>
</table>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>


问:
Hide "Add to cart" button when the product price is zero
I have an event based WordPress website on that I sell tickets using WooCommerce. Is there any way to hide the "add to cart" button for the product having cost zero?

Thanks.

答:
You write this code in your theme function.php

```<code>function remove_add_to_cart_on_0 ( $purchasable, $product ){
        if( $product->get_price() == 0 )
            $purchasable = false;
        return $purchasable;
    }
    add_filter( 'woocommerce_is_purchasable', 'remove_add_to_cart_on_0', 10, 2 );
</code>```

Body:
You write this code in your theme function.php

function remove_add_to_cart_on_0 ( $purchasable, $product ){
        if( $product->get_price() == 0 )
            $purchasable = false;
        return $purchasable;
    }
    add_filter( 'woocommerce_is_purchasable', 'remove_add_to_cart_on_0', 10, 2 );


问:
Creating a regex to replace each matched character of a string with same character
In my application, I have an alphanumeric string being passed into my function. This string is typically 17 characters, but not always. I'm trying to write a regex that matches all but the last 4 characters in the string, and replaces them with X (to mask it).

For example

```<code>Input: HGHG8686HGHG8686H

Output: XXXXXXXXXXXXX686H
</code>```

The Regex I wrote to perform the replace on the string is as follows

```<code>[a-zA-Z0-9].{12}
</code>```

Code:

```<code>const maskedString = string.replace(/[a-zA-Z0-9].{12}/g, 'X');
</code>```

The issue I'm having is that it's replacing all but the last 4 characters in the string with just that single X. It doesn't know to do that for every matched character. Any ideas?

答:
The simple version: (Easier to read)

```<code>const maskedString = string.replace(/(.{4})$|(^(..)|(.))/g, 'X\1'); // or X$1
</code>```

Now using: [a-zA-Z0-9]

```<code>const maskedString = string.replace(/([a-zA-Z0-9]{4})$|(^([a-zA-Z0-9]{2})|([a-zA-Z0-9]{1}))/g, 'X\1'); // or X$1
</code>```

Note: The reason i match on the START PLUS TWO characters is to offset the first match. (The final 4 characters that are appended at the end.)

Body:
In my application, I have an alphanumeric string being passed into my function. This string is typically 17 characters, but not always. I'm trying to write a regex that matches all but the last 4 characters in the string, and replaces them with X (to mask it).

For example

Input: HGHG8686HGHG8686H

Output: XXXXXXXXXXXXX686H

The Regex I wrote to perform the replace on the string is as follows

[a-zA-Z0-9].{12}

Code:

const maskedString = string.replace(/[a-zA-Z0-9].{12}/g, 'X');

The issue I'm having is that it's replacing all but the last 4 characters in the string with just that single X. It doesn't know to do that for every matched character. Any ideas?

Body:
The simple version: (Easier to read)

const maskedString = string.replace(/(.{4})$|(^(..)|(.))/g, 'X\1'); // or X$1

Now using: [a-zA-Z0-9]

const maskedString = string.replace(/([a-zA-Z0-9]{4})$|(^([a-zA-Z0-9]{2})|([a-zA-Z0-9]{1}))/g, 'X\1'); // or X$1

Note: The reason i match on the START PLUS TWO characters is to offset the first match. (The final 4 characters that are appended at the end.)


问:
"Invalid JSON string" in Google visualization API example
I am roughly following this example. But must be doing something silly...

The server side Django view code:

```<code>data_table = gviz_api.DataTable(description)
data_table.LoadData(data)
json = data_table.ToJSon()
return json
</code>```

These are the values of the variables copy-pasted from the pydev debugger: (Im using strings for each description field type just for testing)

description:

```<code>[("sensor","string", "Sensor name"),
 ("timestamp","string", "Time"),
 ("value","string", "Sensor value")]
</code>```

data:

```<code>[['testsensor', '2011-05-09 16:06:43.936000', '22.0'],
['testsensor', '2011-05-09 16:56:23.367000', '23.0']]
</code>```

json (generated by the google api):

```<code>{cols:[{id:'sensor',label:'Sensor name',type:'string'},{id:'timestamp',label:'Time',type:'string'},{id:'value',label:'Sensor value',type:'string'}],rows:[{c:[{v:'testsensor'},{v:'2011-05-09 16:06:43.936000'},{v:'22.0'}]},{c:[{v:'testsensor'},{v:'2011-05-09 16:56:23.367000'},{v:'23.0'}]}]}
</code>```

The client side javascript code that receives the json:

```<code>var json_table = new google.visualization.Table(document.getElementById('dataview'));
var json_data = new google.visualization.DataTable(data, 0.6);
json_table.draw(json_data, {showRowNumber: true});
</code>```

This causes the following error on constructing the DataTable object (second line):

```<code>Uncaught Error: Invalid JSON string: {cols:[{id:'sensor',label:'Sensor name',type:'string'},{id:'timestamp',label:'Time',type:'string'},{id:'value',label:'Sensor value',type:'string'}],rows:[{c:[{v:'testsensor'},{v:'2011-05-09 16:06:43.936000'},{v:'22.0'}]},{c:[{v:'testsensor'},{v:'2011-05-09 16:56:23.367000'},{v:'23.0'}]}]}
in default,table.I.js:152
</code>```

I understood that the whole clue was making sure that the schema format matches the data format but this seems to be the case.  It must be something simple.

答:
Make sure you put 'unsafe-eval' for script sources in Content-Security-Policy.

A policy I use for Google Maps and Google Charts:

```<code><meta
  http-equiv="Content-Security-Policy"
  content="
    default-src 'self';
    script-src 'self' 'unsafe-inline' 'unsafe-eval' maps.googleapis.com www.google.com www.google-analytics.com;
    img-src 'self' csi.gstatic.com www.google-analytics.com maps.gstatic.com maps.googleapis.com;
    style-src 'self' 'unsafe-inline' www.google.com fonts.googleapis.com ajax.googleapis.com;
    font-src 'self' fonts.gstatic.com;
  "
/>
</code>```

Body:
I am roughly following this example. But must be doing something silly...

The server side Django view code:

data_table = gviz_api.DataTable(description)
data_table.LoadData(data)
json = data_table.ToJSon()
return json

These are the values of the variables copy-pasted from the pydev debugger: (Im using strings for each description field type just for testing)

description:

[("sensor","string", "Sensor name"),
 ("timestamp","string", "Time"),
 ("value","string", "Sensor value")]

data:

[['testsensor', '2011-05-09 16:06:43.936000', '22.0'],
['testsensor', '2011-05-09 16:56:23.367000', '23.0']]

json (generated by the google api):

{cols:[{id:'sensor',label:'Sensor name',type:'string'},{id:'timestamp',label:'Time',type:'string'},{id:'value',label:'Sensor value',type:'string'}],rows:[{c:[{v:'testsensor'},{v:'2011-05-09 16:06:43.936000'},{v:'22.0'}]},{c:[{v:'testsensor'},{v:'2011-05-09 16:56:23.367000'},{v:'23.0'}]}]}

The client side javascript code that receives the json:

var json_table = new google.visualization.Table(document.getElementById('dataview'));
var json_data = new google.visualization.DataTable(data, 0.6);
json_table.draw(json_data, {showRowNumber: true});

This causes the following error on constructing the DataTable object (second line):

Uncaught Error: Invalid JSON string: {cols:[{id:'sensor',label:'Sensor name',type:'string'},{id:'timestamp',label:'Time',type:'string'},{id:'value',label:'Sensor value',type:'string'}],rows:[{c:[{v:'testsensor'},{v:'2011-05-09 16:06:43.936000'},{v:'22.0'}]},{c:[{v:'testsensor'},{v:'2011-05-09 16:56:23.367000'},{v:'23.0'}]}]}
in default,table.I.js:152

I understood that the whole clue was making sure that the schema format matches the data format but this seems to be the case.  It must be something simple.

Body:
Make sure you put 'unsafe-eval' for script sources in Content-Security-Policy.

A policy I use for Google Maps and Google Charts:

<meta
  http-equiv="Content-Security-Policy"
  content="
    default-src 'self';
    script-src 'self' 'unsafe-inline' 'unsafe-eval' maps.googleapis.com www.google.com www.google-analytics.com;
    img-src 'self' csi.gstatic.com www.google-analytics.com maps.gstatic.com maps.googleapis.com;
    style-src 'self' 'unsafe-inline' www.google.com fonts.googleapis.com ajax.googleapis.com;
    font-src 'self' fonts.gstatic.com;
  "
/>


问:
MONTHS_BETWEEN function does not give the expected result
I am using MONTHS_BETWEEN function to get the difference between 2 dates , but the result is not 100% correct i think this function mines 1 day .
i tried  this SQL

```<code> SELECT MONTHS_BETWEEN(TO_DATE('20170630','YYYYMMDD'),
   TO_DATE('20170501','YYYYMMDD') ) "Months"
    FROM DUAL;
</code>```

here in this case it should return 2 but the result is 1.93548387096774
So, Any help ?? or is there any way to add 1 more day to date??

答:
Months between will give you a decimal value with respect to a whole month. So from 1st Jan to 1st Feb, you will get 1. But from 1st Jan to 31st Jan you will not get exact 1. It will be 0.9....  Similarly from 31st Jan to 28th Feb (non leap year) you will get 1.

So you will get 2 from 1st May to 1st July OR from 30th April to 30th June,

From 1st May to 30th June, you will never get exact 2.

If you want exact 2, then either add 1 day to greater date or subtract 1 day from start_date.

DBFiddle Demo

Body:
I am using MONTHS_BETWEEN function to get the difference between 2 dates , but the result is not 100% correct i think this function mines 1 day .
i tried  this SQL

 SELECT MONTHS_BETWEEN(TO_DATE('20170630','YYYYMMDD'),
   TO_DATE('20170501','YYYYMMDD') ) "Months"
    FROM DUAL;

here in this case it should return 2 but the result is 1.93548387096774
So, Any help ?? or is there any way to add 1 more day to date??


问:
What is a Stuck Thread?
The term stuck thread is commonly used in Oracle WebLogic Server.

What is a stuck thread and why is thread diagnosed as a stuck thread?

When does stuck thread occur?

What kind of impact does it happen to
the running application?

What are the prevention mechanisms?

答:
Stuck Threads are threads that are blocked, and can't return to the threadpool for a certain amout of time. By Default, the WLS comes with 600 secs. If some thread doesn't return in 600 secs, It gets a flag 'stuck thread'.

– > Stuck Threads are only flags, there to warn you that this thread is taking too long.

Searching a bit on google I found this site: http://www.munzandmore.com/2012/ora/weblogic-stuck-threads-howto

It explains what are stuck threads, as well some methods to work around them.

Title: What is a Stuck Thread?


问:
Jquery Masking returning Float/Int Value
how can i returned back the original value of the input that masked using jquery masking plugin ?

this case, i'm using money currency masking. if i get the value using jQuery, it returning string, not float/int.

how can i returned it back to original value ?

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = $('.money').val();
  console.log(mon);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>

<input type="text" class="money" value="30000"></code>```

答:
You can try using parseFloat(string) function

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = parseFloat($('.money').val());
  console.log(mon);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>

<input type="text" class="money" value="30000"></code>```

Body:
how can i returned back the original value of the input that masked using jquery masking plugin ?

this case, i'm using money currency masking. if i get the value using jQuery, it returning string, not float/int.

how can i returned it back to original value ?

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = $('.money').val();
  console.log(mon);
});

<input type="text" class="money" value="30000">

Body:
You can try using parseFloat(string) function

$(document).ready(function() {
 $('.money').mask('000.000.000.000.000,00', {reverse: true});
  var mon = parseFloat($('.money').val());
  console.log(mon);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.11/jquery.mask.min.js"></script>

<input type="text" class="money" value="30000">


问:
How to import package 'Storage' in to Swift project?
I'm currently studying the source code of Firefox-iOS app by creating my own Swift project and typing the code line by line.

In one of the source code files, it imported a packaged named Storage

But I don't think the package Storage is part of the apple API and I don't really know how I can import it.

Edit

Multiple podfiles are present in the project folder

答:
In Swift you dont import other Swift files as they are readily available to use directly.

But you need to import another module. It looks like Storage here is a module inside the firefox-ios app workspace and hence you need to import it before using it.

I looked at the sourcecode at Github and it does contain a package named Storage.

You can read this to understand more about Modules and import statement.


问:
How to set div height same as parent container without using percentage?
I am using an angular plugin called angular-split, it offers a gutter to split resize-able part on html page.

The problem is that if you want to split something, the div contains the gutter must be set a height in specific value, not percentage.

So my question is if I want my div to full fill the parent container without using height=100%, what could I do?

答:
Are those divs individually style along-with a child div, if so you can do that by changing the display of parent and child element. No need to assign height to child element it by default takes as 100% of parent element.

Check below codes, red div is parent div and blue one child.

#parent {
  width: 100%;
  height: 400px;
  background: red;
  display: table;
  color: white;
  padding-top: 10px;/*Optional*/
}

#parent .child {
  width: 100%;
  height: auto;
  background: blue;
  display: table-cell;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="parent">
  <div class="child">
    Child
  </div>
</div></code>```

Body:
Are those divs individually style along-with a child div, if so you can do that by changing the display of parent and child element. No need to assign height to child element it by default takes as 100% of parent element.

Check below codes, red div is parent div and blue one child.

#parent {
  width: 100%;
  height: 400px;
  background: red;
  display: table;
  color: white;
  padding-top: 10px;/*Optional*/
}

#parent .child {
  width: 100%;
  height: auto;
  background: blue;
  display: table-cell;
}

<div id="parent">
  <div class="child">
    Child
  </div>
</div>


问:
How to organize multiple flash projects sharing common lib as for classpaths
Let's say I have multiple projects organized as

```commonlib
superorg
   org1
     suborg11
     suborg12
   org2
     suborg21
```

How do you declare import and manage classpaths as for classes in commonlib package ?

答: In either the flash ide or flash builder you can specify global classpaths. That way your import statements are the same across projects without having a million copies of the files.  Heres a tut - http://asgamer.com/2009/easily-use-frameworks-in-multiple-projects-by-setting-a-global-class-path</p>

Body:
Let's say I have multiple projects organized as

commonlib
superorg
   org1
     suborg11
     suborg12
   org2
     suborg21

How do you declare import and manage classpaths as for classes in commonlib package ?


问:
C# String Array Contains
Can someone explain to me why the top part of the code works but when test is an array it doesn't?

```<code>string test = "Customer - ";
if (test.Contains("Customer"))
{
    test = "a";
}
</code>```

The code below doesn't work

```<code>string[] test = { "Customer - " };
if (test.Contains("Customer"))
{
    test[0] = "a";
}
</code>```

答:
First snippet searches for string Customer inside another string Customer - which works but in second snippet string Customer is searched inside array of strings one of which is Customer -. Hence the second returns false.

This is evident from how you declare test

```<code>string test = "Customer - ";
</code>```

OR

```<code>string[] test = { "Customer - " };
</code>```

Notice the curly brackets. That's how you define a collection (array here)

To make second snippet work you should do

```<code>string[] test = { "Customer - " };
if (test.Any(x => x.Contains("Customer")))
{
    test[1] = "a";
}
</code>```

Title: C# String Array Contains

Body:
Can someone explain to me why the top part of the code works but when test is an array it doesn't?

string test = "Customer - ";
if (test.Contains("Customer"))
{
    test = "a";
}

The code below doesn't work

string[] test = { "Customer - " };
if (test.Contains("Customer"))
{
    test[0] = "a";
}

Body:
First snippet searches for string Customer inside another string Customer - which works but in second snippet string Customer is searched inside array of strings one of which is Customer -. Hence the second returns false.

This is evident from how you declare test

string test = "Customer - ";

OR

string[] test = { "Customer - " };

Notice the curly brackets. That's how you define a collection (array here)

To make second snippet work you should do

string[] test = { "Customer - " };
if (test.Any(x => x.Contains("Customer")))
{
    test[1] = "a";
}


问:
How can I iterate through object?
I've following object

```<code>Object {
   14533:Object,
   14598:Object,
   43281:Object,
   275047:Object,
   553883:Object,
   602381:Object,
   602639:Object,
   848489:Object,
   16891417:Object,
   26457880:Object
}
</code>```

where

```<code>14533 {
   pageid:14533,
   ns:0,
   title:"India",
   index:1,
   extract:"India, officially the Republic of I…"
}
</code>```

I want to iterate through each of these 10 objects and extract pageid, title, extract

答:
This question is a replica of Iterate through object properties

Do some searching before asking questions or you will be down voted.

UPDATE:

As you will find in the link the key ingredient to solve your question is:

```<code>for(var key in obj){
    if (obj.hasOwnProperty(key)) {
        // your code
    }
}
</code>```

The full solution would look something like this:

```<code>for(var key in obj){
    if (obj.hasOwnProperty(key)) {
        var thisObj = obj[key];
        var thisPageId = thisObj.pageid;
        var thisTitle = thisObj.title;
        var thisExtract = thisObj.extract;

        // console test
        console.log(key, thisPageId, thisTitle, thisExtract);
    }
}
</code>```

Title: How can I iterate through object?

Body:
I've following object

Object {
   14533:Object,
   14598:Object,
   43281:Object,
   275047:Object,
   553883:Object,
   602381:Object,
   602639:Object,
   848489:Object,
   16891417:Object,
   26457880:Object
}

where

14533 {
   pageid:14533,
   ns:0,
   title:"India",
   index:1,
   extract:"India, officially the Republic of I…"
}

I want to iterate through each of these 10 objects and extract pageid, title, extract

Body:
This question is a replica of Iterate through object properties

Do some searching before asking questions or you will be down voted.

UPDATE:

As you will find in the link the key ingredient to solve your question is:

for(var key in obj){
    if (obj.hasOwnProperty(key)) {
        // your code
    }
}

The full solution would look something like this:

for(var key in obj){
    if (obj.hasOwnProperty(key)) {
        var thisObj = obj[key];
        var thisPageId = thisObj.pageid;
        var thisTitle = thisObj.title;
        var thisExtract = thisObj.extract;

        // console test
        console.log(key, thisPageId, thisTitle, thisExtract);
    }
}


问:
type of object while implementing interface
Below is my code...

Its not that much complex.

Here I want to understand that In class D, b is an interface type variable and in that variable we are storing reference to new object of class(C) which implements that interface(B). How we are able to assign object of type C to interface B type variable b..? Class and Interface both are of different types then what makes it special when we implements a interface on class and we are able to do it which is my question

```<code>public interface A {

}

public interface B {

    public A methodABCD();
}

public class C implements B {

    final A typeA;

    public A methodABCD() {
        return typeA;
    }
}

public class D {
  static private B b;

  static public A methodABCD() {
    if (b == null) {
        b = new C();-------------->How..?
    }
    return b.methodABCD();
  }
}
</code>```

答:
This is valid

```<code>B b = new C();
</code>```

only because C implements the interface B, so you are telling the compiler:

"I need an object B that can do something instead of that is something...", this approach is called programming to interfaces and allows you to latter change the class C for a class F as long as F can do something too, that is a more flexible design...

Body:
Below is my code...

Its not that much complex.

Here I want to understand that In class D, b is an interface type variable and in that variable we are storing reference to new object of class(C) which implements that interface(B). How we are able to assign object of type C to interface B type variable b..? Class and Interface both are of different types then what makes it special when we implements a interface on class and we are able to do it which is my question

public interface A {

}

public interface B {

    public A methodABCD();
}

public class C implements B {

    final A typeA;

    public A methodABCD() {
        return typeA;
    }
}

public class D {
  static private B b;

  static public A methodABCD() {
    if (b == null) {
        b = new C();-------------->How..?
    }
    return b.methodABCD();
  }
}

Body:
This is valid

B b = new C();

only because C implements the interface B, so you are telling the compiler:

"I need an object B that can do something instead of that is something...", this approach is called programming to interfaces and allows you to latter change the class C for a class F as long as F can do something too, that is a more flexible design...


问:
click event in jQuery and right mouse clicking
Does click trigger when right mouse button was clicked? I want to implement a right click kind of menu with full calendar, but it only has dayClick event, which I think is triggered only when left mouse button is clicked. I was thinking something like

```<code>dayClick: function(date, allDay, jsEvent){
    if (jsEvent.button === 1){
         //show menu
    }else{
        //do something with day
    }
}
</code>```

but dayClick isn't triggered when right mouse is clicked....Any other ideas?

答:
Here is the my solution for handling right click event of full calendar.Edit dayMousedown function as follows on fullcalendar.js

```<code>dayMousedown: function(ev) {
        var view = this.view;

        // HACK
        // This will still work even though bindDayHandler doesn't use GlobalEmitter.
        if (GlobalEmitter.get().shouldIgnoreMouse()) {
            return;
        }
        switch (ev.which) {
            case 1:
                this.dayClickListener.startInteraction(ev);
                break;
            case 2:
                alert('Middle Mouse button pressed.');
                break;
            case 3:
                // here we can handle right click functionality
                this.dayRightClickListener.startInteraction(ev);

                break;
            default:
                alert('You have a strange Mouse!');
        }

        if (view.opt('selectable')) {
            this.daySelectListener.startInteraction(ev, {
                distance: view.opt('selectMinDistance')
            });
        }
    }
</code>```

And I implemented dayRightClickListener function to handle my requirement.

Body:
Does click trigger when right mouse button was clicked? I want to implement a right click kind of menu with full calendar, but it only has dayClick event, which I think is triggered only when left mouse button is clicked. I was thinking something like

dayClick: function(date, allDay, jsEvent){
    if (jsEvent.button === 1){
         //show menu
    }else{
        //do something with day
    }
}

but dayClick isn't triggered when right mouse is clicked....Any other ideas?

Body:
Here is the my solution for handling right click event of full calendar.Edit dayMousedown function as follows on fullcalendar.js

dayMousedown: function(ev) {
        var view = this.view;

        // HACK
        // This will still work even though bindDayHandler doesn't use GlobalEmitter.
        if (GlobalEmitter.get().shouldIgnoreMouse()) {
            return;
        }
        switch (ev.which) {
            case 1:
                this.dayClickListener.startInteraction(ev);
                break;
            case 2:
                alert('Middle Mouse button pressed.');
                break;
            case 3:
                // here we can handle right click functionality
                this.dayRightClickListener.startInteraction(ev);

                break;
            default:
                alert('You have a strange Mouse!');
        }

        if (view.opt('selectable')) {
            this.daySelectListener.startInteraction(ev, {
                distance: view.opt('selectMinDistance')
            });
        }
    }

And I implemented dayRightClickListener function to handle my requirement.


问:
Incorrect ruby version when installing bundle in rails project
I have a problem when running bundle install in the root of sharetribe rails's project. It shows me this error message:

Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1

I tried installing rvm and installing the 2.3.1 version required to run this project but nothing changes and it still throwing this output.

Have anyone faced this problem before ?

答:
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1

If you run command ruby -v you can see that you have installed Ruby 2.4.0, when you look at the first line in your Gemfile specifies that you want to use Ruby 2.3.1.

You can do either install Ruby 2.3.1 or replace the first line in your Gemfile to with Ruby 2.4.0.


问:
Mailchimp - Delete a list via api
Is there a way to delete a list using MailChimp api? currently I am using listUnsubscribe but I want to completely remove the list.

答:
MailChimp API v3 supports deleting a list.
You can delete the MailChimp list by sending a DELETE request to the lists/{list_id}/ endpoint.

An example request,

```<code>curl --request DELETE \
--url 'https://usX.api.mailchimp.com/3.0/lists/4ca5becb8d' \
--user 'anystring:apikey' \
--include
</code>```

Please note that by deleting a list, you’ll lose the list history—including subscriber activity, unsubscribes, complaints, and bounces. You’ll also lose subscribers’ email addresses unless you exported and backed up your list.

Title: Mailchimp - Delete a list via api

Body:
MailChimp API v3 supports deleting a list.
You can delete the MailChimp list by sending a DELETE request to the lists/{list_id}/ endpoint.

An example request,

curl --request DELETE \
--url 'https://usX.api.mailchimp.com/3.0/lists/4ca5becb8d' \
--user 'anystring:apikey' \
--include

Please note that by deleting a list, you’ll lose the list history—including subscriber activity, unsubscribes, complaints, and bounces. You’ll also lose subscribers’ email addresses unless you exported and backed up your list.


问:
Why some UWP projects has project.json some doesnt has?
I can see that some UWP projects has project.json file and all the NuGet packages entries are included in the project.json. But some UWP projects doesnt has project.json. NuGet packages entries are included in .csproj file itself. Why?</p>

答:
In earlier stages of developing .NET Core tooling project.json (developed by ASP.NET Core team) was seen as a better way to manage NuGet packages, but later decision was made to move back to .csproj for various reasons. So now UWP is storing references to packages in .csproj since it's using .NET Core as well. You can read more here and here.

EDIT:

If I understand correctly, managing packages in .csproj requires Visual Studio 2017, and VS 2015 only understands project.json. That is why, by default, if you create UWP project in VS 2017 it will add project.json to be backwards compatible with VS 2015 (unless you target Creators Update which isn't supported by 2015 anyway).

However, even if you create a project without project.json in VS 2017 and lower its TargetPlatformVersion, it will still work, but only in VS 2017. So to decide to use project.json or not, you should simply decide whether you want to support VS 2015 or not.

This discussion might clear it more.


问:
Adding Text under each image in image gallery
I tried using p tag with max-width attribute but in doesn't worked for me:

```<code>.a {
     max-width:100px;
}
</code>```

With HTML:

```<code><p class="a">Hello Welcome to Stackoverflow.</p>
</code>```

I want this text to be fit under image of resolution 500*500. If the text goes more than image width it should be automatically wrapped in next line.

答:
You can try this.
It works fine for me.

.resized_anchor {
  max-width: 100px;
 }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<title>question reality.</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
 <div>
  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSpMXZY5KMRLpo8vbVxizv5SiRdX2AXeM1lkT-7dXTL2D5el7UHZ59GHWc" height="100px" width="100px" />
  <div class="resized_anchor">
   Hello Welcome to Stackoverflow. Doing a greate job here
  </div>
 </div>
</body>
</html></code>```

Body:
I tried using p tag with max-width attribute but in doesn't worked for me:

.a {
     max-width:100px;
}

With HTML:

Hello Welcome to Stackoverflow.

I want this text to be fit under image of resolution 500*500. If the text goes more than image width it should be automatically wrapped in next line.

Body:
You can try this.
It works fine for me.

.resized_anchor {
  max-width: 100px;
 }

<!DOCTYPE html>
<html>
<head>
<title>question reality.</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
 <div>
  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSpMXZY5KMRLpo8vbVxizv5SiRdX2AXeM1lkT-7dXTL2D5el7UHZ59GHWc" height="100px" width="100px" />
  <div class="resized_anchor">
   <a href="#">Hello Welcome to Stackoverflow. Doing a greate job here</a>
  </div>
 </div>
</body>
</html>


问:
simple_form no input found for json
Environment
Mac OS X
Rails 4.0.4
Ruby 2.1.1

Gems:
simple_form

Create a model with a json typed field, here my migration file:

```<code>create_table :my_model do |t|
  t.string :name
  t.json :my_field

  t.timestamps
end
</code>```

And now when I try to create a New object (New form), I am getting this error

```<code>RuntimeError - No input found for json:
  simple_form (3.0.2) lib/simple_form/form_builder.rb:551:in `find_mapping'
  simple_form (3.0.2) lib/simple_form/form_builder.rb:482:in `find_input'
  simple_form (3.0.2) lib/simple_form/form_builder.rb:111:in `input'
</code>```

I am guessing that simple_form is not handling the JSON type very well, and I really don't know how to work around this one (newbie with simple_form).

Hope you can help

答:
You can also put following line in the initializer to define custom input mappings.</p>

```<code>SimpleForm::FormBuilder.map_type :json, to: SimpleForm::Inputs::TextInput
</code>```

Title: simple_form no input found for json

Body:
Environment
Mac OS X
Rails 4.0.4
Ruby 2.1.1

Gems:
simple_form

Create a model with a json typed field, here my migration file:

create_table :my_model do |t|
  t.string :name
  t.json :my_field

  t.timestamps
end

And now when I try to create a New object (New form), I am getting this error

RuntimeError - No input found for json:
  simple_form (3.0.2) lib/simple_form/form_builder.rb:551:in `find_mapping'
  simple_form (3.0.2) lib/simple_form/form_builder.rb:482:in `find_input'
  simple_form (3.0.2) lib/simple_form/form_builder.rb:111:in `input'

I am guessing that simple_form is not handling the JSON type very well, and I really don't know how to work around this one (newbie with simple_form).

Hope you can help

Body:
You can also put following line in the initializer to define custom input mappings.

SimpleForm::FormBuilder.map_type :json, to: SimpleForm::Inputs::TextInput


问:
Apache had been compromised or being used as a proxy to attack and other system
I received a messages from Sony Interactive Entertainment LLC ("SIE") says my server is abusive to their services.

I checked and make sure:

No one get remote access to my server except me. SSH and all other service only accept my IP, all other are being blocked by firewall

Apache (httpd) not be hacked, no PHP and any active script is running on my server.

All log (system, secure, message, ...) are empty or don't have any strange

Except apache access log I found:

```<code>77.38.177.177 - - [30/Jun/2017:19:21:48 +0000] "CONNECT auth.api.sonyentertainmentnetwork.com:443 HTTP/1.1" 400 226 "-" "-"
138.201.29.228 - - [30/Jun/2017:19:21:48 +0000] "CONNECT www.stoiximan.gr:443 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1409.70 Safari/537.36"
94.122.39.35 - - [30/Jun/2017:19:21:49 +0000] "A" 400 226 "-" "-"
77.108.80.2 - - [30/Jun/2017:19:20:48 +0000] "CONNECT artiwell.com:443 HTTP/1.1" 200 - "-" "-"
138.201.19.161 - - [30/Jun/2017:19:21:48 +0000] "CONNECT www.bet-at-home.com:443 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/17.0.1232.63 Safari/537.36"
77.108.80.2 - - [30/Jun/2017:19:21:48 +0000] "GET http://sea-tools.com.ua/oborudovanie/betonomeshalki/filter/287-k-werk HTTP/1.1" 200 25537 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36"
94.158.152.58 - - [30/Jun/2017:19:21:49 +0000] "A" 400 226 "-" "-"
138.201.19.161 - - [30/Jun/2017:19:21:48 +0000] "GET http://sports.titanbet.com/en/e/5260805/Ansan-Police-v-Ansan-Greeners?mkt_grp_code=TMWIN HTTP/1.1" 200 25023 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.604.118 Safari/537.36"
117.1.114.50 - - [30/Jun/2017:19:21:49 +0000] "GET http://static.doubleclick.net/instream/ad_status.js HTTP/1.1" 200 29 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
94.158.152.58 - - [30/Jun/2017:19:21:49 +0000] "CONNECT static.doubleclick.net:443 HTTP/1.0" 200 - "-" "-"
185.71.186.147 - - [30/Jun/2017:19:21:49 +0000] "CONNECT static.sportsinteraction.net:443 HTTP/1.1" 200 - "-" "-"
</code>```

I have to set firewall to reject every HTTP request to external server to terminate that attack.

By I still have some unanswerable questions are:

Why some one can use my apache connect to external server?

How can they do that? How to stop this issue without use firewall to block every thing?

Below are my apache virtual host configuration:

```<code>NameVirtualHost *:80

<Directory "/data/websource">
    DirectoryIndex index.html index.php
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>
<VirtualHost *:80>
    ServerName subdomain1.my.domain
    DocumentRoot "web_root/subdomain1/source/www"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain1-error.log"
    CustomLog "logs/subdomain1-access.log" combined

    #turn on proxy

    ProxyPreserveHost On
    ProxyRequests On

    ProxyPass /classroom1 http://xyz.my.other.ip/classroom1
    ProxyPassReverse /classroom1 http://xyz.my.other.ip/classroom1

    ProxyPass /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/
    ProxyPassReverse /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/

    ProxyPass /client/ http://xyz.my.other.ip/client/
    ProxyPassReverse /client/ http://xyz.my.other.ip/client/

    ProxyPass /bbb http://xyz.my.other.ip/
    ProxyPassReverse /bbb http://xyz.my.other.ip/

    ProxyPass /demo/ http://xyz.my.other.ip/demo/
    ProxyPassReverse /demo/ http://xyz.my.other.ip/demo/

    ProxyPass /streams.xml http://xyz.my.other.ip/streams.xml
    ProxyPassReverse /streams.html http://xyz.my.other.ip/streams.html

    ProxyPass /testjava.html http://xyz.my.other.ip/testjava.html
    ProxyPassReverse /testjava.html http://xyz.my.other.ip/testjava.html

    ProxyPass /myngleapi/ http://xyz.my.other.ip/myngleapi/
    ProxyPassReverse /myngleapi/ http://xyz.my.other.ip/myngleapi/

    ProxyPass /myngleapi http://xyz.my.other.ip/myngleapi
    ProxyPassReverse /myngleapi http://xyz.my.other.ip/myngleapi

    ProxyPass /help.html http://xyz.my.other.ip/help.html
    ProxyPassReverse /help.html http://xyz.my.other.ip/help.html

    ProxyPass /call.php http://www.source/mynglevline/call.php
    ProxyPassReverse /call.php http://www.source/mynglevline/call.php

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain2.my.domain
    DocumentRoot "web_root/subdomain1/source/admin"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain1-admin-error.log"
    CustomLog "logs/subdomain1-admin-access.log" combined

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain3.my.domain
    DocumentRoot "web_root/subdomain3/source/www"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain3-error.log"
    CustomLog "logs/subdomain3-access.log" combined

    #turn on proxy

    ProxyPreserveHost On
    ProxyRequests On

    ProxyPass /classroom1 http://xyz.my.other.ip/classroom1
    ProxyPassReverse /classroom1 http://xyz.my.other.ip/classroom1

    ProxyPass /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/
    ProxyPassReverse /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/

    ProxyPass /client/ http://xyz.my.other.ip/client/
    ProxyPassReverse /client/ http://xyz.my.other.ip/client/

    ProxyPass /bbb http://xyz.my.other.ip/
    ProxyPassReverse /bbb http://xyz.my.other.ip/

    ProxyPass /demo/ http://xyz.my.other.ip/demo/
    ProxyPassReverse /demo/ http://xyz.my.other.ip/demo/

    ProxyPass /streams.xml http://xyz.my.other.ip/streams.xml
    ProxyPassReverse /streams.html http://xyz.my.other.ip/streams.html

    ProxyPass /testjava.html http://xyz.my.other.ip/testjava.html
    ProxyPassReverse /testjava.html http://xyz.my.other.ip/testjava.html

    ProxyPass /myngleapi/ http://xyz.my.other.ip/myngleapi/
    ProxyPassReverse /myngleapi/ http://xyz.my.other.ip/myngleapi/

    ProxyPass /myngleapi http://xyz.my.other.ip/myngleapi
    ProxyPassReverse /myngleapi http://xyz.my.other.ip/myngleapi

    ProxyPass /help.html http://xyz.my.other.ip/help.html
    ProxyPassReverse /help.html http://xyz.my.other.ip/help.html

    ProxyPass /call.php http://www.source/mynglevline/call.php
    ProxyPassReverse /call.php http://www.source/mynglevline/call.php

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain4.my.domain
    DocumentRoot "web_root/subdomain3/source/admin"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain3-admin-error.log"
    CustomLog "logs/subdomain3-admin-access.log" combined

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain5.my.domain
    DocumentRoot "web_root/subdomain5/source/www"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/release-error.log"
    CustomLog "logs/release-access.log" combined

    #turn on proxy

    ProxyPreserveHost On
    ProxyRequests On

    ProxyPass /classroom1 http://xyz.my.other.ip/classroom1
    ProxyPassReverse /classroom1 http://xyz.my.other.ip/classroom1

    ProxyPass /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/
    ProxyPassReverse /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/

    ProxyPass /client/ http://xyz.my.other.ip/client/
    ProxyPassReverse /client/ http://xyz.my.other.ip/client/

    ProxyPass /bbb http://xyz.my.other.ip/
    ProxyPassReverse /bbb http://xyz.my.other.ip/

    ProxyPass /demo/ http://xyz.my.other.ip/demo/
    ProxyPassReverse /demo/ http://xyz.my.other.ip/demo/

    ProxyPass /streams.xml http://xyz.my.other.ip/streams.xml
    ProxyPassReverse /streams.html http://xyz.my.other.ip/streams.html

    ProxyPass /testjava.html http://xyz.my.other.ip/testjava.html
    ProxyPassReverse /testjava.html http://xyz.my.other.ip/testjava.html

    ProxyPass /myngleapi/ http://xyz.my.other.ip/myngleapi/
    ProxyPassReverse /myngleapi/ http://xyz.my.other.ip/myngleapi/

    ProxyPass /myngleapi http://xyz.my.other.ip/myngleapi
    ProxyPassReverse /myngleapi http://xyz.my.other.ip/myngleapi

    ProxyPass /help.html http://xyz.my.other.ip/help.html
    ProxyPassReverse /help.html http://xyz.my.other.ip/help.html

    ProxyPass /call.php http://www.source/mynglevline/call.php
    ProxyPassReverse /call.php http://www.source/mynglevline/call.php

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain6.my.domain
    DocumentRoot "web_root/subdomain5/source/admin"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain5-admin-error.log"
    CustomLog "logs/subdomain5-admin-access.log" combined

</VirtualHost>
</code>```

答:
ProxyRequests On

This is your problem, quote from  Apache's mod_proxy document:

Warning

Do not enable proxying with ProxyRequests until you have secured your server. Open proxy servers are dangerous both to your network and to the Internet at large.

Body:
I received a messages from Sony Interactive Entertainment LLC ("SIE") says my server is abusive to their services.

I checked and make sure:

No one get remote access to my server except me. SSH and all other service only accept my IP, all other are being blocked by firewall

Apache (httpd) not be hacked, no PHP and any active script is running on my server.

All log (system, secure, message, ...) are empty or don't have any strange

Except apache access log I found:

77.38.177.177 - - [30/Jun/2017:19:21:48 +0000] "CONNECT auth.api.sonyentertainmentnetwork.com:443 HTTP/1.1" 400 226 "-" "-"
138.201.29.228 - - [30/Jun/2017:19:21:48 +0000] "CONNECT www.stoiximan.gr:443 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1409.70 Safari/537.36"
94.122.39.35 - - [30/Jun/2017:19:21:49 +0000] "A" 400 226 "-" "-"
77.108.80.2 - - [30/Jun/2017:19:20:48 +0000] "CONNECT artiwell.com:443 HTTP/1.1" 200 - "-" "-"
138.201.19.161 - - [30/Jun/2017:19:21:48 +0000] "CONNECT www.bet-at-home.com:443 HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/17.0.1232.63 Safari/537.36"
77.108.80.2 - - [30/Jun/2017:19:21:48 +0000] "GET http://sea-tools.com.ua/oborudovanie/betonomeshalki/filter/287-k-werk HTTP/1.1" 200 25537 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36"
94.158.152.58 - - [30/Jun/2017:19:21:49 +0000] "A" 400 226 "-" "-"
138.201.19.161 - - [30/Jun/2017:19:21:48 +0000] "GET http://sports.titanbet.com/en/e/5260805/Ansan-Police-v-Ansan-Greeners?mkt_grp_code=TMWIN HTTP/1.1" 200 25023 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.604.118 Safari/537.36"
117.1.114.50 - - [30/Jun/2017:19:21:49 +0000] "GET http://static.doubleclick.net/instream/ad_status.js HTTP/1.1" 200 29 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
94.158.152.58 - - [30/Jun/2017:19:21:49 +0000] "CONNECT static.doubleclick.net:443 HTTP/1.0" 200 - "-" "-"
185.71.186.147 - - [30/Jun/2017:19:21:49 +0000] "CONNECT static.sportsinteraction.net:443 HTTP/1.1" 200 - "-" "-"

I have to set firewall to reject every HTTP request to external server to terminate that attack.

By I still have some unanswerable questions are:

Why some one can use my apache connect to external server?

How can they do that? How to stop this issue without use firewall to block every thing?

Below are my apache virtual host configuration:

NameVirtualHost *:80

<Directory "/data/websource">
    DirectoryIndex index.html index.php
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>
<VirtualHost *:80>
    ServerName subdomain1.my.domain
    DocumentRoot "web_root/subdomain1/source/www"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain1-error.log"
    CustomLog "logs/subdomain1-access.log" combined

    #turn on proxy

    ProxyPreserveHost On
    ProxyRequests On

    ProxyPass /classroom1 http://xyz.my.other.ip/classroom1
    ProxyPassReverse /classroom1 http://xyz.my.other.ip/classroom1

    ProxyPass /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/
    ProxyPassReverse /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/

    ProxyPass /client/ http://xyz.my.other.ip/client/
    ProxyPassReverse /client/ http://xyz.my.other.ip/client/

    ProxyPass /bbb http://xyz.my.other.ip/
    ProxyPassReverse /bbb http://xyz.my.other.ip/

    ProxyPass /demo/ http://xyz.my.other.ip/demo/
    ProxyPassReverse /demo/ http://xyz.my.other.ip/demo/

    ProxyPass /streams.xml http://xyz.my.other.ip/streams.xml
    ProxyPassReverse /streams.html http://xyz.my.other.ip/streams.html

    ProxyPass /testjava.html http://xyz.my.other.ip/testjava.html
    ProxyPassReverse /testjava.html http://xyz.my.other.ip/testjava.html

    ProxyPass /myngleapi/ http://xyz.my.other.ip/myngleapi/
    ProxyPassReverse /myngleapi/ http://xyz.my.other.ip/myngleapi/

    ProxyPass /myngleapi http://xyz.my.other.ip/myngleapi
    ProxyPassReverse /myngleapi http://xyz.my.other.ip/myngleapi

    ProxyPass /help.html http://xyz.my.other.ip/help.html
    ProxyPassReverse /help.html http://xyz.my.other.ip/help.html

    ProxyPass /call.php http://www.source/mynglevline/call.php
    ProxyPassReverse /call.php http://www.source/mynglevline/call.php

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain2.my.domain
    DocumentRoot "web_root/subdomain1/source/admin"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain1-admin-error.log"
    CustomLog "logs/subdomain1-admin-access.log" combined

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain3.my.domain
    DocumentRoot "web_root/subdomain3/source/www"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain3-error.log"
    CustomLog "logs/subdomain3-access.log" combined

    #turn on proxy

    ProxyPreserveHost On
    ProxyRequests On

    ProxyPass /classroom1 http://xyz.my.other.ip/classroom1
    ProxyPassReverse /classroom1 http://xyz.my.other.ip/classroom1

    ProxyPass /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/
    ProxyPassReverse /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/

    ProxyPass /client/ http://xyz.my.other.ip/client/
    ProxyPassReverse /client/ http://xyz.my.other.ip/client/

    ProxyPass /bbb http://xyz.my.other.ip/
    ProxyPassReverse /bbb http://xyz.my.other.ip/

    ProxyPass /demo/ http://xyz.my.other.ip/demo/
    ProxyPassReverse /demo/ http://xyz.my.other.ip/demo/

    ProxyPass /streams.xml http://xyz.my.other.ip/streams.xml
    ProxyPassReverse /streams.html http://xyz.my.other.ip/streams.html

    ProxyPass /testjava.html http://xyz.my.other.ip/testjava.html
    ProxyPassReverse /testjava.html http://xyz.my.other.ip/testjava.html

    ProxyPass /myngleapi/ http://xyz.my.other.ip/myngleapi/
    ProxyPassReverse /myngleapi/ http://xyz.my.other.ip/myngleapi/

    ProxyPass /myngleapi http://xyz.my.other.ip/myngleapi
    ProxyPassReverse /myngleapi http://xyz.my.other.ip/myngleapi

    ProxyPass /help.html http://xyz.my.other.ip/help.html
    ProxyPassReverse /help.html http://xyz.my.other.ip/help.html

    ProxyPass /call.php http://www.source/mynglevline/call.php
    ProxyPassReverse /call.php http://www.source/mynglevline/call.php

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain4.my.domain
    DocumentRoot "web_root/subdomain3/source/admin"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain3-admin-error.log"
    CustomLog "logs/subdomain3-admin-access.log" combined

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain5.my.domain
    DocumentRoot "web_root/subdomain5/source/www"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/release-error.log"
    CustomLog "logs/release-access.log" combined

    #turn on proxy

    ProxyPreserveHost On
    ProxyRequests On

    ProxyPass /classroom1 http://xyz.my.other.ip/classroom1
    ProxyPassReverse /classroom1 http://xyz.my.other.ip/classroom1

    ProxyPass /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/
    ProxyPassReverse /bigbluebutton/ http://xyz.my.other.ip/bigbluebutton/

    ProxyPass /client/ http://xyz.my.other.ip/client/
    ProxyPassReverse /client/ http://xyz.my.other.ip/client/

    ProxyPass /bbb http://xyz.my.other.ip/
    ProxyPassReverse /bbb http://xyz.my.other.ip/

    ProxyPass /demo/ http://xyz.my.other.ip/demo/
    ProxyPassReverse /demo/ http://xyz.my.other.ip/demo/

    ProxyPass /streams.xml http://xyz.my.other.ip/streams.xml
    ProxyPassReverse /streams.html http://xyz.my.other.ip/streams.html

    ProxyPass /testjava.html http://xyz.my.other.ip/testjava.html
    ProxyPassReverse /testjava.html http://xyz.my.other.ip/testjava.html

    ProxyPass /myngleapi/ http://xyz.my.other.ip/myngleapi/
    ProxyPassReverse /myngleapi/ http://xyz.my.other.ip/myngleapi/

    ProxyPass /myngleapi http://xyz.my.other.ip/myngleapi
    ProxyPassReverse /myngleapi http://xyz.my.other.ip/myngleapi

    ProxyPass /help.html http://xyz.my.other.ip/help.html
    ProxyPassReverse /help.html http://xyz.my.other.ip/help.html

    ProxyPass /call.php http://www.source/mynglevline/call.php
    ProxyPassReverse /call.php http://www.source/mynglevline/call.php

</VirtualHost>
<VirtualHost *:80>
    ServerName subdomain6.my.domain
    DocumentRoot "web_root/subdomain5/source/admin"
    ServerAdmin postmaster@dummy-host2.localhost
    ErrorLog "logs/subdomain5-admin-error.log"
    CustomLog "logs/subdomain5-admin-access.log" combined

</VirtualHost>


答:
Because in second case your if condition is false as you are searching for first string in array of strings. Either you can use any keyword to search for any string in array that match customer or you can search test[0] to search first string in array if it matches to customer like:</p>

```<code>if (test[0].Contains("Customer"))
    {
        //your rest of the code here
    }

 if (test.Any(x => x.Contains("Customer")))
    {
        //your rest of the code here
    }
</code>```

Title: C# String Array Contains

Body:
Because in second case your if condition is false as you are searching for first string in array of strings. Either you can use any keyword to search for any string in array that match customer or you can search test[0] to search first string in array if it matches to customer like:

if (test[0].Contains("Customer"))
    {
        //your rest of the code here
    }

 if (test.Any(x => x.Contains("Customer")))
    {
        //your rest of the code here
    }


问:
AngularJS checkbox avoid counting when uncheck checkBox
Here is my running code in Plunker

I got a bug: When I uncheck the answer, I do not want to count how many times we select this answer? We will only count the number when we check the answer. For example, I check "Yes", I uncheck "Yes", I check "Yes" again, I will only show "Yes" was selected 2 times, instead of 3 times.

I read some posts about this issue, but cannot make it work by using checked property?

```<code><input type="checkbox" ng-change="answerSelected(ans)" ng-model="checkAnswer">{{ans.answer}}
</code>```

答:
Just add a check like this,

```<code>  if (checkAnswer) {
      ans.count++;
      $scope.answerBoxSelected = true;
  }
</code>```

DEMO

// Code goes here

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
  $scope.questions = [{
      id: 1,
      question: "Do you like Foo?",
      answers: [{
        answer: "Yes",
        count: 0,
        id: 1,
        question_id: 1
      }, {
        answer: "No",
        count: 0,
        id: 2,
        question_id: 1
      }]
    },

    {
      id: 2,
      question: "Do you like Bar?",
      answers: [{
        answer: "Yes",
        count: 0,
        id: 1,
        question_id: 2
      }, {
        answer: "No",
        count: 0,
        id: 2,
        question_id: 2
      }]
    }
  ]

  $scope.question_index = 0;

  $scope.answerSelected = function(checkAnswer,ans) {
    if (checkAnswer) {
      ans.count++;
    }
     $scope.answerBoxSelected = true;
  };

  $scope.nextQuestion = function() {
    $scope.question_index++;
    $scope.answerBoxSelected = false;
  };
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>

<head>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>

<body>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

  <div ng-app="myApp" ng-controller="myCtrl">

    <div class="form-group" ng-if="question_index < questions.length">
      <div ng-repeat="item in questions">
        <div ng-if="question_index == $index">
          <h2>{{item.question}}</h2>
          <div ng-repeat="ans in item.answers">
            <input type="checkbox" ng-change="answerSelected(checkAnswer,ans)" ng-model="checkAnswer">{{ans.answer}}
            <br>
          </div>

          <div ng-if="answerBoxSelected" class="alert alert-warning">
            <h3>Answer Selection Summary</h3>
            <div ng-repeat="ans in item.answers">
              <p>
                "{{ans.answer}}" Has been selected {{ans.count}}
                <span ng-if="ans.count == 0">time</span>
                <span ng-if="ans.count > 0">times</span>
                <p>
            </div>
          </div>

          <button class="btn btn-info btn-lg" ng-if="answerBoxSelected && question_index < questions.length - 1" ng-click="nextQuestion()">Next Question > </button>

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

    <div class="alert alert-success" ng-if="question_index == questions.length - 1 && answerBoxSelected">
      Congratulations! You answered all the questions. Good job!
    </div>
  </div>

  <script src="script.js">

  </script>
</body>

</html></code>```

Body:
Here is my running code in Plunker

I got a bug: When I uncheck the answer, I do not want to count how many times we select this answer? We will only count the number when we check the answer. For example, I check "Yes", I uncheck "Yes", I check "Yes" again, I will only show "Yes" was selected 2 times, instead of 3 times.

I read some posts about this issue, but cannot make it work by using checked property?

<input type="checkbox" ng-change="answerSelected(ans)" ng-model="checkAnswer">{{ans.answer}}

Body:
Just add a check like this,

  if (checkAnswer) {
      ans.count++;
      $scope.answerBoxSelected = true;
  }

DEMO

// Code goes here

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
  $scope.questions = [{
      id: 1,
      question: "Do you like Foo?",
      answers: [{
        answer: "Yes",
        count: 0,
        id: 1,
        question_id: 1
      }, {
        answer: "No",
        count: 0,
        id: 2,
        question_id: 1
      }]
    },

    {
      id: 2,
      question: "Do you like Bar?",
      answers: [{
        answer: "Yes",
        count: 0,
        id: 1,
        question_id: 2
      }, {
        answer: "No",
        count: 0,
        id: 2,
        question_id: 2
      }]
    }
  ]

  $scope.question_index = 0;

  $scope.answerSelected = function(checkAnswer,ans) {
    if (checkAnswer) {
      ans.count++;
    }
     $scope.answerBoxSelected = true;
  };

  $scope.nextQuestion = function() {
    $scope.question_index++;
    $scope.answerBoxSelected = false;
  };
});

<!DOCTYPE html>
<html>

<head>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>

<body>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

  <div ng-app="myApp" ng-controller="myCtrl">

    <div class="form-group" ng-if="question_index < questions.length">
      <div ng-repeat="item in questions">
        <div ng-if="question_index == $index">
          <h2>{{item.question}}</h2>
          <div ng-repeat="ans in item.answers">
            <input type="checkbox" ng-change="answerSelected(checkAnswer,ans)" ng-model="checkAnswer">{{ans.answer}}
            <br>
          </div>

          <div ng-if="answerBoxSelected" class="alert alert-warning">
            <h3>Answer Selection Summary</h3>
            <div ng-repeat="ans in item.answers">
              <p>
                "{{ans.answer}}" Has been selected {{ans.count}}
                <span ng-if="ans.count == 0">time</span>
                <span ng-if="ans.count > 0">times</span>
                <p>
            </div>
          </div>

          <button class="btn btn-info btn-lg" ng-if="answerBoxSelected && question_index < questions.length - 1" ng-click="nextQuestion()">Next Question > </button>

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

    <div class="alert alert-success" ng-if="question_index == questions.length - 1 && answerBoxSelected">
      Congratulations! You answered all the questions. Good job!
    </div>
  </div>

  <script src="script.js">

  </script>
</body>

</html>


问:
How to mark a Grails 3 app as distributable?
I'm using Grails 3.2.3.  Since support for web.xml was discontinued in Grails 3, how do I mark my application as distributable so it can be clustered in Tomcat?</p>

答:
A web application can be configured to be distributed in a cluster. You can see this-

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2009719