Fork me on GitHub
#clojure
<
2016-08-22
>
mnewhook00:08:02

@yogthos: Great talk! Enjoyed that.

underplank02:08:23

Does anybody know if there is an arcadia channel?

underplank02:08:42

Just trying to get started with it and having issues with getting the repl started...

zane06:08:36

Huh. There's no way to differentiate between a vector and a map pair using clojure.walk/postwalk?

mhjort07:08:42

@tom I've used Lambada quite a lot. It works ok. Here is a link to a demo project I have used in few Clojure meetups: https://github.com/mhjort/lambda-demo

mhjort07:08:05

You should check that the namespace containing the function is AOT compiled. That's a common mistake I've done multiple times. AWS Lambda env cannot find the function if it is not compiled already

robert-stuttaford09:08:27

@zane try (instance? clojure.lang.MapEntry item)

zane09:08:30

@robert-stuttaford:

> (clojure.walk/postwalk (fn [x] (prn (type x)) x) {:a 1})
clojure.lang.Keyword
java.lang.Long
clojure.lang.PersistentVector
clojure.lang.PersistentArrayMap

robert-stuttaford09:08:28

map-entry? Clojure 1.8+

zane10:08:57

Right. Hence my question.

Alex Miller (Clojure team)12:08:47

2-element vectors are considered to be valid map entries

sandbags12:08:42

@yogthos in clj-pdf I’m looking for the ability to set rowspan on a table cell and not seeing it, am i missing something?

sandbags12:08:36

hrmm… wasn’t looking hard enough, i see it in the docs further down… doesn’t seem to be working though (I had inferred it and asked when it didn’t seem to work). Maybe I made an error using it.

yogthos12:08:58

I recall that's a little fiddly

yogthos12:08:22

make sure you're using the pdf-table when setting that

sandbags12:08:53

Ah, I had not noticed the distinction between a :cell and a :pdf-cell

sandbags12:08:10

oh there’s two distinct types of table… i missed that

sandbags12:08:25

i’m not a PDF expert so i find that a little… confusing

yogthos12:08:31

yeah that's an artifact of itext

yogthos12:08:43

I use that to do all the heavy lifting

sandbags12:08:46

should i assume that you can only put :pdf-cell in :pdf-table ?

sandbags12:08:27

is it the case that “table” is ‘simpler’ than “pdf-table” ?

sandbags12:08:40

beyond one doesn’t have rowspan I’m wondering how to decide when i should use one over the other

yogthos12:08:31

yeah pdf-table just adds a whole bunch of layout options

yogthos12:08:51

so I tend to prefer table unless I need it rendered a specific way

sandbags12:08:34

yeah, unfortunately table seems to be missing rowspan which, of course, i need damnit 🙂

yogthos12:08:16

it should work more or less the same 🙂

sandbags12:08:19

hrmm… in pdf-table the widths vector it’s not clear what that’s measured in, the example sums to 45

yogthos12:08:45

yeah that one is just a hint

sandbags12:08:53

sorry, i didn’t mean to turn this into pdf show & tell 🙂

yogthos12:08:01

it will try to lay it out intelligently

yogthos12:08:05

no worries

sandbags12:08:56

okay pdf-table gets the job done, thanks again

sandbags12:08:39

if i wanted to read a bit more about how all this stuff fits together is there anything you’d point to. I tried visiting the iText site to see if I could find a guide but it was terribly confusing

yogthos12:08:14

I tend to poke through their java docs https://ymasory.github.io/iText-4.2.0/

yogthos12:08:25

the guys making itext got kinda slimy last year

yogthos12:08:57

the last lgpl2 release was 4.2.0 and used to be available in the central maven repo

yogthos12:08:25

but they retroactively changed the artifact to point to their new agpl release

yogthos12:08:41

so I ended up just taking over the source and rolling it into clj-pdf

yogthos12:08:59

or at least the parts I care about 🙂

sandbags12:08:43

oh great maker

sandbags12:08:52

that’s a lot of classes 🙂

yogthos12:08:09

yeah it's gigantic 🙂

yogthos12:08:33

I still haven't exposed all of the stuff in it, I add things in as they come up

yogthos12:08:05

on the other hand clj-pdf can do some stuff itext can't now, like charting and svgs

sandbags12:08:12

yeah having the svg is handy as i can take my spider diagram code from the reagent front end and repurpose it 🙂

