小编Ant*_*nio的帖子

PhoneGap + iOS防止默认滚动操作从输入文本字段开始

我遇到了以下问题:

我有一个滚动区域,其中包含输入文本字段列表.

我用

ontouchmove = function(e){ e. preventDefault(); } 
Run Code Online (Sandbox Code Playgroud)

防止页面的全局滚动.除了手势从输入字段开始的情况外,它工作正常.

首次触摸陷阱到输入字段时,如何防止页面的全局滚动?

谢谢.

iphone html5 webkit ios cordova

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

字符串的快速哈希

我有一组ASCII字符串,假设它们是文件路径。它们既可以很短也可以很长。

我正在寻找一种可以计算此类字符串的哈希的算法,该哈希也将是字符串,但具有固定的长度,例如youtube video id:

https://www.youtube.com/watch?v=-F-3E8pyjFo
                                ^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

MD5似乎是我所需要的,但是对我来说,拥有短的哈希字符串至关重要。

是否有可以执行此操作的shell命令或python库?

python algorithm bash hash hashids

5
推荐指数
2
解决办法
8260
查看次数

休眠:org.hibernate.AssertionFailure:com.xxx.Bean 条目中的空 ID

我面临以下错误:

com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract void com.xxx.Service.save(com.xxx.Bean)' threw an unexpected exception: org.hibernate.AssertionFailure: null id in com.xxx.Bean entry (don't flush the Session after an exception occurs)
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
Caused by: org.hibernate.AssertionFailure: null id in …
Run Code Online (Sandbox Code Playgroud)

java mysql hibernate mysql5 hibernate3

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

为什么Java磁盘I/O的执行速度比用C编写的等效I/O代码慢得多?

我有一个SSD磁盘,每个规格应提供不低于10k的IOPS.我的基准确认它可以给我20k IOPS.

然后我创建了这样一个测试:

private static final int sector = 4*1024;
private static byte[] buf = new byte[sector];
private static int duration = 10; // seconds to run
private static long[] timings = new long[50000];
public static final void main(String[] args) throws IOException {
    String filename = args[0];
    long size = Long.parseLong(args[1]);
    RandomAccessFile raf = new RandomAccessFile(filename, "r");
    Random rnd = new Random();
    long start = System.currentTimeMillis();
    int ios = 0;
    while (System.currentTimeMillis()-start<duration*1000) {
        long t1 = System.currentTimeMillis();
        long pos = …
Run Code Online (Sandbox Code Playgroud)

java io performance solid-state-drive java-8

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

在运行时更新GWT单元表

我试图在运行时更新单元格表,单元格表从列表中获取其日期

Cell_Table.setRowData(0,AllMessages);
Run Code Online (Sandbox Code Playgroud)

我正在尝试更新列表AllMessages然后执行此操作但Cell_Table.redraw();没有成功.

我正在尝试再次这样做 Cell_Table.setRowData(0,AllMessages);,但没有成功

当我使用相同的技术添加行时,一切都很好但是当我从列表中删除一些数据时,单元格表没有被更新!

gwt widget gwt2

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

JButton选择的方法不起作用

下面的代码是在选择3个按钮中的任何一个时更改背景颜色:红色,绿色或蓝色.当我选择其中任何一个时,实际上什么也没发生.但是,从JButtons更改为JRadioButtons或JToggleButtons确实有效.谁知道为什么?是因为JButton.isselected()方法被窃听并且它总是返回false?我感谢任何帮助......谢谢.

public class bgcolor2 extends JFrame
{
private static final int FRAME_WIDTH = 300;
private static final int FRAME_HEIGHT= 400;
private ActionListener listener;
private JButton greenbutton;
private JButton redbutton;
private JButton bluebutton;
private JPanel colorpanel;
private JPanel buttonpanel;

public bgcolor2()
{
    colorpanel = new JPanel();
    add(colorpanel,BorderLayout.CENTER);

    class bgcolorlistener implements ActionListener
    {
        public void actionPerformed(ActionEvent event)
        {
            changebgcolor();    
        }
    }
    listener=new bgcolorlistener();
    createbuttons();
    setSize(FRAME_WIDTH,FRAME_HEIGHT);
}

public void createbuttons()
{
    greenbutton = new JButton("Green");
    greenbutton.addActionListener(listener);
    bluebutton = new JButton("Blue");
    bluebutton.addActionListener(listener);
    redbutton = …
Run Code Online (Sandbox Code Playgroud)

java swing selection jbutton jtogglebutton

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

如何在Python中实现持久计数器

有没有办法让Python中的“最后一个已知”计数器在服务器重新启动后仍然存在?

我有一个按计划(由 cron)启动的 python 脚本。它读取具有预定义格式的文档 ID 的文件。我需要记住最后处理的文档 ID,以便忽略所有先前的文档 ID(如果有)。

python

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

GWT,Enum,RadioButton和Editors框架

这是问题:我有一个bean,这个bean有一个枚举属性:

enum E {
    ONE, TWO, THREE;
}

class A implements Serializable {
    public E foo;
}
Run Code Online (Sandbox Code Playgroud)

我想使用GWT Editor框架让用户编辑这个bean

public class P extends FlowPanel implements Editor<A> {
    // ... UiBinder code here ...
    @UiField RadioButton one, two, three;
    // ...
}
Run Code Online (Sandbox Code Playgroud)

我有一个错误:

[错误] [gwtmodule] - 在代理类型com.company.A中找不到路径1的getter

[错误] [gwtmodule] - 无法在代理类型com.company.A中找到路径二的getter

[错误] [gwtmodule] - 在代理类型com.company.A中找不到路径3的getter

有没有办法在GWT 2.2中完成这项工作?

java gwt gwt2

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

Java中的奇怪符号用Java表示

当我调用方法时NetworkInterface.getInetAddresses(),我得到以下字符串:

"fe80:0:0:0:f06c:31b8:cd17:5a44%5"
Run Code Online (Sandbox Code Playgroud)

我想知道这%5意味着什么?没有这个可能会有IPv6地址%5吗?

java network-programming ipv6

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

Hibernate映射找不到资源

我正在尝试编译我的项目,但编译器一直给出错误,他无法找到我的资源文件,所以他无法编译

    jul 23, 2013 1:29:24 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: src/main/resources/Movies.hbm.xml
Initial SessionFactory creation failed.org.hibernate.MappingNotFoundException: resource: src/main/resources/Movies.hbm.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.hp.videotheek.HibernateUtil.<clinit>(HibernateUtil.java:17)
    at com.hp.videotheek.App.main(App.java:12)
Caused by: org.hibernate.MappingNotFoundException: resource: src/main/resources/Movies.hbm.xml not found
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:738)
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2167)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2139)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2119)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2072)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1987)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1966)
    at com.hp.videotheek.HibernateUtil.<clinit>(HibernateUtil.java:13)
    ... 1 more
Run Code Online (Sandbox Code Playgroud)

hibernate.cfg.xml文件,在这里他找不到映射资源,但它位于正确的位置

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.url">jdbc:postgresql://localhost:5432/postgres</property>
        <property name="connection.driver_class">org.postgresql.Driver</property>
        <property name="connection.username">postgres</property> …
Run Code Online (Sandbox Code Playgroud)

eclipse mapping hibernate maven

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

Liferay:ActionRequest,RenderRequest和PortletRequest之间的关系和区别是什么?

什么是关系和区别ActionRequest,RenderRequestPortletRequest

我们可以从另一个获得一个实例吗?

portlet liferay liferay-6

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

Bash:将stdin复制到文件中

我有两个程序.第一个是客户端,第二个是服务器.他们使用stdin和stdout以文本格式交换数据.

我想在它们之间放置代理bash脚本并记录从stdin到文件的所有内容.

我尝试了以下代码,但/tmp/f-copy.txt为空

Proxy.sh:

exec 6<&0
exec 6>/tmp/f-copy.txt
server
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

bash stdin

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

如何在Python中修剪单词边界处的文本

我有以下文字:

敏捷的棕色狐狸跳过了懒狗

我只需要获得文本的12个第一个字符(只是为了使示例简单).前12个字符是"快速br".有没有办法在Python中剥离单词边界处的文本以摆脱"br"?

python text python-2.7

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