Fork me on GitHub
#clojure
<
2015-08-24
>
Alex Miller (Clojure team)00:08:09

The first Clojure I did was building R2RML and a full SPARQL engine with federation and a pretty nice query optimizer

Alex Miller (Clojure team)00:08:26

Unfortunately all proprietary and now dead

clumsyjedi00:08:58

@machty someone else can probably explain this better than me but keywords have namespaces

clumsyjedi00:08:29

so when you say :foo/bar you are providing a ns (before “/“) and a name (after “/“)

clumsyjedi00:08:04

you can do ::foo to get a keyword in the current ns

clumsyjedi00:08:33

or (keyword “foo/bar/baz”) if you really want more than one slash in a keyword

machty00:08:49

clumsyjedi: maybe this is the wrong channel since it's an Om cljs piece of code that confused me in the first place, but i'm looking at this: https://github.com/omcljs/om/blob/master/dev/om/dev.cljs#L47-L55

machty00:08:38

there's namespaced keywords like :app/title but it's not clear to me whether that's just a cosmetic choice or whether it "means" something to clojure in that case

dmich01:08:04

@rickmoynihan: Why not just make a Slack #rdf channel right here in this team?

ghadi01:08:31

Is RDF still kicking?

cigitia03:08:33

Does anyone have experience with JDBC or using SQLite from Clojure? I’m dipping my toes into it for the first time, but a really simple program is throwing a java.lang.IllegalStateException: I/O in transaction: https://gist.github.com/cigitia/e1635fd4272f8c921303

cigitia03:08:01

I do have the SQLite JDBC driver in my dependencies. The connection itself also seems to be working—running the Gist does create a test.db file in my project root, but it also throws that error.

cigitia03:08:19

Shouldn’t db-do-commands be taking care of any transaction coordination?

cigitia03:08:00

Adding a false second argument to db-do-commands seems to prevent the error, though I don’t yet understand why.

bmay03:08:29

@cigitia: you might need :classname "org.sqlite.JDBC" in the db definition

cigitia04:08:22

@bmay: Do you mean :classname instead of :subname? I had thought that the subname is the database filename or location, but I’m not sure.

bmay04:08:56

yeah classname

cigitia04:08:02

@bmay: [Edit: Not actually fixed unfortunately] Using :classname org.sqlite.JDBC works! Thank you very much!

bmay04:08:14

you're welcome simple_smile

cigitia04:08:42

I…don’t know why that mattered, since adding that transaction? parameter to false suppressed the error and made it work correctly too, but I’m not complaining too much.

cigitia04:08:23

@bmay: No, wait, duh, I forgot to remove the false argument in the first place.

cigitia04:08:34

It still throws the IllegalStateException—sorry about the false alarm, heh.

tel04:08:04

Anyone familiar with the JWT library clj-jwt?

tel04:08:22

I can’t seem to get it to work compatibly with http://jwt.io

tel04:08:33

when working with base64 encoded strings

nicholasf04:08:10

hey, should it be okay to generally run clojure 1.7 on java 8 or should I switch to java 7?

seancorfield04:08:22

We've been running Clojure 1.7 on Java 8 for ages. It's all good.

nicholasf04:08:42

hey seancorfield - thanks

nicholasf04:08:24

yeh, I worked out my problem. We’re trialling clojure at my new gig. I’ll probably have a few more questions for the channel in the next few days

seancorfield05:08:03

We've been running 1.8 Alphas in production but we backed off to 1.7 this week as we're trying to track down a very slow memory leak and need to isolate which of several changes may have caused it... 😞

seancorfield05:08:57

I don't really think it was 1.8 but moving back to stable releases is just a basic first step!

nicholasf05:08:12

right, Im being a total noob and just diving in and writing a data migrator from mongo to firebase in clojure

nicholasf05:08:32

ive learnt clojure twice at different times but havent written a lot of clojure programs

nicholasf05:08:03

so it’s a good exercise for me. Was confused as to whether or not clojure 1.7 needed clj-time because of the new time package in java 8

seancorfield05:08:05

I learned it at a Saturday bootcamp back in May 2010... and we first went to production with 1.3.0 Alpha 7... and we love Clojure simple_smile

nicholasf05:08:39

yeh, it might be a good fit as a backend language for us, so I’m trialling it out

seancorfield05:08:42

There are several date/time library options but clj-time is pretty standard since it wraps Joda Time.

nicholasf05:08:53

unsure if you recall but we know each other from #Polyhack and facebook, share a common friend in Mark Mandel

seancorfield05:08:02

We use clj-time heavily at World Singles (I co-maintain it with Michael Klishin).

nicholasf05:08:27

right, yeh, I have the code loading up clj-time now. It’s failing for a different reason now

seancorfield05:08:50

