Fork me on GitHub
#clojure
<
2018-05-29
>
seancorfield00:05:18

@twashing I think your "completing" arity needs to do something with state (the [accumulator] arity).

seancorfield00:05:03

Hmm, you're returning c' from the 2-arity branch... that would lose the accumulator value... is that what you intended?

twashing00:05:34

@seancorfield I’m wanting to return the joined values that are in c', to the result list.

twashing00:05:38

So part B, vs part A.

...
;; A
record {:uuid 1, :last-trade-price 11.1}
record {:uuid 2, :last-trade-price 11.2}
record {:uuid 1, :last-trade-price-exponential 10}
record {:uuid 2, :last-trade-price-exponential 11}
record {:uuid 3, :last-trade-price 11.3}
record {:uuid 3, :last-trade-price-exponential 12}

;; B
c' {:tick-list {:uuid 1, :last-trade-price 11.1}, :ema-list {:uuid 1, :last-trade-price-exponential 10}, :sma-list {:uuid 1, :last-trade-price-average 10.1}}
c' {:tick-list {:uuid 2, :last-trade-price 11.2}, :ema-list {:uuid 2, :last-trade-price-exponential 11}, :sma-list {:uuid 2, :last-trade-price-average 10.2}}
c' {:tick-list {:uuid 3, :last-trade-price 11.3}, :ema-list {:uuid 3, :last-trade-price-exponential 12}, :sma-list {:uuid 3, :last-trade-price-average 10.3}}

sveri06:05:53

does someone know if its possible to load a keras model in clojure and make predictions with it?

xtreak2906:05:09

Might be possible with Cortex. Below links from quick googling that might be helpful : Reddit post : https://www.reddit.com/r/Clojure/comments/5fo9ym/machine_learning_importing_a_keras_model_into/ Archive link since original link points to 404 : https://web.archive.org/web/20170419160312/http://benkampha.us/2016-11-29.html

sveri06:05:34

Found the article: http://benkampha.us/posts/2016-11-29/ but is has a disclaimer: Note: this post describes a path that no longers work in Cortex, which is itself falling out of mainteance at this point (May 2018). Many of the recommendations also no longer apply as I’m using a mixture of TensorFlow and MXNet for model deployment today, rather than Cortex.

👍 4
vemv07:05:33

how to I expand/resolve this to an absolute path? "/Users/me/foo/../bar"

jgh08:05:34

i see Java has a class called “Paths”, you could maybe run it in and out of that?

vemv08:05:52

yeah I'm playing with that... no luck (-> "/Users/me/foo/../bar" (Paths/get (into-array String [])) .toAbsolutePath str) ;; -> dumb result which still has '..'

jgh08:05:16

