#clojure logs

2015-04-29

00:00codefingernp
00:01amalloynoir-session almost certainly requires sticky sessions
00:01kenrestivothanks alan
00:05kenrestivothat was it! amazing.
00:05kenrestivoyeah it smelled like a thread-related problem. thanks again
00:05amalloynot thread, server
00:06kenrestivoright, two different dynos is two different servers, i guess.
00:06codefinger\o/
00:07kenrestivovery glad the clojure community is still awesome. been away for a while, but to get help fixing this kind of weird problem in ancient code in 10 minutes is fantastic. thanks again.
02:27NataneHow come when i add [cider/cider-nrepl "0.8.2"] to my lein profiles, nothing happens?
02:28Natanei still get the "cider requires nrepl 0.2.7 or newer bla bla" on cider-jack-in
02:28seangrove~ask
02:28clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
02:29Natanei didn't ask to ask D:
02:29Natanei just ask, i'm rude like that
02:30Natanei don't even say hi, that's how efficient i am
02:30Jaoodyou are assuming cider-nrepl and nrepl are the same thing
02:31Natanethere is also [org.clojure/tools.nrepl "0.2.10"] in my dependencies in the same profile
02:31Natanei thought cider-nrepl was cool with that
02:35Natanereally i'm just butthurt eldoc doesn't work for clojure buffers
02:36Natanei can't seem to get it to eat nrepl 0.2.7
02:36Natane(whatever that is)
02:37Natanebut then, i heard using notepad is good for memory
02:56ed-gNatane, I had a similar problem once. It ended up that I had to install a different version on the Emacs side.
02:56ed-gNatane, although its been long enough I don't remember what was happening exactly
02:59ed-gtry [org.clojure/tools.nrepl "0.2.7"]
03:00Nataneactually i think i'm no a path to figuring it out
03:00Nataneit looks like when i start lein repl itself it uses nrepl 0.2.7
03:00Nataneso i'm trying to get it to upgrade
03:00Nataneoh i mean 0.2.6
03:02ed-gNatane, I'm running 0.2.10 on my current project. That could be the latest. Also I've found the lein "ancient" plugin handy for keeping deps up to date.
03:06Natanelooks useful, thanks
03:11Nataneoh my satan i figured it out
03:11Natanei put my profiles.clj in the wrong .lein
03:12Natanefeels stupid but good
04:32engblomWow! I did not know you could add several vectors as argument to map. (map + [1 6 3 4] [1 2 3 4]) is a very nice way to add two vectors.
04:32engblomClojure never cease to amaze me.
04:41dstocktonclojure rulez
04:46TEttingerengblom, I keep having those moments pretty continuously with clojure
04:46TEttingerthe first time I learned about reductions was one
04:48hyPiRionI always love (apply map list ...)
04:49hyPiRion,(apply map list [[1 2 3] [4 5 6] [7 8 9]])
04:49clojurebot((1 4 7) (2 5 8) (3 6 9))
04:51wasamasazipmap?
04:51wasamasaor no, that was interleave
04:52wasamasaI'd call such a function transpose
04:57hyPiRionyep
04:57hyPiRionmatrix transposition
04:58TEttingerI thought this was pretty cool
04:58TEttinger&(let [r5 (Math/sqrt 5.0) phi (/ (+ 1.0 r5) 2.0) prime (fn [n] (bigint (+ (/ (Math/pow phi n) r5) 0.5)))] (map prime (range 1 1001)))
04:58lazybot⇒ (1N 1N 2N 3N 5N 8N 13N 21N 34N 55N 89N 144N 233N 377N 610N 987N 1597N 2584N 4181N 6765N 10946N 17711N 28657N 46368N 75025N 121393N 196418N 317811N 514229N 832040N 1346269N 2178309N 3524578N 5702887N 9227465N 14930352N 24157817N 39088169N 63245986N 102334155N 1655801... https://www.refheap.com/100187
04:58TEttingerfirst 1000 fibonacci numbers calculated by closed-form fn
04:59TEttinger(I didn't know you could get a fibonacci number at any point without a previous calculation)
04:59TEttinger&(let [r5 (Math/sqrt 5.0) phi (/ (+ 1.0 r5) 2.0) prime (fn [n] (bigint (+ (/ (Math/pow phi n) r5) 0.5)))] (prime 1000001))
04:59lazybotjava.lang.NumberFormatException
04:59TEttingerha
05:00TEttingerit would need bigdecimals for that
05:00hyPiRionTEttinger: Well, it sort-of is is a previous calculation. phi^n / r5 is just phi^(n-1)*phi/r5
05:02hyPiRionI like that fibonacci numbers can be calculated through matrix exponentiation. It's based upon the same underlying trick
06:57bcn-florHello! Is it possible to get a semantic representation of a form ? Something like in this snippet: https://gist.github.com/anonymous/2a030b31438c660b3926
07:04noncom|2bcn-flor: hi! well, it is certainly possible to write some functions that will give you such case of "explanation", but to me the explanation is not very correct (i might be mistaking)
07:06noncom|2what confuses me: 1) there is no such thing as "type fn". 2) what about arguments and bodies for multi-arity functions? 3) somehow in your example the (explain) knows that it is a function definition and analyzes the form with that knowledge. otherwise, it's just (defn) applied to the 4 args
07:07noncom|2in other words, ok, you write a macro that parses a defn form like that, but what is the benifit?
07:08noncom|2aside from that it gives a rather confusing output..
07:11j-pbnoncom|2: I think bcn-flor just want a static code analyser and the defn was just an example
07:11j-pbbcn-flor: look at clojure.tools.analyzer
07:11j-pbit does exactly that
07:11j-pbhttps://github.com/clojure/tools.analyzer
07:13noncom|2but that's a syntax (AST to be precise) analyzer, not semantics...
07:14bcn-flornoncom|2 : I'm trying to parse clojure source code in order to build a visual representation of it.
07:14noncom|2well, then what j-pb said, could be a good start
07:15j-pbbcn-flor: yeah go with tools.analyzer
07:15bcn-florthank you both, I'll take a look at the tools.analyzer
07:15Bronsastart directly with tools.analyzer.jvm
07:21j-pbnoncom|2: in most lisps syntax is just a very thin wrapper around semantics, tools.analyzer will actually give you quite a lot of info, it's what clojure.typed uses for its type checker
07:21noncom|2yeah, thinking about it, it is
07:28noncom|2bcn-flor: won't you mind telling a little about what is your project about? you want to visualize clojure code?
07:36dstocktonfor rails it was a blog in 15mins, can anyone suggest a 'classic' toy clojure project?
07:36dstocktonthat shows it off as much as possible
07:36dstocktonperhaps something with lots of parallelism
07:37j-pbdstockton: maybe a blog in 15 minutes ;)
07:37j-pbdstockton: it really depends on what you want to do, clojure feels a bit more general than ruby
07:38dstocktoni want a toy project that can show off as many clojure features as possible
07:38j-pbevry project can do that
07:38dstocktonor perhaps something you might want to extract from a hypothetical web app and make into a clojure microservice
07:39j-pbI'd probably do a toy thing that I always wanted to have, and then just use clojure for that
07:39j-pbyou can use pretty much every clojure feature in every context
07:40dstocktoni suppose so, im actually wanting to write a kind of intructional walkthrough and looking for a good idea to walkthrough building something practical
07:40mpenetdstockton: write a database in 15min?
07:40mpenetsince it deals with data at the core, fits
07:41dstocktonmpenet: that's a great idea actually
07:41mpenetmultiple implementations: show off atoms, then refs, then make it multithreaded, then with core.async
07:41dstocktonno necessarily in 15 mins
07:41mpenetyeah
07:41dstocktonnot*
07:41dstocktonthanks!
07:41j-pbyeah sounds like a good idea
07:41mpenetyou're welcome. I like the community idea btw, looking forward to it (and contributing as well hopefully)
07:43mpenetdstockton: wrong person for the community stuff, I confused you with d. s. gomez
07:44dstocktonthought so :)
07:46bcn-flornoncom|2: yeah, just experimenting. I want to build a visual representation of the source code, in which forms are represented using graphical blocks and the syntax is reduced to bare minimum. The user can navigate between the forms with the keyboard or mouse, move forms around, evaluate them in place, etc.
07:48noncom|2dstockton: have you looked at the luminus guestbook example?
07:49dstocktoni havent noncom|2 but the database idea is perfect for what I want to do
07:49dstocktonof course clojure is great for most things but a guestbook wouldnt give much opportunity to shine
07:50noncom|2bcn-flor: cool! i always liked this kind of projects.. surprisingly there were not so many of them, despite the topic is very captivating
07:50dstocktonits the canonical example for most frameworks, that or a blog
07:50bcn-flornoncom|2: I'm trying to tackle the idea of non-textual representation of programs and visual/interactive development
07:51justin_smithbcn-flor: I've done a lot of visual programming. The problem I ran into was that you can represent a higher dimensionality of connections in linear text than you can in visual form.
07:53noncom|2justin_smith: yeah, i've stumbled into that too. but still i believe. there must be a way...
07:53noncom|2also, maybe i'm repeating myself, but this kind of semi-visual coding is quite interesting, esp on a mobile: www.youtube.com/watch?v=nHh00VPT7L4
07:54bcn-flornoncom|2: yes, that, taken to the extreme
07:57noncom|2bcn-flor: what are you using for graphics, standard GUI libs or OpenGL or something else?
07:57bcn-flornoncom|2: as in, paranthesis can be replaced by background color representation of the form, functions can have image representations, can run the form in place, by supplying values for arguments, etc.
08:00bcn-flornoncom|2: stepping through forms visually, with a function return value pointing an arrow to the next function's argument.
08:06noncom|2yeah, that would be interesting! hope to see it available sometime!
08:06bcn-flornoncom|2: i'm at the idea phase :) I'm rendering html at the moment
08:07noncom|2i forgot about the html5 GUIs, right. they are pretty advanced today.. could really serve as an IDE of sorts
08:08p_lnoncom|2: if you want to waste a lot of resources and/or reimplement local drawing...
08:09bcn-flornoncom|2: it's easier to experiment visually with html, but for a true vi-like experience, a native gui toolkit must be used. html (and even java) doesn't quite cut it in my opinion :)
08:10justin_smithso you are making something for only one OS
08:10bcn-flornoncom|2: or opengl, which opens up 3D which would be interesting as well
08:11justin_smithyou can do opengl in the browser
08:13noncom|2i did a renderer to render clojure forms in OpenGL a while ago ...
08:13noncom|2simple ones, more even for edn
08:14noncom|2i realized that it requires much much optimization
08:18bcn-flornoncom|2, justin_smith: the idea i'm dabbling with is a client-server setup, in which the clojure process (server) performs all the logic operations on the representation and sends out (through socket or IPC) the delta of the changes to the client. the client is written in anything, Objective-C or C++ and is reponsible for rendering the world and user input. Sort-of like game engines. But I'm thinking too far ahead of me..
08:18bcn-flor it's still less than a concept in my head :)
08:22noncom|2bcn-flor: well, i can only encourage you to experiment with it more. we really have to explore the possibilities to improve the media of code
08:23bcn-flornoncom|2: it's from clojure. I'm still learning it, but my mind explodes with ideas of things that could be done with it :)
08:24noncom|2bcn-flor: yeah, but i think not just clojure, but lisp in general. in my opinion lisp is almost the only language that is really viable for such code representations
08:28bcn-flornoncom|2: yes, true. I guess I'm going through those 'aha' moments associated with understanding lisp :)
09:28Empperidoes anyone have a reasonable example for reagent where TransitionGroups are used?
09:28Empperihaving trouble getting it to work and to call the extra lifecycle functions
09:55Empperiguess no one can help :/
09:55Empperithis seems to be somehow myriad to solve
09:56mpenetEmpperi: you'd probably have more luck on #clojurescript
10:30noncom|2is anybody using aleph for tcp recently?
10:40craigglennieI have a function that creates a string and writes it to disk; it doesn't return any value that I care about. I need to call it with a range of integers, so I do (map the-file-writing-fn (range 3)) which returns (nil nil nil). Since I don't care about the result of the call to "map", is "map" the right function to be using? It works, but I wasn't sure if it's idiomatic.
10:40sw1nncraigglennie: doseq is preffered for side effects
10:46craigglenniesw1nn: Thanks, I'll use that
10:56sobelwhat's the difference between a string in "quotes" and a string in ""double quotes"" ?
10:57Bronsasobel: clojure has no double quotes syntax
10:57sobelhuh. it seems to be successful code (project.clj) and i picked it up of the Sonatype site
10:58sobelof=off
10:58oddcullydouble and quotes defined?
10:58oddcully"" double quotes "" e.g.
10:58sobel:url ""http://192.168.244.28:8081/nexus/content/groups/internal-repository""
10:58oddcullyor is it just some way to quote the quote there?
10:59sobelthat is the literal example
11:00sobelah well, it's not a big deal
11:00noncom|2sobel: can you show the full project.clj?
11:00noncom|2or at least this part of it
11:01sobelnoncom|2: the rest of the project.clj is entirely ordinary; i'll make a paste of the :mirrors section
11:05sobelhttp://pastebin.com/AT0J0UYs
11:06sobeli went ahead and stripped identifying info and pasted the whole project.clj
11:07sobelseems to work the same when i remove the extraneous quotes
11:09mpenetsobel: it'll probably be read as {:name "Nexus", :url "", http://192.168.244.28:8081/nexus/content/groups/internal-repository "", :repo-manager true}
11:09mpenetso the url becomes a key (a symbol) with empty str as value
11:10mpenetso yeah, readable, but broken if you need to actually use this mirror
11:12sobelmpenet: that makes sense. i figured it was slipping through a quirk of parsing somehow, but not as intended. might write to Sonatype about their example code.
11:12sobelthanks all
11:12sobelcode is no place for a mystery :)
11:14noncom|2sobel: i believe the automata that puts the second " and the human factor were the cause of this mistype
11:15sobelnoncom|2: true, i end up with unbalanced quotes and parens that way. not every edit is perfectly supported by clever editors.
11:38bobpoekertI have a vim-fireplace question: apparently exceptions are supposed to go in the location list, but when I run :lopen I get "E776: No location list"
11:42oddcullybobpoekert: something special you are doing? e.g. cpp with a typo gives the exception and :lopen shows it to me
11:42bobpoekertI don't think I'm doing anything special. My .vimrc is pretty simple.
11:43oddcullyhow do you trigger the exception?
11:43bobpoekert:%Eval
11:53oddcullybobpoekert: sorry, can't reproduce in any way. once the exception shows up in the statusbar i get the stacktrace in lopen
11:56noncom|2did anyone using Cursive succed in setting up all the hotkeys for clojure ok?
11:57noncom|2when I choose a Cursive or Emacs keybindings scheme, it is full of conflicts and does not apply...
12:00oddcullybobpoekert: i use git://github.com/tpope/vim-fireplace.git via pathogen. is your version reasonable new?
12:00bobpoekertI installed it via pathogen last week
12:01bobpoekertI'm running vim 7.3, though
12:02oddcullyi'm on 7.4
12:03justin_smithanyone have pros/cons for using jsvc to launch clojure services?
12:09justin_smithhttp://www.rkn.io/2014/02/06/clojure-cookbook-daemons/
12:09justin_smithlooks good
12:14i-blisjustin_smith: if you don't mind positive only feedback, been using it very successfully on many projects
12:14i-blisjustin_smith: you may want to adjust the jvm settings
12:15justin_smithawesome, thats good to hear
12:15i-blisjustin_smith: and launch a new thread from start
12:15justin_smithoh, so basically put my -main in a thread?
12:16justin_smith(defn start [] (.start (Thread. -main)))
12:16i-blisin -start
12:16i-blisyes, exactly
12:16justin_smithcool
12:16dnolencfleming: would be nice if find usages on protocols worked :)
12:17justin_smithi-blis: so what happens if I don't create a new thread? accidental shutdown?
12:18i-blisjustin_smith: jsvc wants the -start method to return fast, if I remember correctly
12:18justin_smithahh, that makes sense
12:18justin_smithit thinks something went wrong if it times out
12:18justin_smiththanks again for the info
12:19i-blisjsutin_smith: oh, and check the jsvc's cli options (I am sure you would have)
12:19justin_smithdefinitely on my to-do list, yes
12:19i-blisjustin_smith: my pleasure
12:22i-blisjustin_smith: and I guess you looked at lein-daemon? (it uses jsvc too)
12:22i-blisI had an issue with it, do not remember what kind, so I went on to harness jsvc and the Daemon class directly
12:22i-blisend of my 2 cts
12:33kwladyka(if (contains? {:a nil :b 2} :c) 1 2) - java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn
12:33kwladyka / how to write this corretly?
12:35i-bliskwladyka: what's the problem?
12:35i-blis,(if (contains? {:a nil :b 2} :c) 1 2)
12:35clojurebot2
12:35kwladykammm interesting
12:35kwladykai have error
12:35kwladykalike i wrote
12:36i-blisyou probably had a set of () around (contains?...)
12:36kwladykai have, i paste that like i have
12:36kwladykaor i am blind and i dont see difference
12:37i-blisI suspect this :
12:37i-blis,(if ((contains? {:a nil :b 2} :c)) 1 2)
12:37clojurebot#error{:cause "java.lang.Boolean cannot be cast to clojure.lang.IFn", :via [{:type java.lang.ClassCastException, :message "java.lang.Boolean cannot be cast to clojure.lang.IFn", :at [sandbox$eval49 invoke "NO_SOURCE_FILE" 0]}], :trace [[sandbox$eval49 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.core$eval in...
12:38kwladykai have exatly this copy&past (if (contains? {:a nil :b 2} :c) 1 2)
12:39kwladykawow it works in repl console
12:39i-bliskwladyka: where, how do you run it?
12:39kwladykabut it doesnt work in light table
12:39kwladykammm i reset light table and it works...
12:39kwladykanever mind
12:40kwladykaanyway thank you, without you i would spent hours on that :)
12:40noogaI want to use future fn to run fire-and-forget job frequently - like sending something to external API without blocking the thread and caring about the result
12:40i-bliskwladyka: no pb :)
12:41noogais this a good idea?
12:41mpenetnooga: depends on the "frequently" and the duration of the jobs, future runs on a unbounded threadpool
12:43mpenet(which is same threadpool as agents if I recall)
12:49amalloythere are two agent threadpools, depending on whether you use send (bounded) or send-off (unbounded). i think these days you can actually specify your own executor even, so you can have any number of threadpools
12:50noogampenet: like logging events to a time series database using rest api
12:51noogaI'm writing a service and I want to log 1-3 events per request without delaying the response
12:51mpenetamalloy: for agents yes, for future I don't think so
12:51mpenet
12:51amalloymhm, that's why i said "agent"
12:54noogaalternatively, I could conj them to some list and then have a thread runnig that would iterate through this list and do stuff
12:54noogabut sending them directly without blocking my handler thread would be nice
13:00hiredman<ztellman> that is an unbounded queue
13:01noogawhat is an unbounded queue?
13:03hiredmanthis list you are describing is a queue between some thread and your handler
13:03noogayes, basically that's what I'm trying to implement
13:04hiredmanif you handler can put stuff on the queue without ever blocking, then unless the thread processing the queue always pulls stuff from the queue way faster than handlers can write stuff, it is an unbounded queue
13:05hiredmanjava.util.concurrent has a few nice blocking queues
13:05noogaoh good
13:05noogaI'm going to check that
13:06noogathanks hiredman
13:06hiredmanthe unbounded queue thing in my best ztellman irc voice was because he just gave a talk about (and has been going on about for sometime) backpressure and bounded queues
13:07noogahaha
13:12J_ArcaneSo, data.zip.xml's magic appears to be failing me.
13:14J_ArcaneI have a very simple bit of code, which according to every single example I can find, should work just fine, and yet all I get is ().
13:14J_Arcanehttps://github.com/jarcane/wunderprojectj/blob/db4584c3cc8e1243e52ad2f00a5d0dd4c529ca09/src/wunderprojectj/get-data.clj
13:23TimMcHow come `lein javac` succeeds but `lein deploy` fails on the javac step? https://github.com/brightcove/johnny/blob/master/project.clj
13:23TimMcThis is a profiles thing, right? Where it fails to see the junit dependency?
13:23TimMcI don't know how to set this up correctly.
13:26hiredmanTimMc: add "src/test/java" to java source paths in the dev profile
13:28hiredman(and remove it from the, whatever it is, default profile?)
13:28TimMcAh, of course! That makes sense.
13:29TimMcI had a mismatch in dependencies vs. source paths.
13:34drguildohi. i'm trying to use criterium with a lein project + cider. i added (:require (criterium.core)) to my ns but i can't seem to use criterium.core/bench at all despite being able to use it in a lein repl. am i doing something wrong?
13:35drguildoi'm new to clojure so i probably am. just no idea what.
13:36puredangerdid you reload the ns?
13:37drguildowell i even restarted emacs and it still doesn't work
13:37drguildobut i tried cider-restart
13:38drguildoi'm dumb so i still feel like i don't understand namespaces completely
13:38TimMcdrguildo: Does require need a vector instead of a list there?
13:38puredangernot dumb at all, understanding namespaces when you start is tricky
13:38drguildoTimMc: i'm going by the docs on clojure.org
13:38TimMcI can't remember which of the namespace modifiers is picky...
13:38drguildohttp://clojure.github.io/clojure/clojure.core-api.html#clojure.core/ns
13:39puredangeryeah, that should be fine
13:39drguildoas i say, it works in lein repl which makes me think it's something about cider
13:39puredangerperhaps the repl you are getting with cider is not in the context of your project and doesn't have it's classpath?
13:40drguildoi started it with a file from the project in the current buffer
13:40puredangerwith jack-in?
13:40drguildothen did (ns exercises.project-euler) to switch to the file's namespace
13:41TimMc,(require '(clojure.set))
13:41clojurebotnil
13:41TimMc,clojure.set/union
13:41clojurebot#error{:cause "clojure.set", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.ClassNotFoundException, :message "clojure.set", :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}], :trace [[java.net.URLClassLoader$1 run ...
13:41TimMcdrguildo: Try making it a vector.
13:41drguildobut (criterium.core/bench foo) doesn't work
13:41puredangercan you (require 'criterium.core) ?
13:42TimMcthat should work too
13:42TimMc(:require (criterium.core x y z)) says "Require the following namespaces: criterium.core.x, criterium.core.y, criterium.core.z"
13:42TimMcso (:require (criterium.core)) says "Require the following namespaces: ..."
13:43TimMcYou're using a prefix list with no suffixes.
13:43drguildoTimMc: you're right. it seems to be working in cider now i used a vector.
13:43drguildodoes that mean the docs are wrong?
13:44puredangerthe examples in the docs are fine - you're using it slightly differently
13:44TimMcNo, it means the docs for clojure.core/ns show a somewhat less common usage.
13:44TimMc(:require (clojure.contrib sql combinatorics)) doesn't bring in an ns calle dclojure.contrib
13:44drguildoso how come it doesn't work in cider?
13:44drguildobut works in lein
13:44puredangeryeah, that would probably be good to address
13:45TimMcdrguildo: I don't think it does work in lein.
13:45drguildooh yeah, you're right
13:45drguildoi was doing (require) rather than putting it in an (ns)
13:46drguildoso if it doesn't work, the docs need updating?
13:46TimMcIt does work, it's just not what you want. :-)
13:46drguildocan you explain it to me like you'd explain it to a not-very-bright child?
13:47TimMcOK, take (:require (clojure.contrib sql combinatorics)). See how that uses a list instead of a vector?
13:47drguildoyeah
13:48TimMcThat's a shorthand for using vectors this way: (:require [clojure.contrib.sql] [clojure.contrib.combinatorics])
13:49TimMcA different shorthand would be (:require clojure.contrib.sql clojure.contrib.combinatorics) -- drop the enclosing vectors since you're not passing in any options for require'ing those namespaces.
13:49TimMcPut it a different way...
13:50TimMc,(map #(str "hello " %) ["Alice" "Bob"])
13:50clojurebot("hello Alice" "hello Bob")
13:50TimMc,(map #(str "hello " %) [])
13:50clojurebot()
13:50drguildoahh gotcha
13:50drguildothanks
13:51TimMcNamespace syntax is tricky to learn.
14:07TimMcdrguildo: You already made it past the require vs. :require stage, so that
14:07TimMc's pretty good. :-)
14:07TimMc,(ns foo.bar (:println hello))
14:07clojurebothello\n
14:09amalloyTimMc: wait what, since when is clojure.set not automatically required? i thought it was one of the big three, or big four or whatever, that are automatically loaded with clojure.core
14:09TimMcA couple versions ago, maybe?
14:09TimMcI *think* it was loaded along with the REPL.
14:12TimMcso it might have more to do with the version of lein?
14:14drguildoTimMc: so (:require foo bar) just executes (foo bar)?
14:14puredangerthe clojure.main repl refers a few things from clojure.repl, clojure.java.javadoc, and clojure.pprint and that hasn't changed in at least a few years
14:15puredangerhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L161-L165
14:16TimMcdrguildo: Nope, (:require foo bar) in the ns form results in a call to (require 'foo 'bar).
14:17justin_smithat the top level, it just returns bar
14:17TimMcYou're not *supposed* to put in things like :println because that's not at all a supported form -- I'm just demonstrating an implementation detail.
14:17puredangerjustin_smith: you might want to explain why :)
14:18drguildoahh. that's pretty neat.
14:19justin_smithany keyword used as a function invokes get, and the second arg acts as a default
14:19justin_smith,(:something :else :entirely)
14:19clojurebot:entirely
14:20TimMcOh, you're talking about accidentally using :require outside of an ns block, got it.
14:20TimMc,(:foo :bar :baz :quux)
14:20clojurebot#error{:cause "Wrong number of args passed to keyword: :foo", :via [{:type java.lang.IllegalArgumentException, :message "Wrong number of args passed to keyword: :foo", :at [clojure.lang.Keyword throwArity "Keyword.java" 97]}], :trace [[clojure.lang.Keyword throwArity "Keyword.java" 97] [clojure.lang.Keyword invoke "Keyword.java" 150] [sandbox$eval49 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compile...
14:20TimMcoops
14:20TimMc,(:foo :bar :baz)
14:20clojurebot:baz
14:21TimMcSorry, not at full brain today, didn't see justin_smith's demo.
14:21justin_smitha classic example of this is the accidental (:or nil :otherwise)
14:21justin_smithwhich even seems OK until the first arg is not nil, but doesn't contain otherwise
14:25TimMc,('+ 2 3)
14:25clojurebot3
14:29puredanger,('+ :banana 99)
14:29clojurebot99
14:29puredangerseems right
14:36hiredmanpuredanger: what does 1.7 being in beta mean in regards to patches being merged? I ask just because I had previously written off having a patch make it in to 1.7, but should I raise my hopes at all now that you've looked at clj-1399?
14:39hiredman(I ask only for the sake of my vanity)
14:51puredangeryou should not raise your hopes :)
14:51puredangerI'm prepping for 1.8 :)
14:51puredangerby pre-screening tickets
14:53moquistI just refactored my project to use com.stuartsierra.component, and I immediately ran into the issue caused by reloading protocol definitions in the REPL. I don't see a way to start my system (instantiating component/SystemMap) and reload my code without either losing or hosing the state of the started system.
14:54moquistThis discussion of reloading protocols (https://github.com/clojure/tools.namespace#warnings-for-protocols) says "don't leave old instances around", but that's precisely what I want to do, now that I'm using Component.
14:54moquistDoes anyone have any suggestions for me? I could just re-load my entire system each time, but that's certainly not ideal.
14:55irctcIs there a way to reference the threaded variable when using -> ?
14:55moquistIt's a tiny bit tempting to re-refactor Component back out, so that the state of my system isn't tied up with protocols, so I can reload code in my REPL without restarting the system. :/
14:56i-blis1irctc: you could capture it with a macro, what do you want to achieve
14:57irctci-blis1: for instance: (-> {:a [1 2 3]} (assoc :avga (let [r (:a ???)] (/ (apply + r) (count r)))))
14:57Duke-irctc: use as-> instead
14:57amalloymoquist: i don't think Component is about keeping your program running across reloads
14:57i-blis1(inc Duke-)
14:57lazybot⇒ 1
14:58amalloythe thing i remember from the Component talk is that Component is designed to *avoid* those problems, by making it easy to tear down your app and restart it
14:58irctc:Duke- cool. Thanks!
14:59amalloyDuke-, irctc: you don't have to use it "instead", you can use it in addition, which is kinda what it's for
14:59amalloy,(-> 10 (+ 5) (as-> x (/ x 3)))
14:59clojurebot5
14:59moquistamalloy: Ah! Maybe I should watch the/a talk, instead of just reading the docs. That's a helpful observation. Maybe what I should do is handle the 20-second part of system startup some other way.
15:00moquist(inc amalloy)
15:00lazybot⇒ 264
15:00irctc:amalloy very cool. thanks,
15:01hiredmanpuredanger: oooh 1.8
15:01moquistamalloy, irctc: Yes, very cool.
15:05TimMcNever 2.0, I'm guessing.
15:07irctc,(-> {:a [1 2 3]} (as-> x (assoc x :avg_a (let [r (:a x)] (/ (apply + r) (count r))))))
15:07clojurebot{:a [1 2 3], :avg_a 2}
15:09whodidthisdenormalization! alert
15:10sobel?
15:34TimMcNow `lein deploy` is yelling about not finding a connector: "Failed to deploy artifacts/metadata: No connector available to access repository snapshots (snapshots) of type default using the available factories FileRepositoryConnectorFactory, WagonRepositoryConnectorFactory"
15:35TimMcProject file for reference: https://github.com/timmc/johnny/blob/timmc-release-0.1/project.clj
15:36hiredmanthose repos should be pairs
15:36hiredman[[name map] [name map]] vs [[name map name map]]
15:36TimMcoy, thanks
15:36TimMcSo I probably could have deployed to releases. :-P
15:38irctc_I want to use a library from Javascript in a Clojurescript app, but the library uses JavaScript's "require' module, how can I leverage such libraries from within ClojureScript?
15:44puredangermight want to move to #clojurescript instead
15:49amalloycfleming: https://cursiveclojure.com/userguide/leiningen.html skips over the one step that i was looking for help with: what is meant by an SDK, and how i should pick one. the menu that appears contains zero items, and the + button just opens a Finder window
15:49amalloyit turns out that the Finder window is pointing at a JDK, and i can just hit Choose without navigating at all to get my default JDK, but at first i was like "argh what SDK does it want, how am i supposed to find one in this Finder window if i don't know what i'm looking for"
15:57mskoudAnyone got an example on using boot instead of leiningen to run a ring/compojure webserver?
16:12gfredericksam considering using `apt-get install leiningen` inside of docker as the cleanest option for getting lein; anybody do something different?
16:12gfrederickshaven't checked what version that gets me yet
16:12gfredericks(working on that now)
16:16gfredericks1.7.1; ouch
16:16gfredericksnevermind that I guess
16:19cflemingamalloy_: Thanks - someone else just wrote to me with similar feedback, along with many other documentation bugs. It's pretty out of date, I'm going to bring it up to date soon.
16:21cflemingdnolen: Find usages should work for invocations, but doesn't work for finding implementations yet.
16:21cflemingdnolen: Agreed that this would be very nice.
16:25sobelgfredericks: not only that, but it will use apt for all jar deps. wondering if the deb package maintainer is at all clear on the concept of leiningen.
16:25sobellong-story-short, ~/bin/lein
16:26sobel(i ended up walking away from the lein install when i tried it on my raspberrypi2)
16:26gfrederickssobel: like you do a `curl` in your dockerfile?
16:31oddcullygfredericks: according to github, curl seems to be the popular approach
16:40gfredericksI'm gonna try to convince hypirion to get an official thing on docker hub
16:41gfrederickswould be nice for versionability as well
16:41gfredericksI guess doing such a thing would require choosing a JRE as well :/
16:41gfrederickssooo....I guess we'd just bite the combinatorial explosion?
16:42amalloycfleming: i'm just getting used to apple stuff too, so maybe i am just confused about my keyboard, but the "unused import" popup claims i should hit Cmd-F1, where the key that actually seems to work is fn-F1 (ie, actually just F1, since the key without any modifiers does something to do with brightness)
16:43cflemingamalloy: You probably want to switch that in OSX, see System Preferences->Keyboard->Use F keys as standard function keys
16:44amalloycfleming: i'm not objecting to whether or not i have to hit Fn, i get that that's a keyboard preference/setting. what i'm saying is, it asks me to hit Cmd as well, but that actually doesn't work
16:44cflemingamalloy: Re: the keyboard problem, that's odd - it should prompt with the actual mapped keybinding
16:44cflemingamalloy: Let me check, one sec
16:46cflemingamalloy: So for me, Cmd-F1 pops up the information tooltip, and F1 pops up the doc for the symbol under the caret.
16:47cflemingamalloy: So Cmd-F1 should show you the tooltip without having to use the mouse to hover
16:48amalloyoh, i see. cfleming: i was under the impression that pressing this key combination was supposed to actually do something (eg, remove the import, like the analogous eclipse feature), not just add another line to the popup
16:48amalloyso the keybindings are correctly reported, but the key did something i didn't even notice
16:49cflemingamalloy: No - if your cursor is on the greyed import, you'll get the lightbulb popup on the left which means you have an intention you can perform there. Then you invoke it via alt-enter.
16:51twilesHey all, I'm working my way through https://github.com/omcljs/om/wiki/Basic-Tutorial, but I'm getting the error below when I try to add a :ref to the JS map after an input text box:
16:51twilesError: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a component that doesn't have an owner (that is, was not created inside of another component's `render` method). Try rendering this component inside of a new top-level component which will hold the ref.
16:51twilesAny tips?
16:58Moses_I'm trying to figure out how to use JavaScript libraries that are loaded via the "Require" module in Clojurescript
16:58Moses_Any advice?
16:59bensuMoses_: try asking in #clojurescript
17:02devnClojure Applied is quite good.
17:13bridgethillyerHear, hear. Clojure Applied is filled with all kinds of useful information
17:18gfredericksdoes it address databases at all?
17:18gfredericksthe ToC didn't seem to suggest so
17:18sobelgfredericks: i'm not quite there yet but i'm inclined to version lein with my code for bootstrapping, and generally stay current
17:23caternIs there a good, simple macro in core that I can show off? or what would be a good very simple example of macros?
17:23gfrederickssobel: does that suggest anything in particular about docker+lein?
17:23gfrederickscatern: -> and doto are pretty compelling
17:23gfredericksdoto especially can be compared with a lot of more repetitive java code
17:24caterngfredericks: wow, I didn't actually think I would get a meaningful answer to that question
17:24caternbut yeah that's a good example
17:24caternThis is from the perspective of *writing* the code, btw4
17:25caternokay, uh
17:25caternwhat is a good example of a use of -> or doto
17:25catern(functional style preferred so I guess -> is preferred)
17:25caternoh
17:25caternnvm, I'll check grimoire
17:27caternor, wait, what is the place that has a lot of examples?
17:27gfredericksI particularly like to contrast -> and doto with the fluent APIs in java
17:27caterngrimoire has no examples, it seems
17:29oddcullycatern: there are several examples for doto
17:29caternI'm primarily looking for ->>
17:47sdaltonhi clojurians, just started learning the language and am trying to create a ring app with compojure. app is running fine (very simple) but i can’t get my tests to pass when the request-method matches. I’m getting a java.lang.ClassCastException: clojure.lang.Cons cannot be cast to java.util.regex.Pattern
17:48sdaltonhttps://gist.github.com/scotdalton/a5302b5687b34ddf621b
17:49sdaltonhere’s the code. really any insights would be really appreciated. i’ve been staring at it for the past couple of hours and cannot figure it out.
17:51sobelgfredericks: not really. i would be happy to wget lein in Dockerfile or import it as a vendored part of my codebase
17:51sobelgfredericks: just...anything but apt/deb
17:57sdegutisIs it possible to programmatically scour through a subset of ClojureScript namespaces to get their public vars?
17:57hiredmanthere is nothing in that code that would do that, can you pastebin your entire stacktrace?
17:58hiredman(my guess would be something in the ring.mock.request library, but the stacktrace will show)
18:00sdaltonhiredman: thanks! here’s the stacktrace, http://pastebin.com/atFG6CH6
18:01sdaltonhiredman: the routes work in the repl with ring.mock.request which is confusing
18:03hiredmanhow are you running the tests? `lein test` ?
18:05hiredmanwhat version of compojure are you using?
18:06sdaltonhiredman: yeah, lein test. compojure 1.3.3
18:07hiredmanwhat does `lein deps :tree` say?
18:08sdaltonhiredman: http://pastebin.com/AQ61ZDqL
18:11hiredmanmaybe try running lein clean
18:11sdaltonhiredman: cool. thanks. will do. appreciate you taking a look.
18:15hiredmancompojure uses clout for routing stuff, and that error is coming out of the interface between the two
18:16hiredmanso my guess would be using incompatible versions of compojure and clout, but that seems unlikely and lein deps :tree would generally print a warning
18:16hiredmanso given the :gen-class in your namespace maybe you are aot compiling, which can do weird things, and lein clean might help
18:19amalloyhiredman: it looks like sdalton has left, but that stacktrace was coming from a totally different file: bigtalk.core-test rather than bigtalk.core
18:21amalloymy guess would be a form in bigtalk.core-test was accidentally (and incorrectly) using compojure's syntax for using specialized regexes for route params
18:23hiredmanamalloy: uh, the source to core-test is in the gist and it isn't doing that
18:24hiredman(but who knows, the error sames to bare no connection to anything so he may have shared the wrong source or something)
18:25amalloyoh, it is. i never look for a second file in a gist (and have my fonts large enough that it's not apparent without scrolling)
19:32tomjackI wonder if anyone's thought about cider-jump-to-var and boot?
19:33tomjack(if you have, you know my problem with it already, so I petition for an ~anyone exemption...)
20:33timvisheranyone have any tips on clojure 'workflow' libraries? https://github.com/relaynetwork/impresario is very close, but lacks some basic features like exception transitions, etc.
20:33timvisherbasically, i'm looking for a library that allows me to create a workflow that will happen asynchronously, recording it's progress in a db
20:34timvisheri think i could probably whip something together without _too_ much trouble using core.async but this feels like something that's probably already been written
20:38timvisheractually prismatic's graph might be something else that could come into play for this
22:03ADotld
22:13isaac_rkswhat is clojure's position on homosexuality
22:17brehaut_its fine with homogeneous and heterogenous collections; theres no intrinsic bias
22:24badfish129whats the best way to export environment variables on lein server or lein fig wheel without checking them into source control (can't be in project.clj)
22:33puredangerYou might look at the environ library
23:07TravistyThis probably isn’t the best place to ask, but does anyone know of a standard reference for hashing?
23:07TravistyI’d like to use hashes in place of a random number generator for certain computational reasons. Mostly I want to read about the concerns for that kind of application
23:11echo-areaI don't know if it could be counted as a reference or not, but there is a section in Effective Java talking about hashCode
23:11echo-areaAlso there is https://squarecog.wordpress.com/2011/02/20/hadoop-requires-stable-hashcode-implementations/
23:17crimeminister@Travisty not sure if this is helpful for your purposes, but folks looking for a refresher on the subject might appreciate this lecture:
23:17crimeministerhttp://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/video-lectures/lecture-7-hashing-hash-functions/
23:18Travistyecho-area: Cool, thanks for the reference :) I’ll check it to see if there is something useful :D
23:18Travistycrimeminister: I was watching that a bit earlier in the day :)
23:19crimeministerpsychic much? :)
23:19TravistySo, the actual problem I have is kind of interesting. I want to generate a random vector belonging to the unit sphere in n dimensions, where n is super huge. The only operation I’ll ever do with that vector is computer the inner product with a k-sparse vector
23:19TravistyMy hope is to use a hash function to be able to compute the i^th component of this random vector, rather than actually computing it and storing it
23:19TravistyI mean, storing the random direction vector in memory
23:21Travistyif I can use a hash to effectively generate uniform [0,1] random variables, then I think I can do this really quite efficiently :)