Fork me on GitHub

привет от медоед


hi ppl, I am trying to use stuart's component to setup my compojure/ring webapp and inject the database to be available to any incoming request


(defn create-new-system []
   :database (new-mysql-db)
   :platform-http (component/using (new-platform-http)
                                   {:db :database})))


is it right? if so, how can I have access to the :db at the endpoints now.


@iagwanderson That looks right, when you start the system you should have access to the db inside the platform-http component.


so I'm following the simple instructions here: to explore cljs and figwheel, etc. I always get to this part in the figwheel processing: Prompt will show when Figwheel connects to your application and then nothing happens. I've had this happen when exploring other tools like shadow-cljs too. My localhost:3449 says site can't be reached either. what am I doing wrong?


can you try instead of localhost?


I just ran it and it works for me. Are you on windows by any chance?


figwheel had the following message for me: > Figwheel: Starting server at does your output include this? it should tell you where the app is being served


That doesn't work either. Here is my full terminal output. I remember the same thing happening when trying out shadow-cljs using a beginner tutorial. It just never connected. Here is my full terminal output, not sure if the warnings are relevant:

chaselambert@penguin:~/projects/cljs-demo$ lein figwheel
Warning: implicit middleware found: cider-nrepl.plugin/middleware 
Please declare all middleware in :middleware as implicit loading is deprecated.
Warning: implicit middleware found: refactor-nrepl.plugin/middleware 
Please declare all middleware in :middleware as implicit loading is deprecated.
Warning: implicit hook found: lein-environ.plugin/hooks 
Hooks are deprecated and will be removed in a future version.
Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid ;)
Figwheel: Starting server at 
Figwheel: Watching build - app
Compiling build :app to "target/cljsbuild/public/js/app.js" from ["src/cljs" "src/cljc" "env/dev/cljs"]...
Successfully compiled build :app to "target/cljsbuild/public/js/app.js" in 0.867 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app
Figwheel Controls:
          (stop-autobuild)                ;; stops Figwheel autobuilder
          (start-autobuild id ...)        ;; starts autobuilder focused on optional ids
          (switch-to-build id ...)        ;; switches autobuilder to different build
          (reset-autobuild)               ;; stops, cleans, and starts autobuilder
          (reload-config)                 ;; reloads build config and resets autobuild
          (build-once id ...)             ;; builds source one time
          (clean-builds id ..)            ;; deletes compiled cljs target files
          (print-config id ...)           ;; prints out build configurations
          (fig-status)                    ;; displays current state of system
          (figwheel.client/set-autoload false)    ;; will turn autoloading off
          (figwheel.client/set-repl-pprint false) ;; will turn pretty printing off
  Switch REPL build focus:
          :cljs/quit                      ;; allows you to switch REPL to another build
    Docs: (doc function-name-here)
    Exit: :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
[Rebel readline] Type :repl/help for online help info


I'm on debian stretch


couple things. check your profiles.clj for outdated stuff. probably remove everything in there to be honest. Then, what is your lein version


Leiningen 2.8.3 on Java 1.8.0_181 OpenJDK 64-Bit Server VM


can you remove the cider-refactor stuff?


> Warning: implicit middleware found: refactor-nrepl.plugin/middleware


probably. this profiles.clj seems pretty advanced for me


and get rid of this as well > Warning: implicit hook found: lein-environ.plugin/hooks


you don't need anything in your profiles.clj file


probably best served by deleting it


hmmm? so i created this using lein new reagent cljs-demo +cider like those beginner instructions said. it created the project.clj file for me. I should just delete the whole thing?


there's a file ~/.lein/profiles.clj that i'm talking about


you probably have some old junk in there


Yeah, this is a completely fresh install of everything because I haven't figured this out. I don't even have a .lein/profiles.clj file


I thought you were saying delete the profiles.clj file in the cljs-demo project


oh no. i'm sorry


that project.clj not profiles.clj


