2016-03-14
| 02:47 | MONODA | I have a fully qualified symbol, how can I get the value associated with it? |
| 02:47 | MONODA | (eval A) works but I've been told eval is evil and usually not necessary |
| 02:51 | ben_vulpes | ,(def A :foo) |
| 02:51 | ben_vulpes | ,A |
| 02:51 | clojurebot | #'sandbox/A |
| 02:51 | clojurebot | #error {\n :cause "Unable to resolve symbol: A in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: A 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: A in this context"\n ... |
| 02:51 | ben_vulpes | ,(println A) |
| 02:51 | clojurebot | :foo\n |
| 02:51 | dysfun | MONODA: ns-resolve ? |
| 02:56 | MONODA | That'll give me the var |
| 02:56 | MONODA | what I want is the actual value |
| 02:59 | opqdonut | you can deref the var |
| 03:01 | opqdonut | ,((deref (ns-resolve 'user 'clojure.core/clojure-version))) |
| 03:01 | clojurebot | "1.8.0" |
| 03:02 | MONODA | of course, thanks |
| 03:50 | bendlas | has somebody figured out, how to use a recent cider with custom started piggieback clojurescript repl? |
| 05:31 | sagittarian | n |
| 06:11 | dazlow | How do I make leiningen to build another leiningen project inside my project and use it? I've modified some stuff in a clojar library but not sure if changes will see the upstream |
| 06:12 | MJB47 | i think https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies |
| 06:12 | MJB47 | is what you want |
| 06:14 | dazlow | Ok I'll check that out |
| 06:14 | kwladyka | Is any shortcut for: (if bar (bar foo) foo) ? |
| 06:15 | dysfun | not in core, probably somewhere on the internet |
| 06:15 | dysfun | part of the normal clojure writing process is noticing repeatable things and defining them as utility functions |
| 06:17 | urzds_ | Hello! |
| 06:18 | urzds_ | I see a weird error after creating a project using `lein new compojure `: Exception in thread "main" java.io.FileNotFoundException: Could not locate //handler__init.class or //handler.clj on classpath., compiling:(/tmp/form-init5006717142541663053.clj:1:73) |
| 06:18 | urzds_ | Any idea what's going on here? I ran the same thing yesterday on my other computer and it worked... |
| 06:19 | MJB47 | kwladyka: if you are expecting bar to be a map and foo a keyword you can do: |
| 06:19 | MJB47 | ,(let [bar nil] (or (:foo bar) :foo)) |
| 06:19 | clojurebot | :foo |
| 06:19 | MJB47 | but outside of those conditions it gets more complicated :( |
| 06:20 | ridcully_ | urzds_: are your namespaces sane? are your file locations matching the ns? |
| 06:20 | dysfun | isn't that (get bar :foo :foo) ? |
| 06:20 | kwladyka | MJB47 thx. Unfortunately it is a little more complicated. |
| 06:20 | MJB47 | dysfun: indeed it is, dont know why i overcomlicated it lol |
| 06:21 | urzds_ | ridcully_: I just tried the command again with `lein new compojure folder` instead of `lein new compojure . :force` and compared the differences: Apparently the latter form creates a garbage project.clj where it uses "." in weird places instead of falling back to a sane default for the current directory. |
| 06:21 | urzds_ | ridcully_: Thanks, though! |
| 06:40 | kwladyka | i messed in my mind... is it possible to use anonymous fucntions with -> and ->> ? |
| 06:40 | kwladyka | ,(-> 2 (fn [x] 3)) |
| 06:40 | clojurebot | #error {\n :cause "Parameter declaration 2 should be a vector"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Parameter declaration 2 should be a vector"\n :at [clojure.core$fn invokeStatic "core.clj" 4375]}]\n :trace\n [[clojure.core$fn invokeStatic "core.clj" 4375]\n [clojure.core$fn doInvoke "core.clj" 4357]\n [clojure.lang.RestFn invoke "RestFn.java" 490]\n [clojure.lan... |
| 06:41 | ridcully_ | ,(-> 2 ((fn [x] 3))) |
| 06:41 | clojurebot | 3 |
| 06:45 | kwladyka | hmm |
| 06:45 | dysfun | kwladyka: (fn will be read later |
| 06:45 | ridcully_ | "hmm" is the proper reaction. that construct there is just ugly ;) |
| 06:46 | kwladyka | ;) |
| 06:49 | ridcully_ | for your earlier question: not shorter ((or bar identity) foo) |
| 06:54 | kwladyka | ridcully_ sounds good |
| 07:10 | m_m | Hi. Is it possible to create light processes/threads in clojure like in erlang ? I mean for example 100.000 on reasonable amount of memory. |
| 07:13 | MasseR | clojure threads are OS threads. So, afaik no |
| 07:13 | MasseR | But, the threading is done automatically with thread pools |
| 07:28 | m_m | How about actors etc ? |
| 07:30 | dysfun | no, we don't have actors, we use other mechanisms |
| 07:30 | dysfun | core.async is a popular choice. it models 'channels' (like from go) |
| 07:31 | dysfun | there's also manifold which operates on similar lines but it built atop netty |
| 07:32 | dysfun | the execution of those is modelled by the flow of data and uses an erlang like 'lightweight thread' mechanism based on a thread pool |
| 07:33 | dysfun | it is very easy to write something that behaves like an actor in core.async |
| 08:11 | kwladyka | #(or (nil? %) (= region %)) <- how to write better this condition? I tried with sets, but nil value makes a problem. I need to know the value is nil or region |
| 08:17 | ridcully_ | i guess if you call it? what about contains? ,(contains? #{nil :a} nil) |
| 08:18 | ridcully_ | also if this is an important check, then maybe a anon fn is not the right place? make it a defn with a nice name and the need to "compress" it vanishes. |
| 10:51 | dysfun | ridcully_: symbolic programming, yo :) |
| 10:52 | justin_smith | (-> x ((fn [] ...))) isn't any worse than (-> x (f)), and many prefer that over (-> x f) |
| 10:53 | justin_smith | ((fn [] ...)) means you are calling the fn immediately, and indeed that's what you are telling that form to do |
| 10:56 | sdegutis | What is f? (f [1 2 5] [3 4]) => [1 2 3 4 5] |
| 10:57 | justin_smith | into |
| 10:57 | justin_smith | err, no that is wrong |
| 10:57 | sdegutis | Hmm. Never mind actually. |
| 10:57 | sdegutis | Thanks :) |
| 10:58 | justin_smith | (comp vec sort into) heh |
| 10:58 | sdegutis | I actually meant this: (f [1 2 3 4 5]) => [3 4 5] |
| 10:58 | sdegutis | Ah, nthrest. |
| 10:58 | justin_smith | or (partial drop n) |
| 10:58 | sdegutis | Hmm. Interesting. |
| 10:59 | justin_smith | which might be the same as nthrest actually |
| 10:59 | dysfun | i often find that i want a variant of comp which puts the params given up front after the params given later |
| 10:59 | sdegutis | ,(source nthrest) |
| 10:59 | clojurebot | Source not found\n |
| 10:59 | sdegutis | Weird, nthrest uses loop, pos? seq, rest, dec, and recur. |
| 10:59 | justin_smith | it's eager, yeah |
| 11:00 | sdegutis | Okay. So it's the same as drop but the only difference being it's eager. |
| 11:00 | sdegutis | Makes sense. |
| 11:00 | justin_smith | drop uses a volatile |
| 11:00 | justin_smith | (for the transducer arity that is) |
| 11:02 | sdegutis | Oh wait, destructuring does this more easily. |
| 11:02 | sdegutis | Woot. |
| 11:03 | dysfun | destructuring is pretty ace |
| 11:39 | mr_rm | is anyone using Atom editor with proto-repl plugin? I can't seem to get a working repl and not sure why |
| 12:19 | justin_smith | opqdonut: for the case where you have a fully qualified symbol, it makes more sense to just use resolve instead of ns-resolve. But ns-resolve is good if you have eg 'str/join and the ns maps clojure.string :as str |
| 12:52 | opqdonut | justin_smith: thanks, I had forgotten about resolve |
| 13:56 | amalloy | nthrest. that's not a function i've seen used a lot. nthnext i use occasionally myself; i think i'd forgotten nthrest even exists |
| 13:57 | tolstoy | Is there a handy lib that'll turn raw XML into hiccup-like syntax? |
| 13:58 | justin_smith | tolstoy: how close does clojure.data.xml get you? |
| 13:59 | tolstoy | I think it's the same as clojure.xml: {:tag :foo :attrs {:a "1"} "data"} rather than {:foo {:a "1"} "data"}. |
| 13:59 | justin_smith | I assume you mean [:foo {:a "1"} "data"] |
| 13:59 | tolstoy | yeah. |
| 14:00 | amalloy | tolstoy: why would you do that? hiccup data structures are a bear to work with |
| 14:00 | justin_smith | that looks like a trivial transformation, but you could also see how well enlive works on xml |
| 14:01 | amalloy | enlive style structures are way better to consume. hiccup is popular because it's easy to produce |
| 14:02 | tolstoy | Can you use enlive with just random XML? |
| 14:02 | amalloy | of course |
| 14:03 | tolstoy | I have this "interesting" API where you ssh into a device with an old school menu, and instead of entering a number, you send blocks of XML. |
| 14:03 | tolstoy | Then you get XML back (blocks), as well as the menu stuff. |
| 14:04 | tolstoy | Fortunately, no namespace stuff. |
| 14:06 | tolstoy | I really just need to pull data out. I guess it's zippers, or some java-interop Xpath. |
| 14:06 | tolstoy | Or regex, actually. |
| 14:06 | justin_smith | tolstoy: I've had great luck with clj-tagsoup when it comes to data that is easy to detect regardless of nesting in doc structure |
| 14:06 | amalloy | tolstoy: just parse the data with c.d.xml and get a tree back. i bet you it'll be easy to get data out of without any extra tools |
| 14:09 | tolstoy | clj-tagsoup parses into hiccup-like syntax, which is what I asked for, but I bet just using the raw parse from clojure.xml is probably best. |
| 14:10 | justin_smith | tolstoy: oh, I meant the streaming mode (the truly soupy one), but yeah, if clojure.data.xml works, just use that |
| 15:09 | sdegutis | Ring is such a pain. |
| 15:18 | sdegutis | I'm using ring.middleware.flash/wrap-flash and I have returned {:status 200 :flash (:flash request) :body ...}, but the (:flash request) of the next request is nil. |
| 15:37 | sdegutis | Hi. |
| 16:08 | dysfun | flash requires sessions |
| 16:10 | dysfun | and you have to wrap flash and sessions in the right order |
| 17:12 | sdegutis | dysfun: But I have sess -- ooh! ordering! |
| 17:12 | sdegutis | dysfun: thanks, I'll try that out |
| 17:13 | sdegutis | Ugh I hate Ring middleware. It's so prone to error. |
| 17:13 | sdegutis | I honestly think I'm just gonna rip out the middleware I have and combine them into a single function that wraps my Compojure handler. |
| 17:14 | sdegutis | Middleware is just such an error prone design. |
| 17:22 | benjyz1 | hi. I'm having a small issue trying to return json from ring |
| 17:23 | benjyz1 | I wrap the routes with (wrap-json-body) (wrap-json-params) (wrap-json-response) |
| 17:24 | benjyz1 | and get back an escaped string... "{\"posted\":\"ping\"}" |
| 17:27 | dysfun | sdegutis: yes, but don't do that |
| 17:28 | sdegutis | dysfun: why not |
| 17:28 | dysfun | by all means write a function that wraps a handler with all the others, but don't try and combine them into one nasty middleware |
| 17:29 | dysfun | you can do something like this https://github.com/irresponsible/qarma/blob/master/src/qarma/middleware.clj |
| 17:30 | TimMc | that's irresponsible |
| 17:30 | TimMc | ;-) |
| 17:30 | dysfun | yeah and i'm working on irresponsible/emotional :) |
| 17:30 | dysfun | also irresponsible/asylum |
| 17:31 | dysfun | and every c++ programmer's favourite, irresponsible/overload |
| 17:33 | dysfun | it was just another silly name. i never thought it would makes so many other silly names even sillier |
| 17:55 | rhg135 | now we need responsible/X |
| 17:56 | dysfun | not really as satisfying though, is it? |
| 17:56 | dysfun | :) |
| 17:56 | rhg135 | irresponsible/fun |
| 17:57 | dysfun | the best kind! |
| 17:58 | rhg135 | oh the puns! |
| 17:58 | dysfun | thing is though i've been choosing all the names assuming they were freestanding, so it's always a bonus when it works great together |
| 18:10 | sdegutis | dysfun: hmm, reordering wrap-session and wrap-flash didn't help at all, in fact it made it worse, since the flash no longer worked at all. |
| 18:10 | sdegutis | dysfun: which suggests that the wrap-flash middleware is working correctly and I'm using it correctly |
| 19:48 | spieden | yo clojureverse |
| 23:48 | mmercer | completely unsafe for work but it is so cool i have to post it! http://www.cam4.com/hotnoielya |
| 23:49 | TEttinger | that looks like spam, from that link |
| 23:50 | mmercer | no, it is just a cam girl with dildo backwards in her twat, making it look like she has a penis |
| 23:50 | mmercer | it is glorious |
| 23:51 | mmercer | the is the skills women need, not programming |
| 23:53 | mmercer | (dildo has balls btw :) ) |