Fork me on GitHub
#beginners
<
2021-05-02
>
NoahTheDuke00:05:30

i have some text files that have invalid utf-8 in them. i'd like to write the contents of the files to new files. is that possible?

NoahTheDuke00:05:18

using slurp converts the invalid utf-8 to be valid by changing the actual bytes

hiredman00:05:59

Yes, don't use slurp

hiredman00:05:54

Input and output streams read and write uninterpreted bytes

hiredman00:05:59

Readers, writers, and anything with strings or characters do not deal in uninterpreted bytes, instead need an encoding (like utf8)

FHE04:05:09

Hey all. Quick Q: Which version of adoptopenjdk OpenJDK to install? 8 or 11?

FHE05:05:08

...and wow, for once the installation in Linux seems way more complicated than it does in Windows. Yikes. https://adoptopenjdk.net/installation.html#linux-pkg

Jonas-Daima18:05:25

I recommend using https://sdkman.io/! for your JDKs. It is so easy to install the right jdk on there and switch between them on a later stage, if it should become necessary.

FHE05:05:37

This is (primarily?) for ClojureScript if it matters. Following this (for the 2nd time, now on WSL2 instead of Windows alone): https://clojurescript.org/guides/quick-start

FHE05:05:53

I guess I'll choose 11, but I'm totally lost with what to do with this step:

FHE05:05:56

Configure AdoptOpenJDK's apt repository by replacing the values in angle brackets:

FHE05:05:20

`

echo "deb  <codename> main" | sudo tee /etc/apt/sources.list.d/adoptopenjdk.list
`

seancorfield05:05:57

Any reason to avoid the default openjdk11 version?

FHE05:05:12

What on Earth do I put in place of <codename>?

sb05:05:10

In the documentation I see “You need the codename of your Debian or Ubuntu version. It is usually recorded in /etc/os-release and can be extracted on Debian by running cat /etc/os-release | grep VERSION_CODENAME | cut -d = -f 2 and on Ubuntu by running cat /etc/os-release | grep UBUNTU..”

seancorfield05:05:28

Pretty sure I just did apt-get install openjdk11 when I stuck Java on my Ubuntu setup…?

seancorfield05:05:40

(well, I think I’m on openjdk15 now)

FHE05:05:47

I'm not trying to avoid anything. Just trying to follow the instructions here: https://adoptopenjdk.net/installation.html#linux-pkg

FHE05:05:48

As for my version question, the ClojureScript Quick Start Guide calls for Version 8 or Version 11. Is that not correct? Outdated?

seancorfield05:05:47

https://otodiginet.com/software/how-to-install-java-openjdk-11-on-ubuntu-20-04-lts/ says sudo apt update and then sudo apt install openjdk-11-jdk — ISTR it was harder on Ubuntu 18?

seancorfield05:05:10

11 is the most recent LTS version so it’s a solid choice.

FHE05:05:36

Good enough for me! Thanks!

seancorfield05:05:46

17 will be the next LTS version. I was testing against 14 for ages but recently moved up to testing against 16 on my desktop and 15 on my laptop

FHE05:05:31

What's the benefit to you to trying to be on something newer than the latest LTS.

FHE05:05:20

? Affects whether your programs can be used by people who have newer JRE's installed? ...or maybe not...everything is baked into the program?

seancorfield05:05:33

It just means that Oracle is providing Long Term Support so bug fixes are more likely to be provided over a longer period of time (given that non-LTS releases are only “current” for six months each).

seancorfield05:05:09

The various non-Oracle groups are providing their own support/fixes/maintenance but it’s easier for LTS versions that are more long-lived.

FHE05:05:45

Right, but what's the advantage of trying use something newer and non-LTS?

seancorfield05:05:50

I test against recent versions so that it’s easier to move to the next LTS version when it drops (Early Access builds of 17 are already available and I test some of my projects against those already).

FHE05:05:52

I mean I guess the next question is why move to the newest LTS version if the one you developed in originally is still supported?

seancorfield05:05:01

Right now, a useful thing is the handling of “illegal reflective access” — for several releases, that’s been a warning by default. With 16, the default is to prohibit it, so you have to opt-in if your code (or the libs you use) depend on that feature.

seancorfield05:05:28

Improved GC is the most common reason folks move to newer JVM versions.

seancorfield05:05:00

(at work we are fairly proactive about using alpha/beta builds of stuff, at least for testing, so we can evaluate new features and — with Clojure at least — we’re nearly always on the very latest prerelease build in production: Clojure 1.11.0 Alpha 1 right now)

