问:
install-package with chocolatey never adds anything to the path environment variable
The command install-package <packagename> -providerName chocolatey never seems to add anything to the PATH envirnoment variable (Windows 10 Build 15063).

For example running

```<code>install-package docfx -providerName chocolatey
install-package wkthmltopdf -providerName chocolatey
</code>```

does not do it. Where as

```<code>choco install docfx
choco install wkhtmltopdf
</code>```

does it. When I run the latter the commands docfx and wkhtmltopdf are available in the command line.

So my question is: How is installation different when using the choco command directly compared to install-package and what can I do about this?

答:
As Rob Reynolds pointed out to me on gitter that package provider is not ready for prime time:

do not use the
  prototype provider for OneGet/PackageManagement - it's not official,
  it's a non-fully featured prototype made by MS and it may have
  security issues. See
  https://github.com/chocolatey/chocolatey-oneget/issues/5#issuecomment-275404099
  for details

Body:
The command install-package <packagename> -providerName chocolatey never seems to add anything to the PATH envirnoment variable (Windows 10 Build 15063).

For example running

install-package docfx -providerName chocolatey
install-package wkthmltopdf -providerName chocolatey

does not do it. Where as

choco install docfx
choco install wkhtmltopdf

does it. When I run the latter the commands docfx and wkhtmltopdf are available in the command line.

So my question is: How is installation different when using the choco command directly compared to install-package and what can I do about this?


来源: stackexchange

问:
Check for value of multiple properties only if they exist in Neo4j
I have nodes of type x with some properties.
I am trying to form a query that checks if a given set of properties exist in x, and if they do, compare each them with a value and then return the relevant node. The psuedo code would be something like this:-

```<code>match(x)
if exist(x.a, x.b)
   then if(x.a==1 and x.b==2)
         return x
else if exist(x.a)
   then if(x.a==1)
         return x
else if exist(x.b)
   then if(x.b==1)
         return x
</code>```

I have tried :-

```<code>MATCH (x) WHERE exists(x.a) and ('high' IN (x.a)) and exists(x.b) and ('high' IN (x.b)) RETURN x
</code>```

and:-

```<code>match(x) where x.a='high' and x.b='high' return x
</code>```

But the problem with both these queries is that if, say 'a' is not a property in x and 'b' is, it returns null without giving a result based on at least the value of 'b'. I am assuming that is because of the and clause, but I cant find an alternative.
I am using neo4j 3.1.3

答:
This might work :

```<code>CREATE (:X {a: "first a"})
CREATE (:X {a: "second a", b: "first b"})
CREATE (:X {b: "second b"})

MATCH (x:X)
WHERE exists(x.a)
AND exists (x.b)
AND <any other conditions>
RETURN x
UNION
MATCH (x:X)
WHERE exists(x.a)
AND NOT exists (x.b)
AND <any other conditions>
RETURN x
UNION
MATCH (x:X)
WHERE NOT exists(x.a)
AND exists (x.b)
AND <any other conditions>
RETURN x;
</code>```

Since the three cases return the same thing you can specify the three cases and UNION them together.

Hope this helps,
Tom

ContentLicense: CC BY-SA 3.0

Body:
I have nodes of type x with some properties.
I am trying to form a query that checks if a given set of properties exist in x, and if they do, compare each them with a value and then return the relevant node. The psuedo code would be something like this:-

match(x)
if exist(x.a, x.b)
   then if(x.a==1 and x.b==2)
         return x
else if exist(x.a)
   then if(x.a==1)
         return x
else if exist(x.b)
   then if(x.b==1)
         return x

I have tried :-

MATCH (x) WHERE exists(x.a) and ('high' IN (x.a)) and exists(x.b) and ('high' IN (x.b)) RETURN x

and:-

match(x) where x.a='high' and x.b='high' return x

But the problem with both these queries is that if, say 'a' is not a property in x and 'b' is, it returns null without giving a result based on at least the value of 'b'. I am assuming that is because of the and clause, but I cant find an alternative.
I am using neo4j 3.1.3

Body:
This might work :

CREATE (:X {a: "first a"})
CREATE (:X {a: "second a", b: "first b"})
CREATE (:X {b: "second b"})

MATCH (x:X)
WHERE exists(x.a)
AND exists (x.b)
AND <any other conditions>
RETURN x
UNION
MATCH (x:X)
WHERE exists(x.a)
AND NOT exists (x.b)
AND <any other conditions>
RETURN x
UNION
MATCH (x:X)
WHERE NOT exists(x.a)
AND exists (x.b)
AND <any other conditions>
RETURN x;

Since the three cases return the same thing you can specify the three cases and UNION them together.

Hope this helps,
Tom


问:
onclick not working with selectpicker multiselect dropdown
I have a selectpicker multiselect dropdown. I'm not able to invoke 'onclick' when I select any option. But this works with the normal html multiple dropdown. How to make it work with selectpicker?

Here's the code:

```<code> <!DOCTYPE html>
   <html>
     <head>
       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width, initial-scale=1">

       <link rel="stylesheet"
       href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-
       select/1.6.3/css/bootstrap-select.min.css" />
       <link rel="stylesheet" href="https:
       //maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
       <script
         src=
         "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
       </script>
       <script
         src=
       "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
 >
       </script>
       <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-
         select/1.6.3/js/bootstrap-select.min.js"></script>
     </head>
     <body>

       <form action="/action_page.php">
         <select class="selectpicker" name="cars"  multiple>
         <option value="volvo" onclick="myFunction(this)">Volvo</option>
         <option value="bmw" onclick="myFunction(this)">Bmw</option>
         <option value="opel" onclick="myFunction(this)">Opel</option>
         <option value="audi" onclick="myFunction(this)">Audi</option>
         </select>
         <input type="submit">
       </form>

       <p>Hold down the Ctrl (windows) / Command (Mac) button to select
        multiple options.</p>

       <script type="text/javascript">
         function myFunction(option) {

           if (option.selected) {
             alert(option.text);
           }
         }

       </script>
   </body>

 </html>
</code>```

答:
I have used jQuery to do this. since you use select from bootstrap, it will ordered as list not as options, thats why it didnt worked for you

$(function() {

  $('.selectpicker').on('change', function(){
    var selected = $(this).find("option:selected").text();
    alert(selected);
  });

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet"
 href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/css/bootstrap-select.min.css" />
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
 </script>
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/js/bootstrap-select.min.js"></script>

 <form action="/action_page.php">
 <select class="selectpicker" name="cars"  multiple>
 <option value="volvo" >Volvo</option>
 <option value="bmw">Bmw</option>
 <option value="opel">Opel</option>
 <option value="audi">Audi</option>
 </select>
 <input type="submit">
 </form>

 <p>Hold down the Ctrl (windows) / Command (Mac) button to select
 multiple options.</p></code>```

Hope this helps..!

Body:
I have a selectpicker multiselect dropdown. I'm not able to invoke 'onclick' when I select any option. But this works with the normal html multiple dropdown. How to make it work with selectpicker?

Here's the code:

 <!DOCTYPE html>

       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width, initial-scale=1">

       <link rel="stylesheet"
       href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-
       select/1.6.3/css/bootstrap-select.min.css" />
       <link rel="stylesheet" href="https:
       //maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

       <form action="/action_page.php">
         <select class="selectpicker" name="cars"  multiple>
         <option value="volvo" onclick="myFunction(this)">Volvo</option>
         <option value="bmw" onclick="myFunction(this)">Bmw</option>
         <option value="opel" onclick="myFunction(this)">Opel</option>
         <option value="audi" onclick="myFunction(this)">Audi</option>
         </select>
         <input type="submit">
       </form>

Hold down the Ctrl (windows) / Command (Mac) button to select
        multiple options.

Body:
I have used jQuery to do this. since you use select from bootstrap, it will ordered as list not as options, thats why it didnt worked for you

$(function() {

  $('.selectpicker').on('change', function(){
    var selected = $(this).find("option:selected").text();
    alert(selected);
  });

});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet"
 href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/css/bootstrap-select.min.css" />
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
 </script>
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/js/bootstrap-select.min.js"></script>

 <form action="/action_page.php">
 <select class="selectpicker" name="cars"  multiple>
 <option value="volvo" >Volvo</option>
 <option value="bmw">Bmw</option>
 <option value="opel">Opel</option>
 <option value="audi">Audi</option>
 </select>
 <input type="submit">
 </form>

 <p>Hold down the Ctrl (windows) / Command (Mac) button to select
 multiple options.</p>

Hope this helps..!


问:
SpringBoot: System.loadLibrary run twice
I have Spring Boot app version 1.5.3.RELEASE

In the main class I call System.loadLibrary:

```<code>@SpringBootApplication
@EnableScheduling
public class BlaApplication {

  static {
      System.out.println("xxxxxxxxxxxxxxxxxx Loading Lib");
      System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  }

  public static void main(String[] args) {

    SpringApplication.run(BlaApplication.class, args);
  }
}
</code>```

When app starts System.loadLibrary is called twice:

```<code>xxxxxxxxxxxxxxxxxx Loading Lib
11:10:51.766 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
11:10:51.771 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
11:10:51.771 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/Users/tomas/workspace/formater/formater-backend/target/classes/]
xxxxxxxxxxxxxxxxxx Loading Lib
Exception in thread "restartedMain" java.lang.UnsatisfiedLinkError: Native Library /usr/local/Cellar/opencv/2.4.13.2/share/OpenCV/java/libopencv_java2413.dylib already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1907)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.martoma.BlaApplication.<clinit>(BlaApplication.java:16)
...
</code>```

Why is it called twice?

答:
The solution is to put the System.loadLibrary(Core.NATIVE_LIBRARY_NAME); in its own config class:

```<code>@Configuration
public class LibLoading {
    static {
       System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }
}
</code>```

Body:
I have Spring Boot app version 1.5.3.RELEASE

In the main class I call System.loadLibrary:

@SpringBootApplication
@EnableScheduling
public class BlaApplication {

  static {
      System.out.println("xxxxxxxxxxxxxxxxxx Loading Lib");
      System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  }

  public static void main(String[] args) {

    SpringApplication.run(BlaApplication.class, args);
  }
}

When app starts System.loadLibrary is called twice:

xxxxxxxxxxxxxxxxxx Loading Lib
11:10:51.766 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
11:10:51.771 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
11:10:51.771 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/Users/tomas/workspace/formater/formater-backend/target/classes/]
xxxxxxxxxxxxxxxxxx Loading Lib
Exception in thread "restartedMain" java.lang.UnsatisfiedLinkError: Native Library /usr/local/Cellar/opencv/2.4.13.2/share/OpenCV/java/libopencv_java2413.dylib already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1907)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.martoma.BlaApplication.<clinit>(BlaApplication.java:16)
...

Why is it called twice?

Body:
The solution is to put the System.loadLibrary(Core.NATIVE_LIBRARY_NAME); in its own config class:

@Configuration
public class LibLoading {
    static {
       System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }
}


问:
How to fix textContent as undefined inside of for loop?
When i run the code below, it says "Cannot read property 'textContent' of undefined". Even onclick, addEventListener, length and much more says undefined! How can i fix this?

Here's the code:

```<code><div id = "dropdown-content" class = "d-con">
    <a href = "#">America</a>
    <a href = "#">Canada</a>
    <a href = "#">Rio</a>
