#clojure logs

2015-03-11

00:33cshellHas anyone had problems with clojure.xml and clojure.zip and clojure.data.zip with using a ton of memory even for a 3k XML doc?
01:42tinkertronhi does anyone here know anything about hash array mapped tries?
01:44amalloycshell: how much is "a ton"? i wouldn't be surprised if it used, i dunno, a meg or so?
01:44amalloyand how do you even know it's using up memory irretrievably, vs the garbage collector just not running yet?
01:45cshellamalloy: upwards of a GB - it’s more of a REPL problem I think - when you navigate down and print the children, the REPL output increases significantly
01:46cshellso i was navigating down to where I had 187 children - these children printed to the REPL (as they were returned from a fn i called there) had the entire zipper
01:47amalloyokay, so the problem is that your repl buffers output indefinitely, or what?
01:48cshellyeah
01:48cshellif I add a zip selector to just select an attribute name that’s much better
01:48cshellrather than the zip location
01:49cshellso a ton of output to the REPL
01:49amalloyokay, so fix your repl
01:49amalloythe amount of stuff printed to the repl should not be a concern
01:50macknees hello, I am looking at using the java method .readPassword in a simple project. I do not know java.
01:50mackneesWhen I call the method in my repl I get an error unless I wrap the call inside another call to
01:50macknees(String/valueOf call.
01:51mackneesEven when I do the wrapping, my .readPassword method returns after I type 1 character.
01:51cshellamalloy: I’m not super familiar with the REPL configurations - is there a way to prevent it from spewing endless data?
01:51mackneesI am not sure what to make of this.
01:52mackneesI am guessing that .readPassword returns a datatype that clojure doesn't directly understand, is that correct?
01:55ncthom91hey all. I'm working on a project to learn clojure, and I'm doing a lot with trees and tree traversals. What's the idiomatic clojure way to approach working with trees? Represent a tree as data (i.e. nested maps) and write functions to operate on them, or somethign more like this (http://macromancy.com/2014/04/09/data-structures-clojure-trees.html) which is kind of an OO approach expressed in clojure
01:56ncthom91some of the reading I've been doing suggests that identifying a tree node as a record (defined with defrecord) will have better perf characteristics than the OO approach described in that article
01:56cshellncthom91: I’ve been using Clojure Zippers (clojure.zip and clojure.data.zip) for working with my trees
01:56amalloycshell: what i'm getting at is, i don't know of any repls where output buffering is a major concern. i don't know what repl you are running, so i don't know how you would fix it if it were a problem, but i kinda suspect you are running a common repl and some misunderstanding has caused you to think it is buffering too much data
01:57cshellamalloy: I’m using Cursive
01:57cshellamalloy: maybe it’s because it’s doing a walk of the tree upwards and it’s exploding exponentially
01:58ncthom91cshell woah. Never seen clojure.zip before, this looks sweet
01:58cshell:)
01:58amalloycshell: talk to cfleming
01:58amalloysince it's embedded in an ide, for all i know it does buffer indefinitely
01:59cshellyeah, probably :) thanks amalloy :)
02:02mackneesCan anyone recommend an active channel for newbies?
02:03mackneesI've tried clojure-beginners on multiple occasions, there is never any chat going on when I'm there
02:03mackneesI have no idea where I should try
02:04ncthom91cshell so with clojure.zip, your trees are just raw data? like nested maps or vectors?
02:05cshellI think so - each call to a function returns a new structure
02:05cshellmacknees: If you want someone to help you, you should be more descriptive or put your code example in pastebin and then paste the link here
02:05mackneesthanks cshell, will do
02:10mackneeshere's a simple example of the .readPassword code I'm trying to get working: http://pastebin.com/QZh6fX7p
02:18mackneesCan anyone help me understand why I can call (String/valueOf but for readPassword I have to call (.readPassword (System/console) ? I'm a bit confused by namespaces in java, I don't know what is "included by default" when I run my repl.
02:18mackneeswhy does readpassword need the . macro but String/valueOf does not?
02:20mackneesI was trying to resist learning java first, because I worried that it might make the idiomatic clojure way more foreign to me
02:20mackneesI want to learn clojure because I have a personal interest in lisp and because clojure looked very active with lots of libraries
02:21Jaoodmacknees: only java.lang is imported by default
02:21mackneesI started reading about it, watching rich on youtube, and looking at code and it appeals to me
02:22mackneesthanks Jaood. I will look at java.lang and see what is included there.
02:23mackneesI only need the .readpassword because my project will interact with a web service and I don't want the password to be saved or exposed in plaintext
02:24mackneeswhen the application runs it will prompt for the password on the command line
02:25mackneesI have done this in python and it was very easy. I think I am missing something obvious here...
02:26mackneesJaood, do you have any idea how a proficient java programmer would know if System.console was included under java.lang? I can look on google, but is there a more concise search engine to answer this type of question?
02:28engblommacknees: I have a suggestion: It looks like nobody is around able to help at this point. Just use read-line for now and later add that java thing later...
02:28engblommacknees: In that way you can continue with your project
02:30mackneesengblom: thank you for that. I will look at read-line.
02:32Jaoodmacknees: they use the api docs
02:32Jaoodhttp://docs.oracle.com/javase/7/docs/api/
02:33mackneesJaood - I think there is no shortcut for me, but it was worth a try :-)
02:33mackneesIn the end at some point I will probably need more knowledge of Java
03:33luxbockshould I read The Little Schemer before The Reasoned Schemer, or does it matter?
03:33luxbockI see The Reasoned Schemer has a Kindle edition but The Little Schemer doesn't
03:34luxbockactually it looks like the reviews say that the Kindle version is not very good
04:49borkdudehas anyone here played with modules in cljsbuild? my config isn't working for me
04:49borkdudehttps://www.refheap.com/98297
04:50borkdudeit ouput a single file to /target currently with the prod build
05:23justin_smithI thought I understood metadata, but I don't understand this error
05:23justin_smith,(with-meta (var +) {:foo true})
05:23clojurebot#error{:cause "clojure.lang.Var cannot be cast to clojure.lang.IObj", :via [{:type java.lang.ClassCastException, :message "clojure.lang.Var cannot be cast to clojure.lang.IObj", :at [clojure.core$with_meta__4097 invoke "core.clj" 216]}], :trace [[clojure.core$with_meta__4097 invoke "core.clj" 216] [sandbox$eval25 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6784] [clojur...
05:24justin_smithhow is metadata attached to vars?
05:27zotjkkkkjjjjkkkjjjkkkkkkkjkkj
05:27zot!@#!@$!. sorry.
05:27dysfunanyone familiar with avout?
05:27justin_smithyeah, I've used it, it's pretty cool if you don't need watches of any sort
05:27_2_tuliverhello am new here
05:28dysfunjustin_smith: and thereby you answer the question i was going to follow up with
05:28dysfunwell, one of them
05:28_2_tuliverhow do we use this app
05:28justin_smithwatches in avout don't really work
05:28dysfunthe other one is "i can't see ensure anywhere"
05:28_2_tuliverhelllloooooii
05:28_2_tuliveris anyone listining
05:28justin_smith_2_tuliver: clojure is a programming language
05:28dysfun_2_tuliver: don't be rude
05:29dysfunjustin_smith: does the lack of 'ensure' cause a problem?
05:29_2_tuliverso those here aint reall people?
05:29dysfunnot everyone pays attention all the time
05:30dysfunif you have a question, please ask with more detail than "how do we use this app?" which doesn't make any sense on its own
05:30justin_smithdysfun: hmm... I haven't used the avout refs to be honest.
05:30dysfunoh, just the atoms?
05:31justin_smithyeah, I used the atoms for sharing of state between app instances
05:31justin_smithit works well for small amounts of data that don't need to be instantly acted on
05:31justin_smithvariations from that, ymmv
05:31dysfunyeah, i have...higher throughput needs
05:32justin_smithyeah, avout is not made for throughput
05:32justin_smithyou may want to look into zeromq, hornetmq, redis...
05:32_2_tuliverhmmm i seee guys are very boring
05:32_2_tuliveryou are boring
05:32dysfun_2_tuliver: this is a programming themed channel. what did you expect?
05:34dysfunjustin_smith: well i was hoping avout would be fact enough :/
05:34justin_smithdysfun: oh, it's fast
05:35justin_smithit's just not high throughput
05:35dysfunheh
05:35dysfunsee i'd rather have it the other way
05:35justin_smithlatency vs. throughput is a classic optimization problem
05:35dysfuni'm happy for writes to take a little while
05:35justin_smithyeah, I think some of those other IPC options are more throughput oriented, or at least more tunable
05:36dysfun*sigh* i'm going to have to roll my own on top of zookeeper aren't i?
05:52justin_smithdysfun: no, what I am describing is a limitation due to zookeeper
05:52justin_smithzookeeper is not designed for throughput
05:52engblomluxbock: Regarding your question about Little Schemer, I want to first ask how well you know Clojure?
05:53engblomluxbock: Actually, if you want to learn Clojure by reading Little Schemer?
05:54engblomluxbock: Scheme and Clojure are similar in many ways, but they are not the same language at all
05:55justin_smithdysfun: hmm, I may need to eat my words on that - it could be that avout is more limited for throughput than zookeeper, or is not as limited as I had come to understand
05:55justin_smithdysfun: mayber I misidentified a bottleneck in my code - wouldn't be the first time
05:55justin_smithhaha, mayber
06:04cflemingdysfun: The problem with being happy for writes to take a little while is that then they're not consistent - it goes against what something like zookeeper is designed to do. I haven't used avout, but given that it talks about MVCC and STM I guess that consistency is an important goal for them
06:09cflemingdysfun: Actually, feel free to ignore me - that's not right at all
06:10dysfunisn't it?
06:10dysfunso i'm prepared for eventual consistency and i'm willing to perform manual merges
06:10borkdudethe embedded jetty that is run by lein ring uberjar doesn't do gzip compression by default, right?
06:11dysfunborkdude: you need a middleware for that
06:11borkdudeok
06:11dysfununless you can tap into it with options. i can't remember
06:13dysfunyou can probably configure it in. it seems like something i'd expect jetty to support
06:15cflemingdysfun: No, it's almost exactly wrong. More consistent writes take longer - a major goal of most eventually consistent systems is write availability (Dynamo is the classic example). Datomic is probably write limited since to achieve consistency all writes go through the transactor - this makes consistency easy(ier) but limits write throughput.
06:15dysfun*nod*
06:16cflemingdysfun: If you're really ready for manual merges, what about something like cassandra? I haven't used it but I believe it exposes write consistency knobs, and those must include application merging
06:17dysfuncfleming: i've been put off cassandra since i've been reading aphyr's "call me maybe" series
06:17cflemingdysfun: I haven't read the cassandra entry there
06:17dysfunah, well it rather points out that it's an AP system not a CP system
06:18cflemingWhich is what you want if you're prepared for eventual consistency and merging, right?
06:19dysfunit would be, except that it just outright drops some acknowledged data
06:19dysfunif it guaranteed at least once delivery, that'd be fine
06:19dysfunonce it's been acked, i mean
06:19dysfuni'm perfectly happy for the db to refuse to run something
06:20cflemingOk, that's not a required feature of AP systems :)
06:20dysfunbut once something has gone in, i expect it to not be lost
06:20cflemingRiak, maybe?
06:20dysfunriak is the best off the shelf fit, yes
06:22dysfunthe weak point as far as i can see is merging. i could use avout to regulate that case
06:23dysfunand a library for working with CRDTs
06:26cflemingI thought I heard that Riak supported CRDTs out of the box? Or did I imagine that?
06:26cflemingWhat's the issue with merging?
06:26ianyhi. is it possible to write a simple task scheduling library like quartz, using core.async timeout channels? just a thought.
06:27dysfunthe only way to operate riak safely is to allow multiple versions to coexist and then merge. this is going to happen on every *read* after conflict so you'll want to update it, but you'll now do that many times and create race conditions
06:28cflemingdysfun: IIRC that's pretty common - Dynamo also resolved on reads
06:29dysfunyes. but zookeeper could be useful in dealing with that problem
06:29cflemingdysfun: Are you sure about the race conditions? That seems like a pretty big hole in riak, I'd be surprised.
06:29dysfunwell it's not a hole in riak, is it?
06:29dysfunyour code dealing with it may create a race condition
06:30dysfundistributed systems are hard, and all that
06:30cflemingIf you can't resolve your data correctly on write conflict, then yes it is
06:30cflemingIs it just that that code is tricky to get right, or that riak makes it impossible to do correctly?
06:30dysfunthe former
06:30cflemingAh
06:30cflemingThen yes, it is :)
06:30dysfunso there's a simple strategy
06:31dysfunyou could just never delete multiple versions
06:31dysfunbut then you'll have to merge on every read request
06:31dysfunyay
06:31dysfunhope you don't have any hot data ;)
06:31cflemingDon't those merged versions get written back? It's been a while since I looked at this stuff.
06:32dysfunit has for me too. but as i recall you just write another version to replace them
06:32cflemingAnd that merging will also only happen on any elements that had write conflicts, correct?
06:32cflemingRight - I don't know your use case, but that doesn't sound too bad.
06:33dysfunwell if you want your database to always return correct answers
06:34dysfunbut you can easily see what happens when two threads try to merge the value. what if one gets hit by a GC pause and another one comes and writes another value?
06:34dysfunwhere threads can be 'processes on other machines'
06:34cflemingWell, your merge has to be deterministic
06:35dysfunof course. but the point is that you have to deal with the problem
06:35dysfunzookeeper might be a good option
06:35cflemingRight. That's why eventual consistency sucks from an app developer POV - they talked about this in the Dynamo paper, and said that the merging code was some of the most brittle and difficult to get right.
06:36cflemingYou're essentially pushing the consistency code from the database up to the application, where everyone has to get it right for every data model.
06:37dysfunwhich is why i'm going to record everything as CRDTs
06:37cflemingOnce you put zookeeper in there you're forcing consistency - wouldn't a database or datomic be a better option at that stage?
06:37cfleming(again, no idea of your use case, just asking)
06:38dysfunwell, datomic isn't open source or even free to use in production (heh, no, i'm not running transactor-local storage in production), so it's out
06:39dysfungiven that this is a hobbyist thing
06:39cflemingInteresting, I thought Riak was too - I see I was wrong
06:39cflemingcommercial, that is
06:40dysfunyou can do pretty well without commercial support
06:42dysfunand the reason i'm looking at this is that i want to do the 'all history' thing that datomic does
06:42dysfunpostgres doesn't work terribly well for that
06:50algernonFWIW, Riak's CRDTs work fine, but Clojure library support for them isn't all that great.
06:51algernonwith CRDTs you don't need to have multiple versions, either.
06:52dysfunalgernon: thanks. i'll have a play
06:53algernondysfun: https://github.com/bluemont/kria is the library I had reasonable success with, if you want to play with Riak from Clojure
06:54algernon(Welle is <3, but doesn't support a lot of Riak 2.0 things, including CRDTs, last I checked)
06:54dysfunthanks. i was using well before
06:54dysfunwelle*
06:54krasHi everyone, I have a single datastructure which I pass it to several functions, all these functions work independently. What is the best way to parallelize these functions?
06:55dysfundo you require to tie the results together afterwards?
06:55dysfunor do you just want them all to be executed?
06:56krasyeah, I need to collect all the results
06:56krassomething like fork and join
06:56dysfunclojure.core.reducers is pretty easy for that use case
06:56dysfunit's a very quick win when they're truly parallelisable
06:57justin_smithkras: by "single datastructure" do you mean that every function uses the same immutable input data?
06:57krasjustin_smith: yeah
06:58krasdysfun: thanks I will read about it
07:05krasdysfun: reducers seem to be for large collections where a single reducing function or filter function can be parallelized
07:06justin_smithkras: I thought you said all the functions took the same input, if so why can't they be run in parallel?
07:07dysfunkras: yes, it's just that in this case you generate a list of the same object and reduce that
07:07justin_smithdysfun: sounds like someone needs to invent pjuxt
07:07dysfunheh
07:07dysfunthat sounds useful actually. let me go do that now
07:08krasyeah pjuxt is what I am looking for
07:08justin_smithkras: prismatic/plumbing has something that can do this (or something very much like it)
07:08justin_smithkras: fnk
07:09justin_smithhttps://github.com/Prismatic/plumbing
07:09krasgiven my track record of inventing functions and then realizing that they are already in core, I thought I should ask first
07:09krasjustin_smith: let me check it out
07:09justin_smithkras: the first example for "graph" on that readme looks apropos
07:10justin_smithit can optionally be "normal", or lazy, or parallelized
07:13krasjustin_smith: thank you
07:15mpenetkras: there's also tesser https://github.com/aphyr/tesser
07:16justin_smithmpenet: is that for parallelizing onto multiple machines?
07:16mpenetit supports local too
07:17mpenetthere's an explaination of pros/cons vs reducers and transducers in the readme
07:18justin_smithahh, yeah fuse looks like something similar to what a parallelized fnk would do (if you fuse on one box I guess)
07:22dysfunroshi looks cool https://github.com/soundcloud/roshi
07:23dysfunthey're serving audio over that, which is mega cool
07:24justin_smithdysfun: why would they need something like that for their audio? It's not like the contents of any audio file on their system changes after initial upload.
07:24dysfunah no, i misunderstood
07:24dysfunthey said 'stream', they meant more like the twitter feed sort of thing
07:25justin_smithyeah, different kind of stream :)
07:25justin_smithstream is so overloaded
07:26justin_smithInputStream, streaming data, event streams...
07:26justin_smithbut can you cross the same event stream twice?
07:26dysfunthat rather depends which stream came first, the chicken stream or the egg stream
07:50TimMcI think those are costreams.
07:53justin_smithjust be careful not to cross the streams
08:18AeroNotixhttps://groups.google.com/forum/#!topic/clojure/UtnchSngQAY anyone got any idea for this? Been stuck on it for a day, can't think why it could be
08:21justin_smithAeroNotix: in the gist, you don't run rm -rf target before running make, and iclient is not compiled a second time
08:21justin_smithI have no idea what the effect of these things might be
08:21justin_smithalso, any chance there is a clock skew that would effect make on the centos machine?
09:18AeroNotixjustin_smith: I did clear target.
09:18AeroNotixjustin_smith: weirdly, it's not centos :P it's debian called centos for some reason
09:19justin_smithand what's up with the files being compiled twice anyway?
09:19AeroNotixjustin_smith: unk, seems weird right?
09:19AeroNotixI'm totally lost with this and I really am under pressure to get this working :(
09:19justin_smithyeah
09:19justin_smithwhat does the makefile do?
09:20AeroNotixjustin_smith: lein deps uberjar
09:20justin_smithyou don't ever need to call deps btw, it's implicit in just about every task
09:20AeroNotixyeah I just have it because it's easier to write the makefile explicitly (non-clojure users)
09:22AeroNotixjustin_smith: https://gist.github.com/AeroNotix/f65a846781357db59ced
09:22AeroNotixjustin_smith: calling `lein uberjar` on its own produces the same
09:22justin_smithI think your explicit compile step is why the files are being compiled more than once
09:22justin_smithbecause lein compile and lein uberjar do not use the same profile
09:23justin_smithtry dropping the compile step
09:23AeroNotixsure
09:23justin_smithand it could easily happen that something compiled with the dev profile is not compatible with something compiled with prod profile
09:23AeroNotixhmm
09:23justin_smithleading to eg. two classes with the same name being compiled
09:23AeroNotixjustin_smith: same outcome with just lein uberjar
09:23justin_smithweird issues like that
09:23justin_smithOK
09:23AeroNotixin fact, no
09:24AeroNotixit fails quicker
09:24justin_smithheh
09:24AeroNotixas in, I don't think it's trying to compile them in the same way
09:24justin_smithanyway, the compile step is not explicitly needed either
09:24AeroNotixso lein compile succeeds
09:26AeroNotixjustin_smith: want to see the project.clj?
09:26justin_smithyeah
09:26AeroNotixhttps://gist.github.com/AeroNotix/711906da803cbc24260a
09:27justin_smithAeroNotix: I find it disturbing that your uberjar-name has the same name as the regular jar, that uberjar must generate before forming the uber
09:28justin_smithI would not be surprised if that misbehaved
09:29AeroNotixhmm, ok, let me try changing that too
09:29justin_smithoh wait, the regular jar will have the version string
09:29AeroNotixok
09:29justin_smithjust looking for anything weird here...
09:29AeroNotixrenaming that jar didn't do anything different
09:29AeroNotixit seems that uberjar is trying to compile things in the wrong order
09:29AeroNotixas in, client.clj before iclient.clj
09:29justin_smithI wonder how :aot [...] and :profiles {:uberjar {:aot :all}} interact
09:30AeroNotixindeed - that's what I am thinking now
09:30AeroNotixbut the lein versions are the same
09:30AeroNotixon my local box, it works
09:30AeroNotixhttps://gist.github.com/AeroNotix/3f7fb81fe54b9bdd56d3
09:30AeroNotixjustin_smith: local machine^^
09:31justin_smithinteresting
09:31AeroNotixjustin_smith: https://gist.github.com/AeroNotix/19b637932d614ff4a58d other machines
09:32AeroNotixfor some reason it's trying to compile airos-websocket-client.client first
09:32justin_smiththis probably isn't it, but when you have a SNAPSHOT plugin, that can cause different machines to see different versions of the deps
09:32AeroNotixwhich requires iclient.clj
09:32justin_smithif something was up with cider...
09:32AeroNotixok sec
09:32justin_smithcan't hurt to rule it out
09:32AeroNotixsure
09:33AeroNotixjustin_smith: no dice
09:33justin_smithyeah, I didn't think that one was likely
09:33AeroNotixoke
09:33justin_smithany plugins defined in profiles.clj?
09:33AeroNotixon my local box I've commented them all out and there's none on the other box
09:33justin_smith~/.lein/profiles.clj that is, of course
09:34clojurebotTitim gan éirí ort.
09:34justin_smithplugins/deps
09:34justin_smithOK
09:34justin_smith~/.lein/profiles.clj that
09:34clojurebotHuh?
09:34justin_smithhaha
09:43AeroNotixwhat *else* could be mismatching!?
09:43AeroNotixso confused
09:43justin_smithhave you compared the lein deps :tree output on both machines? I mean it *should* be identical, but couldn't hurt to check
09:43AeroNotixjustin_smith: checking, good idea
09:43AeroNotixjustin_smith: yeah identical
09:43justin_smithI got up too early, napping. Good luck man. Sorry I couldn't be more help.
09:43AeroNotixjustin_smith: thanks anyway
09:43AeroNotixlein install works on the other machine
09:43AeroNotixcompiles in the correct order, for some reason uberjar isn't working on there.
09:45AeroNotixjustin_smith: removing the profiles section works on the other box
09:45AeroNotixfor some reason it was not taking into account the :aot key when doing the uberjar
10:21fellipebritoI'm trying to write a simple json on clojure. What I've seen so far is that clojure.data.json is a good kickstart for simple examples, however I can't use it on lein ring
10:21AeroNotixfellipebrito: hi, what did you try?
10:21fellipebritoI've added the dependence in project.clj
10:21fellipebrito[org.clojure/data.json "0.2.6"]
10:21fellipebritoand tried to lein ring and
10:21fellipebritouser=> (:require [clojure.data.json :as json])
10:21fellipebritothis is the error
10:22fellipebritoCompilerException java.lang.ClassNotFoundException: clojure.data.json, compiling:(/tmp/form-init1871899143900987437.clj:1:1)
10:30hyPiRionfellipebrito: (require '[clojure.data.json :as json])
10:31hyPiRionunless this is in the ns form
10:31fellipebritothank you!
10:31hyPiRionno probs
10:34dukerutledgeMorning All
10:34dukerutledgequick question
10:34dukerutledgeI'm trying to find all of the predefined protocols in clojure
10:34dukerutledgethere does not seem to be a list anywhere
10:34dukerutledgewould anyone mind pointing me in the right direction?
10:35eric_normanddukerutledge: good morning
10:35eric_normandI'm not sure that exists
10:36dukerutledgehmm, that seems like it might be a helpful bit of documentation.
10:36eric_normandyeah
10:36tyson2should be extractable from the source code, no?
10:36eric_normandyeah, definitely
10:36dukerutledgewell while I have you, do you know if there is a protocol for ordering? Akin to Haskell's Ord type class?
10:36eric_normandI just ran `grep -R defprotocol src` and got back a nice list
10:37dukerutledgegood idea
10:37eric_normandno protocol,
10:37eric_normandbut it uses the built in Java Comparable interface
10:38dukerutledgeso it is not possible to extend data types for use in ordered maps
10:38eric_normandhttp://clojuredocs.org/clojure.core/comparator
10:38eric_normandwhich data types?
10:39dukerutledgeno data type in particular, I'm just trying to understand the mechanics of these things.
10:39eric_normandhttps://clojuredocs.org/clojure.core/sorted-map-by
10:39fellipebritohey folks, how can I create a string with quotes? I mean, of course I can use the \", but the return is a \" string, I'd like it to be only "
10:40eric_normand,(println "\"")
10:41clojurebot"\n
10:42dukerutledgeeric_normand: do you know of any reason why a protocol was not provided for ordering to simplify the interface of these functions?
10:42eric_normandyes
10:43eric_normandit was done for compatibility with Java, and also before protocols existed
10:43fellipebrito@eric_normand how can I add this into a defn
10:44fellipebrito@eric_normand how can I add this into a def
10:44eric_normandfellipebrito: I'm not sure what you're asking
10:44fellipebrito(def s-with-quotes ("\""))
10:44eric_normandwhen a string is printed, it's going to show the escaped quote so it can be read back in
10:45eric_normandit does not mean the slash is in there
10:45fellipebritook
10:45fellipebritothank you! eric_normand
10:45eric_normand,(count "\"")
10:45clojurebot1
10:45eric_normandto put an actual slash, you need to escape it, too
10:46eric_normand(def s "\"") is all you need
10:46dukerutledgeeric_normand: so it is an artifact of history. Is there any reason to not push these functions towards polymorphism? Dynamism could add a complication in evaluating ordering, but that problem already exists in the current implementation.
10:48eric_normanddukerutledge: I'm not sure if there is or is not a good reason, besides the limitations of the JVM
10:48eric_normanddukerutledge: I believe there are decent workarounds
10:48eric_normandabout making protocols for everything, there are some who want that, but compatibility with Java interfaces is really nice
10:49eric_normandclojurescript took the notion of protocols and ran with it much farther than JVM Clojure because cljs was written after protocols
10:49dnolendukerutledge: Clojure isn't built on protocols, it's built on Java interfaces - I suspect this won't change anytime soon
10:49dukerutledgeit seems compatability could be maintained with Java interfaces. Since clojure is not self hosted it can make exceptions like this.
10:50dnolendukerutledge: as eric_normand points out, for this reason rhickey bootstrapped ClojureScript on protocols
10:51eric_normandif you're making a new type, you can extend Comparable
10:52dukerutledgeSo is there a disconnect in how this is handled via clojurescript?
10:52dnolendukerutledge: compiling to JavaScript and generating JVM bytecode or two very different implementation details
10:52dnolens/or/are
10:53dukerutledgeah I was under the impression that vanilla clojure should work across both compilation targets.
10:53eric_normanddukerutledge: Clojure / ClojureScript takes a very interesting (and I believe novel) approach to being hosted
10:54eric_normandit's more about having certain core features, but the host is still very much present and available
10:54dukerutledgeare there any articles or papers that go into more depth about the varried decisions made for each of these targets and how that affects the core?
10:55eric_normandthere's a lot written and spoken
10:55dnolendukerutledge: there is a portable intersection, but Clojure can do many things that ClojureScript cannot (multithreading) and ClojureScript has a few things that are not worth breaking binary compat for (protoocols) a bear on the JVM (specify)
10:56eric_normandI like this talk where Rich Hickey releases cljs: https://www.youtube.com/watch?v=tVooR-dF_Ag
10:56dukerutledgeeric_normand, dnolen: thanks for entertaining my questions.
10:57eric_normandthis talk goes into a lot of interesting justifications for jvm decisions: https://www.youtube.com/watch?v=cPNkH-7PRTk
10:57eric_normandthey both seem like "duh" now; clojure has come a long way
10:57eric_normanddukerutledge: you're welcome!
10:58dnolendukerutledge: no articles or papers, lots of talks - also Clojure & ClojureScript are both fairly simplistic compilers - recursive descent mostly single pass - ClojureScript is still only a long weekend read
10:58eric_normanddukerutledge: someone at the react.js conference said it was "learn once, write anywhere" instead of "write once, run anywhere"
10:58dukerutledgednolen: Good to know, I'll have to dig in and check it out.
11:01eric_normanddnolen: that reminds me of a conversation you and Will Byrd had about a spec for Clojure
11:01eric_normanddnolen: any plans for that?
11:01dnoleneric_normand: I already talked to Will about this
11:02dnolendoesn't seem useful or interesting to me
11:02dnolenit's the kind of thing academics like, that doesn't buy you much
11:02eric_normandI see
11:02mdrogalisI'm trying to come up with a way to pass a Clojure function to a Java method expecting a lambda. My idea is to find an interface, like Callable, and use proxy to instantiate it - passing a partially applied Clojure function to its constructor. Callable doesn't take any params though. Has anyone come up with a good solution for this?
11:02dnolenlike most language specs punt on numerics
11:02dnolenwhich is like pretty much what every engineer cares about!
11:03chouserI'm trying clj-refactor for the first time, and cljr-thread is giving me errors. Anyone have any suggestions?
11:04chousermdrogalis: doesn't the Java method expect an object of a specific type? What method is it?
11:04mdrogalischouser: I don't think that's the case. Are you certain?
11:04eric_normandmdrogalis: doesn't IFn extend Callable?
11:04chousermdrogalis: Do you have a javadoc for the Java method you're trying to call?
11:05mdrogaliseric_normand: IFn can't act as a lambda because Java lambda's are classes with exactly one method. IFn has > 1.
11:05eric_normandoh
11:05mdrogalischouser: I was playing around with this guy: https://github.com/real-logic/Aeron/blob/master/aeron-samples/src/main/java/uk/co/real_logic/aeron/samples/SamplesUtil.java#L129
11:06mdrogalisReturns a function of 4 (untyped?) args.
11:06dnolenmdrogalis: why can't you just reify the interface you need and wrap the fn?
11:07chousermdrogalis: I think that's returning a DataHandler
11:07mdrogalisdnolen: Yeah, hm. I was attempting something like that - but I didn't pick up reify.
11:07chousermdrogalis: reify this: https://github.com/real-logic/Aeron/blob/master/aeron-common/src/main/java/uk/co/real_logic/aeron/common/concurrent/logbuffer/DataHandler.java
11:08mdrogalisAhh. I faked myself out last night - I thought Java got a little voodoo on me and inferenced what the types ought to have been.
11:08mdrogalisThanks chouser / dnolen. That'll fix my problem.
11:10chouseranyone know how to work around clj-refactor errors?
11:11mdrogalisWhat errors are you seeing?
11:12chouserclj-refactor.el:32:1:Error: Wrong number of arguments: (lambda (old new) (\` (progn (defalias (\, old) (\, new)) (put (\, old) (quote byte-obsolete-variable) (\, new))))), 3
11:13mdrogalisNot even sure where to start with that one.
11:14chouseryeah, me either. oh well.
11:21fellipebritoDoes anyone know how to make the lein-ring start in a different port than 3000?
11:22kungifellipebrito:
11:22clojurebotTitim gan éirí ort.
11:22kungilein ring server 4000
11:22kungifellipebrito: https://github.com/weavejester/lein-ring
11:22mpenetanyone with experience using Selmer (good or bad)?
11:23fellipebritokungi thanks
11:53nmeumIs there a way to find out if a character is a unicode letter?
11:54nmeume.g 'c', 'a' and 'ö' are unicode letters, but '1' is a digit and not a letter
11:54{blake}nmeum: Well, isn't it easier just to find the digits?
11:54{blake}nmeum: I mean, since there are only 10 of those.
12:01raeknmeum: perhaps using Character/getType
12:01chronnonmeum: You can do it via interop
12:01raek,(Character/getType \ö)
12:01chronno,(Character/isLetter \ö)
12:02clojurebot2
12:02clojurebotfalse
12:02raek,(seq "ö")
12:02clojurebot(\ö)
12:02chronnoum... weird... in my repl the isLetter call returns "true"
12:03fellipebritoI'm looking for a way to return a json header instead plain/text using compojure, does anyone have a start point so I can follow it? Everything I found online so far is old
12:03nmeumchronno: yeah, thanks
12:03raek,Character/LOWERCASE_LETTER
12:03clojurebot2
12:06fellipebritothis is my handler right now http://pastebin.com/Q0NrWhQe
12:10ARM9http://clojurepastebin.appspot.com/11669001 any thoughts on this behaviour?
12:10ARM9also didn't know you could :key a deftype
12:10jdludlowDoes anyone know of a decent example of testing a clojure web app with a test database and fixtures? The docs on use-fixtures are pretty sparse.
12:12AeroNotixjdludlow: what do you want to know?
12:16jdludlowMainly I’m trying to figure out how to have tests that will (1) have some known data populated before and (2) have those tables truncated afterwards. In Rails terms it would be like using transactional fixtures, with either the built-in fixtures or something like FactoryGirl.
12:20gfredericksjdludlow: the word "fixtures" is misleading there
12:20gfredericksfixtures in clojure.test are just arbitrary functions that do things around your tests; they don't do anything specific to test data at all
12:22jdludlowThat makes sense. So if I think of them as a generic callback I could just have my own functions that clear out my database and/or set up test data?
12:25gfredericksyep
12:26gfredericksalso see test.check as an alternative/supplement to having lots of static test data
12:26jdludlowCool, thank you
12:56gfrederickspuredanger: looks like local vars might still print #<>
12:57gfredericks,(with-local-vars [x 12] x)
12:57clojurebot#<Var: --unnamed-->
12:57gfredericks^ like that
12:57gfredericks,(atom nil) ;; checking if clojurebot is on newest code
12:57clojurebot#<Atom@75f250ac: nil>
12:57gfrederickshaven't verified yet, still trying to build master
13:01gfredericksverified
13:02magnarschouser: that's an elisp error. Please open an issue on the github repo.
13:12ARM9anyone know of a fast way to get a clojure repl, lein takes like 500 years to start anything
13:13ARM9and the clojure.jar isn't much faster
13:13FrozenlockARM9: I personally have a repl running in the background at all times.
13:13ARM9that's nice
13:13ARM9not a solution I'm afraid
13:13ARM9I mean I guess hdd cache sort of helps but it's still quite slow
13:13FrozenlockWell, if your problem is "I don't want to wait to execute a command", yes, it's a solution.
13:14{blake}ARM9: SSD.
13:14ARM9soon blake, soon
13:14chousermagnars: Thanks. Looks like it's actually coming from yasnippet
13:14ARM9I guess I'll try to hold out until then
13:14{blake}ARM9: I use Cursive and it only takes a few seconds to open a REPL in it.
13:15{blake}(On this craptastic work machine.)
13:15ARM9oh the jetbrains thing
13:15ARM9I've heard about that, it's out?
13:15puredangergfredericks: I didn't see anything in the commit to handle that so I assume you're right
13:15ARM9nvm early access
13:15{blake}It's in "early experience", but I've been using it exclusively for development for months.
13:16ARM9cool I'll give it a spin
13:17gfrederickspuredanger: definitely a much rarer use case
13:24ARM9I guess I'll just try to avoid leiningen whenever possible
13:31justin_smithfellipebrito: print it to see the printed form
13:31justin_smithnever mind, I was scrolled!
13:32fellipebritojustin_smith np
13:43BigBoy0113hey
14:09ortunaIs there a guide to testing core.async code with clojure.test ?
14:12kungiortuna: if you find one please tell me
14:16ortuna@kungi I havn't found anything but I've searched. So it was leading me to believe I'm doing something wrong? Like I shouldn't test the async code directly?
14:17justin_smithortuna: things I find helpful: a counter in an atom, to see how many times a loop runs, a delay or promise and a test of whether it is realized (this can effectively tell you if certain code has run or not)
14:20seangroveIs there a tool to visualize ns dependencies nicely? ns-dependencies is fast, but the visualization is pretty tough to use
14:21gfredericksI made something a while ago that emitted graphviz; it might be currently broken now though
14:22gfredericksI can't remember in what way I misused the different analyzer libs and how I was supposed to fix that
14:22gfrederickshttps://github.com/gfredericks/clj-usage-graph
14:22gfredericksbut if you understand how to use tools.analyzer then I bet it'd be easy enough to fix
14:22seangrovegfredericks: I don't, but now is as good a time as any to learn, I suppose
14:23gfredericksby "easy" I mean that the analysis code is nicely separated from the visualization code
14:23gfredericksthere were also problems with things like defrecord but hopefully it was the sort of thing that goes away when you use recent versions of the analyzer
14:24Bronsagfredericks: I'll fix what needs to be fixed & open a PR
14:26gfredericksoh man you guys are the best
14:29pjstadigis anyone aware of a library that defines a tagged reader and print method for double arrays?
14:35gfrederickspjstadig: I suggest a pirated-themed library
14:47shempjstadig: i used to frequent those libraries, but my skin just can't take it these days.
14:54shemsorry about that.
15:02Bronsagfredericks: there you go
15:10gfredericksBronsa: omg omg omg thanks
15:11gfredericksseangrove: I'll be trying out Bronsa's PR shortly and will make a release if it works like at all
15:19TEttingerpjstadig: if you don't care about extreme efficiency, you can serialize it as an eval-able string
15:20justin_smithTEttinger: if you don't care about extreme efficiency, you can just use a vector.
15:20TEttingerhttps://github.com/tommyettinger/Ravager/blob/master/ravager/desktop/src-common/ravager/core.clj#L22-L25
15:20TEttingerthat's what I did here
15:21TEttingerI'm sure there's a better way
15:21justin_smithI guess that sacrifices serialization / deserialization speed, but keeps the runtime perf
15:22TEttingeran edn reader literal would make more sense
15:31iwilligis there is a for version of mapv ?
15:32iwilligforv
15:32gfredericksBronsa: having trouble getting this to finish on a large project, but works great on simpler libraries
15:37TEttingeriwillig, seems like a simple enough macro to call vec on the result of for
15:37TEttingerbut I'm half asleep still
15:39iwilligTEttinger: good point… i was checking to see if there was anything the standard lib
15:40Frozenlockiwillig: your question made me discover there is such a thing as `filterv'.
15:41TEttinger(doc filterv)
15:41clojurebot"([pred coll]); Returns a vector of the items in coll for which (pred item) returns true. pred must be free of side-effects."
15:41TEttingerwhaaaaat
15:41FrozenlockAnd there I thought mapv was all alone. How wrong I was...
15:41justin_smith,(clojure.repl/apropos #"v$")
15:41TEttinger(inc Frozenlock) ; I learned something new!
15:41lazybot⇒ 5
15:41clojurebot(clojure.core/filterv clojure.core/mapv clojure.core/reduce-kv)
15:41justin_smithapropos is great
15:46gfredericksseangrove: try version 0.2.0 and let me know how it breaks :)
15:51aneis there a shorter way to get the first truthy from a sequence instead of (first (filter identity (...))
15:52justin_smithane: some identity is slightly better
15:52justin_smith,(some identity [nil false :a])
15:52clojurebot:a
15:52justin_smith,(some identity [nil false nil])
15:52clojurebotnil
15:59anesweet
16:19gfredericksbronsa: core.async uses [org.clojure/tools.analyzer.jvm "0.1.0-beta12"]
16:19gfredericksany guesses if I can safely override that and force it to use the newest version?
16:19arohnerclj-http question: When I request https://ssl.google-analytics.com/ga.js (google analytics) from chrome, I get "content-encoding: gzip" in the response. When I request from clj-http, I get back uncompressed. I think I'm setting Accept-Encoding properly. any ideas why I'm getting uncompressed?
16:22wei_,nil
16:22clojurebotnil
16:23hiredmanhttps://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj#L267
16:27arohnerhiredman: I'm setting :decompress-body false
16:29hiredmanarohner: if you don't set any options, what does :orig-content-encoding in the response say?
16:30arohner:orig-content-encoding nil
16:31arohnerappears I get the same behavior using clj-http.core/request, i.e. content-encoding header isn't set
16:31hiredmanso google is deciding (maybe based on user agent or something?) not to serve you gzipped data
16:31arohnerah, user agent is an interesting idea. I'll try that
16:32arohnerhiredman: yup. spoofing chrome properly gives me gzipped data. sigh
16:33hiredmanthose guys
16:34arohnerhttps://developers.google.com/discovery/v1/performance#gzip
16:36arohnerhttps://stackoverflow.com/questions/7140035/http-server-not-honoring-accept-encoding-gzip-unless-user-agent-is-known-browse
16:55borkdudehmm... I just discovered that symbols as functions also take a default argument... (:foo nil 1)
16:55borkdudeafter 5 years of clojure...
16:55justin_smithand symbols even ##('foo nil 1)
16:55lazybot⇒ 1
16:55Frozenlocks/symbols/keywords :-p
16:55Frozenlockwaaa
16:56borkdudeehm keywords yes
16:56justin_smithand symbols too!
16:56borkdudebut symbols do too, wow
16:56FrozenlockI'm pretty sure justin_smith is a witch...
16:56leandro713hi, some gentleman can tell me why this doesn't works → (for [[v] (.split "abcde" "")] (keyword v))
16:56amalloyevery couple months there's a mailing list thread like "why does ('+ 2 2) return 2?"
16:57justin_smithFrozenlock: no, just very curious, and I try lots of weird things, some of them even work
16:57justin_smithleandro713: ##(keyword "")
16:57lazybot⇒ :
16:58borkdude,(for [v (.split "abcde" "")] (keyword v))
16:58clojurebot(: :a :b :c :d ...)
16:58justin_smithit works, but that first keyword is super weird
16:58borkdudejustin_smith it is the empty keyword
16:58leandro713thanks sirs
16:58borkdudejustin_smith you don't know that? :P
16:58justin_smithhaha
16:59justin_smith,(symbol "")
16:59justin_smiththe empty symbol is even better :)
16:59justin_smith,((juxt identity count) (list (symbol "")))
16:59clojurebot[() 1]
17:00justin_smithrofl
17:00justin_smith,((juxt identity count) (repeat 1000 (symbol "")))
17:00clojurebot[( ...) 1000]
17:01justin_smithfor some reason I find that very funny right now
17:01borkdudejustin_smith the empty symbol is used extensively to optimize clojurescript, in case you wondered
17:02borkdudejk of course
17:02justin_smithof course
17:03justin_smith,(eval `(def ~(symbol "") 42))
17:03clojurebot#'sandbox/
17:04justin_smithOK, that is funny
17:04borkdudejson in clojure:
17:04borkdude,(let [k (keyword " foo")] {"a" k "b" k})
17:04clojurebot{"a" : foo, "b" : foo}
17:04justin_smiththat's kind of evil
17:05borkdudeeven better:
17:05borkdude,(let [k (keyword " \"foo\"")] {"a" k "b" k})
17:05clojurebot{"a" : "foo", "b" : "foo"}
17:05Frozenlock,(resolve (symbol ""))
17:05clojurebot#error{:cause "String index out of range: 0", :via [{:type java.lang.StringIndexOutOfBoundsException, :message "String index out of range: 0", :at [java.lang.String charAt "String.java" 658]}], :trace [[java.lang.String charAt "String.java" 658] [clojure.lang.Compiler maybeResolveIn "Compiler.java" 7041] [clojure.core$ns_resolve invoke "core.clj" 4202] [clojure.core$ns_resolve invoke "core.clj" 41...
17:05Frozenlockwoops
17:05borkdudelol
17:06justin_smithFrozenlock: given the def I made, that should have worked
17:06justin_smithhaha
17:06Frozenlockjustin_smith: that's what I was counting on.
17:06FrozenlockWe must open bug reports at once! :-p
17:07borkdudeFrozenlock I think I have mentioned this once to stuartsierra or someone else in the past, but then the reply was:
17:07borkdudekidding.
17:07justin_smith,@(resolve (symbol "sandbox/"))
17:07clojurebot42
17:07borkdudethe reply was: clojure doesn't prevent you from doing things wrong
17:07FrozenlockWhy the deref?
17:08justin_smithFrozenlock: otherwise you just get the var
17:08borkdudeyou can fuck up things if you want
17:08justin_smith,(resolve (symbol "sandbox/"))
17:08clojurebot#'sandbox/
17:08Frozenlockborkdude: yeah, using empty symbols is probably the definition of doing the wrong thing...
17:08Frozenlockjustin_smith: Ah right
17:08justin_smithclassic case "doctor, it hurts when I do this" -- "OK, then don't do that"
17:12justin_smithFrozenlock: usually when you call resolve, it's to get something you can call, and that will deref automatically in the call position
17:12justin_smithwell, a var will at least :)
17:13borkdudeanother way to write json:
17:13borkdude,{(symbol "a:") 1, (symbol "b:") 2}
17:13clojurebot{a: 1, b: 2}
17:14justin_smith,{(symbol "a :") 1 (symbol "b :") 2}
17:14clojurebot{a : 1, b : 2}
17:15justin_smith,(def w (symbol "{}"))
17:15clojurebot#'sandbox/w
17:15justin_smith,w
17:15clojurebot{}
17:15justin_smith,(type w)
17:15clojurebotclojure.lang.Symbol
17:21Frozenlock,(w :a)
17:21clojurebotnil
17:21FrozenlockFull circle! :-p
17:21justin_smith,(assoc w :a 0)
17:21clojurebot#error{:cause "clojure.lang.Symbol cannot be cast to clojure.lang.Associative", :via [{:type java.lang.ClassCastException, :message "clojure.lang.Symbol cannot be cast to clojure.lang.Associative", :at [clojure.lang.RT assoc "RT.java" 750]}], :trace [[clojure.lang.RT assoc "RT.java" 750] [clojure.core$assoc__4093 invoke "core.clj" 189] [sandbox$eval165 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Com...
17:26paulswilliamsesqHi all
17:26justin_smithhello paulswilliamsesq
17:27paulswilliamsesqjustin_smith hi
17:29borkdudehello paulswilliamsesq
17:29justin_smith,(symbol (apply str "ba" (take (rand-int 5) (repeat "na"))))
17:29clojurebotbanana
17:29paulswilliamsesqborkdude hiya
17:30paulswilliamsesqI was going to ask a question but remembered I had a REPL in which to play ;-) Might be able to answer it myself
17:30borkdudemeanwhile I was trying to figure out how to reify/proxy Symbol to it prints differently
17:30borkdudebut I could not get it to work
17:30justin_smithborkdude: proxy Symbol and override to-string?
17:30justin_smitherr toString
17:31justin_smithor maybe you want print-method
17:31borkdudejustin_smith yes
17:34eric_normandpaulswilliamsesq: that's great!
17:35paulswilliamsesqeric_normand hehe, yeah, I forget the repl. As a recovering imperative coder, I sometimes need a reminder ;-)
17:36nicferrierI need to match one of these weird symbols that the xml parser makes, eg: :a:link
17:36nicferriercore.match is barfing because the reader barfs
17:36nicferrierand when I use a match with (symbol ":a:link") in it it also barfs.
17:36nicferrierI'm guessing core.match needs static symbols.
17:37eric_normandpaulswilliamsesq: whenever I pair, I'm always like "don't ask me, you've got the entire system right there!"
17:37justin_smith,(proxy [Object] [] (toString [] "woof"))
17:37clojurebot#object[sandbox.proxy$java.lang.Object$ff19274a "woof"]
17:38justin_smith,(str (proxy [Object] [] (toString [] "woof")))
17:38clojurebot"woof"
17:39paulswilliamsesqeric_normand yeah, it's a revelation. I hear a REPL is coming to Java but i just don't see how that will work in an statically typed OO language.
17:44iwillighow does one use map in the thread macro ? (-> value fn fn2 (map %())) since needs the map the coll in the last position of the s-exp
17:44iwilligis there a good way of putting map into -> or some-> ?
17:45gfredericksiwillig: embed a ->>
17:45iwilligoh right
17:45iwilligof course
17:45iwilligthanks
17:45gfredericks,(-> 5 inc (range) (->> (map #(* % 2))))
17:45clojurebot(0 2 4 6 8 ...)
17:45iwilligthanks gfredericks
17:47amalloypaulswilliamsesq: scala already has a repl. it should be fine for java really
17:47amalloyand eclipse has had something repl-y for like a decade
17:47justin_smiththere's beanshell, but beanshell is weird and old
17:48borkdudethe JRuby repl is nice for Java too
17:48justin_smiththere's also groovy
17:49paulswilliamsesqamalloyeah, but JRuby and Groovy are more dynamic.
17:52amalloyi didn't say anything about either of those
17:52paulswilliamsesqI can see REPL use for instantiating objects, and querying them etc.
17:52paulswilliamsesqamalloy sorry, my bad irc client use ;-)
17:53paulswilliamsesqBut whilst I can declare and use functions in the clojure repl, declaring a class seems too much effort.
17:53paulswilliamsesqSaying that, I've not tried it.
17:59gfredericks$mail Bronsa this might constitute a bug report? https://github.com/gfredericks/tmp-bronsa
17:59lazybotMessage saved.
18:11nicferrieris there a clojure (not script) dom implementation?
18:13Bronsagfredericks: hah, can you see what's going wrong? https://github.com/gfredericks/clj-usage-graph/blob/master/src/com/gfredericks/clj_usage_graph/usages.clj#L21-L22
18:15gfredericksBronsa: did I write this code?
18:15Bronsano, I did
18:16Bronsagfredericks: s/and/do and it should be fine, sorry :P
18:16gfredericksactually no it looks fine to me
18:16gfredericksoh lol
18:16Bronsagfredericks: assert returns nil
18:16gfrederickscool thanks
18:37justin_smiththe other day someone was asking a question about frequency detection, but I misplaced my log of it. If whoever it was is around, I just found a really good description on how to measure a single frequency bin of a fft by hand
18:40aaelonyis there anything like http://www.clojure-toolbox.com/ for the cljs world or clj+cljs world?
18:42justin_smith*an fft
18:42aaelonyjustin_smith: it wasn't me but sounds interesting
18:43justin_smith(defn bin-level [signal probe] (apply + (map * bin probe)))
18:43aaelonyor core.matrix perhaps?
18:43justin_smithwhere probe contains a sine wave of the frequency you want to measure, padded to the length of the signal, and signal is a sub-array of your input
18:43justin_smithyou don't even need core.matrix for that, but sure
18:44justin_smiththere are optimizations you can do, knowing that you are measuring multiple, related probe inputs
18:44justin_smith(also s/bin/signal in my function above)
18:44justin_smithbut the basic concept is really just a sum over an element by element multiply
18:44aaelonyvery cool. wonder how performance would fare
18:45justin_smiththis is probably the most naive way to do it possible :)
18:45aaelony:)
18:45justin_smithbut it is clear, and shows exactly what the algorithm measures, which is cool
18:46justin_smithit's a specific way of testing the correlation of the input to the probe
18:46aaelonysounds interesting, but more interesting to me at a matrix level
18:46aaelonymmult perhaps
18:47justin_smithsure, in real DSP you would be doing all of this in matrix math
18:47justin_smithyou would calculate multiple probe frequencies at once, thanks to some helpful math
18:47aaelonyagree
18:48justin_smithfftw - the leading impl out there - uses ocaml at compile time to derive the best coefficients for the transform
18:48justin_smiththe ocaml code generates the c code when you compile
18:48justin_smiththe math going on there is *way* over my head
18:49aaelonyme too, can never know enough...
18:50justin_smithhttp://www.fftw.org/doc/Generating-your-own-code.html
18:50justin_smith"a rather sophisticated program that generates directed acyclic graphs of FFT algorithms and performs algebraic simplifications on them"
18:50aaelonyFrench!
18:51justin_smithoh yeah, ocaml is french
18:51aaelony;)
18:51aaelonydidn't know that
18:52justin_smithI like how they are basically like "here's the big picture, if you want to know the details, send us an email"
18:52turbofaili thought the fftw authors were italian
18:52justin_smiththey're probably like "OK, how many math PHDs do you have, we need to know how much to dumb down the answer"
18:52aaelonyhehe
18:52justin_smithturbofail: they use ocaml, a cousin of haskell, to generate partial calculations for their matrix ops at compile time
18:53justin_smithand yeah, it looks like you are right, at least a few of the guys behind fftw are Italian
18:53turbofaili was aware of that partial evaluation step
18:54turbofailbut it looks like only one of the two main authors is italian
18:55justin_smithaaelony: turbofail: they wacky algo they use http://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm
18:56justin_smithhaha, they really have "twiddle factors" http://en.wikipedia.org/wiki/Twiddle_factor
18:56justin_smithI love that that is a real technical term
18:57aaelonyfairly apt
18:59justin_smithwow, they even transpose data in the matrix in order to improve the cache coherency... fascinating stuff - faster to scramble, operate, and descramble than to do the repeated jumps
19:17aaelonypremultiplying transposes is magical
19:27{0}grantDid anything come about that SICP introduction/rehashing and exercise sample book in Clj?
19:28justin_smith{0}grant: last I saw it was still in progress
19:29{0}grantMAL kinda got me interested in Clojure again, generally.
19:29justin_smithaaelony: it was kind of a breakthrough for me to see exactly what the fft algo does - makes me think I could pick up pink and try a few variations - gabor wavlets etc.
19:32justin_smithI think eve is really separate
19:33{0}grantjustin_smith: Interesting. Any idea if it's going to be FOSS too?
19:33justin_smithno, not at all. but cgranger is sometimes around here
19:33justin_smitherr wait, that's not the author is it...
19:34justin_smith{0}grant: probably, if you aren't tied to a particular way of doing things too strongly, cursive + intellij is the most featureful clojure platform right now
19:35gfredericksdoes anybody know what *ns* is set to when an (ns ...) form gets eval'd?
19:35gfredericksI assume either clojure.core or user
19:35Bronsauser
19:35justin_smithI would guess user...
19:35Bronsaor the requiring namespace
19:35justin_smithbut go with Bronsa's knowledge over my guess :)
19:35{0}grantjustin_smith: I"m pretty invested in Emacs at this point; Generally interested in playing with alternatives ... doubt I'll really switch of it though. Any experience with Cider?
19:36justin_smith{0}grant: cider is my worst emacs experience ever. I'm a long time emacs user and gave up on cider, I just use inferior lisp now
19:36Bronsae.g. in (ns foo (:require bar)) (ns bar), (ns foo) is evaluated with *ns* set to user, (ns bar) is evaluated with *ns* set to bar
19:36gfredericksBronsa: my new bug is that I have to be careful what *ns* is when backticks get read :)
19:36{0}grantjustin_smith: That's very disheartening ... I thought it tried to clone Slime's usability?
19:36Bronsaheh
19:37gfredericksI can't just slurp a whole file up through the reader at once
19:37turbofailjustin_smith: i still use nrepl.el on a bunch of machines
19:37Bronsagfredericks: true, but it looked to me that `forms` was lazy, isn't that the case?
19:38Bronsaah, uhm
19:38justin_smithturbofail: yeah, I used to do that, but I just threw in the towel, there's nothing I really need that inferior lisp can't do
19:38aaelonyjustin_smith: I agree, those kind of breakthroughs are the best. There is nothing like strong coffee and deep thoughts ;)
19:39Bronsagfredericks: just wrap the whole fn body in a (binding [*ns* *ns*] ..), I believe that should do it
19:39turbofailjustin_smith: meh. i like my autocomplete, eldoc, and source popups
19:40Bronsagfredericks: and remove the doall in forms :P
19:40Bronsauh, I already bound *ns*.
19:41turbofailjustin_smith: i also like being able to put the result of C-x C-e into the buffer that i'm evaluating in
19:42justin_smithturbofail: fair enough, at this rate I'll just be shelling out to ed from the repl, then reloading the ns after editing it
19:42justin_smith(that's the likely end point, that is)
19:43turbofaileven better would be editing using slurp and clojure.string/replace
19:44justin_smithusing ed, of course
19:48gfredericksBronsa: I dn't want to rely on laziness
19:50Bronsagfredericks: then read a form after analyzing+eval the previous one.. cljs uses a lazy `forms-seq` btw (or used to, at least)
19:51gfredericksyeah I'll do something to that effect
19:56TEttinger2Bronsa: which awesome clojure project are you the dev of again? I can't keep track of how many cool things go on in here :)
19:56BronsaTEttinger2: a bunch of tools.* contrib libraries
19:57TEttinger2neat
19:57Bronsanamely tools.reader, tools.analyzer, tools.analyzer.jvm, tools.analyzer.js and tools.emitter.jvm
19:57TEttinger2I'm making a super hacky hack on lazybot to get it to reconnect on network outage
20:05gfredericksBronsa: is the a/empty-env a mutable thinger that gets mutateded by calling a/analyze+eval?
20:07Bronsagfredericks: no it's an immutable hashmap
20:08gfrederickshokay
20:09gfredericksBronsa: why did you claim that you already did (binding [*ns* *ns*])?
20:10Bronsagfredericks: because I'm tired and didn't realize I wrote that in my local copy earlier while trying to figure out the cause of your exception :P
20:12Bronsaso yeah, you need to bind *ns*
20:12gfredericksroger
20:31TEttingerjustin_smith: my lazybot just reconnected on its own and plugins work
20:31TEttingerthe solution is the hackiest hack possible
20:32TEttinger2(.exec (Runtime/getRuntime) "cmd /c start cmd /c java -jar lazybot.jar")
20:33TEttinger2that executes after 6 minutes of nothing being written
20:33TEttinger2(no pings or pongs, no messages)
20:33TEttinger2then it kills the current process
20:34TEttinger2the new process then will wait 6 minutes if it fails to connect, then do the same thing, spawning a new cmd window and a new lazybot, then killing the current one
20:35TEttinger2if it succeeds on a connection, it resets the timer every time it writes something, and if the timer hits 6 minutes since receiving anything or sending anything, it proceeds to spawn a new cmd, new lazybot, and kill the current one
20:54ShayanjmQuestion - isn't ((complement n) x) the same as (not (n x))?
20:55gfredericksI can't think of a difference
20:55BronsaShayanjm: it is
20:55Shayanjmso why is having complement useful?
20:55gfredericksyou're not always calling it that way
20:55Shayanjmseems like another hoop to generate another function all together
20:56BronsaShayanjm: it's useful when you need to use a hof
20:56gfredericksit's in a family of higher order functions that are useful in certain contexts
20:56Shayanjmhof, Bronsa?
20:56Bronsahigher order function
20:56Shayanjmoic
20:56gfredericksalong with partial, juxt, um
20:56gfredericksI'm blanking on the rest of them
20:56Bronsacomp
20:56gfrederickscomp
20:57Shayanjmoh i understand now
20:59jmpavonhi, I made a small clojure prog to scrap a web. It works on 'lein run' but not on uberjar... looks like a laziness problem, how can I debug it? I put doall before every map and pmap but still doesn't work
21:00gfredericksjmpavon: why do you say it looks like a laziness problem?
21:00gfredericksit's possible, I think `lein run' tries to print the result
21:01jmpavongfredericks: because it works perfect on 'lein run', I read somewhere that could mean I need to 'realize' the lazy seqs
21:01jmpavongfredericks: problem is... I don't know where
21:04gfredericksjmpavon: you have a main function?
21:05jmpavongfredericks: yes
21:05gfrederickstry wrapping the last thing in that function with (prn ...)
21:05gfredericksand see if that helps
21:05gfredericksbut the real fix is to change your style of code so that you don't have to worry about laziness
21:06jmpavongfredericks: hmmm, last thing is a call to a function which actually prints (with print)
21:10gfredericksjmpavon: guess it wouldn't help then
21:10gfredericksjmpavon: so in what way doesit not work when you run the uberjar?
21:11jmpavongfredericks: it doesn't print anything, but it seems to do all the queries (for the time it takes to run)
21:12gfredericksjmpavon: how are you running the jar?
21:13jmpavongfredericks: java -jar uberjar.jar args
21:14gfredericksif you (println "Hallo!") at the top of main do you see that?
21:15gfredericksif the last thing your main does is print then there's no good reason for it being different from lein run
21:18jmpavongfredericks: that's what I thought, actually, with doall before every map, should realize the lazy seqs, but still...
21:20gfredericksthe only difference between lein run and the uberjar should be right at the end, so the internal doalls shouldn't make a difference
21:28jmpavongfredericks: thx, I think I know where the problem might be...
21:32ennI have a library X which wraps Y. Ideally users of X should not need to require Y directly. However, there is a dynamic var *foo* which Y defines which I would like to be available to users of X as X/*foo*. Is there a way to "re-export" a symbol like this?
21:32gfredericksgeez
21:33gfredericksthat's a tricky one
21:33gfredericksyou might be better off trying not to use dynamic vars; what sort of lib is it?
21:34ennan advice/tracing library
21:35gfrederickswhat's the dynamic var do?
21:35amalloyenn: why make it available as a dynamic var at all? if you need to allow access to it you can simply write a function (get-foo) and a macro (with-foo new-foo & body)
21:35ennIt's bound to the currently-advised var, in the context of any advice code that is running
21:36gfredericksseangrove: okay 0.2.1 is pretty good I think
21:36ennamalloy: my plan b is (def get-foo [] y/*foo*) in x. But it would be a little nicer to just expose the var directly.
21:39enn(since consumers of this library should only ever need to read the value of *foo*, never to bind it)
22:19mmitchellanyone know of a good way to use a java servlet filter within a ring app?
22:48justin_smithTEttinger2: glad that works, it would be nice to be able to reconnect the current instance instead (rebinding the connection I guess?
22:48justin_smith)
23:28cnb_I'm trying to create a ws using jax-ws but there is no examples on how this is done, who has created a ws using jax-ws?
23:35sejjeWhat's the best way to determine if you have a dependency conflict? Some googling makes me suspect that's my issue.
23:38justin_smithsejje: lein deps :tree
23:38justin_smithit will show your conflicts, and suggest how to pick explicit versions
23:39sejjejustin_smith: how does it highlight/designate conflicts?
23:39justin_smithsejje: it explicitly lists all conflicts
23:40justin_smithsejje: clojure won't use two versions of the same dep, "deps :tree" will tell you which version lein is choosing, and show other versions that it could have picked
23:40OladonI'm attempting to follow https://mmcgrana.github.io/2010/07/develop-deploy-clojure-web-applications.html, though I realize it's somewhat out of date, but I'm getting a weird error: java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V... anyone have any ideas?
23:41sejjejustin_smith: I don't see anything about conflicts. I'm using lein-git-deps for the newest (breaking) library--is that perhaps why I don't see conflicts?
23:43justin_smithsejje: I'm not sure, I have never used lein-git-deps
23:43justin_smithsejje: my standard way of using a bleeding edge lib is to check out the code, edit the version string to make it clear it is unofficial and installed locally, and run "lein install" so that I can use it as a normal dep
23:44justin_smithsejje: that way it follows the same rules everything else does in terms of dependency resolution
23:44justin_smithI have no idea what lein-git-deps does
23:44sejjejustin_smith: alright, i'll look into that. lein-git-deps was the only/first way i could get it working, obv a new guy here. i'll look into lein install
23:45sejjejustin_smith: much appreciated.
23:45TEttinger(inc justin_smith)
23:45lazybot⇒ 206
23:45justin_smithsejje: lein install is pretty simple. You don't need to edit the version string (which is in project.clj), but that can be a sanity saving measure
23:45justin_smithsejje: eg. if someone else tries to build your code and wonders why it doesn't work, they can see from the version string it's not canonical
23:52OladonAnyone?
23:53amalloyOladon: get a version of clojure that's up to date. you're trying to uise some library that expects a more modern version of clojure, on a version of clojure that's five years old
23:53sejjejustin_smith: that was simple, glad to know about it, thanks again. now back to my lein deps :tree---i'm still not seeing any explicit "conflict" messages. I get lots of "consider using these exclusions" and at least one "possibly confusing dependencies found"
23:53amalloyeg, depend on 1.6.0 instead of 1.2.0-beta1
23:54Oladonamalloy: I'm using 1.6.0
23:54amalloyokay, then it's the opposite. get newer versions of your libraries
23:54amalloythe project.clj in that blog post is very outdated
23:54OladonNods, I figured it would be -- thanks, amalloy!
23:55Oladon(inc amalloy)
23:55lazybot⇒ 235
23:56justin_smithsejje: oh, sorry, "possibly confusing dependencies" and "consider using these exclusions" are how it describes conflicts
23:56justin_smithI forgot that it does not use the word conflict
23:57sejjejustin_smith: haha, i have about way too many of those. i'll sort through them. in other news, grep does not seem to filter lein deps :tree output...unless these are ungodly long lines.
23:59justin_smithsejje: lein deps :tree 2>&1
23:59justin_smith(if you are using bash that is)
23:59justin_smithit puts some output on stderr, other on stdout, that will merge both to stdout so you can filter etc.