问题列表 - 第44849页

在选择框上重新填充日期

我在Rails中创建了一个date_select(这是3个选择框:一个用于一年,一个用于月份,一个用于一天).

2月31日对他们来说是相当混乱的.我希望能够使选择框只有有效日期.我的意思是,当您选择2月,31日,30日(以及某些年份29日)时,将删除,然后,当您选择1月时,它们会再次添加,依此类推.此外,我希望初始选择框仅填充所选月份的日期.

javascript jquery ruby-on-rails ruby-on-rails-3

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

Powershell和wmi,如何将逻辑磁盘/卷映射到硬盘,反之亦然?

Get-WmiObject -ComputerName $ip -Credential $credential -Class Win32_logicaldisk
Run Code Online (Sandbox Code Playgroud)

这让我得到了我在"我的电脑"中看到的磁盘,例如.C:,D:,E:现在我如何获得相应的底层物理磁盘?

如果我运行以下命令

Get-WmiObject -ComputerName $ip -Credential $credential -Class win32_diskdrive
Run Code Online (Sandbox Code Playgroud)

我得到磁盘0,磁盘1,磁盘2

那么如何找出哪个物理磁盘上的逻辑磁盘呢?

另一个问题是如何找出卷号?如果我运行diskpart并执行"list volume",我会得到以下输出

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 2     C                NTFS   Partition     59 GB  Healthy    Boot
  ...
Run Code Online (Sandbox Code Playgroud)

如何找出逻辑磁盘C:是第2卷?

最好的问候,Primoz.

powershell wmi disk

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

如何使用selenium和单个NUnit套件测试多个浏览器并将其保持干燥状态?

我正在寻找一种方法来重用一个NUnit测试套件,而无需为每个浏览器复制整个套件.看起来我需要为每个浏览器安装一个新夹具.我可以从NUnit gui发送某种环境变量或配置设置来切换浏览器吗?见下文:

[TestFixture]
public class User
{
    private ISelenium selenium;
    private StringBuilder verificationErrors;

    [SetUp]
    public void SetupTest()
    {
        // TheBrowser = How do I populate this variable from the NUnit gui? 
        selenium = new DefaultSelenium("localhost", 4444, **TheBrowser**, "http://localhost:52251/");
        selenium.Start();
        verificationErrors = new StringBuilder();
    }

    [TearDown]
    public void TeardownTest()
    {
      ...
    }

    [Test]
    public void SearchUser()
    {
       ... 
    }

}
Run Code Online (Sandbox Code Playgroud)

selenium nunit cross-browser

9
推荐指数
2
解决办法
5164
查看次数

在powershell中保存XML文件需要完整的路径.为什么?

我正在使用powershell的XML功能来修改.config文件.除非我提供完整的路径名,否则调用XMLDocument.Save没有任何效果.

# Open the xml file
$config = [xml](get-content web.config)
#
# modify the XML
$config.SelectNodes("./configuration/connectionStrings/add[@name='LocalSqlServer']") | % { $connNode = $_ }
$connNode.connectionString = $connNode.connectionString -replace '^(.*)Server=[^;]+(.*)$', '$1Server=192.168.5.2$2'
#
#
# Now I save it again
#
# This doesn't save it!
$config.Save("web.config");
# However, this works
$config.Save("{0}\\web.config" -f (get-location));
Run Code Online (Sandbox Code Playgroud)

为什么$ config.Save("web.config")不起作用?

除了本地目录以外,我最终还是将它保存在其他地方吗?

xml powershell

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

如果我从一个单独的线程调用它,为什么我的代码运行得慢?

我刚刚使用Delphi的TThread类为应用程序添加了线程.该线程调用一个函数,该函数比较两个文件并打印它们之间不同的位.在我介绍线程之前,应用程序可以完成此过程并在300KB文件上大约1-2秒打印输出.引入线程检查后,相同的文件可能需要30 - 45秒,并导致50%的CPU峰值(AMD Phenom II Triple Core),之前您没有注意到峰值.

该线程正在执行的代码是:

procedure TForm1.CompareFiles(fil1, fil2 : ansistring; sg : TStringGrid; option : integer; progb : TProgressBar);
var
forg, fpat : file;
byteorg, bytepat : Byte;
byteorgc,bytepatc : ansistring;
arrby : Array Of ansistring;
arrpos : Array Of ansistring;
i,x : integer;
begin

