#clojure logs

2012-04-27

00:02emezeskemefesto: I don't know whether :libs searches recursively; I think you might need to specify files one-by-one
00:02emezeskemefesto: Basically everything I know about that option comes from this blog post: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html
00:02mefestowas reading this and managed to confuse myself even more :) https://groups.google.com/forum/?fromgroups#!searchin/clojure/clojurescript$20third$20party/clojure/96QKwRAkLfU/usQryPg_4d4J
00:05emezeskemefesto: I *think* you're on the right track with using :libs.
00:05mefestoemezeske: necessary to specify the file extension?
00:06emezeskemefesto: I believe so. Not certain, though.
00:06ben_mWhy is :only a list and everything else a vector in :use? e.g. (:use [ring.util.serve :only (serve)])
00:07emezeskeben_m: I'm pretty sure they're interchangeable; I know (:use [ring.util.server :only [serve]]) works, and I'm pretty sure all parens does too
00:07ben_mAh, okay :)
00:08ben_mThanks, that makes sense.
00:08emezeskeI'm not sure which one is preferred, though
00:09technomancyben_m: :only should be a vector
00:09tomojhuh, I always use a list there
00:09ben_mOh, I found it like this in some example code. Will fix.
00:09technomancybecause then it indents correctly if you have to drop to another line
00:10technomancyI mean it'll work either way, but vectors for :use/:require and lists for :import gives you the right indentation
00:10ben_mAh, yeah, that's a good reason.
00:10tomojlike (import (package.name Foo Bar)) ?
00:11tomojstrangely that indents just like a vector for me
00:11Gurragis the statement "closure is similar to lisp" true?
00:11Gurragclojure*, sorry
00:11ben_mGurrag, Clojure is a Lisp.
00:11Gurragoh cool!
00:12Gurragthanks for the info
00:28amalloyTimMc: i can't remember, do you use slime?
00:28amalloycause if so you could use the slime inspector instead of your handy/show
00:52kovasbis there an equivalent of *clojure-version* for clojurescript?
01:21technomancyhuh: http://www.meetup.com/Seattle-Software-Developers/events/62334172/?a=socialmedia
01:22replacatechnomancy: more going on in Seattle than you know about?
01:22ibdknoxtotally not cool
01:23ibdknoxtechnomancy has to approve all clojure things happening in seattle ;)
01:23technomancyreplaca: apparently
01:23technomancythat name sounds familiar; probably from the mailing list
01:24ibdknoxhe's around here sometimes
01:24technomancyibdknox: on irc?
01:24ibdknoxyeah
01:24technomancyhuh, he has a refheap fork
01:24replacaderrida: I don't think so. I asked around for one a while back and none of the usual org-mode suspects seemed to know of one
01:25derridareplaca: yeah, i found nothin
01:26derridawould be nice though :)
01:26replacatechnomancy: Raynes credits him on the refheap github
01:27technomancyI should bug him to attend seajure; what the heck
01:27replacaderrida: agreed. it would give me new ways to procrastinate all the things in my org-mode files :)
01:27technomancybut it's cool that he's presenting to a wider audience
01:27technomancyI tried that once and had a hard time; I just can't put myself back in the shoes of an OO-head
01:27derridareplaca: indeed
01:27hiredmantechnomancy: at least they didn't schedule it for the first thursday
01:27technomancy"it's like... you have these values; see? and they're stable over time."
01:28technomancyhiredman: srsly
01:28hiredmanI am almost tempted to go, to see what kind of turn out there is
01:29technomancyyeah, me too
01:30hiredmanI must know someone who works at the amazon campus
01:30technomancyI don't think you need a friend to sneak you in; you can just rsvp =)
01:31technomancyoh yeah, and they have a zoka down there now
01:31hiredmanhwa
01:31replacait's all about the coffee for you guys, isn't it? :)
01:32hiredman*cough*
01:32technomancyreplaca: I haven't gotten hiredman hooked yet; he's all tea
01:33replacaand they allow him is Sea-Tac. I thought there was some kind of law
01:33replaca*in Sea-Tac?
01:45muhoo&(map #(first %) {:foo 1, :bar 2})
01:45lazybot⇒ (:foo :bar)
01:45muhoo&(map #([(first %) (second %)]) {:foo 1, :bar 2})
01:45lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector
01:45muhoowhy?
01:45clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
01:47muhooaha, reader macro ##(map #(vector (first %) (second %)) {:foo 1, :bar 2})
01:47lazybot⇒ ([:foo 1] [:bar 2])
01:48muhoo&(map #(hash-map (first %) (second %)) {:foo 1, :bar 2})
01:48lazybot⇒ ({:foo 1} {:bar 2})
01:50emezeske&(map #(apply hash-map %) {:foo 1, :bar 2})
01:50lazybot⇒ ({:foo 1} {:bar 2})
01:52muhoothis is fun, but a bit orthogonal to what i set out to do, which is: to map over a map, applying a function to each of the values but leaving the keys the same
01:53muhooi mean (vals ...) sure, but then i lose the keys. i'm missing something fundamental and important.
01:53technomancymuhoo: no, it sucks that the function you want isn't in clojure
01:53technomancy(zipmap (map f1 (keys m)) (map f2 (vals m))) ; is the best you can do
01:54muhooreally? wow.
01:54muhoook, thanks.
01:56muhoohttps://refheap.com/paste/2393 and that'll play
01:57zakwilsonClojure does primative math by default now and doesn't need unchecked-* to be as fast as Java, right?
02:11muhoois the only way to map a macro to do (map #(name-of-macro %) coll) ?
02:12muhooi can live with that, but it seems... hackish
02:14wmealingor you could put the map inside the macro
02:14wmealingif its only going to be mapping
02:14muhooit's not my macro
02:15amalloytechnomancy: ewwww. surely (into {} (for [[k v] m] [(f1 k) (f2 v)])) is better than that zipmap/map/map/keys/vals nonsense
02:16replacaamalloy: I agree. And easy to wrap into a nice func
02:16amalloyand muhoo, if you don't mind depending on useful, you can write it as (into {} (map (knit f1 f2) m)
02:17wmealingoh i see.
02:21amalloyor i suppose you could use useful.map/map-vals, but i kinda prefer the generalized knit
02:26zakwilsonIt's amazing how much flatland.useful looks like my own utilities file.
02:31zakwilsonIs there a way to have leiningen run swank without compiling the project?
03:12TheBusbyany idea how to access the version tag specified in the leiningen project.clj file from code?
03:27muhooamalloy: knit is very cool, thanks
04:10ktsujiTheBusby: for my own class, it was (System/getProperty "myclass.version").
04:11TheBusbyktsuji: thanks, it looks like if Leiningen was writing the "Implementation-Version:" value in the META-INF/MANIFEST.MF file it generates for jars then it could be extracted via .getPackage.getImplementationVersion()
04:12TheBusbyunfortunately no such luck it seems, maybe a good patch for leiningen?
04:15kralnamaste
04:17wmealingClojure Programming is more expensive through oreilly pdf than it is on amazon kindle.
04:17wmealingthats.. not what i expected.
04:17ktsujiit seems like you can specify arbitrary key/value pars for manifest :manifest {"Project-awesome-level" "super-great"}
04:17ktsujiTheBusby: https://github.com/technomancy/leiningen/blob/master/sample.project.clj, but that will be duplicate input so as you mentioned,
04:18ktsujiTheBusby: it might be great if it is done by leiningen.
04:22TheBusbyktsuji: yep, since version is already defined earlier in the project it would be nice to have it Implementation-Version default to that if possible
04:56AWizzArdJava 7 Update 4 is now available, and it includes JavaFX 2.1 and the GC1 (:
06:12dxlr8rI don't know how to explain this. but I'll try. I try to learn clojure, so I do things to complex for a reason (to learn).
06:14dxlr8rhttp://pastebin.com/QAtfAmh8
06:15dxlr8rand get the error at line 11
06:16dxlr8rbut If I paste and replace ":authors2 [:id "integer primary key"]" with "data" on line 9 it works
06:16clgvdxlr8r: your 'intern looks wrong if you only want to use an api
06:17dxlr8rI have tried to replace it with a regular call to. same thing
06:17dxlr8rlike:
06:17dxlr8r(create-table data))
06:17dxlr8rsame thing
06:18dxlr8rI have: (:use [clojure.java.jdbc :only (with-connection create-table)] in the ns to
06:18clgvdid you try a simple tutorial example first to avoid environment pitfalls?
06:18dxlr8ryeah
06:18dxlr8rI'll stupify it
06:18dxlr8rwait
06:19clgvdid it work?
06:20dxlr8rhttp://pastebin.com/cHg3T2S4
06:20dxlr8rsame thing
06:20dxlr8rtried that to
06:20muhooas lovely as clojure and noir is, there just doesn't seem to be a hard floor on how much suck can be removed from html forms
06:21muhoomistyped, there does in fact seem to be one. the suck remains.
06:21dxlr8rif I replace "data" on line 13 with: ":authors2 [:id "integer primary key"]"., it works
06:22dxlr8rso it doesn't seem like I can pass stuff to it :/ which is a shame
06:23dxlr8r(class data) => clojure.lang.ArraySeq
06:26dxlr8rclgv: ? you know :)
06:29dxlr8rhmm. I applied apply, works now :P
06:29clgvdxlr8r: did you check the documentation: http://clojure.github.com/java.jdbc/#clojure.java.jdbc/create-table ?
06:29dxlr8rI have been reading the source code, but it seemed to work with apply
06:31dxlr8rbut this line: (intern 'clojure.java.jdbc (symbol action)) , did you have anything to say there?
06:31clgvdxlr8r: it's rubish. dont use intern.
06:31dxlr8rhow else should I do it?
06:31dxlr8rhow else can I do: (dbdo "create-table" :authors3 [:id "integer primary key"])
06:32clgvif you want to call the static method 'action in that clas just write: (clojure.java.jdbc/action ...)
06:32dxlr8rthe "create-table" part. it could be anything
06:32clgvlol wait
06:32clgvjust put 'action into the :only list
06:34dxlr8rok?
06:34clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
06:34dxlr8r(:use [clojure.java.jdbc :only ('action)] )
06:34clgvwithout the quote
06:35clgv and you probably need the other functions you are using in there as well
06:36dxlr8rI want to do:
06:36dxlr8r(dbdo "create-table" :authors3 [:id "integer primary key"])
06:36dxlr8ror
06:36dxlr8r(dbdo "insert-records" :authors3 {:first_name "Simen"})
06:37clgvwhy?
06:37clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
06:38clgvthere is the 'with-connection macro for that use case
06:38dxlr8rI want to be able to call dbdo from other files
06:38dxlr8rI'll look into
06:40clgvdxlr8r: you should want to encapsulate the low level api and not to distribute database statement in all other namespaces ;)
06:40dxlr8rI want that function and the file to do all the db stuff. to speak with the jdbc and so on… all I want to is to include the dbdo file and call the dbdo function with what I want to do
06:43clgvdxlr8r: you wont reach it if you let other namespaces call (dodb "create" ..) or (dodb "update" ...) ...
06:43dxlr8rit already works in other namespaces with "intern"
06:43dxlr8r(ns no.ifixit.telephonebook.index
06:43dxlr8r (:use [no.ifixit.telephonebook.db]))
06:44dxlr8rthen I can call dbdo with whatever I want to do on the db
06:44dxlr8rwithout haveing to care for anything else
06:44clgvif you are programming a usual clojure app you should not use intern.
06:46dxlr8rthen what should I use?
06:47dxlr8ryou understand what I want to do? I want a generic function that other namespaces can call to do stuff with the database, without them needing to know anything about databases
06:47clgvsimply call the function after you :use or :require the namespace
06:48dxlr8rI want the other namespaces to decide what function they want to call
06:49clgvclojure has first-class functions. you can simply pass a function as parameter to another function
06:50dxlr8rhow would I do that?
06:50dxlr8rsorry
06:50dxlr8rgot it :P
06:50dxlr8r(dbdo create-table :authors4 [:id "integer primary key"])
06:50clgvyou shoud read some introductory material
06:51dxlr8rno quotes, no apostrophes, no nothing
06:51dxlr8rI actually have read 50-60 pages
06:51dxlr8rfrom the clojure book
06:52dxlr8rthen never spoke about sending functions as parameters, but that is really nice :)
06:54clgvwhich clojure book? the wikibook?
06:55dxlr8r"Practical Lisp for The Java World"
06:56dxlr8rand when I try:
06:56dxlr8r(dbdo create-table :authors4 [:id "integer primary key"])
06:56dxlr8rfrom another ns it doesn't work :(
06:56dxlr8rIllegalStateException Attempting to call unbound fn
06:56clgvlook at the files and lines in the stacktrace to find out where it happened
06:57dxlr8rI know what's going on. it tells me that I can't do that :P
06:57dxlr8rIllegalStateException Attempting to call unbound fn: #'no.ifixit.telephonebook.index/create-table clojure.lang.Var$Unbound.throwArity (Var.java:43)
06:57clgvthe book is "Clojure Programming"?
06:58clgvpost another paste of the complete file
06:59dxlr8rhttp://pastebin.com/5wcvPUeR
07:00dxlr8rand yeah, that's the title :)
07:00dxlr8rread "Down the rabbit hole"
07:00clgvcan you restart your repl?
07:01clgvprobably the results of your strange 'intern code are still present
07:02dxlr8rI'll try
07:03dxlr8rCompilerException java.lang.RuntimeException: Unable to resolve symbol: create-table in this context, compiling:(NO_SOURCE_PATH:1)
07:22dxlr8rcan I (ns) use several other namespaces?
07:22dxlr8r:use
07:32dxlr8ror several refers?
07:37madsydxlr8r: Only one can be current, but you can refer to many namespaces.
07:38dxlr8rok? how can I refer to many namespaces?
07:52joegallodxl8r: http://clojuredocs.org/clojure_core/clojure.core/ns see the two last examples near the bottom.
07:52clgv dxlr8r: yes, you can declare multiple :refer and :use statements in the 'ns form
07:52joegallodxlr8r: ^ (sorry for the typeo)
07:53dxlr8ryeah, thanks, I actully found it out by myself. I actually am starting to learn this. I guess my brain is starting to get into clojure mode from java mode
07:55madsySo I'm trying to reason about how Clojure does evaluation. First it transforms the text as according to the (static) reader rules, then macro expansion, and then evaluation?
07:55clgvdxlr8r: try to read some more chapters of the book ;)
07:55dxlr8rit's so boring! programming is far more fun
07:55dxlr8rI read for 3 days :P
07:56Chousukemadsy: hm, not quite
07:56madsyI'm unsure at which point clojure stops compiling data to code, if ever
07:57ChousukeI'm not quite sure how things work with AOT compilation, but mh
07:58dxlr8rI actually read about AOT in the book. so atleast it's there if you have that book
07:58Chousukebasically macro expansion is part of the evaluation step and evaluation happens line-by-line
07:59madsyChousuke: Yeah, so it keeps macroexpanding and evaluating ad-finitum until there is nothing more to macroexpand and compile then
07:59Chousukeclojure reads a single form, macroexpands, compiles the result, and then runs the compiled code
08:00Chousukethe line between evaluation and macroexpansion is a bit hazy because macros can do whatever they want, but it happens before the final evaluation of the form that is being macroexpanded.
08:01madsyI'm still a bit confused why printing a compiled function doesn't give me its form though
08:02Chousukethat's because it's just a java object, and it doesn't store its source form anywhere
08:02Chousukeafter the function is compiled it only exists as jvm bytecode
08:02madsyOkay, so in order to do that, I would need to store it myself by using quote.
08:04ChousukeIIRC clojure creates a class for each function, and then instances of that class for each closure (if there are any)
08:05madsyMakes sense. Thank you.
08:05Chousukeyou can probably understand it better if you just go read the cljs compiler or something :)
08:06Chousukeor the clojure-jvm compiler if you like reading Java
08:06madsyMaybe I'll be that bold later :)
08:06Chousukeit's not too complicated.
08:06madsyI guess not. I've picked up Clojure miles faster than Common Lisp.
08:07Chousukeheh
08:07ChousukeI think Clojure is easier to learn than CL, yes
08:07madsyThe language seems much easier and compact
08:08madsyRead about CL's eval-when and your head explodes
08:08Chousukefunctional programming is a bit of a mindbender at first but precisely because Clojure is opinionated it's easier to get started
08:08Chousukeit's not a bag of possibilities with no clear indicator of what is good and what is not like CL
08:12Chousukeoh, and I really like Clojure having useful evaluation semantics for vectors and maps
09:01fliebelAre there any successful Clojure freelancers in Europe? (and how did you get into that?) I'm a freelancer, but I haven't had any Clojure projects so far.
09:05dxlr8rI am :P and I am a noob. but the firm that hired me has one dude that is clojure guru, and I am willing to learn
09:08Licenserdxlr8r you have your tongue hanging out?
09:08dxlr8ryeah, I am a labrador
09:09Licensercool can you make a picture of your tail - I need that icon for a project of mine *runs for cover*
09:10clgvdxlr8r: which company?
09:11dxlr8rLicenser: :)
09:12dxlr8rclgv: small stuff. some sellsmen, two clojure programmerings (incl.) me and one php guy that is going over to clojure soon to
09:12dxlr8rwe make a website
09:13clgvwhich country?
09:13dxlr8rthe main clojure guy has made the webside in clojure, he has even made a long polling api
09:13dxlr8rwe are named feelgood
09:13fliebeldxlr8r: norway?
09:14dxlr8ryeah
09:17TimMcamalloy_: No, I don't use SLIME yet. But I have some ideas for my show fn -- filtering on return type, method name...
09:18dxlr8rfliebel / clgv: happy :P
10:10dxlr8r(str "1" "\n" "2")
10:10dxlr8rI want a new line there, doesn't work
10:11joegallodoesn't work how?
10:11joegallo,(str "1" "\n" "2")
10:11clojurebot"1\n2"
10:11dxlr8r,(char-escape-string \newline)
10:11clojurebot"\\n"
10:12joegallo,(println (str "1" "\n" "2"))
10:12clojurebot1
10:12clojurebot2
10:12dxlr8rI want it to return it
10:12dxlr8rnot print it
10:12joegalloi don't follow...
10:12joegallothe newline *is* there
10:13dxlr8rI see
10:13dxlr8rit does work then, hehe
10:13joegallothe repl is showing it inside the string -- it won't show as an actual newline (multiple lines printed at the repl) unless you actually println
10:13joegallo(str "\"" "\t" "\n")
10:14joegallo,(str "\"" "\t" "\n")
10:14clojurebot"\"\t\n"
10:14joegallowhich is how it appears to behave for specials characters inside strings generally.
10:15dxlr8rok :) nice to know
10:16joegalloyeah, that's something that still surprises me from time to time. i'm sure there's a very logical explanation for why it's that way, i just don't happen to know it. :)
10:17dxlr8rcan you have constructors in conjure? like (defn x [a b] (x a b 1)) (defn x [a b c] (+ a b c))
10:18fdaouddxlr8r: yes, (defn x ([a b] (x a b 1)) ([a b c] (+ a b c)))
10:19dxlr8rahhh
10:19dxlr8rnice
10:22TimMc&[\a \b \u0000 \c \d]
10:22lazybot⇒ [\a \b \
10:23TimMc^ Does anyone else see lazybot's response stop at the NUL byte?
10:23stuartsierrayes
10:23halgariditto
10:23TimMcWasn't sure if it was my client.
10:23TimMcCould be the IRC server, too.
10:24TimMcWorks fine in my REPL... sort of: [\a \b \ \c \d]
10:25clgv,[\a \b \u0000 \c \d]
10:25clojurebot[\a \b \
10:25fliebelclgv: Whats \u0000?
10:25TimMc&"ab\u0000cd"
10:25lazybot⇒ "ab
10:25TimMcfliebel: NUL byte.
10:26clgv,(pr-str [\a \b \u0000 \c \d])
10:26clojurebot"[\\a \\b \\
10:26clgvuuh
10:26ben_mThis kills the bot.
10:26TimMcMesses up a lot of C programs, which often use NUL-terminated strings.
10:27TimMc&(map char (range 5)) ;; this is how I ran across it
10:27lazybot⇒ (\
10:27fliebelIs it my client that does not display anything after the nul, or is it the bot?
10:27mefestoI'm trying to (:require [goog.net :as net]) in ClojureScript but getting an error: 'required "goog.net" namespace never provided'. A quick scan of goog.jar seems to include this namespace. Am I requiring this incorrectly?
10:27mefestoother requires work fine
10:27TimMcfliebel: Not sure how to determine that.
10:28TimMc,"ab\u0000cd"
10:28clojurebot"ab
10:30fliebelTimMc: Send a real nul byte to lazybot?
10:30fliebel&(println ",'ab\u0000bc")
10:31lazybot⇒ ,'ab
10:31fliebel,(println "&'ab\u0000bc")
10:31clojurebot&'ab
10:31lazybot⇒ ab
10:33TimMcclever
10:34TimMc,(println "&(last \"ab\u0000bc\")")
10:34clojurebot&(last "ab
10:34lazybotjava.lang.RuntimeException: EOF while reading string
10:35TimMc&(map char (range 1 32))
10:35lazybot⇒ (\ \ \ \ \ \ \backspace \tab \newline \ \formfeed \return \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)
10:35TimMcErr, I hope that didn't BEL anyone.
10:36Fossihaha
10:37Fossithat's so ancient :)
10:37Fossiat least my client didn't vertical tab :)
10:37Fossidon't know why actually
10:54mefestoah this person set me straight on my goog.net worries: http://sunng.info/blog/2011/08/using-google-closure-library-with-clojurescript/
10:57Hali_303hi! why is (set? (keys mapinstance)) false?
10:58joly,(class (keys {:a 1 :b 2}))
10:58halgarikeys is a seqence, not a set
10:58clojurebotclojure.lang.APersistentMap$KeySeq
10:58mefesto,(doc keys)
10:58clojurebot"([map]); Returns a sequence of the map's keys."
10:58joly,(seq? (keys {:a 1}))
10:58clojurebottrue
10:59halgari@Hali_303 Part of the reason for this is that if you have 1000 keys in a map, it's a bit wasteful to copy all those into a new structure. Instead it's much faster to simply iterate over each key and return one at a time
10:59halgarilazy seqs ftw!
11:00Vinzenthalgari, there is no copying in clojure actually
11:01VinzentHali_303, it returns ordered seq so you can e.g. (zipmap (keys m) (vals m))
11:01halgari@Vinzent...copy is a poor choice of words...to create a set you'd have to grab all 1000 keys, and then put them into a set. Yes you're right, no copying, but still, slower than using a lazy seq
11:04Hali_303I see
11:04Hali_303thanks, good to know
11:05TimMcHali_303: There's another reason, actually.
11:05TimMcSets are not ordered, and it is useful for (keys m) and (vals m) to be in the same order as each other.
11:06TimMc&(type (keys {:a 1}))
11:06lazybot⇒ clojure.lang.APersistentMap$KeySeq
11:10Vinzenthalgari, hmm, but items can be added to set on assoc in the same way as they're added to seq?
11:10VinzentTimMc, that's actually exactly the reason I had in mind :)
11:11TimMcVinzent: Oops, didn't see your msg. Your nick is the same color and length as halgari's in my client.
11:13mefestois there a page that documents ClojureScript's notation for getting/setting js properties? i've just been finding things on random blogs -- most of which are out-dated since they don't use the new (.-prop obj) style
11:13Vinzentah, ok
11:14Vinzentmefesto, there is cljs cheatsheet
11:15mefestoVinzent: just found the one by fogus. i'm assuming that's the same one you are talking about?
11:16mefestoVinzent: thanks
11:16halgari@Vinzent, I'm not sure I understand, about assoc and seqs
11:17mefestohere's the link for anyone else (pdf): https://github.com/fogus/clojure-cheatsheets/blob/master/pdf/cljs-cheatsheet.pdf?raw=true
11:17halgari@Vinzent, the performance hit is that assoc on a set requires several hash compares, and copying parts of a set tree. doing cons on a seq is just a single allocation. Therefore it's much faster to return a seq from keys
11:17Vinzentmefesto, yeah this is it
11:20Vinzenthalgari, yes, but when assoc'ing to a map these hash compares have to be done anyway, so I think it'd be done effectively if that was a purpose
11:32neotykemacs question: how can I batch exporting of org file to html?
11:34bradwrightneotyk: you probably want #emacs for that
11:35neotykbradwright: true, or even orgmode
11:35bradwrightOr that :)
11:36neotykbut it doesn't hurt to ask best channel on intertubes ;-)
11:39smeltzekWhen using Emacs+swank/slime, is there a way to avoid having to call (use somenamespace) whenever I reload the file? I use C-c C-l, and old definitions are updated fine, etc. but new functions are not visible until I call (use) again
11:41Vinzentsmeltzek, I'm not sure what you're talking about, I'm using C-c C-k (bound to C-s) to save and compile the whole buffer and it works fine for all changes
11:42smeltzekvinzent, even if you write a new toy function you can immediately resolve the symbol in a REPL upon compiling it?
11:42raeksmeltzek: I usually try out the functions from within the namespace they are defined in
11:42Vinzentsmeltzek, if I have REPL in the same namespace - yes
11:43raeksmeltzek: press C-c M-p to change the repl namespace to match the current buffer
11:44Vinzentit's also handy to bind (fset 'to-repl-in-ns [?\C-c ?\M-p return ?\C-c ?\C-z]) this to some key
11:44smeltzekAh, thanks. My problem is that I wasn't adjusting the namespace of the REPL, just manually calling (use whatever). Using C-c M-p gets things working as expected
12:05dnolena good read - Clojure's IFn vs. Python's call http://clojure-py.blogspot.com/2012/04/ifn-vs-call.html
12:08dnolenraph_amiard: ^ definitely something to keep in mind when doing the Lua stuff.
12:14alexyakushevDidn't quite get this one: "So this is why Clojure-JVM never allows direct invocation of static methods."
12:15alexyakushevIs it about something different from ,(Integer/parseInt "42") ?
12:15hiredmanalexyakushev: I dunno, I have generally found the clojure-py blog to be a bad source of information
12:16hiredmanreally he should be able to at compile time figure out if the symbol at the start of a list refers to a python function or not
12:17hiredmanalexyakushev: I believe he means something like "so this is why clojure doesn't treat static methods as functions"
12:18hiredmanbut the real issue there is usage as values
12:18alexyakushevhiredman: Thank you. I got it now.
12:20alexyakushevCould anyone please tell how to add an external dependency (like :extra-classpath-dirs) in Leiningen 2.0.0? The previous method doesn't seem to work.
12:22nDuffcemerick: wrapping a new, empty URLClassloader around the OSGI classloader before calling (swank/start-server). Ugly bit is that the OSGI classloader can't be imported directly due to the sandbox, so I'm looking at its name to detect it.
12:22technomancyalexyakushev: the only good way to get jars on the classpath is to declare them as dependencies
12:23cemericknDuff: sounds like it's solidly in the realm of "gonna break real soon now" ;-)
12:24alexyakushevtechnomancy: could I specify a local jar in the dependencies or it should be only something on the Clojars/Maven/etc?
12:25technomancyit should be something in ~/.m2
12:25technomancythere are ways to do it without getting it in m2, but not good ways
12:27alexyakushevtechnomancy: I need to get the Android SDK libs on the classpath. Does it mean I should search for a Maven repo with android jars?
12:27technomancyalexyakushev: that would be best, yeah
12:29halgari1@alexyakushev what I mean by "direct invocation of a static method" means that you can't do something like this in Clojure-JVM (let [x (.-toHextString Integer)])
12:32muhooare defs's thread-specific[D[D[D[D[D?
12:32muhoosorry are def's thread-specific?
12:32alexyakushevtechnomancy: I'm working on a leiningen android plugin and I don't feel very well about making the user to download all the necessary libs again (and for different Android versions). Could you please at least give a hint on these "not very good ways" so I had something to play around for a starter?
12:33technomancyalexyakushev: sure; I understand the situation with android is different from most libraries. your best bet might be to call add-hook on leiningen.core.classpath/get-classpath to make it return the extra entries you need.
12:35alexyakushevtechnomancy: that's another story, thank you!
12:35technomancyalexyakushev: sorry I missed your /msgs earlier; I'm on an IRC bouncer that is not the most reliable
12:39alexyakushevtechnomancy: No problem. I use a web client since my router doesn't let any IRC connections, so I'm never sure if my messages come through:)
12:42raekmuhoo: values bound using 'binding' are local to the thread which executed the 'binding' (and are mutable)
12:43raekthe root binding is the same in all threads (and should normally not change)
12:43gtuckerkellogganyone here use clojure-test-mode and midje-mode side by side?
12:44alexyakushevhalgari1: yes, thank you, hiredman has already explained that to me.
12:45muhooraek: thanks, that explains what i was seeing
12:45nDuffcemerick: sadly so. I'd have hoped that Spring DM's classloaders would be implementing an interface from the org.osgi namespace, to at least provide cross-vendor detection, but no such luck.
12:48dnolenthis'll be fun https://gist.github.com/2510566
12:49devncemerick: I'm logged in on Clojure Atlas but I don't see the
12:49devncemerick: "Your Atlas" link that used to be there
12:49cemerickdevn: are your prior purchases listed on the "Your account" page?
12:50devnhow do I get to that? :)
12:50technomancyalexyakushev: it may be that you can use :dependencies of :type "provided" for something like the android libs; support for this was recently added to Leiningen, but I am not sure of the details
12:50cemerickdevn: if you're logged in, it's the fourth link from the left in the top bar.
12:50technomancyor maybe :scope "provided"?
12:50technomancycemerick: would that be appropriate?
12:51devncemerick: I'm logged in but I don't see that link.
12:51mefestodnolen: is that clojurescript -> lua ?
12:52devncemerick: https://skitch.com/thinkslate/8scmc/clojure-atlas-an-experimental-visualization-of-the-clojure-language-and-its-standard-library
12:52alexyakushevtechnomancy: There is a :scope kw in the sample.project.clj but according to grep it is used only in pom.clj
12:53technomancyalexyakushev: it may be used by the pomegranate lib
12:53mefestoin cljs, does :libs ["closure/library/third_party/closure"] work? i keep reading varying things online. some say it works, others say they had to build a custom goog.jar that included those things.
12:53cemerickdevn: oh, I'll bet Google is sending a different OpenId for your login. ~10 others have had this problem too. /msg me your email addy.
12:54mefestoi just want goog.dom.query :)
12:57alexyakushevtechnomancy: then I'll take a look at pomegranate. Is it by the way more tolerant to non-repo dependencies? Because from what I see on the github page it is targeted at Maven as well
12:57technomancyalexyakushev: from what I understand :scope "provided" is a way of saying "it should exist on my machine" for things that might come with the JDK
12:58technomancyit's more of a maven thing than a pomegranate thing I believe
12:58technomancybut I haven't used it myself, sorry
12:59dnolenmefesto: looks like it
13:00cemericktechnomancy, alexyakushev: yes, :scope "provided" should work.
13:00alexyakushevtechnomancy: oh, since we are talking about the provided dependencies I remembered another issue. I was trying to run the swank-cdt thing but that requires having JDK's tools.jar on the classpath. Do I have to use pomegranate for it too?
13:01alexyakushevcemerick: thanks! Could you please tell how to specify where this "provided" libs should be?
13:02cemerickalexyakushev: where?
13:02technomancyalexyakushev: actually tools.jar might be another good use of :scope provided
13:02technomancyI guess I should read up on this =)
13:02cemericklike, how to specify one? [com.foo/bar "1.0.0" :scope "provided"], if memory serves
13:02technomancycemerick: don't you have to give it a path though?
13:03cemerickhrm, perhaps I need to re-read the question :-P
13:03alexyakushevcemerick: I mean where do I specify where are the libs located (the folder)?
13:04cemerickoh, you're talking about system scope. I'm pretty sure pomegranate doesn't support that.
13:04cemerickalexyakushev: what are you trying to accomplish?
13:05cemerick(sorry, I had killed my log)
13:05alexyakushevcemerick: put Android jars on the classpath
13:05technomancycemerick: or tools.jar
13:05cemerickand they're not in central or elsewhere?
13:07technomancyin most cases with jars that aren't in central I tell people to file a bug with the project, but I have a feeling Google will just tell you to piss off
13:07alexyakushevOr perhaps, adding a hook is the best option. This would let the user specify the root path to Android SDK and the desired version and the hook will automatically generate the path to an actual files
13:08technomancythat's what they told me when I filed a bug report about their ant tasks giving the wrong error message when there was a 32/62-bit mismatch =(
13:08alexyakushevAnyway thank you both! I very appreciate your help.
13:08cemericktechnomancy: I'm pretty sure aether doesn't even implement system scope. Maven's configuration involves a <systemPath>, but aether's object model has no analogue. http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
13:09technomancycemerick: hm; so no dice on tools.jar either then
13:09technomancycrappé
13:09cemerickI'll bet mvn handles such things directly, since such "dependencies" are really just classpath entires, not Dependencies (tm)
13:09cemericker, ™
13:10cemerickLein could quite easily pull :scope "system" deps out of the map (or maybe we can offer a :path "~/evil/path.jar" option and not abuse :scope like mvn seems to)
13:10cemerick…and add that path to the classpath returned from get-classpath, etc.
13:11technomancyyeah, that might be the way to do it
13:11technomancywhat exactly does :provided mean then?
13:11technomancyif it's in the JDK, why declare it?
13:13dnolennice post from raph_amiard http://raphamiard.posterous.com/gsoc-2012-pluggable-backend-infrastructure-an
13:15cemericktechnomancy: provided is the same as the default "compile", but the dep (and its transitive deps) shouldn't be added to uberjars, etc.
13:15cemerickmmm, and it's not transitive itself
13:16cemericktechnomancy: meditation on the definitions in http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html is warranted :-P
13:16jweissidiomatic clojure way to "split a list at the first item that's in an even index (zero based) that is not a keyword"?
13:18mdeboardtake-while?
13:18mdeboarder, split-by
13:19jweissmdeboard: how does the predicate know what the index is?
13:19jweissi guess i'd have to employ an indexed list or somethig
13:19mdeboardMaybe like (split-by #(and (even? (get % coll)) (not (keyword? %))))
13:19jweissi think that was in contrib someplace
13:19mdeboardthat's untested btw
13:19mefestodnolen: woah, scripting native libs using clojurescript via lua backend... wild :)
13:19mdeboardI might also be getting `get` backward
13:20mdeboardlike, it looks up based on index, I can't renember
13:20jweissmdeboard: yeah that looks close enough, thanks :)
13:21mefestois crate top-of-the-food-chain when it comes to client-side templates in clojurescript? soy used by anyone?
13:21halgari1dnolan: from what I understand we'll still have to use Java to compile ClojureLua to Lua?
13:28dnolenhalgari1: Until somebody actually bootstraps the compiler infrastructure, I don't see that changing anytime soon.
13:32goodieboyif i deref a delay object from 2 threads at the "same time", will the thread that derefs last be blocked until the delay value is delivered?
13:49jweiss,(into {} [1 2])
13:49clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
13:49jweisshm, apparently i forgot how into works... weird.
13:49jweissi could have sworn that used to work
13:50Bronsa, (into {} [[1 2]])
13:50clojurebot{1 2}
13:51jweissi thought you could use 'into' to make maps without pairing the k/v first?
13:51Bronsajweiss: you can use hash-map for that
13:51Bronsa,(apply hash-map [1 2])
13:51clojurebot{1 2}
13:51raek,(conj {} [1 2])
13:51clojurebot{1 2}
13:52nDuffgoodieboy: easy enough to test from the repl
13:52goodieboynDuff: true, just found out for myself :)
13:54y3diwhats the time complexity of inserting into a vector
13:54raeky3di: O(log_32 n)
13:55gf3raek: Really?
13:55y3di32?
13:56mefestowho needs goog.dom.query...
13:58raeky3di: gf3: if you have a vector with 1 000 000 000 elements, then an update operation is 6 steps
13:59nDuffy3di: IIRC, Phil Bagwell's talk went into that at the conj last year
13:59nDuffy3di: http://blip.tv/clojure/phill-bagwell-striving-to-make-things-simple-and-fast-5936145
14:01nDuffy3di: ...again IIRC, worst-case given the maximum size possible is something like 6 or 7 hops, making it close enough to O(1) to not matter much.
14:02nDuff("amortized constant time")
14:03nDuff...wait, that's lookups.
14:04nDuffappending is (32/5)lgN
14:05raeknDuff: why 32/5?
14:07nDuffraek: section 3.2 of Bagwell's paper on RRB trees.
14:14nDuffWhat's convention for managing namespaces when forking someone else's code?
14:15nDuffIf I'm creating my own fork of org.clojars.rabbitmq, should I be renaming it to net.dyfis.rabbitmq?
14:16mefestonDuff: if you plan on contributing back you should keep the same style as the original project
14:16technomancyrule 1 is to not do it if at all possible
14:16nDuffmefesto: the original project seems pretty dead
14:16technomancynDuff: more common is to use org.clojars.$YOUR_CLOJARS_USERNAME
14:16nDuffahh.
14:17mefestonDuff: have you looked for other libs that might do what you want? *cough* wabbitmq :)
14:17nDuff...hmm, hadn't heard of that one. *looks*
14:17nDuffmefesto: nice, thanks!
14:17technomancyyeah, and if that doesn't cover it, there are five other rabbitmq wrappers you could try
14:19mefestobeen meaning to re-write that readme :-\
14:25nDuff...hmm. Ought to be a better way to plug in encoding/decoding mechanisms; seems silly to have the unconditional json dependency.
14:26mefestonDuff: yeah you can plugin your own those just happen to be included
14:26mefestowhich i was wanting to break out into another project
14:26mefestosorry, was thinking about another project :)
14:31nDuff...hmm; leiningen supports flagging dependencies as optional; might make sense to just go that route (and move the json bits into their own namespace, only usable if that optional dep is brought in).
14:32nDuffmefesto: ...moving namespaces around would be an interface change, but we're pre-1.0... so what would your thoughts be on accepting such a patch?
14:32jlongsterdnolen: where do I filed bugs for clojurescript?
14:32jlongster*file
14:33mefestonDuff: works for me. i was thinking about redoing the namespaces anyway to follow what seems to be the convention: wabbitmq.core, wabbitmq.content, etc...
14:34mefestoor wabbitmq.json ... whatever sounds good
14:36dnolenjlongster: http://dev.clojure.org/jira/browse/CLJS
14:39jlongsterdnolen: thanks
14:40dnolenjlongster: np
14:41timvisher&(isa? java.util.Map {})
14:41lazybot⇒ false
14:41timvisheranyone care to explain? ;)
14:42timvisher&(isa? clojure.lang.IPersistentMap {})
14:42lazybot⇒ false
14:42raektimvisher: both arguments need to be classes
14:42raek&(isa? java.util.Map (class {}))
14:42lazybot⇒ false
14:42timvisher&(isa? clojure.lang.IPersistentMap (class {}))
14:42lazybot⇒ false
14:42stuartsierra&(instance? java.util.Map {})
14:42lazybot⇒ true
14:43timvisheroh boy
14:43timvishernow my mind's really blown... :)
14:43raek(isa? (class {}) java.util.Map)
14:43raek,(isa? (class {}) java.util.Map)
14:43clojurebottrue
14:43technomancyyou want instance? rather than isa?
14:43timvisherok... off to read the docs i suppose. :)
14:44stuartsierra`isa?` checks child-parent relationships in a user-defined hierarchy, optionally including Java types.
14:45stuartsierra`instance?` is more or less equivalent to Java's `instanceof` operator.
14:45technomancyisa? is not about "Is X a Y", which is confusing.
14:45timvishertechnomancy: definitely was my assumption
14:45stuartsierrayes
14:46timvishergiven the preponderance of `is a` vs `has a` relationship discussions in OO land
14:46dnolenstuartsierra: any thoughts on when the next CLJS release will go out?
14:46stuartsierradnolen: you want one/
14:46stuartsierra?
14:46technomancyalso the arg ordering is confusing; you nearly always want instance? anyway
14:46dnolenstuartsierra: actually ... not quite yet. we need to re-precate ObjMap first.
14:47stuartsierradnolen: ok
14:47fliebeldnolen: reprecated? ObjMap?
14:47mefestoi've been having trouble using :libs ["closure/library/third_party/closure"] ... is it me or a known thing?
14:47technomancyso apparently lua doesn't have immutable data types. that's worrisome. =\
14:47mefestoi've read that some people were creating their own goog.jar to get around it
14:48dnolenfliebel: we deprecated ObjMap a bit too eagerly when PHMs went out.
14:48stuartsierramefesto: I've been thinking of making a goog-third-party JAR. Just haven't had time.
14:48ibdknoxmy goog-jar includes the third party extensions
14:49mefestostuartsierra: whenever the next cljs release is, would it include that?
14:49pandeirotechnomancy: i was reading your article and kept wondering 'what about JS? (no immutable data types right?)'
14:49stuartsierramefesto: probably not, but you could add it as an extra dependency.
14:49technomancypandeiro: JS has immutable strings
14:50pandeiroah yeah
14:50technomancyIIUC cljs has to do some translation between clojure lists and js objects anyway
14:51technomancythough admittedly I haven't looked at it closely
14:52pbostrom_mefesto: what ended up working for me was :libs ["goog/dom/query.js"]
14:54mefestopbostrom_: this works with a fresh clojurescript clone? (i.e. no customized jars)
14:54stuartsierraIf somebody can send me a goog-third-party JAR with a POM file like the one we made for goog-closure, I can release it to central repositories.
14:55timvisheri have a defrecord form in my core namespace that i can access at the repl after `use`ing that namespace but my tests can't see it. they can see functions defined by that namespace though just fine
14:56timvisherneither clojure-test-mode or `lein-test` seem to be able to find it
14:56timvishereveryone reports that they can't resolve the classname
14:56S11001001timvisher: what are you using the classname for?
14:57timvisherto create a new instance of that record as per http://clojuredocs.org/clojure_core/clojure.core/defrecord
14:57S11001001use the ->blah or map->blah functions it made for you instead
14:58pbostrom_mefesto: I'm trying to remember how I set it up, it's been a while, let me take a look
14:59mefestopbostrom_: hmm i added that to my lein-cljsbuild config and restarted lein cljsbuild auto but no go
15:00mefesto(:require [goog.dom :as dom]) followed by (.log js/console (str "query? " dom/query))
15:01BorkdudeI would like to iterate recursively over a map and use destructuring
15:01Borkdudecan I write smith like [[k v] & rkeyvals] to get the first key-value pair from the map?
15:01timvisherS11001001: i don't see any methods like that reported by .getMethods
15:02raekBorkdude: sure. you can also use map, for, doseq, and reduce if any of those functions "threads" the data in the rigth way
15:02pbostrom_(:require [goog.dom.query :as gquery])
15:03S11001001timvisher: they're functions
15:03Borkduderaek: what's wrong here? http://cljbin.com/paste/4f9aeb74e4b0ee8eed133fc2
15:03pbostrom_mefesto: ^
15:03raekif you can express the map processing as operations on sequences of pairs, then you can use the usual sequence functions
15:04mefestopbostrom_: oh, thanks :)
15:04timvisherS11001001: hmm. forgive me but i'm completely lost
15:04timvisher:)
15:05raekhmm
15:06Borkduderaek: maybe I have to pass it explicitly as a seq?
15:06mefestopbostrom_: ok i think i got it now thanks!
15:06raekBorkdude: ok, it looks like you can't destructure maps as sequences directly...
15:06Borkduderaek: so (seq decimal-roman)
15:07raekBorkdude: yeah, I tried that in my repl and it worked
15:07mefestopbostrom_: it's weird how that requires but it's available under goog.dom/query
15:07mefestopbostrom_: was expecting it to be (gquery/query ...)
15:08S11001001wondering about environments
15:08S11001001~(defrecord blah [x y])
15:08clojurebot,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 10 25))
15:08S11001001something
15:08S11001001,(defrecord blah [x y])
15:08clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
15:08S11001001ok then
15:09S11001001timvisher: functions, you know, like those things you make with defn? Nothing to do with methods. You get ->blah and map->blah when you defrecord blah.
15:09Borkduderaek: hmm (seq decimal-roman) turns the order around… I didn't even mean sorted, but order-preserving..
15:10Borkduderaek: I guess I want to sort from high to low
15:10mefestopbostrom_: you have no idea how much time i burned trying to get to that one function! thanks again :)
15:10mefestohttps://refheap.com/paste/2400
15:11raekBorkdude: yeah, you can use sorted-map-by. sorted-map does not maintain the order you instered with
15:13raekBorkdude: ##(seq (sorted-map-by #(compare %2 %1) :a 1 :b 2 :c 3))
15:13lazybot⇒ ([:c 3] [:b 2] [:a 1])
15:13mefestopbostrom_: i was able to remove the :libs section from my config and rebuild my js file and it still works. i think it was this weird namespacing thing that was the cause the whole time
15:13Borkduderaek: tnx
15:14RoxxiCan anyone share an example of declaring a function that takes some params + optional keyword arguments (e.g. (foo a b key1: c key2: d) )
15:16raekRoxxi: (defn foo [a b & {:keys [key1 key2]}] [a b key1 key2])
15:16raek(foo 1 2 :key2 3 :key1 4) => [1 2 4 3]
15:16mefestois there a way to convert js arrays to clojure in cljs?
15:16Roxxiand if I call (foo 1 2) ?
15:16raekyou get nil for key1 and key2
15:16RoxxiIs there a way to specify defaults?
15:17Borkduderaek: works now, I used reverse, http://cljbin.com/paste/4f9aeeb3e4b0ee8eed133fc3
15:17raekRoxxi: you can also provide defaults defn foo [a b & {:keys [key1 key2]} :or {key1 :default1, key2 :default2}] [a b key1 key2])
15:18RoxxiHm. Thanks raek.
15:18pbostrom_mefesto: yeah, I struggled with it for a while myself; I actually didn't even use it that long before I switched to just using jQuery for everything
15:18mefestopbostrom_: im really close to doing that too but im trying to see how far gclosure gets me
15:19mefestopbostrom_: gclosure libs are pretty painful imo
15:24juhu_chapazamaterian: is clojure-config still unstable?
15:24pbostrom_mefesto: array-seq
15:25mefestohm is there a cljs contrib?
15:26stuartsierramefesto: no
15:26stuartsierraBut there could be.
15:26stuartsierraFor easier DOM-manipulation in ClojureScript, look at Luke VanderHart's Domina.
15:27mefestostuartsierra: will do, thanks
15:28mefestofound myself writing this and thinking there must be a ton of these out there: https://refheap.com/paste/2403
15:28timvisherS11001001: cheeky. ;) The part i'm lost about is that i didn't know a side-affect of defrecord was creation of functions
15:28timvisheris there an example of that online that I can look at?
15:28angermanwhat can I do about this error:
15:28angermanUnable to resolve artifact: Unable to get dependency information: Unable to read the metadata file for artifact 'commons-codec:commons-codec:jar': Cannot find parent: org.apache.commons:commons-parent for project: commons-codec:commons-codec:jar:1.4 for project commons-codec:commons-codec:jar:1.4
15:28angerman commons-codec:commons-codec:jar:1.4
15:28angerman?
15:29mefestobut domina looks like it eliminates my need for goog.dom/query
15:30dnolenmefesto: yeah I would use domina
15:30stuartsierraangerman: Your local Maven repository cache may corrupted by a bad file.
15:30stuartsierramefesto: Try deleting ~/.m2/repository/commons-codec
15:30angermanstuartsierra: how to easily fix? rm ~/.m2 ?
15:30ibdknoxI thought domina used goog.dom/query
15:30stuartsierra^ I meant angerman
15:30dnolenibdknox: it does underneath yeah.
15:31angermanstuartsierra: kk.
15:31angermandid not fix it though :/
15:31dnolenone annoying thing is that I don't think domina is careful about its declares. with lein-cljsbuild it'll spew lots of warnings.
15:31ibdknoxdnolen: yeah he just uses my goog-jar :)
15:31mefestodnolen: yeah i noticed that and it scared me off
15:32mefestotemporarily, but just an hour or so ago it looks like a new domina release is out
15:32Raynesibdknox: You're going to have to offer nudies if you ever want to see 200k.
15:33ibdknoxdnolen: strange loop talk submitted :)
15:33ibdknoxRaynes: that's my last ditch effort at the end ;)
15:33pandeiroibdknox: in korma if i nest a values call in an insert fn, do i still need the query argument?
15:33angermanstuartsierra: no idea what was wrong. but rm -fR ~/.m2 helped
15:33ibdknoxpandeiro: I didn't follow that
15:33stuartsierraangerman: probably a corrupted metadata file somewhere in the tree
15:33Raynesibdknox: Also, stop with the damned talks. How do you get energy for all of that crap? I did one talk and crawled into a whole for 4 months.
15:34pandeiroibdknox: sorry the docstring shows values as having arity 2, but your examples on the korma site show it with just the map/vector of data
15:35dnolenibdknox: exciting!
15:35ibdknoxpandeiro: keep in mind all of the insert/select/etc functions have implicit ->'s
15:35ibdknoxpandeiro: so the query is being threaded through
15:36pandeiroibdknox: yeah ok now the docstring makes sense
15:42ibdknoxRaynes: I'm only good at talking, so I gotta milk that for what it's worth ;)
15:43RaynesPsh.
15:44mefestoyea ibdknox, you're all talk :P
15:45mefestopfft, only 53 public repos :)
15:46RaynesYikes, I have 88.
15:46ibdknoxdude you're like 50% more involved than I am
15:47ibdknoxtechnomancy has more than 100 last time I looked
15:47ibdknox118
15:50mefestogetting this error when pulling the deps for the latest domina 1.0.0-beta4: https://refheap.com/paste/2405
15:51dnolenmefesto: the latest release is 1011, they must be requesting their own build.
15:54mefestois it bad manners to paste a stacktrace on the mailing list? refheap it instead?
15:56mefestoi guess i'll find out if someone yells at me
15:59goodieboyi have a ring app that has a couple of init functions. These functions setup some state, and prepare things like http client pools, search engine instance etc.. What can I do to ensure that these functions only get called once, no matter what... even while in development mode using emacs/slime?
16:00goodieboyI'm using something like this at them moment: (def inited? (delay (init-stuff...))) and later @inited?
16:01metajackgoodieboy: there's defonce
16:01goodieboymetajack: yeah i thought about that too. but I've heard from a few developers that defonce is "evil", not thread safe etc.?
16:02metajackgoodieboy: korma uses it for exactly this purpose, which is used by lots of ring apps.
16:02goodieboyinteresting
16:02pandeirodnolen: have you used swank.js at all? was considering setting it up for some js dev but curious if it's worth the hassle (and how much hassle, incompatability with slime version used by swank clojure)
16:03dnolenpandeiro: I looked at it a couple of times, but didn't think it was worth the hassle.
16:04pandeirocool, thanks.. i actually like regular js mode but am missing an easy repl
16:06jsabeaudryIs there a clojurescript repl running online somewhere? Something like jsfiddle but with clojurescript
16:07pandeirojsabeaudry: himera.herokuapp.com
16:07dnolenjsabeaudry: a JSFiddle like service for ClojureScript would be pretty awesome, at the moment we just have Himera
16:08dnolenjsabeaudry: a CLJSFiddle service could probably just use Himera.
16:09jsabeaudrypandeiro, dnolen: thans for the link, this will do perfectly fine :)
16:09chouserDoes anyone know the justification for defrecords including type in their equality test (and yet lists/vectors not doing so)?
16:10dnolenchouser: I vaguely remember when rhickey made that decision.
16:10dnolenchouser: in general I don't see why you wouldn't want that behavior, you could have just used a map then.
16:11mefestohow does one listen for the document ready event in domina?
16:12nDuffmefesto: have you looked into what's going on with the type-hinting? I'm having trouble getting type-hints for (defn- channel ^Channel [] ...) to stick -- calls to (channel) are still going through introspection unless I hint the result, ie. ^Channel (channel)
16:12pandeiromefesto: any reason you don't wanna use jayq (just curious)?
16:12mefestoi tried (events/listen! (css/sel "body") :load (fn [event] ...))
16:12chouserdnolen: we ran into it because we
16:12mefestonDuff: no i never noticed any issues with the type hints
16:13nDuffmefesto: how many lines of output does "lein2 check" give on your system?
16:13dnolenchouser: here's the ML post from rhickey http://groups.google.com/group/clojure/msg/a7413f4fc8cdd929
16:13mefestonDuff: unfortunately im at work and can't mess with it atm but i'll check it out when i get home
16:13nDuffmefesto: ...I get 63 from "lein2 check 2>&1 | wc -l"
16:13nDuffmefesto: *nod*. I'll file a ticket in github to track, then.
16:14mefestopandeiro: jayq a jquery wrapper?
16:14pandeiromefesto: :)
16:14chouserdnolen: we ran into it because we were serializing in a way that treated all maps the same, but then got back maps that were not equal to what we sent
16:14mefestonDuff: i guess i never really viewed creating a channel has a hotspot perf wise and never worried about it
16:15chouserdnolen: thanks, I'd found that one. I'm not interested in user-defined equality, I'm just surprised concrete type is included in the standard equality
16:15nDuffmefesto: ...if it were only happening on creation I'd be less worried
16:15nDuffmefesto: this is happening on anything that tries to grab the current channel to call something on it
16:15jsabeaudryIn clojurescript is (nth something 0) the right way to write something[0] ?
16:15clojurebot,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 10 25))
16:15chouserand using .equals to get the other behavior doesn't really help me understand why = does what it does
16:15mefestonDuff: oh ok yeah that doesn't sound good
16:15nDuffmefesto: ...(.basicGet (channel)), (.basicRecover (channel)), etc
16:15mebaran151what's the easiest way to say take every 2 elements from a collection?
16:16nickmbaileytake elements 2 at a time or take every second element?
16:16mebaran151,(partition-by #(Character/isUpperCase %1) "AbcDefHij")
16:16clojurebot((\A) (\b \c) (\D) (\e \f) (\H) ...)
16:16mefestopandeiro: i guess i wanted to avoid jquery since gclosure can't do its magic. is that the case with jayq?
16:17pandeirojsabeaudry: aget also works
16:17pandeiromefesto: i think ibdknox has the definitive rationale in the jayq readme... not sure about the advanced optimization issue though
16:17jsabeaudrypandeiro, I'll try aget because nth doesnt work
16:18pandeirojsabeaudry: nth worked for me on himera just now... i think js arrays implement ISeq ?
16:18dnolenchouser: here's you and lpetit and rhickey debating the finer points http://clojure-log.n01se.net/date/2010-07-30.html#12:11a
16:19mebaran151I want every capitalized group (ie (\A) with its uncapitalized tail (\b \c) so to speak (for an uncamelcase function))
16:19mebaran151"AbcDefHij" => "abc-def-hij"
16:20mefestopandeiro: yeah makes sense although im just learning clojurescript now so i'd like to do that with a fresh state of mind instead of just using it as a layer ontop of jquery
16:21jsabeaudrypandeiro, new FormData(cljs.core.nth.call(null, jayq.core.$.call(null, "form.channelconfig"), 0)) FAILS but new FormData(jayq.core.$.call(null, "form.channelconfig")[0]) WORKS (im really stretching the paste limit :P
16:21nickmbailey,(re-seq #"[A-Z][a-z][a-z]" "AbcDefHij")
16:21clojurebot("Abc" "Def" "Hij")
16:21pandeiromefesto: gotcha... in that case if you're just learning you can wrap document.querySelector and document.querySelectorAll since modern browsers have those
16:21nickmbaileymebaran151: ^
16:22mebaran151nickmbailey: there could be any number of characters lowercased
16:22nickmbaileyobviously adjusting that regex for whatever you really want
16:22mebaran151ie (IWantToHandleThisToo)
16:23nickmbailey#"[A-Z][a-z]*"
16:23jsabeaudrynow what I need is clojurescript to output that "[0]" because it doesnt work without it and neighter aget or nth work
16:23mefestopandeiro: cool thanks. although i did manage to get goog.dom/query working :)
16:23emezeskepandeiro, mefesto: jayq works perfectly with advanced optimization -- jquery is left unmolested, and the externs file keeps the optimizer from mangling the jquery calls in your code
16:23mebaran151nickmbailey: great solution! thanks
16:24pandeiromefesto: cool... https://refheap.com/paste/2409 just to give you an idea
16:24pandeiroemezeske: right but what about that feature of closure compiler that removes/inlines extraneous code... obviously it won't touch the minified jquery yeah?
16:25xeqi&(re-seq #"[A-Z][a-z]*" "Uñicode")
16:25emezeskepandeiro: Yeah, but you don't want that anyway, you should have the client get jquery from a CDN
16:25lazybot⇒ ("U")
16:25emezeskepandeiro: It's basically certain that they'll already have it cached
16:26pandeiroemezeske: makes sense, except there's also like 16 different jquery versions being used
16:26emezeskepandeiro: Well, obviously you grab the version you need from the CDN. It's still extremely likely to just already be cached.
16:28jsabeaudryAnyone aware of a html5 file upload example with clojurescript?
16:29jayunit100man... .not alot of resource on cascalog out there.
16:30dnolenjlongster: CLJS-209 is probably not going to go anywhere. Clojure doesn't support inner defines like scheme does.
16:30dnolenjlongster: defs are only top level.
16:31jsabeaudryWhen using (first foo) to try to obtain foo[0] I get Illegal operation on WrappedNative prototype object
16:31angermandoes clojure 1.4 provide convenece methods to format dates?
16:32pandeirojsabeaudry: something funky going on? old version of cljs? works fine on himera
16:33jsabeaudrypandeiro, perhaps, I didnt install it myself I let cljsbuild take care of that for me
16:33jsabeaudryI'll see if there is a new version out
16:34goodieboycould someone tell me whether or not defonce is considered bad practice? I have a friend who swears it's the devils making, any opinions on defonce?
16:34pandeiroas for file upload, if you know how to do it in JS, it's basically the same... i use FileReader (https://developer.mozilla.org/en/DOM/FileReader) for drag/drop uploading
16:35dnolengoodieboy: defonce is fine
16:35goodieboydnolen: thank you. Any problems with thread safety and defonce?
16:35tmcivergoodieboy: does your friend give reasons for that sentiment?
16:36dnolengoodieboy: like what?
16:37goodieboyi think his thought is, if two threads attempt to set a defonce at the same time, then "bad" things can happen, unlike refs and atoms
16:37goodieboythis is mostly talk when in development, using swank and reloading namespaces etc..
16:37jsabeaudrypandeiro, I don't actually im trying to follow this: http://stackoverflow.com/posts/8758614/revisions
16:38jsabeaudrypandeiro, but in stuck on the form data creation...
16:38dnolengoodieboy: why would two threads "set" a defonce?
16:41dnolengoodieboy: even so I don't see how that could be a problem, val field of Var marked volatile. But perhaps someone who understands the finer points of volatile can point out problems.
16:41jsabeaudryemezeske, is there a setting to enable a timestamp on the build result ?
16:41jsabeaudry(in cljsbuild)
16:41jsabeaudry(when running in auto)
16:42emezeskejsabeaudry: You mean, print out the current time at which a build completed?
16:42goodieboydnolen: This is more to the point of his concern: If the goal is to share state amongst threads then he would consider it really bad usage.
16:42jsabeaudryemezeske, exactly
16:42emezeskejsabeaudry: No, there's no setting for that. I could see that being handy
16:42goodieboyI would agree, sharing state, especially if that state is meant to be mutable
16:42pandeirojsabeaudry: emezeske: cljs-template does that by default
16:43dnolengoodieboy: defonce isn't for sharing mutable state
16:43goodieboyyeah, i guess it's all in the name! :)
16:43jsabeaudryI often look at the build window and wonder, did it build? Then I try to remember the last build time and trigger another build by saving the file again) :P
16:44emezeskeYeah, I can see that. I guess I haven't noticed because I always keep the auto output window visible
16:44emezeskeI might just make it always print a timestamp; there's not much reason not to
16:44goodieboydnolen: thanks, you've given me some relief in using defonce, and right about now it could be very helpful for me
16:45jlongsterdnolen: oh! I didn't realize that
16:46jlongsterdnolen: sorry for not doing the proper research
16:47timvisheris it expected that defrecords are not exposed when useing the namespace they're defined in?
16:47daniel_,(unchecked-byte 128)
16:47clojurebot-128
16:47dnolenjlongster: it's ok, common source of confusion coming from Scheme :)
16:47daniel_why isnt it working in my repl??? :'(
16:48daniel_java.lang.Exception: Unable to resolve symbol: unchecked-byte in this context (NO_SOURCE_FILE:1)
16:48xeqi,*clojure-version
16:48clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: *clojure-version in this context, compiling:(NO_SOURCE_PATH:0)>
16:48xeqi,*clojure-version*
16:48clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
16:48stuartsierratimvisher: Yes. defrecords are not Vars, but they do create constructor functions like ->RecordName
16:49timvisherah, _that_ is what M. S11001001 was talking about
16:49timvisheris there documentation on all this other than the docstring?
16:50daniel_hmm, im 1.2.1
16:50timvisheri don't see any of this mentioned in the docstring or in the datatypes section on clojure.org or in the clojuredocs.org documentation either
16:51daniel_yay, 1.4.0 works
16:52kovasbtimvisher: yeah the first time i became aware of it, was just noticing it in people's code
16:52kovasbtimvisher: wondering if it was some kind of convention on library author's part or something
16:53timvisherand defrecord's docstring is _still_ marked as alpha, subject to change
16:53timvisherwhich still makes me nervous about even talking about
16:53timvisherabout it*
16:53stuartsierratimvisher: Rich likes to hedge
16:53technomancywow, rich talks about simple vs easy at railsconf and the very next week, rails talks about adding a queueing system. hard to imagine a more spectacular way to miss the point.
16:53timvisherstuartsierra: yes he does
16:54jsabeaudrytimvisher, As someone here explain to me before, it's marked as alpha as in "alpha male"
16:54kovasblol
16:54timvisherjsabeaudry: hah!
16:54stuartsierratechnomancy: I miss the days when Rails was simple.
16:54timvisheri still think the documentation for defrecord and deftype needs some serious beefing up
16:54cemericktechnomancy: clearly, there needs to be a web framework that's less enterprisey. :-P
16:54kovasbtechnomancy: I think in the original version of that talk, he hypes queues
16:54metajackmy wife went to that talk at railsconf. she liked it :)
16:54timvisheri find them to be very surprising animals
16:54metajackwhich is funny because i've been trying to get her to watch the strangeloop keynote for months.
16:55timvisherespecially when comparing their actual behavior and usage to the documentation available for them
16:55technomancykovasb: queues are great; they are nice and orthogonal =)
16:55timvishermetajack: i find myself trying to get everyone around me to watch that talk, over and over again
16:55timvisherthat talk was seriously transformative for me
16:55timvisherreally drove home the simple ain't easy talk stu gave
16:57kovasbtimvisher: yeah they are serious constructs. pretty much need to go to outside sources (books etc) for a in-depth treament
16:58timvisherkovasb: which books cover them?
17:00jlongsterdnolen: so there aren't inner-defs anywhere? it's always `let`?
17:01dnolenjlongster: defs are always top level.
17:01jlongsteris there are a site that shows a bunch of idiomatic Clojure examples?
17:01jlongsterthat's interesting
17:01dnolenjlongster: and you have a quite a few let forms: let, left, if-let, when-let, etc.
17:02dnolenleft -> letfn
17:02anieroleft!
17:02jlongsterheh, weird :)
17:02dnolenjlongster: if-let / when-let are awesome
17:02dnolensomething I grind my teeth about when using other langs.
17:02jlongsterdnolen: I was just gonna say that, assuming they are like the `and-let` I use
17:03jlongsterI gotta say though, I'm gonna miss inner defs
17:03dnolenjlongster: I never really like them in Scheme.
17:04jlongsterdnolen: so you never use inner functions in Javascript?
17:05dnolenjlongster: of course, but it's pretty much equivalent to var foo = function() {}. same in Clojure, use let / letfn.
17:06jlongsterdnolen: true, but (def (fn x) ...) is a bit cleaner than (letfn [(fx [x] ...)] ...) :)
17:06jlongsteralso doesn't require indentation, which I like
17:06jlongsterbut still, I'm sure nothing like that's going to change, heh
17:07dnolenjlongster: fwiw I also got used to Dan Friedman's style, he never uses inner defines in his Scheme code.
17:07dnolenjlongster: let, letrec
17:07jlongsterdnolen: it's not too bad, but I think it's harder for people coming from javascript
17:08dnolenjlongster: huh, the thought never crossed my mind coming from JS -> Clojure. Even after dabbling with SICP (lots of inner defines) and some CL.
17:09dnolenor if it did, it didn't bother me for long.
17:10jtoydo people use in cater for a bays classifer?
17:10jtoyim
17:10jlongsterdnolen: it does for me at least, but it must just be something I do by default
17:11dnolenjlongster: now that I think about it, I'm not even sure what Scheme's scoping rules are for inner defines
17:11jtoy trying to find a bays classifier for clojure and that is what comes up first
17:11jtoyi just want something simple
17:11jlongsterdnolen: you're only allowed to use `define` at the beginning of expressions, so it's not arbitrary
17:12jlongsterlike right after a `define`, `let`, and `begin`
17:12jlongsterso it's basically like let, but without the extra syntax/indentation
17:12dnolenjlongster: yeah so a little bit less typing and more ways of doing things. Probably why Dan avoid it's.
17:12dnolenavoids it.
17:13jlongsterdnolen: I think having to introduce something like letfn is more confusing
17:13jlongsterjust have `define` and `let`
17:13dnolenjlongster: letfn is more like letrec so not really the same.
17:14jlongstertrue, but `let` could also behave more normally and allow references between variables
17:16dnolenjlongster: references between variables less useful interesting I think then recursive local fn definition.
17:16dnolenjlongster: rarely wanted the former.
17:17jlongsterdnolen: really? I do things like (let ((x (foo (bar y))) (y (+ x 1))) ... )
17:17jlongsterall the time
17:18jlongster(I know that's hard to read)
17:18raekdoes the former even make sense in a language with strict evaluation?
17:19jlongsterraek: why not? just evaluate the first form, assign it to a variable and add to env, evaluate the next form, etc
17:19jlongsterit's very practical
17:19raekjlongster: but what is the value of y when the first form is evaluated?
17:19dnolenjlongster: what raek said.
17:19jlongstery doesn't exist yet
17:20jlongsterit's sequential
17:20jlongsterhm, I thought clojure allowed that
17:20S11001001jlongster: it's sequential, not mutually recursive
17:20raekbut in order to evaluate (foo (bar y)) you must look up the value of y
17:21langmartinjlongster: y is an box that gets set-box!'ed when the second line is evaluated
17:21raek(assuming 'foo' and 'bar' are not macros)
17:21jlongsterraek: oh yikes, sorry, that was a bad typo
17:21langmartinis scheme in a letrec, that is
17:21jlongsterlangmartin: oh hai!
17:21dnolenjlongster: k, heh the world was turned upside down there for a second.
17:21jlongsterright, letrec is different
17:21dnolenjlongster: Clojure let is sequential too.
17:21jlongsterdnolen: sorry, total fail.
17:22jlongsterhaha, ok, that's what I thought.
17:22raekbut in non-strict languages you can actually do crazy stuff like that
17:22jlongsteryes yes. sorry, I'll go back into my hole now.
17:22raekbut yes, you can access x from the second form
17:23jlongsteryeah, it's very practical
17:23raekindeed
17:23raekyou get non-let* for free with destructuring too
17:23raek(let [[x y] [y x]] ...)
17:24jlongsterraek: hot
17:53hcumberdaleHi ;)
17:56Raynes&(clojure-version)
17:56lazybot⇒ "1.4.0"
17:56RaynesCool.
18:07hcumberdaleyeah!
18:07hcumberdaleHow can I get the context of my web application?!
18:08hcumberdalehttp://abc.com/xyz << http://abc.com
18:08muhoothat's really weird. getting UnknownHostExceptions using clutch, connecting to cloudant, but i can wget/curl/firefox to it no problem.
18:10ibdknoxhcumberdale: that information is in the ring request
18:11hcumberdaleibdknox how to extract it?
18:11gfredericksdnolen: just created confluence page for numerics. I will add more to it soon if no one else does.
18:12ibdknoxhcumberdale: ring requests are just maps :)
18:12joegallohttps://github.com/mmcgrana/ring/blob/master/SPEC
18:12dnolengfredericks: I'm sure no one else will :) go to town!
18:13joegallolooking there, i'm betting it would be :server-name.
18:14ibdknoxjoegallo: depends on what parts he needs :)
18:14ivanwhy does ClojureScript look for JS in the classpath?
18:14dnolengfredericks: well I might of course - I think Rich's advice is good. Figure out the ideal goal - and work out how we can get perf back.
18:14ivaner, CLJS
18:14joegalloright, i was just practicing my googling
18:14ibdknoxjoegallo: e.g. server-name for http://localhost:8077 will just be localhost
18:14hcumberdaleibdknox, what key is it? uri?
18:15joegalloibdknox: yes, i'd expect that to be so
18:15ibdknoxhcumberdale: you can get it from a combination of :scheme :server-name and :server-port
18:16ibdknoxhcumberdale: if you're only accepting on port 80, which is most likely, you'd just need :scheme and :server-name
18:16joegalloooh, ooh, and if you're not worried about ssl, you could just use :server-name ;)
18:17ibdknoxlol
18:17ibdknox:D
18:17muhoohere's a general clojure/couch/lein question: what's the best strategy for keeping views in sync between the source code base and the running (live) db?
18:17muhooi'm thinking i could just have (set-views ...) run everytime the slug starts up on heroku maybe
18:18muhooand just overwrite whatever views were there with whatever's new... instant migration.
18:18technomancymuhoo: should probably happen at slug compilation time
18:18muhoowhere would i hook that in, inside my project?
18:18gfredericksdnolen: I'm browsing clojure.lang.Numbers to try to get a handle on how the double dispatch works
18:19hcumberdalenope, uri is just everything after /
18:19gfrederickshcumberdale: maybe the host header?
18:19technomancymuhoo: if you set user_env_compile (https://devcenter.heroku.com/articles/labs-user-env-compile) you can do "heroku config:add LEIN_BUILD_TASK="set-views, compile :all"
18:19technomancymuhoo: provided there's a lein task for set-views
18:20technomancymuhoo: maybe LEIN_BUILD_TASK="run -m myapp.set-views, compile :all"
18:20clojurebotclojure-maven-plugin is http://github.com/talios/clojure-maven-plugin
18:20technomancyshaddup clojurebot
18:21hcumberdale(do (map #(info (% request)) [:scheme :server-name :server-port]) ,....
18:21hcumberdaleit does not work?
18:27daniel_i want to split a 64 character string into a list of 8 separate strings, how can i do this?
18:27AimHeredaniel > Use the partition function
18:28daniel_thanks AimHere
18:28AimHere,(map #(apply str %) (partition 8 "abcdefghijklqeqopweqeqepqeo"))
18:28clojurebot("abcdefgh" "ijklqeqo" "pweqeqep")
18:30daniel_yup, beautiful
18:31AimHereYou could probably do something with repeated take-whiles, or some jiggery-pokery with subs, but I think partition looks more idiomatic
18:33hcumberdale(str "http://&quot; (:server-name request) (:server-port request)) ) << can it be done smarter?
18:34daniel_is there an easy method of finding the length of a string?
18:34hcumberdale(str "http://&quot; (:server-name request) ":" (:server-port request)) <<
18:35raekdaniel_: count
18:35AimHeredaniel_, count. Think of strings as sequences of chars
18:35daniel_ah count
18:35daniel_yeah, just found it
18:48daniel_i have a list like ("line1" "line2" "line3") and im doing (map #(println %) list)
18:49daniel_println also returns nil after printing so i dont get a nice output, can i avoid that somehow?
18:49daniel_actually, i guess i want to compile it into one string with \n's
18:49daniel_and then ill only get one nil
18:50daniel_how can i slot in "\n" in between each value in the list?
18:50hcumberdalecan write a middleware to store the current url to some global ring var ?
18:50pipelineinterleave
18:50daniel_interleave, thats it
18:50daniel_i was thinking interweave
18:50pipelinethat might be it
18:50banjieweninterpose, more likely
18:51pipelineinterwangle
18:52emezeskedaniel_: What is your goal? Just to print a few lines of output?
18:53daniel_yeah, its looking good except i also get the parens around the list
18:53daniel_i want these out as well
18:53ipostelnikif you want just the side-effect of printing, use doseq
18:54daniel_now i have (println (interleave (repeat "\n") ("lin1" "line2" "line3")))
18:54emezeskedaniel_: map is lazy, you shouldn't do I/O stuff inside it
18:54daniel_ipostelnik: i think i want doseq
18:54pipelinedaniel_: println appends a newline to everything anyway
18:55pipelineso doseq println woulda done you nicely
18:55emezeske(doseq [x [1 2 3 4]] (println x))
18:56daniel_right pipeline
18:56daniel_thanks guys
18:57tmciverdaniel_: fyi, you could also just add 'apply str' to what you had: (println (apply str (interleave '("lin1" "line2" "line3") (repeat "\n"))))
18:57njdirkare clojars .jar uploads from lein jar or uberjar?
18:57technomancynjdirk: just jars
18:58njdirkthanks, t -- so where's the resolution of the "dependencies - sub-dependencies" occur?
19:00daniel_got it working fine, not sure if its good code https://gist.github.com/2514050
19:00daniel_having such a complex seq in the bindings
19:00daniel_maybe i can split it into more functions
19:01technomancynjdirk: I can't tell what you're asking
19:01emezeskedaniel_: My suggestion would be to just add more let bindings, for intermediate results
19:03emezeskedaniel_: Also, I think (str (apply str... is redundant
19:03emezeskedaniel_: nevermind that ^
19:03emezeskedaniel_: I didn't read it right
19:04njdirksorry, I'm assuming I don't need the fatter standalone jar since lein deps et'al will recurse as necessary to resolve any nested dependencies -- right?
19:06technomancynjdirk: yeah, that's right
19:06njdirkcoo -- thx again, t
19:06jtoywhat bayes classifier do you guys normally use with clojure?
19:06daniel_thanks emezeske
19:11daniel_can anyone suggest how this can be made more 'DRY'? https://gist.github.com/2514097
19:13rbuchmannwhats the best way to destructure a list into the last element and everything before? I arrived at [[prev [last]] (partition-all (dec (count col)) col)]
19:13mmarczykdaniel_: (apply bit-xor (for [op [bit-shift-left bit-shift-right] arg [1 8 7 9]] (op board arg))) ?
19:14rbuchmann[(butlast col) (last col)] walks twice, right?
19:15daniel_mmarczyk: nice, thanks
19:15mmarczyknp
19:15technomancyyou could use juxt!
19:15rbuchmann[[prev last] (juxt [butlast last] col) ?
19:16mmarczykstill walks twice
19:16mmarczyksplit-at walks twice too
19:16rbuchmannbut cool :)
19:16mmarczykyeah :-)
19:16rbuchmannhmm
19:17mmarczykalthough actually
19:17mmarczyk(partition-all (dec (count coll)) coll) walks twice too, lol
19:17mmarczykif coll is not counted
19:17rbuchmannnot if counted? col, right?
19:17mmarczykso there may be not different
19:17mmarczykargh
19:17aniero(let [v (vec coll)] [(last v) (pop v)])
19:17rbuchmann^^
19:18anierowhy not that? pop/last are constant time on vectors
19:18mmarczykI'm not even sure which of the possible correct versions of the above sentence I meant originally :-P
19:18aniero... i think
19:18rbuchmannhehe
19:18mmarczyk(juxt peek pop)
19:18mmarczyklast is not, but peek is
19:18anieroah!
19:18rbuchmannthat looks good actually
19:18rbuchmannthanks!
19:19mmarczyk:-)
19:19jtoy?
19:19anieroso it's ((juxt peek pop) (vec coll)) as the final solution?
19:20rbuchmannI guess
19:20rbuchmannwalks once, is concise, probably no better
19:21technomancywell it uses juxt, so it does have that going for it
19:21technomancyclojurebot: juxt?
19:21clojurebotjuxt is usually the right answer
19:22technomancy~botsnack
19:22clojurebotThanks! Can I have chocolate next time
19:22mmarczyklooking @ partition-all's source, it uses (take n s) then nthrest, so no chance of a single walk
19:23nDuffHow can I tell if an interface is applicable to an object?
19:23mmarczyknDuff: instance?
19:23mmarczyk&(instance? clojure.lang.IPersistentMap {})
19:23lazybot⇒ true
19:26mmarczyktechnomancy: am I correct in surmising lein2 is complete enough that there's not reason not to switch at this point? in particular, no breaking changes likely between the current preview and 2.0?
19:26technomancymmarczyk: yeah, I recommend upgrading; it's very stable
19:27mmarczyktechnomancy: fantastic, thanks!
19:27technomancymmarczyk: there is one breaking change planned: creating a clojars releases repository and dropping the existing snapshots repository from the default repo list. but that's about it.
19:28mmarczyktechnomancy: oh good, I'd like *that* a lot
19:28mmarczyktechnomancy: anything in particular that needs to be done to make this happen soon?
19:29nDuffBlerg.
19:29technomancymmarczyk: a few things: http://groups.google.com/group/clojars-maintainers/msg/75593b0a3ea6023f
19:29technomancymmarczyk: would love to get help on that if you are interested. right now xeqi is leading the charge, but I hope to be able to pick it back up in a few weeks
19:30mmarczyktechnomancy: yeah, I was hoping to get back into developing lein
19:30mmarczyktechnomancy: I'll be moving a largish project over to lein2 over the weekend, I'll use this as an opportunity to get to know the new codebase
19:33mmarczyktechnomancy: incidentally, I wanted to do a little bit of work on the Clojars front-end in the coming week or two -- add a few minor prettification-type touches to the website and maybe display some additional project info when available in project.clj; who do I send pull requests to?
19:35hcumberdalehow can I control the header for ring responses?
19:37mmarczykhcumberdale: headers are attached to the :headers key in the response map in the form of a map from header name to content; modify that as appropriate
19:38technomancymmarczyk: sorry, lost my connection
19:38mmarczykhcumberdale: e.g. (update-in [:headers] response merge {"Cache-Control" "max-age=0"})
19:39technomancymmarczyk: I was going to say, check out the "preview4" milestone https://github.com/technomancy/leiningen/issues?milestone=4&amp;page=1&amp;state=open&amp;utf8=%E2%9C%93
19:39technomancymmarczyk: and the #leiningen channel is pretty active for discussing development
19:40technomancymmarczyk: xeqi and I both have access on _ato's fork, so just send pull reqs there
19:40mmarczyktechnomancy: oh good, will do
19:42technomancyalso anyone else interested in contributing to leiningen should check that link out; I've tagged low-hanging fruit with the "newbie" tag
19:42mmarczyktechnomancy: so, I'm getting started on my move to lein2 -- once that's done, I'll get started on some of the issues (some will definitely bite me sometime soon if not tackled, so I'll be well motivated :-P)
19:42mmarczykdnolen: ping?
19:44hcumberdalemmarczyk, how do I construct the map?
19:45mmarczykhcumberdale: well, it's just a regular Clojure map, so no different to how you'd normally construct a map
19:46mmarczykhcumberdale: only thing to keep in mind is that any valid Ring handler returns a response with a :headers key; if you're wrapping a handler -- writing a piece of middleware, that is -- you'll probably want to add to that map rather than replace it
19:46dnolenmmarczyk: pong
19:47mmarczykhcumberdale: for which you can use the code from my earlier msg
19:47hcumberdaleahh,....
19:47hcumberdaleI uderstand
19:47mmarczykdnolen: hi
19:47mmarczykdnolen: I've seen your comment on the ObjMap ticket, so about that --
19:47hcumberdalehow to force UTF-8 instad of ISO-8859-1 ?
19:48mmarczykdnolen: I've got a port of PersistentArrayMap almost ready -- it's so simple it'd be a shame not to see if it makes sense in cljs
19:48mmarczykdnolen: so I'll be wiring all this together and rolling a few jsperf tests
19:48dnolenmmarczyk: sure, worth testing.
19:49mmarczykdnolen: but that'll probably take me a day or two, I've got a slightly overloaded work queue atm
19:50dnolenmmarczyk: sure, was just wanting to push out a release so more people play around with the new stuff.
19:51mmarczykdnolen: sure, that'd be great
19:52mmarczykdnolen: just wanted to let you know I've got a handful of related patches coming over the next two to three days, so maybe this can all get released together
19:52dnolenmmarczyk: sounds like a plan.
19:52mmarczykdnolen: one more thing -- do you know if anybody's working on tagged literals for cljs?
19:53dnolenmmarczyk: fogus started a branch.
19:54kovasbone thing that really troubles me about tagged literals..
19:54dnolenkovasb: ?
19:54kovasbif you don't have the definition for the tag, the reader explodes
19:54dnolenin Clojure?
19:54kovasbwhich means its impossible to pass data through the system without every step knowing about what it is
19:54kovasbyes
19:54mmarczykdnolen: good to know, thanks
19:55kovasbit should just return some inert generic record instead, which will then reserialize with the appropriate tag
19:55dnolenkovasb: sounds like something worth bringing up on the ML.
19:56mmarczykkovasb: it would be easy enough to provide an UnknownLiteral wrapper, but this is probably a ggroup topic
19:56kovasbyeah, i thought about it but didn't want to sound like a whiner
19:56kovasb:)
19:56kovasbyeah, something like that would be great. otherwise the purpose is kinda defeated :/
19:56dnolenkovasb: I think the tagged literal design work didn't really make it as far as handling the general extension case.
19:57kovasbdnolen: yeah, somewhat under-baked. which is surprising since I thought it was there because of datomic's needs
19:58hcumberdaleDamn!
19:58kovasbwill bring it up on mailing list..
19:58hcumberdale(defn respond "resp 200 with spec header" [body ctype] {:status 200 :headers { "Content-Type" ctype "Character-Encoding" "UTF-8" } :body body})
19:59hcumberdalejetty doesn't respond in UTF-8
19:59hcumberdaleIt's still ISO-8859-1
19:59hcumberdalePicked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
19:59hcumberdaleENV vars also set to UTF-8
19:59hcumberdalemhh
20:00xeqiwhat is ctype?
20:01hcumberdale "application/rss+xml"
20:06mmarczykhcumberdale: you'll probably want to add ";charset=UTF-8" to that
20:11hcumberdaleworks, thx mmarczyk
20:11mmarczyknp
20:20jimi_hendrixis there a way to get all but the first n items of a vec?
20:21dnolendrop
20:21jimi_hendrixthat gives me a seq though
20:22jimi_hendrixbasically, i have a string. i want to drop the first n words. so far i am splitting it up via clojure.string/split, which returns a vec, but calling drop makes it a seq.
20:22jimi_hendrixwhich i dont think i can easily manipulate
20:24mdeboard&(rest [1 2 3 4])
20:24lazybot⇒ (2 3 4)
20:24mdeboard&(vec (rest [1 2 3 4]))
20:24lazybot⇒ [2 3 4]
20:24jimi_hendrixooh
20:24jimi_hendrixok
20:24jimi_hendrixthanks
20:25mdeboardnp
20:25jimi_hendrixhmm
20:26muhootechnomancy: wow, could it really be that simple? i could just call a function in main that updates whatever couchdb the thing is connecting to, with the most current views. they'll never be out of sync
20:26hcumberdaleis there a way to show all the loc in a github project for a specific folder?
20:26mdeboard&(clojure.string/split "Hello world")
20:26lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: string$split
20:26technomancymuhoo: maybe; I haven't used couch views
20:27muhooi can't see any reason why it won't work. i could even spin up a thread so it doesn't delay the app coming up.
20:28technomancymuhoo: if it happens during git push time that's not an issue
20:28muhoooh, good point. that'd be a good reason to do it in user_env_compile then
20:28mmarczykjimi_hendrix: you could also use subvec, though note that it prevents the original vector from being GC'd
20:29jimi_hendrixmmarczyk, i wont use that then :P
20:29mdeboard&(vec (rest (clojure.string/split "Hello World Potato" #" ")))
20:29lazybot⇒ ["World" "Potato"]
20:29mmarczykjimi_hendrix: well, it's the same as with String.substring, for the same reasons
20:29jimi_hendrixright
20:30mdeboardWorld potato
20:30jimi_hendrixnow, is there an easy way to stringify that vector? if i just call (str my-vec), then i get something like "[\"a\" \"b\"]"
20:30Iceland_jackjimi_hendrix: (apply str ...) ?
20:30jimi_hendrixooh duh
20:31mmarczykif that's all you want to do with it, then subvec's totally fine
20:31jimi_hendrixnow is there a way to throw in a space between each word?
20:32mmarczykinterpose " "
20:32mmarczyk&(apply str (interpose " " ["a" "s" "d" "f"]))
20:32lazybot⇒ "a s d f"
20:32jimi_hendrixthanks
20:33mdeboardno
20:33mdeboard&(clojure.string/join " " ["Hello" "World" "Potato"])
20:33lazybot⇒ "Hello World Potato"
20:33mdeboardamalloy_ will have a stroke if you use apply & interpose :P
20:34mmarczyktrue, join's better
20:37mmarczykNB. taking the substring comprising the first n words is possible with just a regex pattern
20:37mmarczyk&(re-seq #"(\w+\W+){5}" "Foo bar baz quux wibble wobble.")
20:37lazybot⇒ (["Foo bar baz quux wibble " "wibble "])
20:38mmarczyk(guess that needs a little polishing)
20:38mmarczyk(but still.)
20:38alexbaranoskymaybe use ? to stop the greediness
20:38alexbaranosky&(re-seq #"(\w+\W+){5}?" "Foo bar baz quux wibble wobble.")
20:38lazybot⇒ (["Foo bar baz quux wibble " "wibble "])
20:39alexbaranoskyhmmm, not sure... but don't want to spam the channel with code
20:39mmarczykcould use (\w+\W+){4}\w+ or sth
20:40mmarczykor use non-greedy * in place of + after \W
20:40mmarczyk(\w+\W*?){5}
20:51dgrnbrgI have a fn, and I want to call it from an eval'ed piece of code
20:51RickInGAif anyone in here has Alex Miller's email address, could you let him know that the security certificate for thestrangeloop.com has expired
20:51dgrnbrgI tried (eval `(~f)) but that doesn't work
20:52dgrnbrg,(eval `(~(fn [] (println "hi"))))
20:52clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
20:52dgrnbrgwell, it actually works on my machine
20:53dgrnbrgbut i'm seeing an exceptionininitializer error in the lisp reader when I eval
20:54RickInGAdgrnbrg can't you just do (eval (function-name))
20:54dgrnbrgI get the function as an argument
20:54dgrnbrgso no, it wouldn't work
20:54RickInGAwithout the tic and the tilde
20:55dgrnbrgthen i'd eval the function immediately
20:55RickInGAdo you have the function in parens?
20:55RickInGAah, ok
20:55dgrnbrgI actually do (eval `(fn [] ~expr))
20:55dgrnbrgwhere expr is of one of 2 forms:
20:56dgrnbrg`(apply ~some-fn ~some-args) ;some-fn and some-args are objects, probably not readable
20:56RickInGAso what are you trying to do? define an anonymous function that you don't evaluate?
20:56dgrnbrgor a regular fragment of clojure
20:56dgrnbrgI'm writing a clojure code generator
20:56dgrnbrgand i am currently using anonymous function chains to build it
20:57mdeboarddgrnbrg: (future f) ?
20:57dgrnbrgbut for architecture and performance reasons, I want to construct a single fn and then eval it to compile it to byte code, then rerun as needed
20:57dgrnbrgit needs to be evaled
20:59dgrnbrgi am trying to do a gradual migration between the systems
20:59dgrnbrgperhaps that's not possible, and i just need to rewrite everything at once
21:00RickInGAI don't have any experience with eval, I thought it was for executing strings as s-expressions
21:00RickInGADo you just want to define a function?
21:18hcumberdale(GET "/feed" request (content-type (response (render-rssfeed (:host request))) "application/rss+xml;charset=UTF-8")) << damn
21:18hcumberdaleresponse is text/plain
21:26creeseCan someone help me get started with java interop? My test project isn't working.
21:30alexbaranoskycreese, what in particular?
21:49creesecan someone clarify the syntax for ns :import?
21:49creesepage 108 of clojure in action has the following:
21:50creese(ns com.clojureinaction.book (:import (java.util Set)))
21:51alexbaranoskycreese, the ns macro is notorious for having different syntax variations that work
21:52creeseHere is what I'm trying:
21:52creese(ns javatest.core
21:52creese (:import (namesforall TestFile inc get sqr)))
21:53alexbaranosky(ns javatest.core (:import [namesforall TestFile] )) ;; will work
21:53creeseI don't need the method names?
21:53alexbaranosky(ns javatest.core (:import (namesforall TestFile) )) ;; try this, maybe it works too ;)
21:53alexbaranoskyyou import classes like in Java
21:54alexbaranoskyyou call the method name on the objects
21:54creeseright
21:54creeseI knew that
21:55alexbaranosky(.inc (MyObject.))
21:56creeseI tried (def x (TestFile.))
21:57creeseand it doesn't work
21:57creeseUnable to resolve classname: TestFile
22:01creeseI can't create the object.
22:06alexbaranoskywe need someon who has compiled Java alongside Clojure
22:06alexbaranoskyI haven't ever needed to do that
22:09creeserigh
22:09creeset
22:10alexbaranoskycreese, usually there are a lot of people to help you here, but I guess because it is Friday they're hard to find tonight
22:11creeseI am getting a warning when I compile to jar
22:12alexbaranoskypaste it?
22:12creeseit says, "No namespaces to :aot compile listed in project.clj."
22:12creesethat might be a problem
22:12alexbaranoskyah you might have to add a key to the project map in project.clj
22:13alexbaranosky{ ... :aot my.namespace ...}
22:15creeseI found something that said to add
22:15creese:main amr_db.core
22:15creesewhere the argument is the ns in your core.clj file
22:15alexbaranoskytry both :)
22:15alexbaranoskysee which works
22:26creese:main doesn't seem to help
22:26creeseI can't get leiningen to accept anything with :aot
22:26creesedo you know how make a repl forget everything you've told it?
22:32creesenow I'm getting something different:
22:32creesex already refers to: #'javatest.core/x in namespace: user
22:32creesewhich happens when I try: (def x (TestFile.))
22:33alexbaranoskysounds like you are shadowing x
22:33tmcivercreese: are you in the 'user' namespace? Did you (use 'javatest.core)?
22:34tmcivercreese: you could remove-ns ##(doc remove-ns)
22:34lazybot⇒ "([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
22:34tmcivercreese: but it might be easier to just restart the repl
22:47yoklovcreese: are you still trying to aot something?
22:47yoklovits not { :aot my.namespace }, its { :aot [my.namespace] }
22:50creesewhat do the { } brackets mean? are you just saying type what's inside?
22:50creeseI'm still getting an exception
22:50tmcivercreese: no, you type the {}
22:51tmciverit's a map literal
22:53tmcivercreese: actually, it's part of your project.clj; so you don't type the {} in this case; you put ':aot [some.ns]' in your project file
22:53creeseI don't see brackets in the sample.project.clj
22:53leo2007is clojure programming out for sale?
22:54tmciverleo2007: yes
22:55leo2007why do clojure introduce so many syntaxes?
22:56creesecan someone explain the difference between a jar and an uberjar?
22:56creeseI think that may be what I'm doing wrong
22:57xeqijar is just your project code/resources; uberjar is your code/resource + jars of all the dependencies
22:58xeqijars are convienent for libraries, uberjars for running from a single jar
22:58yoklovcreese: what are you trying to do
23:03creeseso I shouldn't need to uberjar if I'm calling java from the repl
23:05xeqinope
23:06xeqiif you paste some code on refheap.com I might be able to help
23:06creeseI have a paste bin, let me update it
23:06xeqiif you have a specific problem w/ java interop
23:06xeqiah
23:16sandaemcHi there, I'm looking for tutorial on how to create a nested map data structure. Do I have to use "ref" for that? I'm used to PHP's $data['key']['nested-one'] = $value and don't know how I can do that in Clojure.
23:17xeqi,{:first-level {:second-level "value"}}
23:17clojurebot{:first-level {:second-level "value"}}
23:17sandaemcNote: I want to create that during a loop.
23:18RaynesYou probably don't want to do it the way you think you want to do it.
23:18yoklovsandaemc: you can't quite do it the same as in php
23:18Raynesupdate-in is what you're looking for.
23:18RaynesBut it doesn't modify the map, it creates and returns a new one.
23:18yoklov(update-in data "key" "nested-one" value)
23:19RaynesSo if you're going to build this map in a loop, the map should be one of the params of your loop.
23:19RaynesUm, no.
23:19xeqi,(update-in {} [:a :b] :c)
23:19clojurebot{:a {:b nil}}
23:19yoklovoh yeah
23:19Raynes&(update-in {:foo {:bar []}} [:foo :bar] conj 1)
23:19lazybot⇒ {:foo {:bar [1]}}
23:19xeqioh, right... update-in not assoc-in
23:20yoklovthough, php's arrays do autovivification
23:20sandaemcOkay, I'll try update-in. Thanks.
23:20yoklovso it makes the nested levels
23:20yoklovas you go
23:21yoklovyeah looking at that question, i think thats what he's asking
23:22Raynes&(loop [x {:foo {:bar []}} y 0] (let [y (inc y)] (if (< y 10) (recur (update-in x [:foo :bar] conj y) y) x)))
23:22lazybot⇒ {:foo {:bar [1 2 3 4 5 6 7 8 9]}}
23:23yoklovin php if you have $data = array(); then do $data["deeply"]["nested"]["array"] = 3 it will make the nested hashes for you.
23:23xeqiugh
23:23yoklovdoes update-in do that?
23:23yoklovoh
23:23RaynesYes.
23:23yoklovyeah
23:23yoklovhuh
23:23yoklovI should use that more
23:24Raynes&(reduce #(update-in % [:foo :bar] conj %2) {} (range 10))
23:24lazybot⇒ {:foo {:bar (9 8 7 6 5 4 3 2 1 0)}}
23:25Raynes&(assoc-in {} [:foo :bar] (range 10))
23:25lazybot⇒ {:foo {:bar (0 1 2 3 4 5 6 7 8 9)}}