Fork me on GitHub
#beginners
<
2019-05-11
>
Kari Marttila06:05:16

Thanks everyone (@noisesmith, @alex.joseph.whitt, @seancorfield and @michael.e.loughlin) for your comments regarding my configuration hassle question yesterday. After a good night's sleep I realized that the answer is pretty simple: I just need one configuration. I use mount to create me a configuration map when the server starts. In domain layer I create a defprotocol and two defrecords to implement the protocol: single-node and aws. Then I use mount to create either single-node or aws. In server I use domain mount state to give the server a domain entity and server uses it without knowing whether it is using single-node or aws. Let's see if there are any issues implementing that.

12
dangercoder09:05:48

Writing some Java-interop code for test.containers, but the clj version keeps on saying: No matching method withExposedPorts found taking 1 args for class org.testcontainers.containers.GenericContainer. Can anyone spot the error?

java
new GenericContainer("redis:5.0.4-alpine")
      .withExposedPorts(6379);
clojure
(defn redis-container []
  (-> (GenericContainer. "redis:5.0.4-alpine")
      (.withExposedPorts 6379)))

4
dangercoder10:05:05

Found the issue. it was how I set the ports.

dangercoder10:05:14

(defn with-exposed-ports [^GenericContainer container & ports]
  (.withExposedPorts container (into-array Integer (map int ports))))
used this function to set my ports.

Patrick Winter11:05:59

I am somewhat stuck at adding data.json as a dependency to my project. Here is what I did so far:

(defproject archivian "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]
                 [org.clojure/java.jdbc "0.7.8"]
                 [org.xerial/sqlite-jdbc "3.23.1"]
                 [org.clojure/data.json "0.2.6"]]
  :plugins [[lein-ring "0.12.5"]]
  :ring {:handler archivian.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})

lein deps
(ns archivian.handler
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ :as io]
            [clojure.java.jdbc :refer :all]
            [clojure.data.json :as json]))
...
When I evaluate my buffer using cider I get:
1. Caused by java.io.FileNotFoundException
   Could not locate clojure/data/json__init.class, clojure/data/json.clj or clojure/data/json.cljc
   on classpath.
Any ideas?

Patrick Winter11:05:11

Nvm, this appears to be a CIDER issue. lein ring server-headless does the right thing.

Adrian Smith14:05:39

Has any one ever used applescript to send forms to a repl from any editor?

Adrian Smith15:05:10

Looks like it works quite well, define a quick action like this: https://i.imgur.com/C5Q4fhd.png after saving you'll find it as a service in your keyboard shortcut settings, then select the form you want to send to your repl and press your assigned keybind

Luiz Sol18:05:02

Is there any difference between next and rest?

rakyi18:05:18

yes

user=> (next [])
nil
user=> (rest [])
()

seancorfield18:05:44

@luizedusol rest always returns a sequence; next returns nil if there are no more items.

Idan Melamed18:05:17

I'm reading "Clojure for the brave and true", and trying to launch a repl from emacs, and I get an error message saying it can't find /usr/bin/zsh... I used zsh for a brief time, and I'm not using it anymore.

Idan Melamed18:05:32

Can't seem to find where emacs is trying to open zsh in order to change the settings

seancorfield18:05:48

@idanmel Maybe ask in #emacs -- not sure how many experienced Emacs users there are here on a Saturday