Fork me on GitHub
#beginners
<
2018-06-04
>
stardiviner06:06:41

Does Leiningen has a way to search templates?

seancorfield07:06:33

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

stardiviner07:06:41

@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.

seancorfield07:06:02

That should give you a fairly complete list.

seancorfield07:06:51

Just FYI, boot-new supports both Leiningen templates and Boot templates https://clojars.org/search?q=boot-template

seancorfield07:06:22

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

rt8507:06:52

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) ?

seancorfield07:06:21

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

rt8507:06:36

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

seancorfield07:06:11

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

seancorfield07:06:25

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

seancorfield07:06:45

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

rt8507:06:17

thanks for your input. @seancorfield

stardiviner07:06:29

@seancorfield clj-templates? Thanks

seancorfield07:06:25

@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).

seancorfield07:06:18

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

stardiviner07:06:58

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

seancorfield07:06:37

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

seancorfield07:06:51

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

stardiviner07:06:25

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

seancorfield07:06:02

If you're using the clj script, having clj-new as an alias is convenient -- https://github.com/seancorfield/dot-clojure

stardiviner07:06:20

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

seancorfield07:06:56

Possibly. Mostly cosmetic updates lately tho

stardiviner07:06:19

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

stardiviner08:06:48

@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].

stardiviner08:06:11

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.

seancorfield15:06:36

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

seancorfield15:06:20

@stardiviner The dot-clojure readme links to the clj-new project which explains the usage https://github.com/seancorfield/clj-new#general-usage

seancorfield15:06:00

And the deps.edn file in dot-clojure has usage examples too https://github.com/seancorfield/dot-clojure/blob/master/deps.edn#L46 -- 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...

seancorfield15:06:01

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.

stardiviner08:06:20

Did I misunderstand this clj -A:new funciton?

jherrlin08:06:39

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?

vinai12:06:02

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?

vinai13:06:13

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?

gklijs13:06:22

It’s not perfect yet 🙂

gklijs13:06:59

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

alexmiller13:06:19

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

grierson13:06:12

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?

grierson14:06:19

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

alexmiller14: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

alexmiller14:06:11

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

alexmiller14:06:42

btw, prob better to ask this stuff in #datomic

dfcarpenter17:06:00

How would I handle distributed transactions in clojure? I was looking at this elixir library https://github.com/Nebo15/sage and curious how I would do something like this in clojure. Core.async?

orestis20:06:46

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 #"\)")

hiredman22:06:07

with spec, the data is already a data structure

hiredman22:06:56

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

hiredman22:06:10

what are you trying to do?

voortuck22:06:29

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?

hiredman22:06:51

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

hiredman23:06:25

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