user=> (require '[ :as io])
nil
user=> (require '[clojure.string :as str])
nil
user=> (def path "/Users/james/foo/../bar")
#'user/path
user=> (-> (apply io/file (str/split path #"/")) (.getCanonicalPath))
"/Users/james/bar"

jgh08:05:28

ah damnit

jgh08:05:43

the canonicalfile one works but absolutepath returns the thing without it collapsed

jgh08:05:34

there we go…getCanonicalPath is the one

vemv08:05:10

Nice! Had gotten this one meanwhile

(-> the-path (Paths/get (into-array String [])) (.toRealPath (into-array [java.nio.file.LinkOption/NOFOLLOW_LINKS])) str)
Looks like I'll go for yours 😉

rascio13:05:52

Hi here! I studied clojure in the past months, and in the following weeks I would like to propose it to my company to rewrite an old background job we have. The alternative to Clojure would be to rewrite it using JavaRx. For what I understood the async module plus the transducers can do the same job as RxJava in clojure, but the fact that I can't find any tutorial/guides/resources about it make me doubt that I'm not on the right track. Am I looking at the right modules to do it? Do you know any resource to do it?

lwhorton15:05:11

while I would always encourage someone to use clj over java, i would be concerned about rewriting a whole process flow without someone who has more than “past months” of expertise

lwhorton15:05:00

especially if this is the first introduction of clj to your company. a rewrite seems like a disaster waiting to happen where the language will take the blame of any failures

lwhorton15:05:56

try to sneak it in with something small, manageable, and predictable.. then grow it to tackle larger and larger projects

rascio20:05:02

good advise, I was thinking about making a poc of it to test clojure for a "real" use case, but no plan to have it in production in the near future. The use case is small, and has very few dependencies on other services, so that I can focus more on the "clojure" part than the "integration" one.

rascio09:05:26

about the transducers and async instead, do you know any resource from which I can study them?

lwhorton15:05:03

sorry I don’t know anything other than the guide on the clojure site… they’re a tricky thing to wrap your head around

valtteri16:05:36

Is it a bad idea to have keywords that begin with a number? Like :1234

pesterhazy16:05:02

you won't be able to destructure them

mg16:05:02

It’s bad-ish, in that it will prevent you from doing :keys destructuring and cause issues any other time you try to turn it into a symbol

pesterhazy16:05:01

but clojure.core/keyword will happily create kws for any string, including "", so by that definition anything goes

Alex Miller (Clojure team)16:05:42

I believe at the moment, clj allows them and cljs does not

Alex Miller (Clojure team)16:05:16

this is a long unresolved point of syntax

Alex Miller (Clojure team)16:05:54

I think it’s unlikely we will ever make them stop working in clj

pesterhazy16:05:57

works in cljs too

> (-> "1a" keyword name keyword)
:1a

pesterhazy16:05:18

at least in bootstrapped cljs

valtteri16:05:02

They seem to work in both clj and cljs. Emacs doesn’t highlight them as keywords and it got me worried.

pesterhazy16:05:36

yup works in JVM cljs as well

valtteri16:05:05

As it seems like it’s gray area I think I’ll use strings instead. Thanks for the answers @pesterhazy @michael.gaare @alexmiller

Alex Miller (Clojure team)16:05:33

I was talking about reader support, not the keyword function

Alex Miller (Clojure team)16:05:59

maybe this got changed though in 1.10

noisesmith16:05:23

when compiling non-self-hosted cljs you are still running in clojure, so it accepts keywords clojure does. if you read a keyword using cljs code (eg read, edn/read) cljs will reject those keywords

justinlee16:05:56

if you’re parsing from json (or converting from any javascript object for that matter) it is definitely possible to get numeric keyword keys in a map in clojurescript:

(js->clj #js {"1" "val"} :keywordize-keys true)
=> {:1 "val"}

justinlee16:05:25

that’s from a browser connected cljs repl

noisesmith16:05:37

right, keyword function accepts any garbage

Alex Miller (Clojure team)16:05:14

that is… “lovingly accepts all data without preconceptions”

😄 16
martinklepsch19:05:43

The other day when working with SQLite I had to do this: (keyword "last_insert_rowid()") 😄

‼️ 4
plins21:06:16

@seancorfield maybe its worth mentioning this on the sqlite tips and tricks section? is this something I could a PR for?

seancorfield21:06:25

@U3QUAHZJ6 Yeah, the Tips and Tricks page should probably list the "generated key" name for all the databases... https://github.com/seancorfield/next-jdbc/blob/develop/test/next/jdbc/sql_test.clj#L94-L101 might be a helpful jumping off point for the DBs that it gets tested against.

plins01:06:45

going to open a PR for it tomorrow thanks a lot!

2
noisesmith16:05:46

but the cljs reader is more picky than the clj reader

noisesmith20:05:23

I remember this being the case, but it could have changed...

justinlee16:05:03

oh i understand what you and alexmiller are saying now 🙂

sobel17:05:36

would it be horrible if i wrote a transducer that mostly depended on a state-transition chart bound into it at creation?

sobel17:05:23

just trying to sorta wrap my head around using them for parsing

martinklepsch18:05:15

I did some refactoring to support snapshots earlier, will look into it. 1s

bhauman18:05:51

no rush, I just wanted to get you the feedback

martinklepsch18:05:22

Greatly appreciated, fix is being deployed :hugging_face:

bhauman18:05:49

friggin sweet 🙂

martinklepsch18:05:15

doing some manual clojars-path stuff which I probably shouldn’t and forgot that dots in group-id are causing new directories… https://github.com/martinklepsch/cljdoc/commit/44990648d29b418467367a09eb9e70a2a2bc94f7

martinklepsch18:05:01

neat library too, could use this for the cljdoc configuration file

bhauman18:05:02

oh I'm going to have to add a bunch of ^:no-doc metadata

bhauman18:05:41

is ^:no-doc meta data respected?

martinklepsch18:05:20

I’m using codox for the actual analysis so I think it should.

martinklepsch18:05:06

I’d also like to experiment with emphasizing vars that seem well-documented and perhaps de-emphasizing others — if you have thoughts on that, lmk

bhauman18:05:31

I think that is just plain smart

martinklepsch18:05:24

I’m a bit undecided as to where to draw the line and what that would actually look like, will have to come up with some variants…

huthayfa20:05:35

has anyone used scjsv jsonSchema validator

caleb.macdonaldblack23:05:10

Do people make much use of dependency injection libraries such as integrant, component or mount?

myguidingstar23:05:33

I use Duct (which is based on integrant) everyday. Very happy with it

👍 4
sobel23:05:35

i've been looking at codependence for that

hiredman23:05:08

I use component whenever I start writing a new service