问:
How do I limit the number of rows returned by an Oracle query after ordering?
Is there a way to make an Oracle query behave like it contains a MySQL limit clause?

In MySQL, I can do this:

```<code>select *
from sometable
order by name
limit 20,10
</code>```

to get the 21st to the 30th rows (skip the first 20, give the next 10). The rows are selected after the order by, so it really starts on the 20th name alphabetically.

In Oracle, the only thing people mention is the rownum pseudo-column, but it is evaluated before order by, which means this:

```<code>select *
from sometable
where rownum <= 10
order by name
</code>```

will return a random set of ten rows ordered by name, which is not usually what I want. It also doesn't allow for specifying an offset.

答:
An analytic solution with only one nested query:

```<code>SELECT * FROM
(
   SELECT t.*, Row_Number() OVER (ORDER BY name) MyRow FROM sometable t
)
WHERE MyRow BETWEEN 10 AND 20;
</code>```

Rank() could be substituted for Row_Number() but might return more records than you are expecting if there are duplicate values for name.

OwnerDisplayName: Mathieu Longtin

Body:
Is there a way to make an Oracle query behave like it contains a MySQL limit clause?

In MySQL, I can do this:

select *
from sometable
order by name
limit 20,10

to get the 21st to the 30th rows (skip the first 20, give the next 10). The rows are selected after the order by, so it really starts on the 20th name alphabetically.

In Oracle, the only thing people mention is the rownum pseudo-column, but it is evaluated before order by, which means this:

select *
from sometable
where rownum <= 10
order by name

will return a random set of ten rows ordered by name, which is not usually what I want. It also doesn't allow for specifying an offset.

Body:
An analytic solution with only one nested query:

SELECT * FROM
(
   SELECT t.*, Row_Number() OVER (ORDER BY name) MyRow FROM sometable t
)
WHERE MyRow BETWEEN 10 AND 20;

Rank() could be substituted for Row_Number() but might return more records than you are expecting if there are duplicate values for name.

OwnerDisplayName: Leigh Riffel

LastEditorDisplayName: Leigh Riffel


来源: stackexchange

问:
Using XML Web Service with VB.Net
Ok! I just created a VB.Net project and added web reference for other company's XML web service. Let's name the web reference as "WebRef". They have provided the web service layout and there is a function named "GetServiceTicketList". It requires "UserID", "UserPassword", and "ServiceTicketNumber".

I am trying to get a service ticket list on datagrid with "GetServiceTicketList".

When I do this, then I get a error "Value of type '1-dimensional array of String' cannot be converted to 'String' from "ls_ParamValue"

```<code>Public Function GetTicketList(ByVal strXMLin As String) As String
   Dim results() As Object = Me.Invoke("GetServiceTicketList", New Object() {strXMLin})
   Return CType(results(0),String)
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  Dim Client As WebRef.service1 = New WebRef.service1
  Dim XMLResoponse As String
  Dim UserId As String = "SuperMan"
  Dim UserPW As String = "Batman"
  Dim Version As String = "1234"
  Dim ls_ParamValue As String()
  ls_ParamValue = {UserId, UserPW, Version}
  XMLResoponse = Client.GetServiceTicketList(ls_ParamValue)

End Sub
</code>```

答: The method is declared to take a single string as a parameter. You are passing it an array of strings.</p>

ContentLicense: CC BY-SA 2.5

Title: Using XML Web Service with VB.Net

Body:
Ok! I just created a VB.Net project and added web reference for other company's XML web service. Let's name the web reference as "WebRef". They have provided the web service layout and there is a function named "GetServiceTicketList". It requires "UserID", "UserPassword", and "ServiceTicketNumber".

I am trying to get a service ticket list on datagrid with "GetServiceTicketList".

When I do this, then I get a error "Value of type '1-dimensional array of String' cannot be converted to 'String' from "ls_ParamValue"

Public Function GetTicketList(ByVal strXMLin As String) As String
   Dim results() As Object = Me.Invoke("GetServiceTicketList", New Object() {strXMLin})
   Return CType(results(0),String)
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  Dim Client As WebRef.service1 = New WebRef.service1
  Dim XMLResoponse As String
  Dim UserId As String = "SuperMan"
  Dim UserPW As String = "Batman"
  Dim Version As String = "1234"
  Dim ls_ParamValue As String()
  ls_ParamValue = {UserId, UserPW, Version}
  XMLResoponse = Client.GetServiceTicketList(ls_ParamValue)

End Sub


问:
I need to run database load test, each time a different user has to login
I need to run database load test, each time a different user has to login and execute the same query. Is there a way the jdbc configuration can be read from a csv file?

I have a JDBC sampler with one query. But i need to run 100 iterations of the query execution, but each time, the database credentials needs to be read from a csv file.

In the JDBC Configuration, the database url will stay the same, but each iteration should take database username and password from the csv file.

答:
There are 2 options on how you can proceed:

Create 100 JDBC Connection Configuration elements and assign different Variable Names to them. As per documentation:

The name of the variable the connection is tied to. Multiple connections can be used, each tied to a different variable, allowing JDBC Samplers to select the appropriate connection.

So you will be able to switch Variable Name in the JDBC Request sampler according to your test scenario use cases.

Switch to JSR223 Sampler where you can use different credentials for each request.

Groovy: SQL

Groovy: Working with a relational database

Apache Groovy - Why and How You Should Use It

ContentLicense: CC BY-SA 3.0


问:
com.gluonhq.charm.glisten.control.TextField does not exist
I'm using scene builder to create an user interface which uses com.gluonhq.charm.glisten.control.TextField. It works properly in the Scene Builder and it's preview.

But in the NetBeans editor I get the class does not exist error.

When I try to run the application, I get the following runtime error.

```<code>Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.TextField
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
    at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
    ... 60 more
</code>```

I used the Library manager in Scene Builder to install com.gluonhq:charm repository. But I still get those errors. Any suggestion will be highly appreciated.

答:
you can download the repo from:
http://nexus.gluonhq.com/nexus/content/repositories/releases/com/gluonhq/charm-glisten/4.4.1/

If you add this as a library in your JavaFX application and reference it with an import in the FXMLDocumentController:

```<code>import com.gluonhq.charm.glisten.control.ProgressBar;
import com.gluonhq.charm.glisten.control.ProgressIndicator;
import com.gluonhq.charm.glisten.control.TextField;
</code>```

And ofcourse the link to the FXML file:

```<code>@FXML
private ProgressIndicator progress;
@FXML
private ProgressBar progressbar;
@FXML
private TextField textfield;
</code>```

in the FXML file:

```<code><?import com.gluonhq.charm.glisten.control.ProgressBar?>
<?import com.gluonhq.charm.glisten.control.ProgressIndicator?>
<?import com.gluonhq.charm.glisten.control.TextField?>
</code>```

and do not forget to set the fx:id:

```<code><ProgressIndicator fx:id="progress" layoutX="85.0" layoutY="14.0" opacity="0.75" prefHeight="132.0" prefWidth="137.0" progress="0.25" radius="75.0" />
<ProgressBar fx:id="progressbar" layoutX="16.0" layoutY="177.0" opacity="0.75" prefHeight="18.0" prefWidth="288.0" progress="0.75" />
<TextField fx:id="textfield" layoutX="118.0" layoutY="80.0" prefHeight="27.0" prefWidth="92.0" />
</code>```

It should work (works fine with me =^)

see for more info:

http://docs.gluonhq.com/charm/javadoc/4.3.5/index.html?com/gluonhq/charm/glisten/control/TextField.html

Body:
I'm using scene builder to create an user interface which uses com.gluonhq.charm.glisten.control.TextField. It works properly in the Scene Builder and it's preview.

But in the NetBeans editor I get the class does not exist error.

When I try to run the application, I get the following runtime error.

Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.TextField
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
    at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
    ... 60 more

I used the Library manager in Scene Builder to install com.gluonhq:charm repository. But I still get those errors. Any suggestion will be highly appreciated.

Body:
you can download the repo from:
http://nexus.gluonhq.com/nexus/content/repositories/releases/com/gluonhq/charm-glisten/4.4.1/

If you add this as a library in your JavaFX application and reference it with an import in the FXMLDocumentController:

import com.gluonhq.charm.glisten.control.ProgressBar;
import com.gluonhq.charm.glisten.control.ProgressIndicator;
import com.gluonhq.charm.glisten.control.TextField;

And ofcourse the link to the FXML file:

@FXML
private ProgressIndicator progress;
@FXML
private ProgressBar progressbar;
@FXML
private TextField textfield;

in the FXML file:

<?import com.gluonhq.charm.glisten.control.ProgressBar?>
<?import com.gluonhq.charm.glisten.control.ProgressIndicator?>
<?import com.gluonhq.charm.glisten.control.TextField?>

and do not forget to set the fx:id:

<ProgressIndicator fx:id="progress" layoutX="85.0" layoutY="14.0" opacity="0.75" prefHeight="132.0" prefWidth="137.0" progress="0.25" radius="75.0" />
<ProgressBar fx:id="progressbar" layoutX="16.0" layoutY="177.0" opacity="0.75" prefHeight="18.0" prefWidth="288.0" progress="0.75" />
<TextField fx:id="textfield" layoutX="118.0" layoutY="80.0" prefHeight="27.0" prefWidth="92.0" />

It should work (works fine with me =^)

see for more info:

http://docs.gluonhq.com/charm/javadoc/4.3.5/index.html?com/gluonhq/charm/glisten/control/TextField.html


问:
PHP Simple HTML DOM Parser returning false on valid url
I'm trying the following:

```<code>$url = 'https://www.tripadvisor.es/Hotels-g187514-Madrid-Hotels.html'

$ta_html = file_get_html($url);
var_dump($ta_html);
</code>```

it returns false, this is working and correctly getting the html for:

```<code>$url = 'https://www.tripadvisor.es/Hotels-g294316-Lima_Lima_Region-Hotels.html#ACCOM_OVERVIEW'
</code>```

My first thought was that it had a redirect but I checked the headers with curl and its 200 ok and it seemed like the same on both cases. What can be happening? how it can be solved?

This seems to be a duplicate of this problem:
 Simple HTML DOM returning false that is also unanswered

答:
It looks like this is happening because of this check in simple_html_dom.php in the file_get_html() function

```<code>if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
    return false;
}
</code>```

It might be that the length of the content is greater than the MAX_FILE_SIZE

Body:
I'm trying the following:

$url = 'https://www.tripadvisor.es/Hotels-g187514-Madrid-Hotels.html'

$ta_html = file_get_html($url);
var_dump($ta_html);

it returns false, this is working and correctly getting the html for:

$url = 'https://www.tripadvisor.es/Hotels-g294316-Lima_Lima_Region-Hotels.html#ACCOM_OVERVIEW'

My first thought was that it had a redirect but I checked the headers with curl and its 200 ok and it seemed like the same on both cases. What can be happening? how it can be solved?

This seems to be a duplicate of this problem:
 Simple HTML DOM returning false that is also unanswered

Body:
It looks like this is happening because of this check in simple_html_dom.php in the file_get_html() function

if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
    return false;
}

It might be that the length of the content is greater than the MAX_FILE_SIZE


问:
Apache FOP in a Java Applet - No ImagePreloader found for data
I'm looking at an issue in a mature commercial product.

In a nutshell, we are using part of the Apache POI library to read in a Word .DOC or .DOCX file, and convert it into XSL-FO so that we can do token replacements.  We then use FOP – embedded into the Java program - to convert the FO data into a PDF for printing.  The catch is, all this is being done on the client inside a Java applet running inside Internet Explorer.

Originally we were using FOP 0.93, which worked reasonably well.  However, it was not able to utilise the fonts inside the DOC file when generating the PDF and would map everything to Times, which one of the customers did not like.  In theory it could be made to work by adding some kind of font metrics data, but that would require a relatively complex definition for every font it was likely to encounter and we can’t predict what the client is liable to use outside of the MS core fonts set.

To fix this, FOP was upgraded to 1.0, which added support for autodetecting the fonts from the operating system.  This worked, but we noticed that the image processing had stopped working and the letterheads had disappeared.
What appears to have happened is that the image loader inside FOP was rewritten at some point between 0.93 and 0.95 so that instead of using Jimi and JAI it now uses ImageIO.  The earlier implementation worked fine, but the new code doesn’t like being run as an applet.

Images are embedded in URIs in the FO data so we get an error like this:
2014-09-30 17:00:10,607 ERROR [org.apache.fop.apps.FOUserAgent] Image not available. URI:
data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAABSCAIAAABysmn6AAA...
...ggg==. Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAABSCAIAAABysmn6AAAA...

When run through a test harness, the correct output is generated, but when run as an applet inside the browser we get the above error which makes me suspect that the browser applet security is jamming the ImageIO plugin loader somehow.

The guts of the FOP transformation, i.e. the bit which is triggering the error is this:

```<code>// Step 4: Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

transformer.transform(src, res);
</code>```

...which is all being run inside a PrivilegedAction block since in FOP 1.0 it needed file I/O access to manage the font cache.

Running the standalone FOP 0.93 and 1.0 programs under linux and using strace shows that it is writing out temporary files for the image data, but both 0.93 and 1.0 do similar things, so it shouldn’t be that by itself, especially since it should have permission to create temp files already.

I've tried different versions of the JRE since some builds a few years back apparently had security issues with the ImageIO library, but to no avail.

Any ideas?

Thanks,

答:
Just been struggling with this one. If you're using the maven-shade-plugin to create an uber jar, use the ServicesResourceTransformer to merge all the services configuration:

```<code><plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>2.2</version>
  <executions>
    <execution>
      <!-- snip -->
      <configuration>
        <transformers>
          <!-- snip -->
          <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
        </transformers>
      </configuration>
    </execution>
  </executions>
</plugin>
</code>```

Body:
I'm looking at an issue in a mature commercial product.

In a nutshell, we are using part of the Apache POI library to read in a Word .DOC or .DOCX file, and convert it into XSL-FO so that we can do token replacements.  We then use FOP – embedded into the Java program - to convert the FO data into a PDF for printing.  The catch is, all this is being done on the client inside a Java applet running inside Internet Explorer.

Originally we were using FOP 0.93, which worked reasonably well.  However, it was not able to utilise the fonts inside the DOC file when generating the PDF and would map everything to Times, which one of the customers did not like.  In theory it could be made to work by adding some kind of font metrics data, but that would require a relatively complex definition for every font it was likely to encounter and we can’t predict what the client is liable to use outside of the MS core fonts set.

To fix this, FOP was upgraded to 1.0, which added support for autodetecting the fonts from the operating system.  This worked, but we noticed that the image processing had stopped working and the letterheads had disappeared.
What appears to have happened is that the image loader inside FOP was rewritten at some point between 0.93 and 0.95 so that instead of using Jimi and JAI it now uses ImageIO.  The earlier implementation worked fine, but the new code doesn’t like being run as an applet.

Images are embedded in URIs in the FO data so we get an error like this:
2014-09-30 17:00:10,607 ERROR [org.apache.fop.apps.FOUserAgent] Image not available. URI:
data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAABSCAIAAABysmn6AAA...
...ggg==. Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAABSCAIAAABysmn6AAAA...

When run through a test harness, the correct output is generated, but when run as an applet inside the browser we get the above error which makes me suspect that the browser applet security is jamming the ImageIO plugin loader somehow.

The guts of the FOP transformation, i.e. the bit which is triggering the error is this:

// Step 4: Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

transformer.transform(src, res);

...which is all being run inside a PrivilegedAction block since in FOP 1.0 it needed file I/O access to manage the font cache.

Running the standalone FOP 0.93 and 1.0 programs under linux and using strace shows that it is writing out temporary files for the image data, but both 0.93 and 1.0 do similar things, so it shouldn’t be that by itself, especially since it should have permission to create temp files already.

I've tried different versions of the JRE since some builds a few years back apparently had security issues with the ImageIO library, but to no avail.

Any ideas?

Thanks,

Body:
Just been struggling with this one. If you're using the maven-shade-plugin to create an uber jar, use the ServicesResourceTransformer to merge all the services configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>2.2</version>
  <executions>
    <execution>
      <!-- snip -->
      <configuration>
        <transformers>
          <!-- snip -->
          <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
        </transformers>
      </configuration>
    </execution>
  </executions>
</plugin>


问:
Remove "sysadmin@thingsboard.org'" from the database to install Thingsboard
I am trying to install Thingsboard on Windows 10. But I get the error: "org.thingsboard.server.dao.exception.DataValidationException: User with email 'sysadmin@thingsboard.org'  already present in database!"

Would anyone please help me to resolve this problem?

Thank you.

答:
i had same problem and fixed it with this method:
Delete thingsboard folder and registry keys.
Install again.</p>


问:
Why does SQL Server say this is wrong?
I have the table "User"

```<code>id         int
username   varchar(40)
joindate   date
email      varchar(60)
password   nvarchar(100)
</code>```

I want to execute the following query

```<code>INSERT INTO User (username, joinDate, email, password)
VALUES ('Kristian', '15/11/2017', 'foo@outlook.com', 'password')
</code>```

SQL Server 2014 throws an error

Incorrect syntax near keyword 'User'

What am I doing wrong?

答:
You are getting the error because of the following

User (as well as Password) is a system defined keyword. So while using it for any tables names or column names - which is not recommended - you should specify them inside square brackets

You are giving the date time as DD/MM/YYYY format. Change that to MM/DD/YYYY.

I changed the query as below and it works for me

```<code>INSERT INTO [User] (username, joinDate, email, [password])
VALUES ('Kristian', '11/15/2017', 'foo@outlook.com', 'password')
</code>```

Title: Why does SQL Server say this is wrong?

Body:
I have the table "User"

id         int
username   varchar(40)
joindate   date
email      varchar(60)
password   nvarchar(100)

I want to execute the following query

INSERT INTO User (username, joinDate, email, password)
VALUES ('Kristian', '15/11/2017', 'foo@outlook.com', 'password')

SQL Server 2014 throws an error

Incorrect syntax near keyword 'User'

What am I doing wrong?

Body:
You are getting the error because of the following

User (as well as Password) is a system defined keyword. So while using it for any tables names or column names - which is not recommended - you should specify them inside square brackets

