Fork me on GitHub
#clojure
<
2017-05-25
>
kzeidler04:05:29

What's the preferred way to create a sandboxed environment that extends dev, that will be ignored when the dev profile builds — is it :profiles?

kzeidler04:05:47

sorry, not profiles. :provided?

noisesmith04:05:16

with leiningen you can give the profile any name you like, and then merge it with dev

noisesmith04:05:02

:provided is for dependencies that are used during development and production, but will be supplied externally in the production environment (so shouldn't be included in the production jar)

kzeidler04:05:01

@noisesmith I'm looking at some examples of that right now, is the idea basically to assoc the required dependencies, etc. with the desired profile name and also alias that name to "lein with-profiles the-name"?

noisesmith12:05:14

kzeidler: the "alias" is automatic, with-profile is how you tell lein to use a custom profile for a task. lein with-profile +foo repl - but you can also define an alias that combines a specific alias and task.

tclamb05:05:21

is there a transducer-accepting apply? something like (apply xf f args)

tclamb05:05:47

(apply = (map first colls)) is to (apply = (map first) colls) as (into [] (map first colls)) is to (into [] (map first) colls)

tclamb05:05:00

it’d need a different name cause of the arities, like reduce and transduce

val_waeselynck09:05:52

@tclamb not that I know of, what would be the benefit over composing apply with sequence / into ?

tclamb16:05:55

val_waeselynck: sequence looks like it’ll work great. thanks!

karol.adamiec12:05:34

why is ring/compojure route like (PUT “/test” [filter]) resulting in a scalar string “aha” when called with a single item array [“aha”]. ??? Callling it with [“asdf” “asdff”] results in proper binding of a 2 element array. For some reason compojure/ring is unwrapping single element arrays…. ?

bpiel13:05:15

Any tips on why I might be getting thousands of these? The server eventually dies from OOM.

"clojure-agent-send-off-pool-1003" - Thread [email protected]
   java.lang.Thread.State: TIMED_WAITING
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for <65be8b86> (a java.util.concurrent.SynchronousQueue$TransferStack)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
        at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
        at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
        at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:942)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
        - None

joshjones14:05:09

@bpizzi a little context might help in answering that

val_waeselynck14:05:03

@curlyfry I used the Http interface directly with http-kit, which made it nicely data-driven, and enabled me to do AWS request signing which was necessary in my case.

kzeidler14:05:24

Fork in the road. For someone most comfortable with static, no-frills Apache servers, but interested in deploying a socket-based app, would Immutant or Http-kit be the friendlier choice?

luxbock15:05:05

does anyone know something similar to this for Clojure / JVM? https://github.com/kalafut/imohash

donaldball15:05:45

luxbock: No, but IIRC clojure uses murmur3 hashing, so it looks like it’d be a fairly easy fn to write

luxbock16:05:30

yep that's likely what I'll end up doing

qqq15:05:17

are there clojure bindings for https://github.com/amzn/amazon-pay-sdk-java anywhere ?

pithyless15:05:51

@adamfrey - I’ve always used getx and getx-in from simulant, when I wanted this functionality. https://github.com/Datomic/simulant/blob/master/src/simulant/util.clj#L24-L37

adamfrey15:05:42

@pithyless Thanks for that, I hadn't seen it before. I'm interested in getting it to work for the more idiomatic (:key {:key 1}), in development at least. Maybe I'll experiment with building clojure myself to try it out

pithyless15:05:09

There are just too many cases, where the key may in fact not be there by design. So I like the explicit nature of getx and getx-in.

john15:05:40

@bpiel Were you using agents for something specifically? If not, wild guess: some logging framework is crapping out.

bpiel15:05:58

@john Thanks. I think we figured it out. We were just spinning up a lot of threads in a place we didn't expect. Nothing interesting.

bpiel15:05:28

My big lesson here was that visualvm is awesome and that I should've reached for it sooner

john15:05:48

Curious though. Were you actually using agents?

john15:05:04

Wondering if futures and friends reuse the agent send-off pool

joshjones15:05:01

they do @john : (future (println (.getName (Thread/currentThread))))

bpiel15:05:37

@john it was a future

mpenet17:05:46

@ghadi what's the status of squee? I'll need a jdbc lib soon and I really like some of the ideas/impl (stole a few things for mpenet/alia)

michaellindon17:05:10

Anybody going to the triclojure meet up in Durham tonight?

ghadi17:05:44

@mpenet I still like it more than clojure.java.jdbc, but obviously I haven't maintained it. maybe I should file a few issues to it and accept pull requests

