#clojure logs

2014-01-29

00:46fowlslegs,(= (reverse [:foo : bar :foo]) (seq [:foo : bar :foo]))
00:46clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :>
00:47fowlslegsI thought the type metadata didn't matter when using =, just that the values were the same.
00:54andyffowlslegs: Metadata is ignored by =
00:54fowlslegsandyf: I thought so, but why the errors
00:55andyfspace between : and bar
00:55fowlslegs,(seq [:foo :bar :foo])
00:55clojurebot(:foo :bar :foo)
00:55fowlslegs,(reverse [:foo :bar :foo])
00:55clojurebot(:foo :bar :foo)
00:55fowlslegshaha
01:04voldymani can't seem to connect to sqlite db here is the code that i used http://pastie.org/8677589
01:16tpopedevn: actually I gave up and switched to sexp.vim. much better
01:23seancorfieldvoldyman: what's in your project.clj as a dependency for SQLite and what platform are you on?
01:24voldymanseancorfield: on ubuntu 13.10 dependency -> org.clojure/java.jdbc org.xerial/sqlite-jdbc
01:25seancorfieldwhat version?
01:25seancorfieldyou shouldn't need the :classname btw, java.jdbc can figure the right thing out from the :subprotocol
01:25voldymanclojure "1.5.1" jdbc "0.3.2" sqlite-jdbc "3.7.2"
01:26seancorfieldhmm, that's the version of SQLite that java.jdbc is tested against so that should be ok
01:27voldymanseancorfield: know of some project where i could find some sample code?
01:28seancorfieldsample code for what, exactly?
01:28voldymanusing sqlite db
01:28seancorfieldregular java.jdbc documentation should apply
01:28seancorfieldon clojure-doc.org
01:29seancorfieldhttp://clojure-doc.org/articles/ecosystem/java_jdbc/home.html
01:29seancorfieldand the tests in java.jdbc exercise SQLite and other DBs
01:30seancorfieldone thing you might try as a sanity check is to clone the java.jdbc repo and run: lein test
01:30seancorfieldthat will show whether the basics are working on your system
01:30voldymanah, great idea
01:30seancorfieldif that doesn't work, it might be something environmental...
01:33seancorfieldit should say Ran 70 tests containing 445 assertions...
01:34seancorfield(that's what it just produced on Windows 8.1 with Java 7 for me)
01:34voldymanseancorfield: same and 0 failures and 0 errors
01:35voldymanbut i don't even have postgres installed (which it checks)
01:35seancorfieldnot by default it doesn't :)
01:35seancorfieldby default it tests apache derby, hsqldb, and sqlite
01:35clojurebotI don't understand.
01:36seancorfieldso that proves that sqlite "works' so something about the way you're invoking it in the repl is the issue
01:36seancorfieldcat paste up your project.clj somewhere?
01:38voldymanseancorfield: http://pastie.org/8677653
01:39seancorfieldthx
01:40seancorfieldi'll try that in a project locally with your repl session and see what happens
01:43seancorfieldheh, well, the good news for you is i can repro your exact issue...
01:43seancorfield...so i guess my question is: gave you actually created that test table?
01:47seancorfieldok, the problem is that you should say: (query db ["select * from test"])
01:48seancorfieldi'm surprised the driver dumps
01:49seancorfieldi'll open a ticket to add better validation for the query function to check it is passed a vector of sql statement followed by optional parameters... or it packages a string up as a vector for processing
01:51voldymanseancorfield: thanks a lot. i tried rewriting some code in repl it it worked!!
01:55seancorfieldfor reference here's the issue i created http://dev.clojure.org/jira/browse/JDBC-89
01:57sm0kehow does one contributes to clojure, do they accept pull reqests on github?
01:58seancorfieldread http://clojure.org/contributing
01:58seancorfieldno pull requests, just patches attached to JIRA tickets, from folks with signed Contributor's Agreements on record with Clojure/core
02:00sm0kewhoa! so much work
02:00deadghostis it?
02:01deadghostfrom what I read, it sounds like all you need to do is sign over your soul to rich hickey
02:01sm0kewho sends a postal mail!
02:01deadghostyou don't even need a goat sacrifice like other languages
02:01sm0kecrap and all i wanted to do was add serialization ids
02:01seancorfieldas you can see from that page, hundreds of people have happily signed and mailed the CA...
02:02seancorfieldyou can always open a ticket on JIRA with a description of what you had in mind and let the project maintainer decide if / how to implement it :)
02:03sm0kewell there is already a bug which i want someone to take up http://dev.clojure.org/jira/browse/CLJ-1327
02:03seancorfieldthe legal protection of a signed CA is necessary for Clojure to be usable by companies
02:03sm0kebut the project maintainers have made it minor
02:09seancorfieldsm0ke: you could always add comments to that issue explaining why you think it's more important than minor - that would likely get an explanation from Clojure/core about it
02:12carlo_auIs there any way to see debug info from Light Table? The InstaRepl doesn't work, the box thing in the bottom-left corner keeps spinning.
02:12seancorfieldok, outta here for the night
02:13carlo_au'lein repl' works fine on the command line
02:13seancorfieldvoldyman: thank you for finding that issue - definitely not an intuitive problem!
02:14TEttingercarlo_au, I have the same problem.
02:15TEttingeractually I've had it for more than one version...
02:15carlo_auTEttinger: no luck on any other platform?
02:16carlo_auI'm trying it on a plain Ubuntu 13.10 VM as it doesn't compile on Debian Wheezy due to some libc version issue.
02:16TEttingerI'm on windows 7... hm.
02:16carlo_auhmm
02:16TEttingerI thought it might have been a threading thing, since when I tried it I was doing stuff with Swing
02:17chippieIf I want to read an environment variable, such as $HOME or $PATH, is there a core function to do this easily? Searching with "env" with find-doc I didn't spot much, so have started down the path of (clojure.java.shell/sh "/usr/bin/env") passed through a series of conversions to get a map back. This feels bad and wrong.
02:17carlo_auI can't evaluate (+ 1 2) in the instarepl, so that's not a threading issue ;)
02:17chippieHave seen the environ library, but would prefer not to have to install a dependency just to read a simple environment variable.
02:18TEttingerwell my problem was I could evaluate (+ 1 2) at an early point, but after evaling some long-running (?) code, it wouldn't do any more
02:20TEttingerchippie, you can call into java for this. https://github.com/niwibe/env-config/blob/master/src/env_config/environ.clj#L20
02:20TEttinger,(System/getenv)
02:20seangonechippie: (System/getenv "HOME")
02:20clojureboteval service is offline
02:21TEttingeruh... what did I miss?
02:21chippieTEttinger, seangone - Ah, thanks! I was so caught up in searching for Clojure-specific solution I never even thought to look for a Java solution.
02:21seangoneg'nite!
02:33elarsonI'm pretty sure I'm missing something here... but is this a typical pattern (def foo {}) (def foo (assoc foo "bar" "baz")) when you want to update some hashmap?
02:34carkthat's wrong
02:34carkwhy don't you do it right away ?
02:35carkwell i suppose you could do that when playing in the repl
02:36carkbut if you want to mutate foo in a program ... put the map in an atom
02:36carkthen (swap! foo assoc "blah" "bleh")
02:37elarsoncark: well here is my use case. I'm writing a craps game to learn clojure (not that it matters that much) so each player has a bank. when that person wins a bet, they get their bank updated. the bank is just a hashmap with player -> total. so I want to update the total
02:38carkwell
02:38carkthere are several ways to do that, without using any mutable state
02:38elarsonI'm totally open to different ways of thinking about it, so just saying that is a bad idea is helpful ;)
02:38carkbut it's quite usual to use an atom to hold the full state of the game
02:39carka single atom for the full state should suffice
02:40cark(def game-state (atom {:hands {"player1" [hand here] "player2" []}}))
02:40mkuitunehmm, if one would like to store the entire state history I suppose you could store those map references to a list
02:40mkuitunethen you could have a history browser functionality "for free"
02:41carkcould do that, with shared structure, clojure will do that in the most efficent way possible
02:41carkkinda
02:41cark=)
02:41mkuituneIf I've understood the current persistent map correctly once the map grows large enough most of the reference cells remain same between versions
02:41mkuitune?
02:42carkyes
02:42mkuituneIs it still using bagwells hash array mapped tries or something else?
02:42carknot sure about the bagwells part, but for the rest that sounds correct
02:43elarsonmkuitune, cark: that sounds like doing {"elarson": [14 10 26]} and using sum to get the total
02:44elarsonis that what you guys meant?
02:44mkuituneIs this still the container used for the map implementation? http://lampwww.epfl.ch/papers/idealhashtrees.pdf
02:45carkelarson: not at all ! but do not worry about this
02:46carkmkuitune: looks like it at first glance
02:46mkuituneelarson: no i meant storing the heads of the maps like [map1 map2 map3] ... but your version is probably more legible :)
02:46carkelarson: just know that once you've created a var with def, it should remain as is
02:46carkif you want to mutate it, make it hold an atom
02:47carkand mutate the atom contents
02:47elarsoncark: ok, so I gather the atom is meant to mutable
02:47carkelarson: yes
02:48cark(let [a (atom 1)] (swap! a inc) @a)
02:48cark,(let [a (atom 1)] (swap! a inc) @a)
02:48clojurebot2
02:48elarsonah and the @a dereferences the atom?
02:48carkright
02:49elarsonah ok
02:49akurilinbbloom: ping.
02:49cark,@(atom 2)
02:49clojurebot2
02:49cark,(deref (atom 2))
02:49clojurebot2
02:49ssafejavaelarson: have you seen rhickey's talk on clojure datastructures & concurrency? it's absolutely worth the 45min, blew my mind
02:49elarsonthat must have been what rich hickey meant in this talk when he mentioned reference in haskell/clojure http://www.infoq.com/presentations/Simple-Made-Easy
02:50elarsonssafejava: I think I have a while back, but I'd love to watch it again. did you have a link offhand?
02:50ssafejavayeah one sec, I just sent it to a friend yest
02:51ssafejavaelarson: http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
02:51elarson(inc ssafejava)
02:51lazybot⇒ 1
02:51ssafejavaahaha
02:51elarsonssafejava: thanks :)
02:52ssafejavanew to the channel, btw - is there a guide to what any of the bots do?
02:52carki think the source code is on github, no idea where
02:53ssafejavaI guess, more specifically, what's the difference between clojurebot & lazybot?
02:53carkclojurebot is the father
02:53carkhttps://github.com/hiredman/clojurebot
02:54ssafejavaclojurebot: how much do you know?
02:54clojurebotIt's greek to me.
02:59ddellacosta,(+ 1 2)
02:59clojurebot3
02:59ddellacosta&(map + [1 2 3])
02:59lazybot⇒ (1 2 3)
03:00ddellacostawhoops
03:00ddellacosta&(map inc [1 2 3])
03:00lazybot⇒ (2 3 4)
03:00ddellacostassafejava: https://github.com/flatland/lazybot
03:13elarsonatoms are super cool
03:13elarsonthe (swap! some-atom (fn [n])) pattern is so great
03:14hhenkelHi all, trying to fetch some info from a server and recieving an error: https://www.refheap.com/29252
03:15hhenkelThe errror occurs imho when the query-params are not used.
03:16ssafejavaddellacosta: thanks, nice link. clojurebot appears to have no docs besides its own source, but there's some fun stuff in there
03:18quizdrelarson and very useful, too. for instance, we are all, every one of us, made of atoms.
03:18ssafejavathey are an elegant solution to existence
03:19quizdr^ what he said
03:32ddellacostaIf I spit a Clojure data structure out to a file, with no attempt at preprocessing whatsoever, is the resultant format EDN?
03:34llasramddellacosta: As long as you don't have any e.g. random Java objects in the mix, then generally yes
03:37ddellacostallasram: okay, thank you. I guess the proper way to do this, generally, would be to ensure that all Java objects were stripped out or otherwise converted to something that could be read by Clojure's reader, huh?
03:38llasramddellacosta: You can define `print-method` and add tagged literal form readers for anything which isn't already readable
03:38llasramBut yeah -- in general you just have to know what's in your data
03:38llasrams,for anything,for any specific things,
03:38ddellacostallasram: gotcha, thanks. I'll have to read up on this, been lazy about the details.
04:32d11wtqWARNING: key already refers to: #'clojure.core/key in namespace: workkit.redis.jobs, being replaced by: #'workkit.redis.jobs/key
04:32d11wtqIs there a way to suppress that warning, besides changing the function name?
04:33llasramd11wtq: You can fix the underlying problem with a `:refer-clojure` form in your `ns` form
04:34llasramOr import the other namespace with an `:as` prefix alias instead of slurping it in
04:34llasramUsually you do the latter, and save the former for when writing namespaces which define functions w/ the same names as clojure.core functions
04:35d11wtqllasram: Yeah, so I've defined a ns that has a key function, which also exists in clojure.core. I'll look at refer-clojure, thanks!
04:35llasramCool beans
04:36d11wtqAh yes, (:refer-clojure :exclude [key])
04:37hhenkelAnyone around who can help me out with http-kit ?
04:37d11wtqhhenkel: Maybe. What's the question?
04:37hhenkeld11wtq: https://www.refheap.com/29252
04:37hhenkelSeems like I got a params problem when accessing the page.
04:38d11wtqhhenkel: If you perform the get without your callback, do you get the same error?
04:39d11wtqhhenkel: Just looks like an http-kit issue more than anything in your code.
04:39hhenkeld11wtq: I'll give it a try.
04:41d11wtqhhenkel: Also curious what JDK version you're using, and if this happens for all URLs.
04:42hhenkeld11wtq: Yes, still seeing the error when I use something like (def resp (client/get url options))
04:43hhenkeld11wtq: OpenJDK "1.7.0_45", the error is "normal" as long as the param "ignoreErrors=true"
04:44hhenkelis not used within the url
04:44hhenkeld11wtq: The error is kind of an feature of "jolokia" and you can get rid of it with this option
04:44noncomhi! what is way to close aleph's tcp client properly?
04:45d11wtqhhenkel: Ah I see. I'm not sure, sorry :-)
04:47hhenkeld11wtq: No prob, would you expect it to work in the way I use it? I tried to follow: http://http-kit.org/client.html
04:50d11wtqhhenkel: Ah, sorry now I'm looking at your :query-params, no, I wouldn't ;)
04:51d11wtqhhenkel: It's supposed to be a map of key-value pairs. So you'd want: {"ignoreErrors" true}
04:51d11wtqI'm not sure what the "none" is. How would that look in the URL?
04:54hhenkeld11wtq: I updated https://www.refheap.com/29252 with the opts.
04:54d11wtqhhenkel: If your query string is ?ignoreErrors=true&none, I think you need {"ignoreErrors" "true", "none" ""}
04:55hhenkeld11wtq: okay, I'll try
04:56hhenkeld11wtq: That looks much better! Thanks!
04:57d11wtqhhenkel: No dramas, apologies for the initial confusion :P
05:03noncomwhat is the easiest way to navigate the xml element emitted by clojure.data.xml/parse ?
05:03noncomit is in defrecords now, but on each level I have to descend into the :content node
05:13luxbockwhen I do C-x C-e to evaluate a form in a file, I get a complaint that the namespace hasn't been defined yet (since I haven't evaluated the ns-form)
05:14luxbockhow can evaluate the form in the user namespace?
05:14luxbockor rather evaluate it in whatever ns the nrepl buffer is set to at the moment
05:18tim_anyone know if congomongo uses connection pooling?
05:20tim_not to worry, just found the info.
05:29noncomanyone familiar with aleph here?
05:29ucbnoncom: somewhat; what's up?
05:29noncomucb: do you know what'd the proper way to close a tcp client?
05:30ucbif it's like the server, then it's a future
05:30ucbsorry; never used the client itself.
05:30noncomidk.. and how would you deal with a future that way?
05:30noncomi just need to release the port
05:31ucblet me take a look one sec.
05:37ucbnoncom: hrm; I can't figure it out. Normally with aleph servers you @(server) to stop serving requests. I can't find any similar mechanism for clients though.
05:39noncomucb: well, ok, thanks anyway! :)
05:40ucbno worries :)
05:40noncomlooks like it all goes back up to netty java classes..
05:40ucblet me know if you figure it out; I'm curious now.
05:40ucbyeah, that's as much as I could gather
05:46d11wtqWhat would be a tyical naming convention for something like to-string/from-string? Those names seem too much like method names bound to something with context.
05:46d11wtqread-string/write-string?
05:47ucbsounds reasonable
05:48d11wtqucb: Except for the fact read-string is a core function that reads in lisp. I suppose that's fine though :)
05:48llasramd11wtq: Typically you'd just piggy-back on the reader
05:48llasramSo you'd define `print-method` to get a `read`able printed representation of your object
05:49d11wtqllasram: Yeah, I'm parsing and dumping json payloads, but don't want to reveal that they are just json.
05:49llasramHuh
05:49d11wtqllasram: I mean, I don't want to reveal the implementation to the end user.
05:49llasramparse/unparase?
05:50d11wtqllasram: unparse sounds odd. Parse/dump? :)
05:50d11wtqHaha, naming things!
05:50llasramNext let's do cache coherency
05:50d11wtqHehehe!
05:50d11wtqhttp://classnamer.com/
05:53noncomi heard arrows are recommended too, like ->string
05:54d11wtqnoncom: Yeah, I've seen that for converting between data types. I think the semantics of that are more around casting though.
05:54llasramnoncom: Yeah, but usually that would just be spelled `str` :-)
05:54noncomhaha :)
05:54llasramThis seems to be something a bit more specialized
05:55d11wtqparse-str/dump-str
05:55d11wtqI particularly like dump-str. Say it fast :_
05:55d11wtq:)
05:55d11wtq(dump-str :fire)
06:01llasramheh
06:11hhenkeld11wtq: still around?
06:12hhenkelI tried to modify some example code of http-kit but I'm currently failing to return an object from my code: https://www.refheap.com/29307
06:15hhenkelI'm also unsure what this exactely does: (let [{:keys [status headers body error] :as resp} @(client/get url options)
06:16hhenkelIt fetches a object and derefences it...so far so good...
06:16d11wtqhhenkel: What output is your code producing? I've never checked the error field before, but your code looks ok.
06:16hhenkeld11wtq: The code is okay...
06:17d11wtqhhenkel: The {:keys [x y z]} thing is Clojure destructuring syntax. It's like pattern matching in other languages and lets you extract elements from complex data structures.
06:17hhenkeld11wtq: But if I try to work with the returned stuff I fail
06:17d11wtqhttp://clojure.org/special_forms#Special Forms--Binding Forms (Destructuring)
06:17hhenkeld11wtq: jolokia-client.core=> (get-data url options) resuluts in nil
06:18d11wtqhhenkel: Do you need an else clause in your callback?
06:18d11wtq(if error (...) resp)
06:19d11wtqhhenkel: Because otherwise your callback always returns nil.
06:19d11wtqhhenkel: If you don't need the callback, don't pass one. http-kit will return a map to you anyway.
06:19hhenkeld11wtq: I tried that...then I get a strange error.
06:20hhenkelhmm ,with call back your referring to the "if error" ?
06:21d11wtqhhenkel: Yes
06:21d11wtqhhenkel: Your callback is used as a filter on the response, before it is returned from client/get
06:21d11wtqAnd your callback returns nil.
06:22hhenkeld11wtq: I updated what I tried: https://www.refheap.com/29307
06:22d11wtqhhenkel: Not (resp), just resp
06:23d11wtq(resp) will try and call it as a function.
06:24hhenkeld11wtq: You're right....thanks again... :)
06:24d11wtqhhenkel: No worries. You should definitely learning how the destructuring syntax works too, as that is used all over in Clojure :)
06:24d11wtqs/learning/learn/
06:26d11wtqhhenkel: here's an article that seems to explain it quite well http://java.dzone.com/articles/clojure-destructuring
06:27hhenkeld11wtq: I will try...started with clojure in September, then was forced to pause for four months and now warming up again... ;)
06:34d11wtqhhenkel: Good luck :)
06:42katoxis (into [] lazy-seq) much faster than (vec lazy-seq) ?
06:47logic_proghttps://gist.github.com/anonymous/8686317 <-- is there some builtin function for changing "fucked up names" to readable names? i.e. util.chan$chan_open_QMARK_ ==> util.chan/chan-open?
06:48llasramlogic_prog: I believe the mangling is not generally reversible
06:48logic_progllasram: it's not a 1-1 mapping? :-)
06:48llasram,(munge "cool-beans_fun_times")
06:48clojurebot"cool_beans_fun_times"
06:49llasramlogic_prog: Correct
06:49logic_prog,(munge "a-b a_b")
06:49clojurebot"a_b a_b"
06:49logic_proghmm, does "a-b" and "a_b" get mapped to the same var ?
06:51llasram~tias
06:51clojurebotTry it and see! You'll get results faster than asking someone in #clojure to evaluate it for you, and you'll get that warm, fuzzy feeling of self-reliance.
06:51llasram:-)
06:51logic_prog,(munge "a?")
06:51clojurebot"a_QMARK_"
06:51logic_prog(,munge "a_QMARK_")
06:52logic_prog,(let [a-b 20] (println a_b))
06:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a_b in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:52Ember-http://i.imgur.com/WGDg5KB.jpg
06:52logic_progso clearly either a-b is not mapping to a_b or a_b is not mapping to a_b
06:52logic_progso it seems like munge is lying
06:52llasramlogic_prog: Well, the mangling doesn't need to happen on locals
06:52logic_prog,(let [] (def a-b 20) (println a_b))
06:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a_b in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:53logic_prog,(let [] (def a-b 20) (def a_b 30) (println a-b a_b))
06:53clojurebot20 30\n
06:53logic_progclearly a-b and a_b, being globals this time, are not clashing
06:53llasramAh, but
06:54llasramActually, the example I was going to give showed them also still not colliding :-)
06:54llasramYeah, so the vars don't colide
06:54llasramcollide
06:54llasramBut the names of the generated classes holding the function implementations will
06:55llasramSo you'll see freaky weirdness if you AOT compile
06:55llasramAnd have names which munge to the same thing
06:55logic_progllasram: I don't understand why, but out of respect for you, I'll trust it.
06:55llasramThis was actually a bug which got a bunch of discussion on the clojure-dev list recently
06:55logic_progah
06:55logic_progtell those guys the easiest way to solve th eproblem is to make munge 1-1
06:56logic_progso we can also unmunge
06:56llasramheh
06:57llasramI'll let you carry that charge :-)
06:57llasramUnfortunately it would be difficult to change the munging algorithm -- the ability to map namespaces to existing AOT'd class files depends on it
06:58llasramWould be a breaking change
06:58pyrtsa,(defrecord Oops [uh-oh uh_oh])
06:58clojurebot#<CompilerException java.lang.ClassFormatError: Duplicate field name&signature in class file compile__stub/sandbox/Oops, compiling:(NO_SOURCE_PATH:0:0)>
06:58llasrampyrtsa: Good thinking!
06:58pyrtsa,(defrecord Oops [uh-oh])
06:58clojurebotsandbox.Oops
06:59pyrtsa,(.uh-oh (Oops. "!"))
06:59clojurebot"!"
06:59pyrtsa,(.uh_oh (Oops. "!"))
06:59clojurebot"!"
06:59pyrtsaThere. :)
07:00logic_progAlright, time to compose email. to clojure mailing list. "llasram agrees me, but wants me to carry the charge ... " :-)
07:00llasramheh
07:03silasdavisI'm using timbre for logging in a web application. Most but not all activity is triggered by an incoming request, I was thinking about adding a request uuid to all my log messages when the code path up until the logging invocation started with a request
07:03silasdavisI don't want to have to explicitly add this or change my existing log messages
07:03silasdaviscan anyone suggest the best way to do this
07:03logic_progllasram: dumbass question -- why can't we just hex encode all clojure names
07:03logic_progllasram: it's not every efficient, but it should solve this issue
07:04silasdavissome kind of thread-local variable?
07:05silasdavisset by ring middleware
07:05llasramlogic_prog: It is nice if a human can figure out what a name is from the mangled version, but yeah -- something akin to URL-style hex encoding of otherwise illegal characters would totally work
07:07llasramsilasdavis: A dynamic var would provide the scope you want (thread-local, bound within the dynamic scope of the request), but I don't know enough about timbre to propose an obvious way of getting it into the log messages
07:13silasdavisIt has middleware sitting between log messages and appenders that will do it easily I think, I'll look at a dynamic var
07:36sobelcan someone help me understand what they're asking on http://www.4clojure.com/problem/19#prob-title ?
07:37sobeli get 'last' but i don't get the point of doing that one without 'last'. what approach are they trying to get me to take?
07:37llasramsobel: Think about how `last` might be implemented, and so implement it :-)
07:45sobelllasram: thx, the hardest part was eventually finding 'count' (len? length? size? google?)
07:55llasramInteresting -- I hadn't thought of that approach. Now try doing it without `count` :-)
08:01sobellast is an nth
08:01sobelwhat are you thinking, (first (reverse x)) ?
08:02lvhHello
08:02llasramWell, so some Clojure data structures know how long they are, but the general seq abstraction is more like a single-linked list -- you need to walk the whole thing to `count` it
08:02sobelmaybe this tutorial isn't demanding enough of a clever cheat-monkey like myself. if i can turn the light green i move on.
08:02llasramThere's (several) ways you can walk the structure yourself and just keep the last value
08:03lvhI am trying to figure out core.unify/logic; can someone epxlain why core.logic constraint functions ("relations") are special? like membero
08:03sobelyeah, i was actually wondering if count is legit on seqs, because what if it's a nonterminating seq
08:03lvhThe docs suggest that they wouldn't be useless anywhere else.
08:03lvhI don't understand why; == seems to work fine
08:03Morgawris there a let-keys macro or something like that to wrap around multiple (let [{:keys [whatev]} map]) calls?
08:03MorgawrI think it would be fairly useful
08:03lvhso I don't understand why membero can't just be contains?
08:04sobelusing nth count did feel hacky. so reverse is generally preferred?
08:05lvhis it because membero understands how to deal with lvars?
08:06llasramsobel: well, think about what you'd need to do to reverse a link list (hint -- you'd be doing even more work, so no)
08:06llasramI mean, none of these are "preferred" -- obviously for real you can just call `last`
08:06llasramBut for learning, these are useful things to think obout
08:06llasramabout even
08:07tbaldridgelvh: yes, but it's also more than that. membero can say "is this value a member of this collection" or it can also say stuff like "give me all possible collections where this value is a member" or "what are all the members of this collection.
08:09sobelwas first reverse the conceptual solution you were thinking of, after i used nth count?
08:09sobelor is there still another approach to understand
08:18lvhtbaldridge: Yes, I think my mind just exploded
08:19voldymanany idea how i can access the last row id after doing insert! in clojure.java.jdbc. insert! returns ({:last_insert_rowid() 3})
08:20lvhvoldyman: At the risk of stating the obvious, (:last_insert_rowid() result)?
08:20lvh(Is that a syntax error or something?)
08:20voldymanlvh: :) i tried it. it return nil
08:20voldymanno actually
08:20voldymanit still returns the same object
08:21lvhvoldyman: No idea, sorry :(
08:22algernonlvh: if you want to understand core.logic, I suggest reading The Reasoned Schemer. It is truly enlightening. (and makes it so much easier to understand core.logic, too)
08:22Morgawropinion on this macro? https://gist.github.com/Morgawr/8687711
08:22MorgawrI don't know if it exists already or not but I always have to destructure my data with :keys and this seems really useful to me
08:23Morgawr(also the map-indexed thing looks horrible to me, maybe there's a better way to do it)
08:23lvhalgernon: okie
08:28mishok13hi all, ran into a problem using Korma: https://gist.github.com/mishok13/8687718
08:29mishok13basically, there's some funky quoting in the where macro happening, but I can't figure out a way to make it work
08:29mishok13does anyone have any tips as to how passing your own quoted form to korma.core/where could be done?
08:30llasramsobel: Another approach :-)
08:34sobelllasram: i'm out
08:39llasram,((partial reduce (fn [_ x] x) nil) [:foo :bar :baz])
08:39clojurebot:baz
08:39llasramOr anything similar using loop/recur etc
08:40mdrogalismishok13: Maybe try looking into HoneySQL.
08:41mdrogalisRuntime constructed queries aren't Korma's strength
08:41sobelok, i don't know partial or reduce or _ yet but i was just reading reduce
08:41sobel(docs)
08:42sobeland recur occurred to me but i thought better of that approach
08:42llasramOh, `_` is just a convention for "I need an identifier here, but I'm going to ignore it"
08:42sobeloh _ isn't special
08:42llasramnope
08:42llasram,(let [_ :fun!] _)
08:42clojurebot:fun!
08:43llasram`reduce` is your friend though. `reduce` holds the key to all Clojure awesomeness
08:43sobelmap and filter are familiar from python use
08:44hyPiRion`for` as well, actually
08:44mdrogalisllasram: I thought #= holds the key to awesomeness.
08:44hyPiRion[x * 2 for x in y] is the same as (for [x y] (* x 2))
08:44mishok13mdrogalis: yeah, I'm considering it, but then how would I execute the queries?
08:44hyPiRion"the same" meaning ignoring laziness etc.
08:44mishok13jdbc, I presume?
08:45mdrogalismishok13: I believe so, yeah.
08:45mishok13that would suck, since it means doing unrelated refactoring in the middle of the project
08:45mdrogalisPick your poison. Either that, or unrelated derpy-ness with Korma.
08:45lvhHi
08:46mdrogalislvh: Morning
08:46lvhfirst/rest makes sense on sets, right?
08:46mishok13lvh: not really :)
08:46lvhalso is (loop [x x] ...) okay? Since Iw ant to start with the current value of x, but I'm rebinding in recur
08:47lvhso, my use case is that I have a set of people, I want to deal with them one at a time, and I need efficient disj.
08:47hyPiRionlvh: first/rest doesn't really "make sense", but first returns any value in the set, and rest returns the rest of the set as a seq
08:47lvhokay, so, it doesn't make sense in the sense that the set has no particular first element
08:48lvhbut if I want *any* element, and all the other elements for recur, then first/rest is how I spell that
08:48lvh?
08:48hyPiRionlvh: yeah, that's what I tried to convey :p
08:48lvhhyPiRion: Gotcha. Just checking if this is something I should be doing :)
08:49lvh(I understand that sets don't really have a meaningful numbered first element)
08:49hyPiRionlvh: yeah, if you want to do something for all the people, first/rest is okay. I'd try to use map/reduce first, but if you need some accumulator value, that's usually a tad hard.
08:50lvhAlso, if I have that first element, want it out of the set, as well as a related element, should I spell that (disj (rest my-set) the-other-element), or (disj my-set the-first-element the-second-element)
08:50hyPiRions/tad/bit/
08:50lvhhyPiRion: Yeah I am writing a lot of code that I am pretty sure could be written as a reduce
08:50hyPiRionlvh: the latter. The first one won't work
08:50lvhbut I don't understand reducers enough yet to be able to turn my code from one to the other
08:50hyPiRion,(rest #{1 2 3 4})
08:50clojurebot(2 3 4)
08:50lvhhyPiRion: the output of rest isn't a set?
08:50lvhegads.
08:50lvhOkay thanks :)
08:51hyPiRion,(disj (rest #{1 2 3 4}) 3) ;; Poor lazybot :(
08:51clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.APersistentMap$KeySeq cannot be cast to clojure.lang.IPersistentSet>
08:51lvh(def any-elem first)
08:51hyPiRion,(disj #{2 3 4} 1 3)
08:51clojurebot#{2 4}
08:51hyPiRionlvh: comma first :)
08:51lvhhyPiRion: I didn't mean to get the bot to execute that
08:51hyPiRionah
08:52lvh(Also I would guess that that isn't persistent so it wouldn't do much?)
08:53hyPiRionwell, someone changed that. It's a 5 min cleanup for clojurebot I think
08:53lvhoh, cool.
08:53hyPiRion,(def any-elem first)
08:53clojurebot#'sandbox/any-elem
08:53hyPiRion,(any-elem #{1 2 3})
08:53clojurebot1
08:53lvhso, whenever I do cider-jack-in, I get java.lang.IllegalAccessError: pp does not exist
08:54lvhI'm guessing that means there's some site file I accidentally typed some junk into
08:54lvhI can't figure out where.
08:54mdrogalislvh: It can't find clojure.pprint apparently.
08:55lvhmdrogalis: Oh. Okay. How do I get that?
08:55lvhDo I have to add it to each project.clj?
08:56mdrogalislvh: No, it's in core. Google the error, you'll find something.
08:57lvhOkay, thanks :)
08:57hyPiRionusually (:require [clojure.pprint :as pp]) should resolve that if you add that into the ns form.
08:57mdrogalisAnytime.
09:01lvhmdrogalis: I found something that suggests putting in (sit-for 1) into a repl init defun. That sounds a bit silly :)
09:01lvhhyPiRion: Which ns form?
09:02noncomhi, i am getting error "javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParser Factory not found" upon trying to parse an XML string with clojure.data.xml library... any ideas on how to fix this?
09:02mdrogalisWeird. Can't say I actually know how to fix it.
09:02hyPiRionlvh: well, the (ns my-namespace.here) in top of your clojure files
09:03lvhhyPiRion: oh. even if that source file doesn't actually use pp?
09:03hyPiRionlvh: uh well, no. If that's the case, then something's weird is going on
09:06mdrogalisnoncom: Do lein deps :tree and check the top for version collisions.
09:07noncomthanks, will check it out!
09:07silasdavisis there away to use git repositories as dependencies in leiningen?
09:08CookedGryphonsilasdavis: checkouts?
09:09noncommdrogalis: it gives advices on adding exclusions and stuff.. you think I should try it? whats funny, it runs fine in Eclipse CCW, but fails as a standalone jar on another machine..
09:09noncom(i mean the xml parsing fails)
09:10mdrogalisnoncom: Yes, exclusions will help.
09:10lvhhyPiRion: It may be because I told cidr to pretty-print things
09:10lvhhyPiRion: perhaps it is expecting pretty print to always be available
09:10silasdavisCookedGryphon, sort of, I was hoping for something a bit slicker than that, sort of like how you can provide git urls in ruby gemfiles
09:11hyPiRionlvh: yeah, then you should probably tell cider to execute `(require '[clojure.pprint :as pp])` when jacking in. Not sure how you do that, though
09:13CookedGryphonsilasdavis: nothing that I know of. What's stopping you just deploying it to clojars if it isn't there already?
09:14silasdavisit is there already
09:15silasdavisI have just serviced some pull requests that were left open on at-at
09:15silasdavisif I push to clojars will it namespace it under my name?
09:16CookedGryphonyep
09:17llasramsilasdavis: You need to modify the project file to use a group-id you control
09:17llasramsilasdavis: If you've done that, then you're gold
09:17daGrevishi! can someone help me with clojure deps?
09:17CookedGryphoni think if the group id in project.clj is already taken, it'll do that automatically for you?
09:17daGrevisi'm using lein exec and I want to use contrib string
09:17daGrevisi have found this https://github.com/kumarshantanu/lein-exec#getting-dependencies-from-within-script
09:17llasramCookedGryphon: Nope -- it'll just reject your push
09:17daGrevisbut I don't know how can I apply it together with http://richhickey.github.io/clojure-contrib/string-api.html
09:17CookedGryphonoh, I'm sure I've done that before without having to edit the project.clj
09:18llasramCookedGryphon: *shrug* I may be mistaken, but that is at odds with my understanding of the system
09:19llasramdaGrevis: (a) anything clojure.contrib is ancient history and unlikely to work, unless you're stuck on Clojure 1.2 for some reason
09:19llasram(b) The official Clojure github repos are under the `clojure` org now, not the richhickey user
09:19daGrevisllasram, ohh. well I would like to use string.substring?. where could I find it?
09:19CookedGryphonllasram: it might depend whether the project.clj already specifies a group-id or you let it pick the default one
09:19llasram(doc subs)
09:19clojurebot"([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."
09:20llasramdaGrevis: ^ that?
09:20daGrevisllasram, not subs. substring? like to check if "xy" is in "xyz"
09:20daGrevisllasram, tried with (some) but it has a lot of boilerplate
09:22llasram,(#(not (neg? (.indexOf %1 %2))) "xyz" "xy")
09:22clojurebottrue
09:22daGrevisllasram, and I think that some won't work with strings, only with integers
09:22daGrevisllasram, yes, that's an option. can I do it w/o Java?
09:23llasramGiven that Clojure strings are Java strings, not technically, no :-)
09:23llasramAvoiding JVM method interop to avoid it is a way to be very unhappy writing JVM Clojure
09:23devn,((complement neg?) (.indexOf "xyz" "xy"))
09:23clojurebottrue
09:23daGrevistoo bad, I'm not a big fun of Java
09:23devni like that a bit better, just nitpicking
09:23hyPiRionpeople
09:23daGrevis*fan
09:24hyPiRion,(.contains "xyz" "xy")
09:24clojurebottrue
09:24llasramhyPiRion: Dorb
09:24devnoh, was that was he was trying to do?
09:24mdrogalisdaGrevis: I don't think any of us are 'fans' of Java, but you're gonna have a bad time if you don't leverage the runtime better.
09:24llasramI knew that was there. I just couldn't remember the method name
09:24daGrevisyou see, I like to imagine clojure as an standard not implementation. might as well run my code on clojure-py
09:25mdrogalisBetter get on that, tbaldridge.
09:25llasramdaGrevis: In my experience, so dreams are not yet to be :-)
09:25llasrams,so dreams,such dreams,
09:25tbaldridgedaGrevis: come to the dark side, we have super fast JITs with the best GCs on the planet :-P
09:26devndaGrevis: i think what you're saying is correct long-term
09:26devnbut right now the reality is: use the jvm
09:26daGrevislets hope it happens :)
09:26hyPiRiondaGrevis: I have a coworker who refuses to write Clojure for that reason. Problem is, creating such a "standard" is super hard if you want to compete with the JVM, and I don't think rhickey and friends got time to compete with that.
09:26devnno one does
09:27daGreviswell jvm is good and bad at the same time
09:27daGrevisit's stable and fast, but it's huge
09:27atyzHey guys. I'm trying to use core.async to validate a collection of entities asynchronously. However its not returning the collection I expect it to. Infact tis not returning anything at all. I feel that I'm doing somethign obviously wrong. https://www.refheap.com/694be39810dace491121144d2
09:27tbaldridgedaGrevis: hyPiRion: is right. I've spent way to much of the last 3-4 years researching this sort of thing. Without the features the JVM offers, getting code that runs even close to the speed of the JVM is very very hard.
09:27atyzIs anyone willing to take a look at that for a second? Just want a step in the right direction
09:28daGreviswhat about contains fn that uses java contains if the code is run on jvm, but uses X if the code is run on X runtime?
09:29daGrevisi really dislike explicit calls of Java fns, that's all
09:29llasramdaGrevis: Why?
09:29lvh actual: java.lang.NullPointerException: null
09:29lvhWoo!
09:29llasramI mean, in practice?
09:29daGrevisllasram, because it means that my code will work only on jvm
09:29hyPiRionPerhaps for strings, just to bridge clj/cljs better.
09:29llasramYes, but where else are you going to run it?
09:30hyPiRionProblem is overhead, probably.
09:30daGrevisllasram, for now, nowhere else. but you know, if clojure gets successful, there will be other runtimes
09:31daGrevisi could compare it to javascript. it would be awful to call v8 specific-fns in js
09:31llasramAnd after the Singularity, none of our code will ever be run again
09:31tbaldridgedaGrevis: when that happens, move those functions into a differend ns and port to CLJS or clojure-clr or something. At least in my code, only about 5% is host interop
09:31daGreviswhat is this Singularity you are talking about, llasram ?
09:31lvhHow do I spell (thing map) except when thing is nil? Is (get thing map) good?
09:32hyPiRiondaGrevis, llasram: Actually, I'd rather just write Java calls and then use use contrib.tools.analyzer to rewrite the code for the other runtime. I'm sure bronsa is at it already :p
09:32hyPiRionGranted, that would be interesting for me, not sure if it suits you.
09:35llasramhyPiRion: Oooh. That would be fancy.
09:35llasramdaGrevis: http://en.wikipedia.org/wiki/Technological_singularity
09:36CookedGryphonatyz: <!! is the blocking version for use outside of go blocks, inside a go block use <!
09:37CookedGryphonso you're probably locking all your threadpools before they've done anything
09:37atyzCookedGryphon: Thanks for the reply. I still don't get the collection back. it just returns the channels
09:38CookedGryphonthreads*
09:38CookedGryphonokay, so go returns a channel
09:39CookedGryphonsorry, I'm not sure I follow the code
09:39CookedGryphonwhy aren't you putting the entities onto the challen
09:39CookedGryphonc is an empty channel with nothing on it
09:39CookedGryphonso nothing is ever going to come out of it...
09:40atyzI thought that the (async/map< #(f entities) c) would put them onto the channel?
09:40CookedGryphonno, map< will apply the function to each item as it passes through the channel
09:40CookedGryphonand returns a channel with your transformed values coming out of it
09:41CookedGryphononto-chan puts the contents of a collection onto a channel
09:41atyzOh, so I would need to (map #(async/!> %) entities) ?
09:41atyzor (async/map> entities c)
09:42CookedGryphonstep back, what's the basic idea here
09:42CookedGryphonyou have a list and you want to validate them one by one and have the items come out of a channel once they've validate
09:42CookedGryphond
09:42atyzCorrect
09:43lvhI have a bunch of persons, defined as: {... :partner other-person}. Is there a group-by :partner, except that I know everything should be 1:1, so group-by except dont put things in a vector + complain loudly when an association already existed
09:44CookedGryphonso, you want to do (onto-chan c entities)
09:44llasramlvh: Nothing exactly like that that I'm aware of, but easy enough to do in a `reduce`
09:44CookedGryphon(let [validated (map< valid-entities c)] ...
09:44CookedGryphonand then pull the values out of that new validated channel
09:45CookedGryphonsorry, map valid-entity?
09:45CookedGryphonin fact you don't want to map at all do you, you want to filter<
09:46atyzYou're very right
09:46CookedGryphonthen you can use async/into to pull the results out into another collection, or you could pull them out one by one with <! or feed that channel into something else
09:47atyzThanks so much! Youv'e been a great help. I'm going to try this
09:47CookedGryphonnot sure what you really gain by doing this with core async though, if this is all there is to the problem
09:47CookedGryphonyou might be better looking at reducers for parallel filtering with much less boilerplate and confusion
09:48atyzCookedGryphon: Its a simple problem I'm using to try out the library
09:48CookedGryphonin that case carry on :)
09:52lvhllasram: Okay. How do I break out of a reduce by raising an exception? I'm guessing it's return an exception from the reducing function?
09:53llasramlvh: No -- if you throw an exception, the exception will propagate normally
09:54lvhI didn't realize I could throw in clj :)
09:55llasram,(throw (ex-info "Alaram!" {:bells :many}))
09:55clojurebot#<ExceptionInfo clojure.lang.ExceptionInfo: Alaram! {:bells :many}>
09:56hyPiRionalaram sounds like character
09:56hyPiRion*some character
09:56hyPiRionlike Radagast.
09:56llasramYeah, I meant to say "alarum". Alaram the Red sounds pretty badass though
09:57hyPiRionhehe
09:57sandbags0i may be imagining it but isn't there already a way of breaking out of a reduce? I'm sure I read some such just a few days ago
09:57Bronsasandbags0: reduced
09:57sandbags0Bronsa: thank you
09:59daGrevislazyness rules so much
10:00daGrevisthought my code is super fast but actually it wasn't evaluated. :( :D
10:03shep-werkdaGrevis: can't get much faster than that!
10:03daGrevisfrom instant to 7s :(
10:03shep-werkonly thing faster would have been to not write it in the first place :-)
10:03daGrevishttp://vpaste.net/u0pzI
10:05ddellacostadaGrevis: why are you doing three filters like that, rather than composing your predicates together and doing it in one, any reason?
10:06ddellacostaand holy heck what is up with that range
10:07daGrevisddellacosta, i don't know any other way. can you show me?
10:07ddellacostadaGrevis: ah, okay
10:07daGrevisddellacosta, are you talking about step being 2013?
10:07ddellacostadaGrevis: naw, just complaining 'cause my repl is spitting out numbers endlessly
10:07ddellacostaheh, one sec
10:15tim_i'm confused about the map function with an anonymous function, for example: '(map #(format "<p>%s</p>" %) ["1" "2" "3"])' What does the last '%' represent? the input list??
10:15lazybottim_: Uh, no. Why would you even ask?
10:15tim_:-)
10:16arkhanyone have any opinions on using Future vs. CompletionHandler for java.nio.channels.AsynchronousSocketChannel ?
10:16RickInAtlantatim_ when declaring a function with #() the % is a standin for a passed parameter
10:16hyPiRiontim_: the last % represents the first input value given. In this case, it is "1", "2" and "3", respectively
10:17RickInAtlanta(map #(* 2 %) [1 2 3])
10:17RickInAtlanta,(map #(* 2 %) [1 2 3])
10:17clojurebot(2 4 6)
10:18dkinzer,(map #(% 2 4) '(+ - *))
10:19clojurebot(4 4 4)
10:19dabbeling_in_clohello there i'm just starting with clojure , if I start a new project with leiningen and then go into the project with lein repl, how do I "re evaluate " I my namespace if I make changes to my file?
10:19dkinzerthat didn't work as expected :)
10:20tim_ok, thanks. So if i wanted to replace the anonymous function with a named function, such as (defn f2 [keyword] (str "<p>" keyword "</p>")), would it need to take the list as an argument as well?
10:20dkinzer,(map #(% (% 2 4)) '(+ - *))
10:20clojurebot(nil nil nil)
10:20llasramtim_: The first % in your original is just part of the format string
10:20llasramIt has nothing to do with the anonymous function
10:20dkinzer,(map #(-> (% 2 4)) '(+ - *))
10:20clojurebot(4 4 4)
10:21tim_@llasram Sorry, was interested in the last '%'
10:21RickInAtlanta,(map #(% 2 4) [+ - *])
10:21clojurebot(6 -2 8)
10:21arkhdabbeling_in_clo: are you using a repl at the command line or through an editor like emacs?
10:21dabbeling_in_cloarkh: I use the command line
10:21dkinzer(inc RickInAtlanta)
10:21lazybot⇒ 1
10:21dabbeling_in_cloarkh: I use the command line, and a seperate text editor
10:22tim_(use 'namespace :reload-all) may help
10:22RickInAtlantajcrossley3: did you have to drive anywhere yesterday?
10:22ToxicFrogdabbeling_in_clo: IME, without using additional libraries, quitting and restarting the repl is the only reliable way; (use 'namespace :reload-all) works sometimes.
10:22llasramtim_: Ok -- thought I sensed some confusion there. Otherwise you can just do e.g. (fn [x] (format "<p>%s</p>" x))
10:22ToxicFrogdabbeling_in_clo: people have in the past recommended using tools.namespace (https://github.com/clojure/tools.namespace) and then using its (refresh) function.
10:23jcrossley3RickInAtlanta: i did! i had to save a few of my neighbors. :)
10:24dabbeling_in_cloToxicFrog: thanks that will do until now :)
10:24RickInAtlantaglad to hear you didn't get stuck any where. I didn't leave the house
10:25jcrossley3RickInAtlanta: i heartily recommend honda ridgelines in freezing snow, fwiw
10:26ddellacostadaGrevis: this isn't much of an improvement but it's a bit easier to read I think: https://www.refheap.com/29352
10:26RickInAtlantaI'll remember that if I ever move back north. Down here, I just don't go out in it.
10:27daGrevisddellacosta, why did you choose rem over mode?
10:27daGreviss/mode/mod/
10:27daGrevisand why do you dislike zero?
10:27ddellacostadaGrevis: oh, I don't have any great reason for it, was just playing around
10:28daGreviswhat's the benefit for using distinct instead of set?
10:28ddellacostadaGrevis: oh, did I leave that in? yeah, I don't know if it's any better than your solution. Again, just playing around with those two, seeing if there were other ways to do it.
10:28daGrevisddellacosta, thanks for (all fn).
10:29ddellacostadaGrevis: still wicked slow though. I take it you're just playing around in the repl though?
10:29daGrevisddellacosta, what do you mean?
10:30ddellacostadaGrevis: well, if you force evaluation it's going to be doing a linear search through a buttload of numbers, I believe
10:31daGrevisddellacosta, force-eval with and, you mean?
10:32daGrevisdistinct is **much** slower than set.
10:32daGrevis( :D
10:32daGrevis* surrealanalysis (~kevin@23-25-48-173-static.hfc.comcastbusiness.net) has joined
10:32daGrevis* aspotashev has quit (Ping timeout: 272 seconds)
10:32daGrevis* sputnikus has quit (Ping timeout: 260 seconds)
10:32daGrevis* zan-xhipe has quit (Remote host closed the connection)
10:32daGrevis* federkasten (~federkast@ad046065.dynamic.ppp.asahi-net.or.jp) has joined
10:32daGrevis* eraserhd (~jfelice@74.201.7.112) has joined
10:32daGrevis* aaronj1335 is now known as aaronj1335_
10:32daGrevis<shep-werk> daGrevis: can't get much faster than that!
10:32daGrevis<daGrevis> from instant to 7s :(
10:32daGrevis<shep-werk> only thing faster would have been to not write it in the first place :-)
10:32daGrevis<daGrevis> http://vpaste.net/u0pzI
10:32daGrevis* animated has quit (Ping timeout: 252 seconds)
10:32ddellacostadaGrevis: what's going on there
10:32daGrevis* goodger has quit (Ping timeout: 272 seconds)
10:32daGrevis* bertrandk (~bertrandk@135-23-72-39.cpe.pppoe.ca) has joined
10:32daGrevis<ddellacosta> daGrevis: why are you doing three filters like that, rather than composing your predicates together and doing it in one, any reason?
10:32daGrevis* lnostdal (~lnostdal@2001:8a0:4925:6801:8bd:21b9:afe1:1184) has joined
10:32llasramObviously a paste error
10:32daGrevis* TEttinger (~notostrac@76-217-24-241.lightspeed.irvnca.sbcglobal.net) has joined
10:32daGrevis* federkasten has quit (Remote host closed the connection)
10:32daGrevis* baoist has quit (Quit: baoist)
10:32daGrevis<ddellacosta> and holy heck what is up with that range
10:32daGrevis<daGrevis> ddellacosta, i don't know any other way. can you show me?
10:32daGrevis<ddellacosta> daGrevis: ah, okay
10:32ddellacostallasram: yep.
10:32daGrevis<daGrevis> ddellacosta, are you talking about step being 2013?
10:32daGrevis* john2x has quit (Remote host closed the connection)
10:32daGrevissorry....
10:32ddellacostaI'm having flashback
10:32daGrevis25s vs 7s
10:33lnostdalwell hello #clojure
10:33ddellacosta*a
10:33daGrevissorry for spam, missclicked middle-click on Linux
10:33surrealanalysisIt made me feel important, at least :)
10:33ddellacostahahaha
10:33lnostdal:D
10:33goodgerwhat in satan's glorious name
10:33gfredericks(inc daGrevis)
10:33lazybot⇒ 1
10:33AeroNotixCan I (require) code from other test/*.clj files when using core.test?
10:33ddellacostash*t happens
10:33llasramAeroNotix: Why would you not be able to?
10:33AeroNotixdunno, just asking
10:34joegallomaybe you should try it, and see
10:34daGrevisso why is set so much faster than distinct on a string?
10:36llasramdaGrevis: With `distinct` you build the set anyway to make sure each item is distinct, but are repeatedly checking the set to see if each item is distinct, performing overhead to build the seq of distinct items which are returned, then you walk it again linearly to get the count
10:36ddellacostadaGrevis: well, distinct is actually filtering through stuff in Clojure whereas set is just creating a set (which is a Java object I believe)
10:36ddellacostaor what llasram said much more eloquently ^^
10:36llasramdaGrevis: With the set you just add everything, then get the stored count of items
10:37daGrevisI'm trying to apply and, but it splits out different results. any ideas why? http://vpaste.net/a9QQS
10:38MorgawrI'll ask again, maybe now there are different people, what do you guys think of https://gist.github.com/Morgawr/8687711 this macro? Is there something similar already?
10:38llasramdaGrevis: You aren't actually calling `digits-unique?`
10:38Morgawrbecause I find it useful for my codebase but I'm not sure if it's safe and/or reasonable
10:38llasramJust including the (always truthy) value of the function itself in the `and`
10:39daGrevisllasram, ye, my bad. thanks
10:39llasramMorgawr: Why is that better than the standard binding form?
10:40daGreviswhat what what !? it runs 7x faster than using three filters
10:40Morgawrllasram: because in my codebase I usually have to destructure a lot of maps and get their keys to use as variable (passing state around etc etc)
10:40Morgawrand it gets tiring when I write multiple (let [{:keys []} map1 {:keys []} map2] etc etc)
10:40zerokarmaleftdaGrevis: why are you checking to see if your range is divisible by 2013 when you're stepping by 2013 anyway?
10:41llasramMorgawr: Sure, but it's like what -- 2 characters shorter? And you can't use it with any other binding forms
10:41Morgawrit's not 2 characters shorter when you have 4-5 maps to destructure
10:41daGreviszerokarmaleft, good point
10:41Morgawrplus it looks tidier to read imo
10:42Morgawrobviously if I don't have maps but have something else to assign I have to use an inner (or outer) normal let but that's expected
10:42zerokarmaleftdaGrevis: I'd replace (range 2013 9876543210 2013) with (iterate (partial + 2013) 2013)
10:43llasramMorgawr: I see. It might mean you are over-using maps :-) It's a bit too trivial for my taste, but I can see the argument. Consistency w/in a code base w/ that sort of thing is probably the most important
10:44Morgawrllasram: It's a game engine where entities are made of components, an entity is a map of components and components are maps of inner state, I can't really do it in another way :P
10:44Morgawrso usually I have code that extracts components from an entity, then extract individual fields from the required components, does some computation and then repackages everything
10:45Morgawraka I deal with maps a lot
10:45gfredericksMorgawr: the f# name is unnecessary
10:45Morgawrgfredericks: is it?
10:45llasramzerokarmaleft, daGrevis: and probably then add a `first` or `take <n>`
10:45Morgawroh well, since it's outside of the quote part I guess you're right
10:45Morgawrnot going to conflict with anything
10:45gfredericksMorgawr: exactly
10:45Morgawrgood point
10:45Morgawrsame for i# and e#
10:46MorgawrI wrote that just to be safe but yeah, didn't think it through
10:46gfredericksMorgawr: I don't think this is a terrible macro; the impl might be slightly clearer with partition-all instead of map-indexed
10:46gfredericksbut I think it's pretty obvious what it does
10:46gfrederickswhich is a good attribute for a macro I think
10:47Morgawrgfredericks: oh, right, I didn't like map-indexed myself so I was looking for a better way
10:47Morgawrpartition-all might be useful
10:53luxbockhttps://gist.github.com/8690806
10:53luxbockhow do I unlazify this mess?
10:53luxbockI thought doall was the solution but maybe it's not working because I'm using the threading macro?
10:53Anderkentdoall realizes, but doesnt unlazify
10:54Anderkenti think you just want seq
10:54Anderkent,(str (doall (map inc [1 2 3])))
10:54clojurebot"clojure.lang.LazySeq@7c42"
10:55Anderkent,(str (seq (map inc [1 2 3])))
10:55clojurebot"(2 3 4)"
10:55luxbockalright thanks
10:56hyPiRion,(pr-str (map inc [1 2 3]))
10:56clojurebot"(2 3 4)"
10:56zerokarmaleftdaGrevis: if I'm correctly understanding what your snippet is trying to do:
10:56lvhWhat is the right way to interpolate some text into a string
10:56zerokarmaleft,(take 5 (filter #(= (count ((comp set str) %)) (count (str %))) (iterate (partial + 2013) 2013)))
10:56mdrogalis,(doc format)
10:56clojurebot(2013 4026 6039 8052 12078)
10:56clojurebot"([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
10:56lvhmdrogalis: Thanks!
10:57quizdr,(println "hi, christine!")
10:57clojurebothi, christine!\n
10:59lvhmdrogalis: Is there an alternative that supports named keys instead of by-index?
10:59mdrogalislvh: Not sure.
10:59Anderkentyou mean in format? not in core java
10:59Morgawrgfredericks: https://gist.github.com/Morgawr/8687711 do you think this might look better? I don't like having to use that map to add {:keys } to the first element of all the pairs (is there a better way?) nor I like having to use flatten + vec
10:59Morgawrbut I guess it's better than the previous one
10:59Anderkenti think java 8 brings that in?
11:02Anderkentmaybe not. Pretty sure apache commons lang has something like that though ;p
11:03stuartsierraThere's a string interpolating macro in core.incubator I think. Hasn't been touched in a while so beware.
11:14gfredericksMorgawr: you can use mapcat instead of map + comp, and then [~@key-bindings] instead of ~key-bindings
11:15Morgawrgfredericks: thanks
11:16ghadishaybanHas anyone gotten friend + openID to work behind a load balancer?
11:16ghadishaybanI'm getting a 'No association found, contacting the OP for direct verification' failed inside OpenID4java
11:23cemerickghadishayban: Should just work; there's an openid example at http://friend-demo.herokuapp.com, which of course always runs behind a load balancer
11:24Anderkentghadishayban: do you pass a custom consumer manager to the workflow?
11:25Anderkentghadishayban: if so, you might not be initializing it fully? See http://stackoverflow.com/questions/7645226 - similar error, friend does most of this in https://github.com/cemerick/friend/blob/master/src/cemerick/friend/openid.clj#L107 but only if it's building the manager itself
11:26Anderkentuh actually nvm, it's not even a similar problem, tricked by google's removal of literal quotes again!
11:27ghadishaybanAnderkent: Huh?
11:27Anderkentjust ignore me :P I searched wrong (no 'literal' option in search tools) and got that stack overflow question thinking it's related. blame google.
11:27Anderkent(s/literal/verbatim. Anyway)
11:30ghadishaybancemerick: are there multiple nodes behine the load balancer at friend-demo?
11:30Anderkentghadishayban: do you get another error following that message? the 'no association' shouldn't abort the entire flow, it just means it can't verify the signature locally
11:31ghadishaybanAnderkent: You're totally right, it continues with: No association found, contacting the OP for direct verification...
11:32ghadishaybanAnderkent: which returns a document with is_valid:false
11:32cemerickghadishayban: no; friend's openid impl just uses the default in-memory backend for openid4java. You can either implement a distributed/cluster-aware component for the corresponding bit in its API, or restrict logins to a single node.
11:32ghadishaybanAnderkent: Direct signature verification failed with OP: https://www.google.com/accounts/o8/ud
11:32cemerickghadishayban: relevant lines: https://github.com/cemerick/friend/blob/master/src/cemerick/friend/openid.clj#L107
11:32ghadishaybancemerick: ty
11:33cemerickghadishayban: oh, or you can just turn on session affinity (if your LB supports it)
11:33ghadishaybancemerick: but it still should be able to perform the direct sig verification, right?
11:34cemerickghadishayban: Don't know, I try to forget as much as I can about openid, etc. :-P
11:34ghadishaybancemerick: heh yeah
11:34cemerickI'm guessing not, even "direct" verification requires a couple of redirects, so if you land on a different web server, you're SOL
11:35Yamazaki-kunanyone just get an email from Apress? "vbvhgvhg" "BUY OUR BOOKS" "Use promo code MKJKJH by MM/DD/YY"
11:35Yamazaki-kunI'll be disappointed if that promo code doesn't do anything.
11:35Yamazaki-kunslaps the copyeditor?
11:35xnilis that the actual promo code?
11:39ghadishaybancemerick: thanks for your help. The direct verif requires redirects in your own app (the Relying Party)? I guess I have to dig in to the spec
11:40cemerickghadishayban: Honestly, no idea. If you can turn on session affinity, that's absolutely the easiest way to go.
11:48bbloomakurilin: pong
11:57Pupeno_wDoes anybody remember that comic, black and white, where a guy learns that closures and poor man's objects and then learns that objects are poor man's closures?
11:59MorgawrPupeno_w: no but I'm intrigued now haha
12:01lvhclojure.contrib.strint does what I want, but it appears to be a gnarly macro that takes a string at compile time
12:01lvhis there a runtime equivalent?
12:01lvhI'm reading templates from files.
12:03devnwell, it's another macro, but there's: https://github.com/alandipert/interpol8
12:03devnlvh: ^
12:03S11001001Pupeno_w: Yeah I remember it.
12:03S11001001Pupeno_w: (not where I saw it, if you're asking :)
12:04AnderkentS11001001: remember a quote or title or something ? :P
12:04Pupeno_wI'm trying to find it.
12:04Yamazaki-kunxnil: I have no idea. Probably just a placeholder, unless they decide to play along and enable it
12:04Pupeno_wI already blew my partner's mind with Smalltalk... Clojure is next and the comic at the end so she goes into deep meditation.
12:04Yamazaki-kunwhat, Erlang's not enough for mind-blowing?
12:05devnlvh: is that at all what you're looking for?
12:06devnlvh: one more for you: https://gist.github.com/blacktaxi/1676575
12:06Anderkentlvh: just wrap http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/text/StrSubstitutor.html if you can't find anything. I'd expect anything that wraps java.util.Format will be a macro (it'll pick out the names out of the string and replace them with ints)
12:06RickInAtlantapupeno_w this isn't a comic, but it starts with a story http://c2.com/cgi/wiki?ClosuresAndObjectsAreEquivalent
12:07devnlvh: both call read-string, so maybe not ideal
12:07devnbut im mostly okay with it
12:07Pupeno_wRickInAtlanta: mmhh... that's definitely what I'm remembering. I wonder if someone turned it into a comic or it was my mind making shit up.
12:15lvhAnderkent: I have no problem that it is a macro
12:15silasdavishas anyone used timbre to write multiple logs
12:15silasdavislike a separate error log and request log?
12:15llasramlog4j 4 life
12:15lvhAnderkent: Although I guess there's no good reason for it to be a macro if it's just doing straught interpolation
12:16silasdavisllasram, srsly?
12:17llasramsilasdavis: Every single Java logging framework is overly complicated, but I can turn log4j into a homogonous stream of text-lines on stderr easier than I can with most of the others
12:17gfrederickslvh: macros can parse a format string ahead of time
12:17llasrameven homogeneous
12:17lvhgfredericks: Right, I understand, but the thing is that I don't necessarily know the format strings ahead of time
12:17lvhgfredericks: I guess maybe I could make it so that I can? I guess?
12:19lvhgfredericks: It just seems to me that if it can be done at compiletime, there should be some easy way to just do it at runtime instead?
12:19lvhmaybe I want apply-macro, except the docstring suggetss against it ;)
12:21gfrederickslvh: some macros with this goal will do compile-time if possible and runtime otherwise
12:21gfrederickscan also accomplish such a thing using :inline metadata
12:21gfredericksbut if this isn't a perf issue for you already them probably don't bother?
12:22lvhgfredericks: Right; I haven't written any code yet. It's my understanding that strint's (>>) simply does not work without a string literal
12:22lvhbut I could be wrong :)
12:24llasramlvh: Nothing is purely compile time, because there is always "eval"
12:25technomancyeval is compile time =)
12:25technomancycompile time is just a subset of runtime
12:25gfrederickslvh: yeah that's probably true; it could be rewritten to support both
12:26llasramtechnomancy: Fair enough
12:27gfredericksruntime is just a subset of time
12:27gfredericks~time
12:27clojurebottime is limited
12:28gfredericks,(clojure.set/subset? (set "time") (set "limited"))
12:28clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
12:28gfredericks&(clojure.set/subset? (set "time") (set "limited"))
12:28lazybot⇒ true
12:29gfredericksif you have a sufficiently small universe of objects you can implement bags using prime numbers for elements and positive integers for bags; then inclusion and subbag? are both divisibility checks
12:30gfredericksunion is LCM?
12:30gfredericksintersection is GCD
12:30gfredericksI doubt this is actually useful
12:41elsenNext time I'll need to use bit-strings to solve a problem I'll go for the prime representation instead
12:41elsenthanks gfredericks
12:46gfredericksbitstrings are for sets, not bags
12:54gfredericksjust split the routing step out of the base ring handler so the middlewares know what route was matched
13:03tim_hi, is pedestal a widely used framework?
13:16technomancytim_: I don't get that impression
13:16technomancynot that I would know
13:17tim_thanks
13:28akurilinbbloom: was going to run a couple of ideas regarding cancan in clj by you, let me drop you a line later in the day when I'm at the office
13:28bbloomakurilin: ok
14:51eyepatchCould someone explain these results to me? I know that last is slow and linear time, but this seems outrageous. http://ideone.com/6vSlaN
14:57edbondeyepatch, time returns early because of laziness
14:58edbondeyepatch, compare (time (map (fn [_] (Thread/sleep 2)) (range 10)))
14:58edbondeyepatch, and (time (doall (map (fn [_] (Thread/sleep 2)) (range 10))))
14:58edbond,(time (doall (map (fn [_] (Thread/sleep 2)) (range 10))))
14:58clojurebot"Elapsed time: 24.298924 msecs"\n(nil nil nil nil nil ...)
14:58edbond,(time (map (fn [_] (Thread/sleep 2)) (range 10)))
14:58clojurebot"Elapsed time: 0.124207 msecs"\n(nil nil nil nil nil ...)
15:02edbondeyepatch, so you got time result first and then repl do the work of realizing lazy sequence
15:04edbondgot time result => you measure time to create lazy sequence
15:05eyepatchedbond, that makes sense, but how do I tell it not to do that? conv to vec?
15:06edbondeyepatch, use dorun/doall/doseq
15:06edbondeyepatch, http://onclojure.com/2009/03/04/dorun-doseq-doall/
15:06edbondeyepatch, and https://stackoverflow.com/questions/9143837/in-clojure-is-there-a-doseq-like-function-that-receives-a-function-instead-of-b
15:08bbloomedbond: i've needed that several times. whenever i make it, i call it "each"
15:09eyepatchWow. I've been working in the completely wrong areas.
15:09eyepatchTaking 1 ms down to < 1 ms instead of working the other 762 ms
15:10xnilHey. I'm following the instructions for getting Clojure working in Emacs here http://clojure-doc.org/articles/tutorials/emacs.html and I've run into the following issue when running `M-x eval-buffer` on ~/.emacs.d/init.el : "error: Package `starter-kit` is not available for installation"
15:13xnilAny idea why?
15:15carktry X-x package-refresh ?
15:15carkM-x
15:16carkpackage-refresh-contents actually
15:22xnilcark: excellent, thanks
15:22carkyay !
15:43CaptainLexIs clojure still dependent on jre6?
15:44hiredmanjre6 is the minimum required version of the jvm
15:45hiredmanwell, I should say, whenever 1.6 is released it will be
15:45CaptainLexBut we can use jre7 if we want to now? I seem to recall when I started there was an issue with use jre7
15:45hiredmansure
15:45CaptainLexCool, thanks hiredman
15:51ghadishaybancemerick: got the OpenID woes sorted out. Turns out that openid4java will attempt to make associations with the provider, then fallback to a direct verification of a client's presented cert
15:52ghadishaybancemerick: that is a violation of the spec, and Google will fail the verification if Association was already performed
15:52ghadishaybancemerick: So I had to call .setMaxAssocAttempts -> 0 on ConsumerManager, which friend allows you to do
15:53mercwithamouthi could have sworn you could start the server like this with light table/compojure...can someone thump me on my head please? http://d.pr/i/niPh
15:53ghadishaybancemerick: that way both nodes behind the balancer will never Associate and instead call Google for direct verification. Good enough for our purposes
15:53mercwithamouththis is what i get for taking 2 week breaks from clojure
15:54ghadishaybanmercwithamouth: (use) first, then (in-ns)
15:54mercwithamouthahh oops
15:55BobSchackA zipper is the data structure I want to use if I need to get an element and the elements to the the left and right of it. I'm trying to implement the borderline sequence of Fortune's algorithm (http://blog.ivank.net/fortunes-algorithm-and-implementation.html)
15:56mercwithamouthghadishayban: that gets me part of the way there. there was something i used to do where i could just (use 'fossacube.repl) then (star-server) why i didn't write it in my notes is beyond me
15:56mercwithamouththat still doesn't work for me either for some reason...
15:57ghadishaybanmercwithamouth: so at this point you have to do a :reload
15:57ghadishaybanmercwithamouth: the first time you did (ns foo) it loaded foo, and now Clojure thinks it's loaded, so will no-op
15:58ghadishaybanmercwithamouth: (use 'foo :reload) , then (start-server)
16:01mercwithamouthahh got it!
16:01mercwithamouththat's it...
16:01mercwithamouthif i start a instarepl from handler.clj then everything loads as it should
16:01mercwithamouththank you
16:21bobajettnoob question - what am I missing here? (let [f 'print] (f "hello"))
16:21dnolenbobajett: just doesn't work
16:21sdegutisbobajett: ##(let [f println] (f "hello"))
16:21lazybot⇒ hello nil
16:21edbondlooks like macro
16:22dnolen'print is a symbol completely unrelated to print the function
16:22sdegutisNobody knows why it works that way, it just does.
16:23insamniacTherefore aliens.
16:23sdegutisWow, that response made my day.
16:23sdegutis(inc insamniac)
16:23lazybot⇒ 1
16:23insamniac:D
16:23bobajettso if f has a function as a symbol in it - and I want to apply f. Do I need to eval it? apply it? ((eval f) "hello")?
16:23stuartsierra,('+ 1 2)
16:23clojurebot2
16:24stuartsierra##('+ 3 4)
16:24lazybot⇒ 4
16:24sdegutisbobajett: why not just store the function itself in f?
16:24edbond,(let [- +] (- 2 1))
16:24clojurebot3
16:24SegFaultAXbobajett: If you ever think to yourself "I need to use eval for this", you've probably gone horribly wrong somewhere.
16:24stuartsierraOh, inlining arithmetic screws with that.
16:24edbondnice, should use somewhere :)
16:24stuartsierra,('assoc {} :a 1)
16:24clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: Symbol>
16:24SegFaultAXNot always of course, but most of the time.
16:25AimHereRedefining arithmetic operations looks like the beginnings of an obfuscated clojure contest entry
16:25bobajettSegFaultAX: good to know. I guess Im trying
16:26sdegutisOh wait, aren't symbols also functions to look themselves up in an associative coll?
16:26sdegutisKinda like keywords?
16:26sdegutisThat would explain why you can't just do (f "hello") in OP's original e.g.
16:26cark,('hello {'hello "hello"})
16:26clojurebot"hello"
16:26sdegutisOkay that makes sense now.
16:27stuartsierraI don't think that's promised.
16:27sdegutisstuartsierra: better? ##(promise ('hello {'hello "hello"}))
16:27lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: core$promise
16:27carkstuartsierra: you mean this symbol behaviour is unspecified ?
16:28stuartsierraI'm not sure.
16:28stuartsierraIt's been that way since 2008 at least.
16:29sdegutisWell, the great mystery is solved. Time to quit my job and move to the sunny islands.
16:29shaungilchristbobajett: (let [f (resolve 'print)] (f "hello"))
16:29stuartsierrahttps://github.com/clojure/clojure/commit/3b7c161286fd469857ff66013f785bef742e3b07
16:29carkah back in the days, we were young, ritch's hair was seemingly alive
16:30bobajettI guess Im trying to convert this lisp code into clojure and looking for the clojure way to do it: (let ((f '+)) (funcall f 1 2)) -> 3
16:30bobajettshaungilchrist: would that imply lisp's funcall = clojure's resolve?
16:31sdegutisbobajett: ##(let [f +] (f 1 2))
16:31lazybot⇒ 3
16:31sdegutisbobajett: Alternatively, ##(let [f +] (apply f [1 2]))
16:31lazybot⇒ 3
16:31mmitchelltechnomancy: Regarding Leiningen and private repos... Is it possible to have Leiningen do a password prompt?
16:32technomancymmitchell: yes, it should prompt for a password on deploy if none is given
16:32mmitchelltechnomancy: cool, so just setting the username in project.clj will trigger that?
16:32bobajettsdegutis: but isn't + the actual function itself in your code rather than a symbol? in the lisp code f is a symbol '+ and not the + function itself
16:32technomancymmitchell: prompting for a password on reads I don't think is supported; I believe it would be too tedious.
16:32sdegutisbobajett: Yes, but I don't see how that matters. What is the higher-level goal you're trying to accomplish?
16:33sdegutisbobajett: You may want the var, which is Clojure's rough analogy to CL's symbol.
16:33technomancybobajett: funcall does what clojure's resolve does, but also does more
16:33sdegutisbobajett: ##(let [f #'+] (f 1 2))
16:33lazybot⇒ 3
16:35shaungilchristbut for the sake of insanity: (defn funcall [x & args] (apply (resolve x) args))
16:35shaungilchrist"one crazy trick that other clojure developers hate"
16:35sdegutisOops sorry, it was actually streetlight-lit rain.
16:36dsrxshaungilchrist: https://pbs.twimg.com/media/BeoLcheCAAAiftC.png
16:36sdegutis"Clojure devs hate him! Transliterate your Common Lisp code in 21 days with this one weird function."
16:37bobajettsdegutis: Im working through The Little Schemer and they're trying to write a function like (filter your-test some-list) and trying to show that you can set your-test to some symbol and the definition of filter can just apply it via (your-test args)
16:37sdegutisztellman: add that one to your stack
16:37shaungilchristhahah
16:37ztellmanha
16:37bobajetttechnomancy: thanks! got it
16:39mmitchelltechnomancy: So for this: ":username :env/archiva_username" - Leiningen will look in the ENV for ARCHIVA_USERNAME?
16:40mmitchelltechnomancy: OK got it! It looks for an upper-cased version of :env/foobar, cool.
16:42technomancyright
16:43gfredericksaccess a value in your map with this one weird keyword
16:44nwolfeexit
16:44ztellmangfredericks: https://twitter.com/ztellman/status/368080217761251328
16:48sdegutisMight try out ClojureCLR soon.
16:56ztellmansdegutis: is that still alive and kicking?
16:56sdegutisno idea, but i hope so
16:56sdegutislast commit was 2 months ago, so maybe? https://github.com/clojure/clojure-clr/commits/master
17:01xnilIs it possible to do (case (type something) java.lang.SomeType return-value-1 java.lang.SomeOtherType return-value-2)
17:02sdegutisxnil: probably, since case just needs compile-time values
17:02hiredmanno, java.lang.SomeOtherType is not a read time constant
17:02sdegutis,(case (type "foo") java.lang.String 3 java.lang.Integer 4)
17:02clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching clause: class java.lang.String>
17:02sdegutisOh.
17:02hiredmanat read time it is a symbol that later is resolved to an instance of a class
17:03xnilThen how may I do what I'm trying to do?
17:03sdegutisxnil: cond
17:03hiredman(instance of the class Class)
17:03xnilah okay
17:03xnilthanks
17:03sdegutisxnil: or use a hash-map and look it up
17:03xnilsdegutis: oh, i can use these as keys
17:04sdegutisOr you could make an RPC call to LaaS (lookups as a service)
17:04xnili like the hash-map idea
17:04sdegutisI had a dream this morning where Apple and MS started DaaS (drawings as a service) as a new way to create GUI apps.
17:04sdegutisBasically you just draw the app you want on paper and mail it to them, and they make it for you.
17:05sdegutisI think that's the direction Apple's going.
17:05fowlslegsl
17:06teslanickThis sounds like a great idea. They could put all those apps into a category on their respective app stores that I would never have to look at.
17:06teslanick"Crap we built with the GUI builders in our IDE, then submitted to the app store."
17:06sdegutisIt's even easier and cheaper than using Interface Builder OR Storyboards, since you only need a pencil and paper.
17:08teslanickLooking at my phone homescreen, all of the apps on it are either Apple-made, or (to one degree or another) ignore the cocoa touch UI
17:08teslanickExcept fucking Alien Blue. Shows how much time I spend on Reddit.
17:11sdegutisWoo, just found a new alternative to IRC: https://news.ycombinator.com/item?id=7147396
17:21gfrederickssdegutis: it links back to the hacker news homepage? is this some joke I don't get?
17:21sdegutisyes
17:21sdegutisgfredericks: it's a bad joke
17:21sdegutisI never learned how to make good noes.
17:21sdegutis*ones
17:22gfredericksI've made at least a hundred bad jokes in this channel
17:22gfredericksjust this week
17:22sdegutisgfredericks: impressive
17:23AeroNotixFor one of my projects lein uberjar doesn't finish
17:23AeroNotixit's a project with a -main function, AOT is skipped for this file.
17:38mmitchelltechnomancy: Hey, I'm attempting to use encrypted credentials but getting this error, have you seen this before? Could not decrypt credentials from ~/.lein/credentials.clj.gpg
17:38mmitchellgpg: can't query passphrase in batch mode
17:38mmitchellgpg: decryption failed: secret key not available
17:41mmitchelltechnomancy: what's weird is that "gpg -d" successfully decrypts my credentials.clj.gpg file
17:42technomancymmitchell: hm; not sure what's going on there
17:43technomancyit should prompt you
17:43mmitchelltechnomancy: oh, I'm using gpg v 1.4.16 -- do I need >= 2 ?
17:43mmitchellit's the stock mac gpg
17:45AeroNotixhttps://github.com/AeroNotix/pismo
17:47technomancymmitchell: there's a stock mac gpg?
17:47technomancyI use 1.4 myself but I know lots of people use 2
17:48mmitchelltechnomancy: oh really? Weird, yes it came with my mac
17:52Raynestechnomancy: I like the reds.
17:52RaynesThey are quite suitable.
17:53technomancyglad to hear it =)
17:54technomancyI just discovered this project yesterday and have been unable to get it out of my head http://geekhack.org/index.php?topic=48718
17:54technomancykind of tempted to build another mech keyboard that's tiny so I can have one for home and one for the road
17:56eggheadclojure.core.async.impl.timers.TimeoutQueueEntry cannot be cast to clojure.core.async.impl.timers.TimeoutQueueEntry
17:56eggheadWELP
17:56technomancyclojurebot: we warned you about records
17:56clojurebotI don't understand.
17:56technomancyhrm; forgot the exact words
18:01Raynestechnomancy: I think the reason that I'm cool with reds is because I pretty much pound on my keyboard.
18:01RaynesSo I always bottom out anywyas.
18:01rasmustobrowns are the coolest
18:01Raynesanyways*
18:01Raynestechnomancy: Also, these are 100% definitely quieter than browns.
18:01Raynestechnomancy: I place a keyboard with browns side by side with it.
18:01technomancyRaynes: a das?
18:02RaynesThe keyboard with browns wasn't a das, but why would it matter?
18:02technomancyI literally have a red switch next to a brown switch on the board I'm using right now and can't tell the difference in sound
18:02technomancywell, plate-mounted switches are going to sound different from PCB-mounted ones, for starters
18:02technomancydifferent placing of the circuit board will absorb the sound different wais
18:02Raynestechnomancy: The keys on the red das are designed differently than the rest of the das line.
18:03RaynesSo perhaps that makes it seem quieter?
18:03technomancycould be, yeah
18:03rasmustosome people do that o-ring mod for bottoming out
18:03AeroNotixOooo I'm in the market few a new keyboard. I've got a Cherry G80 at the moment, previously had a Unicomp Customizer.
18:03rasmustoim using a hhkb lite 2 that I stole off an oscilloscope
18:06akurilinPutting my vote in favor of Realforce. Been using one for 3+ years.
18:06rasmustothose are super top-end right? like $300?
18:07akurilinYeah.
18:07akurilinA bit cheaper these days.
18:07rasmustoI'll have to try one out at best buy sometime :p
18:07akurilinelitekeyboards.com I think has them for 240
18:07akurilinYeah I don't think you can find them at a store, they're imported from Japan.
18:07akurilinCould be wrong though.
18:07rasmustoI was joking a bit :)
18:07AeroNotixHeathens and your tenkeyless boards
18:08rasmustoAeroNotix: tenkeyless "otaku" keyboardss*
18:08akurilinrasmusto: I get it now, sorry :P
18:08AeroNotixrasmusto san
18:08AeroNotixso lame
18:08AeroNotixhoi hoi me so korea
18:08akurilinAeroNotix: I used to hate it at first, then I got used to using the qwerty digits.
18:08AeroNotixqwerty digits, as in you don't even have the 1-9 keys?
18:08rasmustoI still have a printout of programmer dvorak in my drawer
18:09akurilinAeroNotix: I mean the regular digit keys, as opposed to the keypad
18:09RickInAtlantathere is a programmer dvorak?
18:09akurilinUsed to love the keypad on my natural ergonomics 4000
18:10rasmustoRickInAtlanta: it's dvorak with a few of the symbols moved around, and you have to shift+1 to get digits from up there
18:10akurilinThe leatherette on those things, yum.
18:10rasmustoRickInAtlanta: and it does 1234567890 -> 67584839201 or something weird
18:10AeroNotixso lame
18:11RickInAtlantawow, I dont' understand reordering the numbers
18:11rasmustoparedit makes programmer dvorak obsolete
18:11rasmustoRickInAtlanta: yeah, it's done under the assumption that you use the lower digits more frequently, so you don't have to use your pinky
18:11technomancyI was shifting around the layout on my ergodox a couple times a day for the first week or so
18:12TimMcBrown? Red? What?
18:12TimMcrasmusto: I use a right-handed mouse with my left hand.
18:12rasmustobrown feels like a muddy version of blue
18:12technomancyTimMc: http://deskthority.net/wiki/Cherry_MX_Brown
18:12RickInAtlantatechnomancy: i never heard of ergodox until you mentioned it yesterday. My first thought was "I could have dvorak on my laptop"
18:12rasmustoTimMc: I used my g5 wrong-handed for a while, wasn't fun
18:13technomancyRickInAtlanta: firmware-level turns out to be less convenient than it sounds unless you forgo the internal keyboard of your laptop entirel
18:13technomancyy
18:14RickInAtlantaI suppose the easy solution would be to make new labels for my keys and use mapping at the os level.
18:14rasmustoRickInAtlanta: check out "otaku" keyboards (no labels haha)
18:15rasmustoRickInAtlanta: don't actually, I regret it everytime I have to type in a passphrase
18:15RickInAtlantarasmusto: that is much better than wrong labels
18:15RickInAtlantapicture password!
18:16dkinzerI have a Dell Model:SK8115 (not sure if it's mechanical or not, but it has all the keys I need. Oh, and it says in the in small print (Made in China).
18:17RickInAtlantacanadian language keyboard???
18:17lazybotRickInAtlanta: How could that be wrong?
18:18sdegutisTip of the day: You can use two :as clauses when destructuring a map, one to get specific keys and one to name the map itself.
18:18TimMctechnomancy: I... I see.
18:18rasmustosdegutis: can you do that with :keys as well?
18:18technomancyTimMc: blues for life though, natch
18:19rasmustotechnomancy: how's the tinnitus?
18:19technomancyrasmusto: glorious
18:19sdegutisI personally do (POST "/whatever" [param1 param2 :as {:keys [db user]} :as request] ...)
18:19rasmustotechnomancy: <3
18:19sdegutis... with some middleware to wrap the request with a DB instance and assoc a user if you're logged in.
18:21rasmusto,(let [foo :as {:keys [a b]} {:a 1 :b 2}] [a b foo])
18:21clojurebot[1 2 :as]
18:21rasmustooh, whoops
18:23sdegutisSorry, wasn't trying to kill the conversation, just felt the need to projectile-vomit that code snippet into the channel.
18:23sdegutisI think that'll be my new verb in place of "offer" or "throw out there".
18:24rasmustosdegutis: i confused myself, what's the :as getting bindings from?
18:24rasmustoparam2?
18:24sdegutis,(let [{:keys [a b] :as m} {:a 1 :b 2}] [a b m])
18:24clojurebot[1 2 {:a 1, :b 2}]
18:25rasmustosdegutis: it looked like you were using :as outside of a map destructuring though
18:25sdegutisrasmusto: That's part of Compojure.
18:25rasmustosdegutis: ahhh, gotcha.
18:25sdegutisThank/blame weavejester for that.
18:25rasmustoI'm just unfamiliar is all.
18:26sdegutisAlthough he's never around. Out rakin the big bucks in. http://bit.ly/1ffUZuq
18:34dkinzerquit
18:34dkinzeroops..
18:52sritchieany core.typed + emacs users in the house?
18:52sritchielooking for workflow advice
18:56technomancysritchie: I don't use it, but I have opinions on how it should be used, does that count? =)
18:57sritchiehaha, maybe even more so
18:57technomancythat is, I have ideas of how to build commands that you invoke from your editor but are implemented server-side
18:57sritchieI'm interested in the techtonic ideal
18:58technomancyactually I wrote most of my thoughts up here: http://p.hagelb.org/clojurewest-2014.org.html
18:58technomancytl;dr: with an agreed-upon convention for how to annotate vars, you can construct editor commands which feel first-class as if they were written in elisp, vimscript, etc but are actually pure-clojure
18:59technomancyand this can help you avoid re-inventing the wheel for every editor
18:59technomancyas well as letting you skip out on writing a bunch of elisp
18:59sritchieyeah man, I'm on board
18:59technomancycome see my talk, if it gets accepted =)
19:01rasmustotechnomancy: at /west?
19:01rasmustooh nm, saw the url
19:01technomancyyeap
19:01sritchiethis clearly feels like the right approach for evaluating type-annotated code via emacs
19:02sritchietechnomancy: the current lein plugin runs the "compiler" as if it was a block of unit tests, it seems
19:03technomancyI don't think this should be a plugin
19:03technomancyfor basically this reason; not having it available in the repl is silly
19:06akurilinIs there a general pattern out there for retrying SQL transactions? Do you just give yourself a max num of tries / timeout period and hammer the DB until the transaction goes through?
19:08sritchietechnomancy: yes
19:09sritchietechnomancy: I guess :injections could call check-ns?
19:09technomancylearned that lesson the hard way with lein test
19:10sritchiestill hackish
19:10technomancysritchie: once it's a proper dependency yo ushould just use an :alias to lein run -m whatever.typed
19:10sritchiesure, I meant if I wanted to run the checker every time I evaluated anything in the project
19:11technomancyoh hrm. every time you evaluate anything?
19:11sritchieI'm using Schema really heavily now; the runtime checking sort of gets at the feel of the core.typed repl integration you're talking about
19:11technomancyyou could use :prep-tasks to invoke it on every lein invocation
19:11sritchiethe same way the compiler type checks on every evaluation in a typed lang
19:12sritchietechnomancy: otherwise, no instant feedback on type signatures
19:12technomancyyeah, you would need an nrepl middleware for that
19:23_ericif I had an array of maps (like you would often get from a JSON API that lists things)
19:23_ericis there an easy way to pluck out two things from the map and turn the whole thing into a mapping of one of those values to the other?
19:23_eric(like a name to ID lookup table)
19:24aperiodic(into {} (for [{:keys [name id]} maps] [name id]))?
19:25technomancy,(map (comp (partial into {}) (juxt :k :v)) [{:k 1 :v 2} {:k 3 :v 4} {:k 5 :v 6}])
19:25clojurebot#<ExceptionInfo clojure.lang.ExceptionInfo: Don't know how to create ISeq from: java.lang.Long {:instance 1}>
19:25technomancydang it
19:25_ericsweet
19:26x^2hey guys, simple question
19:26technomancy,(map (comp (partial apply hash-map) (juxt :k :v)) [{:k 1 :v 2} {:k 3 :v 4} {:k 5 :v 6}])
19:26clojurebot({1 2} {3 4} {5 6})
19:26x^2if i am using a sequence, like (apply + [1 2 3 4 5])
19:26_erictechnomancy: I'm looking to create a single map
19:26x^2is there any effective difference between that and (apply + '(1 2 3 4 5))?
19:26x^2or is it just convention
19:27x^2they seem to work the same
19:27technomancy_eric: gotcha; you'd need to either apply merge or switch to a reduce
19:28technomancyx^2: they work the same if the list contains nothing but literals
19:28technomancyx^2: if you have an expressions that evaluates to something else, they are different
19:28x^2okay that makes sense
19:28technomancy,(apply + '(1 2 3 (+ 3 4))) ;frinstance, this won't work
19:28x^2so if i have expression that evaluate to something else i want to use '(stuff)
19:28clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number>
19:28AeroNotixis there something like Erlang's make_ref() ?
19:28x^2right?
19:29x^2oh
19:29technomancyno, you would use a vector if you didn't want to prevent evaluation
19:29aperiodic,(into {} (map (juxt :k :v) [{:k 1 :v 2} {:k 3 :v 4}]))
19:29clojurebot{1 2, 3 4}
19:30technomancyoh, much nicer
19:30x^2user=> (apply + [1 2 (+ 1 2)])
19:30x^26
19:30x^2that works
19:30x^2is that the standard way of doingi t?
19:30technomancyx^2: typically you'd use a vector unless you have a reason not to
19:31x^2okay, cool.
19:31x^2are there other times when you really should use '(1 2 3) instead?
19:31technomancysure, to prevent evaluation
19:33technomancyor if you want to build up a list from the head; you can only efficiently grow a vector at the tail
19:34x^2interesting
19:34x^2i've just been playing with REPL a lot while i read this book, but i am trying to actually write something in clojure
19:38tmciverIf anyone is interested in a Clojure job in Framingham, Massachusetts, feel free to PM me.
19:38devntmciver: on site?
19:39AeroNotix,(. clojure.lang.RT (nextID))
19:39clojurebot27
19:43yesachowdy folks
19:43yesacI was wondering if anyone has experience or tips for clojure - scala interop
19:44yesacmore precisely, on using scala libraries in cojure
19:44bbloomyesac: first, you need to be able to use scala libraries from java.... which it turns out, isn't easy
19:44yesactell me about it
19:45bbloomyesac: https://issues.scala-lang.org/browse/SI-4389
19:45bbloomyesac: other than that, it works exactly like calling java code
19:45bbloomif possible, wrap the scala code in a lowest-common-denominator java interface, then call that
19:46yesacthe library in question is https://github.com/snowplow/referer-parser/blob/master/java-scala/README.md
19:46yesaci'm half tempted to take the python port and hack it in jython
19:47yesacin this particular case, the interface is useable, it's just very ugly
19:47yesaca lot of boilerplate is required because the scala None class is truthy in clojure
19:47bbloomyesac: um, that says java-scala
19:47bbloomit's written in java and is wrapped by scala
19:48bbloomyesac: just use the java classes directly
19:48noonianlol, it should be pretty straightforward to write that java usage example in clojure
19:48yesacargh
19:48yesacyou are so right
19:48yesacwhat the hell was I thinking this morning?
19:48yesaci guess I scrolled down to the Scala example. fun.
19:48bbloom....
19:49nooniani think that is the base java classes, it's called java/scala because it is the java and scala interface to referer-parser
20:25kristofWhat?
20:25clojurebotWhat is sampling a random integers betwen 2, 12 s..t. P(X = i) = (7-|i-7|)/36
20:26kristofA day where bitemyapp isn't even idling?
20:28devnheh
20:28technomancyone too many senseless NPEs pushed him over the edge
20:28devnbut you have devn and technomany
20:28devntechnomancy*
20:28technomancyit's OK; I contain multitudes
20:28devnwe've been idling since practically the beginning
20:29devnserious idlers.
20:29metellusnot that serious, if you're talking
20:29devnwell, i've been watching the channel all day
20:30devni think i'm allowed a few lines
20:32kristoftechnomancy: Wait, what happened?
20:32rhg135idling...
20:32technomancykristof: pure speculation
20:32kristoftechnomancy: Ok.
20:35akurilinSo it looks like fireplace will wait for the remote command to complete before returning the output of it to the editor. As in, if I want to run a very lengthy operation printing progress as it goes, that won't work with fireplace since it will wait until the very end to return the output.
20:35akurilinIs that more or less correct?
20:37aperiodicakurilin: that's consistent with my experience, yes. you could try writing progress out to a file and then tailing it in another terminal
20:38mmitchelltechnomancy: What would be the best way to have leiningen pull in username/password (for private repos) from a regular text file? A plugin?
20:38akurilinaperiodic: ok cool, thanks for confirming.
20:40Bronsabbloom: btw surprisingly, it's faster to use `~@ than to flatten
20:40bbloomBronsa: huh? how is that possible?
20:41Bronsabbloom: probably because all the `~@ machinery only concats small vectors while flattening has to walk all the bytecode
20:42bbloomBronsa: don't you need to walk all the byte code to output it anyway? you only need one flatten at the top level, right?
20:45Bronsabbloom: right, but I cannot merge the flattening walking and the emit walking otherwise it would not be possible to implement e.g. `omit?` https://github.com/clojure/tools.emitter.jvm/blob/master/src/main/clojure/clojure/tools/emitter/jvm/transform.clj#L56
20:45bbloomBronsa: ... hmm what's this do?
20:45akurilinaperiodic: well the workaround I tried was with just using lein repl :connect instead
20:46akurilinaperiodic: as in, I'd write / reload the ns in vim and would actually runt he operation in lein
20:46akurilinlame but oh well
20:46Bronsabbloom: nothing fancy for now, just a POC. it's a dummy matching on the bytecode to eliminate some no-ops
20:47bbloomBronsa: why can't you do this as part of the same traversal as the flattening?
20:47bbloomBronsa: also, you can use reducers to eliminate a whole bunch of overhead for intermediate structures
20:47bbloomBronsa: that's what i do in fipp & it performs great
20:48Bronsabbloom: say I want to eliminate a double check-cast, if I'm emitting while flattening there's no way to know if the next instruction is a check-cast so that we can avoid emitting the current one
20:48Bronsait would be possible to know if the previous one was a check-cast but at that point it would already have been emitted
20:49bbloomBronsa: there are more peephole optimizations you can do too besides those with lookahead of N=1
20:50bbloomBronsa: look at https://github.com/brandonbloom/transduce
20:50bbloomBronsa: if you your loop variables in the state value of map-state, then you can stitch together the traversals either lazily or with reducers instead of using an eager loop
20:51timvisherit looks like ring-serve is no longer supported, what are people using nowadays?
20:51bbloomthe lazy implementations are easier to read: https://github.com/brandonbloom/transduce/blob/master/src/clojure/transduce/lazy.clj
20:51bbloombut the reducers implementations are much faster
20:52timvisheri'm specifically trying to start up an nrepl server _and_ a ring server via `lein run`
20:52timvisheri used to do that via ring-serve but it depends on a very outdated version of ring-devel
20:52timvisherand i use hiccup as well, so they screw eachother
20:52bbloomBronsa: if i'm understanding you and this code right :-P
20:57Bronsabbloom: sorry, internet connection died
20:57bbloomBronsa: what did you get last?
20:58bbloomBronsa: or check logs :-P
20:59timvisherah hah. there is apparently an :nrepl configuration knob in ring nowadays. looks like i can just use that.
20:59bbloomBronsa: lmk when you're caught up :-)
21:03bbloomBronsa: in short, peephole optimizations can be implemented as mapcat-state with reducers & should perform quite well. you can use flatten on the source data, map-state and mapcat-state for optimization passes, then each at the end to call -exec
21:03bbloomBronsa: https://github.com/brandonbloom/fipp/blob/master/src/fipp/printer.clj for an example
21:04bbloomBronsa: anyway, i'm curious how a doseq/emit works without the omit? phase. if that's any faster than all the concats
21:05Bronsabbloom: ok, I see what you mean, that's an interesting approach that I didn't consider
21:06bbloomBronsa: can do much faster too if you give up on the pretense of being functional/pure and expose a "send to next pass" function
21:07bbloomBronsa: which is basically how reducers work internally anyway
21:11Bronsabbloom: I don't have much time in the next few days but I'll think about it & try something out. I like the idea & I can see how it could simplify/speedup things
21:14bbloomBronsa: cool. lmk if i can help
21:18timvisherwould anyone else expect route params with + in them to have the + be converted to a ` ` character? it seems upgrading ring has stopped that from working as well.
22:34akurilinRandom question: I'm trying to prevent double-submission of data on my ring app by storing a client-given UUID in redis and checking if it already exists in the application. Prob. of course is that fetch and check is not exactly thread-safe. I could either use redis' transactions or I could use an agent in clojure to something similar.
22:34akurilinShould I prefer one or the other?
22:35rhg135I'd say do what you know best
22:39brehautakurilin: any reason you cant use the common trick of doing returning a redirect to the same url?
22:40akurilinbrehaut: do you 302 on a POST kind of thing?
22:40brehautright
22:41akurilinIn my case this is an iOS app callign into the API, it doesn't really speak redirects.
22:41brehautah. thats painful
22:41akurilinWhat is speaks very well is submitting shit twice :)
22:42brehauthaha
22:42akurilinUhm doesn't look like Carmine does transactions.
22:42brehautand you dont have control over the code to stop it there?
22:43akurilinbrehaut: I don't because it's the hand of users for now and it might take months before they update versions.
22:43brehautah :/
22:43brehautits not a restful api is it?
22:43akurilinIt's REST-style
22:44akurilinNo HATEOAS or anything of that genre.
22:44brehautyeah
22:45brehautanyway, yeah you want some sort of transactional mechanism for serialize access to the critical region on a per client basis
22:45akurilinYessir.
22:45akurilinI was debating between agents and redis transactions.
22:45brehautagents are async so i dont think thats appropriate
22:46brehautbecause then it wont occur within the same thread as the HTTP response
22:46akurilinThat's a fair point.
22:46brehauttransactional redis would probably work fine
22:46brehautthough ive not used it myself
22:48akurilinSounds good, let me try that.
22:48hiredmanI am just watching a video of a aphyr talk, seeing the word "transactional" just makes me wince now
22:49brehautreally?
22:49akurilinFrom a sanity standpoint, if I were to make POSTs idempotent for this one case, I should probably still return a 2xx on the ones that get NOOPed, right?
22:49brehautsure
22:49brehautif its idempotent then its correct to post back the same thing multiple times
22:50brehautanyway i need to empty a garden shed
22:50akurilinThat and I just don't know what's going to happen on the client if I 4xx :P Thousands of iOS apps dying at once.
23:10fowlslegs(loop [result [] x 1 y 5]
23:10fowlslegs (if (zero? y)
23:10fowlslegs result
23:11fowlslegsSorry that was a mistake
23:13fowlslegsCan someone tell me why I'm getting a exception from this http://paste.debian.net/79142/ ?
23:16fowlslegs,(loop [result [] x 1] (recur (conj result x) (+ x (last result))))
23:16clojurebot#<NullPointerException java.lang.NullPointerException>
23:22quizdr,(last [])
23:22clojurebotnil
23:22quizdr( + 1 nil)
23:22quizdr,(+ 1 nil)
23:22clojurebot#<NullPointerException java.lang.NullPointerException>
23:23quizdrfowlslegs there you go ^
23:23quizdrfirst iteration of loop, the last of result is nil
23:31technomancyakurilin: it depends on whether you are load balancing among several server processes
23:31technomancyif so you're kinda forced to do it in the DB
23:35ssafejavaclojurebot: botsnack
23:35clojurebotThanks, but I prefer chocolate
23:37akurilintechnomancy: from what I can tell, and I don't have too much redis experience so far, I can't actually do any sort fo complex operations on redis itself unless I were to write a sproc with LUA in it. As in, if I want to do "does key exist, does its val match what I see, otherwise update it" atomically.
23:37akurilintechnomancy: and yes what you said makes complete sense, I could do the above by serializing in clojure, but that'd fall flat on its face in case of multiple instances of the app
23:38akurilinat that point I'd have to use stored procedures.
23:39akurilinI'm semi-tempted to do this all in clojure and just never expire the keys, since there's a reasonable upper bound for now
23:40akurilinI mean, just have a map in clojure and swap it, since for now it's only one server.
23:40technomancyjust depends how long it will stay that way
23:40akurilintechnomancy: do you see options outside of sprocs for a multi-server scenario?
23:41akurilinor am I correctly reading this?
23:41bbloomakurilin: do you have a rough idea of volume of data and traffic?
23:41akurilinYeah. It's low for now.
23:42bbloomakurilin: and you plan is redis plus postgres? or just redis or what?
23:42technomancyhow long is "for now"?
23:42akurilinThe only reason why I wanted redis was to expire keys when they get old, no other benefit really.
23:42bbloomakurilin: do you need that data to be durable?
23:42akurilinBut that's also a premature optimization.
23:43akurilinSo essentially the situation is: I want to prevent a double-POST based on who does it and what data is in it. I want to keep when, who and what was POSTed for up to 5 mins to prevent double-submissions.
23:43bbloomyou can expire stuff in postgres too. just run a cron job w/ a query :-P
23:44bbloomif your planned volume is sub a few thousand simultaneous users, just do http://www.brandonbloom.name/blog/2013/06/26/slurp-and-spit/
23:44technomancyand you can't use a user-generated UUID as a primary key?
23:44akurilintechnomancy: not right away because those iOS clients that are makign teh POST will take months to update
23:45akurilinIf they were web clients I'd have updated their logic in no time.
23:45akurilinBut with the fact that you're going through app stores and they're K-12 schools, they might be 6mos behind the latest verison.
23:45akurilin(which is kind of atrocious, but what you going to do)
23:46akurilinbbloom: I'll check that link out, thank you!
23:51akurilinbbloom: that's a cool trick!!
23:51bbloomakurilin: the only trick is knowing when to go back to basics :-)
23:51akurilinI like the part where you make sure the file doesn't get corrupted, that's pretty nifty
23:51akurilinIn my case I don't need durability, but that's super handy for when I do.
23:51akurilinI think raynes also made a lib for making temp files
23:51akurilinso the two can probably work in tandem
23:52bbloomakurilin: if you don't need durability, don't bring postgres or redis in to it
23:52bbloomakurilin: just use memory
23:52akurilinbbloom: again, I just wanted to feel good about old keys not staying in forever, but that's also not a big deal at this point
23:52akurilinsomeone write an expiring thread-safe map in clo9jure
23:52bbloomakurilin: just run a cleanup task in a timer
23:53bbloomjust use java.util.Timer
23:54bbloomor now i guess ScheduledThreadPoolExecutor :-P
23:56akurilinI think mikera was recommending something super basic like (future (loop [] (do-something) (Thread/sleep 20) (when (game-still-running) (recur))))
23:56bbloomyeah, that works too lol
23:57akurilinThere's also TimerTask
23:57akurilinI give up on knowing what the java libs offer at this point
23:57akurilinI'm sure there's practically everything you'd ever want if you can stomach the naming :P
23:58bbloompretty much
23:58akurilinbbloom: would it be heresy to dump that future straight into the namespace as opposed to having it in a "init" function somewhere?
23:58akurilinTrying to think of all the ways that'd mess with the state.
23:59akurilinOn reloads etc.
23:59akurilinI imagine reloading the namespace would generate a new future each time
23:59akurilinso that'd suck.
23:59bbloomakurilin: sure, so what you do is you capture the function in a local and check if it changed, if so, you abort