问:
Jmeter JDCB connection error
I am running a query from Jmeter.

Below is my Connection string
[enter image description here][1]

Getting below error.
Response message: java.sql.SQLException: Cannot create PoolableConnectionFactory (The TCP/IP connection to the host DESKTOP-7JSVED6, port 1433 has failed. Error: "Connection refused: no further information. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".)

I opened the port 1433 at inbound rules in advanced firewall setting.

答:
If you are totally sure you have started the SQL server and port 1433 is open in the firewall the only thing I can think of is Enabling TCP/IP Network Protocol for SQL Server:

Start SQL Server Configuration Manager. Click Start, point to All Programs, and click Microsoft SQL Server. Click Configuration Tools, and then click SQL Server Configuration Manager.

In SQL Server Configuration Manager, in the console pane, expand SQL Server Network Configuration.

In the console pane, click Protocols for .

In the details pane, right-click TCP/IP, and then click Enable.

In the console pane, click SQL Server Services.

In the details pane, right-click SQL Server (), and then click Restart, to stop and restart the SQL Server service.

Also double check you're using latest (or matching) Microsoft JDBC Driver for SQL Server

More information:

Building a Database Test Plan

The Real Secret to Building a Database Test Plan With JMeter

Title: Jmeter JDCB connection error


来源: stackexchange

问:
Can I Mass Re-link Files in InDesign? Same Name, Just New Extension?
I've got a document that has several dozen photos that I've kept in .psd until i was done editing. Now I've shot myself in the foot as I'd like to re-link all of these to the .tif version. (Easy Photoshop batch). The file names would remain the same, just the extension changes.

Is there a way to do this without having to manually re-link each photo? I'm thinking even a script maybe?

Thanks for your time. -Joe

答:
Solution!

In the Links panel (Window > Links) select your images and from the menu in the top right corner (the 4 lines) select Relink File Extension.

ContentLicense: CC BY-SA 3.0


问:
R - Error: IllegalArgumentException (Java): Your InputStream was neither an OLE2 stream, nor an OOXML stream
I use R XLConnect package.
When I wrote 'XLConnect' function, such as loadWorkbook(), readWorksheetFromFile() etc. , this error message happen.

Error: IllegalArgumentException (Java): Your InputStream was neither
  an OLE2 stream, nor an OOXML stream

How to solve this problem?

Before using this function, I took action against crashing between R and Mac OS X by the way http://www.r-bloggers.com/getting-r-and-java-1-8-to-work-together-on-osx/ link told.

I have used Mac OS X.

答:
I also use OS X and after working without problem for a while with this function this error raises without apparent reason... But the reason is really simple. Excel (actually, all MS Office suite) creates temporary files meanwhile you have open the file. This file is hidden:

In my case, I list .xlsx files to open them inside a loop. So, the first file was a hidden file and the error raised. Closing excel (to delete those file) is the solution to avoid this error.


问:
Mobile push received for 2 different flavors
I've got android application with 2 different flavors:

```<code>        first {
            applicationId 'com.test.first'
            resValue 'string', 'app_name', 'First'
            resValue 'string', 'host', 'app.first.com'
            resValue 'string', 'app_id', '3'
            resValue 'string', 'auth_client_id', 'xxx'
            versionCode 1
            versionName '1.0'
        }
        second {
            signingConfig signingConfigs.second
            applicationId 'com.test.second'
            resValue 'string', 'app_name', 'Second'
            resValue 'string', 'host', 'app.second.com'
            resValue 'string', 'app_id', '2'
            resValue 'string', 'auth_client_id', 'xxx'
            versionCode 1
            versionName '1.0'
        }
</code>```

And my AndroidManifest.xml looks like this:

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test">
    <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <application>
         <receiver
            android:name="com.test.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
    </application>
</manifest>
</code>```

I receiving push notifications for both flavors correctly. Problem is, that if I have both flavors installed in my phone, I receive 2 same pushes for both flavors.

It seems that application does not recognize for which flavor push belongs. Maybe somebody had the same problem?

答:
I am assuming your problem like..

Your fcm/gcm project package name is "com.test"
and then your android app having two flavours
namly

1. first with applicationId 'com.test.first'

2. second with applicationId 'com.test.second'

so, If you are and any push it will receive in both flavors because your both flavors contain com.test, So you could be manage or handle manually... like

send your application id or any flavor identification token with a push, then you have to manage that in after receiving a push.

for example

send push for first flavor(In your first app)

```<code>if(data.first_flavor_token)
{
   //Create and show your push here
}
</code>```

send push for second flavor(In your second app)

```<code>if(data.second_flavor_token)
{
   //Create and show your push here
}
</code>```

Body:
I've got android application with 2 different flavors:

        first {
            applicationId 'com.test.first'
            resValue 'string', 'app_name', 'First'
            resValue 'string', 'host', 'app.first.com'
            resValue 'string', 'app_id', '3'
            resValue 'string', 'auth_client_id', 'xxx'
            versionCode 1
            versionName '1.0'
        }
        second {
            signingConfig signingConfigs.second
            applicationId 'com.test.second'
            resValue 'string', 'app_name', 'Second'
            resValue 'string', 'host', 'app.second.com'
            resValue 'string', 'app_id', '2'
            resValue 'string', 'auth_client_id', 'xxx'
            versionCode 1
            versionName '1.0'
        }

And my AndroidManifest.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test">
    <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <application>
         <receiver
            android:name="com.test.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
    </application>
</manifest>

I receiving push notifications for both flavors correctly. Problem is, that if I have both flavors installed in my phone, I receive 2 same pushes for both flavors.

It seems that application does not recognize for which flavor push belongs. Maybe somebody had the same problem?

Body:
I am assuming your problem like..

Your fcm/gcm project package name is "com.test"
and then your android app having two flavours
namly

1. first with applicationId 'com.test.first'

2. second with applicationId 'com.test.second'

so, If you are and any push it will receive in both flavors because your both flavors contain com.test, So you could be manage or handle manually... like

send your application id or any flavor identification token with a push, then you have to manage that in after receiving a push.

for example

send push for first flavor(In your first app)

if(data.first_flavor_token)
{
   //Create and show your push here
}

send push for second flavor(In your second app)

if(data.second_flavor_token)
{
   //Create and show your push here
}


问:
Is it viable to use Drupal/Ubercart for an international store? Do any payment gateways support it?
I am picking tools to use for an international store. Company sells training and products in North America, Europe and a few other places. The existing store in the United States (Drupal/Ubercart/Authorize.net) works great and serves all their needs.

Displaying product prices in different currencies are relatively easy to set up, and you can display the correct currency symbols and values depending on where services are rendered, where people want to ship to, etc (useful modules include uc_multiple_currency, uc_multiprice, uc_cck_currency).

Are there viable Ubercart solutions to sell to other international markets using the same storefront? It is possible for any user to buy services/products through the US store, but paying in USD for a service offered in e.g. the Netherlands, when dealing with people based in the Netherlands is not acceptable.

The only payment gateway I could find that would accept payment in multiple currencies is Paypal. However, I am looking for a solution that would accept credit cards from international users and charge them in the correct currency. Authorize.net works great - will accept cards from anywhere and process them, but all transactions is in USD. It would be extremely problematic to charge someone €250 on the site and their final charge (after currency conversion) being e.g. €250.65 or something like it because of a delayed conversion.

Numerous people have asked this question, with very few useful insights and solutions (see for example here, here, and here, which presents a workaround-ish way of doing things).

To be clear: Displaying prices in different currencies is easy. How can I bill credit cards internationally using the correct currency through a gateway that supports it, without having to do conversions?

答:
I have been through the same thing recently, but ended up making my own module to do the price handling. If it's done right, the prices will be displayed correct, even for order total etc. (See the hook_uc_price_handler)

This means that you will need to do two things to handle your problem.

Make sure the order only contain 1 currency, so you don't have one item costing €100 and another costing $100 (what would the total of that order be?) You could handle this by doing currency conversion if you wanted to, I believe that is how one of the modules you listed works.

When the payment is processed you need to send the correct currency to the payment provider. This already needs to be done in most cases as payment providers usually are able to collect in various currencies. Since most do the payment process via a hidden form that redirects or a inline form with hidden fields, you should be able to use hook_form_alter to set the currency to what you want. Depending on the payment module, this may be hard or easy.

ContentLicense: CC BY-SA 2.5


问:
iOS - color on Xcode simulator is different from the color on device
Overview

The background color of my iPhone app in the simulator (iMac) looks different from the color on the device (iPhone 3GS).

EDIT (following section has been added)

The following are all different:

story board color (xib file)

simulator color

device color

I suppose I should go with how it looks on the device.

Questions

Is this is a common problem other developers face and is there a way to match the colors (systematic procedure) ?

will the color look different on different versions of iPhone (3gs / 4 / 4s) or all the color ?

Am I missing something, is there any specific color profile I should use ?

Is there something like a rule of thumb where RGB values vary by a certain percentage ?

In iPhone 4 and 4S, do the color match the simulator ? ( I don't have a iPhone4 and 4S, so I am not sure.)

答:
It's about color spaces.

Make sure you are picking the color from an sRGBcolor space, and replicating its RGBA values on Interface Builder by selecting sRGB IEC61966-2.1 from the dropdown menu.

If you pick a color in one color space, and generate it in a different color space, it will look different, in spite of having replicated the same RGBA values.

Also, have in mind that when you generate a color through code, using UIColor(red:green:blue:alpha:), it's generated on the sRGB color space by default. That's why it's so convenient to use this one (instead of Adobe RGB, P3, or any other). Besides, sRGB is the standard that's most used in the industry currently.

Fun fact: That UIColor constructor I mentioned above creates colors in the sRGB space since Xcode8. Before, that function used to create them within the Generic RGB space instead. That's why it might cause confusions too.

Here is a resource that extends on the topic: https://medium.com/@volbap/working-efficiently-with-colors-in-xcode-bc4c58b16f9a

ContentLicense: CC BY-SA 4.0


问:
Automatically copy text when clicked on input area (multiple lnputs) Javascript
I'm trying to get input area to copy text when the user clicks on it. The code itself is selecting correct text but when i add copy function it won't copy correct text. Problem is that this is a template which website use to add elements to the website (so multiple submissions will use same code).

```<code>echo '<div class="input-group input-group-sm">';
echo '<span class="input-group-addon input-label-' . strtolower($server->status_text) . '"><i class="fa fa-server" aria-hidden="true"></i> ' . $server->status_text . '</span>';
echo '<input type="text" onclick="this.select()" value="' . $server->address . (($server->connection_port != '25565') ? ":" . $server->connection_port : null) . '">';echo '</div>';
</code>```

Output on site:

```<code><div class="input-group input-group-sm">
<span class="input-group-addon input-label-online"><i class="fa fa-server" aria-hidden="true"></i> Online</span>
<input type="text" onclick="this.select()" class="form-control" value="Server IP">
</div>
</code>```

Edit: It looks like i will need to do this via button as using "onclick" is crashing my website. Not sure how to do it with button and without some sort of ID system. The servers are listed via "table" if that helps.

答:
This should work for you:

```<code><input type="text" onclick="this.select(); document.execCommand('Copy');" class="form-control" value="Server IP">
</code>```

The code you were trying has unescaped parentheses.

This works with multiple input elements: https://jsfiddle.net/xx0gs6Lw/

EDIT

That must be only syntax error then, can you post your exact code? It should look something like this:

```<code>echo '<input type="text" onclick="this.select(); document.execCommand(\'Copy\');" value="' . $server->address . (($server->connection_port != '25565') ? ":" . $server->connection_port : null) . '">';
</code>```

Body:
I'm trying to get input area to copy text when the user clicks on it. The code itself is selecting correct text but when i add copy function it won't copy correct text. Problem is that this is a template which website use to add elements to the website (so multiple submissions will use same code).

echo '
';
echo 'status_text) . '"> ' . $server->status_text . '';
echo '<input type="text" onclick="this.select()" value="' . $server->address . (($server->connection_port != '25565') ? ":" . $server->connection_port : null) . '">';echo '
';

Output on site:

 Online
<input type="text" onclick="this.select()" class="form-control" value="Server IP">

Edit: It looks like i will need to do this via button as using "onclick" is crashing my website. Not sure how to do it with button and without some sort of ID system. The servers are listed via "table" if that helps.

Body:
This should work for you:

<input type="text" onclick="this.select(); document.execCommand('Copy');" class="form-control" value="Server IP">

The code you were trying has unescaped parentheses.

This works with multiple input elements: https://jsfiddle.net/xx0gs6Lw/

EDIT

That must be only syntax error then, can you post your exact code? It should look something like this:

echo '<input type="text" onclick="this.select(); document.execCommand(\'Copy\');" value="' . $server->address . (($server->connection_port != '25565') ? ":" . $server->connection_port : null) . '">';


问:
opening an exe file in c++ form
i am implementing an installtion program for my program , i am using c++, QT in debug mode , everything went well till the final stage (run the program after installation)
i tried these two ways for opening the exe file:

```<code>    QString program= "example.exe";
</code>```

method 1:

```<code>    QDesktopServices::openUrl(QUrl("file:///"+program,QUrl::TolerantMode));
</code>```

method 2:

```<code>    QProcess::startDetached(program);
</code>```

but it gives me that error message.

答:
Possible some of application components not founded by executable file. For simple case QProcess::setWorkingDirectory( /* executable directory */ ) can help.
In bad case check environment variables of process in your run. You can loss paths to required libraries.</p>

Title: opening an exe file in c++ form

Body:
i am implementing an installtion program for my program , i am using c++, QT in debug mode , everything went well till the final stage (run the program after installation)
i tried these two ways for opening the exe file:

    QString program= "example.exe";

method 1:

    QDesktopServices::openUrl(QUrl("file:///"+program,QUrl::TolerantMode));

method 2:

    QProcess::startDetached(program);

but it gives me that error message.


问:
How to escape backtick in docker-compose.yml file?
I'm trying to run PHP built in web server as startup for my container, but docker-compose up complain that it failed to parse the ` symbol (backquote? backtick?) in my docker-compose.yml

