clojure

How do I programmatically set gzip in Jetty?

感情迁移 提交于 2020-02-02 02:59:08
问题 I'm writing a web app using Noir and clojure, which uses Jetty. Jetty has two ways of using gzip, one for static, and one for dynamic, they are described in https://stackoverflow.com/a/9113129/104021. I want to turn on both static and dynamic gzipping, but our project doesn't use web.xml files, and doesn't want to start. How do I programmatically set jetty to use gzip (ie without having a web.xml)? 回答1: In a Compojure app I'm working on, I have a Ring/Jetty adapter based on ring-jetty-adapter

Unable to find Clojure

独自空忆成欢 提交于 2020-02-01 04:50:25
问题 EDIT: There are some other discussions going on that are related to this question on the Bukkit forums and on Github. So, I know one or two people have attempted this with no luck.. But I think I'm almost there. One problem: I don't know Java, so this is a little alien to me. Anyway.. So, I made a simple class in Clojure, as follows: (ns com.gdude2002.ClojurePlugin.mainclj (:gen-class :name com.gdude2002.ClojurePlugin.mainclj :extends org.bukkit.plugin.java.JavaPlugin) (:import org.bukkit

Modify Clojure source code file in clojure

混江龙づ霸主 提交于 2020-02-01 03:09:25
问题 I was wondering if it's possible to load the code contained in a Clojure .clj source file as a list, without compiling it. If I can load a .clj file as a list, I can modify that list and pretty print it back into the same file which can then be loaded again. (Maybe this is a bad idea.) Does anyone know if this is possible? 回答1: A slightly simpler example: user=> (def a '(println (+ 1 1))) ; "'" escapes the form to prevent immediate evaluation #'user/a user=> (spit "test.code" a) ; write it to

Modify Clojure source code file in clojure

橙三吉。 提交于 2020-02-01 03:09:05
问题 I was wondering if it's possible to load the code contained in a Clojure .clj source file as a list, without compiling it. If I can load a .clj file as a list, I can modify that list and pretty print it back into the same file which can then be loaded again. (Maybe this is a bad idea.) Does anyone know if this is possible? 回答1: A slightly simpler example: user=> (def a '(println (+ 1 1))) ; "'" escapes the form to prevent immediate evaluation #'user/a user=> (spit "test.code" a) ; write it to

Is there an AES library for clojure?

。_饼干妹妹 提交于 2020-02-01 02:21:09
问题 Is there an AES encryption library for clojure? should I use a java libray available through maven or clojars? Thank your for your time and consideration. 回答1: Here is a perhaps more idiomatic example using the available java crypto libraries. encrypt and decrypt here each simply take input text and the encryption key, both as Strings. (import (javax.crypto Cipher KeyGenerator SecretKey) (javax.crypto.spec SecretKeySpec) (java.security SecureRandom) (org.apache.commons.codec.binary Base64))

How do clojure core.async channels get cleaned up?

前提是你 提交于 2020-01-31 09:06:14
问题 I'm looking at Clojure core.async for the first time, and was going through this excellent presentation by Rich Hickey: http://www.infoq.com/presentations/clojure-core-async I had a question about the example he shows at the end of his presentation: According to Rich, this example basically tries to get a web, video, and image result for a specific query. It tries two different sources in parallel for each of those results, and just pulls out the fastest result for each. And the entire

Emacs Clojure mode without paredit

此生再无相见时 提交于 2020-01-30 23:24:59
问题 I'm using the Clojure mode package from ELPA. Otherwise everything is fine, but I just can't stand paredit mode. I can't seem to turn it off easily, now I just disable it for every buffer I open. I tried setting this variable to nil: (setq clojure-enable-paredit nil) But paredit still appears. Any ideas? 回答1: Not an answer to your actual question, but give paredit mode a chance. I, too, was really annoyed with it automatically closing my parens, and refusing to delete just a single paren for

Emacs Clojure mode without paredit

人盡茶涼 提交于 2020-01-30 23:24:05
问题 I'm using the Clojure mode package from ELPA. Otherwise everything is fine, but I just can't stand paredit mode. I can't seem to turn it off easily, now I just disable it for every buffer I open. I tried setting this variable to nil: (setq clojure-enable-paredit nil) But paredit still appears. Any ideas? 回答1: Not an answer to your actual question, but give paredit mode a chance. I, too, was really annoyed with it automatically closing my parens, and refusing to delete just a single paren for

clojure access enum defined inside a java class

丶灬走出姿态 提交于 2020-01-30 10:57:06
问题 I am trying to use the argon-jvm library for hashing in my application. By default this library uses Argon2i , However, I would like to use Argon2id . To do so, I need to pass the enum value Argon2Factory.Argon2Types.Argon2id to the overloaded create method in the Argon2Factory class. Source code for Argon2Factory.java here. From the lein repl (affter adding [de.mkammerer/argon2-jvm "2.4"] as a dependency), I can do the following: user=> (import 'de.mkammerer.argon2.Argon2Factory) de

Why isn't my code printing like it should?

点点圈 提交于 2020-01-30 04:38:30
问题 I'm trying to create a for in Clojure. I'm following the cheats sheet from the Clojure site. e.g: (take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y])) I'm trying to create my own for which should print "Hello World" 100 times. (take 100 (for [a (range 100) :while (< a 100)] (println "Hello World") ) ) For some reason it's not printing Hello World 100 times. Why not? 回答1: The most important thing you need to be aware of, is that sequences in Clojure are lazy. That