小编Pie*_*rre的帖子

CSS:如何强制将长字符串(没有任何空白)强制包装在XUL和/或HTML中

我有一个长串(DNA序列).它不包含任何空格字符.例如:

ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCGATGATGCTGACGATGCTACGATGCGAGCATCTACGATCAGTCGATGTAGCTAGTAGCATGTAGTGA
Run Code Online (Sandbox Code Playgroud)

什么是css选择器强制将此文本包装在html:textarea或xul:textbox中

html css string xul word-wrap

183
推荐指数
8
解决办法
14万
查看次数

在Java中捕获Ctrl + C.

是否有可能在java命令行应用程序中捕获Ctrl+ C信号?我想在终止程序之前清理一些资源.

java command-line control-c

73
推荐指数
3
解决办法
6万
查看次数

你可以在R中传递参考吗?

你能用"R"通过参考吗?例如,在以下代码中:

setClass("MyClass",
    representation(
    name="character"
    ))


instance1 <-new("MyClass",name="Hello1")
instance2 <-new("MyClass",name="Hello2")

array = c(instance1,instance2)

instance1
array

instance1@name="World!"

instance1
array
Run Code Online (Sandbox Code Playgroud)

输出是

> instance1
An object of class “MyClass”
Slot "name":
[1] "World!"

> array
[[1]]
An object of class “MyClass”
Slot "name":
[1] "Hello1"


[[2]]
An object of class “MyClass”
Slot "name":
[1] "Hello2"
Run Code Online (Sandbox Code Playgroud)

但我希望如此

> instance1
An object of class “MyClass”
Slot "name":
[1] "World!"

> array
[[1]]
An object of class “MyClass”
Slot "name":
[1] "World!"


[[2]]
An object of class …
Run Code Online (Sandbox Code Playgroud)

oop r parameter-passing pass-by-reference

66
推荐指数
5
解决办法
5万
查看次数

Java/ImageIO获取图像尺寸而不读取整个文件?

有没有办法在不读取整个文件的情况下获取图像的尺寸?

URL url=new URL(<BIG_IMAGE_URL>);
BufferedImage img=ImageIO.read(url);
System.out.println(img.getWidth()+" "+img.getHeight());
img=null;
Run Code Online (Sandbox Code Playgroud)

java image dimensions javax.imageio

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

关闭java.util.Iterator

我已经 使用应该使用方法在最后发布的资源实现了自定义java.util.Iteratorclose().该资源可以是java.sql.ResultSet,java.io.InputStream等...

public interface CloseableIterator<T> extends Iterator<T>
  {
  public void close();
  }
Run Code Online (Sandbox Code Playgroud)

使用此迭代器的某些外部库可能不知道必须关闭它.例如:

public boolean isEmpty(Iterable<T> myiterable)
 {
 return myiterable.iterator().hasNext();
 }
Run Code Online (Sandbox Code Playgroud)

在那种情况下,有没有办法关闭这个迭代器?

更新:非常感谢您当前的答案.我会给每个人一个(+1).当hasNext()返回false 时,我已经关闭了Iterator .我的问题是当循环迭代最后一次迭代之前中断时,如我的例子中所示.

java resources iterator

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

在创建顶层目标时告诉'make'忽略依赖关系

我正在运行以下类型的管道:

digestA: hugefileB hugefileC
    cat $^ > $@
    rm $^

hugefileB:
    touch $@

hugefileC:
    touch $@
Run Code Online (Sandbox Code Playgroud)

目标hugefileBhugefileC非常大,需要很长时间才能计算(并需要Make的强大功能).但是一旦创建了digestA,就不需要保留它的依赖关系:它会删除这些依赖关系以释放磁盘空间.

现在,如果我再次调用'make',将重建hugefileBhugefileC,而digestA已经可以了.

有没有办法告诉'make'避免重新编译依赖项?

注意:我不想在'digestA'的规则中构建两个依赖项.