We also use date-clj for some date arithmetic and because it creates java.util.Date which is easy for MongoDB/MySQL

seancorfield05:08:33

Oh cool... I thought I recognized the name but couldn't think where from (I'm terrible with names!).

seancorfield05:08:57

Which library are you using for MongoDB?

seancorfield05:08:34

Cool. Michael et al work really hard on Monger. We use CongoMongo (which I seem to have become the lead maintainer of) but I've looked at migrating to Monger because it's better supported simple_smile

prachetasp05:08:19

@seancorfield: you're the man! thanks for java.jdbc

prachetasp05:08:52

used it on pretty much every project

nicholasf05:08:00

seancorfield: ok, thanks. We are moving everything to firebase for our client side data

nicholasf05:08:13

will be retiring mongo once this migration is over

seancorfield06:08:41

@prachetasp: appreciated... I just put out a new release... I haven't done the formal announcement yet... will do that Monday.

seancorfield06:08:37

Oh wait, no, that was tools.cli I just made a release of... java.jdbc will get a new release... in a few weeks...

seancorfield06:08:36

So, tools.cli 0.3.3 release announcement coming tomorrow simple_smile

seancorfield06:08:43

I have a bunch of stuff coming to java.jdbc ... just need to set aside a week to work on it ...

pupeno09:08:42

What’s that site that shows you which jar is using which other jar?

dottedmag10:08:51

Are the mappings generated by :refer in (ns) stored somewhere with the namespace? Or is it only a transient state of a reader/compiler?

pupeno10:08:46

cfleming: thanks.

dottedmag10:08:52

@crisptrutski: Thanks, very handy.

dottedmag10:08:28

Does symbol resolution work the same in ClojureScript?

crisptrutski10:08:23

not sure, but don’t think so

crisptrutski10:08:28

cljs.user/ns-refers doesn’t exist for a start

crisptrutski10:08:43

not sure the data is even around, may have to dig into analyser cache

crisptrutski10:08:03

question for the #C07UQ678E wizards

dottedmag10:08:09

Yep, I see. Thanks.

pupeno10:08:31

Any ideas why I keep getting this when doing a lein release: gpg: skipped "J. Pablo Fernández <[email protected]>": secret key not available?

pupeno10:08:47

My key is there.

nberger11:08:47

@pupeno: Leiningen 2.5.2? I remember there was an issue about that and the workaround was to downgrade to 2.5.1.

pupeno11:08:33

nberger: argh, yes, 2.5.2.

pupeno11:08:32

2.5.1 also gives me that error.

nberger11:08:15

The same error exactly? There are a few different error scenarios in https://github.com/technomancy/leiningen/blob/master/doc/GPG.md#troubleshooting with similar error messages, have you checked that?

pupeno12:08:19

nberger: yeah, same error, which I’m not seeing in that page, although I didn’t have use-agent in my conf. To test whether it’s working, it’s pointing to a command to decrypt ~/.lein/credentials.clj.gpg, a file I don’t even have.

Busy escaping the comfort zone13:08:00

Hey Clojurians, I'm looking for a messaging library that integrates with core.async (zeromq for example), is there anything out there?

Busy escaping the comfort zone13:08:18

onyx uses Aeron but sadly its not generalized and it tightly bound to the project https://github.com/onyx-platform/onyx/blob/master/src/onyx/messaging/aeron.clj

ljosa15:08:52

Posted this question on StackOverflow (since logs don’t stay around long here): http://stackoverflow.com/q/32186163/17498

joelkuiper17:08:03

We’ve created the #C09GHBXRC channel for those interested in using Clojure with Semantic Web and RDF!

lvh17:08:37

I want to check if a seq is alternating strings with a certain data structure; is there something neater than:

(every? identity
          (map apply
               (cycle [string? #{[:br {}]}])
               subrows))

lvh17:08:51

every? identity is similar to reduce and I guess, but reduce and doesn’t work because and’s a macro.

lvh17:08:08

I’m already using core.match, so if there’s a nicer way to describe preds-over-seqs, I’m all ears

potetm17:08:39

@lvh: The only alternative that comes to mind is partitioning.

potetm17:08:56

(every?
  (fn [[s struc]]
    (and (string? s)
         (#{[:br {}]} struc)))
  (partition 2 subrows))

potetm17:08:53

Not necessarily better. Could argue intent is clearer due to partitioning.

lvh17:08:17

sometimes it’s a single string though, and that’s also okay

lvh17:08:44

it’s 1+ elements that are string, that thing, string, that thing….

lvh17:08:59

partition-all I guess?

potetm17:08:45

Yeah. And your second predicate would have to accommodate nil. Maybe #{[:br {}] nil}?

potetm17:08:53

Kind of weird...

lvh17:08:03

(every? (fn
            [maybe-str]
            (string? maybe-str)            
            [maybe-str maybe-br]
            (and (string? maybe-str)
                 (#{[:br {}]} maybe-br)))
          subrows)

lvh17:08:05

err, nil?

lvh17:08:13

I thought partition-all returned short colls

potetm17:08:26

But, to be clear, it’s not okay to have [“string” [:br {}] “string”]?

lvh17:08:31

> Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the end. Returns a stateful transducer when no collection is provided.

lvh17:08:36

potetm: that’s a good question

lvh17:08:46

potetm: I think that’s okay

lvh17:08:53

my cycle version definitely thinks that’s okay

potetm17:08:59

Right, if you destructured like I did in the first example, struc would be nil.

lvh17:08:02

actually, yeah, no, that has ot be okay

lvh17:08:04

ah, right

lvh17:08:54

(every? (fn [[maybe-str maybe-br]]
            (and (string? maybe-str)
                 (#{nil [:br {}]} maybe-br)))
          (partition-all 2 subrows))
vs
(every? identity
                (map apply
                     (cycle [string? #{[:br {}]}])
                     subrows))

lvh17:08:56

potetm: Thanks! I think that looks pretty good simple_smile

potetm17:08:21

simple_smile Just an alternative. Neither seems particularly good or bad to me.

lvh17:08:41

unfortunately #{a b c} doesn’t work so well when one of them is nil simple_smile

lvh18:08:24

cljs.user> (contains? [nil] nil)
false

bostonaholic18:08:47

@lvh: check the docs for contains?. the second argument is a 'key'. for vectors, this would be index. so you're asking if nil is within the range of [nil]

lvh18:08:20

ah, right

bostonaholic18:08:37

user=> (contains? [nil] 0)
true
user=> (contains? [nil] 1)
false

bostonaholic18:08:39

for the most part, you can think of a vector as a map where its 'keys' are the indexes

lvh18:08:42

which is why (get v 1) works

bostonaholic18:08:11

however, (keys v) does not 😜

joelkuiper18:08:17

What protocol do I need to implement if I want to make a java object as a lazy-seq

joelkuiper18:08:28

or can I just implement ISeq and pass it to lazy-seq?

bostonaholic18:08:50

@joelkuiper: java.lang.LazySeq is a final class, so my guess is to implement ISeq

bostonaholic18:08:04

public final class LazySeq extends Obj implements ISeq, Sequential, List, IPending, IHashEq

bostonaholic18:08:18

or maybe IPending

joelkuiper18:08:21

Right, the concrete use case is that I have an object that implements Iterator, and want to use that as a sequence

bostonaholic18:08:25

hmm, gotta check that out

potetm18:08:14

@joelkuiper: Does your object not implement Iterable?

joelkuiper18:08:45

but I want to consume the results as a lazy-seq

potetm18:08:17

I’m not sure about laziness, but does iterator-seq not do what you want? https://clojuredocs.org/clojure.core/iterator-seq (Note in the docs it mentions using an Iterable as a seq directly)

potetm18:08:43

Though it doesn’t look like ResultSet implements Iterable. It just is an Iterator itself.

potetm18:08:58

Another alternative would be to write a fn that returns a lazy-seq by calling the lazy-seq macro itself.

bmay19:08:57

why does (hash-map) return a PersistentArrayMap and not PersistentHashMap?

spinningtopsofdoom19:08:01

It's an optimization. PersistentArrayMap is faster for small maps

joelkuiper19:08:31

is it possible to dynamically add a field to a Java Object?

kirked19:08:52

@joelkuiper: You can't add fields, as that would change the memory layout. You may be able to wrangle java.lang.reflect.Proxy to simulate it, though.

kirked20:08:10

I'm assuming you mean at runtime simple_smile

rauh20:08:05

I wish, then we'd have specify (as clojurescript has it). I wonder if CLR has it...

nberger22:08:09

I want something like https://github.com/pjlegato/ring.middleware.logger but to use it with taoensso/timbre. I don't want to bring a dependency on onelog which brings slf4j-log4j12 ... any alternative?

danielcompton22:08:13

@nberger: you could just fork it and swap out the logging statements for timbre

danielcompton22:08:37

I wish it didn’t use onelog, and just used clojure.tools.logging

nberger23:08:42

@danielcompton: yes, I'll do something like that, thanks

bostonaholic23:08:44

you should fork it, and submit a PR to allow users to supply a logging implementation 😜

bostonaholic23:08:00

probably a bit more work

danielcompton23:08:48

if it used c.t.logging then that would fit the 90% use case, although not timbre users

danielcompton23:08:00

unless timbre provided a slf4j facade?

nberger23:08:50

@bostonaholic: yes, I'll probably do that... I just wanted something to use like "right now", if it was available simple_smile

bostonaholic23:08:12

we all do 😜