#clojure logs

2014-05-15

00:01dgleesonl1x: makes sense
00:01devnl1x: https://gist.github.com/anonymous/d4dad5ff47ae7e92f7a5
00:02devni've logged to make sure I'm hitting :started.
00:03ddellacostadevn: was just going to ask--so started definitely is happening, huh?
00:03devnif I inc pending in a different place, outside of the condp, right before i add the listener
00:03devneverything works
00:03devnbut it's just weird, and i can't figure out why the hell this would be happening
00:04devnit's like the atom is "warming up" or something
00:04devnbut then again, that might be the s3 transfer manager?
00:04devnit boots up its own thread pool
00:05devnoh no. im a terrible liar.
00:06devn:started apparently is not getting hit now on the first go-round
00:06devni wonder why that's the case...
00:08devnit's weird because i re-eval the ns, run a fn in the REPL, see that :started isn't hit. so then i was thinking well it must be something like the upload completed too quickly, but if I wait for awhile and do another, they forever after hit the :started event
00:08devnit's just after i re-eval, the very first upload, and no others
00:49arrdem,#inst
00:49clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
00:52amalloydevn: i speculate that the :started event never fires at all, on any events; you just get one :failed
00:54amalloytry doing some logging instead of, or in addition to, just munging a number around
00:55Raynesamalloy: I wrote the lein plugin.
00:55Raynesamalloy: You should try it.
01:25bjeanesman trying to write an oauth1 workflow for friend...
01:26bjeaneskeep spinning my wheel
01:26bjeaness
01:52ldshello
02:41TerranceWarrioris it possible to make a c++ interface to unrealengine from clojure?
02:51danielcomptonIs there a more efficient/idiomatic way to write https://gist.github.com/danielcompton/1c741fcac42424433943 ?
02:52danielcomptonI'm wanting the values of a map sorted by key, (map second) seems like a bit of a hack
03:00mangedanielcompton: would (map val) work better for you? (->> m (sort-by key) (map val)) seems like it would be clearest.
03:01mange,(->> {:c :d, :a :b} (sort-by key) (map val))
03:01clojurebot(:b :d)
03:02AimHereSo use 'val' instead of 'second'?
03:03mangeIt's pretty much the same thing, it just reads a bit more naturally, maybe.
03:07danielcomptonmange: Thanks, that's better
03:08danielcomptonBecause you're mapping over a MapEntry, not a vector so val works too?
03:09AimHereI probably should go back and do some more Rosalind problems sometime!
03:09bjeanesam I crazy or is `lein ring server` suppressing stdout?
03:09mangedanielcompton: Yeah, each of your seq elements is a MapEntry, so you can use key and val for readability.
03:11mangeActually, key and val should be slightly more performant, too, but probably not by too significant an amount.
03:16danielcomptonmange: because they're operating directly on the mapentry?
03:18mangeYeah. first/second call seq on their argument (if it's not already a seq), so that will have to do some work (allocation, in particular), whereas key/val just call .getKey/.getValue directly.
03:40Glenjaminyou can also use an actual sorted map
03:40Glenjamin,(into (sorted-map) {1 :a 3 :b 2 :c})
03:40clojurebot{1 :a, 2 :c, 3 :b}
03:41mangeHe's using frequencies, so he can't control the map type.
03:54DEA7THwhat is the typical way to do something with the numbers from 1 to 1000, use range (1 1001)? use some sort of a loop?
03:56numbertenwhat sort of thing?
03:57danielcomptonGlenjamin I thought about rewriting frequencies to use a sorted map, which would be faster?
03:57numbertenDEA7TH: (range 1001) gives you the numbers
03:58numbertenrather 1 1001
03:59numberteni think the typical way of using them varies on what you're using them for
03:59mangedanielcompton: sorted maps don't support transient/persistent! at the moment, so that might end up being slower than frequencies and sorting.
04:00danielcomptonWhat would be the best way to benchmark it? Criterium?
04:01amalloydanielcompton: a map sorted by its vals is, i believe, a priority queue
04:01amalloythere are implementation of those hanging around in clojure somewhere, i'm fairly sure
04:01mangeamalloy: he's looking to sort by key.
04:02amalloyoh, i see. isn't that just vals?
04:02amalloyin a sorted map?
04:02amalloyi see that's been covered too
04:04numbertenis there an idiomatic way to pass around a configuration structure?
04:04numbertenor rather to handle configuration
04:06danielcomptonamalloy, I was wanting to get the values from frequencies sorted by key and I'm trying to work out which would be faster, re implementing frequencies to use a sorted map, or converting the map after.
04:06dbaschdanielcompton: do you really need to optimize it?
04:06danielcomptondbasch not really,
04:07danielcomptondbasch I'm wanting to learn more about building performant clojure, so this seemed like a simple example
04:07DEA7THnumberten: I want to sum over some of the numbers from 1 to 1000
04:07dbaschdanielcompton: you may look into the option of using a java TreeMap
04:07DEA7THnumberten: Project Euler, problem 1. I'm learning Clojure
04:08DEA7TH(btw I know there's a better way to solve it)
04:08dbaschjust for completeness
04:08danielcomptondbasch Now we're talking
04:08danielcomptonIs criterium the best way to benchmark this?
04:09numbertenDEA7TH: folds/reductions are the go-to higher order function for taking a structures of values and turning them into a single value (sum)
04:10dbaschdanielcompton: I don’t know a better way than criterium
04:11dbaschdanielcompton: I did a similar comparison once when I was trying to build an inverted index. Persisten structures < transients < java hashmap in terms of performance
04:12danielcomptondbasch what was the order of performance between each? Order of magnitude each time?
04:12dbaschdanielcompton: no, it was the same order of magnitude
04:12dbaschusing a hashmap was maybe twice as fast as a persistent map
04:13dbaschbut it was a very specific case, not sure I’d generalize from that
04:18numbertenDEA7TH: I guess you could also use the fact that '+' takes an arbitrary number of arguments as well and just (apply + (range 1 1001))
04:19numbertenbut that doesn't abstract the problem really. and relies on implementation details in the function you're trying to apply to the collection
04:34danielcomptonHere's my early results https://gist.github.com/danielcompton/4b1a59054a40a89c19ec
04:36Glenjaminmange / danielcompton / amalloy - clojure.data.avl seems to be a decent sorted-map implementation that supports transients and other neat stuff
04:37Glenjaminand then depending on your use-case, you can use https://github.com/ztellman/immutable-int-map and then (reducers/fold) will give you multicore speedup
04:39numbertenis there a built in function for this: (foo {:a 1 :b 2} {:a 0 :b 0 :c 0}) => {:a 1 :b 2 :c 0}
04:39numbertenso update all values in map 2 from those given in map 1
04:39Glenjamin,(doc merge-with)
04:39clojurebot"([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
04:39numbertenmany thanks
04:40Glenjaminoh, in fact that's just (merge map-2 map-1)
04:41numberteneven simpler
04:59danielcomptonSo using a custom sorted-frequencies implementation is slightly faster https://gist.github.com/danielcompton/4b1a59054a40a89c19ec#file-dna-frequencies-the-second
04:59danielcomptonNow for the tree map
05:17DEA7THHow do I break this code into multiple lines: (reduce + (filter #(= 0 (* (mod % 3) (mod % 5))) (range 1000)))
05:17DEA7THI suppose that's too much for a single line?
05:19danielcomptonDEA7TH you can use a threading macro -> and ->> to break this up and make it more readable
05:19DEA7THmore generally, is there a way to split function arguments into multiple lines
05:20neenaDEA7TH: The function arguments can span multiple lines.
05:21danielcomptonDEA7TH https://www.refheap.com/85517
05:22DEA7TH->> reverses the order?
05:24quizdrWhat is the best clojure approach to connecting to a websockets? I see that both Jetty and http-kit can do this, but it would be an either-or choice, not the two in combination, right?
05:25neenaDEA7TH: It inserts the result of the previous form in the last position of each form.
05:27neenaDEA7TH: Also, you might want to use zero? instead of (= 0 ...)
05:27clgv,(macro-expand '(->> (range 100) (filter even?)))
05:27clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: macro-expand in this context, compiling:(NO_SOURCE_PATH:0:0)>
05:27clgv,(macroexpand '(->> (range 100) (filter even?)))
05:27clojurebot(filter even? (range 100))
05:27clgvDEA7TH: ^^
05:33pepijndevosI use gen-class to subclass a class with a main, how do I get that main to actually work?
05:33pepijndevos$ lein run -m neo4j.server
05:33pepijndevosException in thread "main" java.lang.Exception: Cannot find anything to run for: neo4j.server
05:42DEA7THehh, can I invoke a function which is declared in code below? it doesn't seem to work
05:43emlynpepijndevos: have you added a (defn -main [...] ...)? Also you don't need gen-class for lein run
05:43pepijndevosemlyn, I did not, but I just want to call super's main
05:45pbwquizdr: that's something I'd like to take a look at. AFAIK http-kit doesn't do https. Is that true? It would mean that for a general solution you need some other server element in the mix.
05:45emlynpepijndevos: not sure, but I think you'll have to add a -main and call that explicitly
05:45pepijndevosemlyn, how do I refer to the super's main?
05:46emlynpepijndevos: not done that before but I expect (super/-main ...)
05:46pepijndevosI tried :exposes-methods {main super-main}
05:46pepijndevosbut I get Unable to resolve symbol: super-main in this context
05:51emlynpepijndevos: I'm not sure, but if you can put a minimal example on refheap I can take a look
05:51pepijndevosthis is my current file https://www.refheap.com/85518
05:51quizdrpbw ah that's good to know.
05:52pepijndevosemlyn, it requires org.neo4j.app/neo4j-server "2.1.0-M01"
05:56pepijndevosWhat if I used a proxy and no gen-class. Just a main method that calls main on the proxy
06:00emlynpepijndevos: sorry I'm a bit out of my depth, not sure what to suggest...
06:00pepijndevoshmmm, ok thanks for thinking along :)
06:04pepijndevosI can't even figure out how to call the main of the proxy I made
06:05pepijndevosproxy creates an instance already it seams
06:10emlynpepijndevos: have you tried (proxy-super main) in the proxy?
06:11pepijndevosemlyn, I'm not even overriding main now
06:13pepijndevosthe problem is that I need to call a static method on an instance
06:13clgvpepijndevos: -main is a static method, there is no such thing as inheritance of static methods
06:13pepijndevos(. (Integer. 3) (parseInt "42", 10))
06:13clgvpepijndevos: you'll have to write your own main if you want to start that particular class
06:14pepijndevoswhat should that main look like?
06:15pepijndevosclgv, I have 2 versions: https://www.refheap.com/85518 https://www.refheap.com/85520
06:17clgvpepijndevos: well you will have to replicate whatever the super class does in its main
06:17pepijndevoswhat?! why?
06:17clgvpepijndevos: since its a static method
06:18pepijndevosso?
06:18clgvpepijndevos: you want to run it with your derived class right?
06:18pepijndevosyes
06:18clgvso actually you are trying to extens dome features of that CommunityNeoServer?
06:18clgv*extend
06:19pepijndevosno, just providing a different config
06:19pepijndevoshttp://components.neo4j.org/neo4j-server/milestone/apidocs/org/neo4j/server/CommunityBootstrapper.html
06:19pepijndevoslike this https://github.com/jexp/neo4j-in-memory-server/blob/master/src/main/java/org/neo4j/server/inmemory/InMemoryBootstrapper.java
06:19clgvpepijndevos: ok. so what exactly does that predefined main do and how would you use it in java?
06:20clgvforget the java. how would you use it?
06:20danielcomptonGlenjamin mange amalloy Here's the results https://gist.github.com/danielcompton/4b1a59054a40a89c19ec the TreeMap was 4-5 times faster than a map, sorted-map or avl
06:20pepijndevosI don't know... it starts the server. I just want to do what it did... start the server, but instead use my method to create the server instance.
06:21clgvpepijndevos: (CommunityNeoServer/-main "my" "args" ...) will run that main
06:21clgvpepijndevos: if you cant specify the actual server class via configuration that will not work
06:22pepijndevosI don't get it... why can't I subclass the bootstrapper, overwrite a method and call the inherited main?
06:22clgvpepijndevos: because static methods are not inherited
06:23clgvthey are just static. method of the class instead of methods of an object instance
06:23pepijndevosbut it is listed here as an inherited method http://components.neo4j.org/neo4j-server/milestone/apidocs/org/neo4j/server/CommunityBootstrapper.html
06:23clgvbut it is also listed as static
06:24clgvif they didnt change java 8 significantly there is no inheritance for static methods
06:25pepijndevosgrmph....
06:26pepijndevosahaha, main actually calls start
06:26pepijndevoshttp://grepcode.com/file/repo1.maven.org/maven2/org.neo4j.app/neo4j-server/1.7.2/org/neo4j/server/Bootstrapper.java#Bootstrapper.main%28java.lang.String[]%29
06:27clgvpepijndevos: he well, then you could have saved some time ;)
06:29pepijndevosaaaarg.... but my problem still exists
06:30pepijndevosorg.apache.commons.configuration.ConfigurationException: Cannot load a configuration from a directory
06:30clgvsounds like wrong parameter or something
06:31pepijndevosyea...
06:32pepijndevosi'm just not 100% certain where it's getting its config from, so I created that subclass to explicitly give it a config.
06:32pepijndevosbut it's still looking in the wrong places it seems
06:36pepijndevosanyway, thanks for the help
06:38martinklepschwhen I start a very long running function from the repl is there a way to put that in the background (kind of like detaching it from the repl)?
06:45Glenjaminyou can run it with (future)
06:47clgvmartinklepsch: yes, future is the way to go
06:48martinklepschso when I run (future (pmap ...)) on a remote repl and then disconnect it'll continue to run?
06:48martinklepschI also thought that future would work but I thought it might be bound the the repl session
06:50Glenjaminerm, you'll have no way to get the result value unless you (def) it i think
06:50Glenjaminbut it should probably keep running
06:51Glenjaminnot sure if GC would kick in
07:02clgvmartinklepsch: as Glenjamin said you need to bind that future to a variable otherwise its result will be lost
07:45martinklepschGlenjamin, clgv, if I bind that to a var and then end the repl session, wont that var be lost?
07:48clgvmartinklepsch: no, if the REPL process is not shotdown that will work
07:49clgv"shot down" :P
07:51martinklepschclgv, ok so if I start the remote repl using tools.nrepl.server I should be good to go I gues
07:51martinklepschthat's cool then. thanks!
07:51clgvit is also pretty easy to try ;)
08:06Glenjaminlein repl :headless
08:06Glenjaminlein repl :connect
08:06Glenjaminif you disconnect but leave the headless one running, you can acheive what you describe
08:09clgvGlenjamin: I think he is going to embed an nrepl in his application
08:10mskoudrunning a Clojure server this this project alias :aliases {"up" ["pdo" "cljsbuild" "auto" "dev," "ring" "server-headless"]}. But print does not show up on the console. Or rather, there are no repl, so no output. How can i start this with a repl?
08:14phillordIs there anyway to have Clojure generate a static data member -- I need a single, unchanging value which I can access as fast as possible -- In java, I'd use a static final public. Not sure how to replicate this in Clojure
08:15opqdonut(def +constant+ 17)
08:15opqdonutnow that :dynamic is no longer the default for vars, vars like that are pretty fast
08:16Bronsayou can use (def ^:const my-constant 23)
08:16Bronsathis way it will get inlined
08:16opqdonutoh right, there's that too
08:16opqdonutand a type hint is probably apropos if the value is an object
08:17phillordI'm finding about a 4x difference between accessing a static final in java and accessing a var
08:18opqdonutdid you try :const?
08:18phillordworking on that
08:18phillordbenchmarks take a while:-)
08:19opqdonutand if you're doing something _with_ the value, type hints will help. a java field is typed so there's no reflection going on as opposed to the value of a var
08:19phillordok, will test both of these
08:20opqdonutare you using *warn-on-reflection* btw?
08:20opqdonutif you're optimizing clojure code it's the first thing to do
08:26phillordcuriously, :const causes an AbstractMethodError -- rather unexpected
08:26clgvphillord: ^:const is the way to go here ^^
08:31phillordah, okay, so worked out the abstract method error -- not quite sure how ^:const is working, but it calls "count" on the object and I haven't implemented it, hence the abstract method error.
08:32phillordwhich is a bit worrying because I wonder what it is going to inline -- well I guess I need to read the compiler code to find out
08:36justin_smithphillord: :const only works for primitive types
08:37justin_smithnot objects
08:39phillordreally?
08:40phillordI'm struggling to find the documentation for :const
08:52clgvphillord: http://clojure-doc.org/articles/language/namespaces.html#constant-vars
08:52clgvnot much there though
08:58phillordno, that doesn't describe anything at all! Well, if all else fails, write some code and decompile it!
09:02clgvphillord: usually you get a "can not embed in code" exception when you specify :const for the wrong value
09:04phillordI am guessing it works with lists and such like
09:05phillordyep -- so lists get inlined to a specific implementation
09:05phillordpublic final class core$const_string_list extends AFunction
09:05phillord{
09:05phillord public static final AFn const__0;
09:05phillord
09:05phillord static {
09:05phillord const__0 = (AFn)RT.vector(new Object[] { "const-list-elem" });
09:05phillord }
09:05phillord
09:05phillord public Object invoke() {
09:05phillord return core$const_string_list.const__0;
09:05phillord }
09:05phillord}
09:06phillordokay, well, now I know how it works anyway! Not what I need, unfortunately
09:09Bronsaphillord: next time use a pastebin please
09:10phillordrealised that after I had done it
09:10beamsohas anyone done the basic om tutorial lately?
09:11beamsowhen rendering the first list, i was expecting a ul with 4 li childen. i'm getting a ul with the single child
09:11clgvphillord: it works for clojure values that have literal representations I guess
09:12phillordyep, but it doesn't preserve type, it would appear -- it's using a vector above, but in clojure it's a list
09:12Bronsaphillord: I'm curious btw, what decompiler did you use?
09:12phillordprocyon
09:12phillordhttps://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler
09:13phillordI've run it over clojure.core and my own library (tawny.owl) and it does both just fine. I haven't found anyother which doesn't crash
09:13phillordI should write a lein plugin at some point, come to think of it
09:14Bronsaphillord: hmm, really? we were just talking about it a few weeks ago, clojure produces some bytecode that's not possible to translate to java
09:15BronsaI guess I'll try and see how it deals with that
09:15phillordOh, it's possible to translate into Java just fine
09:15phillordit just wont run correctly
09:16phillordit's not the bytecodes anyway -- Clojure pushes locals onto the stack, then deletes the locals, then pops their values of the stack
09:17phillordthere's no way to access the stack in Java, which is why it doesn't work. But if you just want to read the Java, rather than the javap byte code translator, it's fine.
09:19clgvphillord: you can use luyten as procyon frontend
09:19clgvthough the latest and best has no release last time I checked
09:20phillordmore interested in just producing a dump of Java files, to be honest -- it's what I normally do
09:59quizdris it possible to provide a defaults map for nested map destructuring? For example, I get nil for this: (let [{{g :a h :b} :hhh :or {g 666 h 777}} m] [h]) -- assume map "m" does not have a key :hhh
10:02justin_smith,(let [{{g :a h :b :or {g 666 h 777}} :hhh } {}] [h]) quizdr
10:02clojurebot[777]
10:02justin_smithyou just need to put the :or in the right place
10:02quizdrah, the :or goes on the same "level" as the variable you are defining
10:02justin_smiththe binding of :h parallel to :hhh is not the same as the one inside it
10:03justin_smithbecause having both keys present would be valid, and you need to be able to bind either
10:03quizdrright, got it
10:03quizdr(inc justin_smith)
10:03lazybot⇒ 43
10:03justin_smithalso, pedantry, it's not a "variable" :) it's a binding
10:03quizdri knew that as I was typing it, but couldn't remember the proper term.
10:03quizdrwas hoping no one would notice, but I should know better than to expect that in this room :)
10:04justin_smithnp, like I said, it's a pedantic point, but the more we use the right terms, the less often people try to do things like use def to update values inside a let :)
10:04quizdrnow, to be fair, I've seen many cases of top level lets having defn or def, so that many functions could share the same closure.
10:04quizdrwhat do you think?
10:05quizdr(let [...] (defn ...) (defn ...) etc...)
10:05justin_smithquizdr: that's usually a sign someone has scheme experience
10:06justin_smithclojure's community tends to be fairly anti-information-hiding
10:06quizdrit's quite nifty, also helpful to put defn inside a macro to create many named functions based on certain runtime details
10:06justin_smithit's possible, and in those cases you are actually messing with variables
10:07justin_smiththe distinction I was trying to make was bindings vs. vars
10:07trap_exitwhat is the down side of using _keyword arguments_ for all functions?
10:07justin_smithtrap_exit: they don't compose as well as opts maps do
10:07trap_exiti.e. instead of (defn foo [cat dog blah] ... ) we do (defn foo [{:keys cat dog blah}] ... ) ?
10:07quizdrjustin_smith understand
10:07trap_exitjustin_smith: can you explain in more detail?
10:07trap_exitjustin_smith: how do they not compose ?
10:08justin_smithoh, that is an opts map
10:08trap_exitoh sorry
10:08trap_exitI am confusing terms.
10:08justin_smithI thought you meant the [& {:keys [...]}] thing
10:08trap_exitWhat is the downside of using opts maps for everything?
10:09quizdrtrap_exit are you asking the downside versus say variable arity to define "optional" parameters?
10:09justin_smithtrap_exit: some extra gc churn, and less clarity about missing args at runtime (nils instead of wrong arg count error)
10:09justin_smithalso you end up with a bunch of calls to merge replacing partial
10:10justin_smithI think it's a little uglier too
10:10justin_smithalso, it prevents the arg-count polymorphism that clojure would do for you otherwise
10:11pbwIf I have a function that produces an infinite lazy seq from an integer argument - (repeat n) for example, and a vector of integers, say (def ints [1 2 3]), how can I create a corresponding vector of references to the lazy seqs?
10:11quizdrjustin_smith do you generally advocate multiple aririty instead unless a specific reason exists?
10:11trap_exitquizdr, justin_smith: no, not about optinal arguments
10:11trap_exitI mean for all arguments, I don't want to do [arg1-name arg2-name arg3-name] ...
10:11trap_exitand instead do {:arg1-name ... :arg2-name ... .:arg3-name ... }
10:11justin_smithtrap_exit: understood - just saying that this eliminates the helpfulness of multiple arity overloading
10:11trap_exitbasically to force myself to remember the names of arguments instead of the order
10:12trap_exitjustin_smith: hmm, I've actually never used that feature
10:12trap_exitjustin_smith: but now that you mention it, I suddenly find it useful
10:12trap_exiti.e. a helper "iterative" version of a function togerhe with the real function
10:12trap_exiti.e. (reverse lst) (reverse lst iter-results) ... rather than reverse + reverse-helper
10:12trap_exitcemerick : !
10:12justin_smithit is often used for the (recur) using impl, or for optional arguments
10:13quizdrtrap_exit no need to remember the name or order of args if your code editor shows you the format of the function arguments as you right them (i.e. emacs typically does)
10:13trap_exitquizdr: true
10:14justin_smithquizdr: now if emacs showed you the arg destructuring, it would make an args map at least as convenient I guess
10:15justin_smiththough you probably do not want to be using args maps inside tight loops
10:16peterdon`,(#(case % 1 true false) 1) ; is it possible to prevent magic numbers in a case form?
10:16clojurebottrue
10:16peterdon`I would like to write something like (#(case % any-constant-symbol-with-value-1 true false) 1)
10:17quizdrjustin_smith yes, hence why one would not have that advantage over the other
10:22justin_smithpeterdon`: if it was :const I could imagine that being possible - dunno if it is currently supported though
10:23peterdon`I tried this: (def ^:const any-constant-symbol-with-value-1 1)
10:23peterdon`..doesn't work'
10:24justin_smith,(do (def ^:const x 44) (case 44 x true false))
10:24clojurebotfalse
10:24justin_smithpeterdon`: I think the trick is that at the time that case is compiled the value must be bound
10:26peterdon`justin_smith: it looks like there are no real constants in Clojure
10:27justin_smithpeterdon`: no, not quite I don't think - I just tried my above without the ^:const and it still worked - it's just that the value has to be resolvable at compile time I think
10:27peterdon`justin_smith: I would assume that the result is true
10:28justin_smithoh crap, there's that too :)
10:28justin_smith,(do (def ^:const x 44) (case 'x x true false))
10:28clojurebottrue
10:29justin_smithhaha, it is just matching on the symbol x
10:29justin_smithdon't mind me...
10:29cbpis const actually documented anywhere
10:30cbpit's not in here http://clojure.org/special_forms#def
10:32phillordI looked for :const documentation earlier -- couldn't find it
10:35justin_smithphillord: consider that (defmacro +my-magic-number+ [] 42) causes calls to (+my-magic-number+) to be resolved at compile time
10:36justin_smithit's a hack, but it does do the right thing (except I think case needs resolution at read time, which is hard / weird)
10:38peterdon`so I should probably use cond instead of case
10:39clgvpeterdon`: case needs compile time constants. symbols are not resolved
10:40agarman,(do (def ^:const x 44) (case x 44 true false))
10:40clojurebottrue
10:40agarmannvm me
10:42cbpah so :const removes the call to getRawRoot
10:42agarmanyes
10:43cbp,(do (def ^:const x 1) (defn foo [] (inc x)) (print (foo)) (def x 2) (print (foo) x))
10:43clojurebot22 2
10:45justin_smith,(do (def ^:const x 1) (defn foo [] (inc x)) (println (foo)) (def x 2) (println (foo) x)) slightly clearer imho
10:45clojurebot2\n2 2\n
10:46justin_smithcbp: so what happens there is the new def replaces the old one for new resolution, but foo still sees the old x
10:47justin_smithcorrect?
10:47cbpyes
10:50martinkl_is there some convention in naming lazy/non-lazy things?
10:51waynrmartinkl_: don't know off top of my head but you might find an answer here https://github.com/bbatsov/clojure-style-guide
11:01stuartsierramartinkl_: In Clojure itself, there is no convertion, but in general anything that *can* be lazy *is* lazy.
11:07phillordthere is an anti convention -- anything with "do" is not lazy:-)
11:13phillordSo, consider this code -- http://pastebin.com/1Zmf8iSH -- In my hands, the former is 4x faster than the later
11:14phillordNow, I could achieve parity here by creating a dump piece of Java code with a static final data member and I'd be away
11:15phillordbut I don't *think* I can do this in Clojure
11:17clgvphillord: well call of a static property versus a variable deref. try (let [o System/out] (bench o)) ;)
11:18justin_smiththe solution: define everything inside a giant let block!
11:18phillordexactly, that would work well
11:19justin_smithof course this would cause annoyance if you wanted to change bindings at runtime - but then they shouldn't be const, should they
11:19clgvphillord: is system/out really a proper example for the kind of constants you want?
11:20cbpprintln is too slow for us!
11:20phillordexample no, it's just a handy static final constant in Java
11:21phillordI presume that it gets inlined at JIT so returning System/out is about as fast as it gets
11:22phillordexemplar in the sense that yes it's something without a necessary read syntax -- I can't just inline at compile time
11:22phillordand :const doesn't work for that reason and for another
11:23phillordit's not that important -- after all, what's a few nanoseconds between friends...
11:26clgvphillord: I mostly needed constants for numbers and such which worked well with ^:const
11:35phillordIn my case, I need it for an empty data structure -- and I am at a disadvantage, because clojure.core cheats:-)
11:36phillordah well, I will worry about it tomorrow!
11:41xcthulhuHey! I was wondering if anyone has had any experience with using trapperkeeper and compojure, and could give me some advice about which to use?
11:44vilmibmxcthulhu: they work together.
11:44vilmibmif that's what you want.
11:44xcthulhuOh, sweet
11:45xcthulhuI’ll just use compojure then until my app gets complicated enough to need trapperkeeper
11:45vilmibmyou can make a compojure app and then use (add-ring-handler) to register it :)
11:45vilmibmsure. on its own trapperkeeper is just the service framework + some high level services
11:46vilmibmyou definitely want something like compojure to actually create your routes, and then use add-ring-handler to hang them off a context path (which might just be "/")
12:03{blake}OK, I have a collection of (a (b c) (c b)) (b (a c) (c a)), etc., and I want to turn this into ((a b c)(a c b)(b a c)(b c a)...(etc). I know there's an easy way to do this but I've forgotten what it is.
12:04ssiderisyou mean flatten?
12:04justin_smithdefinitely not flatten
12:04{blake}No. Take the first element and concat it with the nested collections.
12:05{blake}I thought there was an easy way to do it. I mean, like, a built-in function.
12:05{blake}Or a slight variant on a built-in. But i guess that describes nearly everything in Clojure.
12:06justin_smith,(for [[prefix & suffixes] '((a (b c) (c b)) (b (a c) (c a))) suffix suffixes] (conj suffix prefix))
12:06clojurebot((a b c) (a c b) (b a c) (b c a))
12:07ssiderisoh ok
12:07{blake}justin_smith: I was trying to avoid "for". =P
12:08justin_smith{blake}: maybe there is something awesome in a lib like flatland/usefull
12:08{blake}(I'm doing a permutations thing and "haven't learned" for yet. So if I can use "for" my solution doesn't make sense.)
12:08justin_smithbut if you don't find it, there is that
12:09justin_smitha for can be translated into nested maps
12:09hiredmanmapcats
12:09justin_smithoh, yeah, right :)
12:09{blake}justin_smith: Ah!!! Yeah...that's what I gotta grasp.
12:10{blake}mapcat...
12:10{blake}Two collections? First and rest?
12:11justin_smith(mapcat (fn [[p & s]] (map #(conj % p) s)) '((a (b c) (c b)) (b (a c) (c a)))) the translation
12:11justin_smith,(mapcat (fn [[p & s]] (map #(conj % p) s)) '((a (b c) (c b)) (b (a c) (c a)))) oops
12:11clojurebot((a b c) (a c b) (b a c) (b c a))
12:13CookedGryphonSo I just upgraded to the latest core.async, and I've found a *load* of places where I hadn't actually imported <!.... but it was working anyway without any errors or issues at runtime
12:13CookedGryphonwhat's that about?
12:13CookedGryphon(and the newest core.async correctly reports them as errors where it didn't before)
12:13justin_smithCookedGryphon: maybe because of the way the go macro expands what is inside it?
12:13justin_smithit does some complex stuff
12:14CookedGryphonmust be, but I'm sure I saw some errors where I hadn't imported it before...
12:14{blake}Thanks, guys!
12:15ghadishaybanCookedGryphon: latest core.async relies on a different analyzer and gives better error reporting in general (line numbers, etc)
12:16CookedGryphonyeah, i get that, but what was going on before to make it work at all, and why wasn't it causing any other issues
12:17ghadishaybanlots of magic
12:18ghadishaybanwe used to treat <! >! exceptionally
12:19ghadishaybandnolen_: i have basic feature expressions working on CLJ side with a *read-suppress* thing for unreadable forms.
12:19ghadishaybandnolen_: working on updating r0man's cljs patch to do the same
12:20dnolen_ghadishayban: cool!
12:20CookedGryphonghadishayban: fair enough, it's nice to have decent error messages back. Turns out I wasn't recuring from a tail position in about 80% of cases...
12:21ssideriswow, does that mean that features are coming soon?
12:22ssiderisalthough cljx is much better than it used to be
12:23ghadishaybanssideris: i'll be put it in JIRA and the rest is up to the process
12:24CookedGryphonis this going to be a cljs only thing? Or more general. For example I am currently using cljx to compile alternative function versions for jvm java vs android vs clojurescript
12:24ghadishaybanseems like discussion about approaches hasn't been terribly active lately, so I'll take the path of least resistance
12:25ghadishaybanintegrated into the reader (both CLJ + CLJS, maybe tools.reader), basically duplicating Common Lisp feature exprs
12:26CookedGryphonsounds good, will the features be pre-defined, or arbitrary? If so, how do you select which features to include
12:26ghadishaybanpatch looks like #+clojure :foo #+clojurescript :foojs
12:26ghadishaybanenvironment will bind a set
12:27CookedGryphonsounds perfect, and like it would be a drop in replacement for cljx more or less (if you're not using the function transformation feature)
12:28ghadishaybanr0man did all the heavy lifting, just added handling of forms like #+clojurescript #js {:what :ever} not bombing when read in an env not supporting the tagged literals
12:38CookedGryphonis there a way to do global dependency excludes?
12:39CookedGryphoni.e. almost all my libraries depend on some version of clojure or other, but clojure-android depends on clojure-jb instead
12:39CookedGryphonhow do i stop the other things bringing in their own version without putting an exclude on each of them
12:42CookedGryphonnever mind, found it, just :exclusions at the top level
12:44ampharmex<ampharmex> here is a challenge I devised: given 7 9 8 7 6 5 4 3 2 5 6 7 3 4 2 4 5 8 7 = 476 Goal: find out what mathematical operators (minus, multiply, divide, add) satisfy that solution (476)
12:44ampharmex<ampharmex> Order of operation is variable.
12:44ampharmex<ampharmex> 4^18 * 18! is a non optimal approach.
12:44ampharmex<ampharmex> Some example output:
12:44ampharmex<ampharmex> (7 + (9 + (8 + (7 + (6 + (5 + (4 + (3 + (2 + (5 + (6 + (7 + (3 - (4 + (2 * (4 * (5 - (8 * 7)))))))))))))))))) = 476
12:44ampharmex<ampharmex> A dynamic programming approach may suffice.
12:44ampharmex<ampharmex> e.g dp[i][j][k] = Can I make the number k using the numbers a[i ... j].
12:45technomancyampharmex: use a for comprehension to express every possible combination plus a :when clause for what it needs to evaluate to, then just take the first element of that seq
12:46ampharmextechnomancy, If I want to make X with the numbers A[i ... j], then I find a position v such that A[i ... v - 1] can make Y, A[v ... j] can make Y', and either Y + Y', Y * Y', Y - Y', or Y / Y' is equal to X.
12:46ihodestechnomancy: hmm, that's pretty complex… just with + - / * you get a quarter of a trillion things to try, no?
12:47ihodeswith that particular sequence
12:47technomancyihodes: I was thinking of how to do it in a one-liner =)
12:48ampharmexThat is how you compute A[i][j][X].
12:48technomancymaybe mapreduce it over a cluster if you need an answer promptly, you know
12:48ampharmexIf you want to find some sequence that does, then in A[i][j][X] you store the position at which you split (v) and the operator you chose.
12:49ampharmex_Every_ expression that you can form using the numbers in A[i ... j] is of the form (Y) op (Y'), where Y is an expression obtained from A[i ... v - 1], Y' is an expression obtained from A[v ... j], and op is either +, -, *, or /.
12:49ampharmexIf I'm trying to find several, I'll store the several v, but that (since the number of answers is already exponential) will be exponential in space and time. :)
12:53eraserhdIs there a persistent vector-like collection that has a decent `splice`? e.g. insert-element(s) / remove-element(s)
12:54eraserhd"decent" meaning sub-linear.
12:55BobSchackeraserhd I think this is what you want https://github.com/clojure/core.rrb-vector
12:56justin_smitheraserhd: some kind of persistent redblack tree?
12:56justin_smithBobSchack: jynx, and you actually had the sauce
12:56justin_smith(inc BobSchack)
12:56lazybot⇒ 1
12:56BobSchackwooo!
12:56eraserhdBobSchack, justin_smith: Thanks!
12:57ampharmextechnomancy, a 1 liner? :o
13:03technomancyampharmex: (first (for [ops (permutations [+ - * /] (count numbers)) :when (= x (reduce (fn [v [n o]] (o v n)) 0 (map vector numbers ops)))] ops))
13:03ampharmextechnomancy, does it work?
13:03technomancyno
13:04technomancybut something a lot like it probably would
13:04technomancyyou have to get permutations from a contrib lib or something; dunno if that's cheating
13:04bjeaneswrote first clojure in like 8 months
13:04bjeanesman i miss it
13:05technomancybjeanes: oh, what'd you write?
13:05bjeanesa half-functional OAuth1 workflow for Friend
13:06bjeanesbecause Trello does OAuth1 (but very very very badly)
13:06technomancycool
13:06bjeanesit's half-functional because Trello doesn't look at or even care if you signed your messages
13:06bjeanesbecause... computers.
13:07ampharmextechnomancy, is it a dynamic programming solution?
13:08ampharmextechnomancy, have you tested it?
13:08technomancyampharmex: not sure what the strict definition is. it just defines the search space using a lazy seq and picks the first matching element.
13:08technomancyI haven't tested it or seen whether it even compiles
13:09ampharmextechnomancy, dp[i][j][k] = Can I make the number k using the numbers a[i ... j].
13:09ampharmextechnomancy, The code is the usual dynamic programming solution, with a range of [-500, 1000]
13:28Glenjaminbjeanes: that sounds crazy, did you report it to them?
13:29bjeanesi tweeted at them last night
13:29bjeanesbut i found this out at like 1am
13:29bjeanesso i went to bed roughly exactly after that in case I was insane
13:29Glenjaminheh
13:30bjeanesreally their API is *not* OAuth... they just use part of OAuth1 to send you a token back
13:30Glenjamini've done oauth1 via clj-oauth, but not with friend
13:30bjeanesthen you just use your app key and their raw token in the query string
13:30Glenjaminah
13:30bjeanesand boom authenticated
13:30bjeanesGlenjamin: yeah I am using clj-oauth internally
13:32bjeanesI never needed to use https://github.com/mattrepl/clj-oauth/blob/master/src/oauth/client.clj#L77 to authenticate against Trello
13:32bjeanes#lol
13:37technomancy"OAuth-inspired API product"
13:40TimMc"Inspired by a true API"
13:40TimMc"Made with real OAuth"
13:41stompyj“Now with extra OAuth"
13:41bjeaneshah
13:41bjeanestheir api has made more than a few questionable decisions
13:41technomancyI was thinking along the lines of "cheese-inspired food product"
13:41bjeaneswell... the api didn't make the decisions
13:42bjeanestechnomancy: now I really want a grilled cheese sandwich. thanks.
13:42TimMccheese-food-product
13:42Glenjaminbjeanes: as i understand it, the web ui only interacts via the api
13:43Glenjaminand they keep back-compat
13:44TimMcI can't believe I used to eat Kraft singles.
13:44bjeanesI believe that is the case. Web UI powered by API is a good way to dog food I guess
13:44bjeanesit also means that their API allows auth with sessions
13:44bjeaneswhich *is* questionable
13:44TimMc(Note the entire lack of the word "cheese" in the branding.)
13:45justin_smithTimMc: "cheese food product"
13:46justin_smithkind of like how php is a "language interpreter program" - just calling it a language would be giving it too much credit
13:47bjeanesaren't all interpreters language interpreter programs?
13:47gtrakjava is a DSL for turning XML into stacktraces.
13:48justin_smithbjeanes: well there are defined languages as such, I guess how defined they are can be a little fuzzy
13:49arrdemgtrak: haha
13:50justin_smithbjeanes: the interpreter for php is basically a bunch of imperative steps that run as they read tokens from the file, there is no parser or grammar or whatever (theoretically there is one, but it is complected with the execution)
13:50justin_smithbjeanes: anywya, I was mostly just making a joke
13:50bjeanesheh
14:10bridgethillyerI have a question from the book Clojure Programming. In Chapter 3 on Collections, there is this note:
14:11bridgethillyer“NOTE: Your own functions will get this behavior for free if you are building them on top of others’ sequence functions. If you use lazy-seq then it is your responsibility to call seq on your arguments to maintain this convenient characteristic of seq.”
14:12bridgethillyerI think I’m having a reading comprehension problem
14:12bridgethillyerDoes this mean I have to call seq on things I’m passing to lazy-seq?
14:13Jaoodbridgethillyer: it means some functions calls seq on their arguments
14:14Jaoodbridgethillyer: and return a lazy-seq for you
14:14technomancyneeding to call lazy-seq directly is *extremely* rare
14:14technomancyI'm surprised it's mentioned that early in the book
14:15bridgethillyerWell, it’s a “Note,” so it’s not central to the point there
14:15Jaoodbridgethillyer: take a HoF like map for example, it will call seq on the automatically for you
14:16Jaood*on the collection
14:16llasrambridgethillyer: What's the "this behavior" the note refers to?
14:16Jaoodthat's what you get for free I guess
14:17bridgethillyerjaood: That makes sense. I can see in the map implementation where it calls seq on the coll argument
14:19bridgethillyerllasram: The behavior is basically what jaood just described - some functions call seq on their arguments, so that, for example, you can use a String with map
14:19ambrosebsBronsa: how do I get the line/col number of the left hand side of a :let binding?
14:21Bronsaambrosebs: you mean line/col of (let [>this< init] ..) ?
14:21ambrosebsyes
14:21ambrosebsa :binding rather
14:21Bronsauhm it should be in :env as always
14:22arrdemyeah if it exists should be in env... doesn't look like :binding has an associated meta.
14:22ambrosebsok, seems like a :binding inherits the same coordinates as the :let
14:22arrdemBronsa: silly patches incoming, I noticed some English typos in reading t.a
14:23arrdemambrosebs: yep, that's the intended behavior
14:23bridgethillyerI’m still confused about what the Note is telling me to do when I call lazy-seq (which I would rarely do - thanks technomancy)
14:23Bronsaarrdem: ouch
14:24Bronsaambrosebs: you mean it has the same line/column info of the outer let expression? that shouldn't be the case
14:24arrdemBronsa: shrug. it's like two typos. no big deal.
14:24ambrosebsBronsa: ok, I'll play a little more.
14:25amalloybridgethillyer: what behavior is the book saying you'll get for free? it's hard to answer otherwise
14:25Bronsaambrosebs: I'm assuming the form is read by tools.reader btw, no idea what happens with line/column info when read from the repl
14:25arrdemBronsa: do you have a favorite way to play with t.a trees? I'm using folding and a 10kline clojure mode buffer atm and while it works it's a bit of a mess.
14:26bridgethillyerThe behavior it refers to (if I’m reading it correctly) is that some functions call seq on their arguments, so that, for example, you can use a String with map
14:26Bronsaarrdem: I've got `:injections [(set! *print-level* 10) (set! *print-length* 10)]` in my profiles.clj.
14:26amalloyi think you can completely ignore that note. you'd have to try very hard to *not* do what it seems to be suggesting
14:27Bronsaarrdem: then I just (-> ast :node :inner-node whatever ..) to explore it
14:27bridgethillyeramalloy: Ok, thanks. That’s my gut read of it. I just thought there might be something I was missing.
14:28amalloyyou can always ask cemerick. clojure programming is his, right?
14:29bridgethillyerGood point. Ask for some book support.
14:29ambrosebsBronsa: ah no not using tools.reader here.
14:29cemerickbridgethillyer: feel free to shoot me an email
14:30arrdemBronsa: setting print bounds is a good idea... I wound up hacking the print-method of atoms so that I can actually pprint the entire tree without killing Cider
14:30bridgethillyercemerick: will do
14:30cemerickbridgethillyer: hi, BTW :-)
14:30bridgethillyercemerick: hi back at you
14:32Bronsaarrdem: yeah, I remembered about print-level/length only after killing slime/emacs one too many times
14:34Bronsaambrosebs: that's probably it. the source-info pass just tries to find line/column info on the :form's meta or defaults to the outer node info
14:34ambrosebsBronsa: I was trying to avoid creating a file to test this stuff out of laziness.
14:36Bronsa,(-> '(let [a 1]) second first meta)
14:36clojurebotnil
14:36ambrosebsBronsa: works perfectly with t.reader
14:36ambrosebsthans
14:36ambrosebsthanks
14:38ambrosebsI'm spitting out a map of file coordinates to types.
14:38ambrosebsworks great
14:38Bronsaambrosebs: you can use (comp t.r/read-string t.r.rt/indexing-push-back-reader print-str) if you don't want to use a fileI guess
14:38ambrosebsBronsa: sweet, hoping you had a snippet.
14:40sdegutisIs there an alternative to doing (#'my-function) in order for changes made while my server is running to take effect without restarting it?
14:41amalloyBronsa: i've never had to use print-level/print-depth in slime: C-c C-c generally succeeds in aborting an overlarge print, i think
14:41sdegutisI'm storing the functions in a map and storing the map in a var using alter-var-root. This is the root of all my problems.
14:42Bronsaamalloy: belive me, I panic C-c C-c'ed like a mad man when it happened
14:42amalloyhahaha
14:43ambrosebsBronsa: gives me UnsupportedOperationException count not supported on this type: IndexingPushbackReader clojure.lang.RT.countFrom (RT.java:556)
14:43Bronsaamalloy: the only thing that worked was killing the jvm, waiting for slime to print all of it and then M-x slime-repl-clear-buffer
14:43Bronsaambrosebs: well I didn't try it :) one sec
14:44ambrosebsBronsa: oh should be tr/read ?
14:44Bronsa... yeah sorry
14:44srrubyHow do I sort a vector of vectors of numbers: [ [ 3 2 1] [ 3 0 2] [3 1 2] ---> [ [ 3 0 2] [ 3 1 2] [ 3 2 1]] ?
14:45Bronsauser=> (-> ((comp t.r/read t.r.rt/indexing-push-back-reader print-str) '(let [a 1])) second first meta)
14:45Bronsa{:end-column 9, :end-line 1, :column 7, :line 1}
14:45Bronsaambrosebs: yep ^
14:45ambrosebsBronsa: I tried core/read which confused me further :)
14:45ambrosebsnice!
14:46dbaschsrruby: do you want to sort them as if they represented decimal numbers?
14:47srruby dbash: No. I want a multi-level sort. First level by first item, etc
14:47dbaschsrruby: so essentially yes :)
14:47srrubydbasch: OK. :)
14:48dbaschsrruby: one easy way: create a function to-decimal like this
14:48amalloyaren't vectors comparable to each other? you should just be able to call sort
14:48llasramYeah
14:48llasram,(sort [ [ 3 2 1] [ 3 0 2] [3 1 2]])
14:48clojurebot([3 0 2] [3 1 2] [3 2 1])
14:49llasramNot sure what the problem is?
14:49amalloyit won't work if you have lists instead, or if your vectors aren't all the same length
14:49llasramThere is some (IMHO) weirdness that they sort by length first
14:49srrubyThanks all!
14:49sdegutisIs this going to be a negative performance hit?
14:49sdegutisOr in some other way will it be very dangerous?
14:50dbaschsrruby: yeah, if they are all the same length you’re set
14:50sdegutisI am doing this: {:delete #'my-delete, :create #'my-create, :read #'my-read} and then later I do ((:create my-map) arg1 arg2).
14:51sdegutisThis way when I reload the web server, it sees my changes.
14:51srrubydbasch: What threw me is that I tried (sort > [ [ 3 2 1] [ 3 0 2] [3 1 2]]) and I got an error
14:51dbaschthey are not numbers
14:52dbaschsrruby: let sort use compare instead of providing a function
14:52amalloyright, if you wanted to sort them in backwards order (ie, the order > would use), you can use (comp - compare)
14:52amalloysince compare is the default comparator, and if you negate it you get the opposite ordering
14:53sdegutisI want to stop storing them in a map, but they represent a third party service (i.e. Stripe).
14:53sdegutisYou see? I want to hot-swap them out at init-time and test-time. That's the reason they're grouped together in a var.
14:54sdegutisChanging this to an object with real methods will not make any difference: this object is stored in the var instead.
14:55arrdemBronsa: this is guaranteed to be the reach set of vars by definition of the :children vector, right? (->> (ast < forms >) (ast/nodes) (map :var) (filter identity) (into #{}))
14:57Bronsaarrdem: yeah. btw (map :var) (filter identity) is (keep :var)
14:57Jaoodmnb.m,.,mn.
14:58arrdemBronsa: noted. thanks!
14:58TimMcJaood: Cleaning your keyboard?
14:59arrdemBronsa: for generality would you write that as an analyzer pass that creates var reach set metadata on each node recursively upwards?
14:59arrdem'cause then it fits with the rest of your passes rather than being some "run at root" weirdness.
15:03Bronsaarrdem: meh. either the ast/nodes approach or using a postwalk works just as fine if all you need is the reach set of the analyzed form
15:03JaoodTimMc: ;) - was lagging and mistakenly pressed enter and hitting random keys
15:04Jaoods/and/after/
15:04arrdemBronsa: kk. probably gonna do it anyway just to use update-children for the first time.
15:04Bronsaarrdem: I don't think you need update-children for this
15:06Bronsaarrdem: honestly I'd go with the snippet you just pasted, it's going to be shorter than the approach using postwalk/update-children
15:08sdegutisWhat are some alternatives?
15:27nbeloglazovtechnomancy: ping, seems like I did break quil repo on clojars
15:47dgleesonanyone in here using cursive? I'm curious if there is an easy way to reload the repl with changes made to the clj files?
15:51zeeshanlakhanidgleeson: Tools > REPL > Load file in REPL. and yeah. bind to key for
15:51zeeshanlakhani great justice
15:52ShayanjmHi all, completely new to Clojure and trying to dive right in. Wanted to install leiningen via Brew -- am I right in assuming that 2.3.4 is the latest release?
15:53scottjShayanjm: yes, note top of this file https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
15:54Shayanjmgood call, thanks
15:54sdegutisWhy was it that the solution to my Clojure problem came from #clojure-social and not #clojure? :P
15:55gtrakthe offtopic has become on-topic.
15:55gtrakwe should tell people off-topic if they start talking about clojure too hard.
15:56AimHereOr we could just rename this channel #clojure-antisocial and start being nasty to people
15:57arrdemfor K people and 2 channels what is the optimal distribution of conversations so as to ensure the highest content rate on both channels?
15:59dgleesonzeeshanlakhani: weird, that's grayed out for me
16:00dgleesondoes that mean I don't have something set up correctly?
16:00dgleesonoh it's because I didn't have focus on the file correctly
16:00dgleesonDOH
16:00dgleesoncool!!
16:03zeeshanlakhanidgleeson: yay!
16:03technomancynbeloglazov: what's up?
16:04technomancynm; I see the issue
16:11sdegutisarrdem: that kinda knowledge gets jobs
16:23sandbagsCan anyone sign into refheap.com? I'm getting an uncaught ReferenceError in the JS ... is refheap still a thing?
16:23arrdemRaynes: ^
16:24sdegutisI just use gists
16:24arrdemsdegutis is also a terrible person
16:24sandbagssdegutis: yeah i could use a gist but i thought it being clojure an all
16:24arrdemsandbags: just don't use pastebin and nobody will care
16:25technomancywow, paste.lisp.org is still a thing
16:25technomancyit supports haskell but not clojure ._.
16:25sandbagswell i'm tweeting this so i want a little bit o'class
16:25arrdemtechnomancy: we're not a real lisp, right?
16:25sdegutistechnomancy: that's all #macdev uses
16:25sdegutisdon't tell them I sent you
16:26technomancyI used to use this for elisp because you could do M-x lisppaste-buffer and a bot would announce it in the #emacs channel
16:26technomancykinda cool
16:26sdegutistechnomancy: yeah that feature broke a while ago iirc
16:26technomancyyeah, which is probably why I haven't seen anyone use it this decade
16:27technomancyanyway I only paste using my elisp-powered paste site so there
16:29sdegutisWhy not write it in Clojure?
16:29arrdemsdegutis: you haven't finished your emacs in clojure port, that's why
16:29technomancysdegutis: because elisp is simple yet powerful
16:30sdegutistechnomancy: boom got em
16:31arrdem∀T≠C++ claim T is simple yet powerful
16:32sdegutisarrdem: my emacs is written in Lua
16:35hyPiRionarrdem: let T be any DSL written on top of C++
16:36arrdemhyPiRion: my qualifier should have been more explicit... C++ ⊄ T
16:37sandbagsi don't know if refheap magically healed itself, or someone answered my cry but it's working again ... thank you clojure gods
16:37hyPiRionarrdem: there you go
16:38arrdemI suppose it should be ⊈ not
16:38arrdem
16:41scottjtechnomancy: does scpaste-region ever not syntax highlight the region for you, when it's highlighted in the buffer?
16:41technomancyscottj: haven't seen that
16:41technomancythe only problem I've seen is hl-line-mode and idle-highlight showing when they shouldn't
16:41scottjtechnomancy: do you use color-theme.el, that might be it
16:41technomancyI used to, but not any more
16:42scottjtechnomancy: ok, no worries I'll let you know if I ever figure it out
16:52jarosti(clojure.string/replace "somelatex\nwithnewline" #"\n" "\\newline") -> How do I get a backslash to remain in the result?
16:53hiredman,"\\"
16:53clojurebot"\\"
16:53dbasch,(clojure.string/replace "somelatex\nwithnewline" #"\n" "\\\newline")
16:53clojurebot"somelatex\newlinewithnewline"
16:53hiredman,"\"
16:53clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
16:54johncashis there a way to declaratively define base conditions for a loop rather than using if/when? sort of like haskell style.
16:54technomancyjohncash: core.match I guess
16:55johncashive been on a journey to avoid branching logic where possible
16:55johncashtechnomancy: thnx
16:55Glenjaminis there a way to get lein to tell me the profiles and their dependencies? `lein with-profile test repl` leaves me with no nRepl in this project
16:56technomancyGlenjamin: unfortunately that's a bit opaque right now
16:56technomancybut you probably want `lein with-profile +test repl`
16:56Glenjamini feel vindicated in my confusion at least
16:56jarostidbasch: (print (s/replace "somelatex\nwithnewline" #"\n" "\\\newline\n"))
16:56jarostisomelatex
16:56jarostiewline
16:56jarostiwithnewline
16:56technomancyor `lein with-profile base+test repl`
16:57technomancyerr `lein with-profile base,test repl`
16:57Glenjamini ended up doing with-profile base,dev,user,test :D
16:57technomancysame thing, yeah
16:57Glenjaminkept guessing until it worked
16:57Glenjaminxeqi: are you around at all?
16:57technomancyI think a better design would be to allow every task to have two implicit profiles; one provided by the task and one overridable by the user
16:57technomancyas long as the mechanism for such a thing is standardized it would allow for much better transparency
16:58Glenjaminthe + vs , thing seems reasonable
16:58dbaschjarosti: maybe you want (clojure.string/replace "somelatex\nwithnewline" #"\n" "\\\\newline")
16:58xeqiGlenjamin: surprisingly I am atm, but rarely normally
16:58jarostidbasch: thanx
16:58Glenjaminbeing able to do lein show-profiles :tree might help
16:59Glenjaminxeqi: i've pushed a few updates to peridot recently, including passing tests on 1.6
16:59nullptr,(clojure.string/replace "x" #"x" "\\")
16:59clojurebot#<StringIndexOutOfBoundsException java.lang.StringIndexOutOfBoundsException: String index out of range: 1>
16:59Glenjaminabout to do the same kerodon, including merging some PRs
16:59technomancyGlenjamin: most task-specific profiles are not declarative though
16:59technomancywhich we need to fix
16:59Glenjaminwill you be able to publish clojar updates soonish?
16:59johncashi heard rumour that `use` is deprecated now, is that founded?
16:59Glenjamintechnomancy: i didn't follow that last bit i'm afraid
17:00xeqiGlenjamin: awesome, I can tonight. or you could tell me your clojars name and I can give you permissions
17:00Glenjaminglenjamin on clojars, i hope i didn't lose my pgp key :)
17:02xeqiGlenjamin: done
17:02Glenjamintyvm
17:02Glenjaminare you still using peridot/kerodon at all?
17:03nullptr,(clojure.string/replace "x" #"x" (clojure.string/re-quote-replacement "\\")) ; jarosti
17:03clojurebot"\\"
17:04stompyjis that react petehunt?
17:04petehuntyessir
17:04petehuntor ma'am
17:04Glenjamintechnomancy: do you mean that some profiles only work with +profile ?
17:05stompyjpetehunt: haha, do you guys have a clojure stack @ fb? or just interested in the language?
17:05technomancyGlenjamin: no, I mean that some tasks merge profiles inside their defn, which is not introspectable
17:05Glenjaminoh
17:06Glenjamini see
17:06gtraktheir next php compiler is actually a set of clojurescript regexes.
17:06petehuntstompyj: no clojure @ fb, but a lot of FP in mainstream languages
17:07stompyjpetehunt: ahhh ok, very cool. I get pinged by fb recruiters from time to time and if you had clojure, I’d ping back. heh :)
17:07Glenjamingtrak: there actually is a clojure-like lisp that compiles to PHP :o http://pharen.org/
17:07stompyjOne of the best pieces of steak i’ve had in NYC was @ FB’s offices
17:07stompyjheh
17:08petehuntstompyj: haha, the food here is excellent
17:08stompyjfact
17:08xeqiGlenjamin: not really. haven't had much time for clojure recently, and I've been impressed by liberator for api + om/react for ui
17:08xeqiso less html, more cljs
17:08gtrakoh man.. I'm getting enough edge-cases lately by just trying to learn html, thankfully react/om is a respite.
17:08dgleesonSo I have a vector, I want to turn it into a formatted string that I will be putting on syslog. I have this https://gist.github.com/whodevil/2b11a1fc21da95bd33f1, but it is returning lazyseq... Any ideas?
17:09gtrakamortize pain with occasional good tech, that's my secret to success.
17:09petehuntstompyj: yeah no clojure, but hacklang.org is nice
17:10petehuntwe are probably one of the better “big companies” if you like FP, despite the fact that we don’t use functional languages directly. a lot of the core abstractions are FPish
17:10dbaschLinkedin and Twitter do use Clojure
17:10arrdemdo we have a standard fixed point combinator? I don't remember.
17:11stompyjpetehunt: very interesting. maybe I will follow up with them at some point
17:11dbaschof course Twitter is big on Scala, but that doesn’t mean most people use it in functionaly style
17:11dbaschfunctional
17:11wackyvorlonI've been playing with overtone and clojure lately, and using this bit of example code: https://www.refheap.com/85538
17:11stompyjI love LinkedIn’s infrastructure, that’s another place I’d cnosider
17:11wackyvorlonWhat does it mean when you call #'player2?
17:11gtrak#' is a var, that's usually an indicator of repl-convenience.
17:11dbaschstompyj: LinkedIn has a good culture of open-sourcing stuff
17:11petehuntyeah i don’t know too much about their codebase
17:12petehunti just can speak confidently that we use FP techniques all over the frontend
17:12nullptrlinkedin has cool backend tech, yet somehow i encounter more "this doesn't work" bugs on their site vs. any other of the "majors"
17:12technomancypetehunt: how much of that is just an inevitable consequence of operating at scale?
17:12wackyvorlongtrak: How is it different from using (player2)? This in an apply-by.
17:12technomancyliterally no other way to do it =)
17:12nullptrhttps://twitter.com/derekslager/status/448839597410115584
17:13petehunti mean there are probably ways to do it without immutability etc
17:13gtrakwackyvorlon: my guess is overtone needs to serialize something? vars are serializable.
17:13petehuntbut it would suck and require a lot more people.
17:13dbaschnullptr: certainly not more than on Twitter
17:13gtrakmaybe..
17:13stompyjnullptr: agreed. I’m more of a back-end data guy tho, so right in my wheelhouse.
17:13stompyjpetehunt: the fact you guys acknowlege immutability is important is amazing, tbh
17:13wackyvorlongtrak: Basically it is using recursion with a delay, and the idea is that using #' lets you modify the code, reevaluate, and it keeps recursing with the new code.
17:13gtrakah, yea, that makes sense.
17:14dbaschcan’t speak for any front-end stuff at LinkedIn, I worked in the deepest depths of the backend
17:14gtrakwackyvorlon: essentially, vars provide an IFn implementation that delegates through a deref.
17:14petehuntstompyj: the front end eng team here is basically using our (fairly large these days) soapbox to push an FP agenda
17:15petehuntpublicly
17:15petehuntit already won out internally
17:15petehuntmost people are obsessed with syntax though
17:15petehuntso need to pick your battles
17:16gtrakclojure makes me actually *annoyed* at syntax.
17:16nullptrhe said, in a lisp channel...
17:16wackyvorlongtrak: Ahh! Okay, so basically functions are variables, and deref makes it use the latest value of the variable which implements IFn(i.e. the interface for a function)?
17:16gtrakI get uncomfortable when I see it now, it wasn't like that before.
17:16petehunthey i am on your side nullptr
17:16stompyjpetehunt: that’s awesome
17:17gtrakwackyvorlon: yes.
17:17wackyvorlongtrak: Awesome! Thanks, much appreciated:) Also, that is exceedingly cool.
17:17gtrakhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java#L374
17:18wackyvorlonBah, stupid netsplit...
17:18wackyvorlonI take it java doesn't have varargs?
17:19amalloywackyvorlon: one minor detail: functions are not variables, they're immutable values. rather, when you define a function, with def or defn, you also create a var (variable) that points to the function's definition
17:19gtrakjava does, but they're an illusion, it's just an array as far as the jvm's concerned.
17:19wackyvorlonamalloy: So sort of like having a void pointer in C.
17:19gtrakthat's probably what Rich Hickey was going for ;-)
17:20gtrakhow do we give void pointers better semantics so you'll use them more?
17:20wackyvorlongtrak: That makes sense. Void pointers have always struck me as a hack.
17:21gtrakI was kind of joking, but it works.
17:21amalloyi'm not sure what the analogy is there, wackyvorlon. a var is indeed a bit like a void pointer, i guess, but so are most things in clojure: references are untyped, and can point at anything
17:21amalloywell, not "most things in clojure". that was way wrong. most *references* in clojure
17:22sdegutisWhat's a good use-case for Clojure's deriving functionality?
17:22wackyvorlonamalloy: Void pointers are used as a means of pointing to a memory address when you load an object with dlopen().
17:22amalloyvoid pointers are used for like a million things
17:22wackyvorlondlsym() gives you the memory address of the code, which you dump into a void pointer, and call with syntax like *(foo);
17:23wackyvorlonIt's been a while since I used it.
17:23wackyvorlonThat is the speicific application of void pointers I'm thinking of:)
17:23amalloywackyvorlon: i don't think that's a particularly useful frame of reference for understanding vars, but if it helps you, then go for it
17:23amalloysdegutis: mostly it's used as a way to say "look, you can do inheritance!"
17:24wackyvorlonI think I'm used to lower-level stuff, so I tend to think in terms of memory addresses.
17:24Glenjaminsdegutis: grouping stuff together in multimethod implementations?
17:24gtraksdegutis: friend uses it for access control.
17:25gtrakuser roles
17:27gtrakwackyvorlon: after having used java for a while, clojure had a very C-like feel to me, which I think was not intended.
17:27sdegutisderive/parents/isa?/ancestors/descendents look fun, I just can't find any problems they're suitable for (where plain old functions and data aren't)
17:27sdegutisgtrak: I can't imagine how Clojure feels like C
17:28amalloysdegutis: i have found one use-case for derive in my ~four years of clojure
17:28gtrakit's hard to describe. minimal I guess is the word.
17:28gtrakmaybe it's just I was a noob when I used C last, and I was a noob at clojure.
17:28sdegutisGlenjamin: ah yes, that could make a ton of sense, it could act as the "state" for a multimethod!
17:28hyPiRiongtrak: Have you played around with scheme?
17:28gtraka little bit
17:29Glenjamini did it here, but i am unsure if it was worth it: https://github.com/Frozenlock/kerodon/blob/cde0feee8f178757891e4dc552f756194c389925/src/kerodon/impl.clj#L270
17:29sdegutisGlenjamin: like {:kind ::person :name "me" ...}
17:29arrdemmeh... scheme was a waste of three months between SCIP and using Clojure.
17:29hyPiRionI feel the scheme/c analogy fits better, at least for me
17:30sdegutisWith a multimethod that switches off on (isa? ::base-whatever)
17:30wackyvorlonIt's been quite an adjustment to go from stuff like C to clojure.
17:30gtrakthere's no 'Clojure for C programmers' video.
17:30amalloysdegutis: https://github.com/ninjudd/depot/blob/develop/src/depot/pom.clj#L8-L23 let me reuse the multimethod implementation for two different dispatch values that i wanted to treat similarly (as a generic "list of whatever")
17:30sdegutisarrdem: scheme is pretty cool, just also not practical for real-world anything
17:30arrdemI guess due to minimality Scheme is more "c in sexprs" than clisp is...
17:31arrdems/clisp/CL/g
17:31Glenjaminoh, neat - my example is almost identical to amalloy's \o/
17:31sdegutisamalloy: ahh ok
17:32amalloyGlenjamin: wait, https://github.com/Frozenlock/kerodon/blob/cde0feee8f178757891e4dc552f756194c389925/src/kerodon/impl.clj#L275, really? i thought it was supposed to be: checked="checked"
17:33amalloythe w3c even says so, at http://www.w3.org/TR/html-markup/input.checkbox.html
17:33Glenjamin<input type="checkbox" checked="checked" name="foo" value="123"> => foo=123
17:33Glenjamin<input type="checkbox" checked="checked" name="foo"> => foo=on
17:34sdegutisHTML is so lax it's not even funny.
17:34Glenjaminthat form parsing code was a nightmare to write
17:35Glenjaminsee https://github.com/xeqi/kerodon/blob/master/test/kerodon/unit/impl.clj#L56 onwards for checkboxes
17:36Glenjamincurrently trying to remember the passphrase for key i used once a year ago to push to clojars :(
17:40sdegutisI determined a way to solve my problems using multi-methods and shared state.
17:41sdegutisYou see, there will be a single variable called "live?" which will default to false, and two sets of methods that switch off based on this value.
17:42sdegutisThere will also be a variable for one of the "implementations" which stores its state, although I don't like this work-around.
17:44sdegutis,*ns*
17:44clojurebot#<Namespace sandbox>
17:45sdegutis(let [x (def foo)] (= x (clojure.lang.Var$Unbound. #'sandbox/foo))
17:45sdegutis,(let [x (def foo)] (= x (clojure.lang.Var$Unbound. #'sandbox/foo))
17:45clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:45sdegutisFind Never mind.
17:48Bronsa,(let [x (def foo)] (= x (clojure.lang.Var$Unbound. #'sandbox/foo)))
17:48clojurebotfalse
17:48Bronsasdegutis: ^
17:48sdegutisOthanks
17:50whodidthiswhats a cool way to conj x amount of nil to a vector
17:50clojurebotCool story bro.
17:52dbasch,(concat [1] (repeat 3 nil))
17:52clojurebot(1 nil nil nil)
17:53turbofail,(reduce conj [1] (repeat 3 nil))
17:53clojurebot[1 nil nil nil]
17:53martinklepschI'm using flatten around pmap, is that something people do or do I lose pmaps parallelism doing that?
17:54eggheadoh can I play
17:54egghead,(apply conj [1] (repeat 3 nil))
17:54clojurebot[1 nil nil nil]
17:54whodidthiso la la
17:55amalloyinto, guys. into
17:55hyPiRion(inc amalloy)
17:55lazybot⇒ 106
17:55amalloy,(into [1] (repeat 3 nil))
17:55clojurebot[1 nil nil nil]
17:59turbofail,`[1 ~@(repeat 3 nil)]
17:59clojurebot[1 nil nil nil]
18:00amalloyturbofail: that's okay, but it doesn't really use the existing vector
18:00turbofail,`[~@[1] ~@(repeat 3 nil)]
18:00clojurebot[1 nil nil nil]
18:00turbofailof course that doesn't either
18:01Glenjaminwhat does the "promote" button do in clojars?
18:01turbofaili'm just going for silly points
18:04shriphaniHi, I am a bit stumped with some java interop here. I have a lib from maven where the docs and poking around with java show me a public method. However clojure thinks it is private (and so does reflection). Can someone help shed light on this ?
18:05amalloyshriphani: it could be a public method of a non-public class
18:05technomancyGlenjamin: it's an unfinished feature of clojars; you can ignore it
18:05Glenjaminaww
18:05shriphaniamalloy nope
18:05amalloyin which case you can't call it via reflection, you have to type-hint it as some public interface that contains the method you want to call
18:05Glenjamini got all excited and clicked it, but nothing happened :)
18:05shriphaniit is a public class
18:06amalloyare you sure? be more specific: what maven artifact are you having trouble with and where are its docs? do you have a code sample that fails but you think should work?
18:07shriphanisure. this lib: http://mvnrepository.com/artifact/net.sourceforge.htmlcleaner/htmlcleaner , version 2.8. The method in question in HtmlCleaner/getInnerHtml
18:07shriphaniis*
18:08shriphaniamalloy, specifically: (import (org.htmlcleaner HtmlCleaner)) to import said class
18:10amalloyso you have some HtmlCleaner object h, and you're calling (.getInnerHtml h some-tag-node)?
18:10shriphaniyep
18:11justin_smithshriphani: are you shure you are getting the version of the dep you think you are? it could be that the package changed in scope
18:11amalloy*shrug* should work. you could be getting a different version, as justin_smith says
18:11shriphanijustin_smith, I removed the repo and ran lein deps again
18:11justin_smith(between the source/docs you are looking at and the version your program is using)
18:11justin_smithshriphani: but what version did it give you?
18:11justin_smithdid you check?
18:11shriphaniand I have 2.8 specified in project.clj which is the latest version
18:11shriphaniand it downloaded 2.8
18:11justin_smithOK
18:12amalloywell, i don't think what you're describing should be possible. if you create a gist or a git repo or something with minimal failing code for someone else to repro, maybe it will make sense
18:24shriphaniamalloy: https://gist.github.com/shriphani/fa1bea3267389e47b7f7
18:24shriphanithats my 3 files.
18:24shriphaniwell one of those is a repl output but yeah
18:25amalloyshriphani: .clean doesn't return the cleaner object
18:25amalloyso when you call .getInnerHtml on the result of process-page, it's some random other object, not a cleaner at all
18:26sdegutisHow do you solve the require-order problem when you have a defmulti with defmethods in different namespaces?
18:27amalloyyou can tell from the exception message, which says "No matching field found: getInnerHtml for class org.htmlcleaner.TagNode" - note it's not talking about the class HtmlCleaner at all, which is the class you thought you were using
18:27sdegutisDo you have the namespace with the defmulti in it just require the namespaces with the defmethods in dem?
18:30shriphaniamalloy: this is what reflection spits out. getInnerHtml is private: https://gist.githubusercontent.com/shriphani/fa1bea3267389e47b7f7/raw/81375dab6fee4e610f8ab8f754fd26c4ae03d2d6/gistfile1.txt
18:31amalloyno, it clearly says public, right there in that table you ilnked me to
18:32amalloybut even if it didn't, the error message you get is clearly unrelated to access levels on HtmlCleaner, because you're *not using one at all*
18:32shriphaniok nvm. yeah I see it now. that was stupid of me.
20:11arrdemso when iw clojure.core/print-method not bound so that clojure.lang.RT.print() will use its formatter?
20:11arrdemjust trying to read into the boot process here.
20:24cespareIs there a word for #( )
20:24Jaoodfn ?
20:24danielcomptonanonymous function?
20:24arrdem+1 anonymouse function
20:24cesparei mean that specific form
20:25cespare(fn ...) is also an anonymous function
20:25Jaoodfunction literal
20:25danielcomptonAnonymous function literal
20:25danielcomptondarn Jaood beat me to it
20:26cespareok thx
20:26Jaood:)
20:40trap_exitis there a way to cache the result of a cond pair? i.e. when I do (cond t1 e1, t2 e2, t3 e3) ... there is a sub expression x1 used in both t1+e1; x2 used in both t2 + e2; x3 used in both t3 + e3. Now, I only want to evaluate x1, x2 x3 once -- and I only want to eval x2 if t1 fails; and I only want to eval x3 if t1 + t2 fails. Is there a way to do this?
20:41amalloytrap_exit: you can let-bind a delay
20:41arrdemtrap_exit: you could write a helper function and memoize it, but that's the only builtin wa.y
20:41trap_exitamalloy arrdem: damn, both of these are crazy ways
20:41trap_exitbut both very clever
20:41trap_exitI'd never have thought of using a delay / memoization
20:42amalloy(let [x1 (delay (...))] (cond @x1 (inc @x1)))
20:42trap_exitdecisions decisions
20:42trap_exitI like the delay way better
20:42trap_exitamalloy: are you available for consulting?
20:42amalloytrap_exit: you can even wrap it up in a clever macro if you want
20:42trap_exitergh
20:42trap_exitwriting cljs code
20:42trap_exitdebugging macros painful
20:43amalloytrap_exit: no. but i answer questions for free in #clojure and on stackoverflow when i feel like it
20:43trap_exitbut this use of delay is badass
20:43trap_exitoh
20:43amalloyhttps://github.com/flatland/useful/blob/develop/src/flatland/useful/utils.clj#L224 if you want it to look prettier, trap_exit
20:43trap_exithere's adubmass ideas
20:43trap_exitwhy does SO not hcarge peopl e$9.99 / month ?
20:43trap_exitI'd pay $9.99 / month
20:43trap_exitto have the ability to fucking ignore dumbass users
20:43trap_exitknowing that every time they create a new account, it costs them $9.99 / month
20:44trap_exitokay, this let delay
20:44amalloythat's a brilliant idea. why don't you start a competing company and drive them to bankruptcy while you rake in millions?
20:44trap_exitjust got it to work
20:44trap_exitis completely badass
20:45trap_exitamalloy: I'm seriously considering doing so
20:45trap_exitbut have not ifgured out a way to get initial users
20:45locksor just pull a Quora
20:45locksand go bankrupt because the UX is ass
20:45trap_exitwell, Quora solves a different problem
20:45trap_exit"how to raise $80M without doing anything"
20:46turbofailthat's a pretty important problem
20:46dbasch7-minute abs
20:47turbofaileventually we're going to have to solve that problem for everyone as the need for labor decreases
20:47amalloyoh wow, i forgot i made let-later work even for values you're destructuring. that's pretty clever, if i do say so myself
20:48trap_exitamalloy: got pat younger-amalloy on the back
21:15rpauloI see
21:15rpaulooops, wrong window
21:36quizdrrpaulo there are no wrong windows. just windows. the window did nothing wrong. it is not wrong.
21:53danielcomptonAre there any recommendations for test naming conventions?
21:53danielcomptonhttps://github.com/bbatsov/clojure-style-guide didn't have any
22:19FrozenlockUhh... I'm getting a weird error with friend/authenticated. When the user isn't authenticated, it redirects to "/login", but on port 80 even if it's over ssl
22:22kenrestivoare you using a front end proxy like nginx?
22:31Frozenlockkenrestivo: I am
22:32Frozenlockbut I'm setting the x-forwarded-proto AND overwriting the :scheme as https
22:32pbw /part
22:35danielcomptonI'm trying to create prepared statements using alia/cassandra. I'm having trouble working out the clojuresque way of writing this, as the call to prepare the statement requires a connection to the database. So I don't know how to write it so that the first time the function is called the statement is prepared and the rest of the time it is cached.
22:36danielcomptonmemoize didn't seem appropriate
22:37kenrestivofrozenLock: i don't remember anywhere in friend checking :scheme before forwarding to /login. but it's been a while
22:38FrozenlockSo it's just forwarding to 80? o_O
22:38kenrestivoif so, bug should be filed
22:38FrozenlockMy lazy side wanted to avoid checking the source :-(
22:38kenrestivoit's forwarding to /login, no scheme specified, whatever was used for the request, is ring's default
22:39kenrestivoand if you're proxying through nginx, http not https is what arrived at ring
22:40dbaschFrozenlock: why don’t you just rewrite all http requests to https on nginx?
22:41Frozenlockdbasch: that's already what I'm doing. rewrite ^ https:....
22:41Frozenlockfriend redirects to https://my-site/login:80
22:42dbascha search for 80 in the source shows https://github.com/cemerick/friend/blob/94a62e46fd08fbc602a340ce03b784f54d718dcc/src/cemerick/friend/util.clj#L21
22:42zerokarmaleftFrozenlock: I think I patched that
22:43Frozenlockzerokarmaleft: Yes I saw your issue, which was even more confusing me :-/
22:44FrozenlockOh I wonder if I disordered my middlewares
22:52FrozenlockDoesn't seem to be that. Grrrr
23:14White_FlameHi, long-time Lisp user looking at some Clojure source code. I cannot for the life of me figure out how to load a clojure project into a repl and call things interactively. Is there a good beginner tutorial that covers that? Most just type in commands at the repl
23:14White_Flameinstead of load source code from existing files
23:15White_FlameI do have a running repl, from apt-get clojure
23:15dbaschWhite_Flame: are you using leiningen?
23:15White_Flameno, just straight clojure-repl
23:15dbaschinstall leiningen and go from there
23:16White_Flameis it not worth the effort to get this running as is?
23:16scottjWhite_Flame: nope, almost everyone uses leiningen almost all the time
23:16dbaschno, leiningen is by far the best way
23:16Frozenlockleiningen powaaaa
23:18White_Flameso I've got that running. To be clear, is it fetching its own installation of clojure, or does it use what's installed on my system already?
23:19beamsofetching unless you're clojure install was linked to your local maven repository
23:19scottjWhite_Flame: in general though you make sure the src directory or jar is on the classpath and then you require the namespace.
23:19dbaschWhite_Flame: you don’t need an “installation” of clojure
23:19dbascheach project uses its own version of clojure as declared in the project.clj dependency
23:19White_Flamewell, there's already a clojure.jar somewhere, and who knows how the clojure-repl command finds it
23:20White_Flameso it's "installed", at least as far as an apt-get install is concerned
23:20dbaschWhite_Flame: yes, there is one. You just don’t need it
23:20dbaschonce you use leiningen you can disregard it
23:23Frozenlockgodfuckingdamnit
23:23Frozenlockzerokarmaleft: you did patch it, but for the snapshot version
23:23FrozenlockNot the current release :-(
23:24White_Flameok thanks, I'm up and running
23:25zerokarmaleftFrozenlock: I suppose you could ping cemerick and ask him to cut a new release
23:25FrozenlockIndeed
23:26FrozenlockIt would feel weird to run production code with a snapshot :-p
23:26zerokarmaleftI ran a local 0.2.0 with just that fix
23:28technomancywho was the PDX clojure group person who was thinking about doing a lein hack night?
23:29Frozenlocktechnomancy: hey, nice interview with Sasha! I love your batcave :-p
23:30TerranceWarriorHey White_Flame.
23:31White_Flamehey
23:31TerranceWarriorWhite_Flame: Remember me?
23:31technomancyFrozenlock: haha thanks
23:31technomancyalways fun to hack your actual surroundings
23:32White_FlameThe name's familiar...
23:32TerranceWarriorI was on Stealthnet and we were talking about program analysis to get debug information from previous lines in a monitor of 6510 disassembly.
23:32White_FlameAh, yes
23:33TerranceWarriorWhite_Flame: in the far past we also discussed effecient div code on a 6510 as me with another handle. have many, forgotten which.
23:33TerranceWarriorhaving many that is
23:34TerranceWarriorWhite_Flame: i too have recently bitten the clojure bug.
23:34White_FlameWell, I'm actually porting from clojure, not using clojure at the moment ;)
23:34TerranceWarriorWhite_Flame: ?!
23:34Frozenlockzerokarmaleft: You don't have it clojars? ... You mean 'really' local? :-/
23:35FrozenlockWhite_Flame: Porting FROM clojure? To what?
23:37White_FlameCommon Lisp
23:37TerranceWarriorLisp is going to die without nonmutability. even #lisp ers where having a sessions saying that last night.
23:38FrozenlockI'm used to see CL->CLJ, not the other way around!
23:38technomancyracket seems to be adapting somewhat gracefully
23:38gkoEmacs + Cider + Leiningen is awsome.
23:38White_FlameTW: There are lots of immutability libraries in CL as well
23:38White_FlameI tend to use strongly functional code
23:39gkoEspecially since the 0.7.0 doesn't seem to freeze Emacs anymore.
23:39TerranceWarriorWhite_Flame: that means it's all a matter of code and impl. one lock it's somewhat foobars and two.. two can make a deadlock. thats two!
23:39technomancybut racket seems to be better about breaking from tradition where it makes sense
23:40White_FlameTW: I've been doing concurrent programming for, well, a very long time. It's not hard to never have those problems
23:40TerranceWarriorlong is relative.
23:40TerranceWarriorimplementation is fact.
23:41TerranceWarriorthousands of hits a second a 2014 reality.
23:41White_FlameI really don't have much interest in language religion, regardless of whether it's the one I'm using or others'
23:42FrozenlockYeah, stop fighting, elisp is clearly the best.
23:42White_Flameand thousands of hits per second has been a reality for a very long time
23:43TerranceWarriorlong= relative and very long = very relative! ;)
23:43technomancyFrozenlock: it's great; in elisp it's guaranteed that mutable strings will cause no concurrency bugs, because there is no concurrency
23:43TerranceWarriorbeing as though very relative doesn't mean 'very relative'.
23:44White_Flameokay, let's say 15 years? banking systems have always been huge data processors, regardless of the web catching up in volume
23:44TerranceWarrior(++ technomancy)
23:44Frozenlocktechnomancy: Isn't this supposed to change?
23:44White_Flametechnomancy: Works for node.js ;)
23:44technomancyFrozenlock: it's been discussed for a long time... I'm sure it will be a long time before it changes
23:45White_Flame(and then they get weird with process pools)
23:45technomancyWhite_Flame: as much as I like to make fun of JS, they amazingly got strings right
23:45technomancyundoubtedly by accident
23:45TerranceWarriorwith banks realtime usually isn't an issue. it's stuff like reports that need optimization.
23:45TerranceWarriorya know?
23:46White_Flame2014 brings no new requirements, just other interesting options to implement them in
23:46technomancyif there are any new requirements, they might be around scaling *down*, not up
23:47technomancywriting code for small devices that are getting ridiculously cheap
23:47White_Flameyep, and it's nice living with today's compiler & vm technology, instead of the C focus of yesteryear
23:47White_Flameto get all that stuff fast & small
23:48sjyWhite_Flame: what was the last year that brought new requirements? :)
23:48White_Flamesjy: I shall decline to respond ;)
23:49White_Flamebut scalability, responsiveness, and maintainability have always been with us, in need & options in the solution space
23:50sjyyeah just curious if you were making the point that on one level requirements never really change, or saying that 2014 was special
23:50White_FlameI'm saying that 2014 isn't special, in response to TerranceWarrior
23:50TimMcTerranceWarrior: Yeah, it's funny how banking is often used as an example of the need for realtime, concurrent, distributed algorithms... but in reality it's all batched. :-P
23:50technomancyclusters where machines go down and get replaced every day is new-ish
23:51White_Flametechnomancy: what's "new"? people doing it, or the average startup reaching for things off the shelf?
23:51White_Flamebecause I was certainly doing clusters with individual machine downtime in the 90s
23:52White_Flameand of course, that far predated my work
23:53dbaschImagine a Beowulf cluster of ring servers
23:53White_FlameMy network's a star configuration, you insensitive clod!
23:54technomancyWhite_Flame: a few weeks ago I replaced a whole cluster of 44 machines with brand new ones in an hour just to do a trivial-ish deploy
23:54technomancymaybe that was possible in the 90s but you would have had to have been at nasa or something
23:55White_Flamenah, it's all been open a mainstay of open source
23:55White_Flame-open
23:55White_Flamejust different architectures connecting to different services
23:55technomancythe need for fault-tolerance in data centers has risen a lot
23:56technomancybecause virtualization makes things cheap, and cheap things aren't reliable
23:56TerranceWarriortechnomancy: 43.80 seconds per machine? not bad!
23:56White_Flamehmm, virtualization on a nice box, vs a bunch of really crap cheap single-OS boxes...
23:57TerranceWarrioropps 1.3 seconds i mean.
23:58TerranceWarrioroh whatever, meds talking.