yogthos12:08:34

nice! 🙂

sandbags12:08:10

Is there any way to get more info when you get a cljpdf.text.DocumentException? I’m getting an NPE but it’s not clear why

yogthos12:08:31

not really unfortunately

eraserhd12:08:55

It seems like I frequently have a case where I want to side-effect (rather than record) the output of xforms. I've seen code use #(map (fn [x] (log x) x)), and I've made a reducing function for transduce that just returns nil and ignores result. Am I doing it wrong?

eraserhd12:08:20

@alexmiller Also, I think the docs on transduce need tweaking. It doesn't mention that f must have a zero arity.

sandbags13:08:30

@yogthos it looks like you can’t set a border on a pdf-table. Looking at the source it’s not there, is that an oversight?

yogthos13:08:13

Hmm might be

sandbags13:08:09

@yogthos looking at the source for Cell it looks like it should support rowspan as well

sandbags13:08:54

hrmmm… actually it does in the source, i wonder what i did wrong

scriptor14:08:33

anyone here use the carmine library before to work with Redis? How have you handled atomically modifying a key?

scriptor14:08:34

I see that there's a swap function but the docstring just says "experimental", there's also an atomic function but there is a disclaimer that it's in alpha. I was wondering if people have simply implemented something like swap themselves

yogthos14:08:30

@sandbags: any luck? 🙂

tom17:08:50

@mhjort ok thanks! Do you know how that works with putting the jar in the zip by chance? I am reading mixed docs. Some say to put the uberjar in the root of the zip, others say to put it in /lib.

mhjort17:08:18

Not sure. I have always uploaded the uberjar. That works well. If you happen to use Leiningen I also maintain a plugin that can be used for installing/updating Clojure based Lambdas https://github.com/mhjort/lein-clj-lambda

fenton17:08:01

is there a logging formatter/viewer for clojure (backend) that is similar to binaryage/devtools in that you can log a list that when viewed in a browser allows you to collapse lists etc...

Alex Miller (Clojure team)17:08:03

@eraserhd run! is helpful for some sequence cases (run! println (map inc (range 10)))

Alex Miller (Clojure team)17:08:23

@eraserhd as you suggest, you can supply a custom f that side effects and returns nil if you want to transduce. Alternately, you could create a new kind of transducible process that does not retain the outputs, just invokes a side effect fn.

Alex Miller (Clojure team)17:08:16

@eraserhd you could create a wrapper to do this for you with just:

Alex Miller (Clojure team)17:08:31