You are giving the date time as DD/MM/YYYY format. Change that to MM/DD/YYYY.

I changed the query as below and it works for me

INSERT INTO [User] (username, joinDate, email, [password])
VALUES ('Kristian', '11/15/2017', 'foo@outlook.com', 'password')


问:
Remove commas in list and make a sentence with list items
So basically I have a list with 4 items.

```<code>list = ['My', 'name', 'is', 'mike']
</code>```

What I want to do is to remove the commas that split the items and make one string. The removed commas should be replaced with space. What I have seen so far is the replace method for string's. I have been wondering if there is something similar for lists.

答:
You could join the items of your list using a whitespace ' ' as the separator

```<code>list = ['My', 'name', 'is', 'mike']
oneString = ' '.join(list)
</code>```

This question has already been asked and answered in more detail here Concatenate item in list to strings .

Body:
So basically I have a list with 4 items.

list = ['My', 'name', 'is', 'mike']

What I want to do is to remove the commas that split the items and make one string. The removed commas should be replaced with space. What I have seen so far is the replace method for string's. I have been wondering if there is something similar for lists.

Body:
You could join the items of your list using a whitespace ' ' as the separator

list = ['My', 'name', 'is', 'mike']
oneString = ' '.join(list)

This question has already been asked and answered in more detail here Concatenate item in list to strings .


问:
Select, default value in AngularJS
Hey I have problem with set default value in select problem is started when I set inside array objects. How can I fix this problem??

HTML

```<code><div ng-app="select" ng-controller="checking">
  <select ng-model="lala" ng-options="item.name for item in arrayName">
  </select>
</div>
</code>```

JavaScript

```<code>var app = angular.module('select', []);

app.controller('checking', ($scope)=> {
  $scope.arrayName = [{'name':'first'}, {'name':'second'}, {'name':'third'}];
  $scope.lala = "first";
});
</code>```

https://codepen.io/Turqus/pen/EbvGzv?editors=1111

答:
All you need to do is change your ng-options to include a select as

```<code><select ng-model="lala" ng-options="item.name as item.name for item in arrayName">
</code>```

var app = angular.module('select', []);

