#clojure logs

2015-04-19

00:03mfikesmyguidingstar: I suspect a deeper explanation is that printing results in more of the "tree" being realized recursively than dorun, which perhaps results in only shallow realization.
04:17deanmanIs there a specific help channel for CIDER ?
04:30expezdeanman: #clojure-emacs
05:00expezhow can I force all-ns to update itself after modifying the classpath?
05:01expez(filter #(.contains (name %) "schema") (map ns-name (all-ns))) => ()
05:01expez(require '[schema.core])
05:01expez(filter #(.contains (name %) "schema") (map ns-name (all-ns))) => (schema.macros schema.utils schema.core)
05:55visofhi guys
05:56visofi'm trying to package clojure app as war but some directories in the ROOT folder aren't packaged, if i want to deploy the war with tomcat, where should these directories should be located?
05:56visofi tried it at WEB-INF/ and failed
06:32sobelvisof: sounds like you need to set :resources-path
06:32sobel(i looked it up because i will need this soon enough, too)
07:11shafireruns my code automatically concurrent?
07:11shafireor do I need to do something?
07:12ticking_shafire: you need to do something
07:12ticking_shafire: what features are you using?
07:12ticking_core.async?
07:12clojurebotcore.async is 100% imperative
07:13shafireI just looked at clojure
07:13shafirelooking for something where concurrency is easy
07:14ticking_shafire: concurrency is never easy, but in clojure it's a lot easier ;P
07:14ticking_immutable persistent datastructures help with locking
07:15ticking_and pure functions are easily parallisable
07:15ticking_e.g.
07:16ticking_,(map inc (range 5))
07:16clojurebot(1 2 3 4 5)
07:16ticking_will run sequentially
07:16ticking_while (pmap inc (range 5)) will run in parralel
07:16ticking_,(pmap inc (range 5))
07:16clojurebot#error{:cause "no threads please", :via [{:type java.lang.SecurityException, :message "no threads please", :at [clojurebot.sandbox$enable_security_manager$fn__857 invoke "sandbox.clj" 94]}], :trace [[clojurebot.sandbox$enable_security_manager$fn__857 invoke "sandbox.clj" 94] [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkAccess nil -1] [java.lang.ThreadGroup checkAccess "Th...
07:16ticking_ah too bad
07:17ticking_can use threads on the irc bot
07:17ticking_*can't
07:18ticking_shafire: there are also atoms and agents to help you with pararllelism
07:18shafireokay, thank you
07:19ticking_shafire: and if you just want concurrency instead of parallelism you can use core.async, which will schedule lightweight threads onto a threadpool
07:19shafirethanks
07:19ticking_shafire: it's quite similar to Golangs goroutines
07:21luxbockyou can use core.async to do parallelism as well can't you?
07:21ticking_luxbock: yeah, but you have less control
07:21ticking_as I said, it will be scheduled onto a thredpool
07:21luxbockah right
07:22ticking_I mean, it's the same with futures and thus pmap
07:22ticking_they also have a treadpool to run on (not sure if they are the same)
07:43noncom|2how do i call a method of something that was defined with deftype?
07:56AimHerenoncom|2, create an instance of the type. If you (deftype foo [a b ..] Wibble (bar ..)) then you'd need to (def instance (foo. a b ..)) to create a foo called 'instance' and then (bar instance ...) to run the 'bar' method
07:56AimHerequitter
08:04expez#^JarEntry <- what does this mean?
08:05expez#(.getName #^JarEntry %) <- entire snippet. Is it typehinting what % is? Why bother?
08:20expezI'm guessing the dispatch character # is optional when typehinting?
08:32torgeirja, så æ har endelig fått dæ på clojurebølgen
08:32torgeiroups
08:33TEttingerexpez, correct
08:33TEttinger#^ is the old syntax for type hints
08:34TEttingerI believe it still works
08:34TEttingerbut ^ is strongly preferred these days
08:34expezit does, I've just never seen it before heh
08:34TEttingeryeah it's not just old, it's very old
08:35TEttingerI believe it was around for 1 or 2 early versions before ^ became available and encouraged
08:36expezthe reader just removes the typehints when I do read-string, isn't the reader involved in compiling this stuff to bytecode?
08:39TEttingerI'm not actually sure how read-string works with type hints. type hints may only be relevant when generating .class files, or they may be used in other places too
08:41expezMy mental model of this is (eval (read <code>)) and eval takes care of generating the .class files, but that model seems wrong if read strips the type thints
08:44expezread-string just delegates to read
08:55Bronsaexpez: the reader doesn't remove the type hint. it's just that printing data doesn't print metadata by default
09:02TEttingerahhhh Bronsa
09:02TEttinger(inc Bronsa)
09:02lazybot⇒ 107
09:57ambrosebsBronsa: it seems inadvisable/impossible to analyze an entire file without using analyze+eval at each form. Unsurprising I guess, your opinion?
09:58Bronsaambrosebs: all kinds of stuff won't work, it's just not possible given clojure's evaluation strategy
09:59Bronsaambrosebs: even the reader requires previous forms to be evaluated for e.g. ::foo style keywords or for ` auto-qualifying
10:00Bronsait's not just macros the issue
10:01ambrosebsBronsa: I'm thinking about running entire files through core.typed before it's ever evaluated by anything else. I'm realising this basically means I can only show errors now one top-level form at a time, since if I find a type error I'm not going to evaluate the form, then the rest of the file is basically untouchable.
10:01noncom|2does leiningen work differently when i use "lein run" and "lein jar" ?
10:01noncom|2when i do lein run, all works perfectly, however, lein jar fails...
10:01TEttingerah, ambrosebs is the typed clojure smartperson and Bronsa is the analysis smartperson. this explains why I am not following this conversation :)
10:01ambrosebsBronsa: unavoidable sounds like the right word
10:01Bronsaambrosebs: you're not going to have any fun trying to implement that
10:01ambrosebsBronsa: which part?
10:02TEttingernoncom|2: lein uberjar or lein jar?
10:02TEttingerlein jar doesn't produce a runnable jar IIRC
10:02Bronsatrying to avoid form-by-form evaluation :P
10:02ambrosebsah yes
10:03ambrosebsI guess I'll add that to my constraints :)
10:04ambrosebsBronsa: one thing I'll need to implement this is an analyze+eval variant where I can specify the AST -> AST function to "evaluate" the current top form.
10:04ambrosebsBronsa: I'll send you a patch or something once I've figured it out.
10:04ambrosebsfirst thing's first, I'm on tools.analyzer 0.3.0.
10:04Bronsasure -- if it's something I can incorporate in t.a.jvm I will take it
10:05Bronsaambrosebs: core.async is finally on 0.6.x
10:05ambrosebsnow that core.async is a little less ancient I think it's time to upgrade!
10:05Bronsayup
10:05ambrosebsI was going to wait for a release
10:05ambrosebsbut screw it.
10:10noncom|2TEttinger: lein jar
10:15TEttingernoncom|2: I think, not sure, that lein jar doesn't put the manifest in your code that tells it to run the :main ns, and is more commonly used for jar distribution of libs?
10:16TEttingeryou can unzip the produced jar, noncom|2, and check if there's a manifest
10:16andyfNow if we can just get tbaldridge in here, we should have a quorum for the tools.analyzer users club
10:17ambrosebsunite!
10:18ambrosebseveryone is a tools.analyzer user, they just don't know it yet
10:18andyfNot quite everyone that uses Clojure/JVM?
10:18Bronsatime to add a hidden backdoor
10:19ambrosebseveryone who uses the hot new shiz
10:19ambrosebs:)
10:19andyfBronsa?s plans for world domination have been outed here, folks
10:20ambrosebsdonating to Bronsa may come back to haunt me
10:21andyfor .... protect you. bwah hah hah
10:21ambrosebs:D
10:57si14ambrosebs: I believe you are the right person to ask :) can you please help me to understand how type hints work? It's meta on symbols, right? But how than things like (let [x (into-array ...)] ...) can help to avoid reflection?
10:58ambrosebssi14: they avoid reflection on things like method and field calls
10:58ambrosebsand constructors
10:59ambrosebsthere's some basic type inference, like if `x`'s rhs knows its type hint, it gets propagated to all occurrences of x in the body
11:01si14(sorry, erroneous /me)
11:02ambrosebsthe clojure compiler inserts the type hint if it's obvious
11:02ambrosebsotherwise you can add it manually and it'll just trust you
11:02ambrosebsnot that inferring type hints should be "trusted" in any sense
11:03ambrosebsthey're just unchecked metadata
11:03ambrosebs,(read-string "a")
11:03si14yeah, I understand, thank you. basically I've tried to see why here https://gist.github.com/si14/c5d584bf622e6de91348 into-array *doesn't* propagate type hint
11:04clojurebota
11:04ambrosebswhat does *warn-on-reflection* say?
11:04si14without that ugly array hint it uses reflection in .set call
11:04ambrosebsah
11:04Bronsasi14: into-array can't propagate the type hint
11:05Bronsatype-hints are compile-time things, the type returned by into-array is determined at runtime
11:05ambrosebsyou'd need a macro of some sort
11:05si14it's "uknown" type according to reflection warning
11:06si14Bronsa: uhm, now I'm confused. I think I saw an occasion when into-array prevented reflection, but maybe I'm just wrong
11:06ambrosebs,(source into-array)
11:06clojurebotSource not found\n
11:06Bronsanope that's not possible
11:06ambrosebs,(doc into-array)
11:06clojurebot"([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
11:06Bronsainto-array doesn't have any type hint
11:06Bronsait can't have a type-hint
11:07si14Bronsa: ok, I see.
11:07si14so everyone resolve to super-ugly string-based array hints for hinting SomeClass[] ?
11:13ambrosebssi14: nah, I just don't use methods that require arrays ;)
11:17si14ambrosebs: that's a solution, too :)
11:18si14anyway, thanks, ambrosebs and Bronsa!
11:18ambrosebs:)
13:30sobelanyone know how to pass a fully qualified (schema.tablename) table to jdbc?
13:30sobelpostgresql
14:00sobeln/m, looks like . and _ translate literally from keywords
14:15noncom|2is it possible under any circumstances that clojure.core won't be referred to from a newly created namespace?
14:15justin_smithnoncom|2: yes, if you use in-ns for example
14:16justin_smithyou can call (clojure.core/refer-clojure) to fix it
14:17noncom|2interesting, now testing
14:20noncom|2yep! that did it!
14:35noncom|2how do i fix Can't change/establish root binding of: *ns* with set ?
14:35noncom|2(binding) is not a good variant in the current situation
14:36justin_smithnoncom|2: this is what in-ns is for
14:36noncom|2well, this error happens exactly in the place where i use in-ns :)
14:36justin_smiththat's because the ns does not exist
14:37justin_smithchanging the root binding of *ns* without initializing the ns would cause the same problem
14:37justin_smithyou can use ns (like you would in source files) for switching to an ns and getting default initialization if it is new
14:38noncom|2how do i pass a pre-calculated symbol to ns?
14:38noncom|2it behaves like a macro
14:39justin_smithit is a macro
14:39noncom|2so (let [ns-name 'the.good.ns.name] (ns ns-name)) won't work as expected
14:39justin_smithyou would need to write your own macro
14:39justin_smithor use (in-ns ns-name) (clojure.core/refer-clojure)
14:39noncom|2the second variant does not work
14:40noncom|2idk how to do the first one
14:40noncom|2like write a macro wrapper for ns?
14:40justin_smithyes
14:40justin_smithhow does the second variant not work?
14:41noncom|2yes, it does not
14:41noncom|2with the above error
14:41noncom|2macro like this?
14:41noncom|2(defmacro my-ns [sym]
14:41noncom|2 `(ns ~sym))
14:42justin_smithright
14:57noncom|2justin_smith: i keep getting ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
15:02noncom|2justin_smith: here: https://www.refheap.com/99807
15:02noncom|2how is that?
15:13lodin_noncom|2: I think you end up with (ns 'a), but you want (ns a). You have (ns (quote a)) so ns sees a PersistentList, not a Symbol.
15:15noncom|2lodin_: yes, i would think so too, except if (type ~sym) would not return clojure.lang.Symbol ... ?
15:15lodin_noncom|2: It would.
15:15lodin_,(type 'a)
15:16clojurebotclojure.lang.Symbol
15:16noncom|2oh damn
15:16lodin_If you had (type a) then you would look up a and probabaly find that it is undefined.
15:17lodin_noncom|2: Does that make sense?
15:17noncom|2probably...
15:17noncom|2if i try (second a) since i guess that (second (quote a)) would return a, it does not work too
15:18noncom|2since it cannottake second of a symbol
15:18lodinnoncom|2: No, wait.
15:18lodinI think you are confusing what ns sees and what type sees.
15:19AeroNotix_is there something in core for "return true if there exists only one value in coll which (f element) returns true"
15:19AeroNotix_e.g. (only-ony? pred coll)
15:19lodinnoncom|2: If you write (ns (second ~sym)) you still pass a list to ns.
15:19AeroNotix_e.g. (only-oney? pred coll)
15:19AeroNotix_pfft
15:20noncom|2AeroNotix_: yes, tehre is
15:20AeroNotix_noncom|2: what's it called?
15:20noncom|2=> (some even? [1 2 3])
15:20noncom|2true
15:20AeroNotix_uhm, no
15:21AeroNotix_"there exists _only_one_value_"
15:21noncom|2ah
15:21Bronsa(comp zero? dec count filter) :P
15:21noncom|2lodin: that's sad..
15:21noncom|2is there a way around?
15:21J_ArcaneI wrote an idler 'game' with Hoplon for Ludum Dare: http://ludumdare.com/compo/ludum-dare-32/?action=preview&amp;uid=51484
15:22ambrosebs,*clojure-version*
15:22clojurebot{:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true}
15:22lodinnoncom|2: Yes, take second _before_ you're in `(...).
15:22ambrosebs,(let [x 1] (let [{:keys [a b] :or {a b}} {}] a))
15:22clojurebot#error{:cause "Unable to resolve symbol: b in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: b in this context", :at [clojure.lang.Ut...
15:22ambrosebs&*clojure-version*
15:22lazybot⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}
15:22ambrosebs&(let [x 1] (let [{:keys [a b] :or {a b}} {}] a))
15:22lazybot⇒ nil
15:22lodinnoncom|2: Or do second in the unquote.
15:23lodinnoncom|2: `(ns ~(second quoted-symbol))
15:24noncom|2lodin: but hen it comes:
15:24noncom|2=> (macroexpand-1 (my-ns 'a))
15:24noncom|2MY-NS, [A] sym = (quote a)
15:24noncom|2CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(D:\temp\form-init5128613490254520947.clj:1:16)
15:26lodinnoncom|2: (I think you are missing a quote before the form passed to macroexpand-1.)
15:27Bronsaambrosebs: not a bug
15:28noncom|2lodin: strange.. can you modify my example on the refheap into a working one?
15:28ambrosebsBronsa: I can believe that
15:28Bronsaambrosebs: e.g. if you write `:or {b a}` it will work on master while it used to fail
15:28ambrosebsBronsa: thought I might help out with a minimal case :)
15:28ambrosebsyea seems inadvisable
15:29Bronsaambrosebs: something changed the order of something involved in that, but it's unordered so nobody should really rely on that
15:29Bronsaambrosebs: i believe andy posted something about that a bunch of days ago
15:30lodinnoncom|2: Do you really want to pass 'a to my-ns? Or just a?
15:30ambrosebsyea. pretty unintuitive for it to break destructuring.
15:30ambrosebsor at least change it
15:30Bronsaambrosebs: kinda like the hash change in 1.6 -- broke a bunch of code that relied on order of unordered colls
15:30noncom|2lodin: i think it's just a. like it should be
15:31Bronsaambrosebs: unintuitive at first maybe but destructuring doesn't promise you the binding order of destructured locals
15:31lodinnoncom|2: Then you shouldn't use second.
15:31lodinnoncom|2: (defmacro my-ns [sym] `(ns ~sym))
15:32noncom|2lodin: but that's what i have and it causes the error..
15:32lodinnoncom|2: Because you did (my-ns 'a).
15:33noncom|2ah
15:33lodinnoncom|2: So it because (ns 'a) which is not right.
15:33ambrosebsBronsa: yes. just unfortunate I guess.
15:34lodins/because/becomes/
15:34noncom|2lodin: right!
15:34noncom|2got it finally
15:34noncom|2thank you very much!
15:34noncom|2it works
15:34lodinnoncom|2: No problem.
15:36ambrosebsBronsa: I'm mostly just sad this is a decision you need to make if you want to use {} or #{} in user-level syntax
15:36Bronsaambrosebs: yeah understandable
15:38Bronsaambrosebs: uhm I don't think this particular case has actually nothing to do with {}, probably just an accident of how destructure is implemented
15:39ambrosebsah ok.
15:39Bronsaso it might be a bug? depends if core considers binding order to be impl detail or decides to guarantee it I guess
15:41Bronsagiven that there's also non :keys/:syms destructuring and that definitely is unordered I don't think it will be considered a bug though. dunno.
15:42noncom|2lodin: but how would i act if i want to pass 'a, not a ?
15:43noncom|2would i use (second) ?
15:46ambrosebsBronsa: it's not entirely clear what the correct semantics are
15:46ambrosebsBronsa: what if a :keys variable is shadowing another variable?
15:47ambrosebsI guess either 1) disallow overlap in :keys and :or 2) consider :keys being bound outside :or
15:48kwladykaI have error Use of undefined constant STDIN - assumed 'STDIN' during Artisan::call('migrate'); and Artisan::call('db:seed');
15:48kwladykabut only on specyfic server
15:48kwladykaoh not this channel, sorry
15:48ambrosebsalso the case where (let [a 1 {:keys [a] :or {a a}} ...]) is unclear
15:50lodinnoncom|2: `(ns ~(second quoted-sym))
15:50Bronsaambrosebs: uh, righ
15:50Bronsaright
16:05rombocua(take 100 (iterate inc 1))
16:06rombocuajoin #javascript
16:12iamjarvodoes clojure allow -> in the method names?
16:13iamjarvotrying to figure out if the -> does something special or part of the string
16:13oddcullylike in map->Person?
16:14nuwanda_iamjarvo: it's part of the name
16:14iamjarvonuwanda_ thank you
16:45nyomasztoI get this message when I'm trying to install lein: http://pastebin.com/raw.php?i=JNH1v1Nb
16:49oddcullynyomaszto: is it possible that you are behind a firewall?
16:50nyomasztohow do I know?
16:50TimMcnyomaszto: What happens if you visit that URL in your browser?
16:51nyomasztoTimMc: nothing
16:51TimMcAnd are you in a country or using an internet service provider that routinely interferes with web traffic? (e.g. China)
16:52oddcullynothing as in an error? white page?
16:52nyomasztoit's loadding
16:52oddcullycould you use the means of your browser to detect, if a proxy is configured with your browser?
16:54nyomasztoit's download with wget
16:55oddcullyif you hold the file you can place it in ~/.lein/self-installs
16:56oddcullythis still can indicate, that there is some proxy etc needed to be configured, since other parts will need it configured
16:56oddcullyon the other hand it could just have been a hickup with github
16:57oddcullywell that rymes
16:57oddcullys/ry/rhy/
16:59TimMcnyomaszto: What happens if you try to install lein a second time?
17:00nyomasztoTimMc: same problem
17:00nyomasztoTimMc: can I download the file and place it on that directory?
17:00nyomasztoTimMc: without the script?
17:01TimMcI believe so.
17:01TimMchmm... that URL says .zip
17:02TimMcYou may need to rename the extension to jar
17:02oddcullydo you have a (systemwide) wgetrc, that holds a http_proxy line?
17:03nyomasztooddcully: no
17:03nyomasztooddcully: it was a mistake
17:04nyomasztooddcully: wget doesn't download the file, as well.
17:05oddcullyto bad, because there would a HTTP_CLIENT var that you could set to wget -O
17:10nyomasztoAmazonS3 server is forbidden for my ip
17:11oddcullybut your browser worked, right?
17:11oddcullythen move the file to ~/.lein/self-installs/leiningen-2.5.1-standalone.jar
17:12nyomasztothen?
17:12oddcullythen do a `lein repl` and this should download some clojars/maven stuff
17:12nyomasztooddcully: it works
17:13nyomasztothanks for your time
17:13oddcullyyw
17:14nyomasztowhat is this 'nrepl://127.0.0.1:38425'?
17:16oddcullythis is the uri you can connect your e.g. editor to
17:16nyomasztocould you suggest a reference or a book or whatever
17:17oddcullyi found this site ok to start: http://www.braveclojure.com/
17:17oddcullyymmv
17:18nyomasztoI'm a python programmer
17:19nyomasztoand I'm very like to learn something new
17:42snrmwgi want to create (nested) xml and i woulk like to stream the result. any idea how i can do that in clojure?
17:46snrmwgi want to create (nested) xml and i woulk like to stream the result. any idea how i can do that in clojure? i can find a lot about parsing a xml stream, but how can i create one?
18:23profilwhy doesnt this work?
18:23profil,(apply assoc-in [[0 0] [0 0]] [[0 0] 1, [1 1] 1])
18:23clojurebot#error{:cause "Wrong number of args (5) passed to: core/assoc-in", :via [{:type clojure.lang.ArityException, :message "Wrong number of args (5) passed to: core/assoc-in", :at [clojure.lang.AFn throwArity "AFn.java" 429]}], :trace [[clojure.lang.AFn throwArity "AFn.java" 429] [clojure.lang.AFn invoke "AFn.java" 48] [clojure.lang.AFn applyToHelper "AFn.java" 171] [clojure.lang.AFn applyTo "AFn.java"...
18:24profil,(apply assoc-in [[0 0] [0 0]] [[0 0] 1])
18:24clojurebot[[1 0] [0 0]]
18:24devnarrdem: you computing?
18:24devnwhilst in flight?
18:27TimMcprofil: Because assoc-in only does one assoc operation.
18:27TimMc,(doc assoc-in)
18:27clojurebot"([m [k & ks] v]); Associates a value in a nested associative structure, where ks is a sequence of keys and v is the new value and returns a new nested structure. If any levels do not exist, hash-maps will be created."
18:27TimMc,(doc assoc)
18:27clojurebot"([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."
18:28profiloh
18:28TimMcprofil: It doesn't allow you to do a bunch "at once" like assoc does.
18:28profilwhy not :( hmm, and how do I solve it
18:29TimMc(Hmm... "only does one assoc operation" is misleading, because it only does one *path* and that may involve multiple assocs.)
18:29TimMcprofil: Reduce over your list of key-paths and values.
18:31TimMc,(reduce (fn [m [ks v]] (assoc-in m ks v)) [[0 0] [0 0]] [[[0 0] 1], [[1 1] 1]])
18:31clojurebot[[1 0] [0 1]]
18:32profilTimMc: yeah I like that, thanks man
18:33TimMcprofil: That's essentially what assoc with multiple key/value pairs does anyhow, just more efficiently: https://github.com/clojure/clojure/blob/clojure-1.6.0/src/clj/clojure/core.clj#L177
18:35profilTimMc: how is it more efficiently?
18:51TimMcprofil: reduce has to call assoc-in each time in the example I gave you -- if you implemented the if/recur logic yourself like assoc does, you'd save those fn calls.
18:51TimMcI don't think it's a major performance difference, though. If it mattered, you could benchmark it and see.
18:52profilgoing from [[0 0] 1 [1 1] 1] to [[[0 0] 1] [[1 1] 1]] makes it even longer, so I am thinking about recur instead of reduce
19:02TimMcprofil: No, that's not a big or (possibly) even a real difference.
19:02TimMcDon't try to optimize perf on this unless or until it is noticeably slow.
19:03profilno I am talking about readability, the reduce is getting large and hard to understand
19:37justin_smithhow could a loop that traverses a sequence in order be more concise than the equivalent reduce? multiple accumulators?
20:23TimMcprofil: It depends on how you're going to use this. Sure, [[[0 0] 1] [[1 1] 1]] is hard to read, but if you only see one keys/value pair at a time, it's not bad.
20:23TimMc(in the actual code)
21:37jefelantemight anyone be able to point me towards a github project that utilizes event sourcing? i'm getting jammed up in between simple tutorial and real program
22:12TimMcjefelante: I feel like maybe clojars uses it?
22:41justin_smithwould it be a stretch to call datomic a sort of event sourcing?
22:53dunderprotoHi all, I just got a chance to read on Hiccup and thought it was very powerful. Only, I have a question -- how does one incorporate JavaScript into a clojure web app?
22:53dunderprotoI have heard of clojurescript -- is that what I'm looking for? I don't need the entire web app to compile to javascript, only the client part of the web app
22:54justin_smithdunderproto: you have a few options. You can write regular javascript and supply it as a resource, or you can compile clojurescript to js.
22:54justin_smithdunderproto: the normal way to use clojurescript is only compile the client part of the app to js
22:54justin_smithbut clj and cljs are compatible enough that they can share some code as well.
22:55dunderprotojustin_smith: the rest of the app can then be in regular clojure, correct?
22:55justin_smithexactly
22:55dunderprotoThat helps a lot. Thanks very much. I guess I will read up on clojurescript
22:55justin_smithyou can generate a mixed clojure / clojurescript project using leningen
22:57justin_smithfor example lein new mies
22:57justin_smithhttps://github.com/swannodette/mies
22:59dunderprotothanks! I will check it out
23:00TimMcdunderproto: By the way, be careful with hiccup -- it's really, really easy to accidentally render user data as HTML. You might look at ato's fork for a more secure version.
23:05dunderprotoTimMc: Thanks for the heads up
23:05dunderprotoI will check that out
23:26sobelTimMc: could you nutshell that risk for me? does hiccup destructure for the caller?
23:32justin_smithsobel: it doesn't protect from injection of client data into the html
23:43sobeli'm not following the problem. client data that would go into the stream as data becomes markup?
23:44justin_smithsobel: right. And this is a security problem.
23:45justin_smitheg. if they insert js that loads something from a domain they control.
23:45justin_smithbecause given a db, data from one client could be rendered into another client's page (think access logs or comments pages)
23:46justin_smithand via this, a client can access another client's data
23:46justin_smithor direct them to a phishing site
23:46justin_smithor whatever
23:48sobelhow does misrendered markup turn into cross-session contamination?
23:52sobelmaybe there's some practice i don't do that is assumed because most people do.
23:53justin_smithsobel: imagine you have a commenting system, for example
23:53sobelah gotcha
23:54justin_smithwhat TimMc is saying is that hiccup doesn't really prevent data from the user from being interpreted as markup
23:55nuwanda_justin_smith: to be fair, it doesn't do it by default, but it provides the functionality for it
23:55justin_smithnuwanda_: good to know, I wasn't aware of the details so I was just interpreting what TimMc said
23:56sobelhiccup.util/escape-html is apparently the secret sauce