问:
Selection checkboxes not shown in the table
I have seen this example of Table https://openui5.hana.ondemand.com/explored.html#/sample/sap.ui.table.sample.Basic/preview

In the example on the left of each row I have a checkbox to select the row.
In the my implementation don't see the ceckboxes:

This is the code (a table in a wizardstep into a wizard inside a dialog):

<WizardStep id='stepImballo' title="Formato imballo" icon="sap-icon://customer-view"
                        complete="wizardStepCompletedHandler">

                <t:Table
                        rows="{model>/formatoImballoColore/}"
                        selectionMode="MultiToggle"
                        visibleRowCount="6">
                    <t:columns>
                        <t:Column>
                            <m:Label text="Formato"/>
                            <t:template>
                                <m:Text text="{model>formato/description}"/>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Peso (kg)"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Articolo latta"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Tara"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Imballo"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Quantità per UDC"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                    </t:columns>
                </t:Table>

            </WizardStep>
```

<p>On the top of my fragment I have the xml uses:</p>

```xmlns="sap.m"
xmlns:t="sap.ui.table"
xmlns:core="sap.ui.core"
xmlns:f="sap.ui.layout.form"
xmlns:l="sap.ui.layout"
xmlns:m="sap.m"
```

The problem seems to be the incorrect use of one of the component(use sap.ui in place of sap.m)

答:
I faced the same hair splitting issue. Found that the checkboxes were not being rendered on older version of SAPUI5 library ( we were using version 1.28.39).

Found solution by adding class sapUiSizeCompact to container of table.

```<code>  <f:Form id="idSearchResultsFrm" maxContainerCols="4" editable="true"
            class="sapUiSizeCompact">

            <f:layout>
                <f:ResponsiveGridLayout />
            </f:layout>
            <f:formContainers>
                <f:FormContainer>
                    <f:formElements>
                        <f:FormElement>

                            <t:Table id="idSearchResultTable" visibleRowCount="5"
                                rows="{SearchResult>/}" selectionMode="MultiToggle">
                                <t:columns>

                                ...
                                ...
                                ...
                                </t:columns>
                            </t:table>
</code>```

Body:
I have seen this example of Table https://openui5.hana.ondemand.com/explored.html#/sample/sap.ui.table.sample.Basic/preview

In the example on the left of each row I have a checkbox to select the row.
In the my implementation don't see the ceckboxes:

This is the code (a table in a wizardstep into a wizard inside a dialog):

<WizardStep id='stepImballo' title="Formato imballo" icon="sap-icon://customer-view"
                        complete="wizardStepCompletedHandler">

                <t:Table
                        rows="{model>/formatoImballoColore/}"
                        selectionMode="MultiToggle"
                        visibleRowCount="6">
                    <t:columns>
                        <t:Column>
                            <m:Label text="Formato"/>
                            <t:template>
                                <m:Text text="{model>formato/description}"/>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Peso (kg)"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Articolo latta"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Tara"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Imballo"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                        <t:Column>
                            <m:Label text="Quantità per UDC"/>
                            <t:template>
                                <Input value="pluto"></Input>
                            </t:template>
                        </t:Column>
                    </t:columns>
                </t:Table>

            </WizardStep>

On the top of my fragment I have the xml uses:

xmlns="sap.m"
xmlns:t="sap.ui.table"
xmlns:core="sap.ui.core"
xmlns:f="sap.ui.layout.form"
xmlns:l="sap.ui.layout"
xmlns:m="sap.m"

The problem seems to be the incorrect use of one of the component(use sap.ui in place of sap.m)

Body:
I faced the same hair splitting issue. Found that the checkboxes were not being rendered on older version of SAPUI5 library ( we were using version 1.28.39).

Found solution by adding class sapUiSizeCompact to container of table.

  <f:Form id="idSearchResultsFrm" maxContainerCols="4" editable="true"
            class="sapUiSizeCompact">

            <f:layout>
                <f:ResponsiveGridLayout />
            </f:layout>
            <f:formContainers>
                <f:FormContainer>
                    <f:formElements>
                        <f:FormElement>

                            <t:Table id="idSearchResultTable" visibleRowCount="5"
                                rows="{SearchResult>/}" selectionMode="MultiToggle">
                                <t:columns>

                                ...
                                ...
                                ...
                                </t:columns>
                            </t:table>


来源: stackexchange

问:
Identifier is undefined on initialization
I am new to C++ Programming. I am using a cpp file to hold various variables and I am a bit concerned I am doing something wrong here. I have a .cpp file that only holds some variables.

```<code>    #include "Variables.h"

    using namespace::std;

    char ListItem[260] = "<Choose Location>";
    string sqlDirectiveMessage = "";
    int locationIndex = -1;
    int selectionIndex = 0;
    int dataGatheredFromIndex = 0;
    SQLCHAR retconstring[1024];
</code>```

and Variables.h

```<code>#pragma once
#include <Windows.h>
#include <sqlext.h>
#include <sql.h>
#include <vector>
#include <sqltypes.h>
#include <string>

using namespace::std;

extern char ListItem[];
extern string sqlDirectiveMessage;
extern int locationIndex;
extern int selectionIndex;
extern int dataGatheredFromIndex;

extern SQLCHAR retconstring[1024];
</code>```

Piece of relevant code:

```<code>    case IDC_ADD:
    {
        int test = 0;
        HWND listbox = GetDlgItem(hwnd, IDC_LIST3);
        selectionIndex = (int)SendMessage(listbox, LB_GETCURSEL, 0, 0);
        dataGatheredFromIndex = (int)SendMessage(listbox, LB_GETITEMDATA, selectionIndex, 0);

    }
    break;
</code>```

now in this case, if I do a Watch in VS 2017 on a few variables, selectionIndex and locationIndex seems to work fine, test is undefined and so is dataGatheredFromIndex.. Am I doing something wrong?

答:
The compiler can optimize code so that operations are omitted or ordered differently. The optimization is typically enabled in a Release build configuration.

The variable test in your code is a victim of such optimization because no code can read it back. You should ignore variable values if your code doesn't access it if optimization is turned on.

ContentLicense: CC BY-SA 3.0

Body:
I am new to C++ Programming. I am using a cpp file to hold various variables and I am a bit concerned I am doing something wrong here. I have a .cpp file that only holds some variables.

    #include "Variables.h"

    using namespace::std;

    char ListItem[260] = "<Choose Location>";
    string sqlDirectiveMessage = "";
    int locationIndex = -1;
    int selectionIndex = 0;
    int dataGatheredFromIndex = 0;
    SQLCHAR retconstring[1024];

and Variables.h

#pragma once
#include <Windows.h>
#include <sqlext.h>
#include <sql.h>
#include <vector>
#include <sqltypes.h>
#include <string>

using namespace::std;

extern char ListItem[];
extern string sqlDirectiveMessage;
extern int locationIndex;
extern int selectionIndex;
extern int dataGatheredFromIndex;

extern SQLCHAR retconstring[1024];

Piece of relevant code:

    case IDC_ADD:
    {
        int test = 0;
        HWND listbox = GetDlgItem(hwnd, IDC_LIST3);
        selectionIndex = (int)SendMessage(listbox, LB_GETCURSEL, 0, 0);
        dataGatheredFromIndex = (int)SendMessage(listbox, LB_GETITEMDATA, selectionIndex, 0);

    }
    break;

now in this case, if I do a Watch in VS 2017 on a few variables, selectionIndex and locationIndex seems to work fine, test is undefined and so is dataGatheredFromIndex.. Am I doing something wrong?


问:
javascript Type error innerHTML
Im writing a code and im getting a "Uncaught TypeError: Cannot set property 'innerHTML' of null" error

html

```<code><html>
<head>
<script src ="timer.js"></script>
</head>
<body>
<div id="r"></div>
</body>
</html>
</code>```

Java Script

```<code>//window.onload=function(){
var start=Date.now(),r=document.getElementById('r');
(function f(){
var diff=Date.now()-start,ns=(((3e5-diff)/1000)>>0),m=(ns/60)>>0,s=ns-m*60;
r.textContent="Registration closes in "+m+':'+((''+s).length>1?'':'0')+s+'
minutes';
document.getElementById('r').innerHTML = result;
if(diff>(3e5)){start=Date.now()}
setTimeout(f,1000);
})();
//}
</code>```

I just want to display the result on the html page

答:
There is no element with id = 'test'

I think you have to write:

```<code>(function f() {
    var start = Date.now(),
    var r = document.getElementById('r');
    var diff = Date.now() - start,
        ns = (((3e5 - diff) / 1000) >> 0),
        m = (ns / 60) >> 0,
        s = ns - m * 60;
    r.textContent = "Registration closes in " + m + ':' + (('' + s).length > 1 ? '' : '0') + s + ' minutes';
    //here the change
    document.getElementById('r').innerHTML = result;
    if (diff > (3e5)) {
        start = Date.now()
    }
    setTimeout(f, 1000);
})();
</code>```

And please use Javascript indentation.

Title: javascript Type error innerHTML

Body:
Im writing a code and im getting a "Uncaught TypeError: Cannot set property 'innerHTML' of null" error

html

Java Script

//window.onload=function(){
var start=Date.now(),r=document.getElementById('r');
(function f(){
var diff=Date.now()-start,ns=(((3e5-diff)/1000)>>0),m=(ns/60)>>0,s=ns-m*60;
r.textContent="Registration closes in "+m+':'+((''+s).length>1?'':'0')+s+'
minutes';
document.getElementById('r').innerHTML = result;
if(diff>(3e5)){start=Date.now()}
setTimeout(f,1000);
})();
//}

I just want to display the result on the html page

Body:
There is no element with id = 'test'

I think you have to write:

(function f() {
    var start = Date.now(),
    var r = document.getElementById('r');
    var diff = Date.now() - start,
        ns = (((3e5 - diff) / 1000) >> 0),
        m = (ns / 60) >> 0,
        s = ns - m * 60;
    r.textContent = "Registration closes in " + m + ':' + (('' + s).length > 1 ? '' : '0') + s + ' minutes';
    //here the change
    document.getElementById('r').innerHTML = result;
    if (diff > (3e5)) {
        start = Date.now()
    }
    setTimeout(f, 1000);
})();

And please use Javascript indentation.


问:
SQL Update and Join updating wrong records
I am trying to use an UPDATE statement with a JOIN on SQL Server.

if I run the below SELECT statement it returns 42 rows.

```<code>SELECT * FROM [dbo].[Imported] i
inner join [DaisyCompare].[dbo].[Baseline] b
on
b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]

