问:
Permission Denied - Oracle 12c
Installing Oracle 12c on Ubuntu I got permission denied when I executed the line:

```<code>/tmp/database/runInstaller
</code>```

答:
Check permission of .oui :

chmod 777 -r /tmp/database/

Even Ubuntu is not certified for Oracle Database installation, but it's possible to setup Oracle on this on. Not certified means that Oracle hadn't done tests and don't provide support on this plateform.

Title: Permission Denied - Oracle 12c

Body:
Installing Oracle 12c on Ubuntu I got permission denied when I executed the line:

/tmp/database/runInstaller


来源: stackexchange

问:
Android two-way databinding with custom binding logic
I use android data binding lib and I have a layout with checkboxes and I need to use custom checking logic (layout).

Is there a way to create such a binding that checking one of the boxes causes the rest of them to uncheck? What would be the best approach?

答:
To do such a similar task i did the following:

created an unique ViewModel that is added in the data field of xml

```<code><import type="android.view.View"/>
<variable
    name="viewModel"
    type="compackagename.MyViewModel" />
</code>```

in xml binding notice the @={...} which is called a two way binding (updating the variable from the two way binding automatically updates the xml)

```<code>        <CheckBox
        android:checked="@={viewModel.checked1}"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <CheckBox
        android:checked="@={viewModel.checked2}"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</code>```

added ObservableBoolean fields to each checkBox in MyViewModel

```<code>public final ObservableBoolean checked1 = new ObservableBoolean();
</code>```

in MyViewModel constructor

```<code>checked1.set(false);
checked2.set(false);

checked1.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable observable, int i) {
        if (checked1.get()){
            checked2.set(false);
        }
    }
});
checked2.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable observable, int i) {
        if (checked2.get()){
            checked1.set(false);
        }
    }
});
</code>```

You can optimise this by adding the ObservableBooleans in a list but the above is a good starting point that works.

ContentLicense: CC BY-SA 3.0

Body:
To do such a similar task i did the following:

created an unique ViewModel that is added in the data field of xml

<import type="android.view.View"/>
<variable
    name="viewModel"
    type="compackagename.MyViewModel" />

in xml binding notice the @={...} which is called a two way binding (updating the variable from the two way binding automatically updates the xml)

        <CheckBox
        android:checked="@={viewModel.checked1}"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <CheckBox
        android:checked="@={viewModel.checked2}"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

added ObservableBoolean fields to each checkBox in MyViewModel

public final ObservableBoolean checked1 = new ObservableBoolean();

in MyViewModel constructor

checked1.set(false);
checked2.set(false);

checked1.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable observable, int i) {
        if (checked1.get()){
            checked2.set(false);
        }
    }
});
checked2.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable observable, int i) {
        if (checked2.get()){
            checked1.set(false);
        }
    }
});

You can optimise this by adding the ObservableBooleans in a list but the above is a good starting point that works.


问:
Duck Duck go HTML version get next page of results url query param
Is it possible to get the next page of results for a duck duck go search on the html version using a url query param?</p>

答:
I found that with the right parameters, it is possible to get different pages from the /html/ version of duckduckgo.com.

You need to specify:

q for the search

s for the offset of the current page (nothing for the first page)

dc for the offset of the current page + 1 (start of the new page, nothing for the first page)

v to the arbitrary value l

o to the format json

api to the endpoint /d.js

Which gives, given the search $term and the page $n:

```<code>https://duckduckgo.com/html/?q=$term&s=$(($n*30))&dc=$(($n*30+1))&v=l&o=json&api=/d.js
</code>```

And for the first page:

```<code>https://duckduckgo.com/html/?q=$term&s=&dc=&v=l&o=json&api=/d.js
</code>```

Note 1: This can be used with both GET and POST HTML methods.

Note 2: According to my tests, it appears that the s and dc parameters need to respectively be a multiple of 30, and a multiple of 30, plus 1.

HTH

Body:
I found that with the right parameters, it is possible to get different pages from the /html/ version of duckduckgo.com.

You need to specify:

q for the search

s for the offset of the current page (nothing for the first page)

dc for the offset of the current page + 1 (start of the new page, nothing for the first page)

v to the arbitrary value l

o to the format json

api to the endpoint /d.js

Which gives, given the search $term and the page $n:

https://duckduckgo.com/html/?q=$term&s=$(($n*30))&dc=$(($n*30+1))&v=l&o=json&api=/d.js

And for the first page:

https://duckduckgo.com/html/?q=$term&s=&dc=&v=l&o=json&api=/d.js

Note 1: This can be used with both GET and POST HTML methods.

Note 2: According to my tests, it appears that the s and dc parameters need to respectively be a multiple of 30, and a multiple of 30, plus 1.

HTH


问:
background: fixed no repeat not working on mobile
I am building a webpage where I want the background image to scale to fit the whole screen, maintain aspect ratio and be fixed (so if you scroll down, the background image stays in the same place).

I have achieved this in desktop browsers with the CSS below, but it doesn't work on an iPhone or iPad. On those devices the background is too big (it continues below the fold) and if you scroll down far enough, the image will start repeating.  Anyone have a fix? THanks!

```<code>HTML {
  background: url(photos/2452.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
</code>```

答:
I found maybe best solution for parallax effect which work on all devices.

Main thing is to set all sections with z-index greater than parallax section.

And parallax image element to set fixed with max width and height

body, html { margin: 0px; }
section {
  position: relative; /* Important */
  z-index: 1; /* Important */
  width: 100%;
  height: 100px;
}

section.blue { background-color: blue; }
section.red { background-color: red; }

section.parallax {
  z-index: 0; /* Important */
}

