workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
the point is, we would like to log each of those actions with coresponding users
2017-11-19T18:39:54.000112
Logan
clojurians
clojure
for example USER A added entity B with name C , or USER D edited entity (fields E F G) with values ( H I J) .. basicaly an activity log
2017-11-19T18:41:12.000145
Logan
clojurians
clojure
that is readable for non-programmer admin user
2017-11-19T18:41:24.000120
Logan
clojurians
clojure
ah got you! interesting feature. sincerely IDK. the Rails equivalent would be <https://github.com/airblade/paper_trail> which wraps every CRUD action with an object to be persisted, including a `whodunnit` column
2017-11-19T18:44:26.000012
Kristy
clojurians
clojure
<https://blog.clubhouse.io/auditing-with-reified-transactions-in-datomic-f1ea30610285>
2017-11-19T18:46:42.000105
Kristy
clojurians
clojure
switching to Datomic just for this might be overkill
2017-11-19T18:46:58.000058
Kristy
clojurians
clojure
otherwise dunno!
2017-11-19T18:47:06.000036
Kristy
clojurians
clojure
Yea .. well since I am using sqlkorma with postgres i even thought about somehow forking korma and writing this kind of logic. But it's not the clean solution im looking for. :confused:
2017-11-19T18:49:31.000110
Logan
clojurians
clojure
sql log analysis? turn `INSERT into ...` text data into new data to be inserted would seem fragile-ish to me, can be a last resource
2017-11-19T18:51:37.000010
Kristy
clojurians
clojure
hi everyone, basic question about threading. Why doesnt this work ``` (-&gt; 10 inc dec (fn [x] (* x x))) ``` I expected output of 100
2017-11-19T19:18:59.000085
Tobie
clojurians
clojure
``` (-&gt; 10 inc dec ((fn [x] (* x x)))) ```
2017-11-19T19:19:31.000082
Kristy
clojurians
clojure
as for the why... this will reveal :slightly_smiling_face: ``` (macroexpand-1 '(-&gt; 10 inc dec (fn [x] (* x x)))) ```
2017-11-19T19:21:31.000019
Kristy
clojurians
clojure
oh i see it now
2017-11-19T19:24:20.000120
Tobie
clojurians
clojure
thanks :slightly_smiling_face:
2017-11-19T19:24:22.000021
Tobie
clojurians
clojure
duh
2017-11-19T19:24:33.000091
Tobie
clojurians
clojure
<@Logan> have you considered a database trigger that writes to a separate logging table on inserts and updates to specific tables?
2017-11-19T20:25:08.000105
Al
clojurians
clojure
<@Al> Yes I did, but i haven't figured out how to get the current user logged in :confused:
2017-11-19T20:46:38.000081
Logan
clojurians
clojure
<@Logan> Did I see you're using postgres? If so, `CURRENT_USER` should give you what you want.
2017-11-19T20:52:50.000115
Domingo
clojurians
clojure
That would be SQL user, not application user. I would need to find a way to append id of current id to every SQL query for the trigger to work :confused:
2017-11-19T20:54:38.000059
Logan
clojurians
clojure
And that wouldn|t be clean anyways :confused:
2017-11-19T20:54:48.000028
Logan
clojurians
clojure
I'd create a wrapper to the database query functions that takes the logged in user as an argument. Use that data to log anywhere/way you want.
2017-11-19T20:58:53.000155
Domingo
clojurians
clojure
Thanks. <@Kareen> <@Deborah>
2017-11-19T21:09:54.000125
Tari
clojurians
clojure
<@Domingo> that actually sounds good. Are you familiar with sqlKorma ? Im wondering what would be the less possible way to wrap native sqlkorma functions for this to work. There could for example be problem with threading macros
2017-11-19T21:54:23.000008
Logan
clojurians
clojure
I haven't used Korma before. At a very brief glance, it's too magic for me. I pretty much just use clojure.java.jdbc and write my sql directly.
2017-11-19T21:59:40.000029
Domingo
clojurians
clojure
Oh, alright .. Well, i came to clojure from OOP languages with frameworks like SpringMVC .. so at least a querybuilder is kinda a must for me :smile:
2017-11-19T22:05:31.000171
Logan
clojurians
clojure
this may be a good time for a simple macro. `defquery` that takes a user and then just passes everything through to a defn that includes whatever logging form you normally do.
2017-11-19T22:13:08.000153
Willow
clojurians
clojure
Oh , that might actualy work.
2017-11-19T22:21:41.000135
Logan
clojurians
clojure
Hello, are there any clojure libraries that play nicely with bitcoin, or any bitcoin exchanges powered by clojure?
2017-11-19T22:51:05.000172
Magda
clojurians
clojure
district0x got some work on ethereum <https://medium.com/@matus.lestan/how-to-create-decentralised-apps-with-clojurescript-re-frame-and-ethereum-81de24d72ff5>
2017-11-19T23:59:25.000052
Lovie
clojurians
clojure
<@Logan> Clojure requires a different mindset to OOP -- but you might want to look at HoneySQL as a composable way to build queries from expressions (which is compatible with `clojure.java.jdbc`).
2017-11-20T01:24:38.000161
Daniell
clojurians
clojure
is there a way to tell clojure.core/memoize to only keep WEAK references to its arguments ? I need this to be WEAK in both clj and cljs
2017-11-20T02:42:22.000096
Berry
clojurians
clojure
Has anyone tried Clojure with Google App Engine Java 8 RTE ?
2017-11-20T02:54:57.000123
Mario
clojurians
clojure
<@Berry> no but I guess it wouldn't be too hard to roll your own version of memoize using weak maps. Be careful of browser support though.
2017-11-20T03:05:00.000034
Danyel
clojurians
clojure
does clojure have any libraries pertaining to data analysis/data science?
2017-11-20T04:43:43.000479
Delsie
clojurians
clojure
Howdy. What would you guys recommend for putting together a simple ReSTful API for passing JSON from Mongo to a web client?
2017-11-20T05:01:33.000129
Elois
clojurians
clojure
<@Mario> I have been using it for a project for the past couple months and it mostly just works. Most quirks are due to the way the developer server is set up and the REPL. Let me know if you have specific questions and happy to help.
2017-11-20T05:04:40.000136
Ed
clojurians
clojure
hey guys, does somebody know the owner of `<http://tryclj.com|tryclj.com>`? I just tried it today and it says that the domain name has expired :confused: Just putting it here hoping it that the owner sees it.
2017-11-20T05:31:55.000011
Kenia
clojurians
clojure
maybe a clone on `<http://try.clojure.org|try.clojure.org>` The repo is here <https://github.com/Raynes/tryclojure>
2017-11-20T05:32:55.000020
Shantae
clojurians
clojure
unfortunately the owner passed away last year (see <https://cemerick.com/2016/12/07/rip-anthony-grimes/>), not sure if anybody else has access to the domain
2017-11-20T05:33:08.000157
Kareen
clojurians
clojure
oh, didnt know that. Well there are now some other websites out there with Clojure repl so it shouldnt be a problem.
2017-11-20T05:36:27.000437
Kenia
clojurians
clojure
Guys, is there a beautiful way to implement this in clojure? ```(defn handle-job-entity [result {:keys [new_agent new_job job_request] :as entity}] (when new_agent (handle-new-agent entity)) (when new_job (handle-new-job entity)) (when job_request (handle-job-request entity)))``` Every time I receive an entity that has this three keys but only one is true at a time
2017-11-20T05:56:49.000408
Audie
clojurians
clojure
<@Audie> multimethods
2017-11-20T06:01:33.000435
Kristy
clojurians
clojure
ok, I’ll take a look into it tks
2017-11-20T06:05:54.000144
Audie
clojurians
clojure
<@Audie> I had this in mind: ``` (defmulti a (fn [result command] (-&gt;&gt; command (filter second) ffirst))) (defmethod a :new_agent ...) ``` hope it helps!
2017-11-20T06:07:26.000160
Kristy
clojurians
clojure
<@Audie> if all functions use the same argument, why dont you just pass the function as argument? `(handle-job-entity new-whatever entity)` and inside it, you just do `(new-whatever entity)`
2017-11-20T06:10:42.000353
Kenia
clojurians
clojure
Have you been using standard or flexible environment ? I was looking at setting up project for standard environment. It seems like you have to do a fair bit of hackery if you want to use leiningen for building the project. :slightly_smiling_face:
2017-11-20T06:14:07.000353
Mario
clojurians
clojure
But in that case, how can I know what function to pass? I think I’d have to check that three values
2017-11-20T06:15:25.000310
Audie
clojurians
clojure
I’m having a hard time to go from OOP to funcional
2017-11-20T06:15:52.000273
Audie
clojurians
clojure
It’s a whole new way to think
2017-11-20T06:18:40.000230
Audie
clojurians
clojure
<@Audie> the code that calls `handle-job-entity` *must* know which function to call, otherwise it would not be possible to pass it as an argument as you show above. I assumed that you were in control of that code.
2017-11-20T06:21:34.000331
Kenia
clojurians
clojure
Yes, I am. The function that calls `handle-job-entity` is `handle-job-entities` ```(defn handle-job-entities [job-entities] (reduce handle-job-entity {} job-entities))```
2017-11-20T06:24:26.000112
Audie
clojurians
clojure
So in this function will I have to check some how that same values I’m receiving in `handle-job-entity` and pass the correct function right?
2017-11-20T06:27:20.000071
Audie
clojurians
clojure
Is this a better approach than implementing using multimethods?
2017-11-20T06:28:53.000288
Audie
clojurians
clojure
<@Audie> it depends. Multimethods are much more flexible but if you are just starting I would recommend you to stay with the basics. That way you can avoid overloading yourself with new stuff.
2017-11-20T06:41:54.000032
Kenia
clojurians
clojure
I see. Good idea :grimacing: But in that case where I pass the function depending on the value of that three keys, would’n I end up with the same problem before?
2017-11-20T06:44:53.000248
Audie
clojurians
clojure
I’ve tried to do like this: ```(declare handle-new-agent handle-new-job handle-job-request) (def entity-functions {:new_agent handle-new-agent, :new_job handle-new-job, :job_request handle-new-job}) (defn handle-new-agent [result entity] (prn "handle-new-agent: " entity)) (defn handle-new-job [result entity] (prn "handle-new-job: " entity)) (defn handle-job-request [result entity] (prn "handle-job-request: " entity)) (defn handle-job-entities [job-entities] (reduce (fn [result entity] ((entity-functions (first (keys entity))) result entity)) {} job-entities)) ```
2017-11-20T07:42:56.000214
Audie
clojurians
clojure
But it gives me an `Attempting to call unbound fn: #'job-queue.job-queue-core/handle-new-agent`
2017-11-20T07:43:21.000191
Audie
clojurians
clojure
put the `def` before the last `defn`
2017-11-20T07:43:46.000255
Kristy
clojurians
clojure
i.e. you cannot do this `:new_job handle-new-job` before the `defn handle-new-job`
2017-11-20T07:44:36.000142
Kristy
clojurians
clojure
sorry, I forgot that before the `def`I have: ```(declare handle-new-agent handle-new-job handle-job-request)```
2017-11-20T07:45:58.000269
Audie
clojurians
clojure
just fixed
2017-11-20T07:46:20.000143
Audie
clojurians
clojure
in that case code looks fine!
2017-11-20T07:48:01.000238
Kristy
clojurians
clojure
might it be that it's inconsistently evaluated into the repl? try loading it from scratch
2017-11-20T07:48:26.000271
Kristy
clojurians
clojure
if I remove the `declare`and put the `def` after the last `defn`as you said, It works
2017-11-20T07:55:12.000196
Audie
clojurians
clojure
but why is that? the declare did not bind with the function?
2017-11-20T07:59:43.000207
Audie
clojurians
clojure
<@Audie> at first sight I would have said the code worked tbh
2017-11-20T08:21:27.000049
Kristy
clojurians
clojure
here's the fix: `(def entity-functions {:new_agent #'handle-new-agent, :new_job #'handle-new-job, :job_request #'handle-new-job})`
2017-11-20T08:21:37.000404
Kristy
clojurians
clojure
(that's 'var quote' syntax)
2017-11-20T08:22:03.000069
Kristy
clojurians
clojure
oh my.. can you please tell me why is it necessary?
2017-11-20T08:22:26.000269
Audie
clojurians
clojure
`declare` returns special `clojure.lang.Var$Unbound` objects, you aren't supposed to handle them directly as the `(def entity-functions ...` code does
2017-11-20T08:27:39.000008
Kristy
clojurians
clojure
a simpler lesson would be: define things in a way that the compiler can resolve at every moment
2017-11-20T08:28:25.000176
Kristy
clojurians
clojure
coming from other languages you might be tempted to define higher-abstraction-level functions first, it would be nice if Clojure favored that style but it doesn't
2017-11-20T08:29:47.000307
Kristy
clojurians
clojure
``` (condp #(get %2 %1) entity :new_job (handle-new-job entity) :new_agent (handle-new-agent entity)) ```
2017-11-20T08:36:20.000032
Jodie
clojurians
clojure
<@Audie> This is how I would approach this problem ^^
2017-11-20T08:37:21.000273
Jodie
clojurians
clojure
Thanks guys. I really appreciate the help <@Jodie> <@Kristy> <@Kenia> !
2017-11-20T09:00:24.000150
Audie
clojurians
clojure
could anybody remind me the easiest way to get start/end of the year for the datetime instance? I checked `clj-time` sources but without result (or did I skipped those functions?). thanks.
2017-11-20T09:09:07.000657
Verna
clojurians
clojure
<@Verna> did you try `clj-time`?
2017-11-20T09:26:38.000598
Audie
clojurians
clojure
<@Audie>&gt; I checked `clj-http` sources…
2017-11-20T09:27:14.000157
Verna
clojurians
clojure
http != time :stuck_out_tongue_winking_eye:
2017-11-20T09:27:37.000261
Kristy
clojurians
clojure
oh, my bad. meant `clj-time` of course.
2017-11-20T09:28:26.000148
Verna
clojurians
clojure
are there any functions to jump at the beginning/ending of some period: week, month, year etc?
2017-11-20T09:29:18.000187
Verna
clojurians
clojure
<@Verna> "get next Monday": <https://gist.github.com/rauhs/3ec9f05f2501bfb40acec35eca3fa73e#file-java-8-time-clj-L32-L36>
2017-11-20T09:36:57.000361
Randee
clojurians
clojure
It's Java 8's datetime API
2017-11-20T09:37:18.000593
Randee
clojurians
clojure
Beginning/end of year should super easy, no? Just get the current year and create a new date with Jan 1 &amp; Dec 31st?
2017-11-20T09:38:04.000276
Randee
clojurians
clojure
<@Randee> thank you, the code looks interesting. Yes, dealing with the year issue would be easy. I just expected some general functions to exist.
2017-11-20T09:39:21.000198
Verna
clojurians
clojure
for example, in PostresQL, there is a great `date_trunc` function
2017-11-20T09:39:43.000706
Verna
clojurians
clojure
``` select date_trunc('week', current_timestamp); date_trunc ------------------------ 2017-11-20 00:00:00+03 (1 row) ```
2017-11-20T09:40:05.000299
Verna
clojurians
clojure
<@Verna> Read the doc string of TemporalAdjuster, it has `TemporalAdjusters/firstDayOfYear`, and month (and last respectively)
2017-11-20T09:42:57.000657
Randee
clojurians
clojure
Hi, y'all! Is there a way to stub clj-time to return a certain time instead of now, when I call `(t/now)`? I want to write tests and I am looking for something like timecop (a Ruby gem)
2017-11-20T09:58:48.000535
Allie
clojurians
clojure
<@Allie> `with-redefs`?
2017-11-20T09:59:44.000691
Mallie
clojurians
clojure
Sounds like it :slightly_smiling_face:
2017-11-20T10:00:26.000698
Allie
clojurians
clojure
We tend to write our stuff so that most time-based functions take in a definition of 'now' as an argument. Makes testing easier, and then we generally only generate 'now' in one place in the live code and use it where needed
2017-11-20T10:00:27.000005
Mallie
clojurians
clojure
let me read about that, found it being used in the tests of clj-time :slightly_smiling_face:
2017-11-20T10:01:20.000191
Allie
clojurians
clojure
Hey guys, I'm trying to manipulate a record in Java. It seems assoc returns an Associative type. Is there a way to get back the same record type or do I have to just cast it everytime?
2017-11-20T10:06:08.000348
Eddy
clojurians
clojure
example: ``` // c is a record of type "Context" created in Clojure with (defrecord Context [foo bar]) // this returns Associative rather than Context c.assoc("some_key", "some_val") //ideally I could just do this c = c.assoc("some_key", "some_val") ```
2017-11-20T10:10:02.000349
Eddy
clojurians
clojure
<@Allie> you could try using mocking library for that: <https://github.com/igrishaev/mockery> ``` (with-mock _ {:target :clj-time.core/now :return (date-time 2017 12 31)} ... code goes here)) ```
2017-11-20T10:14:34.000238
Verna
clojurians
clojure
What does that get you that a simple `with-redefs` doesn't?
2017-11-20T10:20:12.000837
Mallie
clojurians
clojure
It accumulates info about numbers of calls and arguments.
2017-11-20T10:26:03.000229
Verna
clojurians
clojure
There was a recent library I saw that implemented some sort of computation DAG, very much like AWS Step Functions. I lost the link, does it ring a bell for anyone?
2017-11-20T11:05:39.000394
Guillermo
clojurians
clojure
(It's not prismatics/graph)
2017-11-20T11:07:05.000379
Guillermo