Fork me on GitHub
#clojure
<
2015-12-10
>
eraserhd01:12:06

Anyone know of a terminfo/termcap library for Java or Clojure?

eraserhd01:12:30

I’m not having much luck via Google.

jtackett03:12:56

is loop recur lazy?

threequal04:12:24

That’s really nice! @meow

threequal04:12:29

What are you using to create that?

meow04:12:52

@threequal: thanks. I'm using Clojure. 😉

meow04:12:13

I'm using the http://thi.ng library, my own code, output to an X3D file, upload to Shapeways, use their renderer to create a JPG.

meow04:12:08

You can see a bunch of my designs here: https://www.shapeways.com/designer/pkobrien

threequal04:12:12

Hahaha. Ah right, I had a feeling that you would have been using http://thi.ng - that looks really incredible! I haven’t started mucking around with it yet

threequal04:12:15

Very cool though!

threequal04:12:45

They look great!

meow04:12:16

I'm having a lot of fun creating these designs.

threequal04:12:53

Cool, I have been mucking around with Overtone a lot - maybe it is time to start some visual stuff!

meow04:12:54

Now if I could just figure out how I'm sometimes getting leaks in my meshes that would be great - java.lang.NullPointerException doesn't tell me much to go on.

d-t-w04:12:15

looks great! and I'm colourblind.

meow04:12:10

@d-t-w: thank you!

meow04:12:41

Here's one I just uploaded that you can play around with in the 3D tool: https://www.shapeways.com/model/3dtools/4134592/1/26?key=faf3fe4a5c1a0e19905868764335c760

meow04:12:12

I wish they had better 2D rendering on their site, or even better if the 3D tool was accessible to customers.

roelof06:12:07

Some expert who is willing to help a beginner in the beginners channel with a problem ?

ping07:12:02

Is thee a datomic channel? Is datomic suitable for startup like twitter? (assuming it’s using dynamodb as store)

robert-stuttaford08:12:17

there is a #C03RZMDSH channel

robert-stuttaford08:12:56

suitable is a highly subjective word. i can imagine cases where Datomic can add a lot of value to a system like Twitter’s

danielgrosse08:12:00

How can I access the cause argument for ex-info? https://clojuredocs.org/clojure.core/ex-info

danielgrosse08:12:47

(try
  (throw
    (Exception. "Exception" (Throwable. "cause")))
  (catch Exception e 
    (println (.getMessage e) (.getMessage (.getCause e)))))
Is this okay? Or is there a better way?

ragge08:12:40

to access the cause of an exception, yes

jaen09:12:56

I think you can turn (.getMessage (.getCause e)) into (.. e getCause getMessage) for readability.

jimmy09:12:54

hi guys, is there any way we can develop a macro that can do so : for example (fn), then if we add ??(fn) , it will print out the value of fn but still doesn't break the whole thing. it would be very convenient in testing 😄

robert-stuttaford09:12:12

cider has tooling for this, it’s called tracing

jimmy09:12:30

hmm, I can see. But can we make it to be something like #_ for comment ?

robert-stuttaford09:12:48

you can simply alter the defn to deftrace

robert-stuttaford09:12:03

presumably you wouldn’t keep it traced for production use, this is for dev usage?

jimmy09:12:45

yes, this is for dev usage only

jimmy09:12:15

