This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-23
Channels
- # announcements (7)
- # babashka (40)
- # babashka-sci-dev (74)
- # beginners (74)
- # calva (31)
- # cider (11)
- # clj-kondo (22)
- # cljs-dev (1)
- # cljsrn (1)
- # clojure (70)
- # clojure-brasil (3)
- # clojure-dev (12)
- # clojure-europe (39)
- # clojure-nl (2)
- # clojure-norway (15)
- # clojure-uk (9)
- # clojurescript (69)
- # community-development (2)
- # conjure (1)
- # core-async (3)
- # cursive (1)
- # data-science (1)
- # datalevin (13)
- # datomic (17)
- # emacs (42)
- # events (1)
- # fulcro (16)
- # graphql (9)
- # helix (1)
- # holy-lambda (14)
- # honeysql (2)
- # hugsql (3)
- # hyperfiddle (5)
- # kaocha (10)
- # lsp (41)
- # luminus (5)
- # malli (7)
- # meander (3)
- # membrane (47)
- # off-topic (23)
- # podcasts (2)
- # polylith (34)
- # rdf (4)
- # re-frame (2)
- # releases (2)
- # remote-jobs (1)
- # ring (16)
- # shadow-cljs (111)
- # spacemacs (6)
- # test-check (2)
- # tools-deps (19)
hi, if I want to use curl (https://github.com/babashka/babashka.curl) in babashka to send http POST request of the content of "pic 1", how could I do that? How could I put "content-type" when calling curl/post
And is it required to convert map to json like I did using cheshire.core
(ns )
(require '[babashka.curl :as curl])
(require '[cheshire.core :as json])
(def req
(json/generate-string {:apiKey "xxxxx"
:userId "xxxxx"
:name "Personal"}))
(curl/post "" req)
I could use online api test tool to get the response successfully after http POST (like pic. 3)
(btw, the "Raw" tab in the pic 3 is pic 1)The next version of babashka is going to have support for pods in bb.edn:
{:pods {org.babashka/go-sqlite3 {:pod/version "0.1.0"}}
:tasks {:requires ([pod.babashka.go-sqlite3 :as sqlite])
create-db {:task (do (sqlite/execute! "/tmp/foo.db"
["create table if not exists foo (the_text TEXT, the_int INTEGER, the_real REAL, the_blob BLOB)"]))}}}
Thanks to @cap10morgan .
This is already available on master. To try it out:
bash <(curl ) --version 0.7.9-SNAPSHOT --dir .
Also, when you declare the pods in your bb.edn, you no longer have to use load-pod
in your code, the pod is automatically loaded whenever a related namespace is required.
(ns
example-ns
(:require [clojure.core.async])
(:import
[clojure.core.async.impl.channels
ManyToManyChannel]))
(defn -chan? [x]
(instance? ManyToManyChannel x))
I'm trying to do the same trick from tasks.clj but why
Message: Unable to resolve classname: clojure.core.async.impl.channels.ManyToManyChannel
This class isn't exposed, but I will do that, since there is no other way to check if a chan is a chan...
@benjamin.schwerdtner Hmm, I guess you can still do this:
(.getName (class (a/chan))) ;;=>
"clojure.core.async.impl.channels.ManyToManyChannel"
and then compare the stringthe following code:
(async/<!!
(async/go
(async/alts!
[(async/go
(async/<! (async/timeout 100))
10)])))
on babashka: nil
on jvm: [10 #object[clojure.core.async.impl.channels.ManyToManyChannel 0x1343db14 "[email protected]"]]Workaround:
(async/<!!
(async/thread
(async/alts!!
[(async/thread
(async/<!! (async/timeout 100))
10)])))
Hey y'all! Is there a way to get a stacktrace that's not just the babashka/sci interpreter?
(defn evil []
(/ 1 0))
(try
(evil)
(catch Throwable t
t))
Ah, gotcha--so if I want my program itself to catch an error and print a stacktrace, I'm not gonna have access to the babashka frames?
OK! Just wanted to make sure I wasn't missing something. Thanks for Babashka! 🙂
Not sure how, since not all exception types take extra data and if you use try/catch you just get the "naked" exception. If you would not catch the exception, then the SCI evaluation throws an ex-info with the "frames" which can be printed using sci/stack-trace and sci/format-stacktrace
Right, right. I'm doing something a bit weird and writing a long-running daemon (well, 10 seconds) in Babashka--it needs to log errors and keep running
@U038RGYDGUR FYI, going on in another thread about this. I think I may have found a solution. https://clojurians.slack.com/archives/CLX41ASCS/p1657302458137849
This bottoms out in
[[clojure.lang.Numbers divide "Numbers.java" 188]
[clojure.core$_SLASH_ invokeStatic "core.clj" 1029]
[clojure.core$_SLASH_ invoke "core.clj" 1022]
[sci.impl.analyzer$return_call$fn__8904 invoke "analyzer.cljc" 1036]
[sci.impl.evaluator$eval invokeStatic "evaluator.cljc" 334
... which makes it kind of hard to tell where the error actually happenedslight update/improvement on bash completion
# babashka tasks completer
_bb_complete() {
BB_TASKS=$(bb tasks|bb -io '(->> *input* (drop 2) (map #(-> % (str/split #" ") first)))')
BB_HELP=$(bb help|bb -io '(->> *input* (map #(->> % (re-find #"^ ([-a-z]+)") second)) (filter some?))')
COMPREPLY=($(compgen -W "$BB_TASKS $BB_HELP" -- "${COMP_WORDS[$COMP_CWORD]}"))
}
complete -f -F _bb_complete bb # autocomplete filenames as well
Awesome! That looks similar to this PR https://github.com/babashka/book/pull/46/. but yours has more I think, so this is a superset of that PR?
If so, then maybe we could merge your PR or first merge his PR and then yours on top
mine is quite more progress from that change to use compgen it does not use tail or sed, just bb it is hard for me to submit PRs right now i would just overwrite it with my version
You could also post yours here: https://github.com/babashka/babashka/wiki/Shell-completion