#clojure logs

2015-04-07

01:05ncthom91so in clojure I can define multi-arity functions, i.e. functions that have different bodies that correspond to invocations with differet numbers of arguments
01:06ncthom91can I do the same style of differentiation on the type of a single argument?
01:06ncthom91(defn example ([^String x] x) ([^Integer y] (* 2 y)))
01:11sm0kencthom91: no you will need multimethod which dispatches on type
01:12sm0kereason being clojure is untyped
01:18ncthom91cool thanks
02:31justin_smithWell, dynamically typed. There are untyped languages, but they are nothing like Clojure.
02:33p_lyeah, static/dynamic and strict/weak are two different axes in typing
03:52DyanaHi guys
04:03dstocktonHi
04:11TEttingerhi dstockton
05:17nilernncthom91: you can also use protocols if you just need to dispatch on the type of the first argument
08:08timvisheranyone aware of a function that obeys this contract? `Compares the keys of two maps, a and b, returning a tuple of sets [things-only-in-a things-only-in-b things-in-both]`
08:08timvisherclojure.data/diff doesn't do quite the right thing here, in that it returns nils for equal values
08:08timvisherthe implementation is very straightforward, but this just seems like something that others would have implemented already
08:23TEttinger,(require '[clojure.set :as s])
08:23clojurebotnil
08:27TEttinger,(let [map-a {:a 1 :b 2 :z 26} map-b {:x 24 :y 25 :z 26} key-diff (fn [a b] (let [ak (keys a) bk (keys b)] [(s/difference ak bk) (s/difference bk ak) (s/intersection ak bk)]))] (key-diff map-a map-b))
08:27clojurebot#error{:cause "clojure.lang.APersistentMap$KeySeq cannot be cast to clojure.lang.IPersistentSet", :via [{:type java.lang.ClassCastException, :message "clojure.lang.APersistentMap$KeySeq cannot be cast to clojure.lang.IPersistentSet", :at [clojure.core$disj invoke "core.clj" 1453]}], :trace [[clojure.core$disj invoke "core.clj" 1453] [clojure.core.protocols$fn__6439 invoke "protocols.clj" 135] [clo...
08:27TEttingerwoah, keys aren't a set?
08:28TEttinger(doc keys)
08:28clojurebot"([map]); Returns a sequence of the map's keys, in the same order as (seq map)."
08:28justin_smithTEttinger: no, they have to be in the same order as vals
08:28hyPiRionof course not. It's just (fn [m] /map key m)(
08:28TEttingermm.
08:28hyPiRionWell that formatted nicely
08:28TEttingerheh
08:28TEttinger,(let [map-a {:a 1 :b 2 :z 26} map-b {:x 24 :y 25 :z 26} key-diff (fn [a b] (let [ak (set (keys a)) bk (set (keys b))] [(s/difference ak bk) (s/difference bk ak) (s/intersection ak bk)]))] (key-diff map-a map-b))
08:28clojurebot[#{:b :a} #{:y :x} #{:z}]
08:28hyPiRion,((fn [m] (map key m)) {:a :b :c :d})
08:28clojurebot(:a :c)
08:29TEttingerthere you go timvisher
08:29timvisherTEttinger, hyPiRion: sorry. tried to be clear that the implementation is really straightforward
08:30timvisherwhat i was specifically asking about is whether anything like useful or plumbing had already implemented it
08:30timvisherobviously it's trivial to write yourself
08:30timvisheryou guys have basically written exactly what i already wrote :)
08:30TEttingeryeah I like trivial tasks
08:30justin_smithI'll take obfuscated Clojure one liners for 500, Alex
08:31jcromartiethe docs at https://github.com/clojure/core.cache contains ZERO hints that you need to manage cache state yourself
08:31jcromartieand that caches are immutable values
08:31jcromartiewell, sort of immutable... e.g. the TTL cache changes over time
08:33Glenjaminjcromartie: i found that too, without a "how-to" guide it's a bit abstract
08:35noncomif i have a checkout dependency in lein, how can i find a filesystem path to a ns file inside that project?
08:35noncomor, better to a package
08:38justin_smithnoncom: there's a trick for getting a path for a resource from a classloader iirc
08:41mavbozo_jcromartie, Glenjamin is this guide not enough https://github.com/clojure/core.cache/wiki/Using ?
08:41mavbozo_jcromartie, Glenjamin is this guide not enough https://github.com/clojure/core.cache/wiki/Using ?
08:41mavbozo_sorry, weird keyboard behavior
08:43mavbozo_the core.cache wiki is quite good but no mention about it in the README.md
08:45noncom,(defn z [] [:a :b :c])
08:45clojurebot#'sandbox/z
08:45noncom,(-> (z) first)
08:45clojurebot:a
08:53Glenjaminmavbozo: that Intro doesn't mention anything about persisting the cache. iirc you have to back it by at atom or something?
08:58TEttinger,(defn wat [])
08:58clojurebot#'sandbox/wat
08:58hyPiRionnil
08:58TEttinger,(wat "wat?")
08:58clojurebot"wat?"
08:59justin_smithhaha, bom strikes again
08:59TEttingerheehee
08:59TEttingerthat's a good one, it even works in just about any no-arg fn
09:00TEttinger,(defn unintended-identity [] (+ 1 2 3))
09:00clojurebot#'sandbox/unintended-identity
09:00TEttinger,(unintended-identity 1)
09:00clojurebot1
09:09virmundihello. I have defined a protocol, ActionRecord, in ns something.data. In the ns something.core I :require [something.data :refer :all]. When I attempt to use the function "save-record" on ActionRecord, I get an unable to resolve symbol: save-record error
09:09virmundiThe code is (save-record implOfActionRecord arg1 arg2)
09:10virmundiif I use (.save-record impl arg...), it works
09:10virmundiis this how Clojure functions?
09:10justin_smithif you have :refer :all save-record should work
09:11mavbozoGlenjamin, yeah, the using guide assumes we know what we are going to do with returned value from those cache operations
09:13virmundijustin_smith: you're right. that works. I had :ref [ActionRecord]. is there a way to refer to the protocol without the whole ns and get it work?
09:15dstocktoni want to load a csv (~100s of MB) into some kind of querying engine, run some aggregates/queries based on the columns, and then destroy all traces
09:15dstocktonwas thinking elasticsearch to be a good fit, are there some names/buzzwords i might be overlooking
09:15dstocktoni don't need persistence
09:18schmirdstockton: sqlite may also help
09:18dstocktonschmir: indeed, its between those 2 atm
09:18virmundijustin_smith & all: let me redefine my confuse with Clojure. If I (:require [something.data :refer [save-record]), the function appears. It is totally detached from my protocol scoping. Are protocols just syntax sugar for function declarations, but every function ends up in the namespace in which it's defined?
09:19dstocktonthe advantage of elasticsearch is presumably that i could distribute the work if the data grew
09:19dstocktonharder with sqlite
09:19mavbozodstockton, if you want to put all those rows from the csv into clojure collections, you might want to experiment with datomic datalog https://gist.github.com/stuarthalloway/2645453
09:23dstocktonmavbozo: unfortunately its not a clojure project
09:23dstocktonim just stealing smarts from the clojure community
09:25schmirdstockton: I've done the same recently and used sqlite to import around 1GB csv files into sqlite
09:25schmirdstockton: worked like a charm
09:26schmirdstockton: but elasticsearch certainly is also a good choice
09:27dstocktonsqlite definitely meets my needs for now, i was mostly thinking of future-proofing it
09:28crazydiamondHi. Is there version of split, that preserves splitting elements? https://clojuredocs.org/clojure.string/split e.g. (split "q1w2e" #"\d+") to give ["q" "1" "w" "2" "e"] instead of just ["q" "w" "e"]?
09:29dstocktonprobably optimizing prematurely, if i use decent abstractions i can swap it later
09:43oddcullycrazydiamond: something like (let [s "q1w2e" r #"\d+"] (interleave (clojure.string/split s r) (re-seq r s))) ?
09:43crazydiamondoddcully, cool, thanks!
09:44crazydiamonddon't yet know all the stuff
09:44oddcullybetter wait what the gurus here have to say about it ;P
09:47TMA,(split "q1w2e" #"(\d\+)")
09:47clojurebot#error{:cause "Unable to resolve symbol: split in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: split in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: split in this context", :at [clo...
09:48TMA,(clojure.string/split "q1w2e" #"(\d\+)")
09:48clojurebot["q1w2e"]
09:48TMA,(clojure.string/split "q1w2e" #"(\d+)")
09:48clojurebot["q" "w" "e"]
09:49TMAperl uses capturing () to preserve the delimiters, a thing that was not carried over apparently :(
09:51bjaI thought () in PCRE delimited groups?
09:52bjait certainly does in the python pcre implementation
09:52chouserThis would be specifically for split, I think.
09:52netrobyWhen will Clojure 1.7 will be released?
09:53TMAspecifically perl's split /(\d+)/, "q1w2e" would exhibit the aforementioned behavior
09:55chouserTMA: Here's a fn from a deprecated lib that splits but also captures the delimiters: https://github.com/clojure/clojure-contrib/blob/13f960559f724521070d761639310d8b1f503216/src/main/clojure/clojure/contrib/string.clj#L208
09:56chouserHaven't tested it in ages, but it might still work. Dunno if that helps you or not.
09:58TMAcrazydiamond: ^^
09:58crazydiamondthanks TMA and chouser
10:00chouserI don't know why that didn't make the transition from contrib to clojure.string. *shrug*
10:09jcromartiemavbozo: it seems to be missing from any of the official documentation, even the example usages
10:10jcromartiethe example usages are even misleading, I'd say, because they look like examples of using a stateful object
10:10jcromartiebut it's a wiki
10:10jcromartieso I can edit that, right
10:23mavbozojcromartie, well, in the code comments there are phrases "returns a cache", "returns a new cache". But, I agree on more clarity on the usage.
10:45andyfnetrobyatmobile: They announce when it is released, but do not promise any release dates in advance. My unofficial non-binding best guess: June 2015 or earlier. The list of things left to do is fairly short.
10:55andyfHere is Alex Miller?s list of things left to do before Clojure 1.7 release: https://groups.google.com/forum/#!msg/clojure/D2E4HG1yXBc/C34JWa8ylrQJ
10:57phillordandf: pity they don't have a issue called "write a description of transducers a normal person can understand"
10:57phillordandyf that is...
10:58andyfphillord: Have you watched Rich Hickey?s talk on it? I haven?t yet, but was hoping that would shed light on the topic for me, when I get around to it.
10:58phillordI've watched some of it, but not all
10:58phillordvideo's don't really fit into my life, which might be the problem
10:58andyfUntil then, the short way I keep it in my head is "it is a performance optimization -- useful but not critical until and unless you need that performance"
10:59Bronsaandyf: it's not just about performance
10:59andyfApparently I keep it in my head wrong, then.
10:59BronsaI don't even think transducers are *always* faster than "normal" seq ops TBH
11:00phillordI do wonder how many problems are going to be introduced
11:00phillordI mean, calls that would previously given an arity exception will not return a transducers IIUC
11:00andyfIs it "often performance + unifying how to operate on sequences and core.async streams"? How would you summarize the benefits and reasons to create them?
11:01andyfphillord: That is true. Shows how much they wanted to add them :)
11:01Bronsaandyf: s/sequences and core.async.streams/reducibles/
11:01BronsaIIUC
11:01phillordseems like a pretty overloaded return type to me
11:02phillordbut yes, clearly, they really cared about them
11:02phillordI would have prefered they spent the time on rewriting the docstrings but hey
11:03Bronsaphillord: I'm not a fan of that overloading either and have complained about it when transducers were first introduced. Core is set on making them clojure.core citizens so I don't think there's a chance that will change
11:03andyfThere is ClojureDocs for anyone that wants to for enhancing the doc strings. Has been for years. Do not wait for the core team to rewrite the doc strings. Make it happen!
11:04andyfPlus, by making it happen yourself, you find out how time-consuming it can be :)
11:05sandbagsas someone who is, a little painfully, using CLJX wondering what the wisdom of the group was on the reader conditions in alpha6?
11:06andyfDepending upon your pain points, they may help, they may not.
11:06dnolenBronsa: I've never seen seq ops be faster than transducers unless your talked about chunked seqs, also seq ops presume really good GC, while enjoyed on prduction JVMs may or may not be true for CLR or JS
11:06sandbagsso far mainly process and tooling support, i guess having everything baked in will alleviate those
11:07phillordandyf: sure, I agree -- I think thalia was a notable push in the "better documentation" category
11:07andyfSome tooling may need updating to support them -- depends upon the tool.
11:08andyfphillord: And there isn't much there, and it took quite a bit of digging and experimenting to get even that little bit written.
11:08dnolenandyf: as Bronsa said transducers not just about perf, they are functional operations decomplected from application strategy
11:08Bronsadnolen: definitely the case of chunked seqs -- haven't done any benchmarks myself but I recall puredanger talking about it
11:09phillordandyf: I agree, but it does show the necessity and that it can be much better
11:09chouserdnolen: any sense of reader conditionals timeline for clojurescript?
11:10phillorddnolen: I've seen that written before, but I just don't understand what it means. It sounds really nice, but I have no idea what it is for.
11:12sobelcan i write a transducer in clojure 1.6?
11:12sobelor is that a waiting-for-1.7 thing
11:13chouserhm, if transducers were *completely* decoupled from "application strategy", wouldn't that mean that they could deliver the same semantics as lazy seqs? The fact that they can't suggests they provide an alternative and perhaps more open and efficient application strategy.
11:20andyfsobel: No need to wait if you are willing to try out 1.7.0-alpha6. It may be possible to write one with 1.6, but you would need to implement some groundwork yourself.
11:21sobelandyf: i'm willing to burn a couple cycles on 1.7-a to try them out. i already found the examples i'd seen on blogs would not work with 1.6 unmodified.
11:21sobelthx
11:24matthavardDoes anyone know of a code snippet example where reduce is called with reduce as the second parameter?
11:24matthavard`(reduce reduce <init> <coll>)`
11:25sobelunclear how the outer call would have anything to reduce
11:26matthavardYeah I don't know how it would work either
11:27matthavard<init> would have to be a function I think....
11:28matthavardOkay I got a lame one working
11:28matthavard,(reduce reduce + [[1]])
11:28clojurebot1
11:28matthavard,(reduce reduce + [[1 2 3]])
11:28clojurebot6
11:29sobel,(apply reduce + [[1 1]])
11:29clojurebot2
11:29sobelsame
11:29Glenjaminchouser: i think you can build lazy-seqs on top of transducers
11:29sobelreduce only destructured for you
11:29BronsaGlenjamin: not preserving the same characteristics
11:30Glenjaminthe way they compose, you mean?
11:30matthavardYeah because it was passed + and then the first element of [[1 2 3]] which is [1 2 3]
11:30Glenjaminor the caching and laziness bit?
11:30BronsaGlenjamin: lazy-seq ops can consume 0 elements, transducers need at least 1
11:30Glenjaminoh, interesting
11:31matthavard~(+ 1 2)
11:31clojurebotHuh?
11:31matthavardWhy does clojurebot eval if you use a comma when clojure evals if you use a tilda?
11:31mikerodDoes cljs require Java 7 now?
11:31mikerodI always get "Caused by: java.lang.UnsupportedClassVersionError: com/google/javascript/jscomp/CompilerOptions : Unsupported major.minor version 51.0"
11:31justin_smithmatthavard: ~ is for commands, , is for clojure code
11:31mikerodfor cljs projects when I have Java pointed at Java6
11:32matthavardjustin_smith: What commands can I do with ~?
11:33justin_smithmatthavard: factoid related commands are pretty much it I think
11:33justin_smith~books
11:33clojurebotbooks is book
11:33justin_smith~book
11:33clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
11:33justin_smith~books
11:33clojurebotbooks is book
11:33justin_smitherg.
11:33justin_smiththere is also a books answer
11:33justin_smithbut the factoids are annoying
11:34dnolenphillord: some things in Clojure take some time to understand, and documentation beyond anything official (tutorials, books). I think it took a year before I really understood lazy seqs - I don't really see this as is problem though.
11:35dnolenchouser: Alex Miller is cranking on that, hopefully tools.reader patch drops today/tomorrow, and then ClojureScript just needs some small tweaks
11:35dnolenchouser: the next big release of ClojureScript is waiting on just this
11:35mavbozo~book
11:35clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
11:35mavbozo~book
11:36clojurebotbook is http://clojurebook.com/ http://joyofclojure.com/
11:37matthavard~macros
11:37clojurebotBarking spiders!
11:37matthavard~macro
11:37clojurebotmacro are just a game with symbols
11:37matthavard~book
11:37clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
11:37matthavard~~
11:37clojurebotTitim gan éirí ort.
11:37matthavard~~
11:37clojurebotExcuse me?
11:37mavbozo~educe
11:37matthavard~~
11:37clojureboteduce is a typo
11:37matthavard~~
11:38matthavard~clojure
11:40csd_Is it right to think of Manifold as a competitor to core.async?
11:40justin_smithcsd_: check out ztellman's talk from the last conj
11:41justin_smithmanifold is compatible with core.async, but he compares the two (and also prismatic/plumbing)
11:42csd_justin_smith: the talk titled Always Be Composing?
11:42justin_smithyes
11:43chouserdnolen: fantastic, thanks!
11:44sobelthat was a great talk
11:44sobeli'll have to use more core.async before i'm receptive to manifold, i think, though
11:58csd_is there a curated list of the best conj talks
12:02bjaare #inst meant to work with org.clojure/java.jdbc as ISQLValues out of the box?
12:03bjai.e. (jdbc/query db ["SELECT ?;" #inst "2015-04-07T15:54:15.497000000-00:00"])
12:10sobel~.
12:10sobelcs csd oaeu
12:10clojurebotCool story bro.
12:11sobelapparently ^Q still horks up terminal emulators :/
12:11sobelcsd_: i forget the name offhand but there's an easy to find youtube channel with most the good talks on it
12:11justin_smithsobel: it doesn't hork anything, it does exactly what the vt100 spec says it should
12:11sobelbut ask here for specific topic advice. i think that's more useful than drinking from the firehose.
12:11sobeljustin_smith: you're not wrong
12:12justin_smithsobel: I mean, imagine if I went into my GUI apps and my emacs muscle memory led to me using Control-w instead of Control-c to copy. Should I be surprised that this closes my document?
12:13justin_smiths/copy/cut of course
12:13oddcullyjustin_smith: that's not only emacs musclememory, but terminal. at least there is a hook to fix gtk apps
12:14justin_smithone that I do all the time: Control-p to go up, and then I get a print dialog.
12:14sobeljustin_smith: i have no idea what you are talking about. i bound all my GUI apps to emacs bindings a long time ago. ;)
12:14justin_smithlike, who actually prints so often that they need a keyboard shortcut for it?
12:14sobelhaha
12:14sobeldongetmestarted
12:15oddcullyin (old?) IEs ESC in a textarea just removed the text
12:15justin_smithhaha "fuck you vi users we hate you"
12:15sobelbut really, my tacit assertion here is, why the fuck are we still emulating terminals so literally? (don't answer that)
12:15justin_smithsobel: software that was invented to run on terminals is still useful
12:16justin_smithin 100 years we will be asking why 2d apps are still emulated
12:16sobellike the irssi/tmux combo i use to get here?
12:16justin_smith:)
12:16sobelupgraded from bX+screen from the olden days
12:17justin_smithhell, our programming languages are still 1 dimensional, with a few notable exceptions
12:17sobelthere's plenty of good argument for them staying that way, too
12:17justin_smithindeed
12:18sobeli still play MAME. i shouldn't be allowed to comment on future emulation of 2d apps. :)
12:24bjacan I "unextend-protocol"?
12:24bja(in a way other than restarting my jam)
12:26justin_smith~v1.8 is my jam
12:26clojurebotRoger.
12:27justin_smithsorry, couldn't help it
12:27zerokarmaleftjustin_smith: ugh, that gets me so often (ctrl-p)
12:29zerokarmaleftoften enough that I'm now realizing I should've found a way already to disable that shortcut
12:31oddcullyzerokarmaleft: for gtk there is a config for all apps. e.g. my firefox just moves the cursor up on ctrl-p, ymmv
13:01bjaI think I'm going nuts. (doto (.prepareStatement (jdbc/get-connection db-spec) "SELECT ?") (.setTimestamp 1 (java.sql.Timestmap. (.getMillis (clj-time.core/now)))) .execute) throws "PSQLException ERROR: could not determine data type of parameter $1" with the org.postgresql.Driver
13:02darthdeusis there a talk somewhere about component/jig?
13:16sobelbja: if that's literal code, you might adjuste "Timestmap" to "Timestamp"
13:16sobeladjuste, oe.: Adjust
13:17bjaerr, not literal code, sorry about that
13:17bjathe thing is, this works with sqlite3
13:17justin_smithbrb. must adjuste my Timestmaps
13:17sobel(inc justin_smith)
13:17lazybot⇒ 234
13:17sobel(inc justin_smith )
13:17lazybot⇒ 9
13:18Glenjaminmaps for estimating tim
13:18sobeloof
13:18Glenjamindarthdeus: there was one at clojureX 2014
13:19Glenjamini think, or maybe it was EuroClojure
13:19Glenjaminone of those, anyway
13:20bjais there some function or macro that will invoke javac on a string for me?
13:20bjaI basically want to eval some Java
13:29sm0kepmonks: java can be used with 99% ease from clojure
13:30pmonksRight, but bja wants to eval a string as Java source.
13:30pmonksI guess what you could do is throw the string at Groovy.
13:30pmonksMost Java is also valid Groovy, and Groovy includes a full interpreter*
13:30pmonks* on-demand compiler
13:31justin_smithbja: if javac is present on the machine, there is also the possibility of shelling out
13:31justin_smithbja: what do you need to do at runtime with java that clojure couldn't do?
13:31bjaoh, nothing for production. I just wanted to test a java code sample I could ask about on #postgresql
13:32bjasince nobody responds favorably to questions posed using clojure
13:32justin_smithbja: in that case, why not make a tiny java file and compile and run it?
13:33pmonksbja: I use the Groovy shell for that kind of thing
13:33pmonksBasically a glorified Java interpreter.
13:33pmonksVery handy (even though Groovy itself leaves me with an unclean feeling).
13:34bjaI just wanted to avoid doing that outside of my repl. I was hoping to be able to (./pull 'magic-java-compiler) (require '[magic-java-compiler.core :refer [javac]]) (javac "$BORINGJAVAHERE")
13:34bjaI'll try groovy
13:35pmonksYeah I think it'll work ok, even if it's a bit of a hammer to crack a nut. ;-)
13:36pmonksHere's a Java example that should be pretty directly portable to Clojure: http://stackoverflow.com/questions/20905980/how-can-i-evaluate-my-own-groovy-script-from-java
13:37bjaI think there's something weird with the way I have org.postgresql.Driver setup (or a bug with it), since .setTimestamp(idx, java.sql.Timestamp-instance) works fine for mysql and sqlite3
13:38oddcullyalso be aware, that groovy is not 100% java code compatible
13:40pmonksYeah - the biggest issue I've had with (ab)using it this way is with some identifier names. Groovy has more keywords etc. so some valid Java identifiers names are not valid Groovy.
13:40pmonksBut in practice I run into problems pretty rarely, and for small Java snippets are easy to fix.
13:41oddcullyyeah most likely lists in @SomeInterface will trip you over. the keywords are not to many (in, trait, ?)
13:42pmonksBit more background: http://blogs.alfresco.com/wp/pmonks/2010/08/19/alfresco-and-groovy-baby/
13:43oddcully* pmonks is now known as austin
13:44oddcullymy main groovy visual is Ash
13:45justin_smitham I old? is this is what it's like when you are old? I have no idea what any of these references are.
13:46pmonksOr young. ;-)
13:46pmonkshttp://www.imdb.com/title/tt0118655/
13:47oddcullypmonks: guess so ;P
13:47justin_smithoh damn, I saw it so long ago that the references went over my head
13:47justin_smithhaha
13:47oddcullyand this for Ash: http://www.imdb.com/title/tt0083907/
13:47justin_smithwait, I know ash, but how did it tie in here?
13:48pmonksPeter Jackson's 2nd best movie: http://www.imdb.com/title/tt0103873/
13:48oddcullyiirc its somewhere in part three. something with the boomstick or the chainsaw
13:48oddcullyand Ash says: Groovy!
13:48oddcullyi bet there are even tshirts about it
13:48justin_smithpmonks: Meet the Feebles was damned good too
13:48pmonksThat's #1. ;-)
13:48pmonks(inc justin_smith)
13:48lazybot⇒ 235
13:49justin_smithoddcully: oh man, yeah, I am not hip to the right quotes despite having seen all these things
13:49justin_smithI think its what happens when you've seen too many movies
13:49bjaI put up a sample project here: https://github.com/emidln/clj-pg-jdbc-weirdness/blob/master/src/sample/core.clj. Am I just doing something blatently wrong?
13:49justin_smithif I try to quote movies I sound like a hipper-than-thou asshole because its stuff nobody has seen (not on purpose, mind you)
13:50oddcullystuff like: it's time to kick a** and chew bubblegum... and i am all out on bubblegum
13:50AimHereThat can still work if the quotes are apposite enough
13:51pmonks"I love the smell of napalm in the morning."
13:51AimHereJust don't let on that they're quotes, and people will think you've got a good epigram
13:51justin_smithAimHere: oh yes, then people think I have a very clever and absurd sense of humor.
13:51pmonks"You're all individuals!" "(mob) We're all individuals!" "(lone voice) I'm not." <- best movie quote ever
13:51oddcullyjust use them often enough and the kids will pick it up
13:51justin_smithAimHere: had a hilarious experience where I was riffing on Laurie Anderson lyrics with a friend, and another friend starts improvising weird statements in that style because he didn't know any of the quotes, it was great
13:52justin_smith(inc pmonks)
13:52lazybot⇒ 4
13:52AimHereYour other friend is the one with the imagination I take it!
13:52justin_smithhaha
13:52oddcully:D
13:52justin_smithAimHere: he may have also been high
13:53justin_smithbja: lest you think you are being ignored, I am digging up a project with psql configured to see if I can help out
13:54ncthom91hi all. Anyone have any good suggestions for a short hashing function which produces a short unique id given a long string input?
13:55bjajustin_smith: thanks. I have more configuration, but all of that appears to work okay (extending protocols like jdbc/ISQLValue to convert jodatime, json conversions to/from, etc). This is just distilled to the basic jdbc interop that for whatever reason doesn't appear to be working for me.
13:55pmonks,(.hashCode "This is where the long string would go")
13:55clojurebot-1611456038
13:55pmonksncthom91: not sure if that's what you're after
13:56justin_smithncthom91: for certain values of "unique" (see Shannon, information theory, etc.)
13:56bjaI'm pretty sure I *have* to be doing something wrong because surely .setTimestamp actually works
14:00timvisheris there an analog to the :destroy handler for `lein ring` for in-process http-kit instances?
14:02lemonodorI’m reading https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md#declaring-profiles and wondering if it’s possible to have user-wide profiles that will override profiles of the same name specified in a project.
14:02justin_smithbja: so, here it generates "SELECT '2015-04-07 11:03:28.285000 -07:00:00'"
14:03lemonodorit looks like no, user-wide profiles are overridden by project profiles, i would need a system-wide profile. is that correct?
14:03justin_smithbja: and I get the same error, yeah
14:04bjatimvisher, I do that as part of my http-kit component.
14:04justin_smithbja: I guess jdbc is generating a timestamp format that postgres doesn't like, or at least finds ambiguous?
14:05bjajustin_smith. it seems that way. I don't know how I didn't notice this happening before. I think maybe I need to go back and test older versions to the driver to see if this a regression.
14:06justin_smithbja: clearly it affects both our drivers... one moment, checking what we do with date/time types in Caribou fields
14:07lemonodorbasically i want to say ‘use [cider/cider-nrepl "0.9.0-SNAPSHOT”]’ for everything by putting it in my profiles.clj, but that doesn’t work if i have a project that uses, e.g., lein-gorilla which has a dependency on cider-nrepl 0.8.1.
14:09bjalemonodor: can you exclude in your profile?
14:09bjathe key is :exclusions
14:10lemonodorbja: in my profiles.clj? what would i exclude? cider-nrepl 0.8.1?
14:10bjacider-nrepl
14:11bja:exclusions [cider-nrepl]
14:11bjayou could also add it to lien-gorilla
14:11timvisherbja: in what way?
14:11lemonodorah, right. man, someday we’ll figure out how to do node-style versioning, but even better.
14:12bjatimvisher: https://gist.github.com/add4a2d31fb84977f911
14:13justin_smithbja: as a starting point, this executes without error -- "SELECT TIMESTAMP '2004-10-19 10:23:54'"
14:13timvisherbja: very cool! thanks!
14:14bjatimvishner, the general idea is that you have to hold onto the fn that http-kit returns somewhere
14:14bjaand your restart/stop functions can do something prior to calling it
14:14timvisherbja: yep. makes sense.
14:14bjayou don't need a full-blown component system if you don't want it (although it's sweet)
14:15timvishercan i access active profiles from my system when running with `lein run`?
14:15timvishers/from my/in my/
14:23justin_smithtimvisher: what does 'access active profiles' mean? if you mean get info about which profiles are active, environ is a great way to convey that to the runtime
14:23timvisherjustin_smith: yeah. that's what it looks like
14:23justin_smithtimvisher: idea being you can set environ values per profile, then you can detect profiles via them
14:23timvisheri was looking for a simple way to see if the dev profile was active
14:23justin_smithtimvisher: environ is the simple way
14:23timvisherthat's what it looks like
14:24justin_smithsomething like (defmacro when-dev [& body] `(when (env :dev) ~@body))
14:25justin_smithand then :profiles {:dev {:env {:dev true}}}
14:29vasSo I have my handler take requests that go to tings like /post51762 and find the post with the eid 51762 in datomic, but if it doesn't exist I want to capture the exception .. do a 404 page... any tips on learnin' meself some exception handling?
14:29justin_smithvas: you could try
14:29justin_smithyuck yuck yuck
14:29justin_smith(doc try)
14:29justin_smithit's pretty simple
14:29clojurebotCool story bro.
14:30justin_smith$grim clojure.core/try
14:30lazybothttp://grimoire.arrdem.com/1.6.0/clojure.core/try
14:30justin_smithvas: I think the examples in above link will get you going
14:33vasjustin_smith hehehe Try.
14:33vas+ thanks
14:57bjajustin_smith: I filed a bug report on the postgresql jdbc github page: https://github.com/pgjdbc/pgjdbc/issues/276
15:01sritchiednolen: can I test against a pattern and bind it in core.match? for example, I can do ([(:or 'F 'T)] :seq)
15:01sritchiebut how about ([(:or 'F 'T) :as x] :seq) or something
15:02dnolensritchie: that should work yes
15:02dnolenthough the syntax is not right there
15:02dnolen((:or 'F 'T) :as x)
15:03sritchieI get “unable to resolve x"
15:03sritchie(match (list 'F) ([((:or 'F 'T) :as x)] :seq) x)
15:03sritchieworks without the :or
15:03chouseris there a Right Way to detect, during macroexpansion, whether you're being invoked by the Clojure vs the ClojureScript compiler?
15:03sritchiednolen: (match ['F] [('F :as x)] x)
15:04Bronsachouser look at &env
15:04dnolensritchie: could be a bug
15:04sritchiechouser: https://gist.github.com/sritchie/140200c0c9d013c0438b
15:04sritchiethat works for em
15:04sritchieme*
15:04sritchiednolen: okay, I’ll file
15:05dnolensritchie: thanks
15:05chouserBronsa, sritchie: thanks.
15:09nkozathere is some library like core.match but with first-class patterns, so you can compile a bunch of them to a fast dispatch table in runtime... and also working in cljs? (yes, I want also the sky :))
15:10timvisherhow can i get verbose errors from lein uberjar? it's failing during compilation but not telling me where
15:13zamaterianThe terminal feature in neovim bloody usefull :)
15:23bjazamaterian: waiting for someone to give me a more compelling story than vim+vim-slime+tmux for my vim+clojure development
15:29oddcullybja: tmux+vim/fireplace?
15:32zamaterianbja: just a fast desc : https://gist.github.com/zamaterian/dfbafbeef178daf5c21b
15:35bjaoddcully: I used that for awhile, and realized that I didn't really need/want it very often. I use vim-sexp to select forms and send them via slime to a repl in a different tmux pane
15:36bjawhich, despite the assertions of the vim-fireplace author, is exactly what I want
15:37oddcullybja: i also run my repl in another tmux window and then just :Eval or cpp them over
15:39zamaterianbja, it should be pretty easy, to replace the fireplace functions in my example. One more reason that I use fireplace is that its omnicomple func work nicely together with YouCompleteMe
15:39gastoveI'm having a brain-dumb. Is there a straight-forward way to go from a clojure vector of a type ([Foo, Foo, Foo]) to a java array of the same type (Foo[])?
15:47justin_smithgastove: into-array
15:47justin_smith,(into-array [1.0 3.0])
15:47clojurebot#object["[Ljava.lang.Double;" "[Ljava.lang.Double;@49cb4acf"]
15:48justin_smithgastove: it takes an optional argument if you want to override the type of the first arg
15:48justin_smith,(into-array Number [1.0 3.0])
15:48clojureboteval service is offline
15:48justin_smith&(into-array Number [1.0 3.0])
15:48lazybot⇒ #<Number[] [Ljava.lang.Number;@45a836ff>
15:54borkdudeToday another clojurescript / clojure app I worked on for the last two months went into production. the first serious one for an external customer. Thanks to the peeps in this channel who helped me out with some problems/decisions. Especially ordnungswidrig for his help with liberator.
15:55borkdudeFirst serious one that is entirely in clojure/clojurescript. We've done clojure backend before for another customer.
15:55dnolenborkdude: congrats! :)
15:56borkdudednolen thanks. :)
16:00muraikiw00t!
16:02wackadignhoyhi
16:02wackadignhoyshould all functions with logging get wrapped in a do?
16:02gastovejustin_smith: ahhh. Thanks!
16:03borkdudewackadignhoy functions have an implicit do already
16:04wackadignhoyhum. Interesting. So what is do for, then?
16:06justin_smithwackadignhoy: for things like if that don't
16:06justin_smithand then you use do, and it do
16:07wackadignhoyok. so it's to avoid having to construct a bunch of annon functions for instances like 'if'?
16:08justin_smithyeah - I mean an anon function would be a really roundabout way to do multiple things in one if branch
16:08justin_smithso yeah
16:10TimMcclojurebot: and then you use do, |and| it do
16:10clojurebotA nod, you know, is as good as a wink to a blind horse.
16:12wackadignhoythanks, justing_smith and borkdude
16:20oddcullysometimes the zen quotes of clojurebot are just overwhelming
16:20sritchiewhat’s the right syntax for applying a precondition to an anonymous fn?
16:20sritchieah, got it
16:20sritchie(fn [x] {:pre [(odd? x)]} (* x x))
16:20justin_smith(fn [a] {:pre [(even> a)]} ...)
16:20justin_smithyup
16:21danielglauser(inc sritchie)
16:21lazybot⇒ 2
16:21danielglauserDidn't know that, cool
16:23sobelso, when i was learning sql, knew there were always lots of ways to accomplish something but few of them would be very performant. once i could reason about the combinatorics, i/o costs, and generally understand the challenges the query planner faces, i could write much more effective and clean queries
16:24sobelbut once i figured that out, the path was fully documented, etc. is there a similar vein of learning for lisp/clojure?
16:24sobeli can generally do what i want several ways with clojure, but i have no sense of relative merit
16:24sobel(it's ALL better than writing java)
16:25oddcullywhat's not?
16:25justin_smithsobel: I think following discussion on this channel is very helpful for that
16:25justin_smithsobel: plus, learning how to use the jvm profiling tools
16:25aaelonysobel: I think the only way to know is to profile the code you are interested in...
16:25justin_smithyupyup
16:25sobeljustin_smith: i follow and pitch in when i can. i think i might have helped someone today, which is a nominal milestone
16:26sobelok, i hear profiling.
16:26justin_smithaaelony: well, there are certain things you can figure out - like certain constructs always requiring reflection, so they have an alternate form that always performs much better
16:26szatzcan anyone offer suggestions regarding getting an exception that says "Too many files open" using the clojure.data.csv library?
16:26aaelonyjustin_smith: I agree, but premature optimization is something to consider as well
16:26sobeli know some of the obvious things to avoid, especially when they are familiar from java like reflection performance
16:26justin_smithsobel: also, in general a lot of the best performing stuff revolves around reduce and its variants (transducers, reducers)
16:27sobeli think i am on a better track than i thought, before i asked
16:28sobelthanks
16:28justin_smithalso, there is a whole labrynth of stuff to learn about the lazy functions (especially in my experience concat and range), where they can help make code that performs well much simpler, but you can hit some real landmines too
16:29bjajustin_smith: so apparently the jdbc pg driver doesn't propagate type information it learns to the backend. So saying s=conn.prepareStatement("SELECT ?"); s.setTimestamp(int, Timestamp) doesn't communicate to PG that the ? is a ::timestamp, although it apparently does for MySQL and Sqlite3
16:29justin_smithbja: fascinating - is that a bug?
16:29bjaDave Cramer (maintainer) seems to think it is not
16:30sobeloddly, working with Oracle has helped me connect some ideas between databases and clojure. it is pretty overt about sequences, lazy sequences, and related data/data structure issues.
16:30justin_smithbja: what's the justification?
16:30bjaI didn't really get one. https://github.com/pgjdbc/pgjdbc/issues/276
16:30sobelthat makes sense
16:31sobelit tried to prepare a statement without knowing the type, and predictably failed
16:31justin_smithbja: "basically we hate the people using our library and want using to be a terrible experience"
16:31justin_smithbja: so the solution is to explicitly use the one with or without the timezone?
16:32sobelif you were using a method that did not prepare the statement, but instead executed "SELECT '2015-04-07'::date" or even without the typecast it would be a different deal
16:32justin_smithhmm, what about SELECT ?::date"
16:32justin_smitherr, bad parens there obviously
16:32sobelsure
16:33bjaSELECT ?::datetime works
16:33sobelthen you have supplied the type hint in the query, so good
16:33sobelalso, nominally o/t, always use timestamp with time zone. never use without timezone.
16:33bjayeah, but I was originally under the impression that since I told JDBC that it's a Timestamp that it should have indicated that to postgresql for me. I was wrong.
16:33sobelunless you just hate your data and hate people that will have to use it
16:34bjaI mean, you get the same error if you indicate a time zone too
16:34sobelyes, but only when you're counting on it sending that type info to the backend which doesn't happen
16:35sobeli'm talking about general cases of table design. don't use without timestamp. you'll be sorry. :)
16:35justin_smithbja: "ERROR: type "datetime" does not exist"
16:35bjaerr, timestamp
16:35bjasorry
16:35justin_smithOK
16:35bjaSELECT ?::timestamp
16:35sobeli believe the postgresql type is timestamptz
16:35irctc_can someone help me with the clojure.lang.PersistentQueue/EMPTY exercise
16:36justin_smithOK "SELECT ?::timestamptz" totally worked
16:36justin_smithirctc_: exercise?
16:37bjaI'm also unsure how to indicate to clojure.jdbc that I want it to invoke .setTimestamp(int, timestamp, calendar) as opposed to .setTimestamp(int, timestamp) for my #inst
16:37irctc_I have this function from joy clojure and don't know what the w refers too: (defmethod print-method clojure.lang.PersistentQueue [q w] (print-method '<- w) (print-method (seq q) w) (print-method '-< w))
16:37bjaerr, clojure.java.jdbc
16:38justin_smithirctc_: print-method takes a "writer" arg - the thing to write to
16:38patrickgombertirctc_: it refers to the writer
16:38justin_smith(doc print-method)
16:38clojurebot"; "
16:38justin_smith:(
16:38irctc_Thank you :-)
16:38patrickgombertirctc_: the writer is typically going to be *out*
16:39irctc_Thanks, I needed that clarification.
17:34carymeI have a large lazy sequence of chars. I want to use a java library that requires I pass a java.io.Reader or java.io.InputStream. is there a good way for me to transform that lazy sequence of chars to a Reader (or inputstream)?
17:38amalloyhonestly i'm not aware of anything very good, caryme. we did kinda a mediocre version of this for streams in flatland/io, which you could adapt to readers: https://github.com/ninjudd/io/tree/develop/src/flatland/io/core
17:39amalloybasically wrote an adapter in java, to turn java.io's stream hierarchy into an interface thing instead of inheritance thing, so that it was easy to provide implementations of streams in clojure
17:39amalloythen you could use that to write a reader that's backed by (atom some-lazy-seq)
17:40carymethanks amalloy, Il'l check that out
17:53sobelwhat's the easiest way to integrate a clojure generated class into a java build based on eclipse/maven?
17:55sobelminimum-footprint is ideal. i'm willing to write regular java to keep clojure-y tools out of the build. i am taking enough risk to add a jar (clojure.jar) to the mix already.
17:56sobelit seems my standalone executable clojar distribution method won't cut it, after all
17:58vasSo when you guys deploy your apps to the intarwebz do you (always?) make an uberjar and go from there?
18:01sobel...working on delivery of my first commercial clojure this very moment. so far it's an uberjar but i might have to gen a class and drop it in to a traditional servlet project.
18:02sobelanywho, ideally i might even want to paste the clojure src into a class that compiles it at runtime
18:03sobelit's not a clojure app. this is pretty much a batch-job extension.
18:04sobelunrelated: has anyone dumped clojure.jar on their oracle server and written server-side clojure as stored proc?
18:04sobelnevermind, my coworkers would get pitchforks
18:11rmarianskisobel: you can use clojure.lang.rt from java
19:23kaiyinhow do you solve this exception in repl? (use 'clojure.data.json ) IllegalStateException pprint already refers to: #'clojure.pprint/pprint in namespace: tincanter.core clojure.lang.Namespace.warnOrFailOnReplace (Namespace.java:88)
19:40bbloomso i've got a new machine here & `lein repl` just won't start
19:40bbloomor rather it takes like ~3 minutes to start
19:41arrdemfoo??
19:41lazybotarrdem: Uh, no. Why would you even ask?
19:42arrdemfoo?!
19:43arrdemfoo!?
19:44nooniankaiyin: try (require '[clojure.data.jsoin :as json]); the warning is because clojure.data.json defines its own pprint function and clojure.pprint/pprint is automatically required and refered in the default repl
19:44kaiyincool, thanks.
19:44nooniannote my typo in the lib name also :P
19:45noonianthen you would access the json pprint with json/pprint
20:22darthdeusare people using jig? seems it hasn't been updated in a while
20:35pcnIf I have a list and I want to pass it to a function that takes varargs like (defn foo [a & b]), I know I can take (first input-list) and pass it as a, but how do I turn (rest input-list) into the arguments for the function?
20:37pmonks,(doc apply) ; not sure ?
20:37patrickgombertpcn: you could just (apply foo input-list)
20:37pcnAh,thanks!
20:37patrickgombertnp
20:37clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
20:38pcnWow, that's such an interesting construct
21:32bjakaiyin, did you get an answer?
21:55bmaddyI'm trying to get cider working with emacs (again). Does anyone know what this error means? The lein executable (specified by `cider-lein-command' or `cider-boot-command') isn't on your exec-path
22:11justin_smithbmaddy: your shell env isn't visible to point an xlick gui apps
22:12justin_smithbmaddy: start emacs from a tty, or manually set up emacs' path
22:14justin_smithbmaddy: emacs' path can be set with the setenv function (altering PATH of course)
22:16bmaddyWell, it does seem to start up when I just do plain emacs. Aqumacs must be the problem.
22:17bmaddyI mean, environment stuff, like you said.
22:17justin_smithyeah, not an infrequent issue on osx
22:18justin_smithyou can set your default env but the osx way is weird
22:19justin_smitheasier to start from a shell prompt
22:19bmaddyInteresting, I'll try starting aquamacs from a prompt...
22:20justin_smithyou may need the "open" command
22:21justin_smithiirc (I am a happy migrant back to linux land)
22:25amalloyclojurebot: Aquamacs |must be| the problem.
22:26clojurebotAck. Ack.
22:35timvisheranyone have a good comparison between http-kit and jetty?
22:35timvisheri'm trying to write up what the tradeoffs are between them
22:35timvisherhttp-kit can achieve far higher through put because async i/o?
22:47arrubintimvisher: http-kit appears to use Netty. You will probably have more luck finding comparisons of Jetty and Netty.
22:48timvisherarrubin: my understanding is that it is inspired by netty but not actually implemented with it
22:48arrubintimvisher: Check the project file.
22:48timvisherarrubin: and i went down that route as well and was surprised to not find much information on it
22:49arrubinhttps://github.com/http-kit/http-kit/blob/master/project.clj
22:49arrubin [io.netty/netty "3.6.5.Final"]
22:49timvisherheh. yep :)
22:49timvisherwonder when that happened
22:49timvisherjetty vs netty seems mostly to talk about async vs. sync support, but jetty 7 even seems to support async
22:50arrubinJetty implements the servlet spec.
22:50arrubinNetty is more of a library to implement such things.
22:50timvisherso i'm wondering if jetty has evolved to support async i/o since netty came out
22:50timvishercertainly jetty has been far more widely used
22:51timvisherjetty 9 for instance only use nio
22:51arrubinChances are that your needs will not make either break a sweat.
22:52arrubinYour bottlenecks are almost certainly elsewhere, if there is even a problem.
22:53timvisherarrubin: also, seems like http-kit only uses netty in it's tests https://github.com/http-kit/http-kit/search?utf8=%E2%9C%93&amp;q=netty
22:53timvisherarrubin: i'm sure of that, but i'm tasked with evaluating them. it's looking like jetty is the obvious choice
22:53timvisherwhich is slightly surprising to me because i felt like http-kit has been sweeping the clojureverse since it came out
22:55timvisherarrubin: do you think you could say what the banner differences are between jetty and http-kit?
22:55timvishercertainly jetty 7 is probably more out of date than http-kit (for some value of out of date) but there's also a jetty9 adapter which would bring in jetty 9
22:58arrubintimvisher: Sorry, I have not used http-kit. I assume that it does not implement the servlet spec. They seem designed for different purposes.
22:59timvisherarrubin: ok. in terms of clojure and running an embedded jetty server which is then run from `java -jar`, am i even using the servlet spec?
22:59timvisheradmittedly i'm fairly uneducated when it comes to servlets
23:06ncthom91hey y'all. Is there a cleaner way to do something like this? http://pastie.org/10079510
23:06ncthom91I just want to replace the second element in each match with the result of applying that element to `fib`
23:07amalloy(set (map #(update-in % [1] fib) matches))?
23:12arrubintimvisher: I honestly do not know. I am only a Clojure dabbler.
23:14arrubinAre you using Ring with the Jetty adapter?
23:37tbaldridgetimvisher: one thing I've heard mention more than once by Clojure devs, is that they trust the implementation of Jetty over the implementation of http-kit. In fact I don't know that I've ever seen http-kit in production
23:38tbaldridgeNot that there's anything wrong with it, it's just a big unknown. While ex-java teams are probably a bit more comfortable with Jetty.
23:42Jaoodtbaldridge: Jetty is also more mature, battle-tested and more actively developed.
23:42justin_smithtbaldridge: I have used http-kit in prod without issue
23:43tbaldridgeJaood: exactly
23:43tbaldridgejustin_smith: yeah, I've never really had an issue with it either. But the last time the discussion came up with a client it was a big question of "do we trust the hundreds of Java eyes that have seen the Jetty code...or the dozen of clojure people working on HTTP Kit"".
23:44tbaldridgeNot much of a contest there sadly. But I think it depends on your needs/goals
23:48justin_smiththe container / servlet abstraction is a difference, but a small one when running standalone
23:49Jaoodtbaldridge: I can see why http-kit is attractive, a small, fast http server design for specifically for ring
23:50justin_smithalso, you can use dynamic binding in jetty, bevause a request will stay in one thread, last I checked
23:51justin_smithhttp-kit can break dynamic binding
23:52justin_smiththis might be inherent in any server where you can use sockets
23:52Jaoodjetty is also a fast web server a la nginx
23:53justin_smithis it hardened like nginx?
23:54Jaoodyeah, you can have it public facing
23:55justin_smithI had no idea
23:55Jaoodit already supports http2 I think
23:55justin_smithI'll have to look into that
23:56JaoodIs uncertain if http-kit will ever support http2
23:58Jaoodjustin_smith: I would still prefer nginx though :)