</div>
</code>```

And The javaScript:

```<code>(function(){
    var i;
    var dropdown = document.getElementsByClassName('d-con');
    for(i = 0; i <= dropdown.length; i = i + 1){
        alert(dropdown[i].textContent);
    }
}());
</code>```

答:
Here try to check this code.

No need to make a loop for inner elements.

(function(){
        var i;
        var dropdown = document.getElementsByClassName('d-con');
        alert(dropdown[0].textContent);
    }());```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id = "dropdown-content" class = "d-con">
        America
        Canada
        Rio
    </div></code>```

Body:
When i run the code below, it says "Cannot read property 'textContent' of undefined". Even onclick, addEventListener, length and much more says undefined! How can i fix this?

Here's the code:

    America
    Canada
    Rio

And The javaScript:

(function(){
    var i;
    var dropdown = document.getElementsByClassName('d-con');
    for(i = 0; i <= dropdown.length; i = i + 1){
        alert(dropdown[i].textContent);
    }
}());

Body:
Here try to check this code.

No need to make a loop for inner elements.

(function(){
        var i;
        var dropdown = document.getElementsByClassName('d-con');
        alert(dropdown[0].textContent);
    }());

<div id = "dropdown-content" class = "d-con">
        <a href="#">America</a>
        <a href="#">Canada</a>
        <a href="#">Rio</a>
    </div>


问:
How to delete data based on time interval
I  have a table in my database.The table has a field VehId(Int) and trackdt(Datetime)

My table has 3000 billion rows(yes, that's right 3000 billion). so i want to delete old data. but i want to delete data based on time interval.

I want to delete records of every 20 seconds for each vehicle.

Below is the table I have

```<code>VehId  Trackdt
1      2017-05-20 00:00:30.000
2      2017-05-20 00:00:32.000
2      2017-05-20 00:00:42.000
1      2017-05-20 00:00:40.000
2      2017-05-20 00:00:52.000
1      2017-05-20 00:00:50.000
1      2017-05-20 00:01:00.000
2      2017-05-20 00:01:02.000
1      2017-05-20 00:01:10.000
1      2017-05-20 00:01:20.000
2      2017-05-20 00:01:12.000
1      2017-05-20 00:01:30.000
2      2017-05-20 00:01:22.000
2      2017-05-20 00:01:32.000
</code>```

After delete data should be like below

```<code>VehId  TRackdt
1      2017-05-20 00:00:30.000
2      2017-05-20 00:00:32.000
1      2017-05-20 00:01:00.000
2      2017-05-20 00:01:02.000
1      2017-05-20 00:01:30.000
2      2017-05-20 00:01:32.000
</code>```

I tried below query but it is taking too much time

```<code>ALTER PROCEDURE [dbo].[DELETEINTERVALDATA]

@FROMDATE DATETIME,
@TODATE DATETIME,
@INTERVAL INT,
@FLAG INT

AS
BEGIN
SET NOCOUNT ON;

DECLARE @TRACKDT DATETIME
DECLARE @I INT =1
DECLARE @V INT =1
DECLARE @COUNT INT
DECLARE @VCOUNT INT
DECLARE @STARTDATE DATETIME = ''
DECLARE @VEHID INT
DECLARE @TIMEDIFF INT

 CREATE TABLE #TEMPVEHICLE
 (
    SNO INT IDENTITY(1,1),
    VEHID INT
 )

 CREATE TABLE #TEMPLOG
 (
    SNO INT IDENTITY(1,1),
    TRACKDT DATETIME
 )

 IF (@FLAG = 1 )
    BEGIN

        INSERT INTO #TEMPVEHICLE (VEHID) SELECT VEHID FROM VEHICLEMASTER ORDER BY VEHID

        SELECT @VCOUNT = COUNT(SNO) FROM #TEMPVEHICLE

        WHILE (@V <= @VCOUNT)
            BEGIN

                SELECT @VEHID = VEHID FROM #TEMPVEHICLE WHERE SNO = @V

                INSERT INTO #TEMPLOG(TRACKDT) SELECT TRACKDT
                FROM TRACKINGLOG WITH(NOLOCK)
                WHERE TRACKDT BETWEEN @FROMDATE AND @TODATE AND VEHID = @VEHID
                ORDER BY TRACKDT ASC

                SELECT @COUNT = COUNT(SNO) FROM #TEMPLOG

                WHILE (@I <= @COUNT)
                    BEGIN
                        SELECT @TRACKDT=TRACKDT FROM #TEMPLOG WHERE SNO = @I
                        IF (@I = 1)
                            BEGIN
                                SELECT @STARTDATE = @TRACKDT
                            END
                        ELSE
                            BEGIN
                                SELECT @TIMEDIFF = DATEDIFF(SECOND,@STARTDATE,@TRACKDT)
                                IF @TIMEDIFF <= 20
                                    BEGIN
                                        DELETE FROM TRACKINGLOG WHERE TRACKDT = @TRACKDT AND VEHID = @VEHID
                                    END
                                ELSE
                                    BEGIN
                                        SELECT @STARTDATE = @TRACKDT
                                    END
                            END
                        SELECT  @I = @I + 1
                    END
                TRUNCATE TABLE #TEMPLOG
                SELECT  @V = @V + 1,@STARTDATE= '',@I=1
            END
        DROP TABLE #TEMPLOG
        DROP TABLE #TEMPVEHICLE
    END
   END
</code>```

How can I write query which delete data based on time interval and should be quick??

Thanks in advance

答:
Please read about Parameter sniffing. Assuming your stored procedure is slow BUT correct, I have updated your SP. Kindly Try :</p>

```<code>ALTER PROCEDURE [dbo].[DELETEINTERVALDATA]

@FROMDATE1 DATETIME,
@TODATE1 DATETIME,
@INTERVAL1 INT,
@FLAG1 INT

AS
BEGIN
SET NOCOUNT ON;

DECLARE @TRACKDT DATETIME
DECLARE @I INT =1
DECLARE @V INT =1
DECLARE @COUNT INT
DECLARE @VCOUNT INT
DECLARE @STARTDATE DATETIME = ''
DECLARE @VEHID INT
DECLARE @TIMEDIFF INT

DECLARE @FROMDATE DATETIME = @FROMDATE1
DECLARE @TODATE DATETIME = @TODATE1
DECLARE @INTERVAL INT = @INTERVAL1
DECLARE @FLAG INT = @FLAG1

 CREATE TABLE #TEMPVEHICLE
 (
    SNO INT IDENTITY(1,1),
    VEHID INT
 )

 CREATE TABLE #TEMPLOG
 (
    SNO INT IDENTITY(1,1),
    TRACKDT DATETIME
 )

 IF (@FLAG = 1 )
    BEGIN

        INSERT INTO #TEMPVEHICLE (VEHID) SELECT VEHID FROM VEHICLEMASTER ORDER BY VEHID

        SELECT @VCOUNT = COUNT(SNO) FROM #TEMPVEHICLE

        WHILE (@V <= @VCOUNT)
            BEGIN

                SELECT @VEHID = VEHID FROM #TEMPVEHICLE WHERE SNO = @V

                INSERT INTO #TEMPLOG(TRACKDT) SELECT TRACKDT
                FROM TRACKINGLOG WITH(NOLOCK)
                WHERE TRACKDT BETWEEN @FROMDATE AND @TODATE AND VEHID = @VEHID
                ORDER BY TRACKDT ASC

                SELECT @COUNT = COUNT(SNO) FROM #TEMPLOG

                WHILE (@I <= @COUNT)
                    BEGIN
                        SELECT @TRACKDT=TRACKDT FROM #TEMPLOG WHERE SNO = @I
                        IF (@I = 1)
                            BEGIN
                                SELECT @STARTDATE = @TRACKDT
                            END
                        ELSE
                            BEGIN
                                SELECT @TIMEDIFF = DATEDIFF(SECOND,@STARTDATE,@TRACKDT)
                                IF @TIMEDIFF <= 20
                                    BEGIN
                                        DELETE FROM TRACKINGLOG WHERE TRACKDT = @TRACKDT AND VEHID = @VEHID
                                    END
                                ELSE
                                    BEGIN
                                        SELECT @STARTDATE = @TRACKDT
                                    END
                            END
                        SELECT  @I = @I + 1
                    END
                TRUNCATE TABLE #TEMPLOG
                SELECT  @V = @V + 1,@STARTDATE= '',@I=1
            END
        DROP TABLE #TEMPLOG
        DROP TABLE #TEMPVEHICLE
    END
   END
