#clojure logs

2014-04-27

00:01ToxicFrogArgh. I cannot figure out what is going on here.
00:02ToxicFrog*state* starts out as {}. It does (set! *state* (assoc *state* :pass foo)) and gets {:pass foo}
00:02ToxicFrogThen it does (set! *state* (assoc *state* :user bar)) and gets {:pass foo :user bar}
00:03ToxicFrogAnd then it does (set! *state* (assoc *state* :channels [x y z])) and gets... {:pass foo :channels [x y z]}
00:03ToxicFrogI cannot figure out what is going wrong.
00:07akhudekToxicFrog: why are you using set! ?
00:08ToxicFrogakhudek: because I have given up on making sense of Saturnine's poorly documented state management API
00:10akhudek:-(
00:10ToxicFrogHonestly the only reason I haven't punted Saturnine entirely and reimplemented the parts I want is the lack of a convenient clojure wrapper around the java sockets API
00:15toanHi guys, i'm new to clojure and trying this tutorial. https://github.com/swannodette/enlive-tutorial/
00:15toaneverything is fine until i run > (hn-headlines)
00:17toani get a 403 (forbidden). i've look it up but there is not much info on faking "user-agent"
00:18akhudektry scraping http://webcache.googleusercontent.com/search?q=cache:DjfN_3WYfIsJ:https://news.ycombinator.com/+&cd=1&hl=en&ct=clnk&gl=ca maybe?
00:19akhudekthough I don’t know why you would get a 403
00:19akhudekI was just able to wget hn just fine
00:20toaninteresting
00:20toanthx
00:23ToxicFrogOh goddamnit.
00:23ToxicFrogIt's a race condition.
00:24ToxicFrogMade possible because apparently saturnine spawns a separate thread for each socket, so the upstream handler can run while the downstream handler is still constructing the new state
00:24crispinToxicFrog: can you use channels to consume it on a single thread
00:24crispinusing core.async
00:26ToxicFrogcrispin: not without replacing saturnine, I think
00:26ToxicFrogFor some reason I thought it did that already specifically to avoid this sort of problem
00:27crispinIm not familiar with saturnine
00:27ToxicFrogThis also explains a lot of my confusion around how saturnine's state management works
00:28ToxicFrogLibrary for networking, basic idea is that it lets you install a stack of "handlers" between two sockets (which may be send/recv halves of the same connection) and as messages arrive the appropriate handler functions are called
00:28ToxicFrogEach handler starts with a blank "state" passed to each function, and whatever that function returns becomes the new state
00:28crispinah its already async
00:29ToxicFrog...except apparently it's possible for a handler to send a message, and that message to trigger another handler invocation, and that invocation executes concurrently with the first handler, before it has returned the new state
00:29ToxicFrogSo the second handler gets stale state and everything goes horribly wrong
00:30toanakhudek, i just tried the cached page but got 403 still... maybe it has something to do with the fact i'm tethering the connect through phone... maybe
00:31akhudektoan: that’s very odd. Does wget work? If not, it’s definitely something in your networking.
00:32ToxicFrogI have implemented a fairly ugly workaround here but I really have no idea how to solve this in the general case.
00:32ToxicFrogWithin the framework of this library, I mean.
00:32clojurebotIt's greek to me.
00:32crispinshould you not be using vars?
00:33crispinsaturnines examples don't use any refs except for @users
00:33crispinthe handler just assoc's and returns it
00:33crispinwhat is your *state* ref doing?
00:33toanok, will try. interestingly, yahoo.com returned "()"
00:35ToxicFrogcrispin: that's not the problem here. Within a handler, it does (binding [*state* state] (dispatch function) *state*); the dispatch function may find it more convenient to (set-state) (a wrapper around (set! *state* foo) than to return a new state.
00:35toanwget work just find
00:35toanfine
00:36akhudektoan: well, as a temporary measure you can always just load the file from the disk instead. Just use (html-resource (io/file “myfile”))
00:37toanok. cool. thanks so much.
00:38ToxicFrogcrispin: I could rewrite parts of it to avoid needing set!, and I may even do so at some point, but first I want to fix this.
00:38crispinwell set! is java interop, yet you're using it across threads? the assoc calls with :pass in the hashes two threads
00:39crispincan the STM help you?
00:39crispinseems you want a shared state between threads?
00:39crispinnot sure what is going on, just thinking out loud
00:40crispinsetting refs inside dosync is safe from that behavoir
00:40ToxicFrogEr
00:40ToxicFrogI am not deliberately using it across threads
00:41ToxicFrogThis does not mean Saturnine is not creating its own threads and invoking different handlers of mine in different threads
00:41ToxicFrogWhich shouldn't make a difference, except that the value used for (binding) *state* is passed in by Saturnine, and if one message handler runs before a currently-running one completes, they both get the same state passed in even the currently-running one needed to update it.
00:42ToxicFrogThat said, I have now figured out how to activate Saturnine's threadless mode and reproduce this, so threads are not the problem.
00:42ToxicFrogI think what's happening is this:
00:43crispinso handler 1 puts :pass on *state*
00:43ToxicFrog- upstream handler is invoked, binds *state* containing :pass, calls set-state to add :nick, and generates an upstream message
00:43crispinthen handler 2 and 3 run "simultaneously" and h2 puts :user, and h3 puts :channels
00:43ToxicFrog...wait, no, that doesn't make any sense
00:44ToxicFrogcrispin: that's what I thought was happening, but I have now reproduced this behaviour in a mode that, if the documentation is accurate, is singlethreaded
01:33danlamannacan someone point me to the clojure-way of building up a hashmap from a list of strings, that need processing?
01:34Frozenlockdanlamanna: A list of strings? Like ["hello" "evening" "math" "computer"] ---> {"hello" "evening" "math" "computer"} ?
01:35danlamannaFrozenlock: more like ["foo bar" "baz qux"] ---> {:foo "bar" :baz "qux"}
01:36danlamannaits just the mindset of doing it without mutable variables
01:36danlamannathats tripping me up.
01:38Frozenlock,(into {} (map #(clojure.string/split % #" ") ["foo bar" "baz qux"]))
01:38clojurebot{"foo" "bar", "baz" "qux"}
01:38FrozenlockDo you want keywords as keys?
01:39danlamannayeah, i have the idea now though, not sure why i was trying to loop...
01:39arrdemdanlamanna: because that's what you're used to :P
01:40Frozenlockarrdem: that's my worst enemy. Mr What-im-used-to.
01:40FrozenlockI get stuck on stupid things because of him.
01:43bitemyapparrdem: up for a round?
01:43bitemyapparrdem: I'm ready to take a break, just made some progress.
01:43arrdembitemyapp: wat? no. setting up log rotation and going to bed.
01:44bitemyapparrdem: fair nuff. Just turned on -Wall on my project and got blasted in the face.
01:45bitemyappI thought the types alone were good but this compiler is ridiculous. IT SEES ALL
01:48arrdembitemyapp: the malevolence engine sees all your flaws and it is not pleased
01:49kelseygiblargh i keep getting this streaming json error & i can't figure out why
01:49kelseygiEOFException java.io.EOFException: JSON error (end-of-file inside array)
01:49bitemyapparrdem: you have been measured and you have been found WANTING!
01:51danlamannaended up doing a zipmap on two mapping functions... 3 lines :)
02:08amalloydanlamanna: instead of (zipmap (map f xs) (map g xs)), you want (into {} (map (juxt f g) xs))
02:51derek_cwhy would repl complains "namespace not found" when the namespace is actually there? I'm doing (use 'some-namespace)
03:03Geeky_Vin Hi Everyone, I'm trying to call/create a model in my fuseki server from clojure program but donno how, can someone help me pls?
03:08kelseygiso i'm trying to use the twitter-api library for a streaming call (https://github.com/adamwynne/twitter-api)
03:08kelseygii ahve code very similar to the example there, but with some exception handling
03:08kelseygiand it seems to not be chunking on the right boundaries
03:09kelseygiany ideas about where to look to debug that?
03:37derek_cthis channel doesn't have many people answering newbie questions :(
03:42gunsderek_c: what's your question
03:44derek_cguns: i'm trying to (use my-namespace) in a repl but it says namespace not found. but I'm pretty sure it's there
03:45gunsderek_c: Does your file have dashes?
03:45derek_cin fact when I did it earlier, it works and it's complaining the said namespace using some unresolved symbols
03:45derek_cguns: no
03:45gunsderek_c: that sounds like a compiler error; you probably need to fix your ns
03:46derek_cguns: huh?
03:46gunsderek_c: I'll be glad to help if you post a paste
03:46gunsrefheap.com
03:47derek_cguns: I wonder if it's caused by the same problem that caused this issue: https://github.com/marick/Midje/issues/215
03:48gunsderek_c: I'm sure the problem is hidden in plain sight. it will be easier to look at some code
03:48derek_cguns: thanks: https://www.refheap.com/81463
03:49derek_cso I'm doing (use 'twopc.coordinator)
03:49gunsderek_c: and what's the exact compiler error?
03:50derek_cCompilerException java.lang.Exception: namespace 'twopc.coordinator' not found, compiling:(/tmp/form-init4988673516715825549.clj:1:1)
03:51gunsderek_c: This is how I usually debug this kind of error: comment out the body of the ns, then try to re-require
03:52gunsthen uncomment a hunk/def at a time till you find the error
03:52gunsA manual scan over your code doesn't reveal anything obvious, but something is wrong
03:52Frozenlockderek_c: "this channel doesn't have many people answering newbie questions :(" Dude, it's like 4 am
03:53gunsFrozenlock: he might be russian for instance
03:53FrozenlockAnd #clojure is especially calm on the weekends.
03:53derek_clol I'm in the U.S. yeah didn't realize it's this late already
03:54derek_cwhy do hackers have to sleep
03:54Frozenlockguns: Sure, doesn't change the fact that at these hours freenode channels somewhat less active.
03:54Frozenlock*are
03:54gunsit's true. #clojure is very US centric
03:54guns#archlinux never stops talking for instance
03:55FrozenlockI like to think it's Canada centric. :-p
03:55derek_cguns: it turns out I just needed to add :reload
03:56gunsderek_c: you might want to look into tools.namespace if you'd like more control over namespaces
03:58derek_chow do you use require and :refer in a repl?
03:58guns(require '[my.ns :refer [α β]])
03:59derek_cah, I was placing the ' inside the brackets
03:59derek_cguns: thanks man
03:59gunsnp
04:02derek_care you guys actually using Clojure in production, or just as a hobby? just curious
04:06gunsproduction; but nothing big yet. Writing an IMAP client ATM
04:08derek_cguns: oh. what kind of company are you working at?
04:08derek_cis there a way to *clear* everything that has been imported in a repl?
04:08gunsderek_c: I'm doing contract work; I tried starting a company in the past year, but it didn't turn out well
04:09gunsthe Clojure part was great though
04:09gunsderek_c: tools.namespace can do that
04:09gunsbut you can always (remove-ns 'ns-sym)
04:10gunsand individually (ns-unmap *ns* 'var-sym)
04:10FrozenlockI usually just restart my repl. Just to be sure.
04:10derek_cguns: kk. thanks!
04:10gunsFrozenlock: I hate restarting the damn repl. it really magnifies the one thing Clojure sucks at
04:12gunsI hope this "Lean runtime" initiative bears fruit. I love Daniel Gomez
04:12gunshear that deepbluelambda? You are awesp,e
04:53derek_cwhat's the idiomatic way to write a function that takes an arbitrary number of arguments but simply returns a value? I came up with (fn [& _] addr)
04:53derek_cwhere addr is the thing I want to return
04:54Frozenlock,(apply (constantly "hello") [1 2 3])
04:54clojurebot"hello"
04:55FrozenlockNot sure if it's the idiomatic way...
04:55Frozenlock,(doc constantly)
04:55clojurebot"([x]); Returns a function that takes any number of arguments and returns x."
04:55FrozenlockBut it does seem to be exactly what you need :-)
04:56Frozenlockeh, I didn't even need apply for that
04:56Frozenlock,((constantly "hello") [1 2 3])
04:56clojurebot"hello"
04:58Frozenlockderek_c: ah! You reimplemented `constantly'
04:58Frozenlock,(source constantly)
04:58clojurebotSource not found\n
04:58Frozenlock-_-
04:59derek_cFrozenlock: ah, thanks!
04:59Frozenlockderek_c: https://www.refheap.com/81532
06:12rurumatehas anyone accessed the distributed cache in a cascalog job?
06:13rurumatethere should be a way.. or is there another standard way to access shared "static" data
06:35GlenjaminHi guys, is there a way to write clojure so it goes from high-level functions to low-level functions top-to-bottom?
06:36Glenjaminwould it be considered bad style to (declare) everything at the top, then do this?
06:38ivanGlenjamin: I guess almost everyone expects the opposite
06:38ivansome people mentioned this uniformity as an advantage in mailing list posts about this
06:39Glenjaminwhen i'm not doing clojure, i generally expect the reader to be able to gain more detail by reading further down the file
06:39Glenjaminbut without hiding things in namespaces, i seem to end up with all the detail at the top hiding the "public" api at the bottom
06:40FrozenlockGlenjamin: You'd probably need to use 'declare' everywhere... that'd be nasty
06:40Glenjamini could wrap my whole ns in a (reverse) macro :D
06:42Glenjamini guess i'll just have to get used to it
06:44Frozenlockwtfffff
06:44FrozenlockI think there's a memory leak with my brepl
06:44Glenjaminhere's a good example ";; top-level API for actual SQL operations" -> line 782
06:45FrozenlockMy CPUs are working and I have near 6GB of ram that shouldn't be used o_O
06:46Frozenlock'killall java' just freed 7GB of ram. o_O
07:25ashnurhi. is running `clojure helloworld.clj` with just (println "hello world") in it supposed to take 5-10 seconds to compile and run?
07:27ashnurbecause although i have a fairly slow machine, this still seems very slow for me.
07:28Frozenlockashnur: yes
07:28ashnur:(
07:29ashnurhow do people deal with this?
07:29beamsothey don't kill the JVM but code in a repl
07:30ashnuri like having files to run them
07:30beamsoyou can reload the files and recompile them at runtime
07:30Frozenlockashnur: You won't once you try a REPL ;-)
07:31ashnurFrozenlock: i use repl every day, all day, for javascript
07:31ashnuris there any reason why using the clojure repl would give me a different experience(other than clojure being a superior language of course)
07:31ashnurnot trying to insult anyone :-S
07:32ashnurbeamso: so there is a way to reload/compile files from within the repl?
07:34beamso(use 'your.namespace :reload-all)
07:34Frozenlockashnur: if you are working in emacs, C-c C-k will load the current buffer into the repl
07:34ashnurusing vim :(
07:35ashnurbeamso: ok, will read up on that, thanks
07:35beamsohttps://github.com/guns/vim-clojure-static/wiki/Clojure-REPL-Plugins
07:37ashnurthank you
07:38beamsonot a problem. i think fireplace.vim is what most people use.
07:39ashnuri have it installed :)
07:40ashnurbut the fact is, that i only ever used vim as an editor, no fancy features
07:40Glenjaminhttps://github.com/clojure/tools.namespace#reloading-code-usage can be used to reload things
07:40ashnurbecause it was usually less convenient, and slower
07:52Glenjaminanyone know if there's a technical reason transients aren't sequences?
07:52Glenjamin,(into [] (map identity (transient [1 2 3])))
07:52clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.PersistentVector$TransientVector>
07:59TEttingerGlenjamin: transients are really weird, is what I have to say.
07:59TEttingerthey are mutable, kinda, so they can't really be treated like seqs
08:17ambrosebsGlenjamin: my interpretation is transients should *only* be used to construct a new sequence, and shouldn't be used
08:17ambrosebsthere are lots of seqable things that are mutable, so no technical reason I can think of
08:17ambrosebsdon't have much experience with transients tho
08:38yotsovhow come that redefining static vars makes their new value visible to all threads? afaik the jvm is doing per-thread caching... Are static vars implemented via "volatile" or some other such mechanism to specifically make sure threads do not keep cached copies of them? If such is the case, doesn't that come at a quite big cost?
08:39bob2static var?
08:39yotsovI mean a default var, one that is not ^:dynamic
08:40bob2blithely rebinding them is not a common thing to do
08:40bob2normally you'd use an atom or a agent or a ...
08:40yotsovsure
08:40bob2but I do not know if they are volatile or not (but have never needed to care)
08:41yotsovI actually do not need to care either, it is just that suddenly this struck me as strange
08:41yotsovalthough since indeed they are not expected to change, having them as volatile should not have a cost, you are right
09:02AWizzArdIn Om these both work, which is preferrable? 1. (:my-key (om/get-state owner)) 2. (om/get-state owner :my-key)
09:12owl-v-what's clojure on llvm?
09:13TEttingerowl-v-: hm? I've seen clojurec
09:14TEttingerhttps://github.com/schani/clojurec
09:27owl-v-is clojurec for c or for objective-c ?
09:37TEttingerowl-v-, both I think, I think it uses LLVM to communicate with C
09:38TEttingerif it runs on iOS it likely uses clang which means C and Obj-C and LLVM
09:38owl-v-so, this works only on osx?
09:41TEttingerowl-v-, no, there's clang for windows, mac and linux now
09:41TEttingerclang was funded by Apple to replace GCC on macs, but it has more platforms that it runs on than just macs
10:13Morgawrlet's say I wanted to have a map that mapped keys to methods in a java class, how do I pass a method as a higher order function? Do I need to use lambdas wrapping?
10:13Morgawrwhat I want is something like
10:13Morgawr{ :keyword MyJavaClass/myMethod }
10:13Morgawrso I could do something like ((:keyword map) class-instance parameters)
10:13Morgawris that possible?
10:16GlenjaminMorgawr: i think you want (.)
10:18MorgawrGlenjamin: how do I get a behavior like ((:keyword map) class-instance parameters) with .?
10:18Morgawrusually it's (. instance methodname parameters)
10:18Morgawrbut methodname is defined by a call to a map
10:19Morgawr(. instance (:keyword map) parameters)
10:19Morgawrif I try to return something like 'myMethodName it doesn't work because "Malformed member expression"
10:19Glenjaminhrm
10:20Glenjaminyeah, i assumed that would work
10:22Glenjamini feel like this should work:
10:22Glenjamin,(. (Runtime/getRuntime) (symbol "totalMemory"))
10:22clojurebot#<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>
10:22Glenjaminmeh
10:23MorgawrI could do something like
10:23Glenjaminperhaps with eval
10:23Glenjaminor a macro
10:23Morgawr#(.methodName %1 %2)
10:23MorgawrI mean, I know that works
10:24MorgawrI was hoping for a more elegant solution ,but I guess this'll do
10:24gfredericksMorgawr: yes you need to wrap methods in functions if you want to pass them around
10:24gfredericksmemfn is a helper for that, but not very useful
10:24Morgawroh, never heard of memfn
10:25gfredericks,((memfn toString) 42)
10:25clojurebot"42"
10:25Glenjamin(eval (list '. (Runtime/getRuntime) (symbol "totalMemory")))
10:26gfredericksMorgawr: your map from keywords to methods is fixed at compile-time?
10:26MorgawrGlenjamin: that's not very elegant, it's better to wrap it in a lambda
10:26Glenjamin"Use when you want to treat a Java method as a first-class fn. "
10:26Morgawrgfredericks: yes
10:26gfredericksMorgawr: yeah you could do it with minimal repetition using a macro
10:26gfredericksMorgawr: do you want the wrapper functions to take varargs or a single list of arguments?
10:27GlenjaminMorgawr: you'd only need a map of keyword -> symbol and eval in one place, but memfn is clearly better than lambda/eval
10:27Morgawrgfredericks: the methods just take one single parameter
10:28Morgawr(plus the instance ofc)
10:28gfredericksMorgawr: and they're all methods on the same class?
10:28Morgawryes
10:28Morgawrbasically, I'm just wrapping a library from Java that takes a "Settings" class and calls some setWhatever on it
10:28Morgawrand I want to pass a dictioanry of keywords and value and repeatedly call ((:keyword mapping) settings-instance value)
10:29gfredericksroger
10:29TEttingermemfn ?
10:29TEttinger,(doc memfn)
10:29clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls."
10:29TEttingeroh I'm too late
10:30MorgawrI'm trying to understand how this memfn works...
10:30TEttingerhey Morgawr, I noticed 4 new issues popped up on Cloister... glad you're working on it
10:30gfredericks,(defmacro memfns [& key-syms] (into {} (for [[key sym] (partition 2 key-syms)] [key `(memfn ~sym)])))
10:30clojurebot#'sandbox/memfns
10:30owl-v-lol clochure~* http://clochure.org/
10:30MorgawrTEttinger: yeah, I'm slowly trying to implement the physics engine around it (this is related :P)
10:31owl-v-replacing () with []
10:31Morgawrowl-v-: haha
10:31gfredericks,(def fns (memfns :foo toString))
10:31clojurebot#'sandbox/fns
10:31gfredericks,fns
10:31clojurebot{:foo #<sandbox$fn__141 sandbox$fn__141@e8a53f>}
10:31gfredericks,((:foo fns) 42)
10:31clojurebot"42"
10:31gfredericksMorgawr: ^ there you go
10:31Morgawrgfredericks: neat, thanks
10:33gfrederickssince this is a settings object it's probably not an issue, but for low-level code those memfns will be slow because reflection
10:33Morgawrgfredericks: yeah, thnks
10:34Morgawrowl-v-: what's the purpose of clochure, lol
10:36TEttingermade April 1
10:43Glenjaminif i have a transient map of maps, is there a nice way to make everything persistent?
10:43Glenjamincurrently doing (fmap persistent! (persistent! collection))
10:43sdegutisLooks good to me.
10:45Glenjamini suspect i'm overthinking, but it feels slightly silly to make the outer persistent, then have fmap use into to create a new outer collection via a transient
10:51felherHey folks. Can I overload contains? (maybe via defmethod) for my own types? Or would that be a bad idea anyways?
10:55gfredericksI think that's ILookup
10:55gfrederickswhich is a java interface
10:57gfredericksno it's not ILookup
10:57gfredericksit's clojure.lang.Associative
10:57gfredericks,(def my-thing (reify clojure.lang.Associative (containsKey [_ k] (even? k))))
10:57clojurebot#'sandbox/my-thing
10:57gfredericks,(contains? my-thing 37)
10:57clojurebotfalse
10:57gfredericks,(contains? my-thing 38)
10:57clojurebottrue
10:57Glenjaminhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L705
10:58felherAwesome. Thanks :)
11:15jjl`i'm pretty sure i'm being an idiot, but i can't seem to make 'lein deps' find some dependencies. i'm using lein deploy file://$HOME/.m2/repository group/artifact version path.jar to deploy, have added a "local" repo in project.clj
11:23staskjjl`: is your missing dependency a snapshot? if yes, you will probably need to do something like "lein -U deps"
11:33jjl`stask: it is indeed a SNAPSHOT
11:34jjl`excellent, -U worked. thanks.
12:13Rotwanghi
12:13danlamannaamalloy_: not sure if juxt would work, since its a vector of strings like ["foo bar" "baz "qux"] and i want it to be a map such as {"bar" "foo", "qux" "baz"}
12:14Rotwangwhy does the clojure.java.shell causes ~1 minute exit?
12:16danlamannaso i map on (second (split ..)) and (first (split ..))
12:19jjl`how is performance using (seq "string")? is there a large penalty?
12:21AWizzArdjjl`: no large penalty
12:24jjl`AWizzArd: excellent. thanks.
12:27arrdemuntil it chokes your app, no penalty is large :P
12:27jjl`well, there's a certain degree of that
12:32grimmulfrSo I'm really new to Clojure (mediocre with any Lisp really, but learned enough to set up my Emacs - editor of choice - and StumpWm when I was still using that). What would be some of the best resources I should go through at this point? For now I went trough the "Intro to Clojure" videos.
12:33grimmulfrI will eventually go into web developing with it if I find that it could replace or add to what I'm using now. I do a lot of Javascript anyway, so I though why not try Clojure/ClojureScript too I guess.
12:33AimHereFor a bunch of problems to test your skillz, there's 4clojure. The clojure cheatsheet on the main website is what I use to find out which function does what
12:34arrdemgrimmulfr: there are some good books on Clojure, but what really did it for me was hanging around here asking questions.
12:34grimmulfrHow is the community? :D
12:34AimHereAlso, if you're not already using leiningen, go use it.
12:34arrdemgrimmulfr: amazingly helpful.
12:34jjl`i suspect 4clojure and a link to the cheatsheet would probably do what you want the best
12:34grimmulfrIndeed, I have everything set up for now. Running lein 2 + emacs + autocomplete + eldoc on Ubuntu
12:35jjl`oh and if you're doing frontendy stuff, you should definitely play with Om
12:35grimmulfrProbably the same at work, as I have a working virtual machine for it
12:35Guest86190Anyone know how to convert ["email@email.com" "other@email.com"] into [["email@email.com"] ["other@email.com"]]
12:35Guest86190(please)
12:35grimmulfrWell, frontend and backend. In my line of work I do facebook apps most of the time
12:35grimmulfrI;m a flash developer but I do javascript too where it's needed
12:35AimHere,(map vector ["string1" "string2"])
12:35clojurebot(["string1"] ["string2"])
12:35AimHereOkay, mapv instead
12:35AimHere,(mapv vector ["string1" "string2"])
12:35clojurebot[["string1"] ["string2"]]
12:35Guest86190Thanks AimHere :-)
12:36Guest86190That's Awesome!
12:36jjl`grimmulfr: clojure is a bit of a departure from actionscript. good luck :)
12:36arrdemgrimmulfr: got an .emacs snippet for auto enabling ac-mode and ac-nrepl when in clojure-mode?
12:37jjl`arrdem: (add-hook 'clojure-mode-hook (lambda () (ac-mode) (ac-nrepl-mode))) should do it
12:37grimmulfrWell, I took coding as a hobby a long time ago, I went through most if not all big languages, one extra wouldn't hurt heh.
12:38grimmulfrjjl`: Already set those up :)
12:38grimmulfrand using moe-theme which is simply godly (well structured code + colored parantheses looks really nice)
12:38jjl`you have rainbow-parens-mode ?
12:38grimmulfryes
12:39jjl`editing lisp without that is hell
12:39grimmulfrIt helps a lot. Weirdly enough, I learned about it while setting up my Clojure environment. I had no idea that exists
12:40jjl`unsurprising that lots of people are recommending it
12:40arrdemthere's also a lot of love for paredit around here... can't say that I use it yet.
12:40grimmulfrI enabled that one. Didn't like it much
12:41jjl`https://github.com/jjl/elisp/blob/master/site/jjl-font.el here's how you do fallback over a bunch of fonts
12:41grimmulfrI guess that's what happens when you try something different but heck, I'm used to my way. I'm not really lazy, I can put my own paren on there
12:41grimmulfrI use EnvyCodeR for years
12:41grimmulfrI have yet to find a better programming font
12:42grimmulfr(for me, obviouslly)
12:42jjl`i really wish paredit would work for me. i already visualise the code as an AST, but something about it just irks me
12:42Glenjamingrimmulfr: i'm a big fan of http://aphyr.com/tags/Clojure-from-the-ground-up as an intro series
12:42grimmulfrscratch an l from there :)
12:42arrdemyay got automagical autocomplete working!
12:42grimmulfrGlenjamin: thanks, will give those a go
12:42grimmulfrarrdem: what editor?
12:42Glenjamini'd love to use paredit, but i can't decide what keys to bind it to in lighttable
12:43jjl`arrdem: which method? there are about 4
12:43arrdemgrimmulfr: emacs
12:43arrdemjjl`: I already had what you described in place, but I had my add-hooks in an eval-after-load
12:43grimmulfrI feel like mine is set up all wrong, I should go back to editing it. I've had it set up this way for 1-2 years.
12:43arrdemjjl`: so it wasn't working :P
12:44jjl`oh. i'm using ac-cider-nrepl-compliment (which seems less popular)
12:44arrdemhttps://www.refheap.com/81685
12:44jjl`er ac-nrepl-compliment
12:44grimmulfrac-source-words-in-buffer, ac-source-words-in-same-mode-buffers and ac-source-words-in-all-buffer help too
12:44grimmulfrI love it when I do php with this, but it's kind of overkill
12:51grimmulfrShould remember to not kill emacs while rcirc is running :)
12:54grimmulfrIs there a differencet between nrepl.el and cider? It seems that my setup only uses nrepl (it's what I found while setting stuff uo and it works), so what am I missing by not having cider?
12:54jjl`surely you only kill emacs when it hangs anyway?
12:55arrdemcider is the maintained version of nrepl.el
12:55grimmulfrUsually yes, but now I killed it to refresh all my init.el (I know I shouldn't as I can eval on the fly, but it's a bit faster for me)
12:55grimmulfrso I should remove nrepl and go cider?
12:56grimmulfrI'm guessing yes
12:56arrdemdoing so will likely break your config..
12:56grimmulfrYeah, it's what I'm afraid of
12:56arrdemI don't see a strong reason for doing so unless you have a few hours today to debug it.
12:56jjl`that. especially if you if you use a lot of nrepl plugins and such
12:56grimmulfrI don;t have much of a config for nrepl for now though.
12:56jjl`(although if you want to use ac-nrepl-compliment, i've patched it)
12:58grimmulfrAll I want is an environment to run code in. Open bla.clj, C-c C-k to "compile", C-c M-n to switch to the ns, and then run my DEFNs
12:58grimmulfrAuto complete in the REPL is a nice bonus though
12:58arrdemgrimmulfr: you should be able to take the 90-clojure.el I linked above and run...
12:58arrdemgrimmulfr: it does all that and not much more for cider
13:00grimmulfrAll I had set up for nrepl was autocomplete (which should be fixed by you earlier snippet) and eldoc (not that hard to redo for cider I assume)
13:03grimmulfrhehe, cider switches the ns automagically
13:03grimmulfrThat's one plus :)
13:04arrdemthere's also a nice chord for jumping between your test namespace and your code namespace...
13:04jjl`arrdem: oh that's a handy one
13:04grimmulfrI'm sure that'll come in handly, for now it's just one ns that I learn the language in :D
13:05grimmulfrbut for now*
13:10grimmulfrYeah, cider autocomplete doesn't work. Can't find nREPL middleware providing op autocomplete. Please, install cider-nrepl and restart CIDER. Might just do that
13:11arrdemgrimmulfr: you need ac-nrepl still
13:12grimmulfrWell I have (require 'ac-nrepl) on there
13:12grimmulfrthen I set up the hooks for cider-repl-mode-hook and cider-mode-hook
13:12grimmulfrand I add cider-mode to ac-modes
13:12arrdem(add-hook 'clojure-mode-hook (lambda () (auto-complete-mode) (ac-nrepl-setup)))
13:12arrdem
13:15grimmulfrStill no go :(
13:15grimmulfrWith the regular nrepl I could tab complete my DEFNs, now I get that error above
13:19grimmulfrfixed it
13:20Guest86190hmmm how would I create a vector with one node from a string..?
13:21ToxicFrogAs in, turn the string into a vector with a single element, that element being the string?
13:21Guest86190'cos (vec "I am a string") gives me [\I \space \a \m \space \a \space \s \t \r \i \n \g]
13:22ToxicFrog,(let [the-str "asdf"] [asdf])
13:22Guest86190ToxicFrog exactly
13:22clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: asdf in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:22ToxicFrog,(let [the-str "asdf"] [the-str])
13:22clojurebot["asdf"]
13:22ToxicFrogJust wrap it in []
13:22Guest86190Ah, I see, ok - thanks
13:24ToxicFrog(vec) is for converting sequables to vectors with the same elements; (vec str) treats str as a seq of chars and vectorizes that
13:26Guest86190*nods* That makes a lot of sense - thanks very much
13:26Guest86190:-)
13:28kelseygimorrrrnning
13:28kelseygii got streaming problems
13:28kelseygiwith http.async.client
13:28grimmulfrSo do you guys/(gals maybe?!) generally use Clojure for? Just trying to test the market :)
13:29kelseygiare the chunk boundaries determined by some kinda header?
13:30jjl`grimmulfr: let me guess, you didn't have the clojure side of it?
13:32grimmulfrSomething like that :D
13:41Glenjaminif i'm running something at the repl and i don't want to see the return value, is there a better option than (do form nil) ?
13:44jjl`why do you not want to see the return value?
13:45grimmulfrIs there a way of getting the value of a certain vector key besiders "get"? Or is that the way it should be done? Let's say I have my [1 2 3] x vector. I want to get the value at 2. Any other way besides using (get x 1) ?
13:46jeremyheilergrimmulfr: nth
13:46grimmulfrbasically looking for the equivalent of x[1]
13:46grimmulfroh, nice :D
13:46grimmulfrThank you
13:46jeremyheilernp
13:46kelseygianyone have any ideas/other places to look for my chunk problem?
13:46kelseygii do like typing "chunk" over and over
13:46kelseygiCHUNK
13:53kelseygi…chunk?
14:05pdurbinsloth love chunk
14:09seangrovednolen_: Is there a hook in Om before you start re-rendering from root to let me run some function (layout function in this case) to pre-compute properties that around going to be needed for all of the components?
14:10seangroveare going to be needed*
14:10dnolen_seangrove: not really, but you can do this in the root component.
14:11dnolen_IWillUpdate
14:12seangrovednolen_: Makes sense, we have an explicit root component right now, so we could do that. I'd like to just pass it down to children (ideally in om/get-shared, probably) as a value and not a reference - any way to do that from IWillUpdate?
14:20kelseygido ppl use anything besides lighttable or a text editor, ide wise?
14:20kelseygikinda done with light table i think
14:26kelseygidamn i can't even get an editor war going?
14:27jeremyheilerkelseygi: intellij + cursive is a good combo
14:32katratxokelseygi: ccw http://doc.ccw-ide.org/
14:33ambrosebskelseygi: try cursive
14:35kelseygithere we go!
14:37grimmulfrEmacs all the way. Funny thing, I started using it a long time ago, but not for Lisp hehe
14:37jjl`what do you use instead of apply with java interop method calls?
14:37dnolen_seangrove: hmm, no obvious simple way to do that besides passing a ref down shared that I can see.
14:38seangrovednolen_: No worries, that'll work for the time being
14:40jeremyheilerjjl`: wrap the method with a fn
14:40jeremyheiler&(apply #(.length %) ["foo"])
14:40lazybot⇒ 3
14:42jjl`but i can't use variable arity with that?
14:43jeremyheileryes you can, %&
14:44jeremyheilerthough, methods dont really have variable arity
14:45jeremyheilerso im not sure what you mean
14:51jjl`no, but there are a few overloads, and really i'd rather not have to hardcode them all :)
14:54jeremyheilergotcha. i don't think there's any other way
14:56jjl`cool. thanks. i didn't realise %& existed
15:04yedidid bitemyapp leave the clj community?
15:06whodidthishow do you write (fn [a] [a]) in #() style
15:06dnolen_whodidthis: #(do [%]) or #(vector %)
15:07maxthour1ieIs there any tool that can remove unused parts to shrink the size of an uberjar?
15:08whodidthisoh right them functions, was wondering if theres some super secret syntax instead
15:09ucbgfredericks: apologies for the late reply. The problem is that having a multimethod that dispatches on type A, and having type B use this multimethod, when both A and B are on the same namespace simply doesn't work.
15:09ucbgfredericks: so, to make it more concrete. List/eval eventually uses the multimethod apply, which dispatches on the first item of the List. When this item is an Atom, then you're good to go.
15:10ucbgfredericks: the issue is that both Atom and List resided inside faust.types.
15:10ucbgfredericks: if I put the defmethod in faust.types, but the defmulti in faust.eval, that works just fine.
15:10ucb(but it's ugh)
15:10ucbgfredericks: in sum: keeping Atom and Lisp in separate namespaces is necessary unfortunately.
15:14grimmulfrhttp://pastie.org/9117829
15:14grimmulfrAm I doing this right? :)
15:17ucbgrimmulfr: what are you trying to do?
15:18grimmulfrJust learning the language. It does work, just wondering if that's the correct way of iterating through "arrays" like that
15:18grimmulfrJust took an everyday example from what I work with and tried to translate to clojure
15:19ucbgrimmulfr: if it works, then fine. Keep in mind that you're hiding the function keys though.
15:19grimmulfrOh, wait, there's an actual "keys" in clojure
15:20ucbyes
15:20ucb,(keys {:foo :bar})
15:20clojurebot(:foo)
15:20grimmulfrNice, thank you for that
15:20ucbno bother
15:21maxthour1iegrimmulfr: maybe some destructing:
15:21maxthour1ie,(doseq [{:keys [name job]} map2d] (println name "works as a" job))
15:21clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: map2d in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:21maxthour1ieah, rats, you get the idea
15:21grimmulfrIndeed, really helpful that
15:22maxthour1iegrimmulfr: for this small example, I think I would build a string first, then print it
15:23maxthour1iebut on the other hand, then you have to add newlines, which gets ugly too
15:23grimmulfrI'll play with it sme more. I'm just learning iteration onad though I apply them to maps as I use them quite often in other languages. They are basically the arrays of clojure, did I get this right?
15:24grimmulfrand thought*
15:25maxthour1iegrimmulfr: the part about putting maps in vectors is definetly how you do it
15:26maxthour1iedefinitely - such hard word
15:26grimmulfrTook me years to master
15:26grimmulfr(not a native english speaker, by far)
15:27maxthour1iewww.d-e-f-i-n-i-t-e-l-y.com helps, but the you have to know how to spell it :)
15:27grimmulfrIndeed, kinda like the Japanese kanjis hehe
15:28grimmulfrWhat does this mean? Look it up in the dictionary. But..oh...wait :))
15:28maxthour1ieindeed :)
16:37dazldhey, i'm playing with clojure (coming from a JS background)
16:37jjl`i have a class on which i can call getProperty(name) and getPropertyNames(). I'd like to construct a lazy map such that attempting to access the value for the map triggers it to be created (getting the value involves network traffic so can be slow). Is there any way of doing this without making all the values be lambdas that will compute the value upon request?
16:37dazldjust been doing something that seems like it should be fine, but getting consistent 'out of memory' errors
16:38jjl`dazld: please pastebin
16:38dazldsec
16:38sveri hi, looking at cljs-time the docs say that you can set the time-zone-offset, now my question is, how do I get the current time-zone-offset in cljs? Or, how do I parse a date in a different timezone than utc?
16:39dazldhttps://gist.github.com/dazld/11355058
16:40jjl`dazld: you do realise *why* that runs out of memory, right?
16:40dazldi am a total newb, assume i know nothing
16:40jjl`you're allocating rather a lot of integers there
16:41jjl`that's 1024^2
16:41dazldyep
16:41dazldi was thinking about image data
16:41dazldso, was wanting to buffer up an image, and its rgba values
16:41jjl`oh
16:42dazldlooking at top, it didnt seem to be using that much memory
16:42dazldthe java process
16:42dazldsveri: isnt the closure library available in cljs..?
16:45maxthour1iedazld: it runs fine here
16:45sveridazld: it is
16:46maxthour1iedazld: maybe play with your -Xmx setting?
16:46Frozenlockmaxthour1ie: Really? I had to kill it after it chugged away 4gb of ram
16:46jjl`yeah, it works here too.
16:46maxthour1ieFrozenlock: 4gb? gosh
16:46dazldsveri: http://docs.closure-library.googlecode.com/git/class_goog_i18n_TimeZone.html
16:46dazldit did not use 4gb here
16:47FrozenlockI'll retry to make sure I did exactly what's pasted
16:47dazldmaxthour1ie: is that a repl setting
16:47dazld?
16:47sveridazld: I see, thank you, I will try that
16:47maxthour1iedazld: it's a jvm option
16:47jjl`i think what you're seeing is call stack overflow. perhaps your version of clojure wasn't dealing with such sequences properly?
16:48dazldsounds reasonable
16:48maxthour1iejjl`: but it's says OOM heap space
16:48maxthour1iejjl`: not stack space
16:48Frozenlockah I think I found why
16:48dazldsveri: you could try momentjs.com too, really nice date/time library for js
16:48Frozenlock(last/first (vect n128)) works fine
16:49Frozenlock*vec
16:49Frozenlockbut (vec n128) tries to print everything
16:49jjl`yes. it prints successfully here
16:49grimmulfrWhy is 4clojure failing this test: (= [__] (list :a :b :c) (vec '(:a :b :c)) (vector :a :b :c)) . My input was: (:a :b :c)[:a :b :c][:a :b :c]
16:49dazldwithout casting it to a vec, it returns a lazy seq, right..?
16:49Frozenlockjjl`: o_O
16:49grimmulfrWhat am I getting wrong there?!
16:49sveridazld: I want to stay as close to cljs as possible and cljs-time is awesome already, but thanks anyway :-)
16:49dazldnp
16:50jjl`Frozenlock: 'lein repl' on osx. nothing special
16:50dazldclojure 1.5.1, lein 2.3.4
16:51maxthour1ie,(.maxMemory (Runtime/getRuntime))
16:51clojurebot#<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>
16:51jjl`clojure 1.6.0, lein 2.3.3
16:52dazld:I
16:52maxthour1iedazld: you can run (.maxMemory (Runtime/getRuntime)) to get the maximum amount of memory avail to the jvm
16:52dazldty tring
16:52dazldtrying even
16:52Frozenlockjjl`: Can you see the first values, or are they erased once they get out of the screen?
16:52maxthour1ie(but the bot didn't like it :)
16:52maxthour1ieI have like 1,8 GB avail to my jvm
16:52dazldthats in kb?
16:53jjl`Frozenlock: i can see lots of values, but i'm not scrolling all the way back up to see if i got them all
16:53FrozenlockOh boy, it printed. But Emacs is dying....
16:53dazldits a lot of numbers :p
16:53dazldbut thats normal for image data
16:53maxthour1iedazld: it's in bytes
16:53jjl`dazld: try editing your project.clj to specify clojure 1.6 and see if that fixed anyway
16:54dazldok.. but in general, clojure does not choke when making very large data structures?
16:54dazldthis is just some weirdness that i need to work out, right..?
16:54jjl`that isn't "very large"
16:54dazldwell, its complaining about memory
16:54jjl`and i've failed to make clojure choke doing silly things
16:54dazldbut yeah, as things go, its not that big
16:55dazlduncompressed images should be no problem...?
16:55dazldactually thats a dumb question, ignore me
16:55dazldkeep forgetting this is all on top of java
16:55jjl`i'm aware of financial institutions doing automated trading on clojure. that's a lot more data than you'll ever process
16:55dazldfor sure
16:56Frozenlocklein repl prints it fine on the shell, but it erases most of it
16:56FrozenlockEmacs was printing everything into a buffer
16:56dazldwhats the idiomatic way of creating and manipulating large data sets..?
16:56FrozenlockNot printing them in nrepl I suppose. :-p
16:57dazld;)
16:57jjl`er... worry less about idiom and more about solving your problem
16:57dazldkk
16:58Glenjaminjjl`: did you get an answer to your magic map thing?
16:58jjl`Glenjamin: i did not
16:58Glenjamini suspect you might be able to (deftype) and extend the Map protocol onto your type
16:58jjl`i mean the only other answer i can come up with involves creating a custom ISeq
17:01grimmulfrOh, nvm. I didn;t have to input the actual conversion, I had to input :a :b :c :0
17:03Glenjaminis there a variant of (type) that works on primitives?
17:03Glenjamin,(type (int 1))
17:03clojurebotjava.lang.Integer
17:08dazld1024^2 longs should take up 8MB..
17:08dazldthe runtime has ~130MB available
17:10jjl`did you try upgrading your clojure dependency in project.clj and see if that fixed things?
17:10dazldyep
17:10dazldsame
17:11jjl`do you get the same results trying it at java -jar clojure.jar ?
17:11jjl`(i can't imagine why lein would be the problem, but you never know)
17:11dazldim sorry, but really a newb with java
17:12dazldwhat does that command do?
17:12jjl`java is obviously java. -jar says "i'm specifying a jar file" and clojure.jar is a clojure release. you can get one here http://central.maven.org/maven2/org/clojure/clojure/1.6.0/clojure-1.6.0.jar
17:13jjl`it should spin you up a repl
17:13dazldawesome
17:13jplurIs there a way to print runtime data with atoms so I can inline it as code?
17:14jplurWithout atoms I can do something like (read-string (print-str [:data]))
17:14jjl`and what are you writing now?
17:15jplurlevels for a game jam
17:16jjl`i'm trying to understand what the problem is. could you show some code?
17:16dazldjjl`: that works fine, great tip
17:16dazldseems a lot faster too
17:16GlenjaminRuntime.gc do something different to a normal garbage collect?
17:16jjl`dazld: in that case. please file a bug against leiningen on github
17:17dazldsame amount of memory available
17:17dazldsure, will do
17:17jjl`https://github.com/technomancy/leiningen/issues
17:17dazldyou think its definitely a bug?
17:17jjl`i think that that should work. it appears to work without lein. whether it's lein's fault is another matter
17:18jjl`but at the very least, someone who knows better than me will be able to help better
17:18dazldill go write it up
17:18jjl`please note that it works in the plain clojure repl on your bug report
17:18dazldwill do
17:19jplurjjl`: http://www.pasteall.org/pic/show.php?id=70413
17:20jplurjjl`: I guess my question is can atoms be used for edn?
17:21jjl`jplur: atoms are not part of edn. you can make that work by using deref, try shoving and @ before (atom 6)
17:21jjl`an*
17:21jplurjjl`: understood, thanks!
17:21dazldhttps://github.com/technomancy/leiningen/issues/1516
17:22jjl`i assume you've simplified the code, but that doesn't need to be an atom at all from what i can see
17:22dazldcould include the free memory reports too
17:22jjl`jplur: oh, it won't work of course, read-str. sorry, half asleep. no, doesn't work in edn
17:23jjl`but by the time it hits print-str, it'll be realised because of the @
17:23jjl`so it'll just be 6
17:28jjl`dazld: thanks
17:29dazldnp, back to playing ;) thanks for help
17:29jjl`yw
18:17kelseygihi i need some help trying to handle something w/o using mutable state
18:18kelseygii will try not to use the word "chunk" too much
18:18kelseygii'm using the twitter-api library to process streaming tweets (https://github.com/adamwynne/twitter-api)
18:18kelseygiit takes a callback to handle each, uh….chunk of data
18:19kelseygiunfortunately some response bodies are spread across multiple chunks
18:19kelseygii can add a parameter to get the expected length & check across that
18:19kelseygito know whether a given bodypart has the whole response or not
18:19kelseygibut i'm not sure how to concatenate multiples ones for processing
18:19kelseygimultiple bodyparts
18:20kelseygishould i use an atom? that feels sucky
18:20TerranceWarriorj #scheme
18:21jjl`kelseygi: you could also model it with a promise
18:21kelseygiok, so have the callback i pass in return a promise?
18:22dbaschjjl`: that’s definitely not a leiningen bug, dazld was running with a tiny heap
18:22jjl`i don't know what mechanism you have for dealing with repeated data
18:22TerranceWarriorwhere can I download locally SICP?
18:23kelseygithe callback for handling each chunk of data only takes the response map and the byte string from that chunk :(
18:23jjl`dbasch: he didn't know what a heap was. how on earth did he end up running with it set low?
18:23dbaschjjl`: probably a bad default
18:23jjl`dbasch: i'm running lein on osx and it worked here
18:24jjl`i haven't changed heap size or anything
18:24TerranceWarriornevermind
18:24dbaschjjl`: different jvms have different default heap sizes, that’s the first thing you check
18:24kelseygii feel like i'm missing something that the library itself doesn't handle this?
18:25jjl`dbasch: *nod* i'm still fairly new to javaland
18:25dbaschjjl`: it’s not right to file a bug against leiningen without doing some research first in that case
18:26dbaschjjl`: most likely he was hitting the limits of the default heap size of his jvm while running inside the lein repl but not in a barebones repl
18:27dbaschjjl`: because there was less stuff loaded
18:27jjl`yes, that was my assumption when you said it was his default heap size
18:28dbaschjjl`: for one, lein uses readline and keeps a history of commands
18:28jjl`*nod*, quite sensibly
18:29jjl`i've been spending a lot of time with an orientdb console lately and they didn't appear to be aware readline exists, so it's horrible
18:32dbaschjjl`: also, java objects take more memory than you would imagine
18:32dbaschjjl`: and it’s possible that the repl already had earlier results in * variables taking up memory
18:36kelseygiif anyone was superconcerned for my fate
18:36kelseygii decided it was a bug in the library and filed an issue and moved on
18:36kelseygihaha
18:39kelseygi(WITH a repro case before anyone freaks out)
18:43Glenjaminshould i be using symbols or keywords in my (ns) form?
18:43Glenjamini've just noticed the docs show keywords, but my symbols seem to be working
18:45fifosineDoes anyone have any ideas of why my function might be returning a list within parenthesies when I'm expecting it to just be returning the list?
18:45Glenjaminfifosine: can you give some example code?
18:46fifosineGlenjamin: http://pastebin.com/3AtPHdhP
18:46fifosinehope it's readable
18:46fifosineThe first time the function is called, plan is the empty list
18:46fifosine[]
18:47Glenjamini suspect you want your (for) inside the (into)
18:48fifosineWhy?
18:48clojurebothttp://clojure.org/rationale
18:48fifosineIn english, I'm trying to say, "for each clear block, add these functions to the list"
18:48Glenjaminbecause otherwise you're returning the value of the (for)
18:48Glenjaminwhen you want to return the accumulated list
18:48fifosineohh
18:48fifosineok, so what will the expression inside the for be?
18:49Glenjamini think it's the same
18:49dbaschfifosine: you probably want to use filter, not for
18:49Glenjaminoh, good point ^
18:50fifosineactually, I think I want map
18:50fifosine:D
18:50fifosinecause I can grab the clear blocks easily
18:50fifosineI hate that for loops and while loops exist in clojure
18:51dbaschfifosine: for is not a loop
18:51fifosinewhat makes it distinct
18:51fifosinefrom a loop?
18:51dbaschfifosine: for one, it’s lazy
18:51Glenjaminit's more of a list comprehension
18:51dbaschfifosine: it’s list comprehension
18:52dbasch,(take 5 (for [x (range)] (* 2 x)))
18:52clojurebot(0 2 4 6 8)
18:53Glenjaminthink of it as an expression that declares how to build a list
18:56ToBeReplacedhow would i execute an arbitrary script (and wait for its completion) before repl or run in leiningen?
18:56ToBeReplacedi want to run a script which updates my resources
18:56ToBeReplacedso i guess before jar / uberjar as well
18:59akhudekToBeReplaced: I do it the old fasioned way, with a shell script.
19:00ToBeReplacedakhudek: right, so if i have a script add_resources.sh, how do i make "lein deps" run "add_resources.sh" first?
19:01akhudekToBeReplaced: There is actually a way to hook into lein’s build process, but I don’t know what it is. I just use a shell script that runs e.g. lein deps && add_resources.sh && lein run
19:01akhudekToBeReplaced: Maybe not fancy, but it works.
19:09ToBeReplacedakhudek: acknowledged... answer for me is to use the "lein-shell" plugin and add a value to :prep-tasks like ["shell" "add_resources.sh"]
19:10akhudekToBeReplaced: ooh interesting. I’ll have to checkout lein-shell sometime.
20:47brad1help
20:47brad1quit
21:02danlamannais there a way to get clojure working with gtk, to create a system tray icon of some type?
21:03beamsojava has http://docs.oracle.com/javase/7/docs/api/java/awt/TrayIcon.html
21:09TerranceWarriorcould the dox for using vim with clojure be any more retarded?
21:10TerranceWarriorlike all lisps before it, installing lispy things is still hard as shit and very poorly documented.
21:13dbaschTerranceWarrior: have you tried LightTable?
21:15TerranceWarriordbasch: looking into it
21:16TerranceWarriordbasch: do you need to put the .jar in $PATH?
21:16TerranceWarriorfor clojure that it?
21:16TerranceWarriorfor clojure that is.
21:16dbaschno
21:17TerranceWarriori want to run the repl from anywhere though.
21:17dbaschTerranceWarrior: if I remember correctly, you just create a clojure project and it does the right thing
21:17dbaschyou can always go to the project and run lein repl if you need to
21:17dbaschbut typically you use LightTable's
21:18TerranceWarriori get this when trying to run cpr from within vim:
21:18TerranceWarriorFileNotFoundException Could not locate user__init.class or user.clj on classpath
21:18TerranceWarrior: clojure.lang.RT.load (RT.java:443)
21:18TerranceWarriorok
21:21TerranceWarriorhow do I get the version number of the current repl?
21:21TerranceWarriorand where is the dox for such things?
21:22dbasch,(clojure-version)
21:22clojurebot"1.6.0"
21:22TerranceWarriorhm, my lighttabl is using 1.5.1 how do I upgrade it?
21:23dbaschTerranceWarrior: it’s not LightTable, it’s your project
21:23dbaschedit project.clj and change it
21:23TerranceWarriorthere is no way in hell it's going to know where my clojure.jar is.
21:24dbaschTerranceWarrior: you don’t need to
21:24TerranceWarriorof course you need to
21:24dbaschTerranceWarrior: are you new to clojure?
21:24TerranceWarrioryes
21:24TerranceWarriori have the clojure 1.6 .jar is a subdirect 6 foot below.
21:24dbaschTerranceWarrior: leiningen manages dependencies such as the clojure version for you
21:24dbaschTerranceWarrior: you’re doing it wrong
21:25TerranceWarrioryes, and lein has been pleasent enough to be using 1.5.1
21:25TerranceWarriordbasch: no, i'm not doing anything. something needs to be done.
21:25dbaschTerranceWarrior: when you create a project with “lein new” it generates a tree
21:25dbaschinside, there is a file named project.clj
21:25TerranceWarrioryes?
21:25clojurebotyes isn't is
21:25dbaschthat file contains your clojure version
21:25TerranceWarriorok
21:25TerranceWarriorand?
21:26dbaschif you want 1.6.0, just change the setting
21:26TerranceWarriordid already
21:26johnwalkerbe nice now
21:26TerranceWarriorthe operating system and lein have no idea where my clojure jar is located.
21:26dbaschTerranceWarrior: you don’t need a clojure jar that you downloaded independently
21:27TerranceWarriordbasch: oh?
21:27dbaschTerranceWarrior: lein doesn’t care, it just treats clojure as another dependency and downloads the right jar for each project
21:27TerranceWarriordbasch: did you just want me to use the default 1.5.1 instead?
21:27TerranceWarriorhm.
21:27TerranceWarriorit didn't appear to.
21:27dbaschTerranceWarrior: like I said, change the setting *for that project*
21:27TerranceWarriorit's been using 1.5.1
21:27dbaschexit lein repl, run it again
21:29TerranceWarriorson of a gun.
21:30TerranceWarriorok that worked
21:30TerranceWarriorbut lighttable is still in the past.
21:30TerranceWarriorthanks by the way.
21:30johnwalkerwhat do you mean by in the past?
21:31TerranceWarriorwhat I do mean by in the past is it's 1.5.1
21:31johnwalkerare you trying to build lighttable with 1.5.1?
21:31johnwalkersorry, 1.6.0?
21:32TerranceWarriornope just running it as a 64 linux bin.
21:32johnwalkerso you're saying that lighttable is ignoring project.clj and using 1.5.1 instead?
21:34TerranceWarriori opened project.clj and there is no magic to upgrade.
21:35johnwalkerwhat magic?
21:35TerranceWarrior1) start lightpath 2) load project.clj 3) wa lah a file is loaded and (clojure-repl) remains 1.5.1.
21:36TerranceWarriorI'm not that intuitive to guess the designers intentions.
21:39johnwalkerhold on, trying that out
21:43TerranceWarriorit's a file, it needs a configuration setting from within lightpath i'd imagine.
21:43johnwalkerwell, lighttable's connection just crashes for me so i dunno man. i just use emacs.
21:45TerranceWarriorjohnwalker: thanks anyway.
21:45TerranceWarriorany vim users in the house tonight?
21:45SegFaultAXTerranceWarrior: Voila*
21:46SegFaultAXAlso, yes, I'm a vim user.
21:46johnwalkersorry
21:46TerranceWarriorSegFaultAX: can you agree with me that http://clojure-doc.org/articles/tutorials/vim_fireplace.html is pretty crumby as far as documentation goes?
21:47SegFaultAXTerranceWarrior: Contributions are welcome.
21:50TerranceWarriorfunny how there is no ready documentation to upgraade lein itself on all new projects.
21:51dbaschTerranceWarrior: leiningen is really well documented. http://leiningen.org/
21:51johnwalkeryou mean $ lein upgrade?
21:52SegFaultAXTerranceWarrior: What's your specific issue with fireplace?
21:54TerranceWarriorSegFaultAX: scroll up (if you can) to see my 'cpr' attempt from within vim.
21:54TerranceWarriorotherwise i can repaste.
21:56SegFaultAXTerranceWarrior: Were you in a clojure project for that? Or were you just editing a file by itself?
21:56SegFaultAXOutside of a clojure project.
21:56TerranceWarriorwow, now my vim hangs if i load project.clj.
21:56TerranceWarriorbrilliant
21:57TerranceWarriorSegFaultAX: i believe i had a clojure file loaded, source.
21:57SegFaultAXTerranceWarrior: But were you in a clojure project?
21:57TerranceWarrioroh i don't know.
21:58SegFaultAXTerranceWarrior: I'm going to guess that you probably weren't. That's why you got the above error.
21:59TerranceWarriorhttp://pastie.org/9118490
22:00TerranceWarriorIt's pretty obvious vim needs to know about the clojure jar.
22:01TerranceWarriorI'm tempted to write documentation for all the poor losers after me.
22:02dreverriare you running a repl (lein repl)?
22:02SegFaultAXTerranceWarrior: First of all, there is no need to be so negative. Second of all, the error message is telling you exactly what you need to do.
22:02dreverrithe installation section discusses classpath.vim: https://github.com/tpope/vim-fireplace#installation
22:03SegFaultAXfireplace is trying to create a repl, but it can't determine the classpath without vim-classpath.
22:03TerranceWarriorthis is very suiting to me right now: https://www.youtube.com/watch?v=iNwC0sp-uA4
22:03SegFaultAXSo you can either install that plugin, or manually connect to nrepl.
22:03patrickodwhen using korma is there a neat way to use aliases to refer to related entities ?
22:03patrickodi.e. (belongs-to recipient-user {:fk recipient_user_id :entity user}) L
22:06TerranceWarriorwow, it says First, set up [cider-repl][].
22:06TerranceWarriorthat is telling me authors like, 'meh'. just do it.
22:07TerranceWarriorSegFaultAX: ok
22:09SegFaultAXTerranceWarrior: fireplace works best in the context of a project.
22:09TerranceWarriorSegFaultAX: ok appear to work now. (require command-line-args.core :reload) (clojure.test/run-tests)
22:09TerranceWarriorPthats what I get if I cpr.
22:10SegFaultAXCool.
22:11SegFaultAXcpR for reload-all.
22:12TerranceWarriorapparen't i can :Connect
22:12TerranceWarriorbut I get no astouding feedback from doing so.
22:12TerranceWarriorbut I get no astounding feedback from doing so.
22:13SegFaultAXTry doing `:Eval (+ 1 1)`
22:14TerranceWarriorah sweet.
22:14TerranceWarriorworks.
22:14TerranceWarriorthanks SegFaultAX.
22:15SegFaultAXTerranceWarrior: `:help fireplace`
22:16TerranceWarriorsweet. Eval (foo 1)
22:16TerranceWarriorE149: sorry no help for fireplace
22:17SegFaultAXTerranceWarrior: Did you install through pathogen?
22:17TerranceWarriorSegFaultAX: yes.
22:18SegFaultAX`call pathogen#helptags()`
22:18SegFaultAX`:help fireplace`
22:18SegFaultAXSorry, that was supposed to be :call
22:19TerranceWarriorwow, now it works.
22:19TerranceWarriori am expecting hal9000 to read my lips next. ha!
22:20TerranceWarriorjohnwalker: sorry, didn't see you.
22:21SegFaultAXTerranceWarrior: Add the call to pathogen#helptags to your vimrc after pathogen#infect
22:21TerranceWarriorSegFaultAX: that is clearly something that needs documentation flow.
22:23SegFaultAXTerranceWarrior: https://github.com/tpope/vim-pathogen#runtime-path-manipulation Last two paragraphs
22:23SegFaultAXYou need to learn to read documentation more closely. ;)
22:26TerranceWarriorcall pathogen#helpstags() is clearly not present. The documentation eludes to it but does not at all give you the proper syntax. so fail.
22:27SegFaultAXWell there is the :Helptags shorthand.
22:27SegFaultAXWhich he clearly talks about in that paragraph.
22:28TerranceWarriorSegFaultAX: Thats like saying context is not important but the word in it only is.
22:30SegFaultAXUh.
22:31TerranceWarriorwhat is this magical beast [cider-repl][]. is this some sort of new devilry?
22:32TerranceWarrior'..roam, if you want too... roam around the world.'
22:35danlamannabeamso: yeah that does seem to work. surprised there isn't a clojure lib wrapping it.
22:36beamsoi don't really hear of anyone doing new java desktop development :/
22:37TerranceWarriorSegFaultAX: well, aparently things are working. but the documentation needs improvement. some of it, is rather nervy and anxious because of the implied magicness of it.
22:37danlamannai just want to make a system tray icon to control virtualboxes, sick of that dumb window taking up space.
22:53TerranceWarriorcan someone parse this sentence for me? "Where possible, I favor enhancing built-ins over inventing a bunch of <Leader> maps."
22:56tuftdanlamanna: or use vagrant?
22:56danlamannatuft: i have non vagrant virtualboxes. just like knowing which are on/off at a given time.
22:57danlamannatuft: i actually have some abomination of a shell script that shows via conky which are running.
22:57tuftah cool
23:00TerranceWarriorAm I correct in saying a REPL won't recieve vim Evals?
23:08kelseygiwhat am i doing wrong here? http://pastebin.com/4XgHbcEp
23:08kelseygii get java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
23:08kelseygii can't figure out if i'm using "if" wrong, or equality, or the atom, or what
23:11beamsoshouldn't lines 3 and 5 start with do rather than just a bracket?
23:12TerranceWarriorkelseygi: does let need a lamba function?
23:12TerranceWarriorbecause it is an environmental function afaik.
23:12TerranceWarriorso wrap it in a function.
23:13beamsoi thought it was more that reset! returns the new value, so clojure is trying to execute (1 (println ...))
23:13technomancykelseygi: you need to wrap your branches of if in a do block
23:13dbaschbeamso is correct
23:13technomancy(if pred (do x y z) (do a b c))
23:14technomancyoh right
23:14technomancytoo slow
23:16dbaschtechnomancy: btw, someone here earlier filed an issue against leiningen because his jvm had a small default heap size (?)
23:17dbaschtechnomancy: he didn’t know how to increase the jvm heap so he was blowing the repl heap and blaming it on leiningen
23:21technomancydbasch: I think my fellow conspirators are fielding that one decently =)
23:26kelseygiah it's the return value of reset! that makes sense
23:26kelseygilol i was bemoaning ahving to use the atoms cause it's not functional and i neglected the return value there
23:26kelseygithanks beamso & co
23:32TerranceWarriorhow does one upgrade the version of closure for Lein without having to hack a .clj file?
23:33dbaschTerranceWarrior: what exactly do you mean?
23:34TerranceWarriordbasch: I would like 'lein new' or 'lein repl' to default to 1.6.0.
23:37JaoodTerranceWarrior: yeah, weird there isn't a release that defaults to 1.6 yet
23:37Jaooda lein release I mean
23:37JaoodTerranceWarrior: use the master branch from github
23:38TerranceWarriorJaood: ok
23:39TerranceWarriorJaood: isn't the zip master?
23:43FrozenlockWhat's the idiomatic way in compojure to get /:the-rest-of-the-path ?
23:45TerranceWarriorha! the git clone version of lein has BUGS.
23:46technomancysoftware with BUGS?!
23:46Frozenlockgasp
23:47dbaschFrozenlock: get the uri from the request and parse it
23:47technomancyinconcieveble
23:47Frozenlockdbasch: I think there's a simpler way. https://github.com/weavejester/clout
23:47Frozenlock"*"
23:47FrozenlockBut I still need to test it
23:48dbaschFrozenlock: it depends on what you want the rest of the path for
23:49dbaschFrozenlock: matching a route is not the same as getting the path
23:50TerranceWarriorwhatever you do, don't exit your repl session with a vim-fireplace hooked it it or else the vim session hangs terribly.
23:50TerranceWarriorbut this, this is all rather academic.
23:51TerranceWarrior;)
23:55TravisDDoes anyone know of a library (java or clojure) that has several different random number generators, and ways for sampling from a variety of distributions?
23:56beamsomaybe http://commons.apache.org/proper/commons-math/userguide/random.html ?
23:57TravisDbeamso: Cool, thanks. I'll look into it
23:57TravisDbeamso: Seems to be exactly what I am looking for. Thanks!
23:59beamsonot a problem. i haven't used it but there seemed to be more there than using java.util.Random.
23:59TravisDYeah, sounds like it uses java.util.Random by default, but you can swap in other generators if you want