小编dra*_*onx的帖子

构建docker容器时迭代的最佳方法是什么?

我正在尝试构建一些docker容器,我发现编辑Dockerfile的迭代过程,脚本在其中运行,笨重.我正在寻找最佳实践并了解其他人如何进行.

我的初始流程是:

  1. docker build -t mycontainer mycontainer
  2. docker run mycontainer
  3. docker exec -i -t < container id > "/bin/bash" # get into container to debug
  4. docker rm -v < container id >
  5. docker rmi mycontainer
  6. 重复

这对于每次迭代都感觉很昂贵,特别是如果它是拼写错误.

这个替代过程需要少一点迭代:

  1. 在dockerfile中安装vim
  2. docker run mycontainer
  3. docker exec -i -t < container id > "/bin/bash" # get into container to edit scripts
  4. docker cp 完成后复制已编辑的文件.
  5. 如果我需要运行任何命令,我会仔细记住并更新容器外的Dockerfile.
  6. 没有vim重建图像

这需要更少的迭代,但不是无痛,因为一切都非常手动,我必须记住哪些文件已更改并已更新.

docker

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

是否可以使用ref-struct和ref-array创建一个结构数组?

我正在使用node-ffi来调用一个函数,该函数将out-param作为指针到指针结构的指针.有没有办法使用ref-struct和ref-array来访问我得到的数组?

struct = require("ref-struct");
var rect_type = struct({
    'x': 'int',
    'y': 'int',
    'width': 'int',
    'height': 'int',
});
var rotation_type = struct({
    'yaw': 'short',
    'pitch': 'short',
    'roll': 'short'
});
var face_type = struct({
    'rect' : rect_type,
    'rotation' : rotation_type,
    'confidence' : 'double'
});
Run Code Online (Sandbox Code Playgroud)

我能够在函数调用之后从指针中获取第一个结构,但是我无法获得数组的其余部分:

var mylib = ffi.Library('lib/libN', {
    'GetFaces' : [ 'int', [ 'pointer' ] ]
});

var pface_type = ref.refType(face_type);
var ppface = ref.alloc(pface_type);

result = mylib.GetFaces(ppface);

face = ppface.deref().deref();

console.log("X:" + face.rect.x + " Y:" + face.rect.y);
Run Code Online (Sandbox Code Playgroud)

有没有办法将参数声明为结构数组?我试过这个,但它不起作用: …

node.js node-ffi

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

使用 python -m json.tool 输出中文UTF-8

原始文本文件“chinese.txt”如下

\n

{"type":"FeatureCollection","text":"\xe4\xbd\xa0\xe5\xa5\xbd"}

\n

在 Mac 上,在终端中运行命令,如下所示

\n

$ cat chinese.txt | python -m json.tool

\n

输出是

\n
{\n    "text": "\\u4f60\\u597d",\n    "type": "FeatureCollection"\n}\n
Run Code Online (Sandbox Code Playgroud)\n

如何添加参数以避免“\\u4f60\\u597d”并获得“\xe4\xbd\xa0\xe5\xa5\xbd”

\n

我喜欢做的是从 shell 中使用python -m json.tool而不修改json.tool. 一个常见的用例是重新格式化 UTF-8 编码的 json 文件,并保留中文字符,而不是像 \\uxxxx。

\n

python json cjk

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

我的程序崩溃,我不明白为什么它甚至没有到达第一个printf

我的程序应该订购一个由用户输入的数字列表,但它甚至在到达第一个printf之前就崩溃了.我的编译器发出2个警告,但我没有看到问题.我还没有研究过指针,所以我不想使用它们.以下是消息:

在函数`selection_sort'中:

[Warning] passing arg 2 of `selection_sort' makes pointer from integer without a cast 
Run Code Online (Sandbox Code Playgroud)

在函数`main'中:

[Warning] passing arg 2 of `selection_sort' makes pointer from integer without a cast 
Run Code Online (Sandbox Code Playgroud)

.

#include<stdio.h>

int selection_sort(int n, int v[n])
{
    int high = v[0];
    int i;

    for(i = 0; i < n; i++)
        high = high < v[i]? v[i] : high;

    if(n - 1 == 0)
        return;

     v[n - 1] = high;
     n -= 1;

     selection_sort(n, v[n]);
}   



int main(void)
{   
    int n, …
Run Code Online (Sandbox Code Playgroud)

c function

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

标签 统计

c ×1

cjk ×1

docker ×1

function ×1

json ×1

node-ffi ×1

node.js ×1

python ×1