app.controller('checking', function($scope) {
  $scope.arrayName = [{
    'name': 'first'
  }, {
    'name': 'second'
  }, {
    'name': 'third'
  }];

  $scope.lala = 'first';

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="select" ng-controller="checking">

  <select ng-model="lala" ng-options="item.name as item.name for item in arrayName"></select>

  <p>Value of lala: <b>{{lala}}</b></p>

</div></code>```

Title: Select, default value in AngularJS

Body:
Hey I have problem with set default value in select problem is started when I set inside array objects. How can I fix this problem??

HTML

  <select ng-model="lala" ng-options="item.name for item in arrayName">
  </select>

JavaScript

var app = angular.module('select', []);

app.controller('checking', ($scope)=> {
  $scope.arrayName = [{'name':'first'}, {'name':'second'}, {'name':'third'}];
  $scope.lala = "first";
});

https://codepen.io/Turqus/pen/EbvGzv?editors=1111

Body:
All you need to do is change your ng-options to include a select as

<select ng-model="lala" ng-options="item.name as item.name for item in arrayName">

var app = angular.module('select', []);

app.controller('checking', function($scope) {
  $scope.arrayName = [{
    'name': 'first'
  }, {
    'name': 'second'
  }, {
    'name': 'third'
  }];

  $scope.lala = 'first';

});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="select" ng-controller="checking">

  <select ng-model="lala" ng-options="item.name as item.name for item in arrayName"></select>

  <p>Value of lala: <b>{{lala}}</b></p>

</div>


问:
$.parseJSON(data).shift is not a function
i have to parsing json data get from $post method

```<code>$.post( "vehicle_route_qry.php",function(data) {

    siteshistory = $.parseJSON(data);
    siteshistory.shift();
    draw_route(siteshistory);
    $("#dev_det_spin").hide();

});
</code>```

my php file

```<code>$myJSON = '{ "name":"John", "age":31, "city":"New York" }';
echo json_encode($myJSON);
</code>```

i am getting json properly in my response
but getting this issue

```<code>siteshistory.shift is not a function
</code>```

i have loaded following js files

```<code><script src="js/function.js"></script>
<script src="js/jquery.min.js"></script>
<script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDaL0ieAkLhzy1rDoLifajeowdXPwTvzmI"></script>
<!-- <script type="text/javascript" src="js/date.js"></script> -->
<script type="text/javascript" src="js/loader.js"></script>
<script type="text/javascript" src="js/header_function.js"></script>
</code>```

but shift function for  $.parseJSON(data).shift() is not working
i am not able to find any reference regarding shift function

suggestion would be helpful

答:
Check this:

```<code>https://developer.mozilla.org/tr/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
</code>```

Your json should be an array, should not be an object to execute shift().

You can refer this question to translate object to array in JS :

https://stackoverflow.com/questions/6857468/converting-a-js-object-to-an-array-using-jquery

Body:
i have to parsing json data get from $post method

$.post( "vehicle_route_qry.php",function(data) {

    siteshistory = $.parseJSON(data);
    siteshistory.shift();
    draw_route(siteshistory);
    $("#dev_det_spin").hide();

});

my php file

$myJSON = '{ "name":"John", "age":31, "city":"New York" }';
echo json_encode($myJSON);

i am getting json properly in my response
but getting this issue

siteshistory.shift is not a function

i have loaded following js files

but shift function for  $.parseJSON(data).shift() is not working
i am not able to find any reference regarding shift function

suggestion would be helpful

Body:
Check this:

https://developer.mozilla.org/tr/docs/Web/JavaScript/Reference/Global_Objects/Array/shift

Your json should be an array, should not be an object to execute shift().

You can refer this question to translate object to array in JS :

https://stackoverflow.com/questions/6857468/converting-a-js-object-to-an-array-using-jquery


问:
How to make tkinter button raised before executing command
Am trying to make GUI app which compulsory you have to select one of predict button before the number entered will be printed to the terminal,if none of predictbutton is selected the should print outselect predict button to proceed.

In pseudecode something like:

```<code>def check:
    now = new.get()
    if no lotto_button is selected:
        print("select predict button to proceed")
    else:
        print(now)
</code>```

But having  challenges:

1:when i select one predict button both buttons raised.

2:How to make the predict compulsory to be selected before the content in the entry will  be printed.

```<code>import tkinter as tk

def terminal():
    now = new.get()
    print(now)

def start_func():
    lotto_button.configure(relief=tk.SUNKEN, state=tk.DISABLED)
    lotto_button1.configure(relief=tk.SUNKEN, state=tk.DISABLED)

def stop_func():
    lotto_button.configure(relief=tk.RAISED, state=tk.ACTIVE)
    lotto_button1.configure(relief=tk.RAISED, state=tk.ACTIVE)

root = tk.Tk()
root.geometry("400x400")

new = tk.StringVar()
en = tk.Entry(root, textvariable=new).pack()

lotto_button = tk.Button(root, text="predict one", command=start_func)
lotto_button.pack(side="left")
lotto_button1 = tk.Button(root, text="predict two", command=start_func)
lotto_button1.pack()

tk.Button(root, text="print number", command=lambda :[stop_func(),
terminal()]).place(x=150, y=300)

root.mainloop()
</code>```

Thank you and your advice to do is welcome.

答:
Using Radiobutton widgets tends to be better for this sort of multiple choice processing.

Radiobuttons belong to "groups" which means that you can set them up so that one always needs to be selected by default. This means that you don't need to have any kind of error catching or display any sort of instruction to the user, it just intuitively works.

```<code>from tkinter import *

root = Tk()

def command(v, entry):
    print(v.get(), entry.get())

v = StringVar()
v.set(1)

entry = Entry(root)
rb1 = Radiobutton(root, text="Predict One", variable=v, value=1, indicatoron=0)
rb2 = Radiobutton(root, text="Predict Two", variable=v, value=2, indicatoron=0)
button = Button(root, text="Print Number", command=lambda:command(v, entry))

entry.pack()
rb1.pack()
rb2.pack()
button.pack()

root.mainloop()
</code>```

So we create a StringVar() which we use to define which Radiobutton widgets should be linked together and then we set it's value to 1 which is the value of the "Predict One" button. If the user presses the other Radiobutton then the value changes to 2 which means the first button "unpresses" and the value of the StringVar() is changed to 2.

Body:
Am trying to make GUI app which compulsory you have to select one of predict button before the number entered will be printed to the terminal,if none of predictbutton is selected the should print outselect predict button to proceed.

In pseudecode something like:

def check:
    now = new.get()
    if no lotto_button is selected:
        print("select predict button to proceed")
    else:
        print(now)

But having  challenges:

1:when i select one predict button both buttons raised.

2:How to make the predict compulsory to be selected before the content in the entry will  be printed.

import tkinter as tk

def terminal():
    now = new.get()
    print(now)

def start_func():
    lotto_button.configure(relief=tk.SUNKEN, state=tk.DISABLED)
    lotto_button1.configure(relief=tk.SUNKEN, state=tk.DISABLED)

def stop_func():
    lotto_button.configure(relief=tk.RAISED, state=tk.ACTIVE)
    lotto_button1.configure(relief=tk.RAISED, state=tk.ACTIVE)

root = tk.Tk()
root.geometry("400x400")

new = tk.StringVar()
en = tk.Entry(root, textvariable=new).pack()

lotto_button = tk.Button(root, text="predict one", command=start_func)
lotto_button.pack(side="left")
lotto_button1 = tk.Button(root, text="predict two", command=start_func)
lotto_button1.pack()

tk.Button(root, text="print number", command=lambda :[stop_func(),
terminal()]).place(x=150, y=300)

root.mainloop()

Thank you and your advice to do is welcome.

Body:
Using Radiobutton widgets tends to be better for this sort of multiple choice processing.

Radiobuttons belong to "groups" which means that you can set them up so that one always needs to be selected by default. This means that you don't need to have any kind of error catching or display any sort of instruction to the user, it just intuitively works.

from tkinter import *

root = Tk()

def command(v, entry):
    print(v.get(), entry.get())

v = StringVar()
v.set(1)

entry = Entry(root)
rb1 = Radiobutton(root, text="Predict One", variable=v, value=1, indicatoron=0)
rb2 = Radiobutton(root, text="Predict Two", variable=v, value=2, indicatoron=0)
button = Button(root, text="Print Number", command=lambda:command(v, entry))

entry.pack()
rb1.pack()
rb2.pack()
button.pack()

root.mainloop()

So we create a StringVar() which we use to define which Radiobutton widgets should be linked together and then we set it's value to 1 which is the value of the "Predict One" button. If the user presses the other Radiobutton then the value changes to 2 which means the first button "unpresses" and the value of the StringVar() is changed to 2.


问:
Laravel Ajax request, Auth:login returns false! but user is logged in after refresh
I want to log users in with ajax request and after login in controller, redirect users to dashboard with javascript.

The Problem is when I use Auth:login($user) in controller, it returns false and my return line in controller is not reached.  when I refresh the page manually I see that user is logged in !!

Backend (pseudo code):

```<code>    $r = $request->all();
    $user = User::where('email', $r['email'])->first();

    Auth::login($user);  // this returns false

    return [  // this line is not reached
        'status' > 'success'
    ];
</code>```

Front End :

```<code>$.ajax({
       type: 'Post',
       url: '/login/js-login',
       data: user_data,
       success: function (res) {
        if (res.data.status == 'success') {
         toastr.success(" LoginSuccessfull!")
         window.location.replace("https://www.example.com");
      } else {
         toastr.error('Error Login!')
      }

      });
</code>```

答:
you can use loginUsingId:

```<code> $r = $request->all();
    $user = User::where('email', $r['email'])->first();
    if(isset($user)){
        Auth::loginUsingId($user->id);
        return ['status' => 'success'];
    }
    return ['status' => 'fail'];
</code>```

Body:
I want to log users in with ajax request and after login in controller, redirect users to dashboard with javascript.

The Problem is when I use Auth:login($user) in controller, it returns false and my return line in controller is not reached.  when I refresh the page manually I see that user is logged in !!

Backend (pseudo code):

    $r = $request->all();
    $user = User::where('email', $r['email'])->first();

    Auth::login($user);  // this returns false

    return [  // this line is not reached
        'status' > 'success'
    ];

Front End :

$.ajax({
       type: 'Post',
       url: '/login/js-login',
       data: user_data,
       success: function (res) {
        if (res.data.status == 'success') {
         toastr.success(" LoginSuccessfull!")
         window.location.replace("https://www.example.com");
      } else {
         toastr.error('Error Login!')
      }

      });

Body:
you can use loginUsingId:

 $r = $request->all();
    $user = User::where('email', $r['email'])->first();
    if(isset($user)){
        Auth::loginUsingId($user->id);
        return ['status' => 'success'];
    }
    return ['status' => 'fail'];


问:
Angular2 - How module is different from component?
In the below code from ../src/app/app.module.ts,

```<code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
</code>```

Component consists:

view(../src/app/app.component.html)

logic(../src/app/app.component.ts)

style(../src/app/app.component.css)

Angular application is a tree of components. Good components have high cohesion, i.e. each component contains only elements with related functionality. They are also well encapsulated and loosely coupled.

How modules are different from components?

答:
Module in angular is set of Components, Services, Filters, or some another smaller modules too, or we can say where you import all these in order to use later in the app for future use. in a single app there can be one or more than one module may exist.

Whereas, A component controls a patch of screen called a view.
You define a component's application logic—what it does to support the view—inside a class. The class interacts with the view through an API of properties and methods.

Refer this guide for more details:

https://angular.io/guide/architecture

Body:
In the below code from ../src/app/app.module.ts,

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';

Component consists:

view(../src/app/app.component.html)

logic(../src/app/app.component.ts)

style(../src/app/app.component.css)

Angular application is a tree of components. Good components have high cohesion, i.e. each component contains only elements with related functionality. They are also well encapsulated and loosely coupled.

How modules are different from components?


问:
Replace each occurrence of a char with an array element
I have a file with data :

```<code>bq --schema
corp:STRING,
region:STRING,
load_date_time:TIMESTAMP)
bq --schema
corp:STRING,
load_date_time:TIMESTAMP)
</code>```

and a String variable as :

```<code>table1

table2
</code>```

What i want to do is to replace ')' to an array element and the final output should look like :

```<code>bq --schema
corp:STRING,
region:STRING,
load_date_time:TIMESTAMP table1
bq --schema
corp:STRING,
load_date_time:TIMESTAMP table2
</code>```

The string variable is generated from below file :

```<code>CREATE TABLE UK_CHAIN_PARM_ADDL_FUNDING(
corp:STRING,
region:STRING,
prin:STRING,
assc:STRING,
chain:STRING,
acct_ind:STRING,
transit_nbr:INTEGER,
dda_nbr:STRING,
currency:STRING,
mask:STRING,
value_dt:INTEGER
)
CREATE TABLE UK_SUPPLEMENTAL_FUNDING(
merchant:STRING,
acct_ind:STRING,
transit_nbr:INTEGER,
dda_nbr:STRING,
currency:INTEGER,
mask:STRING,
value_dt:INTEGER,
beneficiary:STRING,
vbc_line_1:STRING
)

CREATE TABLE UK_REGION_PARM(
corp:STRING,
region:STRING,
end_point:STRING,
currency_code:STRING,
tax_id1:STRING,
tax_id2:STRING,
load_date_time:TIMESTAMP)
</code>```

for extracting just table names i have used below command
Tablenames=$(grep -i 'create table' $myfilename | awk -F ' '  'BEGIN{ORS="\n";}{print $3}' | tr "(" "\n")

So ultimately i want output in format

bq --schema "schema of the table" -t tablename

答:
Finally i found the answer. So instead of using the array i placed string values inside a file with new line separation.

The code i have written to achieve expected output :

```<code>while read line1
do
found=$(echo $line1 | grep -c ")")
if [ $found != 0 ];
then
while read line2
      do
           alreadycontainTable=$(grep -c "$line2" NewFileWithTableName.txt)
        if [ $alreadycontainTable == 0 ];
           then
           tableName=$(echo $line2)
           echo $line1 | sed -r "s/\)/ -t $tableName/" >> NewFileWithTableName.txt
          break;
        fi
            done < table.txt
else
           echo $line1 >> NewFileWithTableName.txt
fi
done < fileWithBrackets.txt
</code>```

Body:
I have a file with data :

bq --schema
corp:STRING,
region:STRING,
load_date_time:TIMESTAMP)
bq --schema
corp:STRING,
load_date_time:TIMESTAMP)

and a String variable as :

table1

table2

What i want to do is to replace ')' to an array element and the final output should look like :

bq --schema
corp:STRING,
region:STRING,
load_date_time:TIMESTAMP table1
bq --schema
corp:STRING,
load_date_time:TIMESTAMP table2

The string variable is generated from below file :

CREATE TABLE UK_CHAIN_PARM_ADDL_FUNDING(
corp:STRING,
region:STRING,
prin:STRING,
assc:STRING,
chain:STRING,
acct_ind:STRING,
transit_nbr:INTEGER,
dda_nbr:STRING,
currency:STRING,
mask:STRING,
value_dt:INTEGER
)
CREATE TABLE UK_SUPPLEMENTAL_FUNDING(
merchant:STRING,
acct_ind:STRING,
transit_nbr:INTEGER,
dda_nbr:STRING,
currency:INTEGER,
mask:STRING,
value_dt:INTEGER,
beneficiary:STRING,
vbc_line_1:STRING
)

CREATE TABLE UK_REGION_PARM(
corp:STRING,
region:STRING,
end_point:STRING,
currency_code:STRING,
tax_id1:STRING,
tax_id2:STRING,
load_date_time:TIMESTAMP)

for extracting just table names i have used below command
Tablenames=$(grep -i 'create table' $myfilename | awk -F ' '  'BEGIN{ORS="\n";}{print $3}' | tr "(" "\n")

So ultimately i want output in format

bq --schema "schema of the table" -t tablename

Body:
Finally i found the answer. So instead of using the array i placed string values inside a file with new line separation.

The code i have written to achieve expected output :

while read line1
do
found=$(echo $line1 | grep -c ")")
if [ $found != 0 ];
then
while read line2
      do
           alreadycontainTable=$(grep -c "$line2" NewFileWithTableName.txt)
        if [ $alreadycontainTable == 0 ];
           then
           tableName=$(echo $line2)
           echo $line1 | sed -r "s/\)/ -t $tableName/" >> NewFileWithTableName.txt
          break;
        fi
            done < table.txt
else
           echo $line1 >> NewFileWithTableName.txt
fi
done < fileWithBrackets.txt


问:
How to install apesmit python package?
I tried to install apesmit from PyPi ( pip install apesmit ). But I'm getting error Could not find a version that satisfies the requirement apesmit (from versions: )
No matching distribution found for apesmit
Could you help me to do this?

答:
I have followed these steps to install apesmith

sudo wget http://www.florian-diesch.de/software/apesmit/dist/apesmit-0.01.tar.gz

tar xzf apesmit-0.01.tar.gz.

sudo nano apesmit-0.01/distribute_setup.py
change DEFAULT_URL to "https://pypi.python.org/packages/source/d/distribute/" in distribute_setup.py

pip install /full path/apesmit-0.01

Title: How to install apesmit python package?


问:
How do you work out the IIS Virtual Path for an application?
When I try to change the ASP.NET version to v4 on IIS 6, I receive the following warning:

Changing the Framework version requires a restart of the W3SVC service. Alternatively, you can change the Framework version without restarting the W3SVC service by running: aspnet_regiis.exe -norestart -s IIS-Viirtual-Path

Do you want to continue (this will change the Framework version and restart the W3SVC service)?

How do I work out IIS-Virtual-Path?

I have tried the obvious paths i.e.:

aspnet_regiis.exe -norestart -s "/WebSites/Extranet/AppName"

Where WebSites is the name of the folder in IIS, Extranet the name of the root app and AppName the name of the Virtual Directory application I am trying to change.

Thanks!

Edit:

How do I work out the virtual path for the Auth virtual directory in following IIS6 setup:

(source: imgbag.com)

I have tried:

aspnet_regiis.exe -norestart -s "/Web Sites/Extranet/Auth"

aspnet_regiis.exe -norestart -s "Auth"

I get:

Installation stopped because the specified path (WhateverIPutIn) is invalid.

答:
To change Framework version without restarting W3SVC:
Run aspnet_regiis.exe -norestart -s IIS-Virtual-Path

aspnet_regiis.exe should be run from %SystemRoot%\Microsoft.NET\Framework(required dotnet version)
eg C:\WindowsMicrosoft.NET\Framework\v4.0.30319

IIS-Virtual-Path is: W3SVC/(WebsiteID)/root[/AppName] Where
(WebsiteID) is the identifier as listed in IIS  (see Diego C's image above) and
[/appname] is an optional virtual directory below your website. (eg W3SVC/1234567890/root/dotnetnuke)

Open a command prompt

Navigate (CD) to C:\WindowsMicrosoft.NET\Framework\v4.0.30319

Execute aspnet_regiis.exe -norestart -s “W3SVC/1234567890/root/dotnetnuke”

ContentLicense: CC BY-SA 4.0


问:
Connect to sql server windows authentication
I have a sql server instance ,

I can connect with sql autehntication

```<code>public static void main(String[] args) {
     Connection conn = null;
     String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
     String url = "jdbc:sqlserver://localhost:1434;databasename=Test;";
     String userName = "sa";
     String password = "paquito";
     Statement stmt;
     try{
       Class.forName(driver);//.newInstance();
       conn = DriverManager.getConnection(url,userName,password);
       stmt = conn.createStatement();
       System.out.println("conectado = ");
       conn.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
}
</code>```

but with windows authentication

```<code>public static void main(String[] args) {
     Connection conn = null;
     String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
     String url = "jdbc:sqlserver://localhost:1434;databasename=Test;integratedSecurity=true";
     String userName = "paco";
     String password = "";
     Statement stmt;
     try{
       Class.forName(driver);//.newInstance();
       conn = DriverManager.getConnection(url,userName,password);
       stmt = conn.createStatement();
       System.out.println("conectado = ");
       conn.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
}
</code>```

i take this error:

```<code>com.microsoft.sqlserver.jdbc.SQLServerException: Unable to open the "Test" database requested by the login. Login failed. Client connection ID: 577da72f-f0d4-4ac6-abab-243f0f84d0e3
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:279)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:99)
</code>```

NOTE: in sql management i can connect with sql authentication and windows authentication

suggestion?

答:
Don't specify a username, it will get this from the current user.

See https://www.connectionstrings.com/sql-server/ for more details.

Body:
I have a sql server instance ,

I can connect with sql autehntication

public static void main(String[] args) {
     Connection conn = null;
     String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
     String url = "jdbc:sqlserver://localhost:1434;databasename=Test;";
     String userName = "sa";
     String password = "paquito";
     Statement stmt;
     try{
       Class.forName(driver);//.newInstance();
       conn = DriverManager.getConnection(url,userName,password);
       stmt = conn.createStatement();
       System.out.println("conectado = ");
       conn.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
}

but with windows authentication

public static void main(String[] args) {
     Connection conn = null;
     String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
     String url = "jdbc:sqlserver://localhost:1434;databasename=Test;integratedSecurity=true";
     String userName = "paco";
     String password = "";
     Statement stmt;
     try{
       Class.forName(driver);//.newInstance();
       conn = DriverManager.getConnection(url,userName,password);
       stmt = conn.createStatement();
       System.out.println("conectado = ");
       conn.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
}

i take this error:

com.microsoft.sqlserver.jdbc.SQLServerException: Unable to open the "Test" database requested by the login. Login failed. Client connection ID: 577da72f-f0d4-4ac6-abab-243f0f84d0e3
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:279)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:99)

NOTE: in sql management i can connect with sql authentication and windows authentication

suggestion?


问:
Read html file as string in Powershell
I need to read a html file and parse the content to a string

From this

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Index</title>
</head>
<body>
    Index
</body>
</html>
</code>```

To an output like this

```<code>$stringValue = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"...
</code>```

I've tried with $stringValue = $htmlFile | ConvertTo-Json but it transforms some characters into new codes (> = u003e) where I want to keep the special characters intact.

Any help is appreciated

答:
Try to read it as UTF-16 and see if output is passed through as desired. This answer shows how to read it as UTF-16. </p>

<p>Reading a "string in little-endian UTF-16 encoding" with BinaryReader </p>

Title: Read html file as string in Powershell

Body:
I need to read a html file and parse the content to a string

From this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Index</title>

    Index

To an output like this

$stringValue = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"...

I've tried with $stringValue = $htmlFile | ConvertTo-Json but it transforms some characters into new codes (> = u003e) where I want to keep the special characters intact.

Any help is appreciated

Body:
Try to read it as UTF-16 and see if output is passed through as desired. This answer shows how to read it as UTF-16.

Reading a "string in little-endian UTF-16 encoding" with BinaryReader


问:
Output of gulp-sass is .scss files not css files
I'm trying to compile some .scss files into css using gulp. gulpfile.js:

```<code>var gulp = require("gulp");
var sass = require("gulp-sass");

gulp.task("sass",
function() {
    return gulp.src("app/assets/sass/*.scss")
     .pipe(sass({
                includePaths: [
                    "govuk_modules/govuk_frontend_toolkit/stylesheets/",
                    "govuk_modules/govuk_template/assets/stylesheet/",
                    "govuk_modules/govuk-elements-sass/"
         ]
        }).pipe(gulp.dest("./wwwroot/stylesheets/")));
});
</code>```

I'm using Visual Studio 2017 and when I run the sass task in task explorer, I get the expected files output into the destination folder, however, they are .scss files and not the expected .css files.

There are some 20+ files in total in the paths, and these do get compiled in to 4 files but like I say, are .scss not css.

Any ideas?

答:
OK, so I've found the problem. One of the SCSS files is referencing a path to another file which I've misspelled the path to!

Corrected and working now

Body:
I'm trying to compile some .scss files into css using gulp. gulpfile.js:

var gulp = require("gulp");
var sass = require("gulp-sass");

gulp.task("sass",
function() {
    return gulp.src("app/assets/sass/*.scss")
     .pipe(sass({
                includePaths: [
                    "govuk_modules/govuk_frontend_toolkit/stylesheets/",
                    "govuk_modules/govuk_template/assets/stylesheet/",
                    "govuk_modules/govuk-elements-sass/"
         ]
        }).pipe(gulp.dest("./wwwroot/stylesheets/")));
});

I'm using Visual Studio 2017 and when I run the sass task in task explorer, I get the expected files output into the destination folder, however, they are .scss files and not the expected .css files.

There are some 20+ files in total in the paths, and these do get compiled in to 4 files but like I say, are .scss not css.

Any ideas?


问:
Date formats in VBA from Text String
I have an issue with date formats that I cannot get my head around.

I have 2 dates a reporting date which the user inputs Format is MM/DD/YYYY Showing as (11/15/2017) on the speadsheet. This is input from a Userform asking just for the Month and Date but uses the current year.

I then have a series of codes which validates the Data Line matches the ReportDate and produces information. To get Data date I need to look in a text string find a the word PPP and get the numbers proceeding the @ symbol.

I get the day and month value separately as only the day/month is visible in this string and appears like this PPP@11/15

Below is an extract of my code but it is not the full script.

```<code>Dim Year1 As Variant
Dim Month1 As Variant
Dim Day1 As Variant

If Not IsError(Mid(PODRng, InStr(1, PODRng, "PPP", vbTextCompare) + 4, 5)) Then
Year1 = Format(Now(), "YYYY")
Month1 = Mid(PPPRng, InStr(1, PPPRng, "PPP", vbTextCompare) + 4, 2)
Day1 = Mid(PPPRng, InStr(1, PPPRng, "PPP", vbTextCompare) + 7, 2)
PPPTim = Day1 & "/" & Month1 & "/" & Year1
 'PPPTim.NumberFormat = "MM/DD/YYYY"

    If PPPTim = ReportDate Then

        Cell.Offset(0, 49).Value = PPPTim '
    ElseIf InStr(1, PODRng, "PPP", vbTextCompare) > 0 Then
        Cell.Offset(0, 49).Value = "Other Date"
    End If
</code>```

End If

The data source is roughly 3k-5k lines and I have gone through the code and breaking when it gets to this code. I can confirm when checking the Locals both PPPTim and ReportDate are showing as 15/11/2017 but the match is coming through as False.

Hopefully someone can help?

答:
Is this what you're looking for?

Dim podRNG As String, n1 As Integer, n2 As Integer, yourDate As Date

```<code>podRNG = "PPP@11/15"

n1 = InStr(podRNG, "@") + 1
n2 = InStr(podRNG, "/") + 1

PPPTim = CDate(Mid(podRNG, n1, n2 - n1 - 1) & "/" & Mid(podRNG, n2) & _
    "/" & Format(Now(), "YYYY"))
</code>```

Returns (on my system):

2017-11-15

...since the data type is Date, the date format will vary based on your Regional Settings.

Title: Date formats in VBA from Text String

Body:
I have an issue with date formats that I cannot get my head around.

I have 2 dates a reporting date which the user inputs Format is MM/DD/YYYY Showing as (11/15/2017) on the speadsheet. This is input from a Userform asking just for the Month and Date but uses the current year.

I then have a series of codes which validates the Data Line matches the ReportDate and produces information. To get Data date I need to look in a text string find a the word PPP and get the numbers proceeding the @ symbol.

I get the day and month value separately as only the day/month is visible in this string and appears like this PPP@11/15

Below is an extract of my code but it is not the full script.

Dim Year1 As Variant
Dim Month1 As Variant
Dim Day1 As Variant

If Not IsError(Mid(PODRng, InStr(1, PODRng, "PPP", vbTextCompare) + 4, 5)) Then
Year1 = Format(Now(), "YYYY")
Month1 = Mid(PPPRng, InStr(1, PPPRng, "PPP", vbTextCompare) + 4, 2)
Day1 = Mid(PPPRng, InStr(1, PPPRng, "PPP", vbTextCompare) + 7, 2)
PPPTim = Day1 & "/" & Month1 & "/" & Year1
 'PPPTim.NumberFormat = "MM/DD/YYYY"

    If PPPTim = ReportDate Then

        Cell.Offset(0, 49).Value = PPPTim '
    ElseIf InStr(1, PODRng, "PPP", vbTextCompare) > 0 Then
        Cell.Offset(0, 49).Value = "Other Date"
    End If

End If

The data source is roughly 3k-5k lines and I have gone through the code and breaking when it gets to this code. I can confirm when checking the Locals both PPPTim and ReportDate are showing as 15/11/2017 but the match is coming through as False.

Hopefully someone can help?

Body:
Is this what you're looking for?

Dim podRNG As String, n1 As Integer, n2 As Integer, yourDate As Date

podRNG = "PPP@11/15"

n1 = InStr(podRNG, "@") + 1
n2 = InStr(podRNG, "/") + 1

PPPTim = CDate(Mid(podRNG, n1, n2 - n1 - 1) & "/" & Mid(podRNG, n2) & _
    "/" & Format(Now(), "YYYY"))

Returns (on my system):

2017-11-15

...since the data type is Date, the date format will vary based on your Regional Settings.


问:
onSubmit() call multiple time service
I am write a form with some fields, when all have valid then i am enable the submit button, do a service call on onSubmit() method.My issue is when i click on the submit button twice it do service call twice. Is there any directive for check form submit.</p>

答:
When you click on the submit button twice it will call the service two times just use one variable 'submit' boolean by default false.

reference: https://angular.io/guide/forms#submit-the-form-with-ngsubmit

```<code>onSubmit() {
   if(this.submit) {
      return;
   }
   this.submit = true;
   this.serviceCall(); // got error set submit to false.
}
</code>```

Title: onSubmit() call multiple time service

Body:
When you click on the submit button twice it will call the service two times just use one variable 'submit' boolean by default false.

reference: https://angular.io/guide/forms#submit-the-form-with-ngsubmit

onSubmit() {
   if(this.submit) {
      return;
   }
   this.submit = true;
   this.serviceCall(); // got error set submit to false.
}


问:
PHP Display Values from Object within an Array Based on Key
I have the following array which contains both objects and arrays. How do I get only the specific values (for each object)  based on their keys?
I've tested and the array is displaying (see below) but I cannot isolate the 'name" value as needed.

I have tried the following code to get the name value:

```<code>case 'field_prgm_housing' :
$node = 'field_color';
$tids =  field_get_items('node', $node, $key, $node->language);
$terms = taxonomy_term_load_multiple(array(), array('tid' => $tids));
$nameonly = $terms->[0]->name[0];
return = $nameonly;
break;
Colors (Array, 2 elements)
    12 (Object) stdClass
      tid (String, 2 characters ) 12
      vid (String, 1 characters ) 3
      name (String, 9 characters ) Blue
      description (String, 0 characters )
      format (String, 13 characters ) filtered_html
      weight (String, 1 characters ) 0
      vocabulary_machine_name (String, 15 characters ) colors
      rdf_mapping (Array, 5 elements)
      path (Array, 1 element)
    13 (Object) stdClass
      tid (String, 2 characters ) 13
      vid (String, 1 characters ) 3
      name (String, 8 characters ) Green
      description (String, 0 characters )
      format (String, 13 characters ) filtered_html
      weight (String, 1 characters ) 0
      vocabulary_machine_name (String, 15 characters ) colors
      rdf_mapping (Array, 5 elements)
      path (Array, 1 element)
</code>```

答:
What $terms->[0] suppose to mean?

$terms is an array, so you have to access it by specifying the index you want to get, like: $terms[12], $terms[13]...

Elements of that array are object so when you get one you have to use "->" operator to get it's field (or method).

So it has to be like:

```<code>$nameonly = $terms[12]->name;
$nameonly = $terms[13]->name;
</code>```

Or you can iterate trough all the array items, as @kranthi suggested.

Body:
I have the following array which contains both objects and arrays. How do I get only the specific values (for each object)  based on their keys?
I've tested and the array is displaying (see below) but I cannot isolate the 'name" value as needed.

I have tried the following code to get the name value:

case 'field_prgm_housing' :
$node = 'field_color';
$tids =  field_get_items('node', $node, $key, $node->language);
$terms = taxonomy_term_load_multiple(array(), array('tid' => $tids));
$nameonly = $terms->[0]->name[0];
return = $nameonly;
break;
Colors (Array, 2 elements)
    12 (Object) stdClass
      tid (String, 2 characters ) 12
      vid (String, 1 characters ) 3
      name (String, 9 characters ) Blue
      description (String, 0 characters )
      format (String, 13 characters ) filtered_html
      weight (String, 1 characters ) 0
      vocabulary_machine_name (String, 15 characters ) colors
      rdf_mapping (Array, 5 elements)
      path (Array, 1 element)
    13 (Object) stdClass
      tid (String, 2 characters ) 13
      vid (String, 1 characters ) 3
      name (String, 8 characters ) Green
      description (String, 0 characters )
      format (String, 13 characters ) filtered_html
      weight (String, 1 characters ) 0
      vocabulary_machine_name (String, 15 characters ) colors
      rdf_mapping (Array, 5 elements)
      path (Array, 1 element)

Body:
What $terms->[0] suppose to mean?

$terms is an array, so you have to access it by specifying the index you want to get, like: $terms[12], $terms[13]...

Elements of that array are object so when you get one you have to use "->" operator to get it's field (or method).

So it has to be like:

$nameonly = $terms[12]->name;
$nameonly = $terms[13]->name;

Or you can iterate trough all the array items, as @kranthi suggested.


问:
Scheduling a task with intervals-LibGdx
I want to implement falling leaves in my game in particular intervals.
After 10 seconds of game starts,leaves has to fall.Then again leaves has to fall after 20 seconds and so on.

I have this method for the falling leaves of array;

private void updateFalls(float delta) {
    for (Leaf l : leaves) {
        l.moveLeavesDown(delta);
    }
    spawnleaves();
}
```

Is it possible to do with timer class?Is it possible to call this method inside timer with fixed intervals?
Any help would be appreciated.

答:
You can use Timer in this way :

Timer timer=new Timer();
timer.scheduleTask(new Timer.Task() {
    @Override
    public void run() {
        spawnLeaf();
    }
},10,20);            //  -->  10 is your first delay and 20 is interval in sec.
```
<p>I'm considering Leaf as a <code>Sprite</code> but it may be an <code>Image</code> or any other <code>Entity</code>.</p>
<p>Here is my <code>spawnLeaf</code> method :</p>
<pre class="lang-java prettyprint-override"><code>Array<Sprite> leaves=new Array<Sprite>();
private void spawnLeaf(){
    Sprite sprite=new Sprite(texture);

    sprite.setPosition(MathUtils.random(Gdx.graphics.getWidth()),Gdx.graphics.getHeight());
    leaves.add(sprite);
}
</code>```

Draw and position update part of all leaves

spriteBatch.begin();

Iterator<Sprite> iter = leaves.iterator();
while (iter.hasNext()) {
    Sprite spr = iter.next();
    spr.draw(spriteBatch);
    spr.setY(spr.getY()-50f*Gdx.graphics.getDeltaTime());
    if (spr.getY()<0) {
        iter.remove();
    }
}
spriteBatch.end();
```

Timer has clear() and stop() method that help in removing all scheduled tasks and stops the timer respectively that may start again.

Title: Scheduling a task with intervals-LibGdx

Body:
I want to implement falling leaves in my game in particular intervals.
After 10 seconds of game starts,leaves has to fall.Then again leaves has to fall after 20 seconds and so on.

I have this method for the falling leaves of array;

private void updateFalls(float delta) {
    for (Leaf l : leaves) {
        l.moveLeavesDown(delta);
    }
    spawnleaves();
}

Is it possible to do with timer class?Is it possible to call this method inside timer with fixed intervals?
Any help would be appreciated.

Body:
You can use Timer in this way :

Timer timer=new Timer();
timer.scheduleTask(new Timer.Task() {
    @Override
    public void run() {
        spawnLeaf();
    }
},10,20);            //  -->  10 is your first delay and 20 is interval in sec.

I'm considering Leaf as a Sprite but it may be an Image or any other Entity.

Here is my spawnLeaf method :

Array<Sprite> leaves=new Array<Sprite>();
private void spawnLeaf(){
    Sprite sprite=new Sprite(texture);

    sprite.setPosition(MathUtils.random(Gdx.graphics.getWidth()),Gdx.graphics.getHeight());
    leaves.add(sprite);
}

Draw and position update part of all leaves

spriteBatch.begin();

Iterator<Sprite> iter = leaves.iterator();
while (iter.hasNext()) {
    Sprite spr = iter.next();
    spr.draw(spriteBatch);
    spr.setY(spr.getY()-50f*Gdx.graphics.getDeltaTime());
    if (spr.getY()<0) {
        iter.remove();
    }
}
spriteBatch.end();

Timer has clear() and stop() method that help in removing all scheduled tasks and stops the timer respectively that may start again.


问:
How to call controller function from other controller In symfony 3?
I am new in symfony and I want to call base controller function from other controller. main purpose behind is there is Some common process(code) for all controller so I made one common function in base controller so I able to access function from every controller in sonata admin controller as well as other normal controller but I have not any idea about this, can any one know about this then suggest me. Thanks in advance </p>

答:
You can define your controller as service, then get it in another controller.

In your services.yml define needed controller as a service:

```<code>services:
    service_name:
        class: BundleName\Controller\YourControllerName
</code>```

Then in any controller you'll be able to get this service via container:

```<code>$otherController = $this->get('service_name');
$otherController->methodName();
</code>```

Body:
You can define your controller as service, then get it in another controller.

In your services.yml define needed controller as a service:

services:
    service_name:
        class: BundleName\Controller\YourControllerName

Then in any controller you'll be able to get this service via container:

$otherController = $this->get('service_name');
$otherController->methodName();


问:
Java: I want to get TextField value when I clicked a button. How to do it?
```<code>public Monster createCharacterScene() {
    String name;
    TextField nameTextField = new TextField();
    nameTextField.setLocation(65, 50);
    nameTextField.setSize(60, 10);
    Button myButton = new Button("OK");
    myButton.setLocation(25, 50);
    myButton.setSize(30, 40);
    add(myButton);
    add(nameTextField);
    myButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            name = nameTextField.getText();
        }
    });
    return null;
}
</code>```

I can't do it like this. They says "local variables referenced from an inner class must be final or effectively final". Is there alternative way to do it?

Thanks a lot.

PS. I using applet.

答:
make namea pseudo-final :

```<code>  final String[] name = new String[1];
</code>```

and access it this way  :

```<code> name[0] = nameTextField.getText();
</code>```

Body:
public Monster createCharacterScene() {
    String name;
    TextField nameTextField = new TextField();
    nameTextField.setLocation(65, 50);
    nameTextField.setSize(60, 10);
    Button myButton = new Button("OK");
    myButton.setLocation(25, 50);
    myButton.setSize(30, 40);
    add(myButton);
    add(nameTextField);
    myButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            name = nameTextField.getText();
        }
    });
    return null;
}