section.parallax .image {
  position: fixed; /* Important */
  top: 0; /* Important */
  left: 0; /* Important */
  width: 100%; /* Important */
  height: 100%; /* Important */
  background-image: url(https://www.w3schools.com/css/img_fjords.jpg);
  background-repeat: no-repeat;
  background-position: center;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><section class="blue"></section>
<section class="parallax">
  <div class="image"></div>
</section>
<section class="red"></section></code>```

Body:
I am building a webpage where I want the background image to scale to fit the whole screen, maintain aspect ratio and be fixed (so if you scroll down, the background image stays in the same place).

I have achieved this in desktop browsers with the CSS below, but it doesn't work on an iPhone or iPad. On those devices the background is too big (it continues below the fold) and if you scroll down far enough, the image will start repeating.  Anyone have a fix? THanks!

HTML {
  background: url(photos/2452.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

Body:
I found maybe best solution for parallax effect which work on all devices.

Main thing is to set all sections with z-index greater than parallax section.

And parallax image element to set fixed with max width and height

body, html { margin: 0px; }
section {
  position: relative; /* Important */
  z-index: 1; /* Important */
  width: 100%;
  height: 100px;
}

section.blue { background-color: blue; }
section.red { background-color: red; }

section.parallax {
  z-index: 0; /* Important */
}

section.parallax .image {
  position: fixed; /* Important */
  top: 0; /* Important */
  left: 0; /* Important */
  width: 100%; /* Important */
  height: 100%; /* Important */
  background-image: url(https://www.w3schools.com/css/img_fjords.jpg);
  background-repeat: no-repeat;
  background-position: center;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

<section class="blue"></section>
<section class="parallax">
  <div class="image"></div>
</section>
<section class="red"></section>


问:
Which hosting provider supports Haskell?
I have a hosting account with GoDaddy, but it does not support Haskell.</p>

答: If you are planning anything serious that is a little non-standard, get a VPS somewhere. It’s ~350$/year and you have a little virtual machine on which your are alone and you are root</p>

ContentLicense: CC BY-SA 2.5


问:
Add friend error in django
I can log in from one user, when i try logging in with other user accounts, i get the following error

```<code>Friend matching query does not exist.
</code>```

below is my views.py. i get an error on the line 7

```<code>class HomeView(TemplateView):
    template_name = 'home/home.html'
    def get(self, request):
        form = HomeForm()
        posts = Post.objects.all().order_by('-created')
        users = User.objects.exclude(id=request.user.id)
        friend = Friend.objects.get(current_user=request.user) ...
        friends = friend.users.all()
        args = {
            'form': form, 'posts': posts, 'users': users, 'friends': friends
        }
    return render(request, self.template_name, args)
</code>```

答:
QuerySet.get() raises exception if it does not find one and only one entry in the database with the given conditions.

You can do:

```<code>try:
    friend = Friend.objects.get(current_user=request.user)
except Friend.DoesNotExist:
    # handle the error here, maybe add the friend?
except Friend. MultipleObjectsReturned:
    # multiple friends
</code>```

or:

```<code>current_user_friends = Friend.objects.filter(current_user=request.user)
if not current_user_friends.exists():
    # handle the error here, maybe add the friend?
else:
    friend = current_user_friends[0]
    # at this point, request.user can have more than one friend
</code>```

given that you are looking for request.user's friends, you can try:

```<code>friends = request.user.friends.all()
</code>```

assuming that your Friend model is something like:

```<code>class Friend(models.Model):
    user = models.ForeignKey(User, ..., related_name='friends')
    ...
</code>```

hope this helps!

Title: Add friend error in django

Body:
I can log in from one user, when i try logging in with other user accounts, i get the following error

Friend matching query does not exist.

below is my views.py. i get an error on the line 7

class HomeView(TemplateView):
    template_name = 'home/home.html'
    def get(self, request):
        form = HomeForm()
        posts = Post.objects.all().order_by('-created')
        users = User.objects.exclude(id=request.user.id)
        friend = Friend.objects.get(current_user=request.user) ...
        friends = friend.users.all()
        args = {
            'form': form, 'posts': posts, 'users': users, 'friends': friends
        }
    return render(request, self.template_name, args)

Body:
QuerySet.get() raises exception if it does not find one and only one entry in the database with the given conditions.

You can do:

try:
    friend = Friend.objects.get(current_user=request.user)
except Friend.DoesNotExist:
    # handle the error here, maybe add the friend?
except Friend. MultipleObjectsReturned:
    # multiple friends

or:

current_user_friends = Friend.objects.filter(current_user=request.user)
if not current_user_friends.exists():
    # handle the error here, maybe add the friend?
else:
    friend = current_user_friends[0]
    # at this point, request.user can have more than one friend

given that you are looking for request.user's friends, you can try:

friends = request.user.friends.all()

assuming that your Friend model is something like:

class Friend(models.Model):
    user = models.ForeignKey(User, ..., related_name='friends')
    ...

hope this helps!


问:
Clear specific timeout
How can I clear this timeout:

```<code>var timeout = setTimeout(function() {
    window.setTimeout(arguments.callee, 1000);
}, 1000)
</code>```

clearTimeout(timeout) don't working..

答:
You need to reassign timeout each time you set new timeout. And get rid of arguments.callee.
Try this working example:

```<code><button onclick="myFunction()">Try it</button>
<button onclick="myStopFunction()">Stop the alert</button>

<script>
var timeout;

function myFunction() {
    timeout = setTimeout(function timerHandler() {
        timeout = setTimeout(timerHandler, 1000);
    }, 1000)
}

function myStopFunction() {
    clearTimeout(timeout);
}
</script>
</code>```

Title: Clear specific timeout

Body:
How can I clear this timeout:

var timeout = setTimeout(function() {
    window.setTimeout(arguments.callee, 1000);
}, 1000)

clearTimeout(timeout) don't working..

Body:
You need to reassign timeout each time you set new timeout. And get rid of arguments.callee.
Try this working example:

<button onclick="myFunction()">Try it</button>
<button onclick="myStopFunction()">Stop the alert</button>

<script>
var timeout;

function myFunction() {
    timeout = setTimeout(function timerHandler() {
        timeout = setTimeout(timerHandler, 1000);
    }, 1000)
}

function myStopFunction() {
    clearTimeout(timeout);
}
</script>


问:
Cannot ping AWS EC2 instance
I have an EC2 instance running in AWS. When I try to ping from my local box it is not available.

How can I make the instance pingable?

答:
terraform specific instructions for a security group because the -1 was not obvious to me.</p>

```<code>resource "aws_security_group" "Ping" {
  vpc_id = "${aws_vpc.MyVPC.id}"
  ingress {
    from_port   = -1
    to_port     = -1
    protocol    = "icmp"
    cidr_blocks = ["0.0.0.0/0"]
    ipv6_cidr_blocks = ["::/0"]
  }
}
</code>```

Title: Cannot ping AWS EC2 instance

Body:
terraform specific instructions for a security group because the -1 was not obvious to me.

resource "aws_security_group" "Ping" {
  vpc_id = "${aws_vpc.MyVPC.id}"
  ingress {
    from_port   = -1
    to_port     = -1
    protocol    = "icmp"
    cidr_blocks = ["0.0.0.0/0"]
    ipv6_cidr_blocks = ["::/0"]
  }
}


问:
PostgreSQL 9.5 Update virtual column in view
I am using PostgreSQL for GIS purposes with PostGIS and QGIS, but I think I might find more informations here than on gis.stackexchange.com since my question is not directly GIS related.

I am using views to diplay datas at will for the specific needs of my users, like that they have access to the datas as they are in the DB, but with just what they need. I added some rules to my views to make them "updatable" in QGIS and make them directly "workable" by the users.

Display in QGIS is based on attributes, but since there is the possibility that different persons will access the same data at the same moment, and they might want to display and hide some of these datas according to their needs (map printing for once). So I am looking for a way to give possibility to have a specific display for each view, and I thought about simply adding a "virtual" column in the view definition, with for example a boolean like such:

```<code>CREATE VIEW view1 AS
SELECT oid, column1, True as display from table1;
</code>```

But I would like my users to be able to change the value of this column, to simply make appear or disappear the objects from the canvas (with a ruled-base styling considering this parameter). And obviously it doesn't work direclty since the update would be in conflict with the definition of the view.

Does anyone have any idea on how to achieve that? Maybe a materialized view (but I quite like the dynamics of the regular view)?

Thanks.

答:
If the unique ID field is read from the table (i.e. it is not dynamically created via the row_number() trick commonly used with spatial views in QGIS), you could create a visibility manager table and use it in the view. You could have one table by view or one for all of them. Something similar to:

```<code>create table visibility_manager (oid bigint, visibility_status boolean, viewname text);

CREATE VIEW view1 AS
SELECT table1.oid, column1, coalesce(visibility_status,true) as display
    from table1
    left outer join visibility_manager
    on (table1.oid = visibility_manager.oid and visibility_manager.viewname = 'view1');
</code>```

see it in action:
http://rextester.com/OZPN1777

Body:
I am using PostgreSQL for GIS purposes with PostGIS and QGIS, but I think I might find more informations here than on gis.stackexchange.com since my question is not directly GIS related.

I am using views to diplay datas at will for the specific needs of my users, like that they have access to the datas as they are in the DB, but with just what they need. I added some rules to my views to make them "updatable" in QGIS and make them directly "workable" by the users.

Display in QGIS is based on attributes, but since there is the possibility that different persons will access the same data at the same moment, and they might want to display and hide some of these datas according to their needs (map printing for once). So I am looking for a way to give possibility to have a specific display for each view, and I thought about simply adding a "virtual" column in the view definition, with for example a boolean like such:

CREATE VIEW view1 AS
SELECT oid, column1, True as display from table1;

But I would like my users to be able to change the value of this column, to simply make appear or disappear the objects from the canvas (with a ruled-base styling considering this parameter). And obviously it doesn't work direclty since the update would be in conflict with the definition of the view.

Does anyone have any idea on how to achieve that? Maybe a materialized view (but I quite like the dynamics of the regular view)?

Thanks.

Body:
If the unique ID field is read from the table (i.e. it is not dynamically created via the row_number() trick commonly used with spatial views in QGIS), you could create a visibility manager table and use it in the view. You could have one table by view or one for all of them. Something similar to:

create table visibility_manager (oid bigint, visibility_status boolean, viewname text);

CREATE VIEW view1 AS
SELECT table1.oid, column1, coalesce(visibility_status,true) as display
    from table1
    left outer join visibility_manager
    on (table1.oid = visibility_manager.oid and visibility_manager.viewname = 'view1');

see it in action:
http://rextester.com/OZPN1777


问:
The lacking parts/functions/components of React Native
By far, what do you think about the parts/functions or components that React Native is lack to be officially released ?
And how did you overcome the issues related to those things ?</p>

答:
You have the power of IOS and Andriod to create your own components. If you have never done it before it can seem a little daunting, but once you get your first basic component out you would see that creating custom components and functionality and importing it to the js side is quite easy. I'm not a fan of Objective C I have never tried swift though it was pretty new when I was working on RN projects, but it gets the job done. One thing you have to be careful about is the lack of callbacks. Data needs to be sent from the bottom up. It's not a big deal though you can make some services to get the data if you need to. It's just an extra layer. Those are the big drawbacks I can think of.

Edit:
@BùiQuangTuấn  They already do that and it only applies purely to the react native framework. That's because react-native works the same way as react. One direction data flow. But when you mix react native and native components you're working outside of the framework. Take a look at this link Bridging in react native and a more indepth answer Here


问:
its it possible to have two ELSEIF clauses in a IF ternary?
can this be made into an IF ternary to shorten the code? I don't know how to do it with multiple elseif clause

```<code>if ($ext == "m") {
 $extype = "mp3";
}elseif ($ext == "w") {
 $extype = "wav";
}elseif ($ext == "a"){
 $extype = "aac";
}
</code>```

the is the full function

```<code>function loc($id,$type,$ext) //loc($id,'n',$ext)
{
  if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
  {
    if (mysql_num_rows($query) > 0)
     if ($ext == "m") {
     $extype = ".mp3";
     }elseif ($ext == "w") {
     $extype = ".wav";
     }elseif ($ext == "a") {
     $extype = ".aac";
     }
      return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);

  }
  return 'Error Not Found';
}
</code>```

答:
You can do it by nesting ternary operators.

Don't do that. It will make your code unreadable and harder to maintain.

There are far better solutions to whatever you're trying to do. For the love of everything that is good in the world, don't you dare write code like this:

($var1 = "a") ? (a) : ((($var2 = "b") ? (b) : ((($var3 = "c") ? (c) : ((($var4 = "d") ? (d) : ((($var5 = "e") ? (e) : ((($var6 = "f") ? (f) : ((($var7 = "g") ? (g) : ((h))))))))))))));

The person who has to maintain this will become a psycopath.

Use a switch, use an array with keys, do anything but this.

Switch:

```<code>function loc($id,$type,$ext) //loc($id,'n',$ext)
{
  if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
  {
    if (mysql_num_rows($query) > 0)
           switch ($ext) {
                case "m" :
                     $exttype = ".mp3"; //Make sure you terminate your statements with the ; mark.
                     break;
                case "w" :
                     $exttype = ".wma";
                     break;
                case "a" :
                     $exttype = ".acc";
                     break;
                default : //All cases that didn't match.
                     $exttype = "";
                     break;
           }
           return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);
  }
  return 'Error Not Found';
}
</code>```

The switch will match for all cases specified and has a default action ones that it didn't match (example: you have a "O" in that variable, then the string becomes a blank value)

Arrays

```<code>function loc($id,$type,$ext) //loc($id,'n',$ext)
{

 $list["m"] = ".mp3";
 $list["w"] = ".wma";
 $list["a"] = ".acc";

  if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
  {
    if (mysql_num_rows($query) > 0)
         $extype = $list[$ext];
         return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);

  }
  return 'Error Not Found';
}
</code>```

This array method consumes a bit more memory because the array gets stored, but by specifying the key to the array and matching it with it's value you get that value out of it. The down side being you need to program around a default for items that are NOT in the array (again, if you have the variable with "O", it's not going to find a matching array key-value pair and come up as an error).

Body:
can this be made into an IF ternary to shorten the code? I don't know how to do it with multiple elseif clause

if ($ext == "m") {
 $extype = "mp3";
}elseif ($ext == "w") {
 $extype = "wav";
}elseif ($ext == "a"){
 $extype = "aac";
}

the is the full function

function loc($id,$type,$ext) //loc($id,'n',$ext)
{
  if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
  {
    if (mysql_num_rows($query) > 0)
     if ($ext == "m") {
     $extype = ".mp3";
     }elseif ($ext == "w") {
     $extype = ".wav";
     }elseif ($ext == "a") {
     $extype = ".aac";
     }
      return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);

  }
  return 'Error Not Found';
}

Body:
You can do it by nesting ternary operators.

Don't do that. It will make your code unreadable and harder to maintain.

There are far better solutions to whatever you're trying to do. For the love of everything that is good in the world, don't you dare write code like this:

($var1 = "a") ? (a) : ((($var2 = "b") ? (b) : ((($var3 = "c") ? (c) : ((($var4 = "d") ? (d) : ((($var5 = "e") ? (e) : ((($var6 = "f") ? (f) : ((($var7 = "g") ? (g) : ((h))))))))))))));

The person who has to maintain this will become a psycopath.

Use a switch, use an array with keys, do anything but this.

Switch:

function loc($id,$type,$ext) //loc($id,'n',$ext)
{
  if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
  {
    if (mysql_num_rows($query) > 0)
           switch ($ext) {
                case "m" :
                     $exttype = ".mp3"; //Make sure you terminate your statements with the ; mark.
                     break;
                case "w" :
                     $exttype = ".wma";
                     break;
                case "a" :
                     $exttype = ".acc";
                     break;
                default : //All cases that didn't match.
                     $exttype = "";
                     break;
           }
           return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);
  }
  return 'Error Not Found';
}

The switch will match for all cases specified and has a default action ones that it didn't match (example: you have a "O" in that variable, then the string becomes a blank value)

Arrays

function loc($id,$type,$ext) //loc($id,'n',$ext)
{

 $list["m"] = ".mp3";
 $list["w"] = ".wma";
 $list["a"] = ".acc";

  if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
  {
    if (mysql_num_rows($query) > 0)
         $extype = $list[$ext];
         return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);

  }
  return 'Error Not Found';
}

This array method consumes a bit more memory because the array gets stored, but by specifying the key to the array and matching it with it's value you get that value out of it. The down side being you need to program around a default for items that are NOT in the array (again, if you have the variable with "O", it's not going to find a matching array key-value pair and come up as an error).


问:
Why does Javax' XPath evaluate() method not return elements with non-breaking space when the selector uses the text() node test
I have the following Java code

```<code>    @Test
    public void notGettingNonBreakingSpace() throws ParserConfigurationException, IOException, SAXException, XPathExpressionException {
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

        String html = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \n" +
            "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" +
            "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
            "<body><table><tr><td> </td></tr></table></body>\n" +
            "</html>";

        Document document = documentBuilder.parse(new ByteArrayInputStream(html.getBytes()));
        XPath xpath = XPathFactory.newInstance().newXPath();
        int result = ((NodeList) xpath.evaluate("//tr/td/text()", document, XPathConstants.NODESET)).getLength();
        assertEquals(1, result);
    }
