#clojure logs

2016-02-08

00:25tolstoyIs there a concept of too many file descriptors on Windows? Hm.
00:36slestersorry for asking 'is this idiomatic?' over and over, but I want to have good programming habits in clojure heh
00:37slester(count (filter #(:active %) (:players state))) ;; is that idiomatic for counting the number of active players?
00:37tolstoyYou can (filter :active (:players state)).
00:38slesteramazing :D
00:38tolstoyThese days, I like: (->> state :players (filter :active) count), but YMMV. I wouldn't argue that's preferred.
00:39slesteris there a specific reason?
00:39tolstoyThat I like it? It seems clearer to me when I return the the code, and feels kinda like X-path, easier to see the underlying structure.
00:39rhg135(->> (:players state) (filter :active) (count))
00:39slesteryeah
00:39slesterunderstandable
00:40rhg135that's my pick
00:40rhg135it emphasizes the facts you're working on the players
00:41slesteris that more prevalent amongst clojurians than (count (filter :active (:players state)))?
00:41slesterI mean I guess they're both fine
00:41rhg135not in the code I've read
00:42tolstoyYeah, I don't think they're clearly un-idiomatic.
00:43rhg135I for one like the threading macro, but I also love to (ab)use comp and partial ;)
00:46rhg135,(((comp (partial apply juxt) (partial (comp (fnil conj []) (partial apply vector)) 1)) 2 3 4) 0)
00:46clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 542]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 542]\n [clojure.lang.RT seq "RT.java" 523]\n [clojure.lang.RT cons "RT.java" 662]\n [clojure.core$cons__4331 in...
00:46rhg135no wonder it wasn't working
00:48amalloyi would write (count (filter :active (:players state))) ("count the active players"), but (->> (:players state) (filter :active) (count)) is fine i guess. the only one i hate is (->> state :players (filter :active) count)
00:49rhg135my validation is more than 2 ) in a row moake my brain hurt when reading in a non-rainbowparens environment
00:56rhg135I also like keeping the () around a function call even if unnecessary. reminds you it's a function call
00:57rhg135unlike python were you can have properties call code D:
00:58slesterok so! I have a list of active players, want to get the next player's turn... (second (drop-while #(not= % current) (into active-players active-players))) seems wordy haha
00:59slesterignore the into stuff, it has to be in order, so using a vector
00:59justin_smithwhy (into active-players active-players) ?
00:59justin_smithoh
00:59slesterrotating around
01:00slester[0 1 2 0 1 2] so it goes from 2 to 0
01:02justin_smith(second (drop-while (complement #{current}) (cycle active-players)))
01:02justin_smithis an option
01:02justin_smithas compared to into, cycle probably does less
01:02justin_smithand then it still works with a list too
01:03rhg135,(cycle [0 1])
01:03clojurebot(0 1 0 1 0 ...)
01:03slester,(cycle '(0 1))
01:03clojurebot(0 1 0 1 0 ...)
01:03slesteryeah
01:03slester:D
01:04rhg135(inc justin_smith) ; in spirit as lazybot is no longer with us
01:11slesterseriously would be struggling with clojure a lot more sans justin_smith
01:13amalloythere are machinations afoot to bundle a justin_smith with each jar in the next release
01:13slester+1
01:14hfaafb,(inc amalloy)
01:14clojurebot#error {\n :cause "Unable to resolve symbol: amalloy in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: amalloy in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: amalloy i...
01:40BRODUSwhy doesn't this work? (map #(clojure.test/function? (first %)) (ns-map *ns*))
01:41justin_smithBRODUS: the ns-map has symbols as keys, and vars as values
01:42justin_smithI recommend using key instead of first there (it will work the same way), but if testing for functions, use (map #(clojure.test/function? @(val %)) (ns-map *ns*))
01:42justin_smithyou need to deref the var to get the actual current binding
01:44BRODUSok I didn't realize that the var needed to be derefed
01:45justin_smithoh and there are also classes in that map... so you need to only deref the vars
01:47justin_smith(map (comp clojure.test/function? deref val) (remove (comp class? val) (ns-map *ns*))) ; one way to approach this
01:47BRODUSI'm a bit confused whythe var needs to be dereffed, when I do (clojure.test/function? take) , is it derefed implicitly?
01:47justin_smith,(= + @#'+)
01:47clojurebottrue
01:47justin_smith,(= '+ #'+)
01:48clojurebotfalse
01:48justin_smith,(= '+ @#'+)
01:48clojurebotfalse
01:48justin_smiththat's why
01:48BRODUSgot it
01:49justin_smithBRODUS: take is the equivalent of @#'take, if you are getting #'take from a list, you need @ in order to make it = take
01:53BRODUSok so #' is for quoting vars which I guess is the same as referencing. Do you know why a normal quote isn't used instead? So that symbol can potentially be used for something else?
01:53BRODUS*that the symbol
01:54justin_smith#'v is var-quote, it prevents the symbol from being resolved from the var in the current context, and instead stops with the var itself
01:54justin_smithnormally v is looked up in the current compilation context, and then looked up as either a local or a var
01:55justin_smithand 'v stops even before any lookup
01:55justin_smithso it's stopping at different steps in a multi-step lookup
01:57BRODUSok I think I get it. Thanks! that was informative
02:05ambrosebseg. (let [v 1] v) is 1, (let [v 1] #'v) is the global var called v
02:16rhg135, (with-local-vars [+ 1] @#'+)
02:16clojurebot#object[clojure.core$_PLUS_ 0x4299b045 "clojure.core$_PLUS_@4299b045"]
02:16rhg135Hmm
02:17rhg135,(with-local-vars [+ 1] +)
02:17clojurebot#<Var: --unnamed-->
02:17justin_smithI like how unnamed is impaled on an arrow there
02:19rhg135Impalation!
02:20ridcullywith-local-vars the impaler
02:21rhg135Is there ever a good reason to use it?
02:22justin_smithI think now you'd probably want a volatile instead usually
02:23justin_smithrhg135: I've seen people use atoms for locally scoped stuff, but unlike atoms vars don't do retries when you do a compare-and-swap thingy to them
02:24justin_smithso I could consider using with-local-vars for a local mutable, where I might have threads, and the modifications should not retry... but that's awfully specific
02:26rhg135I don't think a locally scoped atom will ever retry if not shared
02:26justin_smithfair point
02:27justin_smithbut if you are only in one thread, using an atom seems a little silly too
02:27rhg135And if you do share it then you can't use a var
02:27justin_smithor maybe that's just me
02:27justin_smithrhg135: why can't you use a var? vars are thread safe.
02:28rhg135Well, you could but it seems iffy
02:33amalloylocal vars are super sketchy. being single-threaded is no reason to not use an atom
02:33rhg135https://github.com/ztellman/proteus is what I'd use before volatiles existed
02:33amalloyor volatile, these days
02:34justin_smithamalloy: what's sketchy about them?
02:35amalloythey're for dynamic scope, not lexical scope
02:35amalloy(doc with-local-vars)
02:35clojurebot"([name-vals-vec & body]); varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set"
02:36amalloyit creates an object that ceases to work outside of its lexical scope
02:36amalloy,@(with-local-vars [v 1] v)
02:36clojurebot#object[clojure.lang.Var$Unbound 0x1e5f1c12 "Unbound: #<Var: --unnamed-->"]
02:37amalloy,@(let [v (atom 1)] v)
02:37clojurebot1
02:37rhg135That's a new one for me
02:38amalloywhat is?
02:38rhg135I thought dereffing an unbound var threw
02:39justin_smith,(declare a)
02:39clojurebot#'sandbox/a
02:39justin_smith,@#'a
02:39clojurebot#object[clojure.lang.Var$Unbound 0x7e9c09a5 "Unbound: #'sandbox/a"]
02:40rhg135Apparently unbound vars are only a delusion.
02:40rhg135They're bound to Var$Unbound
02:41justin_smithso undefined, unbound, nil, none, and NaN walk into a bar...
02:41rhg135They don't actually exist
02:42amalloywhat about false and 0?
02:43justin_smithamalloy: off having fun with the empty set
02:43rhg135Don't forget ''
02:45rhg135I once saw a language that treated ' ' as falsey
02:46justin_smithis that the string or the char?
02:46rhg135Both
02:47rhg135A string consisting of only whitespace
02:52justin_smithwould it be possible to make a vector or lazy-seq that implemented CharSequence?
02:53justin_smithseems like you could pretty easily (answering myself)
02:55justin_smith,(instance? CharSequence (vector-of :char \a))
02:55clojurebotfalse
02:56rhg135That could be useful if not for the dependence on String in java
02:56justin_smithrhg135: but there's at least a few places where you can use CharSequence instead of needing string
02:56rhg135Very few
03:28TomTheBOMoh yes.
03:28TomTheBOM,(let [‌
03:28clojurebot1
03:28TomTheBOM,(let [
03:28clojurebot1
03:29TomTheBOMat least in the webchat, \u2029 does not print
03:29TomTheBOMit also counts as whitespace
03:47TomTheBOM,(
03:47clojurebot6
07:46qsysJust saw https://www.youtube.com/watch?v=zp0OEDcAro0 and it looks pretty powerful... just wondering if anyone has some experience with condition systems in Clojure?
07:47qsysso, well, is anyone using ribol, slingshot, ...? or anyone using dynamic bindings for this kind of condition systems?
07:49MasseRqsys: can't watch videos atm, can you tl;dr what's a condition system
08:11ashnurmust ask it here too, although probably even less chance for success. how to parse/generate edn from javascript, any ideas? anyone did something like this in the past 3 years? there are 2 modules, one is unusable for anyone than the author and the other is broken
09:20amoehas "C-c ," stopped working in a recent cider version? It now seems to wait for another keystroke, before it ran all tests for the namespace
09:21dysfunyou probably want #clojure-emacs
09:24amoedysfun: thanks
09:24dysfunyw
09:25i-blis1run-ns-tests is (now) bound to C-c , n
09:26i-blis1C-c , C-n
09:27amoei-blis: thanks!
09:27i-blisyw
10:42jonathanjwhat's the easiest way to retrieve the content of an element in an XML document with Clojure?
10:43jonathanjan element at a particular path, i mean
10:43phorseIs there a way to reload changes to server code with reagent? Right now I'm quitting and restarting, but I don't like that.
10:53jonathanjwhy does (clojure.xml/parse (clojure.java.io/file "foo.xml")) never return in my repl but (clojure.xml/parse (slurp (clojure.java.io/file "foo.xml"))) immediately parses the data?
10:56jonathanjoh, slurp doesn't actually succeed, it just fails immediately:
10:56jonathanjCompilerException java.net.MalformedURLException: no protocol
10:59gryyyTry using (clojure.java.io/file (clojure.java.io/resource "foo.xml")) instead
11:00gryyyhttps://clojuredocs.org/clojure.java.io/resource
11:00gryyyFirst example
11:00jonathanjthat seems mostly irrelevant
11:01jonathanjthe file is not a resource, it's just a file somewhere on disk
11:01jonathanjit seems like the slowness here is that parse fetches the DTD to perform validation
11:01jonathanjis it possible to use clojure.xml/parse without validating the DTD?
11:05i-blisjonathanj: are you using the fullpath name?
11:06i-blisjonathanj: what JVM do you run? >= 1.6?
11:20jonathanjit turns out this has nothing to do with the filesystem path
11:20jonathanjit's about clojure.xml/parse trying to download the DTD in order to validate it
11:20jonathanji don't know how to not do that
11:21dysfunit doesn't look like that's an option
11:21dysfunif only there were literally hundreds of options
11:22dysfunwow. clojure-toolbox is a bit short in the xml department
11:22dysfunhas weavejester given up?
11:24i-blisjonathanj: you could pass your custom instance of the saxparser
11:25jonathanjlooks like you have to set http://apache.org/xml/features/nonvalidating/load-external-dtd to false on the SAXParserFactory instance
11:25i-blisand do setValidating false to SAXParserFactory
11:26i-blisyeap, exactly
11:26jonathanjsetting "setValidating" to false doesn't actually do anything by itself
11:26jonathanjyou have to turn both features off
11:26jonathanjSAXParserFactory is just abstract though, what happens if on some system somewhere you get an implementation that is not xerces?
11:27jonathanjand that particular feature is hidden under some other name
11:30dysfunthen you're fucked? :)
11:31dysfun(or you might have to bear it in mind when deploying)
11:33jonathanjthis seems ridiculously complicated
11:36jonathanjhttps://github.com/kyleburton/clj-xpath
11:36jonathanjthis is new since i last looked for xpath clojure stuff
11:37i-blisjonathanj: also have a look at data.xml
11:38jonathanjthe thing with data.xml is that i couldn't find out how to turn it into a zipper or query it
11:38i-blisyou can pass options to the underlying javax.xml.stream.XMLInputFactory
11:39i-bliseven if you force the realization of the lazy-seq
11:40jonathanjso how do i query the result of parsing with data.xmL/
11:40jonathanjdata.xml?
11:42dysfundoesn't it give you back a data structure representing the structure of the document?
11:42dysfunyou have tons of collection functions at your disposal
11:48jonathanjoh, you can actually use xml-zip to turn it into a zipper
11:49jonathanjnone of the documentation actually mentions this
11:49dysfunheh, zippers are kept separately, but they include an xml zipper
11:49dysfunbut it depends if you want the zipper abstraction
11:49dysfunthere are many valid ways of getting data out of data structures
11:54kwladykai am looking symetric encryption algorithm (clojure module) to encrypt id from database. id like 12356 to alphanumerical r2ifdrfwi and back. Can you recommend something?
11:55kwladykaThe purpose is to hide id numbers in database
11:55kwladykaso algorithm has to consume as less CPU as possible
11:58kwladykaeventually it doesn't make sense and i will use uuid instead of id in database
11:59kwladykai am not sure what is the best solution. Better will be use encryption in Clojure not uuid in DB, but i am afraid about performance.
12:00kwladykaor symetric encryption with cash... but it start to be complex
12:01kwladykaMaybe somebody can say something about encryption and performance in Clojure?
12:03dysfunsorry, why are you hiding id numbers in the database?
12:05kwladykabecause inform your competition about so important data like number of orders every month, new users etc. is stupid :)
12:06dysfunuse a uuid, be happy, stop encrypting the wrong thing
12:06dysfunpostgres has native uuid support
12:07kwladykai know, but still i feel better is to have common database and hide id in app. But there is a performance problem. I don't know how to pass that.
12:08kwladykaIf i wouldn't find any solution to hide id in app i will uuid in DB
12:08kwladyka*will use
12:08dysfunjust use a uuid and get on with your day
12:09kwladyka;)
12:09dysfunyour other idea was not a good one
12:11kwladykathere are also other pros using uuid as id in DB. Separated app can generate data without id conflict
12:11dysfunin theory, certainly. in practice, i still have a unique constraint on my postgres tables keyed by uuid
12:12kwladykadysfun how many rows?
12:12dysfunoh, we haven't launched yet
12:12dysfunit's just defense in depth, in case it happens
12:12kwladykadysfun mmm it is "impossible" if you use uuid v4
12:13dysfunyeah yeah, down to more atoms than there are in the universe. and yet every so often i still read about clashes happening
12:13dysfunit matters less on a server, but if you let clients generate ids, they might have a shitty randomness source
12:14dysfunand in the very many 9s case, it imposes almost no overhead
12:15dysfunin the rare event of a collision, the transaction fails and i generate a new uuid
12:15kwladykaoh if client can generate it with other version then v4 that is bad desgined i guess
12:15dysfunhow can you possibly enforce it in my case? it's a REST API with an open source client
12:16kwladykadysfun i don't know details of your project. No idea :)
12:16dysfunwell, the short answer is that you're fighting a losing battle
12:17gganleyhello, how can i look at the "shape" of a datastructure, namely a HTML document pulled from a website using enlive.
12:17dysfunbecause somsone will port it to javascript and then wonder why it clashes a lot
12:17dysfunprn ?
12:18kwladykadysfun but it is not the purpose of your tool so i guess it is ok
12:18gganleyI'm very new to all things web and relearning clojure. but I'm a pretty decent programmer
12:18dysfunyes, but given that i run the (also open source) webservice, it becomes my problem one way or another
12:19dysfunanyway, better safe than sorry
12:22kwladykadysfun i don't what you are doing, but i guess you should demand user to register and save the data under his authorisation id, if he is stupid and using javascript random string generator to generate uuid or something like that... what to do, he will lean to use the tool like is write in the documentation.
12:28dysfunkwladyka: or i could stop fighting the world and do sensible things instead
12:29kwladykadysfun but what you can do with that? nothing. (if i understand what you are doing ;) )
12:30Mokusokwladyka, I really like your nick
12:30kwladykaMokuso why?
12:30dysfunwhat can i do with what?
12:30Mokusoin greeklish it's how the plural form of lapdance bars would be written
12:31dysfuni try and abstract it from a user as much as possible
12:31Mokuso*lapdance bar
12:31dysfunand i catch it if it fails
12:31Mokusoin Greek it's κωλάδικα
12:31Mokusowhich literally means "a place with asses"
12:31Mokuso*"places with asses"
12:32Mokusoanyways, please continue
12:32kwladykaMokuso lapdance bar?
12:32dysfunthat is accidentally hilarious
12:32dysfunquotefiled
12:33kwladykaMokuso what to do, it happens all the time with all nicks :)
12:34kwladykaMokuso even word mokuso exist ;)
12:34dysfuna few years ago a brand of indian sauces and things had to pull out because they found out their brand name was something rude in punjabi or some other language
12:34Mokusokwladyka, yeh, for both comments ;)
12:35Mokusobeen to Poland btw, years ago, it was nice
12:35Mokusogood beer
12:35dysfunbeer and sausage
12:35Mokusobeer and soups :>
12:35dysfunhunter stew!
12:35dysfunand lots of meat
12:35kwladykaMokuso Where do you live?
12:36Mokusokwladyka, in GR
12:36dysfuni don't imagine there are too many clojure jobs in GR
12:36kwladykaMokuso oh you have problem with immigrants now?
12:37kwladykadysfun like in PL....
12:37Mokusodysfun, actually there's a company at Thessaloniki who's looking for clojure programmers :>
12:37Mokusobut yeah, not many companies around
12:37Mokusokwladyka, the islands have huge problem
12:37MokusoAthens too
12:37dysfuni saw a maltese company looking for clojure devs the other day
12:38dysfunseems clojure is mostly breaking out in places you don't normally associate with development because they see it's great and they're not burdened with it being new like enterprise is
12:38kwladykaMokuso whole Europe is so stupid and naive... i am watching this and... that is sad
12:39Mokusokwladyka, yeah...
12:39dysfuni think perhaps that's quite strong, quite a lot of european people are really quite open minded
12:39dysfuntheir leaders less so
12:40kwladykayeah there are too open minded to get so stupid ideas...
12:41MokusoI don't think Europeans can ever be too open minded, 'cos our freedom of thought is bounded by our history
12:42kwladykathe next world war coming and i believe it is the spark
12:42Mokusothe Americans are most likely the most open minded folk, but then they might be way too open minded sometimes, which turns against them in the end
12:42kwladykait will takes years, but history will repeat like always
12:45kwladykaand other countries (also USA and Russia) will help with this fire. But of course it is my opinion. When economical fundament is in dangerous people always go to war.
12:48hyPiRionugh
12:48hyPiRion,(binding [*print-dup* true] (println "hello" "world"))
12:48clojurebot"hello" "world"\n
12:49TMAyou have reminded me of an anecdote from mathematical analysis: "open set is like a closed party -- nobody can get in"
12:49hyPiRion^ is that intentional?
12:49hyPiRionI thought it would only matter for pr and friends
12:52kwladykadysfun what do you think about uuid_generate_v1mc() vs v4? v1mc based on time, v4 is totally random.
12:52dysfuni use v4 because there are even greater issues with v1
12:54kwladykadysfun but in theory (practice?) it mean v1mc will never have conflict because of time based?
12:54dysfunhaha, if you think that, you're going to have to some surprises
12:55kwladykadysfun i don't know, there is didn't find clear information about that
12:55dysfunokay, well let's take out the mathematical security and go back to the example where your random source isn't very good
12:56dysfunhow many transactions a second do you think you have to get to with the reduced number of bits before the same node starts clashing? :)
12:56kwladykahmmm i have to press something on keyboard and it changes my words when i am writing.... it happen too often when i write something with no sense :)
12:57kwladykadysfun i don't know, but i guess a huge number
12:57dysfunv4 uuids are the only ones i'm inclinded to trust, and i'm only inclined to trust them to the point where i expect that in some cases clashes may happen
12:57dysfunwell that depends on how bad your randomness source is. if you're using glibc rand() equivalent, it's actually quite a small number
12:57dysfunand you'd be surprised how often that happens
12:58kwladykadysfun i will use of course solution like http://www.postgresql.org/docs/9.4/static/uuid-ossp.html or similar
12:59dysfunyeah there are two options for uuids in postgres. one of them only supports v4
12:59kwladykaso i guess it is good source
12:59kwladykajust not sure use v4 or v1mc
12:59dysfunbut i still think it's worth putting a unique constraint on if the data is supposed to be uniquely identified
12:59kwladykaalso found this article https://blog.starkandwayne.com/2015/05/23/uuid-primary-keys-in-postgresql/
13:00dysfunuse v4
13:34dysfunholy crap my tests finally pass in clojurescript
13:34dysfun(they previously only supported clojure)
13:34dysfunoh yeah i commented half of them out
13:36macroliciousI'm looking at the cider doc's at https://github.com/clojure-emacs/cider, and it mentions invoking C-c C-e with a 'prefix argument' to insert the result into the current buffer… what is the prefix argument (it's not specified)?
13:37dysfunC-u
13:37dysfunC-c C-c C-e
13:37dysfun(yes, it's the same mechanism you use to repeat actions)
13:38justin_smithmacrolicious: all emacs commands can take a numeric prefix, C-u is 1 (see also Meta+num-key)
13:38justin_smithand yeah, the number is usually interpreted as a count, but that's up to the function
13:39dysfunalso it needn't be a number
13:39justin_smithdysfun: there's no mechanism for a non-numeric prefix
13:39justin_smithdysfun: all prefix keys provide numbers
13:39dysfunthere isn't an interactive means of doing it
13:39dysfunbut it's possible in code :)
13:39justin_smithright, and when you are non-interactive it's not a prefix, it's an argument
13:40justin_smithso like I said, prefixes are numbers
13:40dysfunactually this is emacs, there almost certainly *is* a means of providing a non-numeric argument
13:40dysfunit's just we don't know what it is
13:41macroliciousoh man, this is awesome… thanks!
13:41dysfunbut it would be very handy to know
13:41justin_smithdysfun: no, this is base level emacs impl stuff, any "non-numeric prefix" would not be a true command prefix in this sense https://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html
13:41dysfunokay, fair enough
13:42justin_smithdysfun: lolemacs "numerous commands make a distinction between nil and the integer 1"
13:42justin_smithhahahaa
13:42dysfunnice
13:42dysfunemacs lisp has always seemed so utterly backwards to me
13:42justin_smithit's some crufty old time stuff
13:43dysfuni like the keybindings and having a programming language in my editor and everything, but i wish it were a decent programming language
13:43justin_smithit's like meeting someone that still worships one of the ancient Phoenician gods or something
13:43justin_smithdysfun: true that
13:43dysfuni saw someone tried to make an emacs in clojure, but it stalled because elisp support
13:43dysfunobviously if you have to throw away you entire life of emacs config, it's a problem
13:44justin_smithdysfun: see also emacs in ocaml, emacs in scheme, emacs in haskell, emacs in c, emacs in perl...
13:44justin_smithactually "emacs in scheme" is still ongoing and they still think it's gonna work
13:44dysfunoh, i thought those just stalled because there was no point
13:44MorgawrOkay.. maybe I'm missing something, I'm developing a library and a project that uses that library, I found a bug in the lib, I fixed it, I pushed it to clojar (upped the version), I recompile my project with the new version, I run it and the bug is still there
13:44justin_smithhaha I'm sure they think the same thing of "emacs in clojure"
13:44Morgawrsourcemaps (it's clojurescripts) shows that the cljs file for that library still has the old line in
13:44dysfuni wouldn't actually develop an emacs, i would develop something significantly less batshit
13:45Morgawrwhat am I doing wrong?
13:45Morgawrit's like my bugfix isn't being pushed to clojars
13:45dysfunwhat did the output of pushing to clojars say?
13:45justin_smithMorgawr: you can open a jar file, it's just a zip
13:45dysfundid it take the update?
13:45justin_smithMorgawr: download the one from clojars, check the code in the jar
13:45Morgawrdysfun: Yes it did
13:45Morgawrjustin_smith: I'll try
13:46dysfunah okay, it's not duplicate version then
13:46dysfununzip -l jar.jar
13:46dysfun(*very* useful as a boot user, because boot is batshit crazy insane)
13:46justin_smithor just navigate to it in editor, if your editor is smart enough
13:46justin_smitheg. emacs can open jars, vim, idea
13:46dysfuni hadn't honestly conidered that emacs would just open a zip, but i bet it does
13:47justin_smithdysfun: yup, zips or tars, like directories
13:47justin_smithand then you can get at the files, sometimes saving even works
13:47dysfunoh ace
13:47dysfunit just works
13:47dysfunthis isn't the emacs i know ;)
13:48justin_smithdysfun: another nice one - if you name a file foo.gpg, on first save emacs will prompt for whose public key to encrypt to, and when re-opening it will prompt for the password and decrypt
13:48justin_smithdysfun: amazingly some things in emacs are really nice and simple to use
13:48justin_smithhaha
13:48dysfunyeah, a stuck clock is right twice a day
13:49MorgawrOkay looks like the line for the bugfix is in the .jar pushed to clojar, now I need to check the .jar that is actually used by my project, where can I find it again?
13:49dysfuni wish being an emacs user weren't quite so stockholm syndrome-y
13:49justin_smithdysfun: I have not actually used any other general-purpose software that integrates with gpg / pgp as nicely as emacs does
13:49justin_smithMorgawr: ~/.m2/... I'd delete the version you have locally and force a re-download
13:50Morgawrjustin_smith: trying that, thanks
13:51justin_smithMorgawr: path under .m2 should be easy to find based on package / project
13:51MorgawrYeah, I found it :)
13:51Morgawrjust rm -rf'd its directory so it forces a redownload
13:51Morgawr(not the whole .m2)
13:52MorgawrNope, looks like that didn't fix it... wtf
13:52justin_smithMorgawr: lein clean /
13:52justin_smithyou might also need to restart figwheel if you are running it/ or use clean-build etc.
13:57Morgawrjustin_smith: Okay this is weird, I cleaned the whole project, checked the locally-downloaded (and the only version) library, the bugfix is there, but the project still has the bug and the sourcemaps point to an old line which still has the bug
13:58dysfun#object[Error Error: No protocol method IWithMeta.-with-meta defined for type cljs.core/IndexedSeq: (123)]
13:58dysfunlet's start with 'what is an indexedseq'?
13:58dysfunand why is it not one of the meta-supporting datastructures in clojurescript?
14:00dysfunsounds like you didn't manage to clean out the cljs
14:00dysfunand you haven't rebuilt it since
14:00justin_smithMorgawr: did your clean remove the source map? could be your clean targets are off
14:00dysfunor you're referring to the wrong version in your project.clj
14:00Morgawrdysfun: I doubt that's the case since there's only one version downloaded at all in the current offline repo
14:01Morgawrjustin_smith: that could be the problem, where do I find the source maps?
14:01justin_smithMorgawr: running clean should be removing the source map and all js files that are not external libs
14:01justin_smithMorgawr: your cljs config tells the compiler where to put those things, :output-to
14:01Morgawryeah then they should be cleaned
14:02dysfunthere is a leiningen setting to tell it what to clean
14:02justin_smithMorgawr: try verifying by running clean and seeing if any of those files exist afterward
14:02justin_smithyeah, your cljs config doesn't inform the clean task
14:02justin_smithyou have to manually configure it usually
14:02justin_smithunless you tell cljs to output to a place like target that gets cleaned
14:03dysfunit would be lovely if we had a silver bullet, but we don't
14:03dysfunso we just play with our build configs until they work
14:03dysfunor at least appear to
14:07MorgawrOkay... I fixed it it seems. Thanks for the help! looks like I was erroneously looking in the wrong folder when cleaning some targets
14:07Morgawrnow it works as intended :D
14:12BRODUSdoes clojure or java provide a built-in for unescaping a string?
14:12dysfunwhich type of escaping?
14:12BRODUSbackslash escaping
14:13justin_smith,(print-str "\"OK\"")
14:13clojurebot"\"OK\""
14:14Glenjaminwhat are you going to do with the escaped string?
14:15BRODUShmm, I tried that already, I'm trying to use it on the result of clojure.repl/source-fn
14:16Glenjaminit sounds like the string isn't escape
14:16justin_smithBRODUS: since clojure throws an error for "unknown escape sequences", I don't know what unescaping would be...
14:16Glenjamin*escaped
14:16Glenjaminyou're just displaying it in a place which escapes for you
14:16Glenjaminif you just want to see the source, try (source) instead of (source-fn) ?
14:17BRODUSyeah im using source-fn because I need the string
14:18Glenjaminthe string you get back isn't escaped
14:18Glenjaminwell, the repl escapes the string when displaying it
14:18justin_smith,(count "\\")
14:18clojurebot1
14:18Glenjaminunless i'm missing what you're asking still
14:19justin_smithexactly, the escaping is a detail of the repl / printing mechanism, not a property of the string itself
14:19justin_smithclojure doesn't have any such thing as an "escaped string" as an actual thing
14:19justin_smithexcept as used in printing, and that's a property of printing, not the string
14:20BRODUSGlenjamin: you're right. I was using the repl to examine it and the escaping threw me off.
15:14kwrooijenHey guys, I'm having a bit of trouble with the choices in the concurrency field (still very new to Clojure). Basically I want to spawn a lot of "worker" processes which can do a variety of tasks, and have unpredictable lifetimes.
15:14kwrooijenFrom what I understand, go blocks would be a bad choice since you can only have a limited amount? And I don't think spawning a new native thread for each job is a good idea either.
15:15kwrooijenWould futures be a good candidate for a large amount of tasks?
15:15Hansen-PansenFutures are also handled by an internal, kinda fixed thread pool.
15:16Hansen-PansenTo have more control over the number of threads in a pool, I can recommend https://github.com/TheClimateCorporation/claypoole
15:16kwrooijenI see, so the concurrency tools that Clojure provides by default might not be suitable for this problem?
15:17kwrooijenI'm a bit used to Erlang's concurrency model, since that's my primary language. But I've been wanting to try out Clojure for a long time
15:19Hansen-PansenI dabbled with Erlang a little bit. Clojure's core.async channels come close to Erlangs agents.
15:20justin_smithkwrooijen: you can use core.async to manage concurrent tasks, and use the thread macro in core.async for things that are meant to be long-running
15:20justin_smithkwrooijen: for thread pools and parallel stuff claypoole is handy (it has it's own configurable-pool-using version of pmap)
15:20kwrooijenHansen-Pansen: I assume you meant Erlang's actors? From what I understood about core.async chans is that you can't spawn too many go blocks
15:21justin_smithHansen-Pansen: future thread pool is not fixed
15:21justin_smithHansen-Pansen: it expands indefinitely (and I know this because I needed to stop using futures and use a fixed pool instead :P)
15:21Hansen-Pansenkwrooijen: Yes, of course you are right: ACTORS.
15:21justin_smithkwrooijen: go blocks don't map to threads
15:22kwrooijenDoesn't core.async's "thread" macro spawn a native (unix) thread?
15:22justin_smithkwrooijen: you can have more go blocks than threads, that's fine. What isn't good is long running computation heavy tasks inside go blocks - that steals threads from core.async, and that is where you should use the core.async/thread macro which is much like go but uses its own thread
15:22kwrooijenOr am I misunderstanding you?
15:23Hansen-Pansenjustin_smith: oh, thanks.
15:23justin_smithkwrooijen: yes, and that's what it is for
15:24justin_smithkwrooijen: so use go when the primary task in the block is passing messages and coordination, use thread when you expect a long blocking task (io) or heavy CPU usage that will last a long time
15:24justin_smith(if using core.async)
15:24kwrooijenjustin_smith: Does that also count for a large amount of threads though? I can't imagine spawning 50-100k native threads
15:25justin_smithkwrooijen: I've done it, it isn't a good idea :P
15:25kwrooijenHaha ok then that isn't what I need sadly
15:25justin_smithkwrooijen: if you also need to manage large numbers of heavy cpu usage or long blocking tasks, you want something like claypoole
15:26justin_smithcore.async can have many blocks and use fewer threads, but that is fundamentally incompatible with heavy cpu usage or long blocking io. it isn't magic and can't upgrade your hardware.
15:27kwrooijenYeah I thought that, seems that when I look at the default concurrency tools provided by Clojure, that Erlang would be a better candidate for *this* case
15:27justin_smithkwrooijen: maybe you could do something fancy with aws lambda
15:28justin_smithkwrooijen: clojure's going to get much more work done per CPU cycle. Or do you just mean erlang's better at running a program on multiple boxes at once?
15:29kwrooijenNo I meant more by managing a large amount of long running jobs, not in terms of number crunching
15:29Hansen-Pansenkwrooijen: If you are really trying to match Erlang's model in Clojure, maybe take a look at https://github.com/puniverse/pulsar
15:30justin_smithkwrooijen: large amount / long running are both fine in core.async. What isn't fine is blocking a thread.
15:30clojurebotc'est bon!
15:31Hansen-Pansenkwrooijen: As justin_smith said, blocking will be bad. But the same applies to Erlang's actors.
15:32kwrooijenIsn't the whole point of concurrency to not block any thread? And I'm still a bit confused about core.async
15:32kwrooijenSince before you said it's bad to spawn too many native threads and go blocks are not good for long running jobs
15:33kwrooijenSorry if my questions are bit still, I'm only familiar with Erlangs concurrency model which is pretty dead simple
15:34kwrooijenAnd thank you for bearing with me on this until now
15:34Hansen-PansenAt a Berlin conference, Joe Armstrong said that an actor shouldn't do work for more than 100 .. 200 ms worth.
15:35kwrooijenSome tasks can't be done within 100 ms though
15:35dysfunyes, and it's a rule of thumb
15:35dysfunthe sorts of systems he works on are relatively low latency
15:35dysfunnot like machine intelligence or something
15:36kwrooijenI completely agree on that, if it can be avoided
15:36kwrooijenBut if you you need to invoke a low latency task you might not have a choice
15:37kwrooijenAnd then still, you could have 1 line of execution creating 100 ms tasks, you're still with that one long lasting line
15:37dysfunlow latency isn't all that difficult to program for in the general case, fsvo 'low latency
15:38Hansen-Pansenkwrooijen: Then you have to ship that task off to a new thread. And if threads on that box are limited, ship it off to a different machine.
15:40kwrooijenYeah, if course machines have their limits
15:40kwrooijens/if/of
15:41kwrooijenBut thank you for helping me on this, I'll be taking a look at the libraries you've linked. And possible rethink my strategy :)
16:06amalloylein pro tips: you can add any number of `do` to your lein command line, to emphasize how important you consider the task: $ lein do do do do help
16:07dysfun:)
16:07dysfunlein do do do do do do do do do do do do there's no limit
16:09tcrayford_____amalloy: unix protip: if you pipe `cat` into itself enough times it yells at you
16:34justin_smithkwrooijen: one distinction maybe missing here is the difference between blocking and parking
16:35justin_smithkwrooijen: long-running tasks are fine, but blocking ones (even if much much shorter) are not
16:35justin_smithas long as the long running tasks park.
16:35justin_smiththere are certain actions like channel ops that park, and allow the block to be put aside until later based on channel activity
16:36justin_smithlong-running tasks are fine in a go block as long as they park regularly
16:49dysfunjustin_smith: what you mean they won't magically save us from infinite loops? ;)
16:50justin_smithdysfun: nor will they save us from deadlocks or resource starvation, sadly
16:50dysfundamnit i want a silver bullet
16:53kwrooijenAh I see, so waiting for channel input within a go block is considered "parking" ?
17:05kwrooijenI have to go now, but thank you for the help!
17:25cortexmanflatten an arbitrarily nested sequence of various types...
17:29dysfun'flatten'?
17:29dysfunas in that is the name of a core function
17:32cortexmanyou didn't answer the question...
17:37cortexmani've been trying that function and i'm pretty sure it doesn't do what it says it does
17:37amalloyyou didn't ask the question, cortexman
17:38amalloyyou just gave a sentence fragment followed by an ellipsis. nobody knows what you're asking, and dysfun is guessing
17:38TEttinger,(flatten [1 2 (java.util.ArrayList. 5 6 '(a b c))])
17:38clojurebot#error {\n :cause "No matching ctor found for class java.util.ArrayList"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: No matching ctor found for class java.util.ArrayList, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.IllegalArgumentException\n :message "No matchin...
17:39TEttinger,(flatten [1 2 (java.util.ArrayList. [5 6 '(a b c)])])
17:39clojurebot(1 2 [5 6 (a b c)])
17:39TEttingerthat is not what I guessed
17:39TEttinger,(flatten [1 2 [5 6 '(a b c)]])
17:39clojurebot(1 2 5 6 a ...)
17:42cortexmani think my problem is that hashmaps are collections, and flatten works on sequences
17:42cortexmanso if you have a vector of lists of hashmaps of blah blah blah... it doesn't work, because maps aren't sequences
17:42TEttingersource for flatten is https://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L6843
17:42amalloyyou don't ever really want to flatten something like that anyway
17:42amalloy~flatten
17:43clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
17:43cortexmani agree that you don't ever want to do that
17:43cortexmanbut i'm not you.
17:46kenrestivoit's a blunt instrument, for sure.
17:46cortexmanjson can return messes
17:46cortexmanunpredictable messes
17:52TEttinger,(do (defn seq-like? [x] (or (sequential? x) (map? x))) (defn map-flatten [x] (filter (complement seq-like?) (rest (tree-seq seq-like? seq x)))) (map-flatten [1 2 {:a 3} [10]]))
17:52clojurebot(1 2 :a 3 10)
17:52TEttinger^ cortexman
17:53cortexmanTEttinger: reading this now, thanks
17:53cortexmanwriting it is beyond me
17:53cortexmanfor now..:)
17:54TEttingergenerally once you know enough to write flatten you realize it's a bad idea
17:54TEttingerapply concat is more surgical
17:54cortexmanTEttinger: it totally works
17:55TEttingerwoohoo
17:55TEttingerI totally don't know why it works!
17:55TEttingertree-seq is weird and very common in the source of the standard lib
17:56cortexmanyou're just walking the tree, testing if it's a seq, and if not, seq'ing it
19:56tolstoynote to self: when dealing with something that has to run on windows, double your estimate.
19:57amalloyexcept your expected number of users. quintuple that
19:58tolstoyYep. Most of 'em still on XP. ;)
19:59tolstoyI can't figure out why this cljs/node thing seems to cause 99% action when dealing with opening and closing a socket.
20:00tolstoyEr, 90% CPU running in Electron. So, start from scratch, on windows. I can't even figure out how to edit something! ;)
20:03MalnormaluloIs there an idiomatic way to reduce a seq with a function, but produce a seq of each incremental result?
20:04Glenjamin(doc reductions)
20:04clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
20:04Glenjamin,(doc reductions)
20:04clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
20:04Glenjaminah
20:04MalnormaluloI knew there had to be a function for that. Thanks!
20:08georgeyjhi
20:09georgeyji followed this tutorial https://github.com/bhauman/lein-figwheel/wiki/Running-figwheel-in-a-Cursive-Clojure-REPL but i keep getting an error when i hit run: Exception in thread "main" java.io.FileNotFoundException: Could not locate figwheel_sidecar/repl_api__init.class or figwheel_sidecar/repl_api.clj on classpath.
20:15neoncontrailsgeorgeyj: that's typically a namespace issue related to the structure of your project. You might double check the (ns ... ) declarations of your files to make sure they're consistent with the tutorial's
20:15neoncontrailsalso, welcome to Clojure!
20:16georgeyji just did lein new figwheel
20:16georgeyjand then opened it up
20:16georgeyjbrand new project
20:16georgeyjthanks
20:23georgeyjso anyone know?
20:23georgeyjjust installed intellij and cursive and trying to get figwheel working with intellij
20:33georgeyjok it just started randomly working
20:33georgeyjbut now when i save files it doesnt auto reload
20:33georgeyji have to manually refresh still
20:43neoncontrailsgeorgeyj: ah, yeah there is a reasonably simple fix for that, let me see if I can find it
20:43georgeyjok neato
20:47neoncontrailsgeorgeyj: stop me if you've read through this already https://github.com/bhauman/lein-figwheel
20:47georgeyjyeah i've read that
20:48neoncontrailsAnd on-jsload is set to true?
20:49georgeyjthis? (defn on-js-reload [] ;; optionally touch your app-state to force rerendering depending on ;; your application ;; (swap! app-state update-in [:__figwheel_counter] inc) )
20:49georgeyji just left it as it was generated
20:51neoncontrailsGo ahead and uncomment that, that's the one you're looking for
20:53georgeyjstill not working
20:55neoncontrailsthere is a related flag you'll need to set in your project.clj if you haven't yet, which loads the function into the dev environment
20:55georgeyjok what is the flag?
20:57neoncontrailsI'd recommend the docs, just because there's a few different configuration options and it discusses the tradeoffs
21:00georgeyj??
21:00clojurebot? is !
21:00georgeyji've been reading the docs it's not working though
21:00georgeyji followed the tutorial exactly
21:02neoncontrailswere you able to load the silly birds? that demo should have live code reloading enabled straight out of the box
21:05georgeyjwell i want an empty project
21:05georgeyjughhh why are clojure docs so incomplete...
21:08justin_smithgeorgeyj: "an empty project" as in you don't have a project and just want clojure? "java -jar clojure.jar"
21:08neoncontrailsFigwheel's well-documented. It's just one of the many programs that's easier to learn by example
21:08georgeyjno i mean like
21:08georgeyji'm trying to get this working for a friend
21:09georgeyjand it's very frustrating because we're following the docs exactly and it just isn't working
21:10georgeyjinstalled jdk, lein, intellij, cursive, then did lein new figwheel firstproject then followed that https://github.com/bhauman/lein-figwheel/wiki/Running-figwheel-in-a-Cursive-Clojure-REPL exactly and it just doesnt work
21:10georgeyjbeen messing around with the project.clj, googling stuff, etc. nothing
21:10georgeyjhe tried it too and cant get it working
21:10neoncontrailsDefinitely sounds a lot more frustrating than "git clone https://github.com/bhauman/flappy-bird-demo.git&quot; and getting a working environment up in about 60 seconds
21:11georgeyj??
21:11clojurebot? is !
21:11georgeyjthats how you have to do it?
21:11georgeyjwhy dont the docs work?
21:12georgeyjwe've been on this for hours and i can tell he's about ready to give up
21:12justin_smithgeorgeyj: the tooling around cljs in particular is still kind of brittle
21:12georgeyjgetting started just takes way too long and it just doesnt work
21:13justin_smithgeorgeyj: if you follow the official clojurescript intro, it makes a lot more sense. But people want to tell you to skip that and jump into figwheel because figwheel has all the features.
21:13georgeyjwell i mean it wouldnt be that bad if anyone could help
21:13justin_smithgeorgeyj: we try to help
21:13georgeyjwell it's not like im asking how to do something extremely specific
21:14georgeyjthis is something that everyone has to go through to use figwheel and intellij
21:16georgeyjbleh
21:16justin_smithgeorgeyj: you're hitting multiple levels of stuff at once - lein, figwheel, clojurescript, cursive (I don't know how well you knew intellij before setting this up)... even if all are usable, the small issues when setting each up can have a multiplicative effect when you don't know which one is misconfigured
21:16georgeyjyeah im aware of that thats why i follow every step exactly
21:16georgeyjit still works if i manually refresh the page i just want to get autoreload working
21:17justin_smithgeorgeyj: not following steps is not the only source of misconfiguration though. Versions change, slight incompatibilities happen.
21:17justin_smithtutorials hold google juice past their time of relevance.
21:17georgeyjwhat is google juice
21:18justin_smiththe magic sauce that makes your page be high on the page
21:18justin_smithwhen googled
21:18georgeyjhttps://www.google.com/search?q=intellij+figwheel+tutorial&amp;ie=utf-8&amp;oe=utf-8
21:18georgeyji dont even see any other tutorials
21:20neoncontrailsWhy are you averse to demos?
21:20georgeyjbecause it doesnt matter if i can get that working
21:20neoncontrailsThere's nothing more illustrative of how something works than a working project
21:20georgeyjits not like im going to start every project in the future by cloning a flappy bird demo.. it's just ridiculous
21:20neoncontrailsRight, so admire it, compare with yours, and iterate
21:21georgeyjalso its not even the same
21:21neoncontrailsI'll admit it's not always that easy in practice, but the flappy-birds demo is designed as more of a skeleton showing sane Figwheel defaults
21:22neoncontrailsAnd it just *poof* works
21:22georgeyjthe intellij figwheel tutorial says to make a script file, remove lein-figwheel from :plugins, etc.
21:23georgeyjdoes no one else here use intellij and figwheel?
21:23georgeyji looked at the clojure survey results and it says intellij was the second most popular and figwheel the most popular
21:24georgeyjid imagine this is a common problem??
21:24neoncontrailsI use IntelliJ. It's the bee's knees
21:24georgeyjok have u tried figwheel?
21:25neoncontrailsIntermittently for the past few months. I'm no expert but I think it's a fine piece of software
21:26georgeyjok can you do me a favor and try to get the two working?
21:27marcfontaineis it possible to do structural searches on clojure code with cursive ?
21:28neoncontrailsI don't really know what else I can say that would be helpful to you. I learned by kicking the tires of the flappy-birds demo
21:29georgeyjsigh
21:29georgeyjthe response to a newbie coming in asking how to get started with figwheel and intellij shouldn't be: clone this old demo and do a diff to see whats wrong
21:30georgeyjmaybe ill just go back to js and wait a couple more years for docs to get better
21:32justin_smithfor the record my answer was "the tooling ecosystem is full of brittle things that change quickly, and do the basic clojurescript intro before doing any figwheel or nrepl / cursive integration." https://github.com/clojure/clojurescript/wiki/Quick-Start
21:33georgeyjif things change quickly it's of extreme importance that there's a guide for the most common path or else beginners will never be able to get started and the language will die..
21:34justin_smithgeorgeyj: the quickstart is the common path. All other things are optionals or nice to haves.
21:34justin_smith(in terms of cljs usage)
21:35georgeyjhuh?
21:35georgeyjhttp://blog.cognitect.com/blog/2016/1/28/state-of-clojure-2015-survey-results
21:35georgeyjit's 70% vs 20%
21:35justin_smithgeorgeyj: common as in "all users of cljs will use the tech described in the clojurescript quick start"
21:35justin_smithcommon as in 100% of cljs users need to understand those things
21:36justin_smitheverything else just builds on that
21:36georgeyjive read this before
21:36georgeyjthe quickstart
21:36georgeyji still have this figwheel problem though
21:42georgeyjoh well
21:42georgeyjback to javascript
21:43georgeyjill be back in a couple years i still think clojure is the best language probably but god damn these docs are awful lol
21:43jiegecmy use of cloiure is fluent...
21:44jiegeci love clojure
22:02rhg135Being able to code reload is a nice to have technically, but a very nice to have
22:02rhg135On web apps at least