Fork me on GitHub
#beginners
<
2015-11-16
>
mj_langford16:11:09

Heyo, I’ve been doing some Clojure work for awhile now…but I finally care to put some cljs into the loop here for the project…I’m a little curious if anyone has a resource (book, blog article, course, w/e) that goes into the routing flow for cljs/clj integration? Not sure I need core.async, but it may come up. Really I just need the ability to pass some datastructures to the client side code for display

mj_langford16:11:01

I’ve done a bit of om in a course, and some react native even, I just need the “here is the routing, here is how you get data across” part, nothing else.

leontalbot16:11:35

Hi @mj_langford ! CLJS stack is evolving fast. If you just start and know a bit of Om already, you might be interested in looking at Om Next https://github.com/omcljs/om/wiki/Quick-Start-(om.next)

leontalbot16:11:01

It is well suited for React Native apparently

mj_langford16:11:34

It looks like that’s not explicitly routing on the server side, but just manually mapping generated cljs to hand written html

mj_langford16:11:38

Is this the normal strategy?

mj_langford16:11:47

Am I just expecting a piece to be there that isn’t?

mj_langford16:11:46

the om course I did was entirely client side, hence the disconnect about this connecting up portion

leontalbot16:11:18

I think @dnolen doesn't want om next to handle or provide routing directly. But I guess there are already examples out there.

leontalbot16:11:17

This could be asked in the #C06DT2YSY channel

leontalbot16:11:02

Otherwise secretary or bidi might be interesting to look at for routing

mj_langford16:11:21

I’m not asking about om, sorry if that was confusing, just expressing my experience level. I’m asking about routing to clojurescript. I’m using compojure to route to server side html right now

mj_langford16:11:34

thank you, I will check into those, of course this is implemented in a random library ;D

mj_langford16:11:41

bidi has a pretty table that also appears to list silk

mj_langford16:11:48

as a clj/cljs router

mj_langford19:11:48

@roelof: Hey, over here man

roelof19:11:21

im here too

mj_langford19:11:34

EOF is typically encountered in programming languages when you have reached the End Of File

mj_langford19:11:47

this almost always happens when you have “unbalanced delimiters"

mj_langford19:11:52

aka, more ( than )

mj_langford19:11:56

or more [ than ]

mj_langford19:11:12

so the computer keeps reading and reading and reading and reading waiting for the closing parenthesis

mj_langford19:11:38

the way to prevent yourself from making this error is using something called “rainbow parenthesis” in whatever editor you are using

roelof19:11:39

oke, in the code I see that the compiler does not have found any missing ) or []

mj_langford19:11:44

then the color shows when you messed up

roelof19:11:18

and the csv file does not have () or []

roelof19:11:34

Light table uses Rainbow parenthesis

roelof19:11:21

LIke I said I copie the code right from the book

mj_langford19:11:31

so you see different colored parentheses when you type (((())))

roelof19:11:52

and they look good. I check every bit of code

roelof19:11:47

