#clojure logs

2014-12-29

00:55dweavehow does one listen for when a promise is fulfilled
00:55dweaveis that just not a thing
00:55justin_smith dweave (future @promise (do-something))
00:55dweave@ is the same as dereference right?
00:55justin_smith(do-something) won't be called until the promise is fulfilled (and this will all be done in a thread from the future thread pool)
00:55justin_smithit's the same as deref, yeah
00:56justin_smithif you want to block the current thread, just do @promise ... without the future part
00:56justin_smith(doc realized?)
00:56clojurebot"([x]); Returns true if a value has been produced for a promise, delay, future or lazy sequence."
00:56justin_smithrealized can also be handy
00:56justin_smith*realized? of course
00:58dweavewon’t the promise be dereferenced before do-something
00:59dweavehas completed
00:59justin_smithit will block until the promise is fulfilled
00:59justin_smithso do-something can't happen until something delivers to the promise
00:59dweaveoh i see
00:59dweaveand do something will deliver to the promise
00:59justin_smithno
00:59justin_smithsomething else would have to
01:00justin_smithin another thread, since that one is blocked
01:00dweaveha oops
01:00dweaveright i see
01:00justin_smithbecause do-something would never be called if the promise is not delivered to
01:01dweaveso deref is always blocking?
01:01justin_smithyes, that's where realized? comes in
01:01dweaveor only in this context for some reason
01:01justin_smithif you just want to check
01:01dweaveok i see
01:01justin_smithfor delays and promises, it doesn't return until there is a value to deliver
01:01justin_smiththough for atoms / refs / agents it won't block
01:01justin_smithit just gives you the value as of the moment you deref
01:02justin_smithit also blocks for the completion of futures
01:02dweavei’m more familiar with promises in various JS libs. and promises in clojure really seem more like “defereds”
01:02justin_smithit's a promise because any part of your code can deliver the value
01:03dweaveright
01:03justin_smithand the value can only be delivered once (unlike an atom, agent, or ref that can be updated as often as you like)
01:03justin_smithhow are promises typically used in js that is different?
01:05dweavepromises in most implementations in JS really only exist for supplying a callback
01:05dweavethey have a “then” method which takes a callback which accepts the future value and then returns a promise
01:05justin_smithyeah, the (future @promise (do-something)) followed by passing the promise to something else that delivers to it could work that way
01:05dweaveand as such are composable
01:06justin_smithor better yet (future (do-something @promise)) followed by (go-realize promise)
01:06justin_smithwhere go-realize decides what value to put in that promise of course
01:06dweavenice
01:07justin_smithdweave: but core.async allows similar logic, in much more powerful combinations
01:07dweaveyeah just exploring
01:07dweavethanks again
01:07justin_smithincluding situations where you have multiple elements of your logic that need to coordinate between one another at multiple steps
01:08justin_smithpromises in clojure are much more flexible / general
01:55alexbara`for some reason CLJS that works fine use Chestnut, fails to compile into working JS when compiled using lein cljsbuild once Any suggestions on thing to look at?
01:56dnolen_alexbara`: I'm assuming you're using :advanced?
01:57alexbara`dnolen_: yes. I will try using :none too
01:57alexbara`(:optimizations :none) I mean
01:58dnolen_alexbara`: with :advanced you generally need to supply externs if you're calling into non-Closure or non-ClojureScript libraries
01:58dnolen_alexbara`: generally :none is for dev, :advanced is only for production builds
01:59alexbara`dnolen_: I don't think we are calling into non-cljs libraries but let me investigate that idea
02:00dnolen_alexbara`: that's usually the reason :advanced builds do not work - there have been some more extreme edge case but I doubt you're encountering them
02:01dnolen_alexbara`: even accessing properties on JS objects requires externs under :advanced if they aren't standard browser features
02:04alexbara`dnolen_: aha, I bet it is the property access that might be doing it
02:12dagda1_I can't find much documentation or examples of the core.async sequence functions. Can anyone point me to some concrete examples for e.g. map or take or where is the transformer function mentioned in the docs
02:14dagda1_ok, transformer is now transducer but I'm struggling to find any examples of this
02:14kenrestivothere's not a lot out there
02:14kenrestivoit's very new
02:15kenrestivoin fact, the only use i can find in any indexed open source projects is... in transducers itself :-/ http://crossclj.info/fun/clojure.core/transduce.html
02:18kenrestivothe name "eduction" always makes me laugh. in 1980 when "the wall" first came out, i saw grafitti that said "we don't need no eduction". i scratched underneath it "yes, you do".
02:19luxbockthere's some informaton here: http://gigasquidsoftware.com/blog/2014/09/06/green-eggs-and-transducers/
02:21luxbockdagda1_: http://go.cognitect.com/core_async_webinar_recording
02:21luxbockthis might be of help as well
02:23dagda1_luxbock: thanks, I'm going to blog about this when I understand it. There is very little out there
02:24luxbockdagda1_: yeah, transducers are a 1.7 feature, which is still in alpha
02:30zom_attempting to solve this
02:30zom_https://www.4clojure.com/problem/26#prob-title
02:30zom_i've seen a solution that uses a lazy-seq
02:30zom_(fn [x] (take x ((fn fib [a b] (cons a (lazy-seq (fib b (+ a b))))) 1 1)))
02:30zom_can someone with more experience walk me through it
02:31zom_I get the rough idea
02:31zom_we specify the number of fib numbers to generate (X)
02:31zom_we then take that many from an infinite list
02:32zom_but I dont'get the lazy-seq
02:33dnolen_dagda1_: in core.async channels take the transducer
02:33zom_does the lazy-seq target the take???
02:33lazybotzom_: Yes, 100% for sure.
02:35zom_so to build the list, are we just consing the a param every time?
02:36zom_and only calling the recursion the number of times x is specified
02:36zom_?
02:37nuwanda_the sequence is lazy, which means it's only called when the value is needed, in this case it's "needed" by calling take X
02:37nuwanda_not sure if that's very clear
02:38luxbockzom_: does this help: https://gist.github.com/luxbock/c8ab4eaf7aabf3440cb1 ?
02:44zom_luxbock: I got it, thanks
03:28namrahm can someone enlighten me in case of clj-tools-logging? i didn't what to throw a logger configuration in every namespace, so i thought i can split logging fns into a separate namespace and configure the logger there and when other fns in other namespaces need to log something the call log-fns from the logger-ns and provide their namespace with the call.
03:28namrabut that doesnt seem to work
03:29namranothing gets logged in this case, and no errors whatsover
03:36dagda1_does anyone have an example of alt! as opposed to alts!
06:27Empperioh ffs, lein uberjar seems to do implicit rm -r ./target
06:27Empperimeaning one cannot generate resources to target directory and then package them into uberjar
06:29Empperiseems to be the latest change to uberjar task...
06:29Empperihttps://github.com/technomancy/leiningen/commit/d053f3add4ef80c572d0ed3f1a1493a8758d6cdd
06:35Empperinow I need to add a separate "target-resources" directory, add it into .gitignore and whatnot to make this work
06:37Empperiand lein clean will not be going to clean that directory now
06:37Empperigeesh
06:37Empperimakes me really want to change into boot from leiningen
06:40Emppericursive doesn't support it though
06:41devllIs there a blog or book on "Algorithms in Clojure"?
06:41SagiCZ1there is clojure cookbook...
06:41cflemingEmpperi: I'm hoping to add boot support very soon, since I'd like to use it myself
06:41devllYes. I've read the Cookbook. It's more of a API usage guide styled book.
06:42Emppericfleming: you are the cursive developer?
06:42SagiCZ1is boot not based on maven?
06:42devllI mean algorithms.
06:42Empperiand that is *really* good news!
06:42cflemingEmpperi: I am
06:42Empperigreat work with cursive btw
06:42Empperilove it
06:42cflemingEmpperi: Thanks, I'm glad you're enjoying it!
06:42Empperican I make an additional feature request in addition to boot support?
06:42cflemingEmpperi: Of course, shoot
06:43Emppericurrently cursive doesn't understand evaluated requires in autocompletes, eg. when you dynamically load libraries via (require 'whatnot)
06:43Empperione could implement that by checking if the currently active repl connection knows those vars
06:44cflemingEmpperi: It should understand those
06:44Empperihmmh, it doesn't in our project at least :(
06:44SagiCZ1Empperi: it usually works for me
06:44SagiCZ1sometimes it doesnt load the documentation though
06:44Empperiwe are lazy loading some libraries in order to do stuff before this java library manages to stuff at class load time
06:44Empperido stuff
06:45Empperiand this works fine but cursive's autocomplete breaks
06:45cflemingEmpperi: Can you give me an example of a require that isn't working for you? Are you doing something like using require with a variable rather than a constant?
06:45Empperioh and we are doing it via doseq
06:45cflemingAh
06:45cflemingIn that case all bets are off :-)
06:45Empperihttps://www.refheap.com/1c87512d6f57fea1b077c3ffc
06:45Empperilike that
06:46Empperito make it nicer to add new dependencies
06:47cflemingI see - that won't work unfortunately. If you break it out into explicit requires, it will work. In fact, in your case you can just use a single require.
06:47Empperitrue
06:47cflemingWhich should be just as easy to add new deps to - the doseq there isn't really gaining you anything that I can see.
06:49Empperineed to quote each required dependency separately with plain require :)
06:49cflemingEmpperi: https://www.refheap.com/95513
06:49Empperibut I can live with that
06:49cflemingYeah, that's a small price to pay for resolve support IMO
06:49Empperiindeed
06:49Empperididn't know cursive can parse require form that way
06:49Empperibut makes sense
06:50Empperinot too hard to implement when you've already implemented the ns macro require support
06:50cflemingYeah, anything where the require is explicit should work fine
06:50cflemingRight - in fact the ns support is implemented in terms of the require support, which is how ns works behind the scenes.
06:51cflemingSo all the other forms like refer, import and so on work too.
06:51Empperinice
06:51Empperido you have some kind of guess when the boot support would be released?
06:52cflemingEmpperi: Umm... not really, I'm sorry. It's probably a month or two away.
06:52cflemingEmpperi: But it's definitely on the short-term roadmap.
06:53Empperino problem man, just anxious little kid here who wants a new toy :)
06:54Empperion a more serious note, I'd like to evaluate boot more throughly if we could move to it from leiningen in our project
06:54Emppericurrently our developers use idea+cursive though so not really worth it until cursive supports boot
06:55Empperisince it is kinda pain when cursive doesn't understand dependencies etc even though one can connect to boot repl
06:56cflemingEmpperi: Some Cursive users are already using boot, it actually doesn't need too much support. You can use the External Tools support to run boot tasks, and I think you could use a remote config to connect to the boot REPL
06:56Emppericfleming: how about the dependencies?
06:56Empperiadd manually each to your project?
06:57cflemingEmpperi: https://gist.github.com/bsima/88969126962803a6500f
06:57cflemingEmpperi: So you maintain a project.clj for the dependencies, and then read them in from boot
06:57Empperihmm, interesting idea
06:57Empperihack but not too horrible one
06:58cflemingNot pretty, but it's doable if you're really keen to use boot right away
06:58Empperimight give that one a try
06:58Empperihave this hobby project where I'm using boot
06:59cflemingEmpperi: See also https://github.com/cursiveclojure/cursive/issues/665 for a way to fake the source folder support using a similar idea
07:01Empperinice
07:01Empperigonna definetly try these out when I get home and have some time for my hobby project
07:01Empperi...which might take some time since kids and everything
07:01cflemingOk, if you get it working let us know on the mailing list, a few people have been asking about it
07:02cflemingYeah, kids make hobby projects tough.
07:02cflemingNot to mention work :)
07:02Empperiindeed :/
07:02Empperiit would be so much more fun if one could just do the happy things!
07:02Empperi(not that kids aren't a 'happy thing')
07:03Empperibut I'll try to find some time this evening
07:03cflemingEmpperi: Ok, no rush - like I say, it'll be a while before I get to it
07:04Empperiyeah, but really happy to hear you are working on it :)
07:04Empperileiningen is great but it suffers from same problems as maven in many ways
07:04cflemingI'm planning to migrate the Cursive build to boot at some point, or at least try to, so support will definitely get much better at that point
07:24luxbockwould you use (partial apply =) to check if every item in a collection is the same, or something else?
07:26hellofunk,(doc every?)
07:26clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
07:27hellofunkluxbock: ^
07:28luxbockhellofunk: so you'd do (every? (partial = (first coll)) coll) ?
07:29hellofunkluxbock: that could work
07:30hellofunkluxbock: you could also reduce, though in this case every? is more focused on the problem
07:30luxbockmy original way is less keystrokes at least, but I'm not sure which is clearer in its intention
07:32hellofunkluxbock: the most specialized case is the most clear, thus every? wins out over a reduce in your particular example. just like all whens can be ifs, but whens are clearer for single conds. same idea.
07:33hellofunkluxbock: but ultimately it is a matter of taste and style. the core clojure functions exist for a reason, so if they do the job, consider them over a more generalized approach (like reduce in this case)
07:33luxbock##(let [[x & xs] [1 1 1]] (every? #{x} xs))
07:33lazybot⇒ true
07:37hellofunkluxbock, just be careful about values that are legitemately nil or false:
07:37hellofunk,(let [[x & xs] [nil nil nil nil]] (every? #{x} xs))
07:37clojurebotfalse
07:38hellofunkvs, ,(let [[x & xs] [nil nil nil nil]] (every? #(= x %) xs))
07:38hellofunk(let [[x & xs] [nil nil nil nil]] (every? #(= x %) xs))
07:38hellofunk,(let [[x & xs] [nil nil nil nil]] (every? #(= x %) xs))
07:38clojurebottrue
07:39luxbockyeah good point
07:50krat0sprakharhi all... quick question
07:50krat0sprakharhow can I apply and to a list
07:50krat0sprakhar(apply and '(true false true false))
07:50krat0sprakhargives me an exception
07:50krat0sprakharany idea?
07:51Bronsakrat0sprakhar: and is a macro, you can't use it as a value
07:51krat0sprakharoh!
07:51krat0sprakharso its not a function like str?
07:51Bronsakrat0sprakhar: right
07:51Bronsakrat0sprakhar: to do what you want, look at `every?`
07:52krat0sprakharthanks!
07:52krat0sprakharthats very helpful :)
07:53luxbock,(clojure.walk/macroexpand-all '(and true false true false))
07:53clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.walk>
07:54krat0sprakhar(and true true true)
07:54krat0sprakhar,(and true true true)
07:54clojurebottrue
07:54krat0sprakharoh nice! clojurebot :D
07:54luxbock,(macroexpand '(and true false true false)
07:54clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
07:55krat0sprakhar4clojure is quite tough ..
07:55krat0sprakhardid anyone else also struggle?
07:56hellofunkkrat0sprakhar: yeah some are tricky. the difficulty rankings (easy, medium, etc) are not very accurate either. some of the "easy" ones are hard, and some of the "hard" ones are easy, IMHO
07:57krat0sprakharhaha..yeah.. i've solved around ~60.. and my pace has greatly reduced..
08:06IntegralistHi all, I'm new to Clojure and am trying to figure out how to call certain Thread methods available in Java.
08:07IntegralistI'm able to call (Thread/sleep 1000) but not others like (Thread/isInterrupted)
08:07IntegralistDoes anyone know what that would be? The Java exception suggests the method isn't available, but I'm not doing anything specific for (Thread/sleep 1000) to work
08:07BronsaIntegralist: isInterrupted is not a static method
08:08IntegralistBronsa: ok, so I'd have to create instance of Thread (or access an instance to utilise that method)
08:08Bronsayou have to call it in a Thread instance, like (.isInterrupted some-thread-object)
08:09IntegralistBronsa: for a bit of context, I'm messing around with STM/concurrency https://gist.github.com/Integralist/4d7f4a5f62b4b567e419
08:10BronsaIntegralist: you probably want (.isInterrupted (Thread/currentThread)) or something like that
08:10IntegralistBronsa: aha, gotcha. Cool I'll try that now. Thank you!
08:15luxbockwhy doesn't map-indexed have the transducer arity, or is it not yet implemented?
08:17luxbockah I see: http://dev.clojure.org/jira/browse/CLJ-1601
08:33IntegralistHello again, here is some code that tries to peek at the state of different threads: https://gist.github.com/Integralist/741c2577e97fd8e466a4#file-test-clj-L11-L13 but the problem I'm having is that the function suggests the current thread is the main thread, where I would have expected it to refer to the thread created by the (future ...)
08:34Integralisti.e. output for (Thread/currentThread) looks like: Thread[clojure-agent-send-off-pool-15,5,main]
08:48luxbockin a lot of the microbenchmarks I've seen that compare the core functions against their transducer versions, there are improvements from 2-3x for the transducer version
08:49luxbockis this because the compiler has an easier time optimizing the generated bytecode when the calls happen inside the transduce-operation?
08:49luxbockjust wondering how come the improvements are so consistent accross the board
09:36luxbockheh: http://imgur.com/MleZdbO
10:31bacon1989Could someone tell me what's wrong with this macro? https://www.refheap.com/aca0636be093f888e74e0beab
10:31bacon1989it's complaining about keywords
10:32bacon1989I suspect the (run ...) function, but i'm pretty new to macros, so i'm not too sure
10:33Bronsabacon1989: how are you using it?
10:34bacon1989(new-system-with-name :fixed-width-map (generate-fixed-width-map))
10:36bacon1989it fails when it tries to compile the macro, or something
10:36bacon1989i'm using clojurescript, I don't know if that makes a difference
10:36bacon1989it's basically complaining before I even use itj
10:37bacon1989the error i'm getting is "nth not supported on this type: keyword"
10:38bacon1989everything compiles fine if I don't use :require-macro
10:45dnolen_if you have a ClojureScript library not listed here feel free to add it https://github.com/clojure/clojurescript/wiki#useful-libraries
10:46rboydnice list
10:48rboyddnolen_: any talks about om/pedestal-app merge since your joining cognitect?
10:52dnolen_rboyd: no, and unlikely - pedestal has a new more focused direction - the front end is left for other tools
10:55rboyddnolen_: right on. I finally had a chance to kick the tires on om a couple weeks ago. really cool stuff. one more question I had for you, what is "mies"?
10:55rboydacronym?
10:55dnolen_rboyd: just a minimal CLJS template - like "mies van der rohe"
10:56dnolen_"less is more"
10:56rboydaha. =]
10:57dnolen_also landed some really big changes to how ClojureScript REPLs work to allow them to start faster
10:59dnolen_breakage expected for projects that depend on cljs.repl namespace, planning on writing up notes on the changes - hoping to minimize the effect and also start talking about what assumptions should stabilize
10:59dnolen_still, it's pretty sweet to have Browser, Node.js, and Rhino REPL out of the box and they can all start in a reasonable amount of time now
10:59rboydI think I saw something fly across hn frontpage mentioning your speedups
11:00bacon1989fixed my problem, I wasn't requiring it correctly
11:00bacon1989still have issues with the namespace not being picked up on, but whateves
11:01dnolen_the goal is to support just pointing a REPL at an :output-dir and it will load the analysis caches off disk - no actual analysis or compiling
11:05dysfun(print-system @systems) # ArityException Wrong number of args (2) passed to: repl/print-system/fn--12388 <-- WTF?
11:06jonathanjhow do i rename a key in a map?
11:07jonathanji see there's clojure.set/rename-keys but i'm not sure if that's what i should be using
11:07bacon1989,(def x {:a 1 :b 2})
11:07clojurebot#'sandbox/x
11:10bacon1989,(let [old-val (:a x)] (->> x (dissoc :a) (assoc :c old-val)))
11:10clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.IPersistentMap>
11:10dysfunisn't there a shorthand for that in useful already?
11:10bacon1989woops, wrong threaeding
11:11dysfunseems like the sort of thing it would cover
11:21hellofunk,(let [x {:a 1}] (assoc (dissoc x :a) :b (:a x)))
11:21clojurebot{:b 1}
11:22hellofunkbacon1989: note there is no need to "cache" the old-val since these are immutable data structures
11:54justin_smithluxbock: the non-transducer versions do a lot of work that transducers don't need to do
11:55justin_smithie. (map f (filter p? l)) creates two lazy seqs, when you only need 1
11:56justin_smithand the more chaining you have, the bigger an improvement you get when you can drop that redundancy
11:59justin_smithluxbock: JIT changes bytecode execution, but does not mess with data structures, and data structures make huge performance differences
12:00luxbockjustin_smith: alright thanks
12:01justin_smiththat makes me wonder if JIT couldn't do amazing things if it knew our data structures were immutible
12:02TEttingerPixie probably is doing that
12:02luxbockmaybe some day
12:02justin_smithTEttinger: I hope so, it would be interesting to see
12:02justin_smithof course the haskell compiler is all over that kind of stuff
12:03luxbockdoes anyone ever directly write in JVM bytecode to tweak some inner loop the same way that people mess with assemply to optimize C code?
12:03luxbockassembly*
12:04justin_smithluxbock: well, clojure generates bytecode
12:04justin_smithbut beyond a certain point, JIT is going to do a better job of reorganizing things than you will, since it has actual runtime profiling data on the host machine
12:04sovaho man, playing directly with bytecode... not an impossible task but the beauty of abstraction (i.e. programming languages) is that you don't have to
12:05luxbockI was just wondering if it would be possible in theory to have a Clojure library where you can create callable functions by writing the bytecode as a DSL, like does that even make sense?
12:06luxbockI'm not saying it would be practical or something I'm interested in but I'm just curious
12:06patrickgombertluxbock: tail recursion (loop .. recur) is unrolled into a loop IIRC
12:06tcrayford____luxbock: I've *read* a load of jvm bytecode whilst optimizing clojure. Never really wanted to write it directly though
12:06sovayes you can definitely do it, if it can be done in java it can be done in clojure, and there is a library for java that plays with bytecode (and kinda lets you reverse-engineer programs)
12:07tcrayford____the JIT does so much to bytecode it's not really worth optimizing at the bytecode level IMO
12:07justin_smithsova: in fact clojure uses the ASM.java lib to generate its own bytecode when compiling
12:07dnolen_if you company is using ClojureScript in production add it here https://github.com/clojure/clojurescript/wiki/Companies-Using-ClojureScript
12:07dnolen_s/you/your
12:08sovajustin_smith: wow i did not know that. although that makes a lot of sense!
12:08tcrayford____and the compiler is available at runtime
12:08tcrayford____see how datomic, riemann etc compile queries into functions so the JIT can get ahold of them
12:08justin_smithsova: yeah, clojure does not generate any java, it compiles directly to byte code for each line of code you send to the repl
12:09tcrayford____(both of those just call eval around a (fn expression)
12:11luxbockso clojure.asm contains everything one would need to write JVM bytecode by hand?
12:11justin_smithluxbock: it's just an embedded copy of the asm lib
12:11justin_smithwhich is well documented
12:11justin_smithand yes
12:12justin_smithhttp://asm.ow2.org/
12:12luxbockI remember seeing it in use in the clj-native source files
12:12TimMcdnolen_: Is this going to lead to more consulting cold-emails? :-P
12:12luxbockthat looked like some pretty dark magic to me
12:13luxbockhttps://github.com/bagucode/clj-native/blob/master/src/clj_native/structs.clj#L20
12:17sovacould some kind sir or madam provide a link to understanding macros with examples?
12:19dnolen_TimMc: ha, I doubt it - this is not a Cognitect thing - ClojureScript GitHub is sorely lacking information about the maturity of the project
12:21nooniansova: maybe http://www.braveclojure.com/writing-macros/
12:21sovanoonian: gratitude
12:22TimMcdnolen_: *nod* You send code out into the void and it doesn't write home.
12:22TimMcExcept when it breaks, I guess. :-P
12:22dnolen_lol, yep
12:24m1dnight_Is there a decent way to get [:key :key2] and [val1 val2] into {:key val1 :key2 val2}? atm I'm planning on mapping vector on the two lists, and then reducing them with a function that assocs them
12:24hyPiRionm1dnight_: zipmap?
12:24noonian,(zipmap [:key :key2] ['val1 'val2])
12:24clojurebot{:key2 val2, :key val1}
12:24m1dnight_well i'll be damned
12:25m1dnight_thanks, exactly what i was looking for
12:25m1dnight_thanks, exactly what i was looking for
12:25m1dnight_oops, sorry
12:31TimMc$findfn [:key :key2] '[val1 val2] '{:key val1 :key2 val2}
12:31lazybotExecution timed out.
12:31m1dnight_is that implemented in a brute-force way?
12:31TimMcWarm up those caches, buddy.
12:31m1dnight_One would guess?
12:32lazybot[]
12:32TimMc$findfn [:key :key2] '[val1 val2] '{:key val1 :key2 val2}
12:32TimMcyeah
12:32justin_smithm1dnight_: yeah, totally brute force
12:32sovahahah. "lazybot" says it all
12:32sovavery cool method, gotta say
12:32TimMcWrong kind of lazy. :-P
12:32lazybotExecution timed out.
12:32TimMc...
12:32lazybot[]
12:33TimMclazybot, what was [] the answer to?
12:33lazybotIt's AWWWW RIGHT!
12:33TimMc$findfn 1 2 3
12:33TimMc*sigh*
12:33hyPiRionTimMc: (AWWWW RIGHT!) -> []
12:33sovaHahahah lazybot wins
12:33lazybotExecution timed out.
12:34TimMcRaynes: Your bot is on drugs again.
12:34lazybot[clojure.core/+' clojure.core/bit-xor clojure.core/unchecked-add-int clojure.core/unchecked-add clojure.core/bit-or clojure.core/+]
12:34justin_smithwow, that's a lot of ways to get 3 from 1 and 2
12:35TimMcI don't even know if findfn filters based on arities.
13:03justin_smithhttps://github.com/Raynes/findfn/blob/master/src/findfn/core.clj it's a small namespace, looks like no
13:08TimMc$findfn [a 1] a 1
13:08lazybotjava.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)
13:10TimMc$findfn "a" a
13:10lazybotjava.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)
13:12justin_smith$findfn "a" 'a
13:13lazybotExecution timed out.
13:13justin_smithman lazybot, that's an easy one
13:13lazybot[clojure.core/symbol clojure.core/read-string]
13:13justin_smithhow weird...
13:13justin_smithit's timing out, and then replying....
13:14TimMcwith a delay
13:16hyPiRiondual personality
13:32m1dnight_is anyone here who worked on the clojurebot?
13:32m1dnight_I'm building one myself for fun but i'm stuck a bit on the irc protocol
13:32justin_smithI updated lazybot to use the latest irclj
13:32justin_smithbut I didn't implement the irc protocol stuff directly
13:34m1dnight_hrm, I'm wondering if a direct message can be differentiated by looking at the channel
13:35m1dnight_PRIVMSG #channel :hello would be a channel because of the #
13:35justin_smithm1dnight_: that's exactly it, the difference between a channel message and a direct one is the channel it is on
13:35justin_smithotherwise they are the same thing
13:37TimMcbecause some chat clients correctly treat NOTICE as lower priority than PRIVMSG, but others treat it as a high priority notification.
13:42m1dnight_haha, that's kinda cool :D
13:43m1dnight_I'm thinking about how to do it architectually atm
13:43m1dnight_the main point of practice :p
13:55dangitThis is where I’m at: http://pastebin.com/BBktFWTP
13:56dangitAlternatively, I’m just trying to get the pid so I can kill with something stronger than .destroy, so if anyone has a rec on that…
14:03TimMcdangit: You need (.getInt pid p) or something.
14:16gfrederickshi
14:16tcrayford____hi geary
14:17dangitTimMc: Can you elaborate? What would p be?
14:17drbobbeatygfredericks: Howdy, Gary!
14:17gfrederickshello Tom and Bob
14:18gfredericks~tcrayford is ðomas
14:18clojurebotAlles klar
14:19tcrayford____fanks gary
14:22llasramgfredericks: Gæry?
14:24gfredericksllasram: if you want to
14:25hyPiRiongœry
14:25justin_smithdangit: TimMc: sadly, the jvm doesn't provide that info
14:25justin_smithamazingly enough
14:26gfredericks~hyPiRion is a hyper ion
14:26clojurebotIn Ordnung
14:28ankanowatwhat's the idiomatic way to convert a PersistentArrapMap to java.util.Map for interop with Java libs?
14:28gfredericksit already is one
14:29ankanowatit does implement the Map interface
14:29ankanowatwhy am i getting an error ... need to look deeper before more questions
14:29noonianwhat error are you seeing?
14:29mi6x3mClojure I need a bit of a counseling. I am porting a GUI component which supports custom decorators. Currently a decorator is returned by the a method of the component class which can be overriden
14:29andyfperhaps the Java lib is trying to use a method in the interface that mutates the set contents, and those throw exceptions?
14:30mi6x3malso, one can set a decorator used for all sub-instances the component creates (it can copy itself)
14:30mi6x3mI want to emulate this with a dynamic var
14:30mi6x3m*decorator*
14:30mi6x3mbut setting a binding wouldn't be enough, the value will have to be changed via set! sometimes
14:30mi6x3mand I don't know if it's a good idea
14:31mi6x3mtl;dr Is a dynamic var *decorator* a good idea
14:31noonianit would probably be easier to just pass in a function to use in sub-instances or something along those lines
14:32mi6x3mnoonian: well this is the thing, you have no control over them once the parent component is created
14:32mi6x3mthe class has a static method setDecoratorForSubInstances
14:32mi6x3mand this is all you got
14:33noonianso you're wrapping an existing java component? or trying to re-implement its functionality in clojure?
14:34llasrammi6x3m: Is the thing you pass in for that method an instance or a class or what?
14:36mi6x3mnoonian: I am wrapping an existing java code
14:37mi6x3myes, it's an instance of an interface
14:37mi6x3mand you pass that to a method
14:37mi6x3mbasically you have 1. a method in the class XComponent you can overwrite, 2. a static method on XComponent to pass the decorator for subinstances
14:38mi6x3mI think i can use an additional parameter :decorator when constructing the object for the case 1.
14:38mi6x3mand just provide another api function for the case 2.
14:38mi6x3mset-default-decorator!
14:41winkdid this end up here already? :) If you're using YYYY in your JVM service or %G in anything, fix it now https://news.ycombinator.com/item?id=8810157
14:42gfrederickssounds like a case for test.check :)
14:52jasminhi all. need some assistance deploying to clojars
14:52jasminwhatever I try I keep getting ReasonPhrase: Forbidden
14:52jasminis this the best place to get some assistance with clojars deployment?
14:53jasminusing lein deploy clojure with a very simple project I just can't get past ReasonPhrase: Forbidden
14:55nooniani half remember technomancy saying he disabled ssh uploads or something due to a security vulnerability
14:56bacon1989probably the RSA stuff, also you need to sign your stuff if it's not a snapshot
14:56bacon1989or something
14:56jasminyes i am trying with https
14:57jasmini've signed it but still nothing. do I have to send my keys with gpg for it to work?
14:57jasminwhat keyserver to use?
15:09llasramjasmin: Are you certain you have your clojars credentials correct? Are you able to log in to the website in a browser with them?
15:10jasminyes i am
15:10jasmini am going insane trying to work this out. surely it can't be this hard to deploy to clojars
15:10llasramWhelp, then I'm out of ideas. It's generally not hard
15:10jasminonce I create my gpg key and send them to a keyserver does it take long for clojars to start authenticating my request to deploy? clojars probably isn't even using a keyserver right? that is why we are asked to paste the public PGP key into the Clojar profile right?
15:11justin_smithjasmin: gpg is just for creating signatures for verification
15:11justin_smithjasmin: are you deploying a version that is already up there? it will refuse to let you do that
15:12jasmini've had a look and can't find it. i've also tried to deploy under org.clojars.jasminsehic and that has the same problem
15:13jasminis there something in lein i can use to get more verbose details of failure?
15:13justin_smith#leiningen may be helpful
15:14jasminvery quiet there
15:15jasmincan someone confirm I should be able to deploy to classic clojars under any unused group id/artifact without having to sign anything?
15:15TimMcjasmin: Did you say you were using "lein deply clojure"? Shouldn't that be "lein deploy clojars"?
15:15jasminor is that only applicable to snapshots?
15:16TimMcSigning should be irrelevant.
15:16justin_smithnot under "any unused group id" - you need perms to the group you are deploying to
15:16jasminsorry yes lein deploy clojars..i typed out the wrong text in chat here
15:16TimMcok
15:17jasmineven if its a brand new group?
15:17justin_smithnot sure of that actually
15:18TimMcI think deploying to a new group creates it.
15:18jasmini don't think that is the problem as I can't even deploy to the pre-allocated org.clojars group
15:18TimMc(and that anyone can just create a group like that)
15:18gfredericksTimMc: that's always happened for me, especially by accident
15:19TimMc*nod*
15:19jasminis there a tool to verify the syntax of the clj files?
15:19gfredericksread will tell you if it's readable
15:19TEttingerparenthesis/bracket matching is most of it.
15:20gfredericksand eastwood will attempt to do most of everything else
15:20jasminI've found one article that says Clojars gives ReasonPhrase: Forbidden when the project.clj has unknown parameters
15:20jasminbut for the life of me it all looks good
15:20justin_smith"lein do check, eastwood" catches most of the basic stuff
15:21justin_smithjasmin: project.clj is super freeform, I don't see why lein would care about unknown parameters
15:21justin_smithnow if it isn't even readable, that's another thing entirely
15:21justin_smithany basic lein command should be informing you of that though
15:22TimMcI don't think clojars looks at the project.clj, but the pom.xml that is generated.
15:23jasminyes that is what it looks like and pom.xml gets generated ok
15:24dnolen_required reading for ClojureScript REPL maintainers https://github.com/clojure/clojurescript/wiki/Custom-REPLs
15:24dnolen_cemerick: ^ I'm not sure if the Weasel guy hangs out here
15:24jasmini've tried using my email address and my login as the username when it prompts me when doing lein deploy clojars but still it fails
15:24dnolen_custom REPL maintainers I should say
15:25gfredericksjasmin: you've created an account on clojars.org?
15:25jasminyep
15:25jasmini've been at this now for 4 hours
15:29jasmindoes groupid and artifact in defproject have restriction on characters that can be used. e.g. would a hypen (-) be an invalid character? it is not for pom.xml
15:30gfredericksI've used hyphens plenty
15:30gfredericksjava people don't seem to mind hyphens outside of their source code
15:34jasminuh uh
15:34jasminProject names containing uppercase letters are not recommended
15:34jasminand will be rejected by repositories like Clojars and Central
15:35llasramjasmin: Was that your problem?
15:35jasminapparently there is an env var LEIN_BREAK_CONVENTION that will let me override this
15:36jasmintrying now
15:36gfredericks(defproject com.gfredericks/AllLower-CaseOne_Word "0.1.0-SNAPSHOT"
15:36justin_smithgfredericks: my favorite wifi password is "all one word, no spaces"
15:36jasminthat works for you?
15:36jasminlol
15:36llasramjasmin: Err, the "forbidden" error you reported later doesn't jibe with a problem that should fix
15:37gfredericksjustin_smith: with the network name "down currently, sorry for the inconvenience"
15:38cemerickdnolen_: great, thanks
15:38jasminit works holy mother
15:38TimMcwut
15:39jasmincan't have caps in group id or artifact id
15:39dnolen_cemerick: happy to relax the requirements if there's some unsatisfied need - but the whole idea here is for REPLs to have to do a lot less
15:39TimMcThat seriously did it?
15:39dnolen_cemerick: basically *nothing* after -setup
15:39dnolen_cemerick: the whole libs tracking stuff was crazy
15:39jasminyep..there goes another 4 hours spent on fighting tools
15:40TimMcJasmin and the Fighting Tools
15:40TimMcHmm, doesn't relaly work as a band name.
15:40jasminhahah
15:40gfredericksI'm still confused about the order of events here
15:40gfredericksyou had a project with capital letters this whole time?
15:40jasminFighting Foos maybe
15:41cemerickdnolen_: sounds good; I haven't touched these things in so long, I don't even remember what libs tracking is :-)
15:41cemericklucky me
15:41TimMcYou might open an issue with clojars to provide informative deny for group and artifact names.
15:41dnolen_cemerick: having to track which libs have loaded to avoid stupid Closure errors
15:41TimMc(You may have to implement it yourself though.)
15:41cemerickah, that
15:41jasminyes..project had capital letters in it..matches the class name
15:42dnolen_cemerick: the solution is to just monkey patch goog.isProvided_ and allow libs to load multiple times
15:42gfredericksjasmin: but you didn't read that warning from leiningen until 5 minutes ago?
15:42jasminsure I will post an issue with clojars
15:42jasminlein just needs to be a bit more verbose on failure in general..
15:42dnolen_cemerick: and the REPL infrastructure can do the right thing provided that CLOSURE_IMPORT_SCRIPT is bound to a function that knows how to load the dep in the JS runtime
15:43jasminwhat warning?
15:44gfredericksjasmin: the one you get with `lein new FightingTools` and can bypass with LEIN_BREAK_CONVENTION
15:44gfrederickswhich you quoted earlier
15:44jasminI found that in depths of desparation..using lein new to generate a brand new project.clj
15:45jasminonce I gave it the name it gave me that output
15:45gfredericksoh okay; so somehow missed it when creating the original project
15:46jasminI created the project by hand originally..only 3 lines to it
15:46gfredericksah ha
15:46gfredericksokay that makes more sense
15:47TimMcjasmin: Lein's idea of good project names and clojars' restrictions are not necessarily in sync, though.
15:47justin`what's the reason clojurescript's bit-or operation yields diferent results than clojure's?
15:48gfrederickswith what args?
15:48jasminyes. thanks for help guys, much appreciate it
15:48gfredericksmight be those pesky doubles
15:48jasminoff to get some zzzz
15:48justin`(apply bit-or '(557831 1082379 98306 33564957 134236965))
15:48gfredericks,(apply bit-or '(557831 1082379 98306 33564957 134236965))
15:48clojurebot169471807
15:49justin`cljs is giving me 1607439
15:49gfredericksI think that's well within Double's integer range...
15:49gfredericksbut hm
15:49gfredericksI really have no idea what bit-or means in javascript actually
15:50gfredericksseems kind of ambiguous
15:50dnolen_justin`: might be a bug, should look at the generated JS
15:50TimMc&(map (partial apply bit-or) (partition 2 1 '(557831 1082379 98306 33564957 134236965)))
15:50lazybot⇒ (1607439 1147915 33663263 167799613)
15:50dnolen_gfredericks: all bit operations clamp to 32bit integer before application
15:50gfredericks,Integer/MAX_VALUE
15:50clojurebot2147483647
15:50gfredericksdnolen_: okay so it's semantically all integers
15:51justin`ok I'll dig a little deeper wasn't sure if I was missing something obvious
15:51gfredericks,(apply bit-or '(557831 1082379 98306 33564957))
15:51clojurebot35237663
15:51TimMcjustin`: ^ Does the above differ from CLJS in all places, some, or none?
15:51gfredericks,(apply bit-or '(557831 1082379 98306))
15:51clojurebot1672975
15:51gfredericksstill wrong with 3 nums
15:51gfredericks,(apply bit-or '(557831 1082379))
15:51clojurebot1607439
15:51gfredericks^ that's the first correct one
15:52gfredericksit's as if only the first two numbers are considered
15:52TimMcHimera doesn't allow pasting? Bleh.
15:52gfredericksthis is according to himera
15:52gfrederickswhich allows pasting for me
15:53dnolen_justin`: this is probably just bug, I don't think I've ever use bit operations higher order
15:53justin_smithmaybe it's ignoring all args after the first two?
15:53gfredericksseems to
15:53gfredericks(apply bit-or '(2 2 399482983)) ;; => 2
15:54TimMcHimera doesn't allow pasting in Firefox.
15:54gfredericksI'm using firefox
15:55gfredericksTimMc: we could keep going with this and discover that the only difference between you and me is our first names and that's what himera is discriminating with
15:55TimMcWhat version? v31.3.0 here.
15:55dnolen_gfredericks: oh right, bit ops aren't variadic in CLJS at the moment
15:55dnolen_only implement 2 argument arity
15:55gfredericksoh right it's not even about apply
15:55TimMcyikes
15:55justin`dnolen_: ok cool that makes sense then
15:55gfredericksbroken directly too
15:55dnolen_justin`: simple patch is quite welcome - this is seriously low hanging fruit :)
15:56dangitjustin_smith: Are you saying there is no way to get a PID from a spawned process in clojure??
15:56lazybotdangit: Definitely not.
15:56justin`dnolen_: O
15:56justin`dnolen_: cool I'll see what I can do :)
15:56justin_smithdangit: exactly, it's a stupid limitation of processes under the jvm, at least using Process / ProcessBuilder etc.
15:56dangitWow
15:57andyfdangit: Stackoverflow may have partial answers, at least, e.g. http://stackoverflow.com/questions/4750470/how-to-get-pid-of-process-ive-just-started-within-java-program
15:57llasramdangit: unfortunately still relevant: http://blog.headius.com/2013/06/the-pain-of-broken-subprocess.html
15:57justin_smith$javadoc java.lang.Process
15:57lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Process.html
15:58dangitI’m not from a java background. This pain is all new to me :-(
15:59dangitandyf: That is the route I was going for, but I can’t get the pid out of the UNIXProcess.
15:59justin_smithdangit: how did you attempt to get it out?
16:00dangithttp://pastebin.com/BBktFWTP
16:02justin_smithI think after setting the field accessible, you can just do (.pid (:process p))
16:03justin_smithalso, to what end are you using the pid? There may be a less hacky option that does not require the pid.
16:05TimMcjustin_smith: You have to use the Field instance that you set accessible to access the value.
16:05justin_smithTimMc: OK, I was not aware of that
16:13augustlis there a "make this clojure web app secure" ring middleware around? :)
16:13andyfaugustl: Reroute all requests to /dev/null ? :-)
16:14augustls/make/attempt to make/ ;)
16:14augustlI think friend + ring-anti-forgery should do it.. but what do I know
16:22amalloyi kinda think application security is something you have to think about a bit more than just sprinkling on some middleware like fairy dust
16:23TimMcandyf: Not enough, you also need to return malformed outputs so that you can possibly break the attacker's script. The best defense is a deniable offense.
16:23gfredericks{"status": e404}
16:24SagiCZ1TimMc: I chuckled
16:30augustlamalloy: well, sure, but it would be nice to not have to resort to something like Rails for secure defaults
16:30augustlI want to have my cake and eat it too :)
16:42romain_Hi everyone, anybody knows how to build the cljs compiler from source?
16:42augustlthat's weird - https://github.com/ring-clojure/ring-anti-forgery/blob/f6f1edbaf4f78bea5128b3c36847b0de17d29d22/src/ring/middleware/anti_forgery.clj#L90
16:42augustlwhy doesn't it assoc the token onto the initial request as well?
16:43augustlthe only way to get a hold of the token in the very first request is to read the dynamic var
16:44augustlI suppose it would be sort of weird to "fake" the session and assoc it in manually.. But that seems like a better option to me than forcing the use of dynamic vars
16:45dangitjustin_smith: Yeah, that didn’t work
16:45dangitAll I want to do is start up a local dynamodb instance for my tests
16:45dangitAnd I want to kill it after the tests run.
16:45dangitUnfortunately SIGTERM doesn’t seem to take it down.
16:47justin_smithdangit: did you actually look at the api docs? there is a .kill method on processes
16:47justin_smithsorry, it's .destroy
16:47dangitYeah, destroy isn’t working.
16:47dangitI think it is sending SIGTERM
16:47justin_smithor .destroyForcibly (equivelent to -9)
16:47dangit*that* I didn’t see...
16:47justin_smithit's a really small API...
16:48justin_smithoh wait, .destroyForcibly is java 8 only
16:49dangitYes, the API is even smaller than you suspect ;-)
16:49justin_smithhopefully using 1.8 jvm is an option for you
16:49dangitI suppose it is. What a big hammer, though.
16:52SagiCZ1when i add more bindings in for or doseq, it acts as an inner loop.. this is desirable most of the time, but what if i want to iterate two things at once in one loop?
16:53SagiCZ1,(doseq [i (repeat 3 :a) y (range 3)] (println i y))
16:53clojurebot:a 0\n:a 1\n:a 2\n:a 0\n:a 1\n:a 2\n:a 0\n:a 1\n:a 2\n
16:53SagiCZ1i want this to print just 3 rows
16:53justin_smith(for [[a b] (map list seqa seqb)] ...)
16:53SagiCZ1i see
16:53SagiCZ1this can work with doseq as well right?
16:53justin_smithyeah
16:53noonian,(map println (range 3) (repeat 3 :a))
16:53clojurebot(0 :a\n1 :a\nnil 2 :a\nnil nil)
16:53andyfThat or loop, but if you like for or doseq, justin_smith's suggestion is the best I know
16:54SagiCZ1,(for [i (map list (repeat 3 :a) (range 3))] (println i))
16:54clojurebot((:a 0)\n(:a 1)\nnil (:a 2)\nnil nil)
16:54SagiCZ1oh println is dumb here.. sorry
16:54SagiCZ1ok thanks, i understand this will work for me
16:55noonian,(map (comp println str) (range 3) (repeat 3 :a))
16:55clojurebot(0:a\n1:a\nnil 2:a\nnil nil)
16:55noonian,(println 1 :a)
16:55clojurebot1 :a\n
16:55noonianprinting is just weird with clojurebot
16:56SagiCZ1is it?
16:56SagiCZ1apart from adding \n instead of makin an actual new line it works i think
16:56noonianreturns newlines as a string and at the same time as the return value is printed (same time means in the same irc message)
16:56justin_smithnoonian: println inside constructing a value in a repl does the same thing
16:56SagiCZ1noonian: my REPL does the same
16:57justin_smithrandom interleave of printed values and return values
16:57SagiCZ1its because printing is not atomic or what not
16:57gfredericks,(range)
16:57clojurebot(0 1 2 3 4 ...)
16:58gfredericks,(map (fn [_] (pr (range))) (range))
16:58clojurebot((0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 4 ...)(0 1 2 3 ...
16:58noonianworks pretty well for me in the repl: https://www.refheap.com/95554
16:58gfredericksha what
16:58gfredericksI did not expect that much output
16:58gfredericksand where are the nils
16:59gfredericksI guess it's chunking
16:59justin_smithyeah, thanks to chunking, the nils are somewhere after the last ... I guess
16:59gfredericks,(map (fn [_] (pr (iterate inc 1))) (iterate inc 1))
16:59clojurebot((1 2 3 4 5 ...)(1 2 3 4 5 ...)nil (1 2 3 4 5 ...)nil (1 2 3 4 5 ...)nil (1 2 3 4 5 ...)nil (1 2 3 4 5 ...)nil (1 2 3 4 5 ...)...)
17:00gfredericksthat's a little more reserved
17:00AimHereLooks like clojurebot is using the Schneier algorithm that can do an infinite loop twice in 5 seconds
17:01SagiCZ1whats wrong with this?
17:01SagiCZ1,(let [lines [[3 2 3] [5 7 1]]] (map list lines (range lines)))
17:01clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>
17:01Bronsa,(range [3 2 3])
17:01clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>
17:02BronsaSagiCZ1: ^ that's what you're doing
17:02SagiCZ1oh.. there was supposed to be count there
17:02SagiCZ1(let [lines [[3 2 3] [5 7 1]]] (map list lines (range (count lines))))
17:02SagiCZ1ok thanks Bronsa
17:09hellofunk,(= (let [lines [[3 2 3] [5 7 1]]] (map list lines (range (count lines)))) (let [lines [[3 2 3] [5 7 1]]] (map list lines (range)))
17:09clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:09hellofunk,(= (let [lines [[3 2 3] [5 7 1]]] (map list lines (range (count lines)))) (let [lines [[3 2 3] [5 7 1]]] (map list lines (range))))
17:09clojurebottrue
17:10hellofunkSagiCZ1: note you don't need the count or the lines in the range
17:10amalloy,(let [lines [[3 2 3] [5 7 1]] (map-indexed (fn [i x] [x i]) lines))
17:10clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
17:10amalloy,(let [lines [[3 2 3] [5 7 1]]] (map-indexed (fn [i x] [x i]) lines))
17:10clojurebot([[3 2 3] 0] [[5 7 1] 1])
17:11hellofunkSagiCZ1: ^ that way also
17:17[blake|O
17:17[blake|Whoops.
17:18[blake|I'm trying to "screen capture" an HTML page, one I've generated in Clojure (though CSS is involved) and trying to figure out a clean way to store the results and recall them later.
17:19[blake|I've got html2canvas, which is cool but it's on the client side and I can't see how to pass the canvas back to the server. (I tried serializing it but it's got circular references, apparently.)
17:20[blake|Feels like I'm doing it the hard way.
17:23craigglennie[blake|: Can you call toDataURL on your canvas and pass that to the server?
17:24[blake|craigglennie: Maybe! Let me see!
17:33tolstoy`Hm. defspec in test.check doesn't allow metadata for grouping tests.
17:34tolstoy`Selectors, as leiningen says it.
17:34[blake|(inc craigglennie)
17:34lazybot⇒ 2
17:35[blake|That might just work. I've got the data now, anyway. Thanks!
17:36[blake|It's a PNG, which isn't awesome, but maybe the simplest solution.
17:41craigglennie[blake|: you’re welcome
17:43mi6x3mllasram: still here?
17:44mi6x3mor noonian
17:44mi6x3mit's about the advantages of me having a method set-default-decorator!
17:44noonianhmm?
17:45mi6x3mnoonian: remember our discussion about the decorators?
17:45mi6x3mfor a GUI component
17:45noonianyeah, did you find something that works?
17:46mi6x3mwell in the constructor function of the component I will have a :decorator argument for a decorator for that specific instance
17:46mi6x3mand I plan on having a method set-default-decorator! for the default decorator...
17:47nooniani think the set-default-decorator! is fine since you are wrapping a java thing and that is pretty much the existing interface
17:47nooniani'd still prefer passing in an argument if you can accomplish what you need to that way
17:48mi6x3mnoonian: yes, well they are 2 different concepts. if you don't specify a decorator via :decorator, the default one will be used. the default is also used for the subinstances you have no control over.
17:49mi6x3mnot exactly clojure by the book but oh well
17:49mi6x3mit's what the java component offers, no way around that
17:49reiddrapertolstoy`: (defspec ^:foo bar ...) doesn't work?
17:49nooniancould you just have a :default-decorator you pass in as well to set the one used on sub-componenets?
17:50mi6x3mnoonian: this is impossible to control through the Java component. set-default-decorator affects all subinstances of all constructed components
17:50mi6x3mthere's no way to target the subinstances of one specific component
17:50noonianyeah, i think setting the default is fine then
17:51SagiCZ1how can i get around the fact that macros cant be apply-ied?
17:51mi6x3mnoonian: thanks a bunch for listening and helping :)
17:51mi6x3m(inc noonian)
17:51lazybot⇒ 11
17:51mi6x3mhelped me a lot
17:51noonianSagiCZ1: depending on the macro you can often wrap it in a function and apply that
17:52noonianmi6x3m: no problem, good luck!
17:52SagiCZ1ok
17:52amalloySagiCZ1: by reframing your approach to one where applying a macro doesn't seem necessary
17:52mi6x3mSagiCZ1: apply is runtime, a macro is not :)
17:52mi6x3mcan't work together at all
17:53SagiCZ1amalloy: ok, i have macro add-lines that takes [plot x y] where x and y are lists of points.. i have a function that returns [x y] in a vector.. i need to apply it
17:53amalloywhy is add-lines a macro?
17:53SagiCZ1amalloy: i am not the author of that macro
17:54amalloyincanter?
17:54SagiCZ1yes
17:54SagiCZ1(apply #(add-lines %1 (first %2) (second %2)) plot (foo))
17:55SagiCZ1shouldnt this work?
17:56SagiCZ1(apply #(add-lines %1 %2 %3) plot (foo))
17:56SagiCZ1this one works though
17:57amalloygross. there's no reason for that to be a macro at all. can you use add-lines*, or just write your own wrapper that does the same thing?
17:58SagiCZ1you looked at the source?
17:59amalloyyes
17:59m1dnight_I need some architecture help, anybody got a second to listen? :p
17:59amalloy~anyone
17:59clojurebotanyone is anybody
17:59amalloyi hate you, clojurebot
17:59m1dnight_I'll just go ahead :p
18:00m1dnight_I have a teeny tiny irc framework in clojure (as an exercise for architecture and clean code) but I'm having some issues with my abstraction
18:01m1dnight_Atm I have a loop that listens on a socket in a loop, dispatches on each message it reads. (privmsg and what not). But I have to send on the socket as well. So at the moment I just use a write-out function I built that takes the "bot" (ref {:socket s :user {:nick n}} and picks out the socket and writes to it
18:01SagiCZ1amalloy: thanks, it seems i can apply add-lines* without issues
18:01m1dnight_but, if I want to make it multithreaded (e.g., callbakcs for bot functionality) I should make sure that the socket is synchronized in some way and thus abstracted
18:02m1dnight_I'm thinking about making (write-out [msg]) put a function on a stack/queue in the bot, and creating a loop that executes each function on the socket
18:02m1dnight_anyone got a better idea?
18:03m1dnight_https://github.com/m1dnight/clojbot/tree/master/src/clojbot this is the source, if that interest someone
18:04zophyok, i ran the lein script and it put a jar file in a directory.. so now what ?
18:06zophyoooh, i didn't use -jar.. silly me
18:08amalloyzophy: you should just be able to put lein's script on your PATH
18:08amalloythen run stuff like `lein new`, `lein jar`, whatever
18:18zophyoooh, i renamed lein as lein.sh, didn't know it was used beyond the download stage
18:24dnolen_http://swannodette.github.io/2014/12/29/nodejs-of-my-dreams/
18:25dnolen_give the new Node.js REPL a shot when you have time
18:25dnolen_for all the REPLs, in-ns, require finally work as expected
19:11m1dnight_I think I pooped my REPL
19:11m1dnight_I can do lein run fine (even lein clean && lein run), but lein repl fails
19:11hellofunkdnolen_: possible then to load a custom namespace and fns in the node repl? your example loads clojure.string, how about an original project?
19:11m1dnight_#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character>
19:11m1dnight_nowhere a mention of the namespace of my current project
19:12m1dnight_any tips on how to clear some cache or something?
19:12andyfm1dnight_: Do you have a ~/.lein/profiles.clj file? If so, it may have a syntax error. Or your project.clj file.
19:12andyfYou should be able to tell your current project by what directory you are in, yes?
19:13m1dnight_I just tried a lein repl in my home dir and that goes fine
19:13m1dnight_So might be indeed that my project.clj has a syntax error
19:13andyfso probably an issue with a project.clj file
19:13m1dnight_let me see
19:13m1dnight_strange though, that the lein run goes through fine
19:13andyfagreed.
19:14andyfIt may not be a syntax error, as much as a data value of an unexpected type as the value for a key in your defproject. Not all commands use all of those values, so it could be a bad value for a key used by 'lein repl' that is not used by 'lein run'
19:15m1dnight_hold on, i'm going back to a default project.clj
19:15andyfFrom the error message, my first guess would be you have a string somewhere that a vector of strings is expected.
19:15andyfe.g. :source-paths or :test-paths
19:16m1dnight_oooh
19:16m1dnight_I think I just spotted it yes
19:16andyfWhen you do 'seq' on a string, you get a sequence of characters, so it can lead to error messages like that.
19:16m1dnight_andyf: I had a string on my :main, instead of without quotes
19:17m1dnight_(inc andyf)
19:17lazybot⇒ 19
19:17m1dnight_thanks a bunch man :)
19:17andyfnp. Maybe Eastwood should try to find simple mistakes in project.clj files ...
19:18andyfexcept when run from the cmd line, project.clj has already been run before Eastwood begins, so would need some different way to run it, probably.
19:27dnolen_hellofunk: yep works, anything on the classpath as usual
19:35amalloyandyf: perhaps a separate piece of eastwood that runs without a project.clj, and analyzes your project.clj?
19:35amalloyi know lein plugin commands have some sort of no-project-needed option
19:43andyfamalloy: I may look into that. In this particular case, it seems like something that Leiningen itself could report with a better error message, too.
19:53yedi_anyone know of any resources of how to simply hook up basic transitions (fade-in, slide-out, etc) to state changes in the OM app-state?
19:56andyfA library called Bardo was announced on the ClojureScript Google group a couple of weeks ago: https://github.com/pleasetrythisathome/bardo You can read the discussion surrounding the announcement on the group.
19:56andyfNot sure if it is what you are looking for -- haven't used it myself.
19:59augustlhmm, bidi doesn't seem to play nice with a repl. (bidi.ring/make-handler ["" {"/" home-page-handler/show-home-page}]) seems to somehow keep a reference to the function that the symbol points to at evaluation time, instead of resolving the symbol every time
20:00augustl (bidi.ring/make-handler ["" {"/" (fn [req] (home-page-handler/show-home-page req))}]) makes it work fine
20:00augustltalking about reloading via repl eval
20:01amalloyaugustl: #'show-home-page
20:02augustlamalloy: what is #' called? So I can google it :)
20:02amalloy,'#'inc
20:02clojurebot(var inc)
20:03tolstoy`sharp-tick
20:03tolstoy`or maybe not
20:04andyfaugustl: The cheatsheet has a list of such symbols with some links to more info about most of them: http://jafingerhut.github.io Look for "Reader Macros" section
20:04noonianin clojure it is 'literal' or 'shorthand' or 'reader' syntax for vars
20:05fairuzaugustl: http://conj.io/ calls it as var quote
20:10augustlandyf, fairuz thanks :)
20:27fairuzThere's a function foo that accept [& args]. I want to call foo with (foo 123 456) but now I have [123 456] stored in bar instead, so calling (foo bar) will be wrong. How can I convert [123 456] to 123 456?
20:28Pistahh(appy foo bar) ?
20:28Pistahh(apply ...)
20:28fairuzah cool
20:29fairuzthanks Pistahh
20:29Pistahhnp :)
20:52DomKMIs anyone familiar with how feature expressions and macros in CLJS will work?
20:53DomKMSpecifically, will macros defined in foo.cljc be available to CLJS code within that same file?
21:22djamesShould I expect lein compile to find and compile (gen-class) forms in my code? I know it finds (ns (:gen-class ...))
21:22djamesSomething unexpected is going on -- I'm trying to rule out some problems.
21:24amalloydjames: it should, so long as those forms are in namespaces that get compiled
21:29djamesamalloy: thanks
21:30djamesamalloy: I'm wondering if I need to think about using two passes. My `lein compile` is failing because (I think) a function references the class; e.g. foo.Bar. I thought the compile would happen first, eliminating the problem.
21:31djamesRight now I'm putting all the gen-class stuff into a separate file and only referencing in from another file
21:32djames^ "a function references the class before it is compiled" I meant to say
22:00theme2Hi
22:00theme2I am new to clojure
22:02theme2I still don't fully understand quoting and macros, but clojure looks pretty promising to me
22:14fairuztheme2: hey. welcome :)
22:15theme2fairuz: late answer O_o
22:15theme2but later is better than never :)
22:18TEttingertheme2, yeah it's vacation for a lot of people and I assume that a lot of regulars are away from IRC
22:18theme2TEttinger: no problem :)
22:19TEttingerclojure is a very very expressive language
22:19TEttingerI really find its ability to handle complex data cleanly and simply is almost unmatched
23:36rritochDoes anyone know of any leiningen plugins or clojure libraries to use SableCC in a clojure project?
23:42rritochAll I can find is a maven plugin, sablecc-maven-plugin but it isn't clear how I can get leiningen to execute the compiler from leiningen.
23:58andyfIf there is a Java API, you can write some Clojure code to call that, but I have no idea how complex it might be.