Fork me on GitHub
#clojure
<
2020-10-02
>
Schpaa09:10:41

Anyone know of a library that gives ansi colors in terminal output (that supports babashka)?

restenb09:10:05

(filter identity [1 2 3 nil 4 false true 1234]) => [1 2 3 nil 4 false true 1234]

restenb09:10:21

from my repl. am I going crazy? isn't nil and false supposed to be filtered out?

codonnell09:10:12

Are you sure you're evaluating the full filter expression and not just the vector?

restenb09:10:04

i just copy-pasted the second example from the docs https://clojuredocs.org/clojure.core/identity

ivana09:10:51

> I going crazy? Seems so. Filter returns lazyseq, not vector. So you can not get [] as its output

restenb09:10:17

that's a good point. so my REPL must just be returning the vector somehow

restenb09:10:04

i restarted it and now it is correct: (filter identity [1 2 3 nil 4 false true 1234]) => (1 2 3 4 true 1234)

restenb09:10:23

god knows what that fuckness was

vlaaad10:10:42

that’s easy

vlaaad10:10:24

$ 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]

πŸ’ͺ 1
yury.solovyov11:10:41

hey, what might be the reason I'm getting different carmine response behavior when I run it in repl or via clj ?

yury.solovyov11:10:04

e.g. it does not print responses via clj

slipset13:10:08

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 "") 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 ""))
;; => "/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?

Darin Douglass13:10:53

something like this should work:

user=> (name (keyword ""))
"/foo.bar.com"
user=> (name (keyword "" ""))
""
user=>

Darin Douglass13:10:06

essentially, explicitly provide an empty namespace

βž• 1
slipset13:10:30

right. This feels so wrong πŸ™‚

teodorlu13:10:06

Or provide a nil keyword,

user=> (namespace (keyword "" ""))
""
user=> (namespace (keyword nil ""))
nil

user=> (keyword "" "")
:/
user=> (keyword nil "")
:

Darin Douglass13:10:14

yep πŸ™ƒ just like keywordizing a url. mongo makes people do weird things

slipset14:10:52

It's all mongos fault.

dpsutton13:10:04

What’s your desire for this to be a keyword?

slipset13:10:36

I would hate to admit it, but it's for storing it in mongo....

slipset13:10:54

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.

p-himik14:10:33

name on a string yields a string.

p-himik14:10:08

So unless it actually complains about something not being a keyword, using strings should be fine I imagine.

slipset14:10:33

Yeah, but the true flag to cheshire instructs it to keywordize the keys.

slipset14:10:51

Which one might argue is a bad idea, but that ship has sailed.

p-himik14:10:26

Ah, right.

dpsutton14:10:12

you have no way to put a string into your database?

slipset14:10:47

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.

potetm00:10:34

keywordize keys strikes again!

dpsutton14:10:50

oh its the key in the map? i suppose you've thought about making it a {:type :url :value ""} then and that can't work?

dpsutton14:10:25

that's a pickle

slipset14:10:06

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'"

slipset14:10:42

For this, a map makes perfect sense, since you can just feed it to set/rename-keys

slipset14:10:14

But, I wasn't aware at the time that we'd need to rewrite url-keys.

slipset14:10:16

@dpsutton but I will use your input to hammock this over the weekend. Thanks!

πŸ‘ 1
quadron16:10:09

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

ghadi17:10:55

this is a commonly asked question, but churn isn't really valued in the community

ghadi17:10:13

some libs just finish

ghadi17:10:32

e.g. clojure data.csv

ghadi17:10:23

you could look a library's usage with https://grep.app

πŸ‘ 1
dharrigan17:10:55

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!

dharrigan17:10:48

(as someone who dabbles also in Javascript, the churn there is astronomical!)

emccue17:10:23

on that note maybe we need a "done" badge on github that doesn't read as "not maintained"

upside_down_parrot 1
🎯 1
sova-soars-the-sora23:10:47

RE: donezo libraries... how about "fit" ?

quadron17:10:55

or something like a "health-meter"

emccue17:10:03

nah, health implies metrics

emccue17:10:32

which implies active development

1
emccue17:10:08

the conceit here is that a library is finished and does its task so there is just "no more work to do" on it

emccue17:10:39

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"

🐯 1
emccue17:10:09

whereas the common observation for clojure is that "An active library is like a tree, an inactive library is a house"

πŸ‘ 1
emccue17:10:06

so how to at a glance determine if something is a finished product or an abandoned experiment is something

dharrigan17:10:31

I like the analogy of an inactive library is like a house πŸ™‚

emccue17:10:32

it mostly just comes because clojure dealing with data structures directly

emccue17:10:46

so stuff like clojure.data.csv is just...done

emccue17:10:56

it parses a data format into our "standard" for data

emccue17:10:48

which avoids the sort of "exponential bikeshed" of javascript and java and all the other nominally typed things out there

emccue17:10:00

public final class Row implements Iterable<String> {
    // ...
    String get(int i);
}

public final class Csv {
    public static Iterable<Row> parse(InputStream contents);
}

emccue17:10:53

public class CsvReader {
    // ...
    CsvReader(Options opts) { /* ... */ }

    List<List<String>> parse(InputStream is);
}

emccue17:10:11

or whatever

emccue17:10:46

its just "maybe too big for memory" -> lazy seq,

emccue17:10:55

"probably not too big for memory" -> vector

emccue17:10:23

for csv, there might be too many lines in a big file, but no individual line will be a gb probably

emccue17:10:48

csv reading done, next problem

πŸ‘ 1