</code>```

Body:
I  have a table in my database.The table has a field VehId(Int) and trackdt(Datetime)

My table has 3000 billion rows(yes, that's right 3000 billion). so i want to delete old data. but i want to delete data based on time interval.

I want to delete records of every 20 seconds for each vehicle.

Below is the table I have

VehId  Trackdt
1      2017-05-20 00:00:30.000
2      2017-05-20 00:00:32.000
2      2017-05-20 00:00:42.000
1      2017-05-20 00:00:40.000
2      2017-05-20 00:00:52.000
1      2017-05-20 00:00:50.000
1      2017-05-20 00:01:00.000
2      2017-05-20 00:01:02.000
1      2017-05-20 00:01:10.000
1      2017-05-20 00:01:20.000
2      2017-05-20 00:01:12.000
1      2017-05-20 00:01:30.000
2      2017-05-20 00:01:22.000
2      2017-05-20 00:01:32.000

After delete data should be like below

VehId  TRackdt
1      2017-05-20 00:00:30.000
2      2017-05-20 00:00:32.000
1      2017-05-20 00:01:00.000
2      2017-05-20 00:01:02.000
1      2017-05-20 00:01:30.000
2      2017-05-20 00:01:32.000

I tried below query but it is taking too much time

ALTER PROCEDURE [dbo].[DELETEINTERVALDATA]

@FROMDATE DATETIME,
@TODATE DATETIME,
@INTERVAL INT,
@FLAG INT

AS
BEGIN
SET NOCOUNT ON;

DECLARE @TRACKDT DATETIME
DECLARE @I INT =1
DECLARE @V INT =1
DECLARE @COUNT INT
DECLARE @VCOUNT INT
DECLARE @STARTDATE DATETIME = ''
DECLARE @VEHID INT
DECLARE @TIMEDIFF INT

 CREATE TABLE #TEMPVEHICLE
 (
    SNO INT IDENTITY(1,1),
    VEHID INT
 )

 CREATE TABLE #TEMPLOG
 (
    SNO INT IDENTITY(1,1),
    TRACKDT DATETIME
 )

 IF (@FLAG = 1 )
    BEGIN

        INSERT INTO #TEMPVEHICLE (VEHID) SELECT VEHID FROM VEHICLEMASTER ORDER BY VEHID

        SELECT @VCOUNT = COUNT(SNO) FROM #TEMPVEHICLE

        WHILE (@V <= @VCOUNT)
            BEGIN

                SELECT @VEHID = VEHID FROM #TEMPVEHICLE WHERE SNO = @V

                INSERT INTO #TEMPLOG(TRACKDT) SELECT TRACKDT
                FROM TRACKINGLOG WITH(NOLOCK)
                WHERE TRACKDT BETWEEN @FROMDATE AND @TODATE AND VEHID = @VEHID
                ORDER BY TRACKDT ASC

                SELECT @COUNT = COUNT(SNO) FROM #TEMPLOG

                WHILE (@I <= @COUNT)
                    BEGIN
                        SELECT @TRACKDT=TRACKDT FROM #TEMPLOG WHERE SNO = @I
                        IF (@I = 1)
                            BEGIN
                                SELECT @STARTDATE = @TRACKDT
                            END
                        ELSE
                            BEGIN
                                SELECT @TIMEDIFF = DATEDIFF(SECOND,@STARTDATE,@TRACKDT)
                                IF @TIMEDIFF <= 20
                                    BEGIN
                                        DELETE FROM TRACKINGLOG WHERE TRACKDT = @TRACKDT AND VEHID = @VEHID
                                    END
                                ELSE
                                    BEGIN
                                        SELECT @STARTDATE = @TRACKDT
                                    END
                            END
                        SELECT  @I = @I + 1
                    END
                TRUNCATE TABLE #TEMPLOG
                SELECT  @V = @V + 1,@STARTDATE= '',@I=1
            END
        DROP TABLE #TEMPLOG
        DROP TABLE #TEMPVEHICLE
    END
   END

How can I write query which delete data based on time interval and should be quick??

Thanks in advance

Body:
Please read about Parameter sniffing. Assuming your stored procedure is slow BUT correct, I have updated your SP. Kindly Try :

ALTER PROCEDURE [dbo].[DELETEINTERVALDATA]

@FROMDATE1 DATETIME,
@TODATE1 DATETIME,
@INTERVAL1 INT,
@FLAG1 INT

AS
BEGIN
SET NOCOUNT ON;

DECLARE @TRACKDT DATETIME
DECLARE @I INT =1
DECLARE @V INT =1
DECLARE @COUNT INT
DECLARE @VCOUNT INT
DECLARE @STARTDATE DATETIME = ''
DECLARE @VEHID INT
DECLARE @TIMEDIFF INT

DECLARE @FROMDATE DATETIME = @FROMDATE1
DECLARE @TODATE DATETIME = @TODATE1
DECLARE @INTERVAL INT = @INTERVAL1
DECLARE @FLAG INT = @FLAG1

 CREATE TABLE #TEMPVEHICLE
 (
    SNO INT IDENTITY(1,1),
    VEHID INT
 )

 CREATE TABLE #TEMPLOG
 (
    SNO INT IDENTITY(1,1),
    TRACKDT DATETIME
 )

 IF (@FLAG = 1 )
    BEGIN

        INSERT INTO #TEMPVEHICLE (VEHID) SELECT VEHID FROM VEHICLEMASTER ORDER BY VEHID

        SELECT @VCOUNT = COUNT(SNO) FROM #TEMPVEHICLE

        WHILE (@V <= @VCOUNT)
            BEGIN

                SELECT @VEHID = VEHID FROM #TEMPVEHICLE WHERE SNO = @V

                INSERT INTO #TEMPLOG(TRACKDT) SELECT TRACKDT
                FROM TRACKINGLOG WITH(NOLOCK)
                WHERE TRACKDT BETWEEN @FROMDATE AND @TODATE AND VEHID = @VEHID
                ORDER BY TRACKDT ASC

                SELECT @COUNT = COUNT(SNO) FROM #TEMPLOG

                WHILE (@I <= @COUNT)
                    BEGIN
                        SELECT @TRACKDT=TRACKDT FROM #TEMPLOG WHERE SNO = @I
                        IF (@I = 1)
                            BEGIN
                                SELECT @STARTDATE = @TRACKDT
                            END
                        ELSE
                            BEGIN
                                SELECT @TIMEDIFF = DATEDIFF(SECOND,@STARTDATE,@TRACKDT)
                                IF @TIMEDIFF <= 20
                                    BEGIN
                                        DELETE FROM TRACKINGLOG WHERE TRACKDT = @TRACKDT AND VEHID = @VEHID
                                    END
                                ELSE
                                    BEGIN
                                        SELECT @STARTDATE = @TRACKDT
                                    END
                            END
                        SELECT  @I = @I + 1
                    END
                TRUNCATE TABLE #TEMPLOG
                SELECT  @V = @V + 1,@STARTDATE= '',@I=1
            END
        DROP TABLE #TEMPLOG
        DROP TABLE #TEMPVEHICLE
    END
   END


问:
Share a video to Facebook
I'm writing a simple test app to upload a video to Facebook from iOS.

I'm finding it quite hard to find examples/tutorials online for how to do this with Swift since all the documentation for the FacebookSDK is in Objective-C.

I have this so far which puts a share button on my UI but it looks disabled, from what I have read this is because there is no content set but I can't see how that is possible.

```<code>    let video_content : FBSDKShareVideoContent = FBSDKShareVideoContent()

    video_content.video = FBSDKShareVideo(videoURL: getVideoURL())

    let button : FBSDKShareButton = FBSDKShareButton()
    button.shareContent = video_content

    button.frame = CGRectMake((UIScreen.mainScreen().bounds.width - 100) * 0.5, 50, 100, 25)
    self.view.addSubview(button)
</code>```

my getVideoURL() functions returns a NSURL which definitely contains the url to the video (I have printed it to console and checked it points to a video I have stored in a folder earlier).

I looked at the social framework and its a shame I can't use it because it seems it is only used for sharing photos and not able to share videos.

I'm using latest versions of Xcode, Swift and Facebook SDK.

答:
converted into swift 3 and  4 :-
try this

```<code>func uploadVideoOnFacebook() {
        var pathURL: URL
        var videoData: Data
        pathURL = URL(string: "Your video url string")!
        do {
            videoData = try Data(contentsOf: URL(string: "Your video url string")!)
            print(videoData)
            var strDesc : String
            strDesc = ""
            let videoObject: [String : Any] = ["title": "application Name", "description": strDesc, pathURL.absoluteString: videoData]
            let uploadRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/videos", parameters: videoObject, httpMethod: "POST")
            self.view!.isUserInteractionEnabled = false
            uploadRequest.start(completionHandler: {(connection: FBSDKGraphRequestConnection, result: AnyObject, error: NSError) -> Void in
                if error == error {
                    NSLog("Error")

                }
                else {
                    NSLog("Success")
                }
            } as! FBSDKGraphRequestHandler)
        } catch {
            print(error)
        }

    }
</code>```

Title: Share a video to Facebook

Body:
I'm writing a simple test app to upload a video to Facebook from iOS.

I'm finding it quite hard to find examples/tutorials online for how to do this with Swift since all the documentation for the FacebookSDK is in Objective-C.

I have this so far which puts a share button on my UI but it looks disabled, from what I have read this is because there is no content set but I can't see how that is possible.

    let video_content : FBSDKShareVideoContent = FBSDKShareVideoContent()

    video_content.video = FBSDKShareVideo(videoURL: getVideoURL())

    let button : FBSDKShareButton = FBSDKShareButton()
    button.shareContent = video_content

    button.frame = CGRectMake((UIScreen.mainScreen().bounds.width - 100) * 0.5, 50, 100, 25)
    self.view.addSubview(button)

my getVideoURL() functions returns a NSURL which definitely contains the url to the video (I have printed it to console and checked it points to a video I have stored in a folder earlier).

I looked at the social framework and its a shame I can't use it because it seems it is only used for sharing photos and not able to share videos.

I'm using latest versions of Xcode, Swift and Facebook SDK.

Body:
converted into swift 3 and  4 :-
try this

func uploadVideoOnFacebook() {
        var pathURL: URL
        var videoData: Data
        pathURL = URL(string: "Your video url string")!
        do {
            videoData = try Data(contentsOf: URL(string: "Your video url string")!)
            print(videoData)
            var strDesc : String
            strDesc = ""
            let videoObject: [String : Any] = ["title": "application Name", "description": strDesc, pathURL.absoluteString: videoData]
            let uploadRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/videos", parameters: videoObject, httpMethod: "POST")
            self.view!.isUserInteractionEnabled = false
            uploadRequest.start(completionHandler: {(connection: FBSDKGraphRequestConnection, result: AnyObject, error: NSError) -> Void in
                if error == error {
                    NSLog("Error")

                }
                else {
                    NSLog("Success")
                }
            } as! FBSDKGraphRequestHandler)
        } catch {
            print(error)
        }

    }


问:
Avoiding redefinition of enums in C
I need an explanation as to how to make this work (if it's even possible).

So, in my header file, I have an enum declaration for a BOOL type with some routines I am supposed to implement.

```<code>#ifndef _TABLE_H
#define _TABLE_H

typedef enum BOOL { false, true } Boolean;

#endif //_TABLE_H
</code>```

I'm using this interface in a file that has a definition of various routines using the bool type (not Boolean this time)

```<code>typedef enum BOOL { false, true } bool;
</code>```

I want to be able to use both, how do I do this?

答:
In your provided code you are redefining BOOL. So, to avoid the redefinition of BOOL, do following when you are providing definition to bool:

```<code>typedef enum BOOL bool;
</code>```

So you have followings:

File1.h

```<code>#ifndef _TABLE_H
#define _TABLE_H