</code>```

The assertion fails, as result is 0. If I take the HTML, however, save it as an .htm file, and open it in Chrome, $x("//tr/td/text()") in the Developer Tools Console returns as expected:

```<code>[text]
> 0: text
  length: 1
> __proto__: Array(0)
</code>```

What do I need to do to get the same result in Java, i.e. a node list with one item?

Is there an "ignore whitespace" setting on the DocumentBuilder or the XPath object somewhere, or is the root cause that Java and Chrome's JS engine disagree how to handle that special whitespace character?

NB: Removing the text() (i.e. the text node selection) works; it then returns the right result. Replacing the non-breaking space ( ) with actual text (e.g. foo) also works...

答:
It looks like Java is not able to recognize   when the dtd loading is disabled.

Your problem can be solved by writing an entity for   in html like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [ <!ENTITY nbsp " "> ]>

The evaluate now gives one text node.

Body:
I have the following Java code

    @Test
    public void notGettingNonBreakingSpace() throws ParserConfigurationException, IOException, SAXException, XPathExpressionException {
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

        String html = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \n" +
            "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" +
            "\n" +
            "

\n" +
            "";

        Document document = documentBuilder.parse(new ByteArrayInputStream(html.getBytes()));
        XPath xpath = XPathFactory.newInstance().newXPath();
        int result = ((NodeList) xpath.evaluate("//tr/td/text()", document, XPathConstants.NODESET)).getLength();
        assertEquals(1, result);
    }

The assertion fails, as result is 0. If I take the HTML, however, save it as an .htm file, and open it in Chrome, $x("//tr/td/text()") in the Developer Tools Console returns as expected:

[text]
> 0: text
  length: 1
> __proto__: Array(0)

What do I need to do to get the same result in Java, i.e. a node list with one item?

Is there an "ignore whitespace" setting on the DocumentBuilder or the XPath object somewhere, or is the root cause that Java and Chrome's JS engine disagree how to handle that special whitespace character?

NB: Removing the text() (i.e. the text node selection) works; it then returns the right result. Replacing the non-breaking space ( ) with actual text (e.g. foo) also works...

Body:
It looks like Java is not able to recognize &nbsp; when the dtd loading is disabled.

Your problem can be solved by writing an entity for &nbsp; in html like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [ <!ENTITY nbsp "&#160;"> ]>

The evaluate now gives one text node.


问:
Add email recipient to all new Trac tickets
Is there a configuration change that can be made to Trac to send a notification to an email address only upon the creation of all new tickets? If it can't be done through config, a plugin would be the second best option, with source code modification as a last resort.

NOTE: The setting smtp_always_cc in the notification section of TracIni will send messages on all updates. I'm in need of email notifications only on the creation of a new ticket.

答: Does this have to be an email notification?  One option you have is to create a query that will list the ten (or however many) most recently-created tickets.  When looking at the results of the query, use the "RSS Feed" button at the bottom of the page to subscribe to a feed that will notify you whenever the results of that query get updated.</p>


问:
VBA Excel - Auto run macro to insert new blank row after cell above has value entered
I am trying to get a macro to auto run to:

insert a blank row in each section e.g. Architectural when the data validation row above (in column A) has a value entered into it.
I entered the code as a sub in the worksheet, when I click run in the developer tab in excel, it inserts a line once, but I would like it to run automatically (after the workbook is opened) every time something is entered into column A.

```<code>Sub BlankLine()
    'Updateby20150203
    Dim Rng As Range
    Dim WorkRng As Range

    xTitleId = "KutoolsforExcel"
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
    Set WorkRng = WorkRng.Columns(1)

    xLastRow = WorkRng.Rows.count
    Application.ScreenUpdating = False

    For xRowIndex = xLastRow To 1 Step -1
        Set Rng = Range("B" & xRowIndex)
        If Rng.Value = "" = False Then
            Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown
        End If
    Next

    Application.ScreenUpdating = True
End Sub
</code>```

答:
I think I can help you with your first question.

You can automatically start a macro when a cell changes with a Sub Worksheet_Change(ByVal Target As Range) Sub inside the worksheet.

Here is description: https://support.microsoft.com/en-us/help/213612/how-to-run-a-macro-when-certain-cells-change-in-excel

You can insert a new row with the following code:

```<code>Application.Selection.EntireRow.Insert shift:=xlDown
</code>```

When you do just that, you will encounter that the new line will again trigger the event to start the macro, hence again inserting a new line. This leads to an infinity loop. To stop this from happening, we need to disable events for the time of the change.

```<code>Application.EnableEvents = False
Call new_line_below_selection_macro
Application.EnableEvents = True
</code>```

Here is a question with a similar problem: How to end infinite "change" loop in VBA

I hope this helps.

Here is the code which should go into the sheet:

```<code>Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range
    Set KeyCells = Range("A1:C10") 'Area this should apply

    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
           Is Nothing Then

        Application.EnableEvents = False
        'either you put your code here
        'Application.Selection.EntireRow.Insert shift:=xlDown
        'or you call it from a module
        Call Module1.BlankLine
        Application.EnableEvents = True

    End If
End Sub
</code>```

Body:
I am trying to get a macro to auto run to:

insert a blank row in each section e.g. Architectural when the data validation row above (in column A) has a value entered into it.
I entered the code as a sub in the worksheet, when I click run in the developer tab in excel, it inserts a line once, but I would like it to run automatically (after the workbook is opened) every time something is entered into column A.

Sub BlankLine()
    'Updateby20150203
    Dim Rng As Range
    Dim WorkRng As Range

    xTitleId = "KutoolsforExcel"
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
    Set WorkRng = WorkRng.Columns(1)

    xLastRow = WorkRng.Rows.count
    Application.ScreenUpdating = False

    For xRowIndex = xLastRow To 1 Step -1
        Set Rng = Range("B" & xRowIndex)
        If Rng.Value = "" = False Then
            Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown
        End If
    Next

    Application.ScreenUpdating = True
End Sub

Body:
I think I can help you with your first question.

You can automatically start a macro when a cell changes with a Sub Worksheet_Change(ByVal Target As Range) Sub inside the worksheet.

Here is description: https://support.microsoft.com/en-us/help/213612/how-to-run-a-macro-when-certain-cells-change-in-excel

You can insert a new row with the following code:

Application.Selection.EntireRow.Insert shift:=xlDown

When you do just that, you will encounter that the new line will again trigger the event to start the macro, hence again inserting a new line. This leads to an infinity loop. To stop this from happening, we need to disable events for the time of the change.

Application.EnableEvents = False
Call new_line_below_selection_macro
Application.EnableEvents = True

Here is a question with a similar problem: How to end infinite "change" loop in VBA

I hope this helps.

Here is the code which should go into the sheet:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range
    Set KeyCells = Range("A1:C10") 'Area this should apply

    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
           Is Nothing Then

        Application.EnableEvents = False
        'either you put your code here
        'Application.Selection.EntireRow.Insert shift:=xlDown
        'or you call it from a module
        Call Module1.BlankLine
        Application.EnableEvents = True

    End If
End Sub


答:
You're setting timeout to the result of the first call to setTimeout, but not any following calls. You probably want

```<code>var timeout;

timeout = setTimeout(function() {
  timeout = window.setTimeout(arguments.callee, 1000);
}, 10);

clearTimeout(timeout);
</code>```

But this would be better written as

```<code>function iter() {
  timeout = setTimeout(iter, 1000);
}
</code>```

Title: Clear specific timeout

Body:
You're setting timeout to the result of the first call to setTimeout, but not any following calls. You probably want

var timeout;

timeout = setTimeout(function() {
  timeout = window.setTimeout(arguments.callee, 1000);
}, 10);

clearTimeout(timeout);

But this would be better written as

function iter() {
  timeout = setTimeout(iter, 1000);
}


问:
How do I put a min and max value in an input text for a custom date
I would like to know how I can add a min value and a max value in my input text for a date.
The format that I would like to have is : dd/mm/yyyy

So I've put a maxlenght to my input and I have added automatically "/" after the user type 2 numbers.

When I test it, everything is fine but I still can write "67/34/8888" and not a correct date for example.

Here's my code :

```<code><form method="post" action="#" id="formStep2">
<input type="text" id="txtDate" class="selector" placeholder="dd/mm/yyyy" maxlength="10" required />
</form>

