Fork me on GitHub
#beginners
<
2018-11-29
>
saikyun08:11:14

I've been trying to find some information about using clojure + opengl or at least some sort of tool for creating graphical interfaces. do you have any tips? I want to create a text editor/image viewer

nmdrenard15:11:51

in for answer.

saikyun13:11:29

@ I got recommended http://quil.info/, and I managed to get lwjgl working, following this repo: https://github.com/rogerallen/hello_lwjgl I'm now working on getting text rendering to work using some examples from the official lwjgl repo

saikyun13:11:04

@ thanks for the tip 🙂 I'll definitely check it out

saikyun13:11:23

can you get a more modern look using swing, or are you stuck in the 90s? 😄

saikyun08:11:36

I've tried getting javafx to work, but I got stuck

potetm13:11:21

I figured here was a good place to announce that I’m going to be live streaming AoC this year. Weekdays @ 12:00 CST https://www.twitch.tv/timpote

potetm13:11:32

Specifically going to be targeting Clojure beginner-intermediates. So if you know someone trying to pick up clojure, please point them my way.

allanxp416:11:45

Is using :refer :all when requiring libraries code smell?

nbtheduke16:11:05

unless the library is very small, probably

lilactown17:11:11

I very very much dislike :refer :all and use

nbtheduke17:11:24

Much better to require as something and then use the namespaced function. Very clear what you’re doing in that case

mark54017:11:24

And apparently in clojurescript, use only works with :only, and :refer :all isn't supported.

didibus18:11:58

Ya, they learned from their mistake in ClJs

didibus18:11:45

That said, I like to use refer all sometimes. Mostly in my tests. I refer all the namespace I'm testing. And sometimes at the repl it is nice too.

chadhs18:11:22

what’s the common pattern for using ring’s wrap-reload these days only in dev mode? defining a :main project.core/-dev-main in your project.clj dev profile now makes clojure explode when you want to start a repl

felicityfmn18:11:22

hi, I’m on 4Clojure problem #28 and I am having trouble flattening without using flatten. Someone on the internet suggests using (apply concat seq) but I keep getting an error don't know how to create ISeq . Any hints?

jstaab18:11:10

What's the value of seq?

jstaab18:11:47

(apply concat [[1 2] [3 4]]) => (1 2 3 4) so I think you're on the right track

felicityfmn10:11:48

the value of seq is a mixture of vectors and lists. I’ll give it a go and see

felicityfmn10:11:05

so I am writing (fn[s] (apply concat s)) and it’s failing. The sequences being passed are nested lists and vectors. I am not sure what I’m doing wrong

felicityfmn13:12:24

Never mind, I sorted it 🙂

jstaab19:11:54

Hey all, I can't get the cljs.test/use-fixtures macro working. I'm using refer-macros, with the following in my test file:

(use-fixtures :once
  {:before (fn [] (prn "========="))})

(deftest test-stuff
  (is (= 1 1)))
I just get "0 errors"

hiredman19:11:57

where did you get that map with the before key?

d.ian.b19:11:02

I'm making some interop on Java in Clojure for Twilio

d.ian.b19:11:23

How can I see the properties inside this #object ?

d.ian.b19:11:39

I couldn't with (prn [(class x) x]), and with clojure.reflect/reflect

hiredman19:11:31

that isn't a correct fixture (you don't get an error because maps are also functions)

hiredman19:11:51

a fixture is a function that gets passed a function that executes the tests when invoked

hiredman19:11:18

so (fn [run-tests] (run-tests)) is a fixture that does nothing but runs the tests

d.ian.b19:11:24

I'm generating an JWT with twilio's api, but JWT returns null values on the body

jstaab19:11:38

@hiredman I'm using clojurescript, which has a different signature: https://clojurescript.org/tools/testing#fixtures

jstaab19:11:58

I tried using a function instead of a map, still no dice: (use-fixtures :once (partial prn "====="))

hiredman19:11:22

I don't see :before anywhere in the source there, so who knows

hiredman19:11:05

hah, of course

hiredman19:11:11

test.cljs not test.cljc

hiredman19:11:57

it looks like it depends on if you are testing async or what not

hiredman19:11:59

whatever that means

hiredman19:11:22

with async you get the maps with before and after, and without async you get clojure.test style

jstaab19:11:33

Ohh I see it now

jstaab19:11:41

