小编cze*_*rny的帖子

如何为JavaScript Set自定义对象相等性

新的ES 6(Harmony)引入了新的Set对象.Set使用的身份算法类似于===运算符,因此不太适合比较对象:

var set = new Set();
set.add({a:1});
set.add({a:1});
console.log([...set.values()]); // Array [ Object, Object ]
Run Code Online (Sandbox Code Playgroud)

如何自定义Set对象的相等性以进行深层对象比较?有没有像Java这样的东西equals(Object)

javascript set ecmascript-harmony

142
推荐指数
5
解决办法
3万
查看次数

如何禁用Firefox附加组件的签名检查?

从版本42开始,Firefox默认拒绝安装未签名的附加组件.如何禁用此验证?

javascript firefox signing add-on firefox-addon

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

如何在脚本结束时关闭jshell?

如何指示jshell在脚本结尾处终止,类似于其他语言的解释器,例如python3node

遵循命令

./jshell -q /tmp/shell.java
Run Code Online (Sandbox Code Playgroud)

用脚本 /tmp/shell.java

System.out.println("Hello world");
Run Code Online (Sandbox Code Playgroud)

版画

Hello world
jshell> 
Run Code Online (Sandbox Code Playgroud)

并等待进一步的命令.我希望它立即停止在文件的末尾.

我正在寻找比System.exit(0);脚本末尾更优雅的东西.

java java-9 jshell

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

如何强制Flow将值转换为另一种类型?

是否有可能在Flow中强制转换变量?

type StringOrNumber = string | number
const foo: StringOrNumber = 'hello'

// I look for something like `const bar:string = (string) foo`
const bar: string = foo // fails
const bar: string = (foo: string) // also fails
Run Code Online (Sandbox Code Playgroud)

casting flowtype

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

maven-plugin-plugin:描述符目标在文件和文件中失败

在开发maven插件时,构建打印错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor (default-descriptor) on project default-method-demo: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor failed: syntax error @[8,1] in file:/full/path/to/project/default-method/src/main/java/org/example/Iface.java -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

即使该文件Iface.java是可编译的.

Iface.java:

package org.example;

public interface Iface {
    default String getString() {
        return "string";
    }
}
Run Code Online (Sandbox Code Playgroud)

pom.xml

<packaging>maven-plugin</packaging>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>3.0.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.plugin-tools</groupId>
        <artifactId>maven-plugin-annotations</artifactId>
        <version>3.4</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

是什么原因造成的?怎么修好?

maven-plugin maven java-8 default-method

22
推荐指数
1
解决办法
8758
查看次数

如何强制Firefox在每个选项卡上打开devtools?

有没有办法如何在所有新标签上启用开发工具?我想打开devtools以便能够舒适地调试弹出窗口.

firefox firefox-developer-tools

12
推荐指数
1
解决办法
4618
查看次数

如何为Vagrant VM启用密码ssh身份验证?

我想为可能Vagrant VM启用密码ssh身份验证(并启用基于密钥的身份验证).怎么设置?

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "fedora/26-cloud-base"
  config.vm.box_version = "20170705"

  config.ssh.username = 'vagrant'
  config.ssh.password = 'a'
  config.ssh.keys_only = false
end
Run Code Online (Sandbox Code Playgroud)
$ sudo vagrant ssh-config 
Host default
  HostName 192.168.121.166
  User vagrant
  Port 22
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/jakub/src/kubernetes-vms/kubernetes/.vagrant/machines/default/libvirt/private_key
  LogLevel FATAL
Run Code Online (Sandbox Code Playgroud)

a此设置不接受密码.

我想可能是PasswordAuthentication no在输出中vagrant ssh-config.如何打开该选项?

passwords ssh vagrant

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

从Firefox扩展程序登录到控制台?

我知道在使用带有cfx run命令的Firefox扩展时我可以登录到控制台.

有没有办法在扩展包装后登录到控制台cfx xpi?如果可能的话,记录到Firebug是好的.

我找到了两篇关于此的博文(这里这里).两者都相当陈旧,不再工作了.

我正在使用附加SDK和FF15的1.10版本.

firefox firebug logging firefox-addon firefox-addon-sdk

10
推荐指数
3
解决办法
7031
查看次数

如何在没有类型定义的情况下导入Typescript中的节点模块?

当我尝试在Typescript中导入node.js模块时,如下所示:

import co = require('co');
import co from 'co';
Run Code Online (Sandbox Code Playgroud)

如果没有提供类型定义,两行都报告相同的错误:

error TS2307: Cannot find module 'co'.
Run Code Online (Sandbox Code Playgroud)

如何正确导入?

node.js typescript

10
推荐指数
3
解决办法
8040
查看次数

如何将PostgreSQL数据源添加到WildFly 9.0?

我在mastertheboss.com上试过教程:

  1. ./jboss-cli.sh
  2. module add --name=org.postgres --resources=/tmp/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api
  3. /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
  4. data-source add --jndi-name=java:/PostGreDS --name=PostgrePool --connection-url=jdbc:postgresql://localhost/postgres --driver-name=postgres --user-name=postgres --password=postgres

本教程适用于WildFly 8.2,但它不适用于WildFly 9.0.第3步失败并显示错误消息:

{
"outcome" => "failed",
"failure-description" => "WFLYJCA0041: Failed to load module for driver [org.portgres]",
"rolled-back" => true
}
Run Code Online (Sandbox Code Playgroud)

如何将Postgres数据源添加到WildFly 9.0?

java postgresql datasource jdbc wildfly

9
推荐指数
2
解决办法
3万
查看次数