<script>
$(document).ready(function() {
    $("#txtDate").keyup(function(){
        if ($(this).val().length == 2){
            $(this).val($(this).val() + "/");
        }else if ($(this).val().length == 5){
            $(this).val($(this).val() + "/");
        }
    });
});
</script>
</code>```

Is it possible to add something like :

```<code> if ($(this).val().length == 2 && $(this).val().min == 1 && $(this).val().max == 31){...}
</code>```

Thanks a lot for your help

答:
You should be using type="date":

<input type="date" min="1970-01-01" max="2017-06-08" required>```

Body:
I would like to know how I can add a min value and a max value in my input text for a date.
The format that I would like to have is : dd/mm/yyyy

So I've put a maxlenght to my input and I have added automatically "/" after the user type 2 numbers.

When I test it, everything is fine but I still can write "67/34/8888" and not a correct date for example.

Here's my code :

<form method="post" action="#" id="formStep2">
<input type="text" id="txtDate" class="selector" placeholder="dd/mm/yyyy" maxlength="10" required />
</form>

Is it possible to add something like :

 if ($(this).val().length == 2 && $(this).val().min == 1 && $(this).val().max == 31){...}

Thanks a lot for your help


问:
Does useBean id create an instance of the bean class that it is refering to?
This is a main.JSP jsp

```<code><html>
<body>``
      <center>
         *<h2>Using JavaBeans in JSP</h2>
         <jsp:useBean id = "test" class = "servletexample1.TestBean" />*
         <jsp:setProperty name = "test"  property = "message"
            value = "Hello JSP..." />

         <p>Got message....</p>
         <jsp:getProperty name = "test" property = "message" />
      </center>
   </body>
</html>
</code>```

This is a TestBean Class

```<code>package servletexample1;

/* File: TestBean.java */
   public class TestBean {
       private String message = "No message specified";

       public String getMessage() {
          return(message);
       }
       public void setMessage(String message) {
          this.message = message;
       }
      public static void main(String[] args)
      {
          TestBean test = new TestBean();
      }
    }
</code>```

what exactly is test in main.jsp? Is it the instance of the TestBean() class?what exactly does this statement <jsp:useBean id = "test" do?

答:
Yes when you declare a bean id in useBean tag it is the instance of that class like just you create a instance core java.
In your code test is the instance of TestBean class.

Body:
This is a main.JSP jsp

``

         *
Using JavaBeans in JSP

         <jsp:useBean id = "test" class = "servletexample1.TestBean" />*
         <jsp:setProperty name = "test"  property = "message"
            value = "Hello JSP..." />

Got message....

         <jsp:getProperty name = "test" property = "message" />

This is a TestBean Class

package servletexample1;

/* File: TestBean.java */
   public class TestBean {
       private String message = "No message specified";

       public String getMessage() {
          return(message);
       }
       public void setMessage(String message) {
          this.message = message;
       }
      public static void main(String[] args)
      {
          TestBean test = new TestBean();
      }
    }

what exactly is test in main.jsp? Is it the instance of the TestBean() class?what exactly does this statement <jsp:useBean id = "test" do?


问:
What's the best way to represent a stage script in HTML?
I have a sketch that I want to put up on my website, and I also intend to write a short play at some point which I'd also want to make freely available.

I'm trying to work out the best way of representing this in HTML. I basically need two columns - one for the character speaking, and one for the text. Each speech obviously needs to line up with the speaker though. In other words, something like this:

```
    Jeff        This sure is a nice website we've got now.

    Joel        It certainly is. By the way, working at FogCreek rocks.

    Jeff        Of course it does. Have you played Rock Band yet? It's
                 a lot of fun.
```

