This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-05
Channels
- # adventofcode (41)
- # bangalore-clj (4)
- # beginners (283)
- # boot (62)
- # clara (9)
- # cljsrn (3)
- # clojure (112)
- # clojure-brasil (1)
- # clojure-greece (1)
- # clojure-korea (6)
- # clojure-russia (99)
- # clojure-spec (29)
- # clojure-uk (12)
- # clojurescript (34)
- # clojurex (5)
- # core-logic (1)
- # cursive (31)
- # datomic (30)
- # devcards (5)
- # editors (19)
- # emacs (31)
- # events (5)
- # garden (4)
- # hoplon (137)
- # lein-figwheel (3)
- # luminus (4)
- # mount (7)
- # off-topic (7)
- # om (18)
- # om-next (3)
- # onyx (88)
- # proton (1)
- # protorepl (6)
- # re-frame (48)
- # reagent (15)
- # spacemacs (41)
- # testing (1)
- # untangled (2)
- # yada (18)
Via clojure.tools.namespace
, is there a way to manually signal to the reloader what other namespaces my namespace depends on, rather than let it infer that from the ns
form?
@aengelberg: When you say "manually signal to the loader what other namespaces my namespace depends on," in what way are these manual signals different from arguments passed to the ns declaration via :require/etc?
When working with websockets, is it usually better to (A) define multiple event server-side handlers that all dispatch on a generic message from the client , or (B) emit different kinds of messages (e.g., a "login event message," a "form submit message") " and consume them with a single server-side handler?
what is the most efficient way to test to see whether a set of keys exists within a map?
i'll be doing this for every transforming function (will probably have around a thousand or so), 60 times a second in a game loop
You'd have to benchmark, but it's possible that some of the clojure.set functions applied to a set
of the keys would be fast.
Might be worth toying with reducers, to see if they're quicker than contains? For multiple lookups.
Seems to work once set literals no longer used: (every? (set (keys {:boolean false :something nil})) #{:boolean :something})
@bcbradley Sounds like speed might be important too. In that case I'd use reduce-kv
instead of keys
and set
. Probably a bunch faster
@andfadeev yep, for me too, i guess @bcbradley uses emacs and his cursor takes a wrong place for eval last expr.
@hippo I don't use emacs but you've got the right idea. The error was caused by my cursor being in the wrong spot during a block evaluation.
anybody interested in web scraping? i've built a selenium based DSL in clojure, and i'm looking for beta testers before i publicise it on github!
hey @dhruv, I have a side project that I could try it on
is there a way to alias the #_
reader macro to some other name, e.g., using tagged literals?
take care that for example I can have 10 pages of 10 articles and that all pages have a link so I can browse between the pages
@roelofw so you have a list of 100 articles, and you want a function that will return a slice of 10 of them, and then choose which slice you want?
@mpenet checkmate looks nice 👍
@martinklepsch there are already tons of libs like this, but they all took a weird direction imho
@mpenet yeah seen plenty, what I like about yours is that I can read and understand it in 10min 😄
Didn’t know about the first way to do it. Second is still shorter.
(use 'clojure.pprint)
(use '[ :as io])
(with-open [w (io/writer "/tmp/output.edn")]
(write obj
:stream w
:pretty true))
;; or
(spit "/tmp/output.edn" (with-out-str (pprint obj)))
Has anyone ever tried to read an EDN file which contains a BOM? Is that supposed to work? I just bumped into that.
does it work if you slurp first?
@pesterhazy I am just using edn/read
on a io/reader
where I am not defining an encoding. Do I have to?
@ska, I'd try doing (-> file slurp edn/read)
to see if that works with such a file
@pesterhazy funny thing is, I can read the EDN alright but when I try to create a seq of the keys
of it I get a "java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol"
try wrapping the reading in doall
laziness?
Ah, getting closer. edn/read
just returns an empty map right now. Still at repro stage, did not try your suggestion, yet.
I tested the function inside the 'fold' on a sample of 20 entries after the filter and it works
@fellshard sorry, but I don't know how to answer your question
I know what you're solving (hi, fellow Advent of Code player!) and you'll need something lazy like reductions
🙂
For this problem in particular, you'll really want laziness as long as you can manage
is this lazy? It doesn't say https://clojuredocs.org/clojure.core.reducers/reduce
Given it's supposed to be used in similar contexts to parallel distributed map-reduce, it wouldn't be very practical for these to be lazy...
Try using regular map
, filter
, and replace fold
with reductions
to see what happens.
@fellshard thank you, I will try to find the answer in the current library, if not, I will use map/filter/reductions from core
@fellshard oh amazing, didn't know advent of code was on again 😄
Nice! And yeah, finally realized the obvious - reduce
or fold
alone are always going to be eager, since they're trying to take an entire sequence down to a single value; you can't finish that computation without reaching the end of the list. Hence the nicety of reductions
. 🙂
Cool Clojure editor ideas: if functions that are lazy mark that fact in their metadata, an editor could highlight when you are likely making transitions between lazy and eager. Hmm....
@fellshard I have same issue. Clojure has conventions and special forms that make state change explicit, e.g. swap!
on an atom
or @state
to deref something, but it's not obvious when fn's process lazily or eagerly. As most are lazy perhaps the editors should highlight the eager evaluations instead?
Do I need to do anything besides include the dependency for https://github.com/fzakaria/slf4j-timbre to work? I added the dependency, but am still getting
log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See for more info.
Hey I just got back from Conj and weather delayed my plane for a bunch so I didn’t make it to bed until 3AM; gimme a break
confirm ^
I remember reading clojure applied and at one point they talked about the printing of object types so: #object[Object object] could be #<myType>. If my memory is not wrong, can someone send me an article/blog that covers this?
@dpsutton @richiardiandrea Thanks! Glad you liked it 🙂
@hlolli https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-16_edn-record.asciidoc ?
thanks @pesterhazy this will put me on the right track.
After watching the talks by Rich and Stu, I feel like I should try to actually namespace things correctly. Does anyone know of any good resources on how I should be doing this (not the technical how necessarily, more so that my projects will work nicely with everyone else).
someone here who knows how to deal with a background-image in css with luminus. I did now : background: url('img/old-wall.jpg') no-repeat center center fixed;
but no background-image. the image is in resources/public/img directory
@roelofw 1. can you open the image via localhost:XXXX/img/old-wall.jpg? 2. are you opening a subpage? (in which case '/img/old-wall.jpg') would be needed for relative path. otherwise there exists #css group.
then I guess that dom element you are targeting is not being displayed or other css rules are overwriting. You are welcome to send me your css and html in pm.
got a lead : on ff I see this error message : http://localhost:3000/css/img/old-wall
oh, you need to do background: url('../img/old-wall.jpg') no-repeat center center fixed;
I think or simply start with slash '/img/old-wall.jpg' that way it should ignore the css directory in which the stylesheet is located.