程序设计

专业和发烧友程序员的问答

8
如何使LinearLayout可滚动?
开始活动后,无法向下滚动以查看下面定义的xml中的其他按钮和选项。 有谁知道如何使它滚动? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:background="#000044" android:isScrollContainer="true" android:orientation="vertical"> <TextView android:id="@+id/title" android:text="@string/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff"/> <EditText android:id="@+id/editTitle" android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <TextView android:id="@+id/description" android:text="@string/description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff"/> <EditText android:id="@+id/editDescription" android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <TextView android:id="@+id/location" android:text="@string/location" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff"/> <EditText android:id="@+id/editLocation" android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <TextView android:id="@+id/startTime" android:text="@string/startTime" android:layout_width="wrap_content" android:layout_height="wrap_content" …
155 android 

15
从索引/类型删除所有文档,而不删除类型
我知道可以通过deleteByQuery从某种类型删除所有文档。 例: curl -XDELETE 'http://localhost:9200/twitter/tweet/_query' -d '{ "query" : { "term" : { "user" : "kimchy" } } }' 但是我没有术语,无论什么术语,我都只想删除该类型的所有文档。什么是实现这一目标的最佳实践?空项不起作用。 链接到deleteByQuery

7
如何使用Gradle构建源jar
我正在使用gradle构建的开源项目。我想生成一个(project)-sources.jar文件,可以将其加载到我的IDE(IntelliJ IDEA)中并通过该项目进行调试。我知道如何生成文件(如果可以生成的话)。 我浏览了该项目可用的gradle任务,但没有一个可以生成source jar文件。 为该项目生成源jar文件的最简单方法是什么? 将源添加到包含已编译的类文件的jar文件中也可以。
155 java  jar  gradle 

5
jQuery更改输入文本值
我找不到适合的选择器: <input maxlength="6" size="6" id="colorpickerField1" name="sitebg" value="#EEEEEE" type="text"> 我想将值更改为=000000。我需要选择器来查找“名称”而不是文本输入的ID。 这不行吗?: $("text.sitebg").val("000000"); 提出的解决方案不起作用,这是什么问题? $.getJSON("http://www.mysitehere.org/wp-content/themes/ctr-theme/update_genform.php",function(data) { $("#form1").append(data.sitebg); $('input.sitebg').val('000000'); }); JSON数据运行正常;想法是稍后将JSON值传递到表单输入文本值中。但是不起作用:(
155 jquery 


9
通过逻辑条件过滤data.frame行
我想data.frame根据逻辑条件从中过滤行。假设我有像 expr_value cell_type 1 5.345618 bj fibroblast 2 5.195871 bj fibroblast 3 5.247274 bj fibroblast 4 5.929771 hesc 5 5.873096 hesc 6 5.665857 hesc 7 6.791656 hips 8 7.133673 hips 9 7.574058 hips 10 7.208041 hips 11 7.402100 hips 12 7.167792 hips 13 7.156971 hips 14 7.197543 hips 15 7.035404 …
155 r  subset  dataframe 

6
不应该提交的Gradle配置(例如凭据)放在哪里?
我正在尝试将Gradle构建的工件部署到Maven存储库,并且需要为此指定凭据。现在可以正常工作: uploadArchives { repositories { mavenDeployer { repository(url: "http://.../nexus/content/repositories/snapshots/") { authentication(userName: "admin", password: "admin123") } } } } 但是我不喜欢将凭据存储在源代码管理中。使用Maven,我将定义服务器配置,并在中分配凭据~/.m2/settings.xml。如何使用Gradle做类似的事情?
155 gradle 



8
在Ruby中显式返回的好样式吗?
来自Python背景,在样式方面总是有“正确的方法”(“ Pythonic”的方法),我想知道Ruby是否也存在这种情况。我一直在使用自己的样式准则,但我正在考虑发布源代码,我希望它遵守可能存在的任何未编写规则。 明确输入return方法是“ Ruby之道” 吗?我见过有和没有,它都有,但是有正确的方法吗?也许有合适的时机吗?例如: def some_func(arg1, arg2, etc) # Do some stuff... return value # <-- Is the 'return' needed here? end

11
Java Runtime.getRuntime():从执行命令行程序获取输出
我正在使用运行时从Java程序运行命令提示符命令。但是,我不知道如何获得命令返回的输出。 这是我的代码: Runtime rt = Runtime.getRuntime(); String[] commands = {"system.exe", "-send" , argument}; Process proc = rt.exec(commands); 我尝试做,System.out.println(proc);但是没有返回任何东西。该命令的执行应返回两个数字,以分号分隔。我怎样才能在变量中打印出来? 这是我现在使用的代码: String[] commands = {"system.exe", "-get t"}; Process proc = rt.exec(commands); InputStream stdIn = proc.getInputStream(); InputStreamReader isr = new InputStreamReader(stdIn); BufferedReader br = new BufferedReader(isr); String line = null; System.out.println("<OUTPUT>"); while ((line …
155 java  runtime 

5
数组是否包含来自另一个数组的任何值?
测试数组是否包含第二个数组中的任何元素的最有效方法是什么? 下面的两个示例试图回答问题,但确实foods包含来自的任何元素cheeses: cheeses = %w(chedder stilton brie mozzarella feta haloumi reblochon) foods = %w(pizza feta foods bread biscuits yoghurt bacon) puts cheeses.collect{|c| foods.include?(c)}.include?(true) puts (cheeses - foods).size < cheeses.size
155 ruby  arrays 

5
Lookup <TKey,TElement>有什么意义?
MSDN这样解释查找: A Lookup&lt;TKey, TElement&gt; 类似于Dictionary&lt;TKey, TValue&gt;。区别在于 Dictionary &lt;TKey,TValue&gt;将键映射到单个值,而 Lookup &lt;TKey,TElement&gt;将键映射到值的集合。 我认为这种解释没有特别的帮助。查找的用途是什么?
155 c#  .net  linq  lookup 

10
什么是好的速率限制算法?
我可以使用一些伪代码,或者更好的Python。我正在尝试为Python IRC机器人实现一个限速队列,并且部分起作用,但是如果有人触发的消息少于限制(例如,限速为每8秒5条消息,而该人仅触发4条消息),并且下一个触发时间超过8秒(例如16秒后),机器人将发送消息,但队列已满,机器人将等待8秒,即使由于8秒钟的时间已过去也不需要它。

10
C ++中的dynamic_cast和static_cast
我dynamic_cast对C ++中的关键字非常困惑。 struct A { virtual void f() { } }; struct B : public A { }; struct C { }; void f () { A a; B b; A* ap = &amp;b; B* b1 = dynamic_cast&lt;B*&gt; (&amp;a); // NULL, because 'a' is not a 'B' B* b2 = …
155 c++  dynamic-cast 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.