Here's my docker-compose.yml

```<code>version: "3"
services:
  sf-api:
    image: reston/php:7.1
    ports:
      - "8000:8000"
    volumes:
      - ".:/tmp/target"
    working_dir: "/tmp/target"
    command: ["php","-S","`hostname -i`:8000"]
</code>```

What I'm trying to do is to make the web server binds to container external IP instead of 127.0.0.1.

Edit:
Here's the output running docker-compose up

```<code>$ docker-compose up
Recreating storefrontapi_sf-api_1 ...
Recreating storefrontapi_sf-api_1 ... done
Attaching to storefrontapi_sf-api_1
sf-api_1  | Invalid address: `hostname -i`
storefrontapi_sf-api_1 exited with code 1
</code>```

答:
You explicitly told docker-compose to not run your command inside a shell with the json exec syntax for your command. If you want the shell the parse the backticks inside the container, you'll need to run your command with a shell. Note that this will break things like signal handling since the shell in pid 1 will intercept and ignore a SIGTERM (it assumes it's in single user mode where you don't want the shell to exit). The string syntax for a command runs a shell for you, or you can change your command to explicitly launch a shell. Either of these should work:</p>

```<code>command: ["/bin/sh", "-c", "php -S `hostname -i`:8000"]
command: "php -S `hostname -i`:8000"
</code>```

Body:
I'm trying to run PHP built in web server as startup for my container, but docker-compose up complain that it failed to parse the ` symbol (backquote? backtick?) in my docker-compose.yml

Here's my docker-compose.yml

version: "3"
services:
  sf-api:
    image: reston/php:7.1
    ports:
      - "8000:8000"
    volumes:
      - ".:/tmp/target"
    working_dir: "/tmp/target"
    command: ["php","-S","`hostname -i`:8000"]

What I'm trying to do is to make the web server binds to container external IP instead of 127.0.0.1.

Edit:
Here's the output running docker-compose up

$ docker-compose up
Recreating storefrontapi_sf-api_1 ...
Recreating storefrontapi_sf-api_1 ... done
Attaching to storefrontapi_sf-api_1
sf-api_1  | Invalid address: `hostname -i`
storefrontapi_sf-api_1 exited with code 1

Body:
You explicitly told docker-compose to not run your command inside a shell with the json exec syntax for your command. If you want the shell the parse the backticks inside the container, you'll need to run your command with a shell. Note that this will break things like signal handling since the shell in pid 1 will intercept and ignore a SIGTERM (it assumes it's in single user mode where you don't want the shell to exit). The string syntax for a command runs a shell for you, or you can change your command to explicitly launch a shell. Either of these should work:

command: ["/bin/sh", "-c", "php -S `hostname -i`:8000"]
command: "php -S `hostname -i`:8000"


问:
Way to store variable in JSF / issue with c:set and ui:param
I tried c:set and ui:param, but in the end I think I did something wrong.

Here is the crucial XHTML part:

```<code>    <h:form id="formTable">
    <p:dataTable editable="true" value="#{types.dataList}" var="datalist" style="width:90%; margin-bottom:20px"
        rows="10" paginator="true" rowsPerPageTemplate="10,25" resizableColumns="true" liveResize="true" tableStyle="width:auto">
        <!-- save the old value for the edit action-->
        <c:set var="oldValue" value="#{datalist.getType()}"/>
        <!-- column for testing purpose-->
        <p:column>
            <h:outputText value="#{oldValue}" />
        </p:column>
        <p:column headerText="Type" sortBy="#{datalist.type}">
            <p:cellEditor>
                <f:facet name="output">
                    <h:outputText value="#{datalist.type}" />
                </f:facet>
                <f:facet name="input">
                    <h:inputText value="#{datalist.type}" binding="#{inputUpdateType}" required="true" />
                </f:facet>
            </p:cellEditor>
        </p:column>
        <p:column headerText="Date" sortBy="#{datalist.lastModifyDate}">
            <h:outputText value="#{datalist.lastModifyDate}"/>
        </p:column>
        <p:column headerText="Edit">
            <p:rowEditor rendered="#{!datalist.dependenciesFound}"/>
            <h:graphicImage value="../images/attention.png" rendered="#{datalist.dependenciesFound}" />
        </p:column>
        <p:column headerText="Delete">
            <p:commandLink action="#{types.delete(datalist.type)}" rendered="#{!datalist.dependenciesFound}" update=":formTable">
                <p:graphicImage url="../images/delete.png" />
                <p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" />
            </p:commandLink>
            <h:outputText value="Not editable because of dependency" rendered="#{datalist.dependenciesFound}"/>
        </p:column>
        <!-- We edit/update the value here. This is where the old value is needed-->
        <p:ajax event="rowEdit" listener="#{types.update(oldValue, inputUpdateType.value)}"/>
    </p:dataTable>
    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
        <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
        <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
    </p:confirmDialog>
</h:form>
</code>```

I hope this is somewhat understandable.
For my project I use Primefaces 6.1. To edit a row in this table I need to save the old value and use that value in the ajax call at the bottom. I need this, because the application or rather the DB table behind this demands it (id is this value).
The edited value is stored in the variable inputUpdateType.