if CRCAdlerGenFile(fil1,1) <> CRCAdlerGenFile(fil2,1) then //Only Run if files arn't same
begin
sg.Cols[0].Clear;
sg.Cols[1].Clear;
i := 0;
x := 0;

AssignFile(forg,fil1);
FileMode := fmOpenRead;
Reset(forg,1);
AssignFile(fpat,fil2);
FileMode := fmOpenRead;
Reset(fpat,1);

//Set Progress …
Run Code Online (Sandbox Code Playgroud)

delphi multithreading

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

用于Thor的VIM中类似Ruby的语法突出显示

如何配置vim使用与Thor相同的语法高亮显示为ruby?当我正在编辑*.thor文件时,我可以使用:set syntax=ruby,它可以使用,但不是永久性的.有没有办法在我的.vimrc文件中做一些事情来有条件地将语法设置为ruby,如果它是*.thor?也许创建一个thor语法文件并继承ruby?

ruby vim syntax-highlighting thor vim-syntax-highlighting

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

适用于STL的容器的Boilerplate typedef

在标准库或Boost中是否存在某种实用程序基类,用于使用所需的typedef(size_type,value_type等)填充自定义STL兼容的Sequence.我正在考虑像boost :: iterator_facade这样的东西,但对于容器.

我打算自己卷起来,但是想确保这样的事情还没有存在.

更新:

这是我提出的实用程序基类,以防任何人发现它有用:

template <class C>
class ContainerAdapter
{
public:
    typedef C::value_type value_type;
    typedef C::reference reference;
    typedef C::const_reference const_reference;
    typedef C::const_iterator iterator;
    typedef C::const_iterator const_iterator;
    typedef C::difference_type difference_type;
    typedef C::size_type size_type;

protected:
    typedef C::container_type;
};


// Usage
class MyCustomContainer : public ContainerAdapter< std::vector<int> >
{
...
};
Run Code Online (Sandbox Code Playgroud)

ContainerAdapter简单地"回应"自定义容器的基础容器的嵌套typedef.真的没有什么可以做的.

c++ containers boost stl boilerplate

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

PHP增加一半

我有一个简单的问题,可能很容易回答.我已经四处走动,但不确定我是在正确搜索还是在搜索什么.无论如何,使用PHP,我怎么能增加一半?

例如,我知道我可以使用以下循环:

<?php 
for ($i=1; $i<21; $i++) {
    print($i);
}
Run Code Online (Sandbox Code Playgroud)

它将打印1 - 20.

但是,我怎样才能输出如下内容:

1
1.5
2
2.5
etc...
Run Code Online (Sandbox Code Playgroud)

对不起我对此的无知,我只是不确定如何去做.谢谢!

php loops increment

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

D中3D字符阵列的问题

我正在学习D,我有一个简单的程序,它逐行读取文本文件,将每一行分成不同的单词,并将整个内容打印到stdout.

import std.stdio;
import std.string;

void main(string args[])
{
    char[][][] lines;
    auto input = File(args[1], "r");
    foreach(line; input.byLine())
    {
        auto words = split(strip(line));
        lines ~= words;
    }

    foreach(line; lines)
    {
        writeln(line);
    }
}
Run Code Online (Sandbox Code Playgroud)

创作words作品的代码.如果我只是writeln在每次分配时调用单词,我会得到我想要的输出.但是,如果我添加wordslines输出lines,然后奇怪的事情发生. lines在源文件中有每行的条目,但每行都是最后一行读取的损坏版本.例如,如果文件的最后一行如下所示:

END    START        * End of routine
Run Code Online (Sandbox Code Playgroud)

我得到的输出看起来像这样:

[       , END, ST, *, End , f rout, ne,    ,     , e other]
[     , END, ST, *, End of, rout, ne,      ,   , e othe] …
Run Code Online (Sandbox Code Playgroud)

d

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

dojo如何覆盖dijit类方法

我需要覆盖Tree.js中的onClick方法.是否有任何常见的方法来覆盖dojo/dijit类方法?

javascript dojo dom-events

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