#clojure log - Jul 13 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

1:44 gratimax: anyone seen this? http://clochure.org/

1:47 dstockton: yes

1:48 wasamasa: lol

1:49 and what's their vector syntax then?

1:50 ah, it's (2 3 4)

1:50 gratimax: parentheses

1:50 wasamasa: so silly

1:50 gratimax: I'm like 90% sure it's an april fool's joke of some sort, just thought it would be fun to share

1:51 dstockton: it was an april fools joke

1:51 https://github.com/videlalvaro/clochure/

1:52 gratimax: mm

1:52 lol, in the repl the output is still the clojure representation

2:47 wasamasa: of course

2:48 how else are you gonna now it's working??

2:48 lazybot: wasamasa: Uh, no. Why would you even ask?

5:22 loke: I have a dilemma

5:23 And I need assistance from someone with more clojure experience than me

5:24 broquaint: loke: Go on ...

5:24 loke: yes, typing :-)

5:25 I have a value, let's call it "foo" with the following structure: {"key0" {:a "a0" :b "b0"} "key1" {:a "a1" :b "b1"}}. I then have a list of the following form: [{:id "key0" :a "some value"} ...]

5:25 I want to create a function that does the following:

5:26 Update "foo" with the content of the list, but only modify values that are actually included (and non-nil), otherwise the old vlues should be preserved

5:26 so the result of the above would be:

5:26 {"key0" {:a "some value" :b "b0"} ...}

5:27 Any new values that are not in "foo" should be added

5:27 My current solution is an incredibly hairy mess of union, remove, conj and reduce

5:28 justin_smith: loke: sounds like you want update-in

5:28 or maybe just assoc-in

5:28 loke: assoc-in? Hmm, never used

5:28 justin_smith: ,(assoc-in {:a {:b 1}} [:a :c] 2)

5:28 clojurebot: {:a {:b 1, :c 2}}

5:29 loke: Hmm... I need to think some more on this

5:31 related: Is there a standard way to do "map" on a map (in other words, transform the elements on a map). The best I have come up with is (reduce (fn [z [k v]] (conj z (THE-UPDATE))) {} THE-MAP)

5:32 TEttinger: loke: &(map (fn [[k v]] (str k "," v)) {"a" 1, "b" 2})

5:32 ,(map (fn [[k v]] (str k "," v)) {"a" 1, "b" 2})

5:32 clojurebot: ("a,1" "b,2")

5:32 loke: That results in a list though, I want the output to still be a map, but transformed

5:33 TEttinger: (doc zipmap)

5:33 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

5:33 TEttinger: no...

5:33 (doc map-kv)

5:33 clojurebot: Titim gan éirí ort.

5:33 TEttinger: (doc mapkv)

5:33 clojurebot: It's greek to me.

5:33 TEttinger: what was it...

5:33 justin_smith: (doc reduce-kv)

5:33 clojurebot: "([f init coll]); Reduces an associative collection. f should be a function of 3 arguments. Returns the result of applying f to init, the first key and the first value in coll, then applying f to that result and the 2nd key and value, etc. If coll contains no entries, returns init and f is not called. Note that reduce-kv is supported on vectors, where the keys will be the ordinals."

5:34 loke: Sounds very much like what I have. I wonder if the implmenetation is similar

5:35 justin_smith: it's probably similar but faster (using a transducer and/or transients)

5:35 TEttinger: ,(into {} (map (fn [[k v]] (str k "," v)) {"a" 1, "b" 2}))

5:35 clojurebot: #error {\n :cause "java.lang.Character cannot be cast to java.util.Map$Entry"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Character cannot be cast to java.util.Map$Entry"\n :at [clojure.lang.ATransientMap conj "ATransientMap.java" 44]}]\n :trace\n [[clojure.lang.ATransientMap conj "ATransientMap.java" 44]\n [clojure.lang.ATransientMap conj "ATransientMap.java" 17]\n [...

