#clojure logs

2014-08-30

00:29justin_smithjkj: does using lein clean effect this at all?
00:57BAMbandaI would like to develop a new web presence for a very young educational institutue, please suspend judgements and lets talk tech
00:57BAMbandaits www.alhudauniversity.org and is currently hosted on wordpress
00:58BAMbandaI don't like it at all, horrible design, and overall not appealing for a hacker to work on, so I want to do a complete overhaul, internal and external. I know it will take time, the main concern is the ease of updating content for non techy people
00:59BAMbandathe appeal of wordpress is how easy it is to maintain for small to even large organizations. What options do I have for having an admin interface for adding course descriptions and the like?
00:59arrdem85% probability of having to roll your own
01:00BAMbandaDo you think I should look at how wordpress is built and just translate code to ruby? Potentially kickstarting a rails like wordpress variant?
01:04arrdemwhy are you asking about ruby and php in #clojure? #ruby is a /join away
01:05andrewchambersor #clojurescript
01:05andrewchambersfor frontend
01:06BAMbandawoops, i thought I switched!
01:06BAMbandaSorry guys :/
01:08arrdemnp
01:24andrewchambersBAMbanda: it might be a bit of an undertaking in any language, you gotta do the tradeoff analysis
01:24andrewchambersthats all
01:25andrewchambersarrdem: read soem of your blog, cool stuff
01:26andrewchambersthat thing about startup secrecy is true
01:27arrdemyeah don't get me started on that
01:28arrdem"I'm doing a startup because I have an idea and money and I can so I'm hiring a technical contractor because no skillz" people can go die
01:28andrewchambershaha, I wanted to do a startup, but I'm not the web programming type of person. I always liked compilers etc.
01:29andrewchambersand hardware
01:30andrewchambersI havent really had the problem of people asking me to write software for their next big idea luckily :P
01:31arrdemI'm fine with people who have ideas... the nontechnical founder thing is just a huge warning light to me.
01:32glorbonhey um.. does clojure compile to byto-code or to java?
01:32arrdemglorbon: jvm bytecode
01:32glorbonany good resources on that
01:32arrdemglorbon: and "compile" is generous. AOT compilation of Clojure is rare, 99% of the time Clojure is dynamically compiled.
01:32arrdemglorbon: depends on what you're interested in.
01:32glorbongood enough for me
01:33glorbonim just interested in compilation of functional langs to assembler-like languages
01:33arrdemhum...
01:33arrdemthere's really not a whole lot that's interesting (IMO) to say about Clojure
01:34arrdemmost of it's implementation is driven by JVM details
01:34arrdemfrankly I'd probably find a simpler language with better implementation docs because clojure literally has none.
01:34arrdemand I say that having built a compiler for Clojure this summer
01:35glorbonI suspected as much
01:36arrdemI mean... abstractly "compiling" a lisp to a stack oriented architecture or to a dependency graph representation like LLVM ASM is a trivial depth-first traversal
01:36arrdemtechnically a reverse order one...
01:37arrdem(emit args) (emit op) ...
01:37glorbonwill this be optimized enough thou?
01:37arrdemdepends on your definition of optimisation
01:37glorbonIm wondering like which tricks the hakell/julia/SBCL ppl are using
01:37arrdemdifferent program transforms are visible at different levels of abstraction
01:38arrdema typical "real" compiler will have three or four entire intermediary languages or "representations" with different properties
01:38arrdemeach designed to enable some specific class of transformation
01:38glorbonexample?
01:39arrdema lambda calculus representation for typechecking and typecheck removal
01:39arrdeman ASM representation for stack management and register spilling
01:39arrdemnote that neither of these two is possible (or at least reasonable) at the other's level of abstraction
01:40glorbongot any resources?
01:40arrdemnope. all this shit is implementation/language specific.
01:40arrdemthe GHC folks have a huge collection of papers
01:40BAMbandaandrewchambers, web programming is much more loose and easier to see fruits
01:41BAMbandaif you understand compilers, and you appreciate type inference from languages like clojure, you'll do fine
01:41BAMbandawhat industry is your startup seeking to be a part of?
01:41arrdemBAMbanda: wat we don't have any type inference. Literally everything is dynamically checked.
01:41arrdemcore.typed has zero impact on emitted bytecode
01:42BAMbandaarrdem, ahh i guess i used the wrong terminology, so its being checked and we don't have to explicitly mention the type
01:42arrdemtype annotations also have no impact except on code which is typed to JVM primitives (long, int, float) not to Objects (Long, Int, Float)
01:43BAMbandahmmm
01:43glorbonarrdem: thanks
01:43arrdemit is rarely if ever actually checked by the Clojure language. the Clojure implementation will eventually take an object and attempt to cast it to an instance of something specific and that's what you'll see fail.
01:43arrdemthis pervasive lack of checking is done in the interests of "speed" and JIT performance.
01:44arrdemthis also means that debugging Clojure really means reading shitty stacktraces to determine what the real error was and where it occured because it isn't local to the true source.
01:50amalloyarrdem: do you actually know that the reason typehints are not acted on until it comes time to invoke methods is to improve speed? i always figured it was because it's easier to generate that bytecode; and i would expect the current approach to be generally slower than storing stuff with the right types all along
01:51arrdemamalloy: I don't to be honest. I presume it's to simplify the implementation.
01:52arrdemamalloy: arguably it also doesn't matter before that point... the only real question is whether an invokePrimitive is legal or whether the normal invoke must be used.
01:58Blorgonarrdem: how did u become expert on FP compilation?
02:00amalloyarrdem: i hadn't actually read the backlog - are you really claiming that "type annotations also have no impact except on code which is typed to JVM primitives (long, int, float) not to Objects (Long, Int, Float)"?
02:00amalloyobviously typehints cause non-reflective code to be emitted
02:02arrdemyou're correct. that didn't come to mind. 90% of my work was with the calling convention which entirely ignores typehints except on primitives.
02:04andrewchambersany clojurists here from NZ ?
04:10noncom|2when using clojure.java.api and invoking, for example, a (vector) IFn, then how do i work with this vector back in java ?
04:11noncom|2the "invoke" returns an Object which implies casts which imply time penalties.. am i right?
05:13justin_smithnoncom|2: there is an overhead for downcasts (narrowing) - it always involves runtime checks iirc.
07:23noncom|2justin_smith: thanks :)
08:33clojerThis list comp: (for [l list-of-lists plan (keyword (first l)) deg (Integer/parseInt (second l)) sign (signs (keyword (first (rest (rest l))))) min (Integer/parseInt (second (rest (rest l)))) long (Float/parseFloat (last l))] {plan {:sign sign :deg deg :min min :long long}})
08:34clojer... keeps giving me an error : "Don't know how to create ISeq from: clojure.lang.Keyword"
08:34clojer... but all the bindings work when I test them in the repl
09:12justin_smith$ping
09:13justin_smith,:ping
09:13clojurebot:ping
09:54martinklepschWhen making a library it's probably good to keep dependencies as minimal as possible. Now I need a date like "2014-01-02T00:00:00.000Z" and could use regular Java stuff or clj-time
09:55justin_smithmartinklepsch: meaning a string like that from a date, or a date like the one that string represents?
09:55justin_smith,(java.util.Date.)
09:55clojurebot#inst "2014-08-30T13:55:18.770-00:00"
09:55martinklepschjustin_smith: a string like that
09:56justin_smith,(str (java.util.Date.))
09:56clojurebot"Sat Aug 30 13:55:45 UTC 2014"
09:56justin_smithhrm
09:56justin_smith,(pr-str (java.util.Date.))
09:56clojurebot"#inst \"2014-08-30T13:55:53.569-00:00\""
09:56martinklepsch(from a date created like this: new Date(System.currentTimeMillis()+5*60*1000))
09:57justin_smithmartinklepsch: isn't that the same thing the constructor gives you for no argument?
09:57justin_smith(as in my above examples)
09:58shiranai_justin_smith: with no args it's equivalent to System.currentTimeMillis
09:58shiranai_(or what am i missing here? :p)
09:58martinklepsch,(java.util.Date. (.currentTimeMillis System))
09:58clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: currentTimeMillis for class java.lang.Class>
09:58justin_smithshiranai_: got it, my reading comprehension fail
09:59justin_smithmartinklepsch: static method
09:59martinklepschjustin_smith: I need the string of a time n minutes from now
09:59shiranai_alrighty :p
09:59justin_smith,(java.util.Date. (+ (System/currentTimeMillis) (* 5 60 1000)))
09:59clojurebot#inst "2014-08-30T14:04:25.795-00:00"
10:00shiranai_martinklepsch: can you use a SimpleDateFormat, for example? (java.util.SimpleDateFormat "dd.MM.yyyy") .. then (.format simpleDF (Date. <millis>)) .. ?
10:00justin_smiththe thing is, the default print method for #inst is the format he wants
10:00justin_smithisn't it?
10:00shiranai_i'm not sure :)
10:01justin_smithI mean minus the #inst part
10:01shiranai_but at least by explicitly using a DateFormat, he can get exactly the format he wants
10:01justin_smithtrue that
10:02justin_smithanyway, this is definitely all doable without any libs, just using a small amount of interop
10:02shiranai_yeah
10:02shiranai_Java
10:02shiranai_lkasjdsd
10:02shiranai_Java's got quite a few batteries included :p
10:03shiranai_there was some new Date stuff in Java 1.8, i think
10:03justin_smithyup
10:24martinklepschjustin_smith, shiranai: thanks a lot, found a neat solution with your help I think
10:29shiranai_martinklepsch: kein problem :p
10:31martinklepschhttps://gist.github.com/3bec2f54456a2bcd274b
10:31martinklepschshiranai_: danke sehr
10:31martinklepsch:)
10:32shiranai_:P
10:33shiranai_hmm.. i didn't know "danke sehr" was an expression in German.. but either it is, or i was mistaken about you being German-speaking :P
10:33shiranai_but yeah, it looks like you found a solution :)
10:34shiranai_(my German is very poor anyway :p)
10:34martinklepschshiranai_: it's old-school german. the type of german things you say when you want it to sound very german
10:34shiranai_ohh, ok :p
10:34shiranai_so it's like Sehr-Hoch Deutsch or something.. ? :P
10:36martinklepschI guess you could say so. It's "altbacken".
10:36martinklepsch(another great german word)
10:40martinklepschI'm trying to build a library for clojurescript that helps you with uploading files to S3 right from the browser. It consists of one function you plug in somewhere in your ring app and some clojurescript handling change events on the input and signing/uploading of files.
10:41martinklepschI use core.async a bit but don't feel like I really understood it yet and so I'm wondering what might be the best API to expose that sort of functionality. it's embedded in Om right now but that's probably not necessary
10:41martinklepschhere is some of the code including my amateur core.async usage: https://gist.github.com/mklappstuhl/4d731346e7693b6401a3
10:42martinklepschany code review or advice would be greatly appreciated
10:47justin_smithmartinklepsch: in your timestamp function, couldn't the second let binding be moved into the function body since it is only there for side effects anyway?
10:47justin_smithI mean now-plus
10:49justin_smithoh, I was about to edit it and see it is changed already :)
10:49martinklepschjustin_smith: yeah just did it :)
10:50martinklepschI thought it looks nice because I was thinking that I'd have to integrate it into the second form but you're right, since it's just for side effects I can just rely on (do ... )
10:50martinklepsch*looks better
10:55shiranai_martinklepsch: btw, i may be missing something here, but it might be a good idea to leave out setting the timezone to GMT.. afaik it's easier to work with dates if you handle timezones when *displaying* dates, not when manipulating them
10:55shiranai_ohhh.. and GMT is just UTC anyway.. so i'm not sure if that even changes anything :P
10:56shiranai_(unless there's a system setting for another time-zone and that gets used without specifying a timezone separately, etc)
10:56martinklepschshiranai_: I needed the time as a string in GMT (see here: http://aws.amazon.com/articles/1434/?tag=vig-20 search for "GMT")
10:57martinklepschDate. gives you the current timezone and that wasn't what S3 required
10:57shiranai_martinklepsch: yeah i guess that would be the system timezone then
10:58shiranai_i seemed to remember UTC being the default.. i think that's what the "Z" signifies in the date string
10:58shiranai_but alright :p
11:06justin_smithTimMc: were you the one with the easier to use frontend to clojure.reflect?
11:18nomad111hi folks, trying to start using clojure. I would like to use it to build distributed computation workflow. Currently I am only aware of Apache Storm that is tailored to do this. Are there any libs or frameworks in the Clojure ecosystem that I should also consider?
11:19justin_smithnomad111: I talked to some folks that were running clojure on hadoop
11:19nomad111my understanding is that hadoop is intended for large workloads
11:20justin_smithnomad111: clojure can use anything made for the jvm
11:20justin_smithor maybe it would be better to say anything made for the jvm can use clojure
11:20nomad111yes im aware of this, my problem with storm is the lack of documentation to get started with clojure
11:20bbloom_technomancy: was it you i was discussing semver with? or maybe i was just generally bitching about it in here... anyway, i laughed hard at this: https://gist.github.com/jashkenas/c71021bba8ee580ded92
11:21justin_smithnomad111: have you seen this? http://storm.incubator.apache.org/documentation/Clojure-DSL.html
11:21justin_smithstorm explicitly supports clojure
11:21nomad111ye that’s basically the only docco there is
11:21nomad111and some sample code on github
11:21nomad111referenced in that article
11:22justin_smithOK - I can't help you with anything more specific, maybe someone else here can
11:22nomad111all good. only looking to have some more options to evaluate
11:23justin_smithhttps://github.com/yieldbot/marceline ahh - the people I was talking to about hadoop also made this
11:23justin_smithmemory finally clicking...
11:23justin_smithyou should probably look at all yieldbot's projects actually
11:23nomad111brilliant, thanks!
11:24justin_smithnomad111: they had great things to say about the massive amounts of data and low latencies they were getting with this setup
11:25justin_smithand looking at their people, it was specifically Soren Macbeth
11:27dawkirstfrom a newcomer's
11:28dawkirstperspective: Programming Clojure or Clojure Programming?
11:39lgrapenthindawkirst: Programming Clojure
11:52martinklepschIs there some rule of thumb about the number of go blocks one should use for a given problem? I want to do something like (listen to events, asynchronously run functions with events as args (pipeline-like), return results)
11:53justin_smithmartinklepsch: for that, I would say N g blocks grabbing events and running functions, and one collecting results
11:53justin_smithN is determined based on whether the task is IO vs. CPU bound, how many CPUs you have, etc.
11:53martinklepschso with one event type that would make 2 go blocks?
11:53martinklepschio-bound (uploading files)
11:53justin_smiththe adding of events to the queue doesn't need to be in a block, of course
11:54justin_smithyeah, if you are io-bound, two blocks should suffice (unless you are hitting multiple hosts or whatever)
11:55martinklepschone host. when there are a lot of events I'd like to parallelize stuff but I guess that's not of interest right now
12:12lgrapenthinmartinklepsch: justin_smith: Shouldn't the amount of cores only factor in when using threads?
12:27jeffterrellrkneufeld: Thanks for the lein-try plugin. Pretty useful!
12:50Rapphi everybody
12:50Rappi am fairly new to clojure. i have produced something of this kind: #<String[] [Ljava.lang.String;@6bb7b3fb>
12:50Rappi think this is supposed to be some kind of string array?
12:52Rappi produced it like this: (-> "a b c" .toUpperCase (.replace "C" "X") (.split " ") )
12:53bbloom_,(into-array String ["yup" "like" "this"])
12:53clojurebot#<String[] [Ljava.lang.String;@e2a718>
12:53bbloom_,(class (into-array String ["yup" "like" "this"]))
12:53clojurebot[Ljava.lang.String;
12:53bbloom_at that point, normal java operations can be applied to strings
12:53Rappthanks bbloom_
12:53Rappi was wondering if i could continue the -> threading afterwards.
12:54Rapphowever, trying to do a (map println) failed.
12:54Rapphowever, i could wrap (map println ...) around the whole form
12:54bbloom_Rapp: you can also use http://clojure.github.io/clojure/clojure.string-api.html for more portable, clojure-ish string operations
12:54Rappbbloom_: thanks for the hint. i am more trying to understand core clojure concepts, like the -> macro in this case
12:55Rappso actually, my question is: why does this work:
12:55Rapp(map println (-> "a b c" .toUpperCase (.replace "C" "X") (.split " ") ))(map println (-> "a b c" .toUpperCase (.replace "C" "X") (.split " ") ))
12:55Rappsorry. twice pasted
12:55Rappand not this:
12:55bbloom_a few things
12:55bbloom_1) map is lazy and pritnln is an effect
12:55bbloom_,(do (map print (range 10)) nil)
12:55clojurebotnil
12:56bbloom_,(do (take 2 (map print (range 10))) nil)
12:56clojurebotnil
12:56Rapp(-> "a b c" .toUpperCase (.replace "C" "X") (.split " ") (map println ))
12:56bbloom_,(take 2 (map print (range 10)))
12:56clojurebot(0123456789nil nil)
12:56Rappah yes...
12:56Rappof course
12:56bbloom_Rapp: -> threads to the *first* argument, so you're writing (map XXX println)
12:56bbloom_not (map println XXX)
12:57bbloom_Rapp: if you want to traverse a sequence for effects, use doseq
12:57Rappbbloom_: first argument... yes, it says so in the docs... of course...
12:57bbloom_(doc doseq)
12:57clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
12:57bbloom_Rapp: there's also ->>
12:57Rappallright! thanks!
12:57bbloom_but you're better off using let bindings when things get hairy in a long chain
12:57Rappyes, i saw that, but have not read the docs yet ;)
12:57bbloom_there's also ##(doc ..) for interop with jvm objects
12:57bbloom_(doc ..)
12:58clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."
12:59Rapp(doseq [x (-> "a b c" .toUpperCase (.replace "C" "X") (.split " "))] (println x))
12:59Rappthis works nice :)
13:00Rappthanks bbloom_! learned a lot already!
13:00bbloom_,(into [] (-> "a b c" .toUpperCase (.replace "C" "X") (.split " "))) ; if you need the values out
13:00clojurebot["A" "B" "X"]
13:00bbloom_or just:
13:01bbloom_,(seq (-> "a b c" .toUpperCase (.replace "C" "X") (.split " "))) ; seq works on arrays
13:01clojurebot("A" "B" "X")
13:01bbloom_,(-> "a b c" .toUpperCase (.replace "C" "X") (.split " ") seq) ; to continue the chain
13:01clojurebot("A" "B" "X")
13:02bbloom_,(require 'clojure.string)
13:02clojurebotnil
13:02bbloom_,(alias 's 'clojure.string)
13:02clojurebotnil
13:02bbloom_,(-> "a b c" s/upper-case (s/replace "C" "X") (s/split #" "))
13:02clojurebot["A" "B" "X"]
13:02bbloom_^^ avoiding the jvm interop
13:05Rapphmhm. yes, avoiding the jvm interop seems more clojure'y :)
13:09BronsaRapp: btw map does work on arrays
13:11Bronsa,(map identity (object-array ["foo" "bar"]))
13:11clojurebot("foo" "bar")
13:14justin_smithBronsa: how does object-array compare to into-array?
13:14justin_smithis it that into-array tries to make a more specific array type?
13:15Bronsajustin_smith: yes, into-array takes the type of the first element and uses that to construct an array
13:16Bronsa,(class (object-array ["foo"]))
13:16clojurebot[Ljava.lang.Object;
13:16Bronsa,(class (into-array ["foo"]))
13:16clojurebot[Ljava.lang.String;
13:16justin_smithcool
13:16Bronsa,(object-array ["foo" 1])
13:16clojurebot#<Object[] [Ljava.lang.Object;@32177e>
13:16Bronsa,(into-array ["foo" 1])
13:16clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: array element type mismatch>
13:17Bronsa^ colls handed to into-array must obviously be homogeneous
13:18bbloom_Bronsa: into-array is poorly designed :-/
13:18bbloom_,(class (into-array []))
13:18clojurebot[Ljava.lang.Object;
13:18bbloom_,(class (into-array [1]))
13:18clojurebot[Ljava.lang.Long;
13:18bbloom_argh.
13:18bbloom_if not specified, array of objects is the only thing that makes sense
13:18bbloom_taking teh type of the first value is insane
13:18justin_smith,(into-array Integer/TYPE [1])
13:18clojurebot#<int[] [I@120f5c9>
13:18Bronsabbloom_: agreed
13:19Bronsabbloom_: but it's kinda sorta convenient I guess
13:19bbloom_Bronsa: nope.
13:19Bronsabbloom_: you can always use object-array if you actually want an Object[]
13:20bbloom_(doc object-array)
13:20clojurebot"([size-or-seq]); Creates an array of objects"
13:20bbloom_(doc into-array)
13:20clojurebot"([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
13:20bbloom_i'd just eliminate into-array/1
13:20bbloom_that overload isn't needed at all :-P
13:21Bronsaright, it's not needed, but I'm cool with doing (into-array [(SomeIncrediblyLongJavaClass. "foo")])
13:22bbloom_,(def S java.lang.String)
13:22clojurebot#'sandbox/S
13:22bbloom_,(into-array S ["abc"])
13:22clojurebot#<String[] [Ljava.lang.String;@ae15ce>
13:23bbloom_,(S. "abc") ; does this work? i don't think it does...
13:23clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: S, compiling:(NO_SOURCE_PATH:0:0)>
13:23bbloom_yeah
13:24justin_smith,(new S "hello") ; nor thing
13:24clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: S, compiling:(NO_SOURCE_PATH:0:0)>
13:24justin_smith*this
13:26justin_smith,(-> [] clojure.reflect/reflect :bases) ; TIL
13:26clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.reflect, compiling:(NO_SOURCE_PATH:0:0)>
13:26justin_smith,(require 'clojure.reflect)
13:26clojurebotnil
13:26justin_smith,(-> [] clojure.reflect/reflect :bases) ; TIL
13:26clojurebot#{clojure.lang.APersistentVector clojure.lang.IObj clojure.lang.IEditableCollection}
13:26Bronsathat'd need to be compiled into a reflective call rather than using the bytecode for new
13:26bbloom_Bronsa: right
13:27bbloom_Bronsa: although in theory it could compile in to a reflective call if the class isn't statically known & warn like other operations
13:27Bronsabbloom_: yeah
13:27bbloom_Bronsa: but i think there's actually a syntactic ambiguity in that case
13:27bbloom_i forget exactly, but i ran in to some weird edge case w/ package names or something
13:28Bronsano I don't think so. Classes are always resolved before locals/var lookups
13:28justin_smitharrdem: grimoire is giving me a bad gateway error
13:28Bronsa,(let [String 1] String)
13:28clojurebot1
13:28Bronsaoh well. I'm wrong.
13:28bbloom_heh
13:28Bronsa,(def String 1)
13:28clojurebot#<CompilerException java.lang.RuntimeException: Expecting var, but String is mapped to class java.lang.String, compiling:(NO_SOURCE_PATH:0:0)>
13:28Bronsapff
13:28arrdemjustin_smith: kay. I'll look into it
13:29Bronsa,(intern *ns* 'String 1)
13:29clojurebot#<SecurityException java.lang.SecurityException: denied>
13:29doctormAnyone use vim-fireplace? I’m getting a weird error “Vim(python):Traceback (most recent call last): “ instead of a clojure stack trace like described in the documentation when I evaluate a form that throws an exception.
13:29doctormEvaluating forms that don’t throw an error works fine
13:30doctormThis is using cpp
13:30arrdemjustin_smith: kicked the webserver, it's back up. looks like the JVM actually crapped out somehow
13:31justin_smitharrdem: interesting - with any luck you have logs
13:31arrdemjustin_smith: not as good logs as you'd think
13:31arrdemschool work stuff to do today but 75% of the next Grimoire release is gonna be logs and stability shit
13:32justin_smithone of the few advantages of using a container like Tomcat - you have to work pretty hard to prevent extensive logging
13:33arrdemtrue. one issue with the 0.3.4 build is that I can't uberjar it for something like tomcat
13:33arrdemit relies on File.exists
13:33justin_smitha quick hack - run from nohup with a timestamped output file name
13:33justin_smitharrdem: tomcat unzips the uberwar
13:33arrdemI already have logs, I just need to add a log rotation system
13:33justin_smithahh
13:34dbascharrdem: if you’re running on an aws micro, the kernel probably killed the jvm
13:35arrdemdbasch: digitalocean
13:35dbascharrdem: free tier?
13:36arrdemdbasch: lowest paid. same node I use for this IRC connection among other things.
13:36dbascharrdem: same thing then, the kernel must have killed your jvm
13:36justin_smith#butdoesitscale
13:36arrdemdbasch: the kernel shouldn't be wandering around whacking off long running pss...
13:36dbascharrdem: it shouldn’t but it does
13:37justin_smithit will whack things that exceed your allocated resources, right?
13:37arrdemmeh
13:37dbascharrdem: https://www.kernel.org/doc/gorman/html/understand/understand016.html
13:37justin_smithfor example, the kernel will overcommit, but when memory actually runs out, the program trying to access the new memory gets slain
13:38arrdemright. bah.
13:38arrdemgoddamnit I don't want to memory profile this shit
13:38dbascharrdem: just have a watcher that restarts it
13:38arrdemdbasch: that'd work.
13:39justin_smithdbasch: I know that works, but that reminds me of ruby in ways I don't like
13:39arrdemhum. looks like I'm memoizing the cheatsheet and the namespace pages...
13:39arrdemthose should be almost free
13:40arrdemnot like I'm caching literally every symbol
13:46justin_smithTIL there is such thing as a permutohedron
13:46justin_smithwhich makes me very happy
13:47justin_smith(graph where every node is a corner describing a polyhedron, and edges are swaps of elements to get from one permutation to the next)
13:47justin_smiths/edges/vertexes oops
14:11teslanickI'm trying to get a clojure app to start on heroku, but it's giving me the most useless exception ever -- has anyone ever seen this? https://gist.github.com/nhusher/fa7ed3c6a8b2f98e2352
14:12teslanickI've run other clojure apps in heroku, and their example app starts just fine. My sailcloth app runs just fine locally (lein run / java -cp ...).
14:12teslanickBut it crashes on heroku
14:12justin_smithteslanick: and that's definite an uberjar?
14:13justin_smith*definitely
14:14teslanickFairly sure
14:14justin_smithwell, I guess if java -cp ... works locally
14:14teslanickhttps://gist.github.com/nhusher/fa7ed3c6a8b2f98e2352#file-z-build-log-txt - that's the result of pushing to the heroku remote
14:15teslanickWait a second, I think it might be building into the wrong directory
14:16justin_smithwouldn't java complain about the jar you specify in the path not being there?
14:16teslanickI would think so
14:17justin_smithjava -jar foo.jar version => "Error: Unable to access jarfile foo.jar"
14:18teslanickYeap. For whatever reason, locally it was putting the uberjar named "sailcloth-standalone.jar" into "target", but on heroku, it was putting it into "target/uberjar/..."
14:18teslanickThanks for being my rubber duck. :|
14:19teslanickhttp://sailcloth.herokuapp.com/weather-data/44.4758/-73.2119
14:22justin_smithwell, that sure is some weather data
14:23teslanickPowered by forecast.io, but the forecast.io webapp and darksky (based on the same api) both have lousy wind speed forecasts. I want something to give me a "sailing forecast" for the next 7 days.
14:24justin_smithcool
14:44samfloresis there some core function that returns a coll of values from a map based on provided keys? something like (pseudo-get {:k1 1 :k2 2 :k3 3} [:k3 :k1]) ;; => [3 1]
14:46Duke-,(vals (select-keys {:k1 1 :k2 2 :k3 3} [:k3 :k1]))
14:46clojurebot(1 3)
14:47Duke-hmm, wrong order...
14:47rhg135maps have no defined order though
14:48rhg135i wouldn't be surprised at this behavior
14:48Bronsarhg135: but the vector he's using does
14:49Duke-yeah I guess it should print it in the order of the select-keys vector
14:49rhg135true
14:50Bronsa,(mapv {:k1 1 :k2 2 :k3 3} [:k1 :k2])
14:50clojurebot[1 2]
14:50Bronsasamflores: ^
14:50ephemeronsamflores: Why not just map the hashmap over the keys?
14:50ephemeron…as above.
14:50samfloresdamn, I keep forgeting the keys are functions
14:51samflores:D
14:51samfloresthanks
14:51Bronsasamflores: in this case the map is a function
14:51gfredericks,((juxt :k1 :k2) {:k1 1 :k2 2 :k3 3})
14:51clojurebot[1 2]
14:51Bronsa^ in this case the keywords are instead
14:54samfloresdidn't know juxt. very clever
15:03avi__,(juxt :k1 :k2)
15:03clojurebot#<core$juxt$fn__4304 clojure.core$juxt$fn__4304@7d68>
15:04avi__ah
15:04avi__,((juxt :k1 :k2) {:k1 :kv1})
15:04clojurebot[:kv1 nil]
15:04avi__nice
15:12gfredericks,((juxt inc dec) 41)
15:12clojurebot[42 40]
15:12gfredericks,(map (apply juxt (map (partial partial +) (range 5))) (range 5))
15:12clojurebot([0 1 2 3 4] [1 2 3 4 5] [2 3 4 5 6] [3 4 5 6 7] [4 5 6 7 8])
15:13gfredericksI'm gonna try to create a variant of the lazy-seq macro that lets you refer to the seq itself
15:14gfrederickse.g., (defn cycle [coll] (rec-lazy-seq [s] (concat coll s)))
15:16gfredericksthat was easier than I thought
15:18gfredericks(defn repeat [x] (rec-lazy-seq [s] (cons x s)))
15:19gfredericks(def fib (rec-lazy-seq [s] (list* 0 1 (lazy-seq (map + s (rest s))))))
15:26doctormCan someone explain to me (a newbie) why when the up function is called, none of the tables are created, but when I wrap (create-all-tables spec) with (pprint (create-all-tables spec)) it works? https://www.refheap.com/89606
15:27AimHeredoctorm, map is lazy
15:27doctormAimHere, I figured it might be something like that, is there some other function I should use?
15:28doctormWhat’s the idiomatic way to say “execute this vector of function using these arguments"
15:28AimHereAre you actually wanting to evaluate the results of create-table-foo?
15:28doctormI just need them to fire
15:28justin_smithdoctorm: doseq if you don't need the result values
15:28doctormjustin_smith: great, thanks
15:28rhg135mapv
15:28justin_smithrhg135: why make a vector you will never use?
15:28rhg135returns a (non-lazy) vector
15:29rhg135lazinesss justin_smith
15:29doctormrhg135: Good to know though, thanks
15:29rhg135as in programer laziness
15:29justin_smithif you want the syntax of map, but without the laziness, and don't need the result, use (comp dorun map)
15:29rhg135don't do it though
15:29rhg135dorun the lazyseq
15:29justin_smithright
15:30justin_smithbut usually the syntax of doseq is easier to use anyway
15:30rhg135it should be a core function
15:30rhg135would be small
15:30rhg135just a convenience rally
15:30jeffterrellWow, just found a bug in a combination of `prefer-method` and `clojure.tools.namespace.repl/refresh`: http://dev.clojure.org/jira/browse/TNS-23
15:30rhg135really*
15:31justin_smithrhg135: (def domap (comp dorun map))
15:31rhg135exactly
15:31rhg135i know i've use it enough
15:32rhg135does dorun hold the head of the seq?
15:32justin_smithabsolutely not
15:32justin_smithit never even creates the seq
15:32rhg135k good, i can never remember if it's dorun or doall
15:33justin_smithdoall holds the head, yes
15:33justin_smithand mapv is equivalent to doall map, except you also get a handy vector datatype out of the deal
15:40rhg135i see
15:44justin_smithwhich is even worse for heap usage than holding onto the head would be, but it's associative for lookup by index, so it's got that going for it, which is good
15:44gfredericksimpl of rec-lazy-seq: https://gist.github.com/gfredericks/1fe70ed7cd48f31f6218
15:44lxsameerhey guys, is there any lib for creating a proxy server
15:47gfredericksI made one way back in the day but it's terrible
15:48Bronsagfredericks: neat
15:49sameerynhohey guys, is there any lib for creating a proxy server ( sorry to re-messaged , disconnected )
15:49Bronsa(inc gfredericks)
15:49Bronsa:(
15:50gfredericksBronsa: the one time I get karma for something other than telling jokes
15:50justin_smithsameerynho: wouldn't a proxy-server be more of an app than a lib? or is there really that much to customize about a proxy server that you would have a general lib for making them?
15:50Bronsagfredericks: blame it on Raynes
15:52sameerynhojustin_smith: you're right, but I have to write one
15:54sameerynhojustin_smith: is there any networking lib ? like twisted of python or event machine for Ruby or even natty ?
15:55justin_smithsameerynho: the jvm comes with everything you strictly need, though clj-http makes it easier to use (and pulls in some apache commons libs too)
15:56gfredericksnot going to be able to serve requests with clj-http
15:57sameerynhojustin_smith: I'm a clojure rookie and never used jvm before, What do you suggest me ? Natty or Clj-http or anything else
15:57justin_smithdefinitely clj-http
15:58Blorglorbon,(apply str (concat (drop-last "gtg") (vector "zzz")))
15:58clojurebot"gtzzz"
15:59sameerynhothanks dude
16:33amalloy(inc gfredericks) ; Bronsa
16:33lazybot⇒ 84
16:35Bronsa(inc gfredericks) ; there, take an extra one
16:35lazybot⇒ 85
16:36Bronsaalso
16:36Bronsa(dec lazybot) stop being a lazy bot
16:36justin_smith(dec lazybot)
16:36lazybot⇒ 29
16:36Bronsauh
16:36justin_smithBronsa, did you get ignored?
16:36Bronsa$karma
16:37Bronsa$karma justin_smith
16:37lazybotjustin_smith has karma 70.
16:37Bronsano
16:37Bronsajustin_smith: maybe lazybot has a throttler
16:37justin_smithperhaps you are restricted from using inc/dec
16:37justin_smithI think there is for karma, yeah
16:39Bronsajustin_smith: I just inc'd gfredericks
16:39justin_smithoh, I missed that
16:40arohnergfredericks: what are your requirements for the proxy server?
16:40arohnerI happen to be writing one atm
16:42amalloyBronsa: the parser for inc/dec is just really basic. if you have trailing stuff that isn't commented out, he doesn't like it
16:42Bronsaah
17:18benzapso i'm trying to apply arguments to optional args area of a function, how does one do this?
17:19benzaplike, (defn foo [& args]) (apply foo [:bar true])
17:23benzap,(defn foo [& args] args) (apply foo [:bar true])
17:23clojurebot#'sandbox/foo
17:24benzap,(apply foo [:bar true])
17:24clojurebot(:bar true)
17:24benzapso it appears my problem has something to do with clojurescript, and not clojure
17:53avishaiusing mijde, i need to make a metaconstant behave like a seq
17:53avishaie.g. to make (when (seq x)) happy
17:58avishai(seq ..m..) => (list ..m..) make midje hang
18:01johnwalkerwhat is ..m.. ?
18:03avishaia metaconstant
18:13gfredericksarohner: that wasn't me
18:13gfredericksamalloy: Bronsa: thanks guys I'm gonna use the karma to help pay down my karma-mortgage
18:13arohnergfredericks: ah, you're right. my mistake
18:14TEttingerI'm a bit confused here...
18:14TEttinger,(with-bindings {*print-length* 10} (iterate inc 0))
18:14clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.Var>
18:14amalloyTEttinger: the binding only lasts long enough to eval it, not print it
18:14BronsaTEttinger {#'*print-length 10}
18:15TEttingerwhat's the proper way to set *print-length* ?
18:15Bronsaset!
18:15TEttinger,(do (set! *print-length* 10) (iterate inc 0))
18:15clojurebot(0 1 2 3 4 5 6 7 8 9 ...)
18:15TEttinger##(do (set! *print-length* 10) (iterate inc 0))
18:15lazybotjava.lang.SecurityException: You tripped the alarm! set! is bad!
18:15TEttingerhm
18:15TEttingermaybe not
18:17TEttingerthe exact context is a way to do this on lazybot to show a way around infinite loops in languages with macros
18:18vermado I have to wait for CLojure 1.7 to use transducers?
18:18Bronsaverma: you can use the alphas
18:18Bronsaalpha1 is already out
18:19vermaBronsa, not sure if I should be doing that for semi-production stuff
18:19TEttingerclojurebot already uses it, it seems quite stable so far
18:19Bronsaalpha2 might come out soon according to Alex Miller
18:19Bronsaverma: alpha1 is really just 1.6 + transducers
18:19vermaBronsa, oh ok then, I am convinced ;)
18:19Bronsathe only other thing that changed is how keywords/symbols are interned, internally
18:20fifosineI have a list of elements with which each I perform a series of functions using doseq. I also need to perform functions *between* each element (i.e. if I'm operating on (range 3), I need to execute functions between 0 and 1 and between 1 and 2). How would I go about doing this?
18:20Bronsaverma: transducers might still have bugs though
18:20vermaBronsa, oh, are they deemed stable in clojurescript?
18:21TEttingerfifosine, what argument would the between function take?
18:21TEttinger0.5 ?
18:22fifosineTEttinger: No, the function takes no arguments.
18:22fifosineI'm thinking about using interpose?
18:22fifosineby creating a list of function calls
18:22Bronsaverma: I don't really know, but their implementation is pretty much the same as clojure's
18:23fifosineI'm wondering, does this require the backtick? I don't have much experience using it
18:25Bronsaverma: they should be stable enough though. The only bug reported until now was about comparing a lazy seq produced with a transducers with another lazy seq, a fix for that will be in the next alpha
18:25fifosineTEttinger: Does what I'm asking make sense? In the (range 3) example, I'm thinking of creating a list like ((func 0) (no-arg) (func 1) (no-arg) (func 2)). How do I create this list without evaluating the functions?
18:26Bronsaalso I believe there will be performance enhancements for some transducer functions in the next alpha, there are a bunch of tickets for that on JIRA that people are working on
18:26fifosineAnd then do I use doseq to eval the list of funcs?
18:26vermaBronsa, hmmm, nice, thanks
18:28fifosine,(doseq [foo (for [x (range 3)] `(println x))] (eval foo))
18:28clojurebot#<CompilerException java.lang.RuntimeException: No such var: sandbox/x, compiling:(NO_SOURCE_PATH:0:0)>
18:28fifosineHow do I correct this mistake
18:29TEttinger,(doseq [foo (for [x (range 3)] '(println x))] (eval foo))
18:29clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>
18:29TEttingerhm
18:29fifosineWhile keeping the creation of a list of function calls
18:29Bronsafifosine: you want ~x instead of x, but even then it won't make sense
18:29Bronsa,(for [x (range 3)] `(println ~x))
18:29clojurebot((clojure.core/println 0) (clojure.core/println 1) (clojure.core/println 2))
18:29fifosineAnd then how do you eval that list
18:29weavejesterThe function calls need to be symbols, they can’t be function objects (unless you look in the metadata I guess).
18:29Bronsafifosine: why do you want to do that?
18:30amalloyfifosine: don't create a list and eval it; create a lambda and call it
18:31weavejesterIt also depends on whether you want this in a macro or not
18:31fifosineBronsa: The original problem is: for a list of elements, I need to perform a series of functions via doseq for each element, but also I need to perform a no-arg function *between* each element. I thought I could solve this by interposing the list of fn-calls that take args with a list of the no-arg fn and then evaling the list
18:31fifosineweavejester: Does this seems like a problem solved by a macro? I don't have experience writing them so maybe this is a good opportunity to learn
18:31weavejesterfifosine: Oh, don’t eval - just take advantage of closures
18:31amalloyfifosine: no macro
18:31weavejesterfifosine: No macro is needed
18:32Bronsafifosine: using eval is rarely the right answer, close to never actually
18:32fifosineok, what's the proposed solution then?
18:33weavejesterfifosine: Just to be clear, is it the one function for all elements?
18:33Bronsafifosine: you can't really do that with doseq, you need to use loop
18:34weavejesterfifosine: e.g. (foo a) (no-arg) (foo b) (no-arg) (foo c)
18:34fifosineweavejester: No, ((foo1 a) (foo2 a) (no-arg)…)
18:34weavejesterfifosine: Then (foo1 b) (foo2 b) ?
18:34fifosineyes
18:35fifosineBronsa: How will loop solve the interpose problem?
18:36weavejesterOkay, so ((juxt foo1 foo2) a) will get you [(foo1 a) (foo2 a)]
18:36Bronsafifosine: you can avoid executing no-arg if you're running over the last element
18:36fifosineBronsa: How do you check for last in a loop form?
18:36weavejesterfifosine: Do you want the no-arg function interposed, or after every set of foos? i.e. will the last form be the no-arg function, or foo2?
18:37Bronsafifosine: (loop [x (range 3)] (when (seq x) (f (first x)) (let [r (rest x)] (when r (no-arg)) (recur r))))
18:37fifosineBronsa: I think the way weavejester is going about it is cleaner
18:37fifosineweavejester: interposed for each pair
18:37fifosineThe later in your question
18:38weavejesterOkay, so… maybe you start with: (map (juxt foo1 foo2) xs)
18:38fifosine(foo1 a) (foo2 a) (no-arg) (foo1 b) (foo2 b)
18:38Bronsafifosine: I don't think there's a better way to do it than this
18:39Bronsaother alternatives require running over the sequence more than once
18:39weavejesterThat will get you [[(foo1 x1) (foo2 x2)] [(foo1 x2) (foo2 x2)] …]
18:39weavejesterActually… are these side-effectful functions?
18:39fifosineweavejester: was just gonna say, yes :/
18:39weavejesterI had kinda assumed they were pure.
18:39Bronsafifosine: e.g. you could do (doseq [x (butlast y)] (f x) (no-op)), (f (last y))
18:39fifosineside-effectful
18:40Bronsano-arg, rather
18:40weavejesterOh. Then… it’s just a loop.
18:40weavejesterOr a doseq without the last element, as Bronsa mentioned.
18:41weavejesterNo need to do juxt, map and mapcat interpose.
18:42arohnerin chrome, I can run "Intl.DateTimeFormat().resolved.timeZone;", and get a value
18:42amalloy(doseq [f (interpose no-arg (for [[a b] (partition 2 1 coll)] #(two-arg a b)))] (f)) would be another approach, i think
18:42arohnerin a weasel repl, I can't resolve "Intl" or (js/Intl). Is that expected?
18:42arohner(a weasel repl connected in the same chrome tab)
18:43amalloybut i confess i haven't kept up with the entire backlog
18:45weavejesterOut of interest, does anyone happen to know much about Om?
18:45fifosineamalloy: Thanks! this is the solution I was looking for.
18:45arohnerweavejester: I'm using it, but I wouldn't say I know "much" :-)
18:46Bronsaamalloy: neat
18:46weavejesterI’m curious at how the component functions work. Are they called n times a second in some event loop?
18:46weavejesterI assume not :)
18:46arohnerwdym component functions?
18:46fifosineamalloy: What's the function of the # symbol here?
18:46arohnerweavejester: AFAIK, the rendering is event-driven, based on changes to your state
18:47weavejesterarohner: The functions that return an object that has the IRender or IRenderState protocol
18:47arohnerI'm reasonably confident they only re-render when you change state
18:48arohner(or force it to redraw, using low-level API calls)
18:49weavejesterarohner: So if I change a small part of the state, is Om smart enough to not to re-render components which haven’t been passed changed state?
18:49arohnerweavejester: I think so
18:50weavejesterI guess it must do that with om/build combined with the cursors, then...
18:53arohnerweavejester: yeah. this seems to explicitly say what you expected: https://github.com/swannodette/om/wiki/Cursors
18:54weavejesterarohner: Ah, so Om constructs a tree and assigns a state cursor to each component. Okay, I think that makes sense.
18:55weavejesterOm looks a little magical at first glance. Maybe I’ll suggest to David Nolen that some docs on how Om works behind the scenes might be useful :)
18:57arohneryeah, the docs aren't there yet
18:57arohnerand neither are React's
19:22Guest33092is there anyway to "single step" through clojure? trace seems to fail to produce output when an exception is raised ..?
19:35TehShrikehas anyone successfully used Browserify+Clojurescript?
19:44TehShrikeWhat's the "Eloquent Javascript" equivalent in Clojurescript?
19:45ToBeReplacedTehShrike: I'm not sure there is one... but dnolen's blog posts are a good starting point for cool-things-with-little-code
19:46ToBeReplacedTehShrike: as for browserify... i don't know of anyone trying it, but i think most people would tend to avoid it in favor of alternatives
19:47TehShrikeToBeReplaced: thanks for the tip - what are the alternatives I should be looking at?
19:48TehShrikeI'm hoping to use ClojureScript in the browser, but I can't go back to a world where I write client-side code without modules from npm
19:52benzaphow do I convert a keyword to a string without it keeping the colon?
19:52benzapnvm, name
19:52rhg135,(name :this)
19:52clojurebot"this"
19:53rhg135darn lag :D
19:53ToBeReplacedTehShrike: i would use the namespace system built in to cljs and if necessary the externs system for other libs
19:53ToBeReplacedTehShrike: i haven't reached for npm accessible libs, so i can't comment on how to bring them in effectively
19:57TehShrikewhat do clojurescript peeps use for package management?
19:57ToBeReplacedTehShrike: leiningen
19:57ToBeReplacedmost people use lein-cljsbuild for cljs compilation as well
19:58TehShrikeCool, I guess I should get those installed
20:03TehShrikeoh hey, clojars is handy
20:04justin_smithTehShrike: in my experience, leiningen is generally the sane dependency management system that npm could have been
20:05justin_smithalso check out "lein search" to find things in all your repos, not just clojars
20:05TehShrikeIt's backed by Maven?
20:05justin_smithit uses some of the same libs, but it is its own stack
20:05justin_smithit uses the same apis though
20:05TehShrikeinteresting
20:06justin_smithiow you don't need maven installed for lein to work
20:06justin_smithbut it can use maven repos, and push to them, etc.
21:22TimMcjustin_smith: Yeah, org.timmc/handy has a (partial) reflection lib; the o.t.h.repl/show fn is great from the REPL.
21:23TimMc(if I do say so myself)
21:23justin_smithahh, I remembered correctly then
21:24justin_smithTimMc: question was brought up by this so post http://stackoverflow.com/q/25583694/2258453
21:26justin_smithbest answer was iroh https://github.com/zcaudate/iroh which is kind of heavy on syntax / DSL stuff, but has some neat features
23:00or9obHello folks. I want to change a deeply nested map into a vector with the first level of map entries as entries.
23:00or9obSo, change {:a 1 :b {:c 3 :d 4}} to [{:a 1} {:b {:c 3 :d 4}}]
23:00or9obThis can do that: (map (fn [[k v]] {k v}) deeply-nested-map)
23:01or9obbut I get the sense that there is a more idiomatic way.
23:01or9ob(like using into etc.).
23:01or9obAny better alternatives?
23:02TEttinger,(mapv hash-map {:a 1 :b {:c 3 :d 4}})
23:02clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: [:b {:c 3, :d 4}]>
23:08or9ob,(format "Wow, didn't know %s can eval code here" "clojurebot")
23:08clojurebot"Wow, didn't know clojurebot can eval code here"
23:17amalloy,(map #(into {} %) {:a 1 :b {:c 3 :d 4}})
23:17clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
23:17amalloy,(map #(conj {} %) {:a 1 :b {:c 3 :d 4}})
23:17clojurebot({:b {:c 3, :d 4}} {:a 1})
23:17amalloyor9ob
23:18or9obThanks @amalloy