This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-24
Channels
- # beginners (100)
- # calva (11)
- # cider (17)
- # clj-kondo (2)
- # cljdoc (66)
- # cljs-dev (54)
- # clojure (77)
- # clojure-czech (1)
- # clojure-dev (42)
- # clojure-europe (3)
- # clojure-italy (8)
- # clojure-nl (17)
- # clojure-spec (12)
- # clojure-uk (41)
- # clojurescript (68)
- # cursive (8)
- # datomic (15)
- # emacs (9)
- # expound (3)
- # fulcro (14)
- # garden (3)
- # graphql (2)
- # hoplon (2)
- # lein-figwheel (4)
- # leiningen (4)
- # off-topic (22)
- # onyx (8)
- # parinfer (2)
- # planck (1)
- # re-frame (5)
- # reagent (55)
- # reitit (3)
- # remote-jobs (8)
- # shadow-cljs (35)
- # spacemacs (23)
- # sql (3)
- # tools-deps (32)
- # unrepl (8)
- # vim (25)
- # yada (5)
newbie question: in : "(wrap-cors :access-control-allow-origin [#"http://localhost:3000/"])
user=> (class #"foo")
java.util.regex.Pattern
#"" is a data reading literal for regular expressions, and can be used with things like string/replace, re-matches, re-find
@aarkerio a guide to various weird sigils in clojure programs https://clojure.org/guides/weird_characters
link directly to the regular expression syntax https://clojure.org/guides/weird_characters#_regular_expression
Is there a way in a test to tell it to just fail ? like for instance if the wrong dispatch function is called
Hi @U97FB4VEE, did you see https://github.com/clojars/clojars-web/wiki/About#how-do-i-delete-a-jar
Is there any Redis
library that implements delayed task scheduling?
I need to delay a task which is distributed and kept in redis, something like this one: https://stackoverflow.com/questions/10868552/scalable-delayed-task-execution-with-redis
I currently listen to expire
keyspace notifications.. not sure if that is so scalable.
hmmm funny sounds very similar to what i'm looking at right now (maybe i'm wrong)
you can put timestamps in redis keys so you are independent of Redis time constructs? (need to put the expiry on keys big enough so it doesn't interrupt with your own logic)
are you working in a particular domain?
Not really, its just that I want to do it in a way that scales 🙂
then not use Redis 🙂
or maybe the wrong datastructure one sec
https://discuss.aerospike.com/t/how-would-one-implement-a-sorted-list-like-redis/1046/2
Anyway hard to say if that will solve your issue, and if Redis is the bottleneck at all
in the card game I'm working on, I have a "card" object, which is just a map with certain properties. To make interacting with the objects easier, I have a bunch of "accessor"/getter functions: corp?
returns true if the card is a Corp card, installed?
returns true if the card is currently installed, etc. These functions are all solely reliant on the card map passed in
for the basic ones you could do away with the fn
and replace with keyword (:installed? card)
Sadly, a lot are more like (= "Hardware" (:type card))
, which is a little more annoying and messy to write inline. And then of course, because it's a complex game, others are (or (= "Identity" (:type card)) (= "Fake-Identity" (:type card)))
, which is really annoying to write multiple times
I feel like I've heard @U050P0ACR talk about this kind of decision on his podcast, http://Lispcast.com. I'm sure he's got way more insight than me 😉
thanks for the recommendation! i'll check it out
Is there any "best practice" with organizing groups of functions like this? Seeing as I'm not creating multiple types, I don't see a benefit necessarily of using a protocol. if this was in java, these would all be normal "attributes": public isCorp()
etc
I've moved them into a card-properties
namespace and [card-properties :refer :all]
them, but I feel like I'm falling into a trap or a code smell, lol
Can [pre|post]walk
be used to extract selected leaves from a nested data structure? How? I want to descend only into some submaps and extract particular key from the leaf maps.
(w/postwalk (fn [m] (if (map? m) (select-keys m [:a :b]) m)) {:a 1 :b 2 :c {:a 1 :b 2 :c 3}})
{:a 1, :b 2}
@holyjak I've used tree-seq
plus a filter to select leaves for this sort of thing
doesn't tree-seq return all nodes instead of only leaves?
right, but you can take the final sequence of nodes and return only leaves
in your branch?
and children
functions, you can prune nodes whose children are not wanted
in fact the function to return only the leaves should just be (filter (complement branch?) ...)
where branch? is the same function you passed to tree-seq initially
(cmd)user=> (load-file "/tmp/foo.clj")
(1 4 6 7)
(ins)user=> (print (slurp "/tmp/foo.clj"))
(def input
{:a 1
:b {:a 2
:b 3}
:c {:a 4
:b 5
:c 6}
:d {:a 7
:b {}}
:e {:c 8}})
(def unused-keys
#{:b :e})
(def branch? coll?)
(def children
#(map (fn [node]
(if-not (map-entry? node)
node
(if (contains? unused-keys (key node))
[]
[(val node)])))
%))
(remove branch?
(tree-seq branch?
children
input))
nil
that declines to descend into keys and only returns vals out of key/value pairs, and removes all keys in a blacklist instead of descending deeper when found
thanks a lot!
I want to get out a seq of (leaf) values but exclude some branches
how far above the leaves are the branch points you know you won't want?
± 1 and 2
something like:
(remove map? (tree-seq map? #(vals (select-keys % [:a :b])) {:a 1 :b 2 :c {:a 1 :b 2 :c 3}}))
(1 2)
?Thanks, I think tree-seq doesn't do what I need but I can look at its implementation and copy that for my use case. (The thing is I have a nested data structure consisting of maps and seqs)
usually with tree-seq my predicate is coll?
which catches maps and seqs
but instead of coll?
you can use a predicate that both checks for coll?
and removes branches you don't want
(fn [node] (and (coll? node) (not (ignored? node))))
- where ignored? checks for k/v pars with excluded keys, or whatever
@holyjak You can easily process tree-like data structures with the Tupelo Forest library. See the Lightning Talk: https://youtu.be/RtavTnRr0oM
thanks!
and many live examples: https://github.com/cloojure/tupelo/blob/master/test/clj/tst/tupelo/forest_examples.clj
What do you mean by "bidirectional"?
ex. have a transformation t
that takes some clojure data a
and transforms it into b
, and can also apply the transformation to take b
into a
.
one of the things that seems to come up in literature is taking an updated b
and transforming it into an updated a
as well
Sure. I don't know of any library that does that, except of course for very narrow cases like serialization.
Or, you know, inc and dec :p
are there any other clojure/clojurescript streamers? i know of https://www.twitch.tv/jplur_
Hey @wiseman, I just recently challenged myself to try and build a twitch chatbot during livestreams on twitch: https://www.twitch.tv/upgradingdave
There’s also another clojure livestreamer here: https://www.twitch.tv/rhonin52/
I try to stream every M, W, F 7:30 eastern time. If you’re around, please stop by, love to have some help building the twitchbot!
There's a #livestream channel where folks used to talk about that but it's been inactive for a long time 😐
I think it would be fun if folks got that back up and running @wiseman... it's always very interesting to see different people's workflows!
yeah, that’s mostly what i’m interested in. the details of workflows that don’t always get documented on github pages, etc.
I can't remember what I tried to use to stream with back then... Not Twitch, for sure. But mostly I work on a proprietary code base so streaming isn't something I can really do much of the time.
I did do a short YouTube video recently of my workflow with REBL (and Atom/Chlorine).
(because folks kept asking about "how to use" REBL)