This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-04
Channels
- # aatree (5)
- # admin-announcements (37)
- # alda (1)
- # announcements (4)
- # architecture (1)
- # aws (3)
- # beginners (82)
- # boot (230)
- # braid-chat (14)
- # cider (48)
- # cljs-dev (8)
- # cljsrn (31)
- # clojars (47)
- # clojure (72)
- # clojure-austin (2)
- # clojure-russia (396)
- # clojurescript (72)
- # community-development (3)
- # component (6)
- # core-async (6)
- # cursive (26)
- # datomic (42)
- # emacs (6)
- # events (35)
- # hoplon (57)
- # immutant (3)
- # jobs (2)
- # jobs-discuss (10)
- # ldnclj (16)
- # luminus (2)
- # off-topic (50)
- # om (181)
- # parinfer (285)
- # proton (68)
- # re-frame (19)
- # reagent (2)
- # ring-swagger (23)
- # yada (36)
any one got ideas for building a clojure app for a newlearner coming from Ruby? [1:04] maybe suggest porting some existing Ruby gem?
amrit what kind of project?
@samlinncon: anything interesting and easy enough to start off with and iterate
you are familiar with the syntax first?
okay,you can check out luminusweb which is a framework for building web apps in clojure
@amrit: Database clients, markdown parser, a custom datatype, ... :)
that am not yt that good
@amrit: what kind of libraries have you built before?
@martinklepsch: have you used luminusweb before?
@samlinncon: briefly
worked with sessions in the framework?i could use some help
@samlinncon: don't remember anything about that. I'd recommend to just ask, some people in here might know and be happy to help :)
@martinklepsch @samlinncon Would you guys have experience in session management using ring middleware?
@udit: as said earlier: you're most likely to get help if you state your problem and ideally provide some code to give context
i’m looking for some ideas to solving a small problem: given a number of length 1 to 8 digits, return an 8 digit number filling in with leading zeros, then split it into two 4 digit pieces
making some progress here:
((fn prod-dir [prod-id]
(loop [p (str prod-id)]
(if (= 8 (count p))
p
(recur (cons 0 p)))))
22747)
(defn fx
[n]
(let [n' (str n)
c (- 8 (count n'))
cl (partition 4 (str (clojure.string/join (repeat c 0)) n'))]
(str (-> cl first clojure.string/join) " " (-> cl second clojure.string/join))))
(partition 4 (format "%08d" 25467))
((\0 \0 \0 \2) (\5 \4 \6 \7))
Then you have to do the string/join on each of those
(defn prod-dir [prod-id]
(loop [p (str prod-id)]
(if (= 8 (count p))
(str (apply str (take 4 p)) "/" (apply str (take-last 4 p)))
(recur (cons 0 p)))))
(defn fx
[n]
(let [cl (partition 4 (format "%08d" n))]
(str (-> cl first clojure.string/join) " " (-> cl second clojure.string/join))))
my solution probably stinks, but it still felt good to glue things together and make it work.
The more you use Clojure, the more you’ll find yourself composing functions rather than writing an iterative approach.
When it lends itself to clarity, yeah, so if I’m chaining two or more functions, I usually use it.
And I use it a lot in the REPL because it’s easy to just CTRL-up and add another function to see.
i’ll have to experiment with that. i do find things reasonably readable without it, but my second pass at learning to code i was talked into common lisp (a gentle guide to symbolic computation) — perhaps i’m used to reading inside out
hi all (sorry for bashing into the convo @akiva & @chadhs).. i’m hitting a Unable to resolve var: routes
issue while following this manual https://devcenter.heroku.com/articles/clojure-web-application.. Does this point to a particular beginners mistake I’m unaware of?
Clojure doest't hoist so it'll need to come first in the file
Before it's used.
a bit of a tangent but… @timaeus: if you want to know how to push that to a stand alone server and not just heroku i did a quick write up for digitalocean: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-clojure-web-application-on-ubuntu-14-04
There is a declare
command that allows you to refer to a var that hasn’t yet been defined.
It’s not widely used, though. I like having functions in alphabetical order so I use it personally.
@jeff.engebretsen: @akiva thanks, I’m not really set on putting the routes at the bottom but it seems that wherever I put the defroutes i can’t start the server
What's the idiomatic thing to do? I'm coming from Java and I really like having the method definition appear after first use.
It didn't work with defroutes
before -main
?
Jeff, I don’t see declare
used a lot in the wild. Seems most people put the actual definition right before its first call from another function.
Same issue. You need index
then defroues
then -main
Since routes references index
I guess I'll just get used to the Clojure way.
How do datomic and Clojure tend to work together if you're not ready to make your front end stack Om or Om Next?
(I’ve not used it, mind you; I just doubt the idea of it being tightly coupled to a particular front-end library.)
i’m trying to add a result processor for yesql (and luminus) like this:
(db/get-tenant {:tenantid tenantid} {:result-set-fn first})
I’m getting the following error when i execute the query: IllegalArgumentException db-spec {:result-set-fn #object[clojure.core$first__4339 0x7eee991b "clojure.core$first__4339@7eee991b"]} is missing a required parameter clojure.java.jdbc/get-connection (jdbc.clj:292)
The query works just fine without the processor. Anybody can point my on the right direction?@akiva: I agree I'm just not sure about interfacing with it I guess is my major question
@kamuela Datomic will take/give plain old Clojure data structures.
Found my problem. In case somebody finds it useful it turns out that conman (used by luminus) adds a wrapper to yesql. https://github.com/luminus-framework/conman/commit/73098c925b61971b41df0ebe41f7fc612acea4eb this is how i am using
(db/get-tenant {:tenantid tenantid} @db/*db* {:result-set-fn first})