workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
<@Ahmad>: thanks for all your help, on a sunday evening, with debugging this.
2017-11-05T21:15:18.000001
Berry
clojurians
clojure
No problem :)
2017-11-05T21:19:33.000031
Ahmad
clojurians
clojure
Regarding Datomic, I've been struggling with this for an hour or two, please help me out. I'm trying to run a parameterized query, but apparently I'm doing something wrong, does anyone knows why is the first query not returning the entity? I tried to follow the documentation, but it doesn't seems to be working... ;-; I'm also using the Datomic's Client API (<http://docs.datomic.com/clojure-client/index.html>)
2017-11-05T21:34:27.000049
Ahmad
clojurians
clojure
Just pass the value to bind to `?p-username` in `:args`, e.g. just pass `[db "zignd"]` as `:args`
2017-11-05T22:42:06.000098
Wenona
clojurians
clojure
(There is also <#C03RZMDSH|datomic>)
2017-11-05T22:42:17.000140
Wenona
clojurians
clojure
I have tried .size, .length, .-length how do I get, in O(1) time, the length of a (float-array n) ?
2017-11-05T23:58:48.000044
Berry
clojurians
clojure
<@Berry> acount I think?
2017-11-06T00:00:40.000108
Sandy
clojurians
clojure
nope, `alength` <https://clojuredocs.org/clojure.core/alength>
2017-11-06T00:01:09.000001
Sandy
clojurians
clojure
<https://clojuredocs.org/search?q=acount%20> doesn'ts eem ot exist
2017-11-06T00:01:28.000015
Berry
clojurians
clojure
alength, thanks!
2017-11-06T00:01:41.000022
Berry
clojurians
clojure
arrays are really strange on the JVM, they don't have methods, or fields
2017-11-06T00:01:57.000112
Sandy
clojurians
clojure
So in Java you have to call something to Array/length, and even that I think might be some sort of strange compiler intrinsic
2017-11-06T00:02:22.000075
Sandy
clojurians
clojure
<https://stackoverflow.com/questions/8755812/array-length-in-java> was throwing me off
2017-11-06T00:02:23.000072
Berry
clojurians
clojure
Thank you! It worked!
2017-11-06T05:12:35.000365
Ahmad
clojurians
clojure
I will post there next time
2017-11-06T05:13:00.000110
Ahmad
clojurians
clojure
Can I "append" a pre/post function to a function?
2017-11-06T09:21:39.000116
Jutta
clojurians
clojure
``` (defn constrained-fn [f x] {:pre [(pos? x)] :post [(= % (* 2 x))]} (f x)) ``` :pre and :post assertions
2017-11-06T09:26:24.000225
Ahmad
clojurians
clojure
you mean after the fact?
2017-11-06T09:35:02.000028
Willow
clojurians
clojure
depending on what you mean by append, this might be helpful too <https://github.com/technomancy/robert-hooke>
2017-11-06T09:35:06.000180
Shamika
clojurians
clojure
``` (defmacro foo [x y] `(let [^floats ~x ~y] ~x)) (macroexpand-1 '(foo x (float-array 20))) ;; ==&gt; (clojure.core/let [x (float-array 20)] x) ``` It appears my type hint of ^floats is being stripped away. Is there a way for macros to generate / keep type hints ?
2017-11-06T10:47:40.000111
Berry
clojurians
clojure
[ I need to keep type hints as I end up using primitive math. ]
2017-11-06T10:47:55.000505
Berry
clojurians
clojure
found answer: <https://stackoverflow.com/questions/11919602/generating-clojure-code-with-type-hints>
2017-11-06T10:52:06.000116
Berry
clojurians
clojure
Is there a more updated view of definline ? <http://bytopia.org/2014/07/07/inline-functions-in-clojure/>
2017-11-06T10:59:19.000288
Berry
clojurians
clojure
Probably not, but is there something in key destructuring that lets you rename the keys in one go as you destructure them?
2017-11-06T11:14:47.000514
Johana
clojurians
clojure
yes.
2017-11-06T11:15:39.000693
Jodie
clojurians
clojure
``` {new-name :old-name} ```
2017-11-06T11:16:00.000225
Jodie
clojurians
clojure
Is anyone here using the s3-private-wagon plugin with Leiningen 2.7.1 on Java 1.8? I’m getting authentication errors when using the plugin and running `lein deps`; however, when I run the `aws` cli tool, I’m able to retrieve objects from the private bucket.
2017-11-06T11:16:07.000360
Sadye
clojurians
clojure
It seems s3-private-wagon isn’t retrieving the EC2 instance profile credentials
2017-11-06T11:16:50.000395
Sadye
clojurians
clojure
``` jenkins@ip-10-110-61-60:~/workspace/movr3-api-dev$ lein deps Could not transfer artifact wardrobe:wardrobe:pom:0.1.3 from/to releases (<s3p://artifacts-prd.pnmac.com/releases/>): Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: AA5EF73EDF617F8E) This could be due to a typo in :dependencies or network issues. If you are behind a proxy, try setting the 'http_proxy' environment variable. jenkins@ip-10-110-61-60:~/workspace/movr3-api-dev$ cd ../../.m2/repository/wardrobe/wardrobe/0.1.3/ jenkins@ip-10-110-61-60:~/.m2/repository/wardrobe/wardrobe/0.1.3$ aws s3 sync <s3://artifacts-prd.pnmac.com/releases/wardrobe/wardrobe/0.1.3/> . download: <s3://artifacts-prd.pnmac.com/releases/wardrobe/wardrobe/0.1.3/wardrobe-0.1.3.jar.sha1> to ./wardrobe-0.1.3.jar.sha1 download: <s3://artifacts-prd.pnmac.com/releases/wardrobe/wardrobe/0.1.3/wardrobe-0.1.3.pom> to ./wardrobe-0.1.3.pom download: <s3://artifacts-prd.pnmac.com/releases/wardrobe/wardrobe/0.1.3/wardrobe-0.1.3.jar> to ./wardrobe-0.1.3.jar download: <s3://artifacts-prd.pnmac.com/releases/wardrobe/wardrobe/0.1.3/wardrobe-0.1.3.pom.sha1> to ./wardrobe-0.1.3.pom.sha1 download: <s3://artifacts-prd.pnmac.com/releases/wardrobe/wardrobe/0.1.3/wardrobe-0.1.3.jar.md5> to ./wardrobe-0.1.3.jar.md5 download: <s3://artifacts-prd.pnmac.com/releases/wardrobe/wardrobe/0.1.3/wardrobe-0.1.3.pom.md5> to ./wardrobe-0.1.3.pom.md5 jenkins@ip-10-110-61-60:~/.m2/repository/wardrobe/wardrobe/0.1.3$ ```
2017-11-06T11:18:06.000383
Sadye
clojurians
clojure
<@Johana> <https://clojure.org/guides/destructuring#_associative_destructuring>
2017-11-06T11:18:30.000386
Jodie
clojurians
clojure
<@Jodie> I mean something like this: ``` (let [{:keys [x y]} {:x 1 :y 2} original-x x original-y y {:keys [x y]} {:x 2 :y 3} new-x x new-y y] {:x (+ original-x new-x) :y (+ original-y new-y)}) ``` where I want to assign the destructured `x` directly to the intended name
2017-11-06T11:19:55.000335
Johana
clojurians
clojure
Ah, that is what `{new-name :old-name}` can do, I see
2017-11-06T11:21:05.000055
Johana
clojurians
clojure
By the way, I’m using version 1.3.0 of s3-private-wagon
2017-11-06T11:21:08.000034
Sadye
clojurians
clojure
``` (let [{original-x :x original-y :y} {:x 1 :y 2} {new-x :x new-y :y} {:x 2 :y 3}] {:x (+ original-x new-x) :y (+ original-y new-y)}) ```
2017-11-06T11:22:37.000217
Johana
clojurians
clojure
cool
2017-11-06T11:22:38.000411
Johana
clojurians
clojure
<https://github.com/s3-wagon-private/s3-wagon-private/issues/18> It seems this has already been solved as of version 1.3.0
2017-11-06T11:22:53.000118
Sadye
clojurians
clojure
You may want to try leiningen 2.8.1 <@Sadye>, I know some attention went into updating s3-private-wagon
2017-11-06T11:23:01.000398
Guillermo
clojurians
clojure
Actually the first time I needed this renaming :slightly_smiling_face:
2017-11-06T11:23:09.000505
Johana
clojurians
clojure
Not sure it handles your issue, but it does appear that related issues have been closed upstream
2017-11-06T11:23:37.000164
Guillermo
clojurians
clojure
<@Guillermo> Thanks for the tip! I’ll give that a try
2017-11-06T11:24:10.000386
Sadye
clojurians
clojure
``` Could not find artifact wardrobe:wardrobe:jar:0.1.3 in central (<https://repo1.maven.org/maven2/>) Could not find artifact wardrobe:wardrobe:jar:0.1.3 in clojars (<https://repo.clojars.org/>) Could not transfer artifact wardrobe:wardrobe:jar:0.1.3 from/to releases (<s3p://artifacts-prd.pnmac.com/releases/>): Access key cannot be null. Could not transfer artifact wardrobe:wardrobe:jar:0.1.3 from/to snapshots (<s3p://artifacts-prd.pnmac.com/snapshots/>): Access key cannot be null. Could not transfer artifact wardrobe:wardrobe:pom:0.1.3 from/to releases (<s3p://artifacts-prd.pnmac.com/releases/>): Access key cannot be null. This could be due to a typo in :dependencies, file system permissions, or network issues. If you are behind a proxy, try setting the 'http_proxy' environment variable. ```
2017-11-06T11:29:30.000685
Sadye
clojurians
clojure
I’m getting a similar error with the upgrade to Lein 2.8.1. I’m going to try Lein 2.8.0 next
2017-11-06T11:29:58.000889
Sadye
clojurians
clojure
you're getting a much better error message now
2017-11-06T11:30:48.000384
Guillermo
clojurians
clojure
`Access key cannot be null`
2017-11-06T11:30:59.000369
Guillermo
clojurians
clojure
Might want to ask in <#C09N0H1RB|aws> <@Sadye> -- usually for IAM instance profiles you don't have to do anything
2017-11-06T11:34:31.000182
Guillermo
clojurians
clojure
``` (defmacro ifor [[i start end] &amp; body] `(let [start# (long ~start) end# (long ~end)] (loop [~i start#] (when (p/&lt; ~i end#) ~@body (recur (unchecked-inc ~i)))))) (defmacro iproc [expr [data i v] &amp; body] `(let [~data ~expr] (ifor [~i 0 (alength ~data)] (let [~v (aget ^floats ~data ~i)] ~@body)))) (def x (float-array (* 1000 100))) (cc/quick-bench (ifor [i 0 (alength x)] (aset ^floats x i (float i)))) Evaluation count : 3276 in 6 samples of 546 calls. Execution time mean : 183.588777 µs Execution time std-deviation : 923.219982 ns Execution time lower quantile : 182.996929 µs ( 2.5%) Execution time upper quantile : 185.164436 µs (97.5%) Overhead used : 1.962587 ns (cc/quick-bench (let [^long end (alength x)] (loop [i 0] (when (p/&lt; i end) (aset ^floats x i (float i)) (recur (unchecked-inc i)))))) Evaluation count : 2412 in 6 samples of 402 calls. Execution time mean : 248.133557 µs Execution time std-deviation : 926.589005 ns Execution time lower quantile : 247.272398 µs ( 2.5%) Execution time upper quantile : 249.071233 µs (97.5%) Overhead used : 1.962587 ns (cc/quick-bench (iproc x [x i v] (aset ^floats x i (float i)))) Evaluation count : 6 in 6 samples of 1 calls. Execution time mean : 1.121665 sec Execution time std-deviation : 70.439931 ms Execution time lower quantile : 1.067037 sec ( 2.5%) Execution time upper quantile : 1.206947 sec (97.5%) Overhead used : 1.962587 ns ```
2017-11-06T12:19:44.000410
Berry
clojurians
clojure
any idea why the running time increases ? I would expect the three to be about the same
2017-11-06T12:20:04.000584
Berry
clojurians
clojure
your type hint in iproc isn't doing what you think it's doing
2017-11-06T12:23:20.000010
Kareen
clojurians
clojure
should I be doing ``` (aget ~(vary-meta data assoc :tag 'floats) ~i) ```
2017-11-06T12:23:48.000138
Berry
clojurians
clojure
use `~(with-meta data {:tag 'floats})` instead
2017-11-06T12:23:48.000460
Kareen
clojurians
clojure
i have a question about idiomatic application architecture — i’m writing a server application with a series of modules acting as various services; my thinking now is that i can wrap the important state to each module in an atom and then connect each module w/ `core.async` channels to pass messages around as various events come into the top-level port
2017-11-06T12:28:20.000340
Venessa
clojurians
clojure
does anyone have any feedback on this plan? or a better suggestion for structuring the software? i’m used to the situation in Go where i can just connect all the modules w/ channels to pass messages around; what i’m used to doing in clojure for concurrency is using atoms and i’m trying to resolve the two approaches
2017-11-06T12:29:17.000512
Venessa
clojurians
clojure
<@Venessa> I would caution against that architecture unless you specifically know you need concurrency already
2017-11-06T12:29:53.000033
Aldo
clojurians
clojure
is that basically the erlang / actor model ?
2017-11-06T12:30:22.000041
Berry
clojurians
clojure
<@Kareen> : ``` (defmacro ifor [[i start end] &amp; body] `(let [start# (long ~start) end# (long ~end)] (loop [~i start#] (when (p/&lt; ~i end#) ~@body (recur (unchecked-inc ~i)))))) (defmacro iproc [expr [data i v] &amp; body] `(let [~(vary-meta data assoc :tag 'floats) ~expr] (ifor [~i 0 (alength ~data)] (let [~v (aget ~(vary-meta data assoc :tag 'floats) ~i)] ~@body)))) (do (def x (float-array (* 1000 1000))) (println "\n\n\n\n\n") (println "=====") (cc/quick-bench (ifor [i 0 (alength x)] (aset ^floats x i (float i)))) (cc/quick-bench (iproc x [x i v] (aset ^floats x i (float i))))) ===== Evaluation count : 360 in 6 samples of 60 calls. Execution time mean : 1.680640 ms Execution time std-deviation : 3.250002 µs Execution time lower quantile : 1.677290 ms ( 2.5%) Execution time upper quantile : 1.685090 ms (97.5%) Overhead used : 1.962587 ns Evaluation count : 456 in 6 samples of 76 calls. Execution time mean : 1.324811 ms Execution time std-deviation : 255.773342 ns Execution time lower quantile : 1.324424 ms ( 2.5%) Execution time upper quantile : 1.324963 ms (97.5%) Overhead used : 1.962587 ns ``` not complaining at all -- iproc is now faster than ifor, weird
2017-11-06T12:30:59.000659
Berry
clojurians
clojure
ok great <@Aldo> i’m working on a bitcoin node — messages from peers will end up going to one module and then that will have downstream effects to some other modules
2017-11-06T12:31:09.000597
Venessa
clojurians
clojure
^ <@Berry>
2017-11-06T12:31:22.000427
Venessa
clojurians
clojure
i’m wondering what the best way to do this in clojure is
2017-11-06T12:31:32.000470
Venessa
clojurians
clojure
I don't know enough about erland/actor model to comment on that. you absolutely can set up an app where you have components that own little worker threads and the components talk to each other via channels. I've written apps like that. almost all of them i either have or wish I had gone back and rewritten them in a more functional way
2017-11-06T12:32:10.000144
Aldo
clojurians
clojure
to reinforce <@Aldo>’s point: I've found core.async hard to debug (both stack traces and reasoning about it) -- and found it's much simpler to take the FRP / reagent model /reactive atom route
2017-11-06T12:33:10.000303
Berry
clojurians
clojure
turns out it's hard to predict which parts of your app will benefit from asynchronous programming :slightly_smiling_face:
2017-11-06T12:33:31.000181
Aldo
clojurians
clojure
now when I use core.async I prefer to keep it in one namespace that wires everything together. gives you one place to read/understand your asynchronous algorithm and one place to vary the number of threads for the different parts etc
2017-11-06T12:34:29.000291
Aldo
clojurians
clojure
ok thanks <@Aldo> <@Berry>
2017-11-06T12:37:57.000276
Venessa
clojurians
clojure
<@Venessa> - That sounds to me like a use case that Storm is designed to solve. However, I'm speaking from relative ignorance here on both the application architecture and Storm itself, so take that with a grain of salt. <http://www.storm-project.net/>
2017-11-06T12:42:34.000242
Adelaida
clojurians
clojure
thanks! seems a little like overkill
2017-11-06T12:43:05.000213
Venessa
clojurians
clojure
for me now
2017-11-06T12:43:09.000469
Venessa
clojurians
clojure
I may try putting all the state in a single atom
2017-11-06T12:56:12.000314
Venessa
clojurians
clojure
There will just be a little overhead for each module to only get the pieces it wants
2017-11-06T12:56:34.000397
Venessa
clojurians
clojure
It might also be overkill, but you could take a look at Onyx. It's written in clojure and will handle things like state for your modules and has a clear model for describing how the data flows between your tasks.
2017-11-06T12:56:46.000530
Cecile
clojurians
clojure
Thanks
2017-11-06T12:56:56.000400
Venessa
clojurians
clojure
Anyone use anything like lenses?
2017-11-06T12:57:10.000583
Venessa
clojurians
clojure
Zippers etc
2017-11-06T12:57:20.000177
Venessa
clojurians
clojure
look into Specter
2017-11-06T12:57:38.000595
Cecile
clojurians
clojure
Ah right
2017-11-06T12:58:21.000245
Venessa
clojurians
clojure
I think that will help if I go with one big ball of state approach
2017-11-06T12:58:33.000432
Venessa
clojurians
clojure
Each module can define a lens over the substate it cares about and a single atom can handle concurrent writes
2017-11-06T12:59:34.000327
Venessa
clojurians
clojure
Does anyone have any suggestions on writing maintainable accessors with specter?
2017-11-06T13:00:21.000630
Venessa
clojurians
clojure
Can I avoid having to re-write all my accessors if the shape of the state changes?
2017-11-06T13:00:55.000591
Venessa
clojurians
clojure
onyx/storm are great, but I don't think they're really related to the problem here
2017-11-06T13:00:59.000816
Aldo
clojurians
clojure
Agreed
2017-11-06T13:01:06.000137
Venessa
clojurians
clojure
This is p simple and I just want well factored code
2017-11-06T13:01:21.000089
Venessa
clojurians
clojure
If you just go with a single key per module, you probably won't need lenses. Although that's assuming each module has its own subsection rather than different modules needing state from different pieces.
2017-11-06T13:01:42.000386
Cecile
clojurians
clojure
<@Venessa> specter is probably helpful here. but if you have lots of different functions mutating things then you're not writing very clojurey code
2017-11-06T13:01:52.000140
Aldo
clojurians
clojure
humble suggestion: write functions that take data and return data :slightly_smiling_face:
2017-11-06T13:02:27.000325
Aldo
clojurians
clojure
<@Aldo> can you point to an example that shows the difference?
2017-11-06T13:02:27.000578
Venessa
clojurians
clojure
Yeah I guess the issue is going from that to “here is a stream of events that impact various modules”
2017-11-06T13:03:08.000521
Venessa
clojurians
clojure
if at all possible pull state tracking/munging up to the very top level
2017-11-06T13:03:20.000017
Aldo
clojurians
clojure
Yeah I think that is the single top-level atom idea I like
2017-11-06T13:03:42.000391
Venessa
clojurians
clojure
Then depending on what happens each module will need to read/write the state
2017-11-06T13:04:15.000001
Venessa
clojurians
clojure
right, but if you have a single top level atom I would manipulate it only at that top level, ie deref the atom and pass the contents down, not the atom itself. then receive the changes back up the top and modify the atom
2017-11-06T13:04:23.000336
Aldo
clojurians
clojure
Ok that’s a good suggestion
2017-11-06T13:04:52.000299
Venessa
clojurians
clojure
I’ll keep that in mind
2017-11-06T13:04:57.000111
Venessa
clojurians
clojure
Which invariably has me asking — what’s a good way to diff data structures ?
2017-11-06T13:05:29.000506
Venessa
clojurians
clojure
Is this map different from that map, etc
2017-11-06T13:05:52.000246
Venessa
clojurians
clojure
<@Venessa> ```(= {:a 1} {:a 1}) true (= {:a 1} {:a 2}) false```
2017-11-06T13:07:44.000300
Evan
clojurians
clojure
Great
2017-11-06T13:07:49.000308
Venessa
clojurians
clojure
so long as you're staying in the good world of immutable clojure data structures then comparing is just `=` ya
2017-11-06T13:09:55.000397
Aldo
clojurians
clojure
hello every one, is there a better way to achieve this? `(apply str (map str (interpose “, ” [1 2 3 4 5])))`
2017-11-06T13:11:43.000267
Amado
clojurians
clojure
Unless diffing maps is specific to the task... I'd say it's probably bad practice in general. Think more about how the data flows through the system, the output of a pure function should depend on the input, generally not the input + diff against another piece of changing state.
2017-11-06T13:12:43.000404
Cecile
clojurians
clojure
`(clojure.string/join ", " [1 2 3 4 5])` <@Amado>
2017-11-06T13:12:44.000071
Evan