小编Edw*_*ard的帖子

如何在Eclipse中激活CoffeeScript的语法高亮?

我正在运行Eclipse Luna.另外,我Nodeclipse.17.plus通过市场安装并检查了所有提供的工具.这还包括Nodeclipse Coffee-Script查看器:

CoffeeScript Editor let's you edit *.coffee files with some advanced features.

Highlights include

- syntax highlighting
- variable autocompletion in the current namespace
- correct autoindent
Run Code Online (Sandbox Code Playgroud)

另外我XText Nature为该项目激活了.

但是*.coffee-files 仍然没有语法突出显示.

我做错了什么吗?(顺便说一下,它Nodeclipse EditBox正在工作,但是对我来说,使CoffeeScript可读是不够的)

似乎安装了Nodeclipse CoffeeScript Viewer: 在此输入图像描述

但它没有出现在内部编辑器列表中: 在此输入图像描述

eclipse eclipse-plugin coffeescript

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

如何测试不适合Instaparse-grammar(Clojure)的文本?

我在Instaparse(Clojure)中编写了一个使用无上下文语法解析字符串的项目.现在我想测试几个输入字符串的解析结果.某些输入字符串可能不适合语法.到目前为止,我只测试了"解析后的字符串不符合预期".但我认为使用测试异常会更准确(is (thrown? ...)).是否抛出异常?在我看来,Parse error...生成了一些输出(Containing ),但没有抛出任何异常.

我的project.clj是:

(defproject com.stackoverflow.clojure/tests "0.1.0-SNAPSHOT"
  :description "Tests of Clojure test-framework."
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [instaparse "1.3.4"]])
Run Code Online (Sandbox Code Playgroud)

我的核心资源是:

(ns com.stackoverflow.clojure.testInstaparseWrongGrammar
  (:require [instaparse.core :as insta]))