My problem:

When I enter a new value and hit edit, the old value is the same as the edited value, when the application enters the update method. I made a log entry in my update method to verify what values are passed. Same with c:set and ui:param.

What am I doing wrong? How can I make this work?

EDIT:
Here is how I try to get the old value stored in my bean:

```<code><p:ajax event="rowEdit" listener="#{types.update(types.dataListOld.toArray()[rowIndex].getType(), inputUpdateType.value)}"/>
</code>```

答:
So, it seems with ajax the values will be updated before executing the method. Therefore the old value is not available on server side anymore. Unfortunately storing the variable in JSF is also not possible because c:set will be processed before the JSF tags and will thus not hold any values (without a scope it will act as an alias and in the end also been updated before the method gets executed).

To make this whole thing work I used cell edit mode instead of the default row edit mode. With this I'm able to get the old and new value:

```<code>    public void onCellEdit(CellEditEvent event){
    //We will call this method on edits made to a cell
    //Values are stored in a Arraylist. Number of entries depend on how many components there are in the edited cell/facet
    //Here we have two because in "input" there are two components defined (although both are rendered at the same time).
    @SuppressWarnings("unchecked")
    ArrayList<String> oldValue = ((ArrayList<String>)(event.getOldValue()));
    @SuppressWarnings("unchecked")
    ArrayList<String> newValue = ((ArrayList<String>)(event.getNewValue()));

    //In the end both entries have the same value, so we just take the first.
    if(newValue != null && !newValue.equals(oldValue)) {
        update(oldValue.get(0), newValue.get(0));
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue.get(0) + ", New:" + newValue.get(0));
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}
</code>```

Here is why I have two entries in my values list (two components in "input"):

```<code>    <f:facet name="input">
        <h:inputText value="#{datalist.type}" binding="#{inputUpdateType}" required="true" rendered="#{!datalist.dependenciesFound}"/>
        <h:outputText value="#{datalist.type}" rendered="#{datalist.dependenciesFound}"/>
    </f:facet>
</p:cellEditor>
</code>```

Body:
I tried c:set and ui:param, but in the end I think I did something wrong.

Here is the crucial XHTML part:

    <h:form id="formTable">

        <c:set var="oldValue" value="#{datalist.getType()}"/>

            <h:outputText value="#{oldValue}" />

                <f:facet name="output">
                    <h:outputText value="#{datalist.type}" />
                </f:facet>
                <f:facet name="input">
                    <h:inputText value="#{datalist.type}" binding="#{inputUpdateType}" required="true" />
                </f:facet>

            <h:outputText value="#{datalist.lastModifyDate}"/>

            <h:graphicImage value="../images/attention.png" rendered="#{datalist.dependenciesFound}" />

            <h:outputText value="Not editable because of dependency" rendered="#{datalist.dependenciesFound}"/>

</h:form>

I hope this is somewhat understandable.
For my project I use Primefaces 6.1. To edit a row in this table I need to save the old value and use that value in the ajax call at the bottom. I need this, because the application or rather the DB table behind this demands it (id is this value).
The edited value is stored in the variable inputUpdateType.

My problem:

When I enter a new value and hit edit, the old value is the same as the edited value, when the application enters the update method. I made a log entry in my update method to verify what values are passed. Same with c:set and ui:param.

What am I doing wrong? How can I make this work?

EDIT:
Here is how I try to get the old value stored in my bean:

Body:
So, it seems with ajax the values will be updated before executing the method. Therefore the old value is not available on server side anymore. Unfortunately storing the variable in JSF is also not possible because c:set will be processed before the JSF tags and will thus not hold any values (without a scope it will act as an alias and in the end also been updated before the method gets executed).

To make this whole thing work I used cell edit mode instead of the default row edit mode. With this I'm able to get the old and new value:

    public void onCellEdit(CellEditEvent event){
    //We will call this method on edits made to a cell
    //Values are stored in a Arraylist. Number of entries depend on how many components there are in the edited cell/facet
    //Here we have two because in "input" there are two components defined (although both are rendered at the same time).
    @SuppressWarnings("unchecked")
    ArrayList<String> oldValue = ((ArrayList<String>)(event.getOldValue()));
    @SuppressWarnings("unchecked")
    ArrayList<String> newValue = ((ArrayList<String>)(event.getNewValue()));

    //In the end both entries have the same value, so we just take the first.
    if(newValue != null && !newValue.equals(oldValue)) {
        update(oldValue.get(0), newValue.get(0));
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue.get(0) + ", New:" + newValue.get(0));
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}

Here is why I have two entries in my values list (two components in "input"):

    <f:facet name="input">
        <h:inputText value="#{datalist.type}" binding="#{inputUpdateType}" required="true" rendered="#{!datalist.dependenciesFound}"/>
        <h:outputText value="#{datalist.type}" rendered="#{datalist.dependenciesFound}"/>
    </f:facet>
</p:cellEditor>


问:
image link in drupal 6 content
```<code>.content_left_image{
 float:left;
 width:746px;
 height:368px;
 padding-left:1px;
 background-position:right;
}

<div class="content_left_image">$src</div>
</code>```

This div is used in drupal 6 content. & $src is image source... But image is not showed. i think i have problem in image src...my template name is codemen & image folder is in codemen folder...How can i show this image?

答:
Do you really have this:

```<code><div class="content_left_image">$src</div>
</code>```

If yes, you should do this instead:

```<code><div class="content_left_image"><?php print $src; ?></div>
</code>```

I can't understand where are you writing this. If it's the body of a node, you should be able to view the image if the content type has PHP mode enabled. But where does $src come from? It is a placeholder you wrote just here?

I think I'm can't get something of your question.

Anyway, hope this helps.

—Alberto

Title: image link in drupal 6 content

Body:
.content_left_image{
 float:left;
 width:746px;
 height:368px;
 padding-left:1px;
 background-position:right;
}

$src

This div is used in drupal 6 content. & $src is image source... But image is not showed. i think i have problem in image src...my template name is codemen & image folder is in codemen folder...How can i show this image?

Body:
Do you really have this:

<div class="content_left_image">$src</div>

If yes, you should do this instead:

<div class="content_left_image"><?php print $src; ?></div>

I can't understand where are you writing this. If it's the body of a node, you should be able to view the image if the content type has PHP mode enabled. But where does $src come from? It is a placeholder you wrote just here?

I think I'm can't get something of your question.

Anyway, hope this helps.

—Alberto


问:
How to Add a specific number at the end of merging workbooks
I have an excel file that use to merge all the raw data's found in the same folder(Group 1, Group 2, ... Group 15, Group 16), using the code below :

```<code>Sub MergeFiles()
Dim Path, Filename As String, group As Long
group = 1
Path = "C:\Users\calin.lencar\Desktop\DT Project\Project Holiday Group Raw
Data\"
Filename = Dir(Path & "*.csv")

Do While Filename <> "" And Filename <> "Digital Tracking Panel KPIs v1"
  Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
  LastRow = Range("A65536").End(xlUp).Row
  Range("O2", Cells(LastRow, "O")).Value = group
  Range("A2:X" & Range("A65536").End(xlUp).Row).Copy

ThisWorkbook.Worksheets(21).Activate
  Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
  Application.CutCopyMode = False
  Workbooks(Filename).Close

Filename = Dir()
group = group + 1
Loop

MsgBox "Files have been copied successfully"
End Sub
</code>```

I am trying to add in the column "O:O" of each file the group number. The problem is that it opens them alphabetically: "Group 1, Group 10, Group 11... Group 2, Group 3..." but the group counter still goes : 1, 2, 3...

Could you please help me, I need the group counter to match the number in the file's name(maybe populate O:O with the first number it encounters?) or make excel open the files after explorer name.

Thank you in advance.

答:
This is how it Dir() works - it takes the next file alphabetically. Many programs and functions follow this logic actually. Dir() MSDN.

However, if you have all the files from 1 to 15 and they are with the same names, you may try this:

```<code>Option Explicit

Public Sub TestMe()

    Dim firstPart   As String
    Dim i           As Long

    firstPart = "Group "

    For i = 1 To 15
        Debug.Print firstPart & i & ".xlsx"
        'now open this file
    Next i

End Sub
</code>```

It will work. Consider checking whether the file Group 7.xlsx exists, before openning it.

Body:
I have an excel file that use to merge all the raw data's found in the same folder(Group 1, Group 2, ... Group 15, Group 16), using the code below :

Sub MergeFiles()
Dim Path, Filename As String, group As Long
group = 1
Path = "C:\Users\calin.lencar\Desktop\DT Project\Project Holiday Group Raw
Data\"
Filename = Dir(Path & "*.csv")

Do While Filename <> "" And Filename <> "Digital Tracking Panel KPIs v1"
  Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
  LastRow = Range("A65536").End(xlUp).Row
  Range("O2", Cells(LastRow, "O")).Value = group
  Range("A2:X" & Range("A65536").End(xlUp).Row).Copy

ThisWorkbook.Worksheets(21).Activate
  Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
  Application.CutCopyMode = False
  Workbooks(Filename).Close

Filename = Dir()
group = group + 1
Loop

MsgBox "Files have been copied successfully"
End Sub

I am trying to add in the column "O:O" of each file the group number. The problem is that it opens them alphabetically: "Group 1, Group 10, Group 11... Group 2, Group 3..." but the group counter still goes : 1, 2, 3...

Could you please help me, I need the group counter to match the number in the file's name(maybe populate O:O with the first number it encounters?) or make excel open the files after explorer name.

Thank you in advance.

Body:
This is how it Dir() works - it takes the next file alphabetically. Many programs and functions follow this logic actually. Dir() MSDN.