typedef enum BOOL { false, true } Boolean;

#endif //_TABLE_H
</code>```

File2.h

```<code>#include <File1.h>
...
typedef enum BOOL bool;
...
</code>```

Here, you are providing definition for BOOL in File1.h. In File2.h you are just providing an alias name.

Note: It would be better if you just provide deceleration in File1.h and put definition of BOOL in some another file.

Title: Avoiding redefinition of enums in C

Body:
I need an explanation as to how to make this work (if it's even possible).

So, in my header file, I have an enum declaration for a BOOL type with some routines I am supposed to implement.

#ifndef _TABLE_H
#define _TABLE_H

typedef enum BOOL { false, true } Boolean;

#endif //_TABLE_H

I'm using this interface in a file that has a definition of various routines using the bool type (not Boolean this time)

typedef enum BOOL { false, true } bool;

I want to be able to use both, how do I do this?

Body:
In your provided code you are redefining BOOL. So, to avoid the redefinition of BOOL, do following when you are providing definition to bool:

typedef enum BOOL bool;

So you have followings:

File1.h

#ifndef _TABLE_H
#define _TABLE_H

typedef enum BOOL { false, true } Boolean;

#endif //_TABLE_H

File2.h

#include <File1.h>
...
typedef enum BOOL bool;
...

Here, you are providing definition for BOOL in File1.h. In File2.h you are just providing an alias name.

Note: It would be better if you just provide deceleration in File1.h and put definition of BOOL in some another file.


问:
Merging 2 dataframes on Pandas
Sorry I have a very simple question. So I have two dataframes that look like
Dataframe 1:
columns: a b c d e f g h

Dataframe 2:
columns: e ef

I'm trying to join Dataframe 2 on Dataframe 1 at column e, which should yield
columns: a b c d e ef g h
or
columns: a b c d e f g h ef

However:
df1.merge(df2, how = 'inner', on = 'e') yields a blank dataframe when I print it out.

'outer' merge only extends the dataframe vertically (like using an append function).

Would appreciate some help thank you!

答:
Instead of

df1.merge(...)

try:

pd.merge(left=df1, right=df2, on ='e', how='inner')

Title: Merging 2 dataframes on Pandas


问:
How to check if entity changed in Doctrine 2?
I need to check if a persisted entity has changed and needs to be updated on the database.
What I made (and did not work) was the following:

```<code>$product = $entityManager->getRepository('Product')->find(3);
$product->setName('A different name');

var_export($entityManager->getUnitOfWork()->isScheduledForUpdate($product));
</code>```

That code prints always false, I also tried to flush before check the unit of work, but did not work.

Anyone has a suggestion?

答:
I am curious about Doctrine and everyone documenting postFlush, as in some case, you have an ongoing transaction.
I'd like to point out there's also postTransactionCommit, which could be safer depending on what you're trying to achieve in the postFlush event.</p>

Body:
I need to check if a persisted entity has changed and needs to be updated on the database.
What I made (and did not work) was the following:

$product = $entityManager->getRepository('Product')->find(3);
$product->setName('A different name');

var_export($entityManager->getUnitOfWork()->isScheduledForUpdate($product));

That code prints always false, I also tried to flush before check the unit of work, but did not work.

Anyone has a suggestion?


答:
Just check this</p>

```<code>    (function(){
      $('.d-con a').each(function(key, value){
        console.log(value.textContent);
      });
    }());
</code>```

Title: How to fix textContent as undefined inside of for loop?

Body:
Just check this

    (function(){
      $('.d-con a').each(function(key, value){
        console.log(value.textContent);
      });
    }());


问:
Create ArrayList from array
Given an array of type Element[]:

```<code>Element[] array = {new Element(1), new Element(2), new Element(3)};
</code>```

How do I convert this array into an object of type ArrayList<Element>?

```<code>ArrayList<Element> arrayList = ???;
</code>```

答:
We can easily convert an array to ArrayList.
We use Collection interface's addAll() method for the purpose of copying content from one list to another.

```<code> Arraylist arr = new Arraylist();
 arr.addAll(Arrays.asList(asset));
</code>```

OwnerDisplayName: Ron Tuffin

ContentLicense: CC BY-SA 4.0

Title: Create ArrayList from array

Body:
Given an array of type Element[]:

Element[] array = {new Element(1), new Element(2), new Element(3)};

How do I convert this array into an object of type ArrayList<Element>?

ArrayList<Element> arrayList = ???;

Body:
We can easily convert an array to ArrayList.
We use Collection interface's addAll() method for the purpose of copying content from one list to another.

 Arraylist arr = new Arraylist();
 arr.addAll(Arrays.asList(asset));


问:
When two or three user request the same time then I have duplicate ID
I get the last ID and increment it and store it as second ID of my invoice when two or three user request at the same time it store duplicated ID in DB. HERE IS THE CODE </p>

```<code>$id_num = DB::table('slips')->latest('id')->first();
$now = \jDate::forge('now')->format('date');
$old = $id_num->date;
$slep_id = 0;

 if($now>$old){
    $slep_id = 1;
}
else{
    $slep_id = $id_num->id_num+1;
}
$formatted_slep = sprintf("%04d",$slep_id);
</code>```

<p>Now when I store it in the DB it some times it duplicate </p>

```<code>$slip = new Slip;
$slip->id = $formatted_slep;
$slip->save();
</code>```

答:
Use transaction :</p>

```<code>DB::transaction(function () {
   $slip = new Slip;
   $slip->id = $formatted_slep;
   $slip->save();
});
</code>```

Body:
I get the last ID and increment it and store it as second ID of my invoice when two or three user request at the same time it store duplicated ID in DB. HERE IS THE CODE

$id_num = DB::table('slips')->latest('id')->first();
$now = \jDate::forge('now')->format('date');
$old = $id_num->date;
$slep_id = 0;

 if($now>$old){
    $slep_id = 1;
}
else{
    $slep_id = $id_num->id_num+1;
}
$formatted_slep = sprintf("%04d",$slep_id);

Now when I store it in the DB it some times it duplicate

$slip = new Slip;
$slip->id = $formatted_slep;
$slip->save();

Body:
Use transaction :

DB::transaction(function () {
   $slip = new Slip;
   $slip->id = $formatted_slep;
   $slip->save();
});


问:
Using the panel regression on Hedonic data using plm package in R
I am trying to run the panel regression for unbalanced panel in R using the plm package. I am using the 'Hedonic' data to run the same.

I was trying to replicate something similar that is done in the following paper: http://ftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/vignettes/plm/plmEN.pdf (page 14, 3.2.5 Unbalanced Panel).

My code looks something like this:

```<code>form = mv ~ crim + zn + indus + chas + nox + rm + age + dis + rad + tax + ptratio + blacks + lstat
ba = plm(form, data = Hedonic)
</code>```

However, I am getting the following error on execution:

```<code>Error in names(y) <- namesy :
  'names' attribute [506] must be the same length as the vector [0]
</code>```

traceback() yields the following result:

```<code>4: pmodel.response.pFormula(formula, data, model = model, effect = effect,
       theta = theta)
3: pmodel.response(formula, data, model = model, effect = effect,
       theta = theta)
2: plm.fit(formula, data, model, effect, random.method, random.dfcor,
       inst.method)
1: plm(form, data = Hedonic)
</code>```

I am new to panel regression and would be really grateful if someone can help me with this issue.

Thanks.

答:
That paper is ten years old, and I'm not sure plm works like that. The latest docs are here https://cran.r-project.org/web/packages/plm/vignettes/plm.pdf

Your problem arises because, in the docs:

the current version of plm is capable of working with a regular
  data.frame without any further transformation, provided that the
  individual and time indexes are in the first two columns,

The Hedonic data set does not have individual and time indexes in the first two columns. I'm not sure where the individual and time indexes are in the data, but if I specify townid for the index I at least get something that runs:

```<code>> p <- plm(mv~crim,data=Hedonic)
Error in names(y) <- namesy :
  'names' attribute [506] must be the same length as the vector [0]

> p <- plm(mv~crim,data=Hedonic, index="townid")
> p

Model Formula: mv ~ crim

Coefficients:
      crim
-0.0097455
</code>```

because when you don't specify id and time indexes it is going to try using the first two columns, and in Hedonic that is giving unique numbers for the id, so the whole model falls apart.

If you look at the examples in help(plm) you might notice that the first two columns in all the data sets define the id and the time.

Body:
I am trying to run the panel regression for unbalanced panel in R using the plm package. I am using the 'Hedonic' data to run the same.

I was trying to replicate something similar that is done in the following paper: http://ftp.uni-bayreuth.de/math/statlib/R/CRAN/doc/vignettes/plm/plmEN.pdf (page 14, 3.2.5 Unbalanced Panel).

My code looks something like this:

form = mv ~ crim + zn + indus + chas + nox + rm + age + dis + rad + tax + ptratio + blacks + lstat
ba = plm(form, data = Hedonic)

However, I am getting the following error on execution:

Error in names(y) <- namesy :
  'names' attribute [506] must be the same length as the vector [0]

traceback() yields the following result:

4: pmodel.response.pFormula(formula, data, model = model, effect = effect,
       theta = theta)
3: pmodel.response(formula, data, model = model, effect = effect,
       theta = theta)
2: plm.fit(formula, data, model, effect, random.method, random.dfcor,
       inst.method)
1: plm(form, data = Hedonic)

I am new to panel regression and would be really grateful if someone can help me with this issue.

Thanks.

Body:
That paper is ten years old, and I'm not sure plm works like that. The latest docs are here https://cran.r-project.org/web/packages/plm/vignettes/plm.pdf

Your problem arises because, in the docs:

the current version of plm is capable of working with a regular
  data.frame without any further transformation, provided that the
  individual and time indexes are in the first two columns,

The Hedonic data set does not have individual and time indexes in the first two columns. I'm not sure where the individual and time indexes are in the data, but if I specify townid for the index I at least get something that runs:

> p <- plm(mv~crim,data=Hedonic)
Error in names(y) <- namesy :
  'names' attribute [506] must be the same length as the vector [0]

> p <- plm(mv~crim,data=Hedonic, index="townid")
> p

Model Formula: mv ~ crim

Coefficients:
      crim
-0.0097455

because when you don't specify id and time indexes it is going to try using the first two columns, and in Hedonic that is giving unique numbers for the id, so the whole model falls apart.

If you look at the examples in help(plm) you might notice that the first two columns in all the data sets define the id and the time.


答:
You want to delete a record if the time was 20 seconds or less after the previous time. But if the previous time gets deleted you than you want to compare with the time before that etc.
You will need some kind of loping for that. A recursive table expression or regular looping.</p>

```<code>Declare @myTable table (vehid int, trackdt datetime)
insert into @mytable values
(1,      '2017-05-20 00:00:30.000'),
(2,      '2017-05-20 00:00:32.000'),
(2,      '2017-05-20 00:00:42.000'),
(1,      '2017-05-20 00:00:40.000'),
(2,      '2017-05-20 00:00:52.000'),
(1,      '2017-05-20 00:00:50.000'),
(1,      '2017-05-20 00:01:00.000'),
(2,      '2017-05-20 00:01:02.000'),
(1,      '2017-05-20 00:01:10.000'),
(1,      '2017-05-20 00:01:20.000'),
(2,      '2017-05-20 00:01:12.000'),
(1,      '2017-05-20 00:01:30.000'),
(2,      '2017-05-20 00:01:22.000'),
(2,      '2017-05-20 00:01:32.000')

