这句话是平等的myString != null,myString.length() > 0而且! myString.equals("") ?哪个是效率最高的?(Java 1.4)
我承认我已经在Ubuntu上拼凑了一个大部分正在运行的制作设置,其中Capistrano来自官方文档(看起来过时且做了很多假设)和各种过时的博客文章.无论如何,最后一个烦人的挂断是当我手工完成索引时(并且在部署时我非常肯定),但是Cron无法工作.
这是我的crontab:
$ crontab -l
# m h dom mon dow command
* * * * * cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index >> /var/www/app/current/log/cron.log 2>&1
Run Code Online (Sandbox Code Playgroud)
这是日志输出(这实际上每次调用出现3次):
Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
* bin_path
* searchd_binary_name
* indexer_binary_name
For more information, read the documentation:
http://freelancing-god.github.com/ts/en/advanced_config.html
Run Code Online (Sandbox Code Playgroud)
这是当我手动运行相同的命令时(也可以在记录时运行):
$ cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index
(in /var/www/app/releases/20100729042739)
Generating Configuration to /var/www/app/releases/20100729042739/config/production.sphinx.conf
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew …Run Code Online (Sandbox Code Playgroud) 任何人都可以提供一个如何使用GET和POST(Apache 4.1 HttpClient)的例子吗?
因为我发现的大多数例子都在使用3.x
我在后来的回答中被告知我必须将我在代码中创建的GestureOverlayView添加到我的视图层次结构中,而我不是100%如何做到这一点.以下是完整性的原始问题.
我希望我的游戏能够识别手势.我有一个很好的SurfaceView类,我在onDraw上绘制我的精灵,我有一个运行它的线程来调用onDraw等.
一切都很好.
我试图将GestureOverlayView添加到此,它只是无法正常工作.最后被黑客攻击它不会崩溃的地方,但这就是我所拥有的
public class Panel extends SurfaceView implements SurfaceHolder.Callback, OnGesturePerformedListener
{
public Panel(Context context)
{
theContext=context;
mLibrary = GestureLibraries.fromRawResource(context, R.raw.myspells);
GestureOverlayView gestures = new GestureOverlayView(theContext);
gestures.setOrientation(gestures.ORIENTATION_VERTICAL);
gestures.setEventsInterceptionEnabled(true);
gestures.setGestureStrokeType(gestures.GESTURE_STROKE_TYPE_MULTIPLE);
gestures.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
//GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
}
...
...
onDraw...
surfaceCreated(..);
...
...
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
// We want at least one prediction
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
// We want at least some confidence …Run Code Online (Sandbox Code Playgroud) 我正在使用PowerPoint 2007 VSTO加载项,我正在运行一个小问题.加载项使用以下代码将声音添加到当前幻灯片:
var shape = slide.Shapes.AddMediaObject(soundFileLocation, 50, 50, 20, 20);
Run Code Online (Sandbox Code Playgroud)
生成的形状确实有声音,可以通过PowerPoint幻灯片播放.我的问题是,给定一个以这种方式创建的形状的引用,我想以编程方式播放声音,但我找不到这样做的方法.我试过了
var soundEffect = shape.AnimationSettings.SoundEffect;
soundEffect.Play();
Run Code Online (Sandbox Code Playgroud)
但这会失败/崩溃,当我检查soundEffect时,它的类型是ppSoundNone.
编辑:获得部分成功
var shape = slide.Shapes.AddMediaObject(fileLocation, 50, 50, 20, 20);
shape.AnimationSettings.SoundEffect.ImportFromFile(fileLocation);
Run Code Online (Sandbox Code Playgroud)
这样做可以让我播放声音:
var animationSettings = shape.AnimationSettings;
var soundEffect = shape.AnimationSettings.SoundEffect;
soundEffect.Play();
Run Code Online (Sandbox Code Playgroud)
但是有一个主要问题; 这仅适用于添加的最后一个形状.出于某种原因,shape.AnimationSettings.SoundEffect.ImportFromFile(fileLocation)似乎将SoundEffect属性重置为ppSoundNone以用于先前创建的形状...
如果这不可行,我会感到惊讶,但我似乎无法找到 - 任何帮助都会非常感激!
我想调整线条的大小(两者都有),因为我觉得它们太瘦了.下面的代码会这样做,但会为size创建一个图例,这是没用的,因为size没有可以映射到它的变量.
qplot(date,value,data=graph1,geom="line",colour=variable,xlab="",ylab="",size=1)
+ scale_y_continuous(limits = c(-0.3,0.3)) + opts(aspect.ratio = 2/(1+sqrt(5)))
+ scale_colour_manual("Variable",c(Line1="red",Line2="blue"))
+ opts(legend.size="none")
Run Code Online (Sandbox Code Playgroud)
我的图由两行代表,表示同一时间跨度内两个不同变量的时间序列.变量映射到颜色.如果我试图影响线条的大小,qplot总是尝试将"大小"映射到另一个参数并显示另一个图例.
我也跟着这个讨论,结束了哈德利告诉其他人,删除部分传奇还没有实现.我知道在混合中添加另一个参数意味着需要这个参数的图例.也许我出于视觉原因使用了错误的命令来影响线条大小.
感谢任何建议!
我有以下内容:
<div id="view">
<div id="navbar">
Placeholder Text
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想在'navbar'中设置文本样式.但是,在样式表中名为"navbar"的文档中还有另一个div?
我以为它是这样的:
#view#navbar {
font-style: normal;
...etc
}
Run Code Online (Sandbox Code Playgroud)
但那没用.
思考?
任何人都可以用一种建议的方法来指导我测试通过公共方法修改的类中的私有字段.我已经阅读了很多人的意见,建议不建议测试私有成员,因为它们是实现的内部,但是这种情况似乎与大多数其他答案不同.
我正在考虑使私有字段受到保护并创建一个公开该字段的测试子类,但如果我无法修改该类的内部,该怎么办?
在下面的示例代码中,要测试的私有成员将是_values,它是一个只写集合,通过AddValue()接收新值.
public class Sample
{
private Dictionary<string, string> _values;
private DateTime _created;
public Sample()
{
_values = new Dictionary<string, string>();
_created = DateTime.Now;
}
public void AddValue(string key, string value)
{
_values.Add(key, value);
}
}
Run Code Online (Sandbox Code Playgroud) 我在Postgres中有一张桌子,上面满是文章。文章具有与之相关联的url标记,用于显示它们,example.com/pretty_name而不是example.com\2343。
不幸的是,当我刚开始的时候,我对URL实施了唯一的约束,但是却忽略了对大小写不敏感的限制,因此我想纠正这个错误,并开始要求URL不区分大小写。
作为第一步,我需要修复数据库中已经存在的所有重复URL。如何在不区分大小写的基础上在表中搜索具有重复url的行,并保留原样的行,而对于其余重复项,在末尾附加类似“ _2”的内容?
这特别棘手,因为我不是100%肯定没有重复重复的网址。即,我可能在一个URL上有3个重复项,在理想情况下,我希望第一个为URL,pretty_name第二个为URL,pretty_name_2第三个为URL pretty_name_3。
我有这个简单的脚本:
$(document).ready(function(){
var $yoyo = window.location.hash;
alert($yoyo);
});
Run Code Online (Sandbox Code Playgroud)
但我需要摆脱#符号,因为我将使用变量来定位div ID.我尝试过使用.remove('#'),但这似乎不起作用.
提前谢谢了!
java ×2
.net ×1
android ×1
audio ×1
automation ×1
c# ×1
capistrano ×1
cron ×1
css ×1
duplicates ×1
gesture ×1
ggplot2 ×1
html ×1
jquery ×1
postgresql ×1
powerpoint ×1
r ×1
surfaceview ×1
unique ×1
unit-testing ×1
vsto ×1