Fork me on GitHub
#beginners
<
2018-08-26
>
Ramzi04:08:46

How can I go from adding an input to the front end, to writing to a database table?

Ramzi04:08:11

I want there it be a correspondence between pages and tables, and inputs and columns. Is there a reason this is a bad idea?

Ramzi04:08:52

Then developers can automatically add a column to a database table just by adding a new input.

Ramzi04:08:36

Clearly I must make an ajax call but how do i catch it on a Clojure back end, verify the user is credentialed, and then add a column to the database?

seancorfield04:08:01

That sounds very dangerous to me -- it would open you up to all sorts of hacking if the front end could make arbitrary requests that just automatically modified your DB schema...

fmn05:08:25

Alright I actually don't know how to do this. Basically I'm AOT-compiling a project which in the entry point I'm parsing an args using clojure.tools.cli, using the parsed argument I want to read external config file

fmn05:08:32

So I have project.jar and config.edn side by side and I'm using this to try to execute the jar

fmn05:08:37

java -cp ./ -jar project.jar --target config.edn

fmn05:08:26

And it says it doesn't find the resource. I'm using io/resource to get the resource. Nvm, I should've just used io/file instead of io/resource

Ramzi05:08:50

sean, maybe im not thinking clearly, but i want it to only be for developers

Ramzi05:08:00

you know how each time figwheel detects a change, it hot deploys?

Ramzi05:08:12

im saying i want the new database columns to be done on the hot deployment

Ramzi05:08:38

@seancorfield can you help me make a dummy app that connects an input on the clojurescript front end to a clojure backend and a database?

Ramzi05:08:37

what database does it write to?

henrik06:08:30

Any you wish. Try out http://www.sqlkorma.com/ and add in Postgres for example.

Ramzi06:08:48

How does korma work with Chestnut?

john06:08:11

the luminus template has some good docs on how to set up a db with clojure http://www.luminusweb.net/docs/database.html

👍 4
ackerleytng06:08:37

when i code with the repl, sometimes i end up accidentally defining function a after b when b calls a. It works because the repl has it defined, but it doesn't work after restarting cider. does anybody have a workflow that avoids such issues?

quadron07:08:10

@ackerleytng you might be looking for declare

ackerleytng07:08:56

oh you mean use declare to declare everything upfront?

quadron07:08:17

@ackerleytng yes, use it to declare bindings that are defined after the point at which they are invoked

Timo Freiberg07:08:01

@ackerleytng i assume you want to avoid making definition order mistakes and don't actually have circular dependencies?

ackerleytng07:08:09

ah ok that's not what i mean

Timo Freiberg07:08:50

so far i just accept that i make these mistakes from time to time

ackerleytng07:08:15

hah ok thanks

Timo Freiberg07:08:49

i'm not very experienced, but i already noticed that i'm getting used to defining my helper functions above instead of below (like in java)

Timo Freiberg07:08:36

maybe it's just something to get used to and after some time you don't make this mistake anymore

ackerleytng07:08:35

i usually do! usually it's when refactoring that this happens

tbsvttr10:08:40

@henrik Thanks for all the tips!

valtteri11:08:37

@ackerleytng @timo.freiberg linter is a tool that analyzes your source code and provides warnings if the code contains errors or other problems, such as using undeclared vars. You can usually hook a linter to your editor to get immediate feedback as you type or save the file. Eastwood is a popular linter for Clojure and it has been around for a long time https://github.com/jonase/eastwood . Personally I’m using Joker https://github.com/candid82/joker with Emacs bindings https://github.com/candid82/flycheck-joker

valtteri11:08:10

My experience is that setting up tooling is a time-consuming chore but it pays off in better developer experience. You usually also learn something interesting while banging your head against the wall when trying to get the tools to work the way you like. 🙂

ackerleytng11:08:37

Does all the tooling slow down development? Like when you type, or when the file is big

ackerleytng11:08:05

Why did you pick joker over Eastwood?

valtteri11:08:46

Sure tooling comes with some kind of overhead but nothing significant in my experience. I try to avoid big files in general. With a relatively modern laptop you won’t probably notice any kind of slowdown.

valtteri11:08:37

I initially “chose” Joker because it was the first one I got working with my Emacs setup. 😆

valtteri11:08:10

It was very simple to setup and I’ve been very happy with it.

seancorfield18:08:22

Both Joker and Eastwood are useful. I use both. Joker live via an Atom plugin, Eastwood via the command line.

seancorfield18:08:52

Also Yagni and another tool I can't remember... just a sec...

seancorfield18:08:42

Kibit and Bikeshed. Every little helps!

lspector23:08:38

Any news re: environments for beginners in the last year or so, for editing/executing Clojure or Clojurescript (either or both)? My requirements are: simple installation/setup, syntax-aware re-indentation, and *no* required use of paredit or parinfer. I've taught with many over the years but I'm not fully satisfied with any current options that I know about.

seancorfield23:08:00

@lspector Hi Lee! I assume you've tried NightCode? How did that stack up on your criteria?

seancorfield23:08:56

And are you looking to teach complete programming beginners? Or do they have some programming experience, just new to Clojure.