makefile gnu-make

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

xjc:两个声明在ObjectFactory类中导致冲突

运行以下xjc命令会引发错误:

$ xjc "ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd"
parsing a schema...
compiling a schema...
[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 340 of ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd

[ERROR] (Related to above error) This is the other declaration.   
  line 475 of ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd
Run Code Online (Sandbox Code Playgroud)

虽然我理解JAXB绑定以及XJC中的冲突是什么,但我不明白当前模式中的冲突在哪里.

我应该怎么解决这个问题?

谢谢,

皮埃尔

更新:这里是错误的上下文:

$ curl -s "ftp://ftp.ncbi.nih.gov/bioproject/Schema/Core.xsd" | sed 's/^[ \t]*//' | cat -n | egrep -w -A 10 -B 10 '(340|475)' 
   330  <xs:element maxOccurs="1" name="Description"
   331  type="xs:string" minOccurs="0">
   332  <xs:annotation>
   333  <xs:documentation>
   334  Optionally provide description especially …
Run Code Online (Sandbox Code Playgroud)

java schema binding xsd xjc

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

我为什么要使用EMF?

我已经阅读了一些 关于EMF的教程,我仍然想知道为什么要使用它.

到目前为止,我正在从XSD架构+ JXC生成我的POJO ,或者手动生成.

据我所知,EMF定义类之间的一些复杂关系(一对多等等)会很有用.但这就是全部吗?使用EMF生成代码不是更复杂吗?它不会添加一些额外的依赖吗?

java xsd eclipse-emf

17
推荐指数
2
解决办法
5948
查看次数

维基百科API +跨域请求

我正在尝试使用javascript + CORS访问维基百科

据我所知,维基百科应该支持CORS:http://www.mediawiki.org/wiki/API :Cross-site_requests

我尝试了以下脚本:创建XMLHttpRequest + credential/XDomainRequest,添加一些Http-Headers("Access-Control-Allow-Credentials",...)并发送查询.

http://jsfiddle.net/lindenb/Vr7RS/

var WikipediaCORS=
    {
    setMessage:function(msg)
        {
        var span=document.getElementById("id1");
        span.appendChild(document.createTextNode(msg));
        },
    // Create the XHR object.
    createCORSRequest:function(url)
        {
        var xhr = new XMLHttpRequest();


        if ("withCredentials" in xhr)
            {
            xhr.open("GET", url, true);
            }
        else if (typeof XDomainRequest != "undefined")
            {
            xhr = new XDomainRequest();
            xhr.open(method, url);
            }
        else
            {
            return null;
            }
        xhr.setRequestHeader("Access-Control-Allow-Credentials", "true");
        xhr.setRequestHeader("Access-Control-Allow-Origin","*");
        return xhr;
        },
    init:function()
        {
        var _this=this;
        var url = 'http://en.wikipedia.org/w/api.php?action=opensearch&search=Javascript&format=json';
        var xhr = this.createCORSRequest(url); …
Run Code Online (Sandbox Code Playgroud)

javascript wikipedia-api cors

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

从JSON文档生成AVRO模式

是否有任何工具能够从"典型的"JSON文档创建AVRO模式.

例如:

{
"records":[{"name":"X1","age":2},{"name":"X2","age":4}]
}
Run Code Online (Sandbox Code Playgroud)

我找到了http://jsonschema.net/reboot/#/,它生成了一个' json-schema '

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://jsonschema.net#",
  "type": "object",
  "required": false,
  "properties": {
    "records": {
      "id": "#records",
      "type": "array",
      "required": false,
      "items": {
        "id": "#1",
        "type": "object",
        "required": false,
        "properties": {
          "name": {
            "id": "#name",
            "type": "string",
            "required": false
          },
          "age": {
            "id": "#age",
            "type": "integer",
            "required": false
          }
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但我想要一个AVRO版本.

schema json generator avro

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