I can't do it like this. They says "local variables referenced from an inner class must be final or effectively final". Is there alternative way to do it?

Thanks a lot.

PS. I using applet.

Body:
make namea pseudo-final :

  final String[] name = new String[1];

and access it this way  :

 name[0] = nameTextField.getText();


问:
Drop down button is not responding with selenium in java
I want to click on drop down button and select one among one and click on it.I tried by many ways but it is not working. Attached image of html code, Anyone help me regarding this.
Below is my code which i tried

```<code>driver.findElement(By.id("homepages_dropdown")).click();

    /*List<WebElement> allElements = driver.findElements(By.xpath("//*[@id=\"homepages_item_AccountManagerDashboard\"]"));

    for (WebElement element: allElements)
    {
          System.out.println(element.getText());
    }*/
</code>```

答:
Just use "Select" to create an object that handles dropdowns etc. You can use "Select" to select element by it's text, index and a bunch of other options. It's the easiest way to handle such elements as dropdown and comboboxes.</p>

```<code>new Select(driver.findElement(By.id("homepages_dropdown"))).selectByVisibleText("Your option's text");
</code>```

Body:
I want to click on drop down button and select one among one and click on it.I tried by many ways but it is not working. Attached image of html code, Anyone help me regarding this.
Below is my code which i tried