--set @@rowcount to 1
select 1

while @@ROWCOUNT > 0
begin
    DELETE T1
    from @mytable t1

    --previous time
    outer apply (select top 1 trackdt from  @mytable where vehid = t1.vehid and trackdt < t1.trackdt order by 1 desc)t2
    --previous time before that
    outer apply (select top 1 trackdt from  @mytable where vehid = t1.vehid and trackdt < t2.trackdt order by 1 desc)t3

    --previous time was less or equal to 20 seconds
    where DATEDIFF(second,t2.trackdt,t1.trackdt)<=20

    --previous time before that was more than 20 seconds or there is no time before
    and (DATEDIFF(second,t3.trackdt,t2.trackdt)>20 or t3.trackdt is null)

end

select * from @mytable
</code>```

Title: How to delete data based on time interval

Body:
You want to delete a record if the time was 20 seconds or less after the previous time. But if the previous time gets deleted you than you want to compare with the time before that etc.
You will need some kind of loping for that. A recursive table expression or regular looping.

Declare @myTable table (vehid int, trackdt datetime)
insert into @mytable values
(1,      '2017-05-20 00:00:30.000'),
(2,      '2017-05-20 00:00:32.000'),
(2,      '2017-05-20 00:00:42.000'),
(1,      '2017-05-20 00:00:40.000'),
(2,      '2017-05-20 00:00:52.000'),
(1,      '2017-05-20 00:00:50.000'),
(1,      '2017-05-20 00:01:00.000'),
(2,      '2017-05-20 00:01:02.000'),
(1,      '2017-05-20 00:01:10.000'),
(1,      '2017-05-20 00:01:20.000'),
(2,      '2017-05-20 00:01:12.000'),
(1,      '2017-05-20 00:01:30.000'),
(2,      '2017-05-20 00:01:22.000'),
(2,      '2017-05-20 00:01:32.000')

--set @@rowcount to 1
select 1

while @@ROWCOUNT > 0
begin
    DELETE T1
    from @mytable t1

    --previous time
    outer apply (select top 1 trackdt from  @mytable where vehid = t1.vehid and trackdt < t1.trackdt order by 1 desc)t2
    --previous time before that
    outer apply (select top 1 trackdt from  @mytable where vehid = t1.vehid and trackdt < t2.trackdt order by 1 desc)t3

    --previous time was less or equal to 20 seconds
    where DATEDIFF(second,t2.trackdt,t1.trackdt)<=20

    --previous time before that was more than 20 seconds or there is no time before
    and (DATEDIFF(second,t3.trackdt,t2.trackdt)>20 or t3.trackdt is null)

end

select * from @mytable


问:
Manually telling my ListBox's scrollbar where to be
```<code>private void button2_Click(object sender, EventArgs e)
{
    listBox1.AutoScrollOffset.Y = 10;
}
</code>```

I'm trying to manually set the location of my vertical scrollbar using code during runtime. This is what I've tried.

The .Y property says: "Gets or sets the Y coordinate of this point". Why doesn't this compile and give me an exception:

Error 1   Cannot modify the return value
  of
  'System.Windows.Forms.Control.AutoScrollOffset'
  because it is not a variable

答: Probably, AutoScrollOffset behaves iteself just like the Location. You cannot change Location's X or Y, but you can set Location to new Point(...).</p>

OwnerDisplayName: delete

ContentLicense: CC BY-SA 2.5

Body:
private void button2_Click(object sender, EventArgs e)
{
    listBox1.AutoScrollOffset.Y = 10;
}

I'm trying to manually set the location of my vertical scrollbar using code during runtime. This is what I've tried.

The .Y property says: "Gets or sets the Y coordinate of this point". Why doesn't this compile and give me an exception:

Error 1   Cannot modify the return value
  of
  'System.Windows.Forms.Control.AutoScrollOffset'
  because it is not a variable


问:
Creating Polygon using Google Map API
I am referring the URL : https://housing.com/in/buy/search?f=eyJiYXNlIjpbeyJ0eXBlIjoiUE9MWSIsInV1aWQiOiJmMGZhNTIwNjI0ZjNhOGRlOWY4NSIsImxhYmVsIjoiUGltcGxlIFNhdWRhZ2FyIn1dLCJ2IjoyLCJzIjoiZCJ9

I am trying to make something similar, can anybody suggest how can I achieve it. I tried to search and explore google map APIs, but could not understand which API in particular can be used.

答:
Try to read the Google Maps Showcase. Millions of apps and sites are using Google Maps APIs. Browse the showcase to see some of our favorite implementations.

You can use the MarkerClusterer library in combination with the Google Maps JavaScript API to combine markers of close proximity into clusters, and simplify the display of markers on the map.

Here's a sample project for MarkerCluster: https://github.com/googlemaps/v3-utility-library/tree/master/markerclusterer

Title: Creating Polygon using Google Map API


问:
Set Currency format in hybris
I am trying to set format of currency for a country with impex. Currentlty it is set as '42,953.87'. I want it should be changed to the format as '42.953,87'. Right now impex I am using for it is as

```<code>INSERT_UPDATE Currency;isocode[unique=true];conversion;digits;symbol
;ABC;1;2;kr
</code>```

What changes I need to make in above impex code to make it in format as 24.953,87 I tried ;ABC;;;2;kr but it does not work.Is there any other way in hybris through which I can change currency format?

答:
I believe you are trying to import using the HAC.

Please use the numberformat attribute modifier. Please note that you will have to specify the locale of the entries. To achieve a successful import, please follow the steps:

Specify the locale: #% impex.setLocale( Locale.ENGLISH);

Enable code execution in HAC

Execute code using the numberformat modifier.

INSERT_UPDATE Currency;isocode[unique=true];conversion;digits[numberformat==#.###,##];symbol
;ABC;1;24.953,87;kr

Please comment if you are still facing any issue.

Title: Set Currency format in hybris

Body:
I am trying to set format of currency for a country with impex. Currentlty it is set as '42,953.87'. I want it should be changed to the format as '42.953,87'. Right now impex I am using for it is as

INSERT_UPDATE Currency;isocode[unique=true];conversion;digits;symbol
;ABC;1;2;kr

What changes I need to make in above impex code to make it in format as 24.953,87 I tried ;ABC;;;2;kr but it does not work.Is there any other way in hybris through which I can change currency format?


问:
Group by and select lowest
I am trying to select the non repeated records of my database, and if there is one repeated, choose the one with the soonest date. To do so, I have tried the following query:

```<code>SELECT name, MIN(date) FROM `table` GROUP BY number_offer ORDER BY `date` ASC
</code>```

and then, showing them like this:

```<code>echo $row['fecha'];
echo $row['name'];
</code>```

The query selects correctly all the non repeated records but fails at selecting the sooner date (it says 'undefined index "date"'). Do you have any idea of how to do that?

答:
the index fail is related  to  a missing alias

```<code>SELECT name, MIN(date) as `date`
FROM `table`
GROUP BY number_offer
ORDER BY `date` ASC
</code>```

but you are select for name and grouping by number_offer ..the select for column not aggreation function and not in group by is deprecated

in sql starting recent db version

you should re evaluate you query using proper group by eg:

if you are select name you should group by name (and not number_offer)

```<code>SELECT name, MIN(date)
FROM `table`
GROUP BY name
ORDER BY `date` ASC
</code>```

Title: Group by and select lowest

Body:
I am trying to select the non repeated records of my database, and if there is one repeated, choose the one with the soonest date. To do so, I have tried the following query:

SELECT name, MIN(date) FROM `table` GROUP BY number_offer ORDER BY `date` ASC

and then, showing them like this:

echo $row['fecha'];
echo $row['name'];

The query selects correctly all the non repeated records but fails at selecting the sooner date (it says 'undefined index "date"'). Do you have any idea of how to do that?

Body:
the index fail is related  to  a missing alias

SELECT name, MIN(date) as `date`
FROM `table`
GROUP BY number_offer
ORDER BY `date` ASC

but you are select for name and grouping by number_offer ..the select for column not aggreation function and not in group by is deprecated

in sql starting recent db version

you should re evaluate you query using proper group by eg:

if you are select name you should group by name (and not number_offer)

SELECT name, MIN(date)
FROM `table`
GROUP BY name
ORDER BY `date` ASC


问:
RadioGroup not working in fragment android
I have faced an issue radio check change listener not working in the android fragment, I tried this within an activity it will work fine, while I convert into fragment it will give no response, please help me, here is my code.

K06_Away.java

```<code> public class K06_Away extends Fragment {

        private View kf06_view;
        protected Typeface tfLatoBold,tfLatoMedium,tfLatoRegular;
        private Button button_kf06_back,button_kf06_next;
        private TextView txtVw_kf06_resident_away;
        private EditText edTxt_kf06_visiting_lastname;
        private RadioGroup radioGp_kf06_resident_away;
        List<RadioButton> radioButtons = new ArrayList<RadioButton>();

        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            kf06_view = inflater.inflate(R.layout.k06_away, container, false);

            return kf06_view;
        }

        @Override
        public void onViewCreated(View view, Bundle savedInstanceState) {
            super.onViewCreated(view, savedInstanceState);
                   configViews();
        }

        private void configViews() {
            button_kf06_back = (Button) kf06_view.findViewById(R.id.button_kf06_back);
            button_kf06_next = (Button) kf06_view.findViewById(R.id.button_kf06_next);
            txtVw_kf06_resident_away= (TextView) kf06_view.findViewById(R.id.txtVw_kf06_resident_away);

            radioGp_kf06_resident_away = (RadioGroup) kf06_view.findViewById(R.id.radioGp_kf06_resident_away);
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_1_2_hours) );
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_halfday) );
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_allday) );
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_moreday) );

            configClickListeners();
            radioButtonAction();

        }
        private void configClickListeners() {
            button_kf06_back.setOnClickListener(this);
            button_kf06_next.setOnClickListener(this);
        }
        private void radioButtonAction(){
            for (RadioButton button : radioButtons){
                button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (isChecked) processRadioButtonClick(buttonView);
                        String radio_Text = buttonView.getText().toString();
                        int radio_Id = buttonView.getId();
                        System.out.println("Selected the Radio:"+radio_Text+", Radio-Id:"+radio_Id);
                    }
                });

            }
        }

        private void processRadioButtonClick(CompoundButton buttonView){
            for (RadioButton button : radioButtons){
                if (button != buttonView ) button.setChecked(false);
            }

        }

}
</code>```

k06_away.xml

```<code><RadioGroup
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/lLayout_kf06_resident_away"
            android:id="@+id/radioGp_kf06_resident_away">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:baselineAligned="false"
                tools:ignore="UselessParent">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:layout_marginLeft="150dp"
                    tools:ignore="RtlHardcoded">
                    <RadioButton
                        android:id="@+id/radio_kf06_1_2_hours"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_1"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:paddingStart="20dp"
                        android:layout_marginTop="150dp"
                        android:textColor="@color/colorWhite"
                        tools:ignore="NestedWeights,RtlSymmetry" />

                    <RadioButton
                        android:id="@+id/radio_kf06_halfday"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_2"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:textColor="@color/colorWhite"
                        android:paddingStart="20dp"
                        android:layout_marginTop="50dp"
                        tools:ignore="NestedWeights,RtlSymmetry"/>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:layout_marginLeft="50dp"
                    tools:ignore="RtlHardcoded">
                    <RadioButton
                        android:id="@+id/radio_kf06_allday"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_3"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:textColor="@color/colorWhite"
                        android:paddingStart="20dp"
                        android:layout_marginTop="150dp"
                        tools:ignore="NestedWeights,RtlSymmetry"/>

                    <RadioButton
                        android:id="@+id/radio_kf06_moreday"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_4"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:textColor="@color/colorWhite"
                        android:paddingStart="20dp"
                        android:layout_marginTop="50dp"
                        tools:ignore="NestedWeights,RtlSymmetry,RtlHardcoded"/>

                </LinearLayout>
            </LinearLayout>
        </RadioGroup>
