小编Ste*_*sku的帖子

Makefile规则定义中的分号

我在Makefile中看到许多规则如下所示:

$(PATH)/foo.inc:;
include $(PATH)/foo.inc

$(PATH)/bar.inc:;
include $(PATH)/bar.inc
Run Code Online (Sandbox Code Playgroud)

规则定义末尾的分号是无操作还是具有特定含义?

makefile

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

LWP :: UserAgent坚持验证主机名

以下脚本可以在运行libwww-perl-5.836但不在主机上的主机上返回综合标头libwww-perl-6.30.0.在这种情况下,脚本显示以下内容:

    500 Can't connect to backend.mutegroup.org:443 (certificate verify failed)
    Content-Type: text/plain
    Client-Date: Mon, 28 Jul 2014 21:09:28 GMT
    Client-Warning: Internal response

    Can't connect to backend.mutegroup.org:443 (certificate verify failed)

    LWP::Protocol::https::Socket: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /usr/lib64/perl5/vendor_perl/5.16.3/LWP/Protocol/http.pm line 51.
Run Code Online (Sandbox Code Playgroud)

这是脚本:

#!/usr/bin/perl

use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Request::Common;

my $ua      = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0, } );
my $url     = 'https://backend.mutegroup.org/api/getLastId';

my $request = POST $url;
print $ua->request($request)->as_string …
Run Code Online (Sandbox Code Playgroud)

perl http lwp-useragent

8
推荐指数
1
解决办法
6024
查看次数

`docker build` 根据安装顺序挂起

鉴于这种Dockerfile

FROM ubuntu:20.04

RUN set -ex && apt-get update

RUN set -ex && \
    apt-get install -y \
    git

RUN set -ex && \
    apt-get install -y \
    cmake

ENV HOME_DIR /home/develop

WORKDIR ${HOME_DIR}
Run Code Online (Sandbox Code Playgroud)

挂起docker build配置tzdata

$ DOCKER_BUILDKIT=0 docker build -f Docker/Dockerfile -t cmake:latest .
Sending build context to Docker daemon  161.8kB
Step 1/6 : FROM ubuntu:20.04
 ---> 7e0aa2d69a15
Step 2/6 : RUN set -ex && apt-get update
 ---> Using cache
 ---> 78e8a28063b0
Step …
Run Code Online (Sandbox Code Playgroud)

git ubuntu cmake docker

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

如何仅还原工作目录中的更改

我有一个破坏的合并,我想恢复工作目录中的更改,以找出它被破坏的地方.我想保留索引,以便我可以添加修复程序并最终检入它们.实际上,我希望工作目录与HEAD相同但不修改索引.这基本上会将基于索引的反向补丁应用于工作目录.这似乎与a相反git reset.

你是如何用git做的?

git

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

在git中显示未提交的合并的父项

如何在git中看到未提交的合并的父级?我可以通过这样做看到一个父母,git log -1但我怎么看到另一个父母?

这在Mercurial中很容易做到:

$ hg parents
changeset:   2:b65656dbfff6
tag:         tip
parent:      0:1806d848df54
user:        Stephen Rasku 
date:        Tue Nov 27 10:14:31 2012 -0800
summary:     c

changeset:   1:9aaa22944f41
user:        Stephen Rasku 
date:        Tue Nov 27 10:14:01 2012 -0800
summary:     b
Run Code Online (Sandbox Code Playgroud)

在git中有什么相同的东西吗?我知道你可以在git中看到一个已提交合并的父母.这是专门为了看到未提交合并的父母.

git

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

'*'令牌之前的预期初始化程序

我正在尝试在Design Patterns一书中实现代码.我收到以下错误:

expected initializer before ‘*’ token
Run Code Online (Sandbox Code Playgroud)

对于这一行:

static Singleton *Singleton::itsInstance = 0;
Run Code Online (Sandbox Code Playgroud)

这是完整的代码.我正在使用g ++ 4.2.1来尝试编译它.

class Singleton {
public:
    static Singleton *instance();
protected:
    Singleton();
private:
    static Singleton *itsInstance;
}

static Singleton *Singleton::itsInstance = 0;

Singleton *Singleton::instance()
{
    if (!itsInstance)
    {
        itsInstance = new Singleton;
    }
    return itsInstance;
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

c++ design-patterns

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

.clang-format 末尾的省略号是什么意思?

运行时:

$ clang-format -style=Google -dump-config > .clang-format
Run Code Online (Sandbox Code Playgroud)

该文件附加了省略号 ( ...)。

TabWidth:        8
UseTab:          Never
...
Run Code Online (Sandbox Code Playgroud)

有什么意义吗?我可以删除它吗?有人问这在代码审查中意味着什么。

clang-format

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

如何在 Python 模块中公开变量?

从模块中公开变量的最佳方法是什么?

import otherDBInterface as odbi

def create(host):
    global connection
    global cursor
    connection = odbi.connect(host)
    cursor = connection.cursor()
    ...
Run Code Online (Sandbox Code Playgroud)

我想cursor在模块中公开变量,以便我可以执行类似mydb.cursor.execute("select * from foo;"). 我认为使用global关键字可以做到这一点,但没有这样的运气。 cursor是一个对象,所以我不确定如何声明它以使其公开。

python

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

ValueError使用psycopg2支持格式字符'd'

我有这样的代码:

print "company_id = %d" % company_id
...
db.cursor.execute("insert into person (company_id, first, last, type) values (%d, '%s', '%s', %d);", (company_id, name[0], name[1], type))
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

company_id = 1
Traceback (most recent call last):
...
  File "./GetPeople.py", line 125, in insertPerson
    db.cursor.execute("insert into person (company_id, first, last, type) values (%d, '%s', '%s', %d);",     
Run Code Online (Sandbox Code Playgroud)

为什么它可以打印出第一行,但却给db.cursor.execute()呼叫带来了错误?

python postgresql psycopg2

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

如何使用带有"in(...)"子句的占位符?

我知道我可以用插值来做到这一点.我可以使用占位符吗?

我收到此错误:

DBD::Pg::st execute failed: ERROR:  invalid input syntax for integer: "{"22,23"}" at ./testPlaceHolders-SO.pl line 20.
Run Code Online (Sandbox Code Playgroud)

对于这个脚本:

#!/usr/bin/perl -w

use strict;
use DBI;

# Connect to database.

my $dbh = DBI->connect("dbi:Pg:dbname=somedb;host=localhost;port=5432", "somedb", "somedb");

my $typeStr = "22,23";
my @sqlParms = [ $typeStr ];
my $sqlStr = << "__SQL_END";
    SELECT id
    FROM states
    WHERE typeId in (?)
    ORDER BY id;
__SQL_END

my $query = $dbh->prepare($sqlStr);
$query->execute(@sqlParms);

my $id;
$query->bind_columns(\$id);

# Process rows

while ($query->fetch())
{
    print "Id: $id\n";
}
Run Code Online (Sandbox Code Playgroud)

除了插值之外还有其他方法吗?

postgresql perl dbi

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