workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
<@Herlinda>: maybe ``` (defmacro qkw [kw] `(keyword (str (namespace ::foo)) (str (name ~kw)))) ```
2017-11-14T13:52:34.000832
Berry
clojurians
clojure
Is there any good way of creating an anonymous function which doesn't accept any arguments? I need to be able to create them nested. ``` #(function/one :alpha (partial function/two :bravo)) ``` Using partial with full arguments works, but it doesn't feel right.
2017-11-14T14:01:19.000678
Earlie
clojurians
clojure
<@Earlie>, you can’t nest `#(...)` anonymous functions, but you can nest the `(fn [] ...)` form
2017-11-14T14:05:22.000119
Jonas
clojurians
clojure
Yeah, I know I can just nest fn calls. Was just curious if there was a core function for this type of thing.
2017-11-14T14:06:22.000784
Earlie
clojurians
clojure
so either `(fn [] (function/one :alpha #(function/two :bravo))` or `(fn [] (function/one :alpha (fn [] (function/two :bravo)))`
2017-11-14T14:06:23.000487
Jonas
clojurians
clojure
(A core function that allowed creating nested thunks)
2017-11-14T14:06:51.000450
Earlie
clojurians
clojure
<@Berry> doesn't seem to work at the repl for me
2017-11-14T14:06:54.000017
Herlinda
clojurians
clojure
<#C055AMK5Y|clojure-brasil>
2017-11-14T14:17:25.000177
Natosha
clojurians
clojure
<@Berry> I'm not the best at writing macros and especially calling them from cljs namespaces, but I think you might be on the right track
2017-11-14T14:20:26.000342
Herlinda
clojurians
clojure
I pasted your macro into a clj file and then called `(require-macros '[my-ns :refer [qkw]])` at the figwheel repl and it but when I call `(qkw :foo)` I get `:my-ns/foo`
2017-11-14T14:23:01.000743
Herlinda
clojurians
clojure
so even with the macro it is still giving you the ns where it is defined and not where it's called. I'm not the best at writing macros so maybe it just needs to be tweeked
2017-11-14T14:23:49.000299
Herlinda
clojurians
clojure
hey guys, I'm dealing with this strange issue -- when i call `(keys my-map)` the key `:example-key` is included in the results
2017-11-14T15:39:04.000322
Kathie
clojurians
clojure
however, when i log `(:example-key my-map)` i get nil
2017-11-14T15:39:42.000621
Kathie
clojurians
clojure
and when i print out `my-map` the key is nowhere to be found
2017-11-14T15:40:03.000137
Kathie
clojurians
clojure
what does `(:example-key my-map ::its-not-there)` return?
2017-11-14T15:40:08.000658
Willow
clojurians
clojure
it returns not-there
2017-11-14T15:40:44.000412
Kathie
clojurians
clojure
so all evidence points to the key not existing in the map, except for the `keys` function
2017-11-14T15:41:06.000180
Kathie
clojurians
clojure
also to be clear, i have code that's supposed to add that key and value to the map, so it not being there is problematic
2017-11-14T15:41:40.000042
Kathie
clojurians
clojure
not sure what could be causing this behavior
2017-11-14T15:41:54.000178
Kathie
clojurians
clojure
is it a record by any chance?
2017-11-14T15:42:19.000330
Willow
clojurians
clojure
it's reframe app-db
2017-11-14T15:42:33.000423
Kathie
clojurians
clojure
which i thought was just an atom
2017-11-14T15:42:46.000394
Kathie
clojurians
clojure
it's a `reagent/atom`
2017-11-14T15:43:43.000233
Kathie
clojurians
clojure
```app:cljs.user=&gt; (:search-lol @re-frame.db/app-db ::but-why?) :cljs.user/but-why? app:cljs.user=&gt; (keys @re-frame.db/app-db) (:schema :errors :audio-label :audio-player :loaded :duration :routes-initialized? :search-lol :token :active-page :models :status :path-array :file-download :playing :position :page-query :audio :url-data :location :user :audio-type)``` here's the code incase i'm doing something obviously dumb
2017-11-14T15:50:41.000355
Kathie
clojurians
clojure
What is `(type @re-frame.db/app-db)`?
2017-11-14T15:51:48.000281
Adelaida
clojurians
clojure
cljs.core/PersistentHashMap
2017-11-14T15:52:02.000479
Kathie
clojurians
clojure
its possible to get the current localized datetime without any libs in clojure
2017-11-14T15:52:14.000078
Amado
clojurians
clojure
?
2017-11-14T15:52:15.000013
Amado
clojurians
clojure
<@Kathie> - How about `(let [db @re-frame.db/app-db] (prn 'keys (keys db)) (:search-lol db :no-dice))` (to be sure the value isn't changing out from under you)?
2017-11-14T15:53:23.000415
Adelaida
clojurians
clojure
what does `(-&gt;&gt;(keys @re-frame.db/app-db) (map name))` show?
2017-11-14T15:53:54.000460
Jonas
clojurians
clojure
you can make a keyword with a space in it
2017-11-14T15:54:00.000196
Jonas
clojurians
clojure
it might not be it, but might explain the weird behaviour
2017-11-14T15:54:24.000097
Jonas
clojurians
clojure
```app:cljs.user=&gt; (let [db @re-frame.db/app-db] (prn 'keys (keys db)) (:search-lol db :no-dice)) keys (:schema :errors :audio-label :audio-player :loaded :duration :routes-initialized? :search-lol :token :active-page :models :status :path-array :file-download :playing :position :page-query :audio :url-data :location :user :audio-type) keys (:schema :errors :audio-label :audio-player :loaded :duration :routes-initialized? :search :token :active-page :models :status :path-array :file-download :playing :position :page-query :audio :url-data :location :user :audio-type) :no-dice app:cljs.user=&gt; keys (:schema :errors :audio-label :audio-player :loaded :duration :routes-initialized? :token :active-page :models :status :path-array :file-download :playing :position :page-query :audio :url-data :location :user :audio-type) ```
2017-11-14T15:54:25.000153
Kathie
clojurians
clojure
not sure why it printed 3 times
2017-11-14T15:54:32.000619
Kathie
clojurians
clojure
checking for something like `(keyword "search-lol ")`
2017-11-14T15:54:45.000461
Jonas
clojurians
clojure
```app:cljs.user=&gt; (-&gt;&gt;(keys @re-frame.db/app-db) (map name)) ("schema" "errors" "audio-label" "audio-player" "loaded" "duration" "routes-initialized?" "search-lol" "token" "active-page" "models" "status" "path-array" "file-download" "playing" "position" "page-query" "audio" "url-data" "location" "user" "audio-type")```
2017-11-14T15:55:06.000097
Kathie
clojurians
clojure
¯\_(ツ)_/¯
2017-11-14T15:55:23.000383
Jonas
clojurians
clojure
also this is the db that i reset! the atom to for it to get in this state
2017-11-14T15:55:35.000265
Kathie
clojurians
clojure
```(-&gt; db (assoc-in [:status :search-results-fetch audio-type] :success) (assoc-in [:search-lol :search-results] results))```
2017-11-14T15:55:48.000549
Kathie
clojurians
clojure
seems pretty straightforward to me so i dunno whats up
2017-11-14T15:56:00.000562
Kathie
clojurians
clojure
note: db doesn't start with `(-&gt; db :search-lol :search-results)` existing
2017-11-14T15:56:21.000081
Kathie
clojurians
clojure
My next guess was unicode weirdness, but if you typed in `:search-lol` in the `assoc` then that's surely not it.
2017-11-14T15:56:28.000350
Adelaida
clojurians
clojure
i assume assoc-in automatically creates a map for them
2017-11-14T15:56:30.000531
Kathie
clojurians
clojure
yea
2017-11-14T15:57:03.000389
Kathie
clojurians
clojure
and it does automatically create the nested maps: ```app:cljs.user=&gt; (assoc-in {} [:test :nested] true) {:test {:nested true}}```
2017-11-14T15:57:42.000677
Kathie
clojurians
clojure
so im at a complete loss
2017-11-14T15:57:46.000430
Kathie
clojurians
clojure
<@Amado> - Should be able to use the Java date/time API without any libs. <https://docs.oracle.com/javase/tutorial/datetime/iso/index.html>
2017-11-14T15:59:40.000316
Adelaida
clojurians
clojure
<@Kathie> - you've stumped me! ¯\_(ツ)_/¯
2017-11-14T15:59:58.000472
Adelaida
clojurians
clojure
thanks for trying lol, i have no idea what could be the issue
2017-11-14T16:01:04.000748
Kathie
clojurians
clojure
what does that print?```(let [db @re-frame.db/app-db] (doseq [k (keys db)] (prn k (= k :search-lol) (contains? db k) (get db k ::not-found))))```
2017-11-14T16:01:52.000464
Jonas
clojurians
clojure
just added `(= k :search-lol)` as something to print
2017-11-14T16:04:43.000443
Jonas
clojurians
clojure
ok so this is really strange
2017-11-14T16:06:43.000453
Kathie
clojurians
clojure
prn prints the results twice, and the first time it prints it, :search-lol is there
2017-11-14T16:07:01.000424
Kathie
clojurians
clojure
`:search-lol true true {:search-results [{:au...`
2017-11-14T16:07:46.000167
Kathie
clojurians
clojure
but then it start printing everything again and an old key that should no longer be in there got printed out too
2017-11-14T16:08:19.000448
Kathie
clojurians
clojure
how are you printing the value?
2017-11-14T16:08:43.000488
Jonas
clojurians
clojure
ie. are you using a repl
2017-11-14T16:08:56.000344
Jonas
clojurians
clojure
or putting it as a top level form in a cljs file
2017-11-14T16:09:09.000634
Jonas
clojurians
clojure
repl
2017-11-14T16:09:18.000222
Kathie
clojurians
clojure
lein fighwheel in intellij
2017-11-14T16:09:34.000075
Kathie
clojurians
clojure
seems like the app + dev tools might be in a weird state
2017-11-14T16:11:57.000100
Jonas
clojurians
clojure
yea lemme restart it
2017-11-14T16:12:10.000312
Kathie
clojurians
clojure
there are something things can cause a figwheel refresh
2017-11-14T16:13:11.000458
Jonas
clojurians
clojure
where it will rerun all the top level forms in your code
2017-11-14T16:13:30.000475
Jonas
clojurians
clojure
like saving a file
2017-11-14T16:13:38.000534
Jonas
clojurians
clojure
maybe there’s something with autosave and not having the state setup to make figwheel happy (eg. using `(def state (atom {}))` instead of `(defonce state (atom {}))`
2017-11-14T16:14:05.000209
Jonas
clojurians
clojure
I sometimes hit use-cases for this FN in threading macros. Is there a better/builtin implementation, or suggestions on the name? ``` (defn pred-or-nil [pred? v] (when (pred? v) v)) ```
2017-11-14T16:26:33.000004
Lonna
clojurians
clojure
<@Jonas> idk i'm at a loss. something weird is definitely happening because it's worked fine with every other key every tried previously
2017-11-14T16:27:49.000018
Kathie
clojurians
clojure
the repl doesn't seem trustworthy, so i'm tryign to see if i dissoc the key somewhere in my code
2017-11-14T16:28:20.000057
Kathie
clojurians
clojure
<@Kathie> did you try it from a command-line repl?
2017-11-14T16:31:07.000287
Marx
clojurians
clojure
I guy I work with was having some really weird issues that cleared up when he deleted the contents of the /target dir, fwiw
2017-11-14T16:31:53.000561
Marx
clojurians
clojure
not sure how i'd recreate the state of the app from the cli
2017-11-14T16:31:55.000431
Kathie
clojurians
clojure
hm
2017-11-14T16:32:00.000194
Kathie
clojurians
clojure
lemme delete mine
2017-11-14T16:32:03.000375
Kathie
clojurians
clojure
Oh that’s right, I was thinking clj not cljs, nvm
2017-11-14T16:32:21.000332
Marx
clojurians
clojure
but maybe the /target thing will help
2017-11-14T16:32:31.000537
Marx
clojurians
clojure
it does seem like a weird situation. I would check to make sure that you’re following the tips for reloadable code, <https://github.com/bhauman/lein-figwheel#writing-reloadable-code>. I would also try some of these tests outside of the figwheel repl to try to isolate the issue
2017-11-14T16:36:56.000280
Jonas
clojurians
clojure
in the past, Ive added debug functions like ```(defn ^:export debugprints [] (let [db @re-frame.db/app-db] (doseq [k (keys db)] (prn k (= k :search-lol) (contains? db k) (get db k ::not-found)))))```
2017-11-14T16:38:17.000307
Jonas
clojurians
clojure
and then you can call `my.namespace.debugprints()` from the dev console
2017-11-14T16:38:35.000259
Jonas
clojurians
clojure
ahh cool tip
2017-11-14T16:38:57.000242
Kathie
clojurians
clojure
(and yea lein cleaning and deleting /target didn't help)
2017-11-14T16:39:11.000392
Kathie
clojurians
clojure
Is there a way to run lein tasks from the repl?
2017-11-14T17:23:17.000424
Alix
clojurians
clojure
Should some-&gt; be able to have as-&gt; contained within it?
2017-11-14T17:40:17.000597
Earlie
clojurians
clojure
``` user=&gt; (some-&gt; 1 (as-&gt; % (+ % %))) 2 user=&gt; ```
2017-11-14T17:43:53.000349
Rebeca
clojurians
clojure
<@Earlie> anecdotally, I remember having issues with it a few months ago. I usually bust out <https://github.com/rplevy/swiss-arrows> when I need improved threading
2017-11-14T17:44:21.000174
Lonna
clojurians
clojure
the -&gt; macros are purely transformations of form, usually when people have trouble with them it is because they expect them to be aware of semantics
2017-11-14T17:45:06.000238
Rebeca
clojurians
clojure
Alright, I'd changed a -&gt; into an as-&gt;; I needed to nest my original -&gt; inside the new as-&gt; which was inside some-&gt;. My mistake.
2017-11-14T17:46:53.000326
Earlie
clojurians
clojure
Huh, <@Lonna>, I'll have to look into that.
2017-11-14T17:47:03.000175
Earlie
clojurians
clojure
that is too many arrorws
2017-11-14T17:47:14.000515
Rebeca
clojurians
clojure
Yeah, probably.
2017-11-14T17:47:21.000074
Earlie
clojurians
clojure
It doesn't actually look too bad in reality.
2017-11-14T17:47:34.000109
Earlie
clojurians
clojure
you can't actually tell if it is correct
2017-11-14T17:47:48.000082
Rebeca
clojurians
clojure
that is too many
2017-11-14T17:47:55.000317
Rebeca
clojurians
clojure
``` defn callback [{{{cookie-state :value} "state"} :cookies {:strs [code hd] query-state "state"} :query-params}] (if-let [userinfo (and (= cookie-state query-state) (some-&gt; (-&gt; @(http-client/post (env :google-token) {:form-params {:code code :client_id (env :google-id) :client_secret (env :google-secret) :redirect_uri "<http://localhost:8080/callback>" :grant_type "authorization_code"}}) :body (cheshire/parse-string true) :access_token) (as-&gt; access (-&gt; @(http-client/get (env :google-user-info) {:oauth-token access}) :body (cheshire/parse-string true)))))] (merge (response/redirect "/") {:cookies {"access" (compact/sign {:email} (env :secret))}}) (response/redirect "/login")) ```
2017-11-14T17:48:05.000262
Earlie
clojurians
clojure
that is gross
2017-11-14T17:48:59.000355
Rebeca
clojurians
clojure
Fair enough. Do you have a specific way you'd change it?
2017-11-14T17:49:14.000183
Earlie
clojurians
clojure
The alternative I was running into was having more than 2 exit points. (Duplicating my redirect to /login on multiple branches)
2017-11-14T17:49:54.000500
Earlie
clojurians
clojure
no, I think a good start would be breaking it up, pulling out some helper functions
2017-11-14T17:50:01.000301
Rebeca
clojurians
clojure
agree with the breaking it apart
2017-11-14T17:50:09.000255
Guillermo
clojurians
clojure
Good call there. I definitely will. This was largely just a matter of getting it working.
2017-11-14T17:50:31.000032
Earlie