</code>```

答:
1. Try to call method configViews() from onCreateView() and pass the view kf06_view as parameter.

2. Implement View.OnClickListener to handle button_kf06_back and button_kf06_next click events.

Update your K06_Away Fragment as below:

```<code>public class K06_Away extends Fragment implements View.OnClickListener {

    protected Typeface tfLatoBold,tfLatoMedium,tfLatoRegular;
    private Button button_kf06_back,button_kf06_next;
    private TextView txtVw_kf06_resident_away;
    private EditText edTxt_kf06_visiting_lastname;
    private RadioGroup radioGp_kf06_resident_away;
    List<RadioButton> radioButtons = new ArrayList<RadioButton>();

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View kf06_view = inflater.inflate(R.layout.k06_away, container, false);

        // Init
        configViews(kf06_view);

        return kf06_view;
    }

    private void configViews(View view) {
        button_kf06_back = (Button) view.findViewById(R.id.button_kf06_back);
        button_kf06_next = (Button) view.findViewById(R.id.button_kf06_next);
        txtVw_kf06_resident_away= (TextView) view.findViewById(R.id.txtVw_kf06_resident_away);

        radioGp_kf06_resident_away = (RadioGroup) view.findViewById(R.id.radioGp_kf06_resident_away);
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_1_2_hours) );
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_halfday) );
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_allday) );
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_moreday) );

        configClickListeners();
        radioButtonAction();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button_kf06_back:
                // Do something...
                break;
            case R.id.button_kf06_next:
                // Do something...
                break;
        }
    }

    private void configClickListeners() {
        button_kf06_back.setOnClickListener(this);
        button_kf06_next.setOnClickListener(this);
    }

    private void radioButtonAction(){
        for (RadioButton button : radioButtons){
            button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked) processRadioButtonClick(buttonView);
                    String radio_Text = buttonView.getText().toString();
                    int radio_Id = buttonView.getId();
                    System.out.println("Selected the Radio:"+radio_Text+", Radio-Id:"+radio_Id);
                }
            });
        }
    }

    private void processRadioButtonClick(CompoundButton buttonView){
        for (RadioButton button : radioButtons){
            if (button != buttonView ) button.setChecked(false);
        }
    }
}
</code>```

Body:
I have faced an issue radio check change listener not working in the android fragment, I tried this within an activity it will work fine, while I convert into fragment it will give no response, please help me, here is my code.

K06_Away.java

 public class K06_Away extends Fragment {

        private View kf06_view;
        protected Typeface tfLatoBold,tfLatoMedium,tfLatoRegular;
        private Button button_kf06_back,button_kf06_next;
        private TextView txtVw_kf06_resident_away;
        private EditText edTxt_kf06_visiting_lastname;
        private RadioGroup radioGp_kf06_resident_away;
        List<RadioButton> radioButtons = new ArrayList<RadioButton>();

        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            kf06_view = inflater.inflate(R.layout.k06_away, container, false);

            return kf06_view;
        }

        @Override
        public void onViewCreated(View view, Bundle savedInstanceState) {
            super.onViewCreated(view, savedInstanceState);
                   configViews();
        }

        private void configViews() {
            button_kf06_back = (Button) kf06_view.findViewById(R.id.button_kf06_back);
            button_kf06_next = (Button) kf06_view.findViewById(R.id.button_kf06_next);
            txtVw_kf06_resident_away= (TextView) kf06_view.findViewById(R.id.txtVw_kf06_resident_away);

            radioGp_kf06_resident_away = (RadioGroup) kf06_view.findViewById(R.id.radioGp_kf06_resident_away);
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_1_2_hours) );
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_halfday) );
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_allday) );
            radioButtons.add( (RadioButton)kf06_view.findViewById(R.id.radio_kf06_moreday) );

            configClickListeners();
            radioButtonAction();

        }
        private void configClickListeners() {
            button_kf06_back.setOnClickListener(this);
            button_kf06_next.setOnClickListener(this);
        }
        private void radioButtonAction(){
            for (RadioButton button : radioButtons){
                button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (isChecked) processRadioButtonClick(buttonView);
                        String radio_Text = buttonView.getText().toString();
                        int radio_Id = buttonView.getId();
                        System.out.println("Selected the Radio:"+radio_Text+", Radio-Id:"+radio_Id);
                    }
                });

            }
        }

        private void processRadioButtonClick(CompoundButton buttonView){
            for (RadioButton button : radioButtons){
                if (button != buttonView ) button.setChecked(false);
            }

        }

}

k06_away.xml

<RadioGroup
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/lLayout_kf06_resident_away"
            android:id="@+id/radioGp_kf06_resident_away">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:baselineAligned="false"
                tools:ignore="UselessParent">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:layout_marginLeft="150dp"
                    tools:ignore="RtlHardcoded">
                    <RadioButton
                        android:id="@+id/radio_kf06_1_2_hours"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_1"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:paddingStart="20dp"
                        android:layout_marginTop="150dp"
                        android:textColor="@color/colorWhite"
                        tools:ignore="NestedWeights,RtlSymmetry" />

                    <RadioButton
                        android:id="@+id/radio_kf06_halfday"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_2"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:textColor="@color/colorWhite"
                        android:paddingStart="20dp"
                        android:layout_marginTop="50dp"
                        tools:ignore="NestedWeights,RtlSymmetry"/>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:layout_marginLeft="50dp"
                    tools:ignore="RtlHardcoded">
                    <RadioButton
                        android:id="@+id/radio_kf06_allday"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_3"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:textColor="@color/colorWhite"
                        android:paddingStart="20dp"
                        android:layout_marginTop="150dp"
                        tools:ignore="NestedWeights,RtlSymmetry"/>

                    <RadioButton
                        android:id="@+id/radio_kf06_moreday"
                        style="@style/radionbutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/label_resident_away_hour_4"
                        android:layout_gravity="left"
                        android:checked="false"
                        android:textSize="25sp"
                        android:textColor="@color/colorWhite"
                        android:paddingStart="20dp"
                        android:layout_marginTop="50dp"
                        tools:ignore="NestedWeights,RtlSymmetry,RtlHardcoded"/>

                </LinearLayout>
            </LinearLayout>
        </RadioGroup>

Body:
1. Try to call method configViews() from onCreateView() and pass the view kf06_view as parameter.

2. Implement View.OnClickListener to handle button_kf06_back and button_kf06_next click events.

Update your K06_Away Fragment as below:

public class K06_Away extends Fragment implements View.OnClickListener {

    protected Typeface tfLatoBold,tfLatoMedium,tfLatoRegular;
    private Button button_kf06_back,button_kf06_next;
    private TextView txtVw_kf06_resident_away;
    private EditText edTxt_kf06_visiting_lastname;
    private RadioGroup radioGp_kf06_resident_away;
    List<RadioButton> radioButtons = new ArrayList<RadioButton>();

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View kf06_view = inflater.inflate(R.layout.k06_away, container, false);

        // Init
        configViews(kf06_view);

        return kf06_view;
    }

    private void configViews(View view) {
        button_kf06_back = (Button) view.findViewById(R.id.button_kf06_back);
        button_kf06_next = (Button) view.findViewById(R.id.button_kf06_next);
        txtVw_kf06_resident_away= (TextView) view.findViewById(R.id.txtVw_kf06_resident_away);

        radioGp_kf06_resident_away = (RadioGroup) view.findViewById(R.id.radioGp_kf06_resident_away);
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_1_2_hours) );
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_halfday) );
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_allday) );
        radioButtons.add( (RadioButton) view.findViewById(R.id.radio_kf06_moreday) );

        configClickListeners();
        radioButtonAction();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button_kf06_back:
                // Do something...
                break;
            case R.id.button_kf06_next:
                // Do something...
                break;
        }
    }

    private void configClickListeners() {
        button_kf06_back.setOnClickListener(this);
        button_kf06_next.setOnClickListener(this);
    }

    private void radioButtonAction(){
        for (RadioButton button : radioButtons){
            button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked) processRadioButtonClick(buttonView);
                    String radio_Text = buttonView.getText().toString();
                    int radio_Id = buttonView.getId();
                    System.out.println("Selected the Radio:"+radio_Text+", Radio-Id:"+radio_Id);
                }
            });
        }
    }

    private void processRadioButtonClick(CompoundButton buttonView){
        for (RadioButton button : radioButtons){
            if (button != buttonView ) button.setChecked(false);
        }
    }
}


问:
Input/output operations per second of an application in Windows
I need the Input/output operations per second information of an application. Is there a way to monitor Input/output operations per second of an application ?</p>

答:
Programmatically getting per-process disk io statistics on Windows? seems to answer this question.

You can call GetProcessIoCounters to get overall disk I/O data per process - you'll need to keep track of deltas and converting to time-based rate yourself.

This API will tell you total number of I/O operations as well as total bytes.


问:
Facebook embed posts mobile app

 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
 eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
 minim veniam

Lorem ipsum dolor sit amet,
 consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
 labore et dolore magna aliqua. Ut enim ad minim veniam"```
