我有两个arrayLists,我试图从另一个"减去"一个arrayList.例如,如果我有一个arrayList [1,2,3]并且我试图减去[0,2,4],则得到的arrayList应该是[1,3].
List<Integer> a = new ArrayList<>(Arrays.asList(1, 2, 3));
List<Integer> b = Arrays.asList(0, 2, 4);
subtract(a,b) // should return [1,3]
Run Code Online (Sandbox Code Playgroud)
这是我的代码.
//returns a new IntSet after subtracting a from b
// .minus().toString()
ArrayList<Integer> minusArray = new ArrayList<Integer>();
minusArray.addAll(array1);
for(int i =0; i< minusArray.size(); i++){
for(int j = 0; j < array2.size(); j++){
if(minusArray.get(i).equals(array2.get(j))){
minusArray.remove(i);
if(i == 0){
;
}
else if(j == 0){
;
}
else{
i = 0;
j = 0;
}
}
else{}
}
}
return minusArray;
Run Code Online (Sandbox Code Playgroud)
我的代码在某些情况下有效,比如if …
我的总体目标是安装一个自托管的 gitlab-runner,该运行程序仅限于使用我自己的 docker 注册表中准备好的 docker 镜像。
为此,我有一个 system.d 配置,如下所示:
/etc/systemd/system/docker.service.d/allow-private-registry-only.conf
BLOCK_REGISTRY='--block-registry=all'
ADD_REGISTRY='--add-registry=my.private.registry:8080'
Run Code Online (Sandbox Code Playgroud)
这样,docker pull就只允许从中提取图像my.private.registry/。
在我设法使其工作后,我想清理我的本地注册表并删除旧的docker images. 正是在这个过程中,我偶然发现了一个名为 docker 镜像,该镜像可能是gitlab-runnergitlab/gitlab-runner-helper本身使用的某个组件,并且可能是从.docker.io
docker.io现在我想知道使用gitlab-runner时是否可能/建议阻止图像?
任何提示表示赞赏!
是什么git request-pull,它是如何比较制作pull request,例如在GitHub上?
1.它应该如何使用?
2.可以代替pull request吗(比如在github上)?
3.使用它有什么好处?
我正在使用curl 命令行工具。我做类似的事情
curl -XPUT "https://example.org?p1=value1&p2=value2" -H"Content-Type:application/x-www-form-urlencoded"
服务器回复
HTTP/1.1 411 Length Required
解决方案通常是设置适当的Content-Length标头。
但是这种情况下的 Content-Length 是多少以及如何使用curl 设置它?
我有一个简单的RDF文件,并希望将其转换为漂亮的嵌套JSON.
:b0 a <http://schema.org/Book> ;
<http://schema.org/name> "Semantic Web Primer (First Edition)" ;
<http://schema.org/offers> _:b1 ;
<http://schema.org/publisher> "Linked Data Tools" .
_:b1 a <http://schema.org/Offer> ;
<http://schema.org/price> "2.95" ;
<http://schema.org/priceCurrency> "USD" .
Run Code Online (Sandbox Code Playgroud)
应该成为
{
"type" : "Book",
"name" : "Semantic Web Primer (First Edition)",
"offers" : {
"type" : "Offer",
"price" : "2.95",
"priceCurrency" : "USD"
},
"publisher" : "Linked Data Tools"
}
Run Code Online (Sandbox Code Playgroud) 我有以下示例 Turtle 文档:
@prefix dct: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix example: <http://example.com/vocabulary/> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
<http://example.com/datasets/1>
a dcat:Distribution ;
example:props [ example:prop1 "hello" ;
example:prop2 "1"
] ;
dct:description "test data" .
Run Code Online (Sandbox Code Playgroud)
我使用 Apache Jena(带有 JSONLD_COMPACT_PRETTY 的 RDFDataMgr)将它转换为 JSON-LD 到 JSON-LD:
{
"@context": {
"dct": "http://purl.org/dc/terms/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"dcat": "http://www.w3.org/ns/dcat#",
"example": "http://example.com/vocabulary/"
},
"@graph": [
{
"@id": "_:b0",
"example:prop1": "hello",
"example:prop2": "1"
},
{
"@id": "http://example.com/datasets/1",
"@type": "dcat:Distribution",
"example:props": {
"@id": "_:b0"
},
"dct:description": "test data" …Run Code Online (Sandbox Code Playgroud) 如果我在 vscode 编辑器中输入以下文本:
http://stackoverflow.com/[Link to Stackoverflow]
omg[
Run Code Online (Sandbox Code Playgroud)
我得到这个结果:
https://stackoverflow.com[/Link to Stackoverflo]w
om[g
Run Code Online (Sandbox Code Playgroud)
我观察到,只要我按下german+layout+keyboardAltGr上的 ,光标就会向后移动。
有没有一种方法可以使用StAX和JAX-B创建索引,然后快速访问XML文件?
我有一个很大的XML文件,需要在其中查找信息。这是在桌面应用程序中使用的,因此它应在具有少量RAM的系统上工作。
所以我的想法是这样的:创建索引,然后快速从大文件访问数据。
我不能只分割文件,因为它是我想不更改地使用的官方联邦数据库。
使用XMLStreamReader,我可以快速找到一些元素,然后使用JAXB解组该元素。
final XMLStreamReader r = xf.createXMLStreamReader(filename, new FileInputStream(filename));
final JAXBContext ucontext = JAXBContext.newInstance(Foo.class);
final Unmarshaller unmarshaller = ucontext.createUnmarshaller();
r.nextTag();
while (r.hasNext()) {
final int eventType = r.next();
if (eventType == XMLStreamConstants.START_ELEMENT && r.getLocalName().equals("foo")
&& Long.parseLong(r.getAttributeValue(null, "bla")) == bla
) {
// JAX-B works just fine:
final JAXBElement<Foo> foo = unmarshaller.unmarshal(r,Foo.class);
System.out.println(foo.getValue().getName());
// But how do I get the offset?
// cache.put(r.getAttributeValue(null, "id"), r.getCursor()); // ???
break;
}
}
Run Code Online (Sandbox Code Playgroud)
但是我无法得到补偿。我想用它来准备一个索引:
(id of element) -> (offset in file) …