I guess that makes sense, though failing silently 😞

jstaab19:11:50

and I still can't make it work with just a plain fn

hiredman19:11:22

does prn actually do something useful in cljs?

jayzawrotny21:11:41

Dealt with that yesterday. The most obvious difference to me was that strings were wrapped with quotes and the map could be read back into cljs unlike println. I think that’s similar to its JVM counterpart right?

jstaab19:11:46

as far as I can tell it's the same as println

jstaab19:11:58

it works in deftest and outside tests, so I assume it would work in the fixture

jstaab19:11:03

but I've struggled with that, so maybe not

jstaab19:11:07

I'll try console log

jstaab19:11:20

Looks like execution-strategy is a bit tautological; it does :sync if the fixture is a fn; :async if it's a map

dcreno19:11:18

I see that I have multiple versions of java installed. It’s been suggested that I use java 8. Is there a way to configure lein or the project.clj and/or spacemacs dotfile to accommodate this?

➜  ~ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
➜  ~ /usr/libexec/java_home -v 1.8
/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home

dcreno19:11:35

@, relocating the thread. Last one was getting busy!

jr0cket19:11:41

@ Unless you need Java 10 for something, I would simply remove that version (sorry I dont know how to do that on a Mac). If you need Java 10, then there should be a way to set a specific version for JAVA_HOME. If not, you could write a simple bash/zsh script to set JAVA_HOME and call leiningen, adding an alias called lein for the script (hopefully there is a much simpler approach) There are some other options here https://stackoverflow.com/questions/26252591/mac-os-x-and-multiple-java-versions

dcreno20:11:04

I completely removed java 10. All good now. Thanks for your help.

alexmiller19:11:48

Usually you choose java by setting JAVA_HOME and adding JAVA_HOME/bin to your PATH

joseph.guhlin20:11:21

Getting an error with the following `(def prn-chan (async/chan 5 (map println))) (async/onto-chan prn-chan (range 10))` using 1.9.0 and 1.10.0-RC2 and async 0.4.490. Asset failed because it's trying to put a nil value onto the channel, but docs say it only should put non-nil values onto the channel. Is it something I'm missing?

hiredman20:11:50

println returns nil

hiredman20:11:22

so you transducer is trying to put nils on a channel, which is not allowed

joseph.guhlin20:11:27

Yeah, "and any non-nil return value will be placed in the channel."

joseph.guhlin20:11:52

"If a transducer is supplied a buffer must be specified. ex-handler must be a fn of one argument - if an exception occurs during transformation it will be called with the Throwable as an argument, and any non-nil return value will be placed in the channel." but getting this: "Exception in thread "async-dispatch-1" java.lang.AssertionError: Assert failed: (not (nil? itm))"

hiredman20:11:53

that may be a badly worded docstring

hiredman20:11:52

you are interpreting "and any non-nil return value will be placed in the channel." as "will ignore nils returned" but it can also be interpreted as "don't return nils"

alexmiller21:11:28

You cannot put nil on a channel

peter.kehl20:11:01

Hello. How do you find out programatically if something is a macro, rather than a function, please? (I'm writing code that would work with standard math functions, as well as with macros from https://github.com/ztellman/primitive-math).

didibus21:11:47

It's on the meta for the Var

didibus21:11:20

But for writing code, it shouldn't really matter if something is a macro or a function

joseph.guhlin20:11:55

Yeah, definitely poorly worded then. The way it's worded I'd expect it to be similar to filter identity than to add nil return values into the channel (since it says it specifically doesn't). I'll work on a different solution for my issue

peter.kehl20:11:01

(I have a workaround: (def bit-not-fn clojure.core/bit-not)). But still, any way to tell a symbol resolves to a macro?

alexmiller21:11:39

metadata on the var has a :macro key

joseph.guhlin21:11:42

Peter, (meta (resolve '->)) should give you a good start. May not be the best way but it's there

azzurite23:11:42

hi, I want to create an uberjar for a project, however, running lein uberjar never finishes, it just seems stuck at the end. When I disable aot compilation, it finishes (but that's not what I want). I've read that it could be that I have to stop all top-level-threads (even though I thought that I didn't create any) so I run (shutdown-agents) but that still doesn't work. Here is the project: https://gitlab.com/azzurite/twitch-chat-notifier Is there anything obvious I am missing? can someone help me?