#clojure logs

2014-05-20

00:00danielcomptondbasch does this look correct for comparing two byte-buffers? https://www.refheap.com/85670
00:04dbaschdanielcompton: java.nio.ByteBuffer implements comparable, so you could just do (.compareTo b1 b2)
00:05danielcomptonfacepalm
00:06danielcomptondbasch that's why I was confused about the equality thing earlier
00:06dbaschit returns an int, so you want (= 0 (.compareTo ….))
00:07dbaschyeah, ByteBuffer wraps byte buffers in objects with useful methods
00:07danielcomptondbasch the nio version?
00:07dbaschyes
00:07danielcomptondbasch wait, there is only the nio version rihgt?
00:07dbaschyeah, I don’t think there’s another one
00:08danielcomptondbasch thanks! What is = comparing on two byte-buffers, reference or value?
00:10dbaschdanielcompton: it will do this: http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html#equals(java.lang.Object)
00:10dbaschso it should work
00:11danielcomptondbasch what's the difference between equals and compareTo? They seem to be doing the same thing?
00:11dbaschdanielcompton: compareTo is useful for sorting
00:12dbaschit puts them in order
00:12danielcomptondbasch ahh
00:12dbaschequals is binary
00:12dbaschcompareTo is >, = or <
00:16yeoj___is there any function that will convert "some-var" to :some-var to some-var ? I know about names and keywords, but seems like nothing goes into some-var
00:17dissipateyeoj___, yep, a macro would
00:17tolstoyor intern
00:17yeoj___so in a macro i have to unquote?
00:18tolstoyI think some-var# generates a symbol for you.
00:19yeoj___ahh ok thats what i'm mising
00:19Frozenlockyeoj___: Is this what you are talking about? https://www.refheap.com/11818
00:20yeoj___Frozenlock: i think i need the opposite of mapify, i have a :thingy inside a macro, and i'm trying to pass :thing as part of a larger string
00:21dbasch,(name :thing)
00:21clojurebot"thing"
00:22dbaschyeoj___: isn’t that what you want?
00:23ddellacostayeoj___: if you want a symbol from what dbasch did just do
00:23ddellacosta,(-> :some-var name symbol)
00:23clojurebotsome-var
00:24yeoj___i must be thinking about it the wrong way... i'm trying to do something with this: https://www.refheap.com/85672
00:25yeoj___i've never really understood macros, and am just rewriting a bunch of boilerplate korma crud stuff
00:25yeoj___i guess i want to create a function, that has a function name as a string composition.
00:27ddellacostayeoj___: here's a very simple way to do it
00:28ddellacosta,(defmacro defcrudfn [name] `(defn ~(symbol name) [args#] (println args#)))
00:28clojurebot#'sandbox/defcrudfn
00:28ddellacosta,(defcrudfn "foo")
00:28clojurebot#'sandbox/foo
00:28ddellacosta(foo {:some "args"})
00:28ddellacostado'h
00:28ddellacosta,(foo {:some "args"})
00:28clojurebot{:some args}\n
00:28ddellacosta*d'oh
00:29ddellacostaanyways
00:29ddellacostayeoj___: if you want to concat it, you can do this
00:29ddellacosta,(defmacro defcrudfn [name] `(defn ~(symbol (str "my-crud-fn-" name) [args#] (println args#)))
00:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
00:29ddellacostawhoops
00:29ddellacosta,(defmacro defcrudfn [name] `(defn ~(symbol (str "my-crud-fn-" name)) [args#] (println args#)))
00:29clojurebot#'sandbox/defcrudfn
00:29danoyoungi was wondering if someone could offer advice on how to repeatedly take 5K line from a file, do something with those 5K, and continue getting 5K more until the file contents are exhausted.
00:30danoyoungI'm new to clojure
00:30ddellacosta,(defcrudfn "foo")
00:30clojurebot#'sandbox/my-crud-fn-foo
00:30ddellacosta(my-crud-fn-foo "args")
00:30ddellacosta,(my-crud-fn-foo "args")
00:30clojurebotargs\n
00:30danoyoungI have some files in S3 that I want to loop over and read, take the contents and then index them into elasticsearch using the bulk api.
00:30yeoj___ddellacosta: ok i'm trying to make sense of all that, 1 min
00:31danoyoungso far I have something like this: http://pastebin.com/3ETqp8Fg
00:31ddellacostayeoj___: sure thing--if anything is not clear definitely ask
00:31danoyoungbut I don't know how to grab 5K @ a time….
00:31yeoj___ddellacosta: thank you
00:33dbaschdanoyoung: 5k lines at a time you mean?
00:33danoyoungyea
00:33danoyoungsomething like take 5000
00:34dbaschdanoyoung: you have a sequence of lines, so you can do that, or you can partition it into chunks of 5k
00:35dbaschthen doseq over the chunks
00:35danoyoungdbasch: this is what I have so far: http://pastebin.com/3ETqp8Fg
00:36danoyoungso I need to look into using the clojure.core/partition? I'm new to clojure….just need some direction….
00:37dbaschdanoyoung: you could do something like
00:38dbasch(doseq [chunk (partition 5000 (line-seq rdr))] (index chunk))
00:38dbasch(doc partition)
00:38clojurebot"([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."
00:38danoyoungok…cool, let me look into those functions.
00:38danoyoungthanx!
00:40danoyoungdbasch: learning clojure has been pretty fun so far!
00:43ddellacostadanoyoung: awesome. :-)
00:43dbaschdanoyoung: if you’re looking for a good clojure book, get The Joy of Clojure
00:43danoyounggreat, thanx. Will do!
00:43danoyoungdbasch that worked like a charm! thank you.
00:43dbaschyou’re welcome
00:46mercwithamouthhrmm can someone tell me why selmer is unable to find my index.html file even when the path is hard coded in? https://github.com/jamalburgess/pepper
00:47servodafuq
00:47servohttps://github.com/fogus/lemonad/blob/7e6137fed655777963ac7b74913c78073070adc5/lib/lemonad.js#L515
00:48servohttps://github.com/fogus/lemonad/blob/7e6137fed655777963ac7b74913c78073070adc5/lib/lemonad.js#L470
00:49mercwithamouthlol!!!
00:50beamsomercwithamouth: i found that the selmer templates have to be under src
00:51mercwithamouthbeamso: hmm really? i guess that's fine...good to know
00:53mercwithamouthbeamso: yup! that does it...thanks
00:53kenrestivoservo: um, he's a fan of h.p. lovecraft and breaking bad?
00:59yeoj___ddellacosta: thats great i think i got it, thanks for your help.
00:59ddellacostayeoj___: Great! Glad to hear it.
00:59yeoj___ddellacosta: i've been staring at macros like that for ages thinking d'oh
01:00ddellacostayeoj___: it took me a while before it clicked. I think you just have to keep at it and eventually it'll become second nature.
01:01ddellacostayeoj___: it's also really important to understand how symbols and vars work in Clojure--I found that a lot of my confusion about macros had to do with not understanding how those worked. So definitely read up on those if you haven't yet.
01:02ddellacostayeoj___: ...as well as being clear about compile- vs. run- time.
01:06tolstoymercwithamouth: Is compojure expecting index.html in /resources/public?
01:07servowatcher.core=> (🙈 '🙉 '🙊)
01:07servoException Death watcher.core/🙈 (NO_SOURCE_FILE:1)
01:07servoemoji all the symbols
01:16mercwithamouthtolstoy_: i assume the result says no. i assumed i could tell it where to pull the file from regardless but that wasn't the case
01:17tolstoy_mercwithamouth: I think (route/resource "/view") might do it. It's been awhile.
01:17mercwithamouththat comes from a previous clojurescript attempt i made wher I was allowed to pull from the public folder. i just believe client/server code should be 100% separated
01:18mercwithamouthtolstoy_: i think you're right...i believe that IS what I did...i can't remember. it was over a month ago and i've been inconsistent with my clojure/compojure studying
01:18beamsohas anyone used om in anger?
01:18tolstoy_:)
01:18tolstoy_http://weavejester.github.io/compojure/compojure.route.html
01:18tolstoy_That :root thing.
01:19servowoo i have a legit question now after messing with emoji:
01:19servowatcher.core=> (map (comp byte int) "🙈")
01:19servoIllegalArgumentException Value out of range for byte: 55357 clojure.lang.RT.byteCast (RT.java:993)
01:19servois there a way to coerce that into bytes?
01:20mercwithamouthbeamso: it's on my todo list
01:21mercwithamouthtolstoy_: ah ha...i've heard of this so called 'documentation' thing
01:21ddellacostabeamso: what's going on?
01:21mercwithamouthi should really work through the project in web development with clojure before i go off on my own opposed to 'glancing'
01:21tolstoy_mercwithamouth: The thing about documentation is you kinda already have to know it to even know how to use the documentation.
01:22mercwithamouthddellacosta: tell me you use Om as well
01:22mercwithamouthtolstoy_: true...
01:22beamsoddellacosta: i was wondering how good it is/isn't
01:22ddellacostabeamso: I use Om almost constantly
01:22ddellacostaer, that was for mercwithamouth I suppose
01:22beamsothe things i've read about it (and react) and the tutes seem okay
01:22mercwithamouthom and nolen are a God send...that is all
01:22mercwithamouthddellacosta: i will be harassing you when ready. =)
01:22ddellacostabeamso: it's good. It doesn't solve all problems, but it solves a lot of UX dev problems.
01:22ddellacostamercwithamouth: oh, sure thing. :-)
01:23beamsodo you use anything in particular for models or just plain javascript objects?
01:23ddellacostabeamso: for models--you mean for the app data we pass in?
01:23beamsoyeah
01:23beamsoi notice the tutes send EDN across but i was concerned about that one
01:24ddellacostabeamso: well, it requires maps or vectors basically. Otherwise you can't create a cursor, which is the abstraction that dnolen created to coordinate Clojure data structures with React
01:24beamsookay
01:25ddellacostabeamso: ...and I think that speaks to the biggest problem with Om, is that there are some somewhat confusing concepts involved that I'm still not sure are very clear to me--even though I've been using Om in production for months. But leaving that aside, it works well.
01:26beamsoforgive my ignorance but what would these concepts be?
01:26ddellacostabeamso: not at all--well, I was talking about the cursor concept in particular. I think that's the one that is hardest to grasp, and its purpose is the least clear.
01:28ddellacostabeamso: although I think this explanation is decent: https://github.com/swannodette/om/wiki/Cursors, I would like to see something that is even more general. "cursors wrap up and manage updating Clojure data structures within the React render cycle" or something
01:28ddellacostamercwithamouth: what did you want to ask about btw.? You were talking about testing routes yesterday, no?
01:29ddellacostamercwithamouth: if you have something concrete I can help you with it more easily.
01:30mercwithamouthddellacosta: just now getting to it. for starters...i'd like to just create a route that collects a few fields and know that it does indeed catch the data sent
01:30mercwithamouthtwo secs...i'll create a route now and push it
01:30ddellacostamercwithamouth: k
01:41mercwithamouthddellacosta: ok we can use this to get my feet wet https://github.com/jamalburgess/pepper
01:42ddellacostamercwithamouth: k, so, what within that in particular do you want to work with/test/etc.?
01:43mercwithamouthlike either from the repl or command line i'd like to be able to do something like http:localhost:8080/register:"user-name":"pass" and then see that something has happened correctly
01:43mercwithamouth^ new developer so i'm really not sure what to ask. i'm used to rails hiding a lot of this from me
01:43ddellacostamercwithamouth: gotcha
01:44ddellacostamercwithamouth: well, the first problem is that layout is throwing an error when I try to load up a repl
01:44ddellacostaah, def -> defn
01:44ddellacostaalso, content-type needs to be referenced
01:46mercwithamouthahh hmm...disregard that. i'd just gotten to the point where selmer worked and I started to go through the code in web development in clojure where they change the template over to use selmer. let me go back
01:47ddellacostamercwithamouth: also handle-registration is broken in pepper.routes.home, I just added an id arg to that fn for now
01:48mercwithamouthok sorry about that. layout.clj is back to nromal and feel free to change handle registration. i'd even be fine if we were adding data to a map
01:48ddellacostamercwithamouth: no worries
01:48ddellacostaone sec
01:50ddellacostafreaking noir
01:51ddellacostamercwithamouth: I would suggest minimizing the use of noir...but I guess you're probably following someone's guide, no?
01:51beamsolib-noir?
01:51mercwithamouthddellacosta: i am following someone but i'm not attached to any libraries..i'm very open
01:52mercwithamouthbeamso: yeah i was going to use lib-noir
01:52beamsobetter to use validateur for map/record validation?
01:53ddellacostayeah, I lazily call lib-noir noir
01:53ddellacostahold on, making a refheap
01:54beamsooh, maybe i can use prismatic schema for validation
01:54ddellacostamercwithamouth: so, I had to massage a few things in your code as I described--commented out noir for now--but this is a very simple way to test routes in the repl: https://www.refheap.com/85674
01:54ddellacostamercwithamouth: it's probably way easier than you had imagined. :-)
01:55ddellacostabeamso: we have our own custom validation thing, but I've prismatic's schema definitely seems good
01:55mercwithamouthit is and that's exacty what i was looking for =P
01:56ddellacostamercwithamouth: great! I think there's probably a way to get lib-noir's session working with that too, but I'd have to play with it a bit. However, you can test out a lot of the basics of passing values around this way to start.
01:56ddellacostamercwithamouth: alternatively just use the default ring session stuff for now
01:57mercwithamouthso like would it be as simple as (r/request :post "/register" "name" "pass")?
01:57ddellacostamercwithamouth: oh, I think you pass in a map, lemme see
01:58mercwithamouthlike if i could do (ph/app (r/request :post "/register" {:user-handle "Jamal" :pass "pastry"})) that would be interesting
01:59ddellacostamercwithamouth: this should be illustrative: https://www.refheap.com/85675
01:59ddellacostamercwithamouth: yep, that's exactly what you can do.
02:00mercwithamouthddellacosta: YUP!!! exactly what i wanted
02:00mercwithamouththank you!
02:00ddellacostamercwithamouth: those two lines of output after I call the handler are 1) the request dumped out in the fn, and 2) the redirect response. So you can get all of that easily.
02:00ddellacostamercwithamouth: Great! Glad I could be of service. I'm going to go grab some lunch but let me know if you have more questions. :-)
02:01mercwithamouthOk, I definitely will be back. this gives me enough to tinker around the way that I want to
02:02ddellacostaaweseom.
02:02ddellacosta*awesome
02:28ivanwhere do I get that neat macro to log all function calls and return values inside an expression?
02:30ivanI guess this could work https://github.com/flatland/useful/blob/develop/src/flatland/useful/debug.clj
02:36amalloyivan: i doubt you want to log *all* function calls and return values. that's a lot of them
02:36amalloybut useful/? is pretty good for targeted debugging
02:40ivanthanks
03:01michaelr525hi
03:01michaelr525i
03:02menguhi michaelr525
03:03michaelr525is lein-sub the commonly used plugin for development when your code is spread over multiple leiningen projects?
03:05beamsoi'm unsure if you need a plugin for it : https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies
03:05michaelr525i'd like to reload code from a common project for example without restarting the repl..
03:05michaelr525ok, let me check that link..
03:08michaelr525beamso: thanks! looks like just what I've been looking for
03:30mercwithamouthhmm what's the difference between ring and ring-server...and why does the compojure-app template choose the latter as a dependency?
03:32beamsomercwithamouth: so you can do a 'lein ring server' at the command line and start the server
03:32beamsoit should also let the source be recompiled on the fly (so long as you don't introduce any new dependencies)
03:34visofi have a bin file which need to use inside clojure, but this bin need some time to load things and then get result, i tried (sh "/bin/foo" "-q")
03:35visofwhat is the basic way to do this?
04:31mercwithamouthhmm are there any plans to have rows opposed to just horizontal tabsets with light table?
04:54mercwithamouthahh how i miss emacs =P
04:58visofcan i interact with utils which are reading from STDIN in clojure from inside the code?
04:59visofif i have program behaves like a shell, and waits commands to run from user, can i interact with it from inside clojure, to send commands and print outs ?
05:00xsynread-line?
05:00xsyn,(doc read-line)
05:00clojurebot"([]); Reads the next line from stream that is the current value of *in* ."
05:02visofxsyn: nope, what i meant if i have a problem called foo, when i run like /bin/foo i got >> , and after >> should write my commands to execute, that's inside shell, but i mean inside clojure can i do this?
05:03visofsomething like open a channel between my program and clojure, and send commands to the program, and return back the results
05:04xsynlike nrepl?
05:04xsynwait
05:04xsynyour program and clojure? what is your program?
05:05visofyeah like even lieningen
05:05visofxsyn: well we can suppose the problem is leiningen
05:05visofs/problem/program
05:05visofcan i run lein from inside clojure?
05:06xsynyeah
05:06xsynhold on
05:06visofokay
05:06llasramhttps://github.com/pallet/alembic
05:06llasramAlthough may not be quite what you mean
05:07llasramOh, you want to launch Leiningen (or whatnot) as a subprocess
05:08xsynhttps://github.com/zcaudate/vinyasa
05:08xsynvinyasa/lein
05:08llasramxsyn: But that's also in-process
05:08llasramWhich I don't think is what visof is trying to get a handle on
05:08visofllasram: yep
05:08xsynI'm really not clear on the problem space, so.. :)
05:09visofxsyn: sorry for my English, but i'll explain again, when you open your terminal, it's waiting you to enter command to exec, can i make this behaviour in clojure ?
05:10visofrun anything which waits for me to enter a commands
05:10visoffrom inside clojure
05:11visofxsyn: llasram got it?
05:12xsynNo, but it might be my fault
05:12xsynlike a repl?
05:12beamsowouldn't you just read from system.in until you get a ctrl+d?
05:13llasramvisof: It depends on the program, and is a general Unix programming problem
05:13ddellacostavisof: you are trying to execute shell commands in Clojure?
05:14llasramMostly depends on whether the other process expects to communicate over just stdin/out or expects to control a terminal; in which latter case things can get hairy
05:15llasramEither way though, is largely out of scope for Clojure
05:15mercwithamouthhmm how would one get autocomplete to work with emacs/clojure
05:15mercwithamouthhttps://raw.github.com/clojure-emacs/company-cider/master/screenshot.png <--
05:15mercwithamouthi have cider installed...repl and everything works great as expected
05:16ddellacostavisof: not sure if this is what you want but check out https://github.com/Raynes/conch
05:16visofddellacosta: llasram xsyn thanks
05:17ddellacostamercwithamouth: Hmm, I got autocomplete working w/clojure, what did I do...
05:17llasrammercwithamouth: ac-nrepl ?
05:17ddellacostamercwithamouth: ah, I installed auto-complete via emacs default (since 24) package manager
05:18mercwithamouthyeah i'm using 24.3
05:18mercwithamouthhmm what keys? it definitely worked with emacs-live which i don't want to use again
05:19mercwithamouthok i got it
05:20mercwithamouthwell basic autocompletion...not the list that they're showing in that screenshot...but this works for now...i'm back to using emacs
05:20ddellacostamercwithamouth: my config looks like this if it helps: https://www.refheap.com/85678
05:21ddellacostamercwithamouth: yeah, I don't have all of that either, perhaps needs a clojure-specific dictionary?
05:21mercwithamouthddellacosta: thanks. yeah most likely
05:21mercwithamouthi'll play with it after i get some rest...good to be back on emacs...not that light table isn't very nice
05:22ddellacostamaybe ac-nrepl that llasram suggested would help too
05:22mercwithamouthbeamso: eww =(
05:22beamsoit works well enough for me
05:23beamsothe code completion and warnings are nice
05:23ddellacostanow now, we are accepting of non-emacs editors here in #clojure
05:23beamsoi haven't used it to connect to a repl though
05:23mercwithamouthac-nrepl IS it
05:24mercwithamouthbeamso: just playing around, i like intellij a lot. i'd assume their clojure setup is nice as well
05:25ddellacostamercwithamouth, beamso: my boss uses it w/Clojure and likes it a lot
05:25ddellacostaI'm always giving him crap about not using the one true emacs though
05:25beamsoi've used emacs for it as well
05:27mercwithamouthac-nrepl then ctags... i'm a configuration junkie
05:27mercwithamouthi've never really mastered using ctags, i think it's time to do so
05:28ddellacostamercwithamouth: me neither. :-/
05:58CookedGryphondoes anyone know how to make midje print proper stacktraces? I'm getting an exception when I run a test, but no line numbers annoyingly
06:15cflemingmercwithamouth: you wouldn't have to with Cursive, of course :-)
06:16cflemingmercwithamouth: Cursive isn't a Jetbrains product BTW, although we're trying for the same quality level
06:17cflemingWe have a ways to go yet, though.
06:23ssideriscfleming: is there anything obvious that you can do with emacs that cursive doesn't do in its current version?
06:23cflemingssideris: Well, it has a lot more community support, so there's modes for a lot of things we don't support yet (Expectations, Midje)
06:24cflemingssideris: It has better REPL integration too, e.g. we don't have macroexpansion yet, there's a few other things
06:25cflemingBut I think Cursive is pretty competitive now - we have pretty complete Paredit, although again we're missing some details here and there
06:25ssideriscfleming: ok, thanks :-)
06:26cflemingThe main issue is that Cursive resolves symbols statically in the editor, which requires support for libraries using macros
06:26cflemingSo some libs that are very macro-heavy (Midje, Storm, Cascalog) are a little painful till I fix them.
06:26cflemingI'm planning an extension API for that (in fact I use it internally) but I won't open it until it's stable.
06:27cflemingIt's getting there, bit by bit.
06:27ssideriscfleming: about paredit: there is a "feature" that I have impemented in elisp but isn't supported in emacs paredit out of the box: re-ordering s-expressions, and moving the cursor along with the moved s-expression so that you can move it a few positions easily
06:27ssiderisI think it's useful in some situations
06:27cflemingssideris: So moving an sexp up or down and moving the cursor with it?
06:27ssiderisyes
06:28cflemingYeah, I'm planning that soon - that would be really useful.
06:28ssiderisI'm just mentioning it as an idea for a feature
06:28cflemingIt probably means you don't need transpose any more, I guess
06:29ssiderisoh it seems that you're way ahead of me :-) thanks for your work, even if I don't use cursive, I think it's good for the community that it exists
06:29cflemingI think Cursive is going to be pretty cool in a couple of months, I'm starting work soon on a bunch of features that will be difficult/impossible to do in Emacs (or other REPL based editors).
06:29cflemingWe're already marking unused locals in the editor, which is really useful.
06:30cflemingAnd having a decent rename + find usages is really great
06:30cflemingBut it'll take us a while to catch up with everything Emacs does right now
06:31cflemingThanks, it's a fun product to work on.
06:32ssiderisI'm intrigued by what you said about features being impossible in emacs
06:32cflemingMaybe not impossible, but difficult
06:33cflemingThe main difference is that Cursive resolves symbols statically in the editor
06:33cflemingSo for a particular symbol, I know where it was declared, and thus what type of thing it is
06:33clgvcfleming: I saw that unused locals features - it seemed it had false alarms on macros that have binding definitions
06:34cflemingThat allows me to mark unused locals right now
06:34cflemingclgv: Really? I'd be interested to see a case of that.
06:35cflemingNone of this will ever be perfect with Clojure unfortunately, the language is just too flexible to do everything in an IDE you can do with Java
06:35clgvcfleming: I think the examples where in compojure code that a student showed me in cursive
06:35cflemingBut you can get a long way
06:35cflemingOk - do you mean that the IDE said that it couldn't resolve symbols?
06:36cflemingYeah, that's what I mean by the fact that macros will require some code to identify those symbols
06:36clgvah right. that's the exact description
06:36cflemingThe unused locals is something else - this is where for a let-binding or a function parameter, or something similar, Cursive will tell you if it's never used.
06:36clgvI mixed up unused locals with undeclare symbols, sorry
06:36cflemingNo worries
06:36cflemingIt's really useful, since that is nearly always a bug
06:37cflemingWe'll be marking unused imports and requires in the editor soon too.
06:37clgvcfleming: I know that ccw does a lot of this editor features via static analysis as well. I always thought it shouldnt be that complicated to run an additional repl for the UI which can provide exact infos, is it?
06:37cflemingYou could probably do this in Emacs, and of course you can always use something like Slamhound externally, but having it live in the editor is really nice
06:38cflemingclgv: I don't think ccw does anything statically, it's all done in the REPL, like Emacs or Vim would do it.
06:38clgvcfleming: yeah, I definitiely wont argue against nice to have features. I hardly use emacs ;)
06:38clgvcfleming: the outline is definitely static
06:38cflemingAFAIK they don't even provide rename right now.
06:39clgvauto completion and such is done via the REPL
06:39cflemingHehe, yeah, I'm not trying to start an editor war by any means, it's just interesting to compare them.
06:39clgvyeah, thought so ;)
06:39cflemingEmacs et al never have the problem of undefined symbols, even if they're generated by some gnarly macro
06:40cflemingAlthough with a REPL you can't do anything with local symbols, only globals
06:40cflemingSwings and roundabouts
06:40clgvcfleming: but again, do you think it would be that complicated to combine the static analysis with information from evaluating the project?
06:41cflemingNo, and it's something I've thought about. The issue is that you need a REPL, and you either wait for the user to set one up (and have no support till that's done) or you try to do it automatically
06:41cflemingBut people do some crazy things with macros, you can get all kinds of side effects, or it can require odd startup.
06:42clgvcfleming: I'd choose the automatic option and separate it completely from any repl the user launches
06:42cflemingStorm creates a bunch of vars from fields of a Java class, so for that to work you have to compile + load the class, and there's no way to know from looking at the code that you need to do that.
06:42clgvbut depending on the features some communication might be needed between that repl and a user repl
06:42cflemingclgv: but you can't automatically start a REPL and just try to load everything into it.
06:43cflemingThe user would have to specify what they want loaded.
06:43cflemingI dunno, it's messy.
06:43cflemingBut you can't do macroexpansion without a REPL - for the moment I'll be using whatever the user has open
06:43clgvcfleming: you could lazyily load the namespace as soon as they are needed because the user edits a namespace
06:44cflemingclgv: yeah, but that wouldn't load Storm's Java class
06:44clgvwhen you open an editor for a namespace it can be loaded in the background to provide needed information
06:44cflemingYeah, you can do that. I'm not sure, I'm going to see how far fully static will take me - combining the information from the two would be tricky
06:45cflemingBut it might turn out to be necessary
06:45cflemingI'm hoping not, though :-)
06:47clgvcfleming: well, how can you do anything useful for custom macros defining symbols or functions?
06:47clgvcfleming: I think thats the main problem that static analysis will not solve
06:50cflemingclgv: I have an extension API, which is what I use internally - I'll open that up.
06:51cflemingIt's pretty simple, you basically provide a function that takes a form and returns a map that looks very like var metadata
06:51clgvcfleming: ah, the user can provide the syntax of custom macros so that cursive is able to interprete them correctly?
06:51cflemingYup
06:51cflemingWell, not yet, only I can right now. But that's the idea.
06:51clgvso the most popular libraries can get those annotations like that
06:52cflemingYeah, and people can write support for their internal macros.
06:52clgvinteresting.
06:53cflemingI'll probably have a central repo (like DefinitelyTyped for Javascript)
06:53cflemingBut people would be able to use their own extensions.
06:58ddellacostahmm, what is the plugin for emacs which lets you close/hide clojure forms? is it available in clojure-mode by default? Not sure what to call that operation
06:58clgvddellacosta: fold/unfold?
06:58ddellacostaclgv: yah, that sounds right...know how to do that w/clojure in emacs?
06:59clgvddellacosta: no idea. I just wanted to suggest what name you could search
06:59ddellacostaclgv: ah, okay...will see if that helps find the package
06:59ddellacostathanks
07:00agarmanI've honestly never missed collapsed code in emacs
07:00agarmanbut if you want it
07:00agarmanhs-minor-mode
07:00agarmanshould be available with emacs by default
07:01agarmanC-c @ C-c
07:01agarmanis the default keybinding
07:01ddellacostaclgv, agarman: d'oh, just found that via this stackoverflow question: http://stackoverflow.com/questions/1085170/how-to-achieve-code-folding-effects-in-emacs ...but thanks!
07:01ddellacostaagarman: yeah, I haven't really ever needed it, but figured I'd play with it and see if it helped at all
07:02ddellacostaagarman: I wanted to get rid of a require form in particular...
07:02agarmanIMO, if a require form is so large you don't want to see it, you may have a module that is due to be split apart ;-)
07:02agarmanbut enjoy
07:03mercwithamouthpeep
07:04ddellacostaagarman: generally I'd agree, but this is my base wrapper for my web app, and loads up a bunch of other libs to wrap them up into one main handler. The require block is almost as big as the code in the file!
07:09clgvo_O
07:10ddellacosta(I exaggerate...maybe one-third as big.)
07:17martinklepschAnyone experience getting nothing but "[Opened /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]" when running an uberjar with "java -jar name.jar" ?
07:17martinklepschI tried oracle jdk and openjdk, no luck
07:17martinklepsch(it's all on ubuntu in a docker container)
07:18martinklepschoh and the command had a "-verbose" in it too
07:21beamsono logs from the application apart from that?
07:22silasdavisI'd like a function that truncates the number of children of any node to be less than n, where a child is either a either a key-value pair or an element in a sequence
07:23silasdavisso that I can print large structures without killing my terminal
07:23silasdavisdoes anyone know of an existing function that does this, or a nice way of doing it?
07:24CookedGryphonbind *print-length*
07:24CookedGryphon(binding [*print-length* 10] (pr-str (range 99999999))
07:24martinklepschbeamso, no... same problem as yesterday :/
07:24beamsooh.
07:24beamsoit's still today for me :/
07:24beamsohave you tried running something else in the container?
07:27silasdavisCookedGryphon, ah! I didn't realise that would act recursively across the breadth
07:28martinklepschbeamso, haha, that's fun
07:28martinklepschI slept the 8 of the last 10 hrs
07:30mercwithamouthhmm any ideas on how to stop my server when (stop-server) gives a null pointer error?
07:30mercwithamouthps aux i suppose
07:31mercwithamouthgood enough...
07:33xsyn(pgrep)
07:34master_ophello, how can handle global variables for my probram
07:34mercwithamouth'(pgrep)
07:34mercwithamouthlol break damn you
07:34master_opprogram
07:34mercwithamouthjk
07:35ddellacostamaster_op: need more context
07:35master_opi have a map that change frequently , how can i update it
07:35ddellacostamaster_op: still need more context
07:35agarmanmaster_op: more context, but in general global variables should be minimized
07:35master_opi have a map defined when program start
07:35ddellacostamaster_op: why/when do you need to update it?
07:36master_opand i have a function to update this map
07:36master_opadd some keyword/value every time
07:36agarmanmaster_op: wrap it in an agent, atom or ref
07:37master_opi use ref but when i try to use contains? it tell me that it not supported on refs
07:37agarmanmaster_op: but there's likely a better way to do whatever you're trying to do without depending upon a mutable variable
07:37master_ophow can i do it ?
07:37agarmanyou have to (contains? @v)
07:37master_opok
07:37agarmanmaster_op: read http://clojure.org/concurrent_programming
07:38agarmanor rather http://clojure.org/refs
07:43CookedGryphonIs there a way to make core.async print line numbers on its exceptions, it's really really annoying having it tell me there's an issue doing a take! from nil but not giving me a clue where that's happening....
07:55gfredericksCookedGryphon: haha :(
07:59gfredericksCookedGryphon: do you not at least have a stack trace?
07:59gfredericksI'd think there'd be line numbers from the core.async code at least
07:59CookedGryphonnothing, it just prints the message from the exception and nothing else
07:59llasramgfredericks: Unless tbaldridge has cut a new version, IIRC the last release includes some code (I assume accidentally left in debugging code) which just prints the exception
08:00llasramNo trace, etc -- just the exception object
08:00gfredericksoh that's wonderful
08:00CookedGryphonit's better than failing silently like it used to iirc
08:01gfredericksmy favorite thing is when an ExceptionInfo gets printed without the data
08:01llasramhttps://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/exec/threadpool.clj#L33
08:01CookedGryphoncould someone change that to a print-stack-trace?
08:01gfredericksI bet you could monkey-patch it :P
08:02llasramOr locally install a snapshot build, or use Leiningen checkouts
08:02CookedGryphonI might actually do that, I'm already monkey patching the executor to tweak the threadpool on android
08:02CookedGryphonbut hoped I wouldn't have to for my local unit tests
08:02gfredericksdoes anybody have a core.async utils lib yet?
08:04gfrederickscause if not I might have to make core.a-sink
08:04llasramha!
08:05gfredericksit'll have a function for finding out how many messages are in a buffer
08:06gfredericksand for creating a lazy seq from a channel
08:11gfredericksstuart says: "The channel-to-sequence conversion seems like a questionable idea, making seqs that block."
08:12gfredericksany kind of IO-based seq is a seq that can block though, no?
08:12llasramI would say so
08:13gfredericksI wonder if he considers that questionable too
08:15gfredericksseque should be easy to write with core.async eh?
08:16gfredericksprobably just as easy with one of those j.u.c queues though
08:16gfredericksalthough core.async would let you use the go macro without taking up a thread
08:38mercwithamouthahh nice... ac-repl is now working
09:07crispinhey peeps
09:07agarmancrispin: hello
09:07crispinwhat's some other ways of expressing (and (:key1 opts) (:key2 opts) (:key3 opts))
09:08crispinthat is, whether a handful of keys are in a hashmap?
09:09agarman(if-let [{:keys [key1 key2 key3} opts] ...)
09:09agarmannvm
09:10agarmannot equivalent
09:10crispinreading up on if-let now. heh
09:10crispinso many functions
09:14agarman(every? #(% opts) keys)
09:14mpenet,((every-pred :a :b) {:a 1 :b 2})
09:14clojurebottrue
09:14mpenet,((every-pred :a :b) {:a 1 :c 2})
09:14clojurebotfalse
09:14kaw_How about (every? opts [:key1 :key2 :key3])?
09:14mpenetmany ways to do this
09:14mpenetbut many fail if entry val is nil :)
09:15mpenetor falsey
09:15gfredericksanything wrong with this impl of seque? https://gist.github.com/fredericksgary/2f6d21890bbe82ed5416
09:15gfredericksit seems at least better than clojure.core/seque since it doesn't drop exceptions
09:15agarmanI prefer (every? opts keys) as you're able to use key values that aren't keywords
09:16crispini got (every? opts #{:k1 :k2 :k3})
09:17agarmandon't need set
09:17agarman,(every? {:k1 1 :k2 2} [:k1 :k2 :k3])
09:17clojurebotfalse
09:17agarman,(every? {:k1 1 :k2 2 :k3 3} [:k1 :k2 :k3])
09:17clojurebottrue
09:21gfredericksTimMc: so in my team's chat room we have this chatbot that will do image searches
09:21gfrederickssomebody just searched for "Gary Fredericks clojure" and up came your photo with the shoulder rodents
09:22gfredericksclojurebot: shoulder rodents |would be| an acceptable name for a rock band
09:22clojurebotIk begrijp
09:27CookedGryphonCould someone help me write a version of alts which has an even stronger priority
09:28CookedGryphoni.e. I want to always take from the first channel as long as there's something there
09:28CookedGryphonand only when there's nothing to take look at the next channel
09:28gfrederickswhat does "when there's nothing" mean?
09:28CookedGryphonwhen there's no immediately available value
09:28gfredericksthat sounds like what the :priority option already does
09:29CookedGryphonhmm, from my experience it seems to check them in order, but it still cycles through them
09:29CookedGryphonso if i have (alts! [a b] :priority true
09:29CookedGryphonit will check a first, but after it's taken something from a, it won't keep taking from a, it moves on to take something from b
09:29gfrederickshm.
09:29gfredericksI'll go try that.
09:29CookedGryphonI might be wrong and actually I've done something else wrong
09:31gfredericksthat's my suspicion
09:31gfredericksgiven that alts! only takes one thing I'm not sure what you're even trying to describe
09:31CookedGryphonfair point
09:31CookedGryphonnow I think about it, it was an utterly ridiculous question...
09:31tbaldridgealts! takes options as well gfredericks
09:32tbaldridge(alts! ports & {:as opts})
09:32CookedGryphonwhat he means is, it's only taking one thing from one channel per alts! call
09:32CookedGryphonso my question is nonsensical
09:32tbaldridgeah right
09:32gfrederickshaha "takes one thing"
09:33CookedGryphonI think the issue is my underlying structure needs a rethink
09:34gfredericksI tried to test this out and my code is hanging :(
09:34gfredericksoh I think it gave me a vector of way too many nils
09:34gfredericksbecause alts is happy to "take" from a closed channel
09:36CookedGryphonI'm making a system where events go in the top and there's a mult which broadcasts to various subscribers. These subscribers might themselves generate more events as a result of whatever they're listening for
09:37CookedGryphonI want these internally generated events to get processed first before working on any more externally generated events, so I have an external-input channel and a feedback channel, which I am trying to merge with alts! priority true and then doing mult on the result
09:38CookedGryphonand it seems to work in practice
09:38CookedGryphonbut my tests are creating these, then doing onto-chan which closes immediately after the events are copied onto the input channel
09:39CookedGryphonand what's happening is that it's causing everything to close before all the internal events have been generated
09:39tbaldridgethere's an option to onto-chan that makes it not close
09:39CookedGryphonyep, but then how do I know when it's done?
09:39CookedGryphonwithout just sticking a timeout on my tests
09:40CookedGryphonplus, I want to test that when the channel *is* closed, everything falls out of its go-loops and whatnot and is nicely cleaned up
09:40CookedGryphonand not sat there spinning or anything
09:40CookedGryphon(my tests also listen for the results of all the go blocks that get started to make sure everything has given up control by the end)
09:41tbaldridgeit's hard to say without seeing the code
09:42gfrederickssomebody plz write core.async.erlang
09:43gfredericksyou could rewrite the go macro to support killing "processes"
09:44tbaldridgeI've thought about it, but it gets pretty hard once you consider that a "go" may or may not be currently running or parked. It's easy to cancel a park, hard to kill a thread
09:44gfredericksyeah I was assuming you would only kill while parked
09:45gfredericksare rarely-parked gothreads a common pattern?
09:45CookedGryphonmy issue is that I don't want to kill outright, I want to stop putting new input in the top, allow it to finish processing and then let me know when its finished so I can gather the results for my test
09:47CookedGryphonI sort of want to say "when all these go loops are parked, hand me control"
09:47TimMcgfredericks: This is acceptable to me.
09:48CookedGryphonis there any way of working out whether a go block is parked?
09:50gfredericksclojurebot: TimMc is the Gary Fredericks of Clojure
09:50clojurebotRoger.
09:53clgvTimMc?
09:53clojurebotTimMc is the Gary Fredericks of Clojure
09:53clgv:D
09:54gfredericksdoes seque actually suppress errors? I thought so but now I can't reproduce
09:54gfredericks,(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5))
09:54clojurebotExecution Timed Out
09:54gfredericks&(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5))
09:54lazybot⇒ (3/5 2/3 3/4 6/7 1 6/5 3/2 2 3)
09:55gfredericks&(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5) (last))
09:55lazybot⇒ 3
09:55gfredericks,(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5) (last))
09:55clojurebotExecution Timed Out
09:55gfredericksin my repl that gives an arithmetic exception
09:55gfredericksso...three different behaviors.
09:56gfredericks&(->> (iterate dec 2) (take 5) (map #(/ 6 %)) (seque 5))
09:56lazybot⇒ (3)
09:57gfredericks???
09:57lazybotgfredericks: Oh, absolutely.
09:59TimMcclojurebot: gfredericks?
09:59clojurebotgfredericks is a menace to bots everywhere
09:59tickingI think the edn spec is missing fractions, any thoughts?
10:01gfredericksticking: I hadn't noticed that, that's interesting
10:02gfredericksticking: easy to do with data readers though
10:20tickinggfredericks: yes, but the clojure.edn parser does handle fractions
10:20ticking,(clojure.edn/read-string "1/2")
10:20clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.edn>
10:20tickinghrmph
10:20clgv,(require 'clojure.edn)
10:20clojurebotnil
10:20clgvtry again ^^
10:20ticking,(clojure.edn/read-string "1/2")
10:20clojurebot1/2
10:21hyPiRionwhut
10:21tickingclgv: ah thanks I didn't know that the clojurebot had state ^^
10:21clgvticking: yeah, clojurebot even supports "def" now. I think the variables are cleared after some time
10:21ticking,(pr-str 2/4)
10:21clojurebot"1/2"
10:21tickingclgv: nice ^^
10:22tickingso yeah either clojure.edn implements to much or the formal syntax is missing something
10:24gfredericksticking: I mean doing e.g. #ratio [3 4]
10:24tickinggfredericks: yeah but that's not how the edn toolchain currently implements it
10:24tickingcurrently it simply understands ratios (which is the correct behaviour imho) but this is not conform with the spec
10:34hyPiRionticking: yeah, I would file an issue over at the EDN spec, I guess
10:34tickingcurrently on it ^x
10:34hyPiRionnice
10:38master_ophello, i have a problem at merge-with http://pastebin.com/6DNBSGX3
10:40llasrammaster_op: `merge-with` doesn't have any special handling for nested maps
10:40master_opok
10:41master_ophow can perform this ? any idea ?
10:41llasramYou want something like (merge-with (partial merge-with +) ...), or define your own recursive version
10:41master_opok
11:14stuartsierramaster_op, llasram: some old code you can copy here https://github.com/clojure/clojure-contrib/blob/d04a63371ea8d5313ba427259a58e51270d8f7da/modules/map-utils/src/main/clojure/clojure/contrib/map_utils.clj#L41
11:49gfredericks,(clojure.edn/read-string "3/4")
11:49clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.edn>
11:49gfredericks,(require 'clojure.edn)
11:49clojurebotnil
11:49gfredericks,(clojure.edn/read-string "3/4")
11:49clojurebot3/4
11:49gfredericks,(clojure.edn/read-string "3N")
11:49clojurebot3N
11:49gfredericks,(clojure.edn/read-string "3M")
11:49clojurebot3M
11:49gfredericks,(clojure.edn/read-string "3r222")
11:49clojurebot26
12:04KeithPMGood day. I am trying to implement fibonacci using a dictionary. I tried memoize but could not figure out a function to memoize - I am seeking to implement without recursion. I created a ref to a map, updated it on each iteration and looked up values. It appears that all the updates that are performed within the for comprehension are lost when I leave the for. https://gist.github.com/kpmaynard/f8b539326bf2e903f402
12:05TEttingerKeithPM, for is lazy IIRC
12:06gfredericksKeithPM: you want let instead of def
12:06gfredericksKeithPM: and you can probably replace for with doseq and have it almost work
12:06gfredericksat which point you can remove your do
12:06CookedGryphonKeithPM: *why* do you want to do this without recursion?
12:06KeithPMgfredericks: OK, I will look up doseq
12:07CookedGryphonand memoize isn't a good fit because you have side effects everywhere, memoize works with pure functions
12:07gfredericksKeithPM: doseq has the exact same syntax as for
12:07KeithPMCookedGryphon: I was looking at a dynamic programming course and that was one of the techniques of handling certain classes of 'intractable' problems
12:07gfredericksmemoize can only work if the recursion is memoized as well
12:07KeithPMgfredericks: Thanks
12:08KeithPMTEttinger: IIRC?
12:08CookedGryphonKeithPM: when you say without recursion, do you simply mean without blowing the stack by calling back into your function repeatedly? Because there's nicer ways of doing that
12:08gfrederickshttps://github.com/Prismatic/plumbing/blob/master/src/plumbing/core.clj#L305-320
12:09gfredericks$google iirc
12:09lazybot[The IIRC | INTEGRATED REPORTING] http://www.theiirc.org/
12:09gfrederickshaha
12:09CookedGryphon:P
12:09KeithPMCookedGryphon: yes, I know some really neat approaches. I was trying the memo approach for savng subproblems that have already been solved
12:10TEttingerif I recall correctly
12:11KeithPMTEttinger: OK - cool :) I'll memoize that one LOL
12:11clgvKeithPM: for the dp approach you'd just use a loop-recur with a loop variable to fill the dp-vector
12:12KeithPMclgv: But in the case of exponential problems like Fib, you still perform fib(n) multiple times right?
12:13gfredericks,(defn fib [n] (get (reduce (fn [m n] (assoc m n (+ (m (dec n)) (m (- n 2))))) {0 1 1 1} (range 2 (inc n))) n))
12:13clojurebot#'sandbox/fib
12:13gfredericks,(fib 20)
12:13clojurebot10946
12:13clgvKeithPM: I don't undestand that question
12:13gfredericks,(map fib (range 20))
12:13clojurebot(1 1 2 3 5 ...)
12:13gfredericks,(defn fib [n] (get (reduce (fn [m n] (assoc m n (+ (m (dec n)) (m (- n 2))))) {0 1N 1 1N} (range 2 (inc n))) n))
12:13clojurebot#'sandbox/fib
12:13gfredericks,(fib 100)
12:13clojurebot573147844013817084101N
12:14gfredericks^ dynamic programming, no mutation necessary
12:14clgvgfredericks: I'd use a clojure vector though ;)
12:14gfredericks,(defn fib [n] (get (reduce (fn [m n] (assoc m n (+ (m (dec n)) (m (- n 2))))) [1N 1N] (range 2 (inc n))) n))
12:14clojurebot#'sandbox/fib
12:14gfredericks,(fib 100)
12:14clojurebot573147844013817084101N
12:15gfredericks(inc clgv)
12:15lazybot⇒ 19
12:15clgv:D
12:15gfredericks,(fib 1000)
12:15clojurebot70330367711422815821835254877183549770181269836358732742604905087154537118196933579742249494562611733487750449241765991088186363265450223647106012053374121273867339111198139373125598767690091902245245323403501N
12:15gfredericks^ that guy is lonely because other fibonacci numbers are so far away
12:15KeithPMgfredericks: I will take a look at that
12:16gfredericksKeithPM: it's really common for algorithmic stuff like this to be solvable without any state/side-effects etc
12:16gfredericksthe lazy seq approach is even more common than building up a vector though
12:16adsiscoi have a function that f [index i, index j] that generates a float value, how do i use it to populate a matrix in clojure?
12:17KeithPMclgv: What I was referring to is that in the recursion tree you find the same problem occurring on two sides. The approach we're looking at is saving a problem the first time you meet it and check each new subproblem to determine whether it has been solved already
12:17adsisco[[(f 0 0) (f 1 1)] [(f 1 0) (f 1 1)]]
12:17adsiscoi hope i'm making sense...
12:17jcromartieyeah
12:17jcromartieadsisco: you want for
12:17KeithPMgfredericks: Thanks. The power of reduce and map :)
12:17adsiscoi could do loop in an imperative language
12:17clgvKeithPM: yeah that's memoization if you mean top-down, dynamic programming is bottom up
12:17adsiscois that the clojure way?
12:18adsiscojcromartie: a for loop?
12:18jcromartie,(for [i (range 1) j (range 1)] [i j])
12:18clojurebot([0 0])
12:18jcromartieoops
12:18KeithPMYes I was doing bottom up
12:18jcromartie,(for [i (range 2) j (range 2)] [i j])
12:18clojurebot([0 0] [0 1] [1 0] [1 1])
12:18KeithPMclgv: yes I was doing the bottom up approach
12:18jcromartieclojurebot: for?
12:18clojurebotfor is complected
12:18jcromartiehm
12:18jcromartieadsisco: anyway, for in Clojure is not a for loop, it's a seq comprehension
12:18clgvclojurebot: for |is| awesome
12:18clojurebotRoger.
12:20adsiscojcromartie ok, so i just map the function to the for to get my matrix right?
12:20jcromartiesomething like that
12:21jcromartiehm
12:22jcromartielet's say your function is str, so
12:22jcromartie,(for [i (range 2) j (range 2)] (str i j))
12:22clojurebot("00" "01" "10" "11")
12:22jcromartiethat's probably not what you want
12:23jcromartie,(vec (for [i (range 2)] (vec (for [j (range 2)] (str i j)))))
12:23clojurebot[["00" "01"] ["10" "11"]]
12:23jcromartiethat's better
12:23jcromartieadsisco: right?
12:23jcromartie(is forv a thing yet?)
12:23jcromartie,forv
12:23clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: forv in this context, compiling:(NO_SOURCE_PATH:0:0)>
12:24jcromartieit should be
12:24sdegutisOkay, I finally settled on having the production code be default, and with-redef'ing them out with test functions during tests.
12:25sdegutisOr the inverse, defaulting to the test version and resetting them in web-init.clj
12:25jcromartie(defmacro forv [bindings & body] `(vec (for ~bindings ~@body)))
12:26jcromartiethere should be a macro that defmacros a macro wrapped in something
12:27jcromartiecompmacro
12:27gfredericksso what's the use case for forv?
12:29clgvgfredericks: eager aggregation over nested maps
12:29clgvmeasurements etc.
12:29adsiscojcromartie: yup, thats really helpful, thanks alot!
12:30clgvbut I'd implement it similarly to mapv with one collection
12:32gfrederickseagerness is only useful when your computation is tied to a stateful resource; and vectors are about indexed update/lookup
12:32gfredericksand indexed access seems hard to reconcile with list comprehensions
12:32gfredericksso my guess is this isn't actually useful very often
12:33jcromartiewell in the case above, it was for creating a matrix, which is a great case for indexed lookup
12:33gfredericksfor matrices I'd think something more specialized than for would be more useful
12:33gfrederickse.g., you probably don't need filtering with matrices
12:34gfredericksand you might not want the matrix impl to be concretized as vectors or lazy seqs
12:34jcromartiealright fine, no forv :)
12:35gfredericksunless you're doing tensor products you'd probably never need more than one clause in the for anyhow
12:36KeithPMThanks all for your advice. I changed for to doseq and suddenly my ref was available all over. I will take another look at immutable DP approaches suggested here. Brain surgery in progress :)
12:37adsiscohttps://www.irccloud.com/pastebin/JQRXFSZ0
12:38adsiscocreate a wrapper function?
12:38jcromartie(map (partial get-in-distance-by-index json-data) (for …))
12:38jcromartieor #(get-in-distance-by-index json-data %)
12:39clgvgfredericks: eagerness is also usefull in the cases where you have to be pretty fast ;)
12:40clgvgfredericks: the above version of "forv" won't help for that though ;)
12:40adsiscojcromartie the partial fix works perfectly!?
12:40adsiscojcromartie: great!
12:40gfredericksclgv: fo sho
12:49tegiven "12", I want to add a padding digit to the front until the length of the string is = 4. ,(loop [id "12"] (if (< (count id) 4) (recur (str "0" id)) id))
12:49tehow would you do that without a loop?
12:50clgv,(format "%04d" 12)
12:50clojurebot"0012"
12:50TEttingeryep
12:50jcromartie^winner
12:50storme,(format "%08d" 12)
12:50clojurebot"00000012"
12:50arrdem(inc clgv)
12:50lazybot⇒ 20
12:51TEttinger(inc clgv)
12:51lazybot⇒ 21
12:51clgvdamn. a good day for karma ;)
12:51arrdemformat is osum :D
12:51sdegutis(inc clgv)
12:51lazybot⇒ 22
12:51hyPiRion,(require '[clojure.pprint :refer [cl-format]])
12:51clojurebotnil
12:51cbpno format in cljs ;(
12:51teoh no...
12:51tehere comes hyPiRion
12:51hyPiRion,(cl-format true "~4,'0B" 12)
12:51clojurebot1100
12:52hyPiRionte: it's not *that* bad this time :p
12:52hyPiRioncbp: is clojure.pprint available in cljs?
12:54sc4nHi
12:54tehmm, clgv -- that works, but there are some issues. for instance, it will not work on strings, which is the input
12:54tethere are also situations where it's unlikely, but /possible/ to have a number bigger than a bigint, so it will blow up
12:55teerr than an int
12:55te,(format "%04d" 1243892704832094832904832)
12:55clojurebot#<IllegalFormatConversionException java.util.IllegalFormatConversionException: d != clojure.lang.BigInt>
12:55arrdemte: there is separate formatting for doing the same padding on strings
12:56cbphyPiRion: I don't think so
12:57hyPiRioncbp: a sad day for humanity
12:57tearrdem: what is the syntax for that?
12:57arrdemte: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
12:58hyPiRionof course, the java formatter cannot do stuff like this though:
12:58hyPiRion,(cl-format nil "~14,'0,' ,4:B" 451)
12:58clojurebot"0001 1100 0011"
12:58arrdemhyPiRion: that's fine, and why we have cl-format :P
12:59hyPiRionarrdem: shh you're interrupting my monologue
13:00arrdemhyPiRion: it's a dialog as long as you recognize my interrupts :P
13:00arrdemunless it's a platonic dialogue in which case I'll back off to saying "yes" and occasionally heckling
13:01arrdems/platonic/socratic/
13:02tearrdem: yeah, im looking, just not sure where there is something similar
13:02hyPiRionhrm, I am wrong yet again
13:02hyPiRion:p
13:02arrdemhyPiRion: it's ok, just write it in swearjure and nobody else will ever know
13:02te,(format "%1$3s" "22")
13:02clojurebot" 22"
13:02tebut where do i specify the character to pad with?
13:03TEttinger$google java.util.formatter
13:03lazybot[Formatter - Oracle Software Downloads] http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html
13:03TEttingerit's a mess
13:04hyPiRionarrdem: on my todo-list
13:04teTEttinger: is that for me?
13:04teim just saying, i dont think it's possible to pad with a specified char using format
13:05teyou can pad left with a space, but then need to replace those spaces with your desired char
13:05TEttingerte, yeah, the syntax for format strings is derived from java's syntax for it which comes from C, and so on
13:05cbpte: maybe you want apache.commons stringutils
13:05tecbp: yeah, sounds that way
13:06TEttingerthe other way is to just check the length, subtract length from desired padded length, and use that many chars of padding
13:07hyPiRion,(cl-format nil "~4,,'0@A" "12")
13:07clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: cl-format in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:08hyPiRion,(require '[clojure.pprint :refer [cl-format]])
13:08clojurebotnil
13:08hyPiRion,(cl-format nil "~4,,'0@A" "12")
13:08clojurebot#<RuntimeException java.lang.RuntimeException: Parameter minpad has bad type in directive "A": class java.lang.Character\n~4,,'0@A\n ^\n>
13:08hyPiRion,(cl-format nil "~4,,,'0@A" "12") ; there
13:08clojurebot"0012"
13:09TEttinger,(let [start "22" pad-char \: desired-length 10] (str (apply str (repeat (- desired-length (count start)) pad-char)) start)
13:09clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
13:09TEttinger,(let [start "22" pad-char \: desired-length 10] (str (apply str (repeat (- desired-length (count start)) pad-char)) start))
13:09clojurebot"::::::::22"
13:10ampharmex, (use '[clojure.java.shell :only [sh]]) (sh "free") (sh "top" "-bn1")
13:10clojurebotnil
13:10hyPiRionoh what
13:11TEttinger,(print (sh "top" "-bn1"))
13:11clojurebot#<SecurityException java.lang.SecurityException: denied>
13:11TEttingerhaha
13:11hyPiRion,(sh "shutdown" "-h" "now")
13:11clojurebot#<SecurityException java.lang.SecurityException: denied>
13:11hyPiRion=(
13:11arrdemsdegutis: no worries we all have bad days
13:12sdegutisWell I must have missed them, you're all so nice :)
13:15ampharmexhas anyone broken out the clojure bot jail?
13:15arrdemampharmex: not for a while, but it's been done before
13:16hyPiRionampharmex: xeqi did it once, see http://nelsonmorris.net/2012/09/06/breaking-lazybot-out-of-clojail.html
13:16hyPiRionessentially the shell access problem
13:29sdegutisWow, took technomancy's advice and now my third party service proxy is down from 5 files to 2 small ones.
13:29sdegutisThis is pretty great.
13:29sdegutisI should seriously consider other people's ideas more often.
13:32sdegutisYou know, I find that the more I try to make our code robust, the less I'm relying on fancy language features, but only basic functions and values.
13:33mdrogalissdegutis: Pour extra hot water from tea-making onto the sponge in the sink to kill bacteria.
13:33mdrogalis... Other people's ideas that are good :)
13:34technomancysdegutis: I think the "less reliance on fancy stuff" is just something that happens naturally as you get older. =)
13:36gfrederickstalk to your doctor about using functions and data
13:36technomancyside-effects may include side-effects.
13:36Glenjaminthat sponge trick is a neat one
13:36hyPiRiontechnomancy: I don't think it has anything to do with age, but rather with experience. Perhaps that's what you meant, but I don't want to think I have to be older to be better at something
13:37technomancyhyPiRion: I've noticed a correlation with being cranky and jaded but of course no causation implied. =)
13:37hyPiRionhehe
13:40sdegutistechnomancy: LLOL
13:40sdegutis(literal lol)
13:41sdegutisabout side effects
13:45sorbo_what's the best way to write a leiningen alias that executes two tasks (i.e. the equivalent of lein cljsbuild clean && lein cljsbuild once)?
13:45technomancysorbo_: `lein help do`
13:46hyPiRionsorbo_: :alias {"my-alias" ["do" ["cljsbuild" "clean"] ["cljsbuild" "once"]]}
13:46sorbo_@technomancy perfect, thanks—I'd seen the "do" syntax in an example, but didn't realize there was a separate lein invocation
13:46sorbo_technomancy: thanks!
13:46technomancynp
13:46sorbo_hyPiRion: ditto, thanks!
13:47hyPiRionyw
13:52cemericktcrawley: True to form :-D
13:55TimMc`lein let t clean do t t`
13:56TimMcLooking forward to lein having a full stack-based language for its argument syntax.
13:57technomancyTimMc: there is a half-finished "lein-ski" plugin in my ~/src
13:58hiredmanport line lein's bash script to stack https://github.com/hiredman/stack/blob/master/foo.stack https://github.com/hiredman/stack/blob/master/stack2.sh
13:58ystaelbrb, writing a leiningen driver program for commodore 64
13:59arrdemno way you can start a jvm on a c64...
13:59arrdemlet alone a Clojure instance
13:59amalloyit'll be a virtual java virtual machine
14:00arrdemnetwork jvm client? :P
14:00ystaelarrdem: nah, the driver's just going to be a tiny Forth interpreter that translates the stack based lein command line syntax into a real script and emits it over the serial port
14:00sdegutisWe are about to have no multi-methods, no protocols or interfaces, nothing but functions (and a few alter-var-roots for initialization).
14:00arrdemystael: hehe
14:00ystaelwriting actual lein command lines in 6502 assembly is an exercise for the reader
14:01adsiscohow do i turn [1 2 3 4] into [[1 2][3 4]] ?
14:01amalloy&(partition 2 (range 1 5))
14:01lazybot⇒ ((1 2) (3 4))
14:01technomancywe should rename *read-eval* to *exercise-for-the-reader*
14:01ystaeltechnomancy: ha
14:03adsiscoamalloy: thanks!
14:09arrdemew. Okay. so since the root of a var is volatile the JIT can never inline through it, right?
14:10sdegutisI wish you could do destructuring in conjunction with def.
14:10sdegutisI have some keys of a map that I want to put directly into this namespace.
14:10arrdemsdegutis: defn totally allows for param destructuring..
14:11jcromartiesdegutis: interesting idea
14:11sdegutisI basically have (def name (:name config))
14:11sdegutisUsing destructuring with let would actually make it harder, since there would be shadowing.
14:11gfrederickssdegutis: https://github.com/fredericksgary/lib-4395 (defs-keys)
14:12sdegutisOh boy.
14:12sdegutisYep, macro time.
14:12sdegutisgfredericks: I may copy that.
14:12sdegutisVerbatim.
14:14gfrederickswould a def-utils library be useful?
14:14sdegutisI think Clojure will be part of our homeschool curricula.
14:14sdegutisgfredericks: hard to say
14:14amalloygfredericks: it'd just be a README, saying "dude, you don't need a million special kinds of def"
14:14jcromartie:)
14:15gfredericksdeftwice
14:15arrdemlolwut
14:15arrdembetter def it again just to be sure...
14:15gfredericks"Like defonce, but also works the second time."
14:15amalloyanyway, clojure.tools.macro already has the one def-util you need, name-with-attributes
14:15jcromartie(inc gfredericks)
14:15lazybot⇒ 61
14:16gfredericksI wonder how much of this karma is joke-related
14:16amalloygfredericks: you could use def-utils to create def<nth> for all n up to some reasonable number
14:16gfredericksamalloy: and use my library forty-two to make english variants
14:17amalloy(def-one-hundred-eighty-eight-times foo 1)
14:18gfredericksno more implementing that one in every other project
14:18amalloyhah
14:19gfredericks,(defmacro def...? [name & args] (if (zero? (rand-int 2)) `(def ~name ~@args) `(def ~name)))
14:19clojurebot#'sandbox/def...?
14:19gfredericks,(def...? foo 42)
14:19clojurebot#'sandbox/foo
14:19gfredericks,foo
14:19clojurebot42
14:19gfredericks,(def...? bar 43)
14:19clojurebot#'sandbox/bar
14:19gfredericks,bar
14:19clojurebot#<Unbound Unbound: #'sandbox/bar>
14:19gfredericksw00t
14:20gfredericksclojure should have antiprivate vars that can only be used from other namespaces
14:20hyPiRiongfredericks: sadly that one only works compile-time, so an AOT uberjared version would return the same result all the time, right?
14:20tcrawleycemerick: glad I could help
14:21amalloyhyPiRion: easily fixed
14:21dbaschI want a macro called deface that works just like defn, except it introduces random bugs you can’t know until you try
14:21sdegutisClojure's got so much indirection with these vars.
14:21sdegutisI sometimes wish there were no vars.
14:21amalloy(defmacro def...? [name & args] `(when (zero? (rand-int 2)) (def ~name ~@args))) works, i think
14:22gfredericks,(defmacro definitely [name val] `(def ~name (try ~val (catch Throwable t# :no-sweat))))
14:22clojurebotgfredericks: Titim gan éirí ort.
14:22gfredericksclojurebot: whatever dude
14:22clojurebotIt's greek to me.
14:23llasramclojurebot: Would it be so difficult to jut mumble *something* about exceptions?
14:23clojurebotCool story bro.
14:23gfredericks,(defmacro definitely-not [& args])
14:23clojurebot#'sandbox/definitely-not
14:23llasramniiiice
14:23llasram(inc gfredericks)
14:23lazybot⇒ 62
14:24gfrederickssee this library needs to exist
14:24gfrederickswe just need a good pun for the name
14:24amalloygfredericks: so misleading! (definitely-not (even? 2)) will make readers of my code think that math is broken
14:25gfredericksamalloy: what kind of weirdo gullible people do you get to read your code
14:25amalloycompilers are more gullible than any human being
14:25gfredericks,(def three 4)
14:26clojurebot#'sandbox/three
14:26gfrederickslol he just believed me
14:26amalloy(def largest-prime 85) ;; sure, okay
14:26gfredericks,(def _ "underscore")
14:26clojurebot#'sandbox/_
14:26llasramclojurebot is a he?
14:27amalloygfredericks: were you around when i broke clojurebot by redefining 5 to be 2?
14:28amalloyllasram: it's not super-hard. you use reflection to modify the .value field of (Long/valueOf 5)
14:28technomancyisn't this something we make fun of ruby for making possible?
14:28technomancyI'll have to update my Tome of Mockery
14:31llasramamalloy: Ah. Yeah, ok. IMHO using reflection to stomp on private final (I assume?) fields is basically the same as memcpy()ing
14:31llasramSo I'm somewhat less impressed :-)
14:31gfredericksamalloy: no way that's nutso
14:32TimMc:-(
14:32gfredericksTim does not like it
14:36llasramWell, unless someone re-defined TimMc's smiley face to use ":-("
14:37llasramAt this point we have no real way of knowing
14:39hyPiRionIt's hard to know anything when everything is relative and changing.
14:41gfredericksexcept the undeniable objective fact that it's hard to know anything when everything is relative and changing
14:42TimMcamalloy: How's that?
14:43amalloyhow's what?
14:43TimMcI did (.setAccessible (.getDeclaredField Long "value") true) but then this errors: (.setLong (.getDeclaredField Long "value") 5 2)
14:43hyPiRiongfredericks: but then it's not hard to know anything, it's hard to know anything with the exception of that statement
14:43amalloyTimMc: setAccessible mutates the Field object you have. you can't re-get the Field object
14:43TimMcOh! Point.
14:44amalloy(doto (.getDeclaredField Long "value") (.setAccessible true) (.setLong 5 2)) or something
14:44ystaelamalloy: does that break just one five or all the fives?
14:44amalloyall the (boxed) fives
14:44llasramOh, language
14:44amalloyand since clojure boxes everything, that's all of them
14:44TimMc,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject 2) subject)
14:44clojurebot2
14:45TimMcD-:
14:45hyPiRionamalloy: not all the boxed fives?
14:45amalloyTimMc: ugh, don't do it to clojurebot again
14:45llasram,(+ 5 5)
14:45clojurebot4
14:45hyPiRion,(Long. "5")
14:45clojurebot5
14:45TimMcoops
14:45amalloyhyPiRion: true. all the ones boxed via Long/valueOf
14:45TimMcI should have use a bigger 5.
14:45arrdem,(+ 2 2)
14:45clojurebot4
14:45arrdem,(+ 5 5)
14:45clojurebot4
14:45ystaelis there a numerical threshold above which boxed instances are not cached and shared?
14:45jcromartiewow, nice
14:46TimMc,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject 5) subject) ;; fixed?
14:46clojurebot2
14:46hyPiRionystael: 128 or 256 I think
14:46llasram,(+ 5 5)
14:46clojurebot4
14:46amalloyystael: +/- 128
14:46TimMchahaha
14:46amalloywell, -128 to 127
14:46llasram,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject (Long. "5") subject))
14:46clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: setLong for class java.lang.reflect.Field>
14:46arrdemhttp://i0.kym-cdn.com/photos/images/newsfeed/000/613/012/2fa.gif
14:47hyPiRionTimMc: You have seen nothing yet
14:47llasram,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject (Long. "5")) subject)
14:47clojurebot5
14:47TimMcIt restarts every 12 minutes, right?
14:47llasram,(+ 5 5)
14:47clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
14:47TimMcAnd by 12, I mean 12.
14:47llasramHmm
14:47amalloyllasram: that's the way i tried to fix it the first time
14:47amalloybut you made the same mistake i did
14:47amalloyinstead of defining 5 back to 5, you defined 2 to 5
14:48llasramOh, right
14:48llasramhah!
14:48hyPiRionhahah
14:48amalloyso now like every array access breaks
14:48TimMcI <3 FORTRAN.
14:48amalloywe never did find out if clojurebot's auto-restart actually fixes this problem
14:48llasram*amazing*
14:48amalloyhiredman gave it a manual hard-reset before waiting for that
14:48arrdemamalloy: one way to find out...
14:50TimMc,(let [f (.getDeclaredField Long "value"), subject 0] (.setAccessible f true) (.setLong f subject 42) subject) ;; if it will even run...
14:50clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
14:50TimMc,(.getDeclaredField Long "value")
14:50clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
14:51TimMcAmazing.
14:51amalloyTimMc: right, it's too late i think. you can no longer eval anything
14:51dansdo most people really work with plain SQL migrations for big projects? nothing that generates SQL from some models defined in some clojure data structure?
14:51amalloybecause eval uses the number 2 in an array somewhere
14:51amalloy,1
14:51clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
14:51TimMcGot it.
14:51arrdemhahaha
14:51hyPiRion,'1
14:51clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
14:51arrdem(inc TimMc)
14:51lazybot⇒ 58
14:51TimMcOnly 28 points!
14:52TimMcI thought I had more.
14:52hyPiRionTimMc: well, since 2 is 5 and 5 is 2
14:53gfrederickswait we can prove a contradiction with this right? and then derive anything?
14:53gfrederickslet's derive bugfixes
14:53arrdemgfredericks: quick prove P!=NP then we can keep our jobs forever
14:53TimMcamalloy: Do you know any way to get ahold of that interned 5?
14:53ystaelTimMc: it's no longer a number ... it's a free man now
14:54amalloyTimMc: what do you mean?
14:54gfredericksarrdem: or P = NP but only for galactic algorithms
14:54TimMcWell, I'm trying to restore my REPL's notion of small numbers.
14:54arrdemgfredericks: this is also an acceptable outcome.
14:55amalloyi don't think you can do it if you've gone to the second level of broken like llasram did
14:55amalloybut if you've only broken it one level, it is reversible
14:55TimMcJust one level of fail.
14:56amalloyiirc this works: (let [five (long (int (+ (int 1) (int 4)))), field (nth (.getDeclaredFields Long) 3)] (.setAccessible field true) (.set field five (int (+ (int 1) (int 4)))))
14:56TimMcI'm having trouble figuring out what's going on here: https://www.refheap.com/85696
14:57amalloyfiddling with (Long. "5") doesn't help, because that's not the interned version
14:57TimMcOh! Right-o.
14:57llasramWouldn't (Long/valueOf "5") work? Or does the compiler do funny things?
14:58amalloy&(identical? (Long/valueOf "5") 5)
14:58lazybot⇒ false
14:58llasramOh, interesting
14:58amalloy&(identical? (Long/valueOf 5) 5)
14:58lazybot⇒ true
14:58llasramThat makes sense of course
14:58amalloyi don't know *why*, but apparently the string version bypasses interning
14:59amalloyllasram: does it? it should parse it as a long, then use the intern cache to get a Long
14:59TimMcvalueOf probably just shortcuts, right?
15:00amalloyincidentally, three cheers for repl history: i just searched it for setAccessible to find this fix; i probably wouldn't have remembered it on my own
15:01llasramamalloy: Eh. It's not really clear to me why it should use the cache for the result of string parsing. Not saying it shouldn't -- it just doesn't seem unreasonable for it to not
15:01hyPiRionTimMc: Oh hey, if you find this sort of stuff funny, you should see this one: https://www.refheap.com/85697
15:01hyPiRionThat one segfaults or makes your JVM spin up an infinite loop
15:02amalloyhyPiRion: do you really have to remove its FINAL modifier? once you make it accessible i think you can already write to it
15:02amalloyjust like for Long
15:03amalloymaybe you're doing something weird i don't see there
15:04hyPiRionamalloy: it's static, which makes it a bit different IIRC
15:05hyPiRionat least I just checked, and it doesn't work with just .setAccessible
15:05TimMc,(+(*)(*)(*)(*)(*))
15:05clojurebot5
15:05TimMcIt's back!
15:06llasram,(+ 5 5)
15:06clojurebot10
15:06llasramYay!
15:12TimMcamalloy: I was able to fix it in my REPL by using "subject (+ 2 3)", but when I tried again with "subject 5" nREPL quit with an NPE. :-P
15:12ystaelWhen building a custom coercion matcher in Prismatic/schema, if I'm trying to coerce into a multi-level record structure, it's supposed to recurse into coercing into the sub-schemas automatically, right?
15:12amalloyTimMc: my suggested fix didn't work?
15:13TimMcI didn't try it, since I was able to fix it a different way.
15:14TimMc"Bye for now!" https://www.refheap.com/85699
15:15sdegutisRelated: https://medium.com/message/81e5f33a24e1
15:15amalloyTimMc: yeah, that's setting 2 to 5 again
15:16amalloywhich really is a lot more disruptive than setting 5 to 2
15:17KeithPMgfredericks: I just finished digesting the DP code you shared this morning. Surgery over now :) Thanks
15:18TravisDI'm curious about the DP code now.
15:18KeithPMLOL… (defn fib [n] (get (reduce (fn [memo n] (assoc memo n (+ (memo (dec n)) (memo (- n 2))))) {0 1N 1 1N} (range 2 (inc n))) n))
15:19KeithPMI changed his m to memo… the 'm' was confusing me :)
15:19KeithPMI was seeking a way to use a map to store computed values
15:19amalloyKeithPM: and having n and m doesn't confuse you?
15:20TravisDAh, so it stores the solutions in a dictionary and then if you ever need to recompute it, you can just look it up in the dictionary
15:20TravisD?
15:20TimMcamalloy: Ah, OK. Makes sense.
15:20TimMcsdegutis: Good quotes in there.
15:20KeithPMNo… Actually I think of m and n as integer types… I was struggling OK? :)
15:21KeithPMTravisD: Yes that is the idea.
15:21TravisDcool :)
15:27sdegutisI'm reminded of that article that says the Clojure software ecosystem has no security baked in.
15:28dbaschsdegutis: in what context?
15:29dbaschsecurity is not really something you can have “baked in"
15:30jcromartiesdegutis: what does that even mean?
15:31benmosshttps://hackworth.be/2014/03/26/clojure-web-security-is-worse-than-you-think/
15:31jcromartieClojure web security is exactly what I think.
15:31benmossmaybe you should ask the author to update his blog post
15:32dbaschagree with jcromartie
15:32jcromartieit's only "worse than you think" if what you think is "well I just wrote a networked service, I hope it's secure"
15:33dbaschand that’s the same in any language / platform really
15:33jcromartielike the Ruby secureheaders gem example… a library introduced in Jan 2013
15:34dbaschwhat would be useful is a reference with best practices for writing relatively secure clojure apps
15:34jcromartieor just hit up OWASP and educate yourself
15:35jcromartiethen you'll be prepared to reason about potential security problems of any web app
15:35dbaschwhat I mean is, here are a few libraries that are relatively battle-tested in clojure, and here’s how to use them
15:36dbaschof course you should reason about the problems of apps first, the question is when you get to the point of
15:36sdegutisNo computer is secure. Some are far worse.
15:36technomancyrelevant https://medium.com/message/81e5f33a24e1
15:36dbasch“I need to build a password db, should I roll my own or is there a library that works reasonably well?”
15:37nullptrand remember, if you do an absolutely perfect job of web security in your application, someone can still sniff your server memory if your ssl vendor has a bug...
15:41jcromartie"perfect security" is basically the halting problem
15:42jcromartieif you're talking about depending on some other code to make your app secure at least
15:43dbaschin most contexts security is relative, e.g. nobody wants to be the app that got hacked and had to tell everyone to change their passwords everywhere because they were crappily hashed
15:43lemonodori used to work with guys who did DRM for movie studios, they only browsed the web via BSD VMs they generated fresh every day. “it would cost someone $50K to buy a zero-day and target us, and we know it’s worth a lot more than that to them.”
15:44jcromartielol DRM
15:46llasramjcromartie: Did you see this when it was making the rounds? https://plus.google.com/+IanHickson/posts/iPmatxBYuj2
15:47jcromartieyes
15:47dbaschllasram: that came to mind too
15:47llasramI'd actually wondered for a while what was up with the total non-response on breakage in e-book DRM. That article seems spot on, at least for that instance, and stopped my lols :-(
15:48mdrogaliscemerick: ping
15:48storme,(for [x (range 0 3) y (range 0 2)] { :x x :y y })
15:48cemerickmdrogalis: pong
15:48clojurebot({:x 0, :y 0} {:x 0, :y 1} {:x 1, :y 0} {:x 1, :y 1} {:x 2, :y 0} ...)
15:48jcromartieyeah, nobody cares about DRM
15:49mdrogaliscemerick: Is there a trick for using Austin in applications where browser-connected-repl-js can't come from the server?
15:49jcromartielike I don't believe for one second that anybody would even care to pay for a solution to movie studio DRM
15:49jcromartiethey get it every other way you can think of
15:49mdrogalisReading old IRC logs. Looks like setting up an endpoint just for that is what people are doing.
15:49jcromartieanyway </off-topic>
15:49lemonodorthat post is somewhat correct. the incentives are definitely misaligned between, say, studios & player manufacturers. but the studios do care about their DRM getting cracked—though they only care that it holds up for about 30 days pas the street date.
15:51lemonodorjcromartie: there are offshore businesses making lots of money from subscription blu-ray pirating software.
15:51jcromartieinteresting
15:51stormeMy big-o notation isn't the best, and I'm still new to Clojure... what would be the best way to turn ,(for [x (range 0 3) y (range 0 2)] { :x x :y y }) from O(n^2) to O(1)?
15:52cemerickmdrogalis: Nothing in Austin. People have hacked various ways to inject the necessary JS when they want. I think someone was working on a chrome extension to do roughly that.
15:52llasramstorme: mu
15:52stormellasram, mu?
15:52cbpmooo
15:53mdrogaliscemerick: Interesting. Okay, thanks.
15:54llasramstorme: Un-ask the question :-) Enumerating all those maps is necessarily linear w/ the number of maps you wish to emit
15:55bgilbertHey guys, quick question.....does anyone know how to use apply with javascript interop in cljs?
15:55storme llasram, Ah, so there isn't anything that can be done about it?
15:55bgilbertI'm looking for something like: (apply (.foo bar) [1 2 3])
15:56bgilbertwould be rewrite to: foo.bar(1,2,3)
15:56llasramstorme: Not unless I've misunderstood what you're trying to achieve
15:56bgilbertI guess this question would extend to java interop as well
15:56turbofailwell in java interop you basically can't do it
15:57jcromartieI've done it in cljs
15:57turbofailwith CLJS you should be able to arrange to call the .apply method
15:57llasrambgilbert: well, there's slightly different solutions depending on whether the .bar method is a Java varargs method
15:57llasramoh, javascript
15:57llasramla la la
15:57bgilbertah, well I'm primarily looking for the answer in js
15:57bgilbertya
15:58ghadishaybanwhat turbofail said, make the seq a js array and call js's .apply
15:58bgilbertturbofail: ah duh, thanks :)
16:07RockdtbenHey all
16:08RockdtbenIs there a way to output the code I wrote in the repl to a text file?
16:12llasramRockdtben: Not as a built-in general solution, no. If you're using a REPL which saves history, you can find the history file
16:14amalloystorme: i mean, you want to create n^2 maps. assuming that creating a map takes constant (non-zero) time, you can't help having an n^2 solution
16:15amalloyand if it takes more than constant time, then you can only get worse
16:16stormeamalloy: I was under the same impression but wanted to be sure given I don't come from a CS background. Thank you!
16:19stwRockdtben: if you use cider in emacs you can write the history to a file
16:19stwRockdtben: (setq cider-repl-history-file "path/to/file")
16:23Rockdtbenllasram: Thanks
16:25Rockdtbenstw: Alright
16:25Farehi. Is there a python parser in clojure?
16:26tuftFare: don't think so, but there is jython
16:27tuftFare: you could probably use their parser
16:27Faretuft: that's an interesting thought
16:27Farethanks
16:32michaelr525hi
16:32michaelr525should I build checkouts the first time before running 'lein repl' or 'lein run' in the parent project?
16:33michaelr525lein doesn't currently find the checkouts artifacts
16:33technomancymichaelr525: sounds like you're a bit confused about what checkouts are for
16:34technomancythey don't replace regular dependencies
16:34michaelr525i've added them under :dependencies in project.clj
16:35michaelr525linked as instructed under /checkouts
16:35michaelr525and ran 'lein run'
16:36technomancysounds like the lib isn't declaring its deps correctly then
16:36llasramWell, michaelr525 -- what specific issue are you seeing?
16:37llasramtechnomancy's psychic powers are pretty good especially about Leiningen, but you never know :-)
16:37michaelr525Could not find artifact..
16:37michaelr525hmm.. i think the last thing technomancy said maybe
16:37technomancymichaelr525: yeah, that is unrelated to checkouts
16:38noncom|2i'm trying emacs live, but when i jack-in into the simplest project created by lein, there is no "core" ns seen from the repl, what's wrong?
16:38llasrammichaelr525: Has the checkout-dependency project never been deployed anyway, and exists only as a checkout dependency?
16:38michaelr525llasram: yes
16:39llasramI believe that is unsupported, and you need to at least `lein install` the dependency so that *some* artifact is present to keep the aether bits happy
16:40michaelr525llasram: ah, that's just what I suspected is happening
16:40michaelr525let me try that out
16:41michaelr525yes, that solved the problem..
16:41michaelr525thanks :)
16:41llasramnp
16:42tolstoynoncom|2: No idea if this is helpful, but if you've got one of the project files loaded in the buffer and have that buffer in focus, then call jack-in, it should work.
16:42noncom|2tolstoy: yeah, that's what it should be, but..
16:43michaelr525llasram: btw, which plugin would you recommend for building checkouts?
16:43amalloymichaelr525: fwiw, the reason you need to do this is that checkout dependencies only "replace" source files. the pom files, dependencies, all that stuff, needs to exist for real
16:43tolstoynoncom|2: Not that I use Emacs Live, so I don't know.
16:43llasrammichaelr525: I have no such recommendation :-)
16:43michaelr525heh
16:43michaelr525oh btw guys, are you using smartparens or paredit?
16:44llasram<3 paredit
16:44amalloyparedit
16:45Fareif I wanted to write a parser for python syntax, which clojure tools would be best suited?
16:45amalloyi read smartparen's readme a while ago, and i recall it being kinda like a version of paredit that has one or two of the best features disabled by default
16:45jcromartieinstaparse
16:45Farejcromartie, thanks!
16:45michaelr525oh really?
16:46whompis there a literal for a sequence, or do i have to use something like (seq [1 2])?
16:46whompto get (1 2)
16:46seancorfieldwhy not just [1 2]?
16:46tolstoy'(1 2)
16:47seancorfield(i.e., why do you specifically need it to not be a vector? or '(1 2) for a list?)
16:47whompjust wondering
16:47amalloymichaelr525: https://github.com/Fuco1/smartparens/wiki/Paredit-and-smartparens#random-differences reads to me as like...a radioactive disaster. why would you turn all this important stuff off?
16:48technomancyamalloy: yeah I don't get that at all
16:50whompah thx i get it now :)
16:51michaelr525I'm still getting myself fluent on paredit
16:51michaelr525I wonder if I can detach this ERC buffer to a separate window?
16:52nullptrmichaelr525: M-x make-frame
16:53michaelr525haha it worked! thanks nullptr :)
16:53michaelr525now I know that it's the same buffer in both frames ;)
16:54nullptrheh, figured :)
16:54nullptrfortunately these are lessons you only need to learn once and they apply to other buffers equally
16:54nullptr(inc emacs)
16:54lazybot⇒ 3
17:09noncom|2so why could cider fail to determine that the current buffer is a part of a lein project?
17:10gtrakhow does cider know if a buffer is part of a lein project?
17:10gtrak(I'm pretty sure it just recurses up dir parents until it finds a project.clj)
17:11gtrakwhen you do cider-jack-in, but I'm not sure if it uses that technique for anything else.
17:11noncom|2right, that's what lein is supposed to do i think
17:11noncom|2but from the emacs live doc: "Project discovery is made possible because each buffer has a buffer-local variable named default-directory which stores the directory the file associated with the buffer is located within."
17:11noncom|2so maybe the buffers "buffer-local" variable is damaged?
17:11noncom|2how can i check for it?
17:11gtrakwhat's emacs live got to do with it?
17:12noncom|2emacs live uses cider
17:12gtrakwhat relies on this?
17:13noncom|2well, emacs live fully relies on cider for clojure repling, and that is what the documentation emphasizes
17:13gtrakerr, I mean the variable specifically
17:13noncom|2idk, i am a emacs newb
17:14arrdemBronsa`: question about locals metadata if you've got a minute
17:14Bronsa`sure
17:14noncom|2i guess that the variable "buffer-local" is common for emacs buffers to specify filesystem location of buffer contents if the buffer contains an open file
17:15arrdemBronsa: (->> (clojure.tools.analyzer.jvm.core-test/ast (defn alter-var-root [^clojure.lang.Var v f & args] (.alterRoot v f args))) :init :methods first :body :ret :target :form meta) => nil. wat.
17:15noncom|2and that cider relies on it to know where from the repl start was issued
17:15noncom|2and passes the dir to lein and then you know what should happen
17:15gtraklet me say it another way, how do you know it's broken?
17:15noncom|2but apparently something is broken
17:15bbloomBronsa: have you started on the js analyzer? or are you just about to?
17:16noncom|2i am not sure that the variable is broken since idk how to verify this assumption. so it is just an assumption. the main symptome that i suffer from is that the launched repl is fully unaware of the project namespaces
17:16noncom|2and when i go (ns my-project.core) it creates a new one, empty one
17:16Bronsaarrdem: well, "v" in "(.alterRoot v f args)" has no meta, :form just contains the original symbol
17:17gtraknoncom|2: sounds like just the parent-search thing is what's broken.
17:17gtrakie lein is starting up the default project.
17:17gtrakwhich is not a project
17:17noncom|2yeah, with just the user virtual ns.. so likely.. but this emacs setup is out-of-the-box, how can it be broken?
17:18noncom|2emacs live is pretty popular
17:18arrdemBronsa: sure, but it was my understanding (which apparently is wrong) that the same symbol object was used for "v" as an arg and here as a lvalue. So really the type hint exists only on the arg instance?
17:18Bronsabbloom: I started working on it today, Alex created the repo a few hours ago https://github.com/clojure/tools.analyzer.js
17:18bbloomBronsa: saw that, that's why i asked
17:18bbloomBronsa: cool stuff. i know the cljs analyzer pretty well, so let me know if you find yourself head scratching. happy to help :-)
17:18Bronsabbloom: yeah I'm going to start pushing working code in a day or two
17:19Bronsabbloom: oh, thanks!
17:19gtrakBronsa: when can I start relying on it in cider ;-)
17:20Bronsaarrdem: right, internally in tools.analyzer I use an atom to share that info between the :binding node and the :local nodes
17:20Bronsagtrak: I'll let you know :)
17:20noncom|2gtrak: so don't you have soe ideas on where to look to fix the problem?
17:21gtraknoncom|2: yea, not sure, I'd try running lein and narrowing down stuff.
17:21noncom|2you mean lein from the OS?
17:21gtrakdoesn't sound like anything that's cider's fault.
17:21gtrakyea
17:21noncom|2but emacs is an os!
17:21noncom|2hah :)
17:21noncom|2joke
17:21gtrakit just needs an editor!
17:21noncom|2yeah :)
17:22Bronsaarrdem: you'll see that (-> ast :init :methods first :body :ret :target :tag) will be clojure.lang.Var as you'd expect
17:23Bronsaarrdem: using ast1 at least. ast doesn't run any of the passes
17:23technomancynoncom|2: creating a new empty ns when you run (ns myproject.core) is totally normal behaviour
17:23noncom|2gtrak: you're right, running from the host OS gives the same result
17:23gtrakwelp
17:23arrdemBronsa: something's fishy... that's nil for me.
17:24FrozenlockIs there any plan to add -?> to clojure?
17:24noncom|2technomancy: but not when it is claimed that the repl session is guaranteed to start within the project...? or am i mistaken...?
17:24technomancynoncom|2: starting a repl session in the project just means you can require project code and dependencies
17:24gtrakFrozenlock: I think that's what some-> does
17:24technomancyit doesn't mean that it will require them for you
17:25Frozenlockgtrak: It is! Thanks!
17:25noncom|2technomancy: oh, i see..... so i have to (require) them..
17:26Bronsaarrdem: oh, it's :instance, not :target
17:26Bronsaarrdem: (->> (clojure.tools.analyzer.jvm.core-test/ast1 (defn alter-var-root [^clojure.lang.Var v f & args] (.alterRoot v f args))) :init :methods first :body :ret :instance :tag)
17:27Frozenlock,(:added (meta #'some->))
17:27clojurebot"1.5"
17:27noncom|2just got too used to counterclockwise i guess.. strange... why does then ccw preloads all namespaces so they are already registered within the runtime.. ?
17:27FrozenlockDang, how did I miss that.
17:27Bronsaarrdem: don't use the bare tools.analyzer `analyze`, always use tools.analyzer.jvm's `analyze` since you'll need all the passes.
17:27arrdemBronsa: yeah that one bit me yesterday.
17:27mmitchellis there a fn to create a record from a map, but without knowing the record type until runtime?
17:28michaelr525tools.analyzer, how do you use it?
17:28gtrakmmitchell: what?
17:28gtrakyou can dynamically pass constructors as functions..
17:28gtrakthere's a ->MyRecord function generated.
17:28mmitchellha, did that not make sense? :)
17:28arrdemwoah where'd ast1 come from..
17:28Bronsaarrdem: also in this case :target becomes :instance a pass in taj transforms the host-agnostic :host-call node in the jvm specific :instance-call
17:29Bronsaarrdem: https://github.com/clojure/tools.analyzer.jvm/blob/master/src/test/clojure/clojure/tools/analyzer/jvm/core_test.clj#L18
17:29mmitchellgtrak: ahh ok right
17:29gtrakand map->MyRecord as well, that's probably more appropriate here.
17:29arrdemBronsa: herp a derp. thanks.
17:30Bronsaarrdem: np. I know at first some differences between calling ta/analyze vs taj/analyze might be confusing, but they actually make sense :)
17:30arrdemBronsa: sure. suggestions for pattern matching AST subtrees? I'm currently playing with var taint detection through blacklisting a few symbols and Var.set/Var.alter
17:32Bronsaarrdem: well, there's the datomic datalog interface that's pretty neat.. https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/ast/query.clj
17:32arrdemI gotta write a link rewriter so that just opens my emacs buffer :P
17:33Bronsaarrdem: though unfortunately I don't think you could make datomic a dependency for contrib libs :/
17:34arrdemBronsa: I'd agree with that, which is unfortunate because I think my "whole program AST" thing is gonna wind up looking freakishly like a Datomic db with symbol -> ast mappings .-.
17:34arrdemhum. excuse for me to learn datalog.... taken.
17:36arrdemBronsa: awesome. thanks for the help.
18:07ToxicFrogSay I'm using core.typed. Can I do runtime type checking with it, and if so, can I use that type checking to impose certain constraints on values?
18:08ToxicFrogE.g. I have a type defined that is a map with exactly a certain set of keys; can I add the additional constraint that some of the values fall within a given set, and check that, e.g., structures read from EDN satisfy that constraint?
18:09arrdemToxicFrog: ambrosebs would appear to be offline, but I think the answer is no. core.typed does static checking, you want schema to do complex dynamic checks.
18:09arrdem$google prismatic schema
18:09lazybot[Prismatic/schema · GitHub] https://github.com/Prismatic/schema
18:10arrdemToxicFrog: you can use static checks to prove the consistency of your own code wrt those data constraints, but to impose them on read or sourced values you need to do schema equivalent checking.
18:10ToxicFrogAlright, thanks.
18:11ToxicFrogThe c.t docs talk about "tags" (runtime types) vs "types" (static types) and it's unclear whether it also supports runtime "tag checking"
18:11ToxicFrog...huh. I think I've broken core.typed, or possibly lein-typed.
18:12ToxicFrog'lein typed check' vomits out lots of duplicate 'start collecting <namespace>' messages interspersed with nils and then says 'found errors' without reporting any errors.
18:12ToxicFrog'lein typed coverage' straight up crashes.
18:14numbertenis there a way to filter a collection by 'typeclass'?
18:15amalloynumberten: that probably depends on what typeclass means
18:15numbertenso for example: (filter can-be-added collection)
18:15numbertenreturning a collection of things that can be used with the '+' function
18:16amalloythose typeclasses don't exist
18:16amalloyyou can filter number?, which happens to be the set of things that is addable
18:16numbertenso (filter can-be-added [1 2 3 :c \a]) giving you [1 2 3]
18:16amalloybut in general, for some function f, there's no way to check "is f callable on x"
18:17numberteni had a feeling, but I wanted to make sure I wasn't missing out on something
18:17numbertenthank you, that answers my question
18:31seangroveDoes it make sense to store a tree-structure in datomic, with each node being a datomic 'fact'?
18:32arrdem,(number? \1)
18:32clojurebotfalse
18:33arrdem,(char? \λ)
18:33clojurebottrue
18:37whompwhy is (fn [x] [x x]) valid but #([% %]) not?
18:37hiredman,(macroexpand '#([% %]))
18:37clojurebot(fn* [p1__73#] ([p1__73# p1__73#]))
18:37hiredman,(macroexpand '(fn [x] [x x]))
18:37clojurebot(fn* ([x] [x x]))
18:39dbaschseangrove: what is the tree for?
18:39whomphiredman, now my head hurts
18:40amalloyhiredman: you don't need to call macroexpand there
18:40amalloy,'#([% %]) demonstrates the issue as well
18:40clojurebot(fn* [p1__122#] ([p1__122# p1__122#]))
18:40hiredmanoh, right, the reader does the expanding
18:41whompstill don't understand
18:41aperiodicwhomp: the second form expands into (fn [x] ([x x]))
18:41nullptrwhomp: it's because it's trying to call [x x] as a function
18:41aperiodicwhomp: can you see the difference?
18:41nullptr,([1 1])
18:41clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector>
18:41nullptr,(vec [1 1])
18:41clojurebot[1 1]
18:42whompah i see, thx :)
18:42dbaschthis one should be in a faq, I’ve seen it asked several times recently
18:42nullptreverybody tries that at least once :)
18:43dbaschwhomp: #(do [% %]) or #(-> [% %]) will do what you want
18:44stormeThis might be the wrong place to ask, but does anyone know of any companies in the bay area working with Clojure looking to hire?
18:44nullptr(map inc [hiredman dbasch])
18:44arrdemnullptr: sadly that isn't supported
18:44nullptrbah, it's lazy anyways ;)
18:44dbaschstorme: prismatic for sure
18:45dbaschstorme: there’s clojure at Twitter
18:45arrdemyelp...
18:45stormedbasch: Thanks, I'll check out Prismatic :)
18:54martinklepschbeamso, figured out the issue. docker problem
18:54beamsookay
18:59Farelooks like instaparse has trouble specifically with contextful lexing: either implementing it, or using an external lexer that produces non-characters, is painful.
19:01arrdemFare: yeah instaparse wasn't designed for parsing arbitrary token streams
19:45seangrovedbasch: Sorry, what do you mean?
19:45l1xstorme: yes, i think prismatic is big on clojure and they are hiring
19:46dbaschseangrove: what’s your use for a tree in a db
19:47stormel1x, Thanks!
19:47seangrovedbasch: Storying UI components n children, and being able to walk the tree up or down from a given node
19:47dbaschseangrove: how fast do you need that to be?
19:48dbaschi.e. is it for real-time rendering?
19:52seangrovedbasch: No, not especially fast - it's for debugging the state of the application. I'm not sold on doing it yet, I was just wondering about the difficulty (and performance) of doing something tree-like in datomic/querying with datalog
19:52whomphow do i install incanter? i ran the .dmg for my mac but my repl still can't find it for (require 'incanter.core)
19:53whompis cljr the standard?
19:55l1xwhomp: https://github.com/incanter/incanter/wiki#building-incanter
19:55l1xi would go with this
19:56dbaschl1x, whomp just add the incanter dependencies to your project.clj
20:19whomptrying to install cljr by running the jar, and i'm getting this issue: https://gist.github.com/michaeleisel/2bd83c8dc95f188b1262. any ideas?
20:20amalloydon't use cljr. just install lein
20:20whomplein is a package manager as well?
20:20whompwhat i was trying to do was install the incanter package so that i could use it in the repl, because running incanter's dmg doesn't seem to have done that
20:20arrdemwhomp: nope. it's a maven wrapper, and maven is a dependency management system.
20:21whompok so my main goal here is to install incanter. any ideas on that?
20:21amalloyyou want to create a lein project, and add incanter to its dependencies
20:21whomp(require 'incanter.core) gives an error still after installing the .dmg
20:21amalloydon't touch any dmgs, or install anything but lein
20:22amalloyget lein 2.x, not the 1.1.0 that cljr apparently comes with
20:22whompamalloy, i have to always do that? there's no global package management? that seems kind of crazy, considering that there are lots of repls i might use it in - lighttable's, emacs's, the basic one in bash, etc.
20:22blrlein is clojure's dependancy management tool whomp
20:23amalloythere are other things you can do, but not any you should do. lein encourages repeatable builds, not system-specific installations. and creating a project is not some big difficult task that you should shrink from doing; it takes ten seconds
20:23blryou'll be pleasantly surprised how nice to use it is compared to other similar tools you might have used
20:27whompi'll look into it, thx :)
20:33blrhow I feel every time I go back to my typical work tools http://i.imgur.com/uV2LyXC.png
20:35beamsolucky you, in a way.
20:35blrbeamso: right, it could be worse
20:36beamsoyou could be in visual studio all day every day
20:36beamsoi found it tremendously difficult to try and get a rails job
20:36blrbeamso: yeah, most jobs in my little city are .Net, which I've done a fair bit of and have no desire to return to
20:36dbaschblr: at least it’s not this: http://allenrecruitmentjobs.ie/wp-content/uploads/2013/07/worst-jobs4.jpg
20:37blroh yeah, it's all relative.
20:38blrbeamso: any chance of covertly rewriting stuff in F#? :)
20:38amalloydbasch: i don't get it. that renders an "Account Suspended" page for me
20:38beamsoamalloy: it was an image of a very bad plumbing situation
20:38dbaschamalloy: it’s an image of a plumber in a flooded bathroom
20:39pdk`i like this site
20:39pdk`one link and im already banned
20:39pdk`that's a new record for me
20:42beamsoi've never seen anyone using f#.
20:43S11001001beamso: like, watched them program in it? Or knew someone who uses it?
20:44beamsouses it.
20:44hiredmanI did some euler project problems in f#, and my last laptop had an ugly as sin f# sticker on it I spent a lot of time asking people if they had f# stickers to get
20:44S11001001beamso: Hi there.
20:44beamsohello!
20:44S11001001I use https://github.com/joshcough/f0/tree/master/fsharp/f0/f0 in production.
20:45S11001001beamso: so now you can't say :)
20:46blrpity MS has never made asp.net VS project templates for their alternative languages.. always though the uptake of ironruby/python and possibly f# would be higher if they simply did that
20:46blrerr asp.net mvc rather
20:55l1xwoo uglier than haskel?
21:16whompwhy is this so? (= '() [])
21:17joegalloseqs have equality semantics
21:17joegallosuch that that will work
21:17joegalloit's a feature!
21:17joegallo:)
21:17joegallo,(= [2 3 4] (map inc [1 2 3]))
21:17clojurebottrue
21:18joegallowhich is nice, it would be sortof lame if it were like, OH HO HO, BUT NO, those aren't equal, because you see, the latter thing returns a lazy seq and not a vector
21:18Frozenlock,(= '(#".") [#"."])
21:18clojurebotfalse
21:18joegallonow that's different, because regexes do not have equality semantics that make comparing regexes ever be = unless they are identical
21:18joegallobut you knew that ;)
21:19Frozenlockthey are never equal
21:19joegallo(let [a #"."] (= a a))
21:19joegallo,(let [a #"."] (= a a))
21:19clojurebottrue
21:19FrozenlockThey are the same object
21:20joegallodid i not just say this?
21:20Frozenlockah, yes, identical -_-
21:20joegallono worries, brother
21:21mdedetrichhey guys, im coming to clojure from scala/java land, was wondering if there is a very good book/resource in regards to getting started
21:21FrozenlockIt's still making me mad that you can't test for equality with regexes. Exactly for stuff like that.
21:21Frozenlock,(= [1 2 3 #"."] [1 2 3 #"."])
21:21clojurebotfalse
21:21amalloyFrozenlock: you can't test for equality with functions either
21:21joegalloheh, yeah
21:22joegallomdedetrich: i hear good things about "The Joy of Clojure"
21:22amalloyit's really pretty similar; regex is conceptually a lot like a function
21:22mdedetrichjoegallo: thanks, will have a look
21:22Frozenlockamalloy: Ah? never tried. Perhaps I should fill a bug :-p
21:22amalloyFrozenlock: no way. never going to change
21:22joegalloi believe there's a second edition that's like, right about to hit the presses, so make sure you get that, if you can stand the wait
21:23amalloy(= inc #(+ 1 %))? testing functions for equality based on anything but reference identity is impossible
21:23arrdemamalloy: it may not change in the core compiler :P
21:24Frozenlock,(= #(+ 1 %) #(+ 1 %))
21:24clojurebotfalse
21:25FrozenlockThat's somehow conterintuitive considering that you can clearly see that they are the same thing. I mean, you could check the symbols and say 'oh, look, it's the same thing'.
21:25gfredericks,(assoc {} #"foo" 12 #"foo" 13)
21:25clojurebot{#"foo" 13, #"foo" 12}
21:25arrdemFrozenlock: sorta.. the compiler would have to know that + is commutative.
21:25arrdemgfredericks: ololololol
21:25amalloyFrozenlock: but you don't even *have* the symbols
21:26amalloyyou just have two function objects. they're not even instances of the same class
21:26gfredericksFrozenlock: if something can't be done properly almost all of the time, why bother to do it at all?
21:26Farewhat's the difference between "foo" and #"foo" ? How do I introspect the type of a value?
21:26gfredericksFare: ##(type #"foo")
21:26lazybot⇒ java.util.regex.Pattern
21:26amalloy,(doc type)
21:26clojurebot"([x]); Returns the :type metadata of x, or its Class if none"
21:26Faregfredericks, thanks
21:27Frozenlockamalloy: But I'm entering something into my repl! This is evaluated somewhere into the functions. Couldn't the equal function look at it before and see that it's the same thing?
21:27FrozenlockI suppose it would need to be a macro...
21:28gfredericksFrozenlock: where do you draw the line before giving up?
21:28gfredericksis inc the same as (fn [n] (+ n 17 -16))?
21:29FrozenlockI'd say the effect are the same, but the input isn't
21:29gfredericksyou can put arbitrarily much computational effort into analyzing these things and you still won't cover everything
21:29arrdemFrozenlock: you cannot generally prove that two functions compute the same value. Example, solve the halting problem paired with itself or any other universal problem. If this is possible then you can compute infinite results in finite time, congratulations you broke the universe.
21:29Frozenlockyeah, that's shame :-p
21:29gfredericksyou want equality only if the functions look identical in the source code?
21:29Frozenlockgfredericks: That would solve the regex, wouldn't it? ;-)
21:29gfredericksso (fn [x] x) != (fn [y] y)?
21:30gfredericksI think this would confuse the crap out of users
21:30arrdemgfredericks: hey you could prove that statically just by doing var renaming.
21:30gfredericksyep
21:30Faregfredericks, why did you prefix that with ## ?
21:30gfredericksFare: that's how lazybot knows to evaluate it
21:31Farehow do I get a list of methods for that class?
21:32gfredericksthat is a tricksy question
21:32gfredericksat least if you meant what I think you did
21:32gfredericksif you meant what you said then the answer is http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
21:32Faretrying to introspect things to discover them
21:33Fareprogrammatically, if possible
21:33gfredericksbut my guess is you want to know what clojure functions you can use it with
21:35gfredericksFare: (use 'clojure.repl) and then check out apropos and find-doc
21:35gfredericksyou're not going to able to search by class though, since that's not how clojure code is organized
21:36FareI knew about apropos — thanks for find-doc
21:37Frozenlockabout clojure.repl, is there a way to use it in every namespace?
21:37Frozenlock(not just in 'user' with lein profile)
21:39gfredericksFrozenlock: depends on how you're starting your repl
21:39gfredericksoh wait
21:39gfrederickswe were just discussing this kind of thing a couple days ago
21:40arrdemFrozenlock: in _every_ namespace? no there shouldn't be unless you want to create clojure.core/doc and bind it to clojure.repl/doc or whatever.
21:40gfredericksthe only way to get that kind of magic is to monkey-patch things in to clojure.core, but then you get into sticky situations depending on whether any of your code gets loaded first
21:40gfredericksleiningen didn't seem to have much to offer in that department, but a user.clj file should let you do whatever you need to sufficiently early
21:40gfredericksjust don't tell anybody else that you did it
21:41Fareso if I have a server application in java, and I want some request to open a clojure repl for interactive debugging, how do I do that?
21:41FrozenlockInteresting
21:41gfredericksFare: a request? like HTTP?
21:41Frozenlockliving dangerously :)
21:41arrdemFare: you use the nrepl library, drop an nrepl instance on an arbitrary port on an address behind your vpn ideally and pray.
21:41Farewhat should my request handler do (after proper validation) to start a server that my emacs can connect to?
21:42Fareyes, it's all properly firewalled, of course
21:42Farehopefully, my server should only listen on 127.x.x.x addresses
21:42gfredericksyep look at nrepl's start-server function
21:42blrFrozenlock: I have :repl {:repl-options {:init (use 'clojure.repl)}} in my lein user profile, but that will only load clojure.repl in the user namespace
21:43Frozenlockblr: Yeah, I tend to not stay in that namespace for long.
21:43blragree that it would be nice to have clojure.repl available from any ns though
21:44arrdemeh if it's for debugging just monkey patch what you want into core
21:44Frozenlockgetting to use the 'doc' function takes so much time that I just M-. and check the source.
21:45gfredericksFrozenlock: if you reload code in emacs frequently you don't have to worry about the load order as much
21:45gfredericksthat's basically my approach
21:45Fareand from the emacs side, how do I initiate connection with localhost 12345 ?
21:46arrdemM-x cider-connect
21:46FrozenlockM-x nrepl <enter> the addresse
21:46arrdemor that
21:46Farecan I have several cider connections in the same emacs?
21:47FrozenlockYes, but I find it confusing
21:47Frozenlock--> switch to the nearest nrepl buffer and .... Noooooo what have I done?!?!
21:48FareFrozenlock, fair point. I can start a separate emacs with a different background color
21:48Farebut still... how do I tell cider which host and port to connect to?
21:48FrozenlockThat'd be wise, especially if you connect to your production server's repl
21:48FrozenlockM-x nrepl <enter> localhost <enter> port (or something like that with cider)
21:49arrdemFare: nrepl/cider will ask you for a port
21:50Farethe cider web page suggests M-x cider-connect but that command doesn't look like it exists in my loaded cider
21:50gfredericksM-x cider asks for a port
21:50arrdemanyone know of codebases which use inline, bare load, use or require?
21:51Fareoh, so it's M-x cider not M-x cider-connect --- thanks
21:51Faremaybe the README.md should be updated.
21:51gfredericksarrdem: clojure.core?
21:51Jaoodhow do you access the 'doc' commando when you cider repl switches from the user ns?
21:51gfredericksJaood: (use 'clojure.repl)
21:51arrdemgfredericks: well yeah they do use raw load...
21:51Farehow different is the second edition of the Joy of Clojure ?
21:51Jaoodgfredericks: thanks
21:53blrFare: more on clojurescript and logic programming from what I understand
21:53arrdemblr: no core.typed plug?
21:54blrjust going by what's here http://www.joyofclojure.com/2nd
21:55Fareblr: thanks!
21:55FareI just bought the first edition :-/ Now wondering about the second...
21:56blrpity books don't have upgrade pricing :)
21:56arrdemthe first was good, I read it from $UNIVERSITY library. I may get the 2nd.
21:56blryou went to php university?
21:56arrdemand burned it down after I graduated.
21:57JaoodJoC is a good second book I guess
21:58Farethanks a lot for your support.
22:00arrdem,(macroexpand '(do (ns com.foo) (def bar 3) (ns com.oh-god-why) (def com.foo/bar 5)))
22:00clojurebot(do (ns com.foo) (def bar 3) (ns com.oh-god-why) (def com.foo/bar 5))
22:01arrdem,(do (ns com.foo) (def bar 3) (ns com.oh-god-why) (def com.foo/bar 5))
22:01clojurebot#<CompilerException java.lang.RuntimeException: Can't create defs outside of current ns, compiling:(NO_SOURCE_PATH:0:0)>
22:09quizdranyone know what the "mies" stands for with some line templates?
22:09quizdr*Lein templates
22:10beamsoa minimal clojurescript template, apparently
22:10beamsohttps://github.com/swannodette/mies
22:10beamsoi can't retrospectively add a template to a project, can i
22:11quizdrinteresting, how the letters "mies" come from that as an acronym, i don't know
22:12fortrucebeamso: no, there is no way to merge a template into a project, but you can look at the template and use it to setup your project.clj
22:13beamsookay
22:29zeroem,(name (keyword "foo/bar"))
22:29clojurebot"bar"
22:29zeroemis that expected behavior for keywords?
22:29gfredericksyep
22:29gfredericks,(namespace (keyword "foo/bar"))
22:29clojurebot"foo"
22:30zeroemoh, so keywords are namespaced too
22:30zeroemok, learned something new
22:30zeroemthanks :)
22:36blrthe mies templates are named after the architect Ludwig Mies van der Rohe, because "less is more"
22:47blrwhatever you do, don't lein new gaudí
22:49andrehIs there any tutuorial on PrimeFaces with Clojure for someone who already knows Java or Common Lisp?
22:50blrandreh: things like JSF are kind of anathema to clj web developers for the most part
22:51andrehblr: They normally prefer a Clojure equivalent?
22:52fortrucewill with-redefs get shadowed by a local let?
22:52blrandreh: right, most clojure web apps are composed of discrete libraries, rather than built on frameworks. It's a nice approach, but it does require you to hunt around and take a while to figure out which tools you like
22:53andrehblr: nice, thanks
22:53blrandreh: Pedestal is the closest thing to a framework, but it doesn't provide much in the way of UI components like JSF https://github.com/pedestal/pedestal
22:54blrLuminus is a good way to get a taste for the first approach http://www.luminusweb.net/
22:54blrkind of a currated collection of libraries that work well together
22:58bodie_does anyone know of a good functional database besides datomic? I can't afford the licensing for the version that doesn't suck
22:59beamsofunctional?
22:59bodie_as in datomic
22:59fortrucebodie_: pretty sure datomic is the one and only
22:59bodie_http://www.infoq.com/presentations/datomic-functional-database beamso
23:00bodie_hrm
23:00fortrucebodie_: i haven't tried it yet, you enjoying it?
23:00bodie_no, because I can't afford the version that doesn't suck ;)
23:00bodie_so I haven't checked it out any further
23:00beamsoyou could simulate the immutability of that but i think it would take a lot of work
23:01fortruceit would basically take recreating datomic ;P
23:01bodie_well, it's an implementation of datalog, right
23:02fortrucebut datalog isn't just for databases
23:02beamsoactually, i was thinking of the immutable part, not the functional part.
23:03arrdemI SOMMON THE MIGHTY INTERTUBEZ. Please help me find Clojure/Java/Haskell/Scala benchmarks :P
23:03TEttingergetting an up-to-date one might be challenging, arrdem
23:03beamsohttp://benchmarksgame.alioth.debian.org/
23:03fortrucemeh, benchmarks
23:03TEttingerreducers sped up clojure quite a bit, no?
23:03bodie_benchmeh
23:03arrdembeamso: that's where I'm looking right now.
23:04bodie_maybe I could learn haskell and work from this :P https://github.com/travitch/datalog
23:05fortruceanyone know how to use with-redefs to redefine a java ctor?
23:05dissipateisn't haskell a heavy syntax language?
23:05dissipateafter perl i told myself i would never pursue a heavy syntax language again
23:06TEttingerarrdem, no scala here but https://github.com/jafingerhut/clojure-benchmarks
23:06TEttingerit has the other 3
23:06bodie_dissipate, pretty sure haskell makes perl look like clojure
23:07bodie_but everyone who likes it swears it's easy
23:08dissipatebodie_, no haskell for me then. haskell will end up as the new perl.
23:09amalloy"haskell will end up as the new perl". literally the first time that sentence has ever been said in the history of english
23:09TEttingerhaha
23:09arrdemglad I'm not the only one chuckling at that
23:09TEttinger$google swearjure
23:09lazybot[polymatheia - Swearjure - hyPiRion] http://hypirion.com/musings/swearjure
23:10TEttingerclojure can be quite perlish
23:10dissipatearrdem, you are chuckling because you don't think it is true?
23:11arrdemdissipate: the absurdit/irony of the statement more
23:11bodie_amalloy, LOL
23:11TEttinger,(#(`[{~% ~@%&}] (+)) \: \[ \? \])
23:11clojurebot{\: \[, \? \]}
23:11bodie_it's kind of like saying zebras are the new abrams tank
23:12bodie_or potatoes are the new Mt. Everest
23:12arrdem^ this
23:12bodie_just... neurons sparking all over the place right now
23:12bodie_just left a job that was 120,000+ lines of perl spaghetti code...
23:12fortruceanyone know how to mock a java object?
23:12bodie_what has been seen cannot be unseen
23:13arrdem(inc bodie_) ;; karma cannot heal this pain but it may help
23:13lazybot⇒ 1
23:26Kitty-Hello, I am using Clojure to connect to a database and need to utilize . in my string. I've tried escaping it with \, so for example \. however it does not work. Any suggestions to try? The help would be much appreciated.
23:26fortruceKitty-: can you show me what you mean?
23:27Kitty-fortruce: sure, let me come up with a pastie link
23:29Kitty-fortruce: so here is what I used before... http://pastie.org/9194703 however since "," is a special character I tried to escape it with ,\ in http://pastie.org/9194705 on line 12 however when I compile, it complains about "\" with a stack trace.
23:30justin_smithKitty-: clojure complains about unneeded \ in string literals (and has differing rules for string vs regex literals
23:31mangeKitty-: Use \\. That'll put a literal \ in the string for the database to see.
23:31ddellacostaKitty-: what are you using to run the SQL? Which clojure lib?
23:31justin_smith,"this\."
23:31clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \.>
23:31justin_smith,"vs. This\\."
23:31clojurebot"vs. This\\."
23:31justin_smith,(println "vs. This\\.")
23:31clojurebotvs. This\.\n
23:32Kitty-\\,
23:40Kitty-hmm, here is what I get http://pastie.org/9194732
23:41Kitty-It's not liking "(\"OID\"... should I use \\ with ", so \\" maybe?
23:42justin_smithI think your string escaping is not properly balanced there - are you missing a " after TEMPT_SPINSTER\" ?
23:42justin_smith*TEMP lol freudian slip
23:43Kitty-Lol
23:43Kitty-justin_smith: thanks...let me try adding the "
23:45justin_smithalso if you have a repl available, it is much faster to test things like this in a repl
23:47Kitty-justin_smith: it compiled yaay. so when I execute the .jar against the server, i get an error http://pastie.org/9194741
23:47justin_smithKitty-: what editor are you using?
23:47Kitty-I'm thinking it must have a ; however I'm not sure how to 'escape' those
23:47Kitty-justin_smith: notepad++
23:48justin_smithin some editors (mine for example being emacs) there is an "escaped string composer" mode that automatically escapes a region after you are done editing it
23:48Frozenlockreally? What's the command?
23:48justin_smithin leiu of that in a simpler editor, maybe try interactively using that str invocation in the repl, and take a look at what it generates
23:48beamsoORA-00933 is more to do with the query or queries that you are executing rather than clojure.
23:49justin_smithFrozenlock: string-edit-at-point
23:49justin_smithFrozenlock: the awesome part is it even works recursively for recursively embedded strings
23:49blrsilly emacs question, is there a better indentation strategy than that provided by clojure-mode? The way the body of the anonymous function is indented bugs me: http://i.imgur.com/RmgUpo5.png
23:50Frozenlockjustin_smith: I don't appear to have this function... o_O
23:50justin_smithoh, it may be a package I have
23:50justin_smithFrozenlock: string-edit.el
23:50FrozenlockUnless it came later than 24.3.1, I would say so :-p
23:51justin_smithFrozenlock: package require string-edit
23:51justin_smithI forgot it was not a vanilla thing
23:52Kitty-justin_smith: any hints on what could escape a ";" perhaps? fwiw, I don't think a repl would work because the code has about 213 lines and then on top of that, it relies on compiled code originally written in java which I don't think clojure could do in realtime? So for example, it has to run off of a .jar which I don't think the repl 'does'
23:52justin_smithKitty-: I'm just talking about the generation of that one string
23:52Frozenlock213 is nothing :-p
23:52FrozenlockPush that repl, cmon, push it!
23:52Kitty-Frozenlock: perhaps, but do you copy and paste 213+ lines in repl?
23:53Kitty-justin_smith: perhaps you have an example so I can understand further?
23:53justin_smithKitty-: also, if you connect to your app by running an nrepl server from it, you can access data from the running process - you can make an atom and shove strings into it so you can experiment with them
23:53FrozenlockKitty-: That's not the ideal, but I've pasted entire source code many times.
23:53justin_smithhttps://github.com/clojure/tools.nrepl it is really easy to host nrepl inside your app
23:54justin_smithmake an atom, one of my favorites is a vector of a map, keys are args, vals are results
23:54justin_smithor you can throw timestamps in there if you have multiple things to look at ...
23:54quizdrdoes anyone know the emacs equivalent to the Light Table "add connection" command that you can use in Om to connect a script to a browser? I'm following the Om tutorial but using Emacs
23:54Kitty-justin_smith: hmm
23:55Frozenlockquizdr: Emacs doesn't have the magic LT connection. You'll have to configure a brepl
23:55justin_smithKitty-: another option is to break your code down into smaller parts that can be tested for their output
23:55justin_smiththis is good design anyway
23:55beamsofor the om tutes i just saved then reloaded the browser
23:55Kitty-justin_smith: hmm yea
23:55quizdrbut there is something the Om tutorial says to do about adding a script to the index.html, but it is not clear what it actually is, as it is done via this "connection" command
23:55justin_smiththen you just (require ... :reload) on the ns as you update, and see what things do in a repl
23:56Kitty-justin_smith: I'm pretty sure it's just not liking ";" however I don't know how to escape that
23:56justin_smith,(print "\\;")
23:56clojurebot\;
23:57beamsoquizdr: the script is so that when you save in lighttable it forces the browser to reload or reevaluate the javascript it's referencing. simply saving the clojurescript file, waiting for the recompile and reloading the html page should let you see the changes you want.
23:57Frozenlockjustin_smith: string-edit is amazing
23:57Kitty-woohooo http://pastie.org/9194755 compiles
23:57FrozenlockHow could I live without it?
23:57clojurebotGabh mo leithscéal?
23:57justin_smithFrozenlock: yeah, I know, I wish I had it years ago when I was fucking with shell scripts more often :)
23:58quizdrbeamso ah ,thanks
23:58Kitty-thanks for the tips... I'm gonna keep at it