问题列表 - 第41495页

如何为hashCode()进行单元测试?

如何在单元测试中测试 hashCode()函数?

public int hashCode(){
    int result = 17 + hashDouble(re);
    result = 31 * result + hashDouble(im);
    return result;
}
Run Code Online (Sandbox Code Playgroud)

java junit unit-testing hashcode

35
推荐指数
2
解决办法
3万
查看次数

Facebook Like按钮在Android中集成

我想在我的Android应用程序中集成Facebook Like按钮.

请告诉我如何在Android中集成它的步骤.

android facebook

5
推荐指数
1
解决办法
3531
查看次数

如何使用nginx将address.com/foo/bar重定向到address.com:port/bar?

我在我的服务器ansel.ms上运行nginx,在ansel.ms:46156上运行了node.js应用程序.

我想设置nginx,以便重定向所有内容

ansel.ms/rhythm
Run Code Online (Sandbox Code Playgroud)

ansel.ms:46156.


ansel.ms/rhythm/sub/path
Run Code Online (Sandbox Code Playgroud)

应该成为

ansel.ms:46156/sub/path
Run Code Online (Sandbox Code Playgroud)

这是我的网站文件 - 可用:

upstream rhythm {
    server ansel.ms:46156;
}

server {
    listen   80;
    server_name ansel.ms www.ansel.ms;
    access_log /srv/www/ansel.ms/logs/access.log;
    error_log /srv/www/ansel.ms/logs/error.log;

    location / {
        root   /srv/www/ansel.ms/public_html;
        index  index.html index.htm;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /srv/www/ansel.ms/public_html$fastcgi_script_name;
    }

    location /rhythm{
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://rhythm;
        proxy_redirect off;
    }
}
Run Code Online (Sandbox Code Playgroud)

我不太了解它的作用(proxy_set_header的东西),我只是从几个来源复制和粘贴它.

它不起作用.

你能给我一个暗示要改变的东西吗?这样做我上面描述的是什么?谢谢!

port proxy nginx

13
推荐指数
1
解决办法
2万
查看次数

C++函数指针作为默认模板参数

如何将函数指针编写为默认模板参数,我猜这样写:

template<typename R,
         typename A,
         typename F=R (*PF)(A)> 
class FunctionPtr { ...
Run Code Online (Sandbox Code Playgroud)

我的问题是,

1.有可能吗?

2.如果是,我上面的猜测代码是正确的,PF这里的目的是什么?我需要这个吗?

c++ templates arguments default function-pointers

6
推荐指数
1
解决办法
1029
查看次数

从TSQL OPENXML中的xml文档中选择节点文本值

我有一个xml文档,我想用它来更新存储过程中的值.我可以使用OPENXML处理XML,但我对提取我想要的值感到困惑.xml中的每一行都是产品记录,我想为每个属性创建一个变量.Cell0是ID,Cell2描述等

DECLARE @idoc int  
DECLARE @doc varchar(1000)  
SET @doc ='
<products>    
 <rows>
  <row>
   <cell>1</cell>
   <cell>BALSAMO DERMOSCENT</cell>
   <cell>1.00</cell>
   <cell>0.00</cell>
   <cell>18.00</cell>
   <cell>18.00</cell>
   <cell>8.00</cell>
   <cell>427</cell>
   <cell>No</cell>
  </row>
  <row>
   <cell>2</cell>
   <cell>BAYTRIL 150 MG 1 CPDO</cell>
   <cell>1.00</cell>
   <cell>0.00</cell>
   <cell>3.50</cell>
   <cell>3.50</cell>
   <cell>8.00</cell>
   <cell>57</cell>
   <cell>No</cell>
  </row>
 </rows>
</products>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT    *
FROM       OPENXML (@idoc, '/products/rows/row/cell',1)
with (Col1 varchar(29) 'text()')
Run Code Online (Sandbox Code Playgroud)

运行上面的查询会返回xml中每个CELL的1条记录.我希望能够为每个单元返回1条记录,每个单元格具有不同的列,例如: -

Prod       Description              Qty …
Run Code Online (Sandbox Code Playgroud)

xml t-sql sql-server openxml

3
推荐指数
1
解决办法
1万
查看次数

在xslt中使用position()函数

<EmployeeDetails>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
</EmployeeDetails>
Run Code Online (Sandbox Code Playgroud)

我尝试使用xslt如下:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    exclude-result-prefixes="xd"
    version="1.0">

