This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-02
Channels
- # aleph (6)
- # beginners (57)
- # boot (1)
- # cider (27)
- # clara (23)
- # cljs-dev (166)
- # clojure (287)
- # clojure-dev (23)
- # clojure-greece (1)
- # clojure-italy (2)
- # clojure-russia (13)
- # clojure-spec (34)
- # clojure-uk (36)
- # clojurescript (68)
- # core-async (63)
- # core-logic (1)
- # cursive (1)
- # data-science (1)
- # datomic (26)
- # duct (1)
- # emacs (10)
- # figwheel (8)
- # fulcro (2)
- # garden (16)
- # graphql (8)
- # hoplon (20)
- # jobs (2)
- # leiningen (10)
- # off-topic (16)
- # onyx (2)
- # portkey (5)
- # quil (1)
- # re-frame (63)
- # reagent (95)
- # reitit (6)
- # remote-jobs (1)
- # ring (6)
- # rum (1)
- # shadow-cljs (76)
- # spacemacs (26)
- # specter (11)
- # sql (7)
- # unrepl (68)
- # vim (2)
- # yada (2)
@duminda I would try removing some handlers until you get something working again (albeit less functional while you are debugging)
I've got some maps. I need to sort them so that they're first sorted by gender (females first, then males or non-binary people), and then sorted by last name. Here's my custom comparator, followed by an example I found that sorts strings by length and then alphabetically, followed by my failing attempt to duplicate that logic---
I can kinda see that mine has a different shape but, I'm not sure how to correct it. I'm kinda confused by the sort-by docs
Maybe I need to use sort? But, I'm fuzzy on how composition of comparators works, in any case
@mathpunk A couple things. You are trying to mix the arity of :gender
and :last-name:
(which takes one map, the way you’re using it) and compare-gender
which takes two arguments. Could I recommend the following?
Please --- I'm all messed up on arity over here, I can't quite tell how sort-by is applying the fn
if you score the gender as a unary function, it’s very close to what you seem to want.
(type (int 10)) returns java.lang.Integer. How do i create a primitive int in clojure?
here -
is unary, just negating the score, so you get high-to-low values for gender
OH. See I thought the example function was counting, checking the difference, and getting - or + or 0 that way
thanks @eigenhombre!
sure!
@oliv "exit" isn't a clojure thing, it's a thing nrepl does, so if you make your own repl it won't work
@rgorrepati inside a function the compiler can inline calls that use primitives, but that isn't done for type because type isn't declared to take a primitive arg
@rgorrepati if you need to ensure that numerics are inlined, check out *warn-on-boxed*
<http://insideclojure.org/2014/12/15/warn-on-boxed/>
Boxed math warnings – Inside Clojure
Tales of Developing Clojure
Is there a good tutorial aimed at complete newbs for debugging in clojure and clojurescript? (I mean, it shouldn’t assume familiarity with the language or the environments) I am especially interested in these: 1. debugging cljs code in figwheel repl 2. Debugging compojure ring handlers
this is really good: https://aphyr.com/posts/319-clojure-from-the-ground-up-debugging
This one shows a nice technique: http://blog.cognitect.com/blog/2017/6/5/repl-debugging-no-stacktrace-required
There's also a debugger you can use in editors like emacs, Intellij, and I suspect others.
It's been a few days since I took interest in Clojure, today I dived a bit into control flow and this simple operation brought me so much joy.
(if (nil? nil)
(do (println "Success!")
"nil? nil returned true")
(do (println "Failure!")
"nil? nil returned false"))
It feels so natural, I haven't experienced this with any other programming language. I'm excited to see what else Clojure brings me! 😄in the real world you'd probably use if-not
there though
Makes sense, thank you @joelsanchez!
Also keep in mind that nil is falsy, so that plain (if-not nil... will also work. But of course false is also falsy, so it's not quite the same.
Hi all, I need some help with com.rpl.specter
. I have this:
(let [data [{:id :a
:name "A"}
{:id :b
:name "B"}
{:id :c
:name "C"
:age 20}]
ids #{:b :c}]
(->> data
(specter/select [specter/ALL (comp ids :id)])
(specter/transform [specter/ALL] (juxt :name :age))
(specter/select [specter/ALL specter/ALL some?])))
;; result is ["B" "C" 20]
Basically I need to get the given fields, in this case it's :name
and :age
, from data
whose :id
is in ids
, place it in a single vector filtering nil values. It works, but can this be improved? Thanks!@funyako.funyao156 Prob:
(->> data
(sp/select [sp/ALL (sp/selected? :id ids)
(sp/multi-path :name :age)
some?]))
@funyako.funyao156 (select [ALL (selected? :id #(contains? ids %)) (multi-path (must :name) (must :age))] data)
the highly scientific benchmarks I just performed in the repl seem to indicate that your version is 2x faster 🙂
Btw is it right that selected?
works just like a predicate with selected path but don't actually select the element itself? Maybe the way I'm wording it is a little bit confusing....
@funyako.funyao156 yes, that’s how it works
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.
- How to track the source of this bug?@duminda could we get a little more context? E.g. paste what commands caused the above message.
@eigenhombre:
lein ring server-headless
proj file:
(defproject npuzzle "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.908"]
[re-frame "0.10.5"]
[garden "1.3.2"]
[ns-tracker "0.3.0"]
[yogthos/config "0.8"]
[day8.re-frame/http-fx "0.1.5"]
[metosin/compojure-api "1.1.11"]
[org.clojure/data.priority-map "0.0.7"]]
:plugins [[lein-cljsbuild "1.1.5"]
[lein-garden "0.2.8"]]
:ring {:handler npuzzle.handler/app}
:min-lein-version "2.5.3"
:source-paths ["src/clj" "script"]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
"test/js"
"resources/public/css"]
:figwheel {:css-dirs ["resources/public/css"]
:ring-handler npuzzle.handler/dev-handler}
:garden {:builds [{:id "screen"
:source-paths ["src/clj"]
:stylesheet npuzzle.css/screen
:compiler {:output-to "resources/public/css/screen.css"
:pretty-print? true}}]}
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:profiles
{:dev
{:dependencies [[binaryage/devtools "0.9.4"]
[day8.re-frame/re-frame-10x "0.2.0"]
[figwheel-sidecar "0.5.13"]
[com.cemerick/piggieback "0.2.2"]
[javax.servlet/javax.servlet-api "3.1.0"]]
:plugins [[lein-figwheel "0.5.13"]
[lein-doo "0.1.8"]
[lein-ring "0.12.0"]]}}
:cljsbuild
{:builds
[{:id "dev"
:source-paths ["src/cljs"]
:figwheel {:on-jsload "npuzzle.core/mount-root"}
:compiler {:main npuzzle.core
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:asset-path "js/compiled/out"
:source-map-timestamp true
:preloads [devtools.preload
day8.re-frame-10x.preload]
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:external-config {:devtools/config {:features-to-install :all}}}}
{:id "min"
:source-paths ["src/cljs"]
:jar true
:compiler {:main npuzzle.core
:output-to "resources/public/js/compiled/app.js"
:optimizations :advanced
:closure-defines {goog.DEBUG false}
:pretty-print false}}
{:id "test"
:source-paths ["src/cljs" "test/cljs"]
:compiler {:main npuzzle.runner
:output-to "resources/public/js/compiled/test.js"
:output-dir "resources/public/js/compiled/test/out"
:optimizations :none}}]}
;:main npuzzle.server
;
;:aot [npuzzle.server]
;
:uberjar-name "npuzzle.jar"
:prep-tasks [["cljsbuild" "once" "min"]["garden" "once"] "compile"])
I had an existing re-frame project and added dependencies from a compojure-api project
@duminda That’s a known issue, you can see the FAQ: https://github.com/technomancy/leiningen/blob/master/doc/FAQ.md (search for “insecure HTTP repository”). I think a lot of people deal with that by downgrading leiningen to an earlier version that wasn’t so strict
Hi everyone I have a little problem with transit-clj.
I get a transit string from the client side through a websocket connection.
It looks something like this ["^ ","~:message",["^ ","~:user-name","test","^0","test","~:ts",1520012789825]]
The transit documentation only shows how to use the this with an input stream. -> https://github.com/cognitect/transit-clj#usage
Is there way to parse it back to a map without turning it to an inputstream first?
This thread on google groups explains the same problem but it's dated back to 2014 without a real solution https://groups.google.com/forum/#!topic/transit-format/c_5BuPb1R1A
@ezekills the normal way to use it would be to make an input stream from the string
the string is not intended to be the normal format used by transit in jvm clojure
though if you have enough control of your design, you can get transit to decode instead of generating a string in many cases, which is a good thing
@noisesmith thanks for the quick reply. Ok so best case would be to let transit decode instead of generating a string when receiving it? How exactly is this done?
@ezekills: it looks like on-receive is doing some magic - if you are lucky there's a separate (or maybe lower level) thing you can do to get the input directly
or it could be that because of the way websocket messages are parsed, the easiest thing is to get a string, and create an inputstream from that to hand to transit