#clojure logs

2016-03-14

02:47MONODAI have a fully qualified symbol, how can I get the value associated with it?
02:47MONODA(eval A) works but I've been told eval is evil and usually not necessary
02:51ben_vulpes,(def A :foo)
02:51ben_vulpes,A
02:51clojurebot#'sandbox/A
02:51clojurebot#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:51ben_vulpes,(println A)
02:51clojurebot:foo\n
02:51dysfunMONODA: ns-resolve ?
02:56MONODAThat'll give me the var
02:56MONODAwhat I want is the actual value
02:59opqdonutyou can deref the var
03:01opqdonut,((deref (ns-resolve 'user 'clojure.core/clojure-version)))
03:01clojurebot"1.8.0"
03:02MONODAof course, thanks
03:50bendlashas somebody figured out, how to use a recent cider with custom started piggieback clojurescript repl?
05:31sagittariann
06:11dazlowHow 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:12MJB47i think https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies
06:12MJB47is what you want
06:14dazlowOk I'll check that out
06:14kwladykaIs any shortcut for: (if bar (bar foo) foo) ?
06:15dysfunnot in core, probably somewhere on the internet
06:15dysfunpart of the normal clojure writing process is noticing repeatable things and defining them as utility functions
06:17urzds_Hello!
06:18urzds_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:18urzds_Any idea what's going on here? I ran the same thing yesterday on my other computer and it worked...
06:19MJB47kwladyka: if you are expecting bar to be a map and foo a keyword you can do:
06:19MJB47,(let [bar nil] (or (:foo bar) :foo))
06:19clojurebot:foo
06:19MJB47but outside of those conditions it gets more complicated :(
06:20ridcully_urzds_: are your namespaces sane? are your file locations matching the ns?
06:20dysfunisn't that (get bar :foo :foo) ?
06:20kwladykaMJB47 thx. Unfortunately it is a little more complicated.
06:20MJB47dysfun: indeed it is, dont know why i overcomlicated it lol
06:21urzds_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:21urzds_ridcully_: Thanks, though!
06:40kwladykai messed in my mind... is it possible to use anonymous fucntions with -> and ->> ?
06:40kwladyka,(-> 2 (fn [x] 3))
06:40clojurebot#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:41ridcully_,(-> 2 ((fn [x] 3)))
06:41clojurebot3
06:45kwladykahmm
06:45dysfunkwladyka: (fn will be read later
06:45ridcully_"hmm" is the proper reaction. that construct there is just ugly ;)
06:46kwladyka;)
06:49ridcully_for your earlier question: not shorter ((or bar identity) foo)
06:54kwladykaridcully_ sounds good
07:10m_mHi. 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:13MasseRclojure threads are OS threads. So, afaik no
07:13MasseRBut, the threading is done automatically with thread pools
07:28m_mHow about actors etc ?
07:30dysfunno, we don't have actors, we use other mechanisms
07:30dysfuncore.async is a popular choice. it models 'channels' (like from go)
07:31dysfunthere's also manifold which operates on similar lines but it built atop netty
07:32dysfunthe execution of those is modelled by the flow of data and uses an erlang like 'lightweight thread' mechanism based on a thread pool
07:33dysfunit is very easy to write something that behaves like an actor in core.async
08:11kwladyka#(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:17ridcully_i guess if you call it? what about contains? ,(contains? #{nil :a} nil)
08:18ridcully_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:51dysfunridcully_: symbolic programming, yo :)
10:52justin_smith(-> x ((fn [] ...))) isn't any worse than (-> x (f)), and many prefer that over (-> x f)
10:53justin_smith((fn [] ...)) means you are calling the fn immediately, and indeed that's what you are telling that form to do
10:56sdegutisWhat is f? (f [1 2 5] [3 4]) => [1 2 3 4 5]
10:57justin_smithinto
10:57justin_smitherr, no that is wrong
10:57sdegutisHmm. Never mind actually.
10:57sdegutisThanks :)
10:58justin_smith(comp vec sort into) heh
10:58sdegutisI actually meant this: (f [1 2 3 4 5]) => [3 4 5]
10:58sdegutisAh, nthrest.
10:58justin_smithor (partial drop n)
10:58sdegutisHmm. Interesting.
10:59justin_smithwhich might be the same as nthrest actually
10:59dysfuni often find that i want a variant of comp which puts the params given up front after the params given later
10:59sdegutis,(source nthrest)
10:59clojurebotSource not found\n
10:59sdegutisWeird, nthrest uses loop, pos? seq, rest, dec, and recur.
10:59justin_smithit's eager, yeah
11:00sdegutisOkay. So it's the same as drop but the only difference being it's eager.
11:00sdegutisMakes sense.
11:00justin_smithdrop uses a volatile
11:00justin_smith(for the transducer arity that is)
11:02sdegutisOh wait, destructuring does this more easily.
11:02sdegutisWoot.
11:03dysfundestructuring is pretty ace
11:39mr_rmis anyone using Atom editor with proto-repl plugin? I can't seem to get a working repl and not sure why
12:19justin_smithopqdonut: 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:52opqdonutjustin_smith: thanks, I had forgotten about resolve
13:56amalloynthrest. 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:57tolstoyIs there a handy lib that'll turn raw XML into hiccup-like syntax?
13:58justin_smithtolstoy: how close does clojure.data.xml get you?
13:59tolstoyI think it's the same as clojure.xml: {:tag :foo :attrs {:a "1"} "data"} rather than {:foo {:a "1"} "data"}.
13:59justin_smithI assume you mean [:foo {:a "1"} "data"]
13:59tolstoyyeah.
14:00amalloytolstoy: why would you do that? hiccup data structures are a bear to work with
14:00justin_smiththat looks like a trivial transformation, but you could also see how well enlive works on xml
14:01amalloyenlive style structures are way better to consume. hiccup is popular because it's easy to produce
14:02tolstoyCan you use enlive with just random XML?
14:02amalloyof course
14:03tolstoyI 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:03tolstoyThen you get XML back (blocks), as well as the menu stuff.
14:04tolstoyFortunately, no namespace stuff.
14:06tolstoyI really just need to pull data out. I guess it's zippers, or some java-interop Xpath.
14:06tolstoyOr regex, actually.
14:06justin_smithtolstoy: 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:06amalloytolstoy: 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:09tolstoyclj-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:10justin_smithtolstoy: oh, I meant the streaming mode (the truly soupy one), but yeah, if clojure.data.xml works, just use that
15:09sdegutisRing is such a pain.
15:18sdegutisI'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:37sdegutisHi.
16:08dysfunflash requires sessions
16:10dysfunand you have to wrap flash and sessions in the right order
17:12sdegutisdysfun: But I have sess -- ooh! ordering!
17:12sdegutisdysfun: thanks, I'll try that out
17:13sdegutisUgh I hate Ring middleware. It's so prone to error.
17:13sdegutisI 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:14sdegutisMiddleware is just such an error prone design.
17:22benjyz1hi. I'm having a small issue trying to return json from ring
17:23benjyz1I wrap the routes with (wrap-json-body) (wrap-json-params) (wrap-json-response)
17:24benjyz1and get back an escaped string... "{\"posted\":\"ping\"}"
17:27dysfunsdegutis: yes, but don't do that
17:28sdegutisdysfun: why not
17:28dysfunby 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:29dysfunyou can do something like this https://github.com/irresponsible/qarma/blob/master/src/qarma/middleware.clj
17:30TimMcthat's irresponsible
17:30TimMc;-)
17:30dysfunyeah and i'm working on irresponsible/emotional :)
17:30dysfunalso irresponsible/asylum
17:31dysfunand every c++ programmer's favourite, irresponsible/overload
17:33dysfunit was just another silly name. i never thought it would makes so many other silly names even sillier
17:55rhg135now we need responsible/X
17:56dysfunnot really as satisfying though, is it?
17:56dysfun:)
17:56rhg135irresponsible/fun
17:57dysfunthe best kind!
17:58rhg135oh the puns!
17:58dysfunthing 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:10sdegutisdysfun: 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:10sdegutisdysfun: which suggests that the wrap-flash middleware is working correctly and I'm using it correctly
19:48spiedenyo clojureverse
23:48mmercercompletely unsafe for work but it is so cool i have to post it! http://www.cam4.com/hotnoielya
23:49TEttingerthat looks like spam, from that link
23:50mmercerno, it is just a cam girl with dildo backwards in her twat, making it look like she has a penis
23:50mmercerit is glorious
23:51mmercerthe is the skills women need, not programming
23:53mmercer(dildo has balls btw :) )