Anyone know of a library that gives ansi colors in terminal output (that supports babashka)?
@schpaencoder https://github.com/borkdude/babashka/issues/547
(filter identity [1 2 3 nil 4 false true 1234])
=> [1 2 3 nil 4 false true 1234]
from my repl. am I going crazy? isn't nil and false supposed to be filtered out?
Are you sure you're evaluating the full filter
expression and not just the vector?
i just copy-pasted the second example from the docs https://clojuredocs.org/clojure.core/identity
> I going crazy? Seems so. Filter returns lazyseq, not vector. So you can not get [] as its output
that's a good point. so my REPL must just be returning the vector somehow
i restarted it and now it is correct: (filter identity [1 2 3 nil 4 false true 1234])
=> (1 2 3 4 true 1234)
god knows what that fuckness was
thatβs easy
$ clj
Clojure 1.10.1
user=> (clojure.main/repl :eval last)
user=> (filter identity [1 2 3 nil 4 false true 1234])
[1 2 3 nil 4 false true 1234]
hey, what might be the reason I'm getting different carmine
response behavior when I run it in repl or via clj
?
e.g. it does not print responses via clj
Sorry if this is a faq but say I have a url as a string, and I'd like to convert it to a keyword, (keyword "<http://foo.bar.baz>")
will create me a namespaced keyword, which is not really what I want because it doesn't round trip as I'd like it to:
user> (name (keyword "<http://foo.bar.com>"))
;; => "/foo.bar.com"
user>
Is there a way to construct a non-namespaced keyword from a string that contains a /
and how would one go about doing it?something like this should work:
user=> (name (keyword "<http://foo.bar.com>"))
"/foo.bar.com"
user=> (name (keyword "" "<http://foo.bar.com>"))
"<http://foo.bar.com>"
user=>
Whatβs your desire for this to be a keyword?
essentially, explicitly provide an empty namespace
I would hate to admit it, but it's for storing it in mongo....
api reads json where we do (cheshire/parse-string bla true)
and then stuff it to mongo where the mongo driver probably uses name
to turn the keys into string.
right. This feels so wrong π
Or provide a nil keyword,
user=> (namespace (keyword "" "<http://foo.bar.com>"))
""
user=> (namespace (keyword nil "<http://foo.bar.com>"))
nil
user=> (keyword "" "<http://foo.bar.com>")
:/<http://foo.bar.com>
user=> (keyword nil "<http://foo.bar.com>")
:<http://foo.bar.com>
yep π just like keywordizing a url. mongo makes people do weird things
It's all mongos fault.
you have no way to put a string into your database?
name
on a string yields a string.
So unless it actually complains about something not being a keyword, using strings should be fine I imagine.
Yeah, but the true
flag to cheshire instructs it to keywordize the keys.
Which one might argue is a bad idea, but that ship has sailed.
Ah, right.
We do, but at some point we decided to keywordize the keys of our maps. One could argue if that was a good idea or not, but that ship has sailed.
keywordize keys strikes again!
oh its the key in the map? i suppose you've thought about making it a {:type :url :value "<https://blah.com>"}
then and that can't work?
that's a pickle
Haven't thought about it yet. Thing is that I needed to store some rewriting rules in mongo, basically I needed to store "whenever you see http://foo.bar.baz, rewrite it to 'email'"
For this, a map makes perfect sense, since you can just feed it to set/rename-keys
But, I wasn't aware at the time that we'd need to rewrite url-keys.
@dpsutton but I will use your input to hammock this over the weekend. Thanks!
are there any indexes other than the commits on git repos that demonstrate the "liveliness" of a certain lib? I ask this since it seems for clojure some libs are used but not really under active development
this is a commonly asked question, but churn isn't really valued in the community
some libs just finish
e.g. clojure data.csv
you could look a library's usage with https://grep.app
I certainly use libraries that haven't been touched in a few years, because they work - and work very well. I'm happy with that aspect of the Clojure community. It allows me to focus on my code, and not checking every few days if a new version of the library has come out π A totally super benefit too, is given the great interop of Clojure, I can pull in a regular Java library and use that too. I love it!
(as someone who dabbles also in Javascript, the churn there is astronomical!)
on that note maybe we need a "done" badge on github that doesn't read as "not maintained"
"stable"?
or something like a "health-meter"
nah, health implies metrics
which implies active development
the conceit here is that a library is finished and does its task so there is just "no more work to do" on it
the state of the world in JS is something like "while a library is alive, it is a tiger and when its dead its a dead tiger"
whereas the common observation for clojure is that "An active library is like a tree, an inactive library is a house"
so how to at a glance determine if something is a finished product or an abandoned experiment is something
I like the analogy of an inactive library is like a house π
it mostly just comes because clojure dealing with data structures directly
so stuff like clojure.data.csv is just...done
it parses a data format into our "standard" for data
which avoids the sort of "exponential bikeshed" of javascript and java and all the other nominally typed things out there
public final class Row implements Iterable<String> {
// ...
String get(int i);
}
public final class Csv {
public static Iterable<Row> parse(InputStream contents);
}
vs
public class CsvReader {
// ...
CsvReader(Options opts) { /* ... */ }
List<List<String>> parse(InputStream is);
}
or whatever
its just "maybe too big for memory" -> lazy seq,
"probably not too big for memory" -> vector
for csv, there might be too many lines in a big file, but no individual line will be a gb probably
csv reading done, next problem