WHERE b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]
</code>```

However when I use it as a condition within my update statement (below), the query updates 44 records.

```<code>update [DaisyCompare].[dbo].[Baseline]

set Disposition = ('Match')

where exists (
SELECT * FROM [dbo].[Imported] i
inner join [DaisyCompare].[dbo].[Baseline] b

on
b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]

WHERE b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description] )
</code>```

Presumably my syntax is wrong, but I am not sure where.

Any help greatly appreciated.

答:
you can use an alias to choose which of the join tables to update</p>

```<code>UPDATE b
SET Disposition = 'Match'
FROM [dbo].[Imported] i
inner join [DaisyCompare].[dbo].[Baseline] b
on
b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]
</code>```

Body:
I am trying to use an UPDATE statement with a JOIN on SQL Server.

if I run the below SELECT statement it returns 42 rows.

SELECT * FROM [dbo].[Imported] i
inner join [DaisyCompare].[dbo].[Baseline] b
on
b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]

WHERE b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]

However when I use it as a condition within my update statement (below), the query updates 44 records.

update [DaisyCompare].[dbo].[Baseline]

set Disposition = ('Match')

where exists (
SELECT * FROM [dbo].[Imported] i
inner join [DaisyCompare].[dbo].[Baseline] b

on
b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]

WHERE b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description] )

Presumably my syntax is wrong, but I am not sure where.

Any help greatly appreciated.

Body:
you can use an alias to choose which of the join tables to update

UPDATE b
SET Disposition = 'Match'
FROM [dbo].[Imported] i
inner join [DaisyCompare].[dbo].[Baseline] b
on
b.[CLI]=i.[CLI] AND
b.[Quantity]=i.[Quantity] AND
b.[UnitCost]=i.[UnitCost] AND
b.[TotalCost]=i.[TotalCost] AND
b.[Description]=i.[Description]


问:
Error when trying to make SQL Server database connection in Java code
I'm fairly new to coding for database connections and running queries and all that. I've looked over some tutorials and examples and I feel like I've got 95% of this done correctly but there's gotta be something small I'm missing.

I'm currently trying to make a connection to a SQL Server database and I keep getting the exception:

This driver is not configured for integrated authentication.

Here is what my code looks like:

```<code>try {
        String url = "jdbc:sqlserver://serverName;DatabaseName=database;integratedSecurity=true";
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        Connection conn = DriverManager.getConnection(url, "username", "password");
        Statement stmt = conn.createStatement();
        ResultSet rs;

        rs = stmt.executeQuery("select * from database.dbo.table\n" +
                "  where column = 2785 \n" +
                "  AND anotherColumn = 3");
        while ( rs.next() ) {
            String condition = rs.getString("Condition");
            System.out.println(condition);
        }
        conn.close();
    } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
    }
</code>```

I think I'm running into an issue because our databases use Windows Auth. Here's what that looks like when I log into Microsoft SQL Server Management Studio:

What am I missing here?

答:
You can follow the MSDN Documentation to resolve your problems with Integrated Authentication via JDBC.

Two things to keep in mind when you try this out:

To use integrated authentication, copy the sqljdbc_auth.dll file to a directory on the Windows system path on the computer where the JDBC driver is installed.

If you are running a 32-bit Java Virtual Machine (JVM), use the sqljdbc_auth.dll file in the x86 folder, even if the operating system is the x64 version. If you are running a 64-bit JVM on a x64 processor, use the sqljdbc_auth.dll file in the x64 folder.

Hope this helps you resolve your issue.

Body:
I'm fairly new to coding for database connections and running queries and all that. I've looked over some tutorials and examples and I feel like I've got 95% of this done correctly but there's gotta be something small I'm missing.

I'm currently trying to make a connection to a SQL Server database and I keep getting the exception:

This driver is not configured for integrated authentication.

Here is what my code looks like:

try {
        String url = "jdbc:sqlserver://serverName;DatabaseName=database;integratedSecurity=true";
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        Connection conn = DriverManager.getConnection(url, "username", "password");
        Statement stmt = conn.createStatement();
        ResultSet rs;

        rs = stmt.executeQuery("select * from database.dbo.table\n" +
                "  where column = 2785 \n" +
                "  AND anotherColumn = 3");
        while ( rs.next() ) {
            String condition = rs.getString("Condition");
            System.out.println(condition);
        }
        conn.close();
    } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
    }

I think I'm running into an issue because our databases use Windows Auth. Here's what that looks like when I log into Microsoft SQL Server Management Studio:

What am I missing here?


问:
Object variable or With block variable not set Access vba
I'm working with a couple tables, CTOL and CTOL_Asbuilt in Access. I'm trying to run a query to join these two tables together using VBA code. I ran the query in Access and it works. I'm using DAO for the database library to retrieve data from the local Access database (code is in the same database project as the database), and I'm new to VBA Access scripting.

SELECT CTOL.ID, CTOL.BOM_PART_NAME, CTOL.CII, CTOL.[PART FIND NO], CTOL.CSN,
       CTOL.AFS, CTOL.EQP_POS_CD, CTOL.LCN, CTOL.POS_CT, CTOL.SERIAL_NO,
       CTOL.PART_NO_LLP, [CTOL_Asbuilt].[PART-SN], [CTOL_Asbuilt].[PART-ATA-NO],
       [CTOL_PW-E750207_Asbuilt].[PW-PART-NO]
FROM CTOL LEFT JOIN [CTOL_Asbuilt] ON CTOL.[PART FIND NO] = [CTOL_Asbuilt].[PART-ATA-NO];
```

<p>This is the code below:</p>

```Option Compare Database
Option Explicit

'Const adOpenStatic = 3
'Const adLockOptimistic = 3

Function queryDatabase()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsQuery As DAO.Recordset

Dim part_find_no() As String
Dim eqp_pos() As Integer
'Dim strSQL As String
Dim i As Integer
Dim j As Integer
'Set objConnection = CurrentDb.OpenRecordset("CTOL")

Set db = CurrentDb

Set rsQuery = db.OpenRecordset("SicrProcess", dbOpenDynaset)

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

End Function
```

I'm getting the following error when I run this code with a macro that calls the function:

Run time error '91':

Object variable or With block variable not set

I'm trying to use the code with the query to loop through two fields and increment the value of the EQP_POS_CD field when the PART FIND NO entry matches the last (else, it just moves to the next record until it reaches the end of the result set). I want to test-run this query to make sure that the code retrieves the result that is output by running the query manually in Access.

Can you help me in fixing this error so I can run my code to retrieve the data? Thanks!

答:
```<code>rs.Close
</code>```

You cannot close something that is not open. Perhaps you meant it to be rsQuery.Close?

Body:
I'm working with a couple tables, CTOL and CTOL_Asbuilt in Access. I'm trying to run a query to join these two tables together using VBA code. I ran the query in Access and it works. I'm using DAO for the database library to retrieve data from the local Access database (code is in the same database project as the database), and I'm new to VBA Access scripting.

SELECT CTOL.ID, CTOL.BOM_PART_NAME, CTOL.CII, CTOL.[PART FIND NO], CTOL.CSN,
       CTOL.AFS, CTOL.EQP_POS_CD, CTOL.LCN, CTOL.POS_CT, CTOL.SERIAL_NO,
       CTOL.PART_NO_LLP, [CTOL_Asbuilt].[PART-SN], [CTOL_Asbuilt].[PART-ATA-NO],
       [CTOL_PW-E750207_Asbuilt].[PW-PART-NO]
FROM CTOL LEFT JOIN [CTOL_Asbuilt] ON CTOL.[PART FIND NO] = [CTOL_Asbuilt].[PART-ATA-NO];

This is the code below:

Option Compare Database
Option Explicit

'Const adOpenStatic = 3
'Const adLockOptimistic = 3

Function queryDatabase()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsQuery As DAO.Recordset

Dim part_find_no() As String
Dim eqp_pos() As Integer
'Dim strSQL As String
Dim i As Integer
Dim j As Integer
'Set objConnection = CurrentDb.OpenRecordset("CTOL")

Set db = CurrentDb

Set rsQuery = db.OpenRecordset("SicrProcess", dbOpenDynaset)

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

End Function

I'm getting the following error when I run this code with a macro that calls the function:

Run time error '91':

Object variable or With block variable not set

I'm trying to use the code with the query to loop through two fields and increment the value of the EQP_POS_CD field when the PART FIND NO entry matches the last (else, it just moves to the next record until it reaches the end of the result set). I want to test-run this query to make sure that the code retrieves the result that is output by running the query manually in Access.

Can you help me in fixing this error so I can run my code to retrieve the data? Thanks!

Body:
rs.Close

You cannot close something that is not open. Perhaps you meant it to be rsQuery.Close?


问:
Show element where another was without display: none
I need an element to appear where another was, let's say on hover for the sake of an example. And I need to use CSS animations to make its transition smoother. So I can't use display property. And instead, I have to use this, right?

```<code>div {
  visibility: hidden;
  opacity: 0;
}
</code>```

But my elements need to overlap, as in where one was, the other has to show instead. With display, that was pretty easy, but with this, I have no clue how to do this without making it too messy.

Can someone help me out? Here's the basic outline of my code:

.first-outline .first:hover {
  visibility: hidden;
  opacity: 0;
}
.first-outline .second {
  visibility: hidden;
  opacity: 0;
}
.first-outline:hover second {
  visibility: initial;
  opacity: 1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">

<li class="list-group-item first-outline">
  <p class="first">First</p>
  <p class="second">Second</p>
</li>

<!-- Or something like this, but it still doesn't work -->

<li class="list-group-item second-outline">
  <span class="first">First</span>
  <span class="second">Second</span>
</li></code>```

Thank you.

答:
Give the container a positon: relative and the inner divs positin: absolute then play with the hover states and opacity.

add transition property for smooth effect

.first-outline {
  position:relative;
}

.first-outline .first, .first-outline .second {
  position: absolute;
  top: 0 ;
  left: 0;
  width: 100%;
  height: 100%;
  transition: opacity 500ms linear;
  -webkit-transition: opacity 500ms linear;
  -moz-transition: opacity 500ms linear;
}

.first-outline:hover .first, .first-outline .second {
  opacity: 0;
}

.first-outline:hover .second {
  opacity: 1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">

<li class="list-group-item first-outline">
  <p class="first">First</p>
  <p class="second">Second</p>
</li></code>```

Body:
I need an element to appear where another was, let's say on hover for the sake of an example. And I need to use CSS animations to make its transition smoother. So I can't use display property. And instead, I have to use this, right?

div {
  visibility: hidden;
  opacity: 0;
}

But my elements need to overlap, as in where one was, the other has to show instead. With display, that was pretty easy, but with this, I have no clue how to do this without making it too messy.

Can someone help me out? Here's the basic outline of my code:

.first-outline .first:hover {
  visibility: hidden;
  opacity: 0;
}
.first-outline .second {
  visibility: hidden;
  opacity: 0;
}
.first-outline:hover second {
  visibility: initial;
  opacity: 1;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">

First

Second

  First
  Second

Thank you.

Body:
Give the container a positon: relative and the inner divs positin: absolute then play with the hover states and opacity.

add transition property for smooth effect

.first-outline {
  position:relative;
}

.first-outline .first, .first-outline .second {
  position: absolute;
  top: 0 ;
  left: 0;
  width: 100%;
  height: 100%;
  transition: opacity 500ms linear;
  -webkit-transition: opacity 500ms linear;
  -moz-transition: opacity 500ms linear;
}

.first-outline:hover .first, .first-outline .second {
  opacity: 0;
}

.first-outline:hover .second {
  opacity: 1;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">

<li class="list-group-item first-outline">
  <p class="first">First</p>
  <p class="second">Second</p>
</li>


问:
Adding an inherited entity to the DBContext
I've this entity

```<code>public class FooEntity
{
   public int ID {get; set;}
   public string Name {get; set;}
}
</code>```

I need to extend FooEntity with new fields like this

```<code>public class FooExtended : FooEntity
{
  public int Age {get; set;}
}
</code>```

but I don't want to persist the Age value in the database, it's used only temporarily in the model of the view.

When I try to add an instance of FooExtended to the DBContext

```<code>context.FooEntity.Add(xxx);
</code>```

I get the following exception

"Mapping and metadata information could not be found for EntityType
  'FooExtended'."

I tried adding the attribute [NotMapped] to the field Age but I get the same exception.

Is it possible to achieve what I'm trying to do with Entity Framework 6.1.3?

答:
Use [NotMapped] attribute to exclude a property from the context. You don't need to use inheritance in this case. You can read more about it HERE

```<code>public class FooEntity
{
   public int ID {get; set;}
   public string Name {get; set;}
   [NotMapped]
   public int Age { set; get; }
}
</code>```

If you are really persistent on this inheritance thing you may do this:

```<code>context.FooEntity.Add(
    new FooEntity {
      ID = xxx.ID,
      Name = xxx.Name
    }
);
</code>```

Body:
I've this entity

public class FooEntity
{
   public int ID {get; set;}
   public string Name {get; set;}
}

I need to extend FooEntity with new fields like this

public class FooExtended : FooEntity
{
  public int Age {get; set;}
}

but I don't want to persist the Age value in the database, it's used only temporarily in the model of the view.

When I try to add an instance of FooExtended to the DBContext

context.FooEntity.Add(xxx);

I get the following exception

"Mapping and metadata information could not be found for EntityType
  'FooExtended'."

I tried adding the attribute [NotMapped] to the field Age but I get the same exception.

Is it possible to achieve what I'm trying to do with Entity Framework 6.1.3?

Body:
Use [NotMapped] attribute to exclude a property from the context. You don't need to use inheritance in this case. You can read more about it HERE

public class FooEntity
{
   public int ID {get; set;}
   public string Name {get; set;}
   [NotMapped]
   public int Age { set; get; }
}

If you are really persistent on this inheritance thing you may do this:

context.FooEntity.Add(
    new FooEntity {
      ID = xxx.ID,
      Name = xxx.Name
    }
);


问:
How to show confirm message on condition on asp button click
I have a checkbox cbDue that is by default checked but can be unchecked on certain conditions. When I click the Submit button it should check if the cbDue is checked or not. If cbdue is checked, then it should show confirm message "This is for current month?". if user clicks Yes then the code in the Onclick event of the submit button will run. If user clicks No to the message then the code will not run.

So I need to show the confirm message box On Condition, not always.

Edit: My Checkbox

Submit button:

JavaScript:
function Confirm() {

```<code>        var confirm_value = document.createElement("INPUT");
        confirm_value.type = "hidden";
        confirm_value.name = "confirm_value";
        if (confirm("Submit for current month?")) {
            confirm_value.value = "Yes";
        } else {
            confirm_value.value = "No";
        }
        document.forms[0].appendChild(confirm_value);
    }
</code>```

Code behind for btnSubmit (partly)
If cbDue.Checked = True Then

            If confirmValue = "No" Then

                Exit Sub
            End If
This works some what but shows the message every time I click the submit button.

答:
The code that is working for me -
function confirmation() {
         var DueChecked = document.getElementById('MainContent_cbDue').checked;</p>

```<code>     if (DueChecked == true) {
         if ( confirm('Submit for current month?') == true) {

             return true;
         }else{
             return false;
         }

     } else {

         return true;
     }
 }

 <asp:Button ID="btnSubmit" runat="server" Text="Submit For Review" CssClass="submitBtn" ValidationGroup="ReviewDue" OnClientClick="return confirmation();" onclick="btnSubmit_Click" />
</code>```

Body:
I have a checkbox cbDue that is by default checked but can be unchecked on certain conditions. When I click the Submit button it should check if the cbDue is checked or not. If cbdue is checked, then it should show confirm message "This is for current month?". if user clicks Yes then the code in the Onclick event of the submit button will run. If user clicks No to the message then the code will not run.

So I need to show the confirm message box On Condition, not always.

Edit: My Checkbox

Submit button:

JavaScript:
function Confirm() {

        var confirm_value = document.createElement("INPUT");
        confirm_value.type = "hidden";
        confirm_value.name = "confirm_value";
        if (confirm("Submit for current month?")) {
            confirm_value.value = "Yes";
        } else {
            confirm_value.value = "No";
        }
        document.forms[0].appendChild(confirm_value);
    }

Code behind for btnSubmit (partly)
If cbDue.Checked = True Then

            If confirmValue = "No" Then

                Exit Sub
            End If
This works some what but shows the message every time I click the submit button.

Body:
The code that is working for me -
function confirmation() {
         var DueChecked = document.getElementById('MainContent_cbDue').checked;

     if (DueChecked == true) {
         if ( confirm('Submit for current month?') == true) {

             return true;
         }else{
             return false;
         }

     } else {

         return true;
     }
 }

 <asp:Button ID="btnSubmit" runat="server" Text="Submit For Review" CssClass="submitBtn" ValidationGroup="ReviewDue" OnClientClick="return confirmation();" onclick="btnSubmit_Click" />


问:
DllImport C Sharp const char*
Hy all,

I want to make from a unmanaged dll to a managed dll in C#.

in the documentation it is:

```<code>typedef void*    AP_HANDLE
typedef uint32_t ap_u32

AP_HANDLE ap_CreateVirtual(const char *szFilename)

void ap_SetState(AP_HANDLE apbase, const char *szState, int nValue)

unsigned char *ap_ColorPipe(AP_HANDLE      apbase,
                            unsigned char *pInBuffer,
                            ap_u32         nInBufferSize,
                            ap_u32        *rgbWidth,
                            ap_u32        *rgbHeight,
                            ap_u32        *rgbBitDepth)
</code>```

In C++ works fine, but in C# the syntax is the problem
It seems I can't make not evan the first function work

```<code>public unsafe class appbase
{
    [DllImport("D:\\apbase.dll", EntryPoint = "ap_CreateVirtual")]
    //, CharSet = UnicodeEncoding
    //, CallingConvention = CallingConvention.StdCall

    public static extern void* ap_CreateVirtual(char* szFilename);
}
</code>```

and

```<code>    public static void Main()
    {
        unsafe
        {
            void* ap_handle = null;

            appbase APPbase = new appbase();

            string s = "D:\\ASX.xsdat";

            fixed (char* p = s)
            {
                ap_handle = APPbase.ap_CreateVirtual(p);
            }

            return;
        }
    }
</code>```

tried with argument for ap_CreateVirtual string, String*, char*, char[] and put a break point on return; the ap_handle was always with value 0x0000

what is the proper way to import these functions ?

答:
Just copying over the C++ headers isn't enough. You need to understand what the arguments actually mean and how they are represented. The first function is simple enough:

```<code>[DllImport("...", EntryPoint="ap_CreateVirtual")]
public static extern IntPtr ap_CreateVirtual(
  [In, MarshalAs(UnmanagedType.LPStr)] string szFilename);
</code>```

I assume that in the second, szState is again a simple LPStr, while the pInBuffer is most likely a fixed-length byte[] with size determined by nInBufferSize. rgbXXX seem to be ref arguments. The return type may again be a LPStr.

Title: DllImport C Sharp const char*

Body:
Hy all,

I want to make from a unmanaged dll to a managed dll in C#.

in the documentation it is:

typedef void*    AP_HANDLE
typedef uint32_t ap_u32

AP_HANDLE ap_CreateVirtual(const char *szFilename)

void ap_SetState(AP_HANDLE apbase, const char *szState, int nValue)

unsigned char *ap_ColorPipe(AP_HANDLE      apbase,
                            unsigned char *pInBuffer,
                            ap_u32         nInBufferSize,
                            ap_u32        *rgbWidth,
                            ap_u32        *rgbHeight,
                            ap_u32        *rgbBitDepth)

In C++ works fine, but in C# the syntax is the problem
It seems I can't make not evan the first function work

public unsafe class appbase
{
    [DllImport("D:\\apbase.dll", EntryPoint = "ap_CreateVirtual")]
    //, CharSet = UnicodeEncoding
    //, CallingConvention = CallingConvention.StdCall

    public static extern void* ap_CreateVirtual(char* szFilename);
}

and

    public static void Main()
    {
        unsafe
        {
            void* ap_handle = null;

            appbase APPbase = new appbase();

            string s = "D:\\ASX.xsdat";

            fixed (char* p = s)
            {
                ap_handle = APPbase.ap_CreateVirtual(p);
            }

            return;
        }
    }

tried with argument for ap_CreateVirtual string, String*, char*, char[] and put a break point on return; the ap_handle was always with value 0x0000

what is the proper way to import these functions ?

Body:
Just copying over the C++ headers isn't enough. You need to understand what the arguments actually mean and how they are represented. The first function is simple enough:

[DllImport("...", EntryPoint="ap_CreateVirtual")]
public static extern IntPtr ap_CreateVirtual(
  [In, MarshalAs(UnmanagedType.LPStr)] string szFilename);

I assume that in the second, szState is again a simple LPStr, while the pInBuffer is most likely a fixed-length byte[] with size determined by nInBufferSize. rgbXXX seem to be ref arguments. The return type may again be a LPStr.


问:
Running node.js code just displays a node identifier
I have the following code in a file called server.js.

```<code>var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');
</code>```

I use the command prompt and naviage to the folder where the file recides and then the run the command

```<code>node server.js
</code>```

But I don't get the expected output. Instead I get

```<code>The node identifier for {My Machine Name} is v2hrfnqaj.
</code>```

Note: I already have node installed in my machine and it was working fine.

答:
Don't break your Harvest SCM by removing it from path. Try this one, open your windows command line (cmd) and then pass the following nodejs batch file so that it will set your command line to nodejs environment. Enjoy the node commands there.

C:> "C:\Program Files\nodejs\nodevars.bat"

Body:
I have the following code in a file called server.js.

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

I use the command prompt and naviage to the folder where the file recides and then the run the command

node server.js

But I don't get the expected output. Instead I get

The node identifier for {My Machine Name} is v2hrfnqaj.

Note: I already have node installed in my machine and it was working fine.


问:
I want to send a form to another website using php
I've been trying to send a form my website to another website using this code

$jumlah = $query1->jumlah;
$postdata = http_build_query(
    array(
        'url' => $url,
        'jumlah' => $jumlah
    )
);
$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);
$result = file_get_contents('http://insta.kingdompanel.xyz/addlikes.php', false, $context);
```

<p>Before I send it to that website, I'm trying to send the form to my own website, and it works. I change this code to try send a form there.</p>

<pre class="lang-php prettyprint-override"><code>file_get_contents('http://insta.kingdompanel.xyz/addlikes.php', false, $context);
</code>```

After I change that, it doesn't send anything.

update :
here is it the network tab

my goal is to post this data

to this form which is different website, without opening this page

答: In the request header you can add 'header' => 'Access-Control-Allow-Origin: *' and try. It should work. Even after that request fails means, other server may be blocking it</p>

Body:
I've been trying to send a form my website to another website using this code

$jumlah = $query1->jumlah;
$postdata = http_build_query(
    array(
        'url' => $url,
        'jumlah' => $jumlah
    )
);
$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);
$result = file_get_contents('http://insta.kingdompanel.xyz/addlikes.php', false, $context);

Before I send it to that website, I'm trying to send the form to my own website, and it works. I change this code to try send a form there.

file_get_contents('http://insta.kingdompanel.xyz/addlikes.php', false, $context);

After I change that, it doesn't send anything.

update :
here is it the network tab

my goal is to post this data

to this form which is different website, without opening this page


问:
WCF Service has a paramterized constructor, which accepts a struct
Please see the code below:

```<code>public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                Component.For<ICalculator, Calculator>());
        }
</code>```

Calculator is a struct.  The error I get when opening the .svc is: "Calculator is not a class nor an interface, and those are the only values allowed.".  Is it possible to inject structs using Castle Windsor?

I have spent some time Googling this, however I have not found an answer.

答:
Let's look in source code of Windsor.

So, no, you can't. By design of Windsor container.

Body:
Please see the code below:

public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                Component.For<ICalculator, Calculator>());
        }

Calculator is a struct.  The error I get when opening the .svc is: "Calculator is not a class nor an interface, and those are the only values allowed.".  Is it possible to inject structs using Castle Windsor?

I have spent some time Googling this, however I have not found an answer.


问:
Adding buttons to MahApps.Metro Group box header
I'd like to be able to add icon buttons to the Mahapps.Metro Groupbox header. Is this possible? If anyone has done this, some sample code or pointing me to the necessary documentation would be most appreciated.  </p>

答:
You should be able to add any element that you want to the Header property of the GroupBox:

```<code><GroupBox>
    <GroupBox.Header>
        <StackPanel>
            <Image Source="pic.png" Stretch="None"/>
            <TextBlock Text="header..." />
        </StackPanel>
    </GroupBox.Header>
</GroupBox>
</code>```

Body:
You should be able to add any element that you want to the Header property of the GroupBox:

<GroupBox>
    <GroupBox.Header>
        <StackPanel>
            <Image Source="pic.png" Stretch="None"/>
            <TextBlock Text="header..." />
        </StackPanel>
    </GroupBox.Header>
</GroupBox>


问:
Does a foreign key reduce redundancy if all the columns are referenced?
I've read that one of the benefits of normalization is to reduce redundancy in the DB. But I'm wondering, if you end up referencing all the columns in the target table?

For example, if I have a Video table that references a Genre table, the Genre table might very likely have a single column with a dozen fairly static values like 'Horror' 'Sci-Fi' 'Romance' etc.

In a case like this, does it save any space to separate the two, or is the only benefit making it so you can update all referencing rows from one place?

答: You will save also because 'Horror' takes 12 bytes in Unicode, while GenreId can be a Byte or char(1).</p>

ContentLicense: CC BY-SA 2.5


问:
T-SQL DENSE_RANK() is not returning what I expect
I am having trouble getting the DENSE_RANK() (or similar) to get the values I want from a select query.  I have tried RANK() and ROW_NUMBER() and I have changed the PARTITION and ORDER-BY fields but no luck.
The query follows...

```<code>SELECT         100 * DENSE_RANK() OVER (PARTITION BY UID_CUSTOMER, INT_GROUP_BY ORDER BY UID_CUSTOMER) AS  aINT_GROUP_BY,
                 5 * ROW_NUMBER() OVER (PARTITION BY UID_DIVISION, UID_CUSTOMER,INT_GROUP_BY ORDER BY UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER) AS  aINT_SORT_ORDER,
               UID_DIVISION, UID_CUSTOMER, UID_VEHICLE, INT_GROUP_BY, TXT_GROUP_NAME
FROM           tVEHICLES TV
ORDER BY       UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER;
</code>```

I show the result with an offset of the UID_CUSTOMER-number so you can see three different customers are listed (Column captions are changed to narrow the list display).

```<code>aGROUP_BY  aSORT_ORDER  UID_DIVISION  UID_CUSTOMER  GROUP_BY  TXT_GROUP_NAME
100        5            5             82            100       Group-100
100        10           5             82            100       Group-100
100        15           5             82            100       Group-100
100        20           5             82            100       Group-100
100        25           5             82            100       Group-100
100        5            5             86            100       Group-100
100        10           5             86            100       Group-100
100        15           5             86            100       Group-100
100        20           5             86            100       Group-100
100        25           5             86            100       Group-100
100        30           5             86            100       Group-100
100        5            5             88            100       North
100        10           5             88            100       North
100        15           5             88            100       North
100        5            5             88            200       South
100        10           5             88            200       South
100        15           5             88            200       South
</code>```

The two columns shown are derived from the OVER-constructs and I expected the aGROUP_BY value to be 200 not 100.  The source of the field-data are in the remaining columns 3 to 6.

Your comments and advice is very welcome...John

答:
Try something like this</p>

```<code>SELECT   ROW_NUMBER() OVER (ORDER BY UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER)  AS  aRowNumber,
         100 * DENSE_RANK() OVER (PARTITION BY INT_GROUP_BY
                                  ORDER BY UID_CUSTOMER
                                 ) AS  aINT_GROUP_BY,
         5 * ROW_NUMBER() OVER (PARTITION BY UID_DIVISION, INT_GROUP_BY
                                ORDER BY UID_CUSTOMER, INT_SORT_ORDER
                               ) AS  aINT_SORT_ORDER,
         UID_DIVISION, UID_CUSTOMER, UID_VEHICLE, INT_GROUP_BY, INT_SORT_ORDER, TXT_GROUP_NAME
FROM      tVEHICLES TV
ORDER BY  UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER;
</code>```

Body:
I am having trouble getting the DENSE_RANK() (or similar) to get the values I want from a select query.  I have tried RANK() and ROW_NUMBER() and I have changed the PARTITION and ORDER-BY fields but no luck.
The query follows...

SELECT         100 * DENSE_RANK() OVER (PARTITION BY UID_CUSTOMER, INT_GROUP_BY ORDER BY UID_CUSTOMER) AS  aINT_GROUP_BY,
                 5 * ROW_NUMBER() OVER (PARTITION BY UID_DIVISION, UID_CUSTOMER,INT_GROUP_BY ORDER BY UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER) AS  aINT_SORT_ORDER,
               UID_DIVISION, UID_CUSTOMER, UID_VEHICLE, INT_GROUP_BY, TXT_GROUP_NAME
FROM           tVEHICLES TV
ORDER BY       UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER;

I show the result with an offset of the UID_CUSTOMER-number so you can see three different customers are listed (Column captions are changed to narrow the list display).

aGROUP_BY  aSORT_ORDER  UID_DIVISION  UID_CUSTOMER  GROUP_BY  TXT_GROUP_NAME
100        5            5             82            100       Group-100
100        10           5             82            100       Group-100
100        15           5             82            100       Group-100
100        20           5             82            100       Group-100
100        25           5             82            100       Group-100
100        5            5             86            100       Group-100
100        10           5             86            100       Group-100
100        15           5             86            100       Group-100
100        20           5             86            100       Group-100
100        25           5             86            100       Group-100
100        30           5             86            100       Group-100
100        5            5             88            100       North
100        10           5             88            100       North
100        15           5             88            100       North
100        5            5             88            200       South
100        10           5             88            200       South
100        15           5             88            200       South

The two columns shown are derived from the OVER-constructs and I expected the aGROUP_BY value to be 200 not 100.  The source of the field-data are in the remaining columns 3 to 6.

Your comments and advice is very welcome...John

Body:
Try something like this

SELECT   ROW_NUMBER() OVER (ORDER BY UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER)  AS  aRowNumber,
         100 * DENSE_RANK() OVER (PARTITION BY INT_GROUP_BY
                                  ORDER BY UID_CUSTOMER
                                 ) AS  aINT_GROUP_BY,
         5 * ROW_NUMBER() OVER (PARTITION BY UID_DIVISION, INT_GROUP_BY
                                ORDER BY UID_CUSTOMER, INT_SORT_ORDER
                               ) AS  aINT_SORT_ORDER,
         UID_DIVISION, UID_CUSTOMER, UID_VEHICLE, INT_GROUP_BY, INT_SORT_ORDER, TXT_GROUP_NAME
FROM      tVEHICLES TV
ORDER BY  UID_DIVISION, UID_CUSTOMER, INT_GROUP_BY, INT_SORT_ORDER;


问:
How to resolve the Unterminated array Exception in android
```<code>    W/System.err: org.json.JSONException: Unterminated array at character 12 of [ClassPojo [feed [{"id":0,"businessId":0,"businessName":"Farbinder","businessLogoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/gallery\/0\/fb_icon.png","text":"Some news for yous!","photoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/videos\/0\/8b84c9c1-50ed-4e93-9785797bbf2be667.png","videoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/videos\/0\/_464b2fb6-ede6-403f-b6ae-1666c9504337.mov","isNew":true,"type":"news"},
{"id":198,"specialType":"limited","name":"Big Data Shoes!","description":"Get them now while you can. They're dangerous!","start":"2017-06-04 14:59:01Z","end":"2018-01-26 19:00:00Z","limitedAmount":30,"photoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/specials\/77\/de050600-4aef-4f31-87c3-152ad4871fd4.jpeg","previewPhotoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/specials\/77\/8878e285-8ac7-478d-aee5-73ad5fa2b861.jpeg.jpg","active":true,"expired":false,"totalClaimed":0,"totalShared":0,"businessName":"Big Data Shoes","businessId":77,"businessLogoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/gallery\/0\/ph_logo.png","claimed":false,"redeemed":false,"isNew":false,
"shareInfo":{"title":"Big Data Shoes!","description":"Get them now while you can. They're dangerous!","photoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/specials\/77\/de050600-4aef-4f31-87c3-152ad4871fd4.jpeg","linkUrl":"https:\/\/www.farbinder.com\/profile\/77","type":"share_info"},
"countInfo"{"views":171,"likes":0,"liked":false,"type":"count_info"},"type":"special"},
{"id":"1616636","partnerId":3,"uuid":"57dacc36-abac-4bb3-89a4-f1981130b206","title":"$80 Toward Gourmet Steakhouse Cuisine","category":"Restaurants > American","brand":"Regina's Steakhouse and Grill","imageUrl":"https:\/\/a1.lscdn.net\/imgs\/5605c229-0403-42db-a227-4720be82e29d\/360_q60.jpg","buyUrl":"https:\/\/m.livingsocial.com\/deals\/1616636-80-toward-gourmet-steakhouse-cuisine","price":"80.0 USD","salePrice":"40.0 USD","addr1":"827 Teaneck Road","city":"Teaneck","zip":"07666","type":"partner_offer"},
{"id":"b16cbffd-9162-105b-e342-511ce8e03e44","partnerId":5,"title":"Oil Change","category":"Automotive Oil Change \/ Car & Automotive","brand":"Valvoline Instant Oil Change - Galena Associates","imageUrl":"https:\/\/img.grouponcdn.com\/deal\/hzQxwQdyw5AJmR7PGf7Z\/qB-700x420\/v1\/t440x300.jpg","buyUrl":"http:\/\/tracking.groupon.com\/r?tsToken=US_AFF_0_206503_212556_0&url=https%3A%2F%2Fwww.groupon.com%2Fdeals%2Fvalvoline-instant-oil-change-47-north-jersey%3Fz%3Dskip%26utm_medium%3Dafl%26utm_campaign%3D206503%26mediaId%3D212556%26utm_source%3DGPN","price":"$35.99","salePrice":"$19.99","addr1":"289 Dolson Avenue","city":"Middletown","type":"partner_offer"},
{"id":"1651220","partnerId":3,"uuid":"58da9c36-36cf-4979-aae6-76e02bf21445","title":"IPL Photo Facial ","category":"Health & Beauty > Spas ","brand":"The PRP Institute ","imageUrl":"https:\/\/a0.lscdn.net\/imgs\/58dc2906-bf3d-4d41-be14-c7a41431c19c\/360_q60.jpg","buyUrl":"https:\/\/m.livingsocial.com\/deals\/1651220-ipl-photo-facial","price":"250.0 USD","salePrice":"99.0 USD","addr1":"639 Teaneck Road","city":"Teaneck","zip":"07666","type":"partner_offer"},
{"id":"f267f724-d556-9903-04c4-a6c68eb25d53","partnerId":5,"title":"King Spa Fitness","category":"Bath - Steam \/ Spa Services","brand":"King Spa Fitness","imageUrl":"https:\/\/img.grouponcdn.com\/deal\/bBu8ESxBwUycrCnQDvCk\/22-700x420\/v1\/t440x300.jpg","buyUrl":"http:\/\/tracking.groupon.com\/r?tsToken=US_AFF_0_206503_212556_0&url=https%3A%2F%2Fwww.groupon.com%2Fdeals%2Fking-spa-fitness-7-47%3Fz%3Dskip%26utm_medium%3Dafl%26utm_campaign%3D206503%26mediaId%3D212556%26utm_source%3DGPN","price":"$45.00","salePrice":"$26.50","addr1":"321 Commercial Ave.","city":"Palisades Park","type":"partner_offer"},
{"id":"1632898","partnerId":3,"uuid":"5849a6a8-1bd7-4848-ba0b-e12272f54d01","title":"$40 or $80 to Spend on Italian Cuisine","category":"Restaurants > American","brand":"Vitale's Restaurant","imageUrl":"https:\/\/a0.lscdn.net\/imgs\/584ad77e-3d2e-4b2a-8abe-8494ee6142fb\/360_q60.j
</code>```

I want to parse this json response and design UI layouts.But it was throwing exceptions while parsing the data.Can any one help me how to resolve this issue.I observed that the last element in that response was breaking.I'm thinking that is the reason.

答: According this Json lint tool your json content is incomplete.

Body:
    W/System.err: org.json.JSONException: Unterminated array at character 12 of [ClassPojo [feed [{"id":0,"businessId":0,"businessName":"Farbinder","businessLogoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/gallery\/0\/fb_icon.png","text":"Some news for yous!","photoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/videos\/0\/8b84c9c1-50ed-4e93-9785797bbf2be667.png","videoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/videos\/0\/_464b2fb6-ede6-403f-b6ae-1666c9504337.mov","isNew":true,"type":"news"},
{"id":198,"specialType":"limited","name":"Big Data Shoes!","description":"Get them now while you can. They're dangerous!","start":"2017-06-04 14:59:01Z","end":"2018-01-26 19:00:00Z","limitedAmount":30,"photoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/specials\/77\/de050600-4aef-4f31-87c3-152ad4871fd4.jpeg","previewPhotoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/specials\/77\/8878e285-8ac7-478d-aee5-73ad5fa2b861.jpeg.jpg","active":true,"expired":false,"totalClaimed":0,"totalShared":0,"businessName":"Big Data Shoes","businessId":77,"businessLogoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/gallery\/0\/ph_logo.png","claimed":false,"redeemed":false,"isNew":false,
"shareInfo":{"title":"Big Data Shoes!","description":"Get them now while you can. They're dangerous!","photoUrl":"https:\/\/d1e6yi6s3cx2ur.cloudfront.net\/specials\/77\/de050600-4aef-4f31-87c3-152ad4871fd4.jpeg","linkUrl":"https:\/\/www.farbinder.com\/profile\/77","type":"share_info"},
"countInfo"{"views":171,"likes":0,"liked":false,"type":"count_info"},"type":"special"},
{"id":"1616636","partnerId":3,"uuid":"57dacc36-abac-4bb3-89a4-f1981130b206","title":"$80 Toward Gourmet Steakhouse Cuisine","category":"Restaurants > American","brand":"Regina's Steakhouse and Grill","imageUrl":"https:\/\/a1.lscdn.net\/imgs\/5605c229-0403-42db-a227-4720be82e29d\/360_q60.jpg","buyUrl":"https:\/\/m.livingsocial.com\/deals\/1616636-80-toward-gourmet-steakhouse-cuisine","price":"80.0 USD","salePrice":"40.0 USD","addr1":"827 Teaneck Road","city":"Teaneck","zip":"07666","type":"partner_offer"},
{"id":"b16cbffd-9162-105b-e342-511ce8e03e44","partnerId":5,"title":"Oil Change","category":"Automotive Oil Change \/ Car & Automotive","brand":"Valvoline Instant Oil Change - Galena Associates","imageUrl":"https:\/\/img.grouponcdn.com\/deal\/hzQxwQdyw5AJmR7PGf7Z\/qB-700x420\/v1\/t440x300.jpg","buyUrl":"http:\/\/tracking.groupon.com\/r?tsToken=US_AFF_0_206503_212556_0&url=https%3A%2F%2Fwww.groupon.com%2Fdeals%2Fvalvoline-instant-oil-change-47-north-jersey%3Fz%3Dskip%26utm_medium%3Dafl%26utm_campaign%3D206503%26mediaId%3D212556%26utm_source%3DGPN","price":"$35.99","salePrice":"$19.99","addr1":"289 Dolson Avenue","city":"Middletown","type":"partner_offer"},
{"id":"1651220","partnerId":3,"uuid":"58da9c36-36cf-4979-aae6-76e02bf21445","title":"IPL Photo Facial ","category":"Health & Beauty > Spas ","brand":"The PRP Institute ","imageUrl":"https:\/\/a0.lscdn.net\/imgs\/58dc2906-bf3d-4d41-be14-c7a41431c19c\/360_q60.jpg","buyUrl":"https:\/\/m.livingsocial.com\/deals\/1651220-ipl-photo-facial","price":"250.0 USD","salePrice":"99.0 USD","addr1":"639 Teaneck Road","city":"Teaneck","zip":"07666","type":"partner_offer"},
{"id":"f267f724-d556-9903-04c4-a6c68eb25d53","partnerId":5,"title":"King Spa Fitness","category":"Bath - Steam \/ Spa Services","brand":"King Spa Fitness","imageUrl":"https:\/\/img.grouponcdn.com\/deal\/bBu8ESxBwUycrCnQDvCk\/22-700x420\/v1\/t440x300.jpg","buyUrl":"http:\/\/tracking.groupon.com\/r?tsToken=US_AFF_0_206503_212556_0&url=https%3A%2F%2Fwww.groupon.com%2Fdeals%2Fking-spa-fitness-7-47%3Fz%3Dskip%26utm_medium%3Dafl%26utm_campaign%3D206503%26mediaId%3D212556%26utm_source%3DGPN","price":"$45.00","salePrice":"$26.50","addr1":"321 Commercial Ave.","city":"Palisades Park","type":"partner_offer"},
{"id":"1632898","partnerId":3,"uuid":"5849a6a8-1bd7-4848-ba0b-e12272f54d01","title":"$40 or $80 to Spend on Italian Cuisine","category":"Restaurants > American","brand":"Vitale's Restaurant","imageUrl":"https:\/\/a0.lscdn.net\/imgs\/584ad77e-3d2e-4b2a-8abe-8494ee6142fb\/360_q60.j

I want to parse this json response and design UI layouts.But it was throwing exceptions while parsing the data.Can any one help me how to resolve this issue.I observed that the last element in that response was breaking.I'm thinking that is the reason.


问:
reducing list based on fuzzy values in python
I have a list that contains groups of nearly identical numeric values. i.e. (1004.523, 1004.575, 1004.475, 791.385, 791.298, 791.301, 791.305, 791.299)

What I am trying to do is read through the list and find all the 1004.5 +- values aggregate them and find the average value. then continue on and find all the 791.0 +- values and do the same to them.

I do not know how many individual values there will be in each "group" nor do I know how many groups there will be.

The result I am looking for is another list which would contain the average values of each of the groups. So in the example my result would be (1004.524, 791.3176)

The code I'm currently using is very Kludgey and it seems there should be a much better way to do it.

As you can see I have to repeat code twice once in the else and once at the end of the if since the last set of numbers does not trigger the else. Plus at the completion of the if I need to add the last value.

If I use the len(tones) rather that len(tones)-i I get an out of range error.

Any thoughts or suggestions would be appreciated. Thanks for your help.

Ed

```<code>    toneLen = len(tones) -1
    for i in range(0, toneLen):
        if abs(tones[i]-tones[i+1]) <= 2.0:
            tmpTones.append(tones[i])
        else:
            freq = mean(tmpTones)
            newTones.append(freq)
            tmpTones = []
    tmpTones.append(tones[i+1])
    freq = mean(tmpTones)
    newTones.append(freq)
    tones = newTones
</code>```

UPDATE:
First I wanted to thank everyone who submitted suggestions. The response was very quick and helpful. I should have probably included some more info which I am doing below. Thanks so much for your help.

Second , a quick explanation of what I am trying to do. Our local Fire Department is looking for a way to track dispatches for departments close to them. For the most part they use two tone sequential paging i.e. 1000Hz followed by 500Hz.

So I am using numpy fft to find the tone frequency. Since the accuracy of the tone appears to be about +- 2 Hz, I compare the calculated frequency to a list of known paging tones and pick the closest match. After all the tones have been matched to the paging tones I look for matches to departments of interest.

One thing I did not know when I started this that in any given dispatch the same tone can be repeated several times, so the order of the tones is important. An example:
707.3, 339.6, 707.3, 569.1, 447.2, 569.1 would be a typical dispatch. I then look to see if any of the tone pairs are ones I'm interested in if so I display a message

Thanks again for all your help.

Ed

答:
This finds the borders between groups of nearly identical values and then computes the mean using slices on the original list.</p>

```<code>tones = (1004.523, 1004.575, 1004.475, 791.385, 791.298, 791.301, 791.305, 791.299)
splits = [i for i in range(1, len(tones)) if abs(tones[i-1] - tones[i]) > 2]
splits = [0] + splits + [len(tones)]
tones = [mean(tones[splits[i-1]:splits[i]]) for i in range(1, len(splits))]
# [1004.5243333333333, 791.31759999999997]
</code>```

Body:
I have a list that contains groups of nearly identical numeric values. i.e. (1004.523, 1004.575, 1004.475, 791.385, 791.298, 791.301, 791.305, 791.299)

What I am trying to do is read through the list and find all the 1004.5 +- values aggregate them and find the average value. then continue on and find all the 791.0 +- values and do the same to them.

I do not know how many individual values there will be in each "group" nor do I know how many groups there will be.

The result I am looking for is another list which would contain the average values of each of the groups. So in the example my result would be (1004.524, 791.3176)

The code I'm currently using is very Kludgey and it seems there should be a much better way to do it.

As you can see I have to repeat code twice once in the else and once at the end of the if since the last set of numbers does not trigger the else. Plus at the completion of the if I need to add the last value.

If I use the len(tones) rather that len(tones)-i I get an out of range error.

Any thoughts or suggestions would be appreciated. Thanks for your help.

Ed

    toneLen = len(tones) -1
    for i in range(0, toneLen):
        if abs(tones[i]-tones[i+1]) <= 2.0:
            tmpTones.append(tones[i])
        else:
            freq = mean(tmpTones)
            newTones.append(freq)
            tmpTones = []
    tmpTones.append(tones[i+1])
    freq = mean(tmpTones)
    newTones.append(freq)
    tones = newTones

UPDATE:
First I wanted to thank everyone who submitted suggestions. The response was very quick and helpful. I should have probably included some more info which I am doing below. Thanks so much for your help.

Second , a quick explanation of what I am trying to do. Our local Fire Department is looking for a way to track dispatches for departments close to them. For the most part they use two tone sequential paging i.e. 1000Hz followed by 500Hz.

So I am using numpy fft to find the tone frequency. Since the accuracy of the tone appears to be about +- 2 Hz, I compare the calculated frequency to a list of known paging tones and pick the closest match. After all the tones have been matched to the paging tones I look for matches to departments of interest.

One thing I did not know when I started this that in any given dispatch the same tone can be repeated several times, so the order of the tones is important. An example:
707.3, 339.6, 707.3, 569.1, 447.2, 569.1 would be a typical dispatch. I then look to see if any of the tone pairs are ones I'm interested in if so I display a message

Thanks again for all your help.

Ed

Body:
This finds the borders between groups of nearly identical values and then computes the mean using slices on the original list.

tones = (1004.523, 1004.575, 1004.475, 791.385, 791.298, 791.301, 791.305, 791.299)
splits = [i for i in range(1, len(tones)) if abs(tones[i-1] - tones[i]) > 2]
splits = [0] + splits + [len(tones)]
tones = [mean(tones[splits[i-1]:splits[i]]) for i in range(1, len(splits))]
# [1004.5243333333333, 791.31759999999997]


问:
Clear inputs after adding to list
I have the following HTML in an AngularJS application:

```<code>  <form name="form" ng-submit="vm.save(vm.data)">
    <table>
      <tr ng-repeat="d in vm.data.degrees">
        <td ng-bind="d.school"></td>
        <td ng-bind="d.field"></td>
      </tr>
    </table>
    <div>
      <input id="school" type="text" ng-model="d.school"/>
      <input id="field" type="text" ng-model="d.field"/>
      <button class="button" type="button" ng-click="vm.addDegree(d.school, d.field)">
        Add Degree
      </button>
    </div>
    <input id="name" type="text" ng-model="vm.data.name"/>
    <button>Submit form</button>
  </button>
</form>
</code>```

I have a button which adds a degree (d.school + d.field) to the list (table).
When I add an item to the list I want to clear the inputs school and degree.

How can I do this?

答:
You can reset d.school and d.degree in the ng-click directive like this :

```<code>ng-click="vm.addDegree(d.school, d.field);d.school = '';d.degree=''"
</code>```

You can take a look at this plunker

Title: Clear inputs after adding to list

Body:
I have the following HTML in an AngularJS application:

  <form name="form" ng-submit="vm.save(vm.data)">

      <input id="school" type="text" ng-model="d.school"/>
      <input id="field" type="text" ng-model="d.field"/>
      <button class="button" type="button" ng-click="vm.addDegree(d.school, d.field)">
        Add Degree
      </button>

    <input id="name" type="text" ng-model="vm.data.name"/>
    <button>Submit form</button>
  </button>
</form>

I have a button which adds a degree (d.school + d.field) to the list (table).
When I add an item to the list I want to clear the inputs school and degree.

How can I do this?

Body:
You can reset d.school and d.degree in the ng-click directive like this :

ng-click="vm.addDegree(d.school, d.field);d.school = '';d.degree=''"

You can take a look at this plunker


问:
RxJava convert byte array to Bitmap
Sorry for my english. Now i learning rxJava 1 and try convert byte[] to Bitmap and set it to imageview. But it work slowly. Do i right work whith rxJava? ps: i chek and asynkTask work fater than rxJava, how it possible? </p>

```<code>Observable.just(data)
                .map(new Func1<byte[], Bitmap>() {
                    @Override
                    public Bitmap call(byte[] bytes) {
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        options.inJustDecodeBounds = false;
                        options.inPreferredConfig = Bitmap.Config.RGB_565;
                        options.inDither = true;
                        options.inMutable = true;

                        Bitmap largeBitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);
                        Bitmap bitmap = Bitmap.createScaledBitmap(largeBitmap
                                , (int) ((float) largeBitmap.getWidth() / 10)
                                , (int) ((float) largeBitmap.getHeight() / 10)
                                , true);

                        if (bitmap.getWidth() > bitmap.getHeight()) {
                            Matrix matrix = new Matrix();
                            matrix.postRotate(90); // anti-clockwise by 90 degrees

                            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
                        }

                        float k = (float) bitmap.getWidth() / (float) w_target;

                        if (w_target < bitmap.getWidth()) {
                            bitmap = Bitmap.createScaledBitmap(bitmap, w_target, (int) ((float) bitmap.getHeight() / k), true);
                        }

                        return createBlackAndWhite(bitmap);
                    }
                })
                .observeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Bitmap>() {
                    @Override
                    public void call(Bitmap bitmap) {
                        imageview.setImageBitmap(bitmap);
                    }
                });
</code>```

答:
Maybe you should change the Scheduler used to handle the process , instead of Schedulers.io() try Schedulers.computation() at least for some of your calcul.

According to the documentation

computation(): Creates and returns a Scheduler intended for
computational work. This can be used for event-loops, processing
callbacks and other computational work. Do not perform IO-bound work
on this scheduler. Use Schedulers.io() instead.

io(): Creates and
returns a Scheduler intended for IO-bound work. The implementation is
backed by an Executor thread-pool that will grow as needed. This can
be used for asynchronously performing blocking IO. Do not perform
computational work on this scheduler. Use Schedulers.computation()
instead.

Hope this helps.

Sorry for my english.

Title: RxJava convert byte array to Bitmap

Body:
Sorry for my english. Now i learning rxJava 1 and try convert byte[] to Bitmap and set it to imageview. But it work slowly. Do i right work whith rxJava? ps: i chek and asynkTask work fater than rxJava, how it possible?

Observable.just(data)
                .map(new Func1<byte[], Bitmap>() {
                    @Override
                    public Bitmap call(byte[] bytes) {
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        options.inJustDecodeBounds = false;
                        options.inPreferredConfig = Bitmap.Config.RGB_565;
                        options.inDither = true;
                        options.inMutable = true;

                        Bitmap largeBitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);
                        Bitmap bitmap = Bitmap.createScaledBitmap(largeBitmap
                                , (int) ((float) largeBitmap.getWidth() / 10)
                                , (int) ((float) largeBitmap.getHeight() / 10)
                                , true);

                        if (bitmap.getWidth() > bitmap.getHeight()) {
                            Matrix matrix = new Matrix();
                            matrix.postRotate(90); // anti-clockwise by 90 degrees

                            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
                        }

                        float k = (float) bitmap.getWidth() / (float) w_target;

                        if (w_target < bitmap.getWidth()) {
                            bitmap = Bitmap.createScaledBitmap(bitmap, w_target, (int) ((float) bitmap.getHeight() / k), true);
                        }

                        return createBlackAndWhite(bitmap);
                    }
                })
                .observeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Bitmap>() {
                    @Override
                    public void call(Bitmap bitmap) {
                        imageview.setImageBitmap(bitmap);
                    }
                });


问:
git clone by https does not work on other machine
On my local machine(Linux), I clone the repo with

```<code>git clone https://rcffc@dev.kom.e-technik.tu-darmstadt.de/gitlab/WaelKH/KM_2_2017_Feature_Selection.git
</code>```

and it asks me for my password. After typing the password I can clone the repository, fine.

On the server(Windows), the command leads to

```<code>remote: Not Found
fatal: repository 'git clone https://rcffc@dev.kom.e-technik.tu-darmstadt.de/gitlab/WaelKH/KM_2_2017_Feature_Selection.git/' not found
</code>```

Please help me.

UPDATE: It is a private repository.
UPDATE 2&3: Made question clearer.
UPDATE 4: Included OS info
UPDATE 5: Included actual commands.

答:
Try to check if curl https://username@remote.git works. First, as @sensorario mentioned, you should make sure your URL is valid, and you should also guarantee that curl is using the right certificate for the https connections since AFAIK git commands internally uses curl.

UPDATE

git clone https://your_server_ip/your_user_name/your_repo_name.git

Body:
On my local machine(Linux), I clone the repo with

git clone https://rcffc@dev.kom.e-technik.tu-darmstadt.de/gitlab/WaelKH/KM_2_2017_Feature_Selection.git

and it asks me for my password. After typing the password I can clone the repository, fine.

On the server(Windows), the command leads to

remote: Not Found
fatal: repository 'git clone https://rcffc@dev.kom.e-technik.tu-darmstadt.de/gitlab/WaelKH/KM_2_2017_Feature_Selection.git/' not found

Please help me.

UPDATE: It is a private repository.
UPDATE 2&3: Made question clearer.
UPDATE 4: Included OS info
UPDATE 5: Included actual commands.


问:
Install driver using InstallShield(USB device)
1) I am trying to register the Dll in Installshield based on the Hardware Info(USB\VID_12C1).

-> I want to know the device ID of the USB device connected to PC.
   Then I want to fetch the USB device info into separate file.

-> From installshield I will pass the USB vendor ID to text file
   and fetch the USB info.

-> Whether it is possible to do it in Installshield.

The following is the way I am trying to get the device ID:

```<code>szProgram = WINDIR ^ "temp" ^ "New" ^ "devcon.exe";

szCmdLine = " hwids *";

nvResult = LaunchAppAndWait(szProgram, szCmdLine, LAAW_OPTION_WAIT);

if (nvResult = 0) then

  MessageBox ("ERROR: application created sucfuly", INFORMATION);

else

  MessageBox ("ERROR: application", INFORMATION);

endif;
</code>```

-> While installing the Installer trying to execute "devcon.exe hwids *"
     through LaunchAppandwait Api. It will list the number of devices connected
     to my PC. I want to save the device list in text file.
ISSUE: -> Unable to store the result in text file.

Please provide some ideas to store the device list into file and fetch
   the required device list.

答:
As far as I understand correctly you would like to know if certain device available on the system. For this purpose I would suggest to have a look on DevCon Find command, instead of getting entire list of devices. For example:

```<code>devcon find *USB\VID_046D*
</code>```

If you insist to get the entire list of devices, and want to get it into the file you may look at this answer: Capturing stdOutput and stdError from LaunchApplication. Basically the simplest way is reditecting output into file. For example:

```<code>szProgram = WINDIR ^ "temp" ^ "New" ^ "devcon.exe";
szCmdLine = " hwids * > c:\temp\New\hardware.txt";
</code>```

And in order to parse the file content you would need to get the file content. You may use GetLine or ListReadFromFile functions. The following would be example: OpenFile Example

Body:
1) I am trying to register the Dll in Installshield based on the Hardware Info(USB\VID_12C1).

-> I want to know the device ID of the USB device connected to PC.
   Then I want to fetch the USB device info into separate file.

-> From installshield I will pass the USB vendor ID to text file
   and fetch the USB info.

-> Whether it is possible to do it in Installshield.

The following is the way I am trying to get the device ID:

szProgram = WINDIR ^ "temp" ^ "New" ^ "devcon.exe";

szCmdLine = " hwids *";

nvResult = LaunchAppAndWait(szProgram, szCmdLine, LAAW_OPTION_WAIT);

if (nvResult = 0) then

  MessageBox ("ERROR: application created sucfuly", INFORMATION);

else

  MessageBox ("ERROR: application", INFORMATION);

endif;

-> While installing the Installer trying to execute "devcon.exe hwids *"
     through LaunchAppandwait Api. It will list the number of devices connected
     to my PC. I want to save the device list in text file.
ISSUE: -> Unable to store the result in text file.

Please provide some ideas to store the device list into file and fetch
   the required device list.

Body:
As far as I understand correctly you would like to know if certain device available on the system. For this purpose I would suggest to have a look on DevCon Find command, instead of getting entire list of devices. For example:

devcon find *USB\VID_046D*

If you insist to get the entire list of devices, and want to get it into the file you may look at this answer: Capturing stdOutput and stdError from LaunchApplication. Basically the simplest way is reditecting output into file. For example:

szProgram = WINDIR ^ "temp" ^ "New" ^ "devcon.exe";
szCmdLine = " hwids * > c:\temp\New\hardware.txt";

And in order to parse the file content you would need to get the file content. You may use GetLine or ListReadFromFile functions. The following would be example: OpenFile Example


问:
Split testing transactional emails
I'm trying to figure out a solution to manage our transaction emails (such as the welcome email, you've got a bid, etc...)

