2014-08-05
| 02:00 | michaelr` | good morning #clojure |
| 02:01 | Jaood | michaelr`: what's your time? |
| 02:09 | michaelr` | Jaood: 9 am |
| 02:10 | tybot2 | What are the most recommended intro clojure materials? |
| 02:27 | SagiCZ1 | (doc some?) |
| 02:27 | clojurebot | "([x]); Returns true if x is not nil, false otherwise." |
| 02:34 | ToBeReplaced | call for open source developers -> i'm tired of not using java.nio.file, so i started writing an extensive wrapper to make it workable from clojure, and i'd love help if anyone else wants to donate time |
| 02:34 | ToBeReplaced | https://github.com/ToBeReplaced/nio.file is beginning work... all of Path is complete, and some complicated work on copy and visitors |
| 03:16 | rritoch | Hi, does anyone know why code that compiles in Windows won't compile in Linux? |
| 03:17 | rritoch | In linux I'm getting a file not found exception |
| 03:17 | rritoch | I have verified the the line endings are in linux format on the linux machine so I don't know why it won't compile |
| 03:48 | andyf | rritoch: Does the file not found exception mention any file names in it? What file names do you have? Using Leiningen? |
| 03:56 | SagiCZ1 | how can i use functions from another namespace without the slash delimiter? |
| 03:56 | SagiCZ1 | I use "namespace/foo" but want to use "foo" |
| 03:56 | andyf | Interactively in a REPL: (use 'namespace) |
| 03:57 | andyf | In an ns declaration, many people recommend (:require [namespace] :refer :all) |
| 03:57 | nathan7 | (require [namespace :refer [foo]]) |
| 03:57 | andyf | but I did that last one from memory and I always forget the proper brackets/parens on it. |
| 03:58 | nathan7 | andyf: brackets go around the entire specification of the namespace |
| 03:58 | nathan7 | andyf: think of what it'd look like with multiple |
| 03:58 | SagiCZ1 | (ns this-ns |
| 03:58 | SagiCZ1 | (:require that-ns :refer :all)) |
| 03:59 | SagiCZ1 | this doesnt work |
| 03:59 | SagiCZ1 | sorry i forgot the brackets |
| 03:59 | SagiCZ1 | works now |
| 03:59 | nathan7 | :refer :all is generally a bad idea, it becomes hard to tell where vars came from |
| 04:01 | SagiCZ1 | nathan7: not for me.. all i do is ctrl+click the variable and it shows me the definition |
| 04:01 | clgv | SagiCZ1: better use :as anyway. you wont even have to ctrl+click ;) |
| 04:01 | nathan7 | SagiCZ1: sure, smart editors are nice |
| 04:02 | nathan7 | SagiCZ1: what if some dependency gains a var with a name that you already have in scope? |
| 04:02 | clgv | SagiCZ1: if you navigate from one place to the other having to follow a lot of variables you'll get distracted soon |
| 04:02 | clgv | nathan7: than he will cry in pain :D |
| 04:02 | nathan7 | being able to just look at the ns form and grok what's going on is a godsend |
| 04:02 | SagiCZ1 | clgv: what does :as do? |
| 04:03 | clgv | SagiCZ1: you can provide a short alias to use for this namespace |
| 04:03 | SagiCZ1 | so instead of namespace/foo i could say for example n/foo? |
| 04:03 | clgv | (:require [my.very.well.nested.ns :as m]) (m/awesome-fn 42) |
| 04:03 | clgv | SagiCZ1: ^^ |
| 04:10 | SagiCZ1 | clgv: mmmm okay, i guess that's kind of ok |
| 04:10 | SagiCZ1 | clgv: i still cant say i am excited about those slashes.. don't slash my variables clojure :( |
| 04:11 | SagiCZ1 | dots would look nicer :D |
| 04:11 | clgv | SagiCZ1: well, like that you easily know where they are from. believe me, you cant navigate to each one in a function definition to get to know that. it'll cost you a lot of time |
| 04:12 | clgv | SagiCZ1: dots are claimed for other syntax ;) |
| 04:20 | lpvb | whats the function that creates a function with a constant value? |
| 04:20 | opqdonut | ,(doc constantly) |
| 04:20 | clojurebot | "([x]); Returns a function that takes any number of arguments and returns x." |
| 04:20 | lpvb | oh ok weird name for a function |
| 04:20 | lpvb | I wouldve named it just constant |
| 04:20 | nathan7 | it just constantly returns x |
| 04:20 | opqdonut | well "constantly 3" is a pretty good description of what the return value does :) |
| 04:24 | clgv | (inc opqdonut) |
| 04:24 | lazybot | ⇒ 1 |
| 04:45 | clgv | reflection/typehint question: why does the following not work? (.myattr ^org.bla.MyClass (somefn arg)) I get a reflection warning that Object does not have "myattr" - but MyClass does |
| 04:45 | clgv | somefn is not inline |
| 04:47 | andyf | clgv: Not sure, but try (let [^org.bla.MyClass x (somefn arg)] ... (.myattr x) ...) to see if that works for you. |
| 04:49 | clgv | andyf: yes that works. the interesting thing is that it worked before and I just replaced "somefn" and it stopped working... |
| 04:50 | andyf | I am not sure, but I have a vague notion that perhaps in your code snippet the ^org.bla.MyClass is annotating the list, but not the return value of somefn. Don't take that as authoritative, though. |
| 04:51 | clgv | but usually it works to annotate the list representing the function call |
| 04:51 | andyf | clgv: When you say you replaced "somefn", do you mean you redefined somefn? Or that you had a call to a function other than somefn in your snippet, and then replaced that with a call to somefn? |
| 04:52 | katox | arrdem: just discovered grimoire (via cider update) -- most awsome, thanks! |
| 04:53 | clgv | andyfn: in fact it was an interop ".get" on an arraylist before - but that also just return Object |
| 04:53 | clgv | andyf: oh I think I know what's going on. "somefn" is a primitive function taking one "long" argument |
| 04:54 | clgv | andyfn: there seems to be an inconsistency to the behavior of regular functions with respect to annotation of non-primitive types |
| 04:54 | clgv | oops. |
| 04:54 | clgv | andyf: ^^ |
| 04:55 | andyf | Folks like Bronsa are experts on this kind of thing. I just report hearsay and guesses :) |
| 04:55 | clgv | I dont know if it is worth a ticket? |
| 04:56 | clgv | but it is certainly odd when you switch to primitive and the external type hint stops working |
| 04:56 | clgv | ,(defn f [n] (java.util.ArrayList. n)) |
| 04:57 | clojurebot | #'sandbox/f |
| 04:57 | clgv | ,(set! *warn-on-reflection* true) |
| 04:57 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set> |
| 04:57 | clgv | :( |
| 04:57 | andyf | I'm also not sure if it is worth a ticket, or whether there might already be one in this area. No big deal if there already is one, as someone will likely notice the duplication. |
| 04:58 | Bronsa | clgv: do you have an example? |
| 04:59 | clgv | Bronsa: I'll make one and post the ticket |
| 05:09 | clgv | Bronsa: andyf: http://dev.clojure.org/jira/browse/CLJ-1491 |
| 05:10 | clgv | damn one typo |
| 05:10 | clgv | can I edit the ticket description? |
| 05:11 | Bronsa | clgv: I fixed that for you |
| 05:12 | clgv | Bronsa: ah thank you :) |
| 05:13 | Bronsa | that's a weird issue, I never noticed that behaviour |
| 05:13 | andyf | clgv: If you sign the Clojure CA (which can now be done electronically), you can then request to join the Clojure Dev Google group after you are on the list of contributors, and then you get bumped up permissions for editing tickets |
| 05:13 | clgv | me neither until now ;) |
| 05:13 | clgv | andyf: ah ok. so maybe I should consider that ;) |
| 05:13 | andyf | http://clojure.org/contributing |
| 05:16 | clgv | Bronsa: my code base is split into algorithm code and analysis code. the algorithm code makes heavy use of primitive functions for performance reasons |
| 05:16 | clgv | so I'll find those traps sooner or later ;) |
| 05:16 | Bronsa | clgv: so (let [^java.util.ArrayList al (g 10)] (.add al 23)) works |
| 05:17 | clgv | Bronsa: yes, since the type hint is on the local binding |
| 05:17 | Bronsa | looks like the compiler ignores the hint on the invoke form if it can find a primitive arglist, should be easy to fix |
| 05:17 | clgv | but it is annoying to need a local binding if you need the function result only once |
| 05:17 | clgv | Bronsa: that was what I guessed ;) |
| 05:18 | clgv | Bronsa: it could even detect inconsistent type hints there. primtive type hint as result of the function and object type hint externally at call site |
| 05:26 | Bronsa | clgv: that could be assumed to be a casting |
| 05:27 | Bronsa | clgv: anyway, I should have a working patch, let me test it first |
| 05:27 | clgv | Bronsa: :D |
| 05:33 | Bronsa | clgv: attached to the ticket |
| 05:37 | Bronsa | ambrosebs: http://sprunge.us/ThJW?diff |
| 05:37 | ambrosebs | Bronsa: oh did you figure it out? |
| 05:38 | Bronsa | ambrosebs: look at line 19 of that diff |
| 05:38 | ambrosebs | oh nice catch |
| 05:38 | Bronsa | it's trying to push core.cache/core.cache instead of org.clojure/core.cache |
| 05:39 | Bronsa | also no need to setup the soruce/test dirs, the parent pom takes care of that |
| 05:40 | ambrosebs | Bronsa: can I download a raw version of that patch? |
| 05:41 | Bronsa | ambrosebs: remove the ?diff segment on the url |
| 05:57 | mpenet` | ambrosebs: any eta for c.cache 0.7.0 ? Also core.memoize (which depends on it) |
| 06:11 | clgv | Bronsa: great. now it only needs to succeed in the "integration dance" ;) |
| 06:16 | clgv | Bronsa: did you see that one, already? http://dev.clojure.org/jira/browse/CLJ-1432 |
| 06:17 | Bronsa | clgv: yes, but I'm not sure about that being a bug |
| 06:18 | ambrosebs | mpenet`: there's a few things I want to roll in before 0.7.0. I've never used core.memoize. |
| 06:19 | clgv | Bronsa: no it's more of an enhancement to tell the user what the real error is. |
| 06:20 | ambrosebs | mpenet`: anything in particular you were after i core.cache? |
| 06:20 | Bronsa | clgv: it's not always checkable at compile time though |
| 06:21 | clgv | Bronsa: the manifestation where the compiler explictely generates "null.doubleValue()" should be easily checkable, no? |
| 06:21 | lvh | Are optional keyword arguments like (defn f [a b & {:keys [x y]}] ...) considered a hack, or good API? |
| 06:21 | Bronsa | clgv: sure but that's hardly going to happen in real code |
| 06:22 | lvh | (also if I, as a caller, am building a map of keyword arguments, what is the appropriate way to call a function with those arguments?) |
| 06:22 | clgv | Bronsa: well it did at least two times here ;) |
| 06:22 | lvh | Clojure's equivalent of Python's f(**d), if you will :) |
| 06:23 | clgv | Bronsa: it is likely to happen in projects using primtive functions... |
| 06:24 | TD | Hi, I am programming a project for school in clojure I have some questions |
| 06:24 | lvh | seems like it'd have to be... (apply f (flatten (seq map))) ? |
| 06:24 | lvh | that doesn't look too great |
| 06:24 | Guest97917 | Hi, I am programming a project for school in clojure I have some questions |
| 06:24 | Bronsa | clgv: meh, the way I see it, if you went the extra mile of explicitely type hinting a function return value with a primitive type, then you're telling the compiler you ARE going to return that primitive type, it's not expecting you to be lying |
| 06:25 | lvh | Guest97917: Yes, you just said that, we read it the first time :-) |
| 06:25 | Guest97917 | ok ;p, what does @ do in clojure? |
| 06:25 | Bronsa | '`@foo |
| 06:25 | clgv | Bronsa: yeah, that one is most likely when you change function implementation |
| 06:25 | Bronsa | ,'`@foo |
| 06:25 | clojurebot | (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/deref)) (clojure.core/list (quote sandbox/foo)))) |
| 06:25 | mpenet` | ambrosebs: the LRU patch and also updated dependency on prio-map |
| 06:25 | Bronsa | ,`@foo |
| 06:25 | clojurebot | (clojure.core/deref sandbox/foo) |
| 06:25 | Bronsa | deh |
| 06:26 | clgv | ,`@~'foo |
| 06:26 | clojurebot | (clojure.core/deref foo) |
| 06:26 | ambrosebs | mpenet`: ok. I will release a 0.6 version, I don't think those are breaking changes. |
| 06:26 | clgv | ,(read-string "@foo") |
| 06:26 | clojurebot | (clojure.core/deref foo) |
| 06:27 | Guest97917 | its in something like this: (def foo [a b] (do-something @a))) |
| 06:27 | Bronsa | Guest97917: @a == (deref a) |
| 06:27 | Guest97917 | what is the difference with just using a |
| 06:28 | Guest97917 | deref? |
| 06:28 | AeroNotix | Bronsa: those expressions are the same |
| 06:28 | Bronsa | ,(doc deref) |
| 06:28 | clojurebot | "([ref] [ref timeout-ms timeout-val]); Also reader macro: @ref/@agent/@var/@atom/@delay/@future/@promise. Within a transaction, returns the in-transaction-value of ref, else returns the most-recently-committed value of ref. When applied to a var, agent or atom, returns its current state. When applied to a delay, forces it if not already forced. When applied to a future, will block if computation n... |
| 06:28 | lvh | Guest97917: well, a is a mutable reference to some (usually immutable) value |
| 06:28 | clojurebot | Alles klar |
| 06:28 | Bronsa | AeroNotix: ? |
| 06:28 | lvh | Guest97917: @a gets you the actual value |
| 06:28 | lvh | Guest97917: (deref a) and @a are the same thing, but @a and a are not the same thing |
| 06:28 | mpenet` | ambrosebs: great |
| 06:29 | lvh | Guest97917: Sorry, I'm new to clojure myself, I don't know if there's any documentation that explains references properly |
| 06:29 | clgv | Guest97917: guess it's time for you to read one of those awesome clojure books - that'll save you a lot of time and trouble while learning clojure ;) |
| 06:30 | lvh | Guest97917: you're probably dealing with an atom, so: http://clojure.org/atoms |
| 06:31 | lvh | but yes, what clgv said; any clojure book will tell you about reference types like ref, atom, var... |
| 06:31 | Guest97917 | ok thx guys! |
| 06:32 | lvh | although to be fair I didn't quite get why they were *important* until I saw Value, Identity, State for the... sixth or so time |
| 06:33 | Guest97917 | so to be clear: in (function [a b] (do-something(a))) you do not get the actual value of a?? |
| 06:33 | lazybot | Guest97917: What are you, crazy? Of course not! |
| 06:33 | clgv | Guest97917: you could also start with http://www.braveclojure.com/ in case you are not convinced to buy a book yet ;) |
| 06:34 | Guest97917 | it is just for a school project, I am not going to need it in the near future, it is just to finnish the project and pass the course :) |
| 06:34 | Guest97917 | and it has to be finnished in 7 days ;P |
| 06:35 | lvh | Guest97917: well, you do get a |
| 06:35 | lvh | it's just that you probably wanted the thing that a is pointing at |
| 06:35 | clgv | not the optimal attitude to learn something new... |
| 06:35 | lvh | Guest97917: I'm surprised that, since this is a school project, no-one is around to explain to you what it does |
| 06:35 | Guest97917 | ah ok: with a you get the value of a, if you use @a you get the object a? |
| 06:36 | lvh | Guest97917: Nope. |
| 06:36 | nathan7 | an atom is just a box holding a value |
| 06:36 | lvh | Guest97917: In this particular case, this code is expecting a to be a box with something in it. @a gets you the thing in the box. |
| 06:36 | nathan7 | if a is your atom, a is the box. @a is what's inside. |
| 06:36 | lvh | clojure has a few magical kinds of boxes :) |
| 06:37 | nathan7 | deref/@ is what you do when the postman comes with your parcel from China |
| 06:37 | nathan7 | (though less destructive to the box, I suppose) |
| 06:38 | Guest97917 | lvh: about the explanation in school, it is now holliday and I have to finnish the project in second term (do no know if that exist where you guys live) that why I do not have extra explination, everybody is on holliday ;p |
| 06:39 | Guest97917 | but ok thanks again for the explination |
| 06:39 | Guest97917 | you guys are awsome! |
| 06:58 | Guest97917 | New question, when (fun [a b] (ref-set a 2)(do-something a))) is the a in do-something a then two or value given to the func? |
| 06:59 | lvh | Guest97917: a is always a |
| 06:59 | lvh | you can make a point to something else, but a doesn't magically turn into the value pointed to by a |
| 07:00 | Guest97917 | what does ref-set then do? |
| 07:00 | lvh | (so, do-something gets called with a, not 2) |
| 07:00 | lvh | ,(doc ref-set) |
| 07:00 | clojurebot | "([ref val]); Must be called in a transaction. Sets the value of ref. Returns val." |
| 07:00 | lvh | Guest97917: It sets the ref (a, in this case) to point to 2 |
| 07:00 | lvh | i.e. next time you deref a, it'll be 2 |
| 07:01 | Guest97917 | so next time I do @a it is 2 |
| 07:02 | lvh | well, unless someone else has set it to something else in the mean while, of course :) |
| 07:02 | lvh | but yes. |
| 07:02 | Guest97917 | so: (fun [a b] (ref-set a 2)(do-something @a)) now do-something is with 2 |
| 07:02 | Guest97917 | ok thanks lvh! |
| 07:03 | lvh | Guest97917: Also, if you're doings omething like that, odds are that you don't really want the ref-set, and instead just want to call some function with a value, i.e. the (do-something 2) |
| 07:04 | lvh | but that's a deeper understanding of functional programming and clojure; probably not something I'm qualified to explain, let alone over IRC :) |
| 07:06 | clgv | Guest97917: your best strategy to fast success is to read through some of the available online material on clojure, e.g. http://www.braveclojure.com/ |
| 07:07 | Guest97917 | this is the code http://pastebin.com/BBctZRWp |
| 07:08 | Guest97917 | I got form a buddy of mine, is it good use of ref-set and @ |
| 07:09 | Guest97917 | clgv: I will read some stuff, but if you have the time could you guys take a quick look at the code |
| 07:09 | lvh | I'm not sure why it's using a ref and not an atom here |
| 07:09 | lvh | I'm inclined to suggest (swap! cache assoc k v) or something? |
| 07:10 | lvh | But I'm inclined to agree with clgv about tutorials :) |
| 07:10 | Guest97917 | ok ;p |
| 07:10 | Guest97917 | one last question before I get to reading: what does commute do? |
| 07:10 | clgv | Guest97917: the reading about refs will tell you ;) |
| 07:10 | lvh | ,(doc commute) |
| 07:10 | clojurebot | "([ref fun & args]); Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref. At the commit point of the transaction, sets the value of ref to be: (apply fun most-recently-committed-value-of-ref args) Thus fun should be commutative, or, failing that, you must accept last-one-in-wins behavior.... |
| 07:11 | clgv | Guest97917: without understanding refs an explanation of commute is pointless ;) |
| 07:11 | lvh | Yeah, if you don't understand what that means, you should go read the section on refs, and then you will understand what that means :) |
| 07:11 | Guest97917 | ok, thanks for the explination guys! |
| 07:19 | mr-foobar | in cljx how I annotate cljs macros ? |
| 07:49 | wombawomba | Is anybody familiar with Korma? I'm trying (and failing) to get it to produce something like "SELECT `A`.* FROM `A` LEFT JOIN `B` ON `A`.`id` = `B`.`id`". |
| 07:51 | wombawomba | er, make that "SELECT * FROM `A` LEFT JOIN `B` ON `A`.`id` = `B`.`id`" |
| 07:52 | wombawomba | (select A (join B (= :A.id :B.id))) gives me "SELECT `A`.* FROM `A` LEFT JOIN `B` ON `A`.`id` = `B`.`id`" (i.e. I don't get any of the fields from B) |
| 08:18 | lvh | eh |
| 08:19 | lvh | Are optional keyword arguments like (defn f [a b & {:keys [x y]}] ...) considered a hack, or good API? (also if I, as a caller, am building a map of keyword arguments, what is the appropriate way to call a function with those arguments?) Clojure's equivalent of Python's f(**d), if you will :) (apply f (flatten (seq map))) ? |
| 08:20 | hyPiRion | ~mapply |
| 08:20 | clojurebot | You have to do something like (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))), which just goes to show why unrolled keyword args are a bad idea |
| 08:24 | lvh | hyPiRion: do you share the opinion that unrolled keyword args are a bad idea? :) |
| 08:25 | hyPiRion | lvh: I think it is much better to pass in an optional map. If you're unsure, I'd recommend you to initially start there, then see if it makes sense or not |
| 08:25 | lvh | okiedokie :) |
| 08:26 | hyPiRion | Personally I've found out that's the best option, but maybe you have some use case where unrolled kw args make sense |
| 08:26 | lvh | use case: blake2; it's a hash function, there's a mandatory message input (which may be an empty byte[]), and a bunch of optional arguments |
| 08:26 | lvh | I expect callers to do so in a very static fashion, so I don't expect it will matter much |
| 08:26 | hyPiRion | right |
| 08:27 | lvh | ceratinly too many arguments to have them all be positional |
| 08:27 | lvh | but hey I use semver and that first part of the version is still zero so I just do whatever I want, suckers! |
| 08:27 | lvh | thanks, hyPiRion :) |
| 08:27 | hyPiRion | haha |
| 08:27 | hyPiRion | no problem, good luck with the project :) |
| 08:28 | lvh | there's already kalium which does the hard part of binding java to libsodium.so |
| 08:29 | lvh | so it's really just "find a nice clojure api to call these objects with" |
| 08:29 | hyPiRion | ah |
| 08:30 | lvh | hyPiRion: this may be a stupid question but why is that function not just in clojure.core |
| 08:30 | lvh | hyPiRion: that may actually turn out to be only a small benefit because kalium has stuff like https://github.com/abstractj/kalium/blob/master/src/main/java/org/abstractj/kalium/crypto/Hash.java#L28 in it |
| 08:30 | lvh | that doesn't look right (my java is rusty, but that still doesn't look right) |
| 08:32 | lvh | hyPiRion: when I say "that function" I mean mapply of course |
| 08:32 | hyPiRion | lvh: I don't know why it's not in core, a lot of things are not in core and vice versa for strange reasons |
| 08:32 | hyPiRion | lvh: and yeah, that private byte buffer is just strange |
| 08:33 | lvh | hyPiRion: I'm not worried about it being private, I'm worried about it being static |
| 08:33 | hyPiRion | oh whaa |
| 08:33 | lvh | hyPiRion: (I also don't understand why it's not just a local in the method...) |
| 08:33 | hyPiRion | right, that's super suspicious |
| 08:34 | lvh | this sounds like a threading bug waiting to happen |
| 08:34 | clojurebot | No entiendo |
| 08:35 | hyPiRion | very strange that those methods aren't static either |
| 08:36 | lvh | hyPiRion: so, as a non-Java expert, since this is calling into some C functions that are clearly "static" as far as java cares, I would expect public static final blake2(...) and no members (static or otherwise) |
| 08:37 | lvh | i.e. if you do want "I will copy the byte[]" as part of your contract, fine, but that should be local to the static method |
| 08:37 | lvh | right? |
| 08:37 | hyPiRion | right |
| 08:37 | hyPiRion | that's what I expect too |
| 08:38 | lvh | I don't know jni-ffi but I certainly dont' expect it to stop the world and copy any byte[] you give it |
| 08:38 | lvh | (although maybe that's the only thing it can do, because the JVM can screw with memory layout all it wants, right) |
| 08:38 | hyPiRion | maybe |
| 08:38 | hyPiRion | Still doesn't make sense to have that thing static though. |
| 08:56 | aoisdfsioafu | hi everyone! |
| 08:56 | lvh | hi :) |
| 08:56 | pandeiro | is there a way to make clojure.java.jdbc/insert! return the resulting row with the h2 database? |
| 08:57 | aoisdfsioafu | is this possible: (fun [V] something set-ref V)) when V is a vector? |
| 08:59 | justin_smith | aoisdfsioafu: vectors are immutible, if that's what you mean |
| 09:00 | justin_smith | you can return a copy that is different, but you can't change the original |
| 09:00 | TEttinger | aoisdfsioafu, you may want an atom to have mutation of a sort |
| 09:00 | aoisdfsioafu | what is mutable: list, map? |
| 09:00 | justin_smith | none of these |
| 09:00 | lvh | aoisdfsioafu: almost nothing |
| 09:01 | lvh | aoisdfsioafu: reference types are mutable, like ref, var, atom... |
| 09:01 | lvh | (and even those are only mutable in a limited sense) |
| 09:01 | justin_smith | an atom can hold a reference to a list, map, or vector, or number, but none of these types themselves mutate - you update the atom to point to a different immutible reference |
| 09:02 | justin_smith | but good clojure code won't use atoms very much - instead of mutating variables we pass values into functions, and get new ones out again. |
| 09:03 | clgv | lvh: shameless self-promotion: you might have a look at https://github.com/guv/clojure.options and see whether you like it ;) |
| 09:03 | clgv | lvh: plenta usage examples can be found here https://github.com/guv/frost |
| 09:03 | lvh | clgv: cool thanks! |
| 09:06 | mr-foobar | from a namespace, can you export a symbol ? |
| 09:07 | justin_smith | mr-foobar: the default is for things to be externally visible, but it will still be qualified by it's owning namespace |
| 09:09 | justin_smith | mr-foobar: in the long term this is actually a good thing, in my experience (ie. having to split a coworker's code into multiple namespaces because it got way to big, when he was using "use" was a pain in the ass, but after switching that to 'require foo-ns :as foo' for eace ns it was much easier to refactor) |
| 09:10 | mr-foobar | justin_smith: I import debug symbol from macros ns, I want it to be available from tools ns as well |
| 09:10 | justin_smith | mr-foobar: importing is for java classes |
| 09:10 | mr-foobar | my bad, require |
| 09:11 | justin_smith | mr-foobar: require / use are about mapping to your current ns, and you can't and shouldn't decide how to map to an ns other than the one currently being defined |
| 09:11 | mr-foobar | justin_smith: doesn't that basically mean clojure doesn't have first class namespaces ? |
| 09:14 | zanes | What are some good guidelines for when to expose an API using lazy sequences vs channels? |
| 09:23 | justin_smith | mr-foobar: not at all |
| 09:24 | justin_smith | mr-foobar: namespaces are objects, you can examine their contents, modify them at runtime if needed.... |
| 09:24 | justin_smith | they just don't work the way you may be used to namespaces in other languages working |
| 09:27 | lvh | so, I'm implementing a wrapper for a hash function and I'm trying to add the KATs (known-answer tests, basically I expect h("") to be this string) |
| 09:27 | lvh | that means embedding long strings in my repository. |
| 09:27 | lvh | any suggestions? base64 in the source file? |
| 09:27 | lvh | or is there a reasonable way to read them if I put them in a file separately |
| 09:28 | clgv1 | lvh: the hash functions return byte-arrays? |
| 09:28 | Bronsa | lvh: you can put them in a edn file in the resources directory and read them back using clojure.java.io/resource and clojure.edn/read-string |
| 09:29 | lvh | clgv1: yeah :) |
| 09:29 | clgv1 | lvh: well you could save them as binary. there are several clojure libs to do that ;) |
| 09:29 | mr-foobar | justin_smith: in common lisp, the methods are intern and unintern. what are clojure's equivalents ? |
| 09:30 | justin_smith | (doc intern) |
| 09:30 | clojurebot | "([ns name] [ns name val]); Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace), setting its root binding to val if supplied. The namespace must exist. The var will adopt any metadata from the name symbol. Returns the var." |
| 09:36 | mr-foobar | justin_smith: thx ! it's a bit like -- explicit is better than implicit. makes sense. |
| 09:37 | justin_smith | mr-foobar: imo the concern is "magic" - requiring code should not have invisible side effects |
| 09:38 | justin_smith | so don't put side effecting code at the top level of an ns, and alterations to an ns should be declared in the ns being altered, and not be shoved in by another ns just because you decided to access it |
| 09:38 | SagiCZ1 | and what things should we group into ns? what is their equivalent in other languages? java package? |
| 09:39 | SagiCZ1 | i have trouble understanding what is the proper way to structure large clojure projects |
| 09:39 | clgv1 | SagiCZ1: each topic a namespace works |
| 09:40 | clgv1 | SagiCZ1: though the definition of "topic" is not absolute |
| 09:40 | clgv1 | you can have a look at larger projects like leiningen |
| 09:40 | justin_smith | for a web site, I have a ns for each page, with functions for GET / POST / handling various query strings for that page |
| 09:40 | SagiCZ1 | clgv1: and then how do i connect them or communicate between them? should i also have a "main" namespace from which i call different ns'? |
| 09:40 | justin_smith | plus another ns for common functionality accessed for all pages |
| 09:41 | SagiCZ1 | justin_smith: so that common ns is used as a library for others? |
| 09:41 | clgv1 | SagiCZ1: usually if you want a runnable program in the end you need some kind of "main" namespace yes |
| 09:41 | SagiCZ1 | clgv1: i see |
| 09:41 | justin_smith | SagiCZ1: if you are making a standalone application, then yes you should have a main ns. If making a library, it may be that someone needs x from your lib and not y, so you may have multiple top level namespaces they would access |
| 09:42 | SagiCZ1 | clgv1: my project is a complicated desktop application (not necesserily with gui) |
| 09:42 | SagiCZ1 | justin_smith: ok that does sound natural |
| 09:42 | justin_smith | SagiCZ1: yes, that common ns is effectively a library the others use. This is a common pattern. |
| 09:42 | clgv1 | SagiCZ1: then you need a main namespace that gets that program up and running, e.g. as far as to launch the main window in the GUI case |
| 09:43 | SagiCZ1 | and do you usually develop top-down or bottom-up in clojure? do you build the tiny little blocks before the large-scale logic? |
| 09:44 | nathan7 | I generally do the blocks first |
| 09:45 | SagiCZ1 | nathan7: i see |
| 09:45 | justin_smith | SagiCZ1: I'm sloppy, but I do a bit of each - I write some things in terms of what the final calling code should look like, and some things bottom up from the implementing logic. |
| 09:45 | SagiCZ1 | justin_smith: i am used to similar approach from java - bit of both |
| 09:53 | mr-foobar | justin_smith: could you have a look at https://github.com/harsha-mudi/dbg ?? I want to use a debug macro across clj + cljs |
| 09:54 | mr-foobar | i use that macro all the time |
| 09:54 | testtesthellowor | can I achieve this in closjure: a = 20 (function [a b]) a = 30? |
| 09:54 | testtesthellowor | so that a function changes a |
| 09:55 | gfredericks | testtesthellowor: variables like that are not a part of the core language; so it depends on what you're trying to accomplish I guess |
| 09:55 | SagiCZ1 | testtesthellowor: no |
| 09:56 | justin_smith | mr-foobar: small thing, an if with a nil branch is when |
| 09:57 | testtesthellowor | I want to achieve this: retreive[cache key], this returns the value of something with key in cache, when this value is retrieved the cache needs to update to new state |
| 09:57 | justin_smith | also, you don't need to require clojure.pprint inside the body of the debug - you can do it at the level of the ns |
| 09:58 | justin_smith | oh - is the issue that you would only want clojure.pprint/pprint under clj? |
| 09:59 | justin_smith | mr-foobar: another note, I don't know for sure what you had in mind for "mock", but check out with-redefs |
| 09:59 | mr-foobar | justin_smith: yeah pprint for clj and console.log for cljs |
| 10:00 | mr-foobar | i want to make it work before I cleanup |
| 10:00 | justin_smith | I think feature expressions simplify this stuff (cljx) |
| 10:01 | mr-foobar | justin_smith: but macros in cljs have to be in clj :/ |
| 10:01 | justin_smith | mr-foobar: right, but you can use the cljx stuff to ensure you get the right bindings per target |
| 10:02 | justin_smith | https://github.com/lynaghk/cljx |
| 10:03 | mr-foobar | justin_smith: i tried that initially, but cljx couldn't apply cljs rules to a .clj file |
| 10:03 | justin_smith | oh, ok |
| 10:04 | mr-foobar | maybe i f'ed up somewhere. anyways thanks for looking, I'll give it another shot |
| 10:04 | mr-foobar | might have to ask the cljx guys for some help wrt macro porting |
| 10:06 | borkdude | What is a good IRC channel to ask a question about webdev? |
| 10:06 | borkdude | front end |
| 10:06 | borkdude | I have a problem with Chart.js |
| 10:07 | dnolen_ | borkdude: #javascript or #clojurescript |
| 10:07 | borkdude | dnolen_ sure, thanks |
| 10:13 | gfredericks | testtesthellowor: is there some library or codebase you're already working with, or are you writing code from scratch? |
| 10:13 | testtesthellowor | I have two libraries: one to simulate storing items away on disk, one for splay trees, this is a datastructure to find stuf in log(O) time |
| 10:13 | gfredericks | testtesthellowor: in clojure if you need something that is stateful, presumably like the cache you're describing, the idiomatic approach is to model that as a singular reference (e.g. an atom) to an immutable data structure, rather than as a mutable data structure |
| 10:13 | gfredericks | I believe the core.cache library has that approach, so you might take a look at that |
| 10:13 | testtesthellowor | ok thx ill take a look! |
| 10:14 | visof | hi |
| 10:15 | visof | is this json responce wrapper right https://www.refheap.com/88933 ? |
| 10:15 | visof | response |
| 10:16 | visof | i'm using it to wrap the map of results but sometimes works and not working |
| 10:16 | justin_smith | visof: with ring, you can just give it a string |
| 10:16 | visof | i don't know |
| 10:16 | visof | justin_smith: what do you mean |
| 10:16 | visof | ? |
| 10:16 | visof | justin_smith: i'm using ring |
| 10:16 | visof | what should i do? |
| 10:17 | justin_smith | {:status 200 :headers {"Content-Type" "application/json"} :body (cheshire/generate-string {:a 0 :b 1})} |
| 10:17 | justin_smith | I don't know what you are doing with these OutputStreamWriter and BufferedWriter objects |
| 10:17 | justin_smith | maybe i just don't understand what you are doing |
| 10:19 | justin_smith | oh, so you are manually getting the bytes from the stream inside that handler - I would usually use the ring json-params middleware for that |
| 10:20 | justin_smith | because otherwise I have the same stream unpacking code in each of my request handling functions |
| 10:58 | testtesthellowor | I have this code: (swap! cache add-to-cache @cache key value-from-store) |
| 10:58 | testtesthellowor | getting error: ArityException Wrong number of args (4) passed to: cache$add-to-cache clojure.lang.AFn.throwArity (AFn.java:437) |
| 10:58 | testtesthellowor | but I pass 3 arguments not 4, why does he think I pass 4? |
| 10:58 | TEttinger | testtesthellowor: you don't need the @cache |
| 10:58 | testtesthellowor | ah ok |
| 10:58 | TEttinger | swap! takes cache and passes it as the first arg |
| 11:01 | testtesthellowor | now i get this error :s ClassCastException clojure.lang.PersistentVector cannot be cast to java.util.concurrent.Future |
| 11:02 | Bronsa | ,@[] |
| 11:02 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.concurrent.Future> |
| 11:03 | testtesthellowor | so I changed it to: (swap! cache add-to-cache key value-from-store) |
| 11:04 | testtesthellowor | cache is a vector and add-to-cache returns a new vector |
| 11:04 | Bronsa | cache needs to be an atom |
| 11:04 | Bronsa | swap! works on atoms |
| 11:04 | Bronsa | ,(doc atom) |
| 11:04 | clojurebot | "([x] [x & options]); Creates and returns an Atom with an initial value of x and zero or more options (in any order): :meta metadata-map :validator validate-fn If metadata-map is supplied, it will become the metadata on the atom. validate-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on any state change. If the new state is unacceptable, the v... |
| 11:04 | testtesthellowor | in add-to-cache [cache key added-value] i always use @cache |
| 11:05 | testtesthellowor | I have to return an atom from add-to-cache? |
| 11:05 | Bronsa | testtesthellowor: you don't have to, the first arg will be the value of the atom, not the atom |
| 11:05 | testtesthellowor | then why do I get error? |
| 11:05 | Bronsa | ,(let [a (atom 1)] (swap! a (fn [val i] (+ val i)) 1)) |
| 11:05 | clojurebot | 2 |
| 11:05 | Bronsa | ,(let [a (atom 1)] (swap! a (fn [val i] (+ @val i)) 1)) |
| 11:05 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.concurrent.Future> |
| 11:06 | Bronsa | you don't have to deref inside the function |
| 11:06 | testtesthellowor | a ok |
| 11:06 | TEttinger | (inc Bronsa) |
| 11:06 | TEttinger | clojurebot, you ok buddy? |
| 11:06 | clojurebot | Cool story bro. |
| 11:07 | Bronsa | (inc TEttinger) |
| 11:07 | Bronsa | he dead |
| 11:07 | justin_smith | it's lazybot that does the incs |
| 11:07 | justin_smith | lazybot is slacking |
| 11:07 | Bronsa | justin_smith: rly? |
| 11:07 | justin_smith | as usual |
| 11:07 | TEttinger | lazybot is indeed not here |
| 11:07 | justin_smith | Bronsa: yeah, lazybot is the karma tracker |
| 11:08 | Bronsa | and I thought lazybot was useless. |
| 11:08 | justin_smith | <clgv> (inc opqdonut) <lazybot> ⇒ 1 (from my scrollback) |
| 11:08 | Bronsa | Raynes: bring back the bot so I can have my inc <3 |
| 11:09 | verma | hey, I have this function which takes a histogram with sorted keys and creates a cumulative histogram out of it, https://www.refheap.com/88937 looks a little too complicated, any suggestions on how to make it less cluttery? |
| 11:09 | kungi | When I use a core.async pub/sub channel as a message bus where do the values/messages noone subscribes to go? Are they gathering somewhere? |
| 11:10 | testtesthellowor | Bronsa: thanks man helped me alot! |
| 11:10 | Bronsa | testtesthellowor: np |
| 11:12 | kungi | ... ok they are dropped |
| 11:17 | phillord | I'm trying to embed nrepl-server with cider-nrepl into an app, and it's giving me a ClassNotFound for javax.swing.text.html.parser.ParserDelegator, which is a bit strange. Anyone got any ideas? |
| 11:17 | ucb | which clojure protocol do I have to extend to be able to use as seq a custom Java collection? I've googled around but found nothing that'll help me extend a provided java class to work with clojure's seq fns |
| 11:18 | phillord | List |
| 11:18 | phillord | of ISeq |
| 11:18 | phillord | or, sorry |
| 11:19 | gfredericks | ucb: I don't think that's possible, since ISeq and Seqable are interfaces, not protocols |
| 11:19 | ucb | clojure.lang.ISeq? I've tried both (extend-type ...) and (extend-protocol ...) but no dice. |
| 11:19 | ucb | yeah, that's what I thought as well |
| 11:19 | ucb | well, after doing some reading and trying |
| 11:20 | ucb | it's a shame, since I was looking forward to iterating over my collection using seq fns :( |
| 11:20 | gfredericks | ucb: what sort of class is it? |
| 11:20 | phillord | write an adaptor |
| 11:20 | ucb | phillord: that's what I'll probably end up doing |
| 11:20 | ucb | gfredericks: meaning whether it's final or not? |
| 11:21 | lvh | so, I have a map of args to expected values, what's the canonical way to make sure that for each of the pairs, (is (= (apply f args) expected)? |
| 11:21 | gfredericks | ucb: no, just where it came from, how you use it, etc |
| 11:21 | lvh | I'm using reduce-kv for it now |
| 11:21 | lvh | https://gist.github.com/lvh/ed2c356ffc0cd905f282 |
| 11:21 | ucb | gfredericks: https://code.google.com/p/fastdtw/ |
| 11:21 | gfredericks | lvh: (every? (fn [[args expected]] (= expected (apply f args))) m) |
| 11:21 | ucb | gfredericks: it's a class that wraps a bunch of arrays |
| 11:22 | gfredericks | ucb: is it mutable? |
| 11:22 | ucb | gfredericks: yeah |
| 11:22 | gfredericks | ucb: kind of an iffy case for the seq interface anyhow, then |
| 11:22 | lvh | gfredericks: will that still give me a useful error message when it fails? |
| 11:23 | gfredericks | lvh: no; what sort of thing are you looking for? |
| 11:23 | ucb | gfredericks: yeah, however in any case, it's just me using them (in my project) and I'd make sure they don't mutate, but I take your point |
| 11:23 | lvh | gfredericks: well, ideally when one of the test cases doesn't work, it would tell me *which one* doesn't work |
| 11:24 | gfredericks | (defn errors [f m] (remove (fn [[args expected]] (= expected (apply f args))) m)) |
| 11:24 | gfredericks | lvh: ^ |
| 11:24 | gfredericks | returns a sequence of pairs |
| 11:25 | lvh | oh, and I also just realized that I probably can't use = on byte[]s :( |
| 11:25 | ucb | seems like I'll have to go for something along the lines of http://blog.jayfields.com/2010/04/clojure-converting-custom-collection-to.html |
| 11:25 | ucb | modulo the macro, etc. |
| 11:25 | testtesthellowor | Thanks again guys, thanks to you my project is finished, here is a present: https://www.youtube.com/watch?v=pz4-T3Biusw |
| 11:26 | lvh | gfredericks: and then check that that was empty? |
| 11:26 | gfredericks | lvh: right |
| 11:26 | lvh | not the most useful error: :D actual: (not (every? #<hash_test$fn__26656$fn__26658 caesium.crypto.hash_test$fn__26656$fn__26658@ff908c7> {[#<byte[] [B@4ed999e7>] #<byte[] [B@247d0d41>, [#<byte[] [B@7905dd2f>] #<byte[] [B@58d05598>})) |
| 11:27 | gfredericks | lvh: if you're using clojure.test I think you can use doseq over the map |
| 11:27 | gfredericks | lvh: and if your map is just a literal in your code, I would look at clojure.test/are instead |
| 11:27 | gfredericks | (doseq [[args expected]] (is (= expected (apply f args)))) |
| 11:27 | lvh | oh, right |
| 11:27 | lvh | I forgot about are :) |
| 11:28 | gfredericks | clojurebot: are is ises |
| 11:28 | clojurebot | Ok. |
| 11:28 | ucb | gfredericks, phillord: this does the trick https://gist.github.com/99575ee83b2a1ea5d620 |
| 11:29 | gfredericks | ucb: I bet there's an easier version |
| 11:29 | ucb | gfredericks: I bet! :) |
| 11:29 | gfredericks | ,(->> (range (.size ts)) (map (fn [cnt] (.getMeasurement ts cnt 0)))) maybe? |
| 11:29 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ts in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 11:29 | gfredericks | clojurebot: sorry |
| 11:29 | clojurebot | Huh? |
| 11:30 | ucb | ah, yeah |
| 11:30 | gfredericks | add a doall or change it to mapv if you want it to be eager |
| 11:30 | ucb | no, lazy is fine, thanks for that |
| 11:31 | lvh | is there a trick for comparing byte[] for equality? apparently = isn't it. |
| 11:31 | lvh | (ideally also not Arrays.equal because ick, but okay, if I have to) |
| 11:32 | gfredericks | lvh: how could something be easier than Arrays.equal? |
| 11:32 | lvh | gfredericks: oh, it's plenty easy, just a little ugly imho |
| 11:32 | clgv1 | lvh: no thats the preferred/best one ;) |
| 11:32 | clgv1 | lvh: you can wrap it in a clojure function if that's prettier ;) |
| 11:33 | lvh | Arrays is the one where Java reminds me "see? we can do *just fine* without first-class functions!" |
| 11:33 | ucb | gfredericks: let me share a secret with you: I am an arse |
| 11:34 | ucb | gfredericks: turns out that the TimeSeries objects are created from raw json, and then discarded. I think I'll just keep those around for what I want to do next (with the seq fns) |
| 11:36 | lvh | Unable to find static field: equals in class java.util.Arrays |
| 11:36 | lvh | Is that because there are lots of equalses, and Clojure doesn't know which one at compile time? |
| 11:37 | gfredericks | ,(import 'java.util.Arrays) |
| 11:37 | clojurebot | java.util.Arrays |
| 11:37 | gfredericks | ,(def my-bytes (make-array Byte/TYPE 9)) |
| 11:37 | clojurebot | #'sandbox/my-bytes |
| 11:37 | gfredericks | ,(Arrays/equals my-bytes my-bytes) |
| 11:37 | clojurebot | true |
| 11:37 | gfredericks | ,(Arrays/equals my-bytes 42) |
| 11:37 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: equals> |
| 11:38 | gfredericks | ,#(Arrays/equals my-bytes %) |
| 11:38 | clojurebot | #<sandbox$eval144$fn__145 sandbox$eval144$fn__145@1aec528> |
| 11:38 | gfredericks | ,(#(Arrays/equals my-bytes %) 42) |
| 11:38 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: equals> |
| 11:38 | gfredericks | not sure how to reproduce that error |
| 11:38 | lvh | (defn array-eq [a b] (Arrays/equals a b)) ;; Fixed it |
| 11:38 | lvh | I previously had the same thing, but point-free |
| 11:39 | lvh | (where of course clojure doesn't know I mean byte[] as opposed to the myriad of other a[] that exist |
| 11:39 | gfredericks | ,Array/equals |
| 11:39 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: Array, compiling:(NO_SOURCE_PATH:0:0)> |
| 11:39 | gfredericks | ,Arrays/equals |
| 11:39 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to find static field: equals in class java.util.Arrays, compiling:(NO_SOURCE_PATH:0:0)> |
| 11:39 | gfredericks | lvh: actually it's that you can't refer to methods that way |
| 11:39 | lvh | oh |
| 11:39 | gfredericks | ,Math/sqrt |
| 11:39 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to find static field: sqrt in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)> |
| 11:39 | lvh | why not? |
| 11:40 | gfredericks | clojure wasn't designed to handle methods as runtime values |
| 11:40 | lvh | if there had been only one such implementation |
| 11:40 | lvh | okay |
| 11:40 | gfredericks | not sure why; maybe because it'd be slower and so wouldn't want to encourage that? |
| 11:41 | lvh | gfredericks: I don't understand why it would be slower? |
| 11:41 | lvh | I mean, in this case I understand why it really just can't actually do that |
| 11:41 | lvh | because there's like 20 things I could mean by Arrays/equals |
| 11:42 | gfredericks | I guess it could automatically wrap it in #(Math/sqrt %) |
| 11:42 | gfredericks | so I don't know why that doesn't happen |
| 11:42 | lvh | no worries I will get over my desire for point-free things in the special case of java interop :) |
| 11:43 | stain_ | gfredericks: well, how would Math/sqrt be resolved inside the lambda then? |
| 11:44 | lvh | I did end up writing (defn array-eq [a b] (Arrays/equals a b)) though ;) |
| 11:44 | lvh | stain_: when you call that lambda, you know the types of a and b |
| 11:44 | lvh | so you can happily do dispatch *then* :) |
| 11:44 | lvh | sorry, I should say tag not type in that case |
| 11:44 | lvh | if my rusty java memory serves me right |
| 11:45 | gfredericks | lvh: interop method calls (static & instance) only work in the call position |
| 11:45 | gfredericks | thus: |
| 11:45 | gfredericks | ,Math/sqrt |
| 11:45 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to find static field: sqrt in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)> |
| 11:45 | gfredericks | ,(fn [x] (Math/sqrt x)) |
| 11:45 | clojurebot | #<sandbox$eval69$fn__70 sandbox$eval69$fn__70@1d20361> |
| 11:46 | gfredericks | reflection, which I think is what stain_ is asking about, is somewhat orthogonal |
| 11:50 | lvh | so, kalium (a crypto lib) supports this weird "Encoder" thing as a convenience method |
| 11:50 | lvh | the Encoder turns byte[] into String |
| 11:51 | lvh | for some reason this infects the API for the hash function; if you were using a clojure wrapper around that java lib, would you expect the same API? |
| 11:51 | gfredericks | infects? |
| 11:51 | lvh | I mean, from clojure, I'd expect (bytes2hexstr (hash some-byte-array)) |
| 11:51 | lvh | gfredericks: https://github.com/abstractj/kalium/blob/master/src/main/java/org/abstractj/kalium/crypto/Hash.java#L53 |
| 11:51 | lvh | compare with L61 |
| 11:52 | lvh | the encoding seems totally orthogonal :/ |
| 11:52 | lvh | also, for some bogus reason that code uses .getBytes instead of asking the encoder to decode? |
| 11:53 | lvh | something tells me that someone was just using the first method their IDE suggested to get the type errors to stop... |
| 12:13 | schmee | hey all, I'm trying to crawl a page with a simple recursive breadth-first search, but somehow after the first level things get messed up |
| 12:14 | schmee | can you use map with a recursive call like I've done here? https://gist.github.com/schmee/1eff71c6b24ece20b103 |
| 12:15 | nanishora | hi, I have a question. |
| 12:16 | lvh | If I have a README with some usage documentation in it shaped like a repl session, is there a way to test that automatically? |
| 12:16 | nanishora | I have a hiccups function that create rows given label vlaue |
| 12:16 | nanishora | but certain rows are created based ona condition. Since when and do return the last statem,ent I only get last rows from bunch of calls. |
| 12:17 | nanishora | Is tehre another construct that I could use? |
| 12:22 | teslanick | map/reduce? |
| 12:22 | varioust | nanishora: are you using map to build the sequence of rows? |
| 12:31 | jknighton | I think the bug mentioned in this last mailing-list post w/r/t core.async is still there https://groups.google.com/forum/#!topic/clojure/vtvk7warLE4 |
| 12:31 | jknighton | Anyone interested in confirming with me that I'm not doing something exceptionally stupid? This is very possible |
| 12:40 | michaelr` | hello |
| 13:02 | sveri | Hi, I just read that cider-0.7.0 was released, which is great and shiny and new and awesome, whats the easiest way to get started with clojure / emacs and the latest cider? |
| 13:03 | technomancy | I'm adding the ability to turn off implicit middleware and hooks in Leiningen, and also adding a setting to disable all implicit code loading with :implicits false. |
| 13:03 | technomancy | are there any other places that loading like that happens behind the scenes that should also be effected by that setting? |
| 13:07 | arrdem | it'd be nice if you could turn off user.clj, but you can't so I'm just whining |
| 13:10 | technomancy | out of my jurisdiction =\ |
| 13:14 | gfredericks | doesn't it just take the first user.clj on the classpath? You could "disable" it by prioritizing an empty file |
| 13:16 | meingbg | What's the most popular way of debugging clojure code nowadays? |
| 13:16 | technomancy | gfredericks: true |
| 13:16 | technomancy | this is more about running code in lein itself though |
| 13:18 | gfredericks | sure |
| 13:20 | justin_smith | meingbg: I hear cursive (built on intellij idea) has a proper debugger |
| 13:20 | gfredericks | I have a half-assed debug-repl setup |
| 13:20 | gfredericks | I tried to make it full-assed but nrepl has tricksy outstanding boogs |
| 13:21 | justin_smith | yeah, I think there are a bunch of (< (ass-count x) 1.0) solutions for debugging clojure out there |
| 13:21 | meingbg | justin_smith: So nothing good for emacs-based setups? |
| 13:21 | technomancy | meingbg: specifically a stepping debugger? |
| 13:22 | meingbg | technomancy: I just want to know what's going on without having to write code for it. |
| 13:22 | justin_smith | meingbg: amalloy_ says debugger integration in swank works, but I never really figured that out when I used swank |
| 13:22 | technomancy | meingbg: tools.trace is great for that |
| 13:22 | technomancy | I've got an M-x nrepl-toggle-trace command to make that easy |
| 13:24 | technomancy | it also falls under the half-assed bucket, but for different reasons |
| 13:24 | justin_smith | clearly in clojure we have full rational ass-rankings |
| 13:25 | arrdem | well we can also do perfect hashing and identification using only fractional ass rankings given that [0, 1) is uncountably infinite. |
| 13:25 | technomancy | justin_smith: we can steal the rankings from http://deskthority.net/wiki/Return_key |
| 13:26 | justin_smith | lol |
| 13:26 | arrdem | (inc technomancy) |
| 13:26 | arrdem | lazybot is dead again I see.. |
| 13:26 | gfredericks | thanks obama ; for [0,1) being uncountable |
| 13:28 | justin_smith | lol |
| 13:31 | Tornado68 | Hi |
| 13:32 | Tornado68 | Someone know if is possible interaction between clojure and cpp? |
| 13:32 | cbp | anything is possible |
| 13:33 | technomancy | (inc cbp) |
| 13:33 | Tornado68 | Sure. But its easy? |
| 13:33 | arrdem | is JNI ever easy? |
| 13:34 | Tornado68 | More than assembler |
| 13:34 | Tornado68 | Some times |
| 13:35 | justin_smith | you can use jni. But it may be easier and more portable to use a higher level / more loosely coupled ipc. Depends what the cpp should be doing |
| 13:35 | Tornado68 | Cpp are hardware driver |
| 13:36 | justin_smith | for example if you can make the cpp code standalone, and interact via a process stream, this is much easier to coordinate |
| 13:36 | justin_smith | OK, have fun with jni I guess |
| 13:36 | Tornado68 | Ok its a good way |
| 13:36 | Tornado68 | Thank you justin |
| 13:36 | justin_smith | I dunno, jni is hard to use, but I don't think you have a better option |
| 13:37 | justin_smith | np |
| 13:38 | arrdem | Lua may be a better tool for this than Clojure... you could do real driver/binary interop from Clojure via the JNI but it's probably not really worthwhile. |
| 13:38 | technomancy | chicken scheme is famous for good C level interop |
| 13:38 | Tornado68 | Im thinking to use over roos |
| 13:39 | justin_smith | or ocaml even |
| 13:39 | arrdem | anything that's not a C variant or raw ASM :P |
| 13:39 | Tornado68 | ocaml? |
| 13:40 | justin_smith | in ocaml you can do ffi without having to write any c adaptor code |
| 13:40 | hiredman | jnr is the new coolness for native interop from the jvm |
| 13:40 | daviid | justin_smith: in guile too |
| 13:41 | mocker | Anyone played with setting up something like http://deis.io to deploy clojure web apps to? |
| 13:41 | hiredman | http://www.oracle.com/technetwork/java/jvmls2013nutter-2013526.pdf jnr related slides, but it is so new it is hard to find usage information |
| 13:41 | Tornado68 | Ok. I will explore ocaml. Thank you both. See you |
| 13:42 | justin_smith | mocker: a lot of the abstractions provided by those cloud platforms are more useful for languages that don't have isolated and predictable dependency resolution. In practice all you need with clojure in most instances is to build an uberwar, and run it with the java command |
| 13:43 | justin_smith | mocker: also I am very suspicious of platforms that want to run git on the production end, I would rather have a separate build server if I am not building locally |
| 13:44 | technomancy | justin_smith: if I'm reading this correctly, it just uses git as a transport to get code to the build server. |
| 13:44 | justin_smith | technomancy: oh, don't mind me on that point then |
| 13:45 | mocker | justin_smith: It seems like a Heroku for people with their own servers. |
| 13:45 | mocker | Or at least that's how I read it. |
| 13:52 | amalloy | justin_smith: debugger integration in swank? i wish |
| 13:52 | mikerod | Is it by chance that Java interop for static field access and a static method call with no args can both be written to look like a fn call? e.g. (MyClass/MyStaticField) vs MyClass/MyStaticField vs (MyClass/MyStaticMethodNoArgs) |
| 13:53 | mikerod | I was actually surprised when I realized I could have this (MyClass/MyStaticField) |
| 13:53 | justin_smith | amalloy: must have misremembered - someone was claiming something like that |
| 13:53 | mikerod | but I know it expands to (. MyClass MyStaticField) |
| 13:53 | justin_smith | mikerod: why are you calling that field? |
| 13:54 | amalloy | justin_smith: the stacktraces are a bit nicer and interactiver than in nrepl/cider |
| 13:54 | justin_smith | or, the better question I guess, why do you want field access to look like a function call |
| 13:54 | justin_smith | amalloy: OK, I think I misfiled that, thanks |
| 13:55 | mikerod | justin_smith: I didn't expect to be able to have a static field look like a function call. it surprised me that it worked |
| 13:55 | mikerod | I had an enum |
| 13:55 | mikerod | (MyEnumClass/VAL) was equivalent to MyEnumClass/VAL |
| 13:55 | mikerod | that was the surprising part |
| 13:55 | mikerod | are you supposed to have the parentheses around it or not? |
| 13:56 | mikerod | I see @ http://clojure.org/java_interop it suggests no paren |
| 13:57 | mikerod | which I guess the Compiler has some special handling of this symbol then |
| 13:59 | mikerod | Well, I guess I answered myself. The Compiler#analyzeSymbol handles the static field-styled symbol |
| 13:59 | hiredman | mikerod: . doesn't disambiguate between static fields and methods, so (Foo/Bar) and Foo/Bar both get rewritten in terms of . |
| 14:00 | hiredman | and end up looking the same to the compiler, which then does reflection to figure out if you meant a static method or field |
| 14:00 | amalloy | mikerod: (Foo/bar) as a static field look up is kinda discouraged - it's from back before the bare Foo/bar didn't exist |
| 14:00 | amalloy | er, before it did exist |
| 14:00 | gfredericks | ,(Math/PI) |
| 14:00 | clojurebot | 3.141592653589793 |
| 14:00 | mikerod | hmm I see |
| 14:00 | gfredericks | ,(def TAU (+ Math/PI (Math/PI))) |
| 14:00 | clojurebot | #'sandbox/TAU |
| 14:01 | mikerod | Yeah, the (Foo/Bar) style surprised me since I just always thought Foo/Bar was the one true way to do it. Then I realized how the macro expands and how static fields still work with the `.` |
| 14:01 | hiredman | oh, huh, maybe . does disambiguate |
| 14:03 | mikerod | Hmm |
| 14:10 | ToBeReplaced | spamming again -> I'd really like a usable version of java.nio.file from Clojure; I did some work on this already, and would love help from anyone else willing to donate time: https://github.com/ToBeReplaced/nio.file |
| 14:12 | justin_smith | ToBeReplaced: interesting, checking it out |
| 14:13 | justin_smith | ToBeReplaced: do you have a todo somewhere? |
| 14:15 | justin_smith | ToBeReplaced: are the arglist annotations that don't match any function body implicit ToDo items? |
| 14:18 | ToBeReplaced | justin_smith: didn't write a TODO... just gotta run through all of nio.file really |
| 14:19 | ToBeReplaced | justin_smith: no they aren't. the arglist annotations are there b/c there is protocol dispatch occuring; the arglists make it clear to the user what they can pass in |
| 14:19 | justin_smith | ahh, OK |
| 14:24 | ToBeReplaced | justin_smith: it's nice to be able to (copy "foo" "bar"), or delete all files but leave directories in tact with (walk-file-tree "out" (naive-visitor :visit-file delete!)) |
| 14:26 | justin_smith | yeah, it would be nice to have a more clojure-friendly UI to nio |
| 14:26 | justin_smith | I just answered an SO answer about using nio via interop actually |
| 14:32 | Jaood | hey, run-lisp is not bad :D |
| 14:35 | Jaood | completion rots the mind |
| 14:36 | justin_smith | Jaood: heh, I've used it before. But C-M-x that respects the current namespace is handy |
| 14:40 | hlship | and see if I can track down where the error lies with my "it doesn't recompile" issue; it has to do with overriding (or having multiple) :source-paths |
| 14:40 | hlship | Yes, confirmed, with multiple |
| 14:40 | drusellers | as a simple etag - are there any one liners to turn a clojure map into a 'hash' say SHA1 for giggles |
| 14:41 | justin_smith | ,(hash {:a 0 :b 1 :c 2}) |
| 14:41 | clojurebot | -757818440 |
| 14:41 | justin_smith | well I guess that isn't what you meant |
| 14:41 | drusellers | if its unique it ain't bad |
| 14:41 | hiredman | there is some library for deterministic hashing |
| 14:42 | justin_smith | well - it's a decent hashing function, but of course it isn't guaranteed collision free |
| 14:42 | drusellers | for a POC i think it will be good enough. |
| 14:42 | drusellers | I can come back and make it fancy later |
| 14:43 | hiredman | bbloom_ will rememmber the name |
| 14:43 | amalloy | 32 bits doesn't really give you enough to have a hope of uniqueness |
| 14:43 | hiredman | the library that does sorting of maps and stuff before hashing is connected to some repl pretty printer bbloom_ likes if I recall |
| 14:44 | hiredman | or it colors the output or something |
| 14:45 | amalloy | with 2^32 possible hash values, you only need around 80,000 inputs before you're likely to see a collision |
| 14:45 | justin_smith | a silly one |
| 14:45 | justin_smith | ,(Sring. (. (java.security.MessageDigest/getInstance "SHA-1") digest (.getBytes (str {:a 0 :b 1})))) |
| 14:45 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Sring, compiling:(NO_SOURCE_PATH:0:0)> |
| 14:45 | justin_smith | ,(String. (. (java.security.MessageDigest/getInstance "SHA-1") digest (.getBytes (str {:a 0 :b 1})))) |
| 14:45 | clojurebot | "�5\b`2����f��r����Nn" |
| 14:46 | amalloy | justin_smith: the worst one imaginable |
| 14:46 | amalloy | since it isn't even consistent for (:b 1 :a 0} |
| 14:46 | justin_smith | right |
| 14:46 | justin_smith | but for a string it's all set |
| 14:48 | amalloy | generic solution: convert each map into a directory structure on disk, commit it to git, and check the commit sha |
| 14:48 | amalloy | details left as exercise for reader |
| 14:50 | hiredman | https://github.com/greglook/puget#canonical-representation |
| 14:51 | hiredman | then sha the bytes from that |
| 14:51 | hiredman | (I found it by going to bbloom_'s github and finding his fork) |
| 14:51 | justin_smith | (inc hiredman) |
| 14:52 | justin_smith | that looks like the right way to do it, yeah |
| 14:52 | hiredman | well, no, it is an easy way |
| 14:52 | clojurebot | Ik begrijp |
| 14:53 | hiredman | the right way involves not printing, just hashing, but that is more complicated |
| 14:57 | gfredericks | drusellers: amalloy: justin_smith: hiredman: everybody: https://github.com/weavejester/whorl |
| 14:57 | oatsadn | what’s the current best way to build abritrary SVG in clojurescript? |
| 14:58 | gfredericks | oatsadn: crate isn't terrible |
| 14:58 | technomancy | ugh |
| 14:58 | hiredman | gfredericks: still printing |
| 14:58 | amalloy | gfredericks: i would rather daydream about rube goldberg hashing schemes than use a sensible one |
| 14:58 | technomancy | what is up with github's terrible rendering of ©? |
| 14:59 | hiredman | gfredericks: and it uses an identity hashmap so equal objects could end up with different whorls |
| 14:59 | hiredman | seems terrible |
| 14:59 | gfredericks | hiredman: a what |
| 15:00 | hiredman | oh, no |
| 15:00 | hiredman | I am wrong |
| 15:00 | oatsadn | gfredericks: cool i hadn’t thought of the hiccup approach |
| 15:00 | hiredman | I saw java.util.WeakHashMap and read java.util.WeakIdentityHashMap or whatever it is called |
| 15:01 | hiredman | regardless, it still prints stuff, which is a waste |
| 15:03 | justin_smith | what about hashing the bytes out of a java.io.ObjectOutputStream? |
| 15:04 | justin_smith | I guess that would not be identical for identical structures |
| 15:04 | justin_smith | *equal |
| 15:05 | hiredman | basically you need to do like hash does, get the hash of each element of a collection(in a deterministic order) and mix them together somehow |
| 15:06 | hiredman | lots of xors and multiplies by 31 |
| 15:06 | gfredericks | ha |
| 15:09 | justin_smith | https://www.refheap.com/88944 using the serialized forms, looks promising |
| 15:10 | amalloy | i don't think hash actually does things in a deterministic order, hiredman; instead it uses a combining operation that is commutative (ie, doesn't do lots of multiplying by 31) |
| 15:11 | amalloy | "The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view" |
| 15:15 | hiredman | amalloy: ah, interesting, the deterministic part as a suggestion that you would want to do that in your clojure sha datastructure code, not that hashing does it, but a commutative operation seems like it would be better |
| 15:15 | hiredman | the multiple by 31 was a java string hashing joke |
| 15:15 | hiredman | https://en.wikipedia.org/wiki/Java_hashCode()#The_java.lang.String_hash_function |
| 15:16 | je | why does the clojurescript compiler throw a warning when comparing (less than/greater than) to js/Date objects: https://gist.github.com/jacobemcken/04d264257718f2edea35 |
| 15:16 | amalloy | hiredman: it made me think of eclipse's autogenerated hashCode implementations |
| 15:16 | technomancy | wow |
| 15:16 | amalloy | http://stackoverflow.com/questions/11795104/is-the-hashcode-function-generated-by-eclipse-any-good |
| 15:16 | je | the running code seems to work as expected (being able to compare js/Date objects correctly) |
| 15:17 | hiredman | je: likely the behviour of > and < on non numbers in clojurescript is undefined |
| 15:17 | dnolen_ | je: < is only for numbers in CLJS |
| 15:17 | dnolen_ | je: there is not abstract comparable notion in JS to make it work properly |
| 15:17 | dnolen_ | w/o a perf hit anyway |
| 15:19 | dnolen_ | (< (.valueOf t) (.valueOf (js/Date.)) is the way to do it |
| 15:19 | je | dnolen_: awesome thanks... was about to ask ;) |
| 15:20 | schmee | is it possible to have a lazy-seq where values depend on earlier ones? |
| 15:20 | hiredman | schmee: it depends what you mean by that |
| 15:21 | hiredman | ~google clojure fib |
| 15:21 | clojurebot | First, out of 879 results is: |
| 15:21 | clojurebot | Clojure Programming/Examples/Lazy Fibonacci - Wikibooks, open ... |
| 15:21 | clojurebot | http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci |
| 15:21 | hiredman | has a few different styles, I would steer clear of anything that uses def to tie the knot |
| 15:21 | schmee | well, I'm goofing around with crawling a website, and I'm trying to make a lazy-seq out of the links |
| 15:22 | schmee | but I only want to add the links to the queue if they haven't appeared earlier in the seq |
| 15:22 | amalloy | schmee: definitely! a simple example is (range), where each element is exactly one larger than the previous |
| 15:22 | amalloy | schmee: you can do that yourself by maintaining a set of already-seen links, but just calling distinct is probably good enough |
| 15:23 | schmee | amalloy: that's the approach I'm trying, but I'm getting some weird errors so I wanted to make sure I'm not wasting my time :P |
| 15:24 | schmee | I'll try some more and see if I can get it working, thanks |
| 15:28 | justin_smith | https://www.refheap.com/88947 sha-1 of clojure datatypes, works with identical maps, but doesn't hash vector/seq of the same contents equally |
| 15:28 | justin_smith | *equal maps (even if the keys are shuffled) |
| 15:30 | hiredman | calling .getBytes is terrible |
| 15:31 | hiredman | justin_smith: that also doesn't match = |
| 15:31 | justin_smith | yeah, I could specialize serialized-form and just not call str there |
| 15:31 | hiredman | hash maps won't hash the same as array maps |
| 15:31 | justin_smith | oh, yeah |
| 15:32 | justin_smith | so there would need to be some transition to a canonical form, for any solution |
| 15:32 | hiredman | and you are still serializing before hashing |
| 15:32 | hiredman | which is not great |
| 15:59 | cloojure_ | Is anybody having trouble deploying to clojars today? |
| 16:22 | mocker | Woo, deis seems pretty slick. |
| 16:22 | mocker | https://github.com/deis/example-clojure-ring |
| 17:08 | ben_vulpes | anyone playing with the new cider yet? |
| 17:13 | alpheus | I just got it a couple days ago. Is that the new one? |
| 17:14 | alpheus | When (class obj) returns something like com.google.appengine.api.blobstore.dev.UploadBlobServlet$2 what does "$2" mean? |
| 17:15 | hiredman | it is part of the classname |
| 17:15 | alpheus | The ancestors include javax.servlet.http.HttpServletRequest, but I can't use it as an HttpServletRequest. |
| 17:16 | hiredman | alpheus: are you looking at the ancestors of com.google.appengine.api.blobstore.dev.UploadBlobServlet$2 or com.google.appengine.api.blobstore.dev.UploadBlobServlet? |
| 17:16 | hiredman | because those are different classes |
| 17:17 | alpheus | I call (ancestors (class (:servlet-request request))) |
| 17:17 | hiredman | the java compiler tends to tack $1 or $2 on to the end of the outer classname when to get the name for an annonymous innerclass (at the jvm level all classes have names) |
| 17:17 | alpheus | Oh, so I need an inner class. |
| 17:17 | hiredman | alpheus: and what makes you think you can't use it as a HttpServletRequest? |
| 17:18 | alpheus | java.lang.ClassCastException: Cannot cast com.google.appengine.api.blobstore.dev.UploadBlobServlet$2$1 to javax.servlet.http.HttpServletRequest |
| 17:18 | hiredman | that is a different class again |
| 17:18 | hiredman | note the $1 |
| 17:20 | hiredman | if the class of (:servlet-request request) is com.google.appengine.api.blobstore.dev.UploadBlobServlet$2 and you get that error then you aren't using (:servlet-request request) there |
| 17:21 | alpheus | Can I paste a couple lines of code? |
| 17:21 | hiredman | use a pastebin |
| 17:24 | alpheus | http://pastebin.com/Lqn7dAU8 |
| 17:25 | hiredman | ,(doc isa?) |
| 17:25 | clojurebot | "([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy" |
| 17:25 | hiredman | you want instance? |
| 17:25 | schmee | is there something like `take-until`, that works like `take-while` except that it includes the element which caused it to terminate? |
| 17:25 | hiredman | ,(doc instance?) |
| 17:25 | clojurebot | "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false" |
| 17:25 | alpheus | ok |
| 17:26 | hiredman | and that output is obviously not the output of the pasted code |
| 17:26 | hiredman | (the printed strings are different, etc) |
| 17:27 | puredanger | schmee: http://dev.clojure.org/jira/browse/CLJ-1451 |
| 17:28 | schmee | haha found it at exactly the same time! :D |
| 17:28 | schmee | so I'm not the only one wanting this :) |
| 17:28 | puredanger | no :) |
| 17:29 | schmee | puredanger: so is that approved for 1.7? It's marked as unresolved |
| 17:30 | puredanger | no, it's been triaged (by me) as worthy of Rich to look at |
| 17:30 | puredanger | but he has not yet done so |
| 17:30 | schmee | I see |
| 17:30 | schmee | anyway I can just steal the implementation for now :P |
| 17:30 | puredanger | http://dev.clojure.org/display/community/JIRA+workflow |
| 17:32 | schmee | maybe there should be a more general variant which lets you specify an interval around the termination point |
| 17:32 | schmee | so you can return say, two items before or after termination |
| 17:32 | puredanger | that seems much less common |
| 17:33 | puredanger | if you need that, that's fine but I think it would be much less likely to be accepted for core |
| 17:33 | schmee | indeed, I was just thinking that the goal of core is to be as general as possible |
| 17:33 | schmee | but I guess it's to be as _useful_ as possible |
| 17:34 | puredanger | I'm sure some here would disparage that definition :) |
| 17:35 | alpheus | hiredman: didn't mean to mislead. Here's the actual output: http://pastebin.com/ZSdkuuqM |
| 17:35 | alpheus | I forgot to fix the isa?, but added instance? |
| 17:35 | hiredman | sure, so it could be used in more theoretical cases, but if there are no actual uses, is it actually more useful? |
| 17:36 | hiredman | alpheus: so as you see it is an instance, and the class name is com.Black Mesa.appengine.api.blobstore.dev.UploadBlobServlet$2, and your exception references com.Black Mesa.appengine.api.blobstore.dev.UploadBlobServlet$2$1 a different class |
| 17:36 | hiredman | oh, sorry |
| 17:36 | hiredman | I have my web browser automatically replace some words like google |
| 17:37 | hiredman | plays hell with copy and pasting |
| 17:37 | alpheus | heh |
| 17:37 | hiredman | but yeah, those are different classes |
| 17:37 | hiredman | so you are likely passing the wrong argument somewhere or something |
| 17:38 | alpheus | That seems likely. Thanks for your help. |
| 17:38 | technomancy | hiredman: I heard a rumor that the same extension resulted in a creative pizza order for someone |
| 17:38 | technomancy | https://twitter.com/gregkare/status/494823249373831168 |
| 17:38 | hiredman | huh, dunno, I use my phone to order pizza |
| 17:40 | hyPiRion | I have some replacements |
| 17:40 | hiredman | the script I am using also replaces "witnesses" with "these dudes i know" and "smartphone" with "Pokédex" |
| 17:40 | hyPiRion | literally → figuratively is the most used one |
| 17:40 | hiredman | and gandalf -> garfield of course |
| 17:42 | hyPiRion | "Will Blow Your Mind" → "Might Perhaps Mildly Entertain You For a Moment" |
| 17:46 | gfredericks | "one weird trick" → "thing" |
| 17:48 | alpheus | hiredman: thanks again. you were absolutely right about passing the wrong argument. |
| 17:50 | justin_smith | "disrupt" -> "bullshit" which, when combined with "cloud" -> "butt" will lead to "new technology to bullshit my butt" |
| 18:52 | afhammad | I have a project with Timbre for logging setup using Luminus however the logs are not very readable. Whats the best way to get nice logs when using ring/compojure ? |
| 18:56 | justin_smith | afhammad: you can set the logger format with Timbre |
| 19:02 | afhammad | justin_smith: Do you mean in the config (its not very clear)? https://github.com/ptaoussanis/timbre/tree/dev#configuration |
| 19:05 | justin_smith | the :fmt-output-fn key of the config should have your formatter |
| 19:05 | justin_smith | it gets all the log info as arguments, and can construct the string as it likes |
| 19:07 | cespare | I wish I could make a record that didn't have an auxiliary map. |
| 19:08 | cespare | (assoc r :some-crap 123) should fail. |
| 19:09 | gfredericks | cespare: I bet ztellman's custom map types could do that |
| 19:10 | cespare | gfredericks: what project is that? |
| 19:23 | gfredericks | cespare: https://github.com/ztellman/potemkin#def-map-type |
| 19:27 | cespare | gfredericks: oh, neat. That does seem helpful. |
| 20:02 | technomancy | Leiningen 2.4.3 is out, everybody. |
| 20:02 | technomancy | you know what that means |
| 20:03 | technomancy | PARTY TIEM |
| 20:04 | xeqi | technomancy: time to go do sleep and have the download permissions change? |
| 20:04 | technomancy | bahaha |
| 20:04 | technomancy | pretty much |
| 20:04 | technomancy | xeqi: we're off s3 though, so for real, no more of that nonsense |
| 20:04 | technomancy | also no more $40 monthly bills for traffic |
| 20:15 | Jaood | technomancy: your wishes have come true, there's melpa-stable now ;) |
| 20:17 | technomancy | Jaood: a step in the right direction, for sure |
| 20:17 | technomancy | unfortunately, last I checked it still mangles the version numbers |
| 20:22 | Jaood | guess it needs time, worked fine for cider 0.7 |
| 20:22 | Jaood | this conch lib is nice |
| 20:23 | afhammad | thanks justin_smith |
| 20:24 | Jaood | technomancy: did you push 2.4.3 because of the maven central issue? |
| 20:25 | technomancy | Jaood: yeah |
| 20:25 | Jaood | they added https pretty quick ;) |
| 20:25 | talios | technomancy++ |
| 20:25 | technomancy | Jaood: amazing what getting a story to the top of HN can do |
| 20:26 | talios | Jaood - they were already planning it with contract negs as well. Not that it really does anything. It a false safety net. |
| 20:26 | technomancy | uuuuuh |
| 20:26 | technomancy | it's an important part of a defense in depth |
| 20:27 | technomancy | it's not the be all and end all of security, but it blocks a number of attacks that would otherwise be trivial to perform |
| 20:27 | technomancy | necessary but not sufficient |
| 20:27 | talios | -an- important part. MITM protection yes, but security? god no. You can't really trust arbitrary code, this will let you trust it wasn't altered tho. |
| 20:28 | technomancy | security isn't a black and white thing |
| 20:28 | technomancy | you can't say "this has it, and that doesn't" |
| 20:29 | talios | true. plus, given central isn't immutable ( not sure if clojars is? ) - you could deploy a false 1.2 of nnn overwriting the original. new signage, no MITM. |
| 20:29 | justin_smith | technomancy: I think we can say "that doesn't" - at least in some very silly examples I could invent |
| 20:30 | technomancy | we should be glad when important steps are made in the right direction, but we shouldn't pat ourselves on the back and say "yay, we made it; we're secure" |
| 20:30 | talios | +1 |
| 20:30 | justin_smith | talios: only works with Snapshots in my experience |
| 20:30 | technomancy | the situation is no longer embarrassingly bad, merely bad =) |
| 20:30 | TEttinger | (inc technomancy) |
| 20:30 | lazybot | ⇒ 129 |
| 20:30 | talios | justin_smith - nope. we did it on the weekend when we released a botch artifact. re-rereleased with the same version |
| 20:31 | justin_smith | talios: oh, I thought I had seen that fail, yuck |
| 20:31 | technomancy | talios: clojars and central are both immutable modulo "contact support and get them to un-bork you" afaik |
| 20:31 | technomancy | (plus clojars snapshots) |
| 20:32 | technomancy | talios: or were you able to do that without help from sonatype? |
| 20:32 | justin_smith | talios: oh, you were talking about central, I thought you were talking about clojars |
| 20:32 | talios | technomancy - yep. deployed new version to oss.sonatype.org, published the sync replaced. |
| 20:32 | talios | +and |
| 20:32 | technomancy | huh; I was told that wasn't supposed to be possible |
| 20:33 | technomancy | the policy on clojars is to only perform deletions in the event of leaking sensitive code or license violations |
| 20:33 | technomancy | but it's been proposed to allow users to delete jars they own with zero downloads |
| 20:33 | xeqi | ~zero |
| 20:34 | clojurebot | No entiendo |
| 20:37 | xeqi | usually that happens, but there has been some laziness lately: https://github.com/ato/clojars-web/issues?q=is%3Aopen+delete |
| 20:55 | gfredericks | I just downloaded some code from the internet (lein 2.4.3) that I never read and am not really sure where it came from and it's going to help me make sure I don't accidentally download the wrong code |
| 20:58 | gfredericks | security is fun wheeeee |
| 20:58 | xeqi | just don't run "lein new something something" cause then it will go download more random stuff you've never read and run it |
| 20:59 | hyPiRion | and don't use plugins either |
| 21:00 | xeqi | or dependencies |
| 21:00 | gfredericks | or linux |
| 21:00 | gfredericks | or other operating systems |
| 21:01 | hyPiRion | xeqi: can you run dependencies with lein itself? Execpt for run, repl and compile? |
| 21:01 | gfredericks | man I don't know how security nerds sleep at night |
| 21:02 | hyPiRion | gfredericks: it's 3 am here and I'm not even a security nerd. |
| 21:02 | hyPiRion | They must be in pretty bad shape |
| 21:06 | gfredericks | "Security experts admit the only thing they're sure about is that "foobar" hashes to c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2." |
| 21:07 | xeqi | hyPiRion: well, the exploit would need a class to be loaded to hook off of |
| 21:07 | xeqi | so those, test, update-in maybe? |
| 21:09 | cespare | Trying to use def-map-type from potemkin, but I can't get even the example in the README to work. https://gist.github.com/cespare/7c17f04619227f7df60c |
| 21:09 | cespare | any ideas? |
| 21:14 | gfredericks | cespare: can't reproduce |
| 21:14 | gfredericks | maybe try restarting repl? |
| 21:14 | cespare | I did :( |
| 21:15 | gfredericks | you're using 0.3.7? |
| 21:15 | cespare | i did just the steps in the gist from a fresh repl |
| 21:15 | cespare | yes |
| 21:16 | gfredericks | versions of clojure & jre? |
| 21:16 | cespare | 1.5.1 and 1.7 |
| 21:16 | gfredericks | I'm on 1.6.0 |
| 21:17 | cespare | i'll try 1.6.0 |
| 21:17 | cespare | gfredericks: okay, same result in 1.6.0 |
| 21:19 | danielcompton | technomancy: would it be a good idea to have an install script that people run to install leiningen for the first time? I'm not crazy about curl -sSL https://get.rvm.io | bash -s stable but it certainly is easier |
| 21:20 | cespare | gfredericks: i'll just open an issue |
| 21:20 | gfredericks | cespare: reproduced |
| 21:20 | cespare | oh? |
| 21:20 | gfredericks | I might have been using an older version due to my user profile |
| 21:21 | gfredericks | yep that's it |
| 21:22 | gfredericks | so potemkin 0.3.4 is what I'm using when it works fine |
| 21:22 | gfredericks | you could try that and file an issue for 0.3.7 |
| 21:23 | gfredericks | it looks like a fun error to investigate but I gotta go put corn in bags and do dishes |
| 21:23 | dbell | had a quick idiom question: which is preferable: (list var-to-be-resolved) or `(~var-to-be-resolved) for single-member lists? |
| 21:23 | cespare | gfredericks: i'm surprised the tests pass. |
| 21:23 | cespare | gfredericks: they make a map type |
| 21:23 | gfredericks | cespare: it might be a stale README? |
| 21:23 | cespare | gfredericks: (or maybe they don't) |
| 21:23 | gfredericks | oh |
| 21:24 | cespare | gfredericks: oh, actually, the test def-map-type defines with-meta and meta as well. |
| 21:24 | cespare | gfredericks: even though the readme implies you don't need to define those yourself. |
| 21:25 | gfredericks | yep |
| 21:27 | cespare | gfredericks: yeah, defining meta fixes it. |
| 21:30 | cespare | gfredericks: https://github.com/ztellman/potemkin/issues/26 |
| 21:30 | cespare | thanks for your help |
| 21:31 | gfredericks | np |
| 21:40 | technomancy | danielcompton: I don't really see how that's easier |
| 21:41 | technomancy | lein is its own install script |
| 21:42 | danielcompton | technomancy: or giving people an instruction like: `curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > ~/lein && lein` |
| 21:43 | xeqi | chmod +x |
| 21:43 | technomancy | isn't that already in the readme? |
| 21:43 | technomancy | hm; apparently not |
| 21:43 | danielcompton | Not at http://leiningen.org/#install |
| 21:44 | technomancy | danielcompton: the problem is that not everyone has ~/bin on $PATH |
| 21:45 | danielcompton | technomancy: yeah, I agree it's an issue. I'm just thinking about beginners who don't have a solid grasp on the shell and needing to know how to download this file, and check what's on their path |
| 21:48 | technomancy | yeah, I'm a little conflicted on whether people who don't know how to use computers should be learning clojure in the first place |
| 21:48 | technomancy | it's not exactly a friendly introduction to computing |
| 21:50 | justin_smith | you heard it here first folks, clojure isn't friendly |
| 21:50 | technomancy | same problem as people trying to learn emacs and clojure at the same time |
| 21:50 | technomancy | justin_smith: the idea that this could be controversial didn't occur to me |
| 21:51 | justin_smith | I was double-jokign |
| 21:51 | justin_smith | not controversial at all, clojure is weird |
| 21:56 | cminus1 | Is it possible to pass a :configurator option to run-jetty as called by lein ring server? |
| 22:00 | danielcompton | technomancy: I don't think it's much less friendly than (say) Ruby, it's just that the Ruby community has a bunch of practices and tutorials and 'copy this shell command to execute remote code' which reduce the complexity for a beginner |
| 22:02 | dbasch | danielcompton it’s not just that. Ruby is very forgiving regarding syntax, and even has different names for the same thing (e.g. inject = reduce) |
| 22:02 | dbasch | all of which is horrifying to me, but more tolerant of beginners |
| 22:03 | justin_smith | also, it uses a syntax that looks like the math syntax you have been learning since elementary school |
| 22:03 | danielcompton | dbasch: I guess my point is that it is possible to lower the barrier to entry for Clojure further |
| 22:04 | dbasch | danielcompton: of course, right now it’s relatively high so it wouldn’t be too hard to lower it a bit |
| 22:04 | danielcompton | dbasch: exactly |
| 22:05 | danielcompton | dbasch: I'd love to do some user research with people new to Clojure to see what they find difficult and where they trip up |
| 22:05 | dbasch | but also, what made ruby explode was having a “killer app” of sorts in rails |
| 22:05 | technomancy | I'm all for getting rid of incidental obstacles, but I am fairly sure that Clojure will never embrace beginners the same way Racket does. |
| 22:06 | technomancy | in this case I would argue the complexity is not incidental; if you don't understand how paths work, you should not be manually installing software like leiningen |
| 22:06 | kristof | What does it take to embrace a beginner? |
| 22:08 | technomancy | the people who shape the language need to spend a significant amount of their time interacting with people who are learning it. |
| 22:09 | technomancy | I'd imagine part of why drracket is so good is that it's written by professors who use it for their day job. |
| 22:30 | Jaood | the JVM is in good hands http://openjdk.java.net/projects/panama/ |
| 22:31 | brehaut | i forget, does java 8 or 9 have unsigned primatives? |
| 22:32 | justin_smith | 8 does not |
| 22:33 | justin_smith | http://stackoverflow.com/questions/22903669/java8-unsigned-arithmetic err... maybe I spoke too soon |
| 22:33 | justin_smith | it doesn't have unsigned data, just methods that treat it as unsigned (?) |
| 22:36 | ToBeReplaced | justin_smith: lots of updates to nio.file, and some TODOs carved out if you have any interest |
| 22:38 | justin_smith | ToBeReplaced: awesome, thanks for the update, I'll check it out |
| 22:41 | justin_smith | ToBeReplaced: I forked it onto my github account, and will likely update with PRs |
| 22:42 | ToBeReplaced | justin_smith: cheers, i'd love that |
| 22:46 | justin_smith | you'd think that git would add an upstream remote to a forked repo |
| 22:46 | justin_smith | I guess they prefer you do everything via their UI or something |
| 22:47 | justin_smith | *github |
| 22:52 | brehaut | its been about 5 months since i last looked at Om; whats the best getting started guide atm? |
| 23:00 | ddellacosta | brehaut: probably dnolen's guides remain the best |
| 23:01 | brehaut | ddellacosta: thanks |
| 23:01 | ddellacosta | brehaut: meant these in particular: https://github.com/swannodette/om/wiki/Basic-Tutorial, https://github.com/swannodette/om/wiki/Advanced-Tutorial |
| 23:02 | ddellacosta | brehaut: although something appears to be up with the advanced one... |
| 23:02 | brehaut | hah yeah thats not super comprehensive :P |
| 23:02 | brehaut | its a bit frustrating that the intermediate tutorial wants to have me use datomic too |
| 23:04 | ddellacosta | brehaut: yeah, I guess we really need some more Om tutorials/docs/etc. |
| 23:05 | ddellacosta | brehaut: I would also spend some time checking out the examples, if that is a useful way for you to learn: https://github.com/swannodette/om/tree/master/examples |
| 23:05 | brehaut | ddellacosta: yeah; i understand why theres not currently (alpha etc) but i have found it a bit tricky to get the hang of |
| 23:05 | ddellacosta | brehaut: and I have a few more random examples, which are not super comprehensive but fill in a few gaps in the default examples: https://github.com/ddellacosta/om-cookbook |
| 23:05 | ddellacosta | brehaut: yeah. :-/ |
| 23:05 | brehaut | ddellacosta: i got completely stumped trying to make a numeric text field last time i was experimenting. it was basicaly the first thing i tried to do |
| 23:06 | brehaut | thanks |
| 23:06 | brehaut | (inc ddellacosta) |
| 23:06 | lazybot | ⇒ 6 |
| 23:06 | ddellacosta | brehaut: some things are really not easy to get at first. I'm so busy that I haven't been spending much time writing docs lately, but I really do want to get more Om docs/tutorials/blog posts out there |
| 23:06 | ddellacosta | brehaut: so on that note, let me know what you think would be helpful... |
| 23:06 | blr | is anything special required to use sqlite with ragtime.sql.files? have defined :ragtime {:database "jdbc:sqlite:foo.db"} yet getting exception db-spec ragtime.sql.database is missing a required param |
| 23:06 | blr | hey brehaut :) |
| 23:07 | brehaut | blr: hi :) |
| 23:07 | brehaut | ddellacosta: thank you |
| 23:08 | ddellacosta | brehaut: very welcome. :-) |
| 23:10 | zeebrah | hi the cider docs still recommend putting cider-nrepl 0.7.0-SNAPSHOT in ~/.lein/profiles.clj instead of just 0.7.0 which works without warning |
| 23:11 | blr | brehaut: I noted your issue on the ragtime github repo from last year with emacs autosaves. I've had all manner of issues with those screwing up things unexpectedly, so ended up saving them all in ~/.emacs.d/autosave and ~/.emacs.d/backup respectively |
| 23:12 | brehaut | blr: oh true, i had completely forgotten about that! seems like a good workaround though anyway |
| 23:13 | blr | don't want all that filthy emacs detritus clutting up your filesystem anyway :) |
| 23:13 | brehaut | yeah :) |