However, if you have all the files from 1 to 15 and they are with the same names, you may try this:

Option Explicit

Public Sub TestMe()

    Dim firstPart   As String
    Dim i           As Long

    firstPart = "Group "

    For i = 1 To 15
        Debug.Print firstPart & i & ".xlsx"
        'now open this file
    Next i

End Sub

It will work. Consider checking whether the file Group 7.xlsx exists, before openning it.


问:
Android Device Monitor "data" folder is empty
I have tested creating, inserting and retrieving data into my apps db, and know it works through usage of Log statements.

However, I wish to expedite testing and use the Android Device Monitor. However, though the db exists and data is stored, when accessing below, the data folder is empty:

Why would this be the case? How can this be configured to show the db file and contents?

答:
I had same problem with API_25, it didn't work for me.

Configure an API_23 emulator, it will work on API_23.


问:
Use tasks in always @* blocks
I was intended to use a customized task in an always @* block, like:

```<code>input [31:0] a;
input b;
output reg [31:0] c;

task mytask;
begin
    if (b) begin
        c = a;
    end
end
endtask

always @* begin
    // ... (b is not included)
    mytask;
    // ... (b is not included)
end
</code>```

What I think is that when signal b changes from 0 to 1, c will be set to the content of a. Then I found the always block is not sensitive to signal b (using ISim 14.7).

Is this a bug or designed to behave like this?

答:
Just to add to the answers:
Your original always @* procedure will never execute because it has an empty trigger list. @ * means: Hey tool (simulator which relies on this list), build the sensitivity list for me. always @ * (by the lang spec) is only sensitive to changes on the arguments of a function/task (alongside other triggers)(in your case - no arguments thus empty sensitivity list), not to changes in signals within the function/task contents.

<s>Side note: I think SystemVerilog's always_comb would work here (2012 std 9.2.2.2.2).</s> Dave, thanks for the clarification.

Title: Use tasks in always @* blocks

Body:
I was intended to use a customized task in an always @* block, like:

input [31:0] a;
input b;
output reg [31:0] c;

task mytask;
begin
    if (b) begin
        c = a;
    end
end
endtask

always @* begin
    // ... (b is not included)
    mytask;
    // ... (b is not included)
end

What I think is that when signal b changes from 0 to 1, c will be set to the content of a. Then I found the always block is not sensitive to signal b (using ISim 14.7).

Is this a bug or designed to behave like this?


问:
Remove certain values from a list of vectors
I have a vector with some characters:

The structure glimpse(a)

```<code>List of 5
 $ : chr [1:2] "Thai" "Restaurants"
 $ : chr [1:2] "Vietnamese" "Restaurants"
 $ : chr [1:3] "Restaurants" "Vegetarian" "Indian"
 $ : chr [1:5] "Nightlife" "Bars" "Restaurants" "Thai" ...
 $ : chr [1:4] "Asian Fusion" "Chinese" "Japanese" "Restaurants"
</code>```

Here is a dput(a)

```<code>list(c("Thai", "Restaurants"), c("Vietnamese", "Restaurants"),
    c("Restaurants", "Vegetarian", "Indian"), c("Nightlife",
    "Bars", "Restaurants", "Thai", "Sports Bars"), c("Asian Fusion",
    "Chinese", "Japanese", "Restaurants"))
</code>```

I want to drop some values by exclusion. For example, the values below are the only values which should stay in the vector. All other values should be removed, with no replacement.

```<code>c("Chinese", "Japanese", "Sushi Bars", "Indian", "Thai", "Vietnamese", "Korean","Taiwanese", "Malaysian", "Mongolian", "Indonesian", "Laotian", "Myanmar", "Pan Asian", "Tempura", "Wok")
</code>```

So, I tried the solution from this post:
How to delete multiple values from a vector?

So I did:

```<code>rm <-  c("Chinese", "Japanese", "Sushi Bars", "Indian", "Thai", "Vietnamese", "Korean","Taiwanese", "Malaysian", "Mongolian", "Indonesian", "Laotian", "Myanmar", "Pan Asian", "Tempura", "Wok")

a [! a %in% rm]
</code>```

But nothing changes?!. Anny Idea how to remove those values from a that doesn't belong to rm

答:
We can do a setdiff if the elements are unique by looping over the list elements with lapply

```<code>lapply(a,  setdiff, rm)
</code>```

Or else, use %in% and then negate

```<code>lapply(a, function(x) x[!x %in% rm])
</code>```

Body:
I have a vector with some characters:

The structure glimpse(a)

List of 5
 $ : chr [1:2] "Thai" "Restaurants"
 $ : chr [1:2] "Vietnamese" "Restaurants"
 $ : chr [1:3] "Restaurants" "Vegetarian" "Indian"
 $ : chr [1:5] "Nightlife" "Bars" "Restaurants" "Thai" ...
 $ : chr [1:4] "Asian Fusion" "Chinese" "Japanese" "Restaurants"

Here is a dput(a)

list(c("Thai", "Restaurants"), c("Vietnamese", "Restaurants"),
    c("Restaurants", "Vegetarian", "Indian"), c("Nightlife",
    "Bars", "Restaurants", "Thai", "Sports Bars"), c("Asian Fusion",
    "Chinese", "Japanese", "Restaurants"))

I want to drop some values by exclusion. For example, the values below are the only values which should stay in the vector. All other values should be removed, with no replacement.

c("Chinese", "Japanese", "Sushi Bars", "Indian", "Thai", "Vietnamese", "Korean","Taiwanese", "Malaysian", "Mongolian", "Indonesian", "Laotian", "Myanmar", "Pan Asian", "Tempura", "Wok")

So, I tried the solution from this post:
How to delete multiple values from a vector?

So I did:

rm <-  c("Chinese", "Japanese", "Sushi Bars", "Indian", "Thai", "Vietnamese", "Korean","Taiwanese", "Malaysian", "Mongolian", "Indonesian", "Laotian", "Myanmar", "Pan Asian", "Tempura", "Wok")

a [! a %in% rm]

But nothing changes?!. Anny Idea how to remove those values from a that doesn't belong to rm

Body:
We can do a setdiff if the elements are unique by looping over the list elements with lapply

lapply(a,  setdiff, rm)

Or else, use %in% and then negate

lapply(a, function(x) x[!x %in% rm])


问:
DataGrid for Zend Framework
Can you recommend good data grid component for Zend Framework?</p>

答:
There is also http://code.google.com/p/kontorx/

This library is very elastic.
You can render data as HTML table or Ext.DataGrid (JavaScript)

Live examples shows full implementation.

OwnerDisplayName: JS

Title: DataGrid for Zend Framework


问:
Exclude specific subdomain or no subdomain in htaccess RewriteRule
I keep dynamic content and static content on different sub domains for my web app but I've recently found out that if called directly the dynamic content can be viewed on my static subdomain (www.) or no subdomain at all.

URL Structure:

```<code>http(s)://(subdomain).(domain).(tld)/(static page) OR (direct/random hash) OR (secure/random hash)
</code>```

All static content is accessible via "WWW" which results in my SEO friendly domains such as

```<code>http(s)://www.domain1.com/about
http(s)://www.domain1.com/
http(s)://www.domain2.com/about
http(s)://www.domain2.com/
</code>```

While dynamic content viewed through the web app would be accessed from a domain such as

```<code>http(s)://dynamic1.domain1.com/direct/randomhash
http(s)://dynamic2.domain1.com/direct/randomhash
http(s)://dynamic1.domain2.com/direct/randomhash
http(s)://dynamic2.domain2.com/direct/randomhash
</code>```

This is my current .htaccess file

The rules to rewrite the dynamic links where the URI starts with secure or direct as well as any file extensions to the index.php file.

```<code>Header set Connection keep-alive
<IfModule mod_dir.c>
    DirectorySlash Off
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^index.php  - [L]
    RewriteRule ^(secure|direct)  /index.php [L]
    RewriteCond %{REQUEST_URI} !^/server-status
    RewriteCond %{REQUEST_URI} !^/public/cache
    RewriteRule !\.(png|gif|css|jpg|zip|js|html|htm|swf|ico|fon|ttf|otf|svg|woff|woff2|eot)$  /index.php [L]
</IfModule>
</code>```

The above is currently working but my issue is that if a user simply changes the sub domain from the one used for dynamic content to WWW it will still work and will result in dynamic content being accessible from my SEO friendly sub domain.

I'm hoping to be able to edit this rule RewriteRule ^(secure|direct)  /index.php [L] so that it would be excluded if there is an active www. sub domain or no subdomain all together while still working if the domain or subdomain is anything else.

That is to say the subdomain or domain would still be a wildcard unless the subdomain is www.

I'm assuming I have to add %{HTTP_HOST} to the RewriteRule ^(secure|direct)  /index.php [L] and use a regex to allow any sub domain, domain, and tld but im not sure how to exclude if the http host starts with WWW. or no subdomain at all.

My end goal is so that the secure and direct paths can not be viewed via a www. or no subdomain while still working with any other subdomain / domain.

答:
You should add a condition to the rule that handles 'secure' and 'direct' requests, so that they have to only come from the subdomains you match, not the www one.

```<code>RewriteCond %{HTTP_HOST}  ^dynamic[0-9]+\.[a-z]+
RewriteRule ^(secure|direct)  /index.php [L]
</code>```

That way only requests that have subdomains matching that rule will get re-written to the PHP script. If the user changes the sub-domain back to www, or to anything else that doesn't match the pattern you specify in the condition, then the request won't find its way through to the PHP script.