ghadi17:05:03

the few changes I wanted to explore: - make query return a reducible directly, rather than realizing and internal one. (this means it would delay sending a statement until it was reduced over) - allow a "edn-reader" like construct to get out different value types directly, like java.time.Instants - perhaps registering queries globally a la spec

mpenet17:05:15

Please do :) I ll try to help

ghadi18:05:11

another option is just assume people will use c.j.jdbc and provide the reducible result set from squee alone as a library

mpenet18:05:18

I am mostly interested in the reducible parts yes, also rowgenerator. But the code is generally cleaner in squee too imho

ghadi18:05:19

yeah the transaction and connection handling is solid -- rowgenerator might just end up being a multi arity function

ghadi18:05:55

btw the reducible parts have been extracted into these two functions: https://gist.github.com/ghadishayban/902373e247e920855139902912d237f0

mpenet18:05:57

I ll just try to use it as is, we ll see

ghadi18:05:30

specifically if you want to create a JDBC reducible, you'd use supply

mpenet18:05:14

On my phone right now, but I am saving this for later, I had seen earlier versions of it I think. Cool stuff

ghadi18:05:11

the function passed in would check the ResultSet's .next and extract a row, or return ::eof

mpenet18:05:45

Yup got it

mpenet18:05:59

That s something that could be in c.core actually.

ghadi18:05:33

yeah I'm waiting until it materializes before i suggest that

mpenet18:05:39

Right now ireduceinit is a bit of a hidden thing

mpenet18:05:56

That d be one way of making it more high level

ghadi18:05:35

I think these two functions cover 90% of the usecases for either implementing your own IReduceInit, or having generators/`yield`

timgilbert18:05:29

Say, using clojure.test fixtures, is there a way to specify that I want a certain fixture only to apply to an individual test, instead of to all tests in the namespace?

bfabry18:05:19

@timgilbert I think could just call it directly (your-fixture (fn [] your-test-code))

hiredman18:05:24

the fixture stuff is for executing setup and tear down code around multiple tests so you don't have to repeat that setup code

hiredman18:05:43

if you are doing setup and tear down for a single test, there is no benefit over doing it directly in the test

bfabry18:05:09

@hiredman he could have common setup and teardown between individual tests in different test files

joshjones18:05:41

then just make it a function … fixture is nothing special

hiredman18:05:57

you can also use it as organization guide, tests that rely on the same setup and tear down in the same files, tests that rely on different setup and tear down in different files

bfabry18:05:17

that would seem to be a poor organisation guide. I want to disable logging for some tests and capture it for others. which tests that applies to is very orthogonal to how I'd like to organise my test suite. yes @joshjones fixtures are nothing special, just functions that you can call

hiredman18:05:30

it depends on your fitxtures and how you want things organized

metametadata18:05:54

@bfabry if you want to separate the tests themselves from the list of special cases, wild idea: create a custom macro (e.g. deftest-potentially-logged or something more general like deftest+) and make it check with the global variable which holds the names of tests which must capture the logs.

bfabry18:05:26

Why not just call it?

metametadata19:05:14

ah, guess I a bit misinterpreted what you said. Yes, I agree. I would also wrap every test case with a needed function instead of keeping a separate list of tests to modify 🙂 But if the separate list is really needed than creating a custom macro is one of the solutions as it's not possible with clojure.test out of the box.

plins19:05:56

