This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-05
Channels
- # announcements (23)
- # babashka (23)
- # beginners (48)
- # calva (41)
- # clj-kondo (41)
- # cljs-dev (75)
- # cljsrn (5)
- # clojure (85)
- # clojure-europe (46)
- # clojure-nl (2)
- # clojure-spec (70)
- # clojure-uk (4)
- # clojurescript (52)
- # core-async (2)
- # cursive (16)
- # datahike (2)
- # datomic (4)
- # emacs (15)
- # figwheel-main (2)
- # fulcro (5)
- # gratitude (5)
- # helix (14)
- # introduce-yourself (2)
- # jackdaw (13)
- # keyboards (2)
- # lsp (8)
- # luminus (5)
- # malli (3)
- # meander (12)
- # nextjournal (52)
- # off-topic (19)
- # other-languages (1)
- # overtone (3)
- # pathom (4)
- # podcasts-discuss (1)
- # re-frame (6)
- # reitit (1)
- # releases (2)
- # ring (3)
- # sci (22)
- # shadow-cljs (3)
- # specter (1)
- # testing (3)
- # tools-deps (100)
- # uncomplicate (2)
Nice to meet you. I have a question about a description of project.clj, leiningen. How do I specify the latest of master in dependencies in the project.clj file? I reported a bug, and the author fixed that in https://github.com/sicmutils/sicmutils/pull/383. I want to use this fixed version, but I do not know how to do.
The Clojure CLI (and deps.edn
) can easily use git deps but Leiningen requires a plugin. I haven't used Leiningen for six years at this point but I believe there's a lein-git-deps
plugin (although it hasn't been touched for 8 years?). Maybe ask in #leiningen about git deps? Or switch your project to the CLI and deps.edn
?
• clone the repo
• in project.clj
, change defproject sicmutils "0.19.2"
to defproject sicmutils "0.19.2-SNAPSHOT"
• run lein install
in the repo dir
• in your project, change the dependency version to “0.19.2-SNAPSHOT”
I’m trying out migratus and it’s showing me how much I don’t understand about how to manage a database connection in a clojure app.
I read through https://clojureverse.org/t/how-to-manage-database-connection-in-clojure/5067/5 and I’m still pretty confused on how I should go about managing a db connection (without using a 3rd party library.. I’ll eventually get to component/integrant/etc)
The problem rn is that when I call miginit
more than once in the REPL, I get a This connection has been closed
. How do I keep my db connection alive and available without a third party library?
Sounds like Migratus is closing the connection? I'm not familiar with that library but I would say using atoms to handle datasources and connections seems wrong to me.
Looks like Migratus still uses java.jdbc
rather than next.jdbc
so your :db
key should be a "db-spec", which is a hash map that describes your db -- basically :db db-config
ought to do it.
You don't need any of that get-datasource
/ get-connection
stuff, as far as I can see @U01JYKT6ENL
Hm okay. if I don’t have the get-datasource/connection
fns, when/where should I create those? just in the main- fn?
You don't need any of that for Migratus.
Using next.jdbc
functions with Migratus won't help you since it uses the older java.jdbc
library.
We can talk about using next.jdbc
in a program separately from Migratus (but that discussion better belongs in #sql).
db-config
is your next.jdbc map. Migratus says it takes a db connection so I was passing the db connection retrieved from jdbc/get-connection
And sounds good, thank you.
Migratus docs specifically show that it takes a db-spec hash map, albeit the old-fashioned one that even with java.jdbc
has been outdated for years.
(def config {:store :database
:migration-dir "migrations/"
:init-script "init.sql" ;script should be located in the :migration-dir path
;defaults to true, some databases do not support
;schema initialization in a transaction
:init-in-transaction? false
:migration-table-name "foo_bar"
:db {:classname "org.h2.Driver"
:subprotocol "h2"
:subname "site.db"}})
that is just the old-fashioned form of
(def config {:store :database
:migration-dir "migrations/"
:init-script "init.sql" ;script should be located in the :migration-dir path
;defaults to true, some databases do not support
;schema initialization in a transaction
:init-in-transaction? false
:migration-table-name "foo_bar"
:db {:dbtype "h2"
:dbname "site.db"}})
gotchya.. so instead of trying to reuse and pass the connection just reuse the db-spec hash map 👍
It’s working well. I can run those migrate commands multiple times from the repl without any errors now!
hello, i have a function in php like this $ret = openssl_decrypt($ret['encData'], 'aes-128-cbc', $key, OPENSSL_DONT_ZERO_PAD_KEY, $key);
, how can i translate this in clojure
Is it possible to have a spec to validate that a value of a map arg has a relationship with another arg? It's my first foray into spec and I'm trying to see what it can do. Whenever I try to extract a value from a map in my spec, I get a NullPointerException, telling me I'm probably doing it wildly wrong or applying a wildly wrong concept:
(defn arg-test
[test-map other-field]
(println test-map)
)
(s/def ::pos-int-val (s/and int? pos?))
(s/def ::map-def (s/keys
:req [::pos-int-val]))
(s/fdef arg-test
:args (s/and (s/cat :test-map ::map-def :other-field ::pos-int-val)
#(< (get-in % [:test-map :test-val]) (:other-field %))))
(stest/check `arg-test)
in that function you are treating %
as if it is a map with keys that are the sequence of arguments. You should confirm what argument is actually passed to that function
My issue was actually that the namespace of the key was incorrect. I got it working by fully qualifying, but I'll do a bit more exploring to figure out a better way. Thank you for the suggestion though. It reminded me that in the world of Clojure, I can easily query into things like the type of % 🙂
yeah. i looked at it and just instrumented the function rather than exercising it like that and made the function just print its argument and return true
I just did some experimenting with instrument and that actually is really useful in figuring out what's going on. Thanks again! 🙂
Hi folks, have an issue with starting new project on osx, with clojure 1.10.3.998 and openjdk 17.0.1 2021-10-19,
after creating a new project
lein new figwheel kotek --reagent
and then running lein figwheel
inside, I get https://gist.github.com/gs/0466a64b568dc2bb39dbba2cbfd9b0ab
Any help appriciated
Is this on an M1 Mac? I'm just looking at the dependencies there (Figwheel / Hawk / Barbary WatchService) and it looks like the latter was originally a port to Java 6 of functionality from Java 7 and neither of those last two libraries have been updated in years).
I've never used lein-figwheel
but I got the impression that it's pretty much deprecated and folks should be using Figwheel Main instead, these days?
There's are three Figwheel-related channels you could try asking in: #lein-figwheel #figwheel #figwheel-main @UNDL444G4
right, its M1. thx will check channels!
I'm guessing the Barbary filewatch library either doesn't have an M1 native impl or it relies on a low-level library that doesn't exist on an M1 Mac... purely a guess tho'...
There should be native filewatch capability in the JDK itself but I don't know if there are updates to Figwheel/Sidecar that depend on that instead of Hawk.
I might try to use figwheel main
then, never used that before.
hi, just experimenting with figwheel-main
seems that the files are not hot-reloading on M1. Anything to fix that?
I’ve run lein new figwheel-main test-app -- +deps --reagent
do I need to have that https://github.com/wkf/hawk ?
I don't use Leiningen so I can't help you. I'm not currently doing ClojureScript so I can't help you with that either. Ask in the channels I pointed you at.
(I haven't used Leiningen for six years and when I was doing ClojureScript some, earlier this year, I was using the Clojure CLI and a non-M1 Mac)
But no, you do not need to add Hawk as a dependency. I only pointed that out because it seems really outdated and it is what lein-figwheel
seems to be using via Figwheel Sidecar. Which is why I pointed you at Figwheel Main since I believe that is actively being maintained.
great, thank you. I had some projects before I’ve switched to M1 and they were working, now need to get back to them… and they are not working anymore 😉
should not have switched to M1 - life would be much more easier
I went through two chipset changes on Mac and they usually have some speed bumps. 680x0 -> RISC and then RISC -> Intel. But I've been in the process of moving completely to Windows over the last few years -- no more Apple products for me!