If your names for dynamic sub-domains are truly random, then just use something else that you know about them so that 'www' doesn't match, for example if they're all at least four characters long then this pattern would work:

```<code>RewriteCond %{HTTP_HOST}  ^[^.][^.][^.][^.]+\.
RewriteRule ^(secure|direct)  /index.php [L]
</code>```

because the string 'www.' does not match a pattern starting with four or more non-dots and then a dot.

Body:
I keep dynamic content and static content on different sub domains for my web app but I've recently found out that if called directly the dynamic content can be viewed on my static subdomain (www.) or no subdomain at all.

URL Structure:

http(s)://(subdomain).(domain).(tld)/(static page) OR (direct/random hash) OR (secure/random hash)

All static content is accessible via "WWW" which results in my SEO friendly domains such as

http(s)://www.domain1.com/about
http(s)://www.domain1.com/
http(s)://www.domain2.com/about
http(s)://www.domain2.com/

While dynamic content viewed through the web app would be accessed from a domain such as

http(s)://dynamic1.domain1.com/direct/randomhash
http(s)://dynamic2.domain1.com/direct/randomhash
http(s)://dynamic1.domain2.com/direct/randomhash
http(s)://dynamic2.domain2.com/direct/randomhash

This is my current .htaccess file

The rules to rewrite the dynamic links where the URI starts with secure or direct as well as any file extensions to the index.php file.

Header set Connection keep-alive
<IfModule mod_dir.c>
    DirectorySlash Off
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^index.php  - [L]
    RewriteRule ^(secure|direct)  /index.php [L]
    RewriteCond %{REQUEST_URI} !^/server-status
    RewriteCond %{REQUEST_URI} !^/public/cache
    RewriteRule !\.(png|gif|css|jpg|zip|js|html|htm|swf|ico|fon|ttf|otf|svg|woff|woff2|eot)$  /index.php [L]
</IfModule>

The above is currently working but my issue is that if a user simply changes the sub domain from the one used for dynamic content to WWW it will still work and will result in dynamic content being accessible from my SEO friendly sub domain.

I'm hoping to be able to edit this rule RewriteRule ^(secure|direct)  /index.php [L] so that it would be excluded if there is an active www. sub domain or no subdomain all together while still working if the domain or subdomain is anything else.

That is to say the subdomain or domain would still be a wildcard unless the subdomain is www.

I'm assuming I have to add %{HTTP_HOST} to the RewriteRule ^(secure|direct)  /index.php [L] and use a regex to allow any sub domain, domain, and tld but im not sure how to exclude if the http host starts with WWW. or no subdomain at all.

My end goal is so that the secure and direct paths can not be viewed via a www. or no subdomain while still working with any other subdomain / domain.

Body:
You should add a condition to the rule that handles 'secure' and 'direct' requests, so that they have to only come from the subdomains you match, not the www one.

RewriteCond %{HTTP_HOST}  ^dynamic[0-9]+\.[a-z]+
RewriteRule ^(secure|direct)  /index.php [L]

That way only requests that have subdomains matching that rule will get re-written to the PHP script. If the user changes the sub-domain back to www, or to anything else that doesn't match the pattern you specify in the condition, then the request won't find its way through to the PHP script.

If your names for dynamic sub-domains are truly random, then just use something else that you know about them so that 'www' doesn't match, for example if they're all at least four characters long then this pattern would work:

RewriteCond %{HTTP_HOST}  ^[^.][^.][^.][^.]+\.
RewriteRule ^(secure|direct)  /index.php [L]

because the string 'www.' does not match a pattern starting with four or more non-dots and then a dot.


问:
Why R function doesn't use variable from parent parent environment?
I don't get, why glue_data doesn't use a variable available from parent parent environment? See code below. Function test_call_glue_directly returns desired result. Function test_call_glue returns error  Error in eval(x, envir = data, enclos = envir) : object 'c_1' not found

Of course, my real function has more than one variable. formula_1 might refer to {c_2} and {c_3}. Or {c_456}, {c_7}, {c_8}. The count of c_* might be different.

Is there a way how to create new environment specifically for calling this glue_data? Or pull variable from parent environment? Or some better way how to organize my code? I don't want to pass the parameter c_1 to funciton fill_1 because in my real script there could be unknown count of variables with unknown names.

```<code>fill_1 <- function(letts, n0, formula_x) {
  purrr::cross_df(list(row = n0, column = letts)) %>%
    glue::glue_data(formula_x) %>%
    matrix(ncol = length(letts)) %>%
    as.data.frame
}

test_call_glue <- function() {
  c_1 <- "C"
  formula_1 <-  "={c_1}{row}"
  fill_1(c("A"), c(1:5), formula_1)
}

test_call_glue_directly <- function() {
  # The function without wrapping glue_data in function
  c_1 <- "C"
  formula_1 <-  "={c_1}{row}"
  purrr::cross_df(list(row = c(1:5), column = c("A"))) %>%
    glue::glue_data(formula_1) %>%
    matrix(ncol = 1) %>%
    as.data.frame
}

test_call_glue_directly()
test_call_glue()
</code>```

答:
I'm coming back to revisit my question. Since then I have learned to use dots as argument to my custom function:

```<code>fill_3a <- function(x, ...) {
  paste(paste0(x, c_1), paste0(x, c_2), sep=":::")
}
test_call_paste_a <- function() {
  c_1 <- "C"
  c_2 <- "H"
  ans <- fill_3a("4", c_1, c_2)
  return(ans)
}

test_call_paste_a()
</code>```

Probably it doesn't make sense to call unnamed argument my name, but it makes sense for my use case, where the first argument is string used for glue::glue (variables are substituted to their values by name).

Body:
I don't get, why glue_data doesn't use a variable available from parent parent environment? See code below. Function test_call_glue_directly returns desired result. Function test_call_glue returns error  Error in eval(x, envir = data, enclos = envir) : object 'c_1' not found

Of course, my real function has more than one variable. formula_1 might refer to {c_2} and {c_3}. Or {c_456}, {c_7}, {c_8}. The count of c_* might be different.

Is there a way how to create new environment specifically for calling this glue_data? Or pull variable from parent environment? Or some better way how to organize my code? I don't want to pass the parameter c_1 to funciton fill_1 because in my real script there could be unknown count of variables with unknown names.

fill_1 <- function(letts, n0, formula_x) {
  purrr::cross_df(list(row = n0, column = letts)) %>%
    glue::glue_data(formula_x) %>%
    matrix(ncol = length(letts)) %>%
    as.data.frame
}

test_call_glue <- function() {
  c_1 <- "C"
  formula_1 <-  "={c_1}{row}"
  fill_1(c("A"), c(1:5), formula_1)
}

test_call_glue_directly <- function() {
  # The function without wrapping glue_data in function
  c_1 <- "C"
  formula_1 <-  "={c_1}{row}"
  purrr::cross_df(list(row = c(1:5), column = c("A"))) %>%
    glue::glue_data(formula_1) %>%
    matrix(ncol = 1) %>%
    as.data.frame
}

test_call_glue_directly()
test_call_glue()

Body:
I'm coming back to revisit my question. Since then I have learned to use dots as argument to my custom function:

fill_3a <- function(x, ...) {
  paste(paste0(x, c_1), paste0(x, c_2), sep=":::")
}
test_call_paste_a <- function() {
  c_1 <- "C"
  c_2 <- "H"
  ans <- fill_3a("4", c_1, c_2)
  return(ans)
}

test_call_paste_a()

Probably it doesn't make sense to call unnamed argument my name, but it makes sense for my use case, where the first argument is string used for glue::glue (variables are substituted to their values by name).


问:
How to get a polynomial providing the exponential numbers for each term of the function?
I'm trying to write a polynomial. However, I have found scipy methods which give the polynomial format like x^4 + 2x^3 - x^2 + 3, from which the coefficients are [3, 0, -1, 2, 1], and the exponential by 4, 3, and 2.

Is there a way to manipulate the exponential through a given list of number? Something like, giving:

```<code>nj = [0.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 5.0, 5.0, 5.0, 6.0, 6.0, 6.0, 7.0, 8.0]
</code>```

For example, I could calculate terms of a polynomial like coef*x^nj = 0 for a given unique coef.

Thank you!

答:
If you have a NumPy array of coefficients coef, and a NumPy array of exponents nj, the value of the polynomial at x can be computed as

```<code>coef.dot(x**nj)
</code>```

Example:

```<code>coef = np.array([3.1, 0, -2, 5, 1.1])
nj = np.array([0, 1, 2, 2, 5])
x = 1.23
print(coef.dot(x**nj))   # 10.7355362527
</code>```

Body:
I'm trying to write a polynomial. However, I have found scipy methods which give the polynomial format like x^4 + 2x^3 - x^2 + 3, from which the coefficients are [3, 0, -1, 2, 1], and the exponential by 4, 3, and 2.

Is there a way to manipulate the exponential through a given list of number? Something like, giving:

nj = [0.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 5.0, 5.0, 5.0, 6.0, 6.0, 6.0, 7.0, 8.0]

For example, I could calculate terms of a polynomial like coef*x^nj = 0 for a given unique coef.

Thank you!

Body:
If you have a NumPy array of coefficients coef, and a NumPy array of exponents nj, the value of the polynomial at x can be computed as

coef.dot(x**nj)

Example:

coef = np.array([3.1, 0, -2, 5, 1.1])
nj = np.array([0, 1, 2, 2, 5])
x = 1.23
print(coef.dot(x**nj))   # 10.7355362527


问:
How to know DOM rendering is completed in AngularJS using ng-repeat
I want to raise an alert or message when my html dom has completed rendering using angularjs with the multiple ng-repeat.

