2014-06-30
| 00:00 | fitz | ie '(om/build node {:cx 20 :cy 20}) -> node, ' (om/build-all node [{:cx 20 :cy 20}{:cx 30 :cy 30}]) -> text thing |
| 01:02 | Frozenlock | After 10 min of compiling a uberjar: "Release versions may not depend upon snapshots." Thanks... that would have been nice to know it just before compiling... |
| 01:32 | Frozenlock | My uberjar refuses to run :'-( |
| 01:32 | Frozenlock | Exception in thread "main" java.lang.NoClassDefFoundError: clojure/tools/reader/reader_types/Reader |
| 01:55 | talios | sounds like your uber jar isn't very uber |
| 01:56 | Frozenlock | it's a lamejar |
| 01:56 | Frozenlock | Tried upgrading lein, but I get the same result |
| 01:58 | talios | do you actually have a dependency defined for clojure? or is lein giving that for you? uber would only pack the declared deps afaik |
| 01:58 | talios | if its anything like other uberjar type setups |
| 01:58 | Frozenlock | Yup, sweet clojure 1.6.0 |
| 01:59 | Frozenlock | I also tried adding manually clojure.tool.reader, but without any difference. |
| 02:14 | Frozenlock | I think I found the problem... |
| 02:14 | Frozenlock | piggieback with the :repl-options/:injections |
| 02:19 | Frozenlock | May the #clojure logs help some future souls :-p |
| 04:10 | latk | How should I be making ajax requests from cljs ? |
| 06:12 | broquaint | latk: cljs-http or cljs-ajax perhaps? |
| 06:12 | magopian_ | !seen cgrand |
| 06:13 | magopian | Last seen : Jan 22 05:31:49 2014 (22 weeks, 5 days, 04:40:15 ago) |
| 06:14 | magopian | maybe i'll find another way to contact him than waiting here for him to connect ;) |
| 06:15 | eagleflo | latk: goog.net.XhrIo |
| 06:16 | yocapybara | !seen sritchie |
| 06:20 | magopian | yocapybara: that doesn't work, you need to do something like /msg nickserv INFO <nickname> |
| 06:21 | yocapybara | magopian: thanks! I was trying to remember what the command was then I saw your query and jumped in :) thanks for the tip |
| 06:52 | noidi_ | what's the best Clojure debugger for stepping through code? preferably one that doesn't require installing Emacs :) |
| 06:54 | noidi | CCW doesn't work too well for stepping as you constantly end up inside Clojure's implementation |
| 07:00 | eagleflo | Ritz is the best I've tried, but that's for Emacs |
| 07:06 | clgv | noidi: that happens also when you use "step over"? |
| 07:10 | noidi | clgv, no, only when stepping in. but a debugger is pretty useless without the ability to selectively step into functions. |
| 07:15 | clgv | noidi: well thats the problem of clojure being implemented as java - I mean on a pure clojure vm that would eb easy for the debugger ;) |
| 07:16 | clgv | noidi: maybe there are filtering options such that you can filter out clojure.lang.*? |
| 07:20 | noidi | clgv, that's a great idea! thanks! |
| 07:27 | martinklepsch | Anyone aware of some switch to let liberator render instead of download CSVs? |
| 07:29 | noidi | unfortunately the filters don't seem to work in CCW :/ |
| 07:32 | clgv | noidi: ok I guess it's mainly the unaltered java debugger that is used there |
| 07:39 | instilled | hi. is there a way to use (expect …) and others from ns clojure.contrib.mock.* for fns/vars not declared dynamic? unfortunately I don't own the code I'm mocking. If not, is (with-redefs-fn …) the only way to go? |
| 08:00 | martinklepsch | I'm suddenly getting an error that "hostname" cant be nil when trying to compile my uberjar — the hostname is saved in an env var and retrieved via environ but how does that even matter during uberjar compilation? |
| 08:11 | Glenjamin | martinklepsch: aot compilation involves running the clojure code |
| 08:11 | Glenjamin | which triggers any side effects in the top-level of your namespaces |
| 08:13 | martinklepsch | Glenjamin, does aot of my main namespace also aot all the other namespaces? |
| 08:14 | martinklepsch | because the source of the error is in another namespace |
| 08:15 | martinklepsch | Glenjamin, btw, I realized slightly to late that you were at EuroClojure! Wanted to grab you and thank you personally for all the time you spend here helping people :) |
| 08:15 | perplexa | hellow. i have a function that reads contents of a file and gets called repeatedly from different locations in the code. to make it load the data only nce, would i use a macro that just creates a function that returns the file's contents? |
| 08:16 | martinklepsch | perplexa, what about just using (def x (slurp ...)) and using that reference? |
| 08:24 | Glenjamin | martinklepsch: yeah, AOT is "infectious" as someone put it recently |
| 08:26 | martinklepsch | huh, ok. So how do you get around that? It's kind of as well: ns.core requires ns.index requires ns.retrieval — index and retrieval use the env var but only retrieval fails even though it's further down the requiring chain than index?! |
| 08:30 | martinklepsch | And it worked before with makes it even wierder |
| 08:31 | perplexa | martinklepsch: i'm gonna look into it. thanks |
| 08:42 | perplexa | martinklepsch: but slurp also doesn't cahce the file read ;p |
| 08:44 | noidi | (def x (delay (slurp ...))) |
| 08:45 | noidi | that will load the file the first time you deref x and return the cached contents on subsequent derefs |
| 08:45 | perplexa | that's pretty much what i am looking for :) |
| 08:45 | noidi | that will also avoid loading the file at compilation time (which is what would happen with (def x (slurp ...))) |
| 08:50 | perplexa | noidi: can i somehow wrap that in a function? ;x |
| 08:50 | perplexa | like, (defn x [target] (delay (slurp target))) |
| 08:50 | perplexa | that yields a delay object ;x |
| 08:51 | perplexa | hm |
| 08:51 | perplexa | (defn x [target] @(delay (slurp target))) seemms to do it |
| 08:53 | perplexa | meh. that creates new delays every time |
| 08:55 | perplexa | noidi: any way to wrap that inside a function? |
| 08:59 | Glenjamin | i think you want memoize |
| 08:59 | Glenjamin | ,(doc memoize) |
| 08:59 | clojurebot | "([f]); Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use." |
| 09:00 | Glenjamin | martinklepsch: simplest way is to only read the env as part of your application's -main function, or the equivalent |
| 09:01 | perplexa | thanks :) gonna check in a few |
| 09:06 | martinklepsch | Glenjamin, I see. I wonder though how that worked in the first place then |
| 09:09 | tolitius | having several files/functions to compile, is there a way to see what [which file/function] Clojure compile is doing (e.g. logging)? |
| 09:09 | tolitius | *compiler |
| 09:11 | clgv | def-ing file contents is usually not a good idea |
| 09:11 | clgv | better compose a file-loading function with the rest of the programm |
| 09:12 | clgv | perplexa: ^^ |
| 09:13 | perplexa | i'm actually using the load-props function from here: http://stackoverflow.com/questions/7777882/loading-configuration-file-in-clojure-as-data-structure |
| 09:14 | perplexa | and i want it to be cached and not call load-props every time i access a property |
| 09:14 | perplexa | but i'm new to clojure and really don't even have an idea what i am doing :) |
| 09:14 | perplexa | just trying all of the suggestions that get thrown at me |
| 09:24 | martinklepsch | Glenjamin, ok so I previously had a very minimal main namespace that actually didn't require anything getting these env vars. When I now get these env vars in main how would I access them in the other namespaces? |
| 09:24 | Glenjamin | i'd either pass around a config map from main |
| 09:25 | Glenjamin | or have a config namespace that provides access to the env wrapped in a function/delay or similar |
| 09:28 | perplexa | Glenjamin: memoize is friggin' awesome, exactly what i wanted. thank you |
| 09:46 | jdkealy | is it possible to use karma tests with om ? |
| 09:50 | martinklepsch | Glenjamin, that config namespace sounds like the simplest solution in my case. I'm surprised though about the trouble this is causing me right now. Wonder at what stage it might be worth looking into something like stuartsierra's component lib. |
| 10:17 | benzap | was wondering, if I wanted to make my own remote repl, and I wanted to return results being sent from the server to the client, would I wrap each call made to the repl in a (print-str & body), or is there another way to do this? |
| 10:18 | borkdude | what does The Joy of Clojure 2nd edition offer compared to the first edition? |
| 10:31 | benzap | having an issue figuring out how to catch stdout, and the result of a sexp within clojure |
| 10:31 | benzap | ,(with-out-str (print-str (map (partial + 1) [1 2 3 4]) (println "Hello World!"))) |
| 10:31 | clojurebot | "Hello World!\n" |
| 10:33 | benzap | woops |
| 10:33 | benzap | (with-out-str (print-str (println "Hello World!") (map (partial + 1) [1 2 3 4]))) |
| 10:33 | benzap | what i'd like to see is "Hello World!\n(2 3 4 5)" |
| 10:35 | rplaca | ,(with-out-str (do (println "Hello World!") (println (map (partial + 1) [1 2 3 4])))) |
| 10:35 | clojurebot | "Hello World!\n(2 3 4 5)\n" |
| 10:35 | rplaca | benzap: ^ |
| 10:44 | dbasch | ,(map inc [1 2 3 4]) ;; benzap |
| 10:44 | clojurebot | (2 3 4 5) |
| 11:12 | wei__ | how do I call something like StaticClass.StaticClass2.method(arg1, arg2) in Clojure? |
| 11:13 | cbp | Class1$Class2/method |
| 11:14 | cbp | you also need to import Class1 and Class$Class2 |
| 11:27 | wei__ | cbp: does this work if Class2 is defined as a static class inside of Class1? |
| 11:29 | wei__ | oh! got working. you have to literally (:import [Class$Class2]). thanks for the help |
| 11:29 | mordocai | Hello, I am wanting to make a super simple UI for a Conway's game of life style application I am working on. I want to display a grid of cells, and support pause/play/quit. Would seesaw be my best bet or is something else recommended? Doesn't need to be GUI, if there is a console based library that will work well. |
| 11:29 | radix | does anyone have a description of clojure's implementations of lists and vectors? I'm wondering if they're implemented as HAMTs or in the "usual" way |
| 11:30 | wei__ | mordocai: there’s https://github.com/sjl/clojure-lanterna/ |
| 11:30 | _alejandro | mordocai: https://github.com/sjl/clojure-lanterna/ |
| 11:30 | _alejandro | wei__: too fast |
| 11:30 | wei__ | :) referenced from http://stevelosh.com/blog/2012/07/caves-of-clojure-01/ |
| 11:31 | cbp | radix: http://hypirion.com/musings/understanding-persistent-vector-pt-1 |
| 11:31 | radix | hooray :) thanks cbp |
| 11:32 | mordocai | Looks like it'll probably do what I need. Thank goodness it isn't curses (or if it secretly is, I don't have to deal with it) |
| 11:32 | radix | cbp: great, that's what I was hoping. what about lists, are they typical conses? |
| 11:35 | pjstadig | radix: they are not typical conses in that dotted pairs are not allowed, and there's a difference between a clojure.lang.PersistentList and clojure.lang.Cons |
| 11:36 | pjstadig | but they both behave the same through the sequence abstraction |
| 11:36 | radix | ok, yeah, I knew about no dotted pairs, ... I guess I meant "typical linked list" |
| 11:37 | radix | in other words, putting something at the end needs to reallocate the whole thing? |
| 11:37 | pjstadig | radix: yeah they are pretty typical linked lists |
| 11:37 | pjstadig | radix: yes |
| 11:37 | radix | ok cool, that helps a lot, thank you :) |
| 11:37 | radix | vecs are super cool. |
| 11:42 | Willis1 | mordocai, if you want to get more ambitious you can try this: https://github.com/oakes/play-clj |
| 11:45 | gfredericks | can somebody using lein 2.4.2 try `lein help release` and let me know if it hangs? |
| 11:45 | ndaly | it doesn't for me |
| 11:46 | ndaly | "Leiningen 2.4.2 on Java 1.7.0_51 OpenJDK 64-Bit Server VM" |
| 11:47 | gfredericks | hrm |
| 11:47 | gfredericks | I bet this is related to having lein-release in my profile |
| 11:48 | gfredericks | yep |
| 11:49 | gfredericks | does anybody know if this new `release` task is meant to have the same functionality as the lein-release plugin? |
| 11:49 | gfredericks | or be able to provide it rather |
| 11:57 | {blake} | mordocai, I had trouble with lanterna. It's not something well-documented, supported or widely used, I don't think. (I also used it for a Game Of Life thing.) |
| 11:57 | benzap | was wondering, how does the repl capture both the stdout, and the last evaluation? |
| 11:57 | hotcore | In Clojure, you would define Person with a single line: |
| 11:57 | hotcore | (defrecord Person [first-name last-name]) |
| 11:57 | hotcore | and work with the record like so: |
| 11:57 | hotcore | (def foo (->Person "Aaron" "Bedra")) ; What does the ->Person mean? Something like "new"? |
| 11:58 | benzap | hotcore: you sure it isn't (def foo (Person. "Aaron" "Bedra")) |
| 11:58 | gfredericks | defrecord creates a pair of constructor helpers |
| 11:58 | benzap | ,(defrecord Person [f l])(Person. "Ben" "Zap") |
| 11:58 | clojurebot | sandbox.Person |
| 11:58 | gfredericks | it essentially did a (defn ->Person [first-name last-name] (Person. first-name last-name)) |
| 11:59 | hotcore | benzap nope. Copied it from the book "Programming Clojure 2nd ed" |
| 11:59 | gfredericks | there's also map->Person |
| 12:00 | hotcore | gfredericks thx, I get it. Have to read more docs then. |
| 12:02 | gfredericks | hotcore: hopefully the docstring for defrecord mentions this |
| 12:02 | gfredericks | ,(doc defrecord) |
| 12:02 | clojurebot | "([name [& fields] & opts+specs]); (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the current namespace, the given f... |
| 12:02 | gfredericks | somewhere in the ... |
| 12:05 | benzap | so i'm guessing it's preferred to use ->Person to signify that you're using a clojure record type, instaed of making it ambiguous such that it looks like a java class |
| 12:05 | benzap | or something |
| 12:05 | hotcore | OK thx for the help. |
| 12:07 | gfredericks | benzap: there's also a couple advantages to using regular functions instead of interop |
| 12:07 | gfredericks | e.g., you get to avoid :import, and you allow various dynamic abilities that come with vars |
| 12:37 | dene14_ | Hi guys, any ideas why alia limiting me at 16 connections to cassandra? for sure, I've set core-connections-per-host to 64 and sending ~40 flows of data to my app |
| 12:37 | dene14_ | I've only able to regulate connection pool between 1 and 16 connections |
| 12:43 | benzap | was wondering, is there a way to return the results of a sexp, and also include all stdout calls as well? |
| 12:44 | benzap | ,(let [println (fn [msg] (str msg " foo!"))] (println "I pity the")) |
| 12:44 | clojurebot | "I pity the foo!" |
| 12:46 | cbp | I don't really know what you're asking for but you can bind *out* to a StringWriter |
| 12:48 | benzap | cbp: I mean, say I have a function that has a bunch of (printlns), and I want those concatenated into the (sexp result) |
| 12:48 | benzap | ,(do (println "add me to this result") (inc 1)) |
| 12:48 | clojurebot | add me to this result\n2 |
| 12:48 | benzap | wat |
| 12:48 | benzap | so basically waht clojurebot is doing |
| 12:49 | benzap | ,(do (println "add me to this result") (println "another line") (inc 1)) |
| 12:49 | clojurebot | add me to this result\nanother line\n2 |
| 12:49 | benzap | how is it taking stdout, and incorporating it into the result? |
| 12:51 | cbp | ,(let [f #(do (println 1) 2) sw (java.io.StringWriter.)] (binding [*out* sw] (let [x (f)] (str sw x)))) |
| 12:51 | clojurebot | "1\n2" |
| 12:52 | benzap | ah, I see |
| 14:02 | martinklepsch | a question for the vim people here: how have you setup your vim to "split" namespaced fns or namespaces with multiple segments into multiple words so you can move through them with `w`? |
| 14:13 | PigDude | which is normal for c which will not be falsy? (defn f ([a b] (f a b default-c))..) or (defn f [a b & [c] ... (or c default-c) ...) ? |
| 14:13 | PigDude | 1st style is like in erlang but apart from falsy behavior is there a difference? is one preferred? |
| 14:14 | iamjarvo | martinklepsch: did you see this setup somewhere? |
| 14:14 | arrdem | PigDude: the 1st style won't really work in Clojure unless you have a nilable 3rd argument and are invoking via apply. |
| 14:14 | bbloom | PigDude: if i understand your question, you're asking about default arguments? prefer arity overloading |
| 14:15 | peterko | Hi #clojure, if I want to enhance my Java app with an Clojure REPL, which implementation/project would you recommend? |
| 14:15 | PigDude | bbloom: erm which is arity overloading? :) |
| 14:15 | martinklepsch | iamjarvo, no |
| 14:15 | amalloy | PigDude: the first one. do the first one |
| 14:15 | PigDude | hehe ok |
| 14:18 | Janiczek | martinklepsch: would :set iskeyword-=. help you? |
| 14:18 | PigDude | thank you |
| 14:19 | Janiczek | martinklepsch: /KEYWORDS here: http://vimdoc.sourceforge.net/htmldoc/usr_05.html |
| 14:19 | martinklepsch | Janiczek, there is some conversation in #vim going on about that and tpope basically says it's a no-go |
| 14:19 | hiredman | peterko: it depends what you want, if you embed an nrepl server you can connect to it from any nrepl client (which most editors people write clojure in have) |
| 14:20 | amalloy | martinklepsch: i'm not a vim user, but what about using "f." or something to go inside of these symbols instead of treating them as separate words? |
| 14:20 | tpope | not without breaking other behaviors that is |
| 14:20 | tpope | amalloy: exactly what I recommended |
| 14:21 | Willis1 | peterko - take a look at this: http://hack-tastic.blogspot.com/2013/05/unable-to-resolve-symbol-original-ns.html |
| 14:21 | Willis1 | It's actually simpler now since the nrepl folks fixed the bug mentioned |
| 14:22 | peterko | hiredman: well, I'm pretty new to Clojure, what's a nrepl server? I want to provide a commandline for users to be able to write code "on-the-fly" |
| 14:22 | bbloom | martinklepsch: don't forget that you can use ; after f. |
| 14:23 | martinklepsch | bbloom, whats `;` supposed to do? |
| 14:23 | peterko | the app is just a toy project built on top of NASA's World Wind SDK, so it's a globe. I want users to be able to add various stuff from the repl |
| 14:23 | amalloy | i'm learning all about vim today, apparently |
| 14:24 | bbloom | :help ; |
| 14:24 | hiredman | peterko: a console in a gui kind of application? |
| 14:24 | benzap | was wondering, how could I bound a set of expressions to a given namespace? |
| 14:24 | Janiczek | bbloom: huh, how did I not know about ";" :) basically it repeats the motion? |
| 14:24 | bbloom | Janiczek: yup |
| 14:24 | peterko | hiredman: yes, exactly |
| 14:24 | martinklepsch | bbloom, :) |
| 14:24 | hiredman | incanter has some kind of gui console repl |
| 14:24 | amalloy | there's even http://stackoverflow.com/questions/1523602/the-behavior-of-to-repeat-the-last-t-command-bothers-me-can-you-help-me-make which is about how ; is useless after t |
| 14:25 | bbloom | amalloy: i prefer the way ; works with t the way it is now. it composes for macros better |
| 14:26 | amalloy | sure, you wouldn't want to actually change it |
| 14:26 | bbloom | but apparently 7.3.235 changed it |
| 14:26 | amalloy | "repeat previous thing" is more useful than "repeat previous thing unless it's useless in which case do something smart" |
| 14:26 | bbloom | and there is a compat option |
| 14:27 | tpope | what on earth, this isn't true at all |
| 14:27 | bbloom | amalloy: well, it could be argued that t should be redefined to be move-right-one-char, then do "till" |
| 14:27 | tpope | ; after a t skips a next character match |
| 14:27 | puredanger | peterko: maybe https://github.com/matlux/jvm-breakglass ? |
| 14:27 | bbloom | tpope: seems it was changed in patch 7.3.235 |
| 14:28 | bbloom | *shrug* i didn't notice |
| 14:28 | tpope | bbloom: word. it's also not true in much older vim |
| 14:28 | amalloy | (which is three years ago) |
| 14:28 | bbloom | i guess it doesn't matter that much then |
| 14:28 | tpope | so it was probably a brief regression |
| 14:28 | tpope | probably affected whatever one patch level it was ubuntu had in stable 4 years ago |
| 14:29 | peterko | puredanger: that looks promising, thanks |
| 14:36 | pradeepc | hi .. i have a vector of hash-maps.. i want to remove those hash-maps from the vector whose some field is nil. how can i achieve this |
| 14:37 | martinklepsch | pradeepc, use `remove` |
| 14:37 | cbp | (remove #(when (nil? (:some-field %))) maps) |
| 14:37 | cbp | er |
| 14:37 | cbp | without the when |
| 14:37 | johnwalker | why not |
| 14:38 | johnwalker | (filter :some-field maps) |
| 14:38 | Chousuke | strictly speaking that removes falses too |
| 14:38 | johnwalker | thats true |
| 14:38 | arrdem | and maps where the :some-field is present but associated to nil.. but that may be a feature |
| 14:39 | turbofail | actually that seems to be exactly what's asked for |
| 14:39 | johnwalker | (filter #(-> % :some-field some?) maps) |
| 14:39 | arrdem | &(doc some) |
| 14:39 | lazybot | ⇒ "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)" |
| 14:40 | arrdem | johnwalker: I think that's gonna be a sequence type error |
| 14:40 | johnwalker | &(doc some?) |
| 14:40 | lazybot | java.lang.RuntimeException: Unable to resolve var: some? in this context |
| 14:40 | arrdem | &(doc any?) |
| 14:40 | lazybot | java.lang.RuntimeException: Unable to resolve var: any? in this context |
| 14:40 | amalloy | (filter (comp some? :some-field) maps) |
| 14:40 | cbp | (doc some?) |
| 14:40 | clojurebot | "([x]); Returns true if x is not nil, false otherwise." |
| 14:41 | amalloy | (remove (comp nil? :some-field) maps) |
| 14:44 | pradeepc | amalloy: martinklepsch : thanks |
| 14:48 | martinklepsch | I'm trying to setup my program so that I can AOT compile it but it uses env vars and that broke during the compiling process. So Glenjamin suggested to have a config namespace that uses delay or something similar to not use the env vars during compilation. I'm not sure how to set that up though, the following still breaks: https://gist.github.com/mklappstuhl/0150be874ebc4fc2e1f7 |
| 14:49 | Glenjamin | martinklepsch: the problem is that the def's form will be evalled so it can be assigned |
| 14:49 | Glenjamin | do you really need AOT? |
| 14:49 | martinklepsch | Glenjamin, I use the uberjar to run it inside a docker container |
| 14:50 | martinklepsch | Glenjamin, can I get an uberjar without AOT? |
| 14:50 | Glenjamin | you can skip aot in uberjars |
| 14:50 | Glenjamin | one sec |
| 14:50 | martinklepsch | Glenjamin,uf — really? :D |
| 14:50 | cbp | martinklepsch: the delays are meant to wrap the (def (r/tcp- ...) |
| 14:50 | Glenjamin | yeah, you can delay conn itself |
| 14:50 | martinklepsch | cbp, yeah that makes more sense |
| 14:50 | Glenjamin | then only access it as a deref |
| 14:50 | Glenjamin | or invert control and build up runtime state via -main |
| 14:51 | Glenjamin | oh, i might have been wrong about the uberjar aot thing |
| 14:52 | Glenjamin | https://github.com/timmc/lein-otf seems to do some stuff |
| 15:04 | martinklepsch | cbp, Glenjamin, so with delay it'd look somewhat like this: https://gist.github.com/mklappstuhl/0150be874ebc4fc2e1f7 |
| 15:04 | martinklepsch | ? |
| 15:06 | cbp | martinklepsch: yes |
| 15:17 | jonathanj | is there syntax in Clojure for mimicking this Java: } catch (Foo | Bar | Baz e) { ... } ? |
| 15:22 | PigDude | if i have an async api, how does the channel writer receive a response? |
| 15:22 | PigDude | i am figuring out some things with core.async |
| 15:24 | PigDude | how do i know which <! corresponds with an input from my >!? |
| 15:24 | martinklepsch | cbp, and if I use this connection in multiple places it's probably best to put it into the config namespace and use that from everywhere else right? |
| 15:25 | ttasterisco | PigDude: what do you mean by "channel writer receive a response"? |
| 15:26 | jumblemuddle_ | Is there an irc channel for play-clj? |
| 15:27 | PigDude | ttasterisco: (>! adder [1 1]) => 2 ? (where my channel in this example computes sum) |
| 15:27 | ttasterisco | erm, the channel doesnt do anything |
| 15:27 | PigDude | ttasterisco: for what i'm doing, i want (>! c msg) (>! c msg) ..... see if all messages were processed successfully |
| 15:28 | PigDude | ttasterisco: i must be using the wrong terminology then |
| 15:28 | ttasterisco | the syntax is (put! [channel] [data]) |
| 15:28 | ttasterisco | someone else must take the data from the channel |
| 15:28 | ttasterisco | and do whatever it wants with it |
| 15:28 | PigDude | oh, right |
| 15:28 | PigDude | but how do i know if the puts were successful? |
| 15:28 | PigDude | (that they did not throw, for instance) |
| 15:28 | Glenjamin | they either block, or queue - it's always* successful |
| 15:29 | ttasterisco | putting data in the channel will always be successful unless the channel is closed |
| 15:29 | PigDude | right, i used the wrong terminology |
| 15:29 | Glenjamin | technically a channel can be full, but this isn't supposed to happen if you set the buffer properly |
| 15:29 | PigDude | how can the putting code be aware of the success of the taking code? |
| 15:29 | Glenjamin | if you need a reply, you need something to reply on |
| 15:29 | ttasterisco | PigDude: you're thinking incorrectly |
| 15:29 | PigDude | so i need two channels? |
| 15:29 | ttasterisco | no |
| 15:29 | ttasterisco | you can use the same |
| 15:30 | PigDude | ttasterisco: of course i'm thinking incorrectly, there's one blog post about this |
| 15:30 | PigDude | ttasterisco: so i'm lost :) |
| 15:30 | ttasterisco | as Glenjamin said, if you need a reply, it's up to you to define a protocol |
| 15:30 | Glenjamin | i think you can send a reply channel down the channel |
| 15:30 | Glenjamin | then take off that |
| 15:30 | Glenjamin | *if* you really do want an RPC-like thing |
| 15:30 | PigDude | ah ok |
| 15:30 | PigDude | so like erlang but i have to do it myself |
| 15:30 | Glenjamin | but don't quote me on that |
| 15:30 | PigDude | and no atoms |
| 15:31 | PigDude | so, for instance, I could do this?: |
| 15:31 | Glenjamin | there's probably a lib that implements async RPC over channels for you somewhere |
| 15:32 | ttasterisco | PigDude: there's actually more than 1 blog post. there's also a few videos |
| 15:32 | Glenjamin | here's an example https://gist.github.com/thheller/6140975 |
| 15:33 | PigDude | put many tagged values, then take, identifying success of the put batch by checking for the tags in the tagged response? |
| 15:33 | Glenjamin | there's some rpc discussion here: https://groups.google.com/d/topic/clojure/P95cOfuXBUs/discussion |
| 15:34 | Glenjamin | although, it's worth asking why you want to track success, and whether you could structure things differently |
| 15:34 | PigDude | fair point, |
| 15:35 | PigDude | OK, thanks! |
| 15:35 | PigDude | this helps a ton |
| 15:35 | Glenjamin | as a disclaimer, i've watched a few talks on core.async - but never used it |
| 15:36 | PigDude | my only reference points are various queues, and erlang's mailbox mecahnism |
| 15:36 | PigDude | it sounds like you just need to manage more stuff yourslef with this |
| 15:37 | PigDude | esp. wrt error handling |
| 15:37 | Glenjamin | i've seen fairly little discussion of error handling :) |
| 15:37 | Glenjamin | i guess how to handle errors depends on how you're using the channels, and therefore is too high a level for core.async to worry about |
| 15:39 | _alejandro | PigDude: I'd also recommend Timothy Baldridge's screencasts on core.async |
| 15:39 | _alejandro | He dives into error handling fairly well |
| 15:39 | ttasterisco | PigDude: are you trying to do anything specific with core.async? |
| 15:39 | Glenjamin | oh, i shall have to check them out |
| 15:39 | _alejandro | https://tbaldridge.pivotshare.com/ |
| 15:39 | Glenjamin | with such a low level abstraction, it's best to talk in concrete use-cases imo |
| 15:40 | PigDude | ttasterisco: yea, an async logger |
| 15:40 | fifosine | What's the best way to implement an authorization technique for a REST api written with liberator? |
| 15:40 | Glenjamin | heh, if logging fails, who do you tell? |
| 15:40 | ttasterisco | PigDude: so I'm gonna assume you'll want 1 channel shared by several writers and one single reader that takes the messages from the channel? |
| 15:41 | ttasterisco | "one single reader" as in one entity, not necessarily one thread doing the taking :p |
| 15:42 | ttasterisco | fifosine: I guess everyone recommends Friend. how complex is your authorization scheme? |
| 15:42 | fifosine | ttasterisco: I don't know… that's part of my problem, I'm not sure how I should be doing authorization, I just know I need it. |
| 15:43 | PigDude | ttasterisco: hm ... |
| 15:44 | ttasterisco | fifosine: typically you have a set of resources that you want to have protected with some kind of special access. e.g. using RBAC |
| 15:44 | ttasterisco | (role based access control) |
| 15:45 | fifosine | ttasterisco: I know that I want pretty much all of my resources only to be accessed by a user |
| 15:45 | fifosine | *registered user |
| 15:45 | fifosine | I have no idea if i need to set cookies, or do tokens, or ssl. I'm pretty lost here |
| 15:45 | PigDude | ttasterisco: imagine an API that takes a list of numbers and returns if they are prime. (prime? & ns) would put! all those numbers and read the channel for a tagged response [n prime?]. so, the code could put 1000 numbers at once, then by reading tagged values it would be able to return all prime? results |
| 15:46 | martinklepsch | Can one do something like :refer [[this :as that] ...] ? |
| 15:48 | ttasterisco | PigDude: ok, I can imagine that. what's the question? :) |
| 15:49 | ttasterisco | fifosine: you're falling more into authentication that authorization. how you want to implement your auth strategy really depends on your needs. i.e. are you just trying to protect some website? or is it an API? is the client the browser or something like a mobile app? |
| 15:49 | gfredericks | martinklepsch: there's a renames feature inside of :require |
| 15:50 | gfredericks | I can never remember how it works exactly |
| 15:50 | gfredericks | ,(require '[clojure.string :rename {join s-join}]) |
| 15:50 | clojurebot | nil |
| 15:50 | gfredericks | ,s-join |
| 15:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: s-join in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:50 | gfredericks | ,(require '[clojure.string :rename {s-join join}]) |
| 15:50 | clojurebot | nil |
| 15:50 | gfredericks | ,s-join |
| 15:50 | gfredericks | |
| 15:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: s-join in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:50 | fifosine | ttasterisco: Oh, sorry, I mean authentication. It's a simple REST api. |
| 15:50 | gfredericks | ,(require '[clojure.string :renames {s-join join}]) |
| 15:50 | clojurebot | nil |
| 15:50 | gfredericks | ,s-join |
| 15:50 | gfredericks | |
| 15:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: s-join in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:50 | gfredericks | ,(require '[clojure.string :renames {join s-join}]) |
| 15:50 | clojurebot | nil |
| 15:50 | gfredericks | ,s-join |
| 15:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: s-join in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:50 | gfredericks | okay I give up |
| 15:50 | ttasterisco | ,(require '[clojure.string [refer [join :as j]]) (j "a" "b") |
| 15:50 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 15:50 | nathan7 | gfredericks: you realise it doesn't keep context |
| 15:51 | gfredericks | ,*ns* |
| 15:51 | clojurebot | #<Namespace sandbox> |
| 15:51 | gfredericks | ,(def x 2) |
| 15:51 | clojurebot | #'sandbox/x |
| 15:51 | gfredericks | x |
| 15:51 | gfredericks | ,x |
| 15:51 | clojurebot | 2 |
| 15:51 | gfredericks | ,(require '[clojure.string :as nathan7]) |
| 15:51 | clojurebot | nil |
| 15:51 | gfredericks | ,nathan7/join |
| 15:51 | clojurebot | #<string$join clojure.string$join@8ad131> |
| 15:51 | nathan7 | oh, it does? that's kind of crazy |
| 15:51 | ttasterisco | ,(do (require '[clojure.string [refer [join :as j]]) (j "a" "b")) |
| 15:51 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 15:51 | metellus | ,clojure.string |
| 15:51 | clojurebot | #<CompilerException java.lang.ClassNotFoundException: clojure.string, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:52 | gfredericks | the require docstring doesn't mention this at all :/ |
| 15:52 | ttasterisco | (require '[clojure.string [refer [join :as j]]]) (j "a" "b") |
| 15:52 | ttasterisco | ,(require '[clojure.string [refer [join :as j]]]) (j "a" "b") |
| 15:52 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: true> |
| 15:52 | fifosine | ttasterisco: Oh, sorry, I mean authentication. It's a simple REST api. |
| 15:52 | gfredericks | oh I got it |
| 15:52 | gfredericks | super confusing |
| 15:53 | gfredericks | ,(require '[clojure.string :refer [join] :rename {join s-join}]) |
| 15:53 | clojurebot | nil |
| 15:53 | gfredericks | ,s-join |
| 15:53 | clojurebot | #<string$join clojure.string$join@8ad131> |
| 15:53 | gfredericks | ,join |
| 15:53 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: join in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:53 | ttasterisco | fifosine: is it just consumed by a browser client? or mobile apps, etc? |
| 15:53 | Glenjamin | ,(doc require) |
| 15:53 | clojurebot | "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents... |
| 15:53 | gfredericks | martinklepsch: ^ that's how it works |
| 15:53 | hyPiRion | gfredericks: that's not confusing, is it? You must refer it first, then rename. |
| 15:53 | Glenjamin | do you get both symbols, or only one? |
| 15:53 | gfredericks | hyPiRion: wouldn't be ambigious to only rename amirite? |
| 15:53 | Glenjamin | if you had a join before, is it now clobbered? |
| 15:53 | gfredericks | Glenjamin: just one, see the error on `join` |
| 15:54 | Glenjamin | that seems misleading from the api usage imo |
| 15:54 | fifosine | ttasterisco: I'm writing it to be consumed by the browser, but I may try to take it into an app |
| 15:54 | Glenjamin | ,(def join 1) |
| 15:54 | clojurebot | #'sandbox/join |
| 15:54 | ttasterisco | http://stackoverflow.com/questions/14610957/how-to-rename-using-ns-require-refer |
| 15:54 | Glenjamin | ,(require '[clojure.string :refer [join] :rename {join s-join}]) |
| 15:54 | clojurebot | nil |
| 15:54 | Glenjamin | ,join |
| 15:54 | clojurebot | 1 |
| 15:55 | Glenjamin | i should really stop using the public repl to try things out |
| 15:55 | Glenjamin | but it's so handy! |
| 15:55 | Frozenlock | Glenjamin: Don't you have a REPL always running on your machine? |
| 15:55 | Glenjamin | only when i'm doing clojure stuff :) |
| 15:56 | Frozenlock | Which is not always?!? *gasp* |
| 15:56 | Frozenlock | :-p |
| 15:56 | Glenjamin | heh, if only |
| 15:56 | Glenjamin | the require docstring doesn't even mention :refer :s |
| 15:57 | fifosine | ttasterisco: Both at some point |
| 15:57 | ttasterisco | fifosine: the strategy is usually for a token based authentication |
| 15:57 | fifosine | ttasterisco: Is there a lib I should use for this? |
| 15:57 | ttasterisco | $google clojure friend |
| 15:57 | lazybot | [cemerick/friend · GitHub] https://github.com/cemerick/friend |
| 15:59 | fifosine | ttasterisco: Is using the auth token easy to implement in friend? |
| 16:00 | ttasterisco | I can't really comment on that, my experience with Friend is very limited :p |
| 16:01 | Frozenlock | fifosine: My experience with friend is that it's a little complicated, but better than everything else... |
| 16:01 | amalloy | gfredericks: require/rename, not require/renames |
| 16:02 | amalloy | oh, you got there eventually |
| 16:02 | ttasterisco | fifosine: if you're ok with testing a still alpha library that only easily supports cookies for now, then I have to advertise my own library :p |
| 16:02 | fifosine | ttasterisco: I thought you said to use an auth token? |
| 16:02 | ttasterisco | fifosine: ye, but you said for now a browser. you can always change later |
| 16:03 | ttasterisco | (or even mix them) |
| 16:04 | gfredericks | amalloy: all of my thought processes I put on full display in IRC |
| 16:05 | gfredericks | if it's not worth wasting everybody's time with in a public forum, is it really worth thinking about? |
| 16:08 | Glenjamin | (inc gfredericks) |
| 16:08 | lazybot | ⇒ 73 |
| 16:10 | Jaood | fifosine: or use rails |
| 16:50 | whodidthis | when can we has euroclo videos |
| 17:06 | doroluba | Hi! When looking at om-data-vis, I see the line in project.clj: [org.clojure/clojurescript "0.0-2234" :scope "provided"]. I looked up what scope "provided" means to Maven, but I don't see how it helps in Clojurescript. Any ideas? |
| 17:08 | noncom|2 | ,(doc class?) |
| 17:08 | clojurebot | "([x]); Returns true if x is an instance of Class" |
| 17:08 | noncom|2 | (class? 1 Integer) |
| 17:08 | noncom|2 | ,(class? 1 Integer) |
| 17:08 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/class?> |
| 17:08 | Glenjamin | ,(class? Integer) |
| 17:08 | clojurebot | true |
| 17:08 | Glenjamin | ,(class? "Int") |
| 17:08 | clojurebot | false |
| 17:09 | Glenjamin | ,(instance? Integer Class) |
| 17:09 | clojurebot | false |
| 17:09 | Glenjamin | heh |
| 17:09 | whodidthis | ,(instance? Long 1) |
| 17:09 | clojurebot | true |
| 17:09 | Glenjamin | oh right |
| 17:09 | amalloy | doroluba: it means maven should assume that cljs will wind up in the classpath somehow, and not try to include it as a formal dependency |
| 17:09 | Glenjamin | ,(instance? Class Integer) |
| 17:09 | clojurebot | true |
| 17:09 | Glenjamin | i wish docstrings differentiated between arguments and words |
| 17:12 | doroluba | amalloy: Thanks! I guess I should remove "provided", because I'd hope Maven includes it... |
| 17:15 | noncom|2 | yeah! |
| 18:19 | riotonthebay_ | CLJS question: I'm trying to use something found in google-closure-library-third-party. I'm depending on it explicitly, but can't access it. Is there something else I need to be doing? |
| 18:20 | ttasterisco|away | riotonthebay_: check http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html |
| 18:23 | riotonthebay_ | ttasterisco|away: Thanks for the link. I've seen this and am aware of :libs. I'm not sure how to reference something from a leiningen dependency, however. |
| 18:50 | amalloy | hm. i've got this macro, (keyed [a b c]) expands to {:a a :b b :c c}. i've been using it for ages and it's nice, but i recently realized it means i can't just rename locals and then update the places in which they're used |
| 18:50 | amalloy | like if i decide to call a "absolute" instead of a, and then use its rename, the map that i return changes. bummer |
| 18:50 | cespare | I'm having a problem where loading an EDN-ified record from a file fails with a ClassNotFoundException. Works fine from a repl; not from the code running from my uberjar. Ideas? |
| 18:56 | hiredman | you don't have the source file that defines that record type loaded |
| 18:57 | cespare | hiredman: it's weird -- the file where the exception occurs is the same one where the record type is defined |
| 18:57 | cespare | the record is defined at the top |
| 18:57 | hiredman | what reader are you using? |
| 18:57 | cespare | read-string; about to use edn/read-string now to see if that works. |
| 18:57 | hiredman | record type read literals aren't really part of edn |
| 18:58 | hiredman | they are part of the edn superset that clojure code uses |
| 18:58 | hiredman | cespare: try just read-string |
| 18:58 | nathan7 | amalloy: many languages with { key: value } style records have { key } for this |
| 18:58 | cespare | That's what we're doing. |
| 18:58 | cespare | hiredman: ^^ |
| 18:59 | hiredman | cespare: pastebin the exception from read-string? |
| 18:59 | nathan7 | amalloy: maybe do (keyed [:a absolute b c]) |
| 19:00 | hiredman | cespare: how are you printing the record? could the record contain another record? |
| 19:01 | cespare | hiredman: http://pastie.org/9341826 |
| 19:01 | cespare | hiredman: We're printing with prn |
| 19:01 | cespare | hiredman: the record does contain another record, but those are also defined at the top of the same file, and the exception is about the outer one. |
| 19:04 | hiredman | cespare: put a (prn (.getCanonicalName WeightData)) in the file to have it print out what it thinks the classname for the record is |
| 19:04 | hiredman | at this point I would guess some kind of bug around _/- in a record name |
| 19:05 | hiredman | cespare: it looks like you are aot compiling, you may also want to clear out target/ |
| 19:05 | cespare | hiredman: http://pastie.org/9341842 has a bit more info about the record |
| 19:05 | cespare | hiredman: definitely not aot compiling; getting rid of the aot is what made this issue appear ;P |
| 19:06 | cespare | hiredman: I've reproed without any target dir at all. |
| 19:07 | hiredman | cespare: ah, I would double check your record names all match up, it is very possible a name changed, but it kept working with a stale class file in target |
| 19:07 | cespare | hiredman: the getCanonicalName returns the same as in the edn file: "ml_lib.model.WeightData" |
| 19:08 | cespare | hiredman: the stale name thing doesn't seem possible. I've lein cleaned a bunch and the issue is happening on many machines. |
| 19:08 | cespare | hiredman: additionally, the same thing works in the repl if I require the file beforehand. |
| 19:09 | cespare | just not when calling the jar directly with java. |
| 19:10 | hiredman | cespare: how do you know the namespace is loaded? |
| 19:10 | cespare | If I add aot back in, it works. |
| 19:10 | cespare | hiredman: becauase the place where the exception is thrown is in the same namespace. |
| 19:10 | hiredman | cespare: how do you know the namespace that defines the records is loaded? |
| 19:11 | cespare | that is the same namespace. |
| 19:11 | fifosine | Can anyone recommend a simple library for implementing an authentication scheme that uses an auth token? I'm attempting to write a RESTful api using Clojure and authentication is the one thing that's stumping me. |
| 19:11 | cespare | see the stack trace. |
| 19:11 | hiredman | cespare: a namespace is a compilation environment, you can load and run code defined in a given namespace without loading the namespace |
| 19:12 | hiredman | cespare: is the namespace in question required anywhere? |
| 19:12 | dbasch | fifosine: I had that problem and ended up doing it myself. Not sure if any libraries out there are mature enough |
| 19:12 | cespare | hiredman: in the stack trace, model_manager requires the ml-lib.model namespace at the top |
| 19:12 | fifosine | dbasch: Do you have a github repo I could investigate? I have no idea how I'd implement my own auth-token authentication scheme. |
| 19:12 | cespare | (or rather model-manager in clojure-land) |
| 19:13 | dbasch | fifosine: unfortunately mine is private, but it's really not that hard |
| 19:13 | dbasch | fifosine: for tokens I use java UUID |
| 19:13 | dbasch | keep them in a postgresql db |
| 19:14 | dbasch | they have a ttl that gets refreshed if the user continues to use it |
| 19:14 | andyf | cespare: Is the record name a key in your default-data-readers? Or do you supply an option map to edn/read with key :readers ? |
| 19:14 | fifosine | dbasch: So a user posts their credentials to a resource, if it's successful, do they get a token, stored in their cookie? |
| 19:15 | dbasch | fifosine: yes |
| 19:15 | hiredman | ,(defrecord Foo []) |
| 19:15 | clojurebot | sandbox.Foo |
| 19:15 | dbasch | although in my case I don't care how they store it, this is an api |
| 19:15 | hiredman | ,#sandbox.Foo[] |
| 19:15 | clojurebot | #<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true> |
| 19:15 | hiredman | but anyway, he is trying to do that thing |
| 19:15 | fifosine | dbasch: How do you send the token to them in a way that is secure? |
| 19:15 | cespare | andyf: neither. Why would that be necessary? |
| 19:15 | hiredman | which doesn't require the reader to be the maps |
| 19:16 | dbasch | fifosine: of course, my api is ssl-only |
| 19:16 | hiredman | cespare: what does (prn (.getClassloader WeightData)) say? |
| 19:16 | andyf | I am pretty sure that using the edn reader to read records requires at least one of those things to work |
| 19:16 | cespare | hiredman: answered above. "ml_lib.model.WeightData" |
| 19:16 | arrdem | dbasch: so I actually got asked about that yesterday... did you wind up doing ssl at the Ring layer or do you have a proxy? |
| 19:17 | cespare | andyf: again, works fine when aot is on, works fine from the repl |
| 19:17 | dbasch | arrdem: I have a proxy, and do it over nginx |
| 19:17 | hiredman | cespare: new method |
| 19:17 | arrdem | dbasch: that's what I thought was standard. ok. |
| 19:17 | cespare | hiredman: sorry |
| 19:17 | fifosine | dbasch: Ok, so you mandate all requests use ssl, they send you creds, and you respond with the token. Then do all further requests require it in session-store or as a parameter? |
| 19:17 | hiredman | cespare: getClassLoader not getCannonicalName |
| 19:17 | dbasch | fifosine: as a parameter |
| 19:17 | cespare | hiredman: #<AppClassLoader sun.misc.Launcher$AppClassLoader@6411c21b> |
| 19:17 | andyf | With clojure.edn/read? I don't see how |
| 19:17 | cespare | andyf: i'm just using read-string |
| 19:17 | cespare | andyf: clojure.core/read-string |
| 19:18 | andyf | That is in clojure.core which is different |
| 19:18 | fifosine | dbasch: Are you using liberator by any chance? |
| 19:18 | cespare | andyf: same thing occurs with clojure.edn/read-string |
| 19:18 | hiredman | cespare: what version of clojure? |
| 19:18 | cespare | hiredman: 1.5.1 |
| 19:18 | dbasch | fifosine: no, compojure |
| 19:19 | andyf | Sorry when you said edn I assumed you were using clojure.edn/read or clojure.edn/read-string |
| 19:19 | fifosine | dbasch: Ok, just curious cause liberator was suggested to me for it complying with all http specs |
| 19:19 | hiredman | cespare: what does the reader literal look like? |
| 19:20 | cespare | hiredman: if you mean the string I'm trying to read, I put an example at the bottom of http://pastie.org/9341842 |
| 19:21 | dbasch | fifosine: no idea if liberator would have helped me, I wasn't aware of liberator when I built this (6 months ago more or less) |
| 19:21 | hiredman | cespare: I would try swapping the _ with - in the printed string |
| 19:22 | hiredman | could very possibly be some kind of bug in _ and - handling in records |
| 19:22 | cespare | hiredman: but leave the . instead of a / |
| 19:22 | cespare | ? |
| 19:22 | hiredman | right |
| 19:22 | fifosine | dbasch: When the user logs out, do you delete the record from the db or just mark it expired? |
| 19:22 | hiredman | ml-lib.model.WeightData |
| 19:22 | dbasch | fifosine: I null it out just to be sure, but it's not really necessary |
| 19:22 | hiredman | if at all possible I would avoid namespaces with - in the name all together |
| 19:22 | hiredman | (dunno if that would help here) |
| 19:23 | cespare | hiredman: same ClassNotFoundException with ml-lib.model.WeightData |
| 19:23 | dbasch | fifosine: it's nice because it allows me to look at the db and see who's logged in at a glance |
| 19:23 | cespare | hiredman: and why would it be working when we have aot enabled or from the repl, if such a bug exisetd? |
| 19:24 | hiredman | cespare: good point |
| 19:24 | fifosine | dbasch: Sorry if answering these questions is tiresome—I'm trying to write my first webapp in Clojure. Did it take a lot of effort to make your api ssl-only? |
| 19:24 | hiredman | it must be a classloader thing |
| 19:24 | hiredman | ah |
| 19:24 | dbasch | fifosine: no, the hardest part was buying the cert :) |
| 19:24 | fifosine | I don't really know what's necessary to make sure that happens. Is it even a clojure thing? |
| 19:24 | hiredman | Oh |
| 19:24 | hiredman | cespare: something is fishy |
| 19:24 | cespare | hiredman: if this matters, I'm running the thing with java -cp path/to/proj.jar clojure.main -m project.handler |
| 19:25 | hiredman | cespare: I would check your classpath, if the record didn't come from an aot generated classpath, it's classloader should be a DynamicClassLoader |
| 19:25 | hiredman | cespare: not the sun.misc.Appwhatever |
| 19:27 | hiredman | the sun misc whatever classloader only sees the classfiles that exist on disk/in jars at launch, not the dynamically generated classfiles |
| 19:27 | hiredman | so if a record claims to have been loaded from sun.misc, it must have been aot compiled |
| 19:27 | cespare | hiredman: ok, that was due to my :gen-class I put on the model namespace as part of trying to find the problem |
| 19:27 | cespare | hiredman: Without the gen-class, the problem still happens, but indeed the class loader is DynamicClassLoader |
| 19:28 | hiredman | ok, so that sort of makes sense now at least |
| 19:28 | hiredman | the class is visible from the dynamic classloader, but not the sun.misc whatever that is trying to load it |
| 19:28 | hiredman | so the question is, why is that the classloader trying to load it |
| 19:29 | andyf | cespare: Not your original question, but if you do not have strong trust in the source of data you are reading you should consider using the read or read-string in clojure.edn, not clojure.core. See http://clojuredocs.org/clojure_core/clojure.core/read |
| 19:29 | hiredman | if you put (prn @clojure.lang.Compiler/LOADER) in read-introspectable-models what does it print? |
| 19:30 | cespare | andyf: makes sense. I do have strong trust in this edn data though. |
| 19:31 | cespare | hiredman: ok, trying that |
| 19:32 | cespare | hiredman: uh, #<Unbound Unbound: #<Var: --unnamed-->> |
| 19:32 | hiredman | huh |
| 19:33 | hiredman | cespare: that is very weird |
| 19:33 | hiredman | in order for clojure code to be compiled LOADER *must* have a value |
| 19:34 | hiredman | cespare: you said it worked in the repl? |
| 19:34 | amalloy | but once compilation is over, ie at runtime, it'd be normal for that not to be bound, right, hiredman? |
| 19:35 | hiredman | amalloy: yeah, this might just be a *terrible* bug in record reader literals |
| 19:35 | cespare | hiredman: yes. When I run things from the repl, the prn I put in that function shows #<DynamicClassLoader clojure.lang.DynamicClassLoader@d430c4f> |
| 19:35 | hiredman | cespare: you may be able to work around it by switching to a tagged literal |
| 19:35 | ttasterisco | dbasch: are you using nonces? or are you vulnerable to replay attacks? :) |
| 19:36 | hiredman | cespare: slightly more work, but then the data really would be edn, not clojure's superset of edn |
| 19:36 | cespare | hiredman: that requires this separate data_readers.clj file? |
| 19:36 | hiredman | cespare: that or you pass a map ofr readers in to edn/read or edn/read-string |
| 19:37 | cespare | hiredman: hmm, ok, I'll see if that works. |
| 19:37 | arrdem | ttasterisco: how do you replay an ssl link? you'd have to determine what call takes place in each ssl'd transmission and then replay the packets to a closed one time channel.. |
| 19:38 | ttasterisco | oh, he's using ssl, right |
| 19:41 | hiredman | nice litte repro case: |
| 19:41 | hiredman | java -jar target/clojure-1.7.0-master-SNAPSHOT.jar -e "(do (ns foo.bar) (defrecord Foo []) (defn -main [] (prn (->Foo)) (read-string \"#foo.bar.Foo[]\")))" -m foo.bar |
| 19:44 | cespare | hiredman: sure enough, works fine from repl. |
| 19:44 | amalloy | hiredman: why not (read-string (prn-str (->Foo)))? |
| 19:45 | cespare | hiredman: i'm hoping using edn proper will solve the problem for us...but in the meantime, is this a bug that we should file somewhere? |
| 19:45 | hiredman | amalloy: I didn't have any prn at first |
| 19:45 | hiredman | cespare: I am typing one up |
| 19:45 | cespare | hiredman: thanks! |
| 19:50 | hiredman | http://dev.clojure.org/jira/browse/CLJ-1457 |
| 19:53 | {blake} | Hey, all: Parsing XML using clojure.xml parse and zip and getting back :tag :a-tag, :attrs :a-attr, :content :a-content in a map, when I'd just like :a-tag :a-content. Thought about using the startparse in parse but that seems like a rabbit hole. |
| 19:53 | fifosine | dbasch: How do you force https-only? |
| 19:54 | {blake} | Was looking at walk. Seems like it should work but I can't seem to do anything with it but return exactly what I pass in or...nothing. |
| 20:02 | cespare | hiredman: thanks |
| 20:02 | cespare | hiredman: Got everything working using edn/read-string with explicit readers. |
| 20:04 | hiredman | cool |
| 20:14 | fowlslegs | Is there a way I can convert a BigInt or BigInteger to a binary string or to bytes? |
| 20:15 | fowlslegs | OR is there a way I can perform bitwise operations on BigInts or BigIntegers such as bit-xor? |
| 20:18 | pjstadig | fowlslegs: have you looked at the javadocs for BigIntegeR? |
| 20:19 | amalloy | $google javadoc biginteger xor |
| 20:19 | lazybot | [BigInteger (Java Platform SE 8 ) - Oracle Documentation] http://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html |
| 20:22 | dbasch | fifosine: via nginx |
| 20:22 | pjstadig | bit-xor used to work for BigIntegers back in 1.2 |
| 20:22 | pjstadig | yet another thing that was broken needlessly by clojure.lang.BigInt |
| 20:25 | fowlslegs | .toByteArray might work for what I'm doing |
| 20:26 | pjstadig | or the xor method on BigInteger? |
| 20:26 | hiredman | should have used a rules system for generating Numbers.java instead of writing it by hand |
| 20:27 | fowlslegs | Didn't even see that. Thanks pjstadig. |
| 20:27 | hiredman | pjstadig: it doesn't look that was accidentally broken |
| 20:27 | pjstadig | hiredman: or just not introduce the BigInt class |
| 20:27 | hiredman | Numbers.java seems to expressly rule out "bignums" for bit operations |
| 20:29 | hiredman | https://github.com/clojure/clojure/commit/601d9521f88f8fb00e670d2823857cdcb2b2e1c3 |
| 20:29 | hiredman | I wonder what the rationale for that was |
| 20:29 | pjstadig | true because bit ops don't work for BigDecimal anymore either |
| 20:30 | hiredman | pjstadig: I suspect that don't work for BigInt either |
| 20:30 | hiredman | they |
| 20:30 | pjstadig | nope |
| 20:31 | hiredman | at work every commit message references the jira ticket behind the work, I wish clojure had that policy sometimes |
| 20:31 | hiredman | not that I would expect there to be much useful discussion in the jira ticket |
| 20:32 | pjstadig | i'll have to ask taggart, since i work with him now |
| 20:32 | hiredman | hah, well, see if he remembers |
| 20:32 | hiredman | from 2011 |
| 20:32 | pjstadig | yeah |
| 20:33 | pjstadig | it's worth a try |
| 20:33 | hiredman | Oh, that might be pre jira anyway |
| 20:33 | pjstadig | help us taggart. You're our only hope! |
| 20:33 | amalloy | i recall the decision to disallow some bitops for bignums being made. seemed like some of them don't totally make sense for an arbitrary number of bits? |
| 20:34 | hiredman | http://dev.clojure.org/jira/browse/CLJ-767 |
| 20:34 | pjstadig | BigInteger implements them (which doesn't necessarily mean its correct) |
| 20:36 | hiredman | https://groups.google.com/forum/#!topic/clojure-dev/IZHL8ASNjKY |
| 20:37 | hiredman | rich's jls link doesn't work anymore of course |
| 20:39 | pjstadig | the discussion said that Big* shouldn't work with shift ops, and that the bit ops should have primitives as default, but the patch removed Big* support for bit ops |
| 20:40 | hiredman | that is a splitting a hair pretty fine |
| 20:41 | hiredman | I really should finish Archimedes |
| 21:03 | fitz | cljs/om/js-interop question re: https://www.refheap.com/87685 why aren't the x and y coordinates of the circles being updated on tick? (and yes, I realize using om for this is probably dumb) |
| 21:10 | ivan | fitz: om might not be looking for changes in that mutable .nodes structure |
| 21:10 | ivan | I might have missed other errors, so YMMV with that idea |
| 21:12 | fitz | I'm assuming that's what's happening, just not sure of how to rectify it |
| 21:14 | arrdem | I seem to recall that there was a REPL tool for pulling examples from clojuredocs. Is this the case? |
| 21:22 | fitz | figured it out btw, switching to (om/update (data :nodes (js->clj n))) and (data "x")/(data "y") worked |