This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-15
Channels
- # beginners (26)
- # biff (28)
- # calva (13)
- # clj-commons (4)
- # clj-kondo (3)
- # clojure (45)
- # clojure-austin (17)
- # clojure-europe (8)
- # clojure-finland (1)
- # clojurescript (14)
- # code-reviews (3)
- # emacs (33)
- # helix (4)
- # holy-lambda (7)
- # joyride (5)
- # keechma (1)
- # meander (4)
- # membrane (3)
- # missionary (22)
- # nbb (1)
- # off-topic (1)
- # pathom (4)
- # rdf (24)
- # releases (2)
- # sci (3)
- # shadow-cljs (12)
- # tools-deps (14)
Suddenly curious about this: let's say you have a random small one off task you want to do with clojure that requires dependencies and you sort of want to keep that code around for reference in the future, how do you do this? Make a whole new clojure project with deps.edn? Do you have a dir for a bunch of these types of things with a common deps.edn file? Do you have an alias in your root deps.edn that has a bunch of common dependencies? On a micro level, do you use ns
or just (require 'x ...)
and why?
A recent example for me was there was a blog series with a title of contents page of all the posts, and I wanted to slurp that page and then slurp all the href links on it and concat the bodies so it's one big html file. How do you organize these little things?
I'm trying to reconsider my dev workflow and organization and I'm curious what other people do
I have a junk project for every dependency I can think of for that. If something in it pans out I spin it off
I have a clojure-playground deps.edn project with : deps.edn :
{:paths ["resources"]
:deps {clj-commons/pomegranate {:mvn/version "1.2.1"}
com.github.jpmonettas/flow-storm-inst {:mvn/version "3.0.236"}
com.github.jpmonettas/flow-storm-dbg {:mvn/version "3.0.236"}}}
user.clj :
(ns user
(:require [cemerick.pomegranate :as deps-pomegranate]
[flow-storm.api :as fsa]))
(defn add-deps [& lein-style-dependency]
(deps-pomegranate/add-dependencies
:coordinates `[~@lein-style-dependency]
:repositories {"central" " "
"clojars" ""}))
(defn start-debugger []
(fsa/local-connect {:theme :dark}))
(defn stop-debugger []
(fsa/stop))
and lets say I wan't to test the hiccup library, then I create playground/hiccup.clj with :
(user/add-deps '[hiccup "1.0.5"])
(ns playground.hiccup-test
(:require [hiccup.core :refer [html]]))
(html [:div 1])
The idea of hot loading dependencies is to keep deps.edn deps small so it starts fast, and then every playground file is self contained
Just one note on using RELEASE version - this fools the classpath caching so once you have that, unless you change the deps.edn or -Sforce, you will never get new versions of those deps
yeah, I had been bitten by that before
edited after Alex comments
Nice, coincidentally I have actually experimented recently with Neil, and, separately, using the add-libs tools.deps branch, both seem really nice for this type of stuff
If you have babashka-compatible code you can also use this:
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {medley/medley {:mvn/version "1.4.0"}}})
(require '[medley.core :as medley])
(prn (medley/index-by :id [{:id 1} {:id 2}]))
Eric Normand had a good article about running a single .clj file like a .sh by adding some sort of preamble to the top of the file but I can’t find it, will check my files when I get home
This was in the dark ages before Babashka
@U064UGEUQ I found some of these pretty interesting: https://stackoverflow.com/questions/7656523/how-can-i-run-a-clj-clojure-file-i-created
Ok here it is: https://gist.github.com/ericnormand/6bb4562c4bc578ef223182e3bb1e72c5
I’ve started organizing different scratch projects as polylith components. I stole the idea from someone here but don’t remember who. :thinking_face: It’s been working quite well.
https://gist.github.com/ericnormand/6bb4562c4bc578ef223182e3bb1e72c5
#!/usr/bin/env sh
#_(
#_DEPS is same format as deps.edn. Multiline is okay.
DEPS='{:deps {seesaw/seesaw {:mvn/version "1.5.0"}}}'
#_You can put other options here
OPTS='-J-Xms256m -J-Xmx256m -J-client'
exec clojure $OPTS -Sdeps "$DEPS" -M "$0" "$@"
)
(use 'seesaw.core)
(native!)
(def f (frame :title "Test"))
(-> f pack! show!)
then you chmod the file and run it from bash
This works because this top segment happens to be both valid bash and valid clojure
I see woodstock already linked this too
If I recall @U04V70XH6 helped me adapt this a little while ago to use the -X
parameter so that you can use individual functions from a file but I happen to have that computer in a storage unit
And apparently I don’t know how to back things up to the internets
Does anyone know any tools for recording the network activity coming out of an application? I know tools.deps is based on maven aether and I could read the code to know whats happening behind the scenes but i'm looking to brute force reverse engineer how stuff like VersionRangeRequest work
if you are on linux maybe you can do something like strace -f -e trace=network clj 2>&1 | grep sin_addr
to start clojure and see what it is connecting to. And then use wireshark
to look at the traffic
no idea about macos, but there are probably some gui apps that constantly monitor network activity per app
what about https://www.wireshark.org/?
maybe you can do it just with wireshark, you can capture and filter out all the noise before starting the app, when you run the program you should mostly be seeing what the new process is sending
although tbh, trying to reverse engineer via spying on the network calls rather than reading docs or source seems like the hard way to do it
It’s all just http calls, so an http proxy should be sufficient
I believe it’s requesting the version metadata file from each repository, then doing a local computation
Note that not all repos publish the file so this is a possibly incorrect computation
For HTTP/S traffic something like https://mitmproxy.org/ might be easier to deal with than wireguard
I ended up getting most of what i was looking for with clj -
1. maven2/dev/whatever/maven-metadata.xml
fails
2. dev/whatever/maven-metadata.xml
succeeds
3. then maven2/dev/whatever/0.0.1/whatever-0.0.1.pom
succeeds
4. and it gets the artifact it wants from maven2/dev/whatever/0.0.1/whatever-0.0.1.jar
in the output it doesnt say the domain, but the package im testing is only published to central - so one of those urls. clojars might work differently
I think due to history there are a variety of places that metadata can be?
it would probably be too much to ask from the universe to assume that history is documented, right?
I don’t know where that’s documented, but would search for “maven repository layout”
Or read the code