Fork me on GitHub

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


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


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


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


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.


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


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?


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 is solid. There's a #chlorine channel.


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?


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


The Clojure CLI (the official offering from Cognitect, rather than Leiningen) has an alpha approach to 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).


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.


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 😅, once i got more deeper knowledge then I'll try to move on to macOS. Thanks a lot for the suggestion


Happy to answer any Qs since I work on both Windows 10 (WSL2) and macOS 🙂


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.


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.


cool. The 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! 😆


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))
Any suggestions? Solved it by my own 😊
(let [mapsx (remove nil? (map #(if-not (clojure.string/includes? % "jpg") (conj % ) ) prae))]
        (println mapsx mapsx))


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.


See remove


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).


Also see keep instead of mapping then removing nils.


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

(use (. express (logger))


I believe it’s called the Dot special form, for more reading:

❤️ 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. linked to it, nvm 🙂

👀 3

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


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

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


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


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


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


but how do I get the 2?


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


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


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


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


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


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

👀 3

This way you would have replacement + counting in one go


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

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

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


context is contextual 😄


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?


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: YouTube series on use/setup:

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


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

☝️ 10
👍 4

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

👍 6
☝️ 6
calva 6

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, 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)


enable clojure module, repl is SPC m '


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


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


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 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 🙂 ?