This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-11
Channels
- # adventofcode (116)
- # aleph (10)
- # announcements (2)
- # beginners (67)
- # boot (3)
- # calva (17)
- # cider (8)
- # cljdoc (27)
- # cljsrn (6)
- # clojure (144)
- # clojure-austin (3)
- # clojure-boston (1)
- # clojure-dev (25)
- # clojure-europe (4)
- # clojure-italy (26)
- # clojure-losangeles (4)
- # clojure-nl (28)
- # clojure-russia (1)
- # clojure-uk (34)
- # clojurescript (130)
- # cursive (20)
- # datomic (69)
- # emacs (14)
- # figwheel-main (2)
- # fulcro (31)
- # graphql (3)
- # hyperfiddle (3)
- # jobs (1)
- # jobs-discuss (1)
- # kaocha (1)
- # leiningen (2)
- # lumo (2)
- # nrepl (1)
- # off-topic (182)
- # onyx (5)
- # re-frame (88)
- # reagent (12)
- # reitit (2)
- # ring-swagger (13)
- # shadow-cljs (136)
- # tools-deps (28)
- # vim (4)
(defn create-wrap-rebl-sender
[transport-class]
(fn wrap-rebl-sender
[{:keys [id op ^transport-class transport] :as request}]))
I’m trying to create a function that dynamically returns a function with a type hint based on the class given as an argument. Any ideas how to make that work?
type hints are static information that directs the compiler in method resolution, in the dynamic environment (runtime) code has already been generated so it does nothing
at the macro level maybe, but you shouldn't be dealing in function objects, but forms that evaluate to functions
Thanks for the insight. However, I just realized this approach would not accomplish what I want anyway.
Is there a way to persist java objects? I'm using a java library for some crypto stuff, and one of the things I need to keep around is a com.codahale.shamir.Scheme
, and I'm not sure how to approach storing it.
@datran It looks to me like you can easily recreate a Scheme
from random
, n
, and k
values? And SecureRandom
(the type of random
) is Serializable
so you should be able to persist that (and the simple values n
and k
).
So I want to share the code between the modern nrepl\clojure.deps version with the leiningen version. The implementations are the same but the imports are from different places. How can I share the implementation between the two?
@jayzawrotny here's how cider-nrepl does it. https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/version.clj#L6 Waiting on a leiningen release and then slim it down to only one.
it gets hairy making sure the piggieback/nrepl/figwheel versions are all nrepl aware through the whole eval chain
@seancorfield do you know where I can learn more about Serializable
(protocol, I assume)? I'm new to java interop and I'm not sure where to look for documentation about that
okay, so it looks like you convert it to an ObjectOutputStream
and then to a byte stream.
is there some way to manually close a go-loop? it's not hitting the recur path, but its also not closing. 😕
to see an example, there's technomancy's grenchman project. He also has a frontend in fennel (a lisp on top of lua) but I don't recall the name off hand
Can spec
detect duplicates in some nested map fields? like 'city_id' should be unique in nested maps. Can it be done with spec?
@masta maybe you can use spec
with https://github.com/nathanmarz/specter ? 🙂 you might be able to select then count
haven't used specter
myself, but it sounds like the kind of use case it'd be good for
using spec.alpha
and spec.gen.alpha
, I get:
> (gen/such-that #(not= "" %) (gen/string-alphanumeric))
AssertionError Assert failed: Second arg to such-that must be a generator
(generator? gen) clojure.test.check.generators/such-that (generators.cljc:346)
The spec.gen.alpha combinators take generator thunks, not generators (to allow a hook for dynaloading)
I can’t tell from what you’re doing if you are using spec gen or test check gen, or a mixture
But they differ in this way
(gen/such-that #(not= "" %) #(gen/string-alphanumeric))
I’m on my phone, so can’t check this but that’s what I would expect
> (gen/such-that #(not= "" %) #(gen/string-alphanumeric))
AssertionError Assert failed: Second arg to such-that must be a generator
ok, opened a repl. I was wrong about the function wrapping - the spec gen string-alphanumeric returns a function so it was right originally
user=> (gen/sample (gen/such-that #(not= "" %) (gen/string-alphanumeric)))
("32" "8" "Z" "IkcC" "eLq" "n" "87nE" "edj" "166k" "E2")
if you were using the test.check.gen, I think you would want
(gen/such-that #(not= "" %) gen/string-alphanumeric)
alright, thanks. I wasn't using test.check.gen, but apparently it "leaked" in somehow, then
anybody familiar with the built-in http client in re-frame
? or cljs-ajax
as it's heavily based on that?
i want to know what the correct configuration map for a post
request uploading a pdf
file ought to be
Hi; I'm trying to get in to thi-ng/geom since my dog ate my geometry/woodworking notebook. One of the first things I'm trying to do is "create a line, then create another line constrained by a shared point and an angle between it and the first line". Is that something geom is good at, or am I thinking too much like CAD-style constraints here? (I know how basic trig works; but if you're familiar with how CAD usually works then you probably know why basic trig isn't the answer :-))
Yes, I believe what you're trying to achieve is the job of a constraint solver, which might not be present in geom
I'd really like to do Clojure CAD but the Nice(TM) CAD program is Fusion 360, and they deprecated JS scripting, leaving C++ and Python. Despite knowing a fair bit of Clojure + JNR I have 0 intention of dealing with a C++ API being called over the C ABI from JNR, because this was supposed to be fun 😉
You could always use OpenSCAD (starts at about 17:30 in) https://www.youtube.com/watch?v=uk3A41U0iO4 🙂 AutoCAD still has an active JS API (https://df-prod.autocad360.com/jsapi/v3/docs/contents.html), or you could always try ClojureCLR for it - but I have no idea if what you're trying to do can be done there or not. If you can get useful geometry/woodworking CAD working in that would be way cooler, though.
Yeah, I looked at that a while ago, one of the things I don't love is that I'm not really trying to produce, like, an STL I can go 3D print per se: I'm trying to produce sketches for my notebook, so lots of dimension lines and labels that are helpful for when I take it to a tablesaw. OpenSCAD AFAICT doesn't do that at all. (Not a criticism! It's a solid modeler by defintion and I think the punchline is just "what you wanted is a lot closer to dr geo than openscad".)
Oh hey, apparently someone wrote that for OpenSCAD: https://www.thingiverse.com/thing:280469
Yeah, OpenSCAD is also pretty unpolished if you are used to something more commercial - I tried playing with it when I was thinking of building a Dactyl and by far the coolest part was how much work went in to use Clojure with it 🙂 I found the time it took to render (at least for the Dactyl) really painful, but that might just be for a more complicated model. I couldn't find anything that jumped out at me as any better (QCAD or TinkerCAD seem at least have a usable JS API, but everything else I could find or know of would be a pain to get to work with Clojure).
i also have a hard time believing that "spit entire model file, load from scratch" is a great idea when you have something non-trivially sized
Yeah, definitely. Just put in a talk proposal for next Conj “Writing a CAD Program for Woodworking in Clojure” (which I’m sure would be automatically accepted) and then you’ll have something nice to use right after the talk is due.
hey guys, can you guy help me with good clojure libs for working with graph algorithms?
and depending on your exact needs, https://github.com/Engelberg/ubergraph supports some additional graph features on top of what Loom does
Oh loom looks cool
I had manually written some graph algorithms already
We've had great success with Loom. The core of my project is a DAG, thus making Loom a very key library.
Is there anyway to use aliases on a local procurer in deps edn? e.g. parent project foo depends on {:local/root “bar”} but also wants to include alias “baz” from bar
aliases affect the set of dependencies to resolve, so there would be a bit of a logical cycle if aliases affect dependencies and dependencies affect available aliases
so there are no plans to support a way to use aliases from transitive deps
thanks. sounds like I am barking up the wrong tree to be generating multiple builds/artifacts within one deps.edn file
trying to do exactly this: https://stackoverflow.com/questions/53731940/using-static-methods-from-clojure
Clojure does not even sees the static method does not matter if i implement it in Java or Clojure
EchoHandler::handleEcho isn't a static method, what happens is javac looks at the type and generates an adapter from the interface expected to call the static method
so you need look at the docs to figure out which interface the .json method takes, and use reify to create an instance of that interface which invokes whatever static method
alright, i would just ivent a time machine and fly back to 1995 and murder the guy who created static, abstract, single abstract and co
the EchoHandler::handleEcho syntax for automatically generating the adaptors is newish (maybe in java 7 or 8)
problem is that Clojure did not keep up with these and in the interop there is nothing about it and nobody talks about how should we do these
in this case the sam stuff is all generate by the java language compiler and the jvm doesn't have anything special to support it
public void json(ReqHandler handler) {
HttpHandlers.register(http, routes, verb, path, jsonOpts(), handler);
}
public interface ReqHandler extends OneParamLambda<Object, Req> {
Object execute(Req req) throws Exception;
}
can i simplify this somehow in Java and have a small amount of Java code so that Clojure has a better time?
what are people using nowadays to package up and deploy an app? i’ve seen some combination of thin jars, uberjars, tools like deps-star, cambada, etc.. i’ve also read about strategies to make thin jars and upload each individual dep into a heavily cached system (like https://github.com/HubSpot/SlimFast). just curious what’s been working for people and what’s a real pain. (for example, cambada uberjar worked great until I added a dep that used a signed jar, and now uberjars aren’t going to work without some filtering mechanism)
uberjars inside of docker
in what sense? do you just upload a dockerfile and not bother with a jar? or do you put an uberjar inside a docker file?
my dockerfile is responsible for building the uberjar, the final docker image that is output just has an uberjar and java and runs that
FROM java:8-alpine
WORKDIR /app
COPY target/*standalone.jar .
CMD java -jar *standalone.jar
right now that’s what i’m working with, but i wonder if there’s some way to not have to ship MBs of dependencies all over the networki use something like
FROM alpine:latest AS build
RUN apk add java...
RUN boot build uberjar
FROM alpine:latest
RUN apk add jre
COPY --from=build uberjar /app
yeah i have lein but pretty much the same
@UAEFFG05B do you build docker images in a CI environment?
i currently have an issue where my builds on circleci are always redownloading deps
i've been trying to decide if i should mount in a cached m2 dir as volume
not redownloading dependencies from the internet on every build
so to get around installing your deps you can do something like:
FROM alpine:latest AS build
COPY deps.edn /app
RUN ... install deps only
COPY . /app # copy rest of app
RUN lein uberjar
that way you will only need to reinstall your deps if that first COPY
layer has changed
@U0W0JDY4C i enabled docker layer caching in cirlce ci (have to pay for it) which helps some
between a pom file and caching dirs on circle we’re getting pretty good caching, just make sure to pre-fix your cache keys with v1
for emergencies
- save_cache:
key: v1-deps-{{ checksum "pom.xml" }}-{{ .Branch }}
paths:
- ~/.m2
something like that@UAEFFG05B the problem with that approach is my project.clj file changes on most builds cause the version gets bumped. maybe if i switched to deps.edn that would solve my issue. haven't figured out how well that plays with lein
@U0W0JDY4C do you use slimfast with Clojure?
@U49Q4205T no, i was just looking to it for inspiration. i didnt want to tangle with mvn at all avoidable
@U0W0JDY4C yeah i use the circleci cache like that which is good for test run jobs, but docker builds i'm not currently mounting that .m2 cache into the docker file as a volume
but this https://product.hubspot.com/blog/the-fault-in-our-jars-why-we-stopped-building-fat-jars pretty clearly explains the issue with big-fat-jars floating around your network (especially on a big team)
@U0K6PH6TU sure that makes sense. we use boot, so that isnt an issue and we never build anything other than 0.1.0-snapshot 🙂 .. the git commit SHA is our version number
@U0W0JDY4C right
@UAEFFG05B yeah maybe i need to switch to boot and deps.edn heh
i’ve so far been able to skip boot/lein entirely on my latest proj, getting by with just deps and some shell/make
@UAEFFG05B looks awesome
that would definitely solve my problem
thanks!
well. assuming it plays nice with lein-nvd and other plugins