This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-27
Channels
- # admin-announcements (1)
- # announcements (1)
- # babashka (16)
- # beginners (222)
- # bristol-clojurians (6)
- # calva (13)
- # cestmeetup (5)
- # cider (19)
- # cljs-dev (2)
- # cljsrn (4)
- # clojure (65)
- # clojure-europe (31)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojure-uk (33)
- # clojurescript (64)
- # community-development (5)
- # core-async (18)
- # cursive (15)
- # datomic (6)
- # devcards (1)
- # emacs (18)
- # figwheel-main (102)
- # fulcro (51)
- # graalvm (2)
- # helix (8)
- # instaparse (33)
- # jobs (8)
- # jobs-discuss (3)
- # leiningen (42)
- # off-topic (88)
- # pedestal (15)
- # re-frame (18)
- # reagent (26)
- # reitit (15)
- # rum (3)
- # shadow-cljs (119)
- # spacemacs (9)
- # sql (2)
- # tools-deps (7)
I want to set a color with rgba in my clojure code. How do I do it?
Like {:background-color rgba(0,0,0,0.5)}
Are you talking about a web app or a terminal app?
web app
This solved it: (str "rgba("255","0","0","0.2")")
why not just “rgba(0,0,0,0.5)”
Yeah, much better. Thanks!
there is also https://github.com/thi-ng/color
(require '[.color.core :as col])
@(col/as-css (col/rgba 255 0 0 0.2))
if you need more controlthanks, i needed this
but why is the whole thing only shell
this lib is written using literate programming
interesting
google cloud functions just support java11 runtime, I try to run clojure app on it but got the error. Follow the jave sample from this https://github.com/GoogleCloudPlatform/functions-framework-java, I have this class
(ns cloudfn.core
(:gen-class
:implements [com.google.cloud.functions.RawBackgroundFunction]))
(defn -accept [this s ctx]
(prn s))
then, after build to uberjar file, run function by using the Functions Framework jar directly, I got error (same error as deploy to cloud function)
% java -jar java-function-invoker-1.0.0-alpha-2-rc5.jar --classpath target/cloudfn-0.1.0-SNAPSHOT-standalone.jar --target cloudfn.core
2020-05-27 16:41:36.206:INFO::main: Logging initialized @205ms to org.eclipse.jetty.util.log.StdErrLog
Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.lang.Namespace.<init>(Namespace.java:34)
at clojure.lang.Namespace.findOrCreate(Namespace.java:176)
at clojure.lang.Var.internPrivate(Var.java:156)
at cloudfn.core.<clinit>(Unknown Source)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at com.google.cloud.functions.invoker.NewBackgroundFunctionExecutor.forClass(NewBackgroundFunctionExecutor.java:71)
at com.google.cloud.functions.invoker.runner.Invoker.servletForDeducedSignatureType(Invoker.java:362)
at com.google.cloud.functions.invoker.runner.Invoker.startServer(Invoker.java:290)
at com.google.cloud.functions.invoker.runner.Invoker.main(Invoker.java:140)
Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class, clojure/core.clj or clojure/core.cljc on classpath.
at clojure.lang.RT.load(RT.java:462)
at clojure.lang.RT.load(RT.java:424)
at clojure.lang.RT.<clinit>(RT.java:338)
... 13 more
Idk why clojure can't be load here?I haven't tried it yet, but have you tried to give class a name and add --entry-point parameter? pointing to that class? https://cloud.google.com/blog/products/application-development/introducing-java-11-on-google-cloud-functions I'm sure you have to specify entry point for functions somehow.
How did you package your app?
Doesn't that exception indicate clojure itself hasn't been included in the jar?
@U050PGQ9J Did you able to solve this ?
I have a need for backend WebSocket client library. Any recommendations? There seems to be multiple opinions online, but no definitive answer 🙂
Jetty has one. (Add: gniazdo is working, weve used it too)
We use https://github.com/stalefruits/gniazdo in production. Can't say it's the best thing out there but it gets the job done. Apart from a memory leak I had to deal when using custom low-level client - we haven't had issues with it.
does anyone have a templating library like yogthos/Selmer but with whitespace control? Template tags keep leaving up empty lines which breaks stuff for me.
@roklenarcic selmer doesn't insert any whitespace afaik. I usually have the opposite problem :)
You might need to do something like {{A}}{{/A}}{{B}}{{/B}}
to make sure whitespace does what you want.
It doesn’t add whitespace, but if you put if
or for
tags or endif
or endfor
tags in their own line for readability they will leave behind the empty line
so then I stack so many tags into the same line to prevent empty newlines, that the line gets really really really long, which makes the template unreadable, which makes template pointless
in Jinja templates you can tell it to remove whitespace preceeding or succeeding the tag
or both
Jinja templates being the Python library Selmer is based on
Check this out! Newest version of #reveal (Read Eval Visualize Loop) seamlessly supports chart views for chartable data! And they are not just a picture, every data point can be explored further as a value!
The repo is here: https://github.com/vlaaad/reveal
is there a screenshot of some of the chart stuff available?
oh whoops. didn’t realize the charts.gif wasn’t just the github auto image for the repo
Is this the fastest way to write something like this?
(persistent!
(reduce
(fn [acc itm]
(assoc! acc itm itm))
(transient {})
(range 1e4)))
This is just an example, my real case requires something like this, doing things in the reduce.
then yes, you're reducing over the source and doing amortized adds in batches via transient
Cool 🙂 Tried a bunch of different ways and found this to be much faster than everything else.
transduce
can be convenient here, as you can put the persistent!
call into the completion arity
but if breaking out part of the code into a transducer doesn't fit, reduce
is fine
and you'll do best if your source coll is something self-reducible (map, vector, few other things)
range, like the example :D
I was assuming that was for demo purposes :)
importantly, NOT a seq if you can avoid it
I just found it amusing that range is also one of the self-reducing inputs
yeah, range, cycle, repeat, and iterate all self-reducible too
there's also clojure.core.protocols/CollReduce (a protocol) if you don't control the class impl
(a good opportunity to mention that next.jdbc/plan
returns an IReduceInit
🙂 )