seancorfield05:05:51

Re: Illegal Reflective Access — in 17 that will be an error with no opt-out, which is why testing against 16 is useful to flush out any instances of that. New Relic’s monitoring agent still relies on it (just just committed to fix it a few months back). Crux, the Clojure database, relies on it too.

FHE05:05:54

OK. Maybe for ClojureScript being at the cutting edge is less valuable (just because of all the other bits that have to work with it?)

FHE05:05:02

Anyway, V11 for me. 🙂

FHE05:05:50

Oh...end still not quite in sight: "The Clojure tools require that either the java command is on the path or that the JAVA_HOME environment variable is set." <--- Important in Linux/Ubuntu?

FHE05:05:19

I've only ever dealt with environment variables in Windows.

FHE05:05:31

Bedtime here, but I'll check back here tomorrow. 🙂

seancorfield06:05:10

I tend to have JAVA_HOME set ~/.profile but mostly because I have several JDKs installed and have env vars for all of those too so it makes sense to set JAVA_HOME there to whatever is my current default choice.

FHE06:05:05

One more thing I'm running into. I need an X11 display...thing...for my browser within WSL2. You mentioned VcXsrv, but I ran across a (seemingly easier to install and possibly more secure) alternative called X410. VcXsrv still better? ...and downloading from SourceForge trustworthy?

FHE06:05:17

As for the JAVA_HOME, I'll have to look into how to set it (as well as where to point it to).

FHE06:05:51

OK. REALLY bedtime now. Thanks for the help so far. Will act on those two questions above tomorrow!

Edward Ciafardini13:05:19

Hello - I have been stuck on this for a bit and was hoping to gain some insight. I'm trying to implement bi-directional data binding in Reagent. When the user types in the fahrenheit input field, it should update with its own value and the celsius field should update with a conversion function. As of now, the fields do not update - they are static. Using Reagent for this - and my state for temps is in a separate file: https://gist.github.com/esciafardini/eb24ac1e30403943a24c18d883b9e50d

Stuart13:05:08

I think you need swap! to update your atom.

Stuart13:05:20

