我试图使用gpg到--clearsign一个文件(Debian的包装用途)从脚本。
我有一个导出的无密码private-key.gpg文件,想要:
gpg --clearsign -o output input
Run Code Online (Sandbox Code Playgroud)
我不想与当前用户的混乱~/.gnupg或者/run/user/$(id -u)/gnupg是因为他们什么都没有做我的脚本。另外,该脚本可能同时在多个实例中运行,我不希望它们相互干扰。
我认为那很容易。设置$GNUPGHOME为临时目录并完成。但我无法弄清楚如何让gpg一个脚本,而不与用户的标准配置搞乱运行在所有。似乎gpg已竭尽全力使之无法避免,gpg-agent并gpg-agent坚持使用全局/硬编码路径。
我可以保留一切下$GNUPGHOME?或者如何在gpg不影响用户配置或脚本的使用gpg或其他实例的情况下从shell脚本安全使用?
阅读gpg文档,我发现:
--use-agent
--no-use-agent
This is dummy option. gpg always requires the agent.
Run Code Online (Sandbox Code Playgroud)
和gpg-agent文件说:
--use-standard-socket
--no-use-standard-socket
--use-standard-socket-p
Since GnuPG 2.1 the standard socket is always used.
These options have no more …Run Code Online (Sandbox Code Playgroud) 我似乎无法提取从MySQL任何有用的信息,以帮助我调试这个错误:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction。你能帮我找一些吗?
再生产:
一个进程做这样的事情:
start transaction;
update cfgNodes set name="foobar" where ID=29;
Run Code Online (Sandbox Code Playgroud)
只是坐在那里(不承诺,不回滚)。这显然是罪魁祸首 - 由于长时间运行的事务而占用锁的过程 - 我试图找到的罪犯。
另一个进程尝试:
-- The next line just prevents you from having to wait 50 seconds
set innodb_lock_wait_timeout=1;
update cfgNodes set name="foobar" where ID=29;
Run Code Online (Sandbox Code Playgroud)
这第二个过程得到ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction(之后innodb_lock_wait_timeout,默认 50 秒)
我如何找到有关罪犯的任何信息?
在此codepen中有一个计数器,可以通过“incr”链接递增。
我现在有一个计算属性和一个手表:
computed: {
test() {
let unused = this.counter;
return [42];
}
},
watch: {
test(val, old) {
// Should I avoid firing when nothing actually changed
// by implementiong my own poor-man's change detection?
//
// if (JSON.stringify(newVal) == JSON.stringify(oldVal))
// return;
console.log(
'test changed',
val,
old
);
}
}
Run Code Online (Sandbox Code Playgroud)
也许是一个人为的例子,但实际上这是一个计算,其中真实数据被减少(在 vuex getter 中),并且最常见的是,即使某些数据发生变化,减少的数据也不会改变。
编辑以添加更多详细信息:vuex 中的数据store已标准化。我们还使用vue-grid-layout,它期望其layout属性采用某种非标准化格式。所以我们有一个gridLayoutgetter 来执行 vuex -> vue-grid-layout 转换。即使生成的 gridLayout 实际上没有改变,但其他细节发生了变化(例如 vuex 存储中的名称和其他与 …
我想通过不允许我的页面上的任何内容向托管页面的域以外的其他域发送 XHR/XMLHttpRequest(或其他?)请求,在管理上阻止一整类 XSS 攻击。那可能吗?
我以为我可以通过跨域资源共享 (CORS)做到这一点,但似乎我错了。如果托管在 domain-a.com 上的页面尝试向 domain-b.com 发出 XHR 请求,则可以在 domain-b.com页面上使用 CORS来控制是否允许这样做。
因此,如果 domain-a.com 页面上的某些内容尝试向hackers-r-us.com 发出XHR 请求,该请求将被允许,只要hackers-r-us.com 设置了适当的CORS 标头。
但是,无论hackers-r-us.com 上的CORS 标头如何,我是否可以在domain-a.com 的页面上设置任何内容来禁止对其他域(例如hackers-r-us.com)的请求?
在编写守护进程时,我想关闭STDIN,STDOUT和STDERR以获得"良好的守护进程行为".但我很惊讶.后续打开文件需要与旧STDIN,STDOUT和STDERR相同的属性(因为它们的fileno-s被重新打开了?)
这是warn.pl:
use warnings;
my $nrWarnings = 0;
$SIG{__WARN__} = sub {
no warnings;
$nrWarnings++;
open my $log, '>>', '/tmp/log.txt'
or die;
printf $log "%d: %s", $nrWarnings, @_;
close $log;
};
close STDOUT;
close STDERR;
close STDIN;
open my $o, '>', '/tmp/foobar.txt'
or die;
open my $i, '<', '/etc/passwd'
or die;
open my $i2, '<', '/etc/passwd'
or die;
open my $i3, '<', '/etc/passwd'
or die;
exit $nrWarnings;
Run Code Online (Sandbox Code Playgroud)
在这里我运行它:
> rm -f /tmp/log.txt ; perl warn.pl; echo $? ; cat /tmp/log.txt …Run Code Online (Sandbox Code Playgroud) 我想返回一个空数组,而不是一个空列表.
我有一个返回一系列事物的子.我希望能够用它做到这一点:
my $count = scalar getArray();
Run Code Online (Sandbox Code Playgroud)
我是这样做的:
sub getArray {
if ( !isGood() ) {
return ();
} else {
my @array = calculateSomehow();
return @array;
}
}
my $count = scalar getArray();
Run Code Online (Sandbox Code Playgroud)
我有一个惊喜的时候!isGood(),并$count成为undef,不0!读完perlfaq4之后,我意识到这是因为getArray()是在标量上下文中计算的,因此列表 ()被评估为标量,而且scalar( () )是undef,而my @array; scalar( @array )0是.
现在的问题是:我如何最优雅地返回一个空数组,那么如果$count是这样的0话!isGood()?我只想出:
# This is kind of kludgy: Dereference …Run Code Online (Sandbox Code Playgroud) 我期待一个构建器方法可以访问调用者提供的所有其他属性.但它似乎只能访问那些名字按字母顺序小于当前属性的人.例如,为什么b这里的建造者能看到价值a而不是c?('a'和'c'都出现在最终对象中)
码:
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
{
package P;
use Moo;
printf "Moo version: %s\n", $Moo::VERSION;
# a and c are defined in the same way
has a => ( is => 'ro' );
has c => ( is => 'ro' );
has b => (
is => 'ro',
builder => '_build_b',
);
sub _build_b {
my ($self) = @_;
print Data::Dumper->new(
[ $self ], [ 'self_during_build_b' ]
)->Indent(1)->Sortkeys(1)->Dump;
return "somebuiltvalue";
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个可重用的 gradle 任务,该任务从顶层访问某些内容。这有效:
val foo = 42
tasks.register("foosimple") {
println(foo)
}
Run Code Online (Sandbox Code Playgroud)
但是使用来自开发自定义 Gradle 任务类型的修改示例不会:
open class Foo : DefaultTask() {
@TaskAction
fun foo() {
println(foo)
}
}
tasks.register<Foo>("foo")
Run Code Online (Sandbox Code Playgroud)
失败了:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'keycloak-spi'.
> Could not create task ':foo'.
> Could not create task of type 'Foo'.
> The constructor for type Build_gradle.Foo should be annotated with @Inject.
* Try:
Run with --stacktrace option to …Run Code Online (Sandbox Code Playgroud) perl subs的参数在@_中传递.为了使我的程序更容易阅读,我总是使用这种模式来获取命名参数:
sub foo1 {
my ($bar, $baz) = @_;
do_something($bar,$baz);
}
Run Code Online (Sandbox Code Playgroud)
但它会导致$_[0]与$_[1]被复制.如果我是$_[0]直接访问而不是以$bar上述模式访问,我通过call-by-reference的常见警告对calllers参数进行call-by-value/alias访问,但速度要快得多(参见下面的演示).
我有这种怀疑,这种my ($param1, $param2 ...) = @_;模式因性能原因而不好.所以我发现我必须在快速和可读的程序之间做出选择,这是一个不可能的选择.
我最终编写了以性能为重点的子组件$_[<n>]以及上述模式的所有其他内容.麻烦的是,我经常不知道瓶颈在哪里;-)
有没有办法获得速度快的命名参数?或者似乎是关于此事的佳能?$_[0]还是$bar?
use Time::HiRes qw(time);
# Lets just do *something* with the parameters - here we just add up all
# their lengths
my $totalLength = 0;
sub foo1 {
# Access $_[0] directly - effectively call-by-reference
$totalLength += length($_[0]); …Run Code Online (Sandbox Code Playgroud)