2015-07-25
| 00:00 | TEttinger | I can kinda tell what's going on |
| 00:00 | TEttinger | ,(let [o *] (Math/floor (o (o (o 1/2))))) |
| 00:00 | clojurebot | 0.0 |
| 00:00 | TEttinger | ,(let [o /] (Math/floor (o (o (o 1/2))))) |
| 00:00 | clojurebot | 2.0 |
| 00:02 | TEttinger | so it either repeats 0 times for * |
| 00:02 | TEttinger | err |
| 00:02 | TEttinger | repeats n times for * |
| 00:02 | TEttinger | or n + 2 times for / |
| 00:03 | justin_smith | yup |
| 00:03 | justin_smith | that's so we get the right answer no matter which one gets picked |
| 00:04 | TEttinger | ,(/ (/ 3)) |
| 00:04 | clojurebot | 3N |
| 00:04 | TEttinger | ,(* (* 3)) |
| 00:04 | clojurebot | 3 |
| 00:05 | kavkaz | How do I calculate the sqare root of a number in Clojure? |
| 00:05 | justin_smith | ,(Math/sqrt 2) |
| 00:05 | clojurebot | 1.4142135623730951 |
| 00:05 | TEttinger | kavkaz: typically you use the built in stuff in Java's Math class |
| 00:05 | TEttinger | like justin_smith demonstrated |
| 00:05 | justin_smith | TEttinger: remember reduce supplies two args - that's the last bit to solving the whole thing |
| 00:05 | TEttinger | Math does not have a cube root, but it does have pow |
| 00:06 | kavkaz | Oh I see, thanks justin_smith, TEttinger |
| 00:06 | kavkaz | I thought I tried the same thing before, but trying it again in the REPL showed me i had a typo |
| 00:06 | TEttinger | ,(reduce * [2 2]) |
| 00:06 | clojurebot | 4 |
| 00:07 | TEttinger | ,(reduce / [2 2 2 2]) |
| 00:07 | clojurebot | 1/4 |
| 00:07 | TEttinger | ah |
| 00:07 | justin_smith | and there you have it |
| 00:07 | TEttinger | ,(/ (reduce / [2 2 2 2])) |
| 00:07 | clojurebot | 4N |
| 00:07 | TEttinger | ,(* (reduce * [2 2])) |
| 00:07 | clojurebot | 4 |
| 00:07 | TEttinger | neat |
| 02:44 | TEttinger | justin_smith: re: core.matrix I think it's a great idea but I don't know how it interops with existing java code that produces 2d primitive arrays? |
| 02:45 | justin_smith | TEttinger: it's a protocol, at least one of the backing implementations uses jblas |
| 02:48 | crocket | Is clojurescript ok for making command line apps? |
| 02:51 | TEttinger | hm. vectorz has an impl for double arrays (1D I think) being "vectorizable" |
| 03:19 | crocket | Does clojurescript run on node.js without much hassle? |
| 03:36 | crocket | Can reader monad be an idiomatic construct in clojure? |
| 03:38 | crocket | Reader monad can pass log config data down to the function at the bottom of a call stack without adding the log config to every function in the middle. |
| 03:39 | crocket | Reader monad obviates global log config var. |
| 03:47 | xtrntr | hi, i tried this example on rosetta code |
| 03:47 | xtrntr | it doesn't work |
| 03:47 | xtrntr | http://rosettacode.org/wiki/Draw_a_sphere#Clojure |
| 03:47 | xtrntr | "could not locate quil/core_init.class or quil/core.clj on classpath" it says |
| 03:50 | xtrntr | i followed the instructions on the quil homepage too, met with the same problem |
| 04:00 | oddcully | xtrntr: have you started with the lein template as described here: https://github.com/quil/quil/wiki/Installing ? |
| 04:43 | xtrntr | oddcully: sorry for the late reply |
| 04:43 | xtrntr | i saw that page and yea it works for me now :) |
| 04:49 | xtrntr | the example on the page works, not the rosetta code snippet |
| 04:49 | xtrntr | will -try- at it |
| 05:21 | kwladyka | i stack during write algorithm, i recursive problems :P Do you know good pattern or best practice to write complex algorithms? I don't know, like draw this on paper or something. I am looking new creative things which will help me solve it. |
| 05:52 | crocket | How do I pass log config to every log function concisely? |
| 05:53 | crocket | log/info(log-config "ok, log this")? |
| 05:53 | crocket | This is not working well. |
| 05:53 | crocket | You're going to use a global object, or pass log-config everywhere. |
| 05:53 | crocket | What else do we have in clojure? |
| 05:55 | TEttinger | you may be able to set a log-config as a default? what logger are you using? |
| 06:06 | crocket | TEttinger2, I currently use tools.loggin and unilog. |
| 06:06 | crocket | I even contribute to unilog. |
| 06:06 | crocket | It uses logback. |
| 06:06 | crocket | It's not going to work on clojurescript. |
| 06:28 | kwladyka | it is maybe stupid question, but i am totally confuse now... When use for and when use loop with recur? i have some situations where i am not sure which one should i use in algorithm. |
| 06:29 | kwladyka | i need to build tree of solutions, like backtracking |
| 06:30 | kwladyka | and some of branch will fail so shouldn't be show as result |
| 06:30 | kwladyka | but some will pass |
| 06:31 | kwladyka | oh... it is just complex :) |
| 06:31 | kwladyka | maybe i will find something in the Internet |
| 06:45 | crocket | Reader monad for the win |
| 06:49 | wasamasa | crocket: stuart sierra's component library gives you dependency injection to solve that problem |
| 06:55 | xtrntr | i get this error when following the clojurescript tutorial |
| 06:55 | xtrntr | Error: Could not find or load main class clojure.main |
| 06:55 | xtrntr | when i try to run java -cp cljs.jar:src clojure.main build.clj in termianl |
| 06:56 | xtrntr | using os X |
| 06:56 | xtrntr | anyone knows why? |
| 07:34 | jaarod | hi.. if you are typed clojure user, are you using it everywhere in your new code? |
| 07:35 | xtrntr | oh :( |
| 07:39 | crocket | Is component sort of reader monad? |
| 07:49 | crocket | If a library uses clojure 1.6 and another uses 1.7, will there be a problem? |
| 08:23 | stian | crocket: clojure rarely breaks backward compatibility, 99% of the time stuff just works after an upgrade without any changes. |
| 08:25 | crocket | If A requires clojure 1.6 and B requires 1.7 and C requires A and B, C will end up requiring 1.6 and 1.7. |
| 08:26 | crocket | JVM wasn't known to handle multiple versions of the same dependency well. |
| 08:27 | crocket | stian, ^^ |
| 08:28 | justin_smith | "If A requires clojure 1.6 and B requires 1.7 and C requires A and B, C will end up requiring 1.6 and 1.7." - no, this is 100% wrong |
| 08:28 | crocket | Then, what |
| 08:28 | justin_smith | one of the versions is picked, the logic for picking one is up to the tool (likely lein in your case) |
| 08:29 | justin_smith | the primary job of lein is to take your project.clj and build a classpath. Only one of those deps will end up in the classpath it generates. |
| 08:29 | crocket | If 1.6 and 1.7 are incompatible, what happens? |
| 08:29 | justin_smith | crocket: then you are fucked. But they are compatible, so you are fine. |
| 08:29 | stian | crocket: afaik, it will use the clojure version defined in your project, not the one defined in the library. |
| 08:30 | justin_smith | stian: yes, if you explicitly have a top level dep, it will override transitive deps (with some caveats) |
| 08:30 | crocket | I don't like this. |
| 08:31 | justin_smith | crocket: feel free to find a language ecosystem where libs don't have versions. |
| 08:31 | crocket | justin_smith, I think it makes sense to be able to load two versions of the same dep. |
| 08:31 | crocket | npm does that. |
| 08:31 | justin_smith | and it sucks |
| 08:32 | justin_smith | crocket: note that with clojure on node, you can't have two versions of the same namespace |
| 08:32 | crocket | Is it ok to use OSGi to load multiple versions of the same dep? |
| 08:32 | crocket | Ah, right |
| 08:32 | justin_smith | crocket: it's possible, and it sucks. |
| 08:33 | crocket | namespace doesn't support versions. |
| 08:33 | justin_smith | right |
| 08:33 | crocket | This is very common. |
| 08:33 | crocket | A depends on logback 0.9, and B depends on logback 1.3.3. |
| 08:34 | crocket | logback 0.9 is incompatible with 1.3.3 |
| 08:34 | crocket | Then, I can't depend on both A and B. |
| 08:34 | justin_smith | there's an experimental version of clojure from rritoch that supports multiple versions of a namespace via osgi, but I don't really think the result is worth the complexity |
| 08:35 | crocket | I wish Rich Hickey solved that problem up front. |
| 08:35 | justin_smith | he did, the solution is not to support multiple versions of one namespace |
| 08:36 | crocket | That's not a solution |
| 08:37 | crocket | It amounts to declaring that it's a non-problem. |
| 08:37 | crocket | no problem, no solution. |
| 08:37 | justin_smith | there's no way of allowing multiple versions of a namespace in one process that is better than not having the feature |
| 08:46 | crocket | I don't think Rich Hickey would accept OSGi... |
| 08:46 | crocket | He tries to be conservative. |
| 08:46 | crocket | bruncol, You just sent me a spam message. |
| 08:47 | crocket | Are you on windows? |
| 08:53 | crocket | justin_smith, Do you know reader monad, typeclass, and dependency injection? |
| 09:09 | justin_smith | I'm familiar with these concepts to various degrees... |
| 09:10 | justin_smith | in clojure we use protocols and multimethods instead of typeclasses |
| 09:12 | justin_smith | crocket: typically when I think I need a monad what I end up with is an extra parameters or bindings map that each "monadic" function takes and passes to other functions |
| 09:15 | crocket | Passing log-config to every function that doesn't need to log is not right. |
| 09:15 | crocket | I'm not sure how reader monad is different from dependency injection like component. |
| 09:15 | crocket | I'll have to learn. |
| 09:16 | justin_smith | it is a form of dependency injection, but used in a different way of course |
| 09:17 | justin_smith | crocket: so the alternative to passing the logging config to every function is to use a monad which lifts every function into a thing that holds the logging config? |
| 09:18 | crocket | could be |
| 09:18 | crocket | My guess |
| 09:18 | crocket | I'll soon start learning those tools |
| 09:19 | crocket | justin_smith, What do you think is the best way to handle log config without introducing impurity? |
| 09:19 | crocket | A global var doesn't sound right |
| 09:19 | justin_smith | crocket: one problem with monads in clojure is that unlike haskell, clojure is a very naive compiler, so monads are inevitably slow because they replace the call stack with a less efficient abstraction |
| 09:19 | justin_smith | crocket: does the log config change during one runtime? |
| 09:19 | crocket | yes |
| 09:19 | crocket | justin_smith, Refer to timbre |
| 09:19 | justin_smith | then it's impure |
| 09:19 | crocket | timbre has a mutable var. |
| 09:19 | crocket | timbre has a mutable *log-config* |
| 09:20 | justin_smith | right, yes it does |
| 09:20 | crocket | It is even dynamic. |
| 09:20 | crocket | I currently use unilog. |
| 09:20 | crocket | logback has a similar approach. |
| 09:20 | crocket | It is worse. |
| 09:21 | crocket | Plus, monad seems to intertwine every function it touches. |
| 09:21 | crocket | Like, a phase transition. |
| 09:21 | crocket | Just like any dependency injection framework. |
| 09:21 | justin_smith | yes, once you use a monad everything using that feature has to be lifted into monad-world |
| 09:22 | crocket | justin_smith, What is your suggestion? |
| 09:22 | crocket | It is hard to avoid a global state and a global function signature change at the same time. |
| 09:23 | justin_smith | crocket: if you want something to change, and thus alter how everything works, that is a global state, no matter what fancy technique you wrap on top of it |
| 09:24 | justin_smith | so why not accept that it's global state and manage global state in a reasonable way. |
| 09:24 | justin_smith | crocket: I use timbre with the per-namespace configs |
| 09:26 | crocket | justin_smith, Just do keep in mind that the current timbre maintainer is a tyrant. |
| 09:26 | crocket | He blocks people who want changes. |
| 09:27 | crocket | How do you apply per-namespace config? |
| 09:27 | crocket | By the way, unilog maintainer is open to changes.... |
| 09:27 | justin_smith | crocket: it's a documented feature of the config |
| 09:41 | cmarques | I am trying to run tests from my editor, which is connected to a repl. My tests depend on things defined in the :test environment, however the repl is running with :dev profile. Is there any way to change the current profile when I execute the tests in a test namespace? Thanks! |
| 09:43 | justin_smith | cmarques: perhaps you could create a repl using the :test profile |
| 09:44 | justin_smith | cmarques: you can't change profiles at runtime, the profile isn't a thing that exists by the time your code is loaded - it's used to create the classpath / prep tasks / etc. that are used to launch your code |
| 09:44 | justin_smith | perhaps what you want is a runtime mechanism that changes some of the things your profile is controlling? |
| 09:44 | cmarques | justin_smith yeah, I thought about it, but then I'll need two instances of my editor running, one for each profile. It would be nice if there was a way to force the profile to be :test when I load a test file, like (load-profile :test) or something |
| 09:45 | justin_smith | cmarques: what editor? emacs at least can be connected to multiple repls |
| 09:45 | justin_smith | cmarques: like I said, the profile ceases to exist by the time your code is loaded |
| 09:45 | cmarques | justin_smith I guess that's the problem, I am using Vim with vim-fireplace |
| 09:45 | justin_smith | cmarques: what about the profile is different in your repl with :test ? |
| 09:46 | cmarques | justin_smith database connection urls |
| 09:46 | cmarques | for example |
| 09:46 | justin_smith | cmarques: I'd use a mechanism that allows runtime update - look into env for example |
| 09:46 | cmarques | justin_smith cool, I'll have a look. Thanks! |
| 09:47 | justin_smith | cmarques: my typical approach is to have separate edn files for each config, and some code that loads one of the configs when bootstrapping the code |
| 09:47 | justin_smith | cmarques: then, I can still load another config at runtime, regardless of my initial config |
| 09:48 | justin_smith | this mixes well with stuartsierra/component |
| 09:48 | cmarques | justin_smith Hum... I am trying to use environ, which seems to be doing to much magic |
| 09:48 | cmarques | justin_smith looks like your approach offers more control |
| 09:49 | justin_smith | cmarques: environ is miniscule (check out the source, there's hardly anything there) - I use environ to guide loading my defaults, but have a function that can still be used at runtime |
| 09:49 | flor-bcn | sorry, got disconnected. Asking the same question again, so I have two vectors of equal size, representing questions and answers. How do I merge the two vectors into a vector of hasmaps, something like [{:question "from v1" :answer "from v2"}] ? |
| 09:51 | justin_smith | ,(map merge [{:question "from v1"}] [{:answer "from v2"}]) |
| 09:51 | clojurebot | ({:question "from v1", :answer "from v2"}) |
| 09:52 | justin_smith | or ##(map (fn [q a] {:question q :answer a}) ["from v1"] ["from v2"]) |
| 09:52 | lazybot | ⇒ ({:question "from v1", :answer "from v2"}) |
| 09:53 | flor-bcn | justin_smith: I need each :question and :answer to come from a respective item in the vector. So first item in both vector produces {:question "my question" :answer "first answer"}, second item in both vector produces {:question "second question" :answer "second answer"}, etc |
| 09:53 | justin_smith | depending on what your input looks like |
| 09:53 | justin_smith | flor-bcn: that's what both those examples do |
| 09:53 | cmarques | justin_smith thanks for your help, I'll have a look at environ's source and see if I can come up with a way of redefining some of the values at runtime |
| 09:53 | justin_smith | ,(map (fn [q a] {:question q :answer a}) ["from v1" "also from v1"] ["from v2" "also from v2"]) |
| 09:53 | clojurebot | ({:question "from v1", :answer "from v2"} {:question "also from v1", :answer "also from v2"}) |
| 09:54 | justin_smith | cmarques: like I said it's pretty bare bones, I just use it to generate the default initial argument eg. :staging or :dev, that drives the real config |
| 09:55 | flor-bcn | v1 = ["q1" "q2" "q3"] , v2 = ["a1" "a2" "a3"] . Required result: [{:question "q1" :answer "a1} {:question "q2" :answer "a2"}....] |
| 09:55 | justin_smith | flor-bcn: that is what that code does! |
| 09:55 | justin_smith | ,(map (fn [q a] {:question q :answer a}) ["q1" "q2" "q3"] ["a1" "a2" "a3"]) |
| 09:55 | clojurebot | ({:question "q1", :answer "a1"} {:question "q2", :answer "a2"} {:question "q3", :answer "a3"}) |
| 09:56 | jaarod | hi.. if you are typed clojure user, are you using it everywhere in your new code? |
| 09:56 | snowell | Wrap it in (vec) or (into []) if you really need a vector |
| 09:56 | flor-bcn | justin_smit: you're right, thank you so much ! |
| 09:56 | jaarod | or just in certain parts of your code (which?) |
| 09:57 | justin_smith | snowell: s/map/mapv for that, of course |
| 09:57 | snowell | Heh, I always forget that exists |
| 10:10 | jaarod | ,(map inc "hi123") |
| 10:10 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number> |
| 10:10 | jaarod | ,(inc '1') |
| 10:10 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 10:10 | justin_smith | ,(apply str (map (comp char inc int) "hi123") |
| 10:10 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 10:10 | justin_smith | ,(apply str (map (comp char inc int) "hi123")) |
| 10:10 | clojurebot | "ij234" |
| 10:11 | jaarod | comp char inc int? |
| 10:11 | justin_smith | characters are not numbers, but "int" will return a number when given a character |
| 10:11 | jaarod | ,(map (comp char inc int) "hi123") |
| 10:11 | clojurebot | (\i \j \2 \3 \4) |
| 10:11 | jaarod | I see |
| 10:11 | justin_smith | (comp char inc int) returns a function that applies int, then applies inc to the result, then finally applies char |
| 10:12 | jaarod | ,(str (map (comp char inc int) "hi123")) |
| 10:12 | clojurebot | "clojure.lang.LazySeq@7ad6df1" |
| 10:12 | justin_smith | it's equivalent to (fn [c] (char (inc (int c)))) |
| 10:12 | jaarod | ah |
| 10:12 | justin_smith | jaarod: apply str uses each element of the coll as an argument |
| 10:13 | justin_smith | as opposed to str which simply looks at the coll itself. Because lazy-seqs are potentially unlimited, str does not look at their contents |
| 10:13 | justin_smith | but apply gets around that |
| 10:14 | Bronsa | justin_smith: it actually realized the collection anyway :/ |
| 10:14 | Bronsa | ,(str (range)) |
| 10:14 | clojurebot | "(0 1 2 3 4 ...)" |
| 10:14 | Bronsa | damned clojurebot |
| 10:14 | justin_smith | ,(str (map pr (range))) |
| 10:14 | Bronsa | ,(def a (str range)) |
| 10:14 | clojurebot | #'sandbox/a |
| 10:14 | Bronsa | wat |
| 10:14 | clojurebot | eval service is offline |
| 10:14 | Bronsa | ,(def a (str (range))) |
| 10:14 | clojurebot | #'sandbox/a |
| 10:14 | Bronsa | :| |
| 10:14 | Bronsa | ,*clojure-version* |
| 10:14 | clojurebot | {:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true} |
| 10:15 | justin_smith | Bronsa: the eval service offline was in response to me |
| 10:15 | justin_smith | oh, you mean the def a returning immediately? |
| 10:15 | Bronsa | yeah |
| 10:16 | justin_smith | ,(def b (map identity (str (range)))) |
| 10:16 | clojurebot | #'sandbox/b |
| 10:16 | justin_smith | ,(def b (str (map identity (range))) |
| 10:16 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 10:16 | Bronsa | ,(def a (str (iterate inc 0))) |
| 10:16 | clojurebot | #'sandbox/a |
| 10:16 | Bronsa | wtf |
| 10:16 | Bronsa | justin_smith: well try that in your repl |
| 10:17 | Bronsa | no idea how clojurebot works |
| 10:18 | jaarod | I like comp, first time I see it |
| 10:18 | jaarod | is it a function or a macro? |
| 10:18 | Bronsa | a function |
| 10:18 | justin_smith | a function, a very nice one |
| 10:19 | justin_smith | jaarod: see also, juxt - if you like comp you'll likely like juxt too |
| 10:19 | justin_smith | ,(map (juxt dec identity inc) (range)) |
| 10:19 | clojurebot | ([-1 0 1] [0 1 2] [1 2 3] [2 3 4] [3 4 5] ...) |
| 10:21 | Bronsa | https://groups.google.com/forum/?fromgroups=#!topic/clojure-dev/F68GRPrbfWo |
| 10:21 | crocket | justin_smith, Is it with_config that you use in timbre? |
| 10:23 | justin_smith | crocket: I misremembered, I was actually just using the :ns-blacklist feature to turn off logging in some overly chatty namespaces at runtime |
| 10:23 | justin_smith | s/runtime/dev time |
| 10:24 | justin_smith | Bronsa: yeah, clearly I thought clojure was being smarter than it actually was |
| 10:25 | justin_smith | Bronsa: I mean the intuitive thing is that if a lazy-seq is not printed readably, that's to avoid realizing it... |
| 10:25 | Bronsa | justin_smith: there's no good reason for the toString of lazyseqs to be the way it currently is :/ |
| 10:25 | justin_smith | (inc Bronsa) |
| 10:25 | lazybot | ⇒ 116 |
| 10:25 | justin_smith | always with the facts! |
| 10:33 | crocket | I'm back. |
| 13:06 | smandy | hi I've got a java8 class that takes a lambda - can I call it from clojure? i.e is there some sugar in clojure to let me create the expected SAM implementation? |
| 13:16 | smandy | foos |
| 14:40 | arkh | smandy: i think you would do this through normal clojure<->java interop |
| 14:49 | arkh | smandy: nevermind - I just looked into it and wonder the same thing now |
| 14:50 | amalloy | you can just reify an interface |
| 15:30 | iamjarvo | if one wanted to run this snippet of code how would one go about it? http://pastie.org/private/bsmntfmjesikndoruxdksa my thought process now is i can use lein exec and execute the script or create a lein project. any thing simpler? |
| 15:34 | justin_smith | iamjarvo: java -cp <class path goes here> clojure.main -e '(load-file "path/to/that/file.clj")' |
| 15:34 | justin_smith | class path would hold any jars needed |
| 15:34 | justin_smith | if generating a classpath is complicated, then use a proper lein project and lein will do it for you |
| 15:37 | iamjarvo | justin_smith thanks |
| 15:45 | justin_smith | also, for a script, you can potentially create a project, use `lein cp` to output a classpath, and just run java directly when invoking the script |
| 15:45 | justin_smith | though uberjar might make more sense |
| 15:51 | Fare | I'm trying to reexport a var from one ns into another. That used to work, but I recently updated to 1.7.0 and it doesn't seem to work anymore |
| 15:54 | Fare | I get this error: java.lang.IllegalStateException: apropos already refers to: #'pyjure.debug/apropos in namespace: pyjure.core |
| 16:01 | justin_smith | sounds like you re-exported it already? |
| 16:07 | Fare | justin_smith, but no, I only re-exported it once |
| 16:07 | Fare | if I remove that re-export, the code loads, but the function is not exported. |
| 16:14 | xeqi | Fare: are you requiring pyjure.debug with a :refer? |
| 16:14 | wasamasa | pyjure?? |
| 16:14 | lazybot | wasamasa: What are you, crazy? Of course not! |
| 16:26 | Fare | xeqi: as a :use |
| 16:31 | bcham | I'm using the monger client at http://clojuremongodb.info/ and if I don't have an instance running on my local machine, I can't uberjar my app. |
| 16:32 | bcham | For some reason the connection is being called but I don't have it in a def or anything |
| 16:32 | justin_smith | bcham: move your db connection into a function called in -main instead of doing it at the top level |
| 16:32 | justin_smith | bcham: clearly something is trying to connect while you are building, right? that means it's happening in a top level call somewhere. |
| 16:33 | bcham | justin_smith: that's what I figured it was and that's what I had done, I thought but I guess I'll double check. Just wanted to make sure there wasn't something else I wasn't thinking about. |
| 16:33 | bcham | Yeah I'm with you thank you. |
| 16:37 | bcham | Yup got it, there was just one little thing that I hadn't looked at. Thanks justin_smith. |
| 16:37 | bcham | FWIW I'd really like to thank this IRC channel, always super helpful and nice. |
| 16:38 | justin_smith | thanks, it's great to hear that |
| 17:59 | ed-g | What do people use for web-application user login? |
| 18:03 | justin_smith | ed-g stored bcrypt hash, and a signed token that the client provides with each request (so that one of the load-balanced servers can verify not only the token, but also the contents) |
| 18:09 | ed-g | justin_smith, that sounds good. did you follow a tutorial or docs to set it up, or just dive in and experiment with libraries such as Friend. I'd like to use them but I haven't found examples of working applications, it isn't clear to me which parts of the authentication I am supposed to write versus what the libraries provide. |
| 18:10 | justin_smith | ed-g: by the time I figured out enough so friend would make sense I already had my own solution |
| 18:12 | ed-g | yeah it's weird to me that no examples ever actually show a login page, or a complete web application. glad it's not just me. |
| 18:14 | ed-g | is the login portion of your application open-source, would you mind if I used it as an example? |
| 18:16 | justin_smith | not the one I'm describing, no |
| 19:27 | peat | Hello everyone. Clojure noob here. I have a pretty common pattern, but I'm not finding a clean way to address it -- most likely because I don't know what the name is. I created a gist to try and explain what I'm after. Thanks for your advice! https://gist.github.com/peat/982ad29845bfb003845b |
| 19:32 | scriptor | peat: that's an essential idea behind monads, actually |
| 19:33 | scriptor | I'm not sure what the idiomatic way to to it in clojure is |
| 19:33 | peat | scriptor: Right. :) I'm wary of using the word "monad" because strictly speaking it's not, and people get a little bent out of shape about such things. ;) |
| 19:34 | peat | scriptor: I'm tempted to spend the evening hacking on the thread-first macro to get out a proof of concept, but ... I didn't want to re-invent the wheel if it's already been done. |
| 19:34 | peat | ... granted, I might do it anyway just to learn me a Clojure the hard way. |
| 19:35 | scriptor | peat: yeah, I purposely avoided saying that's what a monad was, just that it's an important idea |
| 19:35 | crazydiamond | Hi. Are there any tools for Clojure, that take e.g. two pure functions, and extract common piece of code? Or refactor it to provide maximum entropy/minimum entropy/maximum of nested levels etc, whatever applicable? |
| 19:36 | peat | scriptor: :) |
| 19:36 | scriptor | peat: https://clojuredocs.org/clojure.core/some-%3E |
| 19:37 | peat | Yes! |
| 19:37 | peat | scriptor: Thank you! I can run with that. |
| 19:37 | scriptor | peat: no prob! For future reference I just looked at the related functions of --> on clojuredocs |
| 19:38 | peat | ... and it looks like there is a cond-> ... literally re-inventing the wheel over here. Haha. |
| 19:38 | amalloy | cond-> is a pretty different thing from what you asked for |
| 19:38 | peat | ... although it's conditional at each step |
| 19:38 | peat | amalloy: Yup, it allows for a custom test at each form, which is pretty nifty. :) |
| 19:39 | peat | Alright, I'm a happy camper. Thanks scriptor. |
| 21:03 | arrdem | Silly question that shows how long it's been since I've touched Java... what's a good example of a class with a public static mutable field? |
| 21:04 | justin_smith | /win 8 |
| 21:06 | arrdem | lols |
| 21:10 | amalloy | arrdem: System.out? |
| 21:11 | amalloy | $javadoc java.lang.System setOut |
| 21:11 | lazybot | http://docs.oracle.com/javase/6/docs/api/java/lang/System.html#setOut(java.io.PrintStream) |
| 21:11 | justin_smith | oh yeah, and the properties list exposed by System/getProperty |
| 21:12 | amalloy | i think that's not mutable without reflection cheats? |
| 21:12 | amalloy | oh, no |
| 21:12 | amalloy | setProperties indeed |
| 21:12 | justin_smith | right |
| 21:14 | arrdem | hum looks like System/out is not directly assignable |
| 21:15 | arrdem | I should probably just add a test class. |
| 21:17 | justin_smith | and System/getProperty System/getProperty is still a getter / setter pair not an exposed mutable field... |
| 21:17 | arrdem | right. |
| 21:17 | arrdem | I'm trying to test TEMJVM's mutable field setter |
| 21:17 | arrdem | test coverage was pretty bad, I've dragged it up to about 79%, trying to get it to 90. |
| 21:34 | Seylerius | There any easy way to turn 5.597661 days into a clj-time interval? |
| 21:35 | arrdem | Seylerius: do you have that number as days or are you sourcing it as milli/microsecond |
| 21:35 | arrdem | *ds |
| 21:36 | Seylerius | arrdem: I have a function that takes that number in days. |
| 21:36 | Seylerius | A math formula, rather. |
| 21:38 | Seylerius | Actually, thought of a way around it. |
| 21:39 | arrdem | That's probably for the best... I didn't want to reccomend anything with a loss of precision. |
| 21:52 | Seylerius | Okay, what's the clojurish way to take the first entry of an infinite, lazy seq that satisfies a function? |
| 21:52 | justin_smith | (comp first (partial filter pred)) |
| 21:53 | justin_smith | ,((comp first (partial filter even?)) [1 3 5 8 7 12 3]) |
| 21:53 | clojurebot | 8 |
| 21:53 | Seylerius | justin_smith: That returns a transducer that eats colls? |
| 21:53 | justin_smith | it returns a function |
| 21:53 | Seylerius | Wait, yeah. |
| 21:54 | Seylerius | And that whole process is lazy? |
| 21:54 | justin_smith | not quite - when called it will evaluate items in the input until one of the items is returned by filter |
| 21:55 | justin_smith | but yeah, it is lazy enough not to consume a huge indefinite sequence |
| 21:55 | Seylerius | Lazy enough. |
| 21:57 | arrdem | You could make it lazier with memoize... |