Fork me on GitHub
#beginners
<
2021-01-29
>
JohnJ00:01:24

writing an "idiomatic" wrapper but that can be more taxing than using the lib directly

๐Ÿ‘ 6
Adrian Imanuel04:01:00

Hi Everyone, i'm really newbie in clojure (i don't have any code exp, except vba & ms. Excel). I'd like to asked several questions 1. lein new app asdf, i do this in my cmd, but how can i do this in atom? is it possible? if not, that's okay. 2. then i create suspects.csv and want to slurp it. but it gives an error. below is the screenshot. I've put this csv in resources, or in src/asdf along with the core.clj, but give same error. PS : I placed my lein.bat & atom repl run in this directory C:\Users\Adrian Imanuel\.atom\packages\proto-repl\proto-no-proj\src thanks a lot for the help

andy.fingerhut04:01:26

If you do this in your program, or a REPL, it will tell you what the JVM thinks is the current directory (or what it thought was the current directory when your REPL started at least -- it can be changed later): (println (System/getProperty "user.dir"))

andy.fingerhut04:01:51

That is the directory it is probably trying to read the file from, unless you direct it differently somehow.

andy.fingerhut04:01:19

If you want to get it from your resources directory, you can do (require '[ :as io]) in the REPL, or add a similar thing into your ns form of your program's namespace that looks like (:require [ :as io]), then do (slurp (io/resource "suspects.csv"))

andy.fingerhut04:01:19

Someone else might know the answer to your question about creating new Leiningen projects from within Atom -- I do not. You could also ask in the #atom-editor channel, if no one here knows.

seancorfield05:01:32

@adrianimanuel With Atom, are you using ProtoREPL or Chlorine?

seancorfield05:01:37

Hmm, ProtoREPL is unmaintained. I'm a bit surprised it still works with Atom.

Adrian Imanuel05:01:35

@seancorfield whoops, i really didn't know that, should i change IDE? is there any recommendations?

seancorfield05:01:37

It hasn't been updated in nearly three years now. I was an Atom/ProtoREPL user and I switched to Atom/Chlorine, but that expects you to start the REPL separately, via a terminal (or cmd.exe window in your case).

seancorfield05:01:21

https://atom.io/packages/chlorine is solid. There's a #chlorine channel.

seancorfield05:01:57

I will caution that Windows is very much a second-class citizen in the Clojure world. If you're on Windows 10 and willing to use WSL2 you'll fare much better.

๐Ÿ˜ฎ 4
Adrian Imanuel05:01:51

why is windows10 isn't suitable env for clojure?

seancorfield05:01:36

All of the tools and libraries are designed for macOS/Linux because that's what most Clojure developers use.

seancorfield05:01:03

The Clojure CLI (the official offering from Cognitect, rather than Leiningen) has an alpha approach to Windows: https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows via Powershell, but it's just so much easier to give up on Windows and use WSL2/Ubuntu (which is what Microsoft increasingly expect developers to do).

seancorfield05:01:32

And VS Code has a Remote-WSL2 mode that lets you run "everything" on Ubuntu while VS Code runs on Windows so it's super-slick.

seancorfield05:01:51

I use VS Code on both Windows and macOS (and it auto-synchronizes the entire setup between the two systems), and on both systems I run everything on the *nix side (Ubuntu on WSL2 on Windows 10 and macOS Terminal).

Adrian Imanuel05:01:19

I'll try to digest this... since i really had no idea, I'm still on progress learning https://www.braveclojure.com/core-functions-in-depth/ ๐Ÿ˜…, once i got more deeper knowledge then I'll try to move on to macOS. Thanks a lot for the suggestion

seancorfield05:01:44

Happy to answer any Qs since I work on both Windows 10 (WSL2) and macOS ๐Ÿ™‚

seancorfield05:01:00

My primary dev env is macOS but my secondary env is Windows with WSL2 (and Ubuntu). I've recently switched from Atom (after several years) to VS Code.

seancorfield05:01:58

That gives you the option of Calva which is very feature-rich and well-maintained or Clover -- which is essentially Chlorine (for Atom, but ported to VS Code). So that's allowed me to port my exact workflow from Atom to VS Code.

Adrian Imanuel05:01:18

@andy.fingerhut it works... (println (System/getProperty "user.dir")) after locate the REPL I'll try the (require '[ :as io]) now.

andy.fingerhut05:01:26

cool. The http://clojure.java.io/resource function is useful if you want to get a file handle to a file in your resources directory, but it isn't really needed if you prefer to put the file in the current directory (the one that "user.dir" property shows)

Adrian Imanuel05:01:55