driver.findElement(By.id("homepages_dropdown")).click();

    /*List<WebElement> allElements = driver.findElements(By.xpath("//*[@id=\"homepages_item_AccountManagerDashboard\"]"));

    for (WebElement element: allElements)
    {
          System.out.println(element.getText());
    }*/

Body:
Just use "Select" to create an object that handles dropdowns etc. You can use "Select" to select element by it's text, index and a bunch of other options. It's the easiest way to handle such elements as dropdown and comboboxes.

new Select(driver.findElement(By.id("homepages_dropdown"))).selectByVisibleText("Your option's text");


问:
I am facing a issue in my project which is created in codeigniter,
I am facing a issue in my project which is build in codeigniter, I am facing auto-logout problem and when I see log(error-log) file I found error the error are following:-

ERROR - 2017-11-15 16:15:50 --> Severity: Warning --> unlink(X:\xampp\tmp\ci_sessionboq544svmdme7blb7djjh1h92tnflmk7): Permission denied X:\xampp\htdocs\nabet-bmo\Code_v1\system\libraries\Session\drivers\Session_files_driver.php 320

ERROR - 2017-11-15 16:15:50 --> Severity: Warning --> session_regenerate_id(): Session object destruction failed X:\xampp\htdocs\nabet-bmo\Code_v1\system\libraries\Session\Session.php 720