project vs profiles


gets confusing sorry 🙂


my fault. yeah, but no profiles.clj either


it's been a frustrating problem. As I said, a similar thing happened when trying to use shadow-cljs. Not sure what I'm doing wrong. I just want to interact with these things with my sweet emacs/cider goodness!


i hear you. i can't replicate your experience though. it sounds like something is funky with your machine


what is the actual problem though? what happens when you curl -I for example?


HTTP/1.1 405 Method Not Allowed Cache-Control: no-cache Content-Length: 0 Server: http-kit Date: Sat, 12 Jan 2019 16:28:00 GMT


ok so that is replying


what does the browser say when you open http://localhost:3449?


This site can't be reached. localhost refused to connect


do you have a proxy configured? or some browser extension that may be blocking local connections?


Doesn't work. What is weird is figwheel is saying things are successful, it just never completes that final step.


I've tried the luminus tutorial and that connects to my localhost just fine. Could it be a cljs specific thing?


something seems to prevent you from loading that page. so CLJS isn't even loaded yet.


just crazy question, but you're not using docker or anything like that right?


interesting question actually. i'm on a pixelbook (chromebook) running their crostini linux capability which is sort of containerized I think. It's debian stretch.


But I've had other things connect to my localhost fine. Things like luminus and things like Rust's rocket web framework.


This figwheel runs smoothly right until the very last part and just hangs there. But it gives me no errors or anything during the build process


right. it is waiting for a browser to connect to it to serve as the js engine of the app. What is happening is that a simple webserver is not seeing any connections on 3449. that's the fundamental problem


and with the confusion of the crostini stuff i have no idea what is going on


let me try something. I'll put a standalone browser inside crostini.


and we have lift off! Yay! Ok. so usually things inside crostini can jump out to my chromeos chrome browser. but i installed firefox inside the linux distribution and tried the localhost there and it connected!


thank you so much folks. My apologies for not being clear on my os setup. this has been killing me! To the point where I was blaming clojure and it's "brittle" tools and questioning my sanity. of course it was user error the whole time.


yeah you just have multiple computers in your computer. so localhost is a bit ambiguous


yup. it's weird how clojure (not clojurescript) and rust and others use my chromeos localhost and cljs uses the debian one.


that was a super smart question about docker though. I couldn't have done it without you! Awesome tech communities are awesome!


Hey all, looking for suggestions on a better way to my data structure. I am updating columns in my db. Normally, all columns (in my case) that require updating are pk or fk columns. So I can safely do an update-map like:

{1 5 55 68 8 47}
However, one table i have is "polymorphic" in that there is 1 column on the table telling you the type of resource it refers to and another column telling you the specific id of the resource. Think: This poses a problem because unlike an fk column, for the plymorphic table if multiple columns have 1 as a value, it does not not mean that they are all referring to the same resource. So now, my update-map above won't work for all tables. I am trying to think of alternative way to handle this. some thoughts:
{:file/1 5 :folder/55 68 :other-resource/8 47}
Another thought is maybe attaching meta_data? Thoughts?


I don’t understand your first example {1 5 55 68 8 47}


is 1 the name of a column?


and 55 another?


and is pk/`fk` referring to primary key / foreign key?


your second example is not so clear what you’re trying to do either. what are the namespaces supposed to help with?


Hi @lilactown, it's a map. The odd items are keys, even items are respective values.


Some people put a comma after each pair. Comma is optional (it's a whitespace). {1 5, 55 68, 8 47}


Lol @peter.kehl I appreciate the info but I'm asking him about the semantics of the problem


Access by key: ({1 5, 55 68, 8 47} 55) ;=> 68


I'm well aware of how clojure data structures work 😉


Ah, I see, you followed up on a previous question...


Hi team. Imagine you have a macro that would be run at the top level only. It doesn't seem to be able to inject (def ...). Can it somehow create new def variables in the consumer's namespace, please?