(defn dotrans [xform f coll]
  (transduce xform (completing #(f %2)) nil coll))

Alex Miller (Clojure team)17:08:43

and use it like (dotrans (map inc) println (range 10))

sdegutis17:08:11

If ./myapp/project.clj has :java-source-paths ["src/java"], then what file do I put class Foo{} in, and what should its package be, in order to call (Foo.) from Clojure?

lmergen17:08:45

well, you cannot call things from the top level namespace if im not mistaken

lmergen17:08:17

so you would probably want Foo/Core.java as per convention

eraserhd17:08:11

@alexmiller Isn't true though, that f from transduce needs a 0-arity and completing doesn't supply it?

eraserhd18:08:05

(It's possible that I fat-fingered something when I did this, though.)

eraserhd18:08:58

(run! ... (eduction ... )) actually works quite nicely.

eraserhd18:08:50

Oh, I see. I probably didn't supply init to transduce when I tried that. Although there would have always been at least one element in coll. Hrmm.

Alex Miller (Clojure team)18:08:00

Transduce invokes f for the init if it's not supplied (it's not the same as reduce)

Alex Miller (Clojure team)18:08:09

run! with eduction is fine too

creese18:08:18

I'm encountering a strange error. When I run tests, I get a "No implementation of method: X of protocol: Y found for class: Z" error. But when them again, all tests pass. After a "lein clean", they break again, but only the first time. What could be causing this?

tanzoniteblack18:08:12

@creese if you’re using protocol/records or something similar, you’re probably only mentioning it in the import part of the NS (or just directly mentioning it without any mention in the NS) and not also putting the necessary namespace in require? That would cause this kind of behavior, where the protocol/record isn’t found the first time because nothing has told clojure to use that namespace, which actually actually creates the protocol/record, but a later test compiles it, which makes it findable because the .class is now available in targets

tanzoniteblack18:08:01

this can also happen if you’re extending an existing interface with the same scenario, where you’re not actually requiring the class that does the extending in the namespace you’re testing

creese18:08:29

@tanzoniteblack I'm requiring the namespace where the record is. I don't have anything in the import. Does the record need to be imported also?

hiredman18:08:27

are you aot compiling?

hiredman18:08:33

(you should stop)

hiredman18:08:48

you shouldn't be importing the record

creese18:08:58

I am aot compiling

hiredman18:08:13

are you sure?

creese18:08:27

it's in the project.clj aot all

hiredman18:08:40

yeah, so stop that

hiredman18:08:14

aot compilation very often ends up masking real issues

creese18:08:48

I stopped aot compiling and now it works (?)

hiredman18:08:03

have you run lein clean?

hiredman18:08:19

my expectation is when you remove aot compilation it would always fail

creese18:08:23

I run lein clean before every time

creese18:08:10

No, when I removed aot compiliation, the error went away. I do "lein clean && lein test"

hiredman18:08:08

so, likely there is some bad file in your src directory

creese18:08:26

bad file in src? What do you mean?

hiredman18:08:46

aot all was loading all the files, when you removed it, now only the files needed by your tests are being loaded

creese18:08:17

ah, so there is a problem elsewhere

hiredman18:08:10

it is kind of hard to say, if you aren't getting an error, who knows. But I am suspicious

hiredman18:08:37

the errors you are seeing don't happen to be about the Query type in yesql, are they?

hiredman18:08:46

were seeing

hiredman18:08:55

I vaguely recall helping someone with a similar issue, which turned out to be something like what tanzoniteblack suggested

hiredman18:08:10

there was a namespace somewhere that was importing a record type, and not requiring the namespace, so if namespaces weren't loaded in a particular order, it would break

hiredman18:08:58

and the problem the guy I was helping had was his combination of os + jdk + lein was loading test namespaces in a different orderer than whoever wrote the project, which causes the source namespaces to be loaded in a different order, which broken things

tom19:08:14

With compojure-api, is there a way to just accept any body in a POST? I might accept a variety of different messages, so validation/coercion isn't really necessary.

hiredman19:08:43

I had an issue open with the yesql project because they import types and don't require the namespace the type is created in. The guy I was helping was working on a pr for yesql. I tried to lookup the issue and found out that apparently the yesql repo has issues disabled now

hiredman19:08:11

tom: schema must have something like an any type

tom19:08:06

ah yes, just s/Any thanks!

zane19:08:30

@alexmiller: Right. The problem I'm having is that now when traversing with clojure.walk/postwalk and friends there's no way for the f passed in to know whether a 2-element vector it receives is a map entry or a vector.

zane19:08:50

I wound up reaching for Specter, for what it's worth.

sandbags19:08:52

@yogthos getting there. Maybe we should setup #pdf or something 🙂

sandbags19:08:03

there’s 304 channels already, one more can’t hurt

yogthos19:08:17

haha sure, I can try help with some questions there

jasonjckn23:08:45

is tools.nrepl still an active project? hasn't seen a release since 2015

jasonjckn23:08:21

i'm running into a bug with it, was wondering if there's a replacement project now

arrdem23:08:50

tools.nrepl is active but is for the most part stable and moves slowly. The bug tracker is here - http://dev.clojure.org/jira/browse/NREPL

ferzco23:08:38

Is there a function in Clojure that can take two lists/vecs and return a boolean if one of them contains all elements in the other? Ex: if we have [1 2 3 4 5] and [2 3 4], it returns true because the second vector is part of the first. It has to be something trivial I am just having a brainfart.

mruzekw23:08:25

Haven’t tested this, and I’m new to Clojure, but you could take the intersection of the two then check if the intersection is empty? or not

hiredman23:08:05

intersection requires sets, and if you are going to use sets, you can just use subset?

tanzoniteblack23:08:10

clojure.set/superset? and clojure.set/subset? do that for sets, don’t think there’s a built in function that does this for any other data type

mruzekw23:08:29

There’s no way to convert between?

mruzekw23:08:12

(into #{} [1 2 3 4])?

hiredman23:08:17

sure, but it isn't free, so it depends on the context

hiredman23:08:31

I would just call set

ferzco23:08:47

I think above should do the trick. I missed that there is a clojure.set, gonna play with it, thanks all!

mruzekw23:08:56

Cool, good luck