5:36 justin_smith: TEttinger: that's silly, you can only create a map out of two element vectors

5:36 TEttinger: right yes I forgot what I was doing

5:36 ~ambien dreams

5:36 clojurebot: Pardon?

5:37 TEttinger: clojurebot: ~~~ is the smooth wave calling you to sleep

5:37 clojurebot: Roger.

5:37 TEttinger: ~~~~

5:37 clojurebot: ~~~ is the smooth wave calling you to sleep

7:40 noncom: does emacs work over ssh in terminal mode ?

7:41 i try to start it like that, on an ssh session, but all i get is the prompt hanging until i ctrl + C and get back to the bash...

7:42 H4ns: do you have a DISPLAY variable set in your shell?

7:46 noncom: nvm, got it.. somehow it was launching without the -nw key :)

7:47 but i was thinking it did..

7:47 emacs is great!

7:47 the only downside (as i see it) is elisp...

7:48 but still much much much better that, say JS, within, say GitHub Atom or Adobe Brackets..

7:48 or python you know where

7:54 dottedmag: noncom: Do you really need emacs over ssh? tramp FTW

7:55 noncom: also with lexical-binding: t elisp is tolerable

7:56 noncom: hmmm, yeah, tramp is a nice option! but it won't make the shell accessible i think..

7:56 algernon: dottedmag: sometimes you run local commands on the remote host that want an editor, an emacs on the remote host is useful then.

7:58 dottedmag: noncom: eshell has some support

7:58 algernon: oh right, pretty much the only case when remote emacs is needed.

7:59 H4ns: dottedmag: what is wrong with using emacs through ssh?

7:59 dottedmag: H4ns: no GUI? Burden of syncing ~/.emacs? Different Emacs versions?

7:59 noncom: http://stackoverflow.com/questions/1346688/ssh-through-emacs-shell/1372805#1372805

8:01 * algernon is using remote emacs through ssh with a GUI, and keeps his ~/.emacs.d in sync with git.

8:09 wiruzx: Good evening

8:12 Could anyone please help me to fix this macro to be able to use it in threading(->) macro?

