This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-24
Channels
- # aws (3)
- # aws-lambda (1)
- # beginners (16)
- # boot (36)
- # cider (3)
- # cljs-dev (90)
- # cljsjs (1)
- # cljsrn (27)
- # clojure (240)
- # clojure-austin (1)
- # clojure-berlin (3)
- # clojure-dusseldorf (2)
- # clojure-france (2)
- # clojure-germany (12)
- # clojure-russia (19)
- # clojure-spec (20)
- # clojure-uk (56)
- # clojurescript (218)
- # clojurex (1)
- # cursive (21)
- # datomic (10)
- # events (1)
- # hoplon (18)
- # instaparse (19)
- # jobs-discuss (3)
- # lein-figwheel (3)
- # luminus (3)
- # lumo (14)
- # off-topic (4)
- # om (76)
- # onyx (67)
- # protorepl (12)
- # re-frame (54)
- # reagent (35)
- # ring (2)
- # spacemacs (5)
- # specter (2)
- # sql (11)
- # untangled (144)
- # yada (34)
Anyone want to recommend a CS related book or blog post i read on the plane tomorrow?
Any subjects in particular that you're looking for? If you want Clojure-related Clojure Applied and The Joy of Clojure are great. The Pragmatic Programmer and The Effective Engineer are cool if you want something more general (perhaps more related to working in the software industry than pure CS).
Getting this error: java.lang.IllegalArgumentException: Body may not be null
with this request:
(client/post <url>
{:body "test"
:multipart [{:name "distributor_id" :content 1419}
{:name "scenario" :content "fair_pricing"}
{:name "file" :content ( "/Users/josh/Desktop/rd/bronx-download2017-02-24T01-59-25-321Z.csv")}]}
)
with this lib: https://github.com/dakrone/clj-httpwhat version? that looks very similar to this issue https://github.com/dakrone/clj-http/issues/287, which my read is it was the result of having :content be something that it doesn't know how to handle, in this case a number instead of a string
@bozhidar I finally started using the cider-debugger, and now I can’t think about not using it. Thank you
Still can't get ntlmauth to work with JTDS for MS SQL 😞 ... "SSO Failed: Native SSPI library not loaded". Tried every possible solution on the net.
I'm trying to use lein to spin up a server, then run some postman tests against it, then spin it down.
tjtolton somthing like -> (-> (java.lang.management.ManagementFactory/getRuntimeMXBean) (.getName))
Lein trampoline
niiiiiice, thanks @pesterhazy
you need to (slurp body)
@pesterhazy thank you!
Anybody here today that's familiar with using windows ntlm auth for sql server with jTDS?
nvm. after huge amounts of wasted time, finally got it right. Need to be very careful of x86 vs x64 of your java version (NOT your machine), and ensure ntlmauth.dll goes into all your jre and jdk "bin" and "jre/bin" folders
hello guys, core.async
issue here ^^
Does anyone ever seen this =>
(when-let [[v c] (a/alts!! [input-channel timeout])]
...))
I got this error =>
No implementation of method: :take! of protocol: #'clojure.core.async.impl.protocols/ReadPort found for class: clojure.core.async$timeout
everything is not in a go
block but when I put it in a go block it’s working..
@doglooksgood If I were going to build a web crawler I’d do a search for “clojure selenium” and use some of the webdriver stuff.
I used clj-webdriver back in the day, but it looks like that is no longer maintained.
my demand is pretty simple, I don't need to handle AJAX request. just need a parser to parse html string to struct(maybe hiccup), and a selector to extract the content that I want.
hmm, maybe hickory then? https://github.com/davidsantiago/hickory
This is what I want! thanks! @manutter51
Awesome :thumbsup:
OMG. I'm cursed with jTDS and SQL Server. I believe I found my problem ... a known bug in jTDS for SQL Server and SSL connections 😞 : https://sourceforge.net/p/jtds/patches/129/
Switched to MS SQL JDBC ... worked first time :S . FYI, followed these instructions: https://micahasmith.github.io/2014/11/18/clojure-mssql-sql-azure/
grats on that one @micahasmith
Usually JDBC is rock solid
Can anyone recommend a simple project template for a server app? It should tick the following boxes - HTTP server - some sort of routing - easy reloading/restarting of the system, either manually through the REPL or automatically, when files change
pesterhazy: I'm partial to this one: https://github.com/danielsz/system-dependency-injection/tree/master
ah yes! 🙂
it could use component or mount but I'm not tied to either
@pesterhazy take a look at Pedestal (http://pedestal.io/)
How can I flatten the list in this vector? [[:a {}] '([:a {}] [:b {}]) [:c {}]]
@danielgrosse what should be the output?
i've used yada & bidi and been very happy with them @pesterhazy - they are all wrapped up in https://github.com/juxt/edge
I'm a fan of bidi so I should check out those other 4-letter words
@pesterhazy I now used (vec (apply concat [[:a {}] '([:a {}] [:b {}]) [:c {}]]))
Oh. not the right output
It should be [[:a {}] [:a {}] [:b {}] [:c {}]]
@ddeaguiar good point on pedestal, I always forget that one
@danielgrosse you'll probably have to write your own selective flatten fn
@danielglauser if you need speed and don't care about laziness (I guess you don't, hence the vec
) you can use this:
@danielgrosse with specter it's just (transform (srange 1 2) first [[:a {}] '([:a {}] [:b {}]) [:c {}]])
@baptiste-from-paris your issue is that you did not actually create a timeout channel. you are trying to take from the timeout
function. so, you need to say:
(when-let [[v c] (a/alts!! [input-channel (timeout 1000)])] ....
Don't understand why korma's defentity macro doesn't accept e.g. (defentity (symbol "mytable") (table "mytable"))
(defmacro defentity "Define an entity representing a table in the database, applying any modifications in the body." [ent & body] `(let [e# (-> (create-entity ~(name ent)) ~@body)] (def ~ent e#)))
@placeboza you call name
on (symbol "mytable")
, that won't work
Repaste:
(defmacro def-korma-entity-by-name
"Define an entity representing a table in the database, applying any modifications in the body."
[ent-name & body]
`(let [e# (-> (create-entity ~ent-name)
~@body)]
(intern *ns* (symbol ~ent-name) e#)))
(doseq [t tables]
(def-korma-entity-by-name (:name t) (database rbe) (table (str (:schema t) "." (:name t)))))
you can also edit posts -- ...
when you hover over your message and choose to edit, or up arrow for most recent message
@joshjones thx I’ve seen my mistake, I really need sleep ^^
@placeboza what do you mean by that?
Im sure you can use a macro on an existing macro's expansion , but guessing you can't modify what the macro does with another macro
Of course , this is crazy talk and would make the coding gods strike me down because it's horrible to do
actually, while I'm putting in intern *ns*
, it's an opportunity to keep all these dynamically created symbols in a separate namespace instead of *ns*
placeboza: FWIW there are many clojurists who share your reservation about korma’s use of vars.
My sense is that most clojurists using sql prefer hugsql or honeysql to korma these days
Tx @U04V4HWQ4 good to know im not alone :)
Anyone have any passion open source projects they're working on (in Clojure)?
Links? 😃
is there any official documentation on how to extend say a Java collection type to ISeq or other protocols? ie, which methods must be implemented?
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Seqable.java is a much easier target (assuming you can easily generate a seq over whatever)
is there something for clojure that lets you do static analysis of code? something like a super-linter?
for example, be able to find instances in the code that doesn't follow a particular convention would be an example
@risto check out Eastwood… there’s another one too, name escapes me right now...
@seancorfield thanks 🙂
No idea whether it works with cljs — check the docs.
The other one is called kibit, I just remembered.
@risto If you're using boot, there is always boot-check https://github.com/tolitius/boot-check
Could an experienced clojure/lisp engineer recommend good sources for thinking in recursion? I’ve been professionally coding in clojure for four years (ten more in jvm/js), and though I’m now in an immutable mindset, I still struggle to solve problems with recursion.
beat me to it
I’d like to try out the examples in Clojure (though it lacks TCO) to focus on refactoring existing code and libraries. Reading Scheme and SICP takes me an abstraction away from the tools.
I'd recommend those SICP video lectures because they will force you to think in terms of substitution instead of iteration
Interesting. Do you think it’s possible to implement the examples in Clojure, along the way?
from my experience, one doesn't need recursion very often in Clojure
@joshjones writing clojure?
once you have powerful HOFs, with combination with comp, partial, the need for recursion is scarce
I’ve written a few recursive functions with mutable data inside (transient/persistent!) to do some transformations on large records. But thinking in recursion doesn’t come naturally to me—immutability does.
@pri This is possibly an obvious and dumb suggestion -- but when solving problems recursively, you really have generally two cases -- the case for termination, which you hit once, and the case for recursion, which happens every other time. If you can clearly identify the terminating case, it often becomes easier to think through the problem.
That sounds good, but do you think outside of processing lazy seqs (that supposedly abstracted away recursion), thinking in raw recursions is an advantage?
Is it possible, for instance, to “rewrite most functions in my library” with just primitives in recursion—whatever that means.
substitution is important because it is easier to reason about than iteration. Stacks represent the total # of steps a procedure has to perform to complete
ok just making sure it was clear that the evaluation of the loop is not done that way
@pri you said: "do you think outside of processing lazy seqs (that supposedly abstracted away recursion), thinking in raw recursions is an advantage?" An advantage over thinking iteratively? Well, for clojure, I think so. To me it's another case of declarative vs imperative; a recursive solution almost defines the solution in terms of the problem itself, and looping defines specifically how to do it.
At the instruction level it all goes back to jumps, pushes and pops anyway, but that's another story
But Clojure’s lazy sequences allowed us to forget about recursion, and I often wonder what I’m “missing” as I haven’t seen a wide adoption of recursive problem solving. Do you have a problem to share, along with a before/after codesize to demonstrate its advantage?
they are exactly that, notice the recursion on line 2859: https://github.com/clojure/clojure/blob/clojure-1.9.0-alpha14/src/clj/clojure/core.clj#L2855-L2859
hey guys, could somebody shed some light on this code? i cannot grasp it:
(def everything (-> (run hello)
(assoc :path "/howdy")
(->> (run howdy))
(merge {:path "/" :port 8081})
(->> (run hola))))
@pri I don't have a sample problem with several solutions to demonstrate approaches, on hand -- but in a language which provides only one primitive for looping (that I know of -- is there another?), the loop
special form (which is identical to recursion, except that it enforces a tail call so it's stack friendly), problems are solved everywhere with recursion, especially under the hood. Now, that may be abstracted away and therefore you may not have to use recursion yourself that much, so only you can judge whether it should be a priority or not for your programming 🙂
user=> (clojure.pprint/pprint (clojure.walk/macroexpand-all code))
(run
hola
(merge
(run howdy (assoc (run hello) :path "/howdy"))
{:path "/", :port 8081}))
loop/recur technically provide iteration, recursion with a bounded stack, for just plain recursion you can just call a function
@istvan combining thread first and last is usually better done with as->
, in that case you'd probably find it easier to read
the terminology is confusing because tail recursion (loop/recur) can be optimized to very efficient iteration, which is good, so people often conflate tail recursion with recursion
(fn f [] (f))
is a recursive function, which will run out of stack space. (fn f [] (recur))
is recursive too, but also iterative, so it won't run out of stack space and will just loop forever
Thinking in recursion has come after working in core.async for a year. But outside of core.async, I don’t often write loop-recurs. @hiredman how would one implement a lazy seq on a stack?
well just take something that creates a lazy seq and do it without the laziness, which would just be a list
priyatam funny you talk about recursion, just yesterday i had to solve a problem where recursion (even do without using recur and loop) helped a lot
recursion and iteration are classifications in the zoology of processes, not really tied to particular constructs in a programming language
@hiredman Yes, but iteration requires constructs in a language that recursion does not
@joshjones that is not always the case
priyatam sure, this is the example from yesterday, i get messages with nested data structures like {:user_name "joe" :address {:city "SF" :state "Cali" }}
goto is a detail of the target language, the source language may not have an implicit iteration construct, but still create iterative processes depending on how it is mapped to the target language
i wrote a simple recursive call that walks in the hashmap and when finds a subhash calls itself with the subhash
(i know there are tools like zip, walk etc. this is a special situation i needed to implement something myself)
for example scheme doesn't have any kind of explicit iteration construct, if I recall, so programs that result in an iterative process look the same as programs that are recursive
I thought we were talking about the point of view of the programmer, who's writing in one language. From his/her perspective, it doesn't matter how it's translated into something else
that is my point basically, iteration and recursion are properties of the execution of programs, not static properties, so it does matter
So if I'm writing scheme, and it has no explicit iteration construct, how do I solve a problem using iteration, and not recursion?
you have to know that the compiler can optimize code that would result in a recursive process when it has the right shape in to a iterative process
So you're saying that because the compiler converts a recursive process into an iterative process (which they all do), ... that affects me how, as I'm writing the program? Or maybe I'm missing you
sicp and that video of the lecture from a sicp class I linked both describe the shape of recursive and iterative processes
an iterative process is constant space, a recursive one is bound by the input in some way
I think I understand what you're saying -- and I agree, but it's a fact that some languages provide syntactic "helpers" to iterate. That's all I'm saying
yeah i have this, a lazy-seq version, lying around
(def fibs ((fn fib [a b]
(lazy-seq (cons a (fib b (+' a b))))) 0 1))
http://agl.cs.unm.edu/~williams/cs491/three-imp.pdf is neat paper, it includes compiling scheme for a very different execution environment, some kind of graph reduction machine
@istvan I’ve worked in core.async for a while and got used to recursion, but unable to think recursively for the rest of my code. Looking for more inspiration to think recursively in other areas.
@pri i've been looking through this book "how to design programs" and it has a pretty good discussion of recursion and exercises http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-32.html
Hi everyone, nice to meet so many clojurians!
@pri may i suggest writting the toposort algorithm in strict tail recursive fashion(i.e. using recur in every tail)
@paulocuneo algorithms don’t excite me, but I'll try, thanks