</div>
</div>
</p>

<p>I have an app that shows posts from a blog and everything works fine but facebook posts. Wherever the facebook iframe appears i receive information:</p>

```"This Facebook post is no longer avaliable. It may have been removed or the privacy settings of the post may have changed."
```

<p>I download content of the post and place it to UiWebView using</p>

```self.webView.loadHTMLString(html, baseURL: nil)
```

I placed part of the content string in snippet:

Moreover - i can display facebook videos using that method - it all works. I also tested it on Android - posts and videos works using the content i placed. Any suggestions what am i doing wrong?

答:
I resolved my problem, all i had to do is pass url to post from blog - embed posts from facebook are displayed correctly now</p>

```<code>self.webView.loadHTMLString(html, baseURL: url)
</code>```

Title: Facebook embed posts mobile app

Body:
 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
 eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
 minim veniam

Lorem ipsum dolor sit amet,
 consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
 labore et dolore magna aliqua. Ut enim ad minim veniam"

I have an app that shows posts from a blog and everything works fine but facebook posts. Wherever the facebook iframe appears i receive information:

"This Facebook post is no longer avaliable. It may have been removed or the privacy settings of the post may have changed."

I download content of the post and place it to UiWebView using

self.webView.loadHTMLString(html, baseURL: nil)

I placed part of the content string in snippet:

Moreover - i can display facebook videos using that method - it all works. I also tested it on Android - posts and videos works using the content i placed. Any suggestions what am i doing wrong?

Body:
I resolved my problem, all i had to do is pass url to post from blog - embed posts from facebook are displayed correctly now

self.webView.loadHTMLString(html, baseURL: url)


问:
Looking at a list of numbers and getting that number from another file>
I don't really know how to word the question, but I have this file with a number and a decimal next to it, like so(the file name is num.txt):

```<code>33    0.239
78    0.298
85    1.993
96    0.985
107    1.323
108    1.000
</code>```

I have this string of numbers that I want to find the certain numbers from the file, take the decimal numbers, and append it to a list:

```<code>['78','85','108']
</code>```

Here is my code so far:

```<code>chosen_number = ['78','85','108']
memory_list = []
for line in open(path/to/num.txt):
    checker = line[0:2]
    if not checker in chosen_number: continue
    dec = line.split()[-1]
    memory_list.append(float(dec))
</code>```

The error they give to me is that it is not in a list and they only account for the 3 digit numbers. I don't really understand why this is happening and would like some tips to know how to fix it. Thanks.

As for the error, there is no actual error. The only problem is that they ignore the two digit numbers and only get the three digit numbers. I want them to get both the 2 and 3 digit numbers. For example, the script would pass 78 and 85, going to the line with '108'.

答:
Your checker is undefined. The below code works.

N.B. I have used startswith because, the number might appear elsewhere in the line.

```<code>chosen_number = ['78','85','108']
memory_list = []

with open('path/to/num.txt') as f:
    for line in f:
        if any(line.startswith(i) for i in chosen_number):
            memory_list.append(float(line.split()[1]))

print(memory_list)
</code>```

Output:

```<code>[0.298, 1.993, 1.0]
</code>```

Body:
I don't really know how to word the question, but I have this file with a number and a decimal next to it, like so(the file name is num.txt):

33    0.239
78    0.298
85    1.993
96    0.985
107    1.323
108    1.000

I have this string of numbers that I want to find the certain numbers from the file, take the decimal numbers, and append it to a list:

['78','85','108']

Here is my code so far:

chosen_number = ['78','85','108']
memory_list = []
for line in open(path/to/num.txt):
    checker = line[0:2]
    if not checker in chosen_number: continue
    dec = line.split()[-1]
    memory_list.append(float(dec))

The error they give to me is that it is not in a list and they only account for the 3 digit numbers. I don't really understand why this is happening and would like some tips to know how to fix it. Thanks.

As for the error, there is no actual error. The only problem is that they ignore the two digit numbers and only get the three digit numbers. I want them to get both the 2 and 3 digit numbers. For example, the script would pass 78 and 85, going to the line with '108'.

Body:
Your checker is undefined. The below code works.

N.B. I have used startswith because, the number might appear elsewhere in the line.

chosen_number = ['78','85','108']
memory_list = []

with open('path/to/num.txt') as f:
    for line in f:
        if any(line.startswith(i) for i in chosen_number):
            memory_list.append(float(line.split()[1]))

print(memory_list)

Output:

[0.298, 1.993, 1.0]


问:
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings
I am getting following error whien i use php -i

date

date/time support => enabled "Olson" Timezone Database Version =>
  0.system Timezone Database => internal PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings.

  You are required to use the date.timezone setting or the
  date_default_timezon

  e_set() function. In case you used any of those methods and you are
  still gettin

  g this warning, you most likely misspelled the timezone identifier. We
  selected

  'UTC' for 'UTC/0.0/no DST' instead in Unknown on line 0 Default
  timezone => UTC

Directive => Local Value => Master Value date.default_latitude =>
  31.7667 => 31.7667 date.default_longitude => 35.2333 => 35.2333 date.sunrise_zenith => 90.583333 => 90.583333 date.sunset_zenith =>
  90.583333 => 90.583333 date.timezone => America/Los_Angeles => America/Los_Angeles

My /etc/php.ini has following setting

```<code>[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = America/Los_Angeles

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.default-latitude
;date.default_latitude = 31.7667

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.default-longitude
;date.default_longitude = 35.2333

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.sunset-zenith
;date.sunset_zenith = 90.583333
</code>```

PHP version details are as below

PHP 5.3.3 (cli) (built: Dec  5 2013 07:09:40) Copyright (c) 1997-2010
  The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend
  Technologies

Apache version as below

Server version: Apache/2.2.15 (Unix) Server built:   Jul 18 2014
  02:31:29

I have restarted Apache multiple times

答:
change date.timezone = UTC
then run command sudo service httpd restart

Body:
I am getting following error whien i use php -i

date

date/time support => enabled "Olson" Timezone Database Version =>
  0.system Timezone Database => internal PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings.

  You are required to use the date.timezone setting or the
  date_default_timezon

  e_set() function. In case you used any of those methods and you are
  still gettin

  g this warning, you most likely misspelled the timezone identifier. We
  selected

  'UTC' for 'UTC/0.0/no DST' instead in Unknown on line 0 Default
  timezone => UTC

Directive => Local Value => Master Value date.default_latitude =>
  31.7667 => 31.7667 date.default_longitude => 35.2333 => 35.2333 date.sunrise_zenith => 90.583333 => 90.583333 date.sunset_zenith =>
  90.583333 => 90.583333 date.timezone => America/Los_Angeles => America/Los_Angeles

My /etc/php.ini has following setting

[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = America/Los_Angeles

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.default-latitude
;date.default_latitude = 31.7667

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.default-longitude
;date.default_longitude = 35.2333

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.sunset-zenith
;date.sunset_zenith = 90.583333

PHP version details are as below

PHP 5.3.3 (cli) (built: Dec  5 2013 07:09:40) Copyright (c) 1997-2010
  The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend
  Technologies

Apache version as below

Server version: Apache/2.2.15 (Unix) Server built:   Jul 18 2014
  02:31:29

I have restarted Apache multiple times


问:
What's the recommended way to pass path params in Angular 2 http object
I am using angular 2, I need to do a delete request to a backend having a path param like this

```<code>import { Http } from "@angular/http";

deletePlayer(id: string): Observable<any> {
        return this.http.delete("/api/players/{id}");
}
</code>```

My question is, what is the best way to pass the id path param to the http object. I've used UrlSearchParams for the query parameters but this does not seem to have an option for path params. The docu is not clear about this either.

答:
You can use TypeScript template syntax : </p>

```<code>return this.http.delete(`/api/players/${id}`);
</code>```

Body:
I am using angular 2, I need to do a delete request to a backend having a path param like this

import { Http } from "@angular/http";

deletePlayer(id: string): Observable<any> {
        return this.http.delete("/api/players/{id}");
}

My question is, what is the best way to pass the id path param to the http object. I've used UrlSearchParams for the query parameters but this does not seem to have an option for path params. The docu is not clear about this either.

Body:
You can use TypeScript template syntax :

return this.http.delete(`/api/players/${id}`);


问:
angular 2 http post issue
i am getting   error , when i am trying to sent post request to my server
 how to solve this ?

error

XMLHttpRequest cannot load http://localhost/posttest.php. Request
  header field Content-Type is not allowed by
  Access-Control-Allow-Headers in preflight response.

php code
 http://localhost/posttest.php

```<code>header("Access-Control-Allow-Origin: *");<br>
$data = array("token"=>"","l_date"=>"");<br>
$data_json = json_encode($data);<br>
echo $data_json;
</code>```

angular 2 http post code

```<code>import {Injectable} from '@angular/core';
import { Http, RequestOptions,Headers,Response } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class PostsService{
constructor(private http:Http){
    console.log("post service initialized ... ");

}
getPosts(id:number){
    return this.http.get('https://jsonplaceholder.typicode.com/posts/'+id).map(res=>res.json());
}
postexample(){
    var json=JSON.stringify({milla:"hi",login2:"milla"});
    var param="json="+json;
    let headers1 = new Headers({ 'Accept': 'application/json','Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers1 });
    let body = JSON.stringify(json);
    return this.http.post('http://localhost/posttest.php', body, options ).map((res: Response) => res.json());
}
}
</code>```

答:
in php add the another access control headers:</p>

```<code>http://localhost/posttest.php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
$data = array("token"=>"","l_date"=>"");
$data_json = json_encode($data);
echo $data_json;
</code>```

Title: angular 2 http post issue

Body:
i am getting   error , when i am trying to sent post request to my server
 how to solve this ?

error

XMLHttpRequest cannot load http://localhost/posttest.php. Request
  header field Content-Type is not allowed by
  Access-Control-Allow-Headers in preflight response.

php code
 http://localhost/posttest.php

header("Access-Control-Allow-Origin: *");

$data = array("token"=>"","l_date"=>"");

$data_json = json_encode($data);

echo $data_json;

angular 2 http post code

import {Injectable} from '@angular/core';
import { Http, RequestOptions,Headers,Response } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class PostsService{
constructor(private http:Http){
    console.log("post service initialized ... ");

}
getPosts(id:number){
    return this.http.get('https://jsonplaceholder.typicode.com/posts/'+id).map(res=>res.json());
}
postexample(){
    var json=JSON.stringify({milla:"hi",login2:"milla"});
    var param="json="+json;
    let headers1 = new Headers({ 'Accept': 'application/json','Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers1 });
    let body = JSON.stringify(json);
    return this.http.post('http://localhost/posttest.php', body, options ).map((res: Response) => res.json());
}
}

Body:
in php add the another access control headers:

http://localhost/posttest.php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
$data = array("token"=>"","l_date"=>"");
$data_json = json_encode($data);
echo $data_json;


问:
Issue with Redis install "cc: Command not found"
Installing redis is really easy. I have done it on several VM. But on one instance, I am facing the following problem.

```<code>[root@server redis-2.4.2]# make
cd src && make all
make[1]: Entering directory `/home/user/redis-2.4.2/src'
MAKE hiredis
make[2]: Entering directory `/home/user/redis-2.4.2/deps/hiredis'
cc -c -std=c99 -pedantic -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings    -g -ggdb  net.c
make[2]: cc: Command not found
make[2]: *** [net.o] Error 127
make[2]: Leaving directory `/home/user/redis-2.4.2/deps/hiredis'
make[1]: *** [dependencies] Error 2
make[1]: Leaving directory `/home/user/redis-2.4.2/src'
make: *** [all] Error 2
</code>```

Is there any other way to install redis?

答:
I got myself into similar situation, hope below steps work

make distclean

sudo make

Body:
Installing redis is really easy. I have done it on several VM. But on one instance, I am facing the following problem.

[root@server redis-2.4.2]# make
cd src && make all
make[1]: Entering directory `/home/user/redis-2.4.2/src'
MAKE hiredis
make[2]: Entering directory `/home/user/redis-2.4.2/deps/hiredis'
cc -c -std=c99 -pedantic -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings    -g -ggdb  net.c
make[2]: cc: Command not found
make[2]: *** [net.o] Error 127
make[2]: Leaving directory `/home/user/redis-2.4.2/deps/hiredis'
make[1]: *** [dependencies] Error 2
make[1]: Leaving directory `/home/user/redis-2.4.2/src'
make: *** [all] Error 2

Is there any other way to install redis?


问:
Unable to change value at edit time with codeIgniter validation
Here i have a list of categories and user can add a new category as well as edit them.

Now at the edit time i'm using server-side validation by codeigniter for reduce redundancies . but the issue is the, whenever i edit an existing category then it can't update it because it compare with their original value, that is wrong. i trying to many time but unable to fix this issue.

Here is my code

```<code>public function category_upd()
{
    extract($_POST);
    $userId = $this->session->userdata('id');
    $original_value = $this->db->query("SELECT cat_name FROM category WHERE user_id=".$userId." and  cat_name ='".$_POST['cat_name']."'") ;

    $original_value  = $original_value->result_array();
    $original_value = $original_value[0]['cat_name'];

    $original_value2 = $this->db->query("SELECT cat_name FROM category WHERE user_id=".$userId." and  cat_name ='".$_POST['cat_name']."'") ;

    $original_value2  = $original_value2->result_array();

    $original_value2 = $original_value2[0]['cat_name'];

    if(ucwords($_POST['cat_name']) != $original_value) {
        $this->session->set_flashdata('cat_failed','Category must be unique.');
        $is_unique =  '|is_unique[category.cat_name]';
    } else if(ucwords($original_value2 == "")){

        echo "go";
        exit;

        $this->session->set_flashdata('cat_failed','Category must be unique.');
        $is_unique =  '|is_unique[category.cat_name]';
    } else {
        $is_unique =  '';
    }
    $this->form_validation->set_rules('cat_name','Category','trim|required'.$is_unique);
    if($this->form_validation->run() ) {
</code>```

A snap with error

I need your kind efforts. Thanks

答:
Check category name is alredy in database.     </p>

```<code> $newcategoryName=$this->input->post('category');
    $query = $this->db->get_where('category', array('cat_name' => $newcategoryName,'user_id' => $userId));
    $val=$query->result_array();
    $original_value = $val[0]['cat_name'];
            if($newcategoryName != $original_value) {
               $is_unique =  '|is_unique[users.EMAIL]';
            } else {
               $is_unique =  '';
            }
    $this->form_validation->set_rules('cat_name', 'Category', 'required|trim|xss_clean'.$is_unique);
</code>```

Body:
Here i have a list of categories and user can add a new category as well as edit them.

Now at the edit time i'm using server-side validation by codeigniter for reduce redundancies . but the issue is the, whenever i edit an existing category then it can't update it because it compare with their original value, that is wrong. i trying to many time but unable to fix this issue.

Here is my code

public function category_upd()
{
    extract($_POST);
    $userId = $this->session->userdata('id');
    $original_value = $this->db->query("SELECT cat_name FROM category WHERE user_id=".$userId." and  cat_name ='".$_POST['cat_name']."'") ;

    $original_value  = $original_value->result_array();
    $original_value = $original_value[0]['cat_name'];

    $original_value2 = $this->db->query("SELECT cat_name FROM category WHERE user_id=".$userId." and  cat_name ='".$_POST['cat_name']."'") ;

    $original_value2  = $original_value2->result_array();

    $original_value2 = $original_value2[0]['cat_name'];

    if(ucwords($_POST['cat_name']) != $original_value) {
        $this->session->set_flashdata('cat_failed','Category must be unique.');
        $is_unique =  '|is_unique[category.cat_name]';
    } else if(ucwords($original_value2 == "")){

        echo "go";
        exit;

        $this->session->set_flashdata('cat_failed','Category must be unique.');
        $is_unique =  '|is_unique[category.cat_name]';
    } else {
        $is_unique =  '';
    }
    $this->form_validation->set_rules('cat_name','Category','trim|required'.$is_unique);
    if($this->form_validation->run() ) {

A snap with error

I need your kind efforts. Thanks

Body:
Check category name is alredy in database.

 $newcategoryName=$this->input->post('category');
    $query = $this->db->get_where('category', array('cat_name' => $newcategoryName,'user_id' => $userId));
    $val=$query->result_array();
    $original_value = $val[0]['cat_name'];
            if($newcategoryName != $original_value) {
               $is_unique =  '|is_unique[users.EMAIL]';
            } else {
               $is_unique =  '';
            }
    $this->form_validation->set_rules('cat_name', 'Category', 'required|trim|xss_clean'.$is_unique);


问:
how to retrieve the value of javascript var through python?
I need to get the data of productSkus[ using python but I don't know how to access it. the javascript comes from http://www.ulta.com/lid-lingerie-eye-tint?productId=xlsImpprod15361061 .
This is how it looks like.

```<code><script type="text/javascript">
  var currentSkuId = '2502111';
  var currentProductId = 'xlsImpprod15361061';

  var productSkus = new Object();

              productSkus[2502111] =
                {"displayName":"Fame & Fortune","id":"2502111","imgUrl":"http://images.ulta.com/is/image/Ulta/2502111?$detail$","largeImgUrl":"http://images.ulta.com/is/image/Ulta/2502111?$lg$","swatchImgUrl":"http://images.ulta.com/is/image/Ulta/2502111sw?$50px$","swatchHoverImgUrl":"http://images.ulta.com/is/image/Ulta/2502111sm?$md$","skuSize":"0.13","skuSizeUOM":"oz"};........
</code>```

Can anyone help me with this?

答: use html form to submit the data to server, or across api</p>


问:
Functional calls get blocked in Angular2 (they are sanitized)
Hi i have an  footer div in that i'm appending innerHtml from typescript file

HTML Code:

```<code><div class="footerbar" [innerHTML]="printProgressfooterHtmlContent"></div>
</code>```

TypeScriptCode:`

```<code>this.printProgressfooterHtmlContent = '<ul class="nav navbar-nav footerNavBarLeft"><li class="backButtonLi"><a href="#/about"><i class="fa fa-angle-left"></i><h4 class="footerDone">BACK</h4></a></li></ul><ul  class="nav navbar-nav footerNavBarRight"><li class="backButtonLi LiSeperator"><a class="footerProgressLeftAtag"><h4 class="footerDone">|</h4></a></li><li><a ><h4 class="footerDone" (click)="myFunc()">GROUPS</h4></a></li></ul>';
</code>```

In here i'm calling a function myFunc() but when the compiler gets loaded i get an warning as WARNING: sanitizing HTML stripped some content in console.

Please provide a proper solution.

Thanks in advance.

答:
You should use the DOMSanitizer:

```<code>import {DomSanitizer} from '@angular/platform-browser'
</code>```

...

```<code>constructor(private sanitizer: DomSanitizer)
</code>```

...

```<code>this.printProgressfooterHtmlContent = this.sanitizer.bypassSecurityTrustHtml('<ul class="nav navbar-nav foo...');
</code>```

Body:
Hi i have an  footer div in that i'm appending innerHtml from typescript file

HTML Code:

TypeScriptCode:`

this.printProgressfooterHtmlContent = '

BACK

|

GROUPS

';

In here i'm calling a function myFunc() but when the compiler gets loaded i get an warning as WARNING: sanitizing HTML stripped some content in console.

Please provide a proper solution.

Thanks in advance.

Body:
You should use the DOMSanitizer:

import {DomSanitizer} from '@angular/platform-browser'

...

constructor(private sanitizer: DomSanitizer)

...

this.printProgressfooterHtmlContent = this.sanitizer.bypassSecurityTrustHtml('<ul class="nav navbar-nav foo...');