小编Eug*_*kov的帖子

如何从`Carton`卸载

我有Carton环境并将模块安装到./local/from cpanfile. 但现在我不需要一些模块,想删除一些。

我可以./local从头开始删除文件夹并安装模块,但这需要一些时间。我找到了这个

carton uninstall Module
Run Code Online (Sandbox Code Playgroud)

但它已经不存在了。

有类似的东西carton uninstall吗?

perl cpanm

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

如何在测试mojolicious应用程序时使用路由名称?

我已经阅读了Test :: Mojo,但在应用程序测试时没有找到如何使用路由名称:

$t->get_ok( 'list_users' )->status_is( 302 )->location_is( 'auth_login' );
Run Code Online (Sandbox Code Playgroud)

在哪里list_usersauth_login是:

$r->get( '/login' )->to( 'auth#login' )->name( 'auth_login' );
$r->get( '/users' )->to( 'user#index' )->name( 'list_users' );
Run Code Online (Sandbox Code Playgroud)

在我看来,如果*_ok计算给定的字符串,它会非常方便redirect_to.VOTEUP,如果这也适合您的功能请求.

作为解决这个问题的方法,我尝试使用url_for但没有成功:

$t->url_for( 'list_users' );
#Can't locate object method "url_for" via package "Test::Mojo"
Run Code Online (Sandbox Code Playgroud)

如何从测试脚本中获取其名称的路径路径?

perl mojolicious

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

如何获取聚合函数选择的行的id?

我有下一个数据:

id | name | amount | datefrom
---------------------------
3  | a    |  8     | 2018-01-01
4  | a    |  3     | 2018-01-15 10:00
5  | b    |  1     | 2018-02-20
Run Code Online (Sandbox Code Playgroud)

我可以使用下一个查询对结果进行分组:

select name, max(amount) from table group by name
Run Code Online (Sandbox Code Playgroud)

但我也需要id选定的行。因此我尝试过:

select max(id), name, max(amount) from table group by name
Run Code Online (Sandbox Code Playgroud)

正如预期的那样,它返回:

id | name | amount
-----------
4  | a    |  8
5  | b    |  1
Run Code Online (Sandbox Code Playgroud)

但我需要 id3的数量8

id | name | amount …
Run Code Online (Sandbox Code Playgroud)

postgresql aggregate-functions

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

如何仅切片定义的值?

我可以将 kes/values 切片如下:

$item->%{ @cols }
Run Code Online (Sandbox Code Playgroud)

但是如果某个列不存在,$item它将在生成的散列中创建。

我可以只切片定义的值吗?

perl perl-data-structures

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

如何使用多列中的值分发表?

Acording到了西特斯文件,很容易使用单一柱分配表:

SELECT master_create_distributed_table('github_events', 'created_at', 'append');
Run Code Online (Sandbox Code Playgroud)

有没有办法使用多列分发表?例如,类似于:

SELECT master_create_distributed_table('github_events', 'user_id,site_id', 'append');
Run Code Online (Sandbox Code Playgroud)

postgresql citus

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

为什么魔术Perl内部变量的解决方法有效?

t2.pl

1;
2;
3;
Run Code Online (Sandbox Code Playgroud)

t.pl

package DB;

sub DB {
    print "HERE";

    our(undef, $f, undef) =  caller;

    # This does not work
    # my $ref =  \%{ "main::_<$f" };
    # $ref->{ 3 } =  {};

    # This does not work
    # *x =  $main::{ "_<$f" };
    # $x{ 3 } =  {};

    *dbline =  $main::{ "_<$f" };
    $dbline{ 3 } =  {};

    $DB::single =  0;
}

1;
Run Code Online (Sandbox Code Playgroud)
PERL5DB="BEGIN{ require 't.pl' }" perl -d t2.pl
Run Code Online (Sandbox Code Playgroud)

当你运行这个代码时,你得到了HEREHERE,但是当你没有使用别名时,神奇的Perl变量没有效果*dbline.

因此,当您更改前两个示例时,如下所示: …

debugging perl

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

是否可以在宏中定义宏?

我想使用这样的宏参数:

  #define D(cond,...) do{         \
    #if cond                      \
    #define YYY 1                 \
    #else                         \
    #define YYY 0                 \
  } while(0)
Run Code Online (Sandbox Code Playgroud)

是否可以?

UPD
也许当源将被预处理两次时:gcc -E source.c | gcc -xc -下一步将起作用:

#define D(cond,...) #define YYY cond&DEBUG
#if YYY
#define D(...) printf( __VA_ARGS__ )
#else
#define D(...)
#endif
Run Code Online (Sandbox Code Playgroud)

c macros

4
推荐指数
3
解决办法
5190
查看次数

如何忽略合并冲突?

我有下一个合并冲突:

<<<<<<< Updated upstream
    my( $c, $name ) =  (shift,shift);
  my %name =  defined $name ? ( name => $name ) : ();

||||||| merged common ancestors
    my( $c ) =  shift;
=======
    my( $c, $name ) =  (shift,shift);

  my %name =  defined $name ? ( name => $name ) : ();
>>>>>>> Stashed changes

<<<<<<< Updated upstream
    return $c->render_to_string( 'control/toggle', id => "toggle$id", %name, @_ );
||||||| merged common ancestors
  return $c->render_to_string( 'control/toggle', @_, id => "toggle$id" );
======= …
Run Code Online (Sandbox Code Playgroud)

git merge-conflict-resolution

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

如何在 JSON 模式中使用 URL URI 识别子模式?

SPEC提供了如何识别模式的下一个示例:

{
    "$id": "http://example.com/root.json",
    "definitions": {
        "B": {
            "$id": "other.json",
        },
    }
}

#/definitions/B   
        http://example.com/other.json
        http://example.com/other.json#
        http://example.com/root.json#/definitions/B 
Run Code Online (Sandbox Code Playgroud)

root.json但是,如果根模式是在路径下定义的,/some/path那么如何识别呢/

{
    "$id": "http://example.com/some/path/root.json",
    "definitions": {
        "B": {
            "$id": "other.json",
        },
    }
}
Run Code Online (Sandbox Code Playgroud)

other.json应该如何鉴别呢?

http://example.com/other.json
Run Code Online (Sandbox Code Playgroud)

或者:

http://example.com/some/path/other.json
Run Code Online (Sandbox Code Playgroud)

SPEC 的哪一部分定义了这一点?

url uri jsonschema

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

如何在不设置上游的情况下将当前分支推送到远程?

我可以将分支推送到远程:

git push --set-upstream origin 293-error-pages
Run Code Online (Sandbox Code Playgroud)

通过明确指定当前分支,我可以在不设置上游情况下推送分支:

git push origin 293-error-pages
Run Code Online (Sandbox Code Playgroud)

如何将当前分支推送到远程?(并且没有明确指定其名称)

git push origin
Run Code Online (Sandbox Code Playgroud)

告诉我:

fatal: The current branch 293-error-pages has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin 293-error-pages
Run Code Online (Sandbox Code Playgroud)

git

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