问题列表 - 第37157页

删除 <nobr> </nobr> 字符串

我有以下变量,其中包含以下字符串。我想把 和<nobr>都去掉</nobr>,只留下里面的东西。

alert(product_code);
Run Code Online (Sandbox Code Playgroud)

产生

<nobr>209/00254/01</nobr>
Run Code Online (Sandbox Code Playgroud)

我如何创建一个删除标签的新变量<nobr>

var product_code = $(this).html();
alert(product_code);
Run Code Online (Sandbox Code Playgroud)

jquery

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

如何在播放MPMoviePlayerController电影之前隐藏控件?

假设iOS 3.2或更高版本.使用最初隐藏的控件进行移动的命令的正确顺序是什么.当电影正在播放时,用户可以选择在屏幕上标记并显示控件.

谢谢!

我的(控件未隐藏)代码:

- (void)playMovie
{
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Test" ofType:@"m4v"]];  
    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];  

    // Register to receive a notification when the movie has finished playing.  
    [[NSNotificationCenter defaultCenter] addObserver:self  
                                             selector:@selector(movieDone:)  
                                                 name:MPMoviePlayerPlaybackDidFinishNotification  
                                               object:moviePlayer];  

    [[NSNotificationCenter defaultCenter] addObserver:self  
                                             selector:@selector(movieState:)  
                                                 name:MPMoviePlayerNowPlayingMovieDidChangeNotification  
                                               object:moviePlayer];  

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(movieReady:) 
                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullScreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:moviePlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullScreen:) name:MPMoviePlayerWillExitFullscreenNotification object:moviePlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];


    if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {  
        moviePlayer.controlStyle = MPMovieControlStyleDefault; // MPMovieControlStyleNone MPMovieControlStyleEmbedded MPMovieControlStyleFullscreen …
Run Code Online (Sandbox Code Playgroud)

iphone mpmovieplayercontroller

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

HTML5平铺引擎

我在哪里可以找到HTML5的平铺引擎<canvas>,用于编写2D游戏?

html5 2d canvas tile-engine

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

在C#中以编程方式在ScriptBlock中传递Parameter对象(PSCredential)

我试图以编程方式运行HPC cmdlet以更改远程计算机上的HPC安装凭据.如果在本地运行cmdlet,则非常简单:

Runspace rs = GetPowerShellRunspace();
rs.Open();

Pipeline pipeline = rs.CreatePipeline();
PSCredential credential = new PSCredential(domainAccount, newPassword);
Command cmd = new Command("Set-HpcClusterProperty");
cmd.Parameters.Add("InstallCredential", credential);

pipeline.Commands.Add(cmd);

Collection<PSObject> ret = pipeline.Invoke();
Run Code Online (Sandbox Code Playgroud)

但是,如果我想对远程PowerShell做同样的事情,我需要运行Invoke-Command并将凭证传递给Command内的ScriptBlock.我怎样才能做到这一点?它可能看起来像这样,除了我需要传递凭证作为绑定到ScriptBlock内的InstallCredential参数而不是字符串的对象:

Pipeline pipeline = rs.CreatePipeline();
PSCredential credential = new PSCredential(domainAccount, newPassword);

pipeline.Commands.AddScript(string.Format(
    CultureInfo.InvariantCulture,
    "Invoke-Command -ComputerName {0} -ScriptBlock {{ Set-HpcClusterProperty -InstallCredential {1} }}",
    nodeName,
    credential));

Collection<PSObject> ret = pipeline.Invoke();
Run Code Online (Sandbox Code Playgroud)

c# powershell hpc

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

这段代码太脆了吗?

我需要创建一个策略模式,用户从二十或三十个唯一策略对象的列表中选择四个策略.随着项目的成熟,策略列表将会扩展,用户可以随时更改所选策略.

我打算将他们选择的策略名称存储为字符串,然后使用类似这样的方法来加载与他们选择的字符串相对应的策略类.

class StrategyManager { // simplified for the example
    public $selectedStrategies = array();
    public function __construct($userStrategies) {
        $this->selectedStrategies = array(
            'first'  => new $userStrategies['first'],
            'second' => new $userStrategies['second'],
            'third'  => new $userStrategies['third'],
            'fourth' => new $userStrategies['fourth']
        );
    }

    public function do_first() {
        $this->selectedStrategies['first']->execute();
    }

    public function do_second() {
        $this->selectedStrategies['second']->execute();
    }

    public function do_third() {
        $this->selectedStrategies['third']->execute();
    }

    public function do_fourth() {
        $this->selectedStrategies['fourth']->execute();
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图避免一个大的switch语句.我担心的是,这似乎有点儿Stringly Typed.有没有更好的方法来实现这个目标而不使用条件或大型switch语句?

BTW:用户在选择四种策略时不输入字符串.我需要维护一个字符串列表,以便在选择框中向用户显示,并在添加新策略对象时将新的字符串添加到列表中.

解释
ircmaxell表达了一些关于我正在尝试做什么的混淆.在上面的示例中,用户从列表中选择了四个策略,并将它们作为字符串数组传递给StrategyManager构造函数.创建相应的策略对象并将其存储在内部数组中,$this->selectedStrategies

"第一","第二","第三"和"第四"是用于四种不同选定策略的内部阵列的数组键.在构建StrategyManager对象之后,应用程序execute在整个过程的生命周期中的各个时刻使用四种策略的方法.

因此,简而言之......每次应用程序需要执行策略编号"one"的方法时,它都会这样做,并且结果会有所不同,具体取决于用户为策略"one"选择的策略

php string strategy-pattern

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

如何在Notepad ++中格式化XML?

我有Notepad ++,我得到了一些__CODE__很长的代码.当我将它粘贴在Notepad ++中时,存在很长的代码行(难以阅读和使用).

我想知道是否有一种简单的方法可以使文本可读(通过可读,我的意思是正确的选项卡代码).

我可以手动完成,但我想要一个永久的解决方案,因为我已经多次面对这个问题.我确信有一种方法可以做到这一点,因为我在几年前做过一次,可能是使用Visual Studio或其他编辑器,我不记得了.

但Notepad ++能做到吗?

code-formatting notepad++

1661
推荐指数
15
解决办法
130万
查看次数

如何使用较少/较少的内存对文件中的数百万行数据进行排序

(从这里)

我上周参加了一个采访,问了这个问题:

如何在基于8080处理器的计算机中仅使用640KB内存的文件中对十亿行数据进行排序?没有虚拟内存,没有外部磁盘.

我明确地询问了面试官我是否可以使用硬盘驱动器,所以我可以在排序树时对其进行序列化,然后在最后进行组合.他说不.我尝试了很多方法,不同的算法.他没有同意.

我放弃了,礼貌地问他,"你会怎么做?" 他直言不讳地说:"我不会告诉你的." (采访在那之后就结束了.我不是故意得罪他,作为一名开发人员,我很好奇.而且,这是一个本能的问题,就像我在工作场所问过任何人一样.)

这次访谈是为了一家非常大的银行.

那么,怎么会有人解决这个问题呢?

algorithm

16
推荐指数
3
解决办法
7372
查看次数

从字符串名称中选择Silverlight组合框选择的项目

我正在尝试从字符串中设置我的silverlight组合框中的所选项目.

在这个例子中,假设我有一个名为"MyComboBox"的组合框,如下所示:

<ComboBox Height="23" x:Name="MyComboBox" Width="200" HorizontalAlignment="Left">
    <ComboBoxItem Tag="0" Content="Pizza" IsSelected="True"/>
    <ComboBoxItem Tag="1" Content="Soda"/>
    <ComboBoxItem Tag="2" Content="Wings"/>
    <ComboBoxItem Tag="3" Content="Bread Sticks"/>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)

我从列表中随机选择一个字符串值来模拟用户保存的首选项.我面临的问题是尝试从字符串中获取"MyComboBox"的索引.

我尝试过使用带有LINQ的MyComboBox.items,但这让我无处可去.

这里有一些关于堆栈溢出的类似问题,但这些问题都没有得到解答.

c# silverlight

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

从文件异步加载图像

我在本地存储中有一个相对的图像,我想在不打扰UI线程的情况下向用户显示它.我正在使用

[[UIImage alloc] initWithContentsOfFile:path];
Run Code Online (Sandbox Code Playgroud)

加载图像.

任何建议/帮助请....

iphone asynchronous objective-c ios4

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

获取文件Python中某些短语的行号

我需要在文本文件中获取短语的行号.这句话可能是:

the dog barked
Run Code Online (Sandbox Code Playgroud)

我需要打开文件,搜索该短语并打印行号.

我在Windows XP上使用Python 2.6


这就是我所拥有的:

o = open("C:/file.txt")
j = o.read()
if "the dog barked" in j:
     print "Found It"
else:
     print "Couldn't Find It"
Run Code Online (Sandbox Code Playgroud)

这不是作业,它是我正在进行的项目的一部分.我甚至不知道如何获得行号.

python file

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