thanks a lot for the enlightment! ๐Ÿ˜†

Sophie08:01:25

Hello, I'm looking for a way to seperate strings without a specific term and store them. The separation works, but it seems nothing is stored...

(let [mapsx (remove nil? (map #(if-not (clojure.string/includes? % "jpg") ( println % ) ) prae))]
        (println mapsx mapsx))
result:
(
whats
the
problem
here
)()
Any suggestions? Solved it by my own ๐Ÿ˜Š
(let [mapsx (remove nil? (map #(if-not (clojure.string/includes? % "jpg") (conj % ) ) prae))]
        (println mapsx mapsx))

โœ… 3
Mno10:01:32

Nice, you solved it, but you might want to look into filter and group-by, as it might make sense for this use case. this would get you all of the ones that dont include jpg

(filter #(not (clojure.string/includes? % "jpg")) prae)
while group-by would give you a map with those who do and donโ€™t include jpg.

tschady10:01:10

See remove

Mno10:01:59

I mean remove was used in the original, so I assumed knowledge of it was present. Although, It is good to point out that remove is very much useable as well (since itโ€™s basically the same as filter with the predicate reversed).

tschady12:01:02

Also see keep instead of mapping then removing nils.

teachtyler11:01:44

hi, what's the terminology for this dot notation and is it conventional or intrinsic? ex:

(use (. express (logger))
      ^

Mno11:01:01

I believe itโ€™s called the Dot special form, for more reading: https://clojure.org/reference/java_interop#_the_dot_special_form

โค๏ธ 3
๐Ÿ™ 3
Piotr Brzeziล„ski11:01:46

Hey! I remember seeing a list of OSS clojure/clojurescript repos with issues good for beginners. Could somebody please point me to it?

Piotr Brzeziล„ski11:01:42

Ah, found it. http://braveclojure.com linked to it, nvm ๐Ÿ™‚

๐Ÿ‘€ 3
Christian11:01:13

When I use clojure.string/replace, is it possible to get the times something was found? Maybe this example helps:

(def teststring "AAABBC")
(str/replace testcode #"\D+" "$1")
I would like to know how many times A was found in a row and use it. Is this possible in regex? I have to code with lots of take-while, count and drop. But this would be a lot more compact

borkdude11:01:43

@christiaaan You can pass a function as the last arg:

$ bb -e '(str/replace "foo" #"(o)+" (fn [& args]  (prn args) "x"))'
(["oo" "o"])
"fx"

Christian11:01:58

What? That looks like some bash thing. Ah, it's the babashka dude!

borkdude11:01:53

$ bb -e '(str/replace "foo" #"o" (fn [match] (prn match) match))'
"o"
"o"
"foo"

Christian12:01:40

for "oo" i would like to have something like "2o" so I know it has found 2 o

Christian12:01:46

but how do I get the 2?

borkdude12:01:12

you mean, you would like to get the amount of replacements?

borkdude12:01:02

I think you might want to use re-seq which gives you all the matches

borkdude12:01:27

$ bb -e '(re-seq #"\D" "AAABBC")'
("A" "A" "A" "B" "B" "C")

Christian12:01:49

Then I'd still have to count them manually. I was hoping that the regex would somehow offer the amount of replacements, like I can access the groups

raspasov12:01:56

I would say the most typical thing in Clojure is to simply (count โ€ฆ) the sequence that (re-seq โ€ฆ) returns

borkdude12:01:12

@christiaaan A little hacky, but you could have a side-effect in the replacement function that increments a counter

๐Ÿ‘€ 3
borkdude12:01:24

This way you would have replacement + counting in one go

dehli13:01:42

With spec, can I have the same namespace qualified keyword speced differently in two different contexts? For example in one map Iโ€™d want :foo/bar to be string? and in another Iโ€™d want :foo/bar to be int? . Ideally theyโ€™d be different keywords if they were different types, but curious if something like this is possible.

Alex Miller (Clojure team)13:01:06

No, spec encourages you to register a single, well namespaced spec that applies globally

๐Ÿ‘ 7
dgb2313:01:53

When I understand correctly, this doesnโ€™t just apply to spec, but is a more general issue about namespaces and namespaced keywords and what they mean right?

Alex Miller (Clojure team)13:01:18

Names need sufficient context

Alex Miller (Clojure team)13:01:53

โ€œSufficientโ€ is highly context dependent

๐Ÿ‘ 3
dgb2314:01:24

Shouldnโ€™t we provide context with metadata generally speaking? I donโ€™t think this is possible with keywords as they are interned. But conceptually this would seem useful.

Alex Miller (Clojure team)14:01:58

there are many kinds of context

dgb2314:01:20

context is contextual ๐Ÿ˜„

dgb2314:01:38

But yeah, thinking about this it makes more sense to put metadata on a symbol (that points to something) rather than a keyword, which is just a value.

Alex Miller (Clojure team)14:01:22

context can just be where/how it's used

Alex Miller (Clojure team)14:01:29

it can be implicit

๐Ÿ‘ 3
Adrian Imanuel15:01:24

hi, anyone using spacemacs? been stuck in here forever, why it didn't download? can anyone help?

clyfe15:01:46

This ate 1 day of my life with %^#&*?!?

Adrian Imanuel16:01:02

alrite, i'll try

Adrian Imanuel16:01:12

thanksss a lotttt for the information

Adrian Imanuel16:01:00

maybe i'll use emacs instead spacemacs... idk what to do (totally clueless), i'll learn it on the go

Jordan Garrison16:01:11

If you are a previous vim user/like vimโ€™s modal editing then Doom Emacs is another distribution of emacs which might meet what you need. It predownloads/compiles (if you want) packages for you so you get a quick startup (< 1s). It has a prebuilt clojure configuration as well which has worked really well for me out of the box. Repo: https://github.com/hlissner/doom-emacs YouTube series on use/setup: https://www.youtube.com/playlist?list=PLhXZp00uXBk4np17N39WvB80zgxlZfVwj

Adrian Imanuel16:01:41

alrite, i'll look into it as well.. I never use any of this before hahhaa.. total newbie... my previous experience is Ms. Excel & VBA.... I'll learn slowly

Joe17:01:31

Starting from scratch in non-VBA programing and Clojure and Emacs is a lot to chew in a single bite!

โ˜๏ธ 10
๐Ÿ‘ 4
clyfe17:01:11

@adrianimanuel https://calva.io/ may be more suitable for you, it's quite beginner friendly (occasional bugs aside).

๐Ÿ‘ 6
โ˜๏ธ 6
calva 6
dharrigan21:01:52

If you are a (neo)vim user, I can't rate highly enough the #conjure plugin for Vim that really is amazing for developing Clojure with Vim.

Adrian Imanuel04:01:01

@U0105JJK1L3 how's it going so far? How long have you been learning Clojure? you inspired me to learn more!!! awesome!

Adrian Imanuel04:01:51

@UCCHXTXV4 I'll try to stick to emacs & (doom/spacemacs). I'm still in chapter 5 http://braveclojure.com, thanks a lot for the advice

Adrian Imanuel15:01:02

@U01J6LMKF2L just installed DOOM, and tried to run repl for clojure, SPC-o-r there's 2 options : Clojure (default), when run said - symbol's function definition is void: cider-current-repl Clojure (cljs)

clyfe15:01:10

enable clojure module, repl is SPC m '

clyfe15:01:35

also have a clj file opened so you're in clojure mode

Adrian Imanuel15:01:11

the lein executable isn't in you exec-path

Adrian Imanuel15:01:26

where should i put lein.bat?

Adrian Imanuel15:01:46

in .emacs.d/bin or ~/.emacs.d/bin?

Adrian Imanuel15:01:00

gotcha, in ~/.emacs.d/bin

Adrian Imanuel16:01:56

@UCCHXTXV4 i've tried SPC m ' it showed like this, i didn't see any REPL windows... thanks a lot for the help

clyfe16:01:13

You have to be in a project (folder with project.clj or deps.edn).

clyfe16:01:53

Also I see some fonts be missing, check doom doctor

Adrian Imanuel17:01:16

ah allrite, will do

Adrian Imanuel17:01:40

thanks a lot for the guidance

๐Ÿ‘ 3
Adrian Imanuel03:02:32

i've tried to create projects, run the core.clj, but still the repl doesn't show up.

Adrian Imanuel04:02:12

okay, found the solutions https://stackoverflow.com/questions/65566706/error-in-process-sentinel-could-not-start-nrepl-server-java-lang-numberformate 1. start git cmd 2. type >> lein repl >> it'll start repl in git cmd 3. goto doom emacs type [SPC m c] >> cider-connect-clj 4. choose local host 5. type port local host as shown in step 2

Mehdi H.16:01:42

Hey guys, has anyone successfully used miner.ftp library with ftps? I can't find out where to use the function encrypt-channel on the client.... if local data transfer is not forced to SSL, just using the ftps protocol works, but when data should be encrypted it seems compulsory to use this encrypt-channel function.

Mehdi H.10:02:34

Is no one interacting using ftp or is my lack of profile picture detrimental to getting any feedback ๐Ÿ™‚ ?