We would like to be able to allow marketing to manage the content of the emails, and create split tests to test content / subject lines / etc...

Ideally we could invent our own success metrics to report back to the email management system (such as user completed registration, accepted bid, etc...).

Right now we have our emails in templates using stringtemplate.  The code replaces tokens with the correct content for that email.

Strongmail is a potential solution, but it is pricey - anybody have experience with alternatives?

答:
Try http://www.cakemail.com/

It is a third party, you design your workflows and give them your contacts.

I work for a 6 million a year website company and we direct all our clients to them, so far so good, everyone is happy.

You have to contact them to have a price but you can get a free account for testing

Title: Split testing transactional emails


问:
Android make view height 50% of screen width
I wish to make a view with the width to be match_parent, but the height to be 50% of the width.

How do I do it?

Is the only way to do it through java code inside the activity? I'll have to read the screen width and set the height that way.

答:
For better look experience and easy implementation I recommend you to simply add a Space or another widget invisible in the center of a RelativeLayout, then add the views you need respecting that Space or invisible widget.

For example there's a listView in the middle-top and another RelativeLayout in the middle-bottom with you requirements:

Also you can easily change to:

XML:

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textViewCenterInvisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />

    <ListView
        android:id="@+id/leftListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_above="@+id/relativeLayout" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/textViewCenterInvisible"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:id="@+id/relativeLayout">

        <TextView
            android:id="@+id/textViewCenterTopSecondLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10sp"
            android:gravity="center"
            android:text="Text in Second Layout Center Top" />

        <ImageView
            android:id="@+id/imageViewCenterSecondLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/coins"
            android:layout_marginTop="10sp"
            android:layout_below="@+id/textViewCenterTopSecondLayout"
            android:layout_centerHorizontal="true" />

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentStart="true"
            android:text="Button of second layout" />
    </RelativeLayout>

