This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-14
Channels
- # beginners (74)
- # boot (23)
- # braid-chat (7)
- # cider (5)
- # clara (3)
- # cljsjs (17)
- # cljsrn (1)
- # clojure (105)
- # clojure-austin (9)
- # clojure-new-zealand (34)
- # clojure-poland (2)
- # clojure-russia (177)
- # clojure-uk (41)
- # clojure-ukraine (2)
- # clojurescript (130)
- # component (1)
- # core-async (2)
- # core-matrix (6)
- # cursive (7)
- # data-science (103)
- # datomic (24)
- # emacs (15)
- # funcool (4)
- # hoplon (21)
- # immutant (151)
- # ldnclj (76)
- # melbourne (1)
- # off-topic (8)
- # om (152)
- # om-next (1)
- # onyx (26)
- # parinfer (38)
- # re-frame (13)
- # reagent (14)
- # spacemacs (1)
- # vim (92)
- # yada (1)
The Raleigh-Durham-Chapel Hill area is known as the Triangle (short for Research Triangle), so the local Clojure meetup is called TriClojure: http://www.meetup.com/TriClojure/
It’s nice in that, at least for the first couple of years, Clojure/conj was also hosted locally, so I was able to attend the 2011 one. 😄
I suppose there’s isomorophic clojurescript running between the browser and node, but is there isomorphic clojure server rendering/passing data to closurescript SPA’s?
you could certainly share code between clojure and cljs with reader conditionals, and there’s implementations of hiccup for cljs that would allow you to render it on the client side
I ran into a problem:
(ns tunnel.datomic
(:require [com.stuartsierra.component :as component]
[datomic.api :as d]
[ :as io])
(:import datomic.Util
com.stuartsierra.component.Lifecycle))
(defrecord DatomicDatabase [uri schema initial-data connection]
Lifecycle
(start [component]
(d/create-database uri)
(let [c (d/connect uri)]
@(d/transact c schema)
@(d/transact c initial-data)
(assoc component :connection c)))
(stop [component]
(d/delete-database uri)
(assoc component :connection nil)))
(defn new-database [db-uri]
(DatomicDatabase.
db-uri
(first (Util/readAll (io/reader (io/resource "data/schema.edn"))))
(first (Util/readAll (io/reader (io/resource "data/initial.edn"))))
nil))
When lein run
without :aot :all, It works fine. However, here will be a ClasssNotFoundException
when I run with :aot :all
.
Is thereany works must be done for AOT-compile?After some search on stackoverflow, I'm going to reinstall my leiningen, and rm .m2
and .lein
I am trying to implement a real-time chat service into an existing compojure/ring web application. I looked into using Lamina but was quickly dissuaded after seeing it's about to be deprecated. What are there some viable alternatives you'd recommend?
doglooksgood: you should implement the protocol for the record
component/Lifecycle
no the interface generated behind the scenes for the protocol@hiredman: remove import
, and use component/Lifecycle
doesn't solve the problem.
Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.lang.Namespace.<init>(Namespace.java:34)
at clojure.lang.Namespace.findOrCreate(Namespace.java:176)
at clojure.lang.Var.internPrivate(Var.java:151)
at user.<clinit>(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/stuartsierra/component/Lifecycle, compiling:(user.clj:1:1)
at clojure.lang.Compiler.load(Compiler.java:7239)
at clojure.lang.RT.loadResourceScript(RT.java:371)
at clojure.lang.RT.loadResourceScript(RT.java:358)
at clojure.lang.RT.maybeLoadResourceScript(RT.java:354)
at clojure.lang.RT.doInit(RT.java:468)
at clojure.lang.RT.<clinit>(RT.java:330)
... 4 more
Caused by: java.lang.NoClassDefFoundError: com/stuartsierra/component/Lifecycle
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at clojure.lang.RT.classForName(RT.java:2154)
at clojure.lang.RT.classForName(RT.java:2163)
at tunnel.datomic$fn__17714.<clinit>(datomic.clj:11)
at tunnel.datomic__init.load(Unknown Source)
at tunnel.datomic__init.<clinit>(Unknown Source)
Is that the defprotocol
will generate the class dynamically, so actually the .class
for component/Lifecycle does not exist?
I would guess, since you mentioned aot compiling at one point that for some reason you have some stale compiled class files in target, given that you changed the code and the error didn't change
(ns user
(:require [reloaded.repl :refer [system init start stop go reset]]
[tunnel.system :refer [prod-system]])
(:gen-class))
(defn -main [& args]
(reloaded.repl/set-init! prod-system)
(go))
The file where prod-system
is defined, require the tunnel.datomic
. But tunnel.system
and tunnel.datomic
are not in the same directory.
files named user.clj at the root of the classpath have some special behavior in the clojure runtime, and the user namespace is created by the clojure runtime, so you don't need the ns macro, and you shouldn't creating your app entry point in user.clj
(they sort of work, but clojure ends up compiling them as classes without a package which is a bad practice on the jvm)
if the reason you aot compiling is just to get a main entry point, you can use something like
java -jar your-uber-jar.jar clojure.main -m your.namespace
insteadaot compilation just saves off the same bytecode the compiled generates for loading in the future
it might, I doubt by much though, unless you are using a lot of really intense macros
I unzip the uber-jar, I found there're lot of .clj
and .java
, is these files necessary?
it is complicated, the ,java generally isn't, but the uberjar is your code combined with the code of all your dependencies, so if your dependencies include the .java source in their jar for whatever reason, you will end up with it in your uberjar
the .clj code is more complex of an answer because clojure's runtime includes the compiler, so the .clj could be turned in to jvm bytecode to be executed at anytime
in theory if you aot compile clojure, you'll be left with classfiles, and you don't need to load the .clj, but there are some provisos to that
Why would I want to use tap
http://clojuredocs.org/clojure.core.async/tap and mult
http://clojuredocs.org/clojure.core.async/mult
@urbanslug: in short mult is some kind of "broadcast" operation with go async. If you wonder what is the difference between pub and mult then Timothy has a comprehensive answer for it : http://stackoverflow.com/questions/22530610/whats-the-difference-between-pub-and-mult-in-core-async-a-sample-usecase
you can build it yourself with core.async primitives but is nice that it offers several higher-level abstractions: mult, pub-sub & mix
I don't suppose anyone knows the status of clj-http 3.0 do they? I just ran the tests and they all passed on master, the readme says that was what's holding up the 3.0 release. Curious to know if it'll be soon or not
don't know about the state of the project but note that you can release you own versions of libraries in Clojars changing their group id @mrjaba
so you could publish under mrjaba/clj-http
and depdend on it until the clj-http
authors release the 3.0 version
@mrjaba: note that the preferred group for a fork would be org.clojars.mrjaba - clojars will show those as non-canonical forks in the search results: https://clojars.org/search?q=org.clojars.tcrawley
What could be the reason for the following error when running lein test aaas.core-test
?
Exception in thread "main" java.lang.ClassNotFoundException: aaas.core-test, compiling:(aaas/core_test.clj:1:1)
I have (ns aaas.core-test
in test/aaas/core_test.clj
Oh dear, I've been struggling with this for hours and justs realised i'd mistyped the namespace
I had (:ns aaas.core-test
How to work with records/protocols and plumatic schema? There are no macros for checking types. What approach should I use? I have a protocol Sender in my app that has send method which sends message that is a map with :body and :to keys. I wanted to document/check that with plumatic/schema.
Hi, I’ve got a lazy seq question: (fn [huge-lazy-seq] (->> huge-lazy-seq rest (reduce f))) Would that hold onto the head and thus create a memory problem?
not normally - at least
Hi, I've been looking for an XPath-like tools for working with Clojure data structures. (Please note: I am not looking for a tool that works with XML) Is there such a thing? If not, is there an easy way to do operations like this: for example, "Given a data structure, find me all maps that contains key :xyz."
@em: you can use assoc-in
update-in
etc... or look at something like specter if you need more: https://github.com/nathanmarz/specter
but depending on the datastructure and exactly what you want to do there are lots of options... e.g. core.zip
tree-seq
etc...
sorry - just realised I misread - your question if you're finding things - obviously don't use assoc-in/update-in - you can do things like this too of course
(-> {:foo {:bar "baz"}} :foo :bar)
and combine with whatever else you might need e.g. some/filter/remove
etc...
Thanks @rickmoynihan, specter is interesting. I'll look into it.
I'm currently looking for something:
1. That works with all (most) clojure data structures. (the way clojure.walk
does)
2. I want it to return a sequence of all sub-data structure that match a criteria.
@em: something like https://github.com/davidsantiago/hickory/blob/master/src/hickory/select.cljx only not specific to HTML? Hickory uses zippers with some predicates on top to select through a map representation of an XML document
@dm3. Thank you. I think you are saying I can look at hickory
as a code sample, which I will do.
@ghadi: The standard JVM LDAP interface is called JNDI. But I don’t know how easy it is to use JNDI with Clojure; I’ve never tried.
At first blush, the Scala Center, <HTTP://scala.EPFL.ch> looks pretty cool. Is there anything like this in clojure land?
From experimentation, Clojure reader conditionals (combined code for Clojure & ClojureScript, etc., e.g., #?(:clj (java.util.Date.) :cljs (js/Date.))
) are only allowed in .cljc
files. Is this indeed the case?
@ghadi use spring-ldap http://projects.spring.io/spring-ldap/. JNDI is not an LDAP implementation
@jonahbenton: To be fair, ghadi was asking for an LDAP library, not an implementation.
hey @cky, sure- my comment was just to the point that JNDI is more of an wrapper around directory services in the abstract; to talk to LDAP in particular from JNDI you still need something to bridge from JNDI to LDAP, plus JNDI configuration. Might as well just talk directly to LDAP...but can work either way
@cky @ghadi I’d avoid the JNDI LDAP stuff. I’ve used https://github.com/pauldorman/clj-ldap with nice success in the past tho
(ldap/add conn entry-dn {:objectClass #{"top" "domain"}})
- nice and clean. Just works with clojure maps and hides all the mess