Fork me on GitHub
#beginners
<
2017-01-29
>
abhishekamralkar07:01:38

I am trying to authenticate with docker-registry2 api

abhishekamralkar07:01:53

Some how giving me 401

tbaldridge18:01:28

@sifou they act the same, but I think resolve is a function so you can do (apply resolve '(+))

tbaldridge18:01:28

var is a special form that is a compiler intrinsic so apply won't work, but the var is found at compile time.

sifou biri18:01:58

@tbaldridge I see, Thank you for your clarification 🙂

abhishekamralkar18:01:40

I am trying to get repository-name out of my Map but unfortunately it is giving me nil output

abhishekamralkar18:01:14

(defn desc-repo []
  (ecr/describe-repositories {}))

abhishekamralkar18:01:30

Output is ArrayMap

eslachance21:01:29

I shall be a noob again for a second. How do I make a newline within a string. I'm trying to write to a log file, using spit. But it shoves everything in one line. Google tells me this should work but it still doesn't print a new line: (spit "event.log" (str msg (newline)) :append true)

schmee21:01:39

luckyevie (str msg “\n")

eslachance21:01:44

I thought of that, but... nope. Still on the same line. (spit "event.log" (str "Test\n blah\n blah\n"), :append true) does everything on the same line, just Test blah blah

schmee21:01:34

weird, works for me

eslachance21:01:41

Clojure 1.8.0?

eslachance21:01:19

Just to be sure it wasn't my project config or whatever, I tried it in a fresh folder with lein repl. Doesn't work. It is \n within the string and now outside of it, right?

schmee21:01:23

what OS are you using?

eslachance21:01:40

Windows at the moment

eslachance21:01:09

So... \r\n I guess?

eslachance21:01:28

I've been spoiled by easy-mode JavaScript which probably does an internal conversion.

eslachance21:01:41

What happens if this code is deployed on a linux host in the future though?

schmee21:01:57

\r\n works on linux as well AFAIK

eslachance21:01:37

Alright. I just also realized that even though I'm spitting to a log, my repl output has new "random" newlines in it. Bravo, Windows. Bravo.

beppu21:01:22

Just use Linux or OSX. trollface

eslachance21:01:41

I would except I'm a gamer.

eslachance21:01:53

And I refuse to have to deal with WINE, really.

eslachance21:01:00

Darnit. It might be something else. (spit "event.log" (str msg "\r\n") :append true) still doesn't make a new line.

schmee21:01:22

what editor are you viewing the file in?

eslachance21:01:59

WAIT, no, it's fine now. must have borked my code update somehow.

eslachance21:01:37

Also tail -f for the win 😄

eslachance23:01:15

Hmm. I'm looking to retrieve a keyword from a hashmap, while also removing that keyword from said hashmap. Something a little like array.shift() in javascript, but more like... hm... let's say

(def thing {:bar "blah"
            :thing "amagig"
            :super "califragilous"})
(def foo (get-and-delete thing :blah))
This would (in my world) make foo equal to "blah" and thing no longer having the :bar key, only :thing and :super. Is there such a thing or do I make it myself?

seancorfield23:01:50

@eslachance data is immutable so you can’t remove an entry from a map, but you can define a new map without that entry...

seancorfield23:01:45

(let [bar-less (dissoc thing :bar)
      foo (:blah thing)]
  …do stuff with foo and bar-less…)