#clojure logs

2012-07-04

00:00technomancythe lanterna google code page links to https://issues.sonatype.org/browse/OSSRH-3751, which has the snapshots repo
00:00technomancybut they really do need to make it more obvious
00:00technomancymaybe they will once they have a release and aren't working with snapshots?
00:00sjlwell I think they have their non-snapshots in Maven central
00:00sjlwhich I think would just magically work with lein, right?
00:01technomancyit's in :repositories by default, yeah
00:02technomancylein pprint :repositories # -> {"central" {:url "http://repo1.maven.org/maven2"} "clojars" {:url "https://clojars.org/repo/"}}
00:08michaelr`technomancy: pprint? a plugin?
00:08technomancymichaelr`: yeah, https://clojars.org/lein-pprint
00:08technomancygood for debugging
00:09michaelr`good to know
00:12michaelr`btw technomancy, is there some list/registry of all lein plugins?
00:12michaelr`could be usefull
00:12technomancythere certainly is
00:12technomancyhttps://github.com/technomancy/leiningen/wiki/Plugins
00:12michaelr`cool thanks
00:13technomancyno problem
00:13michaelr`wow, lots of plugins
00:13technomancyyeah, it's really grown =)
00:27zawzeyhmm, does anyone have much experience mixing library versions: http://groups.google.com/group/clojure/browse_thread/thread/abddc241243a01ea/500864190706078b
00:29zawzeyso can 2 libraries with different versions exist in the same project? (aside from using lein exclusion)
00:29technomancyzawzey: AFIAK there's no good way to do that cleanly, you have to manually construct isolated classloaders
00:29zawzeytechnomancy: Yes, any examples of that?
00:30technomancyno, sorry
00:30taliosdamn you hibernate - you'll make me go even more bald than I am at this rate :(
00:31zawzeytechnomancy: No problems, it's an long-standing topic, i suppose. http://groups.google.com/group/clojure/browse_thread/thread/182f171afc49473b/297393ed49f4dffe
00:31technomancyzawzey: it's almost always going to be better to just make it work with a single version; doing both is going to be a huge yak shave
00:33zawzeytechnomany: True that, it's just using external libraries (with conflicting dependencies) can become a problem, guess when the time comes, just have to fork off the original lib
00:33technomancyhopefully the one using the older version will accept patches
00:33zawzeytechnomancy: Or just have to fork off it, if it's no longer maintained
00:33amalloyyou could give polycosm a shot, but i'm not sure how production-ready it is
00:34technomancyoh right; I forgot about that
00:34zawzeyamalloy: thanks for the headsup
00:34amalloyi think polycosm needs you to plan your whole application around the split classloaders ahead of time, or nearly so
00:35technomancyyeah, there's no way to make this work seamlessly
00:44dnolenShambles_: still there?
00:44zawzeythanks guys, guess will need to be aware of this if we need to scale our project
00:50amalloydid you guys know, there's only one user in here whose name starts with Q? but we have six Xs! what is up with that?
00:51technomancyamalloy: it's an eXtreme channel, no surprise there
00:52amalloyx-clojure, for programmers too eXtreme to wait for an officially-blessed MIME-type?
00:53hiredmanhttp://vimeo.com/44968627 this is great, and I want it
00:54dnolenwell perhaps Shambles_ is gone, but porting animals.py to a vector of maps was pretty dead simple as I expected. no atoms or zippers - code looks pretty much the same - https://gist.github.com/3045400
00:54dnolenhiredman: yeah kovasb's prez was awesome.
00:55amalloysummary from anyone so folks know whether to dedicate half an hour to watching a the video?
00:55borkdudegitrepl: a repl in which the states are bound to commit ids… and always the possibility to go back, clone, etc, who wants to implement that? ;-)
00:56dnolenamalloy: it's worth it, thinking about evolving the REPL
00:57dnolenamalloy: one of most compelling reasons for data literals & CLJS IMO
00:57technomancyborkdude: I've wanted transactional require for a loooong time =)
00:57hiredmanI was just thinking about this because of all the "python notebook" headlines I've been seeing around
00:59dnolenamalloy: session is basically just scratching the surface of what we could do.
01:01hiredmanoh god, he has a checked in .DS_Store
01:03arohnerI've been wanting serializable *everything* for a long time. fns, infinite seqs, etc
01:04hiredman*shrug* just serialize the code that generates them
01:06borkdudeserializing infinite seqs to disk isn't a problem, as long as your disk is lazy too.
01:07borkdudesorry, I just woke up
01:07borkdudemuch too early, grrr!
01:08sjljust serialize them to MongoDB, they're probably get garbage collected before an fsync anyway.
01:14amalloyarohner: serializable-fn serializes any function whose lexical environment is serializable
01:15arohneramalloy: I know. but I think there's a lot of cool things that could be made if the whole environment could be serialized
01:16amalloyautomatic serialization of any old object is basically impossible, unless all your objects are cons cells
01:18arohnerthat's a little overstated
01:18arohnerstrings, ints, clojure data structures are all serializable. I don't see why anonymous fns, refs & atoms & agents can't be
01:19amalloylambdas can be, as i said with serializable-fn
01:19arohnerin a hacky, unsupported way
01:20arohnerI'm talking about fully supported
01:22amalloyrefs and friends are identities, not values; how will you write them? #clj/ref [id-number current-value]? then you have to somehow keep id-numbers around between calls to the serialization mechanism, or require that your entire program state be serializable from a single root. what do you do about the circular data introduced by refs?
01:22amalloyand that still doesn't cover things like mongodb session handles, or whatever - the whole environment isn't serializable if they aren't
01:23amalloyand what's hacky about using the built-in customizable-serialization hook?
01:24amalloythose problems are probably all soluble (maybe not the mongodb handles), but it's not easy
01:25arohnerthis is like arguing that C has "good enough" function pointers and OO features. serialization is a thing that isn't fully supported. Yes you can hack, but it unlocks a lot of power when those things just work
01:26amalloyso do what technomancy did. start a serializable-ref library, and use it until it's awesome enough to get into clojure.core
01:26technomancyamalloy: someone did that... alyssa kwan?
01:26technomancybut it was a fork of clojure
01:26amalloyyeah, those persistent refs or whatever she called them?
01:26technomancyand she posted about it and nobody paid any attention =\
01:27amalloytechnomancy: that doesn't sound like the clojure ML! surely someone showed up to tell her we don't want that?
01:27technomancymwahaha
01:27michaelr`what did you say? i wasn't paying any attention..
01:44cljs_newb_2302when calling javascript functions from clojurescript functions, how is the "this" variable set?
01:48borkdudenice video about Session
02:12wingyanyone here knows what the difference between :db/id and :db/ident is in datomic?
02:12wingyeg. {:db/id #db/id[:db.part/user -2]
02:13wingy :db/ident :person.gender/female}
02:13wingywhy id and ident at the same time .. since im using the latter as reference why do i need to specify the id
02:26john2xHello, i'm following the instructions here (https://github.com/quil/quil/wiki/Installing), and have Leiningen installed and `lein deps` is done. But when I try (use 'quil.core') in the repl, I get a FileNotFoundException.
02:27wingynvm i posted it in the datomic mailing list
02:28wingyand it seems that both are semantically identical, just that when something has a :db/ident you can refer it using the keyword instead of the id
03:12LoganLKevery time I run lein run/repl/deps the console gets filled with "could not find artifact org.clojure:clojure:pom:1.+ in *repo name* messages, then it will successfully execute the command (eg run the project). I'm running lein2 preview7 on windows
03:12LoganLKpic of errors http://i.imgur.com/JjuWU.png . any ideas?
03:15aduLoganLK: are you connected to the internet
03:15adu?
03:15LoganLKadu: yes
03:15aduhmm, i donno
03:15taliosIs that saying version 1.+?
03:16taliosor am I misreading it?
03:16LoganLKtalios: it says 1.+?
03:16LoganLKbut as you can see in the project I have specified the version. I have tried "1.3.0", but same thing happens
03:17aduLoganLK: "org.clojure:clojure:pom:1.+ in *repo name* messages"
03:17aduwhat is your project.clj?
03:17LoganLKadu: http://i.imgur.com/JjuWU.png
03:17taliosproject.clj was at the top of the image
03:18taliosodd - looks like its trying to find org.clojure:clojure:pom:1.+ for some weird reason.
03:18taliosI dont use lein so maybe I'm misreading the output tho
03:19adudoes that mean there's an object called 1, and it's trying to find it's "+" method?
03:19aduthat sounds like a much bigger problem misreported
03:22amalloyi'd guess an issue with one of your lein plugins? ask in #leiningen; it's lower-traffic so shouldn't get lost in the flood of #clojure before being noticed by someone who can help
03:22LoganLKamalloy: no lein plugins :( thanks
05:25ro_stmuhoo: i gave you a link to a clojurescript starter template. now i can't find it. do you have the link handy?
05:25ro_stscratch that, just found it
05:40wingyhow do i convert this line to one without read-string? @(d/transact conn (read-string "[{:db/id #db/id[:db.part/user -1000001], :item/name \"Item 1\"}]"))
05:40wingyIs there a way to do that even though it's using a reader literal?
05:56lewis1711TEttinger: you think THIS language is better than scheme?
05:56lewis1711really?
05:58TEttingerhi lewis1711. yes.
05:59clgvwingy: afaik yes. just write normal clojure and add the reader literal
06:00clgvlewis1711: what's THIS?
06:02lewis1711lol
06:02lewis1711clgv: clojure
06:02clgvjust wanted to know what language you are talking about ^^
07:16clojure-newcomerHi guys, I am trying to simplify the key names on my datomic entity so I can use them with Noir… currently getting 'Can't let qualified name' with keys like ':my entity/name', any ideas ? I thought of using rename-keys but get an AbstractMethodError as I am working with a 'datomic.query.EntityMap'
07:33ro_stargh. so i'm using midje to test my database layer fns. as part of the fns that write data, i timestamp stuff, so i know when created/when updated
07:33ro_sti'm mocking all the data out in my midje test, but i'm not sure how to write my checker to see that some test data that was written is coming back out correctly, because the data coming out has been timestamped
07:37ro_stgot it
07:38ro_stholy crap midje is cool
08:26ordnungswidrigdoes 1.3 use type hints on record fields?
08:28clgvordnungswidrig: only primitive type hints - 1.2 did so as well
08:29ordnungswidrigclgv: (defrecord Foo [^Integer foo]) macro-expands to a deftype* where no typehints are visible
08:30ordnungswidrig,(macroexpand-1 '(defrecord Foo [^Integer foo]))
08:30clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
08:30clgvordnungswidrig: type hints are metadata which is "eaten" by the reader. you have too look at the metadat of the symbol
08:31ordnungswidrigwhich symbol? Foo is a class, so no metadata is available
08:32clgvno Foo is a symbol in the expanded defrecord macro
08:32ordnungswidrigclgv: there's (deftype* Foo user.Foo [foo __meta __extmap] :implements ...)
08:32clgvif you want to know whether your type hint succeeded you can use a decompiler like JD-GUI
08:33ordnungswidrigclgv: so the compiler uses the type hints extracted by the reader?
08:33clgvordnungswidrig: yes. and Foo carries metadata which is not printed.
08:33ordnungswidrigclgv: How can I access this metadata, then?
08:33clgvwhy would you want to do that?
08:34ordnungswidrigI wondered if there is runtime access to the typehints
08:34ordnungswidrigSo I suppose this is only possible when doing AOT
08:34ro_st(meta thing)
08:34ro_st(:type (meta thing)) *shoots from the hip*
08:35ordnungswidrigro_st: *target missed*
08:35clgvno there is no Runtime access if you have the compiled defrecord
08:36clgvyou can access it in the expanded macro though
08:36ordnungswidrigclgv: no there is no type hint in the expanded macro
08:38clgvordnungswidrig: there is! try: (-> '(defrecord Foo [^int a b c]) macroexpand-1 (nth 2) (nth 3) first meta)
08:39clgvtook a bit to get the navigation in the expansion done ;)
08:39ordnungswidrigclgv: *doh*
08:40clgvordnungswidrig: type hints or metadata in general, will never appear in macroexpand.
08:41clgvyou could write a specialized print method to show them
08:41mystiiqI am using clj-ssh in my project, i've got this line: (:use [cljaws core helpers] [clj-ssh.ssh]) and it tells me that Could not locate clj_ssh/ssh__init.class or clj_ssh/ssh.clj on classpath:
08:41mystiiqwhat am I doing wrong
08:42mystiiqin my another project I only got (:use [clj-ssh.ssh]) and it works
08:43ordnungswidrigclgv: I missed that the __meta field actually contains the metadata
08:43ordnungswidrigclgv: or has it attached
08:44clgv ordnungswidrig: no, the __meta field will contain only metadata that was assigned to an instance of your Foo record
08:46clgvordnungswidrig: try that to see the typehint on the fields (binding [*print-dup* true] (-> '(defrecord Foo [^int a b c]) macroexpand-1 pr-str))
08:46clgv=> "(clojure.core/let [] (deftype* Foo user.Foo [^int a b c __meta __extmap] ..."
08:52wingyclgv: it doesn;t work
08:52wingytried this one: @(d/transact conn [{:db/id 17592186045796, :item/name \"Item 1\"})
08:52wingyi mean this one: @(d/transact conn [{:db/id 17592186045796, :item/name \"Galaxy Tab 3\"}])
08:53wingydamn .. let me make it better
08:53clgvbut read-string should not differ much from how a source file is read or the REPL reads
08:54clgvwingy: you should make the test minimal: skip the transaction code
08:55wingyhttps://gist.github.com/3047203
08:57wingybut i think the # read literal is used by read-string
08:57wingyit does some magic on it
08:57wingyoh it worked
08:58wingy@(d/transact conn [{:db/id 17592186045796, :item/name "Galaxy Tab 3"}])
08:58wingywithout the back slashes :)
08:58wingyclgv: thx for the test minimal hint :)
08:59ro_sthow's the clojure going, wingy
08:59ro_styou killin' it?
09:02clgvwingy: btw in your examples you only use namespace-prefixed-keywords, no reader literals
09:04wingyro_st: very fun. using it together with datomic
09:04wingyworld's best database
09:06wingyclgv: yeah i forgot the #
09:06wingy@(d/transact conn [{:db/id #db/id[:db.part/user -1000001], :item/name "Galaxy Tab 2"}]) ;; gave an error
09:07wingyill just use the read-string til i get more about how clojure works
09:07clgvthats probably because [:db.part/user -1000001] is wrong
09:08wingyit cant
09:08wingyits just a keyword and a nr
09:08wingynothing wrong syntatically
09:09wingywhat i get is a clojure error: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
09:09clgvand the function handling #db/id expects a vector of those two things?
09:09wingyoh yeah
09:09wingymust be it
09:10wingyreader literal was used to make it more convenient
09:10wingyill just use the read-string for now
09:11wingycant find my ways around clojure 100% yet
09:11clgvdid you read any of the books?
09:21wingyclgv: im still in Clojure Programming
09:21wingydidn't read all of it though since I realized i have to play with clojure a little to get familiar with the basics first before i jump into macros, records etc
09:22wingyhave to apply an iterative style even on learning .. that's the best method i think
09:25ro_stwingy, found the clojure koans yet?
09:27wingyro_st: what does koans mean?
09:28ro_sthttps://github.com/functional-koans/clojure-koans/
09:31clgvwhy not 4clojure.com ?
09:33wingywow didnt know about all these starter kits
09:33wingyill do the koan first
09:37ro_stwhy not both? :-)
09:37ro_stthere's labrepl too
09:37ro_stwhat's nice about clojure-koans is you do it in your editor of choice
09:37ro_stnice for getting comfy with emacs
09:37clgvwingy: 4clojure only helps a bit when you start with the Elementary problems. it's more to test your clojure skills^^
09:38clgvyou should do the more difficult problems of 4clojure in your own IDE as well ;)
09:41wingyso cool .. clojure-koans autodetects changes :)
09:43wingyalready learned my first lesson
09:43wingy(1 1 1) works :)
09:43clgv&(1 1 1)
09:43lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
09:44wingyis i mean (= 1 1 1) :)
09:44wingybtw .. (= 2 2/1 2) .. how come that 1/2 works .. is it syntatic sugar over prefix mode?
09:45Vinzentwingy, no, it's ratios. Cool, yeah?
09:45wingyoh right forgot that
09:45wingyyeah clojure (lisp) is so cool!
09:46wingyit beats other langs by light years
09:46wingyi will never go back..ever!
09:47Vinzent;)
09:47wingyi rather die
09:47wingyyes
09:49tbaldridgewingy: http://xkcd.com/224/
09:51wingy:)
09:51clgvwingy: http://xkcd.com/297/
09:51wingyi think i would like clojure more though
09:52wingyhaha
09:52wingy() power
09:54wingynot= is the same as != it seems
09:55wingyis there a reason not to use != instead? or is it just a matter of taste?
09:55wingyi mean != in other langs
09:57clgvwingy: well there is also: not, when-not, if-not ...
10:10wingyclojure koans was really fun
10:11wingymore fun than reading a lot without doing code
10:11wingyeven though i try to play with it in repl
10:13wingyi cant wait for light table to come out and help us with the live doc .. too many functions to remember and having to look all up (arity, desc, examples) is taking a lot of efforts
10:19wingyapparently you can use (first []) on a vector
10:20Scriptorwingy: as in (first [1 2 3])
10:20mybuddymichael,(first [3 4 7])
10:20clojurebot3
10:20Scriptorthat's because first calls seq on its argument(s)
10:21Scriptorer, make that just one argument
10:21Scriptorso it converts the vector into a seq, and then gets the result of calling its first() method
10:22Scriptorwingy: note this line https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L567
10:23wingyScriptor: but how do i know this without looking at source
10:23wingyfirst only works on sequences
10:23wingyand vector is not a sequence
10:24wingythe doc doesn't clarify this
10:24wingyhow do you know what functions work on what structures
10:24Scriptorwingy: had a discussion on this a few days ago! Basically first works on *seqables*, not just seqs
10:25Scriptorand vector is a seqable, because it supports the creation of a seq from the vector
10:25dnolenwingy: it does, it says it calls seq on it's argument.
10:25metellus,(doc seq)
10:25clojurebot"([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."
10:25metellussorry
10:25metellus,(doc first)
10:25clojurebot"([coll]); Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil."
10:25metellusa vec is a collection
10:25metellusso first should work
10:28metelluswingy: for the most part, clojure functions will work as you expect them to. Vectors have first elements, so it makes sense that first works on them. There may be minor differences in how things work when they are ambiguous (like conj), but you can find them out quickly in a repl
10:30wingyok so the "sequences" to the left means "seqables" as well http://clojuredocs.org/quickref/shortdesc/Clojure%20Core
10:30clgvwingy: well for questions like that you should progress in your book ;)
10:31Scriptorwingy: that section is for both collections *and* sequences
10:31Scriptorso a hashmap is a collection, but not a sequence
10:31wingythere was a link i forgot to save .. where they listed tables for differences between sequences and collections
10:31dnolenwingy: all the clojure collections are seqable.
10:33wingyScriptor: yeah but _first_ was found below Sequences section
10:33clgvwingy: I would continue reading the book, saves you time ;)
10:33wingythe first function is _seq_ .. that means it returns seqable and not a sequence?
10:34wingyclgv: yeah i will .. after the koans :)
10:34wingybut if it returns seqable then why not call that section Seqable and not Sequence
10:34wingyits ambiguous
10:35clgvfirst returns the element at position 0 or nil
10:35wingyclgv: i mean the first function below that section is seq :)
10:36wingyi think the confusion comes in when the doc is not very clear about what is for seqable (collections) and what is for sequence (list)
10:37metellusis there anything that isn't for both?
10:37tbaldridgewingy: there's a difference between seqable and seq
10:38tbaldridgeseqable means it can be turned into a seq
10:38tbaldridgeso a list is both seqable and seq (in this case calling seq on a list is a no-op because it is a seq)
10:39tbaldridgea vector is seqable as calling (seq [1 2 3]) returns an entirely different type of object.
10:39tbaldridgebut a vector is not a seq
10:40tbaldridgeI don't know if this helps at all, but these map to Java interfaces: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ISeq.java https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Seqable.java
10:40metellushe knows all that; his issue is that the docs don't really explicitly say "things will work for seqables even if they say that they work for seqs"
10:40tbaldridgeyeah that is a bit confusing.
10:41clgvhumm not really.
10:41wingyok ill just assume that everything just works for collections (seqables) .. since they will be converted into sequences
10:42metelluswingy: as far as I know, that will work. If you do encounter something weird, try out some examples in a repl to see what's going on
10:42wingybut honestly i don't enjoy confusions like these where it takes so much time to figure things out .. "Dont make me think" is a really good book explaining why you don't want unnecessary overhead for users
10:43clgvwingy: you could have read it in your book. you won't fin general global-scope explanations in docstrings ;)
10:43mystiiqhow can I iterate over a map and define variables with given key and set value of that corresponding key
10:44wingyif there is someone here with authority/knowledge to change docs i hope these things could be cleared out to make the looking up process more enjoyable
10:44metellusto be fair, http://clojure.org/data_structures#Data Structures-Collections does say "Because collections support the seq function, all of the sequence functions can be used with any collection."
10:44clgvmystiiq: give an example
10:46mystiiqI read a file into a map containing config parameters and then I want to define them as a system-wire variables
10:46clgvmystiiq: oh. then you have to create the def statements and eval them
10:47clgvmystiiq: but that approach does not sound idiomatic...
10:49wingymetellus: yeah more fair
10:49wingyill read them through
10:50wingyand thx for all explanations the 2nd time now :)
10:50wingyi think its solid with the diff :)
11:05tbaldridgeclgv: why is that not idiomatic?
11:06clgvtbaldridge: global defs for config created at runtime sounds pretty wrong. there would be the option to set up something with thread local binding or such
11:07tbaldridgeclgv: yeah, I can see that
11:08clgvtbaldridge: most of the time when you use eval in a function, there is a good chance you are doing it wrong, as well
11:08tbaldridgeclvg: it depends though, if it's a config for a website, global defs would probably be preferable
11:10tbaldridgeso yeah, the eval version sounds bad, but what about putting defs in a seperate namespace, then reading the config file and runtime and using set! to init all the configs
11:10clgvtbaldridge: well thread-local bindings are propagated since 1.3
11:10tbaldridgeno eval, but yet global defs (for stuff like db servers)
11:10clgv tbaldridge: and why not using thread-local bindings?
11:11clgvyou read the config before you do anything website related, I guess
11:12tbaldridgethe problem with using the bindings is that I then have to wrap my entire app in a (binding [])
11:13tbaldridgebut I'll admit can see allot of benefit to your method.
11:14clgvtbaldridge: well you have a single point of entry anyway, when you launch jetty&co
11:15clgvtbaldridge: and you could even easily overwrite config params for user-specific settings
11:18tbaldridgeclgv, yeah, I hadn't thought of it that way. If they are propagated to sub-threads then yeah, it sounds like it would work fine. Cool I learned something today.
11:18clgv=)
11:19wingydoing clojure koans is like doing sudoku
11:19mmarczykdnolen: good catch on 330, thanks!
11:19borkdudethen sudoku must be a very nice game
11:19wingysomeone release a clojure sudoku app for android/iphone
11:19wingyso i can do it on the bus
11:20borkdudewingy this is your next assignment
11:20wingyno .. i pay!
11:20clgvp(l)ay?
11:20clojurebotclojure is the brand
11:20wingyand pay
11:20borkdude4clojure app
11:21borkdudecould be nice project
11:21clgvlol I would not want to program anything on a smartphone ;)
11:21borkdudebut I don't have a smart phone either ;-)
11:21wingybut since it's cumbersome to type things in an iphone it would be better with alternatives as answers
11:21borkdudewingy I have a Nokia E71 for that
11:21mmarczykdnolen: btw, could you look into cljs-319 in a free moment? bbloom's patch worked for me perfectly last time I checked and the issue is so annoying :-P
11:22borkdudewingy well I guess that is a smart phone, but symbian is dead
11:22borkdudewingy at least is has a keyboard
11:24wingyfill in: (= (+ __ 1) 23) 1) 23 2) 31 3) 22 .. and you press a nr
11:24wingyno need to type
11:24borkdudewingy or make the game: drag the expression in the right order ;)
11:24wingyborkdude: yeah but your are on the bus .. and wanna learn with no typing efforts
11:25wingyyeah
11:25wingyall kind of stuff
11:25wingycome on .. some clojure guru who needs some time to kill
11:25wingyi think people would buy the app
11:25wingysubscription based!
11:25borkdudewingy just buy a macbook air or smth, so much easier
11:26wingyif you release new levels each month i could pay like 2 dollars each month
11:26wingyborkdude: but its no fun reading books all day long
11:26wingyyou wanna play and learn just like clojure koans
11:26borkdudewingy that you can do on a macbook air?
11:27borkdudewingy with a full fledged REPL and no limitations
11:27wingyi have a macbook pro .. but i feel it would be more fun to do it on the go
11:27wingynew kind of learning
11:27borkdudewingy yes, on the go… I do clojure while commuting sometimes
11:27wingyfor php, ruby and other langs as well .. this is business!
11:27wingyi know it will be big
11:28wingyborkdude: haha
11:28wingylook at sudoku
11:28wingytry to release one .. you will get millions
11:28wingyim never wrong
11:28borkdudewingy what would you do with all those millions, life would get very boring? ;P
11:29wingyso many people who wants to know programming but not thorugh reading books
11:29wingyand they don't wanna spend efforts in repl typing/testing everything themselves
11:29wingyborkdude: i would make more apps
11:29wingyand get billions!
11:30dnolenmmarczyk: I suspected something deeper was going on w/ 330
11:30dnolenmmarczyk: I don't like the double doseq calls in 319, worth investigating removing those.
11:30wingythen climb up to the top of a mountain screaming .. BILL!!!!!!!!!!!!!!
11:31mmarczykdnolen: re: 330, yeah, I think your commit nails it
11:32mmarczykdnolen: alternatively we could extend to "null" and "undefined" avoiding the nil? check
11:32mmarczykdnolen: probably not worth the trouble though?
11:34mmarczykdnolen: re: 319, ok, that's worth a try
11:40dnolenmmarczyk: I think the nil? check is sufficiently cheap. I think handling undefined at all is not worth it.
11:41technomancyman, I wish the clojure reader would treat nonbreaking spaces correctly =\
11:47pepijndevosIs there anything that prevents one from writing a multithreaded asynchronous server?
11:49dnolenpepijndevos: like Netty?
11:49pepijndevosdnolen, I don't know. Like netty? I just noticed that all these tthings like node, libev, twisted ed are all singlethreaded.
11:50dnolenpepijndevos: look at Netty.
11:50pepijndevoscool, thanks
11:50dnolenpepijndevos: Aleph is built on top of it.
11:51pepijndevosyea, aleph rocks
11:53wingyhow do i make an anonymous fn return 1
11:53wingywhen it's run
11:53wingy(#('1)) ;; yields error
11:54rkzwingy: ' isn't a quote, it's a special form
11:57wingyrkz: it's a quote in '(1 2 3) ?
11:59dnolenwingy: you can't do that with fn literals, regardless of quote, the body of the fn literal is an expression, so you're invoking (quote 1) as a function.
11:59rkzwingy: that says evaluate the form without using 1 as a fuction call and 2 3 as args
11:59Iceland_word wingy: maybe check out http://clojuredocs.org/clojure_core/clojure.core/constantly ?
12:00dnolen,((fn [] 1))
12:00clojurebot1
12:00dnolen,(#(do 1))
12:00clojurebot1
12:00metellus,(#(1))
12:00clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
12:01rkz,(#(identity 1))
12:01clojurebot1
12:02wingycool solutions
12:17gfredericks,((constantly 1))
12:17clojurebot1
13:17cmcbrideif I have a vector of maps, and I want to update a specific key in each map, whats the best way to do that?
13:18borkdude(mapv (fn [m] (assoc m k new)) vec-of-maps) ;; something like this?
13:19cmcbrideyes, I forgot about mapv. Thanks
13:30sirsublimesup peepz
13:30sirsublimeList comprehension question coming up
13:30sirsublimeSay I have some seq and I know it's sorted.
13:31sirsublimeAnd I want to do list comprehension on it, but with n values, instead of one.
13:31sirsublimeSo, if I have a vector [1, 2, 3, 4], then I could itterate by [1,2] and [3,4].
13:32sirsublimeI don't think plain vanilla (for ..) does it.
13:32sirsublimeAny tips?
13:32cockadoodledoomaybe partition?
13:32cockadoodledoohttp://clojuredocs.org/clojure_core/clojure.core/partition
13:33sirsublime(for [[x y] (partition 2 foo-list))?
13:33sirsublimeI love you coc... Almost fell for that one.
13:34cockadoodledoo(partition 2 [ 1 2 3 4])
13:34sirsublimeThis is awesome. Thanks!
13:34cockadoodledoonp
14:06TimMcsirsublime: Also see partition-all, for future reference.
14:21sirsublimeTimMc: Thanks!
15:06lynaghkdnolen: I'm playing with core.logic and the Zebra puzzle, and things take very long if I move the unify statement (milk is drunk in the middle house) past one or two membero statements. Is this because the unify nails down a lot of the free variables early on in the search or something?
15:06lynaghkdnolen: do you find you have to rearrange ordering like this to get your logic programs to complete?
15:18pendlepantsif I have a nested map like {:recent-tracks {:track {:artist {:text "name"} :name "song name"}}}, is there a better way to get nested values than (:text (:artist (:track (:recenttracks var))))?
15:19dnolenpendlepants: get-in
15:19dnolen(get-in x [:recent-tracks :track :artist :text])
15:19pendlepantsthat's perfect; thanks dnolen.
15:40augustlhow do I add unpublished dependencies to a leiningen project? My project consists of a bunch of modules, and some of them depend on some of the others. These modules won't be published on clojars though
15:40augustlset up my own maven repo perhaps?
15:42augustlif so, any suggestion for reading material for a person that has no prior experience on the Java platform? :)
15:43xeqiaugustl: are they just being used on one machine?
15:43augustlxeqi: well, I don't mind building and deploying uberwars, it's ok if you have to somehow link stuff in by hand locally or whatever
15:45TimMc~repeatability
15:45clojurebotrepeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability
15:46augustlTimMc: aww, so I have to set up a repo then
15:46augustllet's hope that won't take too many days of my time :P
15:46augustlooh, private s3 buckets
15:49Jayunit100_man there is no irc for regular old java . just realized that.
15:51yonatanenot many one liners
15:56Shambles_dnolen: I saw the code you posted yesterday. Thanks for doing that. I wasn't expecting it.
15:57TimMcJayunit100_: ##java, but you won't be happy
15:57dnolenShambles_: no problem - as I suspected using a vector allowed pretty much a direct translation
15:57dnolenShambles_: no atom, no zippers etc.
15:57ssutchwhen using java interop, what is the best way to run a method against an instance in let, eg: http://www.exampledepot.com/egs/java.security/GenKeyPair.html
15:58ssutchi want to run keyGen.initialize(1024) (. keyGen initialize 1024) before using it
15:58ssutchwould i just run that as an expr in the body of the let
15:58TimMcNot sure what 'let has to do with it.
15:58TimMc(.initialize keyGen 1024)
15:59TimMcssutch: Or even better, use doto
15:59ssutchTimMc it probably doesn't, this is only my 2nd day with clojure, so looking for best practices
15:59ssutchdoto, interesting, i am not familiar, i'll look it up
16:00TimMc(doto (KeyPairGenerator/getInstance "DSA") (.initialize 1024))
16:00ssutchaha!
16:00ssutchi knew there would bea more succinct way to express that
16:00dnolenShambles_: also hopefully you can see that the functional data structure support is quite good. only 2 lines that deals with managing indexes.
16:01TimMcssutch: It's a good macro to use if you want to call a contructor (or similar), hammer on the object, then return it.
16:01ssutchthat's rad, thanks TimMc
16:02ssutchis it sane to put that in the bindings of a let in the body of a defn?
16:02TimMcSure!
16:02ssutch(let [keygen (doto (KeyPairGenerator/getInstance "DSA") (.initialize 1024))] ...)
16:02TimMcYou'll also see people use it to temporarily sneak in debugging statements: ##(+ 3 (doto (* 5 6) (println))), but that's just a hack.
16:02lazybot⇒ 30 33
16:03Shambles_dnolen: I had no problem believing Clojure (being a functional language) would be good at working with data structures in a functional way. Mutation, or working around using it, is another matter. I probably have a long way to go to get my head around that. I admit to not understanding your code, but I'll stare at it and look at documentation until it sinks in.
16:03Shambles_dnolen: It's not like the original code was the cleanest written thing anyway.
16:03dnolenShambles_: working mutation is just familiarity. It's easy to get frustrated if you can't rely on old habits.
16:04dnolenusing mutation is just famliarity I mean.
16:04dnolenShambles_: the code is a direct translation of animal.py - I didn't stray very far.
16:06Shambles_dnolen: The parts that are giving me trouble are the various -in operations and juxt and the like. Basically the different data structure.
16:06Shambles_dnolen: But I should be able to figure it out if I read the documentation and think about it long enough.
16:07TimMc<3 update-in
16:07dnolenShambles_: yes, it just a vector of nodes, knowledge always starts at index 0.
16:07dnolenShambles_: juxt is sweet
16:07dnolen,((juxt inc dec) 1)
16:07clojurebot[2 0]
16:07TimMc&((juxt filter remove) odd? (range 10))
16:07lazybot⇒ [(1 3 5 7 9) (0 2 4 6 8)]
16:07Shambles_dnolen: Not that this ever happens in this program, but I wonder how tolerant it would be of having nodes removed, since I think that'd mess the indexing up.
16:08dnolenShambles_: functional thinking requires patience, but Clojure delivers a lot of tools so that you can keep code as brief as mutable versions nearly every time.
16:08dnolenShambles_: it's a toy, expect a toy solution.
16:13dnolenShambles_: even so, removing nodes doesn't pose any real challenges
16:20wilfredhI would like to define a macro that has the same semantics as defn, but builds a list of all the functions that have been defined with it. Should I use a var, or something else?
16:22wilfredhI'm not quite sure how to set a variable at compile time such that I can access it at run time.
16:30ohpauleezwilfredh: Your macro can compile down to defns, which is common for macros creating DSLs
16:32ohpauleezwilfredh: https://github.com/ibdknox/noir/blob/master/src/noir/core.clj#L80
16:32bprwilfredh: i would put that macro in its own namespace. Also, in that namespace would be the var with the list(s) as its value. Then define a function in the namespace that can be called at runtime to access the lists.
16:32ohpauleezBut as a rule of thumb, you should prefer to use functions over macros whenever possible
16:33ohpauleeza good solution here would be to use a decorator
16:33bprwilfredh: so the macro updates the var, and the var can be read using the function.
16:33ohpauleezand decorate the functions outside of a defn, onto another def
16:34ohpauleezwilfredh: but here is an example of exactly what you're talking about
16:34ohpauleezhttps://github.com/shoreleave/shoreleave-remote-noir/blob/master/src/noir/shoreleave/rpc.clj
16:35bprohpauleez: unless i'm wrong i think this requires a macro. You'd have to walk the source of the function to see what functions it calls
16:35ohpauleezwith a macro
16:35ohpauleezbpr: No a decorator is appropriate, but it involves double def'ing
16:35ohpauleezor adding metadata
16:35ohpauleezwhich is probably the best idea
16:35ohpauleezsince you can define it with defn anyway
16:36bpri agree with the metadata
16:36ohpauleezwilfredh: Can you use metadata, then just define one predicate function?
16:36bprbut how do you, check which functions are being called?
16:37hiredmancemerick: why is drawbridge so temperamental? I can usual send a single request via curl, where I get a response, after which I always get an empty response
16:38ohpauleezbpr: just use another function (higher-order) that takes a fn, and any args, and has a pre conditional constraint on approved-fn?
16:39ohpauleezwhere the function `approved-fn?` checks the metadata of a function
16:39bpri don't think he wants to write the meta-data by hand
16:39ohpauleezand inside the function described above, you just do an `(apply …)`
16:39ohpauleezbpr: Right, so he can use a decorator, and double def
16:40ohpauleezor he can write a macro
16:40ohpauleezor if it's just a few, I'd write it by hand
16:41bprif i understand what he wants correctly he wants to write: (def-annotated-fn foo [] (bar (baz))) and have a list defined somewhere that says (somehow) that foo calls bar and baz
16:42ohpauleezoh, I thought he just wanted whitelisting
16:42ohpauleezI didn't know he wanted tracing
16:42ohpauleezClojure already has tracing capabilities
16:42bpri coulda read it wrong
16:43gf3How do you guys go about playing with misc. libraries from the command line repl?
16:43gf3As part of no specific project?
16:45bpri did read it wrong lol: he wants (def-annotated-fn bar [] ...) that would then create a list saying bar is called by foo...
16:45bprbut w/e
16:46ohpauleezgf3: You can use lein-exec or just spin up a quick one off project
16:46ohpauleezhttps://github.com/kumarshantanu/lein-exec
16:46bprit still seems to need to consider the source directly
16:47gf3ohpauleez: That's great, thank you
16:47ohpauleezgf3: Totally welcome
16:48bagelzwhy can't I do this in clojure on my phone: (for [x 1 y 1] [x y])
16:52ohpauleezbagelz: (for [x [1] y [1]] [x y])
16:52ohpauleezfor is a list comprehension
16:52ohpauleeznot an iteration, really
16:53ohpauleezperhaps you meant (let [x 1, y 1] [x y])
17:06bagelzI actually meant (for [x 1 y 1] [x y])
17:06bagelzit gives a stack overflow
17:06bagelzdo I only have 16MB in my dalvik vm?
17:09ohpauleezbagelz: That's an incorrect `for`
17:09ssutchif i want to do something like Security.addProvider(new BouncyCastleProvider()); which is a static thing that should be called only once, do i do it in the (ns ) body?
17:10ohpauleezsee my example above
17:10ohpauleezssutch: No you do it in the file like you normally would call it
17:11ssutchso just amongst my defns and whatnot
17:11ohpauleezcorrect
17:11ssutchcool, thanks
17:11ohpauleeznp
17:13ssutchsweet!
17:13ssutchmy first clojure function that does something!
17:16augustlthose are the best functions
17:17y3dido/have you guys used state machines to control your applications' flow?
17:18ohpauleezy3di: Yes when the app can be expressed nicely as a state machine
17:19ohpauleezThere are a few libs (for Clojure and for CLJS), but I've never used them, just used maps and keywords for my limited use cases
17:19y3diohpauleez, can you reccommend some learning materials about state machines?
17:22ohpauleezy3di: I don't any off the top my head - I could dig through some CS, AI or my SE books
17:22ohpauleezbut google turns up this video: http://video.google.com/videoplay?docid=-5837841629284334824
17:23y3diI learned about them a year ago in class, but theoretical cs seemed so far removed from real world coding that i didn't pay much attention to it
17:23ohpauleezThe wikipedia page actually has some helpful links and references
17:24ppppauly3di pinot does (clojurescript framework)
17:24ohpauleezppppaul: that's been pulled out into its own library
17:24ppppauliknow
17:24ppppaulbut i don't know the name of the lib
17:25y3dippppaul, didn't you used to hang out in #documentcloud all the time?
17:25ppppauli still do
17:26ppppaulalso hang out in couchdb and tell the devs to fix all the bugs i find
17:26ppppaulsate machines are really useful for web apps
17:26ohpauleezy3di: If you have a problem that can be expressed in a series of stable states with events that map to clean transitions between those states, and FSM lib could help
17:26ppppauli do some state machine hacky crap with backbone
17:27y3dippppaul, you should write a blogpost on your methodology
17:27ohpauleezI find that I model most of my systems off of event buses (like a C2 architecture) and less off of an FSM
17:27ohpauleezbut I model my Cucumber tests using FSMs
17:27ppppauli do it in JS, so my methodology is discipline :(
17:27y3dievent buses, never heard of that one before
17:28ppppauli use event buses
17:28ohpauleezy3di: pub/sub stuff, same thing
17:28y3dioh ok
17:28ppppaulglobal/tiered event stuff
17:28ppppaulclojure has a event thing in it modelled off of mailboxes
17:28ppppaulit seems very cool
17:28ppppauli forgot the name :(
17:28ohpauleezbecause an FSM is tightly coupled, and not open for extension, whereas C2 avoids those tradeoffs
17:30ppppauli find it tricky to model events, i try to make as loosly coupled components as possible
17:31ppppauli put everything in the event bus and hope i don't have typos or conflicts >_<
17:34amalloy$mail dnolen i tried binding a dynamic variable to a fresh logic variable, to make it easily accessible throughout my program (we discussed this and decided it probably ought to work). but from https://gist.github.com/3049645 it looks like that binding just creates a snapshot of the logic variable, which can't be unified with anything anymore
17:34lazybotMessage saved.
17:38Jayunit100_i learned those dynamic var thingies from this https://github.com/alexott/clojure-hadoop :) its pretty cool . he sets the job context for hadoop as a dynamic global so that macros that call map/reduce functions set it beforehand.
17:40augustlso, just wrote this http://pastie.org/4201008 Any reusable existing module for that?
17:40augustlthat = a ring middleware for parsing JSON on incoming requests and making sure the response is always JSON
17:41weavejesteraugustl: I have a ring-json-response and Mark has a ring-json-params. I'm planning on combining them into a ring-json library soon, but they can be used separately.
17:41augustlweavejester: ah cool, looking them up, thanks
17:42amalloynoir has wrap-json in there somewhere; probably every webapp uses one of those or writes its own
17:42amalloy(i'm sure it's part of lib-noir now, so you don't need the whole noir thing)
17:46augustlthanks folks :)
17:50augustlwant to use https://github.com/technomancy/s3-wagon-private, are there any docs anywhere for how to actually publish projects to an s3 bucket?
17:51brehauti dont think i have seen that
17:51brehautwhoops wrong window sorry
17:59augustlwell that was easy, "lein deploy"
17:59brehauti blame a caffeine deficiency
18:01augustlhmm it seems I need to have _all_ dependencies on s3 when I use that plugin
18:03mybuddymichaelWhy are Java String methods imported automatically by the REPL, and how can I see what other Java classes are automatically imported?
18:06mybuddymichaelAnyone want to take a stab?
18:06taliosthey are?
18:07mybuddymichaelAt least with `leon repl`, yes.
18:07mybuddymichaellein*
18:07mybuddymichael,(.toUpperCase "michael")
18:07clojurebot"MICHAEL"
18:07mybuddymichaelAnd here too, apparently.
18:07brehautmybuddymichael: those are sugar over the . special form; the methods themseves are not imported into the NS
18:08talioswhat brehaut said :)
18:08talioshe types faster
18:08mybuddymichael,(doc .)
18:08clojurebotIt's greek to me.
18:08mybuddymichaelHah.
18:08brehautyou'll probably have to look at clojure.org
18:09mybuddymichaelYep, because that doesn't make too much sense to me.
18:09brehauthttp://clojure.org/java_interop#dot
18:09mybuddymichaelThanks, guys.
18:09augustlare there any tutorials around for s3-wagon-private?
18:09mybuddymichaelOh, awesome.
18:09mybuddymichaelbrehaut: Thanks.
18:09brehautnp
18:10brehautmybuddymichael: its worth reading all the pages on clojure.orgs sidebar
18:11mybuddymichaelbrehaut: Good idea. I'm actually working through Clojure Programming and JoC right now.
18:11brehautthose are both good resources
18:11augustlseems I need to understand much about how maven works in order to be able to have unpublished internal modules as dependencies of my projects
18:11mybuddymichaelbrehaut: But I have not read much from the official site.
18:12mybuddymichaelbrehaut: Other than the "features" section.
18:12gstampsmall problem on OS/X that I was wondering if anyone might be able to help with… whenever a new JVM starts up (for instance when running clojure-jack-in) the focus moves to the new JVM. Is there anyway to stop that? It's very annoying.
18:12mybuddymichaelbrehaut: But I've heard various people mention that the official site is frequently outdated?
18:13brehautits not the most timely resource
18:13brehautbut especially for things like what the reader is doing, what various forms mean etc
18:14brehautits a good place to start
18:14mybuddymichaelbrehaut: Right on.
18:15augustlhttp://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/ seems to be a solution, but it means committing the jars into git
18:15mybuddymichaelbrehaut: By the way, I somehow stumbled upon your "brief over of the Clojure web stack" the other day. Helpful stuff.
18:15mybuddymichaelbrehaut: Thanks for writing it.
18:15brehautthanks
18:16brehautFWIW in that i say that i prefer moustache; ive changed my mind and now prefer compojure
18:17mybuddymichaelbrehaut: Interesting.
18:18brehautit has some features around route and request destructuring that i didnt know about that are really excellent
18:18samaaronMINI BEAST: https://github.com/aaron-santos/mini-beast
18:19brehautsamaaron: that looks amazing!
18:19samaaronbrehaut: it's sick
18:20samaaronit totally works too
18:20samaaronhaha
18:21samaaronthe insanely cool thing is that all the source for it is in Clojure
18:21samaaronevery single part
18:21samaaronfrom the interface, to the MIDI events to the synthesis
18:21augustlany suggestions for how to set up a private maven repo for non-free local dependencies in leiningen?
18:22augustlseems I can just scp files to any HTTP server, would be nice to be able to "lein deploy" though
18:23brehautmybuddymichael: https://github.com/weavejester/compojure/wiki/Destructuring-Syntax btw
18:24mybuddymichaelbrehaut: Sweet. Thanks.
18:37seancorfieldaugustl: have you looked at the s3-wagon stuff for private maven repos based on amazon s3 storage?
18:37ssutchwhat is the & in defn - i can't quite figure it out
18:38enteLhello, im using swank-clojure in emacs which works fine, but unlike with common lisp C-M-x to eval a exp isnt sending the output to the repl, anyone know how to get it do that?
18:38seancorfieldssutch: it's for variadic argument functions - [& more] will initialize more to a sequence of the arguments
18:38ssutchseancorfield thank you!
18:39seancorfieldso [a b & more] has two required args and more is all the rest
18:39ssutchseancorfield excellent that helps a lot, thanks
18:47augustlseancorfield: yeah, only annoyance now is that it spits out a gazillion stack traces when lein resolves dependencies
18:48augustlbasically, it seems that leiningen tries the s3 repo first for all deps, and a non-existing dep in my repo (that is, public clojars) yields an insane 404 and a stack trace
18:48augustlit _works_ but it's pretty annoying
18:50fil512lein compile isn't compiling anything--it's silently failing. thoughts?
18:50fil512it's almost like it doesn't know to look in the src folder...
18:52FrozenlockIs there a way to get every fields from a java class?
18:56cgagI'm trying to base64 encode something, and i found this: http://commons.apache.org/codec/index.html. How would I actually go about using this, like how would I figure out what needs to be put into leinigen? I see that someone put it on clojars, but I'd like to figure this out.
18:58brehaut"Yes, PHP has a better dependency manager than any other languages."
18:58brehautO_o
18:58Frozenlockcgag: This could be helpful https://github.com/clojure/data.codec/
18:59weavejestercgag: Ring has a base64 encode and decode based on Apache commons codec
18:59weavejestercgag: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/codec.clj
18:59weavejestercgag: Line 53 to 61
19:01madsyI tried to build the "simple" example from lein-cljsbuild, but it seems that hiccup 1.0.0 is incompatible with lein-ring 0.7.0, according to the error I get and some hits on google.
19:01madsyAnyone knows it this is an issue with the example at github or if the error is on my end?
19:01augustlany tutorials out there for setting up your own nexus and using it from leiningen? Got a nexus up and running, but getting authentication errors when deploying.
19:03weavejestermadsy: lein-ring 0.7.1 is the latest version, but 0.7.0 shouldn't be incompatible. Do you have a dependency to Ring 1.0.0 on your classpath?
19:03weavejestermadsy: Or Compojure 1.0.0
19:03yonatanecgag: i had problems with data.codec cutting the last character. Use apache commons codec.
19:04cgagweavejester, so i see that's using the commons codec library i was asking about, and i see in your project.clj you just have [commons-codec "1.6"], my question is where did that come from
19:04cgagi see 1.3 on clojars, but it doesn't have the same group/artifact id
19:04madsyweavejester: Yes, I do. Here's the project clj file for the example: https://github.com/emezeske/lein-cljsbuild/blob/master/example-projects/simple/project.clj
19:05weavejestercgag: From maven central. Clojars isn't the only default reposity in Leiningen :)
19:05weavejestermadsy: Update the Compojure dependency to 1.1.0 and the problem should be resolved.
19:06madsyLet me try that :)
19:07yonataneweavejester, I didn't include commons-codec in my project.clj, yet it worked anyway. Could it be because I did include ring or noir?
19:07yonatanei just called (org.apache.commons.codec.binary.Base64/decodeBase64 input-bytes) without thinking about it
19:07weavejesteryonatane: Yes; Ring depends on commons-codec
19:09cgagweavejester, i found this on maven central: http://search.maven.org/#artifactdetails%7Corg.apache.directory.studio%7Corg.apache.commons.codec%7C1.6%7Cjar, but wouldn't your leiningen entry then look like '[org.apache.directory.studio/org.apache.commons.codec "1.6"]?
19:09yonatanethanks
19:10weavejestercgag: Yes, but the library I use is: http://search.maven.org/#browse%7C-1511838660
19:10weavejestercgag: Which is commons-codec/commons-codec
19:10weavejestercgag: Leiningen simplifies that to commons-codec
19:13cgagah guess i missed that one, thanks, i just wanted to be sure i was understanding maven/leiningen conventions
19:19madsyweavejester: Hm.. not sure what the cause is now. When I run "lein ring server-headless 3000" it complains about not finding the "app" ring handler in the path. But the code itself compiles fine.
19:19weavejestermadsy: What do your :ring options in your project.clj file look like?
19:20madsy:ring {:handler example.routes/app}, unmodified from the example on github I linked to
19:20weavejesterAnd there's a file at src/example/routes.clj ?
19:21weavejesterOh, I see your project. Let me look
19:21weavejesterHm, wait, you have lein-ring as a dev-dependency and not a plugin? That's wrong...
19:21weavejesterlein-ring is a plugin
19:21madsyThe clojure source path is :source-path "src-clj", and the routes.clj lives under ./src-clj/example/routes.clj
19:21weavejesterIt's only dev-dependencies on older versions of Lein that didn't have :plugins
19:22madsyYeah, but I did add lein-ring to my profiles.clj
19:22nunoHello, anyone knows a beginning tutorial for clojure? (no previous programming knowledge)
19:24weavejesternuno: Hm, no previous programming knowledge? I'm not sure I've seen a Clojure tutorial that teaches from scratch.
19:24amalloynuno: you could try 4clojure? it's not totally a standalone learn-to-program tool, but it has links to some relevant materials
19:25nunook, thanks
19:26yonatanethere's the SICP book not completely converted to clojure: http://sicpinclojure.com/
19:26ToxicFrog4clojure I really didn't like, personally - its "your answer must be a single form we can splice in" model makes some solutions unnecessarily convoluted, and a lot of the problems are just (poorly) recycled Project Euler.
19:26ToxicFrogAnd it also assumes that you're actually learning Clojure from something else.
19:26yonataneyou will have to do some of the work yourself, reading about clojure a little to convert the samples.
19:27seancorfieldwith no prior programming background, i'd suggest http://tryclj.com/ since you can type in tutorial and it takes you thru with baby steps
19:27weavejestermadsy: It looks like it works if the Clojure source directory is just "src", the default… It looks like it might be a bug in lein-ring.
19:27ToxicFrogyonatane: where do I file bug reports against sicpinclojure?
19:27madsyweavejester: thanks :)
19:28yonataneit has a github repository i think
19:28yonatanebut i have no idea
19:28madsyweavejester: So, uh merge the two src-clj and src-cljs directories to "src" ?
19:29weavejestermadsy: Well, just change the src-clj to src works. But hm… which version of lein are you using?
19:29madsylein 2.0.0-preview7 with openjdk 6
19:30weavejestermadsy: Ah, I think the option might have changed in Leiningen.
19:30weavejestermadsy: In here: https://github.com/technomancy/leiningen/blob/master/sample.project.clj
19:30weavejestermadsy: It's source-paths
19:31weavejestermadsy: Followed by a vector, not source-path
19:31madsyaha, thanks :)
19:31weavejestermadsy: :source-paths ["src-clj"] works
19:32madsyweavejester: Thanks a lot for your time. Different project using lein and lein 2 without specifying can be quite the headache.
19:33weavejestermadsy: Yeah, there's a bit of pain switching, but worth it in the long run, I think :)
19:33madsyI'll be sure to double check the project-clj map keys next time
19:42ToxicFrogHuh. The clojure-clr 1.4.0-3.5 download is broken.
19:59augustlif the key :json-body is present in a map, I want to create a new map without :json-body and where :body is the value of :json-body passed through a function. Suggestions? :)
20:01nicholasfwhat's the convention for organising code in namespaces in clojure projects? It's obviously different than the java conventions?
20:01brehautaugustl: dissoc + assoc
20:01augustlbrehaut: I suppose there's no specific function for this :)
20:01augustlthanks
20:10amalloy&(doc clojure.set/rename-keys)
20:10lazybot⇒ "([map kmap]); Returns the map with the keys in kmap renamed to the vals in kmap"
20:10amalloyis close, but probably just assoc/dissoc is fine
20:16ssutchhow would someone do a (with-connection …) sort of form?
20:16ssutchi want to do a (with-keypair) sort of thing
20:23rlbssutch: this might be more than you need, the source for with-open could be a model -- http://clojuredocs.org/clojure_core/clojure.core/with-open#source
20:28augustlis there a way to require a file by path and access its defs? Was thinking of using a .clj for setting config vars for my app, would be nice of the config file didn't have to define a namespace etc
20:30ssutchload-file?
20:30augustlssutch: experimenting with it now
20:31augustlhow does it work? It seems to "inline" it, so that any defs from the file becomes def in the file where I load-file
20:35ssutchaugustl no idea
20:35ssutchsorry
20:35augustl:)
20:36enteLpa/wc
20:36enteLoops
20:38ssutchrlb that doesn't quite do what i want, i am looking for more like with-connection
20:38ssutchwhich defines a connection and then functions called in the body have the connection available to it
20:39ssutchhttps://github.com/richhickey/clojure-contrib/blob/e2014cf11b5598a955dd5a1d6e8ce9c06f934ae8/src/main/clojure/clojure/contrib/sql.clj#L32
21:20ssutchso i came up with this, but "keypair" is always unbound: https://gist.github.com/fc74626ef88db412d318
21:23ssutchah ha! https://gist.github.com/fc74626ef88db412d318 <- that fixed it
21:28madsyIf a function in Javascript is foo.bar.baz(), can I refer to it as "(baz)" in clojurescript somehow?
21:29madsyHow the namespaces are set up is kind of confusing :)
21:34augustlwhat's a good way to find if a map has keys in it other than keys defined in a vector, like ["foo" "bar"]?
21:36brehaut,(do (use 'clojure.set) (subset? ["foo" "bar"] (keys {"foo" 1 "bar" 2 "baz" 3}))
21:36clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
21:36brehaut,(do (use 'clojure.set) (subset? ["foo" "bar"] (keys {"foo" 1 "bar" 2 "baz" 3})))
21:36clojurebotfalse
21:37brehautbah. something like that
21:37augustlneat
21:37technomancy,(empty? (apply dissoc {"foo" 1 "bar" 2} ["foo" "bar"]))
21:37clojurebottrue
21:38brehauttechnomany wins. his actually answers the question
21:40xeqi&(remove #{"foo" "bar"} (keys {"foo" 1 "bar" 2 "baz"3}))
21:40lazybot⇒ ("baz")
21:40xeqijust checking
21:43augustltechnomancy: nice, that way I'll have the list of invalid keys too
21:51wingywhat does 3N mean?
21:51wingyand 3M
21:52brehaut, (map class [3N 3M])
21:52clojurebot(clojure.lang.BigInt java.math.BigDecimal)
21:53wingybrehaut: i c
21:54wingyim not familiar with java, is there a good place to look up the differences between all the sizes of numbers?
21:56brehaut,Long/MAX_VALUE
21:56clojurebot9223372036854775807
21:57brehautBig numbers dont have a max value
21:58wingyis there a matrix somewhere for fast lookup?
21:58brehautprobably
21:59brehautbut you mostly only want primative longs for speed or bigints for precision
21:59brehautclojure defaults to performance because thats what you want in most cases
22:00technomancy"most" cases
22:00amalloyman, when do i ever want performance
22:00wingyso i work with longs in clojure, but when do i know i have to switch to big int?
22:00wingywill i get an error if clojure can't handle that math operation?
22:01amalloyrich has robbed me of the joy that comes from optimizing my own code
22:01amalloy&(inc Long/MAX_VALUE)
22:01lazybotjava.lang.ArithmeticException: integer overflow
22:01amalloy&(inc' Long/MAX_VALUE)
22:01lazybot⇒ 9223372036854775808N
22:03wingyi c
22:03wingyso no need to know the others only: java.lang.Long and clojure.lang.BigInt ?
22:05wingynDuff: tell us how it goes .. im pretty interested in that topic as well
22:06amalloyi can't think why you'd need to know either of those either. just use numbers, and if they happen to be an instance of Long you usually don't care
22:07brehauts/to/for/
22:08wingyi guess
22:09augustlany recommendations for mongodb libraries? Not sure what kind of abstractions I want, all I know is that I need to write and read to mongodb :)
22:10augustlin general I know I want a level above raw mongodb driver, I need at least data validation
22:18xeqiaugustl: reheap.com recently moved to https://github.com/michaelklishin/monger/
22:18xeqi*refheap
22:18augustllet's pretend for a second that mongodb wasn't a requirement :) Are there any databases that can be said to be "best" for Clojure (other than Datomic)?
22:19augustlxeqi: you work on refheap.com? Have you written your own validations and what not on top of monger?
22:19brehautsurely a database is best for a particular program rather than a language?
22:19augustlbrehaut: I suppose when you leave Datomic out of the equation, that's true
22:19augustlor more true
22:19brehautor do you mean which language has the best library sypport in clojure?
22:19xeqino, but I saw a tweet about it
22:20augustldatomic seems to be a pretty good match for Clojure, since it has similar semantics for abstracting away time
22:20augustlbrehaut: I guess :)
22:20wingyaugustl: why not datomic?
22:21augustlwingy: because I can't use it yet, I think, it's an invite only beta isn't it?
22:21wingyno
22:21wingyjust download it and play with it .. im was pretty amazed
22:21wingyperfect fit for clojure
22:21xeqijust as another data point, clojars uses sqlite3
22:21brehautaugustl: well, SQL has a couple of solid librarys (clojure.something.jdbc, korma (ontop of said)), i understand that mongo is well supported, and the couchdb lib (clutch) is great.
22:22augustlwingy: hmm, why not :)
22:22wingyaugustl: take a look at datomic .. you probably don't want to do mongo et al. afterwards :)
22:23augustlwingy: it seems insane to have all the data in memory :)
22:23wingyyou wont have all the data in the memory (if its big)
22:24augustlmy storage requirements are dead simple though.. Just a few tables and some primary key lookups :)
22:24wingyperfect match :)
22:25augustldatomic you mean?
22:25wingyas far as i understand it it's using storage services (postgresql, mysql, dynamodb etc) as persistent layer .. you don't need to care about how to communicate with these
22:25augustlI'm considering postgres, but since datomic cna store to postgres I can consider datomic a clojure front-end to postgres, heh
22:25wingyjust like these traditional dbs are using the filesystem to persist information
22:25wingyits a layer above
22:26wingyjust the diff that you are able to choose what persistent service to use to save the data of datomic for scalability on read
22:27wingybut i hope they will manage the whole package one day so we don't need to isntall it manually
22:27ToxicFrogWhat would people recommend for parsing a JSON-like (but not actually JSON) language in Clojure?
22:28wingyjust using the datomic peer lib as a lein dep and ready to go
22:28wingyaugustl: then you wont need 3rd party abstraction layers above dbs like we use to need today for some reason
22:29wingyits a new way of interacting with data .. keep it local .. it will persist
22:29brehautToxicFrog: what do you mean?
22:29augustldamn google, queries for datomic turns into atomic
22:29brehautToxicFrog: are you wanting recommendation for parser building libraries, or a specific non-json lib?
22:29ToxicFrogbrehaut: I have input data in a format that resembles JSON. I need to write a parser for it.
22:29ToxicFrogThe former.
22:30ToxicFrogI used LPEG for this in Lua and util.parsing.combinator in Scala; what would you recommend in Clojure?
22:30augustldatomic breaks clojars :) https://clojars.org/search?q=datomic I just get an empty page
22:31brehautToxicFrog: probably not fnparse, because even though its quite nice, its effectively dead; the official version is not 1.3 compatible and hasnt updated in ages (there are 1.3+ forks around though)
22:31wingyit's travelling through time and space .. difficult to lock it in
22:31brehautToxicFrog: there are other parser combinator libraries around but im not familiar enough to talk about them. There is also cgrand's parsley library
22:31brehautToxicFrog: which is its own thing
22:32wingyaugustl: are you new to clj?
22:32augustlwingy: a little
22:35ToxicFrogparsley looks kind of heavyweight and designed for realtime syntax hilighting and the like
22:35brehautyes
22:35ToxicFrogValid parse tree from any input, high-speed incremental reparsing on mutable buffers
22:36brehauti think that specific use case is for building parsers for editors (eg counter clockwise)
22:36ToxicFrogYeah
22:36ToxicFrogA bit heavier than what I'm after
22:36augustlI wonder what most people actually do for data validation, there doesn't seem to be that many libraries for it out there
22:37xeqiaugustl: do you have an example from somewhere else?
22:38augustlxeqi: ActiveRecord in Rails is something I'm already familiar with
22:38augustlclj-record seems similar, but not sure if the active record pattern is a good fit for clojure.. And it seems poorly documented
22:40augustlwingy: datomic does cost money no matter how you use it if you have more than 2 "peers" right?
22:40augustlwhich basically means two in-memory clients?
22:42ToxicFrogOh man, there's a Clojure port of Parsec! Which is missing.
22:43ToxicFrogAnd fnparse is dead and parsley is overkill and that seems to be all that's available. :/
22:47ToxicFrogHmm. There's Parsatron, which has a highly entertaining README and seems to be active
22:49surialI have a pretty weird question, not even sure if it is entirely on topic. I'm holding a talk this weekend: Hello, World! in 10 languages. I'd like to use snippets which are simple yet which let me explain some pretty profound concepts. One of the concepts I want to touch on is conc lists. (like conslists, but where both left and right are subtrees; assuming the tree is balanced, it is highly parallelizable).
22:50surialThe go-to language for this would probably be fortress but I know nothing about it, and can't find much either. I vaguely recall Rich wrote an implementation for clojure. Is that true?
22:50surial(if yes, followup questions would be: Any idea for a nice snippet that shows em in action?)
22:53nDuffOne thing I'm a little unclear about re: the clojurescript REPL -- how do I integrate this into a project running its own server, given as (repl/repl) tries to start its own?
22:57foxdonut,(str \h \i)
22:57clojurebot"hi"
23:01foxdonutclojurebot: CPOR?
23:01clojurebotCPOR is Clojure Programming (O'Reilly): http://www.clojurebook.com
23:02foxdonutcool :)
23:04cmajor7how to memoize the call to "let", in this case "letrem": refheap.com/paste/3455 ? a bit confused on how will memoize recognize the same input to "do-somm"
23:04cmajor7(this is clojurescript calling into the clj server)
23:06ssutchmy first clojure library! https://gist.github.com/3050902
23:07ssutchstring/object signing
23:08ssutchany comments/critique would be greatly appreciated
23:15nDuffjava.lang.ClassCastException: ring.util.servlet.proxy$javax.servlet.http.HttpServlet$0 cannot be cast to javax.servlet.http.HttpServlet
23:18xeqissutch: (.method object) is more common; naming a file fn is asking for confusion; -> and when may be helpful functions
23:18xeqiand why json as the serialization format?
23:19technomancysurial: vectors are tree-based behind the scenes, and the new reducers library lets you easily operate on them in parallel
23:19ssutchxeqi thanks, i'll use .method and rename fn for sure
23:19technomancysurial: there's a good post going into detail on the implementation of them too
23:19ssutchxeqi json because it's simple and works and allows you to encode maps and vectors simply
23:19surialtechnomancy: Right. A link would be fantastic. I can't think of a good way to actually show the effect, somehow, in a snippet of code. I'll have to think about it some more.
23:20cmajor7is there a way to memoize a "defremote" macro?
23:20cmajor7(defremote.. => http://bit.ly/M7evKV)
23:21xeqissutch: theres ##(doc pr-str) and ##(doc read-string) builtin
23:22lazybot(doc pr-str) ⇒ "([& xs]); pr to a string, returning it"
23:22lazybot(doc read-string) ⇒ "([s]); Reads one object from the string s"
23:22clojurebot"([& xs]); pr to a string, returning it"
23:22clojurebot"([s]); Reads one object from the string s"
23:22xeqihmm, that was unexpected
23:22ssutchhaha dueling bots
23:23ssutchdo i do the (doto …) syntax correctly?
23:23ssutch(you can reload, i just updated it
23:24ssutchthe get-csrf-token is not a compete implementation
23:25xeqiyou can use (.initSign ...) in the doto
23:25ssutchremove the space then
23:26nicholasfhi guys
23:26nicholasfI want to look through a good clojure project to gain an idea of namespacing practices, etc. (preferably a leiningen project)
23:26nicholasfI already know about storm - what's another good example?
23:31ssutchxeqi thanks a bunch
23:31FrozenlockCould Clojure run on a raspberry pi?
23:32nDuffFrozenlock: It's been done. You'd get better performance with one of the non-Java implementations, though (ie. ClojureScript)
23:32FrozenlockNice!
23:33FrozenlockAnd if I want to stay on the jvm...? Need more ram?
23:33wingyaugustl: it seems like that
23:33wingyand if it's OS you dont have to pay at all
23:37wingyaugustl: let's use it together
23:37wingyyou and me!
23:42cmajor7is there a way to memoize a macro ?
23:46wingy,(def a 1)
23:46clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
23:47wingywhen running: (def a 1) you get back: #'myapp.core/a
23:47wingyi know that # has to do with the reader (read-string) but not sure how to relate to it in this case
23:49xeqi,(class #'+)
23:49clojurebotclojure.lang.Var
23:50xeqi#' gets the var instead of the value, its useful for long running stuff where the var might change
23:50xeqilike a ring handler
23:54wingyright
23:56ToxicFrogIs the clojurebot meant to say SANBOX instead of SANDBOX?