Please help to resolve this problem

答:
In the config.php file you MUST set sess_save_path to a valid path. It was initially set to NULL. I have mine set to:

Now the sessions are being saved in this folder and can be unlinked when needed to

change application > config > config.php

```<code>$config['sess_save_path'] =  BASEPATH . 'cache/';
</code>```

Body:
In the config.php file you MUST set sess_save_path to a valid path. It was initially set to NULL. I have mine set to:

Now the sessions are being saved in this folder and can be unlinked when needed to

change application > config > config.php

$config['sess_save_path'] =  BASEPATH . 'cache/';


答:
A module is something that has components. It wraps them up so you can import and manage them.

Notice when you make a component you can put anything that's decorated as @Injectable in your constructor:

```<code>@Component({
  selector: 'app-heroes',
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {

  constructor(private myService: MyService) { }

  ngOnInit() {
  }

}
</code>```

And magically you will have a myService to use. This is dependency injection, which is built into Angular - but it's managed on a Module level. In your module you import what other modules you want to be able to use:

```<code>imports: [
  BrowserModule,
  FormsModule
],
</code>```

define what your module includes:

```<code>declarations: [
  AppComponent,
  HeroesComponent,
  MyService
],
</code>```

export any components (so other modules can import them)

```<code>exports: [
  HeroesComponent
],
</code>```

