Fork me on GitHub
#clojure
<
2016-05-25
>
slipset08:05:27

say I have a clojure-application that I distribute as a uberjar, and run with java -jar foo-standalone.jar

slipset08:05:54

How would I go about to make it possible to connect to a repl within this application?

slipset08:05:13

so I could say lein repl :connect localhost:1337 and inspect/modify the state of the app?

slipset08:05:29

seems like -Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}” would do the trick

ragge08:05:08

@slipset: and note that nrepl is not the same as the socket repl available since clojure 1.8

slipset08:05:57

@ragge: thanks, seems as if the socket-repl serves my needs

slipset08:05:45

for now I just need to run a function in a ns to reload some stuff

ragge09:05:40

@slipset: telnet ftw 🙂

slipset09:05:56

jepps, Simple And Easy

dm312:05:35

is anyone using the built-in clojure 1.8 repl for lightweight inter-process RPC?

fabrao14:05:39

Hello all, why (name (keyword "10.12.0.0/16")) => 16? Is there any way to get full string keyword?

Alex Miller (Clojure team)14:05:01

try (name (keyword nil "10.12.0.0/16")) if you want the keyword to have that all as the name

vikeri14:05:10

I might be hopelessly lagging, but still using schema (despite clojure.spec) 😉 anyone knows how if there is a type for anonymous functions?

Alex Miller (Clojure team)14:05:30

note that the reader won't read it that way, but it's fine to programmatically create and use keywords that way

fabrao15:05:27

@alexmiller: thanks, it worked

reitzensteinm16:05:17

Is there a separate Clojure 1.9 release notes floating around somewhere? Or is spec the only addition in this release

hiredman18:05:17

what would you like to do with them?

lmergen18:05:12

i see more things wrong with that code :)

Alex Miller (Clojure team)18:05:18

@reitzensteinm: as we move into other stuff I will start updating the changes.md file again for subsequent releases

lmergen18:05:17

@firstclassfunc: what is it that you're trying to do ?

lmergen18:05:39

read all available data on the socket, or read until the socket is closed ?

reitzensteinm18:05:46

fantastic, thanks!

firstclassfunc18:05:24

@lmergen this is reading from an SSH ChannelInputStream.. The stream needs to remain open so I am just looking to retrieve the buffer

lmergen18:05:00

ok, so all that is available ? what do you want to do when there is no more data available ?

firstclassfunc18:05:37

Well I move onto the next sequence of write->read, write->read.. close..

lmergen18:05:42

because .available only returns 0 when there is no more data waiting in the buffer

firstclassfunc18:05:18

@lmergen: yea but it depends on the overloaded class.. it does not always seem to work

lmergen18:05:33

so, your issue is that your read blocks, even when available returns a non-zero value ?

firstclassfunc18:05:04

it eventually blocks yes because I have no way of knowing what is left in the buffer.

hiredman18:05:35

inpustreams are blocking, why are you trying to process one in a non-blocking way?

lmergen18:05:49

i think this is something that has more to do with the underlying socket implementation rather than clojure, but: you should set your socket to read in non-blocking mode. i vaguely recall, from my days as a C coder that reading from a socket might sometimes block if there is still data left to fill in the socket. as in: nobody guarantees it immediately returns if data is available!

firstclassfunc18:05:59

@lmergen true but that is dealt with within the SSH library. I really just want to inspect the results of the buffer and move on to the next sequence.

hiredman18:05:27

if you want to do non-blocking io, the way to do that is with nio channels, if you are trying to do it with inputsreams you are fighting uphill

lmergen18:05:26

i personally think you should do something different: skip the whole .available() part

lmergen18:05:56

just read in non-blocking mode, and only enter recursion if the return value n == length of buf

lmergen18:05:14

that is the normal way to do this, anyway

lmergen18:05:26

and yes, nio channels like @hiredman suggests is the best abstraction here, you're reinventing the wheel

hiredman18:05:30

I would suggest not bothing with whatever non-blocking async whatever you are trying to do, you will almost certainly be fine spinning up threads and having them block doing io

hiredman18:05:07

but if you must, the way to do it is with nio channels, or netty channels, and the name of the inputstream class you reading from suggests that somewhere this is a channel you should being using instead

firstclassfunc18:05:21

Tke for advice. Its not using NIO/NETTY but I get this is non-trivial. Tks.

hiredman18:05:44

whatever ssh library you are using certainly is

hiredman18:05:23

once you find the way to get the channel instead of the inputstream you'll want to use https://github.com/ztellman/byte-streams

hiredman18:05:29

maybe it isn't, Channel could be refering to ssh channels

hiredman18:05:06

in which case, the library is built on blocking io, so trying to use it to do non-blocking io in someway is going uphill

bensu19:05:42

@vikeri: you could roll your own type using a custom clause with either ifn? or fn?

seancorfield21:05:42

Why not just use a function? (pad-fn "25px" {:color "blue"}) — macros don’t compose so functions are nearly always preferable.

mattsfrey21:05:35

idea is i may have a variable number of style items in that map, and I want to just have that function/macro/whatever expand the 4 values in place

seancorfield21:05:59

(see my expanded answer in #C053AK3F9 )

seancorfield21:05:33

(pad-fn "25px" {:any "arbitrary" :style "attributes" :go "here"})

mattsfrey21:05:12

yeah I’m just using this to simplify notation so while that works^ it doesn’t really help my needs etc - i’m guessing the type of transformation I want to do just isn’t possible in clojure though from everything I’ve read

richiardiandrea22:05:13

It looks like you want something similar to the splice reader #?@ but a) I don't think is going to work anyways b) why not a macro including the "father" of pad-macro?

mattsfrey22:05:02

@richiardiandrea: I was thinking of potentially doing something with the “parent” but have no idea what that’d look like or if it’d allow the sort of convenience notation I was hoping for

richiardiandrea22:05:16

You could get pretty creative with splice but as Sean said usually you prefer functions for composability, what if at some point you want to insert pad AND margin in the hiccup? The two macros won't work together but two functions can be composed

mattsfrey22:05:56

yeah i actually wanted that use case too lol