小编kan*_*rbk的帖子

在文档中添加新元素后,Jquery显示无法正常工作

我正在使用Ajax/Request将元素加载到div容器中.默认情况下我隐藏了一个输入框.如果用户单击该div上的编辑图标,我想显示输入框.这是我的代码:

HTML代码

    <div class='container'>
      <input type = 'text' onkeydown='saveFn(event,this)' name = 'editemail' class = 'editemail' style='display:none;     height:20px;' />
    </div>
Run Code Online (Sandbox Code Playgroud)

JS代码

 $(".container").click(function(){
      console.log($(this).find(".editemail").show()); //Note it works fine If i didn't load any new elements into the div.
 });
Run Code Online (Sandbox Code Playgroud)

控制台日志输出在将新元素加载到容器之前.

   <input type="text" onkeydown="saveFn(event,this)" name="editemail" class="editemail" style="height: 20px; " value="hyther@zohocorp.com" title="press enter to save">
Run Code Online (Sandbox Code Playgroud)

将元素加载到容器后的控制台日志输出.

<input type="text" onkeydown="saveFn(event,this)" name="editemail" class="editemail" style="height: 20px; display: none; " value="saravanan@zohocorp.com" title="press enter to save">
Run Code Online (Sandbox Code Playgroud)

尽管我也试图从这个元素中删除"style"属性并添加一个新的样式元素,但它仍然无效.

javascript jquery javascript-events

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

具有连接池支持的Golang Cassandra客户端

我们正在使用gocqlhttps://github.com/gocql/gocql)驱动程序从我们的golang服务器连接到Cassandra。对于每个http请求,我们将创建一个新会话并将行插入cassandra中。我们认为为每个请求创建会话都非常耗费资源。

典型代码

func NewSession() (*gocql.Session, error) {
    config := NewClusterConfig()
    if config == nil {
        return nil, &CassandraError{"Oops! Cluster initialization failed."}
    }
    return config.CreateSession()
}
Run Code Online (Sandbox Code Playgroud)

有没有办法在gocqlgolang或任何其他cassandra驱动程序中合并连接?

go cassandra datastax gocql

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

Linux ssh无密码登录不起作用?

bharathi-1397@bharathi-1397:~$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/local/bharathi-1397/.ssh/id_rsa): 
/home/local/bharathi-1397/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/local/bharathi-1397/.ssh/id_rsa.
Your public key has been saved in /home/local/bharathi-1397/.ssh/id_rsa.pub.
The key fingerprint is:
de:e3:e5:f6:a3:8e:83:76:f0:7d:d6:e1:b3:d6:cc:93 bharathi-1397@bharathi-1397
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|                 |
|        S        |
|       ...     . |
|        .+o.. .++|
| …
Run Code Online (Sandbox Code Playgroud)

linux ssh

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

使用Integer.MAX_VALUE条目创建ArrayBlockingQueue时出现OutOfmemory错误

我一直在使用LinkedBlockingQueue,最近ArrayBlockingQueue由于插入性能缓慢而改变了这一点.之后我获得了显着的性能提升.但是,我的代码有时会抛出一个内存不足的错误:

我的Java代码

ArrayBlockingQueue<String> s = new ArrayBlockingQueue<String>(Integer.MAX_VALUE);
Run Code Online (Sandbox Code Playgroud)

我查看了ArrayBlockingQueue源代码.真的,我感到震惊 - 它object[]为给定的初始容量分配了一个.这是内存不足错误的原因.

ArrayBlockingQueue源代码

public ArrayBlockingQueue(int capacity, boolean fair) {
    if (capacity <= 0)
        throw new IllegalArgumentException();
    this.items = (E[]) new Object[capacity];
    lock = new ReentrantLock(fair);
    notEmpty = lock.newCondition();
    notFull =  lock.newCondition();
}
Run Code Online (Sandbox Code Playgroud)

这不会猜测初始容量或创建具有最小容量的队列.因为它会在高峰时间和正常时间变化.如果我提供最小容量,队列将在高峰时段立即填写.如果我给出最大容量,我会得到一个内存不足的错误,我不想在插入元素之前分配一个对象[].

请建议任何替代方案.

java collections performance memory-management capacity

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

乘法奇怪的输出

long thirtyDayInMillis = 30 * 24 * 60 * 60 * 1000;
Run Code Online (Sandbox Code Playgroud)

它应该返回,2592000000但它返回-1702967296.

但是,如果我将声明分成两个陈述.

long dayInMillis = 24 * 60 * 60 * 1000;
long thirtyDayInMillis = 30 * dayInMillis;
Run Code Online (Sandbox Code Playgroud)

它返回正确的值.

为什么它返回-170296729630 * 24 * 60 * 60 * 1000

java

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

Java Calendar API的输出错误

Calendar.setTimeInMillis 并且Calendar.getTime 工作很奇怪.它返回错误的日期结果.

Java代码

public static void main(String[] args)
{
    Calendar cal = Calendar.getInstance();
    final int oneDay = 24 * 60 * 60 * 1000;

    for(int i=0; i < 30; i++) {
        cal.setTimeInMillis(System.currentTimeMillis() - i * oneDay);
        System.out.println(cal.getTime());
    }

}
Run Code Online (Sandbox Code Playgroud)

产量

Tue Jun 24 17:50:35 IST 2014
Mon Jun 23 17:50:35 IST 2014
Sun Jun 22 17:50:35 IST 2014
Sat Jun 21 17:50:35 IST 2014
Fri Jun 20 17:50:35 IST 2014
Thu Jun 19 17:50:35 IST 2014
Wed Jun …
Run Code Online (Sandbox Code Playgroud)

java calendar

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

Java与JavaScript变量范围

在以下Java代码段中,范围i仅限于for循环内部.这就是它导致错误的原因.但是,在类似的JS片段中,i显然可以在循环外部访问.怎么可能?

Java的:

for(int i=0;i<10;i++) {
    ...
}
System.out.println(i);
Run Code Online (Sandbox Code Playgroud)

输出:"我没有定义"

JS:

for(var i=0;i<10;i++) { 
    ...
}
console.log(i);
Run Code Online (Sandbox Code Playgroud)

产量:10

我没想到会看到JS的输出.我想知道JS与Java的不同之处.JavaScript变量范围如何工作?

javascript java scope

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