HTML Code:

```<code>       <body>
            <div ng-controller="Ctrl">
               <div ng-repeat="thing in things" my-post-repeat-directive>
                        thing {{thing}}
                  </div>
                  <div ng-show="complete">Complete {{complete}}</div>
            </div>
      </body>
</code>```

JS Code

```<code>       function Ctrl($scope) {
        $scope.complete = false;
          $scope.doComplete = function() {
              $scope.complete = true;
           }

         $scope.things = [
                    'A', 'B', 'C'
                    ];
              }

          angular.module('myApp', [])
          .directive('myPostRepeatDirective', function() {
            return function(scope, element, attrs) {
           if (scope.$last) {
            scope.$eval('doComplete()');
              }
         };
     });
</code>```

答:
AngularJS has LIFECYCLE HOOKS as

```<code>$postLink(() => {
   yours alert
})
</code>```

$postLink() - Called after this controller's element and its children
  have been linked. Similar to the post-link function this hook can be
  used to set up DOM event handlers and do direct DOM manipulation

Body:
I want to raise an alert or message when my html dom has completed rendering using angularjs with the multiple ng-repeat.

HTML Code:

                        thing {{thing}}

Complete {{complete}}

JS Code

       function Ctrl($scope) {
        $scope.complete = false;
          $scope.doComplete = function() {
              $scope.complete = true;
           }

         $scope.things = [
                    'A', 'B', 'C'
                    ];
              }

          angular.module('myApp', [])
          .directive('myPostRepeatDirective', function() {
            return function(scope, element, attrs) {
           if (scope.$last) {
            scope.$eval('doComplete()');
              }
         };
     });

Body:
AngularJS has LIFECYCLE HOOKS as

$postLink(() => {
   yours alert
})

$postLink() - Called after this controller's element and its children
  have been linked. Similar to the post-link function this hook can be
  used to set up DOM event handlers and do direct DOM manipulation


问:
Spyder python: Skip printing all code when using "run current cell"
When I use "run current cell" or "run selection" the compiler print ALL the code it will run to the console and then runs it.

Any way to supress this? I dont want to flood the console with all this non-useful information. I know what code i ran, I don't need it repeated (i just need it to run:).

答:
(Spyder maintainer here) Sorry, there is no way to not print cells in the IPython console in any version of Spyder 3.

However, we are working to make this possibility available in Spyder 4, to be released in 2019.


问:
Getting error when run react-native run-android
```<code>A problem occurred configuring project ':app'.
   > Could not resolve all dependencies for configuration ':app:_debugApk'.
     > A problem occurred configuring project ':react-native-fbsdk'.
       > Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugPublishCopy'.
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.react:react-native:0.46.4
         > Could not find com.android.support:support-annotations:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0
         > Could not find com.android.support:support-core-utils:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:cardview-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:customtabs:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:support-v4:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
</code>```

compileSdkVersion 25

buildToolsVersion "25.0.0"

targetSdkVersion 25

答:
I've faced the same issue today.

Looks like there is some problem with react-native-fbsdk package;

I've found the only way to solve it for now:

at node_modules/react-native-fbsdk/android/build.gradle

change compile('com.facebook.android:facebook-android-sdk:4+')

to compile('com.facebook.android:facebook-android-sdk:4.26.0')

This is very bad solution.

If you will find proper way to solve it - please share.

Body:
A problem occurred configuring project ':app'.
   > Could not resolve all dependencies for configuration ':app:_debugApk'.
     > A problem occurred configuring project ':react-native-fbsdk'.
       > Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugPublishCopy'.
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.react:react-native:0.46.4
         > Could not find com.android.support:support-annotations:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0
         > Could not find com.android.support:support-core-utils:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0
         > Could not find com.android.support:appcompat-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:cardview-v7:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:customtabs:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0
         > Could not find com.android.support:support-v4:27.0.1.
           Searched in the following locations:
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.pom
             file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar
             file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar
           Required by:
             beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0

compileSdkVersion 25

buildToolsVersion "25.0.0"

targetSdkVersion 25


问:
Sort a Set in reverse order
Apologies for the newbie question, but what's the proper way to get a Set (say LinkedHashSet) in reverse order? For Collections there's Collections.reverse(Collection c), but how does one do it for a Set with ordered elements (like a LinkedHashSet)?

答:
I will explain you with an example. Comments are added in mid of the code for better understanding.

```<code>public class ReverseLinkedHashSet {

    public static void main(String[] args) {

        // creating a LinkedHashSet object which is
        // of type String or any. Will take a example of String.
        HashSet<String> cars = new LinkedHashSet<String>();

        // adding car elements to LinkedHashSet object as below
        cars.add("Toyato");
        cars.add("Hundai");
        cars.add("Porshe");
        cars.add("BMW");

        // Iterating using enhanced for-loop to see the order.
        System.out.println("Insertion Order: Iterating LinkedHashSet\n");
        for(String car : cars) {
            System.out.println(car);

        // Output will be as below
        //Toyato
        //Hundai
        //Porshe
        //BMW
        }

        // Now convert to ArrayList to rearrange to reverse
        // the linkedHashset
        List<String> listOfCars = new ArrayList<String>(cars);

        // to reverse LinkedHashSet contents
        Collections.reverse(listOfCars);

        // reverse order of LinkedHashSet contents
        // can be done as below
        System.out.println("\n\n\nReverse Order of LinkedHashSet\n");
        for(String car : listOfCars) {
            System.out.println(car);

        // Output will be as below
        //BMW
        //Porshe
        //Hundai
        //Toyato
        }
    }
}
</code>```

Also, I suggest not to use LinkedhashSet without a strong reason. For a complex application, it will reduce the performance. Use HashSet instead.

Title: Sort a Set in reverse order

Body:
I will explain you with an example. Comments are added in mid of the code for better understanding.

public class ReverseLinkedHashSet {

    public static void main(String[] args) {

        // creating a LinkedHashSet object which is
        // of type String or any. Will take a example of String.
        HashSet<String> cars = new LinkedHashSet<String>();

        // adding car elements to LinkedHashSet object as below
        cars.add("Toyato");
        cars.add("Hundai");
        cars.add("Porshe");
        cars.add("BMW");

        // Iterating using enhanced for-loop to see the order.
        System.out.println("Insertion Order: Iterating LinkedHashSet\n");
        for(String car : cars) {
            System.out.println(car);

        // Output will be as below
        //Toyato
        //Hundai
        //Porshe
        //BMW
        }

        // Now convert to ArrayList to rearrange to reverse
        // the linkedHashset
        List<String> listOfCars = new ArrayList<String>(cars);

        // to reverse LinkedHashSet contents
        Collections.reverse(listOfCars);

        // reverse order of LinkedHashSet contents
        // can be done as below
        System.out.println("\n\n\nReverse Order of LinkedHashSet\n");
        for(String car : listOfCars) {
            System.out.println(car);

        // Output will be as below
        //BMW
        //Porshe
        //Hundai
        //Toyato
        }
    }
}

Also, I suggest not to use LinkedhashSet without a strong reason. For a complex application, it will reduce the performance. Use HashSet instead.


问:
Swift - uiDelegate must either be a UIViewController or implement the signIn:presentViewController: & signIn:dismissViewController: methods
From the Crashlytics, we are receiving a large amount of crash reports in the Google Login process. The crash report is as follows:

```<code>Fatal Exception: NSInvalidArgumentException
uiDelegate must either be a |UIViewController| or implement the |signIn:presentViewController:| and |signIn:dismissViewController:| methods from |GIDSignInUIDelegate|.

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1837f2db0 __exceptionPreprocess
1  libobjc.A.dylib                0x182e57f80 objc_exception_throw
2  CoreFoundation                 0x1837f2cf8 -[NSException initWithCoder:]
3  Hello English                  0x100583d18 -[GIDSignIn assertValidUIDelegate] (GIDSignIn.m:512)
4  Hello English                  0x1005861dc -[GIDSignIn signInWithOptions:] (GIDSignIn.m:961)
5  Hello English                  0x10058a0e4 -[GIDSignInButton pressed] (GIDSignInButton.m:385)
6  UIKit                          0x188988be8 -[UIApplication sendAction:to:from:forEvent:]
7  UIKit                          0x188988b64 -[UIControl sendAction:to:forEvent:]
8  UIKit                          0x188970870 -[UIControl _sendActionsForEvents:withEvent:]
9  UIKit                          0x188988454 -[UIControl touchesEnded:withEvent:]
10 UIKit                          0x188988084 -[UIWindow _sendTouchesForEvent:]
11 UIKit                          0x188980c20 -[UIWindow sendEvent:]
12 UIKit                          0x18895104c -[UIApplication sendEvent:]
13 UIKit                          0x18894f628 _UIApplicationHandleEventQueue
14 CoreFoundation                 0x1837a909c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
15 CoreFoundation                 0x1837a8b30 __CFRunLoopDoSources0
16 CoreFoundation                 0x1837a6830 __CFRunLoopRun
17 CoreFoundation                 0x1836d0c50 CFRunLoopRunSpecific
18 GraphicsServices               0x184fb8088 GSEventRunModal
19 UIKit                          0x1889ba088 UIApplicationMain
20 Hello English                  0x10029b2cc main (AppDelegate.swift:26)
21 libdispatch.dylib              0x18326e8b8 (Missing)
</code>```

We've tried so far:

Moved GIDSignIn.sharedInstance().uiDelegate = self from viewDidLoad() to viewDidAppear(animated: Bool)

We've also implemented all three methods of GIDSignInUIDelegate with no success.

Our view controller was not direct child of UIViewController, but now it is and the crashes are still counting.

