#clojure logs

2015-04-26

00:05nbeloglazovIs there a way in core.typed to check namespace without throwing an error and only printing found issues?
00:05nbeloglazovI'm trying to gradually annotate namespace from emacs and constantly invoking check-ns to test it.
00:09allenj12test
00:09arrdemnbeloglazov: the #typed-clojure folks will probably know
00:09arrdemoffhand I can't say I do
00:10nbeloglazovThanks. Will try there.
00:10arrdemI think there's a typed clojure emacs plugin that deals with that for you
00:10nbeloglazovYeah, but I'd rather start with "low-level" :)
00:10arrdemeh tooling exists to be used :P
00:57dumptruckstuck on another koan... "Or use the names of existing functions" (= __ (map nil? [:a :b nil :c :d]))
00:57dumptruckany hints?
00:58dumptruckinterestingly... i happened to remove the __ and save and it passed...
00:58arrdemdumptruck: what number is this?
00:58arrdem##(= 1)
00:58lazybot⇒ true
00:59dumptruckoh right
00:59arrdem:P
00:59dumptruckit's 08_higher_order_functions
00:59dumptruck3rd one
00:59dumptruckbut
01:00dumptruck,(nil? nil)
01:00clojurebottrue
01:00dumptrucker.. not what i meant
01:00dumptruck,(nil? :a)
01:00clojurebotfalse
01:00dumptruckif that's the first mapping
01:01dumptruckhow does that not invalidate the test with (= (map nil? [:a :b nil :c :d]))
01:01dumptruck(= false)
01:01dumptruck,(= false)
01:01clojurebottrue
01:01dumptruckoh.
01:01arrdem∀ x (= x) == true
01:02arrdem##(map nil? [:a :b nil :c :d])
01:02lazybot⇒ (false false true false false)
01:02dumptruckthe hint it is giving me is throwing me off
01:02dumptruck"Or use the names of existing functions"
01:03dumptruckis it just referring to nil?
01:03dumptrucki guess so...
01:04arrdemhonestly not sure
01:11TEttingerdumptruck: this list of koans? https://github.com/functional-koans/clojure-koans/blob/master/src/koans/08_higher_order_functions.clj
01:12TEttingerI believe that's meant to be a continuation of the previous sentence
01:12TEttinger(= [false false true false false] (map nil? [:a :b nil :c :d]))
01:12TEttinger,(= [false false true false false] (map nil? [:a :b nil :c :d]))
01:12clojurebottrue
01:13dumptruckyeah
01:13dumptrucki mean, that's what i put
01:13dumptrucki thought it was asking me to put a function name
01:14TEttingerI think it was referring to its use of nil?
01:14TEttingerinstead of (fn)
01:14dumptruckright
01:15TEttingeryou're totally right, it's worded poorly
01:22fowlslegsIs there a way to use a local variable name from function A in function B is function A calls function B?
01:22fowlslegsLet me try to write this clearer.
01:24fowlslegsI want to write something like
01:24fowlslegs,(defn b [] local-var-from-a)
01:24clojurebot#error{:cause "Unable to resolve symbol: local-var-from-a in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: local-var-from-a in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: local-var-...
01:25fowlslegsBut I won't be able to resolve local-var-from-a.
01:26lvhfowlslegs: there's two ways to do this
01:26lvhfowlslegs: the obvious way is to pass the var as an argument to b
01:26lvhfowlslegs: the less obvious way is ^:dynamic, but I'd be very surprised if that's actually a thing you want to use here
01:27fowlslegsBut if function a looks like (defn a [] (let [local-var-from-8 42] (b))
01:28puredangerThe whole point of local vars is to have local lexical scope. If you want it in b, pass it in.
01:28fowlslegsFor what I'm doing I can't pass the var as an argument to b.
01:28dumptruckwhy not
01:28fowlslegsSorry I should have made that clear.
01:29dumptruck(defn a [] (let [local-var-from-8 42] (b local-var-from-8))
01:29dumptruckno?
01:29clojurebotno is tufflax: there was a question somewhere in there, the answer
01:29fowlslegsBecause I want my file to run with a certain system and to do that I'd have to modify parts of the system that would break it for other files.
01:30TEttingerfowlslegs: there's technically nothing preventing you from running def inside function a
01:30TEttingerit's not at all encouraged
01:30arrdemOxcart will whine if you try that :P
01:30puredangerWell I'd say this is the wrong overall path, but dynamic vars would give you the dynamic scope you seek
01:31dumptruckcan you not overload b?
01:31puredangerDon't use def, bleh
01:32TEttingerfowlslegs: I would say, make a third def at outer scope, an atom or something that you just assign the value from a
01:32TEttingerthis way only the most recent call to a matters
01:32fowlslegsLet me explain the structure better. I have full control over b, but not a. a calls b as an anonymous function and gives it exactly
01:32dumptrucklike
01:33fowlslegsone argument which is not the argument I need. However, a also defines a variable, which changes as it loops over b
01:33fowlslegsand I want to use that variable.
01:33dumptruck(defn b ([] (b :default-value)) ([a-value] ...))
01:34arrdemthat is in fact the idiom for implicit arguments
01:34puredangerWell, Clojure doesn't work that way
01:34TEttingerif you don't have control over a you can't reach in and and pull out its internal vars without some serious hacks
01:34dumptruckah
01:34TEttingerit may be possible
01:34TEttingernot a good idea
01:34puredangerYou shouldn't want it to work that way :)
01:34fowlslegsTEttinger: Haha indeed. I was hoping the experts here could help me with that.
01:35TEttingerwell hm
01:35TEttingerso A is called without your control?
01:35fowlslegsYes.
01:35TEttingernot even in your lib?
01:36fowlslegsIs there some way I can make b a macro that creates a function that grabs this local-var?
01:36TEttingerI mean you must have access to the source, otherwise you wouldn't know about the loop
01:36puredangerIf b was a macro you could prob get to it via &env
01:36fowlslegsTEttinger: I do. I just really, really don't want to change it.
01:37puredangerBut to be clear, this is a terrible idea :)
01:37fowlslegsTEttinger: My file will not be accepted to the examples if I modify the system files.
01:37TEttingerexamples?
01:37clojurebotexamples is api examples
01:37fowlslegspuredanger: I love terrible ideas.
01:37fowlslegsI have about 4-5 per minute.
01:38TEttingerif there's an acceptance process you really really don't want to be hacking local scope that is not your own?
01:38arrdemTEttinger: you left a -? on that bud
01:39TEttingerit's the expression my eyebrows are making, arrdem
01:39puredangerMacros expand in their caller and have access to an implicit &env that includes locals iirc
01:40fowlslegspuredanger: Can you give me an example of how I might do this or point me to relevant documentation?
01:41puredangerNo, on my phone sorry
01:41arrdemhttp://blog.jayfields.com/2011/02/clojure-and.html
01:41fowlslegsHonestly the fact you might be able to do this is not very comforting from a security standpoint.
01:42arrdemaw dnolen is afk
01:45TEttinger,(defmacro show-form [a b] `(println ~@(next &form)))
01:45clojurebot#'sandbox/show-form
01:45TEttinger,(let [alpha 1 beta 2] (show-form alpha beta))
01:45clojurebot1 2\n
01:48arrdemcan I use CIDER to connect twice to the same nrepl instance?
01:48TEttinger,(defmacro B [] (do (print (keys &env)) 42)
01:48clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
01:48TEttinger,(defmacro B [] (do (print (keys &env)) 42))
01:48clojurebot#'sandbox/B
01:50TEttinger,(loop [a 0] (if (> a 3) (print "Done!") (do (B) (recur (inc a)) )))
01:50clojurebot(a)Done!
01:51TEttinger,(defmacro B [] (do (print (vals &env)) 42))
01:51clojurebot#'sandbox/B
01:51TEttinger,(loop [a 0] (if (> a 4) (print "Done!") (do (B) (recur (inc a)) )))
01:51clojurebot(#object[clojure.lang.Compiler$LocalBinding 0x1f5c0126 clojure.lang.Compiler$LocalBinding@1f5c0126])Done!
01:51TEttingerwoah
01:52TEttinger,(defmacro B [] `(println ~@(keys &env)))
01:52clojurebot#'sandbox/B
01:52TEttinger,(loop [a 0] (if (> a 4) (print "Done!") (do (B) (recur (inc a)) )))
01:52clojurebot0\n1\n2\n3\n4\nDone!
01:53TEttingerfowlslegs: there you go, maybe
01:53TEttingerthere are caveats galore
01:53TEttinger,(let [haha "let messes you up"] (loop [a 0] (if (> a 4) (print "Done!") (do (B) (recur (inc a)) ))))
01:53clojurebotlet messes you up 0\nlet messes you up 1\nlet messes you up 2\nlet messes you up 3\nlet messes you up 4\nDone!
02:05arrdemWhere would you suggest looking to get started with Ring testing?
02:30fowlslegsTEttinger: So really B is calling C and A is calling B, where A has the local var bound in a loop statement as it loops over B among other functions.
02:31fowlslegsThanks anyway for your examples and suggestions everyone, but I can't get what I'm looking for with &env
02:31TEttingerhm?
06:03jaaqoI'm testing my web application routes and am unable to mock out csrf-protection from my queries. Is it a valid approach to create another handler function just to be used in tests, in which the anti forgery is turned off?
06:08ConfusionistI'm not understanding the following: if I execute (require '[clojure.tools.namespace.repl :refer [refresh refresh-all]]) in a repl, I can subsequently call (refresh) and it does it's job. If I put the exact same line in user.clj (which is being loaded, as confirmed by a println), the 'refresh symbol cannot be resolved. Why is that?
06:11Confusionistjaaqo, it's usually easier to just generate a valid csrf token and include it in the request
06:46sohalt`Hi, I'm still wrestling with my clojurescript repl and noticed something. I got the repl working a few times (But only after like refreshing the browser >5 times) in my terminal with lein trampoline run -m clojure.main repl.clj, where repl.clj sets up the browser repl. Now when it works the browser starts sending a first POST to "/" with params {:type :ready, :content "ready", :order 1} and after that starts spammin
06:46sohalt`g POSTs to "/" (~100 or so) until a GET to strings.js returns with a 404 and then follows a last POST to "/" with params {:type :result, :content "{:status :success, :value \"\"}", :order 105}
06:46sohalt`Any ideas, why that could be? Or completely unrelated?
06:47sohalt`When it doesn't work (90% of the time) the browser sends the first POST to "/" and then does nothing and the repl sits there waiting with a "Waiting for broswer to connect ..." message
06:49sohalt`Oh, and now I'm getting nullpointer messages in the repl
06:50sohalt`cljs.user=> Exception in thread "Thread-124" java.lang.NullPointerException
06:50sohalt` at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26)
06:50sohalt` at cljs.repl.server$read_request.invoke(server.clj:95)
06:50sohalt` at cljs.repl.server$handle_connection.invoke(server.clj:153)
06:50sohalt` at cljs.repl.server$server_loop$fn__4477.invoke(server.clj:164)
06:50sohalt` at clojure.core$binding_conveyor_fn$fn__4145.invoke(core.clj:1910)
06:50sohalt` at clojure.lang.AFn.run(AFn.java:22)
06:50sohalt` at java.lang.Thread.run(Thread.java:745)
06:50zol_How can I get only the first level of directories inside a directory? like if I have public/images/{a/{1/,2/},b/{1/,2/,3/}, c/{1/}, I want to only get public/images/{a,b,c} as clojure.java.io.File objects
06:52sohalt`whoops, clicked on the wrong request before. The last POST to "/" has params {:type :result, :content "{:status :success, :value \"true\"}", :order 113}
06:55dnolensohalt`: sounds like a bug but will need more information
06:55dnolensohalt`: I haven't encountered this problem in Chrome (which is what I use to develop), but I have noticed that Safari & Firefox often need a refresh or two in some cases.
06:56zol_Looks that it is files-seq that makes the call recursively
06:58sohalt`I sometimes refreshed >10 times and it still didn't get past that first POST.
06:59oddcully,(.listFiles (new java.io.File "/tmp"))
06:59clojurebot#error{:cause "denied", :via [{:type java.lang.SecurityException, :message "denied", :at [clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]}], :trace [[clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69] [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkRead nil -1] [java.io.File list "File.java" 1111] [java.io.File listFiles "...
07:00sohalt`And I didn't get it to work with inf-clojure, only terminal, although that might simply be coincidence, since from my understanding they do essentially the same. (launch the repl.clj with lein tampoline
07:01zol_Fixed it! .listFiles (io/as-file (io/resource "public/images/courses"))
07:03sohalt`dnolen: is there anything specific I could try to get more info?
07:04dnolensohalt`: it sounds like a potential server bug
07:04dnolensohalt`: would be useful to understand why Chrome doesn't have this problem consistently and Firefox does
07:09noncomdoes usage of more than 4-arity fns in clojure give serious overhead?
07:09noncomor better, what is the additional cost for that?
07:12dnolennoncom: there's nothing specific about any particular arity
07:13dnolennoncom: so the answer to your question - no
07:20noncomokay, thanks. i just remember that there was that issue with defining more functions of primitive types (incl object) than 4 due to the explosion (4 in power 4 is already too many classes)
07:21noncom* correction: ...than it is already dont with arity 4 due to the explosion..
07:21noncom*done :)
08:17gfredericksnoncom: something around there is true, actually; but if you're not intentionally using primitives that doesn't matter
08:25ConfusionistConcerning repl workflows: if I start a lein repl and use a user.clj to make some stuff available in the user namespace, is there a way to make it possible to use e.g. (user.str/replace ...) when user.clj contains a [clojure.string :as str]?
08:26ConfusionistI'm trying to find a way to make common things easy to do, without polluting the app.core namespace and without having to explicitly wrap everything with a separate function in user.clj
08:27ConfusionistSo I e.g. make clojure.tools.namespace.repl.refresh available as user/refresh and I could do the same for those aliased namespaces, but it seems like there should be an easier way
08:34justin_smithConfusionist: no, it does not work that way
08:36justin_smithConfusionist: though I think vinyasa has similar goals https://github.com/zcaudate/vinyasa
08:38Confusionistjustin_smith, Thanks, that does sound like what I currently think may be useful
09:02sobeli just reload my repl when things get horked up. i could learn a better workflow, but i still build my projects around batch-build ideas, and getting to work in/with a repl is pure gravy
09:04sobelthat said, i'll refresh deps in-repl after editing project.clj, but i usually end up with a broken state i need to restore
09:05sobelunrelated: anyone here use irclj? i'm trying to figure out how to capture disconnection. hoping i don't have to inspect the interior socket state.
09:05justin_smithsobel: I've worked on lazybot.... best of luck
09:08sobelthat sounds like a 'no'
09:09justin_smithmore of an "I don't know"
09:09justin_smithbut yeah
09:09sobelfigures. irc is still a mutt protocol.
09:11sobelugh, the java libs are...java
09:12Confusionistsobel, in general you can't reliably determine disconnection from the socket state
09:12ConfusionistWithout a 'ping' or similar in the protocol, you're basically hosed if the other side doesn't nicely close the socket
09:13sobelConfusionist: understood; i actually mean timeout.
09:13sobeli should have said infer rather than inspect ;)
09:14sobeli might be just clever enough to add clojure to PircBotX
09:46JanxSpiritmy team is looking to prototype a project using a full-stack Clojure approach with Om - can anyone direct me to the current most mature stack I should be looking at?
09:51sobelJanxSpirit: i'm looking at http://www.luminusweb.net/ because it looks fairly complete
09:52sobel'complete' in the application library sense, or "just add database and a scaling strategy if you need one"
09:59sveriJanxSpirit: I put together a template which includes chestnut and luminusweb for code reloading of clj and cljs: https://github.com/sveri/closp However if you only need the cljs part look at chestnut: https://github.com/plexus/chestnut
10:00ConfusionistWeird: I have a project with speclj where 'lein spec' passes, but 'lein spec -a' immediately raises 'java.io.FileNotFoundException: Could not locate app/core_test__init.class or app/core_test.clj on classpath'
10:00JanxSpiritIsobel sveri - thank you
10:01JanxSpiritsobel that is
10:01sobelgood luck!
10:04sveriyea and come back if you have questions
10:04smorgyHi all
10:05smorgyWhat's the most elegent way to read from a channel only when a predicate is met?
10:05smorgylike having one go-loop processing every odd number, another processing the even ones?
10:07ConfusionistAh, eastwood found the problem... but still surprising only the -a trips over it
10:07oddcullysmorgy: there is `split`
10:11smorgyok, what if there's more consumers than that, so I'll up doing a split of a split of a split...
11:15caterndear #clojure
11:15caternI would like to partition something on the basis of a predicate
11:16caterntake-while gives me things up to the predicate becoming false
11:16brucehaumangroup-by
11:16brucehaumancatern: I think group-by is what you are looking for
11:16catern:D
11:16caterni think you mean partition-by
11:16caternbut yes
11:18brucehaumancatern: partition-by is subtle
11:18caternoh
11:18caternyeah
11:18caternso it is
11:18brucehaumancatern: group-by actually groups the values
11:18caternhmm, actually, I don't think either of these is what I want
11:18caternwhat I want is
11:19catern[[true false false false] [true] [true false] [true false false]]
11:20brucehaumancatern: yeah that is tough
11:20brucehaumancatern: you only want one true per list
11:20caternis there a take-while that does a split?
11:21caternah
11:21caternhttps://clojuredocs.org/clojure.core/split-with
11:21brucehaumancatern: I dont think that will work either
11:22caternwell
11:22caternhmm
11:22caternwhat I really kind of want
11:22caternis https://clojuredocs.org/clojure.string/split
11:22caternbut for lists
11:23caternand with a predicate instead of a regex I mean
12:13justin_smithpartition-by?
12:13ConfusionistIs there a simple way in core.match to capture the value of an :or match? So I would like to match [(:or 'foo 'bar) 1 2] and I would like to be able to refer to the value 'foo or 'bar. Of course if I matched somevec, I could simple ask (first somevec), but if could capture it directly, like in a regex named group, that would be nice
12:15justin_smithsorry, someone already mentioned that
12:18justin_smith,(map #(apply concat %) (partition 2 1 (partition-by even? [0 1 3 5 2 3 7 4 9 9])))
12:18clojurebot((0 1 3 5) (1 3 5 2) (2 3 7) (3 7 4) (4 9 9))
12:18justin_smithnot quite
12:18justin_smith,(map #(apply concat %) (partition 2 (partition-by even? [0 1 3 5 2 3 7 4 9 9])))
12:18clojurebot((0 1 3 5) (2 3 7) (4 9 9))
12:19justin_smithcatern: ^ I think that's your answer
12:28deanmanHow can someone go about deleting a parentheses on cursive ?
12:28nuwanda__you're using structural editing?
12:29deanmannuwanda__: just started using it so I'm not quite sure what that is. I know that I'm using the "cursive" keybinding set
12:30justin_smithdeanman: if the pair is empty, you should be able to simple delete them. But structural editing only allows deleting by pairs
12:31deanmanSo if i ultimately want to move that parentheses around then i should be using some other trick ?
12:31justin_smithdeanman: the keyword to look for is "structural editing", their's various bindings for moving things in and out of paren groups
12:32gfrederickshello
12:32justin_smithyo
12:32caternjustin_smith: awesome, thanks
12:33deanmanjustin_smith: Slurp barf etc?
12:33justin_smithyup
12:34deanmanjustin_smith: Is that something specific to cursive or something lispy? Where can i find more information what do these terms mean and what they do ?
12:35justin_smithdeanman: it's a concept a few editors have, cursive has its own key bindings for it
12:35justin_smithand yeah, it only works on lispy stuff, but it's not part of the language at all
12:36deanmanjustin_smith: thanks for the tip
12:43lasergoatjustin_smith: re:https://www.refheap.com/99973. I'm sure you figured it out, but it dawned on me why that fetches an extra item
12:43lasergoatweird, actually, that I didn't see it the first time
12:44justin_smithoh? ztellman mentioned that it was inevitable with core.async being push
12:44lasergoati mean, i guess that's the general explanation
12:45lasergoatthe specifics is just that that (>/>! result (first source)) does `first` and then parks on something pulling from the channel
12:45lasergoatso there's always something waiting in "parked" mode
12:45justin_smithoh, right
12:46brucehaumanjustin_smith: great answer to catern’s question
12:46lasergoatso you could do something snazzy with an extra channel that signals "back" that you're ready to pull another item off the upstream source
12:46lasergoatbut that's sort of ugly
12:46justin_smithhmm...
12:47justin_smithan abstraction could be reused, and it can be as ugly as it needs to be...
12:47lasergoatsure, shouldn't be too hard
12:49lasergoatanyway, i'm off; just dropping in to mention it
12:49justin_smiththanks
12:51brucehaumanjustin_smith: it was really great meeting you guys
12:51justin_smithit's mutual, it was a fun conference
12:52brucehaumanyeah it was. I really liked Portland. More than I expected
12:56gfredericksit's the asheville of the northwest oregon area
12:58gfredericksthe dumb thing about conferences is you meet a bunch of people you like and then find out that they live far far away from you
13:02mdallastellanamaste
13:04brucehaumangfredericks: I miss you too man
13:04brucehauman;)
13:05brucehaumangfredericks: actually I’m gonna get up to Chicago sometime this year. I miss that town.
13:06gfredericksdoooo it
13:08gfredericksand kidnap toby if you do
13:10brucehaumangfredericks: thats a good idea
13:12brucehaumanhe’s right next to me
13:13gfrederickssee it'd be so easy
13:15lucasbHello o/, I'm new to clojure. Is there a function in core that returns the index of the first element in a list that is equal to another or nil if it's not there? Let's say I have '(:a :b :c), given ":c", I want 2 as answer.
13:15justin_smith,(.indexof '(:a :b :c) :c)
13:15justin_smitherr
13:15clojurebot#error{:cause "No matching method found: indexof for class clojure.lang.PersistentList", :via [{:type java.lang.IllegalArgumentException, :message "No matching method found: indexof for class clojure.lang.PersistentList", :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]}], :trace [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53] [clojure.lang.Reflector invokeI...
13:15justin_smith,(.indexOf '(:a :b :c) :c)
13:15clojurebot2
13:16justin_smiththat's jvm clojure only, not clojurescript though
13:17lucasbjustin_smith: Thanks! That's it.
13:18arrdemjustin_smith: RFC http://conj.io/contributing
13:19justin_smithcool, I'll check that out
13:28deanman,((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 5)
13:28clojurebot(5 4 3 2 1)
13:30deanmanI'm having difficulty understanding this snippet.
13:30justin_smithdeanman: do you have a specific question about it?
13:30deanmanI do undestand it's an inner function that is being passed 5 as the first argument
13:30justin_smith,(conj '(1 2 3) 0)
13:30clojurebot(0 1 2 3)
13:31deanmanSo the first time that gets evaluated it creates a list of (<something> 5)
13:32deanman<something> is a call to the same function ?
13:32justin_smithno
13:32justin_smithit creates a list of (5 <something>)
13:33justin_smithsee my conj example above
13:33deanmanOk depending its type gets inserted at the beginning
13:33justin_smithdepending on what's type?
13:34deanmanconj always add at the beginning ?
13:34justin_smithno, it adds at the "natural" position for that collection
13:34justin_smith,(conj nil 1)
13:34clojurebot(1)
13:34justin_smiththat's the innermost thing that happens
13:34gfredericks,(conj (conj nil 1) 2)
13:34clojurebot(2 1)
13:35gfredericks,(conj (conj (conj nil 1) 2) 3)
13:35clojurebot(3 2 1)
13:35gfredericksetc.
13:35justin_smithso does this make more sense now?
13:36deanmanYes, it's rather the <something> that troubles me a bit. First time would be (5 <something>) and the <something> is a new call with 4 which returns (4 <something>) right ?
13:37justin_smithright
13:37justin_smith,(when false 0)
13:37clojurebotnil
13:38Cust0dian,(conj nil 1 2 3 4 5)
13:38clojurebot(5 4 3 2 1)
13:43leifwis there a thing like this? (with-java-properties {"java.io.tmpdir" "/my/special/directory"} ...forms...)
13:43leifwI'm not sure what it would be called but if anyone knows offhand
13:48justin_smithso you would want lexically scoped java properties?
13:48leifwthat would be cool
13:49leifwthough I guess they might not be thread local so that's probably not a thing
13:50justin_smithare you using something that needs a property to control its behavior then?
13:51leifwyeah
13:51leifwme.raynes.fs/temp-dir
13:52justin_smithleifw: I see an answer for making properties threadlocal
13:52justin_smithhttp://stackoverflow.com/a/9580288/2258453
13:53leifwwhoa, that's cool
13:53leifwprobably too much machinery for me right now, I'll do something else, but thank you
14:18anedoes anyone remember a blog post from this year in which there were implementations for some sort of algorithm in various lisp variants (clojure, scheme, racket etc.)
14:18aneand you could select them from a handy dropdown on the page
14:19Temurane, this one
14:19Temur? http://hyperpolyglot.org/lisp
14:21aneno. it was a very bloglike thing
14:32gfrederickshow to clojure 1) start a repl 2) check twitter while repl starts
14:34gfredericks#protip
14:36delaneyis it just me or is the repl in cursive come up really fast?
14:36saik0But if clojure starts fast, when will we lay on our hammoks?
14:37underplankhi all. Im using clojure.test and use-fixtures to do setup and tear-down. Is there a way to pass arugments to the test function?
14:37justin_smithdelaney: it uses some tricks you can use outside cursive
14:37justin_smithdelaney: https://github.com/technomancy/leiningen/wiki/Faster
14:37justin_smithdelaney: big ones are trampoline, with fast-trampoline, and not using nrepl
14:37arrdemwait you nerds don't have twitter _in_ your repl?
14:38arrdemnREPL over twitter...
14:38arrdem /s
14:38underplankthis doesnt see to work https://www.refheap.com/100065
14:38underplank*seem
14:41brainproxyin cljs, a (fn ... (recur ...)) boils down to a while loop wrapped in a function, so the recur step doesn't actually call the function again
14:42brainproxyis jvm clj, does something similar happen?
14:42arrdem(recur) compiles to a GOTO yes
14:43arrdemfn and loop generate labels, and (recur) goes to the most lexically local label with new bindings
14:43brainproxyiow, if i can express my function equiv as (fn ... (recur ...) <=> (fn ... (loop ... (recur ...)))
14:44brainproxythere's no reason to prefer the latter for perf reasons
14:44arrdemcorrect they are AFAIK strictly equivalent
14:44brainproxythanks
14:44arrdemthe latter will generate an unused LABEL statement
14:44arrdembut that's fre
14:44arrdem*free
14:45delaneyjustin_smith: yeah i'm very very new to clojure, but watch a lot of videos about it before getting started. i kept waiting for the tooling to be more there, seems to be pretty sweet now.
14:46delaneyi've been ruined by visual studio
14:46brainproxydelaney: what? Emacs is the ultimate tooling!
14:46brainproxy;-)
14:46arrdem(inc brainproxy) ;; emacs hivemind
14:46lazybot⇒ 5
14:49brainproxyall these parens are yours. use them together. use them in peace
14:51arrdemhttps://www.dropbox.com/s/pyrjccl5q71mmtu/4bb44752-9c0c-4c2d-b826-18d0369bb0b2.gif?dl=0
14:51arrdem^ emacs user handshake
14:54brainproxynice
14:55delaneybrainproxy: i went from vim to visual studio. everytime i tried to do anything in emacs my left pinky went on strike claiming cruel work conditions
14:55arrdemswapping capslock and control makes all the difference
14:56delaneyi'm sure with a proper config file emacs is great.
14:56gfredericksdon't even swap, who needs capslock
14:57whodidthispoor capslock, on vim capslock is esc, on emacs control
14:58cflemingdelaney: Don't listen to the hivemind!
14:59cflemingarrdem: I'm busy right now, but I owe you a mail about RT, I can do that easily in IntelliJ to try it out
15:00arrdemcfleming: copy I was up bloody late hacking on Grim last night so I've spent my f/oss free time for a while no rush
15:01cflemingarrdem: Ok cool. I'll take a look when I get a moment - do you have your previous change in a branch somewhere public?
15:02arrdemcfleming: https://github.com/ox-lang/clojure if memory serves
15:02cflemingarrdem: Ok, will check it out. Mostly wanted a list of the methods to move.
15:03arrdemcfleming: that's one approach the the refactor, not the one I'd take were I to do it again but that fork builds and runs code just fine.
15:03cflemingarrdem: Yeah, I'm going to try to make a minimal patch to see how small it can get
15:03arrdem:+1:
15:04brainproxyarrdem: agreed re: capslock
15:04brainproxydelaney: maybe take a look at bbatsov's prelude, good setup right out of the box
15:04cflemingdelaney: If you want a very quick REPL in Cursive to play around with, and you don't need macroexpansion or the test integration, use the clojure.main REPL, starts in a flash.
15:05brainproxygfredericks: actually, that's true; I simply have capslock be another left-ctrl
15:05arrdemcfleming: oh here it is https://github.com/ox-lang/lib-clojure
15:06cflemingarrdem: Cool, thanks
15:07gfredericksbrainproxy: yeah remapping your left ctrl to capslock is bound to only ever be used in error
15:08arrdemcfleming: nope still the wrong repo. This is it. I checked the history :P https://github.com/arrdem/clojure/tree/arrdem
15:08arrdemI should throw away some of these Clojure forks...
15:13arrdemcfleming: the ox-lang/* repos are dead. the arrdem/ repo is the real one.
15:13cflemingarrdem: ok, got it, thanks
15:14TEttingerarrdem, what did you do??? who killed ox-lang????
15:14arrdemTEttinger: chill brah https://github.com/ox-lang/ox
15:14TEttingerhehe
15:14arrdemI BOUGHT THE WEBSITE OK
15:14arrdemI'M NOT GOING ANYWHERE
15:14TEttingerheh
15:15arrdemone day god willing I'll actually be able to hack on it...
15:15delaneyoh i was just saying cursive's repl startup seemed fine to me
15:15TEttingerMade avalable for distribution eh?
15:16delaneyits just nice to have a repl in general
15:16TEttingeris that a pun on vals being static and immutable?
15:16delaneythough i still certainly don't feel at home compared to js/C#
15:16arrdemTEttinger: not consciously
15:16TEttingerhehe
15:19TimMcarrdem: https://s3.amazonaws.com/lowres.cartoonstock.com/animals-shaking_hands-handshakes-secret_handshakes-octopuses-squid-bve0007_low.jpg
15:19arrdem(inc TimMc)
15:19lazybot⇒ 96
15:19arrdemsomething something carpal tunnel
15:19TimMcRelated: http://fc04.deviantart.net/fs71/i/2011/029/8/3/emacs_user_at_work_by_earlcolour-d38aj2x.jpg
15:20arrdemhttps://github.com/jonathanslenders/pyvim okay slackers where's my emacs in clojure
15:21TEttingercfleming: I was wondering how if at all you can get javadoc/clj docstrings to show in intellij
15:22TEttingeris there a keybinding for this? some name I should look for?
15:22puredangerPress f1?
15:22arrdemlol
15:22TEttingerpuredanger, I'm used to f1 opening a browser in VS, where it displays the docs automatically
15:22puredangerNo, seriously :)
15:22TEttingeroh nice
15:23gfredericksdidn't somebody have a lib that had enhanced output for clojure.test things? I thought it was jakemcc but can't find anything there
15:23TEttinger(as in, if you press f1 on, say, a for loop in C#, it opens up the MSDN docs for "how does i looping")
15:23gfredericksthe thing I want in particular right now is for ex-data to get printed
15:23gfrederickshey speaking of which
15:23puredangerThere is a ticket for that
15:23gfredericks,(Exception.)
15:24clojurebot#error{:cause nil, :via [{:type java.lang.Exception, :message nil, :at [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]}], :trace [[sandbox$eval25 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.core$eval invoke "core.clj" 3079] [clojure.core$eval3$fn__4$fn__14 invoke "NO_SOURCE_FILE" 0] ...]}
15:24gfredericks,(ex-info "Alex's ticket" {:foo 12})
15:24clojurebot#error{:cause "Alex's ticket", :via [{:type clojure.lang.ExceptionInfo, :message "Alex's ticket", :at [clojure.core$ex_info invoke "core.clj" 4591]}], :trace [[clojure.core$ex_info invoke "core.clj" 4591] [sandbox$eval49 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.core$eval invoke "core.clj" 3079] ...]}
15:24gfrederickspuredanger: ^ is the ex-data not present there? should it be?
15:25gfredericks(I realize this is separate from clojure.test printing behavior)
15:25puredangerSeems like a good idea
15:25puredangerNothing like that filed
15:25gfredericksI can ticket+patch if you like
15:27gfrederickspuredanger: possible downside: I imagine idiomatically ex-data can be arbitrarily large, and therefore not the best for printing by default
15:29Bronsagfredericks: it used to print it though
15:29gfrederickswho did when?
15:29gfredericks(and what?)
15:29gfredericksI have two different topics I'm actively juggling in this conversation
15:29puredangerIt used to tostring I think
15:29puredangerBut no longer does
15:29BronsaExceptionInfo objects, used to print ex-data in their toString
15:30gfrederickswe're talking about clojure.test now?
15:30puredangerNope
15:30Bronsano
15:30gfredericksdangit
15:30puredangerJust exinfo printing
15:30Bronsa&*clojure-version*
15:30lazybot⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}
15:30Bronsa&(ex-info "foo" {:bar 1})
15:30lazybot⇒ #<ExceptionInfo clojure.lang.ExceptionInfo: foo {:bar 1}>
15:31puredangerTicket welcome :)
15:31gfredericksoh I see, so my possible downside has been active in 1.6 this whole time is what you're saying
15:31Bronsayup
15:31gfredericksACK to you both
15:31gfredericksI'll do a ticket thing later today
15:31puredangerThx
16:36cflemingTEttinger: https://cursiveclojure.com/userguide/documentation.html
16:37cflemingTEttinger: don't mean to RTFM you but, well, it's all there :-)
16:37TEttingerhehe
16:38sveriTEttinger CTRL + Shift + A is a pretty useful command in intellij, you can find most of the things you need there
16:38TEttingerhuh, I don't see f1 there
16:39sveriYea, but if you type documentation you will find "quick documentation" and it's shortcut
16:39sverinot sure if that is enough
16:40TEttingerno it's enough
16:40TEttingerpuredanger mentioned f1 but I don't see it in cursive docs, specifically
16:41TEttingeri guess it may be open manual... another rtfm :)
16:41cflemingTEttinger: Looks like F1 does work, I always use Ctrl-J
16:41TEttingerok
16:41cflemingTEttinger: I don't use the F-keys much for things I use a lot, too far away
16:41cflemingTEttinger: Or Ctrl-P on Win/Linux I think it is
16:42TEttingeryah, agreed. this could be tricky to get used to because I switch so often from VS to IntelliJ now
16:42TEttinger(two simultaneous projects, 3 languages)
16:42sveriah, context switches, expensive! :D
16:43cflemingTEttinger: Ok, if F1 works in both then that's probably your best option, or you can remap in one or the other of course
16:43sveriTEttinger there is also a keymap option called "Visual Studio" maybe that's ok for you
16:44TEttingerhaha wunderbar
17:03bbloom_delaney: just edit text in vim and switch to VS to click around and use resharper w/ the mouse
18:00lodinWhy is there an explicit check "disabling" redefinition in defmulti? Is that a feature that can be relied upon when writing macros that emit defmultis?
18:02gfrederickslodin: I assume it's to prevent redefinition of the dispatch function, which could put existing defmethods in a weird state
18:02gfredericksnone of this global-extension-point stuff is very good with reloading :/
18:04lodingfredericks: I assume so too, but why check against it? Is there a legitimate use case for emitting several defmultis?
18:04gfredericksI figured it had more to do with reloading than with having several of them in a file
18:04gfredericksthose two are indistinguishable in a lot of contexts
18:04lodinYes, I see your point.
18:10lodingfredericks: I assume that it is unsafe to rely on this feature from inside the program then, since it's for tooling.
18:11gfrederickslodin: so what are you up to?
18:11lodingfredericks: Just writing some convenience macros.
18:12gfrederickslodin: and why might they defmulti multiple times?
18:14lodingfredericks: Because I emit a multimethod, and if the defmulti doesn't exist I should create it, and if it does exist I should only emit the defmethod and extend the multi.
18:15gfrederickswhat does the macro do?
18:16lodingfredericks: Don't make me try to explain it in just a few lines on irc. :-)
18:20gfredericksokay then I can't figure out the value judgments you were asking about
18:21gfrederickseverything you've said so far is weird enough that I can't extrapolate or ignore details
18:21lodin:-)
18:34alexbaranosky99anyone out there using leiningen's checkouts feature? I thought all I had to do was create a /checkouts dir, then add symlinks to the local source inside it
18:35alexbaranosky99but when I do that and run the tests, I get an error message like: "no such var: lib-in-checkouts/my-var"
18:36gfredericksalexbaranosky99: you still have the lib declared in the deps?
18:36alexbaranosky99gfredericks: yeah, I just took a working project that was pulling from an internal maen repo, and added the /checkouts folder
18:36alexbaranosky99gfredericks: I wonder if it is a lein version issue?
18:37gfredericksalexbaranosky99: does that var exist in the not-checked-out version?
18:37alexbaranosky99I'm on leiningen 2.5.0
18:37gfredericksand does the lib have an unusual source path?
18:37gfredericks(hopefully that last one doesn't actually cause a problem but who knows)
18:38alexbaranosky99gfredericks: I checked the soruce code -- the var is in there
18:38gfredericksalexbaranosky99: I mean in the version you have declared specifically, not the checkouts version
18:38alexbaranosky99gfredericks: by unusual source path do you just mean the project structure of the source? IT's pretty standard leiningen template
18:38gfredericksyeah that's all I meant
18:38gfredericksI don't know how checkouts works exactly so if it just adds /checkouts/foo/src to your path that would break easily
18:39alexbaranosky99gfredericks: I think I have a sound hypothesis going now
18:40alexbaranosky99the classpath is picking up an old version of that jar... that doesn't have the var in question
18:40alexbaranosky99because that jar is on the resource path
18:40alexbaranosky99ok I think that'll fix it let me see
18:40whodidthisneeds to also be a -SNAPSHOT and installed to m2
18:41gfredericksoh yeah I should have asked about `lein classpath` first
19:03gfredericksoh wow I didn't realize clojure now goes out of its way to pretty-print throwables (as data)
19:04bbloom_gfredericks: yeah, nobody made a big deal about it, but it's awesome
19:04gfrederickspuredanger: opinions about key name? :data, :ex-data, :things
19:04gfredericksbbloom_: took me a minute to realize it wasn't my normally-pretty-printing repl
19:05bbloom_gfredericks: you rocking whidbey/pudget? :-)
19:05puredangeryou can also use the new Throwable->map function to get it as data too
19:05gfredericksbbloom_: yeah
19:06gfredericksthe worst part about new clojure stuff is you can't go put it in your libs right away because of compatibility
19:06puredangergfredericks: dunno, I'd probably be overruled regardless :)
19:06gfredericksI keep wanting to make a lib just for throwing new clojure features in when possible
19:07puredanger:data seems ok
19:08puredangerI found it hugely annoying that due to dependency issues, I could not just leverage (pprint (Throwable->map ex)) in the print-method :)
19:08gfredericksack ack
19:08gfrederickspuredanger: huh? print-throwable does call Throwable->map
19:08gfredericksoh wait
19:08gfredericksyou mean clojure.pprint/pprint
19:08gfredericksrighto
19:09puredangeryeah, had to rebuild a bad version of map printing
19:09gfredericksthese are exciting times we live in
19:10gfrederickshaha I changed :message to :massage in the printing code and the tests passed
19:11puredangerthere aren't any tests for that printing format
19:11gfredericksI'll probably make some :)
19:11puredangerso tedious with all the line numbers and giant strings etc
19:11puredangerif you make some that don't suck, I'd love to have them
19:11gfredericksyou could test a roundtrip pretty easily right?
19:12puredangerwell... maybe
19:12gfredericks(= (Throwable->map ex) (read-string (print-string ex)))
19:12puredangerexcept there is no reader for #error
19:12gfredericksright okay so handwave that in there too
19:12puredangerif you make it, I'll take it :)
19:13gfrederickshey guys I just got a blank check to put new things in clojure
19:13puredangerdefinitely a lot of things written on that check :)
19:14puredangersomeone else has to sign it too
19:15brucehaumangfredericks: I’ll sign it
19:15gfrederickssweet we're in business
19:16brucehaumanlol
19:16gfredericksfirst thing is we implement that one ticket to make colons whitespace in map literals so we can all write json
19:17brucehaumanI’m totally not signing that crap
19:17brucehauman:)
19:17brucehaumanthats not even funny
19:18gfredericksalso effective immediately I will take any patch whatsoever for $100,000 each
19:18brucehauman:)
19:20puredangerUgh that ticket. Been trying to work up the nerve to close that for years :)
19:21gfrederickslol
19:23gfredericksI'm gonna add a ticket for making whitespace be not whitespace so we can write python
19:24brucehaumangfredericks: i didn’t realize your ambitions went so far beyond swerjure
19:25gfredericksI will call it snakejure
19:26brucehaumanso the code is animated and you have to box it in to beable to edit it, I get it
19:37TimMconly commas for whitespace
19:38gfredericks' ' aliases '(' and '\n' aliases ')'
19:38gfredericksfeel free to use all four
19:38TimMcInstead of ))))))) you get a big blank area.
19:39gfredericksfinally, lisp is solved
19:39brucehaumani can’t believe how easy that was
19:52Code_MonkHi Everyone, hope all is well! can anyone kindly tell me how to set a default value for a hash-map using fnil, I couldnt get it right.
19:53Code_Monkits two level deep map e.g: {:A {:B 4, :C 3} :B {:A 2} .....} something like that.
19:57justin_smithCode_Monk: do you want a default on lookup, a default when adding to some nested structure, a default on creation?
19:57justin_smithfnil is usually seen when adding to a nested data structure in multiple steps
19:58Code_MonkI'm looking for a default on lookup, it doesnt necessarily have to use fnil.
19:59justin_smith,(reduce (fn [m k] (update-in m [k] (fnil inc 0))) {} [1 2 3 1 2 1])
19:59clojurebot{1 3, 2 2, 3 1}
19:59justin_smith,(get-in {:a {:b {:c nil}}} [:a :b :c] 42)
19:59clojurebotnil
19:59justin_smitherr...
19:59justin_smith,(doc get-in)
19:59clojurebot"([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied."
19:59justin_smithaha
19:59justin_smith,(get-in {:a {:b {:c nil}}} [:a :b :c :d] 42)
19:59clojurebot42
20:01Code_Monkgreat! thanks guys. I appreciate it!
20:02justin_smithCode_Monk: fnil provides an alternate argument to a function if the input is nil, but get-in, get, etc. all take a default arg
20:19seangroveWhat's the expected way to use tools.analyzer to analyze a file on disk without loading/evaling it?
20:19seangroveCombine with tools.reader?
20:23lodinBug?
20:23lodin,(defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R []) (extend-type R P (p [_] :R)) (p (R.)) (p' (R.))
20:23clojurebotP
20:23seangroveAnd is there an easy way to read in an entire clojure source file with tools.reader?
20:23seangroveambrosebs: ^^
20:23lodinErr. Didn't show what I wanted.
20:23lodinOn my 1.6.0 the last form with p' fails.
20:24justin_smithlodin: you need a do if you want separate forms on one line to run with the bots
20:24lodinIf I contract defrecord and extend-type then it works.
20:24lodin,(do (defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R []) (extend-type R P (p [_] :R)) (p (R.)) (p' (R.)))
20:24clojurebot#error{:cause "No implementation of method: :p of protocol: #'sandbox/P found for class: sandbox.R", :via [{:type java.lang.IllegalArgumentException, :message "No implementation of method: :p of protocol: #'sandbox/P found for class: sandbox.R", :at [clojure.core$_cache_protocol_fn invoke "core_deftype.clj" 554]}], :trace [[clojure.core$_cache_protocol_fn invoke "core_deftype.clj" 554] [sandbox$ev...
20:24lodinjustin_smith: Thanks.
20:25lodin,(do (defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R [] R P (p [_] :R)) (p (R.)) (p' (R.)))
20:25clojurebot#error{:cause "only interfaces are supported, had: sandbox.R", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.IllegalArgumentException: only interfaces are supported, had: sandbox.R, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]} {:type java.lang.IllegalArgumentException, :message "only interfaces are supported, had: sandbox...
20:25lodin,(do (defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R [] P (p [_] :R)) (p (R.)) (p' (R.)))
20:25clojurebot:R
20:25lodin,(do (defprotocol P (p [x])) (defn p' [x] (identity (p x))) (defrecord R []) (extend-type R P (p [_] :R)) (p (R.)) (p' (R.)))
20:25clojurebot:R
20:25lodinBut the first fails. :-/
20:28lodinI.e., it fails if I deref #'p before I do extend-type.
20:40seangrove"Cannot recur across try" - grr, guess I'll just reach for some state then.
20:42amalloylodin: if you capture the value of a protocol function, rather than its var, it doesn't get updated
20:44gfredericksseangrove: I think I tried to make a lib that would make that easier
20:44gfredericksit might have been shoddy though
20:45seangroveIs there a reader that knows how to create ISeq from itself?
20:45seangrovegfredericks: Just surprised at how imperative this stuff is, I suppose
20:45gfredericksyeah it was this https://github.com/gfredericks/referee
20:45gfredericksI think I immediately regretted it but can't remember why
20:46seangroveHeh, looks interesting though
20:46gfredericksI guess it probably works
20:50lodinamalloy: Yes, I noticed. :-)
20:51lodinamalloy: It a different behavior from multimethods though, since defmethod doesn't update the var.
20:58gfredericksoh snap should it include the ex-data of all the causes or only the root cause
21:15seangroveIs it not possible to rewind a reader? I'm trying to use tools.reader, but I want to know if there's more to read without consuming the next form
21:21justin_smithseangrove: in fact this is what the "PushBack" in PushBackReader is named for
21:22seangrovejustin_smith: Ah, makes sense
21:22justin_smithseangrove: it supports mark and reset
21:23justin_smithseangrove: oh wait, it supports calling mark, but doesn't actually support marking, weird
21:23seangrovejustin_smith: any idea why raising an exception is such a popular way of expressing EOF? I'm not sure I really understand the benefit to this approach
21:24justin_smithseangrove: if you are eg. reading a byte, you need some value that is not a byte to indicate the stream is empty. So either you have try/catch or a conditional after your read based on type
21:25justin_smithI imagine this gets messy with primitive values too
21:26justin_smithall that said, an interface that does one thing for a successful read and another for EOF would seem to be the better and unprovided 3rd option
21:26gfredericksis that why the InputStream class uses int instead of byte?
21:27justin_smithgfredericks: could be - also it allows pretending we can do unsigned bytes
21:27gfredericksI like to pretend!!
21:29thatguyUsing compojure/ring. is there an idiom for requiring authentication for part of a site, i.e. anything with /admin in the url?
21:29justin_smiththatguy: sure, a middleware that wraps that subtree
21:29thatguyor you just call the same if statement function around all the handler methods?
21:30thatguyyeah, middleware seemed like a good idea, just never made one yet. think something like that exists?
21:30thatguyotherwise it'd be good simple one to start with I'd guess
21:31justin_smith(defn my-middleware [handler] (fn [request] something something handler request something))
21:31justin_smithtypically you end up calling the handler, maybe you alter the request or do something with the value returned by the value returned by calling the handler on the request
21:32thatguyok. seems easy enough. Think something like Friend would work? probably more than i need right now, but i guess they have their own middleware. thx
21:32justin_smiths/the value returned by the value returned/the value returned/
21:32justin_smithyes, friend has its own middleware
21:33justin_smithwhere you plug in your auth stuff
21:37gfredericksha just had my first bug where I accidentally called map with 1 arg
21:38gfrederickswill we ever get to the point where transducers aren't primarily used by accident?
21:46gfrederickswoah; my cider repl switched to always returning one result from any eval
21:46gfredericksrather than N
21:46gfredericksso "" evals to nil and "1 2" evals to 2
21:49TimMc(do %)
21:49TimMc(do ~@stuff) rather
21:50gfredericks,(do)
21:50clojurebotnil
21:50gfrederickshrmph.
21:50gfredericksas a fuddy-duddy, I object to this change.
21:51TimMcmap should also take zero arguments and randomly return one of nil, a string, or an integer.
21:51TimMcThis will make debugging more entertaining.
21:54gfredericks~as |a fuddy duddy,| I object to this change.
21:54clojurebotOk.
21:54gfredericks~hrmph ||
21:54clojurebotCool story bro.
21:55gfredericks~|| hrmph
21:55clojurebotTitim gan éirí ort.
21:55seangroveCan core.match match against lists? I'm not seeing any examples on the wiki
21:58seangroveI guess this kind of handles it http://dev.clojure.org/jira/browse/MATCH-103
22:04seangroveSeems like it isn't possible to match against nested lists, though? https://www.refheap.com/100081
22:07thatguystill there justin_smith?
22:13thatguywell.. this is my best at an authorization middleware: any glaring flaws?
22:13thatguy(defn auth-required [handler]
22:13thatguy (fn [req]
22:13thatguy (if (and (not (authorized? req))
22:13thatguy (.startsWith (:uri req) "/mgr"))
22:13thatguy (redirect "/enter")
22:13thatguy (handler req))))
22:16seangrovethatguy: Might want to make "/mgr" a vector so you can add a few different prefixes. Nicer to grow into
22:16seangrovee.g. (and (not (authorized? req)) (some #(.startsWith (:uri req)) ["/mgr" "/admin"]))
22:17thatguyha, was just about to ask, now i know about "some". thx
22:17lasergoatprobably need a % in there
22:17seangrovethatguy: What lasergoat said, heh
22:20thatguythx for the help. guess i should be in #clojure-beginners
22:20seangrovethatguy: I think that kind of question is fine for #clojure
22:21seangroveNot an op though
22:34mischovthatguy: https://www.refheap.com/ is a good place to put code samples you want to show
22:40thatguyhttps://www.refheap.com/100082 thx mischov. Glad to support clojure sites :)
22:57mischovthatguy: Updated with Sean's answer. https://www.refheap.com/100083