8:12 (defmacro <? [expr]

8:12 `(throw-err (<! ~expr)))

8:13 If I make it function composition, clojure will yell at me because it outside of go block

8:20 wasamasa: a macro without unquoting??

8:20 lazybot: wasamasa: What are you, crazy? Of course not!

8:20 wasamasa: phew, must be me seeing things

8:44 noncom: hah, so, emacs runs over ssh, yes... but with each new charecter i enter, it.. scrolls the screen and destroys the visual image... unusable... ?

8:44 (currently trying without tramp)

8:45 yeah, i generally want to replace the need for "nano somefile" with "emacs somefile" over ssh

8:45 H4ns: noncom: you've probably not set up your terminal type correctly

8:45 noncom: try "env TERM=vt100 emacs" to see whether that changes anything.

8:46 noncom: #emacs may be a more appropriate channel to get help with this, though.

8:46 noncom: yes, #emacs, but they often just ignore questions.. too much buzz goes over there... but i agree, i must better be asking in #emacs..

8:47 H4ns: noncom: no worries.

8:47 noncom: my experience with #emacs has also not been too good.

8:47 noncom: heh, term=vt100 works... sort of. it looks better, but still in some situations it cripples the visual.. nano works quite well though!

8:48 H4ns: noncom: then your TERM environment variable does not match what your terminal emulator actually supports.

8:48 noncom: frankly, i am not even hoping to get this resolved.. just asking what my odds are..

8:48 probably. i will research into this subject and read the manuals

9:39 hellofunk: if you repeat your question about three or four times in #emacs you will eventually get a good answer

9:39 not the shining example of good help, but works eventually

9:46 kwladyka: How to write this in most readable way? https://www.refheap.com/106526

9:47 i just want check if two conditions are true, but i want check second condition only if (= m n)

9:47 i can write this with "if" but i guess there is shorter way.

9:53 TMA: kwladyka: personally I would (defn solution-checker-rotate* [m n solutions] (or (not (= m n)) (solution-checker-rotate m n solutions)))

9:53 or just inline the (or)

9:54 schmir: kwladyka: (and (= m n) (solution-checker-rotate ...))

9:57 kwladyka: tma shmir thx

10:22 mmeix: What is the best method to find all possible combinations of n elements?

10:25 oddcully: clojure.math.combinatorics/permutations maybe?

10:25 mmeix: must work in clojurescript

10:26 zerokarmaleft: mmeix: I don't think there's any reason those implementations wouldn't work in cljs

10:27 mmeix: ok, will try

10:27 thnx

10:32 divya: Hello?

10:46 mmeix: hello

11:07 hellofunk: i am seeking the most elegant way to return the first positive number from a vector like [nil 0 :a 5 6 0]. i get (->> a (filter number?) (filter pos?) first) but seems rather verbose

11:11 dstockton: im trying to learn from the datascript source https://github.com/tonsky/datascript/blob/master/src/datascript/core.cljc#L341

11:11 can anyone explain the rationale behind defrecord-updatable, rather than having a normal record with mutable refs

11:14 i think the updatable bit is confusing me, its not really updating

11:21 its basically a way to defrecord on-the-fly?

11:22 jsabeaudry: When I rename-buffer my cider repl buffer, it does not work anymore, what is the proper way?

11:27 aztak: bazinga all! Switching to the LRU window (like in vim, C-w C-p) - how do I do that in Spacemacs?

11:27 Like C-6 for buffers.

11:31 ouch - sorry for that - obviously wrong channel!

11:31 I'll ask a Clojure question in the Spacemacs channel to compensate!

11:32 diyfupeco: aztak: Are you a long time vimer who switched to spacemacs?

11:32 aztak: diyfupeco: yupp, that's correct :)

11:33 diyfupeco: aztak: I thought about trying it, where do you see the advantages?

11:34 aztak: diyfupeco: it's a bit like comparing apples and oranges.. I get almost all of the text-editing goodness in VIM *and* I get access to all the Emacs ecosystem.

11:35 org-mode is the feature that pushed me over the edge - it's a killer feature.

11:35 diyfupeco: Hm, thanks.

11:35 I will try it.

11:46 scriptor: diyfupeco: I've also picked up emacs+evil-mode for clojure stuff

11:47 it's not too bad, I'll still keep using just vim for non-clojure work

11:50 diyfupeco: I am so afraid because it totally breaks my workflow. :D

11:52 scriptor: diyfupeco: what specifically about your workflow are you worried about?

11:56 diyfupeco: scriptor: My VIM is configured for quick actions with space as the leader key. Also ctrl+p and splits. Next thing is about connecting to the repl and execute something in it. And those little things like signify, multiple cursors and sayonara (all plugins).

11:57 Ah yeah, and undotree

11:57 scriptor: evil comes with support for splits, at the very least

11:58 and for the quick actions stuff, you can learn a minimum of elisp to recreate some of that

11:59 vaitel: I know that there is a multiple cursors plugin on melpa too.,

11:59 diyfupeco: Hm, ok. How about undo[dir|levels]?

12:00 vaitel: I'd be suprised if emacs wouldn't have one to be honest.

12:01 vaitel: diyfupeco: http://www.emacswiki.org/emacs/UndoTree

12:02 diyfupeco: vaitel: cool :)

12:02 Well, ok, I promise to try it. :D

12:02 wasamasa: emacs' undo system is sort of meh

12:02 diyfupeco: But please don't burn me when I try to recreate my vim expirience at first. :D

12:02 vaitel: I use evil-mode, and undo-tree is installed as a dependency.

12:03 wasamasa: I've had used undo-tree with persistency for some time and found out that the saved history did get truncated after too huge edits

12:03 vaitel: diyfupeco: that's pretty much exactly what I did when I first started with emacs.

12:05 diyfupeco: I think I'll switch to another channel now with my questions. :D

12:07 wasamasa: like, #emacs?

12:08 diyfupeco: wasamasa: #spacemacs on gitter.im is more suited at the moment I think. I joined #emacs anyway.

12:10 wasamasa: right

12:10 the_frey_: multiple cursors on emacs is okay, it's not quite as good as vim

12:10 aztak: diyfupeco: also check irc.gitter.im

12:10 the_frey_: and imho both are worse than sublime text

12:10 *for multiple cursors

12:11 the st implementation is just slick

12:12 diyfupeco: Let's build submacim! :P

12:13 aztak: Thanks for the hint. :)

12:34 binjured: does anybody know how to get cljsbuild to build some cljc files from a dependency jar? i have a shared library dependency that contains combined sources (cljc). i can add it as a dependency and require from the jar as clj, but cljsbuild doesn't know about the cljc in the jar.

12:52 seangrov`: Has anyone tried doing xhr-based file uploads to compojure routes before? I'm not sure what to do with the HttpInput body

13:00 dasik`: Does it make sense to use JSON Web Encryption (JWE) tokens when I'm writing a basic CRUD webapp? All the writing I've found about token authentication talks about single-page applications.

13:17 justin_smith: wasamasa: "emacs undo system is kind of meh" -- have you tried undo-tree?

13:17 oh, never mind, /me goes back to reading

13:17 wasamasa: justin_smith: it builds upon the built-in undo system

13:18 justin_smith: so, while it's really handy to have a tree-style redo, I've run into a really weird bug or two with it and persistency enabled

13:18 csd_: If t represents a java object, and I have a coll of [ts], how can i map .setter to [ts]? I'm having trouble using (map #(.setter %1 %2) ts [vals])

13:18 justin_smith: sure. But aren't your concerns addressed by upping the amount of history saved? like for similar reasons I always expand the size of my kill ring

13:18 wasamasa: at some point I did just disable it when I got "Undo canary detected" messages all over the place

13:18 justin_smith: wasamasa: interesting, you must be using it much more heavily than I ever do

13:19 wasamasa: justin_smith: well, I just have an eye for spotting bugs, that's all

13:19 justin_smith: binjured: which version of clojure is cljsbuild using/

13:21 binjured: with clojure 1.7 I have had no issue getting code from cljc files in libs

13:43 scriptor: have any evil users here been able to use the eval-buffer keybinding with cider?

13:44 justin_smith: scriptor: I don't use cider, but I think your best bet is to rebind the command to something that works better with evil

13:45 scriptor: hmm, I was trying to rebind it on evil's side, but that might be best

13:46 justin_smith: scriptor: that's what I mean. Find out the actual command that keybinding would run, and bind some other key combo to that command

13:46 which is why I hate it when people document the keypress but not the specific command to run - the command is universal, the keypress is particular and very likely to not work on any given person's emacs setup

13:49 scriptor: agreed, had to guess where the actual binding is set in the sourc

13:49 didn't take long, but still

14:01 wasamasa: so you still didn't run F1 k C-c C-k?

14:01 justin_smith: wasamasa: if the keybinding is broken, asking what a key is bound to isn't going to help much

14:02 something already messed up the binding

14:02 wasamasa: yes and you'd want to know what

14:02 justin_smith: wasamasa: evil mode

14:02 he already knew that

14:02 wasamasa: I find this somewhat hard to believe considering evil doesn't bind anything to C-c or C-x

14:02 which is done on purpose

14:03 in vim C-x would be bound to either the increment or decrement command (evil doesn't ship with any of these, it's an extra package you need to install and bind yourself), C-c would be bound to a quitting command, but isn't here

14:06 so I'm curious what would be going on here

14:52 edw: Ping

14:52 Bronsa: edw: hi

14:53 edw: Bronsa: Hey. Slow day…

14:54 Bronsa: edw: lot of traffic has moved from irc to the slack channel it seems

14:54 edw: Whu?

14:54 Clojure.org?

14:54 Bronsa: edw: https://clojurians.slack.com/

14:55 edw: I was just thinking, "I wish i could connect to Freenode via the Slack (Mac|iOS) app…"

14:57 hiredman: really?

14:58 that is too bad

15:01 lemonodor: “To start using Slack, you'll need to be invited by your team administrator” is it not public?

15:05 Bronsa: lemonodor: http://clojurians.net/ to get an invitation

15:05 hiredman: yeah :( it's not as bad as it could be though, slack has an irc gateway

15:06 freeman42x: Bronsa, irc gateway?

15:06 Bronsa: freeman42x: https://slack.zendesk.com/hc/en-us/articles/201727913-Connecting-to-Slack-over-IRC-and-XMPP

15:11 lemonodor: Bronsa: thanks

15:14 Frozenlock: IRC master race

15:14 Slack dirty peasants

15:14 freeman42x: Frozenlock, i for one welcome our new slack overlords

15:15 oddcully: s/overlord/team administrator/

15:29 zphds: Guys, why is the PSQLException in line 5 in this gist not getting caught? https://gist.github.com/sudharsh/6801838e92bc0fc0a985

15:29 It's late and am scratching my head

15:30 evaluating the map form on the repl throws a PSQLException

15:36 amalloy: zphds: having not looked at the paste, i'll bet you a million dollars it's because of lazy sequences

15:36 and, indeed, it is

15:36 ~map

15:36 clojurebot: map is laziness

15:37 zphds: amalloy: but why I don't I get lazy-seq when I do it on the repl?

15:38 s/I don't/don't/

15:38 kwladyka: i have map {[1 1] :king [1 3] :king [1 2] :rook} and i want change it into {{[1 1] :king [1 3] :king [1 2] :rook}{[2 1] :king [2 3] :king [2 2] :rook}{[3 1] :king [3 3] :king [3 2] :rook}} <- the number are just example. I want do some magic operations on keys and change them. How to do this in most elegant way?

15:39 amalloy: zphds: your function immediately returns a lazy sequence, realizing no elements of it. then in the repl, you try to evaluate an element, throwing an exception, and there's no handler installed at that point

15:39 kwladyka: something like (do-magic-algorithm {[1 1] :king [1 3] :king [3 2] :rook}) to produce me that

15:39 zphds: amalloy: is there an implicit doall ?

15:39 ah gotcha

15:39 amalloy: no? i don't understand this question

15:40 ToxicFrog: kwladyka: your "after" example isn't even a valid map, so I have no idea what you actually want here.

15:40 zphds: amalloy: I could do a (doall (map...))

15:40 and realize the lazy-seq

15:40 kwladyka: ToxicFrog, It should be #{}

15:40 zphds: amalloy: dorun should be fine, since I can just throw away the results

15:41 kwladyka: {[1 1] :king [1 3] :king [3 2] :rook} into #{{[1 1] :king [1 3] :king [1 2] :rook}{[2 1] :king [2 3] :king [2 2] :rook}{[3 1] :king [3 3] :king [3 2] :rook}}

15:42 amalloy: kwladyka: nobody can guess what your algorithm is here. how are the outputs related to the inputs? it's like asking "i have the numbers 4, 9, and 17, and i need to get out 491. what function should i use?"

15:42 kwladyka: amalloy, algorithm it is not important, i just want know which function i can use to produce from one map more maps with different keys

15:43 zphds: amalloy: cool, plugging in a dorun is what I needed. Thanks!

15:44 not worried about the size since the input is going to be less anway. So dorun should be good.

15:46 kwladyka: to be more precise, example input and output https://www.refheap.com/106532

15:47 amalloy, ^

16:30 cryptack: I need to integrate with Spring and I’d like to define Spring beans, I’m wondering if anyone knows a way to do this in clojure (it requires Java annotations ontop of a class, I couldn’t find any info online)

16:33 I found something that said you can annotate with deftype, but I don’t know if that corresponds to clojure metadata or Java class annotations

16:41 kwladyka: how change ([1 1] [1 3] [3 2]) into for example ([1 1+4] [1 3+4] [3 2+4]) ?

16:42 justin_smith: what is "1+4"

16:43 kwladyka: 5 :)

16:44 lemonodor: kwladyka: you could look at reduce-kv

16:44 justin_smith: ,(map (fn [[a b]] [a (+ b 4)]) '([1 1] [1 3] [3 2]))

16:44 scriptor: kwladyka: you'll want to map over the list which will let you iterate over the pairs

16:44 clojurebot: ([1 5] [1 7] [3 6])

16:45 justin_smith: lemonodor: oh, reduce-kv would work for that structure wouldn't it...

16:46 ,(reduce-kv (fn [acc k v] (conj acc [k (+ v 4)])) [] '([1 1] [1 3] [3 2]))

16:46 clojurebot: #error {\n :cause "No implementation of method: :kv-reduce of protocol: #'clojure.core.protocols/IKVReduce found for class: clojure.lang.PersistentList"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No implementation of method: :kv-reduce of protocol: #'clojure.core.protocols/IKVReduce found for class: clojure.lang.PersistentList"\n :at [clojure.core$_cache_protocol_fn invoke...

16:46 justin_smith: no, reduce-kv won't work for that actually

16:46 (if that was literally the datastructure)

16:47 scriptor: map seems to make more idiomatic sense in this case, too

16:47 since it's just a one-to-one...mapping

16:47 Seylerius: What's the best way to name a new library one's planning to publish? Should it be at one's own domain, if one has such a domain? If I own seriouslyseylerius.com, should it be "com.seriouslyseylerius/astronomy" if I'm making an astronomy library (for calculating full moon dates and whatnot)? And what sort of lein command should I use for declaring it?

16:48 justin_smith: Seylerius: lein new foo com.seyleruis/astronomy

16:48 where foo is your template

16:48 if the project is already there, you have to edit a bunch of stuff by hand

16:48 lemonodor: i do prefer the reverse DNS style names, but lots of people just choose a top-level unique name, like “astronomie” or something.

16:49 justin_smith: yeah, I think that's sloppy / bad form though

16:50 Seylerius: Okay, so `lein new com.seriouslyseylerius/astronomy`, then push the thing to github as `seylerius/astronomy` on my profile?

16:50 I need to get around to changing my github name from emhs to seylerius, since I'm using that for everything these days...

16:51 lemonodor: justin_smith i tend to agree, but i don’t think the community in general necessarily feels the same way. e.g. midje, clj-time, lein-gorilla, gloss, seesaw

16:51 kwladyka: hmm maybe reduce-kv is even better... on the end i want do https://www.refheap.com/106532

16:52 for now i did https://www.refheap.com/106534

16:52 and i wanted transform positions in zipmap

16:52 justin_smith: kwladyka: you need a data-structure that implements the IKVReduce protocol, and you have duplicate "keys"

16:53 kwladyka: justin_smith, i dont have.

16:54 justin_smith, so.... my solution with zipmap is a good way or should i use something like reduce-kv?

16:55 or any other solution

16:55 oddcully: isn't (map key) the same as (keys) ?

16:55 same for val/vals?

16:55 kwladyka: oddcully, no

16:55 amalloy: yes

16:56 kwladyka: no, it would throw exception

16:56 oddcully: yeahyeah... (map key) is a transducer ;P

16:56 amalloy: no

16:56 oh, you're not calling it on anything?

16:56 no, you are. (map key x) is the same as (keys x)

16:57 that is the implementation of (keys x)

16:57 oddcully: that's what i meant but lazily excluded

16:57 kwladyka: oh i didn't see "s" on the end of this word...

16:57 sorry

16:57 but good to know i can write it shorter :)

16:58 oddcully: and isn't then (zipmap (keys x) (vals x)) just randomizing your map?

16:58 thesaskwatch: I'm trying to test a function using midje and I would like to verify content that it printlns. Any idea how to do that?

16:59 kwladyka: so... do you think my solution with zimap to achive keys transformation for example from ([1 1] [1 3] [3 2]) into ([1 1+4] [1 3+4] [3 2+4]) is good or do you see better solution?

16:59 lemonodor: justin_smith: compojure, cascalog, clj-http, enlive, hiccup, instaparse, every lein plugin, ring, secretary (sorry, i went to the trouble to find popular packages i’ve used that don’t use the reverse dns naming scheme)

16:59 kwladyka: oddcully, it do nothing for now... i have to add something to (keys x) to transform keys

17:01 oddcully, and i know keys and vals give values in order?

17:07 if somebody is interested in this is my full worked solution https://www.refheap.com/106535

17:14 zerokarmaleft: having a weird compojure issue here...prod env is basically nginx reverse proxied to a clojure app with a couple endpoints. routes match when hitting the app server directly, routes match when hitting a dev setup mimicking the nginx setup, GET routes match when hitting the prod setup, POST routes mysteriously fail to match.

17:14 kwladyka: thank you for discussion and goodnight :)

17:15 oddcully: kwladyka: yeah sorry, i actually don't know what garanties clojure map holds in that case. i defensively assumed unordered access. but if the seq of elements is the same, then there is no randomization

17:15 zerokarmaleft: the headers don't appear mangled in any way, and the URI logged at nginx and at the app is correctly formed

17:15 any ideas on what I could check next?

17:54 junger: howdie everyone

17:54 is someone familiar with om-bootstrap ?

17:54 I'm evaluating using it, and I am bumbing into a problem using alerts

17:56 oddcully: junger: just fyi there is also #clojurescript

18:00 junger: @thanks, will check it out

18:19 Seylerius: What's the recommended way for an app using one's library to set a library-wide setting, like API usage level?

18:20 justin_smith: Seylerius: would two parts of one app ever have separate configs for the same lib?

18:21 Seylerius: I'm building a rate limiter into an API lib I'm putting together (refactoring all the Wunderground API stuff I'm using in my weather-generator app to a lib of its own), and I want people to be able to specify which API level they've purchased (Developer, Drizzle, Shower, Downpour) and have it automatically cap their usage at the required rate. So it's unlikely they'd have separate configs. It's a per-API-key setting (I'd probably also

18:21 use this to allow them to set the API key, too)

18:23 justin_smith: So, very unlikely that they'd have multiple configs per app.

18:23 Unless they're using two different API keys in the app, which have different usage levels.

18:23 But what's more likely is there'd be an API key in the dev version and a separate API key in the production version.

18:24 justin_smith: Seylerius: the reason I ask, is a common thing is a top level atom, but that makes using different API keys impossible

18:24 so is it OK to make it not possible at all, or is it worth it to do something slightly less simple so that multiple keys is occasionally an option?

18:38 lodin_: Is there a term for objects that require cleanup? Like objects that should be closed, etc. First thing that came to mind was "stateful" but atoms are also stateful, so that's not quite right.

18:38 Seylerius: justin_smith: I can think of exactly /one/ reason to use multiple API keys in an app: load-balancing requests across different keys.

18:38 But that's probably a violation of the ToS.

18:39 Hell, I'll bug Gundeep and double-check if it is.

18:39 'Cause if it is, disallowing it in my lib will probably make the wunderground people like me better.

18:47 justin_smith: Baring an update from Mr Hora to the contrary, I can't think of a good reason to use multiple API keys, so I'll go with the top-level atom approach. Got a decent link on the basics of it?

18:47 justin_smith: Seylerius: these issues are fresh in my mind because I am setting up our timbre config in an internal project right now, and sometimes I really wish timbre did not have a single global config for all options

18:48 Seylerius: it's pretty straightforward to implement (def config (atom {:credentials nil}))

18:48 then maybe provide a convenience function like set-credentials! or something that mutates the config

18:49 Seylerius: justin_smith: Perfect, thanks.

18:49 justin_smith: Can you think of a good reason for people to need multiple API keys for a weather API?

18:50 justin_smith: Seylerius: if your app had multiple users, but only had to check the weather once and could share that data between the users in one area

18:50 which is probably a weird use case

18:52 Seylerius: justin_smith: Yeah, that wouldn't be likely with Wunderground unless individual users were adding their API keys to the app, which the API key generating interface seems not to be optimized for.

18:54 justin_smith: Confirmation from Gundeep: load-balancing is against ToS.

18:55 justin_smith: then you're probably all set using an atom

18:57 Seylerius: Thanks

18:57 (inc justin_smith)

18:57 lazybot: ⇒ 276

18:57 Seylerius: (Why do you people rock so hard?)

19:17 elvis453561: How do you use CSS selectors with garden for Ronald Mcdonald's sake

19:17 ?

19:18 oddcully: elvis453561: just fyi there is also #clojurescript

19:18 elvis453561: [:input (not [...]) {...}] render as: input, :not [...]

19:19 Yeah I could try it but: Usually it's dead compared to here and I'm using garden on the JVM so...

19:21 oddcully: just mentioning it... feel free to do whatever you thing is right

19:56 devn: anyone here know of an example of using core.async pipeline?

20:13 tmtwd: hello, I was trying out yesql for fun, and put it in the project.clj file deps,and called lein deps. Then today I installed posgresql for the first time but it would work. Could lein have done something to mess up my path or something?

21:05 Shayanjm: arrdem: I didn't realize you worked @ Factual

21:05 we just started using factual @ work

21:09 arrdem: Shayanjm: yeah I'm here for the summer giving amalloy and everyone else a headache IRL rather than just over IRC

21:09 Shayanjm: sweet. We just turned the key on our lead gen engine, so I think we're giving factual a go

21:10 arrdem: cool!

21:10 Shayanjm: Do you guys already do google place scraping btw?

21:10 arrdem: I don't know and probably couldn't say

21:10 Shayanjm: gotcha

21:43 rs0: lodin_: "resources," I suppose?

21:43 lodin_: in the sense of "automatic resource management"/"try-with-resources"

22:05 Seylerius: Is some the best way to see if a given keyword is a member of a specific collection? I've got a map called rates, with a map as each value, and the argument provided to this function needs to be one of the keys in rates.

22:06 Or contains? maybe?

22:06 justin_smith: Seylerius: contains? might be what you are looking for

22:06 * Seylerius nods

22:07 justin_smith: Seylerius: see also find, which returns nil, or the key and value as a vector

22:07 (doc find)

22:07 clojurebot: "([map key]); Returns the map entry for key, or nil if key not present."

22:37 gcganley: are there any clojure stickers for something like the back of a laptop?

22:39 scriptor: gcganley: http://clojure.org/swag

23:12 sturner: Anyone have an recommendations for handling units/measurements? Frinj looks pretty interesting. I'm a clojure newbie... I've used http://www.squants.com/ before which I found to be powerful but I'm wondering how I might convey values with unit across the network to other systems in a similar manner in clojure. Transmit maybe?

23:17 tomjack: hmm "Tries to combine Frink's fluent calculation style with idiomatic Clojure"

23:18 does it succeed?

23:18 (frinj)

23:28 Raynes: Does it?

23:28 You tell me, sir.

23:28 For I am not the judge.

23:30 Well, at first glance, there are some pretty horrifying things going on.

23:30 Like override-operators!

23:30 I'm kinda shivering a bit over that one.

23:32 sturner: Yeah... I'm very much a clojure beginner so I can't comment. Frink is an interesting language in and of itself but the library implementing it seems to only implement a parse().

23:43 amalloy: frinj is just super old, isn't it?

Logging service provided by n01se.net