(def parser (insta/parser "
    <sentence> = words <DOT>
    DOT        = '.'
    <words>    = word (<SPACE> word)*
    SPACE      = ' '
    word     = #'(?U)\\w+'
"))

(defn formatter [expr] 
  (->> (parser expr)
       (insta/transform {:word identity})
       (apply str)))
Run Code Online (Sandbox Code Playgroud)

我的测试来源是:

(ns com.stackoverflow.clojure.testInstaparseWrongGrammar-test
  (:require [clojure.test :refer …
Run Code Online (Sandbox Code Playgroud)

parsing exception clojure context-free-grammar instaparse

6
推荐指数
1
解决办法
510
查看次数

如何在Leiningen中的Clojure代码之后编译Java代码

在我的Leiningen项目中:

(defproject com.stackoverflow.clojure/tests "0.1.0-SNAPSHOT"
  :description "Tests of Clojure test-framework."
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [instaparse "1.3.4"]]
  :aot [com.stackoverflow.clojure.testGenClass]
  :source-paths      ["src/main/clojure"]
  :java-source-paths ["src/main/java"]
  :test-paths        ["src/test/clojure"]
  :java-test-paths   ["src/test/java"]
  )
Run Code Online (Sandbox Code Playgroud)

我正在用gen-class生成Java类:

(ns com.stackoverflow.clojure.testGenClass
  (:gen-class
     :name com.stackoverflow.clojure.TestGenClass
     :implements [com.stackoverflow.clojure.TestGenClassInterface]
     :prefix "java-"))

(def ^:private pre "START: ")

(defn java-addToString [this text post]
  (str pre text post))
Run Code Online (Sandbox Code Playgroud)

我想在Java中使用:

package com.stackoverflow.clojure;

public class TestGenClassTest {

    private TestGenClassTest() {
    }

    public static void main(String[] args) {
        TestGenClassInterface gc = new TestGenClass(); …
Run Code Online (Sandbox Code Playgroud)

java compilation clojure gen-class leiningen

6
推荐指数
1
解决办法
864
查看次数

如何找出Clojure函数(吐出)的允许选项?

Clojure函数spit允许将数据写入文件,例如:

(spit "filename.txt" "content")
Run Code Online (Sandbox Code Playgroud)

它还允许将内容添加到现有文件。

(spit "filename.txt" "content" :append true)
Run Code Online (Sandbox Code Playgroud)

在文档((doc spit))中仅表示可以将选项传递到clojure.java.io/writer。但是(doc clojure.java.io/writer)没有列出允许的选项。那么,有没有可用的“详细模式”文档?

:append通过http://clojuredocs.org/clojure.core/spit找到了-option ,但是我确定它也在文档中的某处列出。

java documentation clojure

6
推荐指数
1
解决办法
648
查看次数

如何在`git stash list`中列出存储的父提交

当我生成一个存储时git,有一个"父"(我隐藏我的更改之前的最后一次提交).

当我git stash用来存储我的更改时,该父提交的ID将添加到描述我的存储的消息中.打电话git stash list可以显示:

stash@{0}: WIP on master: c09a3fc second commit
stash@{1}: WIP on master: 063b893 first commit
stash@{2}: WIP on master: 063b893 first commit
Run Code Online (Sandbox Code Playgroud)

但是当我运行git stash save "My own message"父提交的ID时没有添加(git stash list):

stash@{0}: On master: My own message
stash@{1}: WIP on master: c09a3fc second commit
stash@{2}: WIP on master: 063b893 first commit
stash@{3}: WIP on master: 063b893 first commit
Run Code Online (Sandbox Code Playgroud)

有没有办法显示父级提交的ID到存储列表?

我试过:git stash list --oneline --parents,这给了我:

1b5dfb1 …
Run Code Online (Sandbox Code Playgroud)

git git-stash

6
推荐指数
1
解决办法
639
查看次数

如何从Java中的文件生成PublicKey对象

我有一个包含公共RSA密钥的文件(生成时ssh-keygen).我想读取文件并生成一个PublicKey对象.

在此之前我转换了文件,因为阅读原始文件似乎是不可能的:

# http://unix.stackexchange.com/questions/220354/how-to-convert-public-key-from-pem-to-der-format/220356#220356
ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PEM > ~/.ssh/id_rsa.pub.pem
openssl rsa -RSAPublicKey_in -in ~/.ssh/id_rsa.pub.pem -inform PEM -outform DER -out ~/.ssh/id_rsa.pub.der -RSAPublicKey_out
Run Code Online (Sandbox Code Playgroud)

Java - 使用现有公钥文件加密字符串我定义了函数readFileBytes:

public static byte[] readFileBytes(String filename) throws IOException {
    Path path = Paths.get(System.getProperty("user.home") + filename);
    return Files.readAllBytes(path);
}
Run Code Online (Sandbox Code Playgroud)

现在我想读取文件并生成PublicKey对象,但我找不到办法做到这一点; java.security.spec.RSAPublicKeySpec不提供适合的构造函数并java.security.spec.X509EncodedKeySpec抛出错误java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException: algid parse error, not a sequence:

//RSAPublicKeySpec publicSpec = new RSAPublicKeySpec(readFileBytes("/.ssh/id_rsa.pub.der"));
// No fitting construktor

X509EncodedKeySpec publicSpec = new …
Run Code Online (Sandbox Code Playgroud)

java encryption rsa bouncycastle public-key-encryption

6
推荐指数
1
解决办法
5783
查看次数

是否有可能在电子主过程中捕获渲染器过程的异常?

我正在使用Electrons Quick Start Projekt(Commit dbef48ee7d072a38724ecfa57601e39d36e9714e)来测试异常.

index.html我从改变所需要的模块的名称renderer.jsrendererXXX.js.

require('./renderer.js')
Run Code Online (Sandbox Code Playgroud)

这导致了预期的Exeption(在该窗口的devtools中可见):

Uncaught Error: Cannot find module './rendererXXX.js'
Run Code Online (Sandbox Code Playgroud)

现在,如果main-process(请参阅main.js)知道一个渲染器进程失败,那将会很好.因此,我将窗口的instatiation包装成try-catch-block

try {
  app.on('ready', createWindow)
} catch (e) {
  console.log("Exception caught: " + e.message);
} finally {
  // nothing yet
}
Run Code Online (Sandbox Code Playgroud)

但我意识到,异常不会转发到主进程.那么处理渲染器进程异常的典型方法是什么?有没有办法从主进程处理它们?

编辑:

我还包装了加载index.html到try-catch的行,但我仍然无法处理错误:

  try {
    // and load the index.html of the app.
    mainWindow.loadURL(`file://${__dirname}/index.html`)
  } catch (e) {
    console.log("Exception caught in 'createWindow': " + e.message);
  }
Run Code Online (Sandbox Code Playgroud)

javascript exception-handling exception electron

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

Docker在哪里存储运行容器的内容?

有没有办法浏览在正在运行的容器中创建的文件?

假设我正在使用容器

sudo docker run --name myContainer -d ubuntu
Run Code Online (Sandbox Code Playgroud)

哪个有ID eefea5f7df52e8c1aad24b4068564237021dc7b953026f0adb696878a3d25f72

我以为在某个地方创建了一个文件夹(带有容器ID的名称)/var/lib/docker/,其中包含创建的文件,...

我发现了几个文件夹/var/lib/docker/aufs/diff(删除容器时也会删除它们),但我不知道如何将它们映射到容器ID.

filesystems directory-browsing docker

6
推荐指数
1
解决办法
1540
查看次数

从grep删除行号选项

我为grep使用别名,它将别名添加到输出中:

alias grep="grep -n -I --color"
Run Code Online (Sandbox Code Playgroud)

对于某些命令,我​​想-n从grep命令中删除。我找不到“不添加行号”标志。是否有可用的类似方法,还是必须添加没有行号的别名?

command-line grep alias command-line-arguments

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

如何在 Clojure 中测试抛出的异常?

在测试代​​码时,我也喜欢涵盖失败的情况。

我是 Clojure 的新手,但是否有可能测试抛出的异常?

我想测试以下示例代码:

(ns com.stackoverflow.clojure.tests)

(defn casetest [x]
  (case x
    "a" "An a."
    "b" "A b."
    (-> (clojure.core/format "Expression '%s' not defined." x)
        (IllegalArgumentException.)
        (throw))))
Run Code Online (Sandbox Code Playgroud)

使用以下测试方法:

(ns com.stackoverflow.clojure.tests-test
  (:require [clojure.test :refer :all]
            [com.stackoverflow.clojure.tests :refer :all]))

(deftest casetest-tests
  (is (= "An a." (casetest "a")))
  (is (= "A b."  (casetest "b")))
  (throws-excpeption IllegalArgumentException. (casetest "c")) ; conceptual code
  )

(run-tests)
Run Code Online (Sandbox Code Playgroud)

我的 project.clj 看起来像:

(defproject com.stackoverflow.clojure/tests "0.1.0-SNAPSHOT"
  :description "Tests of Clojure test-framework."
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"} …
Run Code Online (Sandbox Code Playgroud)

testing unit-testing exception-handling exception clojure

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