They help organize an application into blocks of functionality. Components are things that tell angular how to render something. Modules compose Components, Pipes, Services etc into 'blocks' that can be compiled by angular or imported and used by others.

Edit to address comment

Taking your specific question about HttpClient. The HttpClient is the service you are using to perform the actions. The HttpClientModule is the module you import into your module, so you can use the service it contains.

You import the module:

```<code>@NgModule({
  imports: [
    BrowserModule,
    // Include it under 'imports' in your application module
    // after BrowserModule.
    HttpClientModule,
  ],
})
</code>```

And use the service:

```<code>@Component(...)
export class MyComponent implements OnInit {

  // Inject HttpClient into your component or service.
  constructor(private http: HttpClient) {}

  ...
}
</code>```

The HttpClientModule contains within it all you need for the HttpClient to work, and packages it up so you can use it in your own projects.

This particular module only wraps up that one service, but the module could contain a bunch of related services, components, pipes or directives. For example, the RouterModule allows you to use the RouterOutlet and RouterLink directives.

Title: Angular2 - How module is different from component?

Body:
In the below code from ../src/app/app.module.ts,

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';

Component consists:

view(../src/app/app.component.html)

logic(../src/app/app.component.ts)

style(../src/app/app.component.css)

Angular application is a tree of components. Good components have high cohesion, i.e. each component contains only elements with related functionality. They are also well encapsulated and loosely coupled.

How modules are different from components?

Body:
A module is something that has components. It wraps them up so you can import and manage them.

Notice when you make a component you can put anything that's decorated as @Injectable in your constructor:

@Component({
  selector: 'app-heroes',
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {

  constructor(private myService: MyService) { }

  ngOnInit() {
  }

}

And magically you will have a myService to use. This is dependency injection, which is built into Angular - but it's managed on a Module level. In your module you import what other modules you want to be able to use:

imports: [
  BrowserModule,
  FormsModule
],

define what your module includes:

declarations: [
  AppComponent,
  HeroesComponent,
  MyService
],

export any components (so other modules can import them)

exports: [
  HeroesComponent
],

They help organize an application into blocks of functionality. Components are things that tell angular how to render something. Modules compose Components, Pipes, Services etc into 'blocks' that can be compiled by angular or imported and used by others.

Edit to address comment

Taking your specific question about HttpClient. The HttpClient is the service you are using to perform the actions. The HttpClientModule is the module you import into your module, so you can use the service it contains.

You import the module:

@NgModule({
  imports: [
    BrowserModule,
    // Include it under 'imports' in your application module
    // after BrowserModule.
    HttpClientModule,
  ],
})

And use the service:

@Component(...)
export class MyComponent implements OnInit {

  // Inject HttpClient into your component or service.
  constructor(private http: HttpClient) {}

  ...
}

The HttpClientModule contains within it all you need for the HttpClient to work, and packages it up so you can use it in your own projects.

This particular module only wraps up that one service, but the module could contain a bunch of related services, components, pipes or directives. For example, the RouterModule allows you to use the RouterOutlet and RouterLink directives.


问:
Profile Is not woking in angular 4
I am facing an issue while using Profile in index.html file. The anchor tag didnot work properly. I placed header menu on index.html and want to add the following code for Routing in angular 4

```<code><a href="#Profile" routerLink="/Profile" routerLinkActive="active">
<span class="icon-cogs"></span>Profile</a>
</code>```

The <router-outlet></router-outlet>is placed in app.component.html

The Same line code Profile working file when i put it in any other component but not working in index.html

答:
You should not put this code inside index.html, it won't work, it should be inside
  component.

routerLink be like this :

```<code>routerLink="/Profile"
</code>```

So keep it like :

```<code><a routerLink="/Profile" routerLinkActive="active">
</code>```

For more detail please read :

https://angular.io/guide/router

Title: Profile Is not woking in angular 4

Body:
I am facing an issue while using Profile in index.html file. The anchor tag didnot work properly. I placed header menu on index.html and want to add the following code for Routing in angular 4

Profile

The <router-outlet></router-outlet>is placed in app.component.html

The Same line code Profile working file when i put it in any other component but not working in index.html

Body:
You should not put this code inside index.html, it won't work, it should be inside
  component.

routerLink be like this :

routerLink="/Profile"

So keep it like :

<a routerLink="/Profile" routerLinkActive="active">

For more detail please read :

https://angular.io/guide/router


问:
How to automatic search and replace for 18n.properties file with WebStorm
For SAPUI5 there are i18n.properties files.

For the German language I need to replace the special German chars with the unicode codes.

```<code># AE = \u00C4, ae = \u00E4
# OE = \u00D6, oe = \u00F6
# UE = \u00DC, ue = \u00FC
# SZ = \u00DF
</code>```

How can I automate this search and replace with WebStorm?

答:
You could just use WebStorms 'Replace in Path' (CMD+SHIFT+R on Mac) on your i18n folder. IntelliJ IDEA has better editing support for .properties files though (since they are coming from java)

Will be also easy to do this via a node script/bash script/gulp task whatsoever.

Btw: Is this really needed? Having all .properties files in UTF-8 should just do the trick. Afaik only Tomcat got confused by that since in the Java spec these files are ISO-8859-1 by definition. As long as you are deploying to a platform that accepts them as UTF-8 there shouldn't be an issue.

BR
Chris

PS: That code looks really familiar ;D

Body:
For SAPUI5 there are i18n.properties files.

For the German language I need to replace the special German chars with the unicode codes.

# AE = \u00C4, ae = \u00E4
# OE = \u00D6, oe = \u00F6
# UE = \u00DC, ue = \u00FC
# SZ = \u00DF

How can I automate this search and replace with WebStorm?


问:
AND within OR within AND in Excel function?
I need to check if a A is over 200, and if B is over 150, if that's the case, the result should be true.

However, if A is exactly 200, it still has to result in true is B is over 100.

In short

```<code>A>200 AND B>150 = True
</code>```

But if

```<code>A=200 AND B>100 = True
A=200 AND B<=100 = False
</code>```

I tried it myself, but I'm stuck, my brain can't handle all the nesting, and I think I'm missing something easy, I also think the syntax I'm using is not correct, but what I came up with so far is:

```<code>=IF(AND(A>200;B>150;OR(AND(A=200;B>100);"True";"False")
</code>```

答:
```<code>= IF(OR(AND(A=200;B>100);AND(A>200;B>150));"True";"False")
</code>```

Just a tip for future reference: Generally, if several separate conditions can return "true", several AND statements within a single OR statement is what you should use. Of course there are some exceptions to this, but this is the general guideline to follow.

Body:
I need to check if a A is over 200, and if B is over 150, if that's the case, the result should be true.

However, if A is exactly 200, it still has to result in true is B is over 100.

In short

A>200 AND B>150 = True

But if

A=200 AND B>100 = True
A=200 AND B<=100 = False

I tried it myself, but I'm stuck, my brain can't handle all the nesting, and I think I'm missing something easy, I also think the syntax I'm using is not correct, but what I came up with so far is:

=IF(AND(A>200;B>150;OR(AND(A=200;B>100);"True";"False")

Body:
= IF(OR(AND(A=200;B>100);AND(A>200;B>150));"True";"False")

Just a tip for future reference: Generally, if several separate conditions can return "true", several AND statements within a single OR statement is what you should use. Of course there are some exceptions to this, but this is the general guideline to follow.


问:
Changing background colour subject to the value of the Name attribute
I've been experimenting with a Codepen and I'm looking to change the background color of a span subject to the value of the HTML's Name attribute.

The following codepen demonstrates where I am so far:

```<code><div class="card-body">
  <span id="community" class="card-community-tag" Name="test">Community 1</span>
  <span class="card-community-tag">Community 2</span>
</div>

document.load(function changeBackground() {
    var communityName = document.getElementById("community");
    if (communityName.getAttribute("Name") == "test") {
        communityName.style.backgroundColor = "red";
    }
});
</code>```

What am I doing wrong?

My end goal is for the JS to check the name attribute of a given  to determine what the background-color of that  should be.

答:
Try using this for your document load listener:

```<code>document.addEventListener("DOMContentLoaded", function(event) {
  // Do the business
});
</code>```

so:

```<code>document.addEventListener("DOMContentLoaded", function(event) {
  var communityName = document.getElementById("community");
  if (communityName.getAttribute("Name") == "test") {
    communityName.style.backgroundColor = "red";
  }
});
</code>```

Body:
I've been experimenting with a Codepen and I'm looking to change the background color of a span subject to the value of the HTML's Name attribute.

The following codepen demonstrates where I am so far:

  Community 1
  Community 2

document.load(function changeBackground() {
    var communityName = document.getElementById("community");
    if (communityName.getAttribute("Name") == "test") {
        communityName.style.backgroundColor = "red";
    }
});

What am I doing wrong?

My end goal is for the JS to check the name attribute of a given  to determine what the background-color of that  should be.

Body:
Try using this for your document load listener:

document.addEventListener("DOMContentLoaded", function(event) {
  // Do the business
});

so:

document.addEventListener("DOMContentLoaded", function(event) {
  var communityName = document.getElementById("community");
  if (communityName.getAttribute("Name") == "test") {
    communityName.style.backgroundColor = "red";
  }
});