For example : I have this nested function (defn a [] (fn1 (fn2 (fn3)))

jimmy09:12:29

I want to debug the fn3 quickly,

jimmy09:12:50

to something like this (defn a [] (fn1 (fn2 ??(fn3)))

jimmy09:12:26

then I can remove the debug macro quickly later as well, I don't have to deal with brackets just like #_

robert-stuttaford09:12:49

are you using CIDER?

robert-stuttaford09:12:33

i don’t use Cursive so i don’t know what debug facilities it has. perhaps someone who does can share?

jimmy09:12:53

that looks awesome @@

jimmy09:12:12

I gave up on cider since it was bloated then.

jimmy09:12:43

btw thanks for the link.

jimmy10:12:58

@anders: yes, it's the form I'm looking for 😄

robert-stuttaford10:12:05

ah, yes, totally forgot about that. infact, that’ probably exactly waht you need

jimmy10:12:09

I will look into it and maybe build my own thing, thanks 😄

jimmy10:12:17

awesome !

roelof12:12:25

no experts who wants to help a beginner in the beginners channel ?

mbertheau13:12:34

How can I write this more elegantly and concisely? (into {} (map (fn [c] [(:id c) (certificate-name c)]) certificates))

magnars13:12:29

(into {} (map (juxt :id certificate-name) certificates))

mbertheau13:12:24

@magnars Alter Schwede! Cool, thanks simple_smile

roelof14:12:32

Is there a way I can tell clojure a file is in the resources directory. I use now this (def filename "suspects.csv")

larhat14:12:18

@roelof: are you talking about ring application? if so, ring.util.response provides resource-response function, you can use like (resource-response "index.html" {:root "public"})

roelof14:12:54

no, im talking about a example I found where I have to read a csv file with slurp

birdspider14:12:26

@roelof: resource should give you nil if it cannot be found - resource paths configuration (default + whatever) is to be kept in mind though

timvisher17:12:59

does an (if|when)-let exist that ands successive assignments together and executes the body if the result is truthy?

timvisher17:12:16

also am i crazy in saying that when generally implies side-effects?

timvisher17:12:44

for sure not in core

timvisher17:12:59

@bronsa: are you saying that regarding the when-let or regarding the side-effects?

timvisher17:12:04

i responded assuming the former simple_smile

danmidwood17:12:29

I generally use when where the else branch of an if would be a nil. Nothing to do with side effects

bronsa17:12:47

@timvisher: regarding when -- yeah, it's only needed because of side-effects, but I sometimes like to use it in place of one-armed ifs

bronsa17:12:05

some would consider it bad style, I personally like it better

timvisher17:12:35

interesting. i thought the when for side-effects was fairly universal simple_smile

timvisher17:12:41

@bronsa: it's not needed for side-effects because it's semantically equivalent to (if … (do …)), right?

bronsa17:12:06

it is literally equivalent to (if .. (do ..))

timvisher17:12:41

but no one would debate that do implies side-effects, right?

bronsa17:12:17

but implies != guarantees simple_smile

timvisher17:12:18

it seems like the divide would be over whether or not people are used to seeing consequent only if forms or not

timvisher17:12:54

well i would assume anyone reviewing this code would throw it back to me (do (+ 1 1)) or (do (prn "ohai"))

timvisher17:12:12

they'd immediately say "you don't need a do there. it adds nothing but some extra code"

meow17:12:25

Today's colors are brought to you by (mod (* 10 (get-in mesh [:face-area-map face])) 1)

rcanepa17:12:01

Hi everyone, in the context of building and REST API, which sql abstraction library would you recommend to support dynamic queries (pagination, filters, sorting). Until now I was using Yesql, but it seems that I am going to need another one to support this more flexible feature.

noonian17:12:02

@rcanepa: I use honeysql and it has been great for my needs so far https://github.com/jkk/honeysql

bsvingen17:12:06

@rcanepa: I will shamelessly recommend my own: https://github.com/bsvingen/squirrel (only PostgreSQL for now).

rcanepa17:12:53

Thanks guys, I will check both

rcanepa17:12:57

@noonian: to be sure I understood how honeysql works, all that Honeysql does is to create SQL queries (strings), so, I have to rely on another library like clojure.java.jdbc to execute them, right?.

jaen17:12:44

You have to use either clojure.java.jdbc or clojure.jdbc to execute them (I'm not aware of any other JDBC lib).

jaen17:12:09

Though there's also non-JDBC lib - https://github.com/alaisi/postgres.async

jeff.terrell18:12:15

@rcanepa: From what I understand, HugsQL is supposed to be a fairly natural extension of YesQL. Caveat: I'm not very familiar with either of them.

mikeb18:12:07

To chime in, I've been working on a library (very new) for postgres that's similar to yesql which has support for dynamic sections. Any feedback would be very welcome. https://github.com/mikeball/foundation/blob/master/docs/templated-queries.md#you-can-also-specify-dynamic-sections

jaen18:12:22

Oh, I didn't know HugsQL, looks interesting (though I still it still doesn't allow conditional evaluation in queries).

jaen18:12:46

@mikeb: oh, that's interesting, but I understand this means the dynamic part lives in Clojure code not in the external file?

mikeb18:12:44

@jaen: Correct, the dynamic part is just a function that is passed the parameters and that returns a string that is injected into the template.

timgilbert19:12:59

@nxqd: You should take a look at spyscope, it does almost exactly what you were looking for: https://github.com/dgrnbrg/spyscope

darwin19:12:02

is somewhere implementation of java.io.Writer wrapper in clojure? I want to look at it as an example to write my replacement for out and err

codemartin20:12:32

After running clojure.core/load-file on a file with a (ns my-cool-ns), I have that new ns loaded and all. Is there some way to do (unload 'my-cool-ns), and reverse that action? I want to free up memory, kill threads started in that ns, etc. Wipe it from existence. Is this possible?

Lambda/Sierra20:12:31

load-file does almost exactly the same thing as typing each form in the file into the REPL.

codemartin20:12:43

Have this function, which can ns-unmap every var in a ns:

Clojure
(defn unload-namespace!
  "Unloads every var in a namespace"
  [ns]
  (doseq [[sym var] (ns-map ns)]
    (if (and (var? var)
             (= (.. var -ns -name) ns))
      (ns-unmap ns sym))))
It does pretty much half the job I want...

codemartin20:12:58

@stuartsierra: thanks for replying! And thanks for the tools.namespace lib!

Lambda/Sierra20:12:56

@codemartin: You're welcome. There is no code which can "undo" arbitrary side-effects. I wrote http://github.com/stuartsierra/component to help structure code to cleanly shut things down.

codemartin20:12:27

@stuartsierra: I understand. Will look into your linked component project for some inspiration. Thanks for sharing

codemartin20:12:45

Another way would maybe be to remove code paths to objects, and then have the GC eat it. In Javascript you can have the GC eat something by re-defining it to undefined (or just use the delete keyword). What makes a go-block or a thread defined on global (ns) level in clj become 'dirty' for the GC?

thomas20:12:57

Hi, could someone help me with github please... I am trying to do a pull request and struggling a bit. please DM me. TIA.

darwin21:12:42

I got closer on my quest to “tee” stdout in clojure, using proxy, I’m able to intercept all calls to out writer like this: https://gist.github.com/darwin/0375c435ed239db7ce4a the problem is .append, single-paramter arity can receive char or CharSequence, it looks like Clojure is converting both to string for me, and when I pass it to super, it acts differently, it inserts extra newlines and spaces. Any ideas what is going wrong? btw. the underlying StringWriter’s buffer contains proper output (without extra spaces/newlines)

darwin21:12:32

I guess, I need something to tell clojure not to touch my arguments in any way and just pass them through as-is

pmooser22:12:29

I don't usually expect any kind of coercions not related to boxing of primitives

pmooser22:12:41

So my gut feeling is that I'd be surprised if this was the right explanation.

darwin22:12:01

it is interesting when I commend out this particular line, it works as expected for my test case: https://gist.github.com/darwin/0375c435ed239db7ce4a#file-tee-stdout-clj-L15

darwin22:12:46

@pmooser: I did some extra logging and investigation of stack traces, it looks that StringWriter calls write while in the middle of append call, that ruins my original assumption and I end up writing the same content to orig-out multiple times

darwin22:12:10

so your gut feeling was correct simple_smile