hi everyone, while using clojure.jdbc is there an easy way of changing the name conventions of the returned fields? In SQL seems like i cant select myName as my-name and id like to stick to clojure conventions without a :row-fn combined with rename-keys`

donaldball19:05:48

plins: There is a #sql room but have you tried

select myName as `my-name
`

plins19:05:36

will take a look into that thanks

donaldball19:05:03

One could also supply an :identifiers option to jdbc/query

plins19:05:30

it works like a charm thank you very much 🙂

slipset19:05:55

It, if not inspired, got me to write

slipset19:05:37

which is a summary of some sorts of what happened on the Clojure Jira the last seven days.

slipset19:05:00

Being a Jira Jockey by trade, this is something I could continue writing if people find it interesting.

sgerguri20:05:25

Thumbs up to that, @slipset - I don’t have the time nor the inclination to follow the developments on the Clojure JIRA but if this were turned into a newsletter I would definitely subscribe to it.

mobileink21:05:33

@slipset key point from the article: RH is a feature. i would say RH is Clojure's killer app.

mobileink21:05:22

gnu/stallman, web/tbl, linux/torvalds, berkeley/joy, clojure/RH.

mobileink21:05:56

look at the milestones: clojure, clojurescript, core.async, spec, just to name a few. what other language ecosystem even comes close?

ghadi21:05:00

(But I agree Clojure is awesome)

dpsutton21:05:10

but let's not go overboard

mobileink21:05:17

honest, i was not just being provocative!

hiredman21:05:01

all of those things(lisps, compiling to js, csp, contracts/generative testing) are great, and are great together, but also have a long history

mobileink21:05:16

my thesis: clojure can do this kind of stuff. of course any language can. but in clojure you can do it without breaking the language.

hiredman21:05:54

have you looked at the jira for any of those projects?

mobileink21:05:19

why would i do that? 😉

mobileink21:05:08

racket, haskell, c#: clojure added core.async, which, while not part of the language kernel, effectively extended the language. have the other languages mentioned done similar? can they? i honestly do not know

mobileink21:05:09

plus afaik spec is one of a kind.

dpsutton21:05:45

c# has been a steady release of really nice language features, haskell allows for any random (phD) person to make their own compiler extensions, any lisp obviously allows for extensions, java has java 8 and soon java 9,

mobileink21:05:56

dpsutton: without hacking the kernel?

john21:05:45

nothing is one of a kind 😉

dpsutton21:05:07

javascript has gotten typescript and purescript along with es6

mobileink21:05:29

afaik, cobol has steadily added features. yes, you can write oo-cobol. that does not make it good.

ghadi21:05:53

(IMHO) it doesn't matter whether it needed compiler work or not. In core.async's case it's cool that it didn't, but that's it

ghadi21:05:09

Just like it doesn't matter right now if clojure is self-hosted or not. It's great and it works

john21:05:17

this may sound trivial, but I think Clojure's ubiquitous use of data literal forms [] and {} everywhere made lisp just more approachable for newbies. And being on the JVM was the perfect storm.

dpsutton21:05:34

big big fan of those for sure

mobileink21:05:52

ok at this point we should probably go to #off-topic , heh.

raywillig21:05:21

is there a way to detect termination of a standalone clojure application to perform some graceful shutdown procedures?

bfabry21:05:47

@raywillig if you're in java land, you can add a hook to the JVM shutdown

bfabry21:05:32

(.addShutdownHook (Runtime/getRuntime) (Thread. #(shutdown! system)))

adamvh22:05:32

so i'm on hotel wifi and this is causing leiningen to throw a bunch of certificate errors when it tries to fetch deps

adamvh22:05:43

is there any way i can tell it to just throw caution to the wind

raywillig22:05:01

@bfabry thanks. i'll give this a whirl

adamvh22:05:09

and just let me get man in the middle'd

adamvh22:05:18

which i'm pretty sure i won't

bfabry22:05:04

lol... can you get a vpn out through the hotel wifi? that'd solve the problem and mean your safety and privacy stay a bit intact

adamvh22:05:22

maybe if i remember my vpn credentials

noisesmith22:05:52

@adamvh once I tried to use leiningen from a “free wifi” and I ended up downloading a bunch of “jar files” that actually contained the html markup for a “click here to use intarwebs” page

noisesmith22:05:10

because I forgot to access the wifi from a browser first

jfntn22:05:18

With transit-clj I can write multiple objects to the same outputstream, and read them back one by one by calling the reader multiple times with the same inputstream. Is that an artifact of the implementation on the JVM or is it a supported use-case?

noisesmith22:05:10

I doubt it would be in the readme if not supported

jfntn22:05:33

@noisesmith indeed, thanks for pointing that out. My problem is I need to replicate that reader example in ClojureScript and it doesn’t seem supported there

alexmiller22:05:29

@slipset I have done some stuff like this in the past - both in a weekly form and in a longer form at http://insideclojure.org but I think it's hard to get some of the context. Like I would not completely agree with some of the things in your writeup. It also puts all tickets on an equal footing when some tickets are big and important and some are not. It's hard for me to tell where the balance is between doing the work and talking about the work (to the detriment of doing the work)

alexmiller22:05:26

Which is not to say that I'm really for or against you doing it, just some of the things I experienced

lumengxi23:05:54

hey is there a way to run tests under specific directory, or using wildcard in namespace in clojure.test? only option i have found so far, is to use test-selector but I try to avoid annotating all the tests I need to group together

noisesmith23:05:11

you can use clojure.test/test-ns to run tests on a particular ns in the repl

noisesmith23:05:51

or clojure.test/run-tests which takes a varargs of namespaces

lumengxi23:05:44

thanks, let me try that