小编kbe*_*bec的帖子

将长条件表达式拆分为行

我有一些if语句,如:

def is_valid(self):
    if (self.expires is None or datetime.now() < self.expires)
    and (self.remains is None or self.remains > 0):
        return True
    return False
Run Code Online (Sandbox Code Playgroud)

当我输入这个表达式时,我的Vim会自动移动and到新行,并使用与行相同的缩进if.我尝试更多缩进组合,但验证总是说这是无效的语法.如何构建多长的if?

python if-statement python-2.6

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

如何导入和使用com.sun.jdi.VirtualMachine

我找到了一些专门用于在VirtualMachine中进行调试的com.sun.jdi类,但我不能使用它,因为Sun JDK7中似乎不存在包.

如何使用这个包?

BTW.lib/sa-jdi.jar是不是我想要的

java jdi java-7

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

如何动态加载AttachProvider(attach.dll)

我正在使用com.sun.tools.attachjdk tools.jar,它需要一个指定的java.library.pathenv指向attach.dll启动时正确实例化提供程序,如WindowsAttachProvider.出于某些原因,我需要动态加载捆绑的一个attach.dll.我试着用这样的东西:

public static void main(String[] args) throws Exception {
    Path bin = Paths.get(System.getProperty("user.dir"),"bin").toAbsolutePath();
    switch (System.getProperty("os.arch")) {
        case "amd64":
            bin = bin.resolve("win64");
            break;
        default:
            bin = bin.resolve("win32");
    }
    // Dynamic setting of java.library.path only seems not sufficient
    System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + bin.toString());
    // So I try to manual loading attach.dll. This is not sufficient too.
    System.load(bin.resolve("attach.dll").toString());
    // I'm using com.sun.tools.attach in my app
    new myApp();
}
Run Code Online (Sandbox Code Playgroud)

如果我用jdk(在normall jre中)运行它,它会向我报告: …

java dll

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

JBoss中枚举的每个NetworkInterface总是isUp

我写了以下EJB:

@Singleton
@LocalBean
@Startup
public class Starter {
    private static final Logger logger = Logger.getLogger("lab");

    @PostConstruct
    public void init() throws Exception {
        for (final Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
            final NetworkInterface iface = en.nextElement();
            if (iface.isUp()) {
                logger.info(iface);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在部署时,此日志如下:

name:lo (Software Loopback Interface 1)
name:net0 (WAN Miniport (SSTP))
name:net1 (WAN Miniport (L2TP))
name:net2 (WAN Miniport (PPTP))
name:ppp0 (WAN Miniport (PPPOE))
name:eth0 (WAN Miniport (IPv6))
name:eth1 (WAN Miniport (Network Monitor))
name:eth2 (WAN Miniport (IP))
name:net5 …
Run Code Online (Sandbox Code Playgroud)

java java-ee jboss7.x

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

HTML5 JavaScript在Chrome中粘贴图像数据

如何使用此插件开发一个工作示例:HTML5 JavaScript在Chrome中粘贴图像数据

作者提出了一个很好的例子,看起来它符合我们的目的.我不熟悉创建一个jQuery插件.

目标是使用此插件将剪贴板图像粘贴到富文本编辑器(如TinyMCE)中.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PASTE IMAGE</title>

<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript">

// Created by STRd6
// MIT License
// jquery.paste_image_reader.js
(function($) {
var defaults;

  $.event.fix = (function(originalFix) {
    return function(event) {
      event = originalFix.apply(this, arguments);
     if (event.type.indexOf('copy') === 0 || event.type.indexOf('paste') === 0) {
        event.clipboardData = event.originalEvent.clipboardData;
     }
  return event;
};
})($.event.fix);

defaults = {
  callback: $.noop,
  matchType: /image.*/
};

$.fn.pasteImageReader = function(options) {
if (typeof options === "function") { …
Run Code Online (Sandbox Code Playgroud)

jquery html5 tinymce coffeescript

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

如何从href值获取确定的URL?

我有一些与各种hrefs的链接,并希望得到这个值的确定网址,如:

http://localhost/   -> http://localhost/
localhost           -> http://mysite.example/localhost
firstpage           -> http://mysite.example/firstpage
/anotherpage        -> http://mysite.example/anotherpage
#anchor1            -> http://mysite.example/currentpage#anchor1
/#anchor2           -> http://mysite.example/#anchor2
Run Code Online (Sandbox Code Playgroud)

顺便说一下,我不想要点击处理代码.我能做到.

javascript jquery url-routing

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