Fork me on GitHub

Does Leiningen has a way to search templates?


@stardiviner Not sure what you mean by that...?


@seancorfield Leiningen has a command lein new [template] to use that template to generate project. I'm curious whether has a way to search those templates.


That should give you a fairly complete list.


Just FYI, boot-new supports both Leiningen templates and Boot templates


And clj-new supports both of those and clj-templates too (although I expect there aren't any of those yet)


Hi all, I am totally new in Clojure here, have a simple question to ask, why (conj (reverse [4 3]) 2 1) will evaluate as (1 2 3 4) instead of (3 4 2 1) ?


@tthock A good way to understand is to break it into its subexpressions -- what does (reverse [4 3]) produce?


a sequence, mean it's `(3 4) ?


Right, so when you conj onto a sequence, it puts the items on the front.


conj only puts items on the back if the collection is a vector.


so (conj [4 3] 2 1) will produce [4 3 2 1]


thanks for your input. @seancorfield


@seancorfield clj-templates? Thanks


@stardiviner Yes, foo/clj-template would be searched for by clj-new -- but there aren't any yet (I suspect we'll see them as Git coordinates instead of releases on Clojars).


clj-new looks for clj-template first, then lein-template then boot-template


I'm checking out clj-template. Is clj-new supported by CIDER? Or clj-new can be manually setting in CIDER to use directly?


clj-new creates new projects -- so CIDER support doesn't make much sense


clj-new is the clj version of boot-new or lein-new


Let me take a try. I think it should can work directly.


If you're using the clj script, having clj-new as an alias is convenient --


@seancorfield Seems you updated it recently since I last update.


Possibly. Mostly cosmetic updates lately tho


I tested with Emacs CIDER, CIDER seems support project with deps.edn So clj-new (clj-template) is supported.


@seancorfield You might need to improve dot-clojure README, the :new alias require project name as kk/kk2 style. I don't know which one is used for lein template like lein new compojure [project-name].


I tried both clj -A:new demo/compojure and clj -A:new compojure/demo. Neither has compojure dependencies included in deps.edn. Seems not using lein-template.


clj -A:new compojure myname/myapp -- the dot-clojure project is just aliases, read the clj-new project readme for details on how the underlying project works


@stardiviner The dot-clojure readme links to the clj-new project which explains the usage


And the deps.edn file in dot-clojure has usage examples too -- not sure what I could do in the dot-clojure readme to make anything clearer (it deliberately links to all the projects it provides aliases for) but concrete suggestions are always welcome...


Which template you use determines what type of project gets generated. compojure uses Leiningen (`compojure/lein-template` is the artifact that is used) so you get a project with project.clj -- clj-new has no control over that.


Did I misunderstand this clj -A:new funciton?


I am having problem with Emacs, Cider and Weasel. I can connect to a browser repl and eval code from the repl and that will effect my browser. So cljs.user> (js/alert "Hello world!") works just fine. But when i do cider-eval-last-sexp in one of the project files it gives me an error, anyone faced this?


I'm implementing github oauth in a webapp. In a nutshell my problem is that on the initial request where the user authenicates the app the ring session is lost, but on following requests the oauth flow works fine. In slightly more detail, here is what happens in the code step by step: 1) On a login-with-github route, my app sets a random "state" value in ring session and return redirect response to ... 2) On Github: the user authorizes the web app and github redirects the user back 3) On the target URL that github returns the user to with a temporary access code the ring session is empty {} The state value that is required to exchange the code for an access token is not available --- at this point in time the app has successfully been authorized. --- 4) On a new request, exactly the same code is run as in 1) 5) Because the app already is authorized, github redirects the user back to the webapp immediately with the temporary code 6) On the target URL that github returns the user to with a temporary access code the ring session this time is not empty but contains all the expected data So on "my" side the same code runs in both cases. Github redirects to the same URL. Any ideas why the session is lost in the first case? The only difference I can see are the couple of seconds it takes a user to click the "Authorize" button on github. Small udate: the session is lost because the cookies are lost. Now the question is, why are the cookies lost in the once case and not the other?

Denis G13:06:03

Is spec still in alpha?


But it’s used a lot

Denis G13:06:24

Wanted to import the spec namespace in order to generate regex parser, instead of writing my own, and figured out the spec is in alpha. Even though I though it was introduced a long time ago

Denis G13:06:38

Are there any reasons why it’s still alpha?


It’s not perfect yet 🙂


There probably will be some breaking stuff, probably breaking libraries like spec-tools.

Alex Miller (Clojure team)13:06:19

there are some changes under way that will alter the spec implementation (api is likely to stay pretty close to current)


In Datomic how would I model a Runner's time during a race? for example "Alice" started at 10:35 but is still currently running. Would I have a :end nil then (update :end (now)) when she finishes?


But then I need to ask question about the system such as "Who is currently running?"

Alex Miller (Clojure team)14:06:35

you can’t transact a nil (as it’s the absence of data), so you would just add the :end attribute when done

Alex Miller (Clojure team)14:06:11

and you can query for entities that have an :end attribute

Alex Miller (Clojure team)14:06:42

btw, prob better to ask this stuff in #datomic


clj -A:new compojure myname/myapp -- the dot-clojure project is just aliases, read the clj-new project readme for details on how the underlying project works


How would I handle distributed transactions in clojure? I was looking at this elixir library and curious how I would do something like this in clojure. Core.async?


I think I saw support for this in Immutant? By way of wrapping a Java lib... and needs to be run inside the WildFly container... no personal experience.

Denis G22:06:45

what’s the spec for data that looks like this → “(” + expr + “)” I was trying to do like this, but no results:

(s/cat :left-br #"\("
       :expr ::expr
       :right-br #"\)")


with spec, the data is already a data structure


"(" + expr + ")" is typically what you would see if you are trying to parse a stream of text in to a datastructure


what are you trying to do?


I'm trying to query a database via jdbc and return json using clojure. I think this should be easy, but I haven't found any example doing a search. Any examples y'all could recommend?


java.jdbc returns clojure datastructures, cheshire or data.json both encode clojure data structures into roughly the equivalent json


something like (json/write-str ( ...)) using data.json will give you the entire result set as a json array of objects