</RelativeLayout>
</code>```

Just play with the aligns.

Body:
For better look experience and easy implementation I recommend you to simply add a Space or another widget invisible in the center of a RelativeLayout, then add the views you need respecting that Space or invisible widget.

For example there's a listView in the middle-top and another RelativeLayout in the middle-bottom with you requirements:

Also you can easily change to:

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textViewCenterInvisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />

    <ListView
        android:id="@+id/leftListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_above="@+id/relativeLayout" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/textViewCenterInvisible"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:id="@+id/relativeLayout">

        <TextView
            android:id="@+id/textViewCenterTopSecondLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10sp"
            android:gravity="center"
            android:text="Text in Second Layout Center Top" />

        <ImageView
            android:id="@+id/imageViewCenterSecondLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/coins"
            android:layout_marginTop="10sp"
            android:layout_below="@+id/textViewCenterTopSecondLayout"
            android:layout_centerHorizontal="true" />

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentStart="true"
            android:text="Button of second layout" />
    </RelativeLayout>

</RelativeLayout>

Just play with the aligns.


问:
Why is there a NullPointerException in this method call?
When I call a method like this:

```<code>int value1;
Integer value2 = null;

setValue(value2);

private void setValue(int value) {
    value1 = value;
}
</code>```

Why is there a NullPointerException?

答:
A NullPointerException is thrown whenever you try to access something on a null-Reference.

Let's say we have this method:

```<code>public static String test(Object obj)
{
    return obj.toString();
}
</code>```

And we invoke it like this:

```<code>test(new Object());
</code>```

Everything will work fine.

But if we invoke the method with null:

```<code>test(null);
</code>```

a NullPointerException will be thrown.

Looking at the StackTrace you will see, that the NullPointerException was thrown in this line:

```<code>return obj.toString();
</code>```

That's because we tried to invoke the Method "toString" on a null-Reference.

So we see, that not giving the Method a null-Parameter, but invoking a Method on a null-Reference causes a NullPointerException. Some Methods check if the Parameter is null and have a special action for that. Often it's even very useful. But most methods will require the parameters not to be null.

Body:
When I call a method like this:

int value1;
Integer value2 = null;

setValue(value2);

private void setValue(int value) {
    value1 = value;
}

Why is there a NullPointerException?

Body:
A NullPointerException is thrown whenever you try to access something on a null-Reference.

Let's say we have this method:

public static String test(Object obj)
{
    return obj.toString();
}

And we invoke it like this:

test(new Object());

Everything will work fine.

But if we invoke the method with null:

test(null);

a NullPointerException will be thrown.

Looking at the StackTrace you will see, that the NullPointerException was thrown in this line:

return obj.toString();

That's because we tried to invoke the Method "toString" on a null-Reference.

So we see, that not giving the Method a null-Parameter, but invoking a Method on a null-Reference causes a NullPointerException. Some Methods check if the Parameter is null and have a special action for that. Often it's even very useful. But most methods will require the parameters not to be null.


问:
How to run a macro in sheet1 from sheet2
I can't figure out what to change to be able to run this macro from another sheet. Any idea ?

This macro is stored in sheet "Mail"

I want to run the macro from Sheet2 via a button

Is it possible or do I have to change the macro fundamentally?

```<code>    Sub DynamicRange()
    'Find the last row in the range then make the slection
    '-----------------------------------------------------------------------
    Dim sht As Worksheet
    Dim LastRow As Long
    Dim LastColumn As Long
    Dim StartCell As Range
    Dim Sendrng As Range
    Dim strbody As String

    '----------------------------------------------------------------
    If IsEmpty(Range("B26").Value) = True Then
    ThisWorkbook.Sheets("Mail").Range("B2:K26").Select
    Else
    '----------------------------------------------------------------

    Set sht = Worksheets("Mail")
    Set StartCell = Range("B2")

    'Refresh UsedRange
    Worksheets("Mail").UsedRange

    'Find Last Row
    LastRow = sht.Cells.Find("*", SearchOrder:=xlByRows,
    SearchDirection:=xlPrevious).Row

    'Select Range
    sht.Range("B2:K" & LastRow).Select

    End If

    '-----------------------------------------------------
    'Mail codes starts here
    On Error GoTo StopMacro

    With Application
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    'Note: if the selection is one cell it will send the whole worksheet
     Set Sendrng = Selection

    'Create the mail and send it
    With Sendrng

    ActiveWorkbook.EnvelopeVisible = True
    With .Parent.MailEnvelope

        With .Item
            .To = "here@myour.mail"
            .CC = ""
            .BCC = ""
            .Subject = ThisWorkbook.Sheets("Mail").Range("O4").Value
            .Importance = 2
            .ReadReceiptRequested = True
            .Send
        End With

    End With
    End With

    StopMacro:
    With Application
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    ActiveWorkbook.EnvelopeVisible = False

    End Sub
