Fork me on GitHub
#clojure
<
2015-10-28
>
martinklepsch11:10:49

is there some one liner that’s equivalent to cat a.txt b.txt > c.txt? simple_smile

martinklepsch11:10:19

in simple cases spit and slurp would work but I think that breaks with binary contents?

bradford11:10:37

{"=^.^=“, 🐈 } hey look it’s mapcat

bradford11:10:37

cc @mattly @rbxbx look I’m hilarious

bradford12:10:36

@andrewhr: I feel as if I’ve leveled up in life.

viesti12:10:09

@cfleming: Having problems opening Leiningen projects with latests Cursive (0.1.67) https://www.refheap.com/4cbd307737daa513a119e8839

viesti12:10:49

you probably have lot of “report to cursive” reports but though that I’d be extra brutal and send you one in chat simple_smile

andrewhr12:10:23

@bradford: +500xp. It's basically a koan

mishok1312:10:32

@martinklepsch: (spit "boot.sh" (concat (slurp "head.sh") (slurp "my.jar")))

martinklepsch12:10:30

@mishok13: I think that does not work because slurp coerces the contents into strings (I tried it)

mishok1313:10:34

you're right

mishok1313:10:03

I'd isolate writing one file to a separate function, so that the code would look sorta like this:

clojure
(with-open [...]
   (append! head bin)
   (append! head ujar))

mishok1313:10:15

where append! would implement the actual appending

mishok1313:10:40

perhaps using java.nio.channels.FileChannel could be of help here

Alex Miller (Clojure team)14:10:18

yeah, nio is going to be a better answer for stuff like this

Alex Miller (Clojure team)14:10:12

In particular look at FileChannel.transferFrom()

rbxbx15:10:52

bradford: 😛

rbxbx15:10:09

(… way late response to mapcat)

bradford15:10:19

@rbxbx: awfully far in the future for you to yield that reply

rbxbx15:10:08

S’ok, I used to make clojure puns too.

rbxbx15:10:24

ps: yield is ruby/python, what’s it doing in here? 😉

mattly15:10:43

@rbxbx: I think he had to try that one and see if you would catch it

mattly15:10:41

however, @bradford forgot to deliver the promise of his future

rbxbx16:10:14

martinklepsch: does (import ObjectIdRef$PeeledTag) work?

Alex Miller (Clojure team)16:10:38

more likely org.eclipse.jgit.lib.ObjectIdRef$PeeledTag

rbxbx16:10:41

thanks for the assist alexmiller

cfleming17:10:57

@viesti: Thanks, I’ll take a look. Is the project.clj somewhere I can look at it?

cfleming17:10:13

@viesti: BTW there’s a #C0744GXCJ channel here too.

PB17:10:17

Is anyone developing their clj apps in docker containers? If so. How are you getting your emacs to load all the namespaces?

PB17:10:44

I cannot jump to a fn unless I have already evaluated that namespace

meikemertsch17:10:17

@petr: I don't and have no idea about docker, but does it prevent you from using leiningen or boot? Wouldn't those do the job for you?

PB17:10:02

@meikemertsch: I am using leiningen. My issue is that when trying to jump to a fn it doesn’t work unless I’ve already evaluated a namespace in my cider repl

rbxbx17:10:05

atyz: don’t know about emacs, but with fireplace/vim you’ll need to have a local copy of the deps checked out (as I recall)

meikemertsch17:10:21

Sorry, then I cannot help you :(

rbxbx17:10:42

oh jumping works post eval. hmm. maybe a separate issue then.

rbxbx17:10:09

live repl in docker can be a bit weird though, for sure.

PB17:10:32

@rbxbx: I found that just to get cider to connect I had to do this lein repl :headless :host 0.0.0.0 :port 4343

rbxbx17:10:24

aytz yup – I ended up just mounting an nrepl server inside the application itself and having the dockerfile RUN a separate -main for local development.

staypufd18:10:36

anyone here get liberator wrap-trace to work when using bidi for routes? It requires compojure.core which liberator doesn’t and I get CompilerException java.io.FileNotFoundException: Could not locate compojure/core__init.class or compojure/core.clj on classpath

staypufd18:10:45

help appreciated

staypufd18:10:52

I’ve added compojure to project.clj

staypufd18:10:13

and in the require of my file using liberator.dev

stopa18:10:04

is anyone familiar with clj-webdriver by any chance?

Al Baker19:10:42

stopachka: I've gotten the demo to work and used it a bit, what's up

PB19:10:00

rbxbx: would you show me your example?

PB19:10:14

are you able to navigate your code?

rbxbx19:10:50

atyz: I haven’t used the setup in a while – you mean jumping to function definitions and such?

rbxbx19:10:02

just your own or vendor’d ones as well?

rbxbx19:10:10

dependencies, rather.

stopa19:10:15

@albaker nice! I am trying to the --no-sandbox flag to chromeOptions, when setting up the webdriver ->

caps {:acceptSslCerts true
              :javascriptEnabled true
              :browserName "chrome"
              :chromeOptions {:args ["--no-sandbox"]}}
        [_server driver] (s/new-remote-session {:host host
                                                :port port
                                                :existing true}
                                               {:browser :chrome
                                                :capabilities caps})]

PB19:10:17

I’d love to jump to all

PB19:10:35

BUt I’d settle for just within my app

stopa19:10:50

the :chromeOptions is a guess from me on how it should be, but am having a hard time actually providing the right input.

stopa19:10:06

I also tried ->

(let [chrome-opts (doto
                      (ChromeOptions.)
                      (.addArguments ["--no-sandbox"]))
        caps {:acceptSslCerts true
              :javascriptEnabled true
              :browserName "chrome"
              :chromeOptions chrome-opts}
        [_server driver] (s/new-remote-session {:host host
                                                :port port
                                                :existing true}
                                               {:browser :chrome
                                                :capabilities caps})]

stopa19:10:21

the error I am getting is -> `cannot parse capability: chromeOptions from unknown error: must be a dictionary`

Al Baker19:10:38

stopachka: maybe :chrome-switches

Al Baker19:10:52

hard to say, doesn't appear to be documented and I never had to pass in those options

stopa19:10:06

gotcha, thanks @albaker, will try and experiment more

andyparsons20:10:51

hey all. looking at YeSQL vs HugSQL. If anyone has experience please share.

donaldball20:10:22

I prefer the composability afforded by Honey SQL myself

ghadi20:10:06

+1 on Honey

jstew20:10:22

I like YeSQL but I don't care for the way it litters my namespace with vars. And makes it hard to use from a component.

shaun-mahood20:10:13

@andyparsons: YeSQL is pretty easy to get up and running to see if you like it and test your use cases - definitely try it with your most complex query and make sure it works.

andyparsons20:10:35

yes, in the middle of that. Can’t see any shortcomings give the problems it solves, so we’re wondering what HugSQL is better at simple_smile

shaun-mahood20:10:10

Ahh, when I saw the HugSQL announcement I wondered the same thing. Haven't looked into it yet though.

andyparsons20:10:26

@donaldball: that’s new to me. thanks @ghadi taking a look

shaun-mahood20:10:51

@andyparsons: I started on HoneySQL and ran into issues with queries with lots of columns, may be fixed now - I think there was a limit of 20 or so when I tried it. Moved from that to YeSQL as YeSQL was a lot better for my requirements.

shaun-mahood20:10:08

It is a really cool library though if it fits your needs

andyparsons20:10:00

yeah, this particular need is a fairly complex jumble of SQL so I don;t need a DSL or composability so much as a nice way to do raw sql

shaun-mahood20:10:14

I've ended up using java.jdbc for a lot of things as well as YeSQL, I prefer it for some types of queries

theophilusx20:10:58

I've found yesql very good. Most of the SQL DSLs I've tried were OK with simple stuff, but didn't scale well. Yesql seems to provide that nice mix of power and convenience. I can develop my SQL as normal and get all the power of the db, letting sql do what it does well and easy integration with my clojure. The conman package is a useful addition which makes managing pooled connections with yesql very easy see https://github.com/luminus-framework/conman With respect to vars polluting the namespace, I've not found this a problem. I put groups of queries into different files and then add them in separate namespaces and then just require the namespace I need and reference the queries in that namespace accordingly.

rbxbx21:10:50

andyparsons: for another option, I’ve been pretty happy with https://github.com/r0man/sqlingvo + java.jdbc fora while now.

rbxbx21:10:16

after trying other DSL solutions and finding them bonkers eventually.

rbxbx21:10:26

decoupling query generation from execution helps a lot.

andyparsons21:10:49

cool @rbxbx i will take a look!

andyparsons22:10:13

SQL is a pretty good DSL already simple_smile

rbxbx22:10:36

my only problem with Yesql (and many other libs) is the global connection… generally prefer to keep the db connection parameterized/componentized

rbxbx22:10:55

a lot of people aren’t bothered by that practically though.

andyparsons22:10:09

good point, not a pragmatic concern for this particular case for me

rbxbx22:10:29

and maybe there’s a way to use yesql that way now

rbxbx22:10:43

andyparsons: well then. onward and upward simple_smile

andyparsons22:10:52

i’ll report back. working nicely so far. thanks all

martinklepsch22:10:25

I’m trying to understand how 1.8’s socket repl and tools.nrepl compare. Is there something novel about it that tools.nrepl doesn’t support or is this mostly about better integrating repl servers in general?

xeqi22:10:18

@martinklepsch: for your file concat question, you can use instead of manual read/write loop. Still need to manually create the outputstream though to use as destination

martinklepsch23:10:37

@xeqi: cool thanks, that really makes it simpler.

danmidwood23:10:44

Any sente users here? How do people generally handle routing? We've been using a multimethod like the reference project shows, but it's getting a bit messy now (~70+ impls spread over multiple namespaces)

xeqi23:10:25

@martinklepsch: from what I've picked up it is about having a network/socket repl built in that can be started without adding any code. Though I remember reading something about stdin being a stream where as nrepl uses discrete messages with a request for more input (ie requires client support for stdin)

martinklepsch23:10:34

@xeqi: I looked at https://github.com/puredanger/replicant and the binding stuff seems interesting but probably nothing you couldn't do with nrepl (?)

martinklepsch23:10:59

Also understood that it's mostly about being built in