亲爱的,
我的系统有以下分发细节
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 5.0 (lenny)
Release: 5.0
Codename: lenny
Run Code Online (Sandbox Code Playgroud)
我需要在这台机器上安装postgres 9.0,但我找不到postgres 9.0的任何稳定的lenny包,有没有其他方法可以做
任何建议将不胜感激!
什么是Java Web应用程序的最佳托管?亚马逊Ec2 - 价格昂贵(每个小实例每月大约60美元)谷歌应用程序 - 持久性不灵活,不完全支持JDK
鉴于:
case class Foo(a: Int, b: String, c: Double)
Run Code Online (Sandbox Code Playgroud)
你可以说:
val params = Foo(1, "bar", 3.14).productIterator.toList
Run Code Online (Sandbox Code Playgroud)
得到:
params: List[Any] = List(1, bar, 3.14)
Run Code Online (Sandbox Code Playgroud)
有没有办法"向后"并直接从此列表重新创建Foo对象,即:
Foo.createFromList(params) // hypothetical
Run Code Online (Sandbox Code Playgroud)
而不是写:
Foo(params(0).asInstanceOf[Int], params(1).asInstanceOf[String], params(2).asInstanceOf[Double])
Run Code Online (Sandbox Code Playgroud)
编辑:似乎它归结为能够将列表的元素作为参数发送到函数而不显式写出来,例如:
def bar(a: Int, b: Int, c: Int) = //...
val list = List(1, 2, 3, 4, 5)
bar(list.take(3)) // hypothetical, instead of:
bar(list(0), list(1), list(2))
Run Code Online (Sandbox Code Playgroud)
我希望能做到:
bar(list.take(3): _*)
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.
编辑:解决方案基于extempore的答案,但直接调用构造函数而不是使用apply方法:
case class Foo(a: Int = 0, b: String = "bar", c: Double = 3.14) {
val cs = …Run Code Online (Sandbox Code Playgroud) 我想启用触摸listView行时出现的橙色突出显示.
如果onclick事件是从行本身生成的,我可以通过设置listview的样式来调整hightlight.但是在我的情况下,click事件是由下面的TextView生成的,附带onclick事件.
触摸事件发生时,Listview不知道发生了点击.它没有收到重点或压力事件.
我可以像Flex一样使用冒泡或捕捉技术吗?或任何建议/解决方案?
非常感谢你.
我一直在使用哈希在页面之间传递数据(比如设置scrollTop()等),并且还使用hashChange事件来触发给定页面上的更改.
但是,哈希具有我不一定感兴趣的默认行为,例如使页面跳转到给定(有时无关紧要)的位置.
我觉得获取/设置查询字符串会更合乎逻辑,但是:
是吗?
设置查询字符串时是否有可以监听的事件?
我应该知道与查询字符串相关的行为吗?
我在uni中使用c(或多或少是第一次)工作,我需要从字符数组生成MD5。该分配指定这必须通过创建管道并md5在系统上执行命令来完成。
我已经走到这一步了:
FILE *in;
extern FILE * popen();
char buff[512];
/* popen creates a pipe so we can read the output
* of the program we are invoking */
char command[260] = "md5 ";
strcat(command, (char*) file->name);
if (!(in = popen(command, "r"))) {
printf("ERROR: failed to open pipe\n");
end(EXIT_FAILURE);
}
Run Code Online (Sandbox Code Playgroud)
现在这工作得很好(对于作业的另一部分,需要获取文件的 MD5),但我无法弄清楚如何将字符串通过管道传输到其中。
如果我理解正确的话,我需要做类似的事情:
FILE * file = popen("/bin/cat", "w");
fwrite("hello", 5, file);
pclose(file);
Run Code Online (Sandbox Code Playgroud)
我认为,它将执行 cat,并通过 StdIn 将“hello”传递给它。这是正确的吗?
有没有办法填充某些形式的所有输入?比方说,有些事情是这样的:
<form id="unique00">
<input type="text" name="whatever" id="whatever" value="whatever" />
<div>
<input type="checkbox" name="whatever" id="whatever" value="whatever" />
</div>
<table><tr><td>
<input type="hidden" name="whatever" id="whatever" value="whatever" />
<input type="submit" value="qweqsac" />
</td></tr></table>
</form>
<form id="unique01">
<div>
<input type="text" name="whatever" id="whatever" value="whatever" />
<input type="checkbox" name="whatever" id="whatever" value="whatever" />
</div>
<table><tr><td>
<input type="hidden" name="whatever" id="whatever" value="whatever" />
</td></tr></table>
<select>blah...</select>
<input type="submit" value="qweqsac" />
</form>
etc forms... forms...
Run Code Online (Sandbox Code Playgroud)
*注意:每个表单可能有不同的输入和类型,也有不同的html结构
那么有没有办法填充某些表单ID的输入?例如,如果我单击某个表单ID的提交按钮,那么jquery将为我填充那些表单id中的所有输入.目前我正在做的是这样的:
$("form").submit(function(){ return validateForm($(this)) });
function validateForm(form){
var retVal = true;
var re;
$.each(form.serializeArray(), function(i, field) …Run Code Online (Sandbox Code Playgroud) 我想标题并没有真正说明,所以这里是解释.
我有一个父类,我想要保存一个事件Action,其中T是子类继承它的类型.
例如:
abstract class ActiveRecord
{
protected event Action<T> NewItem;
}
class UserRecord : ActiveRecord
{
public UserRecord()
{
NewItem += OnNewItem; // NewItem would in this case be Action<UserRecord>
}
private void OnNewItem(UserRecord obj)
{
// Flush cache of all users, since there's a new user in the DB.
}
}
Run Code Online (Sandbox Code Playgroud)
所以问题是,以上是否可能,以及在Parent类中我将使用什么?
请注意,我不希望我的父类有一个泛型参数,因为它真的看起来很愚蠢,因而妨碍了可读性.
class UserRecord : ActiveRecord<UserRecord>
Run Code Online (Sandbox Code Playgroud)
我正在研究基于继承的ORM,以防你想知道它是什么.只要ORM将数据插入数据库,就会引发NewItem事件.
编辑:尝试通过正确命名类来更好地阐明.
ActiveRecord类驻留在一个单独的程序集中,UserRecord驻留在我正在处理的Web项目中.(注意:我是两个部分的开发者,但它是两个独立的项目)
我希望能够在成功插入行,删除行等时引发事件.事件应该将有问题的记录作为参数传递给事件处理程序,因此需要Action.
但是,当我在基类(ActiveRecord)中声明这些事件时,我需要一些方法将CHILD类型传递给事件处理程序,以获得强类型对象.
我可以,当然去动作,然后做一个类型转换在我的实现,但真的不会是非常好的:-(
希望这能解决一下这个问题,否则请问:-)
编辑2:只是想让你知道反射,动态方法或类似的东西是一个选项,如果这有帮助.但是我怀疑这个特殊情况:-(
我在浏览器检测脚本中遇到了这种独特的做法.
if (/MSIE/.test(_3)) {
IE = true;
} else {
if (/AppleWebKit/.test(_3)) {
Safari = true;
} else {
if (/Opera/.test(_3)) {
Opera = true;
} else {
if (/Camino/.test(_3)) {
Camino = true;
} else {
if (/Firefox/.test(_3) || /Netscape/.test(_3) || ) {
Mozilla = true;
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用这种嵌套的If/Else方法有什么好处吗?
如果我将其更改为:
if (){
} else if (){
} else if (){
} else if (){
}
Run Code Online (Sandbox Code Playgroud)
它会运行得慢还是什么?
javascript language-agnostic performance conditional-statements
在我的应用程序中,我查询其intent-filters中具有特定类别的服务列表.这很好,我得到一个包含ResolveInfo对象的List.在这些ResolveInfos中,我找到了"serviceInfo"字段,该字段应该描述找到的服务的详细信息.
现在我如何从serviceInfo构造一个Intent,它可以启动找到的服务?
我的代码现在是这样的:
PackageManager pm = getApplicationContext().getPackageManager();
Intent i = new Intent();
i.setAction("<my custom action>");
i.addCategory("<my custom category>");
List<ResolveInfo> l = pm.queryIntentServices(i, 0);
gatherAgentNum = l.size();
if(gatherAgentNum > 0){
for(ResolveInfo info : l){
Intent i2 = new Intent(this, info.serviceInfo.getClass());
i2.putExtra(BaseAgent.KEY_RESULT_RECEIVER, new GatherResult(mHandler));
startService(i2);
}
}
Run Code Online (Sandbox Code Playgroud)
这显然是错误的,"info.serviceInfo.getClass()"只返回serviceInfo对象的类.任何人都可以帮我这个吗?
谢谢
编辑:解决方案(至少我使用的那个):
PackageManager pm = getApplicationContext().getPackageManager();
Intent i = new Intent();
i.setAction("<my action>");
i.addCategory("<my category>");
List<ResolveInfo> l = pm.queryIntentServices(i, 0);
if(l.size() > 0){
for(ResolveInfo info : l){
ServiceInfo servInfo = info.serviceInfo;
ComponentName name = …Run Code Online (Sandbox Code Playgroud) javascript ×3
android ×2
c ×1
c# ×1
debian ×1
events ×1
generics ×1
highlighting ×1
hosting ×1
html ×1
java ×1
jquery ×1
listview ×1
md5 ×1
onclick ×1
performance ×1
popen ×1
postgresql ×1
query-string ×1
scala ×1
service ×1
unix ×1
web-hosting ×1