</code>```

答:
Implicit references to ActiveSheet

If the macro is implemented in the code-behind of sheet "Mail", then anywhere you query the Worksheets collection to fetch an object reference for that sheet, you can replace with Me, which refers to the current instance of a class module - and yes, worksheet modules are class modules. Like for userforms, VBA declares a globally-scoped object for them - you can determine the identifier to use for that object in the Properties toolwindow (F4), by changing the (Name) property of the worksheet. So you can name your sheet MailSheet and use that in code:

```<code>Debug.Print MailSheet.Name
</code>```

Now, whenever you use an unqualified Range call (or Rows, or Cells, or Names, or Columns), you're implicitly referring to whatever worksheet is currently active, which may or may not be the worksheet you intended to work with. This regularly causes run-time errors and you will find dozens upon dozens of questions on this site where this is the root cause - always qualify Range calls with a proper worksheet object and you won't have that problem.

I'm heavily involved in Rubberduck, an add-in for the VBE (VBA's IDE/editor) that can locate all instances of implicit references to the active worksheet, and a couple of other common beginner (and some not-so-beginner) mistakes. You may want to give it a try, it's free and open-source.

Calling the procedure

If the procedure were implemented as a Public Sub in a standard module (.bas) instead of a worksheet's code-behind, then you could call it like this, from anywhere in the project:

```<code>DynamicRange
</code>```

Note that that's a rather poor name for a procedure; procedures do something, their names should start with a verb, and the name should convey what it's doing.

If you don't want to move the procedure to a standard procedural module, then you can always leave it a public member of the worksheet module (if Public isn't specified then it's implicit; module members in VBA are always Public by default) and call it like this:

```<code>MailSheet.DynamicRange
</code>```

Assuming you gave the "Mail" sheet the name MailSheet in the properties toolwindow, as described above.

Parameterizing the procedure

If you want your procedure to work against any specified worksheet, then you need to parameterize it. The signature becomes something like this:

```<code>Public Sub DynamicRange(ByVal sht As Worksheet)
</code>```

So when you call that procedure, you can supply a Worksheet object:

```<code>DynamicRange MailSheet
</code>```

or

```<code>MailSheet.DynamicRange Sheet2
</code>```

For this to work though, you need to remove the local declaration and assignment for your sht variable, and have the code work against the specified worksheet instead.

Body:
I can't figure out what to change to be able to run this macro from another sheet. Any idea ?

This macro is stored in sheet "Mail"

I want to run the macro from Sheet2 via a button

Is it possible or do I have to change the macro fundamentally?

    Sub DynamicRange()
    'Find the last row in the range then make the slection
    '-----------------------------------------------------------------------
    Dim sht As Worksheet
    Dim LastRow As Long
    Dim LastColumn As Long
    Dim StartCell As Range
    Dim Sendrng As Range
    Dim strbody As String

    '----------------------------------------------------------------
    If IsEmpty(Range("B26").Value) = True Then
    ThisWorkbook.Sheets("Mail").Range("B2:K26").Select
    Else
    '----------------------------------------------------------------

    Set sht = Worksheets("Mail")
    Set StartCell = Range("B2")

    'Refresh UsedRange
    Worksheets("Mail").UsedRange

    'Find Last Row
    LastRow = sht.Cells.Find("*", SearchOrder:=xlByRows,
    SearchDirection:=xlPrevious).Row

    'Select Range
    sht.Range("B2:K" & LastRow).Select

    End If

    '-----------------------------------------------------
    'Mail codes starts here
    On Error GoTo StopMacro

    With Application
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    'Note: if the selection is one cell it will send the whole worksheet
     Set Sendrng = Selection

    'Create the mail and send it
    With Sendrng

    ActiveWorkbook.EnvelopeVisible = True
    With .Parent.MailEnvelope

        With .Item
            .To = "here@myour.mail"
            .CC = ""
            .BCC = ""
            .Subject = ThisWorkbook.Sheets("Mail").Range("O4").Value
            .Importance = 2
            .ReadReceiptRequested = True
            .Send
        End With

    End With
    End With

    StopMacro:
    With Application
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    ActiveWorkbook.EnvelopeVisible = False

    End Sub

Body:
Implicit references to ActiveSheet

If the macro is implemented in the code-behind of sheet "Mail", then anywhere you query the Worksheets collection to fetch an object reference for that sheet, you can replace with Me, which refers to the current instance of a class module - and yes, worksheet modules are class modules. Like for userforms, VBA declares a globally-scoped object for them - you can determine the identifier to use for that object in the Properties toolwindow (F4), by changing the (Name) property of the worksheet. So you can name your sheet MailSheet and use that in code:

Debug.Print MailSheet.Name

Now, whenever you use an unqualified Range call (or Rows, or Cells, or Names, or Columns), you're implicitly referring to whatever worksheet is currently active, which may or may not be the worksheet you intended to work with. This regularly causes run-time errors and you will find dozens upon dozens of questions on this site where this is the root cause - always qualify Range calls with a proper worksheet object and you won't have that problem.

I'm heavily involved in Rubberduck, an add-in for the VBE (VBA's IDE/editor) that can locate all instances of implicit references to the active worksheet, and a couple of other common beginner (and some not-so-beginner) mistakes. You may want to give it a try, it's free and open-source.

Calling the procedure

If the procedure were implemented as a Public Sub in a standard module (.bas) instead of a worksheet's code-behind, then you could call it like this, from anywhere in the project:

DynamicRange

Note that that's a rather poor name for a procedure; procedures do something, their names should start with a verb, and the name should convey what it's doing.

If you don't want to move the procedure to a standard procedural module, then you can always leave it a public member of the worksheet module (if Public isn't specified then it's implicit; module members in VBA are always Public by default) and call it like this:

MailSheet.DynamicRange

Assuming you gave the "Mail" sheet the name MailSheet in the properties toolwindow, as described above.

Parameterizing the procedure

If you want your procedure to work against any specified worksheet, then you need to parameterize it. The signature becomes something like this:

Public Sub DynamicRange(ByVal sht As Worksheet)

So when you call that procedure, you can supply a Worksheet object:

DynamicRange MailSheet

or

MailSheet.DynamicRange Sheet2

For this to work though, you need to remove the local declaration and assignment for your sht variable, and have the code work against the specified worksheet instead.