我有功能,我希望它有时会挂起.所以我设置了一个全局变量然后读取它,如果它在几秒钟之后没有出现我放弃了.下面不是完整的代码,但是它不起作用,因为我没有将$ START作为值5
START=0
ineer()
{
sleep 5
START=5
echo "done $START" ==> I am seeing here it return 5
return $START
}
echo "Starting"
ineer &
while true
do
if [ $START -eq 0 ]
then
echo "Not null $START" ==> But $START here is always 0
else
echo "else $START"
break;
fi
sleep 1;
done
Run Code Online (Sandbox Code Playgroud) 尝试通过测试容器拉取图像时出现错误 [ERROR]。原因 您组织中的 CI 计算机可以访问公共注册表服务器,但不允许与外部 Web 通信。Testcontainer java对于这个用例有类似的东西
Private registry image name
// Referring directly to an image on a private registry - image name will vary
final MySQLContainer<?> mysql = new MySQLContainer<>(
DockerImageName.parse("registry.mycompany.com/mirror/mysql:8.0.24")
.asCompatibleSubstituteFor("mysql")
)
Run Code Online (Sandbox Code Playgroud)
相当于 testcontainer-go 使用的覆盖图像注册表 url 的 go 是什么?
代码
req := testcontainers.ContainerRequest{
Image: "amazon/dynamodb-local:1.15.0",
ExposedPorts: []string{"8000" + "/tcp"},
ReaperImage: artifact_path,
}
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
// auto-start the container
Started: true,
})
Run Code Online (Sandbox Code Playgroud)
[错误]
2021/09/28 20:21:11 Failed to pull image: Error response …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我想std::uniform_int_distribution在一个结构中创建一个,然后再给出它的范围。下面是我想要的。
#include <random>
#include <iostream>
std::random_device rd;
std::mt19937 gen(rd());
struct group_s {
int k;
std::uniform_int_distribution<> dis;
} group;
int main()
{
group.dis(0,19);
std::cout << group.dis(gen) << ' ';
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
no match for call to '(std::uniform_int_distribution<>) (int, int)'
cpu_group.dis(0,19);
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
在操作系统级别发生什么事情,想要将某些内容写入文件?任何操作系统都没问题,但我对Linux很熟悉,所以如果有人在Linux上给我答案那就太好了.
我知道在下面用C语言打开文件时会发生的一些事情是我的粗略代码.
FILE *fp;
fp = fopen("/tmp/test.txt", "w+");
fputs("This is testing for fputs...\n", fp);
Run Code Online (Sandbox Code Playgroud)
如何在android活动的右上角显示对话框。
下面是我的对话框代码
项目.xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="150dp"
android:layout_height="wrap_content" >
<com.CustomToggleButton
android:id="@+id/toggleButton2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textOff="@string/off_txt"
android:textOn="@string/on_txt" />
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
ActivityMy.java
dialog_box = new Dialog(ActivityMy.this);
dialog_box.setContentView(R.layout.item);
dialog_box.show();
Run Code Online (Sandbox Code Playgroud) 我得到了以下错误,我尝试了这两种方式,但没有解决它.
下面是代码
class Stat_S{
public:
Stat_S(const char *name) :
{
........
}
~Stat_S();
};
struct temp {
Stat_S sp("ppin");
}
Run Code Online (Sandbox Code Playgroud)
错误:字符串常量之前的预期标识符
class Stat_S{
public:
Stat_S(const char *name) :
{
........
}
~Stat_S();
};
const char *temp="ppin";
struct temp {
Stat_S sp(temp);
}
Run Code Online (Sandbox Code Playgroud)
错误:'temp'不是一种类型
class Stat_S{
public:
Stat_S(const char *name) :
{
........
}
~Stat_S();
};
struct temp {
Stat_S*sp = new Stat_S("ppin");
}
Run Code Online (Sandbox Code Playgroud)
工作很好没有错误
main()
{
static temp2 *temp;
temp2 = new temp[2];
}
Run Code Online (Sandbox Code Playgroud)
如何解决第一或第二案件?我想从struct temp调用Stat_S的构造函数.我不会使用第三种情况,因为我已经有了使用dot(.)作为sp的大定义我不想在使用实例后将其更改为 - >.
我想转换char *为enum所以我使用了这个.但转换char *到时我收到错误enum
我不能改变我的enum.也是type[]动态的简化我显示静态值.
enum type_t {
MSG_1 = 0,
MSG_2
};
char type[] = "MSG_1|MSG_2";
char *type_char;
type_char = strtok (type,"|");
while (type_char != NULL)
{
type_t type_enum = static_cast<type_t >(type_char );
type_char = strtok (NULL, "|;");
}
Run Code Online (Sandbox Code Playgroud)
我收到了以下错误
error: invalid static_cast from type 'char*' to type 'type_t'
Run Code Online (Sandbox Code Playgroud)
我想转换char *为enum
我想创建圆形按钮。所以我从这里得到了如何在 Android 中获得圆形的提示。正如链接中提到的,按钮的高度和重量必须具有相同的大小才能形成圆形,否则它将是椭圆形。我们不能使用 wrap_content 因为它是椭圆形的。
购买问题是现在我动态创建按钮,我尝试将按钮的高度和宽度设置为相同,但我仍然得到椭圆形按钮而不是圆形。
我尝试通过 xml 文件保持按钮的重量和高度相同它的工作,但通过动态它不是。下面是代码。
for (int count = 1; count <= rowb; count++)
{
tblRow[count] = new TableRow(getApplicationContext());
tbl.addView(tblRow[count]);
for (int j = 1; j <= rowb; j++) {
String nameB=""+i;
btn[i] = new Button(getApplicationContext());
btn[i].setId(i);
btn[i].setText(nameB);
btn[i].setWidth(1);
btn[i].setHeight(1);
tblRow[count].addView(btn[i]);
btn[i].setOnClickListener(getOnClickDoSomething(btn[i],i));
i++;
}
}
notifyAllObservers();
move--;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过,但它也确实有效
TableLayout.LayoutParams lp = new TableLayout.LayoutParams(5,5);
btn[i].setLayoutParams(lp);
Run Code Online (Sandbox Code Playgroud)
有人可以让我知道问题是什么吗?我如何获得圆形页岩按钮而不是椭圆形?
我正在写函数,我需要找到1到10之间的随机数.最简单的方法之一是使用random()libc调用.我将使用这个功能很多.但我不知道它会有多高效.如果有人知道random()的效率会有帮助吗?
另外我注意到random()在2次运行中给出了相同的模式.
int main()
{
for(int i=0;i<10;i++)
{
cout << random() % 10 << endl;
}
}
Run Code Online (Sandbox Code Playgroud)
输出第一次: - 3 6 7 5 3 5 6 2 9 1
第二次我也得到了相同的输出.
那么它是如何随机的?