they only thing I change it this piece (defn parse "Convert a CSV into rows of columns" [string] (map #(clojure.string/split % #",") (clojure.string/split string #"\r\n")))

mj_langford19:11:32

can you pastebin it again so I can see it in my ide

mj_langford19:11:46

just the code part, not the data

mj_langford19:11:04

you can also add a snippet here if that’s easier

roelof19:11:09

oke, here or on pastebin/lpaste ?

mj_langford19:11:14

either one is fine ;D

roelof19:11:49

(ns core-functions.core (:gen-class)) (def filename "suspects.csv") (slurp filename) (def vamp-keys [:name :glitter-index]) (defn str->int [str] (Integer. str)) (def conversions {:name identity :glitter-index str->int}) (defn convert [vamp-key value] ((get conversions vamp-key) value)) (defn parse "Convert a CSV into rows of columns" [string] (map #(clojure.string/split % #",") (clojure.string/split string #"\r\n"))) (defn mapify "Return a seq of maps like {:name \"Edward Cullen\" :glitter-index 10}" [rows] (map (fn [unmapped-row] (reduce (fn [row-map [vamp-key value]] (assoc row-map vamp-key (convert vamp-key value))) {} (map vector vamp-keys unmapped-row))) rows))

mj_langford19:11:50

I think control enter on windows makes the snippet dialog come up

roelof19:11:27

and it going wrong on this code : (first (mapify (parse (slurp filename))))

roelof19:11:37

suspects.csv

roelof19:11:48

Edward Cullen,10 Bella Swan,0 Charlie Swan,0 Jacob Black,3 Carlisle Cullen,6

mj_langford19:11:56

wait, do you have that data in the bottom of the file?

mj_langford19:11:04

Or does the file end after line 38?

roelof19:11:10

I have to find out how to see line numbers in LT , moment

mj_langford19:11:24

rows)) is line 38

roelof19:11:03

oke, there the file ends, After it I had the line that failed

mj_langford19:11:23

is the file 38 lines long or 39?

mj_langford19:11:50

generally speaking, you want one final blank line at the end of files fed to programming tools

mj_langford19:11:15

this is because programming tools are often quite bad

mj_langford19:11:20

it’s not user error, its crap tools

roelof19:11:57

38 without the failing command : (first (mapify (parse (slurp filename))))

swizzard19:11:19

that’s a lotta nesting!

mj_langford19:11:20

ooh, I undestand now

mj_langford19:11:24

you had another thing there

mj_langford19:11:40

@swizzard I don’t think Cftbat uses -> and ->>

swizzard19:11:12

wait what’s cftbat?

swizzard19:11:21

it should though

mj_langford19:11:23

Clojure for the Brave and True

swizzard19:11:25

they’re friggin’ magical

mj_langford19:11:00

@swizzard: have you see swiss arrows?

swizzard19:11:16

…like once, months ago?

mj_langford19:11:24

the diamond wand is my new favorite ;D

roelof19:11:34

mj_langford: schould I place the failing line back and then paste it again ?

swizzard19:11:10

my list of “probably just include these by default” is pretty much limited to instaparse and clj-http, tbh

mj_langford19:11:15

wait @roelof it’s not working?

swizzard19:11:16

but that’s mostly a function of the stuff i usually do

mj_langford19:11:23

thought you found the bug

roelof19:11:37

nope, I did not find it

mj_langford19:11:52

okay, hit cmd enter, paste in everything you’re doing

mj_langford19:11:02

everything that you need in the clj file

roelof19:11:20

wierd, I closed LT and reopended it and now no error

swizzard19:11:52

like @mj_langford said, programming tools are often dumb as hell

roelof19:11:07

I seen it before that a old error message stays visible even after the culprit is found. I think I will have to find a better IDE then LT

mj_langford19:11:22

There aren’t really IDEs as such for clojure

mj_langford19:11:29

there are a lot of text editors with clojure support

mj_langford19:11:37

cursive clojure is sorta here?

mj_langford19:11:45

but it’s a whole lotta ide for sure ;D

swizzard19:11:59

there are some good vim packages simple_smile

roelof19:11:12

maybe Emacs as the author of Brave is using

mj_langford19:11:17

the difference between ide and text editors is a wierd distinction, but this is the sort of thing that happens in editors, and not in IDEs

mj_langford19:11:37

I use vim and a repl in the command line

mj_langford19:11:05

You don’t have to build in LightTable, you can truly use it for editing, and compile at the command line

mj_langford19:11:15

if you’re getting error messages that are confusing

mj_langford19:11:15

Does anyone know if nightcode is still working?

mj_langford19:11:24

It’s supposed to be a one stop shop targeted at beginners

mj_langford19:11:03

Yeah, @roelof, this might be less headache inducing https://sekao.net/nightcode/

mj_langford19:11:44

but sorry on the behalf of programmers, our tools have edges like razorblades

roelof19:11:50

NP, I have to find out how I can use Nightcode on Windows

roelof19:11:35

Another question : Is it easy to load a source file on repl ?

roelof19:11:58

@binduwavell: can you share your docker file one more time. I do not get it to work properly. Still errors

mj_langford19:11:56

(load-file “src/module/core.clj”)

swizzard19:11:11

why would you do that instead of :require '[module.core…?

mj_langford19:11:42

I assumed he was doing it in the repl?

swizzard19:11:49

but you can do that in the repl also?

swizzard19:11:55

i mean i guess if you’re not making namespaces, but also don’t do that

roelof20:11:51

I mean loading in repl

roelof20:11:07

thanks both

noisesmith21:11:42

swizzard: just for clarity, I am sure you meant (require '[module.core]) - (:require '[module.core]) silently does nothing.

noisesmith21:11:02

also, don't forget the optional :reload argument

saiberz22:11:46

Hey guys i’m new using http-kit and compojure , i’m not sure how to get body from a POST request (not sure if this is the right channel)

noisesmith22:11:27

saiberz: there is a ring middleware that will parse the post request body and give you a hash map, wrap-params