(Well it's better than lorem ipsum...)

I know how I could do this with HTML tables (with one table row per speech) but that seems pretty ugly, and everyone certainly seems to be keen on using CSS to represent non-tabular data. I can't see how this really counts a tabular data - my use of "row" and "column" earlier was to do with the layout rather than the fundamental data.

So, any ideas? I think most of the script websites I've seen (not many, admittedly) either use ``` like my example above, or don't bother trying to keep the normal script format, instead just prefixing each paragraph with the speaker's name. (See the podcast wiki for an example of this style.) I'm having trouble working out even what HTML elements I should be using to represent this, frankly - a dictionary definition list with the speaker as the term and the speech as the definition is probably the closest I've thought of, but that feels like abuse.

答:
I'd say

```<code><dialog>
  <dt>Jeff
  <dd>This sure is a nice website we've got now.
  <dt>Joel
  <dd>It certainly is. By the way, working at FogCreek rocks.
  <dt>Jeff
  <dd>Of course it does. Have you played Rock Band yet? It's a lot of fun.
</dialog>
</code>```

as defined in HTML5.

Of course, you'll need a  to get IE to do something sensible and a dialog { display:block; } in your CSS to get it to work completely.

OwnerDisplayName: Jon Skeet

Body:
I have a sketch that I want to put up on my website, and I also intend to write a short play at some point which I'd also want to make freely available.

I'm trying to work out the best way of representing this in HTML. I basically need two columns - one for the character speaking, and one for the text. Each speech obviously needs to line up with the speaker though. In other words, something like this:

    Jeff        This sure is a nice website we've got now.

    Joel        It certainly is. By the way, working at FogCreek rocks.

    Jeff        Of course it does. Have you played Rock Band yet? It's
                 a lot of fun.

(Well it's better than lorem ipsum...)

I know how I could do this with HTML tables (with one table row per speech) but that seems pretty ugly, and everyone certainly seems to be keen on using CSS to represent non-tabular data. I can't see how this really counts a tabular data - my use of "row" and "column" earlier was to do with the layout rather than the fundamental data.

So, any ideas? I think most of the script websites I've seen (not many, admittedly) either use
 like my example above, or don't bother trying to keep the normal script format, instead just prefixing each paragraph with the speaker's name. (See the podcast wiki for an example of this style.) I'm having trouble working out even what HTML elements I should be using to represent this, frankly - a dictionary definition list with the speaker as the term and the speech as the definition is probably the closest I've thought of, but that feels like abuse.

LastEditorDisplayName: Jon Skeet

Body:
I'd say

<dialog>
  <dt>Jeff
  <dd>This sure is a nice website we've got now.
  <dt>Joel
  <dd>It certainly is. By the way, working at FogCreek rocks.
  <dt>Jeff
  <dd>Of course it does. Have you played Rock Band yet? It's a lot of fun.
</dialog>

as defined in HTML5.

Of course, you'll need a <script>document.createElement('dialog');</script> to get IE to do something sensible and a dialog { display:block; } in your CSS to get it to work completely.


问:
Detect UIWebView links without click
I was wondering is there any possible way to detect a link in UIWebView without click on  urls ? for example if page has PDF file automatically get its link. I know with webview's delegate I can detect clicked urls like this :

```<code>  func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool
    {

        if navigationType == .linkClicked
        {
            print(request.url?.absoluteString)
        }
        return true
    }
</code>```

but is there any possible way to detect links without click ?

答: Use NSXMLParser to parse the HTML body of the UIWebView and look for a tags, and get their href parameter which contains the url.

Title: Detect UIWebView links without click

Body:
I was wondering is there any possible way to detect a link in UIWebView without click on  urls ? for example if page has PDF file automatically get its link. I know with webview's delegate I can detect clicked urls like this :

  func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool
    {

        if navigationType == .linkClicked
        {
            print(request.url?.absoluteString)
        }
        return true
    }

but is there any possible way to detect links without click ?


问:
Create a barcode with upper and lower text
I need to create a barcode with upper and lower text and apply it on all the page of a PDF as the following structure:

```<code>                               TEXT
                              BARCODE
                               TEXT
</code>```

I'm using the iTextSharp DLL to create the barcode.
My idea is create a JPG image (with the structure) and apply on the PDF.

I have used this code:

```<code>Bmgraphics.Clear(Drawing.Color.White)
Bmgraphics.DrawString(UpperText, New System.Drawing.Font("Arial", 8, FontStyle.Regular), SystemBrushes.WindowText, New Point(0, 0))
Bmgraphics.DrawImage(Barcode, New Point(0, height/ 2))
Bmgraphics.DrawString(LoewText, New System.Drawing.Font("Arial", 8, FontStyle.Regular), SystemBrushes.WindowText, New Point(0, height+ 10))
finale.Save("path to save")
</code>```

My problem is about the dimension to give to the Bitmap image.
I need that the longer between barcode, lower text, and upper text give the width of the image.

How can I do?

答:
A readable barcode, AFAIK, is always longer than the underlying text.
What am I missing, here?</p>

Body:
I need to create a barcode with upper and lower text and apply it on all the page of a PDF as the following structure:

                               TEXT
                              BARCODE
                               TEXT

I'm using the iTextSharp DLL to create the barcode.
My idea is create a JPG image (with the structure) and apply on the PDF.

I have used this code:

Bmgraphics.Clear(Drawing.Color.White)
Bmgraphics.DrawString(UpperText, New System.Drawing.Font("Arial", 8, FontStyle.Regular), SystemBrushes.WindowText, New Point(0, 0))
Bmgraphics.DrawImage(Barcode, New Point(0, height/ 2))
Bmgraphics.DrawString(LoewText, New System.Drawing.Font("Arial", 8, FontStyle.Regular), SystemBrushes.WindowText, New Point(0, height+ 10))
finale.Save("path to save")

My problem is about the dimension to give to the Bitmap image.
I need that the longer between barcode, lower text, and upper text give the width of the image.

How can I do?


问:
Access environment name in Program.Main in ASP.NET Core
Using ASP.NET Mvc Core I needed to set my development environment to use https, so I added the below to the Main method in Program.cs:

```<code>var host = new WebHostBuilder()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseKestrel(cfg => cfg.UseHttps("ssl-dev.pfx", "Password"))
                .UseUrls("https://localhost:5000")
                .UseApplicationInsights()
                .Build();
                host.Run();
</code>```

How can I access the hosting environment here so that I can conditionally set the protocol/port number/certificate?

Ideally, I would just use the CLI to manipulate my hosting environment like so:

```<code>dotnet run --server.urls https://localhost:5000 --cert ssl-dev.pfx password
</code>```

but there doesn't seem to be way to use a certificate from the command line.

答:
I think  the easiest solution is to read the value from the ASPNETCORE_ENVIRONMENT environment variable and compare it with Environments.Development:

```<code>var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var isDevelopment = environment == Environments.Development;
</code>```

.NET 6 or higher

Starting from .NET 6 using the new application bootstrapping model you can access the environment from the application builder:

var builder = WebApplication.CreateBuilder(args);
var isDevelopment = builder.Environment.IsDevelopment();
```

Body:
Using ASP.NET Mvc Core I needed to set my development environment to use https, so I added the below to the Main method in Program.cs:

var host = new WebHostBuilder()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseKestrel(cfg => cfg.UseHttps("ssl-dev.pfx", "Password"))
                .UseUrls("https://localhost:5000")
                .UseApplicationInsights()
                .Build();
                host.Run();

How can I access the hosting environment here so that I can conditionally set the protocol/port number/certificate?

Ideally, I would just use the CLI to manipulate my hosting environment like so:

dotnet run --server.urls https://localhost:5000 --cert ssl-dev.pfx password

but there doesn't seem to be way to use a certificate from the command line.

Body:
I think  the easiest solution is to read the value from the ASPNETCORE_ENVIRONMENT environment variable and compare it with Environments.Development:

var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var isDevelopment = environment == Environments.Development;

.NET 6 or higher

Starting from .NET 6 using the new application bootstrapping model you can access the environment from the application builder:

var builder = WebApplication.CreateBuilder(args);
var isDevelopment = builder.Environment.IsDevelopment();

ContentLicense: CC BY-SA 4.0


问:
Wrting out names with 6 cells between them
I would like to write out names from another worksheet to another worksheet with 6 cells inbetween the names.

```<code>Sub names()

Dim i As Integer
Dim j As Integer

For j = 2 To 6054 Step 6
For i = 2 To 1010
Worksheets("Worksheet2").Cells(j, 12).Value = Worksheets("Worksheet3").Cells(i, 1).Value
Next i
Next j

End Sub
</code>```

When i run the code it writes out the last name to every cell.

答:
You only want one loop,

With two each output cell cycles through the list of names till it reaches the last.

```<code>Sub names()

Dim i As Integer
Dim j As Integer

j=2
For i = 2 To 1010
    Worksheets("Worksheet2").Cells(j, 12).Value = Worksheets("Worksheet3").Cells(i, 1).Value
    j=j+6
Next i

End Sub
</code>```

Body:
I would like to write out names from another worksheet to another worksheet with 6 cells inbetween the names.

Sub names()

Dim i As Integer
Dim j As Integer

For j = 2 To 6054 Step 6
For i = 2 To 1010
Worksheets("Worksheet2").Cells(j, 12).Value = Worksheets("Worksheet3").Cells(i, 1).Value
Next i
Next j

End Sub

When i run the code it writes out the last name to every cell.

Body:
You only want one loop,

With two each output cell cycles through the list of names till it reaches the last.

Sub names()

Dim i As Integer
Dim j As Integer

j=2
For i = 2 To 1010
    Worksheets("Worksheet2").Cells(j, 12).Value = Worksheets("Worksheet3").Cells(i, 1).Value
    j=j+6
Next i

End Sub


问:
How to handle UTF-8 character encoding in http log in SOAPUI
We are generating xml using a web service(cobol code) in which we are doing an XML GENERATE to generate xml from a copybook. Now this generated XML consists of special characters like [·, Ý, ¨] which show correctly in SOAP response. But when the same message is viewed in http logs, the characters get converted to HEX like below :
SOAP Response:

```<code><StatusDesc>capital one bank Ýusa¨ ,n.a</StatusDesc>
</code>```

Http Log:

```<code><StatusDesc>capital one bank [0xc3][0x9d]usa[0xc2][0xa8] ,n.a</StatusDesc>
</code>```

Now to handle this we tried to do an XML GENERATE using the WITH ENCODING 1208 clause to support the UTF-8 encoding. This in turn generated the XML in unreadable format, and nothing was readable in SOAP response. So not sure if we are missing out on anything here or is this not how we should be handling the HEX characters in http log.

```<code>?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:mes="http://MessageView/"                                                                                xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body>mes:ÃƒÅ’_%Ã‚â‚¬ÃƒÅ½ÃƒÂÃƒÅ Ãƒâ€¹Ãƒâ€˜?>Ã‚â€šÃ‚â€˜Ã‚ÂÃ‚â€šÃ‚â‚¬ÃƒÂ>Ãƒâ€ž?Ãƒâ‚¬Ãƒâ€˜>Ãƒâ€¦Ã‚â€šÃƒÂÃƒÂ¨ÃƒÂ£Ã‚ËœÃ‚â€šÃ‚Å¾Ã‚Â Ãƒâ€žÃƒâ€žÃƒË†ÃƒÂ±>ÃƒÆ’?ÃƒÂ±>Ãƒâ€°ÃƒÂªÃƒâ€¹Ã‚Å¾ÃƒÂ¬ÃƒÂ«ÃƒË†/ÃƒË†ÃƒÂÃƒâ€¹Ã‚Å¾ÃƒÂ«ÃƒË†/ÃƒË†ÃƒÂÃƒâ€¹ÃƒÂ¤?Ãƒâ‚¬ÃƒÂÃ‚Å¾Ã‚â€˜Ã‚ÂÃ‚â„¢Ã‚ÂÃƒÂ«ÃƒË†/ÃƒË†ÃƒÂÃƒâ€¹ÃƒÂ¤?Ãƒâ‚¬ÃƒÂÃ‚Å¾ÃƒÂ«ÃƒÂÃƒÅ ÃƒÅ½ÃƒÂÃƒÅ ÃƒÂ«Ãƒ
</code>```

The question is that is there a way to handle these characters so that the hex characters in the http log get converted to their proper display. Should this be done in Cobol web service or do we need some kind of conversion to handle the http logs outside z/os.

答:
It is possible to change encoding using below steps.

Go to SOAPUI_HOME/bin.

Open soapui.bat (or.sh), depending on your platform.

You should be able find JAVA_OPTS, then you can add there below line in a new line

set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding="utf-8" - on windows

export JAVA_OPTS=$JAVA_OPTS -Dfile.encoding="utf-8" - on linux

Save the file, start SoapUI using soapui.bat( or .sh) utility.

Body:
We are generating xml using a web service(cobol code) in which we are doing an XML GENERATE to generate xml from a copybook. Now this generated XML consists of special characters like [·, Ý, ¨] which show correctly in SOAP response. But when the same message is viewed in http logs, the characters get converted to HEX like below :
SOAP Response:

<StatusDesc>capital one bank Ýusa¨ ,n.a</StatusDesc>

Http Log:

<StatusDesc>capital one bank [0xc3][0x9d]usa[0xc2][0xa8] ,n.a</StatusDesc>

Now to handle this we tried to do an XML GENERATE using the WITH ENCODING 1208 clause to support the UTF-8 encoding. This in turn generated the XML in unreadable format, and nothing was readable in SOAP response. So not sure if we are missing out on anything here or is this not how we should be handling the HEX characters in http log.

?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:mes="http://MessageView/"                                                                                xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body>mes:ÃƒÅ’_%Ã‚â‚¬ÃƒÅ½ÃƒÂÃƒÅ Ãƒâ€¹Ãƒâ€˜?>Ã‚â€šÃ‚â€˜Ã‚ÂÃ‚â€šÃ‚â‚¬ÃƒÂ>Ãƒâ€ž?Ãƒâ‚¬Ãƒâ€˜>Ãƒâ€¦Ã‚â€šÃƒÂÃƒÂ¨ÃƒÂ£Ã‚ËœÃ‚â€šÃ‚Å¾Ã‚Â Ãƒâ€žÃƒâ€žÃƒË†ÃƒÂ±>ÃƒÆ’?ÃƒÂ±>Ãƒâ€°ÃƒÂªÃƒâ€¹Ã‚Å¾ÃƒÂ¬ÃƒÂ«ÃƒË†/ÃƒË†ÃƒÂÃƒâ€¹Ã‚Å¾ÃƒÂ«ÃƒË†/ÃƒË†ÃƒÂÃƒâ€¹ÃƒÂ¤?Ãƒâ‚¬ÃƒÂÃ‚Å¾Ã‚â€˜Ã‚ÂÃ‚â„¢Ã‚ÂÃƒÂ«ÃƒË†/ÃƒË†ÃƒÂÃƒâ€¹ÃƒÂ¤?Ãƒâ‚¬ÃƒÂÃ‚Å¾ÃƒÂ«ÃƒÂÃƒÅ ÃƒÅ½ÃƒÂÃƒÅ ÃƒÂ«Ãƒ

The question is that is there a way to handle these characters so that the hex characters in the http log get converted to their proper display. Should this be done in Cobol web service or do we need some kind of conversion to handle the http logs outside z/os.


问:
installing wx gizmos for python on windows
I've installed wx for python on windows with
pip install wxpython
The python script I'm using tries to import wx.gizmos. The program fails there with error "No module names gizmos". So i've tried to install it with
pip install gizmos,
pip install wxgizmos,
pip install wx.gizmos,
pip install wxpython.gizmos,
pip install wxpythongizmos.
Error is "No matching distribution found for..."
I've been to https://wxpython.org/Phoenix/docs/html/main.html and it appears gizmos is not there and so can't be used but the python script needs it.
Is there a way of installing this or a way arond this ?</p>

答:
I uninstalled python wx using:
pip uninstall wxpython.
and reinstalled it from here:
https://sourceforge.net/projects/wxpython/files/wxPython/2.9.5.0/wxPython2.9-win64-2.9.5.0-py27.exe/download</p>


答:
Yes, it's possible, but I wouldn't recommend it:    </p>

```<code>echo (($ext == "m") ? $extype = "mp3" : (($ext == "w") ? $extype = "wav" : (($ext == "a") ? $extype = "aac" : '')));
</code>```

Title: its it possible to have two ELSEIF clauses in a IF ternary?

Body:
can this be made into an IF ternary to shorten the code? I don't know how to do it with multiple elseif clause

if ($ext == "m") {
 $extype = "mp3";
}elseif ($ext == "w") {
 $extype = "wav";
}elseif ($ext == "a"){
 $extype = "aac";
}

the is the full function

function loc($id,$type,$ext) //loc($id,'n',$ext)
{
  if (($query = mysql_query("SELECT loc FROM names WHERE id = '".(int)$id."'")) !== false)
  {
    if (mysql_num_rows($query) > 0)
     if ($ext == "m") {
     $extype = ".mp3";
     }elseif ($ext == "w") {
     $extype = ".wav";
     }elseif ($ext == "a") {
     $extype = ".aac";
     }
      return '/rec/'.mysql_result($query,0,'loc').$id.'-'.($type=='n'?'n':'s').$extype);

  }
  return 'Error Not Found';
}

Body:
Yes, it's possible, but I wouldn't recommend it:

echo (($ext == "m") ? $extype = "mp3" : (($ext == "w") ? $extype = "wav" : (($ext == "a") ? $extype = "aac" : '')));


问:
Meaning of "*" and "/" in SPARQL
I want to know the meaning of * and / in SPARQL.

If you check this example from Wikidata, you will see that a / and a * are used in here:

```<code>?item wdt:P361* wd:Q362 .
?item wdt:P31/wdt:P279* wd:Q178561 .
</code>```

What are they for? Why are they used?

Thank you in advance!

答:
They are part of SPARQL 1.1 syntax which is called property paths. They allow you to search for a specific path in the query.

For instance first basic graph pattern of yours (wdt:P361*) is serching for one or more occurance of the property wdt:P361 associated with the resource wd:Q362 - as long as time permits.

Or in the second one / allows you to search for a property wdt:P31 which is followed by a wdt:P279. However, I reccomend you to start with trying shorter paths not to confront any execution timeouts.

Title: Meaning of "*" and "/" in SPARQL

Body:
I want to know the meaning of * and / in SPARQL.

If you check this <a href="https://query.wikidata.org/#%23added%20before%202016-10%0A%0A%23defaultView%3ABubbleChart%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%28%3Fend%20-%20%3Fstart%20AS%20%3Fkk%29%0AWHERE%0A%7B%0A%09%3Fitem%20wdt%3AP361%2A%20wd%3AQ362%20.%0A%09%3Fitem%20wdt%3AP31%2Fwdt%3AP279%2A%20wd%3AQ178561%20.%0A%09%3Fitem%20wdt%3AP580%20%3Fstart%20.%0A%09%3Fitem%20wdt%3AP582%20%3Fend%20.%0A%0A%09SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%7D%0A%7D" rel="nofollow noreferrer">example from Wikidata, you will see that a / and a * are used in here:

?item wdt:P361* wd:Q362 .
?item wdt:P31/wdt:P279* wd:Q178561 .

What are they for? Why are they used?

Thank you in advance!


问:
CSVMIDI converter, how to use?
On the following website:
http://www.fourmilab.ch/webtools/midicsv/
I found a tool that supposedly can convert CSV files to MIDI files and MIDI files to CSV files.

It contains two .exe files that should be able to do the trick.

However, these files only show a black terminal-like screen when opened. When I drag and drop files to them something seems to happen but no new files is generated.

The readme doesn't explain how to do this.

Can anybody help me with this?

I am busy making a random music generator. It's only using soundbeep right now, but I want multiple tracks, hence my need to be able to create midi files from CSV files. If anybody's interested in the music generator I'd gladly share the code (though it's still a bit basic)

答:
I think it is only available on a Windows system, If you are on Windows, open the Midicsv.exe for example, then you should turn another cmd on; In your newly opened cmd, change to where your files in(or you can input exact path later), then in your cmd:

```<code>midicsv [-u -v] [Your MIDI file] [Your out put path with csv name]
</code>```

then you can find your generated csv file.

Title: CSVMIDI converter, how to use?

Body:
I think it is only available on a Windows system, If you are on Windows, open the Midicsv.exe for example, then you should turn another cmd on; In your newly opened cmd, change to where your files in(or you can input exact path later), then in your cmd:

midicsv [-u -v] [Your MIDI file] [Your out put path with csv name]

then you can find your generated csv file.


问:
batch compress all tables in SQL Server
Running into a problem with the code below.  I'm trying to batch compress all tables in a certain database, but there's an issue with my syntax...

```<code>USE backups
GO

DECLARE @tables TABLE ( TABLE_NAME VARCHAR(MAX) )

INSERT INTO @tables ( TABLE_NAME ) SELECT DISTINCT TABLE_NAME FROM information_schema.TABLES

WHILE ( SELECT COUNT(*) ct FROM @tables ) > 0
BEGIN
    DECLARE @table VARCHAR(MAX) = ( SELECT TOP 1 TABLE_NAME FROM @tables )

    DELETE FROM @tables WHERE TABLE_NAME = @table

    BEGIN TRY
        ALTER TABLE @table REBUILD PARTITION = ALL WITH ( DATA_COMPRESSION = PAGE )
    END TRY
    BEGIN CATCH
        RAISERROR( 'Compression failed for backup table : %s', 20, 101, @table ) WITH LOG
    END CATCH
END
</code>```

The error I'm getting is:

Incorrect syntax near '@table'.  Expecting '.', ID, or QUOTED_ID

答:
Turns out I found that you can't use variable names for tables or other schema objects in some situations.  This fixes the problem...</p>

```<code>USE backups
GO

DECLARE @tables TABLE ( TABLE_NAME NVARCHAR(MAX) )
DECLARE @query NVARCHAR(MAX)

INSERT INTO @tables ( TABLE_NAME ) SELECT DISTINCT TABLE_NAME FROM information_schema.TABLES

WHILE ( SELECT COUNT(*) ct FROM @tables ) > 0
BEGIN
    DECLARE @table VARCHAR(MAX) = ( SELECT TOP 1 TABLE_NAME FROM @tables )

    DELETE FROM @tables WHERE TABLE_NAME = @table

    BEGIN TRY
        SET @query = N'ALTER TABLE ' + @table + N' REBUILD PARTITION = ALL WITH ( DATA_COMPRESSION = PAGE )'

        EXEC sp_executesql @query
    END TRY
    BEGIN CATCH
        RAISERROR( 'Compression failed for backup table : %s', 20, 101, @table ) WITH LOG
    END CATCH
END
</code>```

Title: batch compress all tables in SQL Server

Body:
Running into a problem with the code below.  I'm trying to batch compress all tables in a certain database, but there's an issue with my syntax...

USE backups
GO

DECLARE @tables TABLE ( TABLE_NAME VARCHAR(MAX) )

INSERT INTO @tables ( TABLE_NAME ) SELECT DISTINCT TABLE_NAME FROM information_schema.TABLES

WHILE ( SELECT COUNT(*) ct FROM @tables ) > 0
BEGIN
    DECLARE @table VARCHAR(MAX) = ( SELECT TOP 1 TABLE_NAME FROM @tables )

    DELETE FROM @tables WHERE TABLE_NAME = @table

    BEGIN TRY
        ALTER TABLE @table REBUILD PARTITION = ALL WITH ( DATA_COMPRESSION = PAGE )
    END TRY
    BEGIN CATCH
        RAISERROR( 'Compression failed for backup table : %s', 20, 101, @table ) WITH LOG
    END CATCH
END

The error I'm getting is:

Incorrect syntax near '@table'.  Expecting '.', ID, or QUOTED_ID

Body:
Turns out I found that you can't use variable names for tables or other schema objects in some situations.  This fixes the problem...

USE backups
GO

DECLARE @tables TABLE ( TABLE_NAME NVARCHAR(MAX) )
DECLARE @query NVARCHAR(MAX)

INSERT INTO @tables ( TABLE_NAME ) SELECT DISTINCT TABLE_NAME FROM information_schema.TABLES

WHILE ( SELECT COUNT(*) ct FROM @tables ) > 0
BEGIN
    DECLARE @table VARCHAR(MAX) = ( SELECT TOP 1 TABLE_NAME FROM @tables )

    DELETE FROM @tables WHERE TABLE_NAME = @table

    BEGIN TRY
        SET @query = N'ALTER TABLE ' + @table + N' REBUILD PARTITION = ALL WITH ( DATA_COMPRESSION = PAGE )'

        EXEC sp_executesql @query
    END TRY
    BEGIN CATCH
        RAISERROR( 'Compression failed for backup table : %s', 20, 101, @table ) WITH LOG
    END CATCH
END


问:
Unity5 Error while saving blame file
I updated an existing project from Unity 5.6.0 to 5.6.1 and a error I've never encountered appeared. I've looked around but couldn't find anything about it. The consol text mentions Tools and AndroidSDK so I made sure to update everything from Android Studio but the issue is not fixed. SDK & JDK are setup correctly. I still can't build (Nothing has changed except the update and the game has been working well for months). If anyone could give me pointers on how to fix this, it'd be awesome. (Also, the error only happens in this project)
Here is the consol text that appears : </p>

```<code>Error: Error while saving blame file, build will continue
Error: Le préfixe "tools" de l'attribut "tools:overrideLibrary" associé à un type d'élément "uses-sdk" n'est pas lié
UnityEditor.HostView:OnGUI()
</code>```

<p>(The french part is weird since my whole system is in English, but it means : Error: The "tools" prefix of the "Tools:overrideLibrary" associated with a type of element "uses-sdk" is not linked).
Then an other error appears, but I think it is related to the first :</p>

```<code>AndroidSDKToolsException: Unable to merge android manifests. See the Console for more details.
 UnityEditor.Android.AndroidSDKTools.DetectErrorsAndWarnings (System.String logMessages, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.MergeManifests (System.String target, System.String mainManifest, System.String[] libraryManifests, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit)
 UnityEditor.Android.PostProcessor.Tasks.GenerateManifest.MergeManifests (UnityEditor.Android.PostProcessor.PostProcessorContext context, System.String targetManifest, System.String mainManifest)
 UnityEditor.Android.PostProcessor.Tasks.GenerateManifest.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
 UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
 UnityEditor.HostView:OnGUI()
</code>```

答:
In your AndroidManifest.xml  add xmlns:tools="http://schemas.android.com/tools" to manifest tag. It should look something like this:

```<code><manifest xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player"
 android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
</code>```

Title: Unity5 Error while saving blame file

Body:
I updated an existing project from Unity 5.6.0 to 5.6.1 and a error I've never encountered appeared. I've looked around but couldn't find anything about it. The consol text mentions Tools and AndroidSDK so I made sure to update everything from Android Studio but the issue is not fixed. SDK & JDK are setup correctly. I still can't build (Nothing has changed except the update and the game has been working well for months). If anyone could give me pointers on how to fix this, it'd be awesome. (Also, the error only happens in this project)
Here is the consol text that appears :

Error: Error while saving blame file, build will continue
Error: Le préfixe "tools" de l'attribut "tools:overrideLibrary" associé à un type d'élément "uses-sdk" n'est pas lié
UnityEditor.HostView:OnGUI()

(The french part is weird since my whole system is in English, but it means : Error: The "tools" prefix of the "Tools:overrideLibrary" associated with a type of element "uses-sdk" is not linked).
Then an other error appears, but I think it is related to the first :

AndroidSDKToolsException: Unable to merge android manifests. See the Console for more details.
 UnityEditor.Android.AndroidSDKTools.DetectErrorsAndWarnings (System.String logMessages, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
 UnityEditor.Android.AndroidSDKTools.MergeManifests (System.String target, System.String mainManifest, System.String[] libraryManifests, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit)
 UnityEditor.Android.PostProcessor.Tasks.GenerateManifest.MergeManifests (UnityEditor.Android.PostProcessor.PostProcessorContext context, System.String targetManifest, System.String mainManifest)
 UnityEditor.Android.PostProcessor.Tasks.GenerateManifest.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
 UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
 UnityEditor.HostView:OnGUI()

Body:
In your AndroidManifest.xml  add xmlns:tools="http://schemas.android.com/tools" to manifest tag. It should look something like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player"
 android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">


问:
Doctrine Raw SQL not calling custom function
I'm having an issue calling an custom defined function in my database from Doctrine when using the Raw SQL.

Here is an example SQL Query that is being run

```<code> SELECT unicodeDecoder(answer) from answers;
</code>```

unicodeDecoder is a custom defined function in my database and runs perfectly fine when I run the SQL statement directly on the database.

However when I run the query using raw sql, as follows:

```<code>$sql = "SELECT unicodeDecoder(answer) from answers";
$stmt = $this->getEntitityManager()->getConnection()->prepare($sql);
$stmt->execute();
</code>```

I get the following error:

```<code>SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION unicodeDecoder does not exist
</code>```

Do I need to create a custom ORM mapping when using custom functions or could this be some form of caching issue?

Any help would be massively appreciated.

Thanks in advance

答:
If found the issue. Thank you to @alex-blex for giving me a point of somewhere to start looking.

My database has a . in the name: cms.app.com

The issue was caused by the .

When Doctrine tries to access the method it automatically appends the database name to the beginning.

When I attempted to add the cms.app.com to the beginning (as suggested by @alex-blex) it created the following method call (which is the wrong syntax)

```<code>cms.app.com.unicodeDecoder()
</code>```

I attempted the following

`cms.app.com`.unicodeDecoder but this still resolved to

```<code>cms.app.com.unicodeDecoder()
</code>```

I removed the . from the database name and it now works as expected.

Important Note: Do not use . in your database name as Doctorine doesn't resolve the name correctly as the ` symbol get stripped out.

Body:
I'm having an issue calling an custom defined function in my database from Doctrine when using the Raw SQL.

Here is an example SQL Query that is being run

 SELECT unicodeDecoder(answer) from answers;

unicodeDecoder is a custom defined function in my database and runs perfectly fine when I run the SQL statement directly on the database.

However when I run the query using raw sql, as follows:

$sql = "SELECT unicodeDecoder(answer) from answers";
$stmt = $this->getEntitityManager()->getConnection()->prepare($sql);
$stmt->execute();

I get the following error:

SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION unicodeDecoder does not exist

Do I need to create a custom ORM mapping when using custom functions or could this be some form of caching issue?

Any help would be massively appreciated.

Thanks in advance

Body:
If found the issue. Thank you to @alex-blex for giving me a point of somewhere to start looking.

My database has a . in the name: cms.app.com

The issue was caused by the .

When Doctrine tries to access the method it automatically appends the database name to the beginning.

When I attempted to add the cms.app.com to the beginning (as suggested by @alex-blex) it created the following method call (which is the wrong syntax)

cms.app.com.unicodeDecoder()

I attempted the following

`cms.app.com`.unicodeDecoder but this still resolved to

cms.app.com.unicodeDecoder()

I removed the . from the database name and it now works as expected.

Important Note: Do not use . in your database name as Doctorine doesn't resolve the name correctly as the ` symbol get stripped out.


问:
Linq query with multiple subqueries
I'm working on converting an Oracle Sql query to Linq, and not sure how to proceed. Here is the Sql query:

```<code>SELECT *
FROM   CustomerShip,
    (SELECT DISTINCT b.ShipSeq AS shipSeq
     FROM   Orders a,
            CustomerShip b
     WHERE  a.OrderId IN (SELECT OrderId
                          FROM   Orders
                          WHERE  CustomerId = @CustomerId
                          AND    OrderType <> 'A')
     AND    b.CustomerId = @CustomerId
     AND    b.ShipSeq = a.CustShip
     AND    OrderStatus <> 'C'
     GROUP BY b.ShipSeq) i
WHERE  CustomerId = @CustomerId
AND    (Address NOT LIKE '%RETAIL%STORE%')
AND    ShipSeq = i.ShipSeq(+)
ORDER BY ShipTo DESC, OrderDate DESC;
</code>```

I have tried to break it down into three separate queries when converting to linq.

```<code>var query1 = from c in CustomerShip
            where c.CustomerId == customerId
            && !c.Address.Contains("RETAIL")
            && !c.Address.Contains("STORE")
            orderby c.ShipTo descending, c.OrderDate descending
            select c;

var query2 = from o in Orders
         where o.CustomerId == customerId
         && !o.OrderType.Equals("A")
         select o.OrderId;

var query3 = (from o in Orders
         from c in CustomerShip
         where c.CustomerId == customerId
         && c.ShipSeq == o.CustShip
         && !o.OrderStatus.Equals("A")
         select c.ShipSeq).Distinct();
</code>```

Now I'm trying to assemble them all into one query, but unsure how to do it. Here is the direction I am going:

```<code>var query = from c in CustomerShip

let subquery = from o in Orders
               where o.CustomerId == customerId
               && !o.OrderType.Equals("A")
               select o.OrderId

    from or in model.Orders
    where subquery.Contains(or.OrderId)
    && c.CustomerId == customerId
    && c.ShipSeq == or.CustShip
    && !or.OrderStatus.Equals("A")
    group c by c.ShipSeq
    into i
    select c.ShipSeq

where c.CustomerId == customerId
&& !c.Address.Contains("RETAIL")
&& !c.Address.Contains("STORE")
orderby c.ShipTo descending, c.OrderDate descending
select c, i;
</code>```

UPDATE

I have a query that kinds works, but the it takes almost two minutes to execute (compared to .02s for the Oracle query) and the order of the results is incorrect. Anyone see what I'm missing?

```<code>var innerQuery = from x in model.Orders
                    where x.CustomerId == customerId
                    && !x.OrderType.Equals("A")
                    select x.OrderId;

var result = from c in model.CustomerShip
            join subQuery in
            (
                (from o in model.Orders
                from c in model.CustomerShip
                where c.CustomerId == customerId
                && innerQuery.Contains(o.OrderId)
                && !o.FLAG_ORD_STATUS.Equals("C")
                && c.ShipSeq == o.CustShip
                select c.ShipSeq).Distinct()

            ) on c.ShipSeq equals subQuery into temp
            from x in temp.DefaultIfEmpty()
            where c.CustomerId == customerId
            && !c.Address.Contains("RETAIL")
            && !c.Address.Contains("STORE")
            orderby c.ShipTo descending, c.OrderDate descending
            select c;
</code>```

答:
Remember that you are just build a query here.  Nothing is executed until you do a ToList() or .FirstOrDefault() or whatever.  SO, you can use the queries in other queries, and it will create one big SQL statement when executed.

```<code>var query2 = from o in Orders
             where o.CustomerId == customerId
             && !o.OrderType.Equals("A")
             select o.OrderId;

var query3 = (from o in Orders
              join c in CustomerShip on o.CustShip equals c.ShipSeq
              where c.CustomerId == customerId
              && !o.OrderStatus.Equals("A")
              && query2.Contains(o.OrderId)
              select c.ShipSeq).Distinct();

var query1 = from c in CustomerShip
             from i in query3
             where c.CustomerId == customerId
             && !c.Address.Contains("RETAIL")
             && !c.Address.Contains("STORE")
             && c.ShipSeq == i.ShipSeq
             orderby c.ShipTo descending, c.OrderDate descending
             select c;
</code>```

However, I'm pretty sure you can reduce query2 and query3 down to just:

```<code>var query3 = (from o in Orders
              join c in CustomerShip on o.CustShip equals c.ShipSeq
              where c.CustomerId == customerId
              && !o.OrderStatus.Equals("A")
              && !o.OrderType.Equals("A")
              select c.ShipSeq).Distinct();
</code>```

Title: Linq query with multiple subqueries

Body:
I'm working on converting an Oracle Sql query to Linq, and not sure how to proceed. Here is the Sql query:

SELECT *
FROM   CustomerShip,
    (SELECT DISTINCT b.ShipSeq AS shipSeq
     FROM   Orders a,
            CustomerShip b
     WHERE  a.OrderId IN (SELECT OrderId
                          FROM   Orders
                          WHERE  CustomerId = @CustomerId
                          AND    OrderType <> 'A')
     AND    b.CustomerId = @CustomerId
     AND    b.ShipSeq = a.CustShip
     AND    OrderStatus <> 'C'
     GROUP BY b.ShipSeq) i
WHERE  CustomerId = @CustomerId
AND    (Address NOT LIKE '%RETAIL%STORE%')
AND    ShipSeq = i.ShipSeq(+)
ORDER BY ShipTo DESC, OrderDate DESC;

I have tried to break it down into three separate queries when converting to linq.

var query1 = from c in CustomerShip
            where c.CustomerId == customerId
            && !c.Address.Contains("RETAIL")
            && !c.Address.Contains("STORE")
            orderby c.ShipTo descending, c.OrderDate descending
            select c;

var query2 = from o in Orders
         where o.CustomerId == customerId
         && !o.OrderType.Equals("A")
         select o.OrderId;

var query3 = (from o in Orders
         from c in CustomerShip
         where c.CustomerId == customerId
         && c.ShipSeq == o.CustShip
         && !o.OrderStatus.Equals("A")
         select c.ShipSeq).Distinct();

Now I'm trying to assemble them all into one query, but unsure how to do it. Here is the direction I am going:

var query = from c in CustomerShip

let subquery = from o in Orders
               where o.CustomerId == customerId
               && !o.OrderType.Equals("A")
               select o.OrderId

    from or in model.Orders
    where subquery.Contains(or.OrderId)
    && c.CustomerId == customerId
    && c.ShipSeq == or.CustShip
    && !or.OrderStatus.Equals("A")
    group c by c.ShipSeq
    into i
    select c.ShipSeq

where c.CustomerId == customerId
&& !c.Address.Contains("RETAIL")
&& !c.Address.Contains("STORE")
orderby c.ShipTo descending, c.OrderDate descending
select c, i;

UPDATE

I have a query that kinds works, but the it takes almost two minutes to execute (compared to .02s for the Oracle query) and the order of the results is incorrect. Anyone see what I'm missing?

var innerQuery = from x in model.Orders
                    where x.CustomerId == customerId
                    && !x.OrderType.Equals("A")
                    select x.OrderId;

var result = from c in model.CustomerShip
            join subQuery in
            (
                (from o in model.Orders
                from c in model.CustomerShip
                where c.CustomerId == customerId
                && innerQuery.Contains(o.OrderId)
                && !o.FLAG_ORD_STATUS.Equals("C")
                && c.ShipSeq == o.CustShip
                select c.ShipSeq).Distinct()

            ) on c.ShipSeq equals subQuery into temp
            from x in temp.DefaultIfEmpty()
            where c.CustomerId == customerId
            && !c.Address.Contains("RETAIL")
            && !c.Address.Contains("STORE")
            orderby c.ShipTo descending, c.OrderDate descending
            select c;

Body:
Remember that you are just build a query here.  Nothing is executed until you do a ToList() or .FirstOrDefault() or whatever.  SO, you can use the queries in other queries, and it will create one big SQL statement when executed.

var query2 = from o in Orders
             where o.CustomerId == customerId
             && !o.OrderType.Equals("A")
             select o.OrderId;

var query3 = (from o in Orders
              join c in CustomerShip on o.CustShip equals c.ShipSeq
              where c.CustomerId == customerId
              && !o.OrderStatus.Equals("A")
              && query2.Contains(o.OrderId)
              select c.ShipSeq).Distinct();

var query1 = from c in CustomerShip
             from i in query3
             where c.CustomerId == customerId
             && !c.Address.Contains("RETAIL")
             && !c.Address.Contains("STORE")
             && c.ShipSeq == i.ShipSeq
             orderby c.ShipTo descending, c.OrderDate descending
             select c;

However, I'm pretty sure you can reduce query2 and query3 down to just:

var query3 = (from o in Orders
              join c in CustomerShip on o.CustShip equals c.ShipSeq
              where c.CustomerId == customerId
              && !o.OrderStatus.Equals("A")
              && !o.OrderType.Equals("A")
              select c.ShipSeq).Distinct();


问:
How do I make these three aligning divs responsive?
On my website home page (https://abbaproperty.000webhostapp.com/) I have three divs inline that look like this:

But when viewed on a slightly smaller scree (not mobile), it looks like this:

They're no longer the same height. Although I have added some responsive CSS so it does look like this on a smaller mobile device.

So my question here is that there is a sweet spot where these divs are not displayed very well responsively and I can't think of even the logical CSS to get around this.

HTML:

```<code><div class="container" style="width:100%; background-color:#205ba0; padding:30px;">

    <div class="col-md-offset-3 col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
        <div class="trip" style="background-color:white; margin-bottom:10px; padding-bottom:5px;">
            <img src="https://abbaproperty.000webhostapp.com/wp-content/uploads/2017/05/rent.png" style="height:100px;">
        </div>
        <h2 style="font-weight:bold;">Renting? Landlords welcome.</h2>
        A swift liason between landlords and tenants as a fair, independeant party, is just one of our services.<br><br>
        <a href="https://abbaproperty.000webhostapp.com/index.php/property-management/" style="color:white;">Find out more ></a>
    </div>

    <div class="col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
        <div class="trip" style="background-color:white; margin-bottom:15px;">
            <img src="https://abbaproperty.000webhostapp.com/wp-content/uploads/2017/05/val.png" style="height:100px;">
        </div>
        <h2 style="font-weight:bold;">Valuation? Sorted quickly.</h2>
        Providing some of the most effecient valuations in town, we're here to help you sort out an important step.<br><br>
        <a href="https://abbaproperty.000webhostapp.com/index.php/valuations/" style="color:white;">Find out more ></a>
    </div>

    <div class="col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
        <div class="trip" style="background-color:white; margin-bottom:10px; padding-bottom:5px;">
            <img src="https://abbaproperty.000webhostapp.com/wp-content/uploads/2017/05/sale.png" style="height:100px;">
        </div>
        <h2 style="font-weight:bold;">Selling? Now uncomplicated.</h2>
        We aim to make selling easy. Our trained estate agents are constantly available to help.<br><br>
        <a href="https://abbaproperty.000webhostapp.com/index.php/sell/" style="color:white;">Find out more ></a>
    </div>

</div>
</code>```

答:
You should use flexbox and media queries

CSS:

```<code>.container > div {
    display: block;
}

@media (min-width: 640px) {
    .container {
        display: flex;
    }
    .container > div {
        flex: 1 1 auto;
    }
}
</code>```

With flexbox all of the container children will be equal height.

CSS tricks tutorial: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Body:
On my website home page (https://abbaproperty.000webhostapp.com/) I have three divs inline that look like this:

But when viewed on a slightly smaller scree (not mobile), it looks like this:

They're no longer the same height. Although I have added some responsive CSS so it does look like this on a smaller mobile device.

So my question here is that there is a sweet spot where these divs are not displayed very well responsively and I can't think of even the logical CSS to get around this.

HTML:

Renting? Landlords welcome.

        A swift liason between landlords and tenants as a fair, independeant party, is just one of our services.

        Find out more >

Valuation? Sorted quickly.

        Providing some of the most effecient valuations in town, we're here to help you sort out an important step.

        Find out more >

Selling? Now uncomplicated.

        We aim to make selling easy. Our trained estate agents are constantly available to help.

        Find out more >

Body:
You should use flexbox and media queries

CSS:

.container > div {
    display: block;
}

@media (min-width: 640px) {
    .container {
        display: flex;
    }
    .container > div {
        flex: 1 1 auto;
    }
}

With flexbox all of the container children will be equal height.

CSS tricks tutorial: https://css-tricks.com/snippets/css/a-guide-to-flexbox/


问:
How to trace source of $watch model updates in AngularJS?
In my multi-user AngularJS app, I have a model object on my scope. This model can be manipulated by both user input and server updates.

I have a $watch observer to track the model and update the UI. Is it possible to determine the source/reason of my model update from within my $watch function? Without that check, I have problems with feedback loops (e.g. UI→Server→UI).

UPDATE: some code

Controller:

```<code>$scope.elementProperties = { left: 0 };

$scope.$watch('elementProperties.left', function(newVal, oldVal) { changeSelectedElementProperty('left', newVal, oldVal); } );
</code>```

Directive:

```<code>angular.module('myapp.ui-editor').directive('myappPropertiesPanel', function () {
    return {
        templateUrl: 'views/ui-editor/myappPropertiesPanel.html',
        restrict: 'A',
        scope: { elementProperties: '=' },

        link: function postLink (scope, element, attrs) {
            scope.$watch('elementProperties.left', function(newVal, oldVal) { console.log('PropertiesPanel change left', newVal, oldVal); } );
        }
    };
});
</code>```

答:
One way of achieving this is by using events instead of $watch

See working plunker here

In my plunker, I've put in a $interval that will simulate a web service call by changing the value every few seconds.

Here is what you can do.

In the then handler of your http call, before you set the new value retrieved from the web service to the model, publish an event with a payload containing the old value and the new value like below:

```<code>$http.get('url goes here')
 .then(function (response) {
     scope.$broadcast('UPDATE_FROM_SERVER',
                      {oldValue: scope.elementProperties.left, newValue: response.data.left});
     scope.elementProperties.left = response.data.left;
  };
</code>```

Then, in your form control, where the user will change the value, attach an ng-click like below:

```<code>ng-change="userChangeHandler(elementProperties.left, '{{elementProperties.left}}')
</code>```

Notice the quotes around '{{elementProperties.left}}'. This will ensure that the change handler function will get the old value of the property.

Now, you can listen to these change events like below:

```<code>  $scope.$on('UPDATE_FROM_SERVER', function (event, changes) {
    // This code will be invoked when the data is changed by the server
    $scope.messages.push('Data changed by Server from ' + changes.oldValue + ' to ' + changes.newValue);
  });

  $scope.$on('UPDATE_FROM_USER', function (event, changes) {
    // This code will be invoked when the data is changed by the user
    $scope.messages.push('Data changed by User from ' + changes.oldValue + ' to ' + changes.newValue);
  });
</code>```

Body:
In my multi-user AngularJS app, I have a model object on my scope. This model can be manipulated by both user input and server updates.

I have a $watch observer to track the model and update the UI. Is it possible to determine the source/reason of my model update from within my $watch function? Without that check, I have problems with feedback loops (e.g. UI→Server→UI).

UPDATE: some code

Controller:

$scope.elementProperties = { left: 0 };

$scope.$watch('elementProperties.left', function(newVal, oldVal) { changeSelectedElementProperty('left', newVal, oldVal); } );

Directive:

angular.module('myapp.ui-editor').directive('myappPropertiesPanel', function () {
    return {
        templateUrl: 'views/ui-editor/myappPropertiesPanel.html',
        restrict: 'A',
        scope: { elementProperties: '=' },

        link: function postLink (scope, element, attrs) {
            scope.$watch('elementProperties.left', function(newVal, oldVal) { console.log('PropertiesPanel change left', newVal, oldVal); } );
        }
    };
});

Body:
One way of achieving this is by using events instead of $watch

See working plunker here

In my plunker, I've put in a $interval that will simulate a web service call by changing the value every few seconds.

Here is what you can do.

In the then handler of your http call, before you set the new value retrieved from the web service to the model, publish an event with a payload containing the old value and the new value like below:

$http.get('url goes here')
 .then(function (response) {
     scope.$broadcast('UPDATE_FROM_SERVER',
                      {oldValue: scope.elementProperties.left, newValue: response.data.left});
     scope.elementProperties.left = response.data.left;
  };

Then, in your form control, where the user will change the value, attach an ng-click like below:

ng-change="userChangeHandler(elementProperties.left, '{{elementProperties.left}}')

Notice the quotes around '{{elementProperties.left}}'. This will ensure that the change handler function will get the old value of the property.

Now, you can listen to these change events like below:

  $scope.$on('UPDATE_FROM_SERVER', function (event, changes) {
    // This code will be invoked when the data is changed by the server
    $scope.messages.push('Data changed by Server from ' + changes.oldValue + ' to ' + changes.newValue);
  });

  $scope.$on('UPDATE_FROM_USER', function (event, changes) {
    // This code will be invoked when the data is changed by the user
    $scope.messages.push('Data changed by User from ' + changes.oldValue + ' to ' + changes.newValue);
  });