我有一个包含几个模块的项目.当所有测试通过后,Maven测试将全部运行.
当第一个模块中的测试失败时,maven将不会继续下一个项目.我在Surefire设置中将testFailureIgnore设置为true,但它没有帮助.
如何让maven运行所有测试?
我有一个List<bool>.我需要获取前n项的索引,其中item value = true.
例如以下列表项(bool)
10011001000
TopTrueIndexes(3) = The first 3 indexes where bits are true are 0, 3, 4
TopTrueIndexes(4) = The first 4 indexes where bits are true are 0, 3, 4, 7
Run Code Online (Sandbox Code Playgroud)
我怎么能为此写一个lambda?
当您在Android 2.2+中创建LiveWallpaper时,您将获得一个画布(或任何3D等效物).我想使用内置的Android UI工具绘制一些元素,而不是使用canvas命令从头开始构建所有元素或加载预渲染的UI位图.
将单个视图转换为位图工作正常.即这很好:
// For example this works:
TextView view = new TextView(ctx);
view.layout(0, 0, 200, 100);
view.setText("test");
Bitmap b = Bitmap.createBitmap( 200, 100, Bitmap.Config.ARGB_8888);
Canvas tempC = new Canvas(b);
view.draw(tempC);
c.drawBitmap(b, 200, 100, mPaint);
Run Code Online (Sandbox Code Playgroud)
但是,使用子项转换LinearLayout会导致问题.你只能得到LinearLayout本身,而不是它的孩子.例如,如果我将LinearLayout设置为具有白色背景,则会获得一个很好地渲染的白色框,但是Bitmap中没有任何TextView子项.我也尝试过使用类似结果的DrawingCache.
我正在使用的代码是多维数据集示例,唯一的更改是额外的绘制命令.LinearLayout可以作为toast或常规视图(即一切都很好地显示),在LiveWallpaper上我得到的是LinearLayout的背景渲染.
inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) inflater.inflate(com.example.android.livecubes.R.layout.testLinearLayout, null);
layout.layout(0, 0, 400, 200);
Bitmap b = Bitmap.createBitmap( 400, 200, Bitmap.Config.ARGB_8888);
Canvas tempC = new Canvas(b);
layout.draw(tempC);
c.drawBitmap(b, 10, 200, mPaint);
Run Code Online (Sandbox Code Playgroud)
有没有人知道你是否需要做一些特别的事情来让孩子们正确地渲染到我的位图?即我是否需要以某种方式做一些特殊的事情来使布局渲染其余的孩子?我应该写一个函数来递归地对所有孩子做些什么吗?
我可以自己合成一切但是,因为显示是相当静态的(即我画了一次并保留了位图的副本以在背景上绘制)这对我来说似乎更容易并且仍然非常有效.
编辑: 在进一步挖掘布局的状态时,看起来好像布局没有沿着视图树向下移动(即,当我调用layout()时,LinearLayout得到它的布局,但子窗口的大小为null(0x0) ).根据Romain Guy在2008年安卓开发者帖子中的帖子.您必须等待布局传递或自己强制布局.问题是我如何等待壁纸引擎的布局传递给没有连接到根视图组的LinearLayout?如果布局要求您在我不知道这些应该是什么时设置左,上,右,下,我该如何手动布局每个子元素.
我试过在孩子身上调用forceLayout,但似乎也没有帮助.我不确定布局框架如何在幕后工作(除了它做了两遍布局).有没有办法手动让它做布局通过,即现在?由于它不是一个活动我不认为很多正常的背景材料正在发生我想要的方式.
我在Rails 3中使用acts_as_taggable_on v.2.0.3来为帖子添加标签.我添加了一个标签云,如下所述:https://github.com/mbleigh/acts-as-taggable-on,但我遇到了一个错误: Posts中的ActionController :: RoutingError #index:没有路由匹配{:action =>"tag",:id =>"politics",:controller =>"posts"}.我的代码如下:
PostHelper:
module PostsHelper
include TagsHelper
end
Run Code Online (Sandbox Code Playgroud)
模特岗位:
class Post < ActiveRecord::Base
...
acts_as_taggable_on :tags
end
Run Code Online (Sandbox Code Playgroud)
PostController中
class PostController < ApplicationController
...
def tag_cloud
@tags = Post.tag_counts_on(:tags)
end
end
Run Code Online (Sandbox Code Playgroud)
视图:
<% tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class| %>
<%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
routes.rb中:
Blog::Application.routes.draw do
root :to => "posts#index"
resources …Run Code Online (Sandbox Code Playgroud) 考虑这个简单的示例代码:
<form name="text" id="frm1" method="post">
<input type="checkbox" name="name[]" value="1000"> Chk1<br>
<input type="checkbox" name="name[]" value="1001"> Chk2<br>
<input type="checkbox" name="name[]" value="1002"> Chk3<br>
<input type="checkbox" name="name[]" value="1003"> Chk4<br>
<input type="checkbox" id="select_all"/> Select All<br>
</form>
<form name="text" id="frm2" method="post">
<input type="checkbox" name="name[]" value="4000"> Chk1<br>
<input type="checkbox" name="name[]" value="4001"> Chk2<br>
<input type="checkbox" name="name[]" value="4002"> Chk3<br>
<input type="checkbox" name="name[]" value="4003"> Chk4<br>
<input type="checkbox" id="select_all"/> Select All<br>
Run Code Online (Sandbox Code Playgroud)
我试图让Select All在每个表单中工作(表单是在我的生产代码中动态生成的,并且具有不同的,不同的名称)
我正在使用这个jquery,但select_all仅适用于第一个表单; 它对第一个下面的表格没有影响.
$('#select_all').change(function() {
var checkboxes = $(this).closest('form').find(':checkbox');
if($(this).is(':checked')) {
checkboxes.attr('checked', 'checked');
} else {
checkboxes.removeAttr('checked');
}
}); …Run Code Online (Sandbox Code Playgroud) 在Visual Basic中,如果要更改单个对象的多个属性,则需要With/End With声明:
Dim myObject as Object
// ' Rather than writing:
myObject.property1 = something
myObject.property2 = something2
// ' You can write:
with myObject
.property1 = something
.property2 = something2
...
End With
Run Code Online (Sandbox Code Playgroud)
我知道C#可以在创建新对象时执行此操作:
Object myObject = new Object { property1 = something, property2 = something2, ...};
Run Code Online (Sandbox Code Playgroud)
但是,如果myOject已经创建(如Visual Basic正在做什么),我该怎么做?
当笔记本超出一些功能时我遇到的一个典型情况 - 我评估一个表达式,但是我得到了Beep而不是正确的答案,然后是几十个无用的警告,接着是"进一步输出...将被抑制"
我觉得有用的一件事 - 在函数内部使用类似Python的"断言"来强制内部一致性.还有其他提示吗?
Assert[expr_, msg_] := If[Not[expr], Print[msg]; Abort[], None]
Run Code Online (Sandbox Code Playgroud)
编辑11/14 警告雪崩的一般原因是子表达式评估为"坏"值.这会导致父表达式计算为"坏"值,并且此"不良"会一直传播到根目录.内置评估一路上注意到不良并产生警告."坏"可能意味着表达错误的头部,列表中的元素数量错误,负的确定矩阵而不是正定义等等.一般来说,它不适合父表达式的语义.
解决这个问题的一种方法是重新定义所有函数,以便在"输入错误"时返回未评估的值.这将处理内置函数生成的大多数消息.执行像"Part"这样的结构操作的内置函数仍将尝试评估您的值并可能产生警告.
将调试器设置为"中断消息"可以防止出现大量错误,尽管将其一直打开似乎有点过头了
考虑这种方法:
public IEnumerable<T> GetList(int Count)
{
foreach (var X in Y)
{
// do a lot of expensive stuff here (e.g. traverse a large HTML document)
// when we reach "Count" then exit out of the foreach loop
}
}
Run Code Online (Sandbox Code Playgroud)
我会这样称呼它:Class.GetList(10);它会返回10个项目 - 这很好.
我想使用IEnumerable的Take()方法Class.GetList().Take(10)代替使用,我希望foreach循环能够以某种方式获取我传入的数字Take()- 这可能吗?这似乎是一种更清洁的方法,因为它最终会更便宜,因为我可以使用Class.GetList()一次获取完整列表然后使用IEnumerable方法来获取x项.
多谢你们!
我正在尝试使用asp.net mvc 3 RC设计视图.我不确定,但我无法在设计器模式下打开我的cshtml文件.我可以改变他们的源代码html,但没有设计时间的帮助.
我错过了什么吗?
我试图从方案中的字符串列表中获取随机字符串.示例列表("this""that""today""yesterday")因此,基于列表的长度,创建随机数并输出该字.但不断收到错误!
我试过这样的:
;; produces random number that should be input to the random-function
(define (random-num list)
(random-function ((random (length (list))) list)))
;; loops the number of times till random number is 0 and outputs the list value
(define (random-function num list )
(cond
[(zero? num) (car list)]
[else (random-function (- num 1) (cdr list))]))
Run Code Online (Sandbox Code Playgroud)
错误:
procedure application: expected procedure, given:
("this" "that" "today" "yesterday") (no arguments)
Run Code Online (Sandbox Code Playgroud)
当我尝试做的时候:
(random-function (random (length list))
Run Code Online (Sandbox Code Playgroud)
在控制台上我得到一个随机数.
在我的程序里完成时,不明白为什么它会崩溃?
我能以更好的方式做到这一点,而不是循环这么多次.在Java中,我会使用一个数组并直接给出位置.无论如何也要在计划中做到这一点?