We were using simple UIButton, so we thought that might be cause (though illogical, but we tried) of crash; we changed it to GIDSignInButton, but no reduction in crash-count.

For now we have removed the Google Login process, but it is not the solution. And strange thing is that we are unable to reproduce this crash at our end; we are only getting these crashes on Crashlytics.

So Anyone with any solution ?

答:
you need to implement Delegate of the Google and firebase properly

add like this

```<code>class ViewController: UIViewController, GIDSignInDelegate,GIDSignInUIDelegate
</code>```

in the ViewDidLoad add these lines

```<code>GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().signIn()
</code>```

Body:
From the Crashlytics, we are receiving a large amount of crash reports in the Google Login process. The crash report is as follows:

Fatal Exception: NSInvalidArgumentException
uiDelegate must either be a |UIViewController| or implement the |signIn:presentViewController:| and |signIn:dismissViewController:| methods from |GIDSignInUIDelegate|.

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1837f2db0 __exceptionPreprocess
1  libobjc.A.dylib                0x182e57f80 objc_exception_throw
2  CoreFoundation                 0x1837f2cf8 -[NSException initWithCoder:]
3  Hello English                  0x100583d18 -[GIDSignIn assertValidUIDelegate] (GIDSignIn.m:512)
4  Hello English                  0x1005861dc -[GIDSignIn signInWithOptions:] (GIDSignIn.m:961)
5  Hello English                  0x10058a0e4 -[GIDSignInButton pressed] (GIDSignInButton.m:385)
6  UIKit                          0x188988be8 -[UIApplication sendAction:to:from:forEvent:]
7  UIKit                          0x188988b64 -[UIControl sendAction:to:forEvent:]
8  UIKit                          0x188970870 -[UIControl _sendActionsForEvents:withEvent:]
9  UIKit                          0x188988454 -[UIControl touchesEnded:withEvent:]
10 UIKit                          0x188988084 -[UIWindow _sendTouchesForEvent:]
11 UIKit                          0x188980c20 -[UIWindow sendEvent:]
12 UIKit                          0x18895104c -[UIApplication sendEvent:]
13 UIKit                          0x18894f628 _UIApplicationHandleEventQueue
14 CoreFoundation                 0x1837a909c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
15 CoreFoundation                 0x1837a8b30 __CFRunLoopDoSources0
16 CoreFoundation                 0x1837a6830 __CFRunLoopRun
17 CoreFoundation                 0x1836d0c50 CFRunLoopRunSpecific
18 GraphicsServices               0x184fb8088 GSEventRunModal
19 UIKit                          0x1889ba088 UIApplicationMain
20 Hello English                  0x10029b2cc main (AppDelegate.swift:26)
21 libdispatch.dylib              0x18326e8b8 (Missing)

We've tried so far:

Moved GIDSignIn.sharedInstance().uiDelegate = self from viewDidLoad() to viewDidAppear(animated: Bool)

We've also implemented all three methods of GIDSignInUIDelegate with no success.

Our view controller was not direct child of UIViewController, but now it is and the crashes are still counting.

We were using simple UIButton, so we thought that might be cause (though illogical, but we tried) of crash; we changed it to GIDSignInButton, but no reduction in crash-count.

For now we have removed the Google Login process, but it is not the solution. And strange thing is that we are unable to reproduce this crash at our end; we are only getting these crashes on Crashlytics.

So Anyone with any solution ?

Body:
you need to implement Delegate of the Google and firebase properly

add like this

class ViewController: UIViewController, GIDSignInDelegate,GIDSignInUIDelegate

in the ViewDidLoad add these lines

GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().signIn()


问:
What should be provided as parameter to check which enum name occured
If I loop through list containing names like Enum:

```<code>newEnum.ForEach(x => {
    if(x == Enum.AAA) { method(parameter); }
    else if(x == Enum.BBB) { method(parameter); }
    // etc.
});

method(parameter);
</code>```

so when defining a method to do something, I dont want to write It 10 times,
so how should I provide parameter in the method so I can check which of this
enum occured ? Enum.AAA or Enum.BBB or something else ?

EDIT: How to provide information on selected enum in method so I can use it. I need to do something depending on is it Enum.AAA, or Enum.BBB, or maybe some other? hope you understand me

答:
Since you haven't mentioned two different enum-types and always use Enum, Enum.AAA and Enum.BBB, the parameter just needs to be of type Enum. The method can use a switch then.

```<code>public enum Enum{ AAA, BBB }
</code>```

...

```<code>foreach(Enum x in newEnum)
    method(x);
</code>```

....

```<code>public void method(Enum x)
{
    switch(x)
    {
         case Enum.AAA: ... break;
         case Enum.BBB: ... break;
    }
}
</code>```

Body:
If I loop through list containing names like Enum:

newEnum.ForEach(x => {
    if(x == Enum.AAA) { method(parameter); }
    else if(x == Enum.BBB) { method(parameter); }
    // etc.
});

method(parameter);

so when defining a method to do something, I dont want to write It 10 times,
so how should I provide parameter in the method so I can check which of this
enum occured ? Enum.AAA or Enum.BBB or something else ?

EDIT: How to provide information on selected enum in method so I can use it. I need to do something depending on is it Enum.AAA, or Enum.BBB, or maybe some other? hope you understand me

Body:
Since you haven't mentioned two different enum-types and always use Enum, Enum.AAA and Enum.BBB, the parameter just needs to be of type Enum. The method can use a switch then.

public enum Enum{ AAA, BBB }

...

foreach(Enum x in newEnum)
    method(x);

....

public void method(Enum x)
{
    switch(x)
    {
         case Enum.AAA: ... break;
         case Enum.BBB: ... break;
    }
}


问:
How to configure Jacoco with SonarQube and Maven in Jenkins

I Am trying to enable Sonarqube code coverage scan. I work on a Maven project in Eclipse and have already setup a successful Jenkins-build including Sonar-scan.

I already succeeded in using Jacoco locally; I added the Jacoco plugin to the pom.xml and executed jacoco:prepare-agent test jacoco:report via Run As-> Maven build.... After that call the html reports were located in target\site\jacoco and they seem to be correct.

Now I need to make it work in Jenkins but I don't know how to correctly configure the build. Currently the maven goal clean package -fae and an Invoke Standalone Sonar Analysis build step are executed.
 I found out that sonar.jacoco.reportPath needs do be set, but I don't know where to set it or where to call the jacoco:report target. Also I am unsure whether I need to add the jacoco plugin to jenkins as well, or if it is sufficient to do so in the maven project.

Any help is much appreciated, also please let me know if there is anything I can do to improve my question.

答:
Yes you need to install and configure jacoco plugin in jenkins.

Foolow this link which explains it

https://dzone.com/articles/jacoco-jenkins-plugin


问:
How do I fix a Git detached head?
I was doing some work in my repository and noticed a file had local changes. I didn't want them anymore so I deleted the file, thinking I can just checkout a fresh copy. I wanted to do the Git equivalent of

```<code>svn up .
</code>```

Using git pull didn't seem to work. Some random searching led me to a site where someone recommended doing

```<code>git checkout HEAD^ src/
</code>```

(src is the directory containing the deleted file).

Now I find out I have a detached head. I have no idea what that is. How can I undo?

答:
To further clarify @Philippe Gerber's answer, here it is:

Before cherry-pick, a git checkout master is necessary in this case. Furthermore, it is only needed with a commit in detached head.

Title: How do I fix a Git detached head?

Body:
I was doing some work in my repository and noticed a file had local changes. I didn't want them anymore so I deleted the file, thinking I can just checkout a fresh copy. I wanted to do the Git equivalent of

svn up .

Using git pull didn't seem to work. Some random searching led me to a site where someone recommended doing

git checkout HEAD^ src/

(src is the directory containing the deleted file).

Now I find out I have a detached head. I have no idea what that is. How can I undo?


问:
Xcode - How to make a universal app
I have an iPhone app and I want to make it universal, but I don't know how to go about doing this, at least properly anyway. Earlier I tried the "upgrade current target to iPad" but it didn't work properly, but luckily I saved a backup from just before trying it.

Anyway, can anyone advise me on how to do this?

答: Create a new MainWindow_iPad.xib file targeted to iPad. Open the app's info.plist file. Add a new key for (something like) Main Nib Name(iPad). (Don't worry, Xcode will give you autocomplete options) Set it to this new .xib file. Now, when the app boots on an iPad, it'll load the new .xib. You can now write your code as normal.</p>

Title: Xcode - How to make a universal app


问:
SymmetricDS Syncing is not syncing perfectly
I have a 3 server running SymmetricDS. Say i have node 1 which is master, node 2.node 3 are child.

When some data is being inserted into node 2 it's being synced to node 1 and similarly node 3's data is being syncing with node 1. But node 2 data is not going to node 3.

I do not know where to solve this issue. Here is the sample configuration sql

