Fork me on GitHub
#off-topic
<
2020-06-12
>
emccue03:06:01

(defn start-system!
  "Starts and returns a system"
  []
  (let [config (config/load-from-classpath)
        db (db/create-db-connection config)
        server (server/start-server config db)
        scheduler (jobs/create-scheduler)]
    {:config config
     :db db
     :server server
     :scheduler (doto scheduler
                  (.start))}))

(defn stop-system!
  "Stops a system and closes down any resources"
  [system]
  (.close (:db system))
  (server/stop-server (:server system))
  (.shutdown (:scheduler system)))

;; Repl Use
(comment 
  (do
    (def system nil)

    (defn start! []
      (alter-var-root #'system (fn [_] (or system (start-system!)))))

    (defn stop! []
      (alter-var-root #'system (fn [_] (if system
                                         (stop-system! system)))))))

emccue03:06:48

now this isn't nearly a "real" app, but personally it feels like the dependency arranging of system and co might be overkill for simpler cases

plexus06:06:02

I'm looking for more plain-text based visualization languages/tools, examples being dot/graphviz and ditaa. I'm sure there are others out there but my google-fu is failing me.

borkdude09:06:59

created a #releases channel where people can share boring / minor / maintenance releases that do not contain lots of exciting stuff to be mentioned in announcements.

👍 7
sveri11:06:54

Hi, does someone have an example configuration of running clojure integration on gitlab with tools.deps? Or is there a docker container I can derive from that has the latest tools.deps installed?

sveri11:06:55

Ok, I just found the official docker images https://hub.docker.com/_/clojure

borkdude11:06:40

@sveri I usually just curl the installer script and run that in CI

sveri16:06:15

@borkdude Thanks, in the end I created my own docker image 🙂

jaide21:06:46

Are there any ring-like frameworks in other languages such as F#, or Python?

jaide21:06:24

Something where you are transforming common request data into response data without any annoying snowflake classes?

lilactown22:06:30

I’ve used Flask w/ Python in the past that was pretty light and no-nonsense

jaide22:06:28

I think Flask is still request\response class based though right?

jaide22:06:29

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        session['username'] = request.form['username']
        return redirect(url_for('index'))
    return '''
        <form method="post">
            <p><input type=text name=username>
            <p><input type=submit value=Login>
        </form>
    '''

jaide22:06:35

It's close, but I'd love it if there were something that uses dicts for the request data too so you don't have to research as many docs.

jaide22:06:30

def wrap_login (next_handler):
    def handler(request):
        if request['method'] == "POST":
            return {
                "status": 301,
                "session": {
                    "username": request["body"]["username"],
                },
                "headers": {
                    "Location": url_for("index")
                },
            }
        request.update({
            "headers": {
                'Content-Type': "text/html",
            },
            "body": """
            <form method="post">
                <p><input type=text name=username>
                <p><input type=submit value=Login>
            </form>
            """
        })
        response = next_handler(request)
        return response
    return handler

jaide22:06:54

I did start drafting a ring-like library in Python that can work with django views, but it's not battle tested.

jaide22:06:06

Plus I figure someone out there probably did it better