You are also missing a closing paren for (def temps

Edward Ciafardini16:05:08

closing paren missing was a copy/paste error. I've tried using swap! but kept getting error messages. Maybe I will try again. Thanks for the input.

borkdude16:05:01

Might be better to use a gist or pastebin if you want to share long code

Karo17:05:04

Hi team, any useful materials on how to integrate Summologic Open Telemetry with clojure project?

Grzegorz Smajdor19:05:19

Hi, I want to learn my kids pronunciation so I’m thinking about writing some small cljs site that would show the word / number and call google translate for pronunciation - how to call this page in background https://translate.google.com/translate_tts?ie=UTF-8&amp;q=67&amp;tl=en&amp;client=tw-ob?

walterl19:05:17

Not sure if this will help, but you reminded me of this recent announcement: https://clojurians.slack.com/archives/C06MAR553/p1619112778011000

Grzegorz Smajdor19:05:27

right, I’ve seen that but just wondering if this also play it ?

Grzegorz Smajdor20:05:33

Another question, what changes needs to be done in order to deploy reagent template to heroku ? Is there an easy tutorial (or need to follow the heroku guide ?

3
Grzegorz Smajdor21:05:35

Found https://github.com/kliph/figwheel-heroku and modified my project to fit into this one 🙂

👍 3
FHE23:05:04

Hello. Is there anyone here who has installed VcXsrv for used with WSL2 Ubuntu (20.04) for ClojureScript programming with Emacs CIDER (not sure if that matters)?

solf00:05:40

I have, but can't really help you... Forgot about it and I'm not on a windows anymore. However I've heard that wsl2 finally got a gui update, this means vcxsrv shouldn't be needed anymore. More info here: https://github.com/microsoft/wslg https://www.google.com/amp/s/www.techrepublic.com/google-amp/article/linux-on-windows-this-new-upgrade-allows-you-to-run-graphical-apps-simply-and-effectively/

FHE00:05:11

Wow. After hours of combing through info on what X11 is and how to get VcXsrv working. LOl

FHE00:05:29

When I try to run the Quick Start Guide hello world program on the ClojureScript website, though, I get the following error:

FHE00:05:35

`clj --main cljs.main --compile hello-world.core --repl WARNING: When invoking clojure.main, use -M Failed to launch a browser: No X11 DISPLAY variable was set, but this program performed an operation which requires it. You can instead launch a non-browser REPL (Node or Nashorn). You can disable automatic browser launch with this REPL option :launch-browser false and you can specify the listen IP address with this REPL option :host "127.0.0.1" Waiting for browser to connect to http://localhost:9000 ... ClojureScript 1.10.758`

FHE00:05:27

clj --main cljs.main --compile hello-world.core --repl WARNING: When invoking clojure.main, use -M Failed to launch a browser: No X11 DISPLAY variable was set, but this program performed an operation which requires it. You can instead launch a non-browser REPL (Node or Nashorn). You can disable automatic browser launch with this REPL option :launch-browser false and you can specify the listen IP address with this REPL option :host "127.0.0.1" Waiting for browser to connect to ... ClojureScript 1.10.758

FHE00:05:16

...and actually, after completing set-up of VcXsrv, I'm getting the exact same error...as if I wasted the last few hours. 😕

FHE00:05:15

Just need to find out about this X11 DISPLAY variable I guess...or find some way to force WSL2 to use the newfangled feature you mentioned, @U7S5E44DB

FHE00:05:38

...or is there a chance the Ubuntu 20.04 that goes into WSL2 doesn't even have any graphical browser (or any browser), and that's yet another thing I have to install?

FHE01:05:18

OK, so I think I've set my DISPLAY variable correctly, and now I get a different error upon running

FHE01:05:31

clj --main cljs.main --compile hello-world.core --repl

FHE01:05:59

Failed to launch a browser: The BROWSE action is not supported on the current platform!

seancorfield01:05:48

@U7S5E44DB That is only available in Insider builds of Windows right now (that's what I'm running). @UH5SE3NM9 and I already had this exact discussion yesterday (or the day before).

seancorfield01:05:23

Unfortunately, since I updated to the latest WSL2 with Wayland/X11 support builtin, I've forgotten what I used to have DISPLAY set to (you need it on the standard WSL2 setup, but not on the new Wayland version).

seancorfield01:05:57

Sounds like you've figured it out @UH5SE3NM9 -- now you need a browser installed on Liinux.

seancorfield01:05:19

Was it DISPLAY=:1 in the end?

seancorfield01:05:16

I think you should be able to sudo apt install google-chrome or something like that. That's the browser I have installed on WSL2/Ubuntu and it's what starts up automatically when I run a ClojureScript setup...

FHE01:05:27

DISPLAY got set to an IP address with a trailing :0

seancorfield01:05:48

Ah, :0… can’t remember why I thought :1. Anyways, glad you have that bit working. google-chrome next, eh?

FHE01:05:02

Well...it's not working.

FHE01:05:31

Or...you're saying the Ubuntu really didn't ship with a single browser on it?

FHE01:05:41

...and just installing one will resolve this?

FHE01:05:04

@U04V70XH6 Will I installed Chrome, and YIKES. Tons of errors when trying to run it (`google-chrome`):

FHE01:05:49

libGL error: No matching fbConfigs or visuals found libGL error: failed to load driver: swrast ...and many more errors, like 'Failed to connect to the bus [...], and 'Exiting GPU process due to errors [...]', and 'Passthrough is not supported'. Sigh.

FHE01:05:20

I did talk to a few people in an Ubuntu chatroom, and they advised against running a Linux browser for this purpose, and said it should be possible to instead get the WSL2-Ubuntu-based program to talk to a Windows browser. (Their main argument was speed, which I don't care much about at this point, but if it would just work...) None of them were ClojureScript devs, though. What do you think?

FHE02:05:23

O...M...G... Even with all those errors, the browser actually did run (under VcXsrv). I was just not noticing a tiny Chrome pop-up that demanded I decide whether to make Chrome my default browser and whether to send crash and usage reports to Google before, you know, actually launching the browser.

FHE02:05:26

It completely freezes the CLI, though. And if I [Ctrl]+[c] to get the CLI back, the browser window disappears.

FHE02:05:06

I just opened a 2nd Ubuntu CLI. Good enough I guess?

seancorfield02:05:06

Right. When you start up cljs, google-chrome should launch from WSL2 automatically.

seancorfield02:05:53

And yes, if you start a program from the command-line, it’s going to “freeze the CLI” unless you add & at the end of the command to run it in the background.

FHE02:05:38

OK, thanks! I think I'll just let it freeze that CLI and open a new one. I guess I'd like to keep things as visible as possible. I still can't believe all those errors are normal/fine/ignorable, but I guess I'll move on to my next challenge.