#clojure logs

2012-08-04

01:09Frozenlo`Is there clojure/clojurescript libraries to simulate mechanical or electrical systems? (à la Bret Victor would be nice)
01:57Bastianx9|| Paypal Account Full Information || Payment Method Liberty Reserve Only || Paypal Account Full Information || Payment Method Liberty Reserve Only || Paypal Account Full Information || Payment Method Liberty Reserve Only ||
02:16mdeboarditext is the worst.
02:19aperiodicyou mean that PDF parsing library?
02:40mritzwhats the best way to have leon 1 and 2 both installed
02:40mritzis there like a virtual environment ?
02:42eggsbywhy not just have lein and lein2 in your $PATH ?
02:47amalloymritz: just install them both, that's all there is. give the two scripts different names
02:50mritzamalloy: Thanks! that worked
04:20leafwhi all. If I have an int like (bit-shift-left 255 24), and I want to store it in an array of primitive ints, how can I cast it to signed int to do so? Clojure, righly so, complains that it can't be casted because it is out of range
04:21leafwi.e. how to store an unsigned int 0xff000000 in a java primitive int, which is signed?
04:31pyrtsaleafw: Don't know of a direct way, but this works for 32 bit: (defn int* [x] (let [i (bit-and 0x7fffffff x)] (Integer. (if (< x 0x8000000) x (+ -0x80000000 i)))))
04:32leafwpyrtsa: thanks. I am hoping there is a better way, for example casting to int at the right places within bit-and, bit-or, etc.
04:32leafwotherwise performance will suffer lots
04:33pyrtsaLike I said, I don't know of any. :/
04:35leafw,(byte 0xff)
04:35clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for byte: 255>
04:35leafwthat made no sense to me
04:35leafwso clojure considers hexadecimal not as bits filled in but as actual numbers
04:39hyPiRionleafw: Makes perfect sense
04:39hyPiRion,0xff
04:39clojurebot255
04:39leafwhyPiRion: so what is the right way to do bit-wise math in clojure?
04:40amalloyleafw: there is no such thing as unsigned on the jvm
04:40leafwhow to pack 4 bytes into one int?
04:40leafwmind giving an example?
04:40leafwamalloy: I am aware. In the java side, one always masks first to 0xff
04:40hyPiRionleafw: ##(ubyte 0xff)
04:41lazybotjava.lang.RuntimeException: Unable to resolve symbol: ubyte in this context
04:41hyPiRionoh, its name is something else, lemme check it up
04:44leafwno suggestions in the clojure cheatsheet for byte similar to ubyte
04:44mdeboardDid I reinvent the wheel here https://gist.github.com/3256063
04:45raekleafw: unchecked-bit-shift-left
04:45mdeboardwrt metadata on proxies
04:45hyPiRion,(unchecked-byte 0xff)
04:45clojurebot-1
04:45hyPiRion,(unchecked-byte 0xffff)
04:45clojurebot-1
04:45leafwaha
04:45leafwthanks
04:45leafwso the unchecked math is what will do it
04:46leafwthanks a lot!
04:46hyPiRionno problem, it's hard to find
04:46leafwthe cheatsheet doesn't list the bit-wise ops under the unchecked section
04:51leafwraek: Unable to resolve symbol: unchecked-bit-shift-left in this context
04:51leafwraek: so unchecked math must be invoked in a binding or something line that
04:52raekleafw: hrm, that functions does not exist, but other unckecked version for other operators do
04:53raekyou can always do this: (unchecked-int (bit-shift-left 255 24))
04:54raek'unchecked-int' works as (int) in java (it throws away all but the 32 lowest bits)
04:54amalloymdeboard: i think you may have just reinvented being crazy
04:54leafw,(unchecked-int (bit-shift-left 255 24))
04:54clojurebot-16777216
04:54leafwgood!
04:54leafwthanks raek
04:55amalloylike, ignoring whether proxy is the right answer ( i don't know what a PdfReader is, these implementations of the meta functions don't make sense
04:55raekI'm not totally sure how *unchecked-math* is used
04:55leafwlack of examples hinders it suse
04:55raekI think you are supposed to 'set!' it before you eval the defns or something
04:55leafwgoogle is full of past examples, but unchecked math has changed lots over time
04:56leafwthere is a *math-context* for with-bindings
04:56leafwhttp://clojuredocs.org/clojure_core/clojure.main/with-bindings
04:56leafwwithout an explanation on what it is for
05:37leafwI got the bit-wise math to work. In short, to imitate the java side of things with truncating primitives, one has to use unchecked-long (the only kind of cast that doesn't result in a reflection warning when using bit-or, bit-and, etc.)
05:37leafwall bit-wise operators are used as normally one would.
05:38leafwand it is true that operations on primitive types return primitives: no boxing warnings
05:40leafwsuprisingly one gets boxing warnings when feeding byte, short, or int into bit-and, for example. Only a long would avoid the reflection warning.
05:41leafwI'd asume that byte/short/int would automatically promote to long
05:44alexyakushevWhat is the best exception to throw if macro was used incorrectly (wrong number of arguments, for instance)?
05:45hyPiRionException.
05:45hyPiRionIt kind of depends, though. Do you want it to be compile-time or runtime?
05:45alexyakushevCompile time, I guess
05:46leafwthe good news is that bit-or with more than 2 arguments runs at the same speed as an unrolled set of bit-or's
05:47hyPiRionThen go with Exception. Runtime should be RuntimeException
05:47alexyakushevAnd what about this "CompilerException java.lang.RuntimeException" Clojure uses for symbols not resolved?
05:52hyPiRion,foo
05:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>
05:52hyPiRion,(doc resolve)
05:52clojurebot"([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)"
05:53hyPiRionbleh
05:53hyPiRion,(source resolve)
05:53clojurebotSource not found
05:55hyPiRionAh, resolve is a runtime error, but I don't know about CompilerException. It's not the compiler there's some issue with when you're using the wrong number of arguments.
05:55hyPiRion,(let [foo (fn [] (resolve 'bar))] nil)
05:55clojurebotnil
05:55hyPiRion,(let [foo (fn [] (resolve 'bar))] (foo))
05:55clojurebotnil
05:57alexyakushevOK, thank you. Exception will do
06:00hyPiRionClojure isn't all that into Java-exceptions as far as I get it - it's better to have a descriptive error message.
08:51hcumberdale;)
08:52hcumberdaleMy blog in clojure is finished ;)
09:09horofoxhcumberdale: share it.
10:51pandeirois there a good reason that predicate functions should only return true or false/nil? i find myself creating pseudo-predicates that return a val or nil; is that a bad pattern?
10:53duck1123I think it depends on the predicate fn, a lot of them return the val for truthy
10:54cshellseems more robust to return the val or nil
10:56duck1123of course, sometimes writing it to return the val may make that predicate slower. In both cases you'd have the test, but if you want to return the value, you'd need an if and then return the input
10:57duck1123(fn [x] (> x 7)) vs (fn [x] (when (> x 7) x))
10:59pandeiroduck1123: right, in my case i need to retrieve the val anyway, so why not return the val
10:59pandeiroseems it would make no sense to convert val to boolean and then retrieve the val again
10:59pandeirobut maybe the wiser people know a reason that would make sense
11:04alexyakushevduck1123: Why would returning a value make the predicate slower? Is there any difference in performance between returning a boolean or a reference to an object?
11:06pandeiroalexyakushev: think he means if you add the conditional (when...)
11:06Chousukegenerally you should only return true or false explicitly in two cases: you're expecting the function to be used in Java code or when you want to return true for nil/false input
11:21Bronsais there a function that trasforms [1 2 3 4] to ((1 3) (2 4))?
11:21gfrederickswhat's the rule there?
11:22gfrederickswhat does it do with [1 2 3]? or [1 2 3 4 5 6]?
11:22gfredericksdo you only care about 4-tuples?
11:22Bronsaone element in the first list, one in the other
11:22Bronsai can do that with ((juxt keys vals) (apply assoc {} coll))
11:22Bronsabuyt it feels too much like cheating
11:23gfredericks,(partition 1 2 [1 2 3 4])
11:23clojurebot((1) (3))
11:23gfrederickshm
11:23Bronsayeah i tried partition
11:24gfredericksthere are proably 40 cludgy ways to do it
11:31gfredericks,(let [pairs (partition 2 (range 6))] [(map first pairs) (map second pairs)])
11:31clojurebot[(0 2 4) (1 3 5)]
11:31gfredericksthat's the cleanest I can think of
11:31Bronsaoh, cool thanks!
11:33mdeboardamalloy_: lol. I'd like to hear more about the dumb things I did wrong.
11:33mdeboardamalloy_: (seriously)
11:43mdeboardamalloy_: https://github.com/mattdeboard/clj-itext/blob/master/src/clj-itext/core.clj is the full file. PdfReader is a class from iText, a PDF-processing library. It has a very painful API. So when you say I've reinvented being crazy wrt my usage of metadata, I'm assuming what you really mean is "that's dumb." Why? I was basically just using it to store metadata about the PDF on the class instance.
11:46pyrtsagfredericks, Bronsa: Here's a little simpler still:
11:46pyrtsa,(apply map list (partition 2 (range 6)))
11:46clojurebot((0 2 4) (1 3 5))
11:47Bronsaeg! thanks
11:59gfrederickspyrtsa: oh of course
12:00pyrtsagfredericks: To be honest, it wasn't that obvious to me at first either.
12:01Bronsathis is funny http://i.imgur.com/GzpUF.png
12:04gfrederickspyrtsa: the (map list ...) things does matrix transpose; I just didn't realize that's what he was asking for
12:05Bronsagfredericks: yeah, sorry if I didn't explain myself properly
12:06Bronsathanks both anyway :)
12:12gfredericksBronsa: oh no it was me
12:20sproustist
12:20sprousttechnomancy: I just saw nrepl.el
12:20sprousttechnomancy: got a few questions about it.
12:21sproustWhy two modes? I saw there's a major and a minor mode. If it's meant to be used with clojure-mode, why not just have a minor mode?
12:34duck1123"code generated by ClojureScript macros must target the capabilities in ClojureScript" -- does that mean I can't make a macro that calls console.log ?
12:34duck1123I'm getting odd errors when I try
13:01sprousttechnomancy: Ah. never mind. Figured it out, forgot the repl installs its own mode.
13:45Frozenlo`I get this error when I try to evaluate a function: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentCollection.
13:45Frozenlo`The function evaluates fine by itself, but when I add a given macro in it, it chokes. Any idea why?
13:48pandeirodoes himera only work with lein <2? anyone know?
13:49pandeiroi get an error: Problem requiring leiningen.js hook
13:49mdeboardFrozenlock: Not without seeing the code
13:51Frozenlockmdeboard: https://gist.github.com/3258950 the macro is used near the end of the function.
13:51mdeboardFrozenlock: You're missing something
13:52mdeboardoh, nm, there the signature defintiion
13:52FrozenlockYou litteraly, or in my understanding?
13:52mdeboarddidn't see it
13:52mdeboardwhy do you have a vector in your args like that
13:53Frozenlockthat? [[fetch-fn coll & {:as args}]]
13:53mdeboardyeah
13:53mdeboardis thata macro thing I'm not familiar with?
13:54Frozenlock(with-random (fetch ....)) would be single argument. With the added vector I use destructuring to directly get the components.
13:55FrozenlockCould it be that the arguments aren't evaluated, thus I don't have a map as a I was expecting, but simply a symbol?
13:56treehugare there refactoring tools for clojure like for example: extract sexp to local variable, rename symbol in sexp, etc?
13:56mdeboardDunno, seems weird. On line 31, the (fetch (...)) expression is going to be evaluated before it's passed to (with-random)
13:56FrozenlockSo the query-map in `:where query-map' will not be a simple symbol if I understand correctly.
13:57mdeboardI dunno, that is some weird-to-me syntax (but I'm not an expert by any stretch)
13:57Frozenlockok, thanks anyway.
14:00mdeboardWhat is that function signature supposed to do? Destructure? I've literally never seen a vector used as a symbol
14:02mdeboardsupposed to represent*
14:02FrozenlockIf you are talking about the macro, yes it's for destructuring.
14:02mdeboardThat shouldn't be in the function signature though
14:02FrozenlockSignature?
14:03mdeboardin ``(defn foo [a b] (+ a b))`` ``[a b]`` is the signature
14:04mdeboarddestructuring should be in binding statements like let/for/etc.
14:04metellusmdeboard: you can destructure in a function signature
14:04mdeboardI see
14:06mdeboardThat seems weird, since if you're just destructuring in the signature why not just pass the function the destructured args in the first place?
14:06metellusFrozenlock: based off of this http://stackoverflow.com/questions/11170424/maintaining-agent-state-while-returning-in-clojure and completely making things up, I'd say that you need to put "fetch-fn coll & {:as args}" into parentheses
14:07gfredericksmdeboard: in a lot of cases that could mean spreading implementation information all around your code rather than keeping it in one place
14:07metellusmdeboard: so instead of (some-fn some-vec) you'd have to do soething like (let [;destructuring goes here] (some-fn args))?
14:10mdeboardor just restructure in a different let statement, it's just a convention that I've never seen before (except obv like `(defn foo [x & [y z]] (stuff x y z))`
14:11FrozenlockI think I should be using a function instead of a macro in this case. Let me try that...
14:16muhooi've seen a lot of people writing functions with quoting and unquoting ` ~ ' etc, i call the "funcros"
14:17gfredericksmuhoo: misquote is good for ` without symbol expansion
14:17gfredericksi.e., for just the unquoting mechanisms
14:21muhooyeah, the first time i saw gensyms and syntax-quotes in a non-macro, i was confused. then i figured out how useful it could be.
14:22gfredericks,`foo#
14:22clojurebotfoo__27__auto__
14:22FrozenlockMeh, it works as a simple function and without the quoting unquoting stuff. Perhaps I was trying to be to fancy.
14:51mdeboardfuncros
14:51mdeboardI liek that.
15:14sjlI'm trying to eliminate reflection and can't seem to figure out the magic type hinting incantations... anyone feel like taking a look? https://gist.github.com/3259412
15:20sjloh sweet, I think I found it
15:26antares_sjl: you more likely want to use hints before locals: ^String s, not s ^String (…). Also, the last parameter needs to be passed as a java array, so see clojure.core/into-array
15:27sjlantares_: actually this does the trick: https://gist.github.com/3259412
15:27sjlantares_: there's an alternate version of that method that takes a set instead of that weird java varargs
15:27sjlantares_: I just had to inform clojure that (set foo) does indeed produce a persistenthashset
15:28antares_sjl: it is still less common to hint expressions if you bind them to locals but ok. And interop with variadic methods is a common source of confusion so I decided to mention it.
15:29antares_sjl: to hint on core Clojure types, it is probably a better idea to use interfaces (IPersistent*)
15:29antares_also, you probably can just hint it has java.util.Set?
15:29sjlmaybe
15:29antares_the Java method is likely to be expecting j.u.Set, not a specific Clojure interface
15:30antares_Clojure sets implement the read-only part of j.u.Set
15:30sjlah
15:33pandeiroanyone noticed a bug with goog.json.parse() ? JSON.parse() is parsing my string just fine, goog.json.parse() isn't
16:44wtetznerpandeiro: what string are you trying to parse?
16:51pandeirowtetzner: sorry i figured it out - goog.json.parse uses eval, which is prohibited in chrome extensions
16:52antares_pandeiro: are you writing a chrome ext in cljs?
16:52pandeirokinda silly that goog.json.parse doesn't first check for a native method imo, but whatever
16:52pandeiroantares_: i am
16:52pandeiroand i'm loving it
16:53emezeskepandeiro: That is really cool!
16:55pandeiroemezeske: yeah my first try was a couple of months ago, i wanted to convert himera to a chrome extension that would allow using CLJS on any random webpage
16:55pandeirobut i ran into the no eval() problem
16:55pandeirothere is a workaround tho, eventually i will get on that
16:56emezeskepandeiro: Oh, neat, the extension would like see a special script tag and send it off to himera seamlessly?
16:56pandeiroemezeske: ah no, just to be able to screw around in cljs on any random page
16:56emezeskepandeiro: I see
16:57emezeskepandeiro: Cool stuff
16:57pandeiroeventually have a store of convenience functions, like get-all-links
16:57pandeiroyeah, eventually i'll get there
16:57pandeirowith cljsbuild it has been very easy throwing together an extension
16:57emezeskenice!
16:57pandeirosince you can output to multiple files easily
17:05pandeirosay i have a flattened seq like (:head :sub :sub :sub :head :sub :sub :head :sub :sub :sub) and i want to restore the hierarchy like ([:head (:sub :sub :sub)] ...)
17:09pandeiroi got to using partition-by to get ((:head) (:sub :sub :sub) (:head) (:sub :sub) ...) ... trying to figure out the next step
17:11gfrederickspandeiro: (->> % (partition 2) (map (fn [[[h] subs]] [h subs])))
17:12pandeirogfredericks: my mind reached its recursion limit with that destructuring
17:12pandeirobut thank you, am trying to parse
17:12gfredericksit's just pulling the head and the subs out of your ((:head) (:sub :sub :sub))
17:26FrozenlockIs there a way to use drag/drop in html5 without javascript?
17:30RaynesRewriting all the temp file/dir stuff and making other things less weird.
17:30RaynesGoing to commit-bomb the repo soon.
17:33antares_Raynes: (with the towlie voice) don't forget to use travis-ci
17:33Raynesantares_: I'm not already doing that?
17:33RaynesHrm.
17:33RaynesGuess I just haven't worked on fs in a while.
17:33RaynesI'll get that set up before releasing.
17:35RaynesAlso, if anybody has ever found something weird or un-nice in fs, nows your chance to get it fixed while I'm on a roll.
17:35RaynesI didn't write the vast majority of this code and I haven't used fs a whole lot, so I'm not the one who would know about issues.
17:36FrozenlockWell, a more detailed readme could be nice. (to know what that's all about)
17:37RaynesIt's all about the fs, man.
17:37Frozenlock*cricket*
17:40technomancyImma let you finish but reiserfs was the best fs of all time
17:40Raynestechnomancy: You're so hip and with it.
17:40danlarkinmurders your wife ✓
17:45amalloymdeboard: you aren't actually storing the metadata, though. like, your implementation of withMeta returns a map, instead of a new object with new metadata
17:46amalloywhich is, in turn, what makes with-proxy-meta's implementation so bizarre. with-proxy-meta should be able to just be a simple call to ##(doc vary-meta)
17:46lazybot⇒ "([obj f & args]); Returns an object of the same type and value as obj, with (apply f (meta obj) args) as its metadata."
17:47technomancyso what if namespaces were persistent?
17:47technomancywhat if new definitions were append-only and old function definitions stayed around until there were no other references to them?
17:48technomancyif you used nix-style hashing and dependency closures, you could keep multiple versions of a library in memory in the same classloader
17:50technomancyyou could theoretically have every version of every clojure function loaded at once without conflict
17:51gfrederickstechnomancy: so you just solved dependency management then?
17:52technomancyno, I just told you how to solve it. go implement it.
17:52Spaceghostc2cHagelberg!
17:53technomancyme?
17:54gfredericks~hagelberg
17:54clojurebotGabh mo leithsc?al?
17:59jayunit100__trying to convert csv to json
18:00jayunit100__any hints on the standard lib to do this csv i/o (clojure)
18:00jayunit100__trying [clojure-csv/clojure-csv "2.0.0-alpha1"]
18:19FrozenlockWhat's the way to add a favicon in noir?
18:23RaynesFrozenlock: https://github.com/Raynes/refheap/commit/3fa0100722faad54418a1e712dcf0176463b789d
18:24jayunit100__(:import [java.io StringReader]) <-- this seems to fail
18:24FrozenlockRaynes: Thanks!
18:27jayunit100__ah dsantiago !
18:27jayunit100__I'm using your csv parser now :)
18:27jayunit100__dsantiago: ^^ … thanks :)
18:28dsantiagoOh, cool.
18:28dsantiagoI've been speeding it up lately.
18:28jayunit100__cool!
18:28jayunit100__Caused by: java.lang.IllegalArgumentException: Unable to resolve classname: long
18:28jayunit100__^^ anyone ever see this error before?
18:30jayunit100__ah i think its clojure class path related
18:30jayunit100__or maybe its leon related.
18:31dsantiagoDid you hint something to be a long or try to create one like (long. …) or anything like that?
18:35jayunit100__ looks like you have to reload lein reps or something maybe .
18:35jayunit100__no its not in my source, it seems to be in a jar.
19:23FrozenlockIs there a forum library for clojure?
19:37mdeboardamalloy: I see, noted
19:38cmajor7forgot where I read how to force (re)compilation on save.. e.g. I have it working nicely with clojurescript via "lein-cljsbuild".. I am sure there is something similar (and probably simple) for clojure itself
19:39cmajor7is it just another lein plugin?
19:40xeqicmajor7: web service?
19:40xeqiring.middleware.reload I think
19:41cmajor7xeqi: thx. no, simpler :) just clojure code
19:41weavejestercmajor7: (:require blah.core :reload)
19:42weavejestercmajor7: Er, I mean: (require 'blah.core :reload)
19:42weavejesterToo used to the ns macro
19:42cmajor7once I save any clojurescript file, it gets recompiled right away, and I can see in a console whether there are any errors. just wanted to do the same thing with clojure itself
19:43cmajor7weavejester: so I would need to append :reload to every namespace… I have ~ 15 files, is that the only way?
19:43weavejestercmajor7: There's also :reload-all, which reloads a namespace and all its dependencies.
19:43amalloyi don't think it's ever right to put :reload into your namespace definition
19:44cmajor7I think there is something similar in emacs land (swank?), but I am using vi. not sure if that matters
19:44amalloythat's only intended for repl usage
19:44weavejesteramalloy: Right, but I'm assuming cmajor7 is reloading via the REPL...
19:44weavejestercmajor7: Is that right?
19:45amalloy(as an aside, you forgot the []s in (require '[blah.core :reload]))
19:45amalloyor i dunno, maybe it works outside
19:45cmajor7weavejester: I just want to start "something", that would be running, and every time I save my code, I it gets recompiled, and that "something" reports exceptions/errors/etc..
19:46emezeskecmajor7: I think most people use vimclojure or swank or something similar for that
19:47emezeskecmajor7: I have heard of people adding hooks to their editors that automatically reload the current file on save
19:47weavejestercmajor7: Usually I just use SLIME for that. I believe VimClojure might have something similar. And some of the various IDEs might have that, too.
19:47emezeskes/swank/slime
19:47cmajor7emezeske: I use vimclojure, but as far as I understand you need to always force the compilation e.g. "\ef"
19:47cmajor7which pops up an internal vim buffer that you have to switch to and close
19:48cmajor7or worse scroll up to actually see the exception
19:48emezeskeYou don't have to switch to it, you can do \p to close it
19:48cmajor7feels like 4 extra steps for every save..
19:48emezeskeAnd you can set options for where it appears, and how big
19:48emezeskeYou can just leave it open...
19:48cmajor7right, but if there is an exception, you have to switch to it to scroll up
19:49weavejestercmajor7: Isn't that an issue with screen size more than anything? I mean, if the stacktrace scrolls off screen, then you'd have the same problem with whatever, right?
19:49mdeboardamalloy: With the definition of withMeta, I spent a few hours last night trying to figure out how to extend an Object instance with the IObj interface. I basically just hacked at it until it works. I couldn't find an example implementation of withMeta (except for one really crummy blog post from 2009)
19:49cmajor7I just really like what "lein-cljsbuild" does, and I find it hard to believe there is nothing similar for clojure itself?
19:50amalloymdeboard: just look at the examples in clojure.lang
19:50amalloythey're in java, but it's pretty easy
19:50mdeboardamalloy: I tried to find it in the source last night but I think I was exhausted
19:51mdeboardI found the IObj.java and IMeta.java classes, but there's no actual code there, just interface defs
19:51weavejestercmajor7: I haven't heard of anything. I find it more useful to have errors integrated with my editor. However, it would be pretty trivial to create something like it. Just combine clj-stacktrace, ns-tracker, and :reload-all in a loop.
19:51weavejesterI imagine it would be 8 lines of code or something.
19:52mdeboarder, I should say, no function definitions, not no code :P
19:52amalloylook at, eg, PersistentHashMap
19:55muhoocmajor7: i think noir does it on page reload
19:55cmajor7weavejester: I see. still find it odd. do you actually go an extra step every time to see if your code is solid? e.g. 1. save it 2. force compilation 3. go scroll the exception ?
19:56mdeboardamalloy: I see... so, do I need to specify a constructor for this PdfReader class that has a signature that includes metadata? Based on PersistentHashMap, I'm not sure how to do something similar for this class instance. PersistentHashMap implements the IObj interface out of the box; PdfReader not.
19:56weavejestercmajor7: No, I just use SLIME.
19:57amalloyjust...implement withMeta to call proxy-meta or whatever it is
19:57cmajor7muhoo: noir does, but if you work with 3 files simultaneously, going from one vim buffer to another and back, saving each, noir does not help you here (nor it should)
19:57cmajor7weavejester: I see. how does it work in slime?
19:57cmajor7it auto recompiles on save?
19:57amalloyyou really don't want to recompile on save
19:58weavejestercmajor7: No, but it saves if you trigger a compile without saving, IIRC
19:58cmajor7amalloy: why not?
19:58muhoocmajor7: i dunno then. i was poking in the cljsbuild source, and stumbled across the function that checks the filesystem for changed files, but didn't read it in depth. you could probably adapt that to a lein plugin that does that for clj instead of cljs
19:58weavejestercmajor7: And the error is reported through SLIME, so the top part of the stack trace is shown
19:59weavejestermuhoo: There's a library called ns-tracker that does that for clojure
19:59cmajor7weavejester: pretty similar to vimclojure.. although the bottom of the exception is shown.. )
19:59amalloyfor example, you don't want to recompile a protocol implicitly, because then implementations of it won't match up anymore
20:00weavejestercmajor7: Why not add a key binding that saves, compiles, then goes to the top of the exception?
20:02cmajor7amalloy: does sound like a special case, and implementations can be also recompiled after the protocol, can they?. I am not saying it should be enabled by default, but there should be something that does it as an option.
20:05cmajor7weavejester: might work, but still a bit rough. let's say you are working through several files related to one another. ideally there should be a single console that shows you errors/[OK]s/exceptions every time you save and go to another file. so your mental flow is not interrupted.. (may be it's just me though)
20:09muhooit is funny to me how personal and unique everyone's workflow can be. mine is quite idiosyncratic.
20:10amalloycmajor7: just write a little shell script that compiles everything, eg: echo "(require 'my-app.core)" | lein repl, and then open another console that runs: watch my-script.sh
20:11amalloythere's no need for it to happen when you save, or be incremental and mess with your open session
20:12cmajor7amalloy, weavejester: thx, I'll experiment
20:26gfredericksdoes the new finite-domain stuff in core.logic not play well with negative numbers?
20:29gfredericksI get no results with (interval -100 100) (even though I should), but changing it to (interval 1 100) gives results.
20:43mdeboardMan the people who wrote iText must hate programmers
20:44mdeboardor love carpal tunnel syndrome or I dunno
20:55amalloyi can sympathize with hating programmers
20:58mdeboardamalloy: That is obvious, but that's why we like you. To be fair to the itext people I'm sure they're in backward compatibility hell. I know they are actually because they put all their backward compatibility burden on me
21:09mdeboardIs there a way to invoke (proxy) in such a way that the class being extended doesn't get constructed first? I've been reading the source for the macro and am assuming not.
21:10mdeboardI think that's the sort of thing Python's ``object.__new__`` method is there for; curious if there's an analog in Clojure specifically for Java interop.
21:14amalloysorry mdeboard, that is not possible on the jvm
21:42mdeboardamalloy: Cleaned that up then https://github.com/mattdeboard/clj-itext/blob/master/src/clj-itext/core.clj#L43
21:43mdeboardremoved `with-proxy-meta' since it was redundant
21:43amalloydon't call `merge`. withMeta is "here is your new metadata"
21:45mdeboardwhich merge is redundant? in the withMeta definition?
21:45amalloynot redundant, incorrect
21:46amalloy(and yes, that one)
21:46amalloy(meta (with-meta x y)) should return y in all cases
21:46mdeboardOh, I see what you're saying then. with-meta completely replaces the metadata.
21:46mdeboardI misunderstood how that worked.
21:48mdeboard##(doc vary-meta0
21:48mdeboard##(doc vary-meta)
21:48lazybot⇒ "([obj f & args]); Returns an object of the same type and value as obj, with (apply f (meta obj) args) as its metadata."
21:48mdeboardI see.
21:52amalloywhat, does chas say something misleading about metadata?
21:52mdeboardNo, I just don't believe in taking personal responsibility
21:54mdeboardBut seriously, having no Java background whatsoever the proxy/gen-class bit specifically could use somewhat better documentation. Maybe it's more transparent if you've got a background in Java
22:06mdeboardamalloy: Done, thanks for the tough love
22:06mdeboardI work better when I think someone thinks I'm an idiot
22:08amalloyhaha
22:08amalloyyou should pair with hiredman
22:10danlarkinbahahahah
22:10mdeboardWhy, does he think I'm an idiot? :P
22:10mdeboardor does he just think everyone is
22:11muhoo,*ns*
22:11clojurebot#<Namespace sandbox>
22:11muhoo,(= :sandbox/foo ::foo)
22:11clojurebottrue
22:12cmajor7once friend authenticates a user, it puts "{ :username.. :password… :roles.." under the identity into a session. Is there a way to make friend to keep additional user details there? (e.g. user-id)
22:13muhoowell, you can using ring
22:13muhoojust add whatever you want to the :session
22:14xeqicmajor7: try returning more data from you're credentials-fn
22:14cmajor7yea, I just did, it still hangs on to those 3
22:15muhoocmajor7: are you writing a custom workflow?
22:15cmajor7muhoo: yes, but it is not going to be a part of friends identity + needs to be handled separately => not nice
22:15muhooi wrote one for google step2 auth, but it's been months now and my memory fails me
22:16cmajor7muhoo: no this particular one is a built in "interactive-form"
22:16muhoooh, so you're out in ring?
22:17muhoonot inside a (defn workflow ... ) ?
22:17cmajor7muhoo: I am home at the moment
22:17muhoohehe
22:17muhooi mean not you specifically, but your code :-)
22:18cmajor7there is a "credentials-fn" that returns the auth
22:18cmajor7which is the only "data hook" into friend that is used
22:18muhoo:credential-fn i expect
22:18muhoono "s"
22:18cmajor7the app is of course ring based. noir to be exact
22:19cmajor7right. "bcrypt-credential-fn" if you want to be really accurate
22:19muhoocool, so my guess is you have something like this in your server.clj: https://www.refheap.com/paste/4047
22:20cmajor7yep. very similar
22:20cmajor7no "step2" though
22:20muhoowell, of course
22:20muhoothat was my test code
22:21muhooalright, so you're using creds/bcrypt-credential-function. what does it return?
22:21cmajor7so once the user is authed, only username, password and roles make it to the identity
22:21muhoosomewhere, something returns a ring response, which has (or can have) a :session key in it
22:22cmajor7muhoo: it returns a map of those 3. I tried to add other keys there, but they get ignored, since only those 3 seem to be read by friend
22:22muhooby interactive-form
22:23clj_newb_29840is there any standard toolkit for keeping _data structures_ updated on client/server over clojurescript/clojure?
22:23clj_newb_29840i.e. I'd like ot find the right abstractions so I have some data structure so that its state is automatically synched over both the server and the client
22:24xeqicmajor7: strange, returning extra-keys there works for me
22:25muhoocmajor7: ok i see this (assoc-in [:session ::identity] auth))
22:25cmajor7muhoo: right, http://bit.ly/PUxKWX
22:25cmajor7xeqi: interesting.. which key did you try, if you don't mind
22:26muhooso whatever is returned in auth, from the who-knows-where-that-comes-from, should end up in your session
22:26cmajor7I tried, id, user-id, but no go..
22:26xeqi:extra
22:27xeqibut the only one creds/bcrypt-crednental-fn removes is :password
22:27xeqiblah, I can't spell today
22:27muhooi remember i spent days tracing through the (authenticate* ..) function to figure out how all this works, but i've long since forgotten
22:28muhoowith like printlns everywhere
22:36cmajor7xeqi: yep, works now. had to restart the server
22:36cmajor7I wonder why… since I did clear the session (it does it on logout)
22:39xeqinoir's reload doesn't work with middleware
22:44Frozenlo`Anyone wants to critic my website? (general layout, colors, etc...) Made with love with Noir :) https://bacnethelp.com
22:47FrozenlockI'm pretty sure I have tunnel vision right now, so please be direct.
22:48emezeskeFrozenlock: Whoa, I worked on a BACnet stack once
22:48Frozenlockemezeske: Yay! BACnet friend :)
22:48emezeskeFrozenlock: I wrote the MS/TP layer :)
22:48FrozenlockThe C stack?
22:48emezeskeYeah, it was all C. Well, actually, C++
22:48xeqiFrozenlock: I can't read the example at all
22:48xeqiwell, barely
22:48FrozenlockOh I only do BACnet/IP with this.
22:49Frozenlockxeqi: Colors?
22:49emezeskeYeah, MS/TP is a bitch to set up, and tends to require custom code most of the time :/
22:49muhoocmajor7: right, i had to do stuff like this https://www.refheap.com/paste/4048 and this (def rel (reloader #'-main)) and this https://www.refheap.com/paste/4049
22:49cmajor7xeqi: ah.. makes sense, good to know (about noir reload)
22:49emezeskeFrozenlock: BACnet/IP is so much better
22:49Frozenlockemezeske: And it's slooooow :)
22:49emezeskeFrozenlock: omg yeah
22:50mdeboardFrozenlock: Where are you hosting your images?
22:50mdeboardoh, I see you just acknowleged
22:50mdeboardFrozenlock: Only thing I'd say is have your links open up in new windows
22:50mdeboardtarget="_blank" etc
22:51Frozenlockmdeboard: All the links?
22:51cmajor7muhoo: hmm.. I wonder whether I should just jump a level down to compojure.. so far noir introduces more problems than it solves..
22:51FrozenlockSeems it would be intrusive.
22:51xeqiFrozenlock: http://imgur.com/s4qnX is what I get on ff14.0.1
22:51mdeboardFrozenlock: well just external, like the one to github imo
22:51muhoocmajor7: you wouldn't be the first to do that. i think that's why they broke out a lot of noir-ish stuff into lib-noir
22:51FrozenlockHmm that would be wise...
22:52cmajor7muhoo: also, how do you usually debug through a 3rd party libs? (you said to did do it with friend's "authenticate*")
22:52xeqicmajor7: I use compojure over noir
22:52muhoocmajor7: i'm old-skool. lots of printlns :-)
22:53muhooand the repl helps a lot too, though not so much with web authentication stuff that requires a browser
22:53cmajor7muhoo: so you get the source, and depend on the source.. and then mod it in the friend's branch itself?
22:53xeqiFrozenlock: oh, if I hover over it then it expands and becomes brighter
22:53Frozenlockxeqi: Is that too discrete? If you hover it should change transparency...
22:53emezeskecmajor7: If you are doing anything complex with routing, noir tends to just get in the way
22:53cmajor7xeqi: you mean you use noir, but drop back to compojure for routes?
22:53muhoooh, that? yes, i git cloned'ed friend, then ln -s'ed it into the "checkouts" directory in the lein project
22:54xeqicmajor7: sorry, I mean use compojure, don't use noir
22:54cmajor7emezeske: yea I noticed that doing xhr.. :)
22:54emezeskecmajor7: ;)
22:54cmajor7xeqi: I see.. do you roll out your own "defremotes"?
22:55muhooisn't defremote from fetch?
22:55cmajor7muhoo: yea, but fetch is noir..ish
22:55FrozenlockAnd here is a project I'm logging https://bacnethelp.com/project/4ffac84b44ae35711d15d214
22:56FrozenlockSo my most urgent change should be to open external links in another window.
22:57mdeboardFrozenlock: Also see about solving package dependencies
22:57mdeboardnot website-related but you'd be a hero
22:57mdeboardI could also use a drink
22:57xeqicmajor7: I haven't used clojurescript much yet, but that would be the way I lean
22:57Frozenlockpackage dependencies? For the network scanner?
22:58xeqithough I'm interested in what shoreleave does for remotes
22:58xeqijust haven't explored it yet
22:58mdeboardFrozenlock: Oh, no, I Meant for software development in general
22:58FrozenlockI _really_ appreciate your feedbacks btw!
22:59mdeboard(I'm deliberately being obtuse)
22:59Frozenlockmdeboard: Could you give me an example?
22:59xeqiah, looks like it does the same thing as fetch
22:59FrozenlockDependencies are in the project.clj file... am I missing something?
23:00mdeboardI was just making a joke that was in hindsight really stupid
23:00FrozenlockIt's hard to transmit sarcasm with text :P
23:00mdeboardyeah, you'd think I'd have learned in 20 years
23:02cmajor7xeqi: yep http://bit.ly/OBWSWk
23:03muhooyeah, i think rhickey and stuart holloway both did talks about "easy" vs "simple"
23:03muhoostuff like noir and fetch is great if you're coming from rails and are used to the "easy" approach. but aren't necessarily "simple" once you dive into them.
23:05mdeboardFrozenlock: You should move that "How to scan your network" numbered list up "above the fold" imo, and put your "Download" button right there in the "1!" <p>
23:06FrozenlockAh! Yes!
23:07xeqiFrozenlock, mdeboard: I agree. and if you can get it so that is the first thing the eye jumps to even better
23:07xeqicurrently my eye jumps to the "Scan and see ..." blue banner
23:08xeqimuhoo: yeah, cemerick was horrified at the hoops I had to jump through to get a working noir/fetch + friend example
23:13muhooxeqi: is that posted somewhere? i'd be curious to see it
23:14xeqimuhoo: https://github.com/xeqi/friend-fetch-example
23:14xeqiinteresting part is https://github.com/xeqi/friend-fetch-example/blob/master/src/friendly/server.clj
23:17muhoohmm, there's a lot going on there
23:19muhooit looks a lot less complex than what i had to go through to get google step2 workflow working, but a lot more complex than perhaps it could be.
23:20xeqimuhoo: yeah, it could be cleaned up
23:20xeqistep2 definitly looks more complicated
23:20xeqiis it a multistep workflow?
23:31m0smithI am trying to wrap my brain around event processing in a purely functional environment
23:32m0smithHow can the state of the world be passed around?
23:33mdeboard(##doc ref)
23:34RaynesThat was creatively failed.
23:34mdeboardm0smith: Clojure has tools that allow you to introduce state to your application if necessary.
23:34mdeboard##(doc ref)
23:34lazybot⇒ "([x] [x & options]); Creates and returns a Ref with an initial value of x and zero or more options (in any order): :meta metadata-map :validator validate-fn :min-history (default 0) :max-history (default 10) If metadata-map is supplied, it will be come the meta... https://www.refheap.com/paste/4050
23:34m0smithmdeboard: I am trying to avoid that is possible
23:34mdeboardm0smith: Are you talking about cljs or clj?
23:35m0smithboth actually
23:35m0smithThe problem arises from cljs not having blocking deref
23:36m0smithso how to get the same code base to run in both environments. javascript is all about callbacks but that assumes a shared state, I think.
23:36emezeskem0smith: For state in cljs, there's a good chance you want to use an atom
23:37muhooyou could pass the state in the callback?
23:38muhoooic, it'll depend on the state which may have mutated by the time the callback gets called. hmm.
23:39m0smithmuhoo: I am writing a multi-player game so the state is the current state of the game which I want to protect from cheating code
23:39mdeboardNever done anything with asynchrony with Clj* but I was under the impression from what I do know that you could use watches to do event handling
23:39mdeboard##(add-watch)
23:39lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: core$add-watch
23:39mdeboard##(doc add-watch)
23:39lazybot⇒ "([reference key fn]); Alpha - subject to change. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any regis... https://www.refheap.com/paste/4051
23:39mdeboardfail tonight
23:42muhoom0smith: sounds like fun. it sounds like you'll want a mirror of the state in the server and on all the clients.
23:43muhoothe only time i've done this (js, not cljs), i had the server broadcasting all the updates of each player to each client.
23:43m0smithmuhoo: Exactly. The game engine would have the real state and when it is a players turn, the client is sent the current state
23:44m0smithI also thought of supporting events from the clients to get the current state or send a message, etc.
23:44muhoothe server was basically this, but it didn't keep much state: https://github.com/kenrestivo/simple-clojure-websocket-chat
23:44m0smithI am just having a brain cramp meshing the game loop with asynchronous calls without something like an agent
23:44m0smiththat can block
23:45muhoostarted as a chat thing, then ended up as a gameserver of sorts, more or less unwillingly
23:46m0smithor do I just trash the game loop and handle everything through asychronous events?
23:47muhooit's worth a try. also, there's a neat aleph framework for doing async stuff too
23:47m0smithwhich is then how to maintain state without a stuffing it in a global ref ...
23:47muhoowell, state is state. you have to store it somewhere
23:48m0smithwith a game loop/lazy-seq the state is simply passed around to the functions
23:50muhoodo any of those functions do i/o?
23:51m0smithI am separating all the user stuff into different threads so no
23:51muhoooh. hmm.
23:52muhooconcurrency with refs. i haven't done much with it, but i'm told that clojure makes it more manageable.
23:53m0smithThe more I think and talk about it the more a shared state atom or agent supporting an event system may solve the problems I am facing
23:54muhoosounds reasonable to me. might be a fun way to play around with clojure's concurrency features.
23:54m0smithAnd it should mesh better with most UIs as they are almost all event based at some level
23:56m0smithhttps://github.com/m0smith/crossfire is the code I am talking about. It is a Battleship-ish game. Now all it does is allows 3 computer players to battle.
23:56muhooenjoy :-)
23:57m0smiththx. This has really helped me make decide the direction to go