    <xsl:template match="EmployeeDetails/Employee">
        <xsl:copy>
        <xsl:attribute name="id"><xsl:value-of select="position()"/></xsl:attribute>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="@*|node()"/>
        </xsl:element>
    </xsl:template>
    <xsl:template match="@*">
        <xsl:attribute name="{local-name()}">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

对于上面的xslt,position()的输出打印为2,4,6,8,10.

输出应该是:

<EmployeeDetails>
    <Employee id="1">
        <Name>TEST</Name>
    </Employee>
    <Employee id="2">
        <Name>TEST</Name>
    </Employee>
    <Employee id="3">
        <Name>TEST</Name>
    </Employee>
    <Employee id="4">
        <Name>TEST</Name>
    </Employee>
    <Employee id="5">
        <Name>TEST</Name>
    </Employee>
</EmployeeDetails>
Run Code Online (Sandbox Code Playgroud)

如何打印像1,2,3 ....的序列作为id属性.

xslt

12
推荐指数
2
解决办法
8万
查看次数

Microsoft SQL Server:每天生成一个序列号

我的任务是每天为项目创建一个不断增加的序列号。多个进程(理论上在多台机器上)需要生成它。最终结果是

[date]_[number]
Run Code Online (Sandbox Code Playgroud)

喜欢

20101215_00000001
20101215_00000002
...
20101216_00000001
20101216_00000002
...
Run Code Online (Sandbox Code Playgroud)

由于我在这个项目中使用的是 SQL Server (2008),因此我尝试使用 T-SQL/SQL 魔法来完成此操作。这就是我现在所处的位置:

我创建了一个包含序列号的表,如下所示:

CREATE TABLE [dbo].[SequenceTable](
    [SequenceId] [bigint] IDENTITY(1,1) NOT NULL,
    [SequenceDate] [date] NOT NULL,
    [SequenceNumber] [int] NULL
) ON [PRIMARY]
Run Code Online (Sandbox Code Playgroud)

到目前为止,我的天真的解决方案是在插入后设置一个触发器,设置 SequenceNumber:

CREATE TRIGGER [dbo].[GenerateMessageId]
ON  [dbo].[SequenceTable] 
AFTER INSERT
AS 
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- The ID of the record we just inserted
DECLARE @InsertedId bigint;
SET @InsertedId = (SELECT …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server sequence

5
推荐指数
1
解决办法
1万
查看次数

Magento - 在所有页面中创建固定块

如何在包含主页的所有页面中显示的右栏中创建一个块,而无需录制模块名称?

谢谢.

php xml layout magento

1
推荐指数
1
解决办法
3049
查看次数

两次之间的差异?

StartCopying = DateTime.Now;
File.Copy(@"C:\Users\sshap5x\Desktop\line4\shiraDebbi\Hackers.avi", @"C:\Users\sshap5x\Desktop\test\Hackers.avi", true);

EndCopying = DateTime.Now;
CopyingTime1 = (endCopying - startCopying).Duration;
Run Code Online (Sandbox Code Playgroud)

我的代码有什么问题?

复制时间是TimeSpan对象.

c#

-2
推荐指数
1
解决办法
137
查看次数

在github上没有空格更改的提交

有没有办法在github.com上显示提交而不显示空格更改?

有没有办法从控制台显示?即克隆然后查看提交(树)本地忽略所有空格的变化?

我广泛使用Trac; 我正在寻找类似的东西Ignore White space changes(可以在变更集视图中找到).

git trac github

24
推荐指数
2
解决办法
9915
查看次数