```<code>        -- =========================================
        -- channel starts

        insert into sym_channel
        (channel_id, processing_order, max_batch_size, enabled, description)
        values('acc', 1, 100000, 1, 'account sample');

        -- =========================================
        -- channel ends

        -- =========================================
        -- group starts

        insert into sym_node_group
              (node_group_id, description)
              values ('corp', 'A corporate node');
        insert into sym_node_group
              (node_group_id, description)
              values ('store', 'A retail store node');
        -- group ends
        -- =========================================

        -- =========================================
        -- Group links starts

        insert into sym_node_group_link
        (source_node_group_id, target_node_group_id, data_event_action)
              values ('store', 'corp', 'P');
        insert into sym_node_group_link
        (source_node_group_id, target_node_group_id, data_event_action)
              values ('corp', 'store', 'W');

        -- Group link ends
        -- =========================================

        -- =========================================
        -- trigger starts
        insert into
        sym_trigger (trigger_id, source_table_name, channel_id, last_update_time,  create_time)
        values      ('a1',     'acc_asi',        'acc',   current_timestamp, current_timestamp);

        insert into
        sym_trigger (trigger_id, source_table_name, channel_id, last_update_time,  create_time)
        values      ('a2',     'acc_lop_asi',        'acc',   current_timestamp, current_timestamp);

        -- =========================================
        -- trigger ends

        -- =========================================
        -- router starts
        insert into sym_router
        (router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
        values('corp_2_store', 'corp', 'store', 'default',current_timestamp, current_timestamp);
        insert into sym_router
        (router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
        values('store_2_corp', 'store', 'corp', 'default',current_timestamp, current_timestamp);
        -- router ends
        -- =========================================

        -- =========================================
        -- trigger router starts

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a1', 'store_2_corp', 1, current_timestamp, current_timestamp);

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a2', 'store_2_corp', 1, current_timestamp, current_timestamp);

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a1', 'corp_2_store', 1, current_timestamp, current_timestamp);

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a2', 'corp_2_store', 1, current_timestamp, current_timestamp);

        -- =========================================
        -- trigger router ends
</code>```

It would be very helpful if i can know how to push node 2's  data to node 3. or  node 2 push data on node 1 and then node 1 push those data to node 3

Regards,

Nixon

答: Set the sym_trigger's column sync_on_incoming_batch to 1 for the tables needed to get synced from 2 to 3 and vice-versa via master 1.

Body:
I have a 3 server running SymmetricDS. Say i have node 1 which is master, node 2.node 3 are child.

When some data is being inserted into node 2 it's being synced to node 1 and similarly node 3's data is being syncing with node 1. But node 2 data is not going to node 3.

I do not know where to solve this issue. Here is the sample configuration sql

        -- =========================================
        -- channel starts

        insert into sym_channel
        (channel_id, processing_order, max_batch_size, enabled, description)
        values('acc', 1, 100000, 1, 'account sample');

        -- =========================================
        -- channel ends

        -- =========================================
        -- group starts

        insert into sym_node_group
              (node_group_id, description)
              values ('corp', 'A corporate node');
        insert into sym_node_group
              (node_group_id, description)
              values ('store', 'A retail store node');
        -- group ends
        -- =========================================

        -- =========================================
        -- Group links starts

        insert into sym_node_group_link
        (source_node_group_id, target_node_group_id, data_event_action)
              values ('store', 'corp', 'P');
        insert into sym_node_group_link
        (source_node_group_id, target_node_group_id, data_event_action)
              values ('corp', 'store', 'W');

        -- Group link ends
        -- =========================================

        -- =========================================
        -- trigger starts
        insert into
        sym_trigger (trigger_id, source_table_name, channel_id, last_update_time,  create_time)
        values      ('a1',     'acc_asi',        'acc',   current_timestamp, current_timestamp);

        insert into
        sym_trigger (trigger_id, source_table_name, channel_id, last_update_time,  create_time)
        values      ('a2',     'acc_lop_asi',        'acc',   current_timestamp, current_timestamp);

        -- =========================================
        -- trigger ends

        -- =========================================
        -- router starts
        insert into sym_router
        (router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
        values('corp_2_store', 'corp', 'store', 'default',current_timestamp, current_timestamp);
        insert into sym_router
        (router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
        values('store_2_corp', 'store', 'corp', 'default',current_timestamp, current_timestamp);
        -- router ends
        -- =========================================

        -- =========================================
        -- trigger router starts

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a1', 'store_2_corp', 1, current_timestamp, current_timestamp);

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a2', 'store_2_corp', 1, current_timestamp, current_timestamp);

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a1', 'corp_2_store', 1, current_timestamp, current_timestamp);

        insert into sym_trigger_router
        (trigger_id, router_id, initial_load_order, create_time, last_update_time)
        values ('a2', 'corp_2_store', 1, current_timestamp, current_timestamp);

        -- =========================================
        -- trigger router ends

It would be very helpful if i can know how to push node 2's  data to node 3. or  node 2 push data on node 1 and then node 1 push those data to node 3

Regards,

Nixon


问:
Teradata odbc driver for Mac OS sierra
I am trying to connect to Teradata on my Tableau Desktop 9.2.7.

I am on Mac OS Sierra. It shows the following error when I try to connect to Teradata database

Detailed Error Message:

```<code>[iODBC][Driver Manager]dlopen(/Library/Application Support/teradata/client/ODBC/lib/tdata.dylib, 6): Library not loaded: libtdparse.dylib Referenced from: /Library/Application Support/teradata/client/ODBC/lib/tdata.dylib Reason: image not found [iODBC][Driver Manager]Specified driver could not be loaded Unable to connect to the server "wm1". Check that the server is running and that you have access privileges to the requested database.
</code>```

I have already installed the required ODBC drivers from the Teradata website. I even tried installing the previous versions of the driver. I'm not able to get past this error message. Can someone guide me towards a fix?

答: I’d the same problem and am on Sierra too. but it was resolved after i installed the Teradata ODBC driver v16.20 (previously was v15.00). See if it works?</p>

Title: Teradata odbc driver for Mac OS sierra

Body:
I am trying to connect to Teradata on my Tableau Desktop 9.2.7.

I am on Mac OS Sierra. It shows the following error when I try to connect to Teradata database

Detailed Error Message:

[iODBC][Driver Manager]dlopen(/Library/Application Support/teradata/client/ODBC/lib/tdata.dylib, 6): Library not loaded: libtdparse.dylib Referenced from: /Library/Application Support/teradata/client/ODBC/lib/tdata.dylib Reason: image not found [iODBC][Driver Manager]Specified driver could not be loaded Unable to connect to the server "wm1". Check that the server is running and that you have access privileges to the requested database.

I have already installed the required ODBC drivers from the Teradata website. I even tried installing the previous versions of the driver. I'm not able to get past this error message. Can someone guide me towards a fix?


问:
How to add a character like ("," , "[" , "]") at the end of a JSON-Object

I have a Python-script that makes an File with invalid JSON.
Now I want to manipulate this JSON-File so it becomes a valid JSON-file by adding a comma between every object, at the beginning of the File a '[' and at the end a ']'.
Is there a way to make this with JSON alone or do i have to find a way with other read and write functions?

Exsample_File.json:

```<code>    {
    "firstName": "Bidhan",
    "lastName": "Chatterjee",
    "age": 40,
    "email":"bidhan@example.com"
    }
    {
    "firstName": "hanbid",
    "lastName": "jeeChatter",
    "age": 10,
    "email":"example@bidhan.com"
    }
     ....
    n times
</code>```

New_File.json:

```<code>    [
    {
    "firstName": "Bidhan",
    "lastName": "Chatterjee",
    "age": 40,
    "email":"bidhan@example.com"
    },
    {
    "firstName": "hanbid",
    "lastName": "jeeChatter",
    "age": 10,
    "email":"example@bidhan.com"
    },
     ....
    n times
    ]
</code>```

This is the function that makes this JSON-File. I dont want to touch the other code where the str is generated.

```<code>data = json.loads(str)
    with open('Example_File.json','ab')as outfile:
        json.dump(data, outfile, indent=2)
</code>```

So far i dont have an idea to solve this problem. so there is no code sample that would help.

The result should be like the New-File

答:
First of all I don't think there is a way to parse it directly as JSON array.
However, if your JSON objects are not nested a simple way to parse them is to split your string:

```<code>with open(YOUR_FILE) as jsons_file:
    jsons = [x.strip() + '}' for x in jsons_file.read().split('}')][:-1]
</code>```

now you can dump it to file or string using json's library dump or dumps

```<code>json.dumps(jsons)
</code>```

or

```<code>with open(OUT_FILE, 'w') as out_file:
    json.dump(jsons, out_file)
</code>```

Body:
I have a Python-script that makes an File with invalid JSON.
Now I want to manipulate this JSON-File so it becomes a valid JSON-file by adding a comma between every object, at the beginning of the File a '[' and at the end a ']'.
Is there a way to make this with JSON alone or do i have to find a way with other read and write functions?

Exsample_File.json:

    {
    "firstName": "Bidhan",
    "lastName": "Chatterjee",
    "age": 40,
    "email":"bidhan@example.com"
    }
    {
    "firstName": "hanbid",
    "lastName": "jeeChatter",
    "age": 10,
    "email":"example@bidhan.com"
    }
     ....
    n times

New_File.json:

    [
    {
    "firstName": "Bidhan",
    "lastName": "Chatterjee",
    "age": 40,
    "email":"bidhan@example.com"
    },
    {
    "firstName": "hanbid",
    "lastName": "jeeChatter",
    "age": 10,
    "email":"example@bidhan.com"
    },
     ....
    n times
    ]

This is the function that makes this JSON-File. I dont want to touch the other code where the str is generated.

data = json.loads(str)
    with open('Example_File.json','ab')as outfile:
        json.dump(data, outfile, indent=2)

So far i dont have an idea to solve this problem. so there is no code sample that would help.

The result should be like the New-File

Body:
First of all I don't think there is a way to parse it directly as JSON array.
However, if your JSON objects are not nested a simple way to parse them is to split your string:

with open(YOUR_FILE) as jsons_file:
    jsons = [x.strip() + '}' for x in jsons_file.read().split('}')][:-1]

now you can dump it to file or string using json's library dump or dumps

json.dumps(jsons)

or

with open(OUT_FILE, 'w') as out_file:
    json.dump(jsons, out_file)