2014-05-01
| 00:08 | amalloy | i remember lein-xml. that was a good plugin |
| 00:13 | livingston | amalloy: what did it do? (I've never seriously use lein) |
| 00:13 | amalloy | livingston: it was an april fool's joke |
| 00:14 | amalloy | it did some kind of conversion between project.clj and pom.xml |
| 00:14 | livingston | ah |
| 00:14 | amalloy | i think it let you specify project.clj in an xml format that looked like pom.xml |
| 00:15 | livingston | I kinda get why people hate the xml, but it's really not that bad once you've used it even a little. |
| 00:15 | amalloy | s/xml/parens is the more usual thing to hear in here |
| 00:15 | livingston | if I had to tinker with it daily it would probably drive me nuts, but honestly you mostly just forget about it. maybe come drop in a resource from time to time. |
| 00:17 | livingston | I mean yeah the sexperssions are easier and you don't have to know what tag to use to close etc. blah blah but half the time in a big config file like that you end up notating ;end foo section anyway |
| 00:19 | amalloy | i've never written ;end foo to denote a sexpr section in my life |
| 00:19 | amalloy | maybe when i'd been using clojure for a week |
| 00:19 | livingston | oh no not in code |
| 00:20 | amalloy | anyway, i don't know how i wound up involved in a "you defending xml from me" conversation, since i never said anything bad about xml |
| 00:20 | livingston | I meant in some big ungodly configuration file or something where the blocking may not be so obvious or scroll off the screen. in code that's definitely bad code. |
| 00:20 | livingston | lol |
| 00:20 | amalloy | right. i was saying i've never done that |
| 00:20 | amalloy | why would i have such an ungodly config file? |
| 00:21 | livingston | I don't know, if you shove everything I have in my most complex pom into a project file I bet it would get somewhat unruly? maybe not |
| 00:22 | amalloy | i'm sure it would |
| 00:22 | amalloy | but that's one reason people like leiningen. project.clj doesn't have to have all that mess that's in pom.xml |
| 00:27 | livingston | ok, time to go. thanks for talking everyone. goodnight. |
| 00:32 | yuri_niyazov | Hi guys. I have a question |
| 00:32 | yuri_niyazov | Consider this form: (doseq [:let [a 1] b '(1 2 3)] (println b)) |
| 00:32 | yuri_niyazov | versus this one: (for [:let [a 1] b '(1 2 3)] (println b)) |
| 00:33 | yuri_niyazov | The first one compiles and runs fine. The second one breaks. |
| 00:33 | yuri_niyazov | Is that known and expected behavior, or is it a bug? |
| 00:33 | Frozenlock | second one is lazy |
| 00:33 | yuri_niyazov | No, the second one is invalid. |
| 00:34 | danoyoung | IllegalStateException Can't pop empty vector clojure.lang.PersistentVector.pop (PersistentVector.java:380) |
| 00:35 | Frozenlock | Yeah that too, what's up with this syntax? |
| 00:35 | yuri_niyazov | :let, :when and :while are modifiers that you can put inside doseq and for |
| 00:35 | yuri_niyazov | http://clojuredocs.org/clojure_core/clojure.core/for |
| 00:36 | Frozenlock | I know that, but they're usually used after the binding |
| 00:36 | Frozenlock | like this (for [b '(1 2 3) :let [a 1]] (println b)) |
| 00:36 | yuri_niyazov | Yea, I am aware of that too. |
| 00:37 | yuri_niyazov | However, it is certainly usual that the first item in that form is a binding for a seq rather than a modifier |
| 00:37 | yuri_niyazov | but it is not, strictly speaking, incorrect. |
| 00:37 | yuri_niyazov | Because it is supported in doseq |
| 00:37 | Frozenlock | Ehh I don't know about that. My repl is chocking when I try your form. |
| 00:37 | yuri_niyazov | for doseq? |
| 00:37 | Frozenlock | no, for `for' |
| 00:37 | yuri_niyazov | yes |
| 00:37 | yuri_niyazov | That's exactly my point |
| 00:37 | yuri_niyazov | It chokes for me to |
| 00:37 | yuri_niyazov | too |
| 00:38 | yuri_niyazov | But it doesn't choke on doseq |
| 00:38 | Frozenlock | Ok, so your point is that this form should work for `for' too? |
| 00:38 | Frozenlock | Perhaps... fill a bug on Jira :-p |
| 00:38 | yuri_niyazov | Happy to do that. Was just wondering if this is known |
| 00:39 | Frozenlock | It's frankly the first time ever I see someone writing those this way |
| 00:40 | yuri_niyazov | it's shorthand for (let [a 1] (for [b '(1 2 3] ...)) |
| 00:40 | Frozenlock | And it's probably because if you use `let' in a loop, it's to use something from the binding, like this (doseq [b '(1 2 3) :let [a b]] (println a)) |
| 00:40 | yuri_niyazov | it obviates the need for one level of nesting |
| 00:40 | Frozenlock | Sure, I'm aware of that. But you're writing it in reverse :-p |
| 00:41 | Frozenlock | ,(doseq [b '(1 2 3) :let [a b]] (println a)) |
| 00:41 | clojurebot | 1\n2\n3\n |
| 00:41 | Frozenlock | ,(doseq [:let [a b] b '(1 2 3)] (println a)) |
| 00:41 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 00:41 | yuri_niyazov | the :let form isn't required to use something from a binding |
| 00:42 | yuri_niyazov | it can be an arbitrary function call to anywhere else |
| 00:42 | Frozenlock | Correct. |
| 00:43 | beamso | moving the :let after b '(1 2 3) worked for me. |
| 00:43 | Frozenlock | beamso: Yeah, that's how it's usually used. |
| 00:44 | beamso | i couldn't remember seeing it before |
| 00:44 | Frozenlock | :let ? |
| 00:44 | yuri_niyazov | Correct. Except that the :let after b '(1 2 3) rebinds it on every execution of the loop |
| 00:44 | yuri_niyazov | so, if [:let a (expensive-fn-call)] then that's wasteful. |
| 00:45 | yuri_niyazov | I *understand* that I can move it out of the for form, which is what I am doing at the moment |
| 00:46 | beamso | http://clojuredocs.org/clojure_core/clojure.core/for mentions that it's illegal for for to start with :let |
| 00:46 | Frozenlock | beamso: What's surprising is that it isn't for `doseq' |
| 00:46 | Frozenlock | amalloy: need an expert here. |
| 00:48 | amalloy | i've never understood why it doesn't work with 'for. some implementation detail, i imagined, since i don't see a technical reason it couldn't |
| 01:45 | muhuk | Is there a function in core, that assigns test's (non-nil) result in a while? while-let like when-let. |
| 01:47 | muhuk | I don't have a collection to start with, just a function. Would the idiomatic way be (repeatedly f) ? |
| 01:54 | dbasch | muhuk: it sounds like you could do it with a regular loop. What does your function do? |
| 01:56 | TravisD | Ah, are there any tricks for dealing with laziness and dynamic bindings? |
| 01:57 | muhuk | dbasch: pops something from a queue-like object, returns nil if it's empty. I need to repeatedly call this function each time and process all items. It is an input queue. |
| 01:59 | dbasch | (loop [something (pop queue)] |
| 01:59 | dbasch | (when something (do whatever (recur (pop queue)))) |
| 02:00 | TravisD | Does anyone have a common workaround for this type of problem? |
| 02:00 | TravisD | ,(def ^:dynamic x 0) (binding [x 1] (lazy-seq [x])) |
| 02:00 | clojurebot | #'sandbox/x |
| 02:01 | TravisD | er |
| 02:01 | muhuk | dbasch: thanks, I was hoping to avoid that. But I couldn't come up with anything better either. |
| 02:01 | muhuk | I was hoping the seq returned by (repeatedly f) to terminate when f returns nil. |
| 02:03 | TravisD | but yeah, realizing a lazy-seq created inside a binding form outside of the binding form will not reflect the bindings. Do laziness and dynamic binding just not play well together? |
| 02:04 | muhuk | TravisD: there should be another way to do XXX without combining binding/lazy-seq. If we knew XXX... |
| 02:04 | dbasch | muhuk: you could do (take-while (complement nil?) (repeatedly f)) |
| 02:04 | muhuk | dbasch: neat. But I'll go with your 1st suggestion. There's & body. |
| 02:05 | TravisD | muhuk: It is true that I'm working on another problem, but I asked the question because I am curious |
| 02:06 | muhuk | TravisD: it's cool. I just don't think there's a way out there. |
| 02:08 | TravisD | that's unfortunate :( |
| 02:18 | TravisD | looks like you can use bound-fn to reinstall the bindings present when some function was called |
| 02:34 | `tlm | What would be a good name for a higher order function like this? |
| 02:35 | `tlm | (fn [f coll] (if (< (count coll) 2) [] (map f coll (rest coll)))) |
| 02:35 | `tlm | (It returns a collection of results from calling f on every two adjacent elements of coll.) |
| 02:35 | amalloy | `tim: that's just (map f coll (rest coll)). there's no need for the if clause |
| 02:36 | amalloy | also, (< (count coll) 2) is really bad: consider how it works when given an infinite sequence. instead, you want (not (next coll)) |
| 02:37 | `tlm | amalloy: Ah, so the idiom is short enough there's no need for a function... |
| 02:37 | `tlm | Good point! |
| 02:38 | amalloy | `tim: i'd also often do it differently, depending on what f is: (for [[a b] (partition 2 1 coll)] (...use a and b...)) is more my style, unless there's a ready-made f |
| 02:40 | `tlm | Do you happen to know what this would be called in other Lisps, where (cdr '()) throws an error? |
| 02:41 | amalloy | are there a lot of such lisps? most of them return '() afaik |
| 02:42 | `tlm | Maybe it's just Scheme. |
| 03:06 | cpetzold | Does anyone know of any public web api’s that return edn? |
| 03:15 | Raynes | cpetzold: Refheap's API. |
| 03:15 | cpetzold | Raynes: oh cool, thanks! |
| 03:16 | Raynes | https://github.com/Raynes/innuendo Is a client to that API that uses edn |
| 03:18 | cpetzold | hmm, application/clojure |
| 03:20 | cpetzold | Raynes: so if I’m reading this right.. https://www.refheap.com/api/paste/83935?return=clojure should return me a paste in edn? |
| 03:21 | cpetzold | oh, looks like they changed it to application/edn |
| 03:21 | cpetzold | https://www.refheap.com/api/paste/83935?return=edn works |
| 03:22 | amalloy | heh. "they" |
| 03:22 | Raynes | amalloy: Shhhhhhh stealth |
| 03:22 | amalloy | cpetzold: for context, refheap is Raynes's thing. he's secretly trying to gain more users |
| 03:23 | cpetzold | :D |
| 03:23 | cpetzold | i see |
| 03:23 | cpetzold | Well you need to update innuendo then ;) |
| 03:24 | cpetzold | By the way, here’s what your api looks like using the really stealthy project I’m working on: https://cloudup.com/c7pOt5pXmWE |
| 03:24 | TEttinger | I use refheap to generate copious amounts of fake words https://www.refheap.com/16011 |
| 03:25 | amalloy | is your project google chrome, cpetzold? |
| 03:25 | amalloy | (i kid, i kid. a chrome extension to pretty-print edn is pretty sweet) |
| 03:25 | cpetzold | :P |
| 03:26 | amalloy | those are surprisingly pronounceable, TEttinger |
| 03:27 | amalloy | though i confess i'd stumble over rhourtauspotron |
| 03:27 | TEttinger | the fake star wars names https://www.refheap.com/83943 are even harder to tell from the real ones |
| 03:29 | TEttinger | I had help on the first one, which is meant to be fake ancient greek |
| 03:29 | amalloy | TEttinger: tbh it sounded like a mix between greek and cthulu |
| 03:29 | amalloy | more like greek names for chemicals than people, though |
| 03:29 | TEttinger | considering cthonic is the adjective for earth gods in greek haha |
| 03:30 | gko | Any user of cider ? It seems to make Emacs hanging (high CPU load, only solution is to kill Emacs) from time to time on Windows... |
| 03:31 | TEttinger | err chthonic https://en.wikipedia.org/wiki/Chthonic |
| 03:32 | dbasch | some of those words are real |
| 03:33 | TEttinger | dbasch, that was the hope yes |
| 03:34 | dbasch | anyway, neat |
| 03:34 | TEttinger | thanks, it's a great use for a one-liner |
| 03:43 | jack_rabbit | Hey, there. Is it appropriate to ask questions about Korma, the clojure sql library, here? |
| 03:43 | Frozenlock | sure |
| 03:44 | jack_rabbit | I've got a question regarding relationships between entities. I have a 'user' entity which "has-many" 'posts', but when I (select users (with posts)), I get "IllegalArgumentException No value supplied for key" |
| 03:47 | jack_rabbit | It seems when I have an odd number of users, the query doesn't work. The returned structure is a map, but each key is a 'user' and its value is also a 'user'. |
| 03:47 | jack_rabbit | Seems like it should be a list rather than a map, but I'm not sure quite what I'm doing wrong. |
| 03:52 | dimsuz | hello! I do this: (map :a [{:a 1} {:a 2} {:a 1} {:a 2}]) => (1 2 1 2), is there a quick way to make returned seq uniq? i.e. (1 2) |
| 03:52 | dimsuz | i mean maybe give some clever function to map rather than :a |
| 03:52 | dimsuz | i smell 'set' here, but dunno where to put it... |
| 03:53 | dbasch | ,(distinct (map :a [{:a 1} {:a 2} {:a 1} {:a 2}]) ) |
| 03:53 | clojurebot | (1 2) |
| 03:53 | dimsuz | oh, ok, so I'll have to apply a function to the result. just thought maybe i can get away with just 'map' :) |
| 03:54 | Raynes | You could reduce into a set. |
| 03:54 | dimsuz | i also know i can do into #{} |
| 03:54 | dimsuz | I see, thanks! |
| 03:55 | Raynes | (reduce #(conj % (:a %2)) #{} [{:a 1} {:a 2} {:a 1} {:a 2}]) |
| 03:56 | Raynes | But you don't really lose anything by doing into after a map. |
| 03:56 | Raynes | Map is lazy. |
| 03:56 | dimsuz | or shorter: (into #{} (map :a [{:a 1} {:a 2} {:a 1} {:a 2}])) |
| 03:56 | Raynes | What I was just saying, yes. |
| 03:57 | dimsuz | ok :) i just thought maybe there's some syntactic sugar I didn't know about, decided to ask :) |
| 03:57 | dbasch | but into is not lazy, distinct is |
| 03:57 | dimsuz | oh, right. |
| 03:58 | Raynes | Which is extremely unlikely to matter in this case. |
| 03:58 | Raynes | Depending on how representative the input set is :P |
| 03:58 | dbasch | sure, but “be lazy when possible” is good practice, especially when you don’t lose clarity :) |
| 03:59 | Raynes | Sets exist for a reason. |
| 03:59 | Raynes | If you're faking set behavior, you often should just use a set. |
| 03:59 | amalloy | stop the presses! new headline: "Laziness doesn't matter", says Raynes |
| 03:59 | Raynes | :p |
| 03:59 | Raynes | Anyways, it really just depends on the greater goal. |
| 04:00 | Raynes | But OP mentioned sets specifically. |
| 04:00 | Raynes | So I was kinda latching on to sets. |
| 04:00 | dimsuz | usecase is i receive some data from DB and need to distinctify it. but now that you said it I see that I can ask DB to do that for me instead |
| 04:01 | Raynes | What database? :o |
| 04:01 | dbasch | select distinct :P |
| 04:01 | Raynes | I don't know of many dbs that don't do that for you if you ask nicely enough. |
| 04:12 | dimsuz | playing with nedb (nosql-like for nodejs) - toying with some clojurescript based project in node-webkit env :) |
| 04:12 | dimsuz | i didn't check but i guess it must've something like select distinct :) |
| 04:17 | deobalds | Hey folks. Did anyone else experience breakage with cider/cider-nrepl in the past month or so? I just upgraded prelude and cider, and now M-. tells me "Can't find nREPL middleware providing op info. Please, install cider-nrepl and restart cider." |
| 04:17 | deobalds | The hints for setting up cider-nrepl aren't very helpful, since they're all lein-focused. We don't use lein to run our app or connect to it with a repl. |
| 04:20 | dimsuz | guys and having [1 2 3 4 5], what is the best way to create smth like [{:a 1} {:a 2} {:a 3}]. I would do this: (map #(assoc :a %) [1 2 3]) |
| 04:20 | dimsuz | is this a right way? :) |
| 04:25 | jack_rabbit | Well, seeing as I can't seem to navigate this korma thing, and the documentation is terribly minimal, and it doesn't work in an intuitive way, does anyone have a suggestion for a SQL library for clojure? |
| 04:25 | beamso | i use clojure/java.jdbc |
| 04:26 | deobalds | jack_rabbit: We're using java.jdbc directly as well. Though one of our teams tried honey on top of that and liked it. |
| 04:27 | jack_rabbit | I saw honey. I might give that a shot. I'd like some sort of abstraction on top of the sql. The idea of writing queries in string form isn't appealing. |
| 04:28 | beamso | you don't have to write all your queries in string form using clojure/java.jdbc |
| 04:29 | ucb | dimsuz: try a combination of interleave and constantly |
| 04:29 | ucb | ,(doc constantly) |
| 04:29 | clojurebot | "([x]); Returns a function that takes any number of arguments and returns x." |
| 04:29 | ucb | sorry, repeat |
| 04:29 | ucb | ,(doc repeat) |
| 04:29 | clojurebot | "([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs." |
| 04:29 | ucb | ,(doc interleave) |
| 04:29 | clojurebot | "([] [c1] [c1 c2] [c1 c2 & colls]); Returns a lazy seq of the first item in each coll, then the second etc." |
| 04:30 | ucb | ,(interleave [1 2 3] (repeat :a)) |
| 04:30 | clojurebot | (1 :a 2 :a 3 ...) |
| 04:30 | ucb | then add partition |
| 04:30 | ucb | ,(doc partition) |
| 04:30 | clojurebot | "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items." |
| 04:30 | ucb | and take it from there dimsuz |
| 04:30 | jack_rabbit | beamso, yeah, I'm looking through the API now. |
| 04:33 | dbasch | ,(take 5 (map hash-map (repeat :a) (range))) |
| 04:33 | clojurebot | ({:a 0} {:a 1} {:a 2} {:a 3} {:a 4}) |
| 04:34 | dbasch | ,(map hash-map (repeat :a) (range 1 5)) |
| 04:34 | clojurebot | ({:a 1} {:a 2} {:a 3} {:a 4}) |
| 04:46 | deobalds | So, is anyone here using cider-0.7.0 and cider-nrepl-0.7.0-SNAPSHOT? |
| 04:50 | ucb | deobalds: I am |
| 04:50 | deobalds | ucb: No issues? Do you ever use it without lein? |
| 04:50 | ucb | deobalds: without lein? I usually cider-jack-in (I assume that uses lein behind the scenes) |
| 04:50 | ucb | deobalds: so far no issues |
| 04:51 | deobalds | ucb: It does. We always connect cider to a running repl inside an exernal process on our projects, so lein isn't involved. Makes it hard to use stuff that assumes lein will always be there. :( |
| 04:52 | ucb | deobalds: I see! I've used it to connect to long running processes without much fuzz, though not that much to be fair |
| 04:52 | deobalds | ucb: Good to know, thanks. Maybe we've got something else misconfigured. |
| 04:52 | CookedGryphon | deobalds: I'm working on a pull request that will let you customise the command for cider-jack-in completely |
| 04:52 | CookedGryphon | also per project |
| 04:53 | CookedGryphon | but afaik not much assumes lein will be there, if you just use plain cider to connect and not jack in |
| 04:53 | deobalds | CookedGryphon: Not sure what you mean? 0.6.0 works perfectly for us; we just use `cider` rather than `cider-jack-in`. |
| 04:54 | deobalds | CookedGryphon: Cider 0.7.0 works. It can't find cider-nrepl (or some part of it) when I try to do things like navigate the code using M-. |
| 04:54 | deobalds | CookedGryphon: All the cider-nrepl intallation instructions involve plugins in lein profiles.clj, dev-dependencies, or some other leiningen malarkey. |
| 04:56 | supersym | could someone please enlighten me how I implement this interface exactly, I can't seem to get it right |
| 04:56 | supersym | https://github.com/asciidoctor/asciidoctorj/blob/master/src/main/java/org/asciidoctor/Asciidoctor.java |
| 04:56 | deobalds | CookedGryphon: Just getting cider-nrepl 0.7.0 on the classpath doesn't seem to be enough for cider to find it. |
| 05:04 | CookedGryphon | fair enough, I'm not sure then |
| 05:04 | dimsuz | ucb: thanks! |
| 05:07 | supersym | ah... import-static from contrib ... that might be it ;_) |
| 05:20 | CookedGryphon | Can anyone tell me why clojurescript has its own separate :source-paths? I've got a project with different profiles for each different platform on which it builds |
| 05:20 | CookedGryphon | and clojurescript sticks out a bit as it's got a custom :builds thing with a separate :source-paths which can't inherit from the common one |
| 05:24 | muhuk | Promises are not like agents in the sense that they are only delivered on transaction success, right? |
| 05:26 | muhuk | So, I should use agent & await to leak values outside of transactions. |
| 05:31 | muhuk | await blocks :/ |
| 05:32 | muhuk | I got it to work with the (promise), but if the transaction fails, it will still be delivered. |
| 05:33 | muhuk | The code is like this BTW: (swap! a (fn [...] (deliver p ...) ...) (do-something @p) |
| 05:37 | muhuk | Another solution is to throw another atom at the problem: http://stackoverflow.com/a/22414839/42188 |
| 06:01 | CookedGryphon | is cljx hard wired to only deal with cljs and clj, or can you define other output targets? |
| 06:01 | CookedGryphon | for example jvm6/jvm7 versions |
| 06:01 | CookedGryphon | or jvm vs android implementations |
| 06:04 | ssideris | CookedGryphon: as far as I can tell, it will do other targets too |
| 06:24 | grimmulfr | Been learning Clojure for a few days. Made this with that knowledge: https://www.refheap.com/84169 (I tried using everything just to see how stuff works, we have JQuery, DOM manipulation, strings, custom functions, the works). ANy thoughts, suggestions and critique? :D |
| 06:25 | devurandom | Hello! |
| 06:26 | devurandom | I need help in translating a JavaScript program to ClojureScript (the code is at https://gist.github.com/anonymous/ac60b1f22c7de9aec355 if that helps you understand): |
| 06:27 | devurandom | In JS, I created a 2d array of nested maps. The inner maps carry references to the outer maps, to ease traversal. I also need a way to update these maps. |
| 06:27 | devurandom | How do I do this best in Clojure(Script)? |
| 06:29 | devurandom | I.e. how do I easily keep references to the outer map in the inner map, in a way that works with immutability? And how would you recommend to update or add keys to the maps, without rebuilding everything? |
| 06:30 | muhuk | devurandom: if I understand you correctly, I don't think you can easily build your references as such. |
| 06:30 | CookedGryphon | devurandom: What's the basic problem? Better to start from that and think how to explain it in clojure rather than thinking about how to do your javascript implementation in clojure |
| 06:31 | CookedGryphon | because the javascript implementation was based on assumptions that might not be true any more, you might not need these back references for the clojure implementation for example |
| 06:33 | muhuk | devurandom: even if you re-write your code in clojurescript, you'll still be using whatever Kinetic.Layer() returns, so no immutability there. |
| 06:34 | devurandom | I need to represent a 2d grid. Each cell can contain data and stuff that is necessary for drawing it (I used KineticJS, which iirc uses HTML5 Canvas, before). I need to draw certain parts differently, based on the values of the cell's data. I also need onmouseover callbacks and such, to implement the UI - so onclick or onmouseover I need to find the correct cell and change it, update other parts of the program, etc. |
| 06:36 | muhuk | devurandom: if you want to store your data in an immutable container, I'd start by removing edge.parcel |
| 06:36 | devurandom | muhuk: Yeah, the drawing is not immutable, I know. My problem was that in Clojure everything is immutable, so I cannot do this.street = true anymore, as I did before. It seems like the whole way of dealing with the data (traversing, having functions that take objects that are not an atom, ...) is different now. |
| 06:36 | muhuk | devurandom: and then, I'd use a different index for quick edge->parcel lookups |
| 06:36 | devurandom | "different index"? |
| 06:37 | muhuk | devurandom: think of it as a reverse map |
| 06:37 | muhuk | devurandom: (def parcels [{:edges [...]} {:edges [...]}]) |
| 06:38 | muhuk | devurandom: (def edge->parcel {:edge-id parcel-value ...}) |
| 06:38 | muhuk | devurandom: does that make sense? |
| 06:38 | muhuk | devurandom: you can build the latter based on the former. |
| 06:38 | devurandom | You mean like storing the path "x -> y -> horiz/vert" and looking up the parcel that way? |
| 06:39 | devurandom | Or create a unique ID for each edge and parcel and then map only those? |
| 06:39 | muhuk | devurandom: in that case: (def edge->parcel {[x y :horizonal] p1 [x1 y1 :vertical] p2 ...}) |
| 06:40 | l3dx | how would I "alias" a static java value? ie. KeyEvent.VK_LEFT without using contrib static-import ? |
| 06:40 | muhuk | devurandom: I'm just giving you some ideas, you know the requirements of your code better than me. |
| 06:41 | muhuk | l3dx: does (def x KeyEvent/VK_LEFT) work? |
| 06:42 | muhuk | devurandom: also, if you are storing your state in an atom, you'd probably want to store both parcels and the index in the same atom, so that they are in sync. And you probably want functions that modify this data structure to make changes in both places. |
| 06:44 | l3dx | muhuk: yes |
| 06:44 | l3dx | thanks |
| 06:44 | l3dx | I was trying to do it with :require :as |
| 06:45 | muhuk | l3dx: yw |
| 06:47 | devurandom | muhuk: Ok, so you would address the parcels/edges via their path in the datastructure (instead of storing references as in JS)? |
| 06:48 | muhuk | devurandom: yes. |
| 06:49 | muhuk | devurandom: reference in clojurescript means, AFAIK, a javascript object or an atom. The former, as you know, is mutable. Instead of dealing with many atoms, I'd start with a single top-level atom and see how far that takes me. |
| 06:50 | devurandom | And is there maybe a better datastructure than the 2d array, that I used in JS? I will need to find parcels based on their x/y location, and I will need to iterate everything to e.g. draw it. I choose the 2d array in JS, because it seemed like the most efficient way to do the x/y lookup. |
| 06:50 | muhuk | devurandom: tough question. |
| 06:51 | muhuk | devurandom: 1st answer that comes to my mind is a map with keys of [x y] |
| 06:51 | muhuk | devurandom: but it wouldn't come close to the raw js array |
| 06:51 | devurandom | If [x y] can be a key in a map - would that be an efficient way to store them? Instead of in a list/vector, in a map with [x y] indices? |
| 06:51 | devurandom | Haha, same idea. :) |
| 06:51 | hennry | hello can any body tell me where we define the properties file filename.properties in luminus web application |
| 06:52 | muhuk | devurandom: my suggestion is to try a map with composite keys ([x y) and a nested map |
| 06:52 | muhuk | devurandom: see how they perform |
| 06:52 | devurandom | Regarding the single top-level atom: And then you update the top-level atom using something like (swap! the-atom assoc-in [the path] ...)? |
| 06:52 | muhuk | devurandom: perhaps the fastest is a vector where you calculate the index as (+ x (* y w)) |
| 06:53 | devurandom | muhuk: nested map is {0 {0 ... 1 ...} 1 {...}}? |
| 06:53 | muhuk | devurandom: yes, top level atom idea, I'm pretty confident you should start with that. |
| 06:53 | muhuk | devurandom: yes. |
| 06:53 | hennry | hello can any body tell me where we define the properties file filename.properties in luminus web application |
| 06:53 | devurandom | hennry: Your question came through the last time already :) |
| 06:54 | hennry | ok |
| 06:55 | devurandom | muhuk: Thanks! |
| 06:55 | muhuk | devurandom: yw |
| 07:51 | hennry | how to get a single value of map from load-file |
| 07:52 | TEttinger | hennry: ##(doc read-string) |
| 07:52 | lazybot | ⇒ "([s]); Reads one object from the string s" |
| 07:53 | TEttinger | not sure about load-file |
| 07:54 | hennry | <TEttinger>i am getting the full map but i need a single value |
| 07:55 | TEttinger | do you know the key of that value? |
| 07:55 | hennry | yes |
| 07:55 | lvh | hennry: Can you get the full map and then extract the value? |
| 07:55 | TEttinger | ,(get {"whatever-key" :value} "whatever-key") |
| 07:55 | clojurebot | :value |
| 07:55 | hennry | yes but not get succes |
| 07:56 | TEttinger | ,(get {"whatever-key" :value} "whatever-key-not-this" :default-get) |
| 07:56 | clojurebot | :default-get |
| 07:57 | hennry | <lvh> yes but not success to extract single value |
| 07:58 | gfredericks | hennry: what goes wrong? |
| 08:00 | hennry | <gfredericks> i am extracting the single value of map from load-file but i get the whole map |
| 08:01 | hennry | is there any way to get single value |
| 08:05 | gfredericks | hennry: yes, TEttinger showed you how to do it above using the get function |
| 08:06 | hennry | thanks to all |
| 08:24 | hennry | is there way to reload the repl from the code |
| 08:28 | muhuk | hennry: you do mean reload the code from the repl? |
| 08:38 | cYmen | Is there a flag or something to make emacs indent 2 spaces after a line break instead of after the function name in a sexp? |
| 08:41 | justin_smith | cYmen: you would have to make a new mode to replace clojure-mode I think |
| 08:41 | hennry | <muhuk> no i want to reload the repl from the code my motive is to refresh the application frm the code |
| 08:41 | justin_smith | hennry: you can use :reload to force a dep reload, or :reload-all as args to require |
| 08:42 | hennry | it refresh my application |
| 08:42 | justin_smith | it will grab any changes in your clj files |
| 08:43 | justin_smith | (require '[my-app.core :as core :reload-all]) |
| 08:43 | justin_smith | there are still some tricky things (like old definitions still being around even if they are deleted in the source) but it mostly works |
| 08:51 | cYmen | justin_smith: I find that odd because I see it in a lot of code examples. |
| 08:51 | phillord | @cYmen (setq lisp-indent-offset 2) ? |
| 08:52 | cYmen | phillord: as soon as I find out how to eval that :p |
| 08:52 | phillord | oh, sorry |
| 08:52 | cYmen | not your fault that I don't know how to use my editor ;) |
| 08:52 | phillord | Alt-Shift : |
| 08:53 | phillord | or M-x customize-variable |
| 08:53 | phillord | I've been meaning to look that up for ages, because I really don't like the default when I've been using core.logic |
| 08:54 | cYmen | phillord: sweet. works. :) |
| 08:54 | cYmen | thank you! |
| 08:55 | phillord | no worries, have fun |
| 08:55 | justin_smith | cYmen: TIL, thanks |
| 08:56 | justin_smith | also, there is M-x IELM to get an elisp repl |
| 08:56 | justin_smith | or control-j to evaluate the form before point in the *scratch* buffer |
| 08:56 | cYmen | cool |
| 08:57 | justin_smith | (or C-M-x to evaluate the enclosing form) |
| 08:57 | cYmen | I wish I had a clever system to write down all these tricks. |
| 08:57 | cYmen | I tend to not find them when I need them. |
| 08:57 | justin_smith | I discovered ielm and the *scratch* bindings when I was trying to debug a poorly thought out elisp package |
| 08:58 | justin_smith | my very-bad-code led to extensive knowledge of emacs' elisp facilities as I tried to fix it / debug it |
| 09:01 | phillord | cYmen --- Org-Mode:-) |
| 09:05 | gfredericks | (defmacro errly [& body] `(binding [*out* *err*] ~@body)) |
| 09:26 | cYmen | phillord: I tried but I can't get the hang of it. |
| 09:27 | cYmen | I need a new job. All this windows and C++ is taking up space in my brain that I would rather allocate differently. :/ |
| 09:43 | jkj | cYmen: evernote |
| 09:45 | justin_smith | cYmen: if you ignore every feature of org mode other than * subgroup ** subsubgroup *** subsubsubgroup etc. and tab to expand / collapse, it is very easy to learn, and very useful for keeping track of things |
| 09:48 | AeroNotix | justin_smith: pretty much this^ |
| 09:48 | AeroNotix | I've been using just those features for ~1.5 years |
| 09:48 | AeroNotix | good thing is that you can put .org files into a github gist and share them with co-workers, too |
| 09:49 | AeroNotix | github renders them in gists, but not in actual repos, though. Weirdly. |
| 09:49 | justin_smith | [[/home/justin/clojure/][clojure]] <- for extra credit, make an occasional clickable hyperlink to a directory or file |
| 09:50 | AeroNotix | justin_smith: nice :D |
| 09:55 | justin_smith | also, something I try to remember to use more often [[/home/justin/test-uber/src/test_uber/core.clj::defn -main][-main]] |
| 09:56 | justin_smith | that links to a text search for the first instance of the specified string |
| 09:56 | justin_smith | IOW it is a clickable link to a def |
| 09:57 | AeroNotix | justin_smith: insanity! I never knew that. :D |
| 09:57 | justin_smith | see that is what makes org mode look hard - so many nice features to be found |
| 09:58 | justin_smith | but we must remind ourselves, there is an easy to remember and very easily usable subset :) |
| 09:58 | AeroNotix | for sure |
| 09:58 | AeroNotix | as with all emacs features |
| 09:58 | justin_smith | right |
| 09:59 | justin_smith | it only looks hard because you want to know what *all* the buttons do :) |
| 10:00 | AeroNotix | yupp |
| 10:09 | gfredericks | has anybody written an org-mode parser for clojure yet? |
| 10:13 | AeroNotix | best off just writing an ELisp interpreter and running the code there! |
| 10:13 | AeroNotix | :) |
| 10:15 | justin_smith | gfredericks: I started to make a two way org subset / edn translator and got stuck |
| 10:15 | justin_smith | gfredericks: a parser and an exporter would be more humble and doable, and very useful |
| 10:17 | justin_smith | I think I got stuck on how maps should be represented in org |
| 10:24 | justin_smith | perhaps maps should be :PROPERTIES: |
| 10:24 | justin_smith | but that doesn't allow collections as keys |
| 10:27 | cYmen | quickest introduction to core.async? |
| 10:33 | BobSchack | cYmen David Nolen's blogs about it are a pretty good introduction |
| 10:44 | gfredericks | justin_smith: I like the idea of clojure code that persists collections of maps to org tables :) |
| 11:18 | stompyj | bbloom: SHOTS FIRED |
| 11:18 | bbloom | stompyj: ? |
| 11:18 | stompyj | bbloom: turbopape: if you have to ask, you probably don't have large traffic |
| 11:18 | stompyj | LOVE IT |
| 11:18 | stompyj | from yesterday |
| 11:19 | bbloom | stompyj: yup, well it's true |
| 11:19 | stompyj | no, I 1000% agree |
| 11:19 | AeroNotix | link plz |
| 11:19 | stompyj | Love how direct it was |
| 11:25 | gtrak | technomancy: I got Syne working this morning, but I didn't get a chance to try git-pushing and such. Are there any gotchas? Is the project that you specify in the form handled specially in some way? |
| 11:29 | gtrak | s/Syne/Syme |
| 11:36 | rolfb | when i call `lein repl` outside of any projects on my mac, it loads clojure 1.5.1 ... how do I make it load 1.6 by default? |
| 11:36 | gtrak | I just make extra projects to play in. |
| 11:37 | gtrak | might also want to try: https://github.com/rkneufeld/lein-try |
| 11:40 | rolfb | gtrak: thanks, what i'm mostly curious about is why it's choosing 1.5.1 |
| 11:41 | rolfb | can I inspect where it's loading it from? |
| 11:42 | gtrak | I figured it'd be in the default profile, but it's not. |
| 11:44 | rolfb | gtrak: they haven't released another version of leiningen since it bumped clojure to 1.6.0 |
| 11:44 | rolfb | that's why |
| 11:44 | rolfb | :/ |
| 11:44 | gtrak | that's not 'why'.. |
| 11:45 | gtrak | that's just some kind of correlation :-) |
| 11:45 | rolfb | gtrak: leiningen includes clojure |
| 11:45 | rolfb | they've updated it in their repositoriy |
| 11:45 | rolfb | but not pushed a new version |
| 11:45 | gtrak | lein creates two processes, one for leiningen itself, another for the repl. It has to set up the classpath somehow. |
| 11:45 | rolfb | gtrak; https://github.com/technomancy/leiningen/commit/a296ff8918a581c975f49127d7e37a3f0c510d22 |
| 11:46 | gtrak | I'm guessing it defaults to adding that leiningen-standalone jar if there's no project, which contains the clojure version. |
| 11:46 | gtrak | I believe you.. I'm just saying I don't see the connection, and I'd like to :-) |
| 11:46 | gtrak | the literal, in the code, connection. |
| 11:47 | rolfb | gtrak, wdym? clojure is included in leiningen-core, current published version contains clojure 1.5.1 |
| 11:48 | stompyj | new “web benchmarks test” came out today. (or recently). Is anyone optimizing the clojure code for speed, or in general, do we just not care (I don’t ) |
| 11:48 | rolfb | gtrak: are you thinking about the exact point where it switched based on the current project.clj? |
| 11:49 | gtrak | yea |
| 11:49 | tbaldridge | dnolen_: does cljs.core.logic not include to-stream? |
| 11:49 | gtrak | rolfb: so, the repl task has 'no-project-needed' metadata on it, but it still takes a project argument. I'm guessing somewhere there's a default project map that gets merged in. |
| 11:49 | technomancy | rolfb: you can run from a git checkout of lein if you need 1.6 outside a project |
| 11:50 | rolfb | technomancy: my desire is to just open a terminal and type "lein repl" :-) |
| 11:50 | rolfb | silly, i know |
| 11:50 | gtrak | I once made a terrible mistake, that might be useful here. put a project.clj in your root home directory.. :-) |
| 11:51 | rolfb | technomancy: any reason a new version of leiningen hasn't been pushed? |
| 11:51 | rolfb | gtrak: well, that might just work :-) |
| 11:51 | technomancy | rolfb: it's not done yet https://github.com/technomancy/leiningen/issues?milestone=15&state=open |
| 11:51 | gtrak | rolfb: I didn't know that's what I'd done, but lein repl scans up parents to find a project.clj. I was getting weird stuff on 'lein install'. |
| 11:51 | rolfb | technomancy: aha, thanks :-) |
| 11:52 | gtrak | everything works as normal if you're actually in a project dir. |
| 11:53 | technomancy | hyPiRion: did you mean to add the mktemp issue to the 2.4.0 milestone? |
| 11:53 | hyPiRion | technomancy: well, I could. It's not a hard fix |
| 11:54 | hyPiRion | just want to ensure I have a windows instance running so I can confirm that it works first |
| 11:54 | technomancy | no problem; just checking it was intentional |
| 11:54 | hyPiRion | well, it's not a big deal really -- people can use the .bat file instead |
| 11:54 | hyPiRion | (Or at least that's what I've understood) |
| 11:55 | technomancy | hyPiRion: any opinions about https://github.com/technomancy/leiningen/issues/1512 ? |
| 11:56 | hyPiRion | technomancy: yeah, but I'm a bit busy now |
| 11:56 | technomancy | no worries |
| 11:57 | technomancy | rolfb: part of the reason this release has taken so long was that we were going to include https://github.com/technomancy/leiningen/issues/1388, which is really hard to get right |
| 11:57 | technomancy | but I decided to drop that from the 2.4.0 release |
| 11:57 | hyPiRion | It's good, but I feel it breaks backwards compatibility. Not sure how big issue that is for people in general. |
| 11:58 | technomancy | hyPiRion: I feel like it's probably safe in the `lein deploy` case. |
| 11:58 | technomancy | if you're manually compiling some stuff and then relying on it being present on clojars without putting it in project.clj, you're doin' it wrong |
| 11:59 | rolfb | technomancy, i'm too new at clojure to understand that issue :-) |
| 11:59 | technomancy | but the general case of jar files is less clear-cut; people could be using the jar task for non-traditional workflows |
| 12:02 | hyPiRion | technomancy: yeah, if you have intermediate compilation steps, I would assume there might be some breakage |
| 12:02 | hyPiRion | not found any examples yet though. |
| 12:03 | technomancy | intermediate compilation steps that aren't declared in :prep-tasks, yeah |
| 12:03 | hyPiRion | yeah |
| 12:05 | hyPiRion | I could see it being a problem for people with long compilation times |
| 12:05 | hyPiRion | (as there's no make-like functionality bundled with Lein) |
| 12:06 | technomancy | oh, like if there are tasks that you can't cheaply check if they need to be re-run before running? |
| 12:06 | technomancy | you can always memoize tasks, but that doesn't persist across invocations |
| 12:07 | technomancy | I feel pretty safe about making the change in deploy, because any weird deploy work flow is likely to apply to applications only and not libraries |
| 12:08 | hyPiRion | technomancy: I mean tasks where it's taking a long time to compile something, and the task isn't using date checks to check for updates in source files |
| 12:09 | hyPiRion | So they make a command to compile whatever |
| 12:09 | hyPiRion | I don't know if that's actually a problem though |
| 12:24 | llasram | Is there any way to nest test.check generation? Say generate a positive integer, then generate vectors in ranges around that integer |
| 12:25 | nullptr | yes, see gen/bind |
| 12:25 | llasram | Ah, awesome |
| 12:25 | llasram | Thanks |
| 12:25 | nullptr | something like (gen/bind gen/int #(gen/choose % (+ % 5))) |
| 12:27 | heiz | Hello! Tell me please if leiningen is able to use custom default template? |
| 12:28 | technomancy | heiz: custom default sounds like a contradiction of terms =) |
| 12:29 | justin_smith | heiz: you can define a template and use it via lein new foo |
| 12:30 | justin_smith | http://yogthos.net/blog/34-Creating+Leiningen+Templates |
| 12:31 | heiz | For example, I want lein to use compojure-app template by default. So I don't need to specify it every time. Is it possible? |
| 12:32 | technomancy | heiz: you can make an alias for ["new" "compojure-app"] if you like |
| 12:32 | technomancy | you can even call that alias "new" |
| 12:37 | gtrak | oh, man, I'm banging out 20 compojure apps a day :-) |
| 12:39 | gtrak | eclipse is what broke me, rather it broke itself too often, also archlinux (which I enjoyed otherwise) |
| 12:40 | llasram | Hmm. Property-based testing may not actually be the best way to test probabilistic data structures |
| 12:40 | bbloom | heiz: technomancy: isn't this what ~/.bash_aliases is for? |
| 12:40 | nullptr | llasram: that doesn't mean it isn't fun... |
| 12:40 | llasram | "Hey, look -- I found an example which exceeds the average expected error!" Well, yes |
| 12:41 | technomancy | bbloom: that works too. unfortunately I don't think you can have bash aliases over one word though. |
| 12:41 | bbloom | technomancy: the guy left, but the idea of changing what `lein new` does by default just seems insane to me |
| 12:41 | gtrak | thank goodness |
| 12:42 | gtrak | multi-word bash aliases, not the guy leaving. |
| 12:42 | technomancy | bbloom: eh; there is a good case for overriding built-ins |
| 12:42 | hyPiRion | llasram: Usually you'd do prop-based with confidence intervals |
| 12:42 | technomancy | like if you want `lein test` to actually run expectations or something |
| 12:42 | llasram | hyPiRion: What does that look like in test.check? |
| 12:43 | technomancy | gtrak: it's just pattern matching =) |
| 12:44 | gtrak | we'd get weird bash dsls.. ambiguous: $ r v m shoot myself |
| 12:44 | reiddraper | llasram: have you looked through the docs? |
| 12:44 | l1x | morning guys |
| 12:44 | gtrak | you just know people would use it that way. |
| 12:44 | gtrak | and make others use it |
| 12:44 | reiddraper | llasram: take a looks in the docs dir of test.check repo |
| 12:45 | technomancy | no one can make you use pattern matching against your will; it's a human rights violation |
| 12:45 | justin_smith | gtrak: I wonder if anyone has created a forth out of bash aliases treating their arg lists as stacks |
| 12:45 | hyPiRion | llasram: Instead of checking if a single data structure is broken, check multiple and test whether they are in the confidence interval or not |
| 12:45 | gtrak | justin_smith: so crazy it could possible work. |
| 12:45 | l1x | is there a better way of getting the difference between two lists than http://clojuredocs.org/clojure_core/clojure.data/diff ? |
| 12:45 | gtrak | possibly* |
| 12:46 | gtrak | justin_smith: I'm going to tweet that. |
| 12:46 | llasram | hyPiRion: By e.g. "manually" calling `gen/sample` w/in the property test to generate the set? |
| 12:46 | justin_smith | l1x: how much do you know about the lists? if they are two arbitrary lists diff is probably best, if you know more about their potential structure you can probably improve on it |
| 12:47 | l1x | it is just 2 simple flat lists with keywords like (:a :b :c) (:a :b) |
| 12:47 | llasram | hyPiRion: I literally started trying it out 10 minutes ago, so haven't really explored it yet and don't know what facilities are available |
| 12:47 | justin_smith | recently I discovered that clojure.data/diff combined with clojure.string/split makes tracking down what broke in unit tests that compare string equality much easier |
| 12:47 | l1x | nice :) |
| 12:47 | llasram | reiddraper, hyPiRion: but yes, did read the `docs/` files :-p |
| 12:47 | technomancy | justin_smith: you mean ... you aren't using lein difftest?? |
| 12:47 | lazybot | technomancy: Definitely not. |
| 12:48 | justin_smith | l1x: then diff will probably help, but also consider whether it would help to sort them first, or compare them as sets... |
| 12:48 | justin_smith | technomancy: no, I haven't tried it |
| 12:48 | technomancy | it is, as they say, the cats |
| 12:49 | hyPiRion | llasram: Like, generate a vector (gen/vector) of at least x data structures, then check if the elements are within the confidence interval |
| 12:49 | l1x | justin_smith: you think that a set would improve that much if the maximum number of elements in the list is ~100 |
| 12:49 | l1x | question mark |
| 12:49 | justin_smith | technomancy: very nice |
| 12:49 | llasram | hyPiRion: Oh. Duuuuuh. Thanks |
| 12:49 | justin_smith | l1x: well a set helps if you care about what is there, but not the order |
| 12:49 | justin_smith | (or how many times) |
| 13:41 | apricots | how does one get result set metadata using clojure.java.jdbc? i tried (jdbc/db-query-with-resultset db-spec ["select ..."] jdbc/metadata-result) but it just returns the data, not the metadata |
| 13:43 | justin_smith | apricots: that should return the function jdbc/metadata-result |
| 13:43 | justin_smith | oh, never mind |
| 13:46 | apricots | hmm looking at it more, it seems c.j.jdbc doesn’t actually let me get result set metadata |
| 13:47 | justin_smith | that sucks - is it a limitation of that driver, or of jdbc? |
| 13:48 | eraserhd | Does pomegranate have a way to query the latest version of a dependency? I'm not seeing one. |
| 13:50 | eraserhd | And, if not, should it? |
| 13:52 | technomancy | eraserhd: probably not; legitimate use cases are fairly rare. |
| 13:54 | joegallo | apricots: maybe i'm misunderstanding, but this is working just fine for me... (jdbc/db-query-with-resultset db-spec ["select * from foobar"] #(.getMetaData %))) |
| 13:55 | eraserhd | technomancy: I just realized that `lein new` does this... time to steal code? |
| 13:56 | technomancy | eraserhd: you can set the version to "RELEASE" but it's almost always the wrong thing |
| 13:56 | technomancy | but yeah, lein new is a special case because template creation isn't supposed to be repeatable |
| 13:58 | seangrove | bbloom: Working on calculating the height of a formatted block of text without rendering to the DOM to vertically center it in the layout manager - Anything jump out at that's naive in this approach? http://jsfiddle.net/QWQ4c/6/ |
| 13:58 | apricots | joegallo: yeah calling the low level methods works. i suppose i was just looking for something more clojury |
| 13:59 | bbloom | seangrove: any plans to target IE8? :-P |
| 13:59 | seangrove | bbloom: Not immediately, no. Maybe in the future? |
| 13:59 | bbloom | seangrove: IE8 doesn't have canvas |
| 14:00 | seangrove | Well then, probably not, unless there's some other API for measuring text in IE8. |
| 14:00 | seangrove | As it is, there's no reliable way to get pixel height from text without rendering it :P |
| 14:00 | bbloom | seangrove: my first thought is: does canvas text size stuff respect system accessibility settings? |
| 14:00 | bbloom | seangrove: that's a fact about text heights in general |
| 14:00 | eraserhd | technomancy: This is for an internal lein template, and I want it to always use the latest version of our internal plugin. |
| 14:00 | bbloom | seangrove: fonts are programs |
| 14:00 | bbloom | seangrove: you can only tell what they do by evaluating them :-P |
| 14:00 | eraserhd | But I agree, it's usually not hte right thing to do. |
| 14:01 | technomancy | eraserhd: gotcha; makes sense |
| 14:01 | nullptr | seangrove: if you're in cljs goog.graphics has an abstraction across canvas, vml, svg |
| 14:01 | technomancy | you can probably try to load a "RELEASE" version and then see what it resolves to, but it's a bit tricky |
| 14:02 | nullptr | though the vml back end for getTextWidth just has a todo comment and returns 0... :P |
| 14:02 | bhauman | seangrove: you probably didn’t render it and measure in a div for reason.. I am wondering why? |
| 14:02 | bbloom | seangrove: i believe that spaces can vary in width |
| 14:02 | seangrove | bbloom: Even so, shouldn't have to put them into the DOM to get the height of a given font |
| 14:02 | bbloom | seangrove: oh yeah, having to put them in to the dom is a nightmare :-P |
| 14:02 | bhauman | and there it is |
| 14:02 | bbloom | seangrove: i'm also wondering why you didn't just use a div to measure, especially considering that will handle wrapping etc for you |
| 14:02 | seangrove | I'll add that approach in as well |
| 14:04 | seangrove | nullptr: I would guess it'd be way too slow for what I'm using it for, but good point |
| 14:04 | bbloom | i think that's a much better approach b/c you're never going to be able to get all the little edge cases right |
| 14:04 | bbloom | divs i mean |
| 14:05 | bbloom | you'll want to handle line spacing, system font size scaling, text justification, hyphenation, etc etc etc |
| 14:05 | bbloom | ellipses for truncation, etc |
| 14:05 | bbloom | text is fucking hard. |
| 14:06 | seangrove | Definitely agree that it's hard. The thing that kills me is that browsers have done all this work, but don't expose it at all, not even in their usually insane ways. |
| 14:06 | bbloom | unless you plan on implementing a full on true/open type renderer, i'd 100% delegate to the browser |
| 14:06 | justin_smith | you could translate TeX to javascript via empscripten and just use that :P |
| 14:06 | bbloom | justin_smith: sounds like a solid plan. seangrove go with that lol :-) |
| 14:06 | justin_smith | maybe that would be less trouble than the alternatives, lol |
| 14:06 | seangrove | I think I have a perfect place for it right here in this tight loop |
| 14:07 | eraserhd | technomancy: I'm assuming the resolve here isn't necessary anymore, now that new is in leiningen? https://github.com/technomancy/leiningen/blob/master/src/leiningen/new.clj#L22 |
| 14:07 | seangrove | justin_smith: Working on a layout system, so have to be very wary of the costs involved |
| 14:07 | justin_smith | fair enough, I figured it was a silly suggestion |
| 14:08 | bbloom | seangrove: i've used off screen divs for measuring before and perf was "good enough" |
| 14:08 | bbloom | give it a try, see how it compares |
| 14:08 | technomancy | eraserhd: oh yeah, that probably dates from when lein-new was a plugin that needed 1.x compatibility |
| 14:08 | seangrove | bbloom: Yeah, adding it now |
| 14:08 | bbloom | seangrove: won't be as good as canvas measure string, but will support rich text w/ proper typogrophy |
| 14:15 | dnolen_ | tbaldridge: hmm it probably doesn't actually, wouldn't be hard to add |
| 14:15 | s2013 | is clojure similar to scala in terms of being on jvm |
| 14:17 | tbaldridge | dnolen_: I tried copying over to-stream from the CLJ version, but Choice seems to be different in CLJS |
| 14:17 | noonian | in the sense that they both interoperate with java, yes, but the languages have very different philosophies. Clojure only really supports functional programming whereas you can write javaish oo code in scala. |
| 14:18 | s2013 | do you need to know java to use clojure? |
| 14:18 | ToxicFrog | s2013: no, although it will help if you find yourself needing to interact with plain Java APIs (e.g. for sockets) |
| 14:18 | justin_smith | s2013: definitely not, though being able to read javadoc well enough to use something via interop is helpful |
| 14:18 | s2013 | gotcha. stupid question but do you need to compile clojure code? |
| 14:19 | nullptr | scala is a terrific choice if you like swordfighting ... http://xkcd.com/303/ |
| 14:19 | s2013 | only bits of java i remember is from college 10 years ago |
| 14:19 | justin_smith | s2013: clojure is a compiler, all code is compiled into jvm bytecode by clojure |
| 14:19 | s2013 | oh ok |
| 14:19 | s2013 | my current work is mostly ruby and rails and some python. but ive been wanting to learn something else on the side |
| 14:20 | justin_smith | s2013: well, if you haven't done functional programming there is a lot to learn, and a lot to gain, with clojure |
| 14:20 | noonian | i'd recommend clojure over scala if you are just trying to learn something new that will expand your horizons |
| 14:20 | technomancy | s2013: you don't need to sit around and wait for code to compile, if that's what you mean |
| 14:20 | technomancy | you type code in, it compiles, then runs |
| 14:21 | s2013 | yeah im not thinking about scala |
| 14:21 | technomancy | but it usually happens instantaneously once your repl has started |
| 14:21 | s2013 | i got a book on Go but have been hearing good things about clojure |
| 14:21 | s2013 | i wonder if i can jus tlearn both side by side |
| 14:21 | bbloom | s2013: learn one language at a time |
| 14:21 | bhauman | s2013: they are extremely different |
| 14:21 | noonian | if you are new to functional programming, clojure will probably be a lot to learn on it's own |
| 14:21 | s2013 | yeah i havent done much functional programming |
| 14:21 | noonian | the syntax will also be very different if you haven't used a lisp before |
| 14:22 | s2013 | would js be considered be close to some functional programming? |
| 14:22 | tbaldridge | s2013: the way Go does polymorphism is similar to Clojure, but Clojure does it 100x better, imo. |
| 14:22 | s2013 | cause js isnt true oo |
| 14:22 | bbloom | s2013: "functional" js is a joke |
| 14:22 | s2013 | i mean i gues sthats my closest exposure to fp |
| 14:23 | s2013 | not saying that its much of an exposure |
| 14:23 | bbloom | s2013: i suggest you start with www.4clojure.com & try some puzzles... it's fun |
| 14:23 | eraserhd | technomancy: I was going to submit that pull request, but I can't seem to run tests. Keep getting "Unable to resolve var: *force?* in this context. |
| 14:23 | noonian | js has functional features but if you get into it knowing only imperative programming it is unlikely you are using it functionally :P |
| 14:23 | s2013 | thanks bbloom |
| 14:23 | s2013 | let me check it out |
| 14:23 | eraserhd | But the line number reported doesn't make sense. |
| 14:23 | bbloom | s2013: be sure to follow some top users, so you can see their alternative solutions after you solve some |
| 14:24 | s2013 | stupid question but what is clojure commonly used for |
| 14:24 | cbp | programming |
| 14:24 | bbloom | cbp: lol |
| 14:24 | s2013 | thanks cbp |
| 14:24 | nullptr | web applications |
| 14:24 | TimMc | I use it as an egg replacer. |
| 14:24 | nullptr | too heavy for embedded/mobile at present |
| 14:24 | nullptr | offline/server/web app |
| 14:25 | s2013 | gotcha nullptr |
| 14:25 | s2013 | can you write system apps with it? |
| 14:25 | bbloom | s2013: depends on what you define "system" to mean |
| 14:25 | s2013 | like low level stuff |
| 14:25 | llasram | s2013: Hadoop MapReduce jobs |
| 14:25 | bbloom | s2013: there are at least a few databases & serious high perf stuff written w/ clojure |
| 14:25 | s2013 | gotcha. thats cool |
| 14:25 | bbloom | s2013: anything the java can do, clojure can do |
| 14:25 | s2013 | can you run it on windows/ |
| 14:26 | joegallo | you can |
| 14:26 | tbaldridge | s2013: datomic is written in Clojure |
| 14:27 | s2013 | cool. well im on ubuntu anyways, but just wondering |
| 14:27 | s2013 | how long did take you guys before you felt comfortable writing some basic apps inc lojure? |
| 14:28 | bbloom | s2013: if you're just looking to learn, don't fret so much: just get started |
| 14:28 | joegallo | about 1 basic apps |
| 14:28 | tbaldridge | 1 year for me, but that was 4 years ago when the documentation was quite a bit more sparse |
| 14:28 | s2013 | 1 year? damn |
| 14:28 | technomancy | s2013: depends on how many bad imperative habits you have to overcome |
| 14:28 | joegallo | that is, struggle through the first basic app, and hey presto, you'll probably have learned a whole lot |
| 14:28 | s2013 | im loking at some basic tutorials.. the syntax looks a bit weird |
| 14:28 | bhauman | hey guys I wrote a live coding leinigne plugin for CLJS and I’m looking for some feedback, kinda been in a cave writing it |
| 14:28 | tbaldridge | s2013: that being said, I haven't really touched Python or C since, so it was a great investment for me |
| 14:28 | s2013 | but if i could overcome obj-c syntax im sure i can overcome anything |
| 14:30 | nullptr | a month or so of active effort for me (but spread out over much longer), though i had experience with lisp and fp (ocaml/f#) going in |
| 14:30 | s2013 | gotcha |
| 14:30 | justin_smith | s2013: lisp style languages are a whole other world, I think one of the main revelations is there is a relative *absence* of syntax, and that is why all the parens are there |
| 14:30 | nullptr | keep in mind that clojure is still relatively early and things change quickly, so your level of comfort will decrease rapidly without continued investment |
| 14:30 | seangrove | bbloom: Maybe I should expose both strategies - one for when 'simple text layout' and one for full-fledged text flow http://jsfiddle.net/QWQ4c/7/ |
| 14:30 | technomancy | nullptr: wait, clojure changes quickly?? |
| 14:30 | justin_smith | s2013: the hard part is really getting how little syntax there is, and how consistent it is (mostly) |
| 14:30 | lazybot | technomancy: What are you, crazy? Of course not! |
| 14:30 | bbloom | seangrove: lol... you ready for an MSDN link? |
| 14:31 | seangrove | bbloom: I may have beat you to this one ;) |
| 14:31 | seangrove | But yes, please |
| 14:31 | s2013 | do you need to know Lisp or no? |
| 14:31 | justin_smith | s2013: no, I am just saying it is in the lisp family |
| 14:31 | s2013 | gotcha |
| 14:31 | bbloom | seangrove: http://msdn.microsoft.com/en-us/library/bb613560.aspx |
| 14:31 | justin_smith | which is why it looks so weird, the lisp family is like the australia of programming |
| 14:31 | justin_smith | parallel evolution |
| 14:32 | s2013 | ok so i think ill set aside an hour or two a day for clojure. im hoping by this sumemr i can write some basic apps |
| 14:32 | s2013 | are there any orms for clojure? |
| 14:32 | s2013 | i write mostly web apps |
| 14:32 | tbaldridge | s2013: you don't need ORMs with clojure ;-) |
| 14:32 | technomancy | justin_smith: the madagascar of programming |
| 14:33 | justin_smith | technomancy: even better :) |
| 14:33 | seangrove | bbloom: Nope, I came across a different one. Reading through this now, thanks |
| 14:33 | tbaldridge | ORMs are an abomination created because of the limitations of OOP |
| 14:33 | s2013 | i see |
| 14:33 | s2013 | so you write pure sql queires? |
| 14:33 | bbloom | seangrove: in short, there are two types of text-rendering components... one for simple text runs and one for rich text / flow documents |
| 14:33 | justin_smith | technomancy: or the new zealand, all things replaced by s/birds/functions |
| 14:34 | tbaldridge | there are many ways to go about it, there are LINQ like dsls for clojure, or write SQL, or use Datomic |
| 14:34 | s2013 | ok thanks |
| 14:34 | s2013 | i guess ill cross that bridge when i get there |
| 14:34 | justin_smith | we do map storage / retrieval with edn for caribou |
| 14:35 | nullptr | s2013: it's probably good to absorb a bit of the clojure philosophy before diving in, gives helpful context to understand "the clojure way" |
| 14:35 | justin_smith | (since clojure is more about maps than objects and all) |
| 14:35 | nullptr | rich hickey's "simple / easy" talk will shed some light -- and i believe it touches on orm specifically |
| 14:35 | tbaldridge | s2013: have you seen any of Rich Hickey's talks? |
| 14:35 | nullptr | http://www.infoq.com/presentations/Simple-Made-Easy |
| 14:35 | seangrove | bbloom: Ok, this is heartening. Seems like we can start with these strategies, and make them more configurable as we need. |
| 14:35 | tbaldridge | also this list is probably a great way to start learning about Clojure http://thechangelog.com/rich-hickeys-greatest-hits/ |
| 14:36 | bbloom | seangrove: yeah, just be careful not to use names that will confuse the fuck out of you later & make a compatability nightmare ;-) |
| 14:36 | tbaldridge | seangrove: bbloom: I recently started trying to do some layout stuff in SVG, that was insanely painful. |
| 14:36 | tbaldridge | seangrove: bbloom: like the fact that SVG text only returns the width of text when you measure |
| 14:36 | bbloom | tbaldridge: seems like seangrove is having success w/ some prototype code i sent him recently |
| 14:36 | bbloom | tbaldridge: but text is the hardest part |
| 14:37 | tbaldridge | bbloom: probably true, my skills with most web UI stuff is sub-par |
| 14:37 | seangrove | Yeah, I'm going to add this in, and I'll post a screenshot of properly laid-out app |
| 14:38 | Foxboron | Anyone picked up "Clojure for Machine Learning"? Thoughts? |
| 14:39 | seangrove | Well, this is pre-text layout anyway http://dl.dropboxusercontent.com/u/412963/Screenshots/e0.png scroll view with a fixed-height table view with rows of absolutley-positioned canvas layout for the relative time component and the text-view component |
| 14:39 | seangrove | Working towards the right-hand, left is what we have so far |
| 14:40 | seangrove | Then we talked with the designer and he said that the text is actually variable-height even though it's not shown in the screenshot, so had to implement proper text-block sizing |
| 14:54 | BobSchack | Anyone here use / play around with fressian? I'm porting fressian to clojurescript (https://github.com/devn/longshi) and would like any comments on the api design. I'm currently going to model the api after data.fressian. |
| 14:56 | tbaldridge | BobSchack: yeah, I've used it a fair amount |
| 14:56 | tbaldridge | BobSchack: lol, it's you devn? |
| 14:56 | tbaldridge | oh I see multiple people in this repo |
| 14:56 | BobSchack | No I'm working with devn |
| 14:59 | mdrogalis | tbaldridge: Tell Stuart to keep the Clojure version in sync with the Java dependency. It causes classpath woes when used in conjunction with Datomic :P |
| 15:00 | tbaldridge | BobSchack: so I started on a CLJS port of fressian once, and ran into a problem that perhaps you'll be able to solve better than I |
| 15:01 | BobSchack | what problem? |
| 15:01 | tbaldridge | namely, decoding UTF-8 strings in JS from a byte array. |
| 15:02 | BobSchack | oh I already have the string encoding / decoding portion done (at least in JS) I haven't tested it with java encoded fressian |
| 15:02 | BobSchack | any codepoints that caused problems? |
| 15:03 | tbaldridge | ah, I see that code now |
| 15:06 | blake__ | Is there any documentation on how to build a new Clojure system? Like, if I wanted to target a new VM, a la ClojureScript or clojure-py? |
| 15:09 | BobSchack | tbaldridge I've smoke tested encoding / decoding of the base types (integer, strings, byte array, etc) and I'm working on the extension point / caching system. |
| 15:09 | akhudek | blake__: there is no such thing that I’m aware of. I’ve heard it’s best to start with clojurescript as a base though. The much desired clojure-in-clojure would make this much easeir, but it’s yet to appear. |
| 15:09 | tbaldridge | blake__: tools.analyzer is always a good starting place for this sort of thing |
| 15:10 | tbaldridge | BobSchack: nice! then you're further than I ever was. |
| 15:10 | blake__ | tbaldridge: Tx. I seem to keep coming back to that. Guess I better figger it out. =P |
| 15:10 | tbaldridge | blake__: shameless plug https://www.youtube.com/watch?v=KhRQmT22SSg |
| 15:11 | blake__ | tbaldridge: Ha! Shameless plugs are the best kind! I'll watch! |
| 15:11 | Frozenlock | tbaldridge: Nooooo, my productivity! |
| 15:11 | seangrove | tbaldridge: You and your shameless, helpful plugs |
| 15:12 | BobSchack | Getting InterleavedIndexHopMap to work an decent speed was a fun challenge. I'd especially like to know how people are using in to do perf tuing once I get everything working |
| 15:17 | tbaldridge | blake__: code from that talk https://github.com/halgari/data-all-the-asts/blob/master/src/data_all_the_asts_talk/core.clj |
| 15:17 | amalloy | i think it's only shameless if you don't explicitly say so. loudly excusing it as shameless suggests you must feel some shame |
| 15:22 | blake__ | Unless it's meant ironically. |
| 15:22 | dbasch | amalloy: “shameless plug” is just a template. Only a programmer will take that literally and not evaluate it :) |
| 15:35 | dbasch | btw, I’ve been thinking about a generic way to do user management. Here’s a super basic idea for an api, thoughts? https://www.refheap.com/84419 |
| 15:38 | bhauman | dbasch: the anonymous user case? or are you not going to have that? |
| 15:39 | bhauman | dbasch: that case seems to creep into every web product |
| 15:39 | dbasch | bhauman: not for now, although this wouldn’t preclude you from allowing users to create bogus accounts |
| 15:40 | bbloom | dbasch: there's basically no such thing as a "generic way to do user management" |
| 15:40 | bbloom | the list of possible features is hilariously large |
| 15:40 | dbasch | bbloom: I know, but you can provide a template to aid with a couple of basic things |
| 15:40 | dbasch | 1) never use a plaintext password |
| 15:40 | dbasch | 2) enforce a minimum password length |
| 15:40 | dbasch | 3) have a sane key derivation function |
| 15:41 | dbasch | I think that alone would help many people |
| 15:41 | dbasch | it’s really easy to make horrible mistakes in 10 lines of code to authenticate users |
| 15:42 | bhauman | it’s easy to make horrible mistakes in 100 lines too |
| 15:42 | bhauman | :) |
| 15:42 | bhauman | dbasch: you are getting at correct core functionality, I like it |
| 15:42 | dbasch | of course, the point being most people start with the most basic authentication features and make mistakes |
| 15:43 | amalloy | huh, i got a different error message than i was expecting from ##(count [] []) |
| 15:43 | lazybot | clojure.lang.ArityException: Wrong number of args (2) passed to: core$count |
| 15:43 | amalloy | errrrr. in my repl i get "Wrong number of args (2) passed to: core/count--inliner" |
| 15:43 | llasram | huh |
| 15:44 | llasram | I get what you get. Clojure 1.6? |
| 15:44 | llasram | &*clojure-version* |
| 15:44 | lazybot | ⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil} |
| 15:44 | llasram | Oh, lazybot |
| 15:44 | llasram | You so old |
| 15:44 | bbloom | dbasch: i don't see how this is any better than a one page readme on how to properly hash/store passwords |
| 15:44 | bbloom | dbasch: in fact, this is already wrong, since it doesn't do any salting |
| 15:45 | bbloom | there's no substitute for understanding security |
| 15:45 | dbasch | bbloom: it does salting |
| 15:45 | bbloom | dbasch: where? |
| 15:45 | dbasch | bbloom: crypto-password |
| 15:45 | dbasch | I’m trying to bridge crypto-password and friend somewhat |
| 15:46 | dbasch | bbloom: the idea is that a readme is one step less than a template for most people who just want to build an app |
| 15:47 | dbasch | bbloom: if there’s a default that you can stick in your project, that’s easy to find than a readme on the web (of which there are probably thousands, and many of them outdated/wrong) |
| 15:50 | bbloom | dbasch: so the salt is stored as part of the hashed password result string? |
| 15:50 | bbloom | odd. but ok |
| 15:50 | dbasch | bbloom: yes, it’s a standard |
| 15:51 | dbasch | bbloom: I have my own implementation where I store salt in a db column, but I prefer to use crypto-password because it’s already out there |
| 15:53 | dbasch | bbloom: btw, I asked Colin Percival about that library and he said it seemed ok |
| 15:53 | bbloom | dbasch: sure, i'm just saying i've never worked on a web app that didn't out grow a simple auth API basically overnight |
| 15:54 | dbasch | bbloom: yeah, me either. But I always wanted a starting point. It happened to me very recently in fact. |
| 15:54 | dbasch | I started working on cointipping.com and realized I had to reinvent passwords from scratch |
| 15:55 | dbasch | it’s really easy to forget basic things like enforcing minimum password lengths |
| 15:55 | coventry | dbasch: Do you want to store a salt as well, and use it in generating the hash? |
| 15:55 | bbloom | coventry: we just discussed this :-P |
| 15:55 | dbasch | coventry: ScryptUtil does that |
| 15:56 | bbloom | coventry: apparently the libraries he calls in to stores the hash in the returned string value |
| 15:56 | bbloom | stores the salt* with the hash, i mean |
| 15:57 | dbasch | crypto-password looks pretty solid. I hardcoded scrypt because I see no reason to make that optional, but it could be if someone really cares |
| 15:57 | dbasch | although I would assume that if someone is at that level, they don’t need this |
| 15:57 | bbloom | dbasch: yeah, no reason to expose multiple crypto algorithms. just pick the most secure one available |
| 15:58 | dbasch | I think for 99.99% of apps the three choices in crypto-password are just fine |
| 15:59 | dbasch | if you are building a clojure app that must withstand a concerted attack by a government, this is not for you :) |
| 16:00 | dbasch | also, it’s easy to bikeshed about password algorithms and forget many other mundane aspects of user management |
| 16:00 | bhauman | dbasch: shouldn’t we really default to forcing people to install pgp |
| 16:00 | dbasch | bhauman: that would be nice, but who’s we? :P |
| 16:00 | bhauman | the programming elite :) |
| 16:01 | dbasch | for example, one of the things I want to do is swallow the password, and make sure it’s not being passed around in the user’s app |
| 16:01 | dbasch | if I could zero-out the in-memory password after hashing it, I would |
| 16:02 | dbasch | also, I want to remove reasons for people to print plaintext passwords in debug logs |
| 16:02 | bbloom | dbasch: blows my mind how often i encounter that |
| 16:03 | dbasch | bbloom: right. If you don’t need to debug your password implementation, it’s less likely that you’ll log passwords |
| 16:03 | dbasch | of course, nothing stops your from logging every request |
| 16:03 | bbloom | dbasch: it's particularly funny in rails apps where there's a way to filter request params, yet ppl decide to use something like password2 instead of confirm_password or whatever the OFFICIAL second field is |
| 16:03 | bbloom | so sure enough, logs are full of plain text passwords |
| 16:03 | bbloom | :-/ |
| 16:03 | dbasch | bbloom: also, confirm_password should never really make it to the server. In 2014, that’s a UX matter. |
| 16:04 | bbloom | dbasch: if you're not writing any client side code, it's perfectly reasonable to send that to the server |
| 16:04 | bbloom | whether or not the absence of client side validation is acceptable in 2014 is another matter |
| 16:04 | dbasch | bbloom: it’s reasonable, but it’s preferable to avoid it |
| 16:05 | dbasch | it’s one more opportunity for an error to be logged somewhere, containing a password |
| 16:06 | bbloom | dbasch: that's the least of our worries really. it's not all that uncommon for passwords to be sent via http in the clear anyway |
| 16:07 | dbasch | bbloom: not much we can do about that, other than fight to make ssl mandatory |
| 16:07 | bbloom | i'd suggest that browsers should just start stripping out password fields from form posts, but that won't work as soon as somebody does some wacky AJAX nonsense w/ some jquery plugin |
| 16:07 | bbloom | end-to-end encrypted network traffic should be *the fucking law* |
| 16:07 | dbasch | bbloom: preaching to the choir :P |
| 16:10 | {blake} | Or maybe it should all be totally open and obviously hackable. Might teach people to be more circumspect online. =P |
| 16:10 | dbasch | bbloom: one of my worries is the very common scenario where someone accesses a server, steals logs and password dbs |
| 16:11 | dbasch | it happens to pretty much every company at some point |
| 16:11 | dbasch | and it’s hard to protect against, especially as a company grows and more people have server access |
| 16:11 | dbasch | at the very least we should help people make sure that information is un-bruteforceable |
| 16:12 | dbasch | because we won’t stop people from reusing passwords across sites |
| 16:12 | noonian | the nsa will still get theirs |
| 16:13 | bbloom | passwords won't get fixed until auth is a proper browser feature that has a compelling dev story |
| 16:13 | dbasch | {blake}: it’s even worse now that people have cryptocurrency on their machines |
| 16:13 | {blake} | noonian: My point! |
| 16:13 | {blake} | dbasch: "Why do you rob banks--er, computers?" "'cause that's where the money is!" |
| 16:13 | dbasch | yeah, I wouldn’t even try to protect against the NSA |
| 16:14 | dbasch | meaning, the threat model presented by the NSA goes way beyond anything that can be done in software |
| 16:15 | dbasch | for all we know, the NSA owns every keystroke on every network-connected computer on the planet, and many unplugged ones |
| 16:15 | noonian | i think thats a reasonable assumption to go with |
| 16:15 | {blake} | Going back to my "Well, if it can't be protected, we should at least be honest about it" theory. Heh. |
| 16:16 | dbasch | {blake}: protected is not an absolute. You can protect against some things and not others |
| 16:16 | {blake} | dbasch: Yeah, I know. I just think there's been more than a little dishonesty about what's being protected from whom. |
| 16:17 | dbasch | {blake}: I could so go on a rant, starting by the invention of the phrase “identity theft” :P |
| 16:17 | dbasch | but we’re probably getting offtopic |
| 16:17 | {blake} | dbasch: Moving on... |
| 16:18 | dbasch | I see many people coming into clojure and the first thing they do is a compojure/ring app |
| 16:19 | {blake} | <--Is doing that. (Not first thing but...top 10.) |
| 16:19 | dbasch | and it’s true that the state of security in Clojure can improve, even if it’s not as bad as abedra’s talk made it sound |
| 16:25 | coventry | Yeah, if you're worried about concerted attack by a government, you're pretty much lost unless you are one. :-) |
| 16:25 | bbloom | (doc assoc) ; because of the lack of the 1 arg arity.... |
| 16:26 | clojurebot | "([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)." |
| 16:26 | bbloom | what's the best way to take & kwargs and assoc them in to an existing map? |
| 16:27 | fowlslegs | I'm trying to use this https://github.com/kephale/clj-random/blob/master/src/clj_random/core.clj library's #'lrand-bytes to produce vectors of integers with 8-bit binary representations. However when I try (map #(Integer/toBinaryString %) (vec (lrand-bytes 8))) strings with more than 8 bits are produced. |
| 16:29 | fowlslegs | I need a fast way to psuedorandomly generate and manipulate binary data, but am having trouble finding the right tools to use. |
| 16:31 | AimHere | slurp and /dev/null! |
| 16:31 | TimMc | /dev/random you mean |
| 16:31 | AimHere | yes |
| 16:31 | stompyj | how is intellij clojure support? |
| 16:32 | stompyj | semi-bummed in what happened with lighttable |
| 16:32 | dbasch | fowlslegs: why not (byte (- 127 (rand-int 256)))) |
| 16:32 | dbasch | and repeat as needed |
| 16:32 | akhudek | stompyj: not bad, get the cursive clojure plugin |
| 16:32 | stompyj | still early I guess, but i hope they don’t abandon it in favor of aurora. |
| 16:32 | dbasch | concatenate into byte array, etc |
| 16:32 | cbp | I've heard good things about cursive |
| 16:33 | cbp | but never tried it |
| 16:33 | dbasch | TimMc: /dev/random is for when you need secure random bits, but it may be slow for some apps |
| 16:33 | stompyj | akhudek: I’d need the paid version of intellij to try that right? |
| 16:33 | dbasch | TimMc: and if you’re going to use it, do it through SecureRandom |
| 16:33 | akhudek | stompyj: noope |
| 16:34 | fowlslegs | I think I came up with a solution. |
| 16:34 | akhudek | stompyj: community version works fine |
| 16:34 | stompyj | akhudek: thansk! |
| 16:34 | {blake} | Wait, what happened with LightTable? |
| 16:35 | stompyj | {blake}: I looks like he’s ramping down dev on lighttable and ramping up dev on that aurora thing |
| 16:35 | stompyj | Right now LT isn’t a better general IDE then ST3 for my workflow, so I can’t switch yet |
| 16:36 | {blake} | stompyj: Huh. LT needs work. But Cursive is pretty solid as is CCW. (In my limited experience.) Also, emax. |
| 16:36 | fowlslegs | dbasch: Yeah that should work using a different rand. I also thought of an optimization for creating large random strings of random length. Will post details when I get it working. |
| 16:36 | akhudek | stompyj: I’ve expereinced issues with st3 and the repl |
| 16:36 | stompyj | {blake}: Yeah, I’m excited to try Cursive |
| 16:36 | dbasch | fowlslegs: cool |
| 16:36 | noonian | yeah, i like LT and hope development continues, but it's open source now so in theory the community could move it forward |
| 16:36 | stompyj | akhudek: 1000% agreed. I meant ST3 is my non-clojure IDE |
| 16:37 | stompyj | noonian: Yeah, it just feels like it needs a couple more releases to get it to the point where the community will want to push it over the edge |
| 16:37 | {blake} | I've been using LT when I don't want to deal with "projects" and "workspaces" and what-not. |
| 16:37 | stompyj | All that said, props to Chris, it’s amazing for what it is |
| 16:38 | akhudek | lighttable has always had too much magic in it when I’ve tried it. It’s great for the cases it’s explicitly programmed for, but very quicly falls flat in more complicated scenarios |
| 16:38 | TimMc | stompyj: Source on LT statement? |
| 16:39 | stompyj | sure, one sec |
| 16:40 | noonian | i don't even use the in-line evaluation stuff really, i just like it as an editor that's as pretty or prettier than sublime text and the configuration files use edn and have a nice auto complete feature |
| 16:40 | noonian | i just keep a lein repl up next to it |
| 16:40 | stompyj | https://groups.google.com/forum/?fromgroups#!topic/light-table-discussion/A3pc87gGcHc |
| 16:40 | stompyj | I won’t quote bomb the channel, but scroll down to see his response |
| 16:42 | TimMc | thanks |
| 16:43 | noonian | nice, i hadn't seen the new lighttable.com site |
| 16:44 | noonian | sounds like he's focusing on aurora to try and make the company sustainable, and that he's not ditching LT, just trying to get the time to keep working on it |
| 16:44 | fowlslegs | ,(Integer/toBinaryString -20)(Integer/toBinaryString 255) |
| 16:44 | clojurebot | "11111111111111111111111111101100" |
| 16:44 | fowlslegs | dbach: ^ |
| 16:45 | fowlslegs | ,(Integer/toBinaryString 255) |
| 16:45 | clojurebot | "11111111" |
| 16:45 | justin_smith | dbasch: what about storing the password as a byte-array instead of string - that prints opaquely and can be zeroed |
| 16:45 | justin_smith | dbasch: also the underlying crypto stuff expects byte arrays, it is the lib in front that will convert from string from what I have seen |
| 16:46 | dbasch | justin_smith: I’m not too worried about the password after it’s hashed, I’d like to zero-out the plaintext password that comes into the api but (being Clojure) I can’t :) |
| 16:47 | justin_smith | dbasch: you can get the request before the middleware expands the body, while it is still an input stream |
| 16:47 | justin_smith | as long as you give it back another input stream (with pw zeroed), you are fine |
| 16:47 | justin_smith | I did something similar with a request serializer lib |
| 16:48 | fowlslegs | The whole integer to binary string thing maxes out a bit before 2^32 |
| 16:48 | fowlslegs | ,(count (Integer/toBinaryString (dec (Math/pow 2 31)))) |
| 16:48 | clojurebot | 31 |
| 16:49 | fowlslegs | I can still work with this because I can map bitwise operators across vectors of numbers with binary representations that are at maximum 1 byte. |
| 16:50 | fowlslegs | Bijective rotations left and right might be hard to do efficiently though. |
| 16:50 | dbasch | justin_smith: interesting idea. I’ll think about it. |
| 16:50 | fowlslegs | Anyway, if anyone has any ideas, let me know, otherwise I'll stop thinking aloud. |
| 16:52 | dbasch | fowlslegs: well, you can move on to Long :) |
| 16:52 | justin_smith | dbasch: the key is to make sure it sees the request before any other handler or middleware, of course |
| 16:52 | fowlslegs | dbasch: My knowledge of Java is very limited. |
| 16:53 | dbasch | justin_smith: although in the real world nginx or waht have you also has the password in memory |
| 16:53 | fowlslegs | dbasch: Not that I'm not willing to learn. |
| 16:53 | dbasch | justin_smith: it’s probably not that important anyway |
| 16:53 | justin_smith | fair enough |
| 16:53 | dbasch | fowlslegs: Long has the same api, only it’s 64 bits |
| 16:54 | dbasch | fowlslegs: how much random data do you need, and in what format? |
| 16:57 | fowlslegs | dbasch: This is a genetic programming experiment to evolve a compression function for use in a cryptographic hash. |
| 16:57 | fowlslegs | (defn gen-plaintext [distr-center] (-> (r/lrand-gaussian) Math/abs (* distr-center) round #(repeatedly (r/lrand-int 255)))) |
| 16:58 | fowlslegs | This is what I'm using to create random binary strings. If I put in 100000 I get an email, 1000 a short txt file, etc.. |
| 16:59 | dbasch | what is round? |
| 16:59 | dbasch | oh, never mind |
| 17:00 | dbasch | fowlslegs: any reason to use a gaussian? |
| 17:01 | dbasch | fowlslegs: and also, why do you need binary strings? Couldn’t you just generate random text? |
| 17:03 | fowlslegs | dbasch: For the error function I'm trying to analyze each compression functions performance measured in terms of a random sampling of its performance on higher orders of the strict avalanche criterion when implemented in a variation on the classical Merkle-Damgard. |
| 17:03 | fowlslegs | dbasch: I think my results will be best if I use varying length strings. |
| 17:04 | stompyj | noonian: understood, I didn’t mean to insinuate he was ditching LT, just that he was shifting priorities a bit |
| 17:04 | stompyj | which makes sense to me, I just hope LT is far enough along that people really want to dig in |
| 17:05 | fowlslegs | dbasch: I can say test it's adherence to GSAC for 3 small, 3 medium, and 3 long strings, with variation in all three categories. |
| 17:05 | noonian | stompyj: yeah, thanks for linking that discussion anyway, i'm now discovering a bunch of features that were added like the plugin manager |
| 17:06 | fowlslegs | dbasch: Does that make sense? Kind of going with the more variation and randomness, the better results I will get, at least in terms of what I throw at the compresssion functions (this is not the same for the function set, terminals, gen operators, etc.). |
| 17:07 | dbasch | fowlslegs: so you’re looking to generate strings with varying levels of entropy? |
| 17:10 | Jaood | is it common practice to use -main in applications? |
| 17:13 | amalloy | there's not really any other way to do it, Jaood? |
| 17:13 | justin_smith | amalloy: well you can name it something else I guess (or I seem to remember having done so) |
| 17:14 | amalloy | justin_smith: yes, you can in fact change the prefix |
| 17:14 | Jaood | amalloy: lein lets you use a different name |
| 17:14 | amalloy | from - to anything you want. but why bother? |
| 17:14 | fowlslegs | dbasch: Entropy as I understand it in the language of computer science is the randomness that comes from hardware timings and such. This may not meet the mathematical distribution of a cts uniform distr when we look at it in large quantities, but it is much less deterministic than a PRNG. It might be true that the values generated by our PRNG have greater entropy when they are shorter, but that is not what I'm trying to achieve. The Mersenn |
| 17:14 | fowlslegs | Did that cut off? |
| 17:14 | welder | yes |
| 17:14 | fowlslegs | Where? |
| 17:14 | stompyj | The Mersenn |
| 17:15 | fowlslegs | Mersenne-Twister algorithm is cryptographically secure, so I'm more looking for variation in length for testing purposes because perhaps the performance of certain compression functions in my population will be poor when given very short or long strings and it needs to be able to perform well on all strings. |
| 17:16 | Jaood | amalloy: but I meant that any function call can really just start your app |
| 17:17 | amalloy | i'm not aware of such an option. what is it? |
| 17:17 | amalloy | like, if i want to build an uberjar which, when run, first calls my.ns/foo instead of my.ns/-main, what do i do? |
| 17:17 | llasram | amalloy: Use `lein-otf` :-) |
| 17:18 | amalloy | $google lein otf |
| 17:18 | lazybot | [timmc/lein-otf · GitHub] https://github.com/timmc/lein-otf |
| 17:18 | amalloy | i see. plausible, i guess, but i wouldn't say that because some random plugin allows it it's a feature of lein |
| 17:19 | TimMc | It's not random, it's my wife! |
| 17:19 | Jaood | Calls the -main function in the namespace specified as :main in project.clj. |
| 17:19 | Jaood | You may use -- to escape the first argument in case it begins with `-' or `:'. |
| 17:19 | Jaood | If your main function is not called "-main", you may use a namespaced symbol |
| 17:19 | Jaood | like clojure.main/main. |
| 17:19 | amalloy | Jaood: right, i said uberjar. not lein run |
| 17:19 | llasram | Jaood: More generally -- although `lein run` and other tricks will let you invoke some arbitrary function, (a) the built-in `clojure.main` class wants to run a function named `-main` (b) the genclass tooling wants a function named `-main` (mod you can change the prefix if you want) |
| 17:19 | TimMc | Jaood: So, all lein-otf is doing is providing a -main and calling something else that you specify. |
| 17:20 | TimMc | Jaood: All Java processes start with a call to main. |
| 17:20 | Jaood | amalloy: right, I wasn't talking about jars, just a simple file, like a script |
| 17:20 | amalloy | something that you make the user run via lein is not much of an app |
| 17:20 | llasram | Additionally -- you could name all your Clojure source files with the extension `.funkyfuntimes` and get everything to work. But why? |
| 17:21 | Jaood | TimMc: goi it |
| 17:21 | Jaood | I should haved said script instead of app :P |
| 17:24 | Jaood | llasram: yeah, was just reading about genclass |
| 17:25 | fowlslegs | dbasch: Long ain't as long as you think. |
| 17:26 | fowlslegs | I mean it's probably #'Integer/toBinaryString |
| 17:26 | Jaood | do you guys have like a shell allas for 'java -cp clojure.jar clojure.main' then? for running scripts |
| 17:26 | fowlslegs | Won't work on anything with a minimal binary representation > 32 bits in length |
| 17:26 | Jaood | s/allas/alias/ |
| 17:26 | llasram | Jaood: No scripts. Doesn't really work |
| 17:27 | noonian | is there anyway to reload code in a repl such that multimethod definitions are re-evaluated? |
| 17:27 | Jaood | llasram: why not? |
| 17:27 | turbofail | i don't have a general script for doing something like that, but i do have some scripts that specify namespaces to run |
| 17:28 | llasram | Jaood: I mean that in practice. You pay the whole JVM start-up time to get a process with no libraries. Just isn't worth it |
| 17:28 | llasram | noonian: You mean e.g. changing the dispatch function? |
| 17:28 | justin_smith | Jaood: that would only work with clojure.core + what comes with the jvm, I typically use other deps, which means needing to manage deps, which means lein to me |
| 17:28 | noonian | llasram: ah, yes |
| 17:29 | llasram | noonian: Yeah, for that you need to actually replace the multimethod instance, which will drop all of the implementations too |
| 17:29 | turbofail | oh yeah usually my scripts are dealing with some sort of uberjar with clojure in it, not the clojure jar alone |
| 17:29 | llasram | noonian: OTOH, that's almost always what I want, so I just use the pattern of having `(def my-mm nil)` right before the actual declaration |
| 17:29 | turbofail | and they're usually running a long process, as part of a cron job |
| 17:30 | justin_smith | turbofail: then I would do lein uberjar + java -jar usually |
| 17:30 | Jaood | justin_smith: llasram: well the jvm surely has lots of libraries for simple system tasks/scripts no? but I can see how the startup time can be an issue |
| 17:30 | noonian | llasram: just during development? or do you leave that in there and not worry about it? |
| 17:30 | llasram | noonian: The latter. Doesn't hurt anything :-) |
| 17:30 | noonian | llasram: thanks |
| 17:31 | llasram | I'll even claim that it more closely aligns multimethods with protocols, since re-compiling the namespace containing a protocol loses all existing registered protocol implementatinos |
| 17:31 | turbofail | justin_smith: `java -cp uber.jar clojure.main ...` gives more flexibility. i can pick a namespace to run, or specify a random file to run with those dependencies available, or whatever |
| 17:31 | turbofail | also having to AOT a main class is lame |
| 17:31 | justin_smith | turbofail: oh, interesting point |
| 17:32 | llasram | You can also add extra deps, which is useful for running under frameworks |
| 17:32 | technomancy | turbofail: as of the next version of lein if you dont specify an uberjar entry point, it assumes clojure.main |
| 17:32 | technomancy | so you can use java -jar |
| 17:33 | turbofail | ah |
| 17:33 | turbofail | that's handy |
| 17:33 | technomancy | I agree re: having to AOT just to get a main |
| 17:38 | l1x | hey clojure aces, I am trying to write a function that does multiple update-in -s for a single swap! call but i fail https://gist.github.com/l1x/1d29bc762a316461a849 |
| 17:38 | l1x | it throws a null pointer exception on a key that does not exist yet |
| 17:39 | llasram | l1x: try s,inc,(fnil inc 0), |
| 17:41 | technomancy | fnil is great |
| 17:41 | technomancy | partly because, you know, f-ing nils. |
| 17:41 | llasram | hah |
| 17:41 | l1x | llasram: you right |
| 17:41 | l1x | thanks! |
| 18:00 | m1dnight | hey guys o/ |
| 18:01 | noonian | yo |
| 18:03 | Glenjamin | hi guys, does anyone have any experience with pulsar - is there such thing as pmap for pulsar, does it make sense to use lightweight threads in this way? |
| 18:05 | rasmusto | ~trampoline |
| 18:05 | clojurebot | trampoline is the clenched fist in the gauntlet of letfn |
| 18:06 | justin_smith | bhauman: very nice |
| 18:06 | bhauman | justin_smith: Thanks man |
| 18:06 | whodidthis | how do i use clojure.set/union on '(#{:a} #{:c} ...) |
| 18:07 | rasmusto | whodidthis: apply |
| 18:07 | whodidthis | sweet thanks |
| 18:08 | rasmusto | whodidthis: yeah, most of the set functions are multi-arity, so you can use apply on all of them |
| 18:08 | rasmusto | "difference" is the only one that might do something confusing, the rest should be straightforward :p |
| 18:09 | justin_smith | ,(set/difference #{1 2 3 4 5} #{1 2 3} #{4}) kind of like multi arity - |
| 18:09 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)> |
| 18:09 | justin_smith | ,(clojure.set/difference #{1 2 3 4 5} #{1 2 3} #{4}) kind of like multi arity - |
| 18:09 | clojurebot | #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set> |
| 18:10 | rasmusto | ,(require 'clojure.set) |
| 18:10 | clojurebot | nil |
| 18:10 | justin_smith | ,(clojure.set/difference #{1 2 3 4 5} #{1 2 3} #{4}) kind of like multi arity - |
| 18:10 | mmitchell | is it considered "ok" to have side effects in a watcher fn? |
| 18:10 | clojurebot | #{5} |
| 18:10 | justin_smith | thanks :) |
| 18:11 | mmitchell | i'd think that watchers would really be all about side effects anyway? |
| 18:11 | stompyj | bhauman: badass! |
| 18:12 | justin_smith | yeah, seeing the whole thing, it was very well done |
| 18:12 | coventry | mmitchell: om does. |
| 18:12 | justin_smith | (inc bhauman) |
| 18:12 | lazybot | ⇒ 1 |
| 18:12 | dbasch | bhauman: just watched it, awesome. |
| 18:12 | mmitchell | coventry: ok thanks, good to know |
| 18:12 | bhauman | justin_smith: stompyj: thank guys, BTW I just posted it to HN so … you can dec me for asking for votes |
| 18:13 | stompyj | I was just looking for it on HN :) |
| 18:13 | bhauman | on the new page |
| 18:13 | coventry | I find that when I re-evaluate clojurescript, the attached web page only updates accordingly maybe 50% of the time, and I haven't been able to figure out why. |
| 18:14 | mdeboard | Glenjamin, Is Pulsar still relevant since the advent of goroutines in Clojure? |
| 18:14 | mdeboard | (This is the first time I've read about pulsar) |
| 18:15 | Glenjamin | i think the thing i was actually looking for was reducers in my case |
| 18:15 | mdeboard | I agree with most of that blog post regardless |
| 18:15 | Glenjamin | but afaik pulsar provdes an api-compatible version of core.async |
| 18:15 | Glenjamin | so they must think it's useful |
| 18:15 | mdeboard | ahh |
| 18:16 | Glenjamin | as i understand it, quasar does it's own scheduling across a threadpool, rather than leaving it to the OS |
| 18:16 | Glenjamin | which has some benefits in some cases apparently |
| 18:20 | Glenjamin | bah, i wish i'd read this rich hickey reducers blogpost before starting this latest project |
| 18:20 | Glenjamin | i've got everything working with lazy seqs and recur |
| 18:20 | bbloom | Glenjamin: this talk is really good too: http://vimeo.com/45561411 |
| 18:20 | amalloy | mmitchell: yeah, a watcher with no side effects does nothing at all |
| 18:21 | Glenjamin | i've been trying to optimise a large DB read via lazy-seqs |
| 18:21 | amalloy | i mean, arguably you should try to stay away from watchers, but if you do use one, it necessarily has side effects |
| 18:21 | mmitchell | amalloy: cool yep, thanks for the confirmation! |
| 18:21 | Glenjamin | and it turns out i was solving the wrong problem |
| 18:21 | bbloom | i've only found watchers useful for interop with externally stateful things during dev time |
| 18:21 | bbloom | like managing a "debug window" in swing or something |
| 18:22 | Glenjamin | i've got no explict paralleism in this code, and it still manages to use all my cores - sounds like reducers are the solution i wanted |
| 18:22 | amalloy | i used a watcher once at geni |
| 18:22 | amalloy | we had a background thread churning through a work queue as fast as it could, and some client would say "let me know when my task id #1234 is done" |
| 18:22 | Glenjamin | i wanted something in between a watcher and a validator the other day |
| 18:23 | amalloy | so there was an atom or something with the id of the last-processed job, and we'd set a watcher to notify the user when their thing was done |
| 18:23 | Glenjamin | i wanted to throw some data into an atom, but have it compute some derived values before swapping - but i guess that's just an agent |
| 18:23 | amalloy | that sounds like a function, Glenjamin |
| 18:24 | Glenjamin | well yeah, that what i have, but i wanted to ensure you couldn't put the wrong thing in the atom |
| 18:24 | Glenjamin | i suspect this is my OO reflex, which i need to beat down |
| 18:26 | justin_smith | Glenjamin: well, you didn't subclass hash-map with a version of conj that throws exceptions on certain inputs |
| 18:26 | Glenjamin | i did add a validator to my atom to check the keys |
| 18:27 | m1dnight | could anyone tell me, how I can create a key-value map (or what is the proper term?) from [[:a 1] [:b 2]]? I.e., to {:a 1 :b 2} |
| 18:27 | m1dnight | please :) |
| 18:27 | justin_smith | m1dnight: into |
| 18:27 | Glenjamin | ,(into {} [[:a 1] [:b 2]]) |
| 18:27 | m1dnight | oh |
| 18:27 | clojurebot | {:a 1, :b 2} |
| 18:28 | m1dnight | is that the same then, as #{} ? |
| 18:28 | m1dnight | I was reading about this in the docs |
| 18:28 | Glenjamin | #{} is a set |
| 18:28 | justin_smith | ,(class #{}) |
| 18:28 | clojurebot | clojure.lang.PersistentHashSet |
| 18:28 | m1dnight | oh :) |
| 18:28 | justin_smith | ,(class {}) |
| 18:28 | clojurebot | clojure.lang.PersistentArrayMap |
| 18:28 | m1dnight | ohhh that's what I need |
| 18:28 | noonian | but you can also use with into heh |
| 18:28 | Glenjamin | justin_smith: is that something someone did? |
| 18:28 | rasmusto | ,[#{1 2 3} {1 2, 3 5}] |
| 18:28 | clojurebot | [#{1 3 2} {1 2, 3 5}] |
| 18:28 | m1dnight | hey, thanks a lot!! :) |
| 18:28 | noonian | ,(into #{} [[:a 1] [:b 2]]) |
| 18:28 | clojurebot | #{[:b 2] [:a 1]} |
| 18:29 | noonian | ,(into #{} [1 2 3]) |
| 18:29 | clojurebot | #{1 3 2} |
| 18:29 | justin_smith | Glenjamin: no, just going even more OO with it, saying you aren't that far off the saintly path yet |
| 18:29 | m1dnight | hmm, just saw it here :p seems not to be what I want |
| 18:29 | m1dnight | oh wait, yes it is |
| 18:29 | Glenjamin | heh |
| 18:29 | m1dnight | thanks |
| 18:29 | justin_smith | ,(into #{} [1 2 3 2 1]) |
| 18:29 | clojurebot | #{1 3 2} |
| 18:30 | m1dnight | ,(into {} [[:a 1][:b 2]]) |
| 18:30 | clojurebot | {:a 1, :b 2} |
| 18:30 | m1dnight | yes sir indeed :) |
| 18:30 | m1dnight | thanks guys |
| 18:30 | Glenjamin | i've got a map in an atom {:a a, :b b}, where (= (f a) b) always holds but is expensive to calculate on demand |
| 18:30 | Glenjamin | so i kinda wanted to encode that relation into the data structure |
| 18:31 | Glenjamin | but for now i'm just creating that data with a function and only updating the atom via those functions |
| 18:31 | justin_smith | Glenjamin: that sounds like a cache / memoization |
| 18:31 | Glenjamin | it is |
| 18:31 | coventry | (doc memoize) |
| 18:31 | clojurebot | "([f]); Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use." |
| 18:32 | Glenjamin | sort of |
| 18:32 | amalloy | why not just put a delay of the result in? then you don't have to calculate it unless it's needed |
| 18:32 | justin_smith | Glenjamin: what about a map from input to a delay of that input's realization? |
| 18:32 | justin_smith | jynx |
| 18:32 | Glenjamin | i get update events, and get requests can receive the previous version |
| 18:32 | Glenjamin | requests are continuous, and should get the latest value as soon as it's ready |
| 18:33 | Glenjamin | currently doing something like: new info -> ~ 10 seconds of work -> update atom with latest data |
| 18:33 | justin_smith | would you want to prevent the situation where two threads are trying to realize the same result in parallel? |
| 18:33 | Glenjamin | yes |
| 18:34 | {blake} | I'm going through the "How Clojure babies are made" article, and when I get to the lein run part, I find that lein puts nothing in the classes directory! I can't find the classes anywhere on my disc (except for the ones I made the manual build). What am I missing? |
| 18:34 | Glenjamin | {blake}: possibly ~/.m2 ? |
| 18:34 | amalloy | it's probably just really old, {blake}, like from lein 1 |
| 18:34 | Glenjamin | if i understand the question |
| 18:34 | Glenjamin | oh, i perhaps dont |
| 18:34 | {blake} | amalloy: Where'd they go? Does lein bundle the classes into...something else? |
| 18:35 | Glenjamin | justin_smith: calculating the result currently takes over all cores for some time, so doing more than one at once would be bad |
| 18:35 | rasmusto | Glenjamin, justin_smith: https://www.refheap.com/20471 maybe useful? |
| 18:35 | amalloy | i don't know what that tutorial asks you to do, so i don't know what lein does in that case :P |
| 18:35 | justin_smith | Glenjamin: a delay will only be in progress of being forced once |
| 18:35 | {blake} | It's just a "lein run". |
| 18:36 | {blake} | It goes through the manual build process to illustrate what lein does for you automatically. |
| 18:36 | Glenjamin | justin_smith: but i'd only end up deref-ing it straight away, as i dont want to update the atom until the result is ready |
| 18:36 | Glenjamin | i'd rather serve the old value |
| 18:36 | {blake} | I guess it doesn't really matter for my purposes. Just curious. |
| 18:37 | justin_smith | Glenjamin: ahh, that sounds almost more like an agent than a delay, if we are talking about "old value" and "new value" |
| 18:37 | Glenjamin | yeah, i might re-work it like that when i'm done optimising the calculation |
| 18:37 | technomancy | {blake}: classes arent generated if you don't AOT |
| 18:38 | Glenjamin | at the mo i just have to not reset! the atom until i know i'm done |
| 18:38 | Glenjamin | it's a league table for an in-play game |
| 18:38 | Glenjamin | with ~1 million players |
| 18:38 | {blake} | technomancy: Oh! So it just ... what, compiles in-memory and then discards? |
| 18:39 | technomancy | {blake}: yep |
| 18:39 | technomancy | its clojure that does that btw, not lein |
| 18:40 | Glenjamin | hrm, actually an agent doesn't really make a difference here |
| 18:41 | {blake} | Ahhhh. So maybe if I want to update this I'd have to put the AOT in there or "lein compile"? Seems like the latter should work but I don't see the class files. I'll search... |
| 18:41 | Glenjamin | i think i'm happy that calculating derived fields is just calling the right function, rather than trying to set things up so no-one can call the wrong function |
| 18:42 | turbofail | {blake}: lein will only AOT compile namespaces that you explicitly tell it to |
| 18:43 | technomancy | `lein compile` means "compile the things in :aot" which is usually nothing |
| 18:43 | justin_smith | {blake}: lein check will compile every ns, as a side effect |
| 18:43 | justin_smith | also I advise runnint lein check frequently it helps catch problems |
| 18:43 | turbofail | anyway if you want to look at the compiler output no.disassemble is way more useful/fun |
| 18:43 | justin_smith | *running |
| 18:45 | turbofail | hm. looks like bytecode exploration's not really what that article's about. oh well. |
| 18:47 | coventry | What kinds of problems is lein check useful for catching? |
| 18:48 | technomancy | lein check complects reflection warnings with compilation failures |
| 18:48 | justin_smith | coventry: code that is infrequently run but statically invalid |
| 18:48 | coventry | I see. Thanks. |
| 18:49 | technomancy | you can also do `lein compile :all` to get the latter without the former |
| 18:49 | technomancy | but then you need to clean, which is annoying |
| 18:49 | justin_smith | technomancy: oh, cool - though I actually am glad to see reflection warnings on the whole project |
| 18:50 | dbasch | turbofail: have you seen this series of posts? http://blog.guillermowinkler.com/blog/2014/04/27/decompiling-clojure-iii/ |
| 18:50 | technomancy | justin_smith: it's useful, it's just a weird way to expose it |
| 18:51 | turbofail | dbasch: yeah i read those |
| 18:52 | justin_smith | coventry: or a more concrete example, one of the top level namespaces in a lib has a bad function definition, lein check lets you find that within the lib repo, instead of finding it in an app that uses the lib |
| 18:53 | justin_smith | coventry: nothing that wouldn't be caught if you defined at least one test which required the ns, but it's still useful |
| 18:57 | rasmusto | oh god I made a nested thing |
| 19:01 | justin_smith | #onlyon#clojure |
| 19:02 | rasmusto | })})})})})})})})})})})})] in my repl |
| 19:02 | justin_smith | ahaha |
| 19:03 | justin_smith | that's some serious nesting |
| 19:03 | rasmusto | that's with :max-steps 4 :o |
| 19:03 | TimMc | Sell it as modern art. |
| 19:04 | rasmusto | ~art |
| 19:04 | clojurebot | Pardon? |
| 19:04 | coventry | ,(nth (iterate vector []) 1000) |
| 19:04 | clojurebot | [[[[[[[[[[#]]]]]]]]]] |
| 19:04 | TimMc | clojurebot is artless |
| 19:05 | rasmusto | I'm doing something like this: (loop [fns (interleave (repeat fn1) (repeat fn2)) thing blah] (recur (drop 1 fns) ((first fns) blah))) |
| 19:05 | rasmusto | :p |
| 19:05 | rasmusto | er, (map (first fns) blah) |
| 19:06 | rasmusto | It's supposed to be a breadth-first traversal of sorts? |
| 19:06 | TimMc | coventry: http://clojure-log.n01se.net/date/2014-03-25.html#18:04 |
| 19:06 | justin_smith | ,(nth (iterate (comp #(apply hash-map %) (juxt identity identity)) {}) 4) |
| 19:06 | clojurebot | {{{{{} {}} {{} {}}} {{{} {}} {{} {}}}} {{{{} {}} {{} {}}} {{{} {}} {{} {}}}}} |
| 19:07 | rasmusto | I was reading about ((.)$(.)) yesterday |
| 19:07 | justin_smith | ,(nth (iterate #(hash-map % %) {}) 4) 'doh |
| 19:07 | clojurebot | {{{{{} {}} {{} {}}} {{{} {}} {{} {}}}} {{{{} {}} {{} {}}} {{{} {}} {{} {}}}}} |
| 19:08 | justin_smith | rasmusto: that's a funny place to keep your money |
| 19:08 | rasmusto | ,(juxt identity identity identity) |
| 19:08 | clojurebot | #<core$juxt$fn__4213 clojure.core$juxt$fn__4213@1af86ae> |
| 19:08 | coventry | TimMc: You are a bad, bad man. |
| 19:09 | TimMc | :-D |
| 19:09 | TimMc | :-D :-D :-D |
| 19:09 | justin_smith | ,(nth (iterate #(hash-map % %) {}) 20) |
| 19:09 | clojurebot | {{{{{{{{{{# #} {# #}} {{# #} {# #}}} {{{# #} {# #}} {{# #} {# #}}}} {{{{# #} {# #}} {{# #} {# #}}} {{{# #} {# #}} {{# #} {# #}}}}} {{{{{# #} {# #}} {{# #} {# #}}} {{{# #} {# #}} {{# #} {# #}}}} {{{{# #} {# #}} {{# #} {# #}}} {{{# #} {# #}} {{# #} {# #}}}}}} {{{{{{# #} {# #}} {{# #} {# #}}} {{{# #} {# #}} {{# #} {# #}}}} {{{{# #} {# #}} {{# #} {# #}}} {{{# #} {# #}} {{# #} {# #}}}}} {{{{{# #} {# #}... |
| 19:10 | TimMc | justin_smith: See my link to coventry for an infinite version. |
| 19:10 | justin_smith | looking at that now... |
| 19:10 | justin_smith | I remember that |
| 19:19 | {blake} | turbofail, justin_smith, technomancy: Thanks all! |
| 19:20 | {blake} | ,(map inc (list turbofail justin_smith technomancy)) |
| 19:20 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: turbofail in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 19:20 | {blake} | eh well |
| 19:22 | justin_smith | the inc bot command is not that smart |
| 19:22 | justin_smith | (inc juxt) |
| 19:22 | lazybot | ⇒ 8 |
| 19:23 | justin_smith | I could have sworn that was more popular |
| 19:23 | rasmusto | (inc juxtin_smith) |
| 19:23 | lazybot | ⇒ 1 |
| 19:43 | andrewchambers | Hi there |
| 19:43 | andrewchambers | is there a clojurescript irc too? |
| 19:43 | justin_smith | yeah, #clojurescript |
| 19:43 | andrewchambers | has anyone benchmarked clojurescript vs clojure |
| 19:43 | andrewchambers | btw |
| 19:44 | andrewchambers | Trying to decide which to use for a project |
| 19:44 | technomancy | server-side cljs? |
| 19:44 | andrewchambers | not a server really |
| 19:44 | justin_smith | I would be surprised if clojurescript beat jvm clojure on any benchmark, but I can't cite proof |
| 19:44 | andrewchambers | Im writing a C compiler with clojure |
| 19:44 | technomancy | any benchmark but startup time or memory usage, yeah |
| 19:45 | andrewchambers | the only benefit I can think of clojurescript is deploying to web for fun |
| 19:45 | andrewchambers | if its not faster |
| 19:45 | andrewchambers | the tooling for clojurescript also seems worse |
| 19:45 | technomancy | heh, that is a generous way to put it |
| 19:46 | andrewchambers | I just tried to benchmark my start of a tokenizer in both |
| 19:46 | justin_smith | technomancy: well for a fair comparison you would want uberjar with java -jar vs. clojurescript already compiled - unless we mean dev spin up time |
| 19:46 | andrewchambers | and i couldnt even get it to work on clojurescript |
| 19:47 | justin_smith | also the lib scenario with clojure is much more solid |
| 19:47 | justin_smith | *jvm clojure (since technically all the impls are clojures) |
| 19:47 | justin_smith | andrewchambers: there is also the too often neglected CLR port of clojure |
| 19:48 | andrewchambers | yeah, i dont care too much about that since im linux dev |
| 19:48 | justin_smith | andrewchambers: it works great under mono |
| 19:48 | andrewchambers | I think most of my code is purely algorithmic |
| 19:48 | andrewchambers | so i can swap between |
| 19:48 | andrewchambers | with a little bit of effort |
| 19:50 | andrewchambers | If anyone is interested, I'm trying to reimplement my own version of this guys C compiler https://github.com/rui314/8cc in clojure. To prove to myself a clojure implemention is superior |
| 19:50 | andrewchambers | and to kind of test, the differences and benefits |
| 19:52 | andrewchambers | might be an interesting benchmark at least |
| 19:54 | technomancy | writing code to prove one technology is superior doesn't always work out well |
| 19:55 | technomancy | why not write it in order to discover the strengths and weaknesses of a given language/runtime? |
| 19:55 | technomancy | http://technomancy.us/169 |
| 19:56 | andrewchambers | I actually wrote a large part of a C compielr in python previously |
| 19:56 | andrewchambers | the immutability in clojure makes the way things are done slightly different |
| 19:56 | TimMc | technomancy: (Note: On stupidly large monitors, the "next post" arrow floats over the post's text.) |
| 19:56 | andrewchambers | like, im representing the input source as a lazy seq |
| 19:57 | andrewchambers | so implementing a recursive descent parser is a bit different |
| 19:57 | technomancy | TimMc: yeah... I should just get rid of those. I don't have the CSS chops to pull it off correctly =) |
| 20:00 | ppold | Hi guys, what is the current state of debugging in Clojure, using Emacs? |
| 20:01 | TimMc | technomancy: Another layer of indirection should do it. |
| 20:01 | technomancy | TimMc: go on?Z |
| 20:08 | TimMc | technomancy: If you enclose them in a div that is position:fixed and dropped 280 pts down the page, then float the arrows to the two ends of the div... |
| 20:08 | technomancy | TimMc: I'll give that a shot; thanks! |
| 20:08 | TimMc | But you may have to futz around with ems and pts for a bit. |
| 20:09 | technomancy | futzing is what css is all about |
| 20:09 | TimMc | technomancy: One downside: Selecting text between teh arrows may cause shenanigans. |
| 20:10 | technomancy | I'm sure it'd be better than what I have |
| 20:46 | andrewchambers | is a difference in behaviour in clojurescript and clojure a bug? |
| 20:47 | andrewchambers | if you do a (println my-lazy-seq) in clojure it pritns it as it evaluates it, if you do it in clojurescript it waits until the whole seq is generated before printing anything |
| 20:47 | justin_smith | is an insect a bug? sometimes |
| 20:47 | andrewchambers | to be more specific :) |
| 20:49 | justin_smith | I'm not sure. Maybe someone else knows. |
| 20:49 | hiredman | the jvm has streams you can print to incrementally |
| 20:50 | hiredman | js doesn't really |
| 20:50 | hiredman | the reallity of the platforms |
| 20:50 | andrewchambers | does that java console not just have a .write method |
| 20:51 | TimMc | andrewchambers: Javascript doesn't have anything like OutputStream, no. |
| 20:52 | TimMc | You can fake it with incremental output to the page, but you can't do that in the console. |
| 20:52 | andrewchambers | Well, im using the nodejs one for a command line program |
| 20:52 | andrewchambers | I guess its just used much |
| 20:52 | andrewchambers | or too hard to detect which platform you areo n |
| 20:53 | andrewchambers | not used much* |
| 21:02 | andrewchambers | well did my tests |
| 21:03 | andrewchambers | clojure with reflection took 2 minutes to process my file |
| 21:03 | andrewchambers | clojure with typehints and large heap took 22 seconds |
| 21:03 | andrewchambers | clojurescript took 3 minutes with no optimization and clojurescript took 1.5 minutes with advanced |
| 21:12 | akhudek | andrewchambers: reflection really is a killer |
| 21:12 | andrewchambers | yeah, it was on a single call to my BufferedReader |
| 21:13 | andrewchambers | since im processing a 30 meg text file |
| 21:13 | andrewchambers | though the C version does it in less than a second haha |
| 21:13 | akhudek | it’s really hard to beat C |
| 21:15 | bbloom | shouldn't be that big a disparity for a simple file parse job though... |
| 21:16 | akhudek | bbloom: including startup time possibly? |
| 21:16 | akhudek | ro rather andrewchambers |
| 21:17 | andrewchambers | yeah, but startup time is aroudn a second |
| 21:17 | andrewchambers | my PC is pretty quick at starting clojure |
| 21:17 | andrewchambers | I am using lazy seqs and other things in the clojure code |
| 21:17 | akhudek | lazy seqs slow things down |
| 21:17 | andrewchambers | so its probably just overhead from that sort of thing |
| 21:18 | andrewchambers | But thats kind of what im testing |
| 21:18 | andrewchambers | if using high level features like that negatively affect performance too badly |
| 21:18 | akhudek | in my experience they do |
| 21:18 | akhudek | it’s ok for most of the code |
| 21:19 | akhudek | but awful for the cpu intensive bits |
| 21:19 | andrewchambers | haha, well my application is pretty cpu intensive |
| 21:20 | akhudek | what is your app? |
| 21:33 | andrewchambers | compiler |
| 21:35 | technomancy | if you want to write code that sacrifices maintainability for perf, it's hard to beat http://meshy.org/2009/12/13/widefinder-2-with-clojure.html for a starting point |
| 21:36 | andrewchambers | technomancy, thanks for that link , its actually pretty applicable |
| 21:37 | technomancy | old but classic |
| 21:38 | andrewchambers | If my code is written in a way that allows some concurrency and future computers have more than 4-8 cores it might actually be faster |
| 22:02 | ivan | https://github.com/cldwalker/datomic-free/blob/master/bin/datomic-free |
| 22:03 | ivan | I find all the useful things from unrelated google searches |
| 22:04 | Jaood | talking about datomic, is there a favourite storage option for it? |
| 22:10 | wildnux | hi, i am using emacs prelude with clojure mode to learn clojure, when i type say a function and go to next line, it does not auto-indent, how do i make emacs to auto-indent? |
| 22:10 | wildnux | i am trying to learn emacs and clojure together :) |
| 22:11 | Jaood | ctrl + j |
| 22:11 | wildnux | Jaood: :) thank you |
| 22:11 | wildnux | Jaood: is there a way to make it automatic with enter key? |
| 22:13 | Jaood | wildnux: you can with some elisp I guess (I'm noob too) |
| 22:13 | wildnux | Jaood: :) no problem |
| 22:13 | Jaood | wildnux: you can ask in emacs, but I have sense that doing that is anti-emacs |
| 22:14 | Jaood | #emacs |
| 22:15 | wildnux | Jaood: in that case, i will try to remember it |
| 22:15 | Jaood | wildnux: you can change pretty much anything in emacs with elisp |
| 22:16 | Jaood | wildnux: but stick to emacs/clojure-mode defaults while learning clojure so you don't feel overwhelmed |
| 22:17 | Jaood | wildnux: this is a nice starter config https://github.com/technomancy/better-defaults |
| 22:18 | ToxicFrog | When using lein repl, how do I get it to print the entire stack trace on error by default? |
| 22:35 | technomancy | ToxicFrog: not sure, but if you figure it out could you submit a PR to add it to sample.project.clj? |
| 22:35 | technomancy | because I am so not a fan of the current behaviour |
| 22:42 | ToxicFrog | technomancy: oh, I thought this was something you'd done deliberately |
| 22:42 | technomancy | nah I use emacs for everything. trptcolin wrote the repl client. |
| 22:49 | ToxicFrog | So apparently lein uses REPLy, which in turn uses nREPL, and I'm not sure which of those the problem is in. |
| 22:49 | technomancy | ToxicFrog: it's in reply |
| 22:57 | ToxicFrog | technomancy: :repl-options { :caught pst } |
| 22:57 | technomancy | nice |
| 22:57 | ToxicFrog | That is almost correct; it prints the first line of the stack trace twice for some reason |
| 22:57 | technomancy | maybe it's in addition to whatever reply does by default |
| 22:57 | ToxicFrog | I suspect so. Still trying to figure out how to suppress that. |
| 22:57 | ToxicFrog | This is close enough for me to be content with, though. |