Fork me on GitHub
#clojure
<
2016-08-12
>
lvh00:08:24

Has anyone here used https://jarkeeper.com/ ? For some reason, some repos work, some just redirect you to the front page. E.g. caesium (my crypto lib) works fine, but cloverage just redirects me to the front page, e.g.: https://jarkeeper.com/lvh/caesium https://jarkeeper.com/lshift/cloverage

lvh00:08:40

(Sorry, the slash at the end made it not work, I removed it)

richiardiandrea00:08:01

I have a weird case of exception disappearing in my Clojure code: it looks like I need a setDefaultUncaughtExceptionHandler but the problem is that it is already there...the Exception itself is a compiler exception (I use a seq instead of a map) is executing inside a Runnable. I can catch it with a try no problem but I wonder why it was not going through the setDefaultUncaughtExceptionHandler, has anybody had the same issue?

richiardiandrea00:08:47

It is maybe one of these things that need a repro project, I will try to create one

richiardiandrea01:08:38

Thanks @danielcompton for the links I'll check them out

richiardiandrea05:08:54

@danielcompton: it turns out it might be a manifold executor service issue

pesterhazy12:08:35

@richiardiandrea: futures also swallow exceptions

Alex Miller (Clojure team)12:08:23

I don't think that's accurate. Rather they cause a failure in a background thread without a handler

Alex Miller (Clojure team)12:08:01

The default uncaught exception handler should be able to trap those

Alex Miller (Clojure team)12:08:09

And if you override the send-off executor you can catch set the thread handler

pesterhazy12:08:02

@alexmiller: what I meant was that if you run (do (future (assert false)) nil) (i.e. you don't deref the future), the exception will never be shown, regardless of default exception handlers

Alex Miller (Clojure team)13:08:00

oh right, it does capture it and emits on deref

Alex Miller (Clojure team)13:08:19

but again, I’d say that’s not “swallowing” which implies to me “throwing away"

pesterhazy13:08:55

@alexmiller: didn't mean to imply that 🙂

asolovyov13:08:38

is there a better way to do (catch #?(:cljs :default :clj Exception) e ...)?

pesterhazy13:08:40

though it's true that just using (future ...) to do something in the background is a common idiom in clojure, but a dangerous one

Alex Miller (Clojure team)14:08:51

@asolovyov: currently, no (you might want to use Throwable rather than Exception in the :clj branch btw)

grzm14:08:35

I've come across an Om/Transit server encoding issue when using the Stuart Sierra's Reloaded workflow, Pedestal, and Figwheel. When Figwheel compiles the (client) code, and I reload the server code via (reset), the om.transit writer no longer encodes the #om/id tagged literal. I've set up a test case with instructions on how to replicate it as a git repo: https://github.com/grzm/bad-om-transit

grzm14:08:41

My theory is that the client code compilation pollutes the code that's reloaded by (reset). But I've reached my current limits on how to further reduce the test case. Any thoughts?

robert-stuttaford14:08:31

can you move your client code out of the server-side classpath?

grzm14:08:59

@robert-stuttaford: Good idea. How would I do that?

robert-stuttaford14:08:56

well, you can confirm your hypo by deleting the client code, restarting your jvm and doing a reset, and seeing that it still works. i had a similar issue, where reset couldn't find cljs macros

robert-stuttaford14:08:17

i ended up putting the cljs deps in the :dev profile of our backend project so it could 😊

grzm14:08:47

If I don't compile the client code (i.e., don't run Figwheel), I don't have the problem.

grzm14:08:28

I'd like to keep the client code and the backend code in the same project to keep them in sync.

robert-stuttaford14:08:55

yeah. so the trick is figuring out how to exclude your compiled js from your classpath while still keeping it somewhere that your web server can serve it from

robert-stuttaford14:08:09

or, maybe reset can be given a list of exclusions ?

grzm14:08:18

I wonder if there's a way to set up different profiles in the project file?

grzm14:08:27

I haven't done a lot of that.

robert-stuttaford14:08:48

but... are you using the om dep on the backend?

grzm14:08:10

Yup. For the parser.

robert-stuttaford14:08:28

actually, profiles won't help

robert-stuttaford14:08:50

the root cause is that the compiled cljs in your public folder is on the classpath, and tools.namespace is loading it

robert-stuttaford14:08:55

that's what needs to be prevented

robert-stuttaford14:08:23

i actually needed the same thing, but i managed to bullet-time myself around it 🙂

grzm14:08:00

oh? Can I have a red pill, please?

grzm14:08:23

Was that setting up the client and server as separate projects?

robert-stuttaford14:08:37

no, in my case, the issue was that t.n.r/reset found cljs project macros in the classpath, and the required nses within were missing, because i had not included the dependencies in the project. all i had to do was add them to the :dev profile

robert-stuttaford14:08:00

one way you could hack it (and it IS a hack) is to have cljsbuild put your compiled stuff somewhere eg ./out and then update your template to serve from another service e.g. localhost:8000/my.js, and then run e.g. python -m SimpleHTTPServer from within your out folder

robert-stuttaford14:08:10

essentially run another webserver and update your js paths

grzm14:08:47

Gotcha. Thanks for the explanation!

grzm14:08:48

Thanks 🙂

richiardiandrea14:08:45

@pesterhazy: I was aware of that and I have the uncaught handlers in place, what happens is that manifold actually swallows them, see repro case here: https://github.com/arichiardi/uncaught-ex/blob/master/src/uncaught_ex/core.clj It looks like the reason is that the manifold/dirigiste executor service collects stats and (understandably) you don't want it to crash. In any case I opened an issue and Zach will brilliantly advise :)

shader19:08:16

so what's the currently recommended way to make mobile apps with clojure/clojurescript?

gnejs19:08:27

you put the app on a usb-stick so that you can carry it around.. ? 🙂

grzm20:08:46

@robert-stuttaford: Here's my fix:

(defn refresh-dirs
  "Remove `resource` path from refresh-dirs"
  ([] (refresh-dirs repl/refresh-dirs))
  ([dirs]
   (let [resources-path (-> "public" resource .getPath File. .getParent)
         exclusions #{resources-path}
         ds (or (seq dirs) (cp/classpath-directories))]
     (remove #(contains? exclusions (.getPath %)) ds))))

(defn reset
  "Destroys, initializes, and starts the current development system"
  []
  (stop)
  (apply repl/set-refresh-dirs (refresh-dirs))
  (repl/refresh :after 'user/go))

grzm20:08:57

Getting the path to the resource directory feels a bit hacky (what if I have multiple resource paths?) but that's a problem to solve another day.

grzm20:08:58

I'd love to figure out a way to include anchor fragments for individual messages to make it easier to reference a particular point in a conversation.

grzm20:08:57

Thanks @shaun-mahood . Do you think that would be useful?

shaun-mahood20:08:19

Yeah, I think that would help - I actually would have used it a couple times this week.

grzm20:08:12

@plexus: hi! Is @shaun-mahood correct? Are you the one I can credit with maintaining the clojurians-log?

plexus20:08:13

Yeah I've been wanting that for some time myself, just not high enough on the list so far

grzm20:08:37

I'd be happy to look into it. I was just looking at your github repos to see if the code were there 🙂

plexus20:08:55

Yes, I inherited it though, it's generated by a bunch of python scripts

grzm20:08:48

Is the code somewhere I can grab?

plexus20:08:35

here's the current version, I had to hack in some changes to make the GFM rendering work. https://github.com/plexus/slack-archivist

grzm20:08:06

I'll take a look this weekend. Might be good to get my head out of the code I'm currently working on.

shaun-mahood20:08:57

@plexus: How does the pipeline work from generating the log files to hosting them on clojureverse? Do you think it would be possible to put in a clojure step that modifies the files for the final output?

plexus20:08:18

would love to replace some or all of it with clojure, it works in two steps, a bot collects the messages, a cron job turns them into static HTML

plexus20:08:59

would be cool to at least have the second part in Clojure

plexus20:08:42

would make it easier/more fun for me to improve it as well, but like I said not something I can spend a lot of time on right now

shaun-mahood20:08:13

Is the message format that comes out of step 1 reasonable to work with?

plexus20:08:33

it's a flat file with one JSON map on each line

plexus20:08:06

{"text": "ah right", "ts": "1470864853.000602", "user": "U050B88UR", "team": "T03RZGPFR", "type": "message", "channel": "C07UQ678E"}

plexus20:08:50

it needs to resolve to those channel id's, can't remember now if it caches those or what

grzm20:08:51

I'd probably just use that ts value as the anchor, or maybe the ts value and the user

grzm20:08:20

Or maybe a user-readable timestamp value

plexus20:08:53

pull requests very welcome! I'm sure many people would appreciate such a change

grzm20:08:48

Is there a sample of the log files for testing?

plexus20:08:51

here are some notes how I set things up, might be useful to get it going locally https://gist.github.com/plexus/c4ec0335f43e7d27c65da94741069e8d

plexus20:08:21

@grzm I'll get you some logs you can work with

plexus20:08:32

what's your Github name?

shaun-mahood20:08:22

@plexus: Do you have the set of existing JSON stored somewhere still, or does it consume it as it goes? I'm thinking it could be a fun and useful future project to replace the interface, but probably not for a few months unless it becomes a good project to test other ideas with.

plexus20:08:27

the logs are in a private github repo and are all kept, so it's always possible to regenerate with new templates or even build a complete new front-end

shaun-mahood20:08:42

Ok awesome. Can you send me over a couple sample logs as well?

plexus20:08:36

it's debatable whether those need to be private since you can scrape it all from the site but that's how it is now

plexus20:08:45

going offline. have fun with it!

fellshard21:08:36

Slack archival bots are against the ToS for Slack, sooo that's probably why they're kept private. 😬

bur21:08:50

I got a problem

bur21:08:16

my resource/public/index.html has a <script src="js/app.js"></script> which points to compiled cljs code inside the resource. but when I try it out i always get 404 on the app.js resource. this thing is running on a compojure

bur21:08:36

path for js is resource/public/js/app.js/

bur21:08:52

Failed to load resource: the server responded with a status of 404 (Not Found)

grzm21:08:00

@bur Have you confirmed that there is a file at resources/public/js/app.js ?

grzm21:08:53

And can you directly load http://localhost/js/app.js in the browser?

bur21:08:33

I can confirm that there is a file in the folder but I cannot access the file via browser

bur21:08:10

(defroutes app
  (GET "/" []
       (slurp (io/resource "public/index.html")))
)

bur21:08:18

that is my only route inside compojure

grzm21:08:45

Does compojure include middleware to serve resources directly?

bur21:08:11

I am a bit of a noob and currently just hacking away

bur21:08:24

the only middleware I got is for hot reloading for ring

grzm21:08:37

we're all noobs at some level 🙂

bur21:08:12

how kind of you to say 🙂

grzm21:08:15

This looks like it may be relevant

shaun-mahood21:08:59

@bur: Did you start with a specific template?

bur21:08:30

I started from the heroku clojure example and expanded it slowly from there. https://github.com/heroku/clojure-getting-started

bur21:08:48

I think I'll give up for today, it's almost 11 pm and it's a friday

bur21:08:40

but hacking away on clojure has been fun so far. started out today and already did some fiddlements with redis 🙂