#clojure logs

2014-04-25

00:03ddellacostakwertii: protocols explicitly do not provide implementation inheritance--this avoids a lot of the problems multi-inheritance in OO brings with it.
00:03ddellacostakwertii: If you want to use the same implementation w/protocols, define a set of functions in a hash-map and use extend-type
00:05gunskwertii: Multiple record types doesn't sound that bad on second thought; it's the same as your multiple subclasses implementing one interface.
00:06gunsusing hash-maps with extend-type like ddellacosta suggests also relieves having to write a bunch of macros
00:06ddellacostakwertii: or extends rather
00:06ddellacostawhoops, got booted, maybe missed some messages
00:06gunsddellacosta: nothing from kwertii yet
00:07ddellacosta(extends -> extend)
00:13kwertiifunctions in a hash map + extend-type.. I like it!
00:13kwertiiCould use a little syntactic sugar, but that's easy enough to make
00:16danlamannais there a naming convention for sort of internal functions? i.e. in emacs it tends to be foo--bar instead of foo-bar
00:16ddellacostadanlamanna: maybe -foo-bar? Depending on what you're doing
00:17ddellacostadanlamanna: see that in protocol defs mostly I guess
00:17gunsthat's also the default gen-class prefix
00:18technomancydanlamanna: I like to attach ^:internal metadata
00:22arrdemddellacosta: I've gotten crap before on PRs for using defn- and -\w+
00:23ddellacostaarrdem: ah okay, good to know...what were the complaints though?
00:23arrdemit's not like the clojure compiler _really_ lets you hide anyway..
00:23arrdemddellacosta: there was some other legitimate stuff.. lemme go find it
00:24gunsEverything on the JVM can be .setAccessible. It's just metadata
00:24arrdemddellacosta: https://github.com/aysylu/loom/pull/8/files#r7550133
00:25arrdemddellacosta: the other complaints are legitimate and fixed, but the fixes broke the PR and I haven't had time to rework it.
00:25ddellacostaarrdem: that just seems to be..."I don't like functions starting with -" I gotta say. Don't see much rhyme or reason to that complaint, unless the reason is that that is for protocol specifications only (convention-wise)
00:26arrdemddellacosta: I would agree with that assessment. I've seen -\w+ used in core.typed and several other libraries to denote implementation methods, often together with ^:private, but it's not like anything's really private if you don't want it to be so...
00:26arrdem(dec so)
00:26lazybot⇒ -9
00:27arrdemddellacosta: I know that tools.analyzer also uses the -\w+ convention for implementation detail multimethods with a bootstrap method matching the name body.
00:28arrdembut that's just like my opinion man...
00:28ddellacostaarrdem: yeah. I would like to see some kind of authoritative list of those kind of conventions now that we're talking about it. Maybe there is one and I don't know about it, but most of what I know I've picked up from reading others' code, and I can imagine that would be inconsistent based on whose code one is reading.
00:28arrdem$google clojure style guide
00:28lazybot[bbatsov/clojure-style-guide · GitHub] https://github.com/bbatsov/clojure-style-guide
00:28ddellacostaarrdem: that doesn't have all of this stuff, does it?
00:28arrdemddellacosta: so there's that... but it's not really maintained and it's totally unenforced. and yeah I don't even know if it covers this.
00:29ddellacosta(it is a solid guide though, agreed)
00:29ddellacostaarrdem: I think it's a good one for basic formatting, based on my recollection of the last time I read it
00:29arrdemI just scanned it and yeah it's more of a formatting/whitespace guide.
00:30arrdemthere's some other more general advice...
00:30ddellacostaarrdem: yeah, I don't see anything like this; the closest it comes to is talking about earmuffs for dynamic stuff, and denoting private functions
00:30arrdem,(doc io!)
00:30clojurebot"([& body]); If an io! block occurs in a transaction, throws an IllegalStateException, else runs body in an implicit do. If the first expression in body is a literal string, will use that as the exception message."
00:30arrdemwhat the hell... that's a thing!
00:30arrdemTIL...
00:30gunswhat's wrong with using ^:private to signal "this is an implementation function"?
00:31ddellacostaguns: yeah, I definitely do that
00:31ddellacostaguns: the main problem is that that is really (mostly) just informational
00:31arrdem nothing. just style. I don't do that because it's meaningless at runtime... but I do kinda like the -\w+ style.
00:31arrdemI for one vote that we write a clj-epic-refactor project to autoreformat and autorename every project and symbol on GitHub...
00:31gunsddellacosta: that's not a problem; JVM private fields aren't private either
00:32arrdemPRs for everyone!
00:32ddellacostait's kind of long for a convention, if you want to treat it like that, and otherwise it's kinda meaningless
00:32ddellacostaI suppose
00:32ddellacostaarrdem: that sounds terrifying...haha
00:32arrdemddellacosta: the style guide does argue... that defn- is better than defn ^:private...
00:33arrdems/ue.../ue/g
00:33gunsarrdem: ^:private isn't meaningless; it doesn't show up in (ns-publics) for one
00:33arrdemguns: fine, but I can still #' my way to whatever I want and routinely do..
00:33gunsYou can #'reference it at your risk
00:34gunsexactly. everyone's happy AFAICT
00:34ddellacostagotta go, cheers folks
00:35gunsplus, doesn't leading dash conflict with the -field notation in CLJS?
00:36kelseygiis there a way to sort of "reverse" functions?
00:36kelseygilike i'm calling .contains
00:36kelseygiand i want to have the first argument second & vice versa
00:36kelseygii know there's ->
00:37kelseygibut i'm passing it to another funciton
00:39gunskelseygi: do you mean reverse the arguments to a function?
00:39kelseygii do
00:40gunsyou could (fn [& args] (apply f (reverse args)))
00:43programmer10101is anyone there?
00:44gunseveryone, shhh..... programmer10101 is here
00:44arrdemonly bots here move along
00:44programmer10101you guys know of any good channels for java programming?
00:45arrdemJava sucks. Clojure sucks. you should go hang out in #haskell and learn a real programming language
00:45guns#jsoftware
00:46gunstry that channel
00:46jack_rabbitarrdem, here, here.
00:46programmer10101is haskell new?
00:46arrdemjust came out last week!
00:46programmer10101no need for sarcasm
00:47arrdemtouchy touchy...
00:47arrdemhttp://www.arrdem.com/i/oppinion.gif
00:48jack_rabbitIt's been around since the 80's
00:48gunsprogrammer10101: I was just kidding about #jsoftware. J is an APL descedent
00:48jack_rabbitprogrammer10101^
00:48gunsdescendant
00:49programmer10101how do you enter another chatroom?
00:49arrdemls
00:49lazybotbin boot dev etc lib lost+found media opt proc sbin selinux srv usr var
00:49gunsprogrammer10101: /join #java
00:49arrdemtests passing and we've got a troll to play with! http://www.arrdem.com/i/dance.gif
00:49gunsI think that's what you're really looking for
00:50programmer10101thank you guns
00:50gunsprogrammer10101: also /list -re regex for searching channels
01:04ppoldHi, in the Python world for running backends it is common to have a process manager like Circus or Supervisor, what is the analog of those services in Clojure?
01:07gunsppold: Are those just process watchers like monit?
01:07Jaoodppold: I guess you could keep using those if you are talking about OS processes
01:09jgmizeppold: you might check out https://github.com/puppetlabs/trapperkeeper
01:10ppoldThanks guys, yes I think monit also does those tasks, like relaunching the process if it dies, etc.
01:12gunsppold: systemd will also do it if you're using a Linux distribution
01:14ppoldIs it safe to use systemd in Ubuntu 14.04?'
01:16gunsppold: You should ask in the ubuntu channel; Canonical made their own init system, so it was never officially supported (though it will be )
01:17ppoldYep, last I know is that they are considering moving to systemd in version 14.10
01:18gunsppold: You should check out #coreos if you're interested in just systemd + your app
01:18gunsBut anyway, monit and friends work just fine
01:21ppoldI am using DigitalOcean though, I think it is possible to try CoreOS in Linode
01:32eggheadis it safe to say that defmethod is a side effect?
01:32arrdemooh yeah
01:34eggheadi was just kind of confused when a defmethod wasn't listed in ns-publics
01:34eggheadbut I guess if its just modifying the defmulti fn
01:34arrdemyep. it's just adding another dispatch fn to the defmulti
03:45Frozenlo`Is gzip included/active by default in compojure nowadays?
03:45Frozenlo`I remember having to add a middleware for it a couple years ago.
03:45ordnungswidrigFrozenlock: i would off-load this to ngnix/apache
03:46Frozenlockordnungswidrig: Ah! I didn't even think about that
03:46Frozenlockthanks
03:46ordnungswidrigyou're welcome
04:06GlenjaminHi guys, is there a lazy equivalent of (into) - or is it lazy but i'm doing something wrong?
04:07Glenjamin,(take 10 (into [] (repeat 10)))
04:07clojurebotExecution Timed Out
04:08ordnungswidrig,(take 10 (into '() (repeat 10)))
04:08clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
04:13gunsGlenjamin: concat; into is eager
04:14gunsinto is also very fast for collections implementing IEditableCollection
04:15henrikhodneHi! I'm writing a library that involves talking to an HTTP API, and the HTTP requests can sometimes "fail" (as in return 500 errors). What is the idiomatic Clojure way to handle such errors in a way that they are able to be logged by either the library or the library consumer (ie. I can't just return 'nil' or something like that)?
04:15ordnungswidrighenrikhodne: exceptions are not bad.
04:16Glenjaminpossibly via (ex-info)
04:16Glenjaminguns: ok - thanks
04:16ssiderishenrikhodne: ex-info will allow you to attach clojure data to your exception to make it more useful
04:18henrikhodneAh, thanks.
04:25frankie_Hey guys
04:25frankie_I stumbled on a behavior that I can't fully understand
04:25frankie_Wonder if anyone can give me some pointers
04:26frankie_(apply str "a" ["b" "c"])
04:26frankie_Gives "abc"
04:26frankie_If I do
04:26frankie_(def s [["b" "c"] ["a" "c"] ["a" "b"]])
04:26frankie_(map #(apply str % s) "abc")
04:27frankie_I would expect "abc" "bac" "cab"
04:27frankie_instead I get ("a[\"b\" \"c\"][\"a\" \"c\"][\"a\" \"b\"]" "b[\"b\" \"c\"][\"a\" \"c\"][\"a\" \"b\"]" "c[\"b\" \"c\"][\"a\" \"c\"][\"a\" \"b\"]")
04:27Glenjaminfrankie_: sounds like you want zip
04:27ordnungswidrigstrings are sequences
04:28ordnungswidrig,(apply str "abc")
04:28clojurebot"abc"
04:28Glenjaminwait, no - zip in clojure is just mutli-arity map
04:28Glenjamin,(map #(apply str %1 %2) "abc" [["b" "c"] ["a" "c"] ["a" "b"]])
04:28clojurebot("abc" "bac" "cab")
04:29frankie_Oh I see
04:29frankie_That's quite cool :)
04:30frankie_Thanks Glenjamin
04:30Glenjaminno probs
04:31GlenjaminThe reason I wanted a lazy (into) is for creating a large hash-map - is this possible (or even something that makes sense?)
04:32Glenjaminhrm, no
04:32Glenjaminit doesn't make sense
04:47clgvGlenjamin: there are no lazy hashmaps in clojure.core
04:47Glenjamini realised that if it's actually lazy you couldn't do the O(1) lookup without realizing it
04:47Glenjaminand i didn't actually need a hashmap until later in the program flow
04:58mr-foobardoes clojurescript have the concept of classpaths ? how does it resolve :use and :require ?
05:07Glenjaminis there a neater way to acheive this? it seems more convoluted than it should be: https://www.refheap.com/80240
05:09noidiGlenjamin, http://clojuredocs.org/clojure_core/1.2.0/clojure.core/group-by
05:10Glenjaminbingo
05:10Glenjaminthanks!
05:10Glenjaminoh wait
05:10Glenjaminthat gives me a vector for each key
05:11noidi,(group-by :id [{:id 1 :a "a"}, {:id 2 :a "b"}, {:id 3 :a "c"}])
05:11clojurebot{1 [{:id 1, :a "a"}], 2 [{:id 2, :a "b"}], 3 [{:id 3, :a "c"}]}
05:12noidiah, right
05:12noidithat's because the seq may contain several values with the same key
05:13Glenjaminmm
05:15Glenjaminthe implementation looks be reduce and transients
05:15Glenjaminso i guess i could do that
05:16BronsaGlenjamin: (zipmap (map :id maps) maps)
05:17Glenjaminat the risk of overthinking it, wouldn't that iterate twice?
05:18clgvGlenjamin: what exactly is your problem with group-by?
05:19Glenjaminclgv: it gives me a different data-structure to the one i want
05:19Glenjamini'm selecting rows from a DB then putting into a hash-map by primary key
05:19clgvGlenjamin: you have no duplicate value for the grouping attribute and thus want no vector?
05:19Glenjamincorrect
05:19BronsaGlenjamin: if that's a performance bottleneck to you sure, use (reduce (fn [m m1] (assoc m (:id m1) m1)) {} maps) i guess
05:20clgvGlenjamin: yeah just make sure it's really a bottleneck. otherwise you'll waste time ;)
05:20Glenjamin~600k rows
05:20clojurebotCool story bro.
05:20Glenjaminseems like (into {} (map #(vector (key %) %) coll)) isn't too bad after all
05:21Glenjaminreduce is probably clearer
05:21clgvGlenjamin: well than you can use the equivalent reduce with transients...
05:21Glenjaminmm, going to crib the implementation from group-by and remove the vector bit
05:27Glenjaminyeah, that feels neater - thanks guys https://www.refheap.com/80240
05:42pyrtsaGlenjamin: While zipmap technically iterates over two sequences (i.e. twice), in practice it won't evaluate either more than roughly one cache line at a time (because of laziness), so you shouldn't be worrying about that.
05:44pyrtsaIMO, (zipmap (map :id maps) maps) reads much much better than keyed-by in https://www.refheap.com/80240
05:45Glenjaminpyrtsa: ah, i see
05:45Glenjaminthat makes sense
05:45Glenjamini think
05:46pyrtsaThat said, I think keyed-by is a neat function. But you could just implement it with zipmap.
05:46Glenjaminright
05:47Glenjaminis there a transient zipmap?
05:47pyrtsaHa, was just about to point out that zipmap doesn't use transients.
05:47Glenjamini shall have a play about, gives me an excuse to try out criterium
05:47Bronsahttp://dev.clojure.org/jira/browse/CLJ-1005
05:49pyrtsaGlenjamin: You could write just (defn keyed-by [k xs] (into {} (for [x xs] [(k x) x])))
05:49pyrtsaOr (into {} (map (juxt k identity) xs))
05:51Glenjamincool, will give them a spin and see if there's much in it
06:16oskarthWhen using my own library with schema defns from another project, I get a "no such var s/defn <line-in-library-code>" error. Why is that? I don't want to (have to) use schemas in the other project.
06:21Glenjaminhere's my results if anyone is interested https://www.refheap.com/80269
06:26oskarthSeems like it's because I have AOT compilation enable. Using schema.macros (sm/defn) instead of schema.core for defns seems to solve it.
06:29clgvoskarth: sounds like some macro expands to a symbol with a namespace alias whose namespace is not required (or equally aliased) in the usage context of the macro
06:29oskarthyeah
06:30clgvoskarth: could be an error in the macro similar to 's/mysym versus `s/mysym
06:30oskarthI'm not sure what the right solution is though, seems a bit fragile to have that collision
06:30clgvthe altter is correct
06:30oskarthoh
06:30oskarthyou mean in the schema source?
06:31clgvyeah maybe, if the guilty macro is from there
06:32oskarthhttps://github.com/Prismatic/schema/blob/ea6eea2392685ec6afe58046c7691c6397858e57/src/clj/schema/macros.clj#L453-L527
06:33clgvoskarth: thats the macro that causes the exception?
06:33oskarthThat's the schema macro which works though, so it's the wrong one, sec
06:33oskarththe other one was schema.core/defn, but I can't find it in the source code
06:34clgvoskarth: well I guess you used regular clojure.core/defn and added type information starting with "s/"?
06:34oskarthclgv: in the library it's s/... and in the other project it's regular defn, yes
06:35Bronsaoskarth: it's imported via potemkin https://github.com/Prismatic/schema/blob/ea6eea2392685ec6afe58046c7691c6397858e57/src/cljx/schema/core.cljx#L905
06:35Bronsait might be that potemkin doesn't work with AOT
06:35oskarthBronsa: oh, there it is
06:36clgvpotemkin? is that a tool to make codebases harder to read?
06:36oskarthhaha
06:36oskarth"Potemkin is a collection of facades and workarounds for things that are more difficult than they should be. All functions are within the potemkin namespace."
06:37oskarththis feels like a rabbit hole. The workaround is pretty straightforward though, as long as the ugliness is somewhere else ;)
06:37clgvoskarth: from the current short experience I got some doubts about that quote ;)
06:38Glenjaminpotemkin is the one that's designed to let you expose a friendly public namespace, but remain free to arrange vars across namespaces internally however you want iirc
06:38clgvah seems that the feature expression stuff is the complicating part and not potemkin ;)
06:39Bronsaclgv: that's cljx
06:40clgv(potemkin.namespaces/import-vars potemkin.namespaces/import-vars) ;; totally meta
06:40clgv:D^^
06:42clgvfrom a quick scan it does not seem as if import-vars might have problems with aot
06:45oskarthclgv: there's this issue @schema: https://github.com/Prismatic/schema/issues/21
06:46oskarthseems to be several in one though
06:56akazlouhi, from proxy documentation: ...Method fns are closures and can capture the environment in which proxy is called. Each method fn takes an additional implicit first arg, which is bound to this. ...
06:56akazlouwhat does it mean "capture the environment" and how I can access this implicit argument?
06:57nightflyI think the "which is bound to this" literally means the name "this"
06:58nightflyAnd captures the environment means that any variables that were visible within the scope where you define the proxy function will be available inside of it too.
07:01clgvakazlou: yeah "this" is implicitely defined in contrast to protocols/defrecord/deftypes
07:59akazlouok, need to experiment with it in that case, thanks
08:08akazlouactually the question was raised because of http://www.4clojure.com/problem/113, how anyone can determine the "scope" of the return value, either string or list from the function itself, is it possible? and if, it sounds like very bad practice to return the data base on the caller's expectation
08:08agarmanthe exclusion is a pretty good hint
08:09agarmanyou can't use proxy, but are there other functions that make a type
08:09akazlou:) ok, I understood it the opposite way, the must to use "proxy"
08:09akazlouthank you for clarifying this
08:10akazlouno spoiler on the function name, will try to find it myself
08:10agarmanenjoy
08:48petronHow are you peeps deploying your Clojure applications to the web?
08:49petronElastic Beanstalk recently started to support Docker, so that seems like a potential avenue.
08:50asalehpetron, right now I used openshift ... https://www.openshift.com/blogs/how-to-host-your-clojure-app-on-openshift
08:52asalehpetron, but 1) I wouldn't use it for production quality stuff 2) I work at RedHat, what means, that If stuff doesn't work I get to complain to developers over a coffe :)
08:56rebcabinis user/clojuredocs now deprecated from lein/repl?
09:43rebcabin,(defrecord x [y])
09:43clojurebotsandbox.x
09:43rebcabin,(x. 42)
09:43clojurebot#sandbox.x{:y 42}
09:43rebcabin,(->x 42)
09:43clojurebot#sandbox.x{:y 42}
09:43rebcabinWhat is the difference between the (x. 42) and (->x 42) for defrecord constructors?
09:45hyPiRion,(doc ->x)
09:45clojurebot"([y]); Positional factory function for class sandbox.x."
09:47clgvrebcabin: "->x" is a function and can be used as such which you can't with "x.", e.g. passed to map (map ->x (range 10))
09:47clgv,(map ->x (range 10))
09:47clojurebot(#sandbox.x{:y 0} #sandbox.x{:y 1} #sandbox.x{:y 2} #sandbox.x{:y 3} #sandbox.x{:y 4} ...)
09:47rebcabinty :)
09:48rebcabin(,doc x.)
09:48rebcabin,(doc x.)
09:48clojurebotIt's greek to me.
09:48rebcabin:)
09:48clgvunluckily primitive type hints are not passed to the function definition...
09:48clgv,(doc new)
09:48clojurebotTitim gan éirí ort.
09:48clgv$(doc new)
09:49clgv&(doc new)
09:49lazybot⇒ "Special: new; The args, if any, are evaluated from left to right, and\n passed to the constructor of the class named by Classname. The\n constructed object is returned."
09:49clgv,(read-string "(x. 1)")
09:49clojurebot(x. 1)
09:49turbopapewhich one is better guys : (reduce conj {} (seqing a map ) or into {} (seqing a map ) ?
09:49clgv,(macroexpand '(x. 1))
09:49clojurebot(new x 1)
09:49clgvah right ^^
09:50wagjoturbopape: into
09:50clgvturbopape: if you do not want to modify the items "into" is more concise
09:50turbopapeok, but I am modifying the elements. If you say better, it's only for conciseness sake ?
09:50wagjointo is faster, sometimes
09:51clgvturbopape: "into" is even more efficient in terms of runtime for datatypes supporting transients
09:51turbopapeok, thank yo guys !
09:54rebcabin,(clojuredocs defrecord)
09:54clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: clojuredocs in this context, compiling:(NO_SOURCE_PATH:0:0)>
09:54rebcabin,(doc defrecord)
09:54clojurebot"([name [& fields] & opts+specs]); (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the current namespace, the given f...
09:59clgv$clojuredocs defrecord
09:59lazybotclojure.core/defrecord: http://clojuredocs.org/v/5457 clojure.core/*verbose-defrecords*: http://clojuredocs.org/v/5313 clojure.core/defrecord: http://clojuredocs.org/v/1647
09:59clgvthere you go ;)
10:00rebcabin@clgv ty :)
10:00clgvthere are some gems hidden in lazybot ;)
10:00rebcabinnod — i shall have to study it. "clojuredocs" seems gone from leiningen
10:01myguidingstarhi all, we use "java -Duser.language=..." to change an app's default locale. Is it possible to binding a locale to just an expression body? Something like (binding [*locale* "en_US"] (my-body))
10:02mdrogalismyguidingstar: You can, but dynamic bindings are to be avoided when possible.
10:03myguidingstarmdrogalis, I know it
10:04myguidingstarcan you help me with that?
10:06mdrogalismyguidingstar: Have you considered other options first?
10:07myguidingstardo you suggest any other options? I can't think of any
10:08mdrogalismyguidingstar: What exactly are you trying to accomplish? Why does the value need to change temporarily?
10:10myguidingstarmdrogalis, I want my web app to allow users to set their locale
10:10myguidingstarmy webapp use sevaral java libraries
10:11myguidingstarand it takes too much time to config each of those libs
10:11myguidingstaror even impossible for my reject-java-brain ^^
10:12mdrogalismyguidingstar: Can you try parameterizing your calls to those libs?
10:12mdrogalisMaybe a little functional layer over them.
10:13myguidingstarmdrogalis, it'll be a lot of painful work, I guest
10:14mdrogalismyguidingstar: I've used binding a few times in my Clojure life. Never once been happy with the outcome.
10:15myguidingstarmdrogalis, I'll take the risk. I won't use any more dynamic bindings, I promise ;>
10:16mdrogalismyguidingstar: ;)
10:29gtuckerkellogganyone having trouble with cider v0.6.0?
10:36mdrogalis,(let [x 42] (quote ~x))
10:36clojurebot(clojure.core/unquote x)
10:36mdrogalisTrying to get that to eval to "42". Any help?
10:36mdrogalisRiemann's requiring me to quote a form.
10:38mdrogalisNevermind -- got it.
10:53szymanowskihello, in clojurescript, is there a way to "import" all vars of a ns to another? like with (ns myns (:use other-ns)) in clojure
10:56jonasenszymanowski: no, I don't think there is a way to do that
10:56szymanowskiok thank you
11:13stompyjwhats the next big clojure conference?
11:14stompyjclojure “east"?
11:14stompyjand strangeloop just opened for RFP’s right?
11:17jonasenstompyj: euroclojure?
11:20stompyjjonasen: thanks!
11:38camdenx#join rvm
12:32mzarellaAfter putting me.raynes/fs "1.4.4" into the :dependencies in my project, how do I make sure lein actually installs the dependency?
12:32mzarellaAnd then How would i actually use something like the cwd function? https://raynes.github.io/fs/me.raynes.fs.html#var-*cwd*
12:32alejandromzarella: most lein tasks will install it for you
12:32alejandroe.g. lein deps or lein repl
12:34oskarthWhen using nrepl in emacs, I often find myself wanting to evaluate a sub-expression that uses a variable "out of scope" (i.e. it's in a let block above) - any tips for dealing with that instead of rewriting my whole expression?
12:34mzarellaIs there a tutorial which explains how to use modules?
12:34oskarthmzarella: what do you mean by modules?
12:35mzarellacommunity contributed libraries
12:35alejandromzarella: it's really just namespaces that you bring in from the outside. But using them is just like using your own namespace
12:35alejandrofor a good namespace intro/refresher, i'm a fan of http://www.braveclojure.com/organization/
12:35oskarthusually all you have to do is to add the latest version in :dependencies at project.clj (this can be found at either clojars.org or the github page)
12:36oskarthwhat alejandro said
12:36AWizzArdAbout cider-nrepl: adding this as a :plugin to my :user profile is enough, right? I won’t need to add :nrepl-middleware to my :repl-options, yes?
12:37dbaschoskarth: in the repl, just use def
12:38dbaschoskarth: and *1, *2, etc
12:38oskarthdbasch: thats what I do now, I prefer to evaluate it in my code window though
12:39oskarthjumping around and ctrl-c spamming different expressions
12:39dbaschoskarth: if you need the variable outside of a scope, then increase the scope :)
12:39oskarthyeah sure, I guess what I was looking for what a nnrepl shortcut to use the closest let for scope, since it's kind of a common situation
12:40rasmustoC-x C-e hurts my delicate fingers
12:40oskarthwhat's cpab?
12:41rasmustoit's 'cp' as an eval prefix in vim-fireplace, then ab for the current sexpr
12:41rasmusto'ab' is just a vim text motion
12:47justin_smithrasmusto: there is such a world of language outside vim! while it is true that no clojure.core defs start with ab, imagine where we would be without Math/abs, absolution, the alphabet, or Abba
12:47rasmustojustin_smith: fabulous!
12:49seangroveIf a message is good enough to send once to the ml, it's good enough to send 3x
12:53AimHereWhatever I tell you three times is true
12:54akielhi
12:54akielis there a build-in function doing this: (defn to-seq [xorxs]
12:54akiel (if (sequential? xorxs)
12:54akiel xorxs
12:54akiel (list xorxs)))
12:55Bronsaakiel: there's `sequence` that calls seq? rather than sequential?
12:55akielbut (sequence 1) returns an error
12:56devnim trying to hook up pulsar to play with it in the emacs cider repl. the README says to add the PATH to my quasar.jar to my jvm-opts. I've done so: "-javaagent:/Users/devn/.m2/repository/co/paralleluniverse/quasar-core/0.5.0/quasar-core-0.5.0.jar"
12:56devnWhen I try to create a fiber it's still complaining that there's no instrumentation though
12:56devnAnyone know what might be going on?
12:57akielBronsa: sequence calls seq if the args is no seq?
12:58justin_smith$source sequence
12:58lazybotsequence is http://is.gd/5eF6sb
12:58justin_smithakiel: see there ^
12:58akieljustin_smith: thanks I was already on github
12:59justin_smithoh, you don't want that, based on the scroll up you want your original (but that is only a proximate fix - a problem like that looks like a rough edge in a design to me)
13:00justin_smithI can't know for sure, of course, but my hunch is if you need to force 1 to be '(1) either the producer or consumer of the data has issues
13:02cbpAnyway i mostly linked to that atwood post because of this https://medium.com/tech-culture-briefs/a1e93d985af0
13:02cbper
13:02cbpwrong channel
13:02cbpsorry
13:06justin_smithcbp: good link anyway
13:07justin_smith(inc cbp)
13:07lazybot⇒ 3
13:12coventryHow hard is it to get at the raw nodes in the trees making up clojure's persistent data structures? Are they clojure structures too? Also, is there a good explanation of the clojure persistent hashmap data structure?
13:13coventrys/persistent data structures/persistent vectors/
13:13jcromartiecoventry: they are not also clojure data structures...
13:13jcromartiebut you can examine the Java source code
13:13justin_smithcoventry: you could probably get at the internals via interop
13:14jcromartieI can't imagine you can bootstrap persistent data structures with themselves… you need some primitives in the host platform
13:14agarmanhttp://hypirion.com/musings/understanding-persistent-vector-pt-1
13:14BobSchackhttp://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation
13:14agarmanhttp://en.wikipedia.org/wiki/Hash_array_mapped_trie
13:14coventryjcromartie: Yeah, definitely they can't be clojure all the way down. :-)
13:15justin_smith,(do (require '[clojure.reflect :as refl]) (refl/reflect [])) ; coventry
13:15clojurebot{:bases #{clojure.lang.APersistentVector clojure.lang.IObj clojure.lang.IEditableCollection}, :flags #{:public}, :members #{#clojure.reflect.Method{:name empty, :return-type clojure.lang.IPersistentCollection, :declaring-class clojure.lang.PersistentVector, :parameter-types [], :exception-types [], ...} #clojure.reflect.Method{:name iterator, :return-type java.util.Iterator, :declaring-class cloju...
13:16justin_smiththough reading source and reasoning from that may be easier
13:16ztellmancoventry jcromartie: simple persistent objects can model most, if not all, of clojure's persistent data structures
13:16ztellmannot the transient versions, obviously
13:17ztellmanjust a bunch of final fields on an object, in Java-land
13:17coventryThanks, everyone. I'm developing a serializer which uses structural sharing to compress its output. I was going to do it by just walking the input structure and looking for (identical?) components, but then I realized that would be missing a lot of opportunities.
13:18ztellmanconventry: naive serialization and compression are a reasonable proxy for that
13:18ztellmanstill pay the cost on deserialization, though
13:28devnbah. bah! i cannot get pulsar to work.
13:30coventryztellman: Thanks. Are there any compression tools which let you give hints about where you expect the repetition to be? I'm expecting repetition periods of about 1M, which gzip is not going to catch.
13:30jcromartieyou can set the block size
13:30jcromartieright?
13:30BobSchackcoventry why not use fressian if you're handling clojure datastructures?
13:31coventryBobSchack: Does it have a representation of structural sharing?
13:34coventry`Maybe its STRUCT opcode can be used that way.
13:35BobSchackI believe it has something similar, domain aware caching. You can tell the encoder the fields to be cached (https://github.com/clojure/data.fressian/blob/45b413805f746de94803f72c3bbe78d939a72a3f/src/main/clojure/clojure/data/fressian.clj#L125)
13:35coventry`Thanks, BobSchack.
13:36BobSchackI've been writing an implementation in ClojureScript and from the delve through the source it should be able to do structural sharing
13:36BobSchackNP
13:37coventry`Oh, that's great, it's actually the ClojureScript side I'm most interested in. Is your implementation public?
13:37BobSchackhttps://github.com/devn/longshi
13:38coventry`Terrific, this looks really handy.
13:38BobSchackI've only gotten the basic types working so far (strings, ints, etc). I working on the readme right now
13:39BobSchackIt's my first non toy clojure project so if you see improvements let me know
13:42mdeboardCan someone tell me what I'm doing wrong here with defprotocol/defrecord? The code & traceback are in this gist: https://gist.github.com/mattdeboard/5041ce78a99064546c83
13:43mdeboardI thought you didn't define implementations in a protocol, and can use them in a record to define how to implement
13:43llasrammdeboard: In-line protocol implementations are implemented via JVM interfaces, in which case all bare method names must be distinct
13:43llasramRecords already implement various Map interfaces, one of which already defines `get`
13:43mdeboardAhso
13:44llasramYou can work around this by using `extend`(`-type`/`-protocol`) to externally extend your record type to your protocol
13:45mdeboardNo that's fine, I tihnk I'd rather not stomp on the built in
13:45bbloommdeboard: yeah, you can simply use extend-protocol instead of defining the method inline... protocols respect namespaces, unlike java method names
13:45bbloommdeboard: you wouldn't be stomping the builtin
13:46bbloommdeboard: your fn is technically named courses.models.course/get
13:46mdeboardYeahI noticed that when using it in the repl
13:46mdeboardit threw off a warning about stomping clojure.core/get
13:46bbloommdeboard: however, i suggest that you *stop making records and protocols* for this use case
13:46mdeboardMmkay
13:46mdeboardWhy so
13:46bbloomjust use a normal map
13:47bbloomdefrecord is for when you need a unique named type
13:47bbloomunless you plan to do polymorphic dispatch by type, there's not much benefit to creating one
13:48mdeboardbbloom: Well, I was looking at the comparison here https://github.com/Prismatic/eng-practices/blob/master/clojure/20130926-data-representation.md
13:48mdeboardand how hash maps require up to 10x the contents of the map
13:48mdeboardI'm almost certainly thinking too OO
13:49bbloommdeboard: 10X contents for a small value is meaningless unless you have a large number of those small values
13:49bbloommdeboard: premature optimization for sure
13:49bbloommdeboard: you're *definitely* thinking too OO
13:49mdeboardSure, I understand that, but this isn't a greenfield project I'm working on
13:50mdeboardInstead reimplementing certain parts of a production API in Clj
13:50bbloommdeboard: do you have existing java code that needs you to implement specific interfaces?
13:50bbloomi'd suggest a simple (defn get-course [conn course-id] ...) function
13:51mdeboardYeah, you're right. idk what I was thinking
13:51mdeboardalways takes time to change midnset
13:51mdeboardmindset*
13:52bbloomabsolutely, learning clojure is mostly about unlearning bad habits forced on you buy crummier languages
13:52gvickersTruth^
13:52mdeboardI've written a nontrivial amount of Clojure, but there's always long periods of Python-writing between :P
13:52eggheadlol mdeboard
13:52justin_smithmdeboard: each language has its vices. OO: I know, we can fix it with more classes! LISP: I know, we can fix it with more layers of macros! etc. etc.
13:52rasmustopython_writing()
13:53justin_smithPHP: oh I know, we can fix it by randomizing our function naming conventions and argument order
13:53bbloomjustin_smith: and in OO languages the true answer is usually less classes and in lisps the answer is virtually no macros :-P
13:53coventry`Last time I wrote a serious amount of python code, I did it in clojure style. It was fun, and the inefficiency didn't matter in that case.
13:53justin_smithbbloom: I know, I had hoped to be making that point (somewhat sarcastically)
13:54justin_smithcoventry`: I plan to be doing that soon, may hit you up for pointers
13:54ambrosebs,(name :abc)
13:54clojurebot"abc"
13:55mdeboardcoventry`: Exactly. I write functional python
13:55technomancycoventry`: "how horrified can you make a python programmer" sounds like a fun game
13:55mdrogalisbbloom: "learning clojure is mostly about unlearning bad habits" Can I quote you? I like that.
13:56mdeboardlearning clojure is mostly about bookmarking docs because googling problems usually only yields 3-year-old how-tos :P
13:56coventry`justin_smith: Have you persuaded people to let you use python instead of java? That's a small victory I imagine.
13:56bbloommdrogalis: sure, but only if you keep the "forced on you by crummier languages" part ;-)
13:56mdrogalisbbloom: You.. You want me to get beat up on Twitter. ;[
13:57bbloommdrogalis: take your beating like a man
13:57justin_smithcoventry`: the backend is highly dictated by clients, some want java, some allow clojure (yay), some prefer python, others php (omgwtf)
13:58llasrammdrogalis takes his beating like a duck
13:59mdrogalisllasram: :)
14:18gfredericksI think it'd be cool to combine the strint macro to make an ex-info macro that lets you reference keys from the data map inside the msg string
14:30mdeboardHm, is there any particular reason why Emacs would hang (using cider + cider-nrepl) when editing a clojure buffer? It's like it's trying to do something in the background; I mash C-g enough and it returns control to me.
14:31gfredericksit might be pinging the server for arglists and stuff
14:31gfredericksnot sure why that would hang it
14:31mdeboardwhat server?
14:31gfredericksthe nrepl server
14:32gfredericksis your nrepl server on a distant planet?
14:32arrdemgfredericks: rover on mars, why do you ask?
14:32arrdemgfredericks: made with alien technology :D
14:32jcromartiearrdem: seriously?
14:32gfredericksarrdem: irrc mars is a laggy connection
14:32gfredericksiirc*
14:32Frozenlo`mdeboard: I had a similar experience with Cider... I decided to go back to nrepl.el
14:33mdeboardFrozenlo`: Well, damn.
14:33arrdemjcromartie: oh for real?
14:33technomancyjcromartie: JPL?
14:33Frozenlo`Good ol' nrepl, works perfectly well :-p
14:33arrdemjcromartie: I've got a chance to write C++/Rust at UT's satellite lab and was kinda laughing about being able to run Clojure on a nanosat
14:33mdeboardhttps://github.com/clojure-emacs/cider-nrepl/issues/37 probably
14:33ystaelmdeboard: Try disabling autocomplation?
14:34ystael*autocompletion
14:34technomancyI once emailed Ron Garrett to try to get his CL HTTP server working in clisp.
14:34technomancyI don't remember if that was after he left the JPL or not
14:34arrdemgfredericks: if you can deal with a few minutes of lag and potentially screwing a multi million dollar rover, sure!
14:34mdeboardystael: Not sure how to in cider, do you know off the top of your head?
14:34technomancyhttp://www.flownet.com/gat/jpl-lisp.html
14:34stuartsierramdeboard: Maybe autocomplete
14:35justin_smithmdeboard: M-x (global-autocomplete-mode) will toggle it
14:35mdeboardI toggled auto-complete-mode, still hung
14:35ystaelmdeboard: as I fuzzily recall, I removed the ac-nrepl and clojure-complete packages. this was a while ago though, i definitely do not have recent builds
14:36coventry`mdeboard: M-x toggle-debug-on-quit <RET>, then mash C-g next time it happens. Should give you a backtrace which may tell you what's causing it.
14:36mdeboardcoventry`: nice, it did
14:37mdeboardWhat it means, idk https://gist.github.com/mattdeboard/89e9ed61a091b8bbddfa
14:37coventry`Try turning off eldoc.
14:38mdeboardGiving that a whirl
14:38mdeboardSeems to be aok
14:39coventry`No idea how to get at what's happening on the server to figure out why that's slow, though. I guess you could try running jstack while emacs is hung.
14:39technomancy"Also in 1993 I used MCL to help generate a code patch for the Gallileo magnetometer. The magnetometer had an RCA1802 processor, 2k each of RAM and ROM, and was programmed in Forth using a development system that ran on a long-since-decommissioned Apple II. The instrument had developed a bad memory byte right in the middle of the code. The code needed to be patched to not use this bad byte."
14:40technomancy"The magnetometer team had originally estimated that resurrecting the development environment and generating the code patch would take so long that they were not even going to attempt it. Using Lisp I wrote from scratch a Forth development environment for the instrument (including a simulator for the hardware) and used it to generate the patch. The whole project took just under 3 months of part-time work."
14:40technomancydang
14:40mdeboardcoventry`: I just added that gist to the issue on github
14:40justin_smithtechnomancy: alien tech at its best
14:41mdeboardwow.
14:42arrdemjcromartie: you can't just say that to a room full of nerds and fade into the shadows. WE DEMAND DETAILS.
14:42technomancyheh, "My best hope at this point is that the dotcom crash will do to Java what AI winter did to Lisp, and we may eventually emerge from "dotcom winter" into a saner world. But I wouldn't bet on it."
14:42justin_smithnice
14:43coventry`At least we got an AI spring.
14:43Frozenlocktechnomancy: we have JS now. hurray.
14:43technomancyFrozenlock: so what we need is a "web winter" I guess
14:44arrdemhttp://arrdem.com/i/alien.png
14:44arrdemtechnomancy: or clojurescript...
14:45FrozenlockNew top domain names ----> new world war ----> web winter
14:45Frozenlock'logic' :-p
14:45arrdemhave you seen the things you can get for a TLD these days? :P
14:45justin_smithtechnomancy: I think the problem is that the partial gains of AI never made the CEO chuckle at the antics of a fluffy animal or supplied him with pornographic material. So they never saw the baby that was being thrown out with the bath water when AI was defunded.
14:45turbofaildidn't ron garret have some followup article about how he met people at google who kicked his ass in productivity using whatever language?
14:45Frozenlockarrdem: I have. I also have very mixed feelings about it.
14:45coventry`I was hanging out on #javascript recently. People there seemed quite certain that no one's going to be manually programming javascript for much longer.
14:46arrdemFrozenlock: I'll just wait for DNS to be found fatally flawed so we can get on with namecoin adoption
14:46mdeboardcoventry`: Oh good, so we'll have machine-generated javascript built by generators built by humans who love javascript
14:46mdeboardWhat could possibly go wrong
14:46mdeboardabstraction porn
14:47arrdem(inc mdeboard) ;; why do you think I like compilers..
14:47lazybot⇒ 5
14:47llasramYou know, just like how know one writes anything in assembly, for any reason
14:47llasrams,know,no,
14:47coventry`I don't think the people who wrote clojurescript and elm are particularly in love with javascript. :-)
14:47Frozenlockarrdem: I'd like that. (I think)
14:48aditya-atechnomancy: the jpl-lisp article is so cool... among my permanent lisp bookmarks :)
14:48arrdemFrozenlock: it's all fun and games until you have to debug the emitter..
14:49llasramArgh. Did that that GSoC proposal to do persistent probabilistic data structures for Clojure get accepted?
14:49llasramTrying to very hard to avoid shaving too many yaks right now, but these Java HyperLogLog implementations are making it hard
14:49arrdemllasram: not that I know of.
14:49llasramBah
14:50llasramAnd humbug to boot
14:50arrdemllasram: Bronsa and I got in... another Sweedish guy got accepted to do a variant of my project.. there's a guy on Light Table, and there's one more I think.
14:53llasramarrdem: Well, congrats to you and Bronsa at least :-)
14:53ystaelmdeboard: don't worry, idris will fix all our javascript problems :)
14:53arrdemllasram: is there a paper you can shoot me? I'm curious what you mean by probabalistic datastructures.
14:54coventry`arrdem: persistent probabilistic
14:54coventry` data structures
14:54coventry`Oops.
14:54llasramarrdem: the (rejected?) GSoC proposal has pretty much all of the links you'd want: http://www.google-melange.com/gsoc/proposal/public/google/gsoc2014/matteo_ceccarello/5778586438991872
14:55coventry`I meant to send that, but cutting-and-pasting is broken in this emacs.
14:55llasramBasic idea is you have a data structure which lets you trade something (usually space) for certainty. Bloom filters are probably the most famous
14:56llasramAnd of course all the existing Java implementations are mutable to the max, and mark their backing data as `private` so you can't sanely serialize them
14:57coventry`I can see why it wasn't accepted. The proposal doesn't cohere around an interesting problem.
14:57llasramcoventry`: That's fair. I was just saw the original post and thought "man, I could really use those" :-0
14:58llasramInstead -- I either get mutability or yak-shaving, and ATM am sadly going for mutability
15:03pjstadigllasram: don't you know should should always err on the side of yak-shaving?
15:07llasrampjstadig: What if I know / tell myself that I'm really just putting the yak-shaving off until later? Do I get them back?
15:08llasramIn a sense I'm both yak-shaving *and* procrastinating
15:14mdeboardQuestion about clojure.java.jdb.c If I'm using insert! with multiple records, I have to use apply, e.g. `(apply sql/insert! db :table records)` ... does this mean that a query is being made per insert?
15:15justin_smithmdeboard: best way to answer that is check the source
15:15mdeboardjustin_smith: Yeah I've got it open but it's kind of bonkers.
15:15pjstadigllasram: i've spoken to the council and you are temporarily reinstated for a probationary period. if you meet your yak shaving quota, you'll have no problem getting fully reinstated.
15:15justin_smithweird, my version of jdbc doesn't even seem to have insert!
15:16mdeboardBased on the fact there's this line, I assume it's a single query per: `(map (fn [row] (insert-single-row-sql table row entities)) rows)`
15:16mdeboardNevermind
15:16justin_smithmdeboard: not neccessarily - where is the transaction bound?
15:16justin_smithor the connection even
15:17mdeboardI see here
15:17justin_smithmdeboard: another approach could be to turn on verbose logging on the sql server side
15:18justin_smithmay or may not be easier
15:18mdeboardeven better.
15:19justin_smith?
15:19harovalihi! , I'm really impressed at clojure, I'd like to embrace it. My first newbie question; why it hasn't the + fuction to be escaped in an expression like this: (reduce + [ 1 2 3 4] ) ?
15:20agarman+ is a symbol
15:20agarmanso it's escaped already
15:20agarmanwhen you put it at the head of a list
15:20Anderkentor rather, + 'the symbol' evaluates to + 'the fucction
15:20Anderkent,+
15:20clojurebot#<core$_PLUS_ clojure.core$_PLUS_@1775cce>
15:20harovaliagarman: aha!, not like in CL that you have to type #'+ IIRC ?
15:20Anderkentand then that function is applied in reduce
15:20agarmanlike (+ 1 2 3) it is looked up like a function
15:20agarmanand evaled as a function
15:21harovalisure, but there it's clearer since it's in first form position
15:21Anderkenteh, i don't think that's the right explanation
15:21llasramharovali: Yeah, Clojure is a "Lisp-1", with only one way of resolving symbols to things
15:21harovalillasram: aha! like elisp , say ?
15:21llasramYep, or Scheme, at least in that regard
15:21mdeboardjustin_smith: even better wrt tailing the pg log
15:21harovalillasram: thanks
15:21justin_smithharovali: clojure is a lisp-1, which means that functions and variables are in one "namespace"
15:22justin_smithmdeboard: ahh, cool, so it was in one query?
15:22harovalijustin_smith: thanks too
15:22justin_smithnp
15:23justin_smithllasram: well, we have multiple ways of looking symbols up (local vs. ns bi ndings etc.) but they are the same for functions and not-functions
15:23johnjelinekhihi all, how's it goin'?
15:23llasramjustin_smith: Yeah -- I just was groping around for a way to avoid saying that Clojure "only has one namespace"
15:23llasramSince it, you know, has an arbitrary number of first-class namespaces :-)
15:23harovalia rather obnoxious question, aren't people worried at tha oracle's policies regarding jvm , when embracing clojure (or when designing it in the first place, although possible it started befor oracle's buy of java IIRC)
15:24agarmanI use clojure because I have to work on the JVM
15:24justin_smithllasram: in retrospect, maybe "functions and non functions are looked up in the same way" would be more clear
15:25agarmanif I weren't restricted to the JVM, I'd consider Clojure, but along with Ocaml, F# or elixir
15:25harovaliagarman: thanks
15:25johnjelinekis it better to add data to an atom like a collection of records (ie: '({:resource "data" :val 1} {:resource "data" :val 2})) or like a collection of documents (ie: '({:resource "data" :vals '[1 2]})?
15:25justin_smithharovali: clojure has versions (of various maturity) on various target languages / platforms. I trust that if Oracle got onerous to clojure clojure would move on.
15:25johnjelinekwhich is more idiomatic?
15:25harovalijustin_smith: thanks
15:25bbloomjohnjelinek: niether
15:26johnjelinekbbloom: what do you suggest?
15:26bbloomjohnjelinek: also you don't need that ' on your vector, numbers are self evaluating
15:26johnjelineknoted
15:26bbloomjohnjelinek: i probably should have said *either*
15:26johnjelineklol
15:26agarmanjohnjelinek: depends upon your use case
15:26bbloomjohnjelinek: represent your value how you need it
15:27bbloomjohnjelinek: if you have a map, you're using some key to look up some value. build up data that match your algorithms
15:27harovaliI have to supose that the java standard library and the enterprise java beans, and such stuff , are really useful when one progams in clojure. Is that better thatn say the satandard library of perl or python or .. ?
15:27johnjelinekhere's the case: I have different routes, and I want to collect http responses so I can broadcast data to them all over http chunked encoding, but I want to filter out data to broadcast based on who is listening on a route
15:28agarmanharovali: the JVM libraries vary in usefulness...some are terrible...such as Date and text formatting...some are excellent like concurrent libs
15:28bbloomjohnjelinek: i'm not quite sure what that means, but all you need to do is figure out what data you have, what questions you want to ask of your data set, and then encode data to best answer those questions
15:28johnjelinekI think maybe I'll keep things super flat, it sounds like it'd be easier to query
15:29johnjelinekrather than nesting arrays
15:29bbloomflatter is generally easier to query and, if your data set is small, linear performance is probably just fine
15:30harovaliagarman: aha!, I'd previously thing that precisely, the Date library was excellent
15:30harovalis/thing/think/
15:30bbloomyou can always add extra indexes and such later, since you've got immutable data it's easy to create consistent alternate views of data either incrementally or in a batch. start w/ the simplest information model & optimize later
15:30johnjelinekthanks :)
15:30johnjelinekbbloom: good thought :)
15:30agarmanharovali: like with Ruby, Python etc. learning the stdlib and it's gotchas is a rather large part of learning the language. The functions provided by Clojure are almost universally excellent. When I need to use Java libs, they're there, but it's often depressing.
15:30johnjelineklol, filter and remove always get me confused on the predicate
15:31bbloomjohnjelinek: me too.
15:31bbloomfilter-out vs filter-for
15:31bbloomargh.
15:31johnjelinekright
15:31justin_smithlooking at the real world, a filter catches things, but the mental model of whether you are interested in the things that pass through the filter or the things filtered out can be confusing
15:32justin_smithso perhaps a filter should have two outputs :)
15:32bbloomjustin_smith: i like the name "where"
15:32justin_smithreally clojure's filter may be clearer as "net" or "trap"
15:33agarmanharovali: Java's date lib was so pathologically bad that no one used it for years. Everyone used Joda. And now JSR 310 is a brand new implementation of same functionality for Java 8 and beyond.
15:33justin_smithbbloom: where sounds like a logical condition though (a where f(a) < x)
15:34stuartsierra(for [x (range 10) :when (even? x)] x)
15:35bbloom,(for [x (range 10) :when (even? x)] x)
15:35clojurebot(0 2 4 6 8)
15:35bbloomstuartsierra: what are bots for if we don't make them do any work?
15:36stuartsierrabbloom: I always forget to include the bot syntax.
15:36bbloomstuartsierra: in the spirit of making the bots do extra work, they should speculatively evaluate anything that resembles code you may want to evaluate in irc
15:36dbaschwhy is that more useful than
15:36dbasch,(range 0 10 2)
15:36clojurebot(0 2 4 6 8)
15:36justin_smithbbloom: though I guess that logical condition is exactly what filter is doing, so...
15:37bbloomdbasch: b/c (for [x some-result-from-earlier :when (even? x)] x)
15:37stuartsierradbasch: It's not. Just an example of `for :when` syntax.
15:37dbaschstuartsierra: gotcha :)
15:38turbofailhm. filter always seemed intuitive to me, perhaps because i'm used to thinking of filters by what they pass
15:39coventryYeah, filter is great, but for / :when is very useful when you want to iterate over and filter a cartesian product.
15:40justin_smithturbofail: well, in natural language it is ambiguous - "high frequency filter" "water filter" "carbon monoxide filter" - totally inconsistent
15:41szymanowskihello, when I try (declare foo) at the clojurescript repl it throws an error is it normal?
15:41dbaschthere used to be a separate function in clojure contrib, don’t know if it’s still around
15:41dbaschbut it was like (juxt filter remove)
15:42justin_smith,(group-by even? (range 4)) ; dbasch
15:42clojurebot{true [0 2], false [1 3]}
15:42justin_smiththat's all that's needed for that
15:43dbasch,((juxt filter remove) even? (range 4))
15:43clojurebot[(0 2) (1 3)]
15:43rhg135,(doc group-by)
15:43clojurebot"([f coll]); Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."
15:43rhg135hmm
15:44dbaschjustin_smith: depends on what you want
15:47dbaschjustin_smith: group-by is not lazy, for one
15:47justin_smithfair point, yeah
15:59amalloy(juxt filter remove) is only half-lazy, really
15:59justin_smithhalf-lazy?
16:00amalloytry: (let [[evens odds] ((juxt filter remove) even? (range 1e8))] (list (last odds) (first evens)))
16:00amalloyit has to walk over the list twice, so it has to hold onto the head of the list for the second traversal
16:07teslanickIs this a totally nutty idea? https://gist.github.com/nhusher/11301237
16:08teslanickPutting data to the redis-ch posts it to a redis pubsub, taking from awaits data on the pubsub.
16:15alejandr_teslanick: that's a cool idea. Can you explain how the readPort portion works?
16:16teslanickcore.async channels are just a small box of protocols. I'm implementing the same protocols with different behavior.
16:16teslanickI borrowed the idea from https://github.com/james-henderson/chord
16:18teslanickBut it's just calling the protocol function against the read-ch. So when you do (<! redis-ch) you're actually doing (<! read-ch), which is a channel fed by the redis-listener.
16:19alejandr_Ah got it, had missed that the redis subscriber was filling a separate channel
16:19alejandr_thanks
16:19teslanickIt's the only way I could think of to stitch together the (weird) way that carmine handles pubsub and a core.async channel
16:20justin_smitharrdem: regarding out convo the other day about using log on units, one way to clarify it may be to say that currently your usage of numbers for the units is an implicit multiplying factor, and you need some other datum to represent curvature, which is something not represented currently (you are using math such that all is implicitly linear, log is not linear)
16:21justin_smith*our convo...
16:30sveriHi, I am still on my way through om, right now I am trying om-sync. I am running this function: (om/transact! data edit-key (fn [_] (.-date e)) :update) where data is a map like this: {:id 2394 :foo "foo" :bar "bar"}, edit-key is :bar and the fn just returns sime text for :bar. It works at altering the state and om-sync also calls the server side. However, it only provides the edit-key :bar map like this: {:bar "new_val"} instead of the whol
16:32justin_smithe..
16:38AWizzArdAbout cider-nrepl: adding this as a :plugin to my :user profile is enough, right? I won’t need to add :nrepl-middleware to my :repl-options, yes?
16:53tickinghas anyone found a local maxima for a simple clojure editor yet?
16:54mikerodticking: does that mean emacs?
16:54tickingmikerod: simple ;p
16:55justinho1vim?
16:55clojurebotGesundheit!
16:55mikerodticking: (not= simple easy)
16:55mikerod:P
16:55amalloywell, emacs is neither, mikerod
16:55tickingmikerod: emacs is neither
16:55amalloyi mean, i love emacs
16:55mikerodamalloy: I was waiting on a response like that :P
16:55mikerodfair enough, but yes I do love emacs
16:56justinholguinSeriously though, LightTable is probably it
16:56tickingjustinholguin: nope, LT is probably easy but BOT is the opposite of simple, even the emacs internals are cleaner compared to that hairball ^^
16:56hrathodticking: Nightcode, perhaps?
16:57justinholguinBOT?
16:57tickingjustinholguin: the object model LT
16:57tickingLT employs, Behaviours Objects Tags
16:58justinholguinOk, thanks.
16:59justinholguinI started with LT and it served me well while I was still experimenting with basics, but I use vim now and I can't really go back.
16:59tickinghrathod: good idea but seems very IDE focused
16:59mikerodwhen going for simple
16:59mikerodin an editor
16:59mikerodthat is tricky I suppose
16:59tickingyeah, I was thinking about Sublime :/
17:00tickingGithub atom looks promising but feels alpha
17:00mikerodEclipse + counter clockwise :)
17:00tickingjustinholguin: yeah, LT is awesome on paper but flawed in reality
17:00tickingmikerod: oh you ;)
17:03hrathodWhat is the definition of "simple" in this case? Just syntax highlighting? ability to connect to nrepl?
17:04mikerodis a "notepad" style editor simple?
17:04tickingmikerod: yeah
17:05mikerodthen notepad
17:05tickinghrathod: connect to nrepl should be the most advanced feature
17:06tickingmikerod: I'm on a mac, also notepad might be a bit tooo simple
17:06tickingbut I'd lean more forward to something like it than say lighttable
17:07mikerodI know people coming from Java-land tend to use Counterclockwise since they are already using Eclipse
17:07hrathodticking: I don't know what the status of Clooj is, but I believe it was fairly simple
17:07tickinghrathod: yeah commited a fix to it once, but it is also very IDE like
17:08tickingI'll just conclude that no local maxima has been found yet ^^
17:09justinholguinWhere's the appeal in an editor that's basically notepad with nREPL support? I don't think I get it.
17:09tickingjustinholguin: simple things have less points of failure
17:09eggheadLOCAL MAXIMA
17:09llasramAlso, where's the appeal of an editor that isn't Emacs? I don't get it :-)
17:10tickingllasram: same answer ;) less points of failure
17:10eggheadlight table?
17:10eggheademacs?
17:10clojurebotemacs is a nice operating system if it only had a decent editor
17:10technomancyI point people to inferior-lisp if they're having a hard time getting nrepl working
17:10justin_smithjustinholguin: I have a hack to add atom:link to clj-rss, which is something that validators seem to think should be there
17:10technomancyit's good to have a fallback
17:10justin_smithjustinholguin: with a bit of work it could maybe be made a feature of clj-rss even
17:11justinholguinjustin_smith: did you read my mind or my GitHub profile?
17:11justin_smithjustinholguin: I was looking at the clj-rss code on gh and saw you were the last to commit
17:11justin_smithfigured the nick carried over
17:12justin_smiththough I guess I could actually make what I have into a proper PR
17:12justinholguinYeah, so I figured
17:12justinholguinCool, that library needs work.
17:12justinholguinI saw an open issue for that
17:12justinholguinBut that's not really something I care about
17:12justin_smithjustinholguin: https://www.refheap.com/80485
17:13justin_smithof course you probably don't want "localhost:33333" in the real outptut :)
17:13justin_smithand I don't know what kind of mess my brain was making of reality when I typed "clojure.edn" in the comment, hah
17:14justinholguinjustin_smith: yes, that is a safe assumption. I would definitely recommend sending yogthos a PR
17:14justin_smithcool, will clean it up
17:14justinholguinI'm working on some unrelated issues I've been having with clj-rss, which incidentally appears to be the only library out there for generating RSS feeds with Clojure.
17:15justin_smithI figured that out :)
17:15justinholguinI keep forgetting that RSS is "dying" because I've used it every day for like 12 years
17:15justin_smith(also I found out the clojure web framework I help maintain totally fails to allow rss content type of non-static data at the moment :()
17:16justinholguinWhich framework is that?
17:16justin_smithcaribou
17:16justin_smithand yes I know frameworks are terrible, it's my job though :)
17:16tickingjustinholguin: a edn based replacement would be nice though ^^
17:16akurilinQuick question, what do you guys use for storing slightly more involved external configuration than what can be handled with just env vars? e.g. I want to be able to read in a list of strings in my ring app at boot, should I use some sort of yaml/edn/json thingy?
17:16gworley3here's a simple enough question I could use some advice on: what's the best way to store a shared connection in a ring app? a ref? atom?
17:16justinholguinI use yaml, but I'm kind of a heretic.
17:17justin_smithakurilin: I use a set of edn files, and a boot time var to decide which one is loaded
17:17bbloomyaml is the worst thing ever.
17:18akurilinjustin_smith: edn comes for free with 1.6, right?
17:18justin_smithgworley3: will the shared connection need a coordinated change alongside some other shared mutable value?
17:18justinholguinYAML is terrible, but it's easy to read and edit by hand. For me, that makes it a decent way to handle config files
17:18justin_smithakurilin: well even before that, given that all you need to do is call read on the bufferedstream (it's just safer in 1.6)
17:19gworley3justin_smith: nope. just need to come into existence once per jetty process and then be shared by all the threads (may eventually expand to pooling, but shouldn't be necessary since in this particular case i'm using rabbitmq)
17:19justin_smithakurilin: edn is just a json-like subset of clojure data literals
17:19akurilinjustin_smith: yeah I guess since technically this isn't an unsafe file, I can just eval it?
17:19justin_smithgworley3: if it never changes, consider using delay or even a declare and a later def
17:19gworley3akurilin: edn is great
17:19akurilinbbloom: I hate anything that uses whitespace for formatting
17:19justin_smithakurilin: well read is fine, no need for eval even
17:20bbloomakurilin: whitespace is the least of yaml's problems
17:20bbloomirb(main):004:0> YAML.load("foo: 1\nyes: two\n3: :four\n'5': null")
17:20bbloom=> {"foo"=>1, true=>"two", 3=>:four, "5"=>nil}
17:20justin_smithakurilin: 1.6 just adds some extra reading safety, but it's your file so no need to be too worried
17:21akurilinjustin_smith: fair enough, I'll play around with read then
17:21bbloomalthough this highlights one of my complaints about clojure's syntax too... true/false/nil *look* like symbols but aren't
17:21justin_smithakurilin: (-> "caribou/plugin/rss/dummy-input.edn" io/resource io/reader PushbackReader. edn/read))
17:21justin_smithakurilin: that is from the same project I was just quoting to justinholguin
17:21akurilinah neat
17:21gworley3justin_smith: ah, delay looks like just the thing. thanks!
17:21akurilinthx
17:21lemonodori like the google approach to app configuration: everything is a command line flag. if you want, you store them in a file and read them from there. everything that can be configured can be set in a file, or from the command line.
17:21justin_smithgworley3: np
17:22lemonodorit’s consistent between languages, and it’s consistent between deploying to 10K machines or running on your desktop
17:22justin_smithlemonodor: yes, it would be nice to have a lib that made that work with clojure (maybe it exists and I don't know it)
17:23lemonodorjustin_smith: https://github.com/wiseman/clj-gflags (i’m new to clojure, it’s not done, etc.)
17:23gworley3on a related question, once i have this shared connection, rabbitmq has a concept of channels (it takes care of multiplexing requests across a single tcp connection using them) that i should create once per thread
17:23justin_smithlemonodor: cool!
17:24justin_smithgworley3: weird. I wonder if piggybacking on :dynamic vars (which by clojure definition have different bindings per thread) would be a win or lose there
17:24gworley3right now i have this set using (def ^:dynamic channel) that i later bring into existence when i need it, but is this actually thread local in this case? I'm using ring and compojure and it's not 100% clear to me when the threads get created
17:24justin_smithmaybe someone with deeper expertise than me can weigh in on that
17:24justin_smithamalloy maybe
17:25justinholguingworley3: just a note, dynamic vars should have earmuffs (*channel*). Their ears get cold.
17:25justin_smithgworley3: I think :dynamic means it can be different per thread, but in no way tells you it will be
17:25gworley3justinholguin: oh, they do; i just forgot them here
17:26justin_smithgworley3: mainly what I know about :dynamic is that it correlates highly with bugs in my code. That could be my fault, could be the feature's fault, I will need more learning before I know which.
17:28gworley3justin_smith: from the docs it mentions needing to use binding to set a thread local value, but in the case of using compojure it's not clear to me where i would need to stick this in
17:28justin_smithakurilin: that PushbackReader is java.io.PushbackReader btw (oddly, not covered by clojure.java.io)
17:28justin_smithgworley3: I don't think compojure has anything to do with that, or even ring, it has to do with the way the individual ring backend uses threads
17:29justin_smithgworley3: we had bugs with dynamic vars get exposed when trying to get http-kit compatibility
17:29justin_smithbecause http-kit does not use threads the same way jetty does
17:29gworley3hmm
17:30justin_smithat this point I consider "breaking bad code which misuses :dynamic" as a positive feature of http-kit
17:30gworley3justin_smith: yeah, i'm trying to make sure these vars end up doing what i want in a multithreaded environment using jetty, but right now it's a little fuzzy to me
17:30akurilinjustin_smith: any particular reason for that specific class?
17:31justin_smithakurilin: edn/read needs it (as does the normal read iirc)
17:31justin_smithakurilin: a regular Reader does not suffice
17:31amalloythere are many ways to get a different value for a var per thread, but like justin_smith says, is that really what you want? if you do part of a job on one thread and want to spin some of the gruntwork for that job off to another thread, you may want them to share the resource, for example
17:33amalloyif you really truly want a fresh instance of something per thread, useful has a good tool for that: https://github.com/flatland/useful/blob/develop/src/flatland/useful/utils.clj#L201 lets you write (def channel (thread-local (make-a-channel)))
17:33justin_smithakurilin: you can more concisely do (edn/read-string (slurp (io/resource "file/path.edn"))) and punt on efficiency
17:34amalloythen each thread evaluates (make-a-channel) at most once, and @channel gets you the channel for that thread
17:34gworley3amalloy: i came across thread-local but was trying to see if i could do it with clojure primitives before i dug into that
17:35gworley3amalloy: i actually just found this while i've been on here and it suggests a way of using bound-fn: http://blog.steveolsen.us/dynamic-vars-in-ring-handlers/
17:47bbloomwhat causes files to get copied to target/classes ?
17:49amalloybbloom: that's where lein puts them when you do aot, no?
17:49bbloomamalloy: i haven't done any aot compilation & these aren't .clj files
17:49dbaschbbloom: compilation
17:49amalloybbloom: then i'd say it's some bad lein plugin?
17:49amalloybut it'd be .class files, not .clj files
17:50amalloy(if you were doing aot)
17:50bbloomthey are files be loaded as resources out of src
18:02technomancybbloom: maybe cljx or something
18:03bbloomtechnomancy: i'm not using any plugins for this project
18:03technomancymysterious
18:03bbloomindeed
18:05Bronsabbloom: using swank and compiling a file puts the .clj files in target/classes
18:05bbloomBronsa: i use vim
18:05Bronsamaybe something similar happens with the vim plugin?
18:05bbloomi don't think so
18:05Bronsabbloom: rm -rf target, connect via vim and compile the file & see if it gets populated
18:12AWizzArdAbout cider-nrepl: adding this as a :plugin to my :user profile is enough, right? I won’t need to add :nrepl-middleware to my :repl-options, yes?
18:13gtrakAWizzArd: correct
18:14gtrakthat's basically the point of the plugin
18:14AWizzArdgtrak: k, thx
18:14AWizzArdgtrak: btw, does this plugin have anything to do with piggieback or cljs repls?
18:14gtrakyes
18:14gtrakrather, not the plugin bit
18:14gtrakbut the middlewares do
18:15gtrakshould *just work* when piggieback is active.
18:21akurilinjustin_smith: good to know, thank you sir.
18:22akurilinOn an unrelated note, what's a simple way of breaking lein ring unberjar?
18:22akurilinI need to make sure the script is handling the failure correctly
18:23justin_smithakurilin: having an invalid :handler in your project.clj :ring config?
18:23justin_smithor an invalid ring option maybe?
18:23akurilinhm let me try that in a bit, good call
18:23justin_smithdepends where you want it to break I guess
18:25amalloyset your computer on fire
18:25amalloythat should break lein ring uberjar
18:25justin_smithlol
18:44l1xhi, has anybody seen this problem? https://gist.github.com/l1x/11305543
18:45justin_smithl1x: try (io/write (io/file file)), or just (io/writer file)
18:45justin_smith*io/writer of course
18:45l1xsame results
18:46justin_smithwhat is "file" in that context
18:46justin_smiththe name of a file?
18:46justin_smithan io/file?
18:46justin_smithand why are you calling str on it?
18:48l1xfile is (io/file "string" "anotherstring")
18:48l1xi have tried both using it as it is and calling str on it
18:48l1xboth fails
18:48justin_smiththen yeah, calling string on the file is the wrong thing
18:50l1xfyi it works
18:50justin_smithwhich works?
18:50l1xboth, using it as it is or calling str on it, both is supported for io/write
18:51penthiefllx: data needs to be a String for the write method to be found.
18:51l1xand it works in repl, but not when i am calling it in the real code
18:51justin_smithcalling str on the file object?
18:51l1xyes
18:51l1xpenthief: thanks, that might be it
18:51justin_smiththat's weird
18:52justin_smithyeah, I guess io/writer coerces strings to files
18:52l1xbut you are right, it should be a File object it is better that way
18:53amalloycalling (str) on a file object gets you useless garbage
18:53amalloy,(str (java.io.File. "/tmp/foo"))
18:53clojurebot"/tmp/foo"
18:53amalloyhuh. it doesn't? i didn't know that
18:53justin_smithamalloy: surprised me too :)
18:54amalloyi'm so used to its pr-str, i guess
18:54cbp:-P
18:54l1xand the winner is penthief
18:54l1xthanks bro, (str data) fixed the problem
18:54l1xit was a hashmap and i thought it is just a string
18:54justin_smithalso, there is spit
18:54l1xnow it works
18:55l1xamalloy: what are you talking about? calling str on a File returns you the operating system specific string that is your path to the file
18:55l1xeg on windows it is going to be \ on unix it is /
19:14hyPiRion,(str (java.io.File. "I'm not so sure\\"))
19:14clojurebot"I'm not so sure\\"
19:15hyPiRionGranted, a *real* file will give you a valid file name
19:15TravisDIs there a function that returns the first element of a seq satisfying some predicate? Something like (defn first-satisfying [p xs] (first (filter p xs)))
19:16hyPiRionTravisD: no, that's your best bet. Can define it as (def ffilter (comp first filter)) though
19:16TravisDah, I like the name and definition :)
19:17justin_smithbonus points if you use metadata so ffilter has a doc string :)
19:17justinholguin,(doc some)
19:17clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
19:17justinholguinTravisD: ^^^
19:17justin_smith(some even? (range)) justinholguin: not quite
19:17justin_smith,(some even? (range)) justinholguin: not quite
19:17clojurebottrue
19:18justin_smith(oops)
19:18TravisD:(
19:18justinholguinAh, I see
19:19justin_smithof course (some (apply set (all-even-numbers)) (range)) would work, but that set is expensive to construct :)
19:19akurilinSo if want to cache some resources in memory when starting my ring app, is a promise delievered from ring's init handler pretty much my best bet?
19:20akurilinI basically just need to run a "def" that one time when init is run, but actually calling def is frowned upon afaik
19:20justin_smithakurilin: you could use an actual caching function, or even better use varnish in front of your app and let varnish do the caching
19:20justin_smithif the thing cached is the response to the client, that is
19:21akurilinjustin_smith: in my case it's more of a large .json payload that I need to parse into memory and that is then used by a lot of the internal business logic. It's basically 100% like a totally static db.
19:21TravisDjustinholguin: Wouldn't that still just return true?
19:21akurilinI just need to load it once.
19:21TravisDer, justin_smith ^^^
19:21l1xis there a way to convert a hashmap to a string without escaping quotes?
19:21justin_smithakurilin: fair enough
19:21TravisDsorry about that. Didn't realize you were both justins
19:21justin_smithTravisD: that was my point
19:21justinholguinWe forgive you.
19:21akurilinjustin_smith: so would a promise be a goot match there in your view?
19:22justin_smithheh, yeah, trickiness
19:22justin_smithI am one of 5 justins in my office
19:22justin_smithyou could also do declare / def in init
19:22justin_smithbut yeah, I think a promise is cleaner
19:22TravisDHehe, Travis' are considerably rarer
19:22guns"Heather? Not me, Heather."
19:23justin_smithguns: yeah, it's pretty bad
19:23justin_smiththe fun part is seeing all the emails meant for the other justins
19:23justin_smithand getting invited to meet with clients (one of the justins is a partner)
19:23akurilinjustin_smith: fair enough. Do people ever try to bypass having to use @ to access promises to clean up the syntax by wrapping them in some kind of accessor or is it not worth it?
19:24justin_smithakurilin: that seems silly to me
19:24justin_smithI mean @ is an accessor (short for (deref ...))
19:24akurilinhey man, I save ONE entire character worth of typing, think about it!
19:24akurilin:P
19:24justin_smitha let binding, to keep things concise, maybe
19:25akurilinok fair enough, I'll buy that
19:25justin_smithI go for the philosophy that the closer a binding is to usage, the shorter a name you can get away with
19:25justin_smithso ns + var should form something totally unambiguous when combined
19:26gunsre variable length: https://news.ycombinator.com/item?id=840331
19:26justin_smithand then for things bound right before usage, go super small, sure
19:26akurilinjustin_smith: were you the one who recommended the init startegy to me many months ago? As in, you have Ring's init, and from there you call all of the other various inits in different namespaces?
19:27justin_smithprobably, that is how I do it (when namespaces need state of course)
19:27justin_smithbut I am working on more and more having state be returned from an ns, rather than being in it
19:28justin_smith(big plan is a plugin system where features are returned by a constructor function in each plugin ns)
19:29akurilinI also wonder if maybe it's a good idea to have a separate namespace for all the state that gets accumulated at init
19:29justin_smithhtml / enlive question: what is my best bet when I have some html and I want to get a truncated plain text out of it - or is there even some sane way to handle that?
19:30justin_smithakurilin: ns app.state or some such?
19:30akurilinyeah, cause right now I have "model.foo" with its own state, and "model.bar" with its own state
19:30akurilinI guess we'll see on the long term
19:31akurilinit's like with routers, splitting them up in different files is fun until you get to about 3 routes, after that you re-write it all in one place :P
19:42gunsI'm thinking about symmetrically encrypting runtime passwords to keep them out of stacktraces (so just obfuscation); is this too heavy handed? Is there a reliable way of filtering stacktraces?
19:44hiredmanwhat do you mean "keep them out of stacktraces" ?
19:44justin_smithhow would the string end up in the stack trace - an exception handler that leaks info in constructing its message?
19:45justin_smith*exception thrower that is
19:45technomancyyou mean core dumps?
19:45gunsThe record with password field gets pr-strd
19:46justin_smithby some tracing code, or in a stack trace?
19:46justin_smith
19:46gunsjust stack trace to a log file
19:46gunstechnomancy: I won't bother with local attackers
19:46gunsa local user can just get root and use gdb
19:56justin_smithguns: in that case, what about making sure the stacktrace never leaves the server?
19:56justin_smiththen you only have local to worry about
19:57gunsjustin_smith: I won't be controlling the infrastructure
19:57gunsIt's actually an IMAP client
19:57justin_smithahh
19:58justin_smithso you can't be sure the client doesn't see a server stack trace
19:58gunsI'm pretty sure they would see it :) and they're the sort of folks that would storm the gates
19:59justin_smithwhat about a redesign such that the actual password is never in a record? shouldn't you be comparing to a salted hash anyway?
20:00gunsjustin_smith: No, the actual IMAP password is needed to connect to the server; this is different from typical auth scenarios
20:00justin_smithahh
20:01justin_smithI mean I would call that an infrastructural flaw that the password needs to be passed around like the village bicycle, but that's out of your control if you want to use that protocol
20:01gunsIt's up to the user. they can always use 2-factor auth with gmail etc
20:01justin_smithyou could put the password inside a Byte[]
20:01justin_smithit is still readable by applying str, but won't get printed
20:02justin_smith,(.getBytes "hello")
20:02clojurebot#<byte[] [B@aeddb5>
20:02justin_smith,(apply str (.getBytes "hello"))
20:02clojurebot"104101108108111"
20:03justin_smiththat at least prevents any legible printing, with a low overhead
20:03dbaschguns: keep passwords in memory only while you need them, don’t pass them around
20:03justin_smithoh oops!
20:03fortruce_when using clojure.lang.RT/loadLibrary, where does the Classloader attempt to find my library at, i'm getting UnsatisfiedLinkErrors trying to use OpenCV
20:03gunsthat's true; I might opt for that. I'll think a little harder about keeping the password in memory
20:03dbaschguns: passwords should be very short-lived in memory anyway
20:03justin_smith,(String. (.getBytes "hello"))
20:03clojurebot"hello"
20:03gunsdbasch: I think that's right. It's convenient for me; but the user should just be using gpg-agent or whatever anyway
20:05amalloyhuh. i thought java had a SecureString or something like in C#
20:06justin_smithamalloy: maybe, but byte[] does what you want from it in terms of printing at least
20:07justin_smithor char[] I guess
20:07gunsjustin_smith: if you're going to do that; it's not that much harder to XOR, and not much harder to use AES
20:08gunsAs long as it's understood that it's just obfuscation, no encryption
20:08justin_smithguns: the printed rep of byte[] reveals nothing of hte content
20:08justin_smiththat's what you wanted, right?
20:08gunsjustin_smith: yes, it was.
20:08gunsand it's a good point
20:09justin_smithor am I missing something?
20:09justin_smithIf you already punt on local attacks, an xor or aes or whatever don't get you anything the untrintable representation didn't
20:09gunsno, not at all; I concede the point
20:09gunsdbasch is right in the end
20:10justin_smithhah, that was my first tack too
20:11justin_smitherr not my first, but on of
20:12justin_smithanother consideration regarding byte[] - since string is immutible you can't zero it out or obfuscate it when done, so it is hanging around until garbage collected
20:13gunsI can just unload the responsibility of password storage to gpg-agent, and whatever's built into OS X; my only concern was efficiency, but it's really nothing in comparison to the IO
20:13gunsthanks everyone!
20:18dbaschjustin_smith: that’s probably the case regardless, unless you control all layers of communication between the client and your app
20:20justin_smithdbasch: the various caching spots?
20:21dbaschjustin_smith: no, your server. nginx, jetty, etc.
20:21justin_smithright, I mean caching abstractly, each of those has places where things stick around in memory
20:22dbaschyes
20:22gworley3back again with another question and possibly free SO points. anyone know how to do what i'm trying to do: http://stackoverflow.com/questions/23305042/automatically-require-dependent-namespace-in-clojure-macro
20:23justin_smiththough ideally one could transfer and use credentials in such a way that the password is only plaintext in one specific place, and then one has the power to clear out the thing once done with if it is mutible
20:23amalloygworley3: your problem is imaginary. they don't need to refer to env
20:23dbaschjustin_smith: that’s really what oauth is for
20:24gworley3amalloy: oh?
20:24amalloytry macroexpanding that. you'll see that it expands to environ.core/env
20:24justin_smithyeah, that way you don't even need to pass the password around (what I was referring to with my talk about treating the password like a community bicycle above)
20:24gunsI bet memset(p,0,n) isn't even guaranteed on cheapo RAM
20:24gworley3amalloy: yep, i've already seen that it does that
20:25amalloysyntax-quote fully-qualifies all symbols within it, for just this reason
20:25amalloyokay, so what's the problem? clearly there's no :refer needed in the caller's namespace
20:25justin_smithgworley3: once required, the ns exists throughout the clojure process, loading the ns is not a per-parent thing
20:25gworley3amalloy: but when it include in a namespace without requiring environ.core, i get "unable to resolve symbol"
20:26amalloygworley3: you must be misunderstanding either what you're doing or what the error message means, because that isn't what happens
20:26amalloyyou still have to require gworley3.utils, of course, but the reference to environ.core is unnecessary
20:27gworley3"Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: env in this context"
20:28justin_smithbut env won't end up in that code - it will be fully qualified, that is what ` does
20:28justin_smithsomething else is called env
20:28gworley3oh, you know what, you're right; i'm dumb
20:28justin_smithdid you have an arg called env nearby?
20:28gworley3yeah, it was part of some other new code i had been writing and forgot about while i was doing the refactor to add the macro
20:28justin_smitherr I mean code that referred to something called env
20:29gworley3welp, guess i learned the lesson that i actually know more about how macros work than i thought and should have looked for a more mundane explanation
20:29justin_smithalso, read stack traces carefully
20:30justin_smith(pst) is your friend
20:30arrdemAs is (e)
20:31justin_smitharrdem: *e ?
20:31amalloygworley3: on the other hand, why is this a macro? write a function (defn env* [name default] (fn ([] (or (env name) default)) ([x] x))), (def username (env :username "mike"))
20:31amalloyer, (def username (env* :username "mike"))
20:32gworley3amalloy: so i only have to write username once instead of twice
20:33justin_smithat a certain point DRY has deminishing returns I think
20:33amalloyi think that's a questionable economy, but if you're set on it, you should still define a function that does the actual work, and then a macro that wraps the little bit of sugar around it
20:34gworley3amalloy: that makes sense. this is actually the first time i've done something i could only dry up by writing a macro
20:34gworley3normally i try to stick to functions
20:37amalloyreally you can even write this as a function, by using intern instead of def. but again i'm not convinced that that's super-amazing
21:28dnolen_DataScript + Om example just so people can start experimenting https://gist.github.com/swannodette/11308901
21:29dnolen_that said, lots of potential here
21:29ToxicFrogOh my god death to Java sockets
21:34bbloomdnolen_: pretty cool. coupled with the use of equiv, you'll be passing around tuples of [entity-id transaction-id] to all your react components in no time ;-)
21:34dnolen_bbloom: actually I think most people will just pass entities
21:34dnolen_bbloom: you just need to add entity caching over DataScript
21:35dnolen_get all the flexibilty of Datomic for the data model
21:35dnolen_w/o changing how components work and w/o losing fast rendering
21:35bbloomdnolen_: that definitely will be nice
21:36irctchello
21:36llasramhello
21:37bbloomdnolen_: what would be cool would be if you could somehow hook the server side transaction log & stream "relevant" datoms down to the browser
21:38bbloomnot at all clear how you'd enable that w/o lots of custom work, but it would certainly be nicer than some half baked backbone/socket.io clusterfuck
21:38tomjackseems like maybe a can of worms though?
21:38akhudekbbloom: we just recently did this for sql, worked out really well. Planning on doing a source release at some point.
21:38bbloomakhudek: cool
21:39dnolen_bbloom: yes that's the next step
21:39akhudekbbloom: basically we have materialized views sitting in the browser, then any changes to the server database cause deltas to be sent to efficiently update any relevent client views
21:40dnolen_bbloom: DataScript's making me rethink some assumptions about how Om works (a good thing). It's much a better M story than what you see in most JS MVCs
21:40dnolen_definitely something I thought about when I was working on Om, but too lazy to implement the Datomic API, glad somebody else picked it up
21:41tomjackdo you set up filtered server txlog to auto-transact into client's db?
21:42tomjackand not transact into that db at all from the client otherwise?
21:43tomjacks/db/conn/
21:44tomjackI guess my confusion is where the boundaries are between the client and server databases
21:44dnolen_tomjack: that needs sorting out
21:44dnolen_tomjack: I'm mostly interested in the repercussions for data modeling on the client side as well as repercussions for app structure
21:45bbloomakhudek: that's neat. i'm curious to see how it came out
21:46bbloomdnolen_: yeah, the cursor stuff seems to make sense for view-level state, but i was never sold on it for the M layer
21:46dnolen_bbloom: def, that's where it's kinda busted
21:47dnolen_bbloom: but widgets will want to update an entity, so you need some kind of reference back to the original data, but cursors may very well be overkill for this
21:47bbloomdnolen_: i think you can do much better for view state than the cursor approach too, but it's a pretty reasonable approximation of the "right" solution for both, so rather than dissuad you from going that route i wanted to see how far you could push it
21:47bbloomanswer: pretty far :-)
21:47bbloomdnolen_: well, entities have a db ident in them, right?
21:48dnolen_bbloom: yep, the cursor idea was separate from the real goal anyway - efficient time travel
21:48dnolen_the end is more important than the particular means
21:48dnolen_bbloom: yes
21:49dnolen_re: db ident
21:49bbloomdnolen_: i'd be interested to see if you can decouple the om design from the cursor such that you can ship om.cursor as a separate library for compat sake as you move towards supporting/encouraging various ad-hoc external state mechanisms
21:50bbloomdnolen_: actually, i'd imagine such a cursor library could have zero dependencies on om entirely & still work w/ virtually the same api
21:50dnolen_bbloom: yeah, cursors are completely protocolized
21:50dnolen_so I think we're OK for a transition to something better if need be.
21:52bbloomdnolen_: you might want to re-read some of the crazy ramblings on awelonblue about ad-hoc external state
21:52dnolen_bbloom: will do
21:52bbloomdnolen_: also, here's the awelonblue/plan9/datomic inspired external state tree thing i was talking talking about: https://github.com/brandonbloom/exstate/blob/master/src/exstate/core.clj
21:53TerranceWarriorthere a way to get upscroll in the Clojure REPL?
21:54bbloomdnolen_: i'm not sold on the tree shape, but i'm quite happy with the division of labor of the 5 protocols in there
21:54zspencerI'm sure there's a canonical blog post about looping until a predicate is met
21:54zspencerAnyone want to point me there?
21:54zspencerI'm doing loop recur, but the function may have side effects (callback prints things to screen)
21:54bbloomdnolen_: the snapshotting model would work quite nicely with a render loop
21:54dnolen_bbloom: yeah I think I'm finally coming around to the fact that trees are good for components, not good for the application - you want a real data model for that
21:55gunsTerranceWarrior: That depends on the REPL, terminal, etc
21:56gunszspencer: If you're not accumulating a value, then there's `while`
21:56dbaschzspencer: you mean while ?
21:56zspencerdbasch: guns: derp I am truly an idiot
22:01TerranceWarriorguns: java -cp clojure-1.6.0.jar clojure.main
22:02gunsTerranceWarrior: Then it's up to the terminal to provide scrollback
22:02gunsTerranceWarrior: try tmux if your terminal doesn't have it
22:05technomancyTerranceWarrior: the repl that ships with clojure is kinda junk
22:05TerranceWarriorguns: ok
22:05technomancywell, not just kinda.
22:05guns:) rlwrap to the rescue
22:05jcromartieException in thread "main" java.lang.NoSuchMethodError: com.google.common.io.ByteStreams.limit(Ljava/io/InputStream;J)Ljava/io/InputStream;
22:05jcromartiewhen compiling ClojureScript code :(
22:05danneuIs there way to make it so that byte-arrays print out like `#<byte[] [00 aa bb cc dd]>` instead of `#<byte[] [B@170eca98>`? (To see the hex of its contents).
22:05johnrxAny pointers on getting a better "out of the box REPL" technomancy ?
22:05johnrxI never envisaged to change it...
22:06jcromartiethis is pretty mysterious to me https://gist.github.com/jcromartie/6571f07675cd4768a308
22:07technomancyjohnrx: depends on what box you're talking about
22:08gunsdanneu: I believe you can do this by extending print-method
22:09johnrxTo be honest, I never thought of improving the REPL. It's still a little foreign for me.
22:09johnrxI don't really know where to start exploring. I'm still using it in a very Pythonic way...
22:09danneuno limit on that byte stream. your compiler is open to heartbleed
22:10TerranceWarriorguns: invalid.
22:11technomancyjohnrx: leiningen ships with a much better repl, including a readline port
22:11technomancybut I don't know if it's worth trying to improve the one that ships with clojure
22:11johnrxtechnomancy: you mean the one when you "lein repl" ?
22:12gunsjline2 is in the uncanny valley for me; so close
22:12gunsTerranceWarrior: ?
22:13technomancyjohnrx: yeah
22:13jcromartieit's my dependency on clojurewerkz/urly
22:14johnrxtechnomancy: This is what I use :) I thought this was the standard REPL for Clojure, since it's (for me) the easiest and quickest way to get running.
22:17jcromartieI should jettison that dependency just for being called "clojurewerkz/urly"
22:18gunsdanneu: (defmethod print-method (Class/forName "[B") [v w] (.write w (str (mapv #(symbol (format "%02x" %)) v))))
22:19guns,(byte-array [0 127 255])
22:19clojurebot#<byte[] [B@1f782b8>
22:19gunsI guess that's not allowed
22:20gunsby the bot I mean; works in the REPL
22:22llasramguns: Well, you didn't have clojurebot eval the print-method definition
22:22gunsllasram: oh, I guess I don't know much about the bot
22:22gunsoh I forgot the ,
22:22guns,(defmethod print-method (Class/forName "[B") [v w] (.write w (str (mapv #(symbol (format "%02x" %)) v))))
22:22clojurebot#<MultiFn clojure.lang.MultiFn@1952e89>
22:22guns,(byte-array [0 127 255])
22:22clojurebot[00 7f ff]
22:27jcromartiein ClojureScript, how can I access the results of document.getElementsByTagName(…) as a seq?
22:27jcromartiethe result is not seqable
22:27jcromartieand I can't coerce it to a vector
22:28jcromartiei.e. what's wrong with this? (def body (-> js/document (.getElementsByTagName "body") first))
22:31gunsjcromartie: IIRC that's a NodeList; I'm not sure why that doesn't implement ISeq, but there's probably a good reason for it
22:31gunsyou can use the native methods to iterate, or maybe implement the seq protocols yourself
22:39j201jcromartie: (def body (-> js/document (.getElementsByTagName "body") array-seq first))
22:43j201or (def body (.-body js/document))
22:54fortruce_how do I call into a java method that modifies one of the args as the return value
22:57fortruce_nvm, I got it
23:05TerranceWarrioranyone else us eclipse with clojure?
23:06ivanI wanted to SSH into a Clojure REPL a week ago: https://gist.github.com/candera/11310395
23:08TerranceWarriori installed the plugin for eclipse. but i get a an empty memory window for a new clojure project.
23:16Frozenlockivan: What's the benefit?
23:16FrozenlockVersus using the usual SSH on your machine that is
23:20ivanFrozenlock: nREPL as everyone uses it allows anyone on the machine to connect to your REPL
23:24xhhany knows is there a way to access ENV variables in project.clj?
23:26bbloomxhh: i think the whole project.clj file is in a syntax-quote, so you can just ~(some code here) and get env vars the normal way
23:26xhhbbloom: thanks, will try
23:30xhhbbloom: you are right, System/getenv works in project.clj, thanks again
23:51johnjelinekhihi all
23:51johnjelinekis anyone available to review my code to see if it's idiomatic or if it sucks?
23:52TerranceWarriori think after I get a Doctorial in computer configuration I'll be able to upgrade the REPL under Eclipse.