Fork me on GitHub
#beginners
<
2021-06-03
>
Rob Haisfield00:06:37

Is there some way to get a continuous range (range of floats) instead of a range of integers?

Rob Haisfield00:06:07

I’m trying to create a schema for a data structure and say that -1 to 1 are the range of acceptable values for a valence

dpsutton00:06:52

(range 0 1 0.1)

Rob Haisfield00:06:46

Hmm so that’s another discrete range with a small increment. Is it possible to get a continuous range? I want to say “This value can be any possible value between -1 and 1”

Rob Haisfield00:06:59

Alternatively, I could specify a very small interval and also have a function that would round any values to the accepted interval

dpsutton00:06:02

a predicate satisfies that.

dpsutton00:06:22

not sure what your requirements are, but enumerating lots of floating points sounds weird for those purposes

dpsutton00:06:40

#(<= -1 % 1) or something like that

Rob Haisfield01:06:53

Ooooh that’s good

Martyna Miśkowiec12:06:20

Hey, i'm very-very new to clojure, and i'm having issues installing it on windows. Clj -h works just fine, but when i try to run a repl i'm getting 'Error: Could not find or load main class clojure.main'. Any ideas? Any help really appreciated!

Juλian (he/him)12:06:39

you're just running clj without arguments, right? which version are you using and which Java version?

Martyna Miśkowiec12:06:54

it's java 8, and clojure 1.10.3

Martyna Miśkowiec12:06:19

also, when i run ' java -cp .\clojure-tools-1.10.3.855.jar clojure.main ' directly on the jar it starts REPL with no issue

ghadi12:06:31

How was clojure installed?

seancorfield16:06:39

Try the #clj-on-windows channel if you’re still stuck @U023X1UCEUB — folks there are pretty dedicated to getting Windows folks up and running with either the Powershell install or the Scoop package manager.

Erik B Good21:06:51

Hello, I was wondering if there was a guide somewhere to write proper boolean expressions. I am a bit surprised that there is no IN operator (similar to SQL), I was also wondering if there was any way of writing cleanly a bunch of OR expressions.. Any one have a blogpost or tutorial on some advanced conditional logic features of clojure?

dpsutton21:06:18

can you explain what a proper boolean expression is?

alexmiller21:06:00

Clojure sets are functions that can be used to check inclusion

alexmiller21:06:30

(#{1 2 3 4 5} 1)

alexmiller21:06:21

or (contains? #{1 2 3 4 5} 1) if that reads better for you

alexmiller21:06:57

it will also return a boolean rather than a logical true value (which is generally true of any predicate that ends in ?)

alexmiller21:06:01

boolean is a useful function to convert a logically true value (anything but nil or false) to an actual boolean value

Erik B Good21:06:18

What I meant by proper boolean expressions is complex valid boolean expressions. @U064X3EF3 that helps yeah I will make up for many OR by using this set notation. Thank you very much

alexmiller21:06:49

I assume you're aware of or and and

dpsutton21:06:05

if you have an example of a boolean expression from another language i can help you translate it. but it's largely gonna be a 1-1 infix to prefix translation

dpsutton21:06:52

here's an example from our codebase that i'm looking at right now

(when (and (send-email-on-first-login-from-new-device)
             (first-login-on-this-device? login-history)
             (not (first-login-ever? login-history)))

alexmiller21:06:03

these are macros (to do short-circuiting of eval) but can be turned into functions by wrapping in #( ) (with eager eval)

Erik B Good21:06:30

for instance let's say I had if x ==2 or x == 3 or x ==4. In python I could write if x in (2, 3 ,4) instead. Now I can use @U064X3EF3 to write (#{2 3 4} x) which looks good

dpsutton21:06:51

there's also (if (<= 2 x 4) ...) that could possibly work depending on the domain (ie, floats aren't going through)

yuhan23:06:15

you could also do (some #(= x %) [1 2 3]) which can be generalised beyond equality checks

sova-soars-the-sora23:06:30

The resource from “.../js/jquery.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff) I have not run into this problem before, I don't know why the javascript is not loading, firfeox seems to be expecting text/html ... any thoughts?

seancorfield23:06:29

JS should be served with a MIME type of text/javascript, not text/html.

sova-soars-the-sora23:06:05

Right... I tried adding type="text/javascript" to the <script> tag but it's still a porblam

seancorfield23:06:23

What is serving up that JS file? That’s where the problem is.

sova-soars-the-sora23:06:34

Hmm. Well other JS files seem to work fine from the same server..

seancorfield23:06:33

Use curl -I <url of JS file> to see what the server is sending back.

sova-soars-the-sora23:06:30

Well that's weird. my /img/ directory works fine through the CDN but my /js/ directory does not

sova-soars-the-sora00:06:43

thanks for the curl tip. more head scratching

sova-soars-the-sora00:06:42

In my server.clj I have (route/resources "public") in my non-authenticated routes

sova-soars-the-sora00:06:11

folders img and js both live there... img will load assets, js will give me the login page to the site o_O

sova-soars-the-sora00:06:31

I figured route/files ought to help serve js assets as well... maybe I need to add a specific line for that?

seancorfield00:06:42

You mentioned a CDN above?

seancorfield00:06:41

Can you try curl directly against the server (without the CDN) and compare the results against the same calls through the CDN?

sova-soars-the-sora00:06:18

yeah, I stopped using the CDN for now, to debug this...

sova-soars-the-sora00:06:31

It just gives me the application login page, which is text/html of course

sova-soars-the-sora00:06:45

so that makes sense, but why is it not serving /js/ files and instead acting like i'm in authenticated territory

seancorfield00:06:36

And your JS and image folders are both under that public resources folder?

seancorfield00:06:18

How are you applying the auth check in your code? Is it perhaps allowing various image file extensions through but not .js?

sova-soars-the-sora00:06:55

good time for a sanity check as any.. 😄 yeah they are both under resources/public/ img | js

sova-soars-the-sora00:06:34

hmm let me double check i actually uploaded them to the server d'oh

sova-soars-the-sora00:06:52

omg i'm a fruitcake

sova-soars-the-sora00:06:58

the assets weren't there! xD

sova-soars-the-sora00:06:16

Haha sorry for the mixup. I appreciate you and your helpful nature! 😃

sova-soars-the-sora00:06:42

i plugged the plug into itself.. why is nothing turning on

🔌 1
💡 1