#clojure logs

2014-11-28

00:22thearthurwhat version of nrepl and cider does cider-spy work with? and is this the place to ask about cider-spy? #cider seems to be about the beverage
00:28justin_smiththearthur: there is #clojure-emacs
00:28justin_smiththearthur: but lots of cider users here too
00:29justin_smithit mentions cider/cider-nrepl 0.1.0-SNAPSHOT which is very old
00:30justin_smith(in its project.clj)
00:36thearthurjustin_smith: I'll just keep an eye on the project and see what happens
01:56Ninerian /msg NickServ identify Shad0wrun
03:05kenrestivoderp, time to change yer password
03:05kenrestivoNinerian: ^
03:10NinerianThe funny thing is, i dont now if its the right one.
03:14rritochNinerian: You should change that password everywhere you use it. The bots in this channel log to the web. I setup an automatic nickserv registration script on connect because I knew eventually end up in that situation if I didn't.
03:15daniel`whats his password? i didnt catch it?
03:17ucbdaniel`: it was *********
03:17daniel`thanks ucb
03:17ucbno bother, he must've changed it anyway
04:14NinerianAlready done
04:16plllxNinerian: what is
04:18nonubyif I have a record that implement a prototype, and a create an inst of this, how do I call the protype method if the prototype is defined in a different ns?
04:26nonubyhttps://github.com/stuartsierra/component/blob/master/src/com/stuartsierra/component.clj and my ns code (:require [com.stuartsierra.component :refer [start] :as component]) how does clojure know that start refers to that in Lifecycle protocol what is component.clj defined multiple prototypes that had a start method?
04:41rurumatecan zippers be used on nested maps, or nested seqs / vectors only?
04:47sm0keso i have this function from an external library `.foo` which i call on a dom element
04:48sm0kehow do i save it from being munged
04:52rurumate,(clojure.zip/zipper #(throw (NullPointerException.)) #(throw (NullPointerException.)) #(throw (NullPointerException.)) '(1 2 (2 3)))
04:52clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.zip>
04:52rurumate,(require [clojure.zip])
04:52clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.zip, compiling:(NO_SOURCE_PATH:0:0)>
04:52rurumate,(require '[clojure.zip])
04:52clojurebotnil
04:52rurumate,(clojure.zip/zipper #(throw (NullPointerException.)) #(throw (NullPointerException.)) #(throw (NullPointerException.)) '(1 2 (2 3)))
04:52clojurebot[(1 2 (2 3)) nil]
04:53rurumateit's not invoking any of the three functions. what's missing?
04:56daniel`sm0ke: externs
05:07sm0kedaniel`: what should be the extern string for it
05:08sm0kevar foo = {};
05:08sm0ke?
05:08daniel`i think so, yes
05:08daniel`not really sure right now, but im sure google can bring up some examples
05:30michaelr525hello friends
05:31michaelr525does anyone know how to switch between tabs in tool windows in intellij idea? such as multiple debug sessions in the debug tool window..
05:55noncom|2can somebody point me to that latest doc that speaks about using clojure from java ?
05:55noncom|2i remember there is some new kind of interop, but i cannot find the doc with google...
06:14gavilancomunPerhaps this from the clojure 1.6 change notes: https://github.com/clojure/clojure/blob/master/changes.md#21-java-api
06:16noncom|2gavilancomun: right! thanks, this is it :)
06:16gavilancomunnp :-)
06:27clgvwhy does `into` internally convert to transients if possible, but does not accept transients as first argument? this is pretty weird
06:27clgvfrom a user perspective
06:27Glenjamin,(transient! (transient! []))
06:27clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: transient! in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:27Glenjamin,(transient (transient []))
06:27clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector$TransientVector cannot be cast to clojure.lang.IEditableCollection>
06:28Glenjaminhrm, i can't decide if that makes sense or not :s
06:28clgvit does query whether it can create a transient. it could easily query whether the collection is a transient, as well
06:28clgv$source into
06:28lazybotinto is http://is.gd/caQYZB
06:29Glenjaminif transients were transient-able that just did identity, it'd make sense?
06:29clgvyeah, that would work as well, but fail for `into`
06:29clgv`into` would fail as well because of "(instance? clojure.lang.IEditableCollection to)"
06:30Glenjaminwould it? if TransientVector implemented clojure.lang.IEditableCollection
06:30clgvoh, or is IEditableCollection only the "can create transient" interface?
06:30Glenjamini think so
06:30clgvah right
06:31clgvlets check whether there is something in jira already
06:37dm3does anyone know if there's such a thing as a best-effort reader, which would read as much as possible and leave unreadable things as strings?
06:37SagiCZ1dm3: if unreadable things get to be strings, what are the other things?
06:38dm3forms
06:40SagiCZ1dm3: do you mean s-expressions?
06:41dm3yes
06:42SagiCZ1dm3: sorry, i have no idea, lets wait for the more experienced
06:42dm3I guess I'm being silly
06:43SagiCZ1dm3: i guess it would be really hard for the reader to partially read some invalid s-exps
06:43dm3it would, would require constant backtracking
06:44SagiCZ1yeah
06:44SagiCZ1why would you need such thing?
06:46dm3after thinking a bit I now understood that I don't need it :) I only need a way to skip reading java objects printed by clojure printer
06:46dm3like #<Object java.lang.Object@1934eeb0>
06:46SagiCZ1dm3: oh i remember dealing with this.. yes some java objects are not serializable to string
06:47SagiCZ1maybe you could just try to catch the exception
06:47dm3I guess there should be a way to use my custom data_reader
06:47dm3and just leave them as string
06:47clgvSagiCZ1: most java objects are printed that way ;)
06:47dm3and just leave them as strings
06:47SagiCZ1clgv: that is true
06:48clgvif you use a data reader you just have to implement print-method for your datatype
06:48dm3:)
06:48dm3which is any java object
06:48rritochdm3: If your just trying to extract specific values why not just read in quoted form, and then walk through your data to resolve what you need resolved?
06:48rritochdm3: ex. (read-string (str "(quote " my-str ")"))
06:49clgvdm3: why do you try to print any java object?
06:50dm3It's for a browser client for nREPL which can connect to remote repls
06:51dm3so arbitrary output possible
06:51clgvbut in a repl you get no useful print for arbitrary objects neither
06:52dm3yes, but I can have a map {:x #<Object>, :y #<Object>}
06:52dm3still want to pretty print that
06:52dm3and colorize
06:53clgvhm other nrepl clients manage that as well. so you can compare what you do different from them
06:54dm3they just display the string
06:54dm3only if you have middleware on the repl server
06:54dm3then you have control of the data
06:54clgvah so you want to navigate the data structure and render it?
06:54dm3yes
06:55clgvbut you want to keep using a text-based protocol?
06:55dm3yes :)
06:56clgvwell then you could walk the datastructure and replace non-printable objects with strings
06:57dm3that would imply access to the nrepl server
06:58clgvdm3: you will need that likely
06:58dm3ok, I'll try playing with data readers a bit more
06:58clgvdm3: or you have to write your own clojure reade that handles those #<Class ...> forms
06:58dm3yeah
06:58clgvdata-readers wont work
06:59dm3will also take a look at tools.reader
07:00clgvdm3: tools.reader will throw as well, since it is for valid clojure code. but maybe it has hooks to treat the errors
07:00clgvdm3: you can ask Bronsa. he's usually somewhere around here ;)
07:00dm3thanks for your help! :)
07:07noncom|2clgv: hi
07:07noncom|2whta ccw version are you currently on ?
07:07noncom|2i am on Version 0.30.0.STABLE001 and it cannot create clojure projects
07:10noncom|2oh, that happens only if i try to create the project inside the workspace...
07:10chennaiyinHi Everyone, I am new to clojure and I'm stuck with a small problem.Any help will be appreciated than you. I have a list of map say, [{:name Tom :child {:name Mark :child{:name Jimmy}} } {:name Ben :child {:name John}} {:name Tom :child {:name Lucy}}] it should be converted to something like [{:name Tom :child [{:name Mark :child {:name Jimmy}} {:name Lucy}]} {:name Ben :child [{:name John}] }]
07:10chennaiyinI tried merge , conj unsuccessfully :(
07:10noncom|2chennaiyin: what do you expect to happen with the data?
07:10Empperiso you try to do what?
07:11Emppericombine those maps?
07:11Empperiin what way?
07:11chennaiyinyeah combine them basically
07:11trisshey all. are there any good articles on breaking apps up in to modules when using clojure (or other functional languages I suppose)?
07:11SagiCZ1is there a difference between using -> and doto for java interop<
07:11SagiCZ1?
07:11Empperiyou have same keys in each map in your sequence, if you just combine them you'll end up with data in your last map
07:12Empperi,(reduce merge [{:foo "foo"} {:foo "bar"}])
07:12clojurebot{:foo "bar"}
07:12Empperisee
07:12Empperi,(reduce merge [{:foo "foo"} {:bar "bar"}])
07:12clojurebot{:bar "bar", :foo "foo"}
07:12chennaiyinyeah thats what seem to happen but I need them to be added/appended
07:12Empperithat does give you a map with all the data combined but keys need to be unique
07:13Empperithat doesn't explain what you are trying to achieve too well yet
07:13Empperido you want the value of :name to become the key?
07:13Empperiand then group all the children underneath that?
07:14chennaiyinI want the child to be grouped/added and the name to be the key.
07:14chennaiyinyeah
07:19Empperichennaiyin: and you need to flatten the hierarchical tree?
07:21chennaiyin@Empperi : I'm sorry what do you mean?
07:22chennaiyinI want it to be nested as it is, but no redundant keys in the list.
07:22chennaiyinjust the children added
07:27Empperichennaiyin: something like this? https://www.refheap.com/6671907e7d6b04957ae7a8a48
07:28Empperiah, add (merge-with conj) to the end
07:29Empperito make it complete
07:35chennaiyin@Empperi ok sure, I'll try that. thank you :)
07:44dgellowthere is no format fn in clojurescript ?
07:45dgellowcljs.user> cljs.core/format
07:45dgellownil
07:46Bronsadgellow: there's goog.string/format
07:46dgellowcljs.user> goog.string/format
07:46dgellownil
07:47dgellowother fns from goog.string are available
07:49Bronsadgellow: yeah, you have to import the goog.string.format gclosure namespace
07:50dgellowWith (require '[goog.string :refer [format]]) ?
07:51dgellowbecause it doesn't work
07:51Bronsano, cljs doesn't have a top-level require
07:51Bronsadgellow: (ns foo (:import goog.string.format))
07:52dgellowimport is not for "classes" ?
07:52Bronsadgellow: g.s.format is weird because it's a gclosure namespace but must be used as a function
07:52dgellowokay …
07:52Bronsadgellow: there are no classes in cljs, import is for gclosure ctors
07:53dgellowBronsa: it works :)
07:53dgellowBronsa: thank you
07:53Bronsadgellow: but gclosure has a bunch of namespaces (like g.s.format) that have weird semantics
07:53Bronsadgellow: np
08:05kungiOk I get CamelCase, I also get snake_case but why kebap-case? (Taken from camel-snake-kebab.core)
08:08dm3Bronsa: is there a way to "skip" reading java objects with tools.reader? E.g. "{:x #<Object>}" -> {:x "#<Object>"}
08:09dm3I see you can provide :default opts to the edn read function
08:11Bronsadm3: no
08:11Bronsadm3: that's for tagged readers
08:12rritochkungi: The underscore key was a fairly "late" addition to keyboards, so in lisp hyphens where used as a way to connect words into a symbol. Clojure inherited this tradition from LISP.
08:12kungirritoch: yes I know that it's a historic lisp thing. I was asking why is it called kebap case?
08:12dm3Bronsa: do you know of any way to achieve that?
08:13Bronsadm3: there's no way to do that without monkey-patching the reader
08:15dm3Bronsa: thanks! I see a `dispatch-macros` which returns a throwing reader for '<', will try to patch that
08:21p_lrritoch: it's more lack of infix operators enabling the use of less annoying keys ;)
08:22p_lkinda like why Unix cli options typically start with - instead of +, the latter required pressing the rather heavy shift key
08:23clnoob hello everyone!
08:23clnoobcan you someone give a hint why there is a need for nested braces in such construction: (-> ["aaaaa" "bbbbbb" "account"] ((fn [arg] (map #(re-matches #".*ccoun.*" %) arg))) )
08:24clnoob why (-> ["aaaaa" "bbbbbb" "account"] (fn [arg] (map #(re-matches #".*ccoun.*" %) arg)) ) is incorrect? As i understand first (fn ...) is function declaration and ((fn ..)) is function call.
08:25SagiCZ1clnoob: yeah, and you want to call the function.. not declare it
08:26clgvnoncom|2: thats weird
08:26clnoobhm, but i want it to be called while calling to (-> ... ) construction. i though it will callall mentioned functions ?
08:27noncom|2clgv: yeah, in case if i force the new wizard to create the project inside the workspace dir, it says "project project-name overlaps with existing project project-name"
08:27SagiCZ1clnoob: i know that if you have one argument function decalred elsewher you can use either "foo" or "(foo)" equaly.. not sure how is it with in-place function definitions
08:27noncom|2clgv: as if both eclipse and ccw try to create it and somehow interfere
08:28noncom|2clgv: creating elsewhere, not in the current workspace dir, goes smoothly
08:28noncom|2eclipse is kepler
08:28noncom|2have you experienced something like this ?
08:28SagiCZ1noncom|2: eclipse is so bugged i am surprised your pc didnt explode yet
08:29clnoobSgiCZ1, hm...tnx anyway for answer=)
08:29llasramclnoob: The `->` macro is operating on the source forms directly, so it threads your `["aaaaa" ...]` vector as the second form in the literal `(fn ...)` source
08:30llasram,(macroexpand-1 `(-> ["a"] (fn [x] x)))
08:30clojurebot(clojure.core/fn ["a"] [sandbox/x] sandbox/x)
08:31llasram,(macroexpand-1 '(clojure.core/-> ["a"] (fn [x] x)))
08:31clojurebot(fn ["a"] [x] x)
08:31llasramThere we go -- a bit more readable
08:40clnoobllasram,yeas i know about the way it passes args and nest calls, just use it because its more readable for me at the moment then nesting.chaining like unix-bash =) its easy when i have (-> arg fn1 fn2 fn3),but as you can see when fnX is complex - iam stuck =)
08:42gfredericksplumbing might have something for that
08:42gfredericksoh maybe not
08:42gfrederickstheir fn-> is a bit different
08:43gfredericks,(defmacro ->fn [form arglist & body] `((fn ~arglist ~@body) ~form))
08:43clojurebot#'sandbox/->fn
08:44gfredericks,(-> 7 inc dec (->fn [y] (+ y y)) inc)
08:44clojurebot15
08:45gfredericksclnoob: ^
08:52clnoobgfredericks, did not get your idea. i understand the order expansion, i dont get why i can do (-> "2" string?) and can do (-> "2" (string?)) but cant do (-> data (fn ...)) and must (-> data ((fn ...)) )
08:54gfredericksclnoob: I'm not clear on what you're not clear on; my idea was to use ->fn instead of fn
08:55gfredericksclnoob: although now that I think about it I think what you really want is as->
08:55gfredericks,(-> 7 inc dec (as->y (+ y y)) inc)
08:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: as->y in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:55gfredericks,(-> 7 inc dec (as-> y (+ y y)) inc)
08:55clojurebot15
08:55clnoobgfredericks, oh, now i see. my problem is why should i wrap one more time (fn ...) when passing to (->...).Why i cant just pass (-> arg (fn ...)).
08:56gfredericksclnoob: did you not understand llasram's expansion?
08:56clnoobgfredericks, yeas.i think i do
08:57gfredericks,(macroexpand-1 '(-> x (fn [y] (inc y))))
08:57clojurebot(fn x [y] (inc y))
08:57gfredericks,(macroexpand-1 '(-> x ((fn [y] (inc y)))))
08:57clojurebot((fn [y] (inc y)) x)
08:58clnoobgfredericks,oh.your example seems more clear to me..tnx.i'll rethink it
09:00gfredericksclnoob: I do think as-> should have you covered
09:05justin_smithmail nonuby I think by prototype you mean protocol, and the protocol functions are defined where the protocol is defined. The methods are usable via interop like any other method though. If a caller had to know the ns your record was from, that would defeat a major point of prototypes, so only the ns where the prototype is defined is needed to make the call.
09:05justin_smith$mail nonuby I think by prototype you mean protocol, and the protocol functions are defined where the protocol is defined. The methods are usable via interop like any other method though. If a caller had to know the ns your record was from, that would defeat a major point of prototypes, so only the ns where the prototype is defined is needed to make the call.
09:05lazybotMessage saved.
09:05justin_smithsorry for the double
09:08rritochIs there any realiable way to get the current namespace within a function other than using (:ns (meta #'myfunc)) which is some ugly syntax to be reading, I would prefer something like *ns* but to my surprise that doesn't resolve to the current functions namespace at runtime.
09:10rritochI thought I may be able to do it with a macro, but (meta &form) within a macro doesn't return the namespace, so I'm a bit stuck on ways to cleanup this code.
09:10justin_smithrritoch: *ns* refers to the namespace that is current when it is run
09:10justin_smithnot the namespace of the definition it is inside
09:10justin_smithmaybe you want a macro (compile time) version of *ns* ?
09:10rritochjustin_smith: Yeah, I just relized that recently, which is how I ended up with this ugly code
09:11rritochjustin_smith: Exactly what I want, but I'm not sure how to do it
09:11rritochjustin_smith: I was able to get rid of all of the gen-classes in the MVC framework, using functions which accept namespaces
09:12rritochjustin_smith: But using those functions is turning out to make some horrible to read code.
09:13rritochjustin_smith: Here is an example... https://github.com/rritoch/clj-grid-core/blob/master/src/applications/grid/views/grid/grid.clj
09:14rritochI want to get rid of this (:ns (meta garbage and replace it with something clean
09:17justin_smith&(.ns #'clojure.core/+)
09:17lazybotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Var is bad!
09:17justin_smith,(.ns #'clojure.core/+)
09:17clojurebot#<Namespace clojure.core>
09:17justin_smithrritoch: does that suffice?
09:18rritochHmm
09:18justin_smith,(name (.ns #'clojure.core/+))
09:18clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.Named>
09:18justin_smithhmm
09:18justin_smithanyway, the ns should have some method you can find via clojure.reflect/reflect to get what you want from it
09:19rritochso I can replace (:ns meta #'display)) with (.ns #'display))
09:19justin_smithbtw clojure.reflect/reflect was how I found the .ns method
09:19justin_smith,(:ns (meta #'clojure.core/+))
09:19clojurebot#<Namespace clojure.core>
09:19justin_smithyeah, you can
09:20rritochWell, that is certainly much cleaner
09:20justin_smithanyway, clojure.reflect/reflect. You probably want to use pprint with it.
09:27rritochHmm
09:27rritoch,`~*ns*
09:27clojurebot#<Namespace sandbox>
09:28rritochWill that always resolve to the namespace of the current function?
09:28SagiCZ1hi i want to do something like this
09:28SagiCZ1,(for [x [:a :b :c] y [:a :b :c]] [x y])
09:28SagiCZ1but i dont care about the order, so i need only one from [:a :b] and [:b :a]
09:28clojurebot([:a :a] [:a :b] [:a :c] [:b :a] [:b :b] ...)
09:29SagiCZ1i just need to measure distance from each point to every other
09:37justin_smithrritoch: no, *ns* refers to the namespace that is calling the current function
09:38justin_smithrritoch: almost always this is either user or the one containing -main
09:42rritochjustin_smith: Won't wrapping it in the resolution unquote `~*ns* cause it to get resolved to the load-time namespace instead of the current value of *ns*? I would think that would cause it to be in the namespace of the function it's used in.
09:43justin_smithrritoch: that's not what ` does
09:43justin_smitha macro that uses *ns* may help
09:44rritochjustin_smith: I got the idea from making a macro (defmacro cur-ns [] `~*ns*)
09:44justin_smithyou don't need ` there
09:45justin_smith(defmacro cur-ns [] *ns*) would do the same thing
09:45SagiCZ1is reduce-ing generally faster than apply-ing?
09:45SagiCZ1specifically in the case of (apply min ...)
09:45justin_smithSagiCZ1: look at the definition of min
09:45justin_smith$source min
09:45lazybotmin is http://is.gd/NAAfLh
09:46SagiCZ1justin_smith: thats a bummer then.. they thought of that
09:47justin_smithreduce1 is just an internal version of reduce https://github.com/clojure/clojure/blob/clojure-1.7.0-alpha1/src/clj/clojure/core.clj#L891
09:47SagiCZ1justin_smith: thank you
09:47justin_smithnp
09:56rritochjustin_smith: Ok, well thanks. (cur-ns) is better than what I have now, anything is better than this (:ns meta syntax.
09:58rritochjustin_smith: But this `~*ns* also seems to be working
09:59rritoch,(do (ns foo) (defn foo [x] `~*ns*) (ns bar) (foo/foo))
09:59clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: foo/foo>
09:59rritoch,(do (ns foo) (defn foo [] `~*ns*) (ns bar) (foo/foo))
09:59clojurebot#<Namespace bar>
10:00rritochAah, I guess it doesn
10:00rritocherr, doesn't.
10:00rritochIt worked from repl though when I ran those functions separately
10:10gfredericksrritoch: justin_smith: you can definitely use a macro to capture the namespace that the macro is being called in
10:10gfredericksclojure.tools.logging does this
10:10gfredericksso that it can include the namespace in the log message
10:10SagiCZ1any idea why wouldnt type hinting speed up a function which gets called many times?
10:11gfredericksSagiCZ1: well if there wasn't any reflection in the first place then type hinting wouldn't change anything
10:11SagiCZ1isnt there always reflection? i thought the function is always getting Objects..
10:12gfredericksthere's only reflection if you do interop
10:12gfredericksuse *warn-on-reflection* to figure out if there is or not
10:12SagiCZ1i do.. i call Math/pow on the parameters
10:12SagiCZ1gfredericks: ok
10:12SagiCZ1,*warn-on-reflection*
10:12clojurebotfalse
10:13SagiCZ1how do i set it
10:13gfredericks(set! *warn-on-reflection* true)
10:13gfredericksdo that in the repl if your code is being eval'd in the repl, or else at the top of your file (under ns)
10:13gfredericksyou can also run `lein check` and it will print reflection warnings for all your code (and libs)
10:14SagiCZ1so is that an atom? thanks
10:14gfredericksno it's a dynamic var
10:14SagiCZ1ok
10:14SagiCZ1ok so i set it to true, ran my code again, and it didnt show any warnings, how is that possible
10:14SagiCZ1,(set! *warn-on-reflection* true)
10:14clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set>
10:15gfredericksSagiCZ1: I think if the interop is unambiguous it doesn't need to reflect
10:15gfrederickse.g., if Math/pow only has one signature
10:16SagiCZ1yeah.. looks like there is only pow(double, double)
10:16gfrederickswhereas if you tried one of the ambiguous methods you should see the warning, and much slower code
10:17SagiCZ1gfredericks: thank you.. that is very smart.. the bad news is, i cant speed up the code
10:17gfrederickshaha
10:17gfredericksdid you type-hint with primitives?
10:17gfredericksi.e., ^double vs ^Double
10:17SagiCZ1i had a capital D there.. let me try it with lower-case
10:18gfredericksI think that will only have an effect under specific circumstances
10:18SagiCZ1yeah, still the same speed
10:18gfrederickslike maybe only if the call site has hinted primitives as well...or something
10:20SagiCZ1the whole function takes 1ms on average, so i guess thats pretty fast.. the problem is probably that the algorithm is O(n^2) which is pretty nasty for n=5000
10:23gfredericksclojurebot: O(n^2) is pretty nasty for n=5000
10:23clojurebotA nod, you know, is as good as a wink to a blind horse.
10:24SagiCZ1hehe
10:43kungiI would like to validate if a given string is a mail address? Any suggestions for a good validation library?
10:45SagiCZ1kungi: wouldnt some wicked regex be enough?
10:45kungiSagiCZ1: Hmm no. I will need to do more validation soon :-)
10:46SagiCZ1kungi: in what sense "more" <
10:46SagiCZ1?
10:46kungiSagiCZ1: Also I stopped using perl in production because of wikced regex
10:46kungiSagiCZ1: Like validate if fields are not empty or contain a name already present in the model or ....
10:47justin_smithgfredericks: re *ns* in a macro - agreed. I was just saying that `~*ns* was pointless, and he should just use *ns*
10:47leandro1hi! given «palabras» is a vector, what is wrong with this ? → for [ p palabras :when (even? .indexOf palabras p)] p)
10:48SagiCZ1leandro1: interop calls cant act as symbols directly
10:48SagiCZ1wrap it in #(.. %)
10:49justin_smithleandro1: many missing parens there
10:49justin_smith:when (even? (.indexOf palabras p))
10:50justin_smithSagiCZ1: (even? #(.indexOf %) palabras p) makes no sense, if that's what you meant
10:50leandro1mmm
10:50justin_smith,(even? (.indexOf [0 1 2 3] 2))
10:50SagiCZ1justin_smith: it was a first mistake i spotted.. but you are right
10:50clojurebottrue
10:51justin_smith,(even? .indexOf [0 1 2 3] 2)
10:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: .indexOf in this context, compiling:(NO_SOURCE_PATH:0:0)>
10:51justin_smithSagiCZ1: you saw the right problem, just not yet the right solution
10:51SagiCZ1justin_smith: yeah
10:51leandro1ok, lets add some parens
10:52kungiSagiCZ1: Hmm ok about that wicked regex you have been talking about :-). Which one would you use?
10:53SagiCZ1check out this article http://www.regular-expressions.info/email.html
10:55ajmccluskeykungi: is it possible to simply send an email with a validation link/code?
10:55justin_smithajmccluskey: yeah, that's the only right way to validate an email. The actual spec for what is valid in an email is actually kind of insane.
10:56rritochkungi: If you are using leiningen you can try https://javamail.java.net/nonav/docs/api/javax/mail/internet/InternetAddress.html#validate() by adding [com.sun.mail/javax.mail "1.5.2"] to your dependencies. with syntax (.validate (InternetAddress. addr-str))
10:56ajmccluskeyjustin_smith: yeah, I saw this question come up recently, and the consensus was basically "that's a deep, dark hole so just send an email"
10:57ToxicFrogYes. Don't. Just don't. If you try, you will fuck it up, and people will enter their real, working email addresses only to have them rejected by the system, and then they will be angry and either not use your service or send you angry emails.
10:58ToxicFrogOr both.
10:58kungiajmccluskey: It's for an API parameter validation. I get some object by mail and would like to have a valid mail address as parameter.
10:59kungirritoch: Thank you that sounds feasable.
11:02EvanRyeah a valid email pattern wont ensure anything about anything
11:03EvanRinstructive to (re)establish what the point of having their email is and what it would mean
11:04EvanReven if they respond to an email, it may eventually become invalid anyway
11:05EvanRToxicFrog: just make sure your "angry email" address is weird enough that most mail clients reject it, thus when they go to send you angry emails they get even more angry ;)
11:05mavbozoso, people build email validation as as service
11:05kungiEvanR: A valid mail pattern will ensure that the mail address in the string I am processing is well formed. (whatever I define as well formed).
11:06EvanRkungi: but what is the point of that?
11:06kungiEvanR: I can give out an error message saying. This mail address is not well formed please try again to the user of my api. Instead of just giving an error or empty result.
11:07EvanR"not an empty string" is the only invariant i can think of that id be ok with relying on
11:07mavbozoemail can be invalid, for example, because yahoomail deactivates account after 6 months of inactivity
11:07ToxicFrogEvanR: I think email addresses are guaranteed to contain a @ and at least two other characters, as long as they aren't addresses on localhost? Don't quote me on that, though.
11:07kungiEvanR: No. "hello" for example cannot be a mail address.
11:08ToxicFrogkungi: it can in fact be a local mail address; I have daemons that send mail to 'root' and 'webmaster'.
11:08EvanRToxicFrog: right.. and your "send them an email" routine will catch anything that doesnt work
11:08kungiToxicFrog: ok point taken :-)
11:08mavbozogot burned by lots of customers who forget their password and cannot reset their password
11:08SagiCZ1cant we just rule out the 0.000001% of insane addresses and simplify thus the problem immensely?
11:08EvanRkungi: because you said so? or by fiat? or you have critical code that causes a hospital to catch fire if no @ is found?
11:08mavbozofalse negative?
11:10kungiEvanR: I don't write code for hospitals or anything "critical" in that sense. But I see your point.
11:10EvanRSagiCZ1: its simplified by just not caring, like random symbols is a bad "first name field" but its not simple to write code to define and ignore those
11:10kungiI just tried for my software to be a bit more convenient and give a more sensible error message than "no result found".
11:11EvanRkungi: when you try to send a confirmation mail, and it doesnt work, you will get one of a myriad of possible problems. you can translate these for the users benefit, or just dump the message if youre lazy
11:11kungiBut I see now this is a dead end full of spiders.
11:12EvanRthat is, youll get a message describing why it didnt work
11:12EvanRone of them is something like "bad email address format"
11:12CookedGryphoncould somebody help explain how this code is okay? https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/middleware/session.clj#L34
11:12CookedGryphonIt looks like it's calling .close on java.io.Writer, which is an abstract method and so shouldn't have an implementation
11:12CookedGryphonwait, no it's not
11:13EvanRbut its not nearly the only possibility
11:13mavbozokungi: yeah, there is discussion on hackernews years ago. https://news.ycombinator.com/item?id=5763327
11:13CookedGryphonit's type hinting this to Writer, which is abstract and calling .flush, is what I meant
11:14clgvnoncom|2: no. creating clojure projects via "New" works like a charm here. (Luna SR1)
11:15ToxicFrogCookedGryphon: exactly, and the actual value is going to be some sort of concrete implementation of Writer with an actual impl for it.
11:15CookedGryphonbut it's a wrong type hint
11:15CookedGryphonsorry, I mean the bytecode makes it look wrong
11:15noncom|2clgv: oh well.. what a luck here :)
11:15CookedGryphoneven though it should work at runtime
11:15CookedGryphonthis is coming up as a verification error in art, thinks it's calling an abstract method
11:16kungimavbozo: That is interesting
11:21clgvnoncom|2: did you try out a fresh workspace?
11:22noncom|2nope.. but that happens whatever is the name of the project, even a new random one.. so i guess that does not matter much..
11:22noncom|2maybe the fact that i am still with kepler - does matter
11:22kungiI am now going for the mail must contain at least an @ and a . "solution".
11:23clgvnoncom|2: not sure about that. I had kepler running until a few weeks ago
11:24noncom|2clgv: i suppose the issue is here with the stabile 30 version since it ings some differences in project creation
11:24noncom|2*brings
11:26clgvnoncom|2: try the fresh workspace and if that fails report an issue - since it should be reproducible then
11:27noncom|2yeah, gonna try that
11:35SagiCZ1i want 'iterate' to stop iterating when f returns nil, is that possible?
11:35luxbockSagiCZ1: you can use take-while on it
11:36SagiCZ1luxbock: cool, thanks
12:13leandro1how to print each item of a vector line by line?
12:14leandro1(println (for [m mix] (str m "\n"))) <- doesn't work :/
12:14clgvthe clojure function `hash` should call the hash code method of my deftype, correct?
12:15clgvargs! how I hate those stale class files :(
12:28andyfleandro1: one way is (doseq [m mix] (println m))
12:28andyfSomething closer to the way you tried would be (apply println (for [m mix] (str m ?\n?)))
12:29andyfbecause (apply f [i1 i2 i3]) turns into (f i1 i2 i3)
12:34upwardindexbit-shift-* with only 1 argument should bit shift by 1 bit.
12:35andyfbecause 1 is so hard to type?
12:35upwardindexandyf: what do you propose the 1 arity be used for?
12:36andyfthrowing an exception seems reasonable to me
12:36andyfbecause it means I forgot the shift amount arg
12:36andyfbut tastes can differ
12:39andyfyou may define macros that behave as you wish, and they could even have much shorter names like << >> >>> like Zach Tellman's primitive-math lib does: https://github.com/ztellman/primitive-math
12:43liflashhi everybody
12:43liflashsomeone familiar with kioo?
12:45andyf~anyone
12:45clojurebotanyone is anybody
12:45andyfUsually that gives a sentence about 'better to ask your question, and someone will answer if they know'
12:45andyf!anybody
12:45andyf~anybody
12:45clojurebotanybody is anyone
12:46andyfbut not today :)
12:46clgvandyf: now you broke it
12:46clgvit was anybody
12:46clgv~anybody
12:46clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
12:46clgvah it still is
12:47andyfglad you were here to fix it :)
12:47clgvnot really ;)
12:47liflash`since my internet connection is pretty unstable i'll start again: hi everybody
12:47clgvandyf: maybe the bot is playing tricks on you ;)
12:47liflash`anybody familiar with kioo?
12:48clgv~anybody
12:48clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
12:48andyfTry asking your question with more details. If someone knows, they will answer.
12:48liflash`ok ;)
12:49liflash`i'm using kioo for a web app and have a selector like [(attr= :attr "something")] and don't know why it works, because i never import attr=
12:50liflash`when defining a function like this (defn attr [attr-name] (attr= :attr attr-name)) it doesn't work
12:50liflash`why?
12:50clojurebothttp://clojure.org/rationale
12:51clgvliflash`: some macro magic? where is the selector placed?
12:51liflash`within a defsnippet
12:53Bronsaliflash`: https://github.com/ckirkendall/kioo/blob/master/src/kioo/core.clj#L72-L73
12:53Bronsaliflash`: https://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L801-L803
12:54Bronsaliflash`: so attr= is automagically resolved to net.grand.enlive-html/attr=
12:54clgvmacro magic ^^
12:55liflash`automagically nails it ;)
12:55liflash`hmmm
12:56liflash`does it make sense to you that it only works if it's directly within the defsnippet but not if it's wrapped in a function call?
12:56liflash`i'm not that familiar with macros yet
12:57Bronsaliflash`: yes, it's the defsnippet macro that transforms attr= into net.grand.enlive-html/attr=
12:57liflash`ok, thought so
12:57Bronsawell, not the defsnippet macro itself but part of its implementation
12:57liflash`so if i want to use it in my own function i would have to import the enlive macros, right?
12:57clojurebotHuh?
12:58Bronsaliflash`: (:require [net.grand.enlive-html :refer [attr=]]) in your ns form. btw attr= is a function not a macro
12:59liflash`ok, as i expected
12:59liflash`it's not exactly a function, is it? (def attr= ...)
13:01Bronsaliflash`: it is -- (multi-attr-pred ..) returns a function
13:02Bronsaliflash`: (defn foo [..] ..) is ~= (def foo (fn [..] ..))
13:04liflash`of course... sorry. still new to all this ;)
13:04liflash`thanks a lot Bronsa
13:04Bronsanp
13:28Fenderhi there
13:29Fender,(let [m (transient {}) ]
13:29Fender (doseq [i (range 10)]
13:29Fender (assoc! m i (inc i)))
13:29Fender (count m))
13:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
13:29Fenderohh
13:29Fender,(let [m (transient {}) ] (doseq [i (range 10)] (assoc! m i (inc i))) (count m))
13:29clojurebot8
13:29Fenderwtf=
13:29Fender?
13:29Fenderit should be 10, anyone has an idea why that is?
13:30yediwhats it called when an editor provides a matching parentheses for you when you type (
13:30yeditryna figure out why lighttable isn't doing that
13:30yedianymore
13:31Fenderparedit is the best know tool used for that
13:31Fendermaybe you can search for lighttable + paredit
13:31BronsaFender: that's not how transients should be used
13:31FenderI know, I constructed a minimal example
13:31BronsaFender: you should always operate on the return value of a transient operation
13:31Fenderoh
13:32Fenderbut it shouldnt make a difference, right?
13:32Fenderit's mutable
13:32BronsaFender: e.g (assoc! (assoc! x 1 1) 2 2) rather than (do (assoc! x 1 1) (assoc! x 2 2))
13:32BronsaFender: clearly it does
13:33andyfFender: Think of it this way: (assoc x ...) returns a new value, and the original value is still around for use, or for doing further operations like assoc on. (assoc! x ...) returns a new value, and the original value is now UNDEFINED, and should never be used.
13:33Fender,(count (reduce #(assoc! %1 %2 1) (transient {}) (range 10)))
13:33clojurebot10
13:33andyfeven though clearly it causes no error if you try to use the original value again.
13:33gfredericks,(doc assoc!)
13:33clojurebot"([coll key val] [coll key val & kvs]); When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vector, sets the val at index. Note - index must be <= (count vector). Returns coll."
13:33Fenderto keep it as functional as possible
13:34gfredericksFender: and also the return value is different sometimes
13:34andyfclgv: http://clojuredocs.org/clojure.core/assoc!
13:34BronsaFender: it's mostly for efficiency reasons, this way creating a transient and converting it back to a persistent data structure can be constant time operations
13:35Fenderhmm, ok, I didnt know that
13:35Fenderbut that's a pretty strange bevahior
13:35Fenderanyhow, thanks very much
13:35BronsaFender: http://clojure.org/transients "Note in particular that transients are not designed to be bashed in-place. You must capture and use the return value in the next call"
13:35gfredericksI wonder if the ztellman vectors will have transient versions
13:35FenderI was thinking I found a bug because googling for transient! map clojure didnt bring up anything useful
13:35Fendermany many thanks!!!!
13:36andyfClojureDocs.org for some functions and macros has useful additional info
13:36clgvandyf: for what?
13:36andyfclgv: You want a list of the ones I think are most useful? :)
13:37clgvandyf: huh?
13:37andyfSorry. I don't know what you are asking about when you asked "for what?"
13:37Fenderwhat about bashed-in handling of transients vectors in transient maps?
13:37gfredericksclojurebot: huh is <reply> what?
13:37clojurebotI don't understand.
13:37clgvandyf: I didn post anything for ~40mins ;)
13:38BronsaFender: what?
13:38gfredericksFender: whatever you're doing should never bash in place
13:38gfredericksI think nested transients tends to be pretty awkward
13:38Fenderfor example, I have a map where the values are vectors
13:38gfrederickswhat's your broader algorithm here?
13:38Fenderand I would these vectors to be transients as well
13:39Fenderlet's say it's a weird group-by
13:39gfredericksmulti-group-by? :)
13:39gfredericksI wrote such a thing and it's probably the only time I've tried to use nested transients
13:39andyfFender: You could probably do that and make it work correctly, but you would need to do assoc on the map every time you did assoc! on one of the vectors it contains as a value, to update the top level map.
13:40andyf(or assoc! on the top level map, if it was also a transient)
13:40gfredericks^ thus "awkward"
13:40andyfAt the end, you'd need a pass of going through all vectors in the map to do persistent on them, again each time updating the top level map, and finally when all that was done, persistent on the top level map
13:41Fenderhmmm
13:41Fenderit may well be that I got some algorithms wrong then
13:41andyfpossible, but best to isolate in one carefully written function.
13:41Fenderit's just for performance actually becuase it's lots of data
13:41gfredericksI might have ended up using a java.util.HashMap at the top level; can't remember
13:42andyfSure. performance is the only reason transients exist.
13:42Fendertrue^^
13:44leandro1if i do lein run my_param, it gets the para. but if i compile to .jar it can't get the param :(
13:44clojurebotTitim gan éirí ort.
13:45gfredericksleandro1: how do you run the jar exactly?
13:47Fenderok, thanks again, guys, without this channel I'd be looking for days
13:47Fenderbye
13:48leandro1java -jar myjar.jar my_arg
13:49andyfgfredericks: assoc! and similar doc strings are not as explicit as I would have written them, but then most doc strings aren't :)
13:49andyfHence my editing of ClojureDocs.org
13:50leandro1java -jar myjar.jar my_arg, gfredericks
13:50gfredericksandyf: I think there's a ticket with a patch for that
13:50gfredericksandyf: cuz I think I patched it maybe
13:50gfredericksleandro1: and your main function runs correctly but without the arg?
13:51leandro1yes
13:51gfredericksI can't think of how that would happen
13:51leandro1with lein works perfectly, gfredericks
13:51gfredericksif you can create some minimal example project, that might help us diagnose it
13:54leandro1yes, i have an example. 1 seg.
13:56leandro1oh, my fault
13:57leandro1i'm an idiot :) a typo
13:57gfredericks:)
13:59leandro1,inc gfredericks
13:59clojurebot#<core$inc clojure.core$inc@18ceb26>
14:01leandro1,(inc gfredericks)
14:01clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: gfredericks in this context, compiling:(NO_SOURCE_PATH:0:0)>
14:01gfredericks(inc example)
14:01lazybot⇒ 0
14:02leandro1whats the comma for?
14:02leandro1(inc gfredericks)
14:02lazybot⇒ 109
14:03cristian3Is there a way to make let bindings lazy? For instance:
14:03cristian3(let [x "yay" y (println (str "yo"))] x)
14:03gfredericksleandro1: comma is for normal eval, wherewithalupon "gfredericks" is meaningless
14:03cristian3I'd expect println to not be called
14:03gfrederickscristian3: just manually with delay & deref
14:03cristian3Since it's not being used in the body of let
14:03cristian3Ok... I'll look into it
14:03cristian3Thanks sir
14:05mr_rmI know there must be an overflow here but i'm not sure how to fix it... why does this return an empty list? (take 6000 (drop 30000 (range 50000000)))
14:07andyfmr_rm: It doesn't for me.
14:07mr_rmandyf: hmmm are you using java 8?
14:08andyfmr_rm: Not in the test I just did, which was java 7, but I will try again on another machine with java 8
14:09mr_rmoh... hmmm. i just started a lein repl in my project and it works there. i was evaluating this in Eclipse ccw which is where i was seeing the empty list
14:09mr_rmthat's odd
14:10andyfEclipse ccw may have something that is limiting the size of the output? I haven't used Eclipse ccw
14:11mr_rmwhat's weird is it's fine with showing me the whole list if i just drop the first 30000. when i add the take 6000 it fails, but (take 5000) still works. yes there is some limit there but this sucks. i would have expected at least to get an exception
14:18{blake}Works for me everywhere I try it (but not using CCW).
14:22mr_rm{blake}: thanks for letting me know. yes it's fine in the plain lein repl here too. seems to be some problem with my eclipse CCW. everything is the latest (eclipse 4.4, java 8, ccw stable branch). i'm gonna go try the nightly branch of ccw or something later
14:23gfredericksmr_rm: curious what happens if you e.g. wrap the expression in (vec ...)
14:23mr_rmnever ran into such an issue before where it just gave me a bad result
14:23{blake}mr_rm: I've ping-ponged between cursive and ccw and settled on cursive (where it also works).
14:24mr_rmgfredericks: restarting eclipse... 1 min
14:26mr_rmgfredericks: wrapping it in vec just returns [] :)
14:27gfrederickshow about (count ...)?
14:27mr_rmahhh (take 6000 (vec (drop 30000 (range 50000000)))) OutOfMemoryError Java heap space java.lang.Long.valueOf (:-1)
14:28gfredericksyeah that makes sense
14:28mr_rmwithout the vec, i get nothing :\
14:29mr_rmi'll try updating to a later "unstable" ccw version
14:29gfredericksI asked about count
14:30gfrederickswhich hopefully would distinguish between strange collection-printing-behavior and some deeper stranger problem
14:32mr_rmgfredericks: yes count worked. returned 6000
14:32grandyhello, new to clojure and working with compjure and cemerick/friend and experiencing a bit of confusion about how the simple form login works ... not sure if I have to implement the POST handler for /login
14:32gfrederickspr-str is another thing to try
14:32gfredericksor (apply str ...)
14:33mr_rmgfredericks: (range 6000) showed ok. yes i'll try your suggestion
14:34mr_rmgfredericks: ok... apply str turns it into one giant string. so it seems to be some weird display problem
14:35gfredericksyeah :/
14:35gfredericksat least that was the sanest possibility
14:38mr_rmi can doseq over it fine too. oh well... going to try later plugin now and see if that helps
15:00mindbender1How do I build a reusable tab widget in om?
15:01justin_smithgrandy: friend can be confusing even for experienced clojure users.
15:02grandyjustin_smith: is there a super simple auth library out there? or should i just keep at it?
15:02grandyjustin_smith: seems like friend is very cleverly designed
15:02justin_smiththere's a working friend example here https://github.com/eggsby/warden/blob/master/src/clj/warden/api.clj#L117-L152
15:03justin_smithanother one here that may be more clear https://github.com/hiredman/ideapad/blob/master/src/com/thelastcitadel/ideapad.clj
15:03justin_smithgrandy: it is clever, but not intuitive for most of us
15:04grandyjustin_smith: well glad to hear it's not just me...
15:04grandyjustin_smith: brb in 2 mins
15:05mindbender1what's clever about it?
15:06justin_smithmindbender1: it provides a pluggable authentication layer, without the prerequisite that you use some framework
15:07justin_smithand without much in the way of OO style state management
15:09mindbender1i.e. it cleverly leaves the authentication layer for you to worry about. What then does it provide? authorization?
15:10justin_smithit has functions that do authentication and authorization
15:10justin_smithvia bcrypt/scrypt and ring middlewares, respectively
15:11mindbender1It also compojure based.
15:11justin_smithno, it is not compojure based
15:11justin_smithit's a ring middleware
15:11justin_smithnothing about it requires or uses compojure
15:12mindbender1Well I use pedestal and I had a hard time implementing it.
15:13mindbender1clauth even does a better job IMHO.
15:14mindbender1Yet I end up writing something that was more understandable to me.
15:16justin_smithmindbender1: I have used compojure and other ring based routing libs, and had a hard time implementing friend. The problem is the design is unintuitive. It isn't because you weren't using compojure.
15:17grandywhich one do you guys think is the easiest/simplest?
15:17mindbender1I meant to say it used old style middleware composition which compojure is based on.
15:17jjttjjany guidelines/best practices out there for how to organize directory structures for projects with clojure and clojurescript?
15:18justin_smithmindbender1: well, anything that handles requests in the clojure universe is capable of middleware composition, it's just a functional design pattern.
15:18justin_smiths/anything that handles requests/anything/
15:19grandyoddly teh thing i'm finding confusing with friend is that when i submit the form to log in the login always fails, and as far as i can tell my code is equivalent to what is in the friend demo app
15:20mindbender1justin_smith: I agree. Just the effort required when you need to untie.
15:21justin_smithgrandy: so you have a map of usernames and password hashes, and use the friend middleware to authenticate, and have a session store that stores the authenticated state?
15:21grandyusername and password hashes: yes
15:21grandymiddleware: yes
15:22justin_smithhow are you storing the session?
15:22justin_smithfriend doesn't do that automatically
15:22justin_smithand without a session you can't persist the state of a user being logged in
15:23grandyjustin_smith: using ring middleware session and wrap-session -- session appears to work ( created a page that increments a value) but for some reason doens't appear to be using the config i'm passing in
15:23justin_smithOK
15:23grandyahh i need to check where friend updates the session
15:26grandythis is my code: https://gist.github.com/anonymous/bf566201083c937e868d
15:26grandyjustin_smith: just trying to get the basic auth/unauthed handlers working
15:28justin_smithso does pages/login get called when soemone tries to access /requires-authentication ?
15:29grandyyes
15:30grandyit's just a view template, actually i used the one that was used by the friend demo app
15:30grandythere is a function that wraps it with a layout, etc. before it is rendered
15:31grandyjustin_smith: this is the login handler:
15:31grandyhttps://www.irccloud.com/pastebin/1Camp8sz
15:32grandyand login-form2 is identical to the one in the friend demo except that i implemented it as a function rather than as a global value
15:36grandyI also don't see anything referencing the session in this example: https://github.com/cemerick/friend-demo/blob/master/src/clj/cemerick/friend_demo/interactive_form.clj
15:37justin_smithoh - is friend using its own state / session separate from user provided?
15:37justin_smithI may be the wrong one to ask about using friend. Make that am.
15:38grandyjustin_smith: not sure, just reading over the source
15:39grandymaybe i'll just implement a simple session based one for now
15:39grandyit's not fun being this stupid
15:40justin_smithyeah.
15:46grandyhmm
15:46grandywell thanks for all your help, justin_smith, both today and in the past
15:51justin_smithgrandy: thanks. It's clear I'll have to figure out friend one of these days, maybe make a blog post or something walking through it.
15:57mindbender1The confusing aspect of friends is the workflow.
15:58mindbender1Figure that out and you know if friend is for you.
16:00grandymindbender1: yeah i am now pasting in some of the friend source into my app so I can debug line by line and figure out what is going wrong...
16:21gfredericksis there a lib somewhere that adapts a java.net.Socket to a pair of core.async channels?
16:21gfredericks(for line<->msg equivalence)
16:28bbloomgfredericks: why do you need a lib for that? isn't it just a thread + a loop?
16:28bbloomit's only tricky if you need to do multiplexing
16:28gfredericksbbloom: seems to be some tricky shutdown logic too
16:29gfredericksbbloom: I didn't mean a *big* lib :P
16:29bbloomthe shutdown logic can be pretty simple depending on your needs
16:30gfrederickswell I've got two different go loops going
16:30gfredericksand exceptions thrown in either of them will just disappear
16:31grandyjustin_smith: got it working
16:31bbloomgfredericks: are there IOExceptions you have to catch for correct functionality of a socket? (i wouldn't be surprised, but i forget)
16:31grandyhad the handlers set up nested incorrectly
16:31justin_smithgrandy: interesting, what was the issue?
16:31grandyoddly it still worked
16:31grandyfor serving requests, just not for authenticated ones
16:32grandyjustin_smith: this app definition works:
16:32grandyhttps://www.irccloud.com/pastebin/GexTqrnq
16:32gfredericksbbloom: I don't know either, that's why I asked about a lib :)
16:33bbloomlooking at docs, i'm pretty sure all you need to do is create a socket, then grab it's InputStream, then read from that stream in a loop
16:33gfrederickswell I need to write also
16:33justin_smithgrandy: so friend goes between the routing and the handler
16:33gfredericksthus two channels, two go-loops
16:33grandyyes
16:33bbloomgfredericks: sure, what i'm saying also applies for outputstream & writing
16:34bbloomlooking at this you can just call read and catch IOException if the channel is closed on you
16:34gfredericksbbloom: and my point is that the failure modes seem squared now that I'm doing both
16:34gfredericksthey might not be
16:35bbloomthat's gonna depend on your mode of use of the socket. are you reading/writing independently? is there some alternating between reading and writing? depends on the protocol
16:35gfredericksit's irc
16:35gfredericksso...anything's possible?
16:35bbloom*shrug* ii dunno much about irc's protocol
16:36bbloombut i'd imagine async inbound messages can occur
16:37bbloomanyway, the reason there's no lib for this is b/c it would be super specialized to a particular style of protocol
16:37gfredericksyeah? why would just two channels not be generally useful?
16:38bbloomb/c you may need to coordinate between reading and writing
16:38bbloomlike a handshake, for example
16:38gfredericksand channels make that harder?
16:39bbloomno channels can make that easier... it's just that having two of them that pump the in/out streams isn't what you want in that case really
16:40bbloomgfredericks: you'd want a more complete abstraction over sockets. checkout http://golang.org/pkg/net/#Conn
16:41bbloomgfredericks: if a lib just provided those two channels, it would also need to provide some mechanism for working w/ the java Socket object too, but it couldn't ensure you'd use it correclty w/ it's invariants (probably) so you'd really want to completely encapsulate the socket object
16:44gfrederickshmmm. good thoughts, thanks
16:44gfredericks(inc bbloom)
16:44lazybot⇒ 49
16:47Guest40995Is (inc username) sort of like +1ing?
16:47gfredericksI think so
16:47Guest40995(inc gfredericks)
16:47lazybot⇒ 110
16:48Guest40995(dec gfredericks)
16:48lazybot⇒ 109
16:48TEttinger(inc gfredericks)
16:48lazybot⇒ 110
16:48Guest40995;(+ gfredericks 1000)
16:48TEttinger(identity TEttinger)
16:48lazybotTEttinger has karma 30.
16:48TEttingeronly inc and dec and identity
16:49Guest40995Thats pretty cool
16:50justin_smithnot what the actual clojure functions do though
17:08officialxianHehy
17:08officialxianHey*
17:19helpmepleasecan i disable cider's prompt to save a file when I do C-c k?
17:21jeremyheilerhelpmeplease: yes. check out the cider readme... search for "save"
17:23helpmepleasejeremyheiler: thanks!
17:24jeremyheilernp
18:11fowlslegs,{:naturalpowersoftwo '(2 4 8 (Math/pow 2 4))}
18:11clojurebot{:naturalpowersoftwo (2 4 8 (Math/pow 2 4))}
18:11fowlslegsHow can I have this evaluate the Math/pow expression?
18:16gfredericks,(list 2 4 8 (Math/pow 2 4))
18:16clojurebot(2 4 8 16.0)
18:16gfredericksor
18:16gfredericks,[2 4 8 (Math/pow 2 4)]
18:16clojurebot[2 4 8 16.0]
18:16gfredericksthe latter is better unless there's some reason you can't use a vector
18:17fowlslegsdanke gfredericks
18:18justin_smith,(take 4 (interate #(* 2 %) 2))
18:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: interate in this context, compiling:(NO_SOURCE_PATH:0:0)>
18:18justin_smith,(take 4 (iterate #(* 2 %) 2))
18:18clojurebot(2 4 8 16)
18:18justin_smith"interate" lol :P
18:18gfredericks,(def interate (partial map int))
18:18clojurebot#'sandbox/interate
18:18justin_smithlol
18:44trisshey all. just want to double check theres not a function similar to update-in that only takes one key.
18:44trissi.e. isn't designed for nested datastructures.
18:45trissis there a more efficient one or something that only goes one deep?
18:45jeremyheilertriss: not yet, but one will be available in clojure 1.7
18:45jeremyheileri wouldn't worry about efficiency in this regard tho
18:45trisscheers man.
18:45trissi'll stick to update-in then
18:50munderwoHI all. anyone had an issue using slimerjs on OSX to test clojurescript where slimerjs runs but doesnt do anything?
20:44helpmepleasehey everyone! im trying to install cider fom MELPA, but when I do M-x package-install cider
20:44helpmepleaseit says "Error during download request: Not Found"
20:53xeqihelpmeplease: do you have melpa or marmalade added to your repo list/
20:53xeqi?
21:27cateryclojurescript needs to win and beat coffeescript
21:54myguidingstarcataska, I thought it did?
22:00caterywhy is this channel so dead
22:04cateryare you guys working to make clojurescript win?
22:09justin_smithfridays are usually a bit slow. US holidays also. Today is kind of both.
22:13TEttingercatery, they aren't really competing, I would say. coffeescript is a slight improvement on top of javascript, clojurescript is a completely different everything
22:13cateryjavascript sucks right so we need a replacement like clojurescript right?
22:16TEttingerjs sure does suck, and there are a LOT of replacements
22:16TEttingera list https://github.com/jashkenas/coffeescript/wiki/List-of-languages-that-compile-to-JS
22:17technomancyor you could just write software that runs on another runtime
22:18cateryso we want clojurescript to become the de facto standard replacement for javascript
22:18TEttingerthis is nuts https://tardisgo.github.io/
22:19technomancy"we" just want to never have to write any software that runs in the browser
22:19fatalpotatoxeqi: yeah i added them both
22:19technomancyymmv
22:19TEttingerit compiles go to haxe, then you can compile that haxe to js (or that haxe to C++ and then that C++ to native code)
22:23fatalpotatohi everyone! i can't install cider for some reason, does anyone know what's going on?
22:23fatalpotatoI added melpa and marmalade
22:24fatalpotatowait it just installed this time
22:24fatalpotatonevver mind
22:40dcunit3dis clojure sorted-set optimized for performance when doing .contains? and inserting?
22:40dcunit3dlike if i have a huge sorted-set of integers, will it use a binary search for contains? or when finding the index it needs to insert to?
22:42dcunit3di'm also looking in the docs, but thought i'd ask to see
22:45dcunit3dit looks like yes, but i'll need to use sorted-set-by to ensure the right comparator function is set
23:27andyfdcunit3d: Clojure sorted-set does use balanced binary search trees in their implementation, as does sorted-map
23:27andyfSo searching, inserting, and removing items are all O(log n) time operations