Fork me on GitHub
#beginners
<
2017-08-17
>
andershessellund08:08:57

apparently, chrome headless can be used from command line to convert an HTML page to PDF. I dont know of any libs to make it more convenient though. https://tecadmin.net/create-pdf-google-chrome-headless/

sb09:08:58

@josh.freckleton I did with PhatomJS in Clojure, but not works with AWS lambda.

sb09:08:35

Because do you need install the phatomjs

sb09:08:35

.. and I never tried.. but I saw the https://github.com/GoogleChrome/puppeteer what could be very interesting too.

sb09:08:12

If I remember what I use https://github.com/strongh/phantom-clj - maybe that.. of course you can export to pdf too (if I remember good)

sb10:08:17

pdfkit-clj clj-pdf maybe interesting for you depend on what you want

rmuslimov13:08:55

I met very annoying problem with org.apache.cxf. I generated files with wsdl2java and tried to initiate Service class in REPL - it worked. Then I generated jar with lein uberjar and it fails in moment of initiating this instance. Here is trace:

1. Unhandled java.lang.NullPointerException
   (No message)

   WSDLServiceFactory.java:   85  org.apache.cxf.wsdl11.WSDLServiceFactory/<init>
          ServiceImpl.java:  217  org.apache.cxf.jaxws.ServiceImpl/initializePorts
          ServiceImpl.java:  160  org.apache.cxf.jaxws.ServiceImpl/initialize
          ServiceImpl.java:  129  org.apache.cxf.jaxws.ServiceImpl/<init>
         ProviderImpl.java:   82  org.apache.cxf.jaxws.spi.ProviderImpl/createServiceDelegate

rmuslimov13:08:54

What may cause this problem? Whatโ€™s the difference running lein repl and java -jar on generated jar with lein uberjar?

rmuslimov13:08:11

Spent whole day on it

schmee15:08:06

@rmuslimov are you using AOT compilation?

rmuslimov15:08:16

I think I solved the issue after 8 hours of googling

rmuslimov15:08:37

:uberjar-merge-with {"META-INF/spring.handlers" [slurp (fn [x y] (str x "\n" y "\n")) spit]
                       "META-INF/spring.schemas" [slurp (fn [x y] (str x "\n" y "\n")) spit]
                       "META-INF/spring.tooling" [slurp (fn [x y] (str x "\n" y "\n")) spit]
                       "META-INF/cxf/bus-extensions.txt" [slurp (fn [x y] (str x "\n" y "\n")) spit]}
this magic thing in project.clj helped

schmee15:08:24

whoa, looks Java-esque ๐Ÿ˜„

schmee15:08:34

good that you got it working!

chang16:08:46

I saw this (very similar) code from https://reagent-project.github.io/

(defn timer-component []
  (let [seconds-elapsed (atom 0)]
    (fn []
      (js/setTimeout #(swap! seconds-elapsed inc) 1000)
      [:h1 "Seconds Elapsed: " @seconds-elapsed] )))
Then when I tried to reimplement it again without looking, I had something like:
(defn timer-component []
  (let [seconds-elapsed (atom 0)]
    (js/setTimeout #(swap! seconds-elapsed inc) 1000)
    [:h1 "Seconds Elapsed: " @seconds-elapsed] ))
> In this case the page only freezes at: "Seconds Elapsed: 0" After multiple trials, I looked and noticed that I was missing the (fn [] ) below the let binding. I assume that it is there for scope reasons. But I'm scratching my head like "What the hell" there is no loop here. How come the seconds-elapsed is being updated every second? As far as I know setTimeout on JS land only executes a callback only once. I guess I'm still not groking how loops work in Clojure. So, my question: why the first piece of code is looping, when apparently there is no loop countruct? Any explanation that could bring me to enlightment would be greatly appreciated. ๐Ÿ˜ƒ

captainlexington17:08:56

@mohamedhayibor I believe code is looping because the component re-renders, and re-triggers the setTimeout

captainlexington17:08:20

But in the original version, the (fn[]) wrapper prevents this from happening

captainlexington17:08:23

Does that make sense?

captainlexington17:08:16

Oops, it's backwards. My explanation

captainlexington17:08:07

Reagent is looking for a fn to render, and every time the anonymous function is called, the let is triggered again and the setTimeout is triggered again

captainlexington17:08:34

But if you return mark-up instead of a function, it just gets redrawn every render cycle

chang17:08:47

@captainlexington waouh, got my mind blown. That makes sense. How often do you think the page is getting redrawn here before the 1 second mark?

chang17:08:12

Thanks a lot for this explanation by the way. This really helps.

captainlexington17:08:54

That I couldn't tell you. It depends what else is going on in the app. I also might be completely wrong.

captainlexington17:08:13

It /might/ be that reagant is re-rendering when atom is swapped

captainlexington17:08:50

If it's a proper reagent atom instead of a native atom, reagent could know to listen for changes and re-render

captainlexington17:08:58

Then, when it re-renders, it called the setTimeout again

chang17:08:57

Yes it a reagent atom. Thanks for the explanation. ๐Ÿ˜ƒ

sb18:08:20

๐Ÿ™‚

vinnyataide18:08:21

Hello all! Is there a way to lint a big map to find where is the key that is giving an error "...even number of forms"?

lepistane19:08:40

how does one undo git add -A? git reset --hard?

lepistane19:08:58

LESSON dont do git reset --hard with no commits in repository everything got deleted YAY ๐Ÿ˜„

ghadi19:08:08

I feel bad, I almost suggested doing a commit, then doing a reset, but alas I didn't

josh.freckleton20:08:18

I'm working within in an emacs/cider environment, and for some reason it stays in that test context, barring me from doing eg ( "../resources")

noisesmith20:08:24

resource looks up relative to the classpath, not file system

noisesmith20:08:34

and you canโ€™t do ../ from the classpath

noisesmith20:08:58

resources itself is on the classpath though, so ask for the thing you want without prefixing with resources

noisesmith20:08:50

so if you have ../resources/foo/bar.txt you can do (io/resource "foo/bar.txt") to find it, if you are in the right project

noisesmith20:08:01

regardless where the shell was in that project when starting

josh.freckleton20:08:08

that worked :face_with_rolling_eyes: