2015-09-28
| 00:12 | justin_smith | kenrestivo: isn't the natural way to control startup order with component to create a dependency? if you prefer a to start before b, make sure a doesn't return from its start method until full initialized, and make b depend on a, right? |
| 01:59 | kenrestivo | i did that. something's amiss. i'll figure it out eventually. |
| 01:59 | kenrestivo | now i'm chasing down how to turn off the colors in the new version of timbre. it's all changed :/ |
| 02:01 | kenrestivo | justin_smith: oh by the way i did figure that out! the log component was failing because timbre was exploding |
| 02:01 | kenrestivo | and the other components were just loading as normal. component wasn't broken. |
| 05:35 | namra | does anyone have some links that compare tuple-spaces and key/value-store (the concepts) or can someone enlighten me on the differences? because so far i can't really see a difference between them when i take an implementation for a key-value store like redis. |
| 05:47 | justin_smith | namra: aren't key/value more limited and specific than tuples? in a tuple space you can pattern match, in key/value you look up by key right? |
| 05:49 | TEttinger | also aren't tuple spaces often sorta relational? like the ontology tuple space stuff stores ("dog" "chases" "cat") ("cat" "chases" "mouse") |
| 05:50 | namra | justin_smith: true, but depends on how you structure the tuples |
| 05:51 | justin_smith | also, key-value does not provide any sort of mutual exclusion (and has no rules about lifetime at all) |
| 05:51 | justin_smith | namra: sure, but key-value only allows one structure! |
| 05:52 | namra | justin_smith: can you elaborate on "rules about lifetime" please? i probably misunderstand you here, because usually a key-value provides ttl for keys |
| 05:53 | justin_smith | also, key-value stores are often unique by key, tuple spaces allow multiple instances of the same item |
| 05:53 | namra | i see |
| 05:55 | justin_smith | namra: oh, I hadn't thought that key-value usually provided ttl. For what it's worth the wiki page for key-value database has no mention of time or ttl (not that this proves anything at all of course) |
| 05:56 | namra | ah ok so it's an implementation detail. used memcached and looked at redis and both provide the ttl option. |
| 05:57 | tdammers | those are caching solutions, not really databases |
| 05:57 | justin_smith | tuple spaces could be thought of as a specific variety of key value store I guess (though pattern matching is still more general than looking up by key) |
| 05:57 | namra | tdammers: tuplespace isn't supposed to be a database too, one can use it for caching but usually it's used for distributed process communication |
| 05:57 | justin_smith | tdammers: but a tuple space is meant to throw away items as soon as they are read, which isn't much of a db either |
| 05:57 | justin_smith | nor is it a cache... |
| 05:58 | namra | but some commercial software uses them as an in-memory database |
| 05:58 | tdammers | yeah, uhm... |
| 05:58 | tdammers | some commercial software also uses MySQL as a communication pipeline |
| 05:58 | tdammers | but anyway, OK |
| 05:59 | justin_smith | tdammers: maybe I'm thinking too specifically of the "take" usage, and other people are using copy more.. |
| 05:59 | namra | na i'm also wondering why is there no open source solution available |
| 05:59 | tdammers | just wanted to note that the "caching" vs. "database" thing is why memcached has a TTL while the wikipedia page for key/value stores doesn't mention one |
| 05:59 | namra | considering space-based architectures and what benefits they can provide. probably because memory is still too expensive |
| 06:00 | justin_smith | tdammers: ahh, OK |
| 06:00 | namra | ahh ^^ |
| 06:00 | justin_smith | namra: also because tuple-space kind of breaks when things are mutable, which means it's outside the mainstream still... |
| 06:01 | tdammers | tuple-space feels awfully related to reactive programming |
| 06:01 | justin_smith | seems like a predecessor to things like onyx too in some ways |
| 06:04 | namra | thanks guys, certainly clear things up |
| 06:04 | namra | s |
| 06:38 | dm3 | does anyone know how to change the emacs+CIDER behaviour to not complete with a single quote when pressing a backtick inside of a string? |
| 07:56 | nowprovision | using stuart sierra's component, i have several products in a database that I want to fetch every 5 minutes (yeah its not optimal from integration point of view) so they are locally fresh, I'm thinking of a loop that pulls from a timeout channel or a control channel with alts and assoc the control channel with the component, and then in lifecycle/stop send :stop to the control channel to stop the loop, thoughts |
| 07:56 | schmir | AFAIR there's a function that does the equivalent of (remove nil? (map ....)). what is it's name? |
| 07:59 | nowprovision | i dont think there is (filter (complement nil?) [1 nil 2]) |
| 08:01 | noidi | nowprovision, (remove nil? ...) |
| 08:01 | noidi | oops, I missed the line before that :) |
| 08:02 | nowprovision | what about (mapcat your-map-fn orig-col) |
| 08:02 | nowprovision | and then in your-map-fn omit [] for what you previously outputted nil |
| 08:03 | dstockton | schmir: keep |
| 08:03 | dstockton | (keep (map ...)) |
| 08:04 | nowprovision | drop the map (keep identity [1 nil 2]) |
| 08:05 | nowprovision | replace identity with the original map-fn your were enclosing |
| 08:05 | schmir | dstockton: thanks! |
| 08:06 | dstockton | sorry, nowprovision is right |
| 08:06 | dstockton | (keep fn coll) |
| 08:07 | nowprovision | i never knew keep existed, just doc'd it though, great thing about #clojure channel :) |
| 08:07 | ane | (doc keep) |
| 08:07 | clojurebot | "([f] [f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects. Returns a transducer when no collection is provided." |
| 08:34 | justin_smith | another nice specialized replacement for map is run! which is like (comp dorun map) |
| 08:35 | justin_smith | but it's actually better and reduce based |
| 08:42 | TEttinger | justin_smith: what are we both doing up in pacific time? |
| 08:42 | justin_smith | haha |
| 08:43 | justin_smith | TEttinger: I have a big deadline I'd like to hit today |
| 08:43 | justin_smith | so I'm up and at it early |
| 08:43 | justin_smith | in other words, the only motivation I understand is terror of absolute failure, so I must suffer |
| 08:43 | TEttinger | I have a deadline that I need to be somewhere tomorrow, and not being able to sleep is not playing well with said deadline |
| 08:44 | justin_smith | TEttinger: ouch |
| 08:44 | TEttinger | it's odd, I'm barely tired and not at all sleepy |
| 08:44 | justin_smith | I of course don't know what causes your insomnia, but journaling helped a lot with mine |
| 08:44 | TEttinger | I think I'll probably sleep something really weird and make it |
| 08:44 | justin_smith | heh |
| 08:44 | justin_smith | sleep-coding ? |
| 08:45 | TEttinger | I don't think it's insomnia in the normal sense. when I fall asleep I'm extremely hard to wake up |
| 08:45 | TEttinger | yes |
| 08:45 | TEttinger | I do sleep-code |
| 08:45 | TEttinger | I have lots of dreams of whatever code was troubling me |
| 08:47 | TEttinger | currently it's a C# project but the appearance of the language or Visual Studio never appear in my dream, it's all the abstract thought process of dealing with algorithms repeatedly in different ways. and every time the dream is unrelated to any real problems in the code |
| 08:48 | TEttinger | no ouroboros benzene moments here |
| 08:50 | sveri | When I started with clojure I was dreaming of paranthesis for several months night and night again |
| 08:50 | sveri | I have seen them while falling asleep and when waking up again |
| 08:51 | justin_smith | TEttinger: I often sleep-solve code problems, but it's unreliable to say the least |
| 08:52 | TEttinger | I think I have better luck just browsing the weird parts of CS wikipedia articles |
| 08:53 | TEttinger | "oooh, this could be a run-length encoding on a hilbert curve!" |
| 08:53 | nowprovision | any open thoughts on this, https://www.refheap.com/c4380845111240a385d6c8fbc i need to pull data out of a couchdb server every X minutes, ive just come up with this, I plan the change the job-fn closing over the atom, but it the general direction Im thinking, thoughts because it feel icky |
| 08:53 | nowprovision | https://www.refheap.com/c4380845111240a385d6c8fbc |
| 08:55 | Hydro-x1 | v Hello gays |
| 08:55 | Hydro-x1 | Oh sorry Hello Guys |
| 08:57 | TEttinger | hello Hydra-x1 |
| 09:05 | sveri | nowprovision: I am not sure if this method is always on point regarding timing. I you don't need it to be exact using a substraction should be ok. Otherwise you should look for a framework like quartzite or something similar |
| 09:07 | nowprovision | sveri, schedule will be X minutes in real world, some drift is fine. but http://clojurequartz.info/ looks interesting, this could take care of some other scenarios I have just to plan out, cheers |
| 09:07 | sveri | nowprovision: no problem, good luck |
| 09:16 | dzhus | If I define something in my Leiningen project.clj, how can I access it from other modules of my project? |
| 09:17 | justin_smith | dzhus: project.clj is there to tell leiningen how to build your project, it isn't meant to be part of your code. That said, you can set system properties or environment variables, and get them via System/getenv or System/getProperty |
| 09:17 | justin_smith | dzhus: environ is a nice lib for setting up this sort of thing |
| 09:18 | dzhus | justin_smith: I want to serve my project version from one of my HTTP handlers |
| 09:18 | dzhus | oh, turns out I can just :require [project] |
| 09:18 | justin_smith | yeah, the project.clj ends up on classpath iirc |
| 09:19 | dzhus | great |
| 09:19 | justin_smith | now, next question is whether you have defproject in scope in your namespace? I guess you do if that works... |
| 09:20 | justin_smith | err wait you would need defproject in clojure.core for that to work (or somehow implicitly global) |
| 09:20 | dzhus | oh, right. Somewhy it works with lein ring server but not with lein uberjar (Unable to resolve symbol: defproject) |
| 09:21 | justin_smith | dzhus: you could use (read-string (slurp (io/resource "project.clj"))) I guess, then manually navigate the data structure it hands you |
| 09:21 | dzhus | I'll just move shared definitions to a separate file and require it from project and my other source files |
| 09:22 | justin_smith | dzhus: I just tried the read-string / slurp / io-resource in my repl and that gave me a list with the version string at position 2 |
| 09:22 | dzhus | Does it work in compile time? |
| 09:23 | justin_smith | dzhus: checking it from a jar |
| 09:23 | justin_smith | yes! works from inside a jar |
| 09:23 | justin_smith | I even made sure my shell was in a totally unrelated directory just in case it ended up checking for a file too |
| 09:25 | justin_smith | dzhus: relatedly, I have a leiningen plugin that runs some git commands to verify the status of the repo (checks for uncommitted changes, gets commit hash of the current state of the repo) and stores that in the jar so we can tie a specific jar to a specific state of the codebase unambiguously |
| 09:26 | dzhus | justin_smith: I already have that too |
| 09:26 | dzhus | I think I was given code to do that on this channel, too :) |
| 09:26 | justin_smith | heh, yeah, it's a very simple plugin |
| 09:27 | bja | am I the only person who really really dislikes environ's require-time caching? |
| 09:27 | nowprovision | project.clj is just clojure so you can do (slurp verison.txt) inside project.clj, which makes it easy to pull in your app code too.. |
| 09:28 | bja | I like environ, but I have it defined in my project as `(def env [] (merge (#'environ.core/read-env-file) (#'environ.core/read-system-env) (#'environ.core/read-system-props)))` |
| 09:30 | bja | that way I can do side-effecty stuff (like read my ~/.boto) and just read my settings at system initialization |
| 09:30 | justin_smith | nowprovision: well, with ~ you can do that, sure, but I prefer to keep my project.clj declarative if possible |
| 09:30 | nowprovision | bja, given environement variables are not meant to be changed during a process lifetime I think its consistent behavior, the only one you have some argument with is .lein-env but I guess the give away is in the name, if you want to handle live config changes perhaps something like zookeeper client is better etc. |
| 09:31 | bja | environment variables aren't supposed to be changed |
| 09:31 | bja | java properties might be |
| 09:31 | bja | in fact, that's exactly how I load my ~/.boto, I parse it and then set the properties the amazon java sdk expects to find |
| 09:32 | justin_smith | bja: changing directories is done via environment variable, but I guess we can't really do that easily in the jvm can we :P |
| 09:32 | justin_smith | bja: boto? |
| 09:32 | bja | boto is the amazon python sdk |
| 09:32 | bja | my work is mixed python and clojure |
| 09:32 | justin_smith | cool |
| 09:33 | bja | it's just some credentials in an INI file |
| 09:33 | bja | but there's no reason to spew my dev credentials all over the filesystem |
| 09:33 | bja | makes it inconvenient when we rotate |
| 09:34 | nowprovision | justin_smith, i don't think unquoting is necessary, this is from an old project.clj using an old version of ragtime https://www.refheap.com/110034, things have changed now but it demonstrates the flexibility, it works well with http://12factor.net/config idea |
| 09:36 | justin_smith | nowprovision: wow, at least at one point I remember this requiring using ~ to unquote... |
| 09:37 | dzhus | why doesn't clojure use , for unquoting |
| 09:37 | justin_smith | dzhus: for whatever reason, rhickey decided it should be whitespace instead |
| 09:37 | dstockton | dzhus: , is equivalent to whitespace as it can make lists/vectors more readable |
| 09:38 | dstockton | actually, maps more than anything |
| 09:38 | dstockton | {:a 1, :b 2, :c 3} |
| 09:38 | justin_smith | I guess for people more familiar with using , for a list or hash-map delimiter |
| 09:38 | justin_smith | ,,,,,,,,,,:whitespace,,,,,,,,,, |
| 09:38 | clojurebot | :whitespace |
| 09:38 | justin_smith | don't actually do that in your code, of course |
| 09:38 | dstockton | it can help when you have a long map and multiple types of keys values |
| 09:39 | dstockton | you can lose track of which is the key and which is the value |
| 09:39 | snowell | ,(assoc,{:a,1,:b,2},:c,3) |
| 09:39 | clojurebot | {:a 1, :b 2, :c 3} |
| 09:39 | justin_smith | it's also handy as a marker in long cond calls |
| 09:40 | justin_smith | (cond q a,, r b,, s c,, :else d) |
| 09:40 | dzhus | hmmm, I can use that |
| 09:41 | dzhus | If you replace ALL whitespace in Clojure code with `,`, will it still work? |
| 09:41 | justin_smith | sure, it's just whitespace, but it would be hard to read |
| 09:41 | dzhus | that goes to my pre-commit hook right now! |
| 09:42 | justin_smith | ,((fn,f,[x],(*,x,x)),5) |
| 09:42 | clojurebot | 25 |
| 09:42 | justin_smith | haha |
| 09:44 | snowell | ,(str,(get,(assoc,{\,,\,},\,,\,),\,)) ; justin_smith, am I doing clojure right? |
| 09:44 | clojurebot | "," |
| 09:45 | justin_smith | LOL |
| 09:45 | justin_smith | that's terrible |
| 09:45 | snowell | You misspelled 'awesome' |
| 09:46 | oddcully | snowell: no, you misspelled brainfuck |
| 09:47 | snowell | Oh sorry, my mistake |
| 09:47 | TEttinger | ,((fn f [x] (* x x)) 5) |
| 09:47 | clojurebot | 25 |
| 09:48 | justin_smith | TEttinger: woah |
| 09:55 | TEttinger | ,((fn[]([]))0) |
| 09:55 | clojurebot | #error {\n :cause "Unable to resolve symbol: fn in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: fn in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: fn in this co... |
| 09:55 | TEttinger | ,((fn []([]))0) |
| 09:55 | clojurebot | #object[sandbox$eval165$__166 0x67a72e43 "sandbox$eval165$__166@67a72e43"] |
| 09:56 | TEttinger | ,((fn []([]))(+)) |
| 09:56 | clojurebot | #object[sandbox$eval191$__192 0x6c530d60 "sandbox$eval191$__192@6c530d60"] |
| 10:17 | TEttinger | hmmm... I'm wondering how to go from a 2d integer position where the 2 indices can be from 0-255, and get the length you need to advance on a square spiral (probably outward in) to reach that point |
| 10:18 | dzhus | Is anybody using compojure-api |
| 10:18 | TEttinger | if you start at the upper left as 0, then you end up with some odd numbering as you go down |
| 10:18 | dzhus | ? |
| 10:19 | justin_smith | TEttinger: I'd start with the numeric pattern formed by the square spiral going outward, then figure out how to calculate n iterations of that for a given x/y, followed by the "remainder" |
| 10:19 | justin_smith | if you're lucky you'll find a simple way to calculate the sum directly, without having to add up the paths manually |
| 10:20 | TEttinger | hmmmm |
| 10:22 | justin_smith | so 1, 1, 2, 2, 3, 3, 4, 4, 5 ... |
| 10:22 | akkad | love this channel |
| 10:22 | justin_smith | I think I see a pattern there |
| 10:23 | justin_smith | TEttinger: that's just drawing it with pen on graph paper and counting squares mind you |
| 10:23 | TEttinger | I sketched it in a text editor |
| 10:24 | TEttinger | I didn't see a pattern going outward in |
| 10:25 | tdammers | let me see |
| 10:25 | tdammers | I guess determining which loop each point is on is simple enough |
| 10:25 | tdammers | also, we can reduce the problem from "find the spiral distance between two points" to "find the spiral distance from one point to the center" |
| 10:26 | tdammers | so you could take one point |
| 10:26 | tdammers | find the loop it is on (the larger of the absolutes of the x and y coordinates relative to the center) |
| 10:26 | tdammers | find the point in the top-left corner of that loop |
| 10:26 | tdammers | and then figure out the distance from there to your point |
| 10:27 | justin_smith | sounds about right |
| 10:27 | tdammers | which in turn is a matter of finding which quadrant the point is in |
| 10:27 | tdammers | and adding the appropriate number of pixels |
| 10:27 | tdammers | I think the rest of it amounts to footwork |
| 10:29 | TEttinger | tdammers: that sounds much simpler than I thought it would! thank you |
| 10:29 | tdammers | np |
| 10:29 | TEttinger | (inc tdammers) |
| 10:29 | TEttinger | (inc justin_smith) |
| 10:29 | TEttinger | (dec lazybot_uptime) |
| 10:29 | ikitommi_ | tzhus: yes |
| 10:37 | dzhus | ikitommi_: Do you know if it should be possible to constrain request body to be an array of integers? I'm trying to do `:body [body [s/Int]]` but it simply doesn't show up in docs and is silently ignored when I actually do the request |
| 10:37 | dzhus | It works with `:body [body {:articles [s/Int]}]` but that's different because now request body is expected to be an object with one key (that's not what I want) |
| 10:47 | TEttinger | tdammers: and now I realize that even though run-length encoding on a spiral is good for a very specific set of possible point arrangements in a square, it is rather wasteful for most that aren't centered. Hilbert curves, which I was originally looking at, might actually do much better when the arrangement is not centered |
| 10:47 | tdammers | heh |
| 10:48 | TEttinger | and there's moore codes too |
| 10:49 | justin_smith | TEttinger: so by RLE here you mean encoding positions as a linear index on a space filling curve? |
| 10:49 | ikitommi_ | dzhus: yes, it should work, but currently doesn't render anything for the swagger |
| 10:51 | ikitommi_ | dzhus: wait a sec. |
| 10:54 | ikitommi_ | dzhus: here's a gist https://gist.github.com/ikitommi/977cc9fcf037770d6687 |
| 10:55 | dzhus | ikitommi_: a-ha |
| 10:55 | dzhus | thanks |
| 10:55 | ikitommi_ | dzhus: so the ring-swagger issue needs to be fixed to get it to rendered for the swagger. |
| 10:56 | dzhus | I see now, thanks for the reference |
| 10:56 | ikitommi_ | no probs. hopefully we'll get that one fixed soon. |
| 11:24 | sdegutis | This is cool: (->> results (map some-key) (filter some-thing) (clojure.pprint/pprint) (with-out-str) (spit "/some/file")) |
| 11:38 | sdegutis | I never thought of chaining pprint, with-out-str, and spit using ->> |
| 12:27 | zxc | Hello! I can't use this function, why? (user/clojuredocs min) |
| 12:27 | justin_smith | zxc: who defined clojuredocs? |
| 12:27 | zxc | justin_smith: Can you specify? I found it in a course and just can't use it, it throws an error |
| 12:28 | justin_smith | zxc: my point is it shouldn't actually exist unless someone defines it |
| 12:28 | justin_smith | maybe there's some code in the course that does so in a prior lesson? |
| 12:28 | zxc | justin_smith: Oh, maybe. I will check! |
| 12:28 | justin_smith | zxc: user/clojuredocs is not part of clojure, user is for things you define interactively in a repl |
| 12:29 | justin_smith | so it would likely be part of a repl session example, or maybe a custom user.clj but I find that less likely |
| 12:30 | zxc | justin_smith: Still throws an error |
| 12:31 | zxc | justin_smith: Can I give you a link to the course? |
| 12:33 | zxc | "You can also use (user/clojuredocs function) to see some examples for function. This should work for most of the built-in functions." But it doesn't |
| 12:41 | oddcully | zxc: please post the link here. you miss some step before this code would work |
| 12:43 | zxc | http://iloveponies.github.io/120-hour-epic-sax-marathon/training-day.html |
| 12:43 | zxc | oddcully: But I've read it all and it says nothing about it |
| 12:49 | rhg135 | The repl itself tells you this |
| 12:50 | zxc | It explodes with java exceptions |
| 12:50 | rhg135 | That message should not be there. I don't think it ever works. |
| 12:51 | oddcully | zxc: sorry no clue. the only things to find are from old clojure version. could be a thing of the past, maybe? |
| 12:51 | rhg135 | Sounds like it |
| 12:51 | justin_smith | yeah, could be a deprecated feature of nrepl |
| 12:51 | oddcully | zxc: if you need code examples you could go to http://conj.io/ for now |
| 12:52 | zxc | thank you, just wanted if I was doing something wrong here |
| 12:52 | justin_smith | zxc: also there is clojure.repl/doc which you should be able to just use as (doc +) |
| 12:52 | zxc | is it a good course, if it's that old? |
| 12:52 | rhg135 | Someone should open a ticket |
| 12:52 | zxc | justin_smith: Yeah, I've used it |
| 12:53 | rhg135 | My repl says it on start too |
| 12:53 | oddcully | maybe a plugin? my `lein repl` into 1.7 does not |
| 12:54 | rhg135 | Could just be lein using old nrepl |
| 12:54 | justin_smith | oddcully: same here, I don't see the clojuredocs message either |
| 12:54 | zxc | google says rubbish about that, by the way |
| 12:54 | rhg135 | Ah yes, it is. |
| 12:55 | justin_smith | yeah, clojure still moves fast enough that the top google results aren't all that useful |
| 12:55 | oddcully | searching for it only produces some console prints also with 1.4/1.5 clojure |
| 12:55 | rhg135 | Lein needs an update |
| 12:56 | zxc | "is it a good course, if it's that old?" - can someone help me with that? |
| 12:56 | justin_smith | oddcully: yeah, clojure.main has "Clojure 1.7.0" as the only splash message, the rest is all nrepl |
| 12:56 | rhg135 | Clojure does not change all that much api-wise |
| 12:57 | ane | ehm am i doing anything idiotic by making a ref in a let block and then returning a reified object that messes with the ref |
| 12:57 | justin_smith | yeah, the tooling is all in flux, but the lang itself has good backward compatibility |
| 12:57 | justin_smith | anything post clojure-1.0 will mostly be good I bet |
| 12:57 | zxc | o-kay,thanks a lot |
| 12:58 | rhg135 | Ane, you are doing oop in clojure |
| 12:59 | rhg135 | Stateful objects, prodding some hidden state |
| 13:02 | rhg135 | I mean it has uses, but at the fringes of your code |
| 13:11 | justin_smith | rhg135: hidden state inside the fringes? |
| 13:12 | rhg135 | Like for interop |
| 13:13 | justin_smith | rhg135: yeah, that's true, it's a funny clash of metaphors |
| 13:13 | rhg135 | An iterator over a seq |
| 13:24 | zxc | Why does (-2) throw an error, and (- 2) give just -2? |
| 13:25 | oddcully | zxc: look at the error message it hands you down |
| 13:26 | zxc | oddcully: 2 is an integer, not long, iirc |
| 13:26 | oddcully | you remember wrong |
| 13:27 | oddcully | ,(-1) |
| 13:27 | clojurebot | #error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6943]... |
| 13:28 | zxc | I still don't know why it's related |
| 13:28 | oddcully | -1 is no function, but - is a function you can call with 1 as the argument |
| 13:28 | oddcully | ,(- 1) |
| 13:28 | clojurebot | -1 |
| 13:28 | oddcully | ,-1 |
| 13:28 | clojurebot | -1 |
| 13:29 | zxc | now I understand, thank you |
| 13:31 | oddcully | ,(+ 1,000) |
| 13:31 | clojurebot | 1 |
| 13:32 | zxc | ,(+ 1 000) |
| 13:32 | clojurebot | 1 |
| 13:34 | oddcully | that was intended for you. there was some , abuse going on some hours ago and i wanted to add to it. but well spotted |
| 13:35 | zxc | it could add some confusion for a newcomer, it seemed like you were trying to add 1 to a thousand |
| 13:36 | oddcully | depending to what locale you are used to |
| 13:49 | sotojuan | completely unrelated to clojure but |
| 13:49 | sotojuan | does anyoen know of a good site or blog that goes through project euler |
| 13:49 | sotojuan | but doesnt tell you the answer, just hints/explanation? |
| 13:49 | sotojuan | ~_~ |
| 13:49 | clojurebot | It's greek to me. |
| 13:50 | Balveda | I'm trying to do a ring/http-response redirect but instead of redirecting the page's HTML is being printed out to console.. any ideas? |
| 13:51 | sdegutis | ,(load-string "(+ 2 4)") |
| 13:51 | clojurebot | 6 |
| 13:51 | sdegutis | ,*ns* |
| 13:51 | clojurebot | #object[clojure.lang.Namespace 0x4d288e1c "sandbox"] |
| 13:52 | sdegutis | ,(do (def foo 2) (load-string "(alter-var-root #'sandbox/foo (constantly 3))") foo) |
| 13:52 | clojurebot | 3 |
| 13:52 | sdegutis | Haha. |
| 13:53 | sdegutis | That is so terrible. |
| 14:02 | sdegutis | I mean, it's a bad practice to actually do that. |
| 14:02 | sdegutis | Cool that it works tho :) |
| 14:03 | rhg135 | That's a fun way to break things |
| 14:14 | roelof | why does this work (apply str (repeat n "*" ))) and not this (str (repeat n "*" )) ? |
| 14:16 | rhg135 | ,(str (range 1 10)) |
| 14:16 | clojurebot | "(1 2 3 4 5 ...)" |
| 14:17 | rhg135 | ,(apply str (range 1 10)) |
| 14:17 | clojurebot | "123456789" |
| 14:18 | roelof | rhg135: so apply is taken care that str is carried out |
| 14:19 | roelof | and that the output is a string and not a list |
| 14:20 | rhg135 | ,(doc apply) |
| 14:20 | clojurebot | "([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args." |
| 14:20 | rhg135 | It passes a seq as arguments |
| 14:21 | oddcully | (apply str '(1 2 3)) basically becomes (str 1 2 3) |
| 14:22 | roelof | oke but here I do a repeat so that is why I need apply |
| 14:22 | rhg135 | Yup |
| 14:23 | rhg135 | That produces a seq |
| 14:23 | roelof | oke, up-to the next assignment. IM learning now to use apply map and friends |
| 14:24 | rhg135 | Fun, fun, fun |
| 14:25 | roelof | http://iloveponies.github.io/120-hour-epic-sax-marathon/structured-data.html#exercise-17 and the next problems till the end :) |
| 14:25 | roelof | so for a few days a lot of fun :) |
| 14:26 | rhg135 | Soon you will wield the power |
| 14:27 | rhg135 | apply is insanely powerful |
| 14:27 | roelof | rhg135: I will see. I do exercise for exercise and see how far I will come |
| 14:28 | roelof | no hurry for a next thing till I have a idea that I understand this well |
| 14:29 | rhg135 | Just remember java methods aren't functions |
| 14:30 | schmir | memfn helps with that |
| 14:31 | schmir | ,(doc memfn) |
| 14:31 | clojurebot | "([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls." |
| 14:37 | snowell | oddcully: We weren't abusing the commas. We were treating them very well! But yeah, I hadn't thought that people might try to put commas in numbers here in 'Murica |
| 14:37 | snowell | ,(+ 400 3,000) |
| 14:37 | clojurebot | 403 |
| 14:37 | snowell | Then again, doing it with ANY separator and you're gonna have a bad time |
| 14:38 | snowell | ,(+ 400 3.000) |
| 14:38 | clojurebot | 403.0 |
| 14:38 | mungojelly | let's write a reader macro o wait |
| 14:38 | roelof | Here in the Netherlands we also use comma's . so you say 3.4 and we says 3.4 |
| 14:39 | snowell | Well we use commas to separate thousands, and then a point for the decimals |
| 14:39 | snowell | 1,234,567.89 |
| 14:39 | snowell | Which is, I believe, completely backwards from other ways of doing it |
| 14:39 | snowell | But I haven't put commas in a number since I started programming |
| 14:40 | snowell | Unless it's in a presentation for a high-up manager :) |
| 14:40 | roelof | snowell: and in the Netherlands we do it exactly the other way around :) |
| 14:40 | TimMc | snowell: Use scientific notation in that case. ;-) |
| 14:41 | snowell | Oh yeah, Americans LOVE that |
| 14:41 | TimMc | 1.23456789e6 |
| 14:43 | snowell | "Using this new method, we achieved a 1.65e-1% time reduction!" |
| 14:43 | roelof | where can I find info how to use apply with checking if a seq is monotonic ? |
| 14:43 | mungojelly | i just wish everything weren't always numbers, i don't want to choose the number of anything, why can't i ever say :wait-time :not-too-long and :box-location (prefer :upper-left), please don't make me always speak in numbers |
| 14:44 | snowell | Because there would be endless debate on what the threshold is for :too-long |
| 14:44 | mungojelly | (deviations-above :system-average 2) |
| 14:45 | mungojelly | oh no a number |
| 14:45 | snowell | SHAME |
| 14:45 | mungojelly | :enough. :enough deviations. |
| 14:46 | roelof | can I do something like apply <= seq ? |
| 14:47 | luma | sure |
| 14:47 | oddcully | ,(apply < (range 10)) |
| 14:47 | clojurebot | true |
| 14:48 | mungojelly | we have a "memory manager" as in someone who'll take out the garbage, i want a memory manager who'll decide for me whether my things get memory, how can i like control or even monitor the memory footprint of anything?? |
| 14:48 | roelof | oddcully: thanks, The exercises are getting harder now |
| 15:18 | jonathanj | liberator and friend don't seem to interact particularly well |
| 15:18 | jonathanj | at least reading <http://sritchie.github.io/2014/01/17/api-authentication-with-liberator-and-friend/> seems to indicate it's quite involved |
| 15:19 | jonathanj | is there a better option? |
| 15:24 | schmir | buddy may help - though I didn't use it. |
| 15:26 | bja | jonathanj that page you linked doesn't seem particularly awful |
| 15:31 | jonathanj | bja: i guess i'm not all that keen on using a library with no tests that is, for all intents, abandoned |
| 15:31 | bja | jonathanj: I mean, you would rather write your own tests to verify functionality or write your tests and start from scratch on the code too? |
| 15:32 | bja | obviously finding a pre-built solution would be best |
| 15:47 | jonathanj | hrm, buddy looks interesting |
| 15:47 | jonathanj | i'm wondering if there is a nice way of specifying the auth and unauthed representations of the same route with something like compojure |
| 15:52 | jonathanj | schmir: thanks, i think buddy might be more helpful considering it's less opinionated |
| 16:09 | mzdravkov | is there a way to force evaluation of argument to macro, before passinng it to the macro itself? |
| 16:13 | justin_smith | mzdravkov: by calling the macro in another macro, sure |
| 16:13 | justin_smith | mzdravkov: we call this phenomenon "macro contagion" |
| 16:33 | mzdravkov | can anyone help me with macro to generate patterns for core.match - I'm spending a second evening trying to write one and I can't make it work |
| 16:35 | amalloy | mzdravkov: the one you had last night seemed like it was working fine |
| 16:35 | amalloy | you were upset about the "30 lines of obfuscated code", but it sounded to me like exactly what you'd want to happen |
| 16:40 | mzdravkov | well, I thought it was working but it doesn't. The problem is that I have to pass the argument with some form, which has to be evaluated, but because it's a macro it doesn't evaluate it |
| 16:58 | justin_smith | mzdravkov: you can control evaluation before something hits a macro via another macro, but if the data isn't available until runtime a macro simply can't deal with that |
| 16:58 | justin_smith | mzdravkov: I don't even know if this is related to your issue though |
| 18:57 | aaelony | a colleague wants to dashboard using ruby's http://shopify.github.io/dashing/, is there anything in the Clojure world that might be comparable/better/waay-better ? |
| 18:59 | mzdravkov | I decided to post my problem to stackoverflow: If anyone wants to help: http://stackoverflow.com/questions/32832982/clojure-evaluate-argument-of-macro |
| 19:09 | justin_smith | mzdravkov: it's what I said above - the macro can't use the data because the data isn't there at compile time and macros only run at compile time |
| 19:11 | mzdravkov | justin_smith: ah, that's so unfortunate. I'll have to think for another way, maybe make my own version of match... Anyway, thanks. |
| 19:12 | justin_smith | does core.match not have an underlying function you can use? |
| 19:12 | justin_smith | I mean I am sure it wouldn't be as pretty, but it seems like it could exist hypothetically... |
| 19:16 | amalloy | i think the main thing core.match does is compile match patterns down into efficient decision trees. doing it at runtime seems like something that's possible and maybe even useful, but pretty different from core.match |
| 19:16 | amalloy | in particular it couldn't really bind the matches to variables like core.match does |
| 19:16 | justin_smith | amalloy: oh, OK |
| 19:34 | audaxion | is there any way to look at adjacent elements in a collection inside of a function like map? |
| 19:35 | amalloy | ,(doc partition) |
| 19:35 | clojurebot | "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items." |
| 19:39 | justin_smith | ~partition |
| 19:39 | clojurebot | partition is probably not what you want; see partition-all. |
| 19:39 | justin_smith | amalloy: that's a funny reversal |
| 19:39 | amalloy | reversal? |
| 19:40 | justin_smith | how many times have I mentioned partition, to have you jump in with "partition-all" |
| 19:40 | amalloy | that's hiredman's factoid |
| 19:40 | justin_smith | n/m |
| 19:40 | amalloy | i usually just use partition and forget that partition-all is better |
| 19:40 | justin_smith | the partition-all gotcha doesn't even apply with step 1 |
| 19:40 | amalloy | certainly (parition n 1 xs) is never a problem |
| 19:40 | justin_smith | haha |
| 19:40 | justin_smith | right |
| 19:41 | justin_smith | ,(map (partial apply -) (partition 2 1 [1 4 8 9 22 3])) |
| 19:41 | clojurebot | (-3 -4 -1 -13 19) |
| 19:44 | akkad | does clojure have a (ignore-errors) clone? |
| 20:28 | sdegutis | Is it possible to add a :where clause in a query where the lack of a match doesn't negate the whole rest of the query's where-clauses? |