2016-01-19
| 00:00 | mheld | hey y'all |
| 00:01 | mheld | I have a ring handler that spits out other ring handlers (liberator resources), thus requiring to be called twice on a request to get a response — is there a better way of doing this? |
| 00:02 | mheld | so I end up having to do something nasty like this -> (fn [x] ((user-handler x) x)) and it barfs if I try to go up the stack |
| 01:45 | amalloy | well, if it returns a ring handler it's not a ring handler itself, since those return responses |
| 01:47 | amalloy | an easy solution would be to define a trampolining middleware, (defn tramp [handler] (fn [req] (let [x (handler req)] (if (fn? x) (x req) x)))), and then insert that at the appropriate place in your middleware stack |
| 01:49 | amalloy | mheld: ^ |
| 02:08 | kenrestivo | liberator is weird that way, IIRC |
| 02:08 | kenrestivo | some keys in their map want handlers, some want results, and i think some want functions that return handlers (wrappers), it's been a few years |
| 04:16 | jonathanj | i think returning a static result is just convenience for (fn [ctx] (merge ctx {:my 'values})) |
| 04:17 | jonathanj | pretty sure everything can just be a function |
| 04:17 | jonathanj | however what the function does depends on which key it is, there are decisions, actions and handlers; it's all pretty well documented |
| 04:18 | jonathanj | it doesn't really make any sense for a decision function to return a ring response because the nature of the function asking a question like "is this resource available?" |
| 04:19 | jonathanj | my biggest wish for liberator (and ring) is handling async correctly |
| 04:21 | jonathanj | (or at all) |
| 04:32 | RedNifre | Hey there. I had a brief look at Clojure and wrote a tiny program in it. It seems nice but I'm not sure if I should dive in. Do you have a link to some examples of complex/brilliant/interesting/impressive/unusual things that you can do with Clojure? I might be looking for a unique selling point so to speak. |
| 04:35 | TEttinger | RedNifre: ohoho! |
| 04:35 | TEttinger | got any unusual problems you want tackled? |
| 04:39 | TEttinger | RedNifre: you around? I'm curious what the audience for this is |
| 04:40 | TEttinger | the seq abstraction is really good at making code cleaner |
| 04:41 | TEttinger | ,(map count [{:a 1, :b 2} [1 2 3] #{:red :green :blue :beige}]) |
| 04:41 | clojurebot | (2 3 4) |
| 04:41 | jonathanj | i'm trying to remember the last time i found something brilliant or impressive in a language |
| 04:42 | jonathanj | i think it must have been Erlang |
| 04:42 | TEttinger | gave it three different kinds of collection and it could count all of them just fine |
| 04:42 | TEttinger | clojure tends to be very very short code |
| 04:46 | TEttinger | so as part of a "how short can you go" contest, |
| 04:46 | TEttinger | (let[a #(apply str(flatten %))p partition R rand-nth n #(a(R(mapcat p[1 2 3]%&)))v #(n"aioeu""iaaiaa")](a[(n"STKNYPKLGVZ""GlThShNyFtCh""ZvrCthShrMycTch")(for[_" "][(v)(n"lpstnkgxzv"(concat[(R '[h gl gr nd])(v)]"rnthggghtsltrkkhshng")"ghnlok")])])) |
| 04:46 | TEttinger | ,(let[a #(apply str(flatten %))p partition R rand-nth n #(a(R(mapcat p[1 2 3]%&)))v #(n"aioeu""iaaiaa")](a[(n"STKNYPKLGVZ""GlThShNyFtCh""ZvrCthShrMycTch")(for[_" "][(v)(n"lpstnkgxzv"(concat[(R '[h gl gr nd])1(v)]"rnthggghtsltrkkhshng")"ghnlok")])])) |
| 04:46 | clojurebot | "Kakol" |
| 04:46 | TEttinger | 250 character or less demonic name generator |
| 04:50 | schmir | TEttinger: that actually makes me want to run away from clojure |
| 04:50 | TEttinger | haha |
| 04:50 | TEttinger | it's heavily heavily obfuscated |
| 04:51 | RedNifre | Yes, I'm here, somewhat. Sorry. |
| 04:51 | TEttinger | cleaned up and long version: http://ideone.com/L0eHc6 |
| 04:51 | TEttinger | the impressive thing is some of the shorter versions have about the same features |
| 04:53 | alex`` | yeah that's pretty impressive, and the management of different sorts of types within the same function is nice too |
| 04:53 | TEttinger | it was a team effort |
| 04:53 | schmir | RedNifre: REPL based development is a unique selling point for me |
| 04:53 | TEttinger | yep |
| 04:53 | RedNifre | No, I don't have a particular problem in mind. But jonathanj mentioned Erlang, I find it impressive that it is geared towards reliability and it's interesting how actors are somewhat like OOP on top of FP. Or in Haskell I was impressed by how those hyper abstract concepts make your brain explode. Or in Kotlin I found the syntax rule "if the last parameter is a lambda you may close the paren before it" very neat because foo(x) {bla() } loo |
| 04:53 | RedNifre | ks nicer than foo(x, { bla() }) etc. |
| 04:54 | RedNifre | Don't all languages except Java have a REPL? |
| 04:54 | TEttinger | probably. clojure has a good one |
| 04:54 | TEttinger | others probably have good ones too |
| 04:54 | MasseR | RedNifre: no, not really no :) |
| 04:55 | alex`` | lispies have good REPLs |
| 04:55 | MasseR | C, C++, Java, HaXe, etc |
| 04:55 | schmir | RedNifre: I've been doing python before, which has a REPL. but clojure's REPL is *much* better |
| 04:55 | TEttinger | clojure can call java about as easily as java can call java. with macros involved, it can be easier to call java from clojure than calling java from java |
| 04:55 | schaueho | schmir, to be fair, ipython isn't exactly bad |
| 04:55 | schaueho | IMHO, of course |
| 04:55 | mpenet | it's more the advanced integration of the repl in every editor/IDE more than the repl itself |
| 04:55 | alex`` | interop is a really nice feature for commercial purpose |
| 04:56 | TEttinger | sane names. |
| 04:56 | TEttinger | one of my favorites. |
| 04:56 | schaueho | and btw, there are REPLs for Java |
| 04:56 | TEttinger | "I want something like reduce but it doesn't throw away the intermediate values" |
| 04:56 | TEttinger | "reductions" |
| 04:57 | TEttinger | "it maps and then concats" "mapcat" |
| 04:57 | schmir | schaueho: ipython is fine. but I've used that mostly to explore 3rd party libraries. when you're trying to reload your own code, I've hit a wall pretty early in python. |
| 04:57 | MJB47 | on the flip side: contains |
| 04:57 | TEttinger | "it finds the frequencies things appear in a collection" "frequences" |
| 04:57 | TEttinger | frequencies |
| 04:57 | RedNifre | Well, in Haskell you can create an infinite list of fibonacci numbers by zipping it with itself, which I find pretty wild: fibs = 1 : 1 : zipWith (+) fibs (tail fibs). Is there something like that in Clojure i.e. something that made you think "Huh, I didn't expect that could be done like that"? |
| 04:58 | TEttinger | ,(doc contains) |
| 04:58 | clojurebot | excusez-moi |
| 04:58 | TEttinger | ,(doc contains?) |
| 04:58 | clojurebot | "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'." |
| 04:58 | schaueho | schmir, agreed, although reloading can be a pain in Clojure, too |
| 04:58 | TEttinger | RedNifre: you can do the same in clojure |
| 04:59 | alex`` | RedNifre: i found a lot of stuff that surprising in clojure, even coming form lisps |
| 04:59 | RedNifre | Is it called mapcat everywhere or just for lists? E.g. I find it annoying that in Java, mapcat is called flatMap for Optionals and Streams, but it's called thenCompose on CompletableFuture. |
| 04:59 | alex`` | lazy evaluation is really good, maybe haskell partialitation is easier, tho |
| 05:02 | RedNifre | alex`` do you have an example for something surprising? |
| 05:03 | Kneiva | ,(def cats (cons 'cat (lazy-seq cats))) |
| 05:03 | clojurebot | #'sandbox/cats |
| 05:03 | Kneiva | ,(take 20 cats) |
| 05:03 | clojurebot | (cat cat cat cat cat ...) |
| 05:04 | jonathanj | RedNifre: i don't think i could tell you anything about Clojure that doesn't apply to other lisps, but i really enjoy the (almost entirely) consistent syntax |
| 05:04 | jonathanj | being able to write (if) inside a function call is something i find quite convenient and totally foreign compared to languages where if is a statement |
| 05:07 | TEttinger | ,(defn fibs ([] (fibs [1 1]) ([so-far] (conj so-far (apply + (take-last 2 so-far)))) |
| 05:07 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 05:07 | ridcully | well that fn(x) {...} bit on kotlin makes me even more believe, that it's just groovy in disguise |
| 05:07 | TEttinger | ,(defn fibs ([] (fibs [1 1])) ([so-far] (conj so-far (apply + (take-last 2 so-far))))) |
| 05:07 | clojurebot | #'sandbox/fibs |
| 05:07 | TEttinger | ,(iterate fibs) |
| 05:07 | clojurebot | #error {\n :cause "Wrong number of args (1) passed to: core/iterate"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/iterate"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval164 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$ev... |
| 05:07 | TEttinger | ,(iterate fibs [1 1]) |
| 05:07 | clojurebot | ([1 1] [1 1 2] [1 1 2 3] [1 1 2 3 5] [1 1 2 3 5 ...] ...) |
| 05:08 | TEttinger | ,(nth (iterate fibs [1 1]) 20) |
| 05:08 | jonathanj | except isn't recursion without (recur) usually a mistake? |
| 05:08 | clojurebot | #error {\n :cause "Unable to resolve symbol: fibs in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: fibs in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: fibs in this co... |
| 05:08 | TEttinger | yes |
| 05:08 | TEttinger | it isn't iterating here |
| 05:08 | scottj | ,(do (def fibs' (lazy-cat [0 1] (map + fibs' (rest fibs')))) (take 10 fibs')) |
| 05:08 | clojurebot | (0 1 1 2 3 ...) |
| 05:08 | TEttinger | ah, lazy-cat |
| 05:08 | TEttinger | that's what I was looking for |
| 05:08 | mpenet | error messages could be nicer. It doesnt matter much once you get used to it, but a 300 line stacktrace isn't very welcoming to somebody trying it out |
| 05:08 | jonathanj | RedNifre: i think Clojure's pragmatism is kind of a hard sell to make but it's incredibly valuable |
| 05:09 | TEttinger | indeed |
| 05:09 | ridcully | mpenet: +1 |
| 05:09 | TEttinger | there's lots of "make your life easier" tools |
| 05:10 | mpenet | personnally I dont mind the stacktraces, but for somebody with 1h clojure experience I doubt installing libs for better output is something reasonable |
| 05:11 | mpenet | but I think I've hear it's something we might get sometime soon (whatever "soon" means heh) |
| 05:11 | jonathanj | mpenet: really? where did you hear that? |
| 05:12 | jonathanj | i've managed to become conversationally fluent in reading clojure stack traces but boy i would love for them to be better |
| 05:12 | mpenet | I think on twitter or slack |
| 05:13 | mpenet | well, sometimes scrolling through 1km of noise from the compiler to get to 1 line is a tiny bit annoying |
| 05:13 | mpenet | I guess having different output levels could make sense |
| 05:14 | mpenet | if you work on core you might want the over chatty stacktraces |
| 05:14 | jonathanj | i don't really know if this is doable but reading stacktraces caused by async code is basically meaningless garbage |
| 05:14 | jonathanj | in other words, you get a stacktrace that occurs in exactly zero of your own code |
| 05:15 | jonathanj | it would be really nice to be able to tell where the call originated from, but that's possibly more of a JVM requirement than a Clojure compiler one |
| 05:21 | alex`` | i prefer common lisp error reports more than java ones |
| 05:22 | alex`` | unfortunately, clojure took the java ones |
| 05:24 | jonathanj | was that even a choice? |
| 05:24 | alex`` | i guess not, the JVM has counterparts |
| 05:29 | jonathanj | ,(if-let [[x y] [0 nil]] :a :b) |
| 05:29 | clojurebot | :a |
| 05:29 | jonathanj | ,(if-let [[x y] nil] :a :b) |
| 05:30 | clojurebot | :b |
| 05:30 | lnostdal | with some overhead ("debug mode") i'm sure closures and stuff could have metadata needed for filename, line + col number etc. added to them |
| 05:30 | lnostdal | jvm or not doesn't matter i think |
| 05:31 | jonathanj | to be honest i'd be a bit hesitant about slapping "debug mode" on that kind of information |
| 05:31 | lnostdal | why? |
| 05:31 | clojurebot | why is the ram gone |
| 05:31 | jonathanj | having that information in a production environment would be just (if not more) useful |
| 05:32 | lnostdal | sure in some cases i guess, but that wasn't the point |
| 08:07 | visof | hi guys |
| 08:07 | visof | is there anybody using archimedis? |
| 09:56 | visof | is there a method which partition [1 2 3 4] to [[1 2] [2 3] [3 4]] ? |
| 09:56 | aurelian | partition |
| 09:56 | visof | ,(partition [1 2 3 4]) |
| 09:56 | clojurebot | #error {\n :cause "Wrong number of args (1) passed to: core/partition"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/partition"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox... |
| 09:57 | visof | ,(partition 2 [1 2 3 4]) |
| 09:57 | clojurebot | ((1 2) (3 4)) |
| 09:57 | aurelian | partition with a twist :) |
| 09:57 | ridcully | ,(partition 2 1 [1 2 3 4]) |
| 09:57 | clojurebot | ((1 2) (2 3) (3 4)) |
| 09:58 | visof | ah thanks |
| 09:59 | aurelian | ,(doc partition) |
| 09:59 | 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." |
| 10:30 | dadinn | hi all |
| 10:30 | dadinn | I am trying to use clojure.data.zip.xml |
| 10:31 | dadinn | xml-> specifically |
| 10:31 | dadinn | and it doesn't seem to work at all |
| 10:31 | dadinn | I parsed html with crouton |
| 10:32 | dadinn | turned it into zipper with clojure.zip/xml-zip |
| 10:32 | dadinn | but xml-> returns nothing but empty lists |
| 10:33 | dadinn | is this a known issue I missed? |
| 11:02 | csd_ | I have a defrecord that is implementing an interface that only throws FooException. If I instantiate that record with a function that instead calls BarException, what happens? |
| 11:10 | juanjo_ | hi |
| 11:10 | juanjo_ | how can I add to leingen dependencies a path lo a local repo of a lib i'm trying to debug= |
| 11:10 | juanjo_ | ? |
| 11:14 | mpenet | juanjo_: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies |
| 11:20 | juanjo_ | thanks mpenet |
| 11:58 | dadinn | hi all |
| 11:58 | dadinn | could anyone help with a bit of html parsing with zippers? |
| 12:00 | dadinn | I specifically have issues with clojure.data.zip.xml/xml-> |
| 12:01 | dadinn | I have the following code: |
| 12:01 | dadinn | (ns stuff |
| 12:01 | dadinn | (:require [org.httpkit.client :as http] |
| 12:01 | dadinn | [clojure.data.xml :as xml] |
| 12:01 | dadinn | [crouton.html :as html] |
| 12:01 | dadinn | [clojure.zip :as z] |
| 12:01 | dadinn | [clojure.data.zip.xml :as zx])) |
| 12:02 | dadinn | (def res2 (http/get "http://help.websiteos.com/websiteos/example_of_a_simple_html_page.htm")) |
| 12:02 | dadinn | (def body2 (:body @res2)) |
| 12:02 | dadinn | (det xdat2 (html/parse-string body2)) |
| 12:02 | dadinn | (def zdat2 (z/xml-zip xdat2)) |
| 12:02 | ridcully | whoa |
| 12:02 | ridcully | could you please use some paste site? |
| 12:02 | dadinn | sorry |
| 12:03 | dadinn | one last line: |
| 12:03 | dadinn | (zx/xml1-> zdat2 :html :title zx/text) |
| 12:03 | dadinn | this one is not returning what I would expect instead an () empty list |
| 12:04 | dadinn | what I am doing wrong (besides pasting multiple line to the channel :))? |
| 12:12 | dadinn | hi |
| 12:13 | dadinn | trying again, would need some help with clojure.data.zip.xml: http://pastebin.com/D3UzTA2Y |
| 12:13 | dadinn | can anyone help why its not returning the title of the html? |
| 12:14 | dadinn | thanks |
| 12:15 | dadinn | plz |
| 12:17 | luxbock | dadinn: maybe you are thinking that xml1-> works like ->, when based on the doc string it seems more analogous to cond-> ? |
| 12:18 | luxbock | I haven't used clojure.data.zip.xml before so it's hard to say for me |
| 12:18 | dadinn | can I ask for some help with xml zippers? |
| 12:19 | luxbock | dadinn: do you know how zippers work in general? |
| 12:20 | dadinn | luxbock: yes I used zip-filter a year ago and it was working then only now it seems I am trying to do the same what then but it doesn't work |
| 12:21 | dadinn | luxbock: this is the example code: http://pastebin.com/D3UzTA2Y |
| 12:23 | dadinn | I would like to get the text of the title, I remember using xml-> or xml1-> before but it returns an empty list not what I would expect |
| 12:25 | dadinn | I've been trying to figure what I am doing wrong for days but couldn't get it to work :( |
| 12:26 | luxbock | yeah I'm not sure, I've used zippers before but not with xml |
| 12:26 | dadinn | any ideas? |
| 12:30 | luxbock | dadinn: I'd just try to break down what you're doing into smaller and smaller parts while testing at the REPL where things go awry |
| 12:31 | dadinn | I'we used xml-> when it was part of contrib zip-filter and I've been using it to extract gigabytes of xml elements and in ETL kind of processing with xml-> parallelly and I am completely surprised why this is not working, what I am doing wrong |
| 12:32 | luxbock | dadinn: if you're using Emacs, the debugger that comes with Cider is pretty awesome |
| 12:33 | dadinn | luxbock: it doesn't really go awry only that xml-> returns empty list, and xml1-> nil |
| 12:34 | luxbock | by awry I meant find the point where your expectation deviates from what actually happens |
| 12:34 | dadinn | luxbock: the httpkit, crouton parser part works fine until xml-> |
| 12:37 | dadinn | luxbock: possibly I am using the xml-> wrong, but I don't know how else it should be used, it's according to the docs keywords should be transformed into tag= matchers, so it should be working... |
| 12:37 | luxbock | dadinn: so you need to zoom in, use the source |
| 12:46 | dadinn | lukbock: I understand, but if the source of clojure.data.zip needs to be modified for it to work then I would call it a bug... and it was working before... I came here hoping that the answer would be that I am doing something wrong instead :( |
| 12:48 | Kamuela | What is the rails of Clojure? Not necessarily the same design pattern, but certainly the relative popularity? |
| 12:48 | ecelis | Kamuela: for web development I have used luminus |
| 12:49 | mavbozo | luminus |
| 12:50 | MJB47 | clojure typically likes to go with picking a choosing various libraries |
| 12:50 | MJB47 | compared to using a framework |
| 12:50 | MJB47 | luminous is the closest you have, but it is actually a collection of libraries and some documentation around them |
| 12:50 | MJB47 | it isnt a framework |
| 12:50 | ridcully | dadinn: leave out the :html |
| 12:51 | ridcully | dadinn: or rather use :head instead of :html |
| 12:52 | mavbozo | MJB47, it's not a framework but a tasty omakase that yogthos creates |
| 12:52 | mavbozo | (inc yogthos) ;; i hope it works |
| 12:52 | mavbozo | ,(inc yogthos) ;; i hope it works this time |
| 12:53 | clojurebot | #error {\n :cause "Unable to resolve symbol: yogthos in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: yogthos in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: yogthos i... |
| 12:53 | dadinn | :ridcully thanks that was the problem indeed |
| 12:53 | justin_smith | mavbozo: inc is done by lazybot, who is on long term vacation |
| 13:02 | Kamuela | Thank you |
| 13:08 | sdegutis | Hi. |
| 13:08 | sdegutis | Good day. |
| 13:08 | sdegutis | I mean good day to all of you here. |
| 13:16 | mavbozo | sdegutis, good day to you too |
| 13:17 | sdegutis | Thanks :) |
| 15:49 | engblom | Thread/sleep seem to not be able to wake the thread up fast enough if one got really small values like (Thread/sleep 0.1). Is there any busy waiting alternative that would be faster? |
| 15:50 | amalloy | 0.1 is a pretty strange integer |
| 15:50 | justin_smith | engblom: with a value that low, aren't you dealing with the time slice of the OS itself? |
| 15:50 | justin_smith | that too |
| 15:51 | amalloy | anyway you can't ever expect timing stuff like that to be precise. at any moment your thread might be descheduled for whatever reason, maybe the user is rendering six video files at once and the OS decides your program is boring |
| 15:52 | amalloy | so instead, ask *why* you want a sleep precision of a tenth of a millisecond, and then maybe find a solution that is possible to the real problem |
| 15:52 | justin_smith | there is (Thread/sleep 0 500000) which I think would do what that intends? |
| 15:53 | engblom | justin_smith: Where do you find documentation about Thread/sleep? |
| 15:53 | amalloy | it might, anyway. microsleep support depends on platform |
| 15:53 | amalloy | $google javadoc thread |
| 15:53 | amalloy | er |
| 15:53 | justin_smith | engblom: javadoc https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html |
| 15:53 | amalloy | someone restart that bot pls |
| 15:54 | justin_smith | engblom: one arg is long millis, two args is long millis followed by int nanos |
| 15:54 | engblom | Thanks! |
| 15:54 | justin_smith | but you still have to wrestle the OS for time slices that small if they need to be accurate |
| 15:56 | justin_smith | engblom: for linux kernel the smallest unit reliable would be 100ms if I read this right |
| 15:56 | justin_smith | http://stackoverflow.com/questions/16401294/how-to-know-linux-scheduler-time-slice |
| 15:58 | justin_smith | "Timeslice will be always between sysctl_sched_min_granularity and sysctl_sched_latency, which are defaults to 0.75 ms and 6 ms respectively and defined in kernel/sched/fair.c." |
| 15:59 | hiredman | a technique used sometimes to stall a thread for a small amount of time on the jvm is to busy loop for a small amount of time |
| 16:00 | hiredman | that also isn't predictable because of the jit, and also because to cpus, that kind of code can end up looking like an idle run loop for the os so the cpu may go in to a lower power state |
| 16:01 | hiredman | (amazing hear say) |
| 16:07 | nuttynutnut | what's a good way of removing all parts of a string that don't match a regex? i was trying something like this but keep getting "error: null" (filter #(re-matches #"\w" %) "Have a nice day.") |
| 16:07 | nuttynutnut | ,(filter #(re-matches #"\w" %) "Have a nice day.") |
| 16:07 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.CharSequence> |
| 16:08 | nuttynutnut | oo lambabot gives a better error message than light table |
| 16:08 | nuttynutnut | still not sure what the problem is though |
| 16:08 | amalloy | what is a "part of a string"? "Have a" doesn't match the regex \w either |
| 16:08 | nuttynutnut | or if this is even the best way of doing this |
| 16:09 | hiredman | ,(seq "Have a nice day.") |
| 16:09 | clojurebot | (\H \a \v \e \space ...) |
| 16:09 | nuttynutnut | isn't \w [a-zA-Z0-9_]? |
| 16:09 | nuttynutnut | i just want all the letters, numbers, and spaces |
| 16:09 | amalloy | yes, and "Have a" is six characters |
| 16:09 | nuttynutnut | i dont get it |
| 16:10 | amalloy | so you want (re-seq #"\w" "Have a nice day") |
| 16:10 | nuttynutnut | oh |
| 16:10 | nuttynutnut | ,(re-seq #"\w" "Have a nice day") |
| 16:10 | clojurebot | ("H" "a" "v" "e" "a" ...) |
| 16:10 | nuttynutnut | o |
| 16:10 | nuttynutnut | i still need the spaces |
| 16:10 | nuttynutnut | where did the space go |
| 16:12 | matthavener | \w doesn't match spaces |
| 16:12 | matthavener | ,(re-seq #"." "Have a nice day") |
| 16:12 | clojurebot | ("H" "a" "v" "e" " " ...) |
| 16:12 | pbx | ,(re-seq #"[\w ]" "have a nice") |
| 16:12 | clojurebot | ("h" "a" "v" "e" " " ...) |
| 16:13 | hiredman | ,*clojure-version* |
| 16:14 | clojurebot | {:major 1, :minor 8, :incremental 0, :qualifier nil} |
| 16:14 | amalloy | did 1.8 just come out? |
| 16:15 | nuttynutnut | \w doesnt match spaces? |
| 16:15 | hiredman | amalloy: yep |
| 16:15 | nuttynutnut | "\w stands for "word character". It always matches the ASCII characters [A-Za-z0-9_]" |
| 16:15 | lokien_ | amalloy: clojure 1.8? |
| 16:15 | nuttynutnut | am i missing something or is java's regex different |
| 16:15 | amalloy | nuttynutnut: are you aware of what character _ is? |
| 16:15 | nuttynutnut | oooooo |
| 16:15 | nuttynutnut | lol |
| 16:15 | nuttynutnut | got it |
| 16:15 | lokien_ | and new site! my god, so excited |
| 16:16 | amalloy | the site certainly looks a lot nicer |
| 16:16 | lokien_ | and looks good on mobile too |
| 16:17 | lokien_ | but.. where is j-pb? |
| 16:29 | hiredman | https://vimeo.com/65102395 is a really neat doug lea talk that touches on how long it takes to just wake up a thread, and some different idling approaches |
| 16:32 | momerath | i have what amounts to a style question: I have some types and compound types, which need to be 'serialized' to basic edn, throwing away some information in the process, which I don't need for my current purposes (shipping out to a visualization in clojurescript). The types already implement toString to output compact human readable forms, which in some cases elide the bulk of the data. Is there |
| 16:32 | momerath | some other existing interface that would be idiomatic? Some library? Just a term other than 'serialize' that's less misleading? |
| 16:37 | amalloy | it's a bit like marshaling, or encoding |
| 16:43 | engblom | How soon is leiningen usually catching up with the newest release of Clojure? |
| 16:43 | hiredman | in what context? |
| 16:44 | hiredman | projects that build using lein specify which clojure version they want to use |
| 16:44 | amalloy | 0.1 milliseconds after a clojure version is released, you can use it with lein |
| 16:45 | hiredman | well, as soon as it is up in a maven repo |
| 16:45 | amalloy | i'm choosing to call that the release |
| 16:45 | amalloy | really i just wanted a cheap 0.1ms joke for engblom |
| 16:46 | engblom | :) |
| 17:09 | Kamuela | What construct is identified like #’thing-here |
| 17:09 | rhg135 | var |
| 17:09 | hiredman | it is #' |
| 17:09 | amalloy | ,#'x |
| 17:09 | amalloy | er |
| 17:09 | clojurebot | #error {\n :cause "Unable to resolve var: x in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve var: x in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve var: x in this context"\n :at ... |
| 17:09 | amalloy | ,'#'x |
| 17:09 | clojurebot | (var x) |
| 17:09 | rhg135 | #,+ |
| 17:10 | rhg135 | ,#+ |
| 17:10 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 17:10 | rhg135 | uh, I can't type |
| 17:10 | hiredman | #’ (hash followed by, what I think is the unicode prime mark) isn't anything |
| 17:11 | hiredman | #' is var quote, and #' followed by the name of a var, is the var |
| 17:11 | hiredman | ,#'+ |
| 17:11 | clojurebot | #'clojure.core/+ |
| 17:11 | hiredman | ,(deref #'+) |
| 17:11 | clojurebot | #object[clojure.core$_PLUS_ 0x74070ee9 "clojure.core$_PLUS_@74070ee9"] |
| 17:11 | hiredman | ,+ |
| 17:11 | clojurebot | #object[clojure.core$_PLUS_ 0x74070ee9 "clojure.core$_PLUS_@74070ee9"] |
| 17:14 | hiredman | and the difference between (var +) and #'+ is one is a list that needs to be evaluated to get a var, and the other is a var |
| 17:16 | Kamuela | so is it a reference to this var? |
| 17:16 | amalloy | hiredman: i'm not so sure about this last one. they're both a list that needs to be evaluated |
| 17:16 | amalloy | #'+, unevaluated, is just turned by the reader into (var +) |
| 17:17 | amalloy | ,(= '(var +) '#'+) |
| 17:17 | clojurebot | true |
| 17:18 | hiredman | amalloy: huh, and there is commented out code for it that does return the var |
| 17:18 | hiredman | which was commented out in 2009, so I am just wrong and I don't know why |
| 17:39 | Kamuela | Ok thank you |
| 17:39 | Kamuela | Finally separated out routes to different files in luminus |
| 17:42 | Kamuela | I’m wondering if my development setup is correct, does changing code require a rebuild? |
| 17:51 | justin_smith | Kamuela: depends, do you have anything that auto-loads changed code? |
| 17:52 | Kamuela | justin_smith: what do you mean? basically I’m running luminus with lein within nightcode |
| 17:54 | justin_smith | Kamuela: I mean there is nothing inherent about a standard setup that would auto reload anything |
| 17:55 | Kamuela | that’s what I figured, so basically a rebuild is what’s required |
| 17:56 | justin_smith | Kamuela: well, depends what you mean by "rebuild" - at the very least it requires reloading your changed namespaces, it could require restarting the server or ensuring that you use a var rather than just a function as your handler |
| 17:59 | Kamuela | well, right now I am clicking “stop” and “run” which I admit, i’m not totally sure what it’s doing. i do know that a stop/run procedure is needed when I change code and it seems to take a very long time to start up again |
| 18:00 | Kamuela | so I figured I may just be doing something inefficiently |
| 18:01 | justin_smith | yeah, stop and run is going to be the slowest thing, if you make sure your handler is a var and not function (eg (start-web-server #'handler) rather than (start-web-server handler)) then reloading the apropriate namespaces will suffice, and is much faster |
| 18:11 | sdegutis | Someone wanna change the topic? |
| 18:11 | sdegutis | Clojure 1.8 is out. |
| 18:12 | sdegutis | I forgot alex's IRC nick. |
| 18:12 | justin_smith | sdegutis: it's not on maven yet? |
| 18:12 | sdegutis | http://search.maven.org/#artifactdetails%7Corg.clojure%7Cclojure%7C1.8.0%7Cjar |
| 18:12 | sdegutis | ping puredanger |
| 18:13 | sdegutis | I hope this translates into CIDER! |
| 18:13 | sdegutis | I mean, I hope CIDER gets slimmer, or something. |
| 18:14 | justin_smith | cidr |
| 18:15 | sdegutis | haha |
| 18:15 | sdegutis | cidr.io |
| 18:16 | justin_smith | sdegutis: odd, 1.8.0 still not showing up here http://mvnrepository.com/artifact/org.clojure/clojure |
| 18:16 | sdegutis | Hmm. |
| 18:17 | puredanger | That stuff gets added by some batch system - usually takes a day or two |
| 18:17 | amalloy | that's an indexer |
| 18:18 | rhg135 | cool |
| 18:20 | amalloy | quote now throws if passed more or less than one arg - dang, that's an old bug to finally fix |
| 18:21 | justin_smith | :message java.lang.NoClassDefFoundError: IllegalName: compile__stub.clj_http.headers.clj-http.headers/HeaderMap, compiling:(clj_http/headers.clj:105:1) |
| 18:21 | justin_smith | interesting |
| 18:23 | amalloy | looks like some pretty good stuff in 1.8 |
| 18:23 | amalloy | http://dev.clojure.org/jira/browse/CLJ-1208 was a common cause of confusion |
| 18:24 | justin_smith | hmm, the namespace getting that error uses potemkin |
| 18:25 | ashnur | can someone please tell me in a few words what is the relationship between edn, transit, datascript ? |
| 18:26 | sdegutis | ashnur: edn and transit are json alternatives, datascript is an in-browser datomic-like thing |
| 18:26 | sdegutis | also datomic uses both edn and transit iirc |
| 18:26 | ashnur | datascript is a database? |
| 18:26 | ashnur | holy shit |
| 18:26 | ashnur | it writes on the github page |
| 18:26 | justin_smith | regarding the above error with clj-http when using 1.8.0, updating to a newer clj-http fixed it |
| 18:26 | ashnur | but somehow i missed it |
| 18:27 | sdegutis | "Immutable database and Datalog query engine for Clojure, ClojureScript and JS" |
| 18:27 | sdegutis | first few words |
| 18:27 | sdegutis | :D |
| 18:27 | ashnur | yeah :( sorry |
| 18:28 | sdegutis | I'm excited to figure out how Clojure 1.8 can help us! |
| 18:42 | puredanger | ashnur: I wrote some stuff about transit and edn (and fressian) at https://groups.google.com/d/msg/clojure/9ESqyT6G5nU/2Ne9X6JBUh8J if you're interested |
| 18:43 | ashnur | reading it, thanks |
| 19:12 | ashnur | puredanger, thanks, that was exactly what i needed to orient myself :) |
| 19:19 | leavesofgrass | if I have a ref foo and add a watch to it that updates another ref bar, will it do it in a transaction if I change foo in a dosync block? |
| 19:26 | justin_smith | leavesofgrass: I was curious so I tried it. the watcher is not run inside the transaction. https://gist.github.com/noisesmith/653e2280be728ab3909f |
| 19:31 | leavesofgrass | justin_smith cool, thanks |
| 19:31 | leavesofgrass | (i could/should have tried it though, lol) |
| 19:32 | leavesofgrass | was afraid of it maybe not giving me an exception but not running in a transaction at the same time, which I now realize doesn't make sense |
| 19:34 | justin_smith | leavesofgrass: of course I would only have shared the example if it proved one way or another that it was/wasn't in a transaction |
| 19:36 | leavesofgrass | I know, thanks a lot |
| 20:18 | jarjar_p_ | (wave) |
| 20:18 | jarjar_p_ | I'm trying to enable compiler options in my project file |
| 20:18 | jarjar_p_ | "Can't change/establish root binding of: *compiler-options* with set" and getting this error |