问:
How can I search a json file to return values satisfying a particular criteria?
Here is my json file:

```<code>{"items":[{"reputation":6623,"user_id":836,"location":"Durham, United Kingdom","link":"https://datascience.stackexchange.com/users/836/neil-slater","display_name":"Neil Slater"},{"reputation":6267,"user_id":381,"location":"Silicon Valley","link":"https://datascience.stackexchange.com/users/381/emre","display_name":"Emre"},{"reputation":5033,"user_id":2452,"location":"Atlanta, GA","link":"https://datascience.stackexchange.com/users/2452/aleksandr-blekh","display_name":"Aleksandr Blekh"},{"reputation":3537,"user_id":11097,"location":"Gurgaon, India","link":"https://datascience.stackexchange.com/users/11097/dawny33","display_name":"Dawny33"},{"reputation":3257,"user_id":21,"location":"London, United Kingdom","link":"https://datascience.stackexchange.com/users/21/sean-owen","display_name":"Sean Owen"}]
</code>```

How can I extract display names of users who are from a particular location, say Israel? I am trying to write nested query for the same but getting syntax errors.

答:
```<code>import json

fp = open('myfile.json', 'r')
data = json.load(fp)

for user in data['items']:
    if user['location'] == 'Israel':
        print (user['display_name'])
</code>```

Body:
Here is my json file:

{"items":[{"reputation":6623,"user_id":836,"location":"Durham, United Kingdom","link":"https://datascience.stackexchange.com/users/836/neil-slater","display_name":"Neil Slater"},{"reputation":6267,"user_id":381,"location":"Silicon Valley","link":"https://datascience.stackexchange.com/users/381/emre","display_name":"Emre"},{"reputation":5033,"user_id":2452,"location":"Atlanta, GA","link":"https://datascience.stackexchange.com/users/2452/aleksandr-blekh","display_name":"Aleksandr Blekh"},{"reputation":3537,"user_id":11097,"location":"Gurgaon, India","link":"https://datascience.stackexchange.com/users/11097/dawny33","display_name":"Dawny33"},{"reputation":3257,"user_id":21,"location":"London, United Kingdom","link":"https://datascience.stackexchange.com/users/21/sean-owen","display_name":"Sean Owen"}]

How can I extract display names of users who are from a particular location, say Israel? I am trying to write nested query for the same but getting syntax errors.


来源: stackexchange

问:
json_decode doesn't work on my string
I have JSON Object which I have encoded like so

```<code>{
"id": "",
"steps": [
             {
        "target": "purchase_order_items_itemmaster_id",
        "title": "",
        "placement": "",
        "content": "",
        "xoffset": "",
        "yoffset": ""
              }
         ]
}
$JSONData = json_encode($finalData,JSON_PRETTY_PRINT);
</code>```

I am taking this JSON data and storing it in a file like so

```<code>File::put("path","var tour = \n [ \n\t $JSONData \n ];");
</code>```

which looks something like this in the file

```<code>    var tour =
 [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];
</code>```

Now I am reading it back form the second line like so

```<code> [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];
</code>```

The problem is when I want to decode it back it doesn't happen,this is how I am trying to do that,

```<code>$lines = file_get_contents("path",NULL,NULL,10);

$a = json_decode($lines);
</code>```

Now according to expected output the $a should have the decoded data but it has null.

Can someone point out the mistake?

答:
It will be

```<code>$str = file_get_contents('http://example.com/example.json/');
 $json = json_decode($str, true); // decode the JSON into an associative array
</code>```

See the post
Parsing JSON file with PHP

ContentLicense: CC BY-SA 3.0

Title: json_decode doesn't work on my string

Body:
I have JSON Object which I have encoded like so

{
"id": "",
"steps": [
             {
        "target": "purchase_order_items_itemmaster_id",
        "title": "",
        "placement": "",
        "content": "",
        "xoffset": "",
        "yoffset": ""
              }
         ]
}
$JSONData = json_encode($finalData,JSON_PRETTY_PRINT);

I am taking this JSON data and storing it in a file like so

File::put("path","var tour = \n [ \n\t $JSONData \n ];");

which looks something like this in the file

    var tour =
 [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];

Now I am reading it back form the second line like so

 [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];

The problem is when I want to decode it back it doesn't happen,this is how I am trying to do that,

$lines = file_get_contents("path",NULL,NULL,10);

$a = json_decode($lines);

Now according to expected output the $a should have the decoded data but it has null.

Can someone point out the mistake?

Body:
It will be

$str = file_get_contents('http://example.com/example.json/');
 $json = json_decode($str, true); // decode the JSON into an associative array

See the post
Parsing JSON file with PHP


问:
How to replicate android:editable="false" in code?
In the layout you can set the EditText widget to be non-editable via the android:editable attribute.

How can I do this in code?  I need to make the EditText widget to be editable depending on conditions.

答:
I think the correct way to achieve the desired effect is:

```<code>mEditView.setText("my text", BufferType.NORMAL);
</code>```

If you want to switch between editable and non-editable you can do the following:

```<code>// Switch to non-editable
mEditView.setText(mEditView.getText(), BufferType.NORMAL);

// Switch back to editable
mEditView.setText(mEditView.getText(), BufferType.EDITABLE);
</code>```

OwnerDisplayName: AngryHacker

Body:
I think the correct way to achieve the desired effect is:

mEditView.setText("my text", BufferType.NORMAL);

If you want to switch between editable and non-editable you can do the following:

// Switch to non-editable
mEditView.setText(mEditView.getText(), BufferType.NORMAL);

// Switch back to editable
mEditView.setText(mEditView.getText(), BufferType.EDITABLE);

ContentLicense: CC BY-SA 2.5


问:
Choose from list?
Can someone tell me why this won't work? I can't for the life of me figure out why it doesn't. It compiles fine, looks fine, and this method has worked everywhere else for me... Really need some help, anyone know what's wrong?

```<code>set areatype to (choose from list {"Triagles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")

if areatype contains "Triangles" then

    set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")

    set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")

    set area to (height * base) / 2

    display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

else

    if areatype contains "Trapezium" then

        set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")

        set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")

        set area to ((a + b) / 2) * h
        display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

    end if
end if
</code>```

-Thanks

答:
Look at your very first line in the code.  You spelled Triangles incorrectly  and you needed the "s" in Trapeziums added to the "else" line in the code. </p>

```<code>on goAgain()

    set areatype to (choose from list {"Triangles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")

    if areatype contains "Triangles" then
        set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")
        set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")
        set area to (height * base) / 2

        display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

        if the button returned of the result is "Go again" then
            goAgain()
        else
            return
        end if

    else

        if areatype contains "Trapeziums" then
            set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")
            set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")
            set height2 to text returned of (display dialog "What is the height of the trapezium?" with title "Area Calculator" default answer "")
            set area to ((base1 + base2) / 2) * height2

            display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

            if the button returned of the result is "Go again" then
                goAgain()
            else
                return
            end if

        end if
    end if
end goAgain

goAgain()
</code>```

Title: Choose from list?

Body:
Can someone tell me why this won't work? I can't for the life of me figure out why it doesn't. It compiles fine, looks fine, and this method has worked everywhere else for me... Really need some help, anyone know what's wrong?

set areatype to (choose from list {"Triagles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")

if areatype contains "Triangles" then

    set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")

    set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")

    set area to (height * base) / 2

    display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

else

    if areatype contains "Trapezium" then

        set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")

        set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")

        set area to ((a + b) / 2) * h
        display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

    end if
end if

-Thanks

Body:
Look at your very first line in the code.  You spelled Triangles incorrectly  and you needed the "s" in Trapeziums added to the "else" line in the code.

on goAgain()

    set areatype to (choose from list {"Triangles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")

    if areatype contains "Triangles" then
        set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")
        set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")
        set area to (height * base) / 2

        display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

        if the button returned of the result is "Go again" then
            goAgain()
        else
            return
        end if

    else

        if areatype contains "Trapeziums" then
            set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")
            set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")
            set height2 to text returned of (display dialog "What is the height of the trapezium?" with title "Area Calculator" default answer "")
            set area to ((base1 + base2) / 2) * height2

            display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}

            if the button returned of the result is "Go again" then
                goAgain()
            else
                return
            end if

        end if
    end if
end goAgain

goAgain()


问:
Split vals depending on condition
I need to split invoice.number like if there is white-space Serial is first part and Number is second. But also if there is no whitespace then Serial stays blank and Number will be all invoice.number. how can i do it?
i need to create some IF statement in my for loop ?

Update

for Exmaple invoice.number is AA 555 so Serial will be AA and number will be 555 , but if invoice.number is AA555 Serial will be "" and Number will be AA555. But we don't know what exact invoice.number will be

```<code>for line in invoice.invoice_line_ids:
     vals = {
            'Serial': invoice.number or '',
            'Number':invoice.number or '',
            }
</code>```

答:
Becase the values is a dictionary, so you can use it very sample,

```<code>def parse(number):
    resultList = []
    resultDirt = dict()
    tempList = number.split(" ")
    if len(tempList) > 1:
        resultDirt['Serial'] = tempList[0]
        resultDirt['Number'] = tempList[1]
    else:
        resultDirt['Serial'] = ""
        resultDirt['Number'] = tempList[0]

    resultList.append(resultDirt)
    print(resultList)
    return resultList

parse("1321321 jkhhkhk")
parse("13215465465")
</code>```

The output is,

```<code>[{'Number': 'jkhhkhk', 'Serial': '1321321'}]
[{'Number': '13215465465', 'Serial': ''}]
</code>```

Title: Split vals depending on condition

Body:
I need to split invoice.number like if there is white-space Serial is first part and Number is second. But also if there is no whitespace then Serial stays blank and Number will be all invoice.number. how can i do it?
i need to create some IF statement in my for loop ?

Update

for Exmaple invoice.number is AA 555 so Serial will be AA and number will be 555 , but if invoice.number is AA555 Serial will be "" and Number will be AA555. But we don't know what exact invoice.number will be

for line in invoice.invoice_line_ids:
     vals = {
            'Serial': invoice.number or '',
            'Number':invoice.number or '',
            }

Body:
Becase the values is a dictionary, so you can use it very sample,

def parse(number):
    resultList = []
    resultDirt = dict()
    tempList = number.split(" ")
    if len(tempList) > 1:
        resultDirt['Serial'] = tempList[0]
        resultDirt['Number'] = tempList[1]
    else:
        resultDirt['Serial'] = ""
        resultDirt['Number'] = tempList[0]

    resultList.append(resultDirt)
    print(resultList)
    return resultList

parse("1321321 jkhhkhk")
parse("13215465465")

The output is,

[{'Number': 'jkhhkhk', 'Serial': '1321321'}]
[{'Number': '13215465465', 'Serial': ''}]


问:
Fix XmlBeanFactory Deprecated error Spring
These days I'm learning Spring Framework. And I'm following some youtube videos.
According to the video I wrote my first code in Spring as same as the tutorial. But at a point I'm getting XmlBeanFactory deprecated warning which are not shown in tutorial.

I'm having two classes on MyPackage package.

```<code>package MyPackage;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class DrawingApp {

public static void main(String[] args) {
    // TODO Auto-generated method stub

    BeanFactory factory=new XmlBeanFactory(new FileSystemResource("Spring.xml"));
    Triangle triangle =(Triangle) factory.getBean("triangle");

    triangle.draw();
}

}
</code>```

Here my XmlBeanFactory is deprecated. I checked everywhere couldn't fix it

This is my Triangle class.

```<code>package MyPackage;

public class Triangle {

public void draw(){
    System.out.println("Draw a Triangle");
}
}
</code>```

And this is my xml file "spring.xml"

```<code><?xml version="1.0" encoding="UTF-8"?>

<beans>
<bean id="triangle" class="MyPackage.Triangle"></bean>
</beans>
</code>```

答:
As XmlBeanFactory was deprecated you can use ClassPathXmlApplicationContext

```<code>    public static void main(String[] args) {
        ApplicationContext context=new ClassPathXmlApplicationContext("spring.xml");
        Triangle trianle=(Triangle)context.getBean("triangle");
        trianle.draw();

    }
</code>```

Body:
These days I'm learning Spring Framework. And I'm following some youtube videos.
According to the video I wrote my first code in Spring as same as the tutorial. But at a point I'm getting XmlBeanFactory deprecated warning which are not shown in tutorial.

I'm having two classes on MyPackage package.

package MyPackage;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class DrawingApp {

public static void main(String[] args) {
    // TODO Auto-generated method stub

    BeanFactory factory=new XmlBeanFactory(new FileSystemResource("Spring.xml"));
    Triangle triangle =(Triangle) factory.getBean("triangle");

    triangle.draw();
}

}

Here my XmlBeanFactory is deprecated. I checked everywhere couldn't fix it

This is my Triangle class.

package MyPackage;

public class Triangle {

public void draw(){
    System.out.println("Draw a Triangle");
}
}

And this is my xml file "spring.xml"

<?xml version="1.0" encoding="UTF-8"?>

<beans>
<bean id="triangle" class="MyPackage.Triangle"></bean>
</beans>

Body:
As XmlBeanFactory was deprecated you can use ClassPathXmlApplicationContext

    public static void main(String[] args) {
        ApplicationContext context=new ClassPathXmlApplicationContext("spring.xml");
        Triangle trianle=(Triangle)context.getBean("triangle");
        trianle.draw();

    }


问:
Xcode attempted to locate or generate matching signing assets

Please let me know why this happen and what is the solution.

答:
Please check how are you archieving your code:

Select your project in xcode(after play stop button on top)

Change scheme to release.

In your entitlement file make sure app-release has a value 'production'

Archieve again and it should work


问:
Google Sheets only return columns containing key word using arrayformula
I have a pivot table of info, with totals (the totals columns contain the word "Total").

I want to do some more processing with this data, so I created a new sheet.
The new sheet first has

=arrayformula('Pivot Table mins'!A:B)

to grab the first two columns.

But then I want to "import" over JUST the columns that have the word Total in them.

e.g. if the Pivot Table data spans columns A to Z, but only columns D & F have the keyword "Total", I only want to "import" those columns.

I could do a query, but then I'd have to have a huge query (e.g. I'd have to have ..."C contains 'total' OR D contains 'total'..." etc...all the way to Z, I believe)

Is there a better way to do this?

答:
Case #1. Some columns

The first option is to build query

The second option is to use filter:

=FILTER(Sheet!A:G,(REGEXMATCH(Sheet!D:D,"Total"))+(REGEXMATCH(Sheet!F:F,"Total")))

Plus + in the formula means OR logic.

Regexmatch us used to make sure column contains the string.

Edit

You may also shorten the formula to:

=FILTER(Sheet!A:G,(REGEXMATCH(Sheet!D:D&Sheet!F:F,"Total")))

It works because Sheet!D:D&Sheet!F:F concatenates 2 columns so if any contains "Total", the filter will find it.

Case #2. Any column from range

Answer to the comment:

Is there a way to do that for all columns? That's my problem...the
  columns with the word "Total" changes.

=FILTER('Sheet'!A:M,MMULT(--REGEXMATCH('Sheet'!A:L,"Total"),ROW(INDIRECT("a1:a"&COLUMNS('Sheet'!A:L)))^0))

used mmult to convert 2d array of true/false values into single line. Now any row from A:L where some column contains "Total" will be returned as a result.


问:
Set up a link in slack reminder
Is there any way to set up a slack /reminder with a link in the text?

Example:

```<code>/reminder me Hey! Check out the weather in https://www.yr.no/place/Norway/ every weekday
</code>```

When I try to type this on Slack, I get the following message:

/reminder me Hey! Check out the weather in https://www.yr.no/place/Norway/ every weekday is not a valid command. In Slack, all messages that start with the "/" character are interpreted as commands.

If you are trying to send a message and not run a command, try preceding the "/" with an empty space.

答:
yep, it is always nice to include links to Docs, Jira, etc. To include a link, use quotation marks when you describe what to remind.
e.g., /remind @Trump to "use Google Scholar when searching for scientific  evidence https://scholar.google.com" every weekday.</p>

Title: Set up a link in slack reminder

Body:
Is there any way to set up a slack /reminder with a link in the text?

Example:

/reminder me Hey! Check out the weather in https://www.yr.no/place/Norway/ every weekday

When I try to type this on Slack, I get the following message:

/reminder me Hey! Check out the weather in https://www.yr.no/place/Norway/ every weekday is not a valid command. In Slack, all messages that start with the "/" character are interpreted as commands.

If you are trying to send a message and not run a command, try preceding the "/" with an empty space.


答:
pass the second parameter true for recursively decoding

```<code>$a = json_decode(chop($lines,";"),true);
</code>```

check the php mannual here json_decode

Title: json_decode doesn't work on my string

Body:
pass the second parameter true for recursively decoding

$a = json_decode(chop($lines,";"),true);

check the php mannual here json_decode


问:
How to trigger the update on entity in spring data?
I have two entity employee and Salary, I want my salary entity should updated whenever there is change in Employee Entity role property.
Employee Entity:
emp_id
name
Role
Salary Entity:
id
emp_id
SalarySlab

I need to automatically update the salary slab whenever there is any change in role of employee.
I am not able get the proper approach to achieve this in spring data/jpa

答:
I assume You have a @OneToOne relation between Employee and Salary, so your Employee entity has a salary field annotated properly. For example:

```<code>@OneToOne(mappedBy="employee")
private Salary salary;
</code>```

More about entity relation mapping here.

The simplest solution is that You have to put this logic in the role setter. For example:

```<code>void setRole(Role newRole) {
    this.role = newRole;
    updateSalary();
}

void updateSalary() { ... }
</code>```

If you have no setter method for that field - which I would not recommend - You can use JPA's @PrePersist and @PreUpdate annotations. For example:

```<code>@PrePersist
@PreUpdate
public void updateSalary() { ... }
</code>```

This way updateSalary will be called every time spring creates a new Employee entity or updates an existing one. More about lifecycle callbacks' hibernate implemantation here.

Body:
I assume You have a @OneToOne relation between Employee and Salary, so your Employee entity has a salary field annotated properly. For example:

@OneToOne(mappedBy="employee")
private Salary salary;

More about entity relation mapping here.

The simplest solution is that You have to put this logic in the role setter. For example:

void setRole(Role newRole) {
    this.role = newRole;
    updateSalary();
}

void updateSalary() { ... }

If you have no setter method for that field - which I would not recommend - You can use JPA's @PrePersist and @PreUpdate annotations. For example:

@PrePersist
@PreUpdate
public void updateSalary() { ... }

This way updateSalary will be called every time spring creates a new Employee entity or updates an existing one. More about lifecycle callbacks' hibernate implemantation here.


问:
Is paypal do direct payment possible from individual account
I have PayPal Individual account and I want my customers can pay via credit and debit card. For that I am using paypal dodirect payment method. In that we need API signature, username and password.

I have tried taking credentials from my paypal account > selling tools > API access > Add or edit API permissions but nothing happens with this. It just redirects to setting page (https://www.paypal.com/myaccount/settings/)

My question is, can I get API access signature, username and password for do direct payment from my individual account?

答:
If by individual you mean a Personal PayPal account, then no, you won't be able to do that.  You'll need a business account for access to most APIs, and you'll need PayPal Payments Pro for access to DoDirectPayment specifically.

PayPal Pro is $30/mo, however, I can get you a Pro account for free if you want to contact me directly to discuss.


问:
GCC: how to fix or suppress the warning: unknown escape sequence: '\#'
The OpenGL ES shader code is defined as a C string. To make writing the shader code more intuitively, I define a macro named SHADER_STRING(code) like below. But I encounter a GCC warning unknown escape sequence: '\#' and don't know how to suppress it or fix it.

A example code is below

```<code>#include <stdio.h>

int main(void)
{
#define _SHADER_STRING(code) #code
#define SHADER_STRING(code) _SHADER_STRING(code)
    // OpenGL ES Shader codes
    char vShaderStr[] = SHADER_STRING(
        \#version 300 es \n

        void main()
        {
            // ... some OpenGL ES codes.
        });
    printf("%s\n", vShaderStr);
    return 0;
}
</code>```

Because the #version is a preprocessor supported by OpenGL ES 3.0, then it's invalid to replace the \# with \\#, otherwise the codes will become

```<code>\#version 300 es
void main() { }
</code>```

The OpenGL shader compiler will complained knowing nothing about the \#version .

答:
```<code>#define _SHADER_STRING(str) #str
#define SHADER_STRING(str) _SHADER_STRING(str)
// OpenGL ES Shader codes
char vShaderStr_30[] = SHADER_STRING(#version 300 es \n

    void main()
    {
         // ...
    });
</code>```

But without a good Minimal, Complete, and Verifiable example it's hard to have a better answer.

Body:
The OpenGL ES shader code is defined as a C string. To make writing the shader code more intuitively, I define a macro named SHADER_STRING(code) like below. But I encounter a GCC warning unknown escape sequence: '\#' and don't know how to suppress it or fix it.

A example code is below

#include <stdio.h>

int main(void)
{
#define _SHADER_STRING(code) #code
#define SHADER_STRING(code) _SHADER_STRING(code)
    // OpenGL ES Shader codes
    char vShaderStr[] = SHADER_STRING(
        \#version 300 es \n

        void main()
        {
            // ... some OpenGL ES codes.
        });
    printf("%s\n", vShaderStr);
    return 0;
}

Because the #version is a preprocessor supported by OpenGL ES 3.0, then it's invalid to replace the \# with \\#, otherwise the codes will become

\#version 300 es
void main() { }

The OpenGL shader compiler will complained knowing nothing about the \#version .

Body:
#define _SHADER_STRING(str) #str
#define SHADER_STRING(str) _SHADER_STRING(str)
// OpenGL ES Shader codes
char vShaderStr_30[] = SHADER_STRING(#version 300 es \n

    void main()
    {
         // ...
    });

But without a good Minimal, Complete, and Verifiable example it's hard to have a better answer.


问:
NSIS Compile - mysql Not Recognised as operable program - Why does NsExec::ExecToLog statement Fail?
I have stared at this until almost BLIND! Checked PATH Environment, Use DOS shortname where possible etc. Below is script with test results and comments.
I have search many posts prior to submission of following.

---- TESTS 01 - 04 follow
; Var $SYSDIR           = c:\Windows\System32

; =======================================================================

[TEST-01]

    Var folder

    StrCpy $folder "$PROGRAMFILES64\MySQL\MySQL Server 5.7"

[TEST-STMT-01]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-01]

    'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after PROGRAM in "c:\PROGRAM FILES\MySQL...)"

; =======================================================================

[TEST-02]

    Var folder

    StrCpy $folder "c:\PROGRA~1\MySQL\MySQL Server 5.7"

[TEST-STMT-02]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-02]

    'c:\PROGRA~1\MySQL\MySQL' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after MySQL in "...\MySQL\MySQL Server 5.7)"

; =======================================================================

[TEST-03]
    Var folder

    StrCpy $folder "c:\PROGRAM FILES\MySQL\MySQL Server 5.7"

[TEST-STMT-03]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-03]

    'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after PROGRAM in "c:\PROGRAM FILES\MySQL...)"

; =======================================================================

[TEST-04]
    Var folder

    StrCpy $folder "NOT USED"

[TEST-STMT-04]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "c:\PROGRAM FILES\MySQL\MySQL Server 5.7\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-04]

    'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after PROGRAM in "c:\PROGRAM FILES\MySQL...)"

; =========================================================================
Any Suggestions would be appreciated!

```<code>Name "MySQL script Installation"

# use variables initialized from custom.ini
Var folder
Var login
Var errorsrc

!define DBNAME demo      ; target database

# Included files
!include MUI2.nsh
!include LogicLib.nsh

OutFile Sample_script.exe

ShowInstDetails show

Page custom GetInfos "" ": Information page"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English

# Ensure the user has Administrator Rights
Function .onInit

###NOTE: Only one STRCPY valid for TEST-01 thru TEST-04
;; StrCpy $folder "$PROGRAMFILES64\MySQL\MySQL Server 5.7"   # TEST-01
StrCpy $folder "c:\PROGRA~1\MySQL\MySQL Server 5.7"       # TEST-02
;; StrCpy $folder "c:\PROGRAM FILES\MySQL\MySQL Server 5.7"  # TEST-03
;; StrCpy $folder "NOT USED"                                 # TEST-04
StrCpy $login root

FunctionEnd

Section -Main

DetailPrint "verify SysDir: $SYSDIR"
DetailPrint "verify nsEXEC target: $folder\bin\mysql.exe"

###NOTE TEST-01 thru TEST-03 USE 1st nsEXEC stmt, COMMENT ";;" 2nd nsEXEC stmt
nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"'    # TEST01 - 03
### TEST-04 comment ";;" previous nsEXEC  and un-comment " " next nsExec statement                   # TEST-04
;;    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "c:\PROGRAM FILES\MySQL\MySQL Server 5.7\bin\mysql.exe"  -u$login -p -e "SHOW DATABASES;"'
Pop $0  # Get Results

StrCmp "error" $0 +1 +2
DetailPrint "return-error: $0"    ; ck return = 'error'
DetailPrint "return-err:   $0"    ; return = 1

StrCmp $0 1 +1 +3
StrCpy $errorsrc "DB Connect Error - Wrong login or password"
Goto abortinst

##    DetailPrint "Check Options Switch"
##    Check Switch Create DB = 1 true, then CREATE database before, else IMPORT
##    StrCmp $createdb 1 createdbs importdbs

createdbs:
DetailPrint "Creating DATABASE"
##  Do it .....
Goto abortinst

importdbs:
DetailPrint "IMPORT SQL files"
##   do it......
Goto endinst

abortinst:
DetailPrint "                         "
DetailPrint "$\n An error occured ! $\n"
DetailPrint "  $errorsrc              "
DetailPrint "                         "
Abort

endinst:
DetailPrint "ADD Table Successful     "
SectionEnd

Function GetInfos
!insertmacro MUI_HEADER_TEXT "Database informations" "Database informations - please fill all elements"
;;    !insertmacro INSTALLOPTIONS_DISPLAY "custom.ini"
FunctionEnd
</code>```

答:
'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

This is telling you that there's a problem with the path leading up to your MySQL folder. You should know it's a problem because there's spaces within it's path.

```<code>!define SQLFLD `$PROGRAMFILES64\MySQL\MySQL Server 5.7`

ReadEnvStr $R0 COMSPEC
ExecDos::Exec /TOSTACK `"$R0" /c "${SQLFLD}\bin\mysql.exe"  -u$login -p -e "SHOW DATABASES;"`
</code>```

Try this.. haven't tested this myself though.

Body:
I have stared at this until almost BLIND! Checked PATH Environment, Use DOS shortname where possible etc. Below is script with test results and comments.
I have search many posts prior to submission of following.

---- TESTS 01 - 04 follow
; Var $SYSDIR           = c:\Windows\System32

; =======================================================================

[TEST-01]

    Var folder

    StrCpy $folder "$PROGRAMFILES64\MySQL\MySQL Server 5.7"

[TEST-STMT-01]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-01]

    'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after PROGRAM in "c:\PROGRAM FILES\MySQL...)"

; =======================================================================

[TEST-02]

    Var folder

    StrCpy $folder "c:\PROGRA~1\MySQL\MySQL Server 5.7"

[TEST-STMT-02]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-02]

    'c:\PROGRA~1\MySQL\MySQL' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after MySQL in "...\MySQL\MySQL Server 5.7)"

; =======================================================================

[TEST-03]
    Var folder

    StrCpy $folder "c:\PROGRAM FILES\MySQL\MySQL Server 5.7"

[TEST-STMT-03]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-03]

    'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after PROGRAM in "c:\PROGRAM FILES\MySQL...)"

; =======================================================================

[TEST-04]
    Var folder

    StrCpy $folder "NOT USED"

[TEST-STMT-04]

    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "c:\PROGRAM FILES\MySQL\MySQL Server 5.7\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"' $0

[TEST-ERR-04]

    'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

; Returns an error code $0 = 1  (error, space after PROGRAM in "c:\PROGRAM FILES\MySQL...)"

; =========================================================================
Any Suggestions would be appreciated!

Name "MySQL script Installation"

# use variables initialized from custom.ini
Var folder
Var login
Var errorsrc

!define DBNAME demo      ; target database

# Included files
!include MUI2.nsh
!include LogicLib.nsh

OutFile Sample_script.exe

ShowInstDetails show

Page custom GetInfos "" ": Information page"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English

# Ensure the user has Administrator Rights
Function .onInit

###NOTE: Only one STRCPY valid for TEST-01 thru TEST-04
;; StrCpy $folder "$PROGRAMFILES64\MySQL\MySQL Server 5.7"   # TEST-01
StrCpy $folder "c:\PROGRA~1\MySQL\MySQL Server 5.7"       # TEST-02
;; StrCpy $folder "c:\PROGRAM FILES\MySQL\MySQL Server 5.7"  # TEST-03
;; StrCpy $folder "NOT USED"                                 # TEST-04
StrCpy $login root

FunctionEnd

Section -Main

DetailPrint "verify SysDir: $SYSDIR"
DetailPrint "verify nsEXEC target: $folder\bin\mysql.exe"

###NOTE TEST-01 thru TEST-03 USE 1st nsEXEC stmt, COMMENT ";;" 2nd nsEXEC stmt
nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "$folder\bin\mysql.exe" -u$login -p -e "SHOW DATABASES;"'    # TEST01 - 03
### TEST-04 comment ";;" previous nsEXEC  and un-comment " " next nsExec statement                   # TEST-04
;;    nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c "c:\PROGRAM FILES\MySQL\MySQL Server 5.7\bin\mysql.exe"  -u$login -p -e "SHOW DATABASES;"'
Pop $0  # Get Results

StrCmp "error" $0 +1 +2
DetailPrint "return-error: $0"    ; ck return = 'error'
DetailPrint "return-err:   $0"    ; return = 1

StrCmp $0 1 +1 +3
StrCpy $errorsrc "DB Connect Error - Wrong login or password"
Goto abortinst

##    DetailPrint "Check Options Switch"
##    Check Switch Create DB = 1 true, then CREATE database before, else IMPORT
##    StrCmp $createdb 1 createdbs importdbs

createdbs:
DetailPrint "Creating DATABASE"
##  Do it .....
Goto abortinst

importdbs:
DetailPrint "IMPORT SQL files"
##   do it......
Goto endinst

abortinst:
DetailPrint "                         "
DetailPrint "$\n An error occured ! $\n"
DetailPrint "  $errorsrc              "
DetailPrint "                         "
Abort

endinst:
DetailPrint "ADD Table Successful     "
SectionEnd

Function GetInfos
!insertmacro MUI_HEADER_TEXT "Database informations" "Database informations - please fill all elements"
;;    !insertmacro INSTALLOPTIONS_DISPLAY "custom.ini"
FunctionEnd

Body:
'c:\PROGRAM' is not recognized as an internal or external command, operable program or batch file.

This is telling you that there's a problem with the path leading up to your MySQL folder. You should know it's a problem because there's spaces within it's path.

!define SQLFLD `$PROGRAMFILES64\MySQL\MySQL Server 5.7`

ReadEnvStr $R0 COMSPEC
ExecDos::Exec /TOSTACK `"$R0" /c "${SQLFLD}\bin\mysql.exe"  -u$login -p -e "SHOW DATABASES;"`

Try this.. haven't tested this myself though.


问:
Assign variable to group based on filter of one event using data.table
I need to create new columns based on if a user has completed an action at least once.

```<code> USER ACTION
 A    Attack
 A    Jump
 B    Attack
 B    Die
 C    Attack
 C    Die
 C    Jump
 D    Die
</code>```

Desired result would be something like:

```<code> ## If ACTION == something
 ## Create new column and apply '1' for that user for all rows

 USER ACTION HAS_DIED HAS_JUMPED HAS_ATTACKED
 A    Attack    0         1            1
 A    Jump      0         1            1
 B    Attack    1         0            1
 B    Die       1         0            1
 C    Attack    1         1            1
 C    Die       1         1            1
 C    Jump      1         1            1
 D    Die       1         0            0
</code>```

So I can end up with a unique USER list

```<code> USER  HAS_DIED HAS_JUMPED HAS_ATTACKED
 A       0         1            1
 B       1         0            1
 C       1         1            1
 D       1         0            0
</code>```

I've been using the method below of filtering and merging for each feature, but that's getting cumbersome with large amounts of features. Ex)

```<code> ## mark logs of deaths
 df[ACTION == "Die", HAS_DIED := 1]

 ## get unique list of users that have died
 died_df <- df[HAS_DIED == 1]

 ## merge and change none 1s to 0s
 merged_df <- died_df[df, on = "USER"]
 merged_df$HAS_DIED[is.na(merged_df$HAS_DIED)] <- 0
</code>```

Looking for a faster and more efficient way to do this!

答:
As the initial object is data.table, we can use dcast from data.table and it is very efficient as well

```<code>library(data.table)
setnames(dcast(setDT(df1), USER ~ACTION, length), -1,
         c('HAS_ATTACKED', 'HAS_DIED', 'HAS_JUMPED'))[]
#    USER HAS_ATTACKED HAS_DIED HAS_JUMPED
#1:    A            1        0          1
#2:    B            1        1          0
#3:    C            1        1          1
#4:    D            0        1          0
</code>```

Body:
I need to create new columns based on if a user has completed an action at least once.

 USER ACTION
 A    Attack
 A    Jump
 B    Attack
 B    Die
 C    Attack
 C    Die
 C    Jump
 D    Die

Desired result would be something like:

 ## If ACTION == something
 ## Create new column and apply '1' for that user for all rows

 USER ACTION HAS_DIED HAS_JUMPED HAS_ATTACKED
 A    Attack    0         1            1
 A    Jump      0         1            1
 B    Attack    1         0            1
 B    Die       1         0            1
 C    Attack    1         1            1
 C    Die       1         1            1
 C    Jump      1         1            1
 D    Die       1         0            0

So I can end up with a unique USER list

 USER  HAS_DIED HAS_JUMPED HAS_ATTACKED
 A       0         1            1
 B       1         0            1
 C       1         1            1
 D       1         0            0

I've been using the method below of filtering and merging for each feature, but that's getting cumbersome with large amounts of features. Ex)

 ## mark logs of deaths
 df[ACTION == "Die", HAS_DIED := 1]

 ## get unique list of users that have died
 died_df <- df[HAS_DIED == 1]

 ## merge and change none 1s to 0s
 merged_df <- died_df[df, on = "USER"]
 merged_df$HAS_DIED[is.na(merged_df$HAS_DIED)] <- 0

Looking for a faster and more efficient way to do this!

Body:
As the initial object is data.table, we can use dcast from data.table and it is very efficient as well

library(data.table)
setnames(dcast(setDT(df1), USER ~ACTION, length), -1,
         c('HAS_ATTACKED', 'HAS_DIED', 'HAS_JUMPED'))[]
#    USER HAS_ATTACKED HAS_DIED HAS_JUMPED
#1:    A            1        0          1
#2:    B            1        1          0
#3:    C            1        1          1
#4:    D            0        1          0


问:
Chained Hash Tables vs. Open-Addressed Hash Tables
Can somebody explain the main differences between (advantages / disadvantages) the two implementations?

For a library, what implementation is recommended?

答:
My understanding (in simple terms) is that both the methods has pros and cons, though most of the libraries use Chaining strategy.

Chaining Method:

Here the hash tables array maps to a linked list of items. This is efficient if the number of collision is fairly small. The worst case scenario is O(n) where n is the number of elements in the table.

Open Addressing with Linear Probe:

Here when the collision occurs, move on to the next index until we find an open spot. So, if the number of collision is low, this is very fast and space efficient. The limitation here is the total number of entries in the table is limited by the size of the array. This is not the case with chaining.

There is another approach which is Chaining with binary search trees. In this approach, when the collision occurs, they are stored in binary search tree instead of linked list. Hence, the worst case scenario here would be O(log n). In practice, this approach is best suited when there is a extremely nonuniform distribution.


问:
Weird positioning in certain browsers
I'll try to be short and clean. I did website for friend, although she says some people complain about pink quote field to cover the text area, I've tried this on different PCs, browsers but haven't seen this kind of issue. So I was thinking maybe that old IE or something?

Here's websites link: http://www.zlobekbambino.pl

Thanks in advance

答:
Assuming you have a Windows PC, you can test with all versions of IE by installing IETester. It's a very usefull program that allows you to run all versions of IE in tabs in the same window.

Obviously though, it only works on a Windows PC, so if you're on a Mac you won't be able to use it. In that case, http://www.browsershots.org allows you to download screenshots from virtually any browser ever released. The downside of that is that you only get a static screenshot, so not much use for testing dynamic content, but still a useful tool.

Title: Weird positioning in certain browsers


问:
UWP search in a ComboBox
I am making a UWP App in which I have a ComboBox with a lot of items. I want users to be able to jump to a particular item by typing in. I discovered  that using IsTextSearchEnabled="True" on the ComboBox does exactly what I want. But I am not sure how to use this property and the docs has no examples on it

```<code>   <ComboBox x:Name="BrowseBySourceComboBox"
                                      SelectionChanged="BrowseBySourceComboBox_SelectionChanged"
                                      Grid.Row="1"
                                      PlaceholderText="Select Source"
                                      IsTextSearchEnabled="True"
                                      Style="{StaticResource ComboBoxStyle}"
                                      ItemsSource="{x:Bind BrowseBySourceComboBoxList, Mode=OneWay}">
</code>```

This is not giving any text box to type in.

答:
But I am not sure how to use this property and the docs has no examples on it

According to the remarks of IsTextSearchEnabled property:

Starting in Windows 10, version 1607, ComboBox introduces a text search feature. By default, the ComboBox jumps to a relevant value as the user types.

This feature enabled by default, you don't need set anything for the Combobox it will work if your windows 10 version is higher than 1607. For how it works, for example, as the following picture shows, when the Comboxbox get focused, I type B from the keyboard it will jump to Blue,  type R it will jump to red. More details you may reference slide 29 of this ppt.

This is not giving any text box to type in.

Combobox is not editable in UWP app. The IsEditable will always return false.  The IsTextSearchEnabled property worked without a editable area. If you want a control that has editable TextBox and as well a drop down list can be searched by text typed from the TextBox, the AutoSuggestBox is more fitter for you as @Justin XL said. Here is the official sample of AutoSuggestBox.

Title: UWP search in a ComboBox

Body:
I am making a UWP App in which I have a ComboBox with a lot of items. I want users to be able to jump to a particular item by typing in. I discovered  that using IsTextSearchEnabled="True" on the ComboBox does exactly what I want. But I am not sure how to use this property and the docs has no examples on it

   <ComboBox x:Name="BrowseBySourceComboBox"
                                      SelectionChanged="BrowseBySourceComboBox_SelectionChanged"
                                      Grid.Row="1"
                                      PlaceholderText="Select Source"
                                      IsTextSearchEnabled="True"
                                      Style="{StaticResource ComboBoxStyle}"
                                      ItemsSource="{x:Bind BrowseBySourceComboBoxList, Mode=OneWay}">

This is not giving any text box to type in.


问:
Position animated icons and remove overlapping using CSS
I am trying to position the icons to the right and the tags to the center.
My website is using BootStrap and Font-Awesome. Below is the HTML:

```<code><div class="row">
  <div class="col-lg-12" style="text-align: center">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>
    <span> </span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>
    <span> </span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>
    <span> </span>
    <i class="fa fa-heart faa-pulse animated" style="float:right;"></i>
    <i class="fa fa-star faa-pulse animated" style="float:right;"></i>
    <i class="fa fa-smile-o faa-pulse animated" style="float:right;"></i>
  </div>
</div>
<div class="row">
  <div class="col-lg-12">
    <h1 class="post-header" style="text-align: center">This is the header</h1>
  </div>
</div>
</code>```

CSS:

```<code>@keyframes pulse {
  0% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }

  50% {
    -webkit-transform: scale(0.8);
    -ms-transform: scale(0.8);
    transform: scale(0.8);
  }

  100% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }
}

.faa-pulse.animated,
.faa-pulse.animated-hover:hover,
.faa-parent.animated-hover:hover > .faa-pulse {
  -webkit-animation: pulse 2s linear infinite !important;
  animation: pulse 2s linear infinite !important;
  font-size:1.8em;
}
.fa-heart {
    color: red !important;
}
.fa-star {
    color: gold !important;
}
.fa-smile-o {
  color: deeppink !important;
}
</code>```

The problem is my icons are overlapping with each other during animation and the tags are not aligned to the center. Also,there is very little space between the icons. How can I solve this problem?

Here is the demo

答:
There are 2 ways to do this,

from user guide example http://fontawesome.io/examples/

Use fa-fw to set icons at a fixed width. Great to use when different icon widths throw off alignment. Especially useful in things like nav lists & list groups.

```<code> <div class="row">

   <!-- edited (1) -->
  <div class="col-lg-12" style="text-align: center;position: relative;">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>
    <span> </span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>
    <span> </span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>

    <!-- edited  (2) -->
    <div style="position: absolute;top: 0;right: 0;">
        <i class="fa fa-fw fa-heart faa-pulse animated" ></i>
        <i class="fa fa-fw fa-star faa-pulse animated" ></i>
        <i class="fa fa-fw fa-smile-o faa-pulse animated" ></i>
    </div>

  </div>
</div>
<div class="row">
  <div class="col-lg-12">
    <h1 class="post-header" style="text-align: center">This is the header</h1>
  </div>
</div>
</code>```

or u could change css

```<code>.faa-pulse{
  margin:3px;
}
</code>```

see this https://jsfiddle.net/jayakrishnancn/73Lfxnpg/3/

Body:
I am trying to position the icons to the right and the tags to the center.
My website is using BootStrap and Font-Awesome. Below is the HTML:

      Health

      Fitness

      Safety

This is the header

CSS:

@keyframes pulse {
  0% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }

  50% {
    -webkit-transform: scale(0.8);
    -ms-transform: scale(0.8);
    transform: scale(0.8);
  }

  100% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }
}

.faa-pulse.animated,
.faa-pulse.animated-hover:hover,
.faa-parent.animated-hover:hover > .faa-pulse {
  -webkit-animation: pulse 2s linear infinite !important;
  animation: pulse 2s linear infinite !important;
  font-size:1.8em;
}
.fa-heart {
    color: red !important;
}
.fa-star {
    color: gold !important;
}
.fa-smile-o {
  color: deeppink !important;
}

The problem is my icons are overlapping with each other during animation and the tags are not aligned to the center. Also,there is very little space between the icons. How can I solve this problem?

Here is the demo

Body:
There are 2 ways to do this,

from user guide example http://fontawesome.io/examples/

Use fa-fw to set icons at a fixed width. Great to use when different icon widths throw off alignment. Especially useful in things like nav lists & list groups.

 <div class="row">

   <!-- edited (1) -->
  <div class="col-lg-12" style="text-align: center;position: relative;">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>
    <span>&nbsp;</span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>
    <span>&nbsp;</span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>

    <!-- edited  (2) -->
    <div style="position: absolute;top: 0;right: 0;">
        <i class="fa fa-fw fa-heart faa-pulse animated" ></i>
        <i class="fa fa-fw fa-star faa-pulse animated" ></i>
        <i class="fa fa-fw fa-smile-o faa-pulse animated" ></i>
    </div>

  </div>
</div>
<div class="row">
  <div class="col-lg-12">
    <h1 class="post-header" style="text-align: center">This is the header</h1>
  </div>
</div>

or u could change css

.faa-pulse{
  margin:3px;
}

see this https://jsfiddle.net/jayakrishnancn/73Lfxnpg/3/


问:
slideshow of forms by clicking dots on the right side of it
I am working on making a slideshow of forms. Here is my working codepen link. As you can see I have two dots on the right side which if I click then it opens another form. Only thing is those dots are getting shown at the very bottom of my page. I want to show them actually on the form instead at the right side.

For example as shown in this image. I am trying to replicate exactly like this image and as you can see those dots are on the form instead but at the very right side of it close to the right border. Also LAST NAME, PHONE NUMBER , PROVINCE and CITY label and its textbox are just above those dots. I want to do something similar. Is this possible to do?

Below is my HTML code:

```<code><!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>SlidesJS Standard Code Example</title>
  <meta name="description" content="SlidesJS is a simple slideshow plugin for jQuery. Packed with a useful set of features to help novice and advanced developers alike create elegant and user-friendly slideshows.">

  <!-- SlidesJS Required (if responsive): Sets the page width to the device width. -->
  <meta name="viewport" content="width=device-width">
  <!-- End SlidesJS Required -->

  <!-- CSS for slidesjs.com example -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  <!-- End CSS for slidesjs.com example -->

  <!-- SlidesJS Optional: If you'd like to use this design -->
  <style>
    body {
      -webkit-font-smoothing: antialiased;
      font: normal 15px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
      color: #232525;
    }

    #slides,
    #slides2,
    #slides3 {
      display: none;
      margin-bottom:50px;
    }

    .slidesjs-navigation {
      margin-top:3px;
    }

    .slidesjs-previous {
      margin-right: 5px;
      float: left;
    }

    .slidesjs-next {
      margin-right: 5px;
      float: left;
    }

    .slidesjs-pagination {
      margin: 6px 0 0;
      float: right;
      list-style: none;
    }

    .slidesjs-pagination li {
      float: left;
      margin: 0 1px;
    }

    .slidesjs-pagination li a {
      display: block;
      width: 13px;
      height: 0;
      padding-top: 13px;
      background-image: url("https://s16.postimg.org/pt4k43i9x/pagination.png");
      background-position: 0 0;
      float: left;
      overflow: hidden;
    }

    .slidesjs-pagination li a.active,
    .slidesjs-pagination li a:hover.active {
      background-position: 0 -13px
    }

    .slidesjs-pagination li a:hover {
      background-position: 0 -26px
    }
    .navbar {
      overflow: hidden
    }
  </style>
  <!-- End SlidesJS Optional-->

  <!-- SlidesJS Required: These styles are required if you'd like a responsive slideshow -->
  <style>
    #slides {
      display: none
    }

    .container {
      margin: 0 auto
    }

    /* For tablets & smart phones */
    @media (max-width: 767px) {
      body {
        padding-left: 20px;
        padding-right: 20px;
      }
      .container {
        width: auto
      }
    }

    /* For smartphones */
    @media (max-width: 480px) {
      .container {
        width: auto
      }
    }

    /* For smaller displays like laptops */
    @media (min-width: 768px) and (max-width: 979px) {
      .container {
        width: 724px
      }
    }

    /* For larger displays */
    @media (min-width: 1200px) {
      .container {
        width: 1170px
      }
    }
  </style>
  <!-- SlidesJS Required: -->
</head>
<body>
<div class="topnav">
   <img src="https://s4.postimg.org/ojd13poal/northman_wordmark_CMYK.png">
   <nav>
      <ul>
         <li class="dropdown">
            <a href="#"><b>INSURANCE</b> <i class="fa fa-angle-down"></i></a>
            <ul class="dropdown-content">
               <li><a href="#"><i>INDIVIDUAL</i></a>
               </li>
               <li><a href="#"><i>CORPORATE</i></a>
               </li>
            </ul>
         </li>
         <li class="our-story">OUR STORY</li>
         <li class="login-signup">Log In | Sign up</li>
         <li class="get-covered">GET <strong style="font-style:italic">COVERED</strong>
         </li>
      </ul>
   </nav>
</div>
  <!-- SlidesJS Required: Start Slides -->
  <!-- The container is used to define the width of the slideshow -->
  <div class="container">
   <h3>INSURANCE FORM</h3>
   <h4><i>BASIC DETAILS</i></h4>
   <br>
    <div id="slides">
  <form action="/action_page.php" class="form-horizontal">
      <div class="form-group">
         <div class="col-sm-6">
            <label>FIRST NAME</label>
            <input type="text" class="form-control" name="fname" value="Mickey 1">
         </div>
         <div class="col-sm-6">
            <label>LAST NAME</label>
            <input type="text" class="form-control" name="lname" value="Mouse">
         </div>
      </div>
      <div class="form-group">
         <div class="col-sm-6">
            <label>EMAIL</label>
            <input type="text" class="form-control" name="email" value="abc@host.com">
         </div>
         <div class="col-sm-6">
            <label>PHONE NUMBER</label>
            <input type="text" class="form-control" name="number" value="123-456-789">
         </div>
      </div>
      <div class="form-group">
         <div class="col-sm-6">
            <label>COUNTRY</label>
            <select name="country" class="form-control">
               <option value="canada">Canada</option>
            </select>
         </div>
         <div class="col-sm-3">
            <label>PROVINCE</label>
            <select name="province" class="form-control">
               <option value="ontario">ONTARIO</option>
            </select>
         </div>
         <div class="col-sm-3">
            <label>CITY</label>
            <select name="city" class="form-control">
               <option value="ottawa">OTTAWA</option>
            </select>
         </div>
      </div>
   </form>
  <form action="/action_page.php" class="form-horizontal">
      <div class="form-group">
         <div class="col-sm-6">
            <label>FIRST NAME</label>
            <input type="text" class="form-control" name="fname" value="Mickey 2">
         </div>
         <div class="col-sm-6">
            <label>LAST NAME</label>
            <input type="text" class="form-control" name="lname" value="Mouse">
         </div>
      </div>
      <div class="form-group">
         <div class="col-sm-6">
            <label>EMAIL</label>
            <input type="text" class="form-control" name="email" value="abc@host.com">
         </div>
         <div class="col-sm-6">
            <label>PHONE NUMBER</label>
            <input type="text" class="form-control" name="number" value="123-456-789">
         </div>
      </div>
      <div class="form-group">
         <div class="col-sm-6">
            <label>COUNTRY</label>
            <select name="country" class="form-control">
               <option value="canada">Canada</option>
            </select>
         </div>
         <div class="col-sm-3">
            <label>PROVINCE</label>
            <select name="province" class="form-control">
               <option value="ontario">ONTARIO</option>
            </select>
         </div>
         <div class="col-sm-3">
            <label>CITY</label>
            <select name="city" class="form-control">
               <option value="ottawa">OTTAWA</option>
            </select>
         </div>
      </div>
   </form>
      <a href="#" class="slidesjs-previous slidesjs-navigation"><i class="icon-chevron-left"></i></a>
      <a href="#" class="slidesjs-next slidesjs-navigation"><i class="icon-chevron-right"></i></a>
    </div>
  </div>
  <!-- End SlidesJS Required: Start Slides -->

  <!-- SlidesJS Required: Link to jQuery -->
  <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  <!-- End SlidesJS Required -->

  <!-- SlidesJS Required: Link to jquery.slides.js -->
  <script src="js/jquery.slides.min.js"></script>
  <!-- End SlidesJS Required -->

  <!-- SlidesJS Required: Initialize SlidesJS with a jQuery doc ready -->
  <script>
    $(function() {
      $('#slides').slidesjs({
        width: 940,
        height: 528,
        navigation: false
      });

      /*
        To have multiple slideshows on the same page
        they just need to have separate IDs
      */
      $('#slides2').slidesjs({
        width: 940,
        height: 528,
        navigation: false,
        start: 3,
        play: {
          auto: true
        }
      });

      $('#slides3').slidesjs({
        width: 940,
        height: 528,
        navigation: false
      });
    });
  </script>
  <!-- End SlidesJS Required -->
</body>
</html>
</code>```

答:
Try changing the top value to less percentage, something like this and check

```<code>#slides .slidesjs-pagination {
    position: absolute;
    top: 4%;
    right: 0;
    transform: translateY(-50%);
    z-index: 9999;
}
</code>```

Update
As per the comment, if you want achieve the same design as in the image, try the following

Your forms width is set to 100% change it to width: 96%; or something lesser than 100% with the above style mentioned. (Do the width change for both forms)

Body:
I am working on making a slideshow of forms. Here is my working codepen link. As you can see I have two dots on the right side which if I click then it opens another form. Only thing is those dots are getting shown at the very bottom of my page. I want to show them actually on the form instead at the right side.

For example as shown in this image. I am trying to replicate exactly like this image and as you can see those dots are on the form instead but at the very right side of it close to the right border. Also LAST NAME, PHONE NUMBER , PROVINCE and CITY label and its textbox are just above those dots. I want to do something similar. Is this possible to do?

Below is my HTML code:

<!doctype html>

  <meta charset="utf-8">
  <title>SlidesJS Standard Code Example</title>
  <meta name="description" content="SlidesJS is a simple slideshow plugin for jQuery. Packed with a useful set of features to help novice and advanced developers alike create elegant and user-friendly slideshows.">

  <meta name="viewport" content="width=device-width">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

            INSURANCE

INDIVIDUAL

CORPORATE

OUR STORY

Log In | Sign up

GET COVERED

INSURANCE FORM

BASIC DETAILS

  <form action="/action_page.php" class="form-horizontal">

            FIRST NAME
            <input type="text" class="form-control" name="fname" value="Mickey 1">

            LAST NAME
            <input type="text" class="form-control" name="lname" value="Mouse">

            EMAIL
            <input type="text" class="form-control" name="email" value="abc@host.com">

            PHONE NUMBER
            <input type="text" class="form-control" name="number" value="123-456-789">

            COUNTRY
            <select name="country" class="form-control">
               <option value="canada">Canada</option>
            </select>

            PROVINCE
            <select name="province" class="form-control">
               <option value="ontario">ONTARIO</option>
            </select>

            CITY
            <select name="city" class="form-control">
               <option value="ottawa">OTTAWA</option>
            </select>

   </form>
  <form action="/action_page.php" class="form-horizontal">

            FIRST NAME
            <input type="text" class="form-control" name="fname" value="Mickey 2">

            LAST NAME
            <input type="text" class="form-control" name="lname" value="Mouse">

            EMAIL
            <input type="text" class="form-control" name="email" value="abc@host.com">

            PHONE NUMBER
            <input type="text" class="form-control" name="number" value="123-456-789">

            COUNTRY
            <select name="country" class="form-control">
               <option value="canada">Canada</option>
            </select>

            PROVINCE
            <select name="province" class="form-control">
               <option value="ontario">ONTARIO</option>
            </select>

            CITY
            <select name="city" class="form-control">
               <option value="ottawa">OTTAWA</option>
            </select>

   </form>

Body:
Try changing the top value to less percentage, something like this and check

#slides .slidesjs-pagination {
    position: absolute;
    top: 4%;
    right: 0;
    transform: translateY(-50%);
    z-index: 9999;
}

Update
As per the comment, if you want achieve the same design as in the image, try the following

Your forms width is set to 100% change it to width: 96%; or something lesser than 100% with the above style mentioned. (Do the width change for both forms)


问:
Why phpMyAdmin is not importing my table?
I'm a designer, but as there's no programmer in my company I have to start studing programming. Which I did only somedays ago (and I have only  a html and css knowledge background) so pleasepleaseplease don't take any knowledge for granted if you can answer me!

I'm studing PHP and MySQL using "PHP & MySQL in easy steps" by Mike McGranth (if any of you have it I'm at page 90/91). So, the task is simple: write a .sql file and create a table in phpMyAdmin with it.

Since it's an exercise from a book I just have to write as it's written on the page and test it; yes, I have the solution-file too, but the point is I can't see the difference between my code, which can't be processed by phpMyAdmin, and the solution-code, which gives no problem.

The .sql file written by me is this:

```<code>CREATE TABLE IF NOT EXISTS products
(
id INT UNIQUE AUTO_INCREMENT ,
code INT NOT_NULL ,
name VARCHAR(25) NOT NULL ,
quantity INT DEFAULT 1 NULL ,
price DECIMAL(6,2) NOT NULL
) ;
</code>```

And the solution-file code is this:

```<code>CREATE TABLE IF NOT EXISTS products
(
  id        INT UNIQUE  AUTO_INCREMENT ,
  code      INT     NOT NULL ,
  name      VARCHAR(25)     NOT NULL ,
  quantity  INT     DEFAULT 1 NULL ,
  price     DECIMAL(6,2)    NOT NULL
) ;
</code>```

This is also how the look like in a code-editor program:

This is the error that phpMyAdmin gives to me (if the japanese part is important I can add the translation):

Since I have a solution, why do I ask? Because maybe I've done just a small mistake, but if I don't understand it I'm afraid to do it again when handling bigger files, maybe a client db, real work, not just an exercise.
So, if anyone will be so kind to explain it to me he/she will have my ethernal gratitude!

答:
update this cause NOT_NULL is not correct

```<code>code INT NOT_NULL ,
</code>```

to

```<code>code INT NOT NULL ,
</code>```

Body:
I'm a designer, but as there's no programmer in my company I have to start studing programming. Which I did only somedays ago (and I have only  a html and css knowledge background) so pleasepleaseplease don't take any knowledge for granted if you can answer me!

I'm studing PHP and MySQL using "PHP & MySQL in easy steps" by Mike McGranth (if any of you have it I'm at page 90/91). So, the task is simple: write a .sql file and create a table in phpMyAdmin with it.

Since it's an exercise from a book I just have to write as it's written on the page and test it; yes, I have the solution-file too, but the point is I can't see the difference between my code, which can't be processed by phpMyAdmin, and the solution-code, which gives no problem.

The .sql file written by me is this:

CREATE TABLE IF NOT EXISTS products
(
id INT UNIQUE AUTO_INCREMENT ,
code INT NOT_NULL ,
name VARCHAR(25) NOT NULL ,
quantity INT DEFAULT 1 NULL ,
price DECIMAL(6,2) NOT NULL
) ;

And the solution-file code is this:

CREATE TABLE IF NOT EXISTS products
(
  id        INT UNIQUE  AUTO_INCREMENT ,
  code      INT     NOT NULL ,
  name      VARCHAR(25)     NOT NULL ,
  quantity  INT     DEFAULT 1 NULL ,
  price     DECIMAL(6,2)    NOT NULL
) ;

This is also how the look like in a code-editor program:

This is the error that phpMyAdmin gives to me (if the japanese part is important I can add the translation):

Since I have a solution, why do I ask? Because maybe I've done just a small mistake, but if I don't understand it I'm afraid to do it again when handling bigger files, maybe a client db, real work, not just an exercise.
So, if anyone will be so kind to explain it to me he/she will have my ethernal gratitude!

Body:
update this cause NOT_NULL is not correct

code INT NOT_NULL ,

to

code INT NOT NULL ,


问:
How to check if not available methods are used if deployment target < base sdk?
I would like to know how you check that your code do not call not available methods when the deployment target is inferior to base SDK ?

It is possible to run the application on a device with the SDK equal to deployment target, but I search a way more 'automatic'. Any idea ?

Regards,
Quentin

答:
If you have an instance of a class, you can use the following to see if it understands the method you want to call:

```<code>if ([mipmapBrowserView respondsToSelector:@selector(setBackgroundColor:)]) {
    // set the background layer since IKImageView supports it
}
</code>```

Here, mipmapBrowserView is an instance of IKImageView, which was first introduced in Mac OS X 10.5. The setBackgroundColor: method of IKImageView was only added in 10.6, however, so I need to check before I call it. This allows me to build against the 10.6 SDK, and take advantage of the new features, yet still support OS X 10.5 as well. While this example involves OS X rather than iOS, the same method (pun intended?) works in iOS as well.

Note that things are slightly different when you are subclassing a class, and you want to know whether the superclass responds to a certain selector:

"You cannot test whether an object inherits a method from its superclass by sending respondsToSelector: to the object using the super keyword. This method will still be testing the object as a whole, not just the superclass’s implementation. Therefore, sending respondsToSelector: to super is equivalent to sending it to self. Instead, you must invoke the NSObject class method instancesRespondToSelector: directly on the object’s superclass...."

Body:
If you have an instance of a class, you can use the following to see if it understands the method you want to call:

if ([mipmapBrowserView respondsToSelector:@selector(setBackgroundColor:)]) {
    // set the background layer since IKImageView supports it
}

Here, mipmapBrowserView is an instance of IKImageView, which was first introduced in Mac OS X 10.5. The setBackgroundColor: method of IKImageView was only added in 10.6, however, so I need to check before I call it. This allows me to build against the 10.6 SDK, and take advantage of the new features, yet still support OS X 10.5 as well. While this example involves OS X rather than iOS, the same method (pun intended?) works in iOS as well.

Note that things are slightly different when you are subclassing a class, and you want to know whether the superclass responds to a certain selector:

"You cannot test whether an object inherits a method from its superclass by sending respondsToSelector: to the object using the super keyword. This method will still be testing the object as a whole, not just the superclass’s implementation. Therefore, sending respondsToSelector: to super is equivalent to sending it to self. Instead, you must invoke the NSObject class method instancesRespondToSelector: directly on the object’s superclass...."


问:
Not able to display select box as ajax response in wordpress
I have two drop-down box one with custom taxonomy and other with it custom post under the current selected taxonomy. For that i have wrote an on-change function. i have some problem with displaying out put
it's showing output like this

```<code>8Associate<select class="form-control" name="upload_designation" id="upload_designation" >

<option value="">Select Designation</option><option value=""></option></select>
</code>```

instead of

```<code><select class="form-control" name="upload_designation" id="upload_designation" >

<option value="">Select Designation</option>
<option value="8">Associate</option></select>
</code>```

i am posting my on change function here
kindly help me to figure out the problem

```<code>function change_desgination() {
$post_val=explode("_",$_POST['id']);
$id=$post_val[0];
$taxonomy_name=$post_val[1];

$out='<select class="form-control" name="upload_designation" id="upload_designation" >
<option value="">Select Designation</option>';

    $args = array(
    'post_type' => 'designation',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'tax_query' => array(
        array(
            'taxonomy' => 'domain',
            'field' => 'slug',
            'terms' => $taxonomy_name
        )
    )
);
$the_query = new WP_Query( $args );

while ( $the_query->have_posts() ) : $the_query->the_post();
$theid=the_ID();
$thetitle=the_title();

  $out.='<option value="'.$theid.'">'.$thetitle.'</option>';

endwhile;
  $out.='</select>';
  die($out);
 }
</code>```

may be the problem is with the quotes. Any one please help me to find the the problem. Thanks in advance.

答:
checked your code i suggest you to use foreach loop instead of while as follows

```<code><?php

$out='<select class="form-control" name="upload_designation" id="upload_designation" >
<option value="">Select Designation</option>';

$array = array('one','two','three','four');

foreach ($array as $key => $value) {
  $out.='<option value="'.$key.'">'.$value.'</option>';
}
  $out.='</select>';
  die($out);
?>
</code>```

replace your data with array shown in code

Body:
I have two drop-down box one with custom taxonomy and other with it custom post under the current selected taxonomy. For that i have wrote an on-change function. i have some problem with displaying out put
it's showing output like this

8Associate<select class="form-control" name="upload_designation" id="upload_designation" >

<option value="">Select Designation</option><option value=""></option></select>

instead of

<select class="form-control" name="upload_designation" id="upload_designation" >

<option value="">Select Designation</option>
<option value="8">Associate</option></select>

i am posting my on change function here
kindly help me to figure out the problem

function change_desgination() {
$post_val=explode("_",$_POST['id']);
$id=$post_val[0];
$taxonomy_name=$post_val[1];

$out='<select class="form-control" name="upload_designation" id="upload_designation" >
<option value="">Select Designation</option>';

    $args = array(
    'post_type' => 'designation',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'tax_query' => array(
        array(
            'taxonomy' => 'domain',
            'field' => 'slug',
            'terms' => $taxonomy_name
        )
    )
);
$the_query = new WP_Query( $args );

while ( $the_query->have_posts() ) : $the_query->the_post();
$theid=the_ID();
$thetitle=the_title();

  $out.='<option value="'.$theid.'">'.$thetitle.'</option>';

endwhile;
  $out.='</select>';
  die($out);
 }

may be the problem is with the quotes. Any one please help me to find the the problem. Thanks in advance.

Body:
checked your code i suggest you to use foreach loop instead of while as follows

<?php

$out='<select class="form-control" name="upload_designation" id="upload_designation" >
<option value="">Select Designation</option>';

$array = array('one','two','three','four');

foreach ($array as $key => $value) {
  $out.='<option value="'.$key.'">'.$value.'</option>';
}
  $out.='</select>';
  die($out);
?>

replace your data with array shown in code


问:
How do I remove these values in a list in Python?
```<code>x1 = [1, 2, 3, 4, 5, 6]
x2 = [3, 5, 6, 8, 9]
x3 = [2, 4, 5, 7, 13]
x4 = [11, 22, 33, 24, 55, 66]
x5 = [11, 7, 1, 2, 3, 4, 5, 6]
</code>```

How do I remove the increasing values on every list?

If I removed the increasing in those lists, they should look like this:

```<code>x1 = [1, 6]
x2 = [3, 9]
x3 = [2, 13]
x4 = [11, 33, 24, 66]
x5 = [11, 7, 1, 6]
</code>```

答:
You can use a generator to build up the runs and yield the results, e.g.:

```<code>def runs(iterable):
    iterable = iter(iterable)
    i = [next(iterable)]  # Empty iterable not handled
    for j in iterable:
        while j and i[-1] < j:
            i.append(j)
            j = next(iterable, None)
        i[1:-1] = []      # Removes the middle of the run, if there is one
        yield from i
        i = [j]
    if j:
        yield j

# Using @StephenRauch data set
data = (
    [1, 2, 3, 4, 5, 6],
    [3, 5, 6, 8, 9],
    [2, 4, 5, 7, 13],
    [11, 22, 33, 24, 55, 66],
    [11, 7, 1, 2, 3, 4, 5, 6]
)

>>> [list(runs(d)) for d in data]
[[1, 6], [3, 9], [2, 13], [11, 33, 24, 66], [11, 7, 1, 6]]
</code>```

Body:
x1 = [1, 2, 3, 4, 5, 6]
x2 = [3, 5, 6, 8, 9]
x3 = [2, 4, 5, 7, 13]
x4 = [11, 22, 33, 24, 55, 66]
x5 = [11, 7, 1, 2, 3, 4, 5, 6]

How do I remove the increasing values on every list?

If I removed the increasing in those lists, they should look like this:

x1 = [1, 6]
x2 = [3, 9]
x3 = [2, 13]
x4 = [11, 33, 24, 66]
x5 = [11, 7, 1, 6]

Body:
You can use a generator to build up the runs and yield the results, e.g.:

def runs(iterable):
    iterable = iter(iterable)
    i = [next(iterable)]  # Empty iterable not handled
    for j in iterable:
        while j and i[-1] < j:
            i.append(j)
            j = next(iterable, None)
        i[1:-1] = []      # Removes the middle of the run, if there is one
        yield from i
        i = [j]
    if j:
        yield j

# Using @StephenRauch data set
data = (
    [1, 2, 3, 4, 5, 6],
    [3, 5, 6, 8, 9],
    [2, 4, 5, 7, 13],
    [11, 22, 33, 24, 55, 66],
    [11, 7, 1, 2, 3, 4, 5, 6]
)

>>> [list(runs(d)) for d in data]
[[1, 6], [3, 9], [2, 13], [11, 33, 24, 66], [11, 7, 1, 6]]


问:
json_decode doesn't work on my string
I have JSON Object which I have encoded like so

```<code>{
"id": "",
"steps": [
             {
        "target": "purchase_order_items_itemmaster_id",
        "title": "",
        "placement": "",
        "content": "",
        "xoffset": "",
        "yoffset": ""
              }
         ]
}
$JSONData = json_encode($finalData,JSON_PRETTY_PRINT);
</code>```

I am taking this JSON data and storing it in a file like so

```<code>File::put("path","var tour = \n [ \n\t $JSONData \n ];");
</code>```

which looks something like this in the file

```<code>    var tour =
 [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];
</code>```

Now I am reading it back form the second line like so

```<code> [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];
</code>```

The problem is when I want to decode it back it doesn't happen,this is how I am trying to do that,

```<code>$lines = file_get_contents("path",NULL,NULL,10);

$a = json_decode($lines);
</code>```

Now according to expected output the $a should have the decoded data but it has null.

Can someone point out the mistake?

答:
I believe the issue is the semicolon at the end of the JSON you've read back in from the file. Try chopping that off before attempting json_decode:

```<code>$a = json_decode(rtrim($lines, ";"));
</code>```

Title: json_decode doesn't work on my string

Body:
I have JSON Object which I have encoded like so

{
"id": "",
"steps": [
             {
        "target": "purchase_order_items_itemmaster_id",
        "title": "",
        "placement": "",
        "content": "",
        "xoffset": "",
        "yoffset": ""
              }
         ]
}
$JSONData = json_encode($finalData,JSON_PRETTY_PRINT);

I am taking this JSON data and storing it in a file like so

File::put("path","var tour = \n [ \n\t $JSONData \n ];");

which looks something like this in the file

    var tour =
 [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];

Now I am reading it back form the second line like so

 [
     {
    "id": "",
    "steps": [
        {
            "target": "purchase_order_items_itemmaster_id",
            "title": "",
            "placement": "",
            "content": "",
            "xoffset": "",
            "yoffset": ""
        }
    ]
}
 ];

The problem is when I want to decode it back it doesn't happen,this is how I am trying to do that,

$lines = file_get_contents("path",NULL,NULL,10);

$a = json_decode($lines);

Now according to expected output the $a should have the decoded data but it has null.

Can someone point out the mistake?

Body:
I believe the issue is the semicolon at the end of the JSON you've read back in from the file. Try chopping that off before attempting json_decode:

$a = json_decode(rtrim($lines, ";"));


问:
Android Studio fails to install update (error : Failed to read or create install properties file.)
Screenshot of error

I am running [ Android Studio 2.3
Build #AI-162.3764568, built on February 24, 2017
JRE: 1.8.0_112-release-b06 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o] on Ubuntu 16.04. From last few days android studio gives me error on trying to update. I have no idea how to fix this.

答: I ran the Android studio as administrator and then it worked as it is a permission issue.</p>

ContentLicense: CC BY-SA 4.0


问:
NSwagStudio generating broken client code (duplicate enum values). What am I doing wrong?
I'm trying to generate a c# client from an AspNetCore Web API using NSwagStudio. The generated code contains a set of enums that, based on the attributes decorating them, are apparently flags for Json serialization - I can't locate where any of them are actually used. Several of these are generated with duplicate values, which makes the code not compile out of the box.

Example:

```<code>[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "8.30.6304.31883")]
public enum ConstructorInfoMethodImplementationFlags
{
    _0 = 0,

    _0 = 0,

    _1 = 1,

    _2 = 2,

    _3 = 3,

    _3 = 3,

    _4 = 4,

    _4 = 4,

    _8 = 8,

    _16 = 16,

    _32 = 32,

    _64 = 64,

    _128 = 128,

    _256 = 256,

    _4096 = 4096,

    _65535 = 65535,

}
</code>```

Is this a problem with the generator or something with my documentation? Is there a way to fix this without hand-editing the code?

Thanks.

答:
Seems your enum in Web API project defined wrong.
You have something like that:

```<code>[Flags]
public enum ConstructorInfoMethodImplementationFlags
{
    None,
    Method0 = 0,
    Method1 = 1,
    Method2 = 2
    Method3 = 4,
    ...
    AllMethods = 65535
}
</code>```

So that translates to OAI specification in a way you don't expected:

```<code>"ConstructorInfoMethodImplementationFlags": {
          "format": "int32",
          "enum": [
            0,
            0,
            1,
            2,
            4
            ...
            65535
          ],
          "type": "integer"
        }
</code>```

The solution here is assign integer values to every enum member.

Body:
I'm trying to generate a c# client from an AspNetCore Web API using NSwagStudio. The generated code contains a set of enums that, based on the attributes decorating them, are apparently flags for Json serialization - I can't locate where any of them are actually used. Several of these are generated with duplicate values, which makes the code not compile out of the box.

Example:

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "8.30.6304.31883")]
public enum ConstructorInfoMethodImplementationFlags
{
    _0 = 0,

    _0 = 0,

    _1 = 1,

    _2 = 2,

    _3 = 3,

    _3 = 3,

    _4 = 4,

    _4 = 4,

    _8 = 8,

    _16 = 16,

    _32 = 32,

    _64 = 64,

    _128 = 128,

    _256 = 256,

    _4096 = 4096,

    _65535 = 65535,

}

Is this a problem with the generator or something with my documentation? Is there a way to fix this without hand-editing the code?

Thanks.

Body:
Seems your enum in Web API project defined wrong.
You have something like that:

[Flags]
public enum ConstructorInfoMethodImplementationFlags
{
    None,
    Method0 = 0,
    Method1 = 1,
    Method2 = 2
    Method3 = 4,
    ...
    AllMethods = 65535
}

So that translates to OAI specification in a way you don't expected:

"ConstructorInfoMethodImplementationFlags": {
          "format": "int32",
          "enum": [
            0,
            0,
            1,
            2,
            4
            ...
            65535
          ],
          "type": "integer"
        }

The solution here is assign integer values to every enum member.


问:
Bind DataTable to Excel spreadsheet directly in C#
I am building a C# VSTO Add-in, and looking for ways to bind System.Data.DataTable directly to Excel spreadsheet (like binding a datasource) and track user modified cells in the spreadsheet and read the changes back in C#.

Thanks for help.

答:
There is no direct method to bind DataTable to Excel spreadsheet.

You have to enumerate rows and columns in your DataTable and insert data into Worksheet.

Then you have to decide when to update back (i.e. during saving Workbook - then create event handler for BeforeSave event) and enumerate rows and columns in Worksheet moving values back into DataTable and update database.


问:
Serving index.html at root context with embedded Jetty
With the following code I am able to serve up my views at / as well as my REST API at /rest. Currently, I am not using a web.xml.

Can I serve /index.html at / using Jetty or without defining a web.xml? (This is part of a framework I'm building - I'd like to avoid file generation if possible).

```<code>protected RESTServer(int port, Class<?> api, String path) {
        // Server
        this.server = new org.eclipse.jetty.server.Server(port);

        // REST
        ServletContextHandler restHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        restHandler.setContextPath(path);

        ServletHolder servlet = restHandler.addServlet(ServletContainer.class, "/rest/*");
        servlet.setInitOrder(0);
        servlet.setInitParameter(JERSEY_PROVIDER, api.getCanonicalName());

         // Web
        ResourceHandler webHandler = new ResourceHandler();
        webHandler.setDirectoriesListed(true);
        webHandler.setResourceBase("src/main/webapp");
        webHandler.setWelcomeFiles(new String[]{"index.html"});

        // Server
        HandlerCollection handlers = new HandlerCollection();
        handlers.addHandler(webHandler);
        handlers.addHandler(restHandler);
        server.setHandler(handlers);
}
</code>```

答:
Here is the solution I came up with. It requires the Jetty webapp dependency.</p>

```<code>protected RESTServer(int port, Class<?> api, String path) {
        this.server = new org.eclipse.jetty.server.Server(port);
        WebAppContext webAppContext = new WebAppContext();
        webAppContext.setResourceBase("src/main/webapp");
        ServletHolder restServlet = webAppContext.addServlet(ServletContainer.class, "/rest/*");
        restServlet.setInitOrder(0);
        restServlet.setInitParameter(JERSEY_PROVIDER, api.getCanonicalName());
        HandlerCollection handlers = new HandlerCollection();
        handlers.addHandler(webAppContext);
        server.setHandler(handlers);
}
</code>```

Body:
With the following code I am able to serve up my views at / as well as my REST API at /rest. Currently, I am not using a web.xml.

Can I serve /index.html at / using Jetty or without defining a web.xml? (This is part of a framework I'm building - I'd like to avoid file generation if possible).

protected RESTServer(int port, Class<?> api, String path) {
        // Server
        this.server = new org.eclipse.jetty.server.Server(port);

        // REST
        ServletContextHandler restHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        restHandler.setContextPath(path);

        ServletHolder servlet = restHandler.addServlet(ServletContainer.class, "/rest/*");
        servlet.setInitOrder(0);
        servlet.setInitParameter(JERSEY_PROVIDER, api.getCanonicalName());

         // Web
        ResourceHandler webHandler = new ResourceHandler();
        webHandler.setDirectoriesListed(true);
        webHandler.setResourceBase("src/main/webapp");
        webHandler.setWelcomeFiles(new String[]{"index.html"});

        // Server
        HandlerCollection handlers = new HandlerCollection();
        handlers.addHandler(webHandler);
        handlers.addHandler(restHandler);
        server.setHandler(handlers);
}

Body:
Here is the solution I came up with. It requires the Jetty webapp dependency.

protected RESTServer(int port, Class<?> api, String path) {
        this.server = new org.eclipse.jetty.server.Server(port);
        WebAppContext webAppContext = new WebAppContext();
        webAppContext.setResourceBase("src/main/webapp");
        ServletHolder restServlet = webAppContext.addServlet(ServletContainer.class, "/rest/*");
        restServlet.setInitOrder(0);
        restServlet.setInitParameter(JERSEY_PROVIDER, api.getCanonicalName());
        HandlerCollection handlers = new HandlerCollection();
        handlers.addHandler(webAppContext);
        server.setHandler(handlers);
}


问:
What does this code means?
```<code>namespace myApplication    {
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}
</code>```

What is partial class Form1 : Form

and what is InitializeComponents();

and why it is used Form1 : Form instead of only Form1

答:
Class declaration

Method call

Inheritance

But asking questions like this is no good.

Title: What does this code means?

Body:
namespace myApplication    {
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}

What is partial class Form1 